// verifie la validite d'un email
function validemail(champ)
{
	
 test = document.formulaire.elements[""+champ+""].value;
 valeur = test.indexOf("@");
 valeur2 = test.lastIndexOf(".");
 valeur3 = valeur2 + 1;
 longueur = test.length;
 ext = test.substring(valeur3,longueur);
 ok=0;
 temp = ext.length;
 if ( temp==2 || temp==3 ) 
    { ok=1; }
 else
    { ok=0; }
 if ( valeur2 == (valeur + 1) )
     { ok=0; }
 if (valeur==0)
     { ok=0; }
 if (valeur==-1 || valeur2==-1 || ok==0)
    { alert("L'email que vous avez rentrée n'est pas valide.\nVeuillez la ressaisir s'il vous plaît.");
      return false; }
 else
    { return true; }   
    
}

// verifie les champs obligatoire d'un formulaire
valider_formulaire = function () {
	var tab = valider_formulaire.arguments;

	taille = tab.length;

	for (i=0;i<taille;i++) {
		if (tab[i]=="email") {
			if (!validemail(tab[i])) {
				return 0; 
			}
		}else{
			if ((document.formulaire.elements[tab[i]].value=="") || (document.formulaire.elements[tab[i]].value==" ")) {
				str_temp = tab[i].replace(/_/g," ");
				alert("Le champ "+str_temp+" est obligatoire.\nVeuillez le ressaisir s'il vous plaît.");
				return 0; 
			}
		}
	}
	
	document.formulaire.submit();
}

function empechechar()
{
	if( event.keyCode < 48 || event.keyCode > 57 )
 	{ 
 		alert( "Ce champ doit être numérique, il ne peut contenir aucun autre type de caratères." );
   		event.returnValue = false;
   	}
}

// fonction qui ouvre la popup de réservation
function openRes(param) {
	window.open("","Reservation",'width=300,height=300,scrollbars=yes');
}

// navigation de niveau 4
function validNav4() {
	if (document.form_nav.url.value!=0) {
		location.href=document.form_nav.url.value;
	}
}

// ouvre un zoom sur une photo
function openPhoto(id_photo) {
	window.open("popup/visu.php?id="+id_photo,"Photo",'width=500,height=400,scrollbars=yes');
}

// ferme la popup de zoom
function fermer() {
	window.close();	
}

// ouvre la reservation
function openReservation(num,nom) {
	var url_resa = document.getElementById("url_moteur_resa").value;	
	location.href = "rappel.php?iframeSrc="+url_resa+"reserverRecall;jsessionid=0000sQ-_QY_P_U87zG8LL4eavzp:-1%3FnoDossier="+num+"%26nomPassager="+nom;
}

// redimentionne l'Iframe
function getDocHeight(doc) {
var docHt = 0, sh, oh;
if (doc.height) docHt = doc.height;
else if (doc.body) {
if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
if (sh && oh) docHt = Math.max(sh, oh);
}
return docHt;
}

function setIframeHeight(nom) {
//	document.getElementById(nom).height=800;
	var iframeWin = window.frames[nom];
	var iframeEl = document.getElementById? document.getElementById(nom): document.all? document.all[nom]: null;
	if ( iframeEl && iframeWin ) {
	iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
	var docHt = getDocHeight(iframeWin.document);
	// need to add to height to be sure it will all show
	if (docHt) iframeEl.style.height = docHt + 30 + "px";
	}
}

// redimentionne l'Iframe
function setIframeNormal(nom) {
	document.getElementById(nom).height=509;
}

function showFaq(nom) {
	if (document.getElementById(nom).style.display=="none") {
		document.getElementById(nom).style.display = "block";
	}else{
		document.getElementById(nom).style.display = "none";	
	}
}