// JavaScript Document
var selSourceSize = []; // array de societysize
var selSourceDomaine = []; // Array pour les dommaines

// Fill arrays
function initSelectionsLists() {
	selSourceSize = document.getElementById('fld-1037').cloneNode(true);
	selSourceDomaine = document.getElementById('fld-1055').cloneNode(true);
}

function AfficherCoordonnees(){
	//alert (document.getElementById('fld-213').checked);
	if (document.getElementById('fld-213').checked == true || document.getElementById('fld-215').checked == true || document.getElementById('fld-216').checked == true || document.getElementById('fld-217').checked == true || document.getElementById('fld-647').checked == true){
		document.getElementById("form-contact-coordonnee").style.display = 'block';
		document.getElementById("form-contact-complement").style.display = 'block';
	}
	else{
		document.getElementById("form-contact-coordonnee").style.display = 'none';
		document.getElementById("form-contact-complement").style.display = 'none';
	}
}

function AfficherChamps(){
	var selectSize = document.getElementById('fld-1037');
	var selectDomaine = document.getElementById('fld-1055');
	
	/*On remet tout le contenu de la liste*/
	// SelectSize
	var i=0;
	while (selectSize.firstChild) {
  		selectSize.removeChild(selectSize.firstChild);
	}

	for(i=0; i < selSourceSize.childNodes.length; i++)
	{	// Ajoute les enfants originaux
		selectSize.appendChild(selSourceSize.childNodes[i].cloneNode(true));
	}
	
	// SelectDomaine
	while (selectDomaine.firstChild) {
  		selectDomaine.removeChild(selectDomaine.firstChild);
	}

	for(i=0; i < selSourceDomaine.childNodes.length; i++)
	{	// Ajoute les enfants originaux
		selectDomaine.appendChild(selSourceDomaine.childNodes[i].cloneNode(true));
	}
	//alert(selSourceSize.length);
	//alert(selectSize.length);
	
	//On affiche tous les champs
	/*Taille de l'entreprise*/
	document.getElementById('societysize').style.display = 'block';
	/*statut*/
	document.getElementById('statut').style.display = 'block';
	/*Compagnie*/
	document.getElementById('compagnie').style.display = 'block';
	/*Le numero SIREN*/
	document.getElementById('siren').style.display = 'block';
	/*Domaine d'activite champ libre*/
	document.getElementById('societyactivity').style.display = 'block';
	/*Le numero ORIAS*/
	document.getElementById('orias').style.display = 'block';
	/*Domaine d'activite*/
	document.getElementById('activity').style.display = 'block';
	
	switch (document.getElementById('fld-1019').value)
	{
		case '0':
			/*Taille de l'entreprise*/
			selectSize.removeChild( selectSize.options[9]);
			selectSize.removeChild( selectSize.options[8]);
			selectSize.removeChild( selectSize.options[7]);
			selectSize.removeChild( selectSize.options[6]);
			selectSize.removeChild( selectSize.options[3]);
			/*statut*/
			document.getElementById('statut').style.display = 'none';
			/*Compagnie*/
			document.getElementById('compagnie').style.display = 'none';
			/*Le numero SIREN*/
			document.getElementById('siren').style.display = 'none';
			/*Domaine d'activite*/
			selectDomaine.removeChild( selectDomaine.options[18]);
			selectDomaine.removeChild( selectDomaine.options[17]);
			selectDomaine.removeChild( selectDomaine.options[16]);
			selectDomaine.removeChild( selectDomaine.options[15]);
			selectDomaine.removeChild( selectDomaine.options[14]);
			selectDomaine.removeChild( selectDomaine.options[13]);
			selectDomaine.removeChild( selectDomaine.options[12]);
			selectDomaine.removeChild( selectDomaine.options[11]);
			selectDomaine.removeChild( selectDomaine.options[10]);
			selectDomaine.removeChild( selectDomaine.options[9]);
			selectDomaine.removeChild( selectDomaine.options[8]);
			selectDomaine.removeChild( selectDomaine.options[7]);
			selectDomaine.removeChild( selectDomaine.options[6]);
			selectDomaine.removeChild( selectDomaine.options[5]);
			selectDomaine.removeChild( selectDomaine.options[4]);
			selectDomaine.removeChild( selectDomaine.options[3]);
			/*Domaine d'activite champ libre*/
			document.getElementById('societyactivity').style.display = 'none';
			break;
		case '1':
			/*Taille de l'entreprise*/
			selectSize.removeChild( selectSize.options[9]);
			selectSize.removeChild( selectSize.options[8]);
			selectSize.removeChild( selectSize.options[7]);
			selectSize.removeChild( selectSize.options[6]);
			selectSize.removeChild( selectSize.options[3]);
			/*statut*/
			document.getElementById('statut').style.display = 'none';
			/*Le numero SIREN*/
			document.getElementById('siren').style.display = 'none';
			/*Domaine d'activite */
			selectDomaine.removeChild( selectDomaine.options[18]);
			selectDomaine.removeChild( selectDomaine.options[17]);
			selectDomaine.removeChild( selectDomaine.options[16]);
			selectDomaine.removeChild( selectDomaine.options[15]);
			selectDomaine.removeChild( selectDomaine.options[14]);
			selectDomaine.removeChild( selectDomaine.options[13]);
			selectDomaine.removeChild( selectDomaine.options[12]);
			selectDomaine.removeChild( selectDomaine.options[11]);
			selectDomaine.removeChild( selectDomaine.options[10]);
			selectDomaine.removeChild( selectDomaine.options[9]);
			selectDomaine.removeChild( selectDomaine.options[8]);
			selectDomaine.removeChild( selectDomaine.options[7]);
			selectDomaine.removeChild( selectDomaine.options[6]);
			selectDomaine.removeChild( selectDomaine.options[5]);
			selectDomaine.removeChild( selectDomaine.options[4]);
			selectDomaine.removeChild( selectDomaine.options[3]);
			/*Domaine d'activite champ libre */
			document.getElementById('societyactivity').style.display = 'none';
			break;
		case '2':
			/*Taille de l'entreprise*/
			selectSize.removeChild( selectSize.options[5]);
			selectSize.removeChild( selectSize.options[2]);
			selectSize.removeChild( selectSize.options[1]);
			/*statut*/
			document.getElementById('statut').style.display = 'none';
			/*Compagnie*/
			document.getElementById('compagnie').style.display = 'none';
			/*Le numero ORIAS*/
			document.getElementById('orias').style.display = 'none';
			/*Domaine d'activite*/
			document.getElementById('activity').style.display = 'none';
			break;
		case '3':
			/*Taille de l'entreprise*/
			selectSize.removeChild( selectSize.options[5]);
			selectSize.removeChild( selectSize.options[2]);
			selectSize.removeChild( selectSize.options[1]);
			/*statut*/
			document.getElementById('statut').style.display = 'none';
			/*Domaine d'activite*/
			selectDomaine.removeChild( selectDomaine.options[18]);
			selectDomaine.removeChild( selectDomaine.options[17]);
			selectDomaine.removeChild( selectDomaine.options[16]);
			selectDomaine.removeChild( selectDomaine.options[15]);
			selectDomaine.removeChild( selectDomaine.options[14]);
			selectDomaine.removeChild( selectDomaine.options[13]);
			selectDomaine.removeChild( selectDomaine.options[12]);
			selectDomaine.removeChild( selectDomaine.options[11]);
			selectDomaine.removeChild( selectDomaine.options[10]);
			selectDomaine.removeChild( selectDomaine.options[9]);
			selectDomaine.removeChild( selectDomaine.options[8]);
			selectDomaine.removeChild( selectDomaine.options[7]);
			selectDomaine.removeChild( selectDomaine.options[2]);
			selectDomaine.removeChild( selectDomaine.options[1]);
			selectDomaine.removeChild( selectDomaine.options[0]);
			/*Domaine d'activite champ libre*/
			document.getElementById('societyactivity').style.display = 'none';
			break;
		case '4':
			/*Taille de l'entreprise*/
			selectSize.removeChild( selectSize.options[5]);
			selectSize.removeChild( selectSize.options[2]);
			selectSize.removeChild( selectSize.options[1]);
			/*statut*/
			document.getElementById('statut').style.display = 'none';
			/*Le numero ORIAS*/
			document.getElementById('orias').style.display = 'none';
			/*Domaine d'activite*/
			selectDomaine.removeChild( selectDomaine.options[18]);
			selectDomaine.removeChild( selectDomaine.options[17]);
			selectDomaine.removeChild( selectDomaine.options[16]);
			selectDomaine.removeChild( selectDomaine.options[15]);
			selectDomaine.removeChild( selectDomaine.options[14]);
			selectDomaine.removeChild( selectDomaine.options[13]);
			selectDomaine.removeChild( selectDomaine.options[12]);
			selectDomaine.removeChild( selectDomaine.options[11]);
			selectDomaine.removeChild( selectDomaine.options[10]);
			selectDomaine.removeChild( selectDomaine.options[9]);
			selectDomaine.removeChild( selectDomaine.options[6]);
			selectDomaine.removeChild( selectDomaine.options[5]);
			selectDomaine.removeChild( selectDomaine.options[4]);
			selectDomaine.removeChild( selectDomaine.options[3]);
			selectDomaine.removeChild( selectDomaine.options[2]);
			selectDomaine.removeChild( selectDomaine.options[1]);
			selectDomaine.removeChild( selectDomaine.options[0]);
			/*Domaine d'activite champ libre*/
			document.getElementById('societyactivity').style.display = 'none';
			break;
		case '5':
			/*Taille de l'entreprise*/
			selectSize.removeChild( selectSize.options[5]);
			selectSize.removeChild( selectSize.options[2]);
			selectSize.removeChild( selectSize.options[1]);
			/*statut*/
			document.getElementById('statut').style.display = 'none';
			/*Le numero ORIAS*/
			document.getElementById('orias').style.display = 'none';
			/*Domaine d'activite*/
			selectDomaine.removeChild( selectDomaine.options[18]);
			selectDomaine.removeChild( selectDomaine.options[17]);
			selectDomaine.removeChild( selectDomaine.options[16]);
			selectDomaine.removeChild( selectDomaine.options[15]);
			selectDomaine.removeChild( selectDomaine.options[14]);
			selectDomaine.removeChild( selectDomaine.options[13]);
			selectDomaine.removeChild( selectDomaine.options[12]);
			selectDomaine.removeChild( selectDomaine.options[8]);
			selectDomaine.removeChild( selectDomaine.options[7]);
			selectDomaine.removeChild( selectDomaine.options[6]);
			selectDomaine.removeChild( selectDomaine.options[5]);
			selectDomaine.removeChild( selectDomaine.options[4]);
			selectDomaine.removeChild( selectDomaine.options[3]);
			selectDomaine.removeChild( selectDomaine.options[2]);
			selectDomaine.removeChild( selectDomaine.options[1]);
			selectDomaine.removeChild( selectDomaine.options[0]);
			/*Domaine d'activite champ libre*/
			document.getElementById('societyactivity').style.display = 'none';
			break;
		case '6':
			/*Taille de l'entreprise*/
			selectSize.removeChild( selectSize.options[9]);
			selectSize.removeChild( selectSize.options[8]);
			selectSize.removeChild( selectSize.options[7]);
			selectSize.removeChild( selectSize.options[6]);
			selectSize.removeChild( selectSize.options[3]);
			/*statut*/
			document.getElementById('statut').style.display = 'none';
			/*Le numero ORIAS*/
			document.getElementById('orias').style.display = 'none';
			/*Domaine d'activite*/
			selectDomaine.removeChild( selectDomaine.options[18]);
			selectDomaine.removeChild( selectDomaine.options[17]);
			selectDomaine.removeChild( selectDomaine.options[16]);
			selectDomaine.removeChild( selectDomaine.options[15]);
			selectDomaine.removeChild( selectDomaine.options[11]);
			selectDomaine.removeChild( selectDomaine.options[10]);
			selectDomaine.removeChild( selectDomaine.options[9]);
			selectDomaine.removeChild( selectDomaine.options[8]);
			selectDomaine.removeChild( selectDomaine.options[7]);
			selectDomaine.removeChild( selectDomaine.options[6]);
			selectDomaine.removeChild( selectDomaine.options[5]);
			selectDomaine.removeChild( selectDomaine.options[4]);
			selectDomaine.removeChild( selectDomaine.options[3]);
			selectDomaine.removeChild( selectDomaine.options[2]);
			selectDomaine.removeChild( selectDomaine.options[1]);
			selectDomaine.removeChild( selectDomaine.options[0]);
			/*Domaine d'activite champ libre*/
			document.getElementById('societyactivity').style.display = 'none';
			break;
		case '7':
			/*Taille de l'entreprise*/
			selectSize.removeChild( selectSize.options[9]);
			selectSize.removeChild( selectSize.options[8]);
			selectSize.removeChild( selectSize.options[7]);
			selectSize.removeChild( selectSize.options[6]);
			selectSize.removeChild( selectSize.options[3]);
			/*statut*/
			document.getElementById('statut').style.display = 'none';
			/*Le numero ORIAS*/
			document.getElementById('orias').style.display = 'none';
			/*Domaine d'activite*/
			selectDomaine.removeChild( selectDomaine.options[14]);
			selectDomaine.removeChild( selectDomaine.options[13]);
			selectDomaine.removeChild( selectDomaine.options[12]);
			selectDomaine.removeChild( selectDomaine.options[11]);
			selectDomaine.removeChild( selectDomaine.options[9]);
			selectDomaine.removeChild( selectDomaine.options[8]);
			selectDomaine.removeChild( selectDomaine.options[7]);
			selectDomaine.removeChild( selectDomaine.options[6]);
			selectDomaine.removeChild( selectDomaine.options[5]);
			selectDomaine.removeChild( selectDomaine.options[4]);
			selectDomaine.removeChild( selectDomaine.options[3]);
			selectDomaine.removeChild( selectDomaine.options[2]);
			selectDomaine.removeChild( selectDomaine.options[1]);
			selectDomaine.removeChild( selectDomaine.options[0]);
			/*Domaine d'activite champ libre*/
			document.getElementById('societyactivity').style.display = 'none';
			break;
		case '8':
			/*Taille de l'entreprise*/
			document.getElementById('societysize').style.display = 'none';
			/*Compagnie*/
			document.getElementById('compagnie').style.display = 'none';
			/*Le numero ORIAS*/
			document.getElementById('orias').style.display = 'none';
			/*Domaine d'activite*/
			document.getElementById('activity').style.display = 'none';
			/*Domaine d'activite champ libre*/
			document.getElementById('societyactivity').style.display = 'none';
			break;
		default : alert('autre');
	}	
}
	

window.addEvent('domready', function(){
	initSelectionsLists();
	AfficherChamps();
	
	document.getElementById('fld-213').onclick = function(){
		AfficherCoordonnees();
	};

	document.getElementById('fld-215').onclick = function(){
		AfficherCoordonnees();
	};

	document.getElementById('fld-216').onclick = function(){
		AfficherCoordonnees();
	};
	
	document.getElementById('fld-217').onclick = function(){
		AfficherCoordonnees();
	};
	
	document.getElementById('fld-1019').onclick = function(){
		AfficherChamps();
	};
	
	document.getElementById('fld-647').onclick = function(){
		AfficherCoordonnees();
	};
	AfficherCoordonnees();
});

