function switchDIV(id) {
	var obj = document.getElementById(id);
	if (obj){
		 if (obj.style.display == "none"){
		 	 obj.style.display = "block";
		 }else{
		 	 obj.style.display = "none";
	     }
	}
}

var openedItem = []
function switchDetail(id, level)
	{
	if (document.getElementById(id).style.display == "none")
		{
		document.getElementById(id).style.display = "block"
		if (openedItem[level] != null)
			{
			document.getElementById(openedItem[level]).style.display = "none"
			}
		openedItem[level] = id
		}
	else
		{
		document.getElementById(id).style.display = "none"
		openedItem[level] = null
		}
	}

function openDetail(id)
	{
	document.getElementById(id).style.display = "block"
	document.getElementById(id).status = "open"
	document.getElementById(id).hide = function ()
		{
		if (this.status == "closing")
			{
			this.style.display = "none"
			this.status = "close"
			}
		}
	}

function closeDetail(id)
	{
	document.getElementById(id).status = "closing"
	hideTimer = setTimeout("document.getElementById('" + id + "').hide()",10)
	}

//ouvre une fenetre fille de localisation
function localise(id)
	{
	var browser = window.open("localisation90ea.html?lieuID=" + id, "plan","resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no,width=650,height=510")
	}


function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,statusbar=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=530,height=450,screenX=150,screenY=150,top=100,left=100')
}
	

function MailFaux(ValeurInput)
{
  if (ValeurInput!='')
  {
	  dotPos = ValeurInput.indexOf('.');
	  if (dotPos>0)
	  {
		  if (dotPos <= (ValeurInput.length - 3))
		  {
			  var Regex = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$");		  
	    	  var Result = Regex.test(ValeurInput);
			  if (Result) {return false;}
			  else {return true;}
		   }	  
		   else 
		  {
		  	  return true;
		  }				
		}
		else 
		{
			return true;
		}
	}
}
	
	
function verifFormProjet(formProjet){
var nbre=0;
var nbre2=0;

for (i=0; i< document.formProjet.elements["jesuis[]"].length; i++) { 
	if (document.formProjet.elements["jesuis[]"][i].checked){ nbre ++	}
} 
if (nbre<1){ alert("L'item \"je suis\" doit être renseigné");return false;}

if ( (document.getElementById('autreJesuis').style.display=="block" ) && (document.formProjet.jesuisAutre.value=="") ){
alert("Le champ \"Autre\" doit être renseigné (item \"Je suis\")");
document.formProjet.jesuisAutre.focus();
return false;
}

for (i=0; i< document.formProjet.elements["jepossede[]"].length; i++) { 
	if (document.formProjet.elements["jepossede[]"][i].checked){ nbre2 ++	}
} 
if (nbre2<1){ alert("L'item \"je possède\" doit être renseigné");return false;}

if ( (document.getElementById('autreDestination').style.display=="block" ) && (document.formProjet.destinationAutre.value=="") ){
alert("Le champ \"Autre\" doit être renseigné (item \"Mon projet\")");
document.formProjet.destinationAutre.focus();
return false;
}

if (document.formProjet.surface.value==''){alert("Le champ \"surface\" doit être renseigné (item \"Mon projet\")");document.formProjet.surface.focus();return false;}
if (document.formProjet.lieu_construction.value==''){alert("Le champ \"lieu de construction\" doit être renseigné (item \"Mon projet\")");document.formProjet.lieu_construction.focus();return false;}

if (document.formProjet.nom.value==''){alert("Le champ \"nom\" doit être renseigné (item \"Mes coordonnées\")");document.formProjet.nom.focus();return false;}
if (document.formProjet.societe.value==''){alert("Le champ \"société\" doit être renseigné (item \"Mes coordonnées\")");document.formProjet.societe.focus();return false;}
if (document.formProjet.email.value==''){alert("Le champ \"email\" doit être renseigné (item \"Mes coordonnées\")");document.formProjet.email.focus();return false;}
if ( (document.formProjet.email.value!='') && ( MailFaux(document.formProjet.email.value)==true ) ){alert("L'adresse \"email\" saisie est invalide (item \"Mes coordonnées\")");document.formProjet.email.focus();return false;}
if (document.formProjet.telephone.value==''){alert("Le champ \"téléphone\" doit être renseigné (item \"Mes coordonnées\")");document.formProjet.telephone.focus();return false;}
if (document.formProjet.adresse.value==''){alert("Le champ \"adresse\" doit être renseigné (item \"Mes coordonnées\")");document.formProjet.adresse.focus();return false;}
if (document.formProjet.cp.value==''){alert("Le champ \"code postal (Cp)\" doit être renseigné (item \"Mes coordonnées\")");document.formProjet.cp.focus();return false;}
if (document.formProjet.ville.value==''){alert("Le champ \"ville\" doit être renseigné (item \"Mes coordonnées\")");document.formProjet.ville.focus();return false;}


return true;
}
