function popwin(url,name,w,h,optionlist,align)
{
	if(align == "center")
	{
		t = ((screen.height-h)/2);
		l = ((screen.width-w)/2);
		optionlist += (optionlist != "" ? "," : "")+"top="+t+",left="+l;
	}
	optionlist = optionlist != "" ? ","+optionlist : "";
	eval(name+" = window.open('"+url+"','"+name+"','width="+w+",height="+h+optionlist+"');");
	eval(name+".focus();");
}
function deco()
{
	window.close();
}
function printMe()
{
	popwin('print.html','printwin',790,590,'scrollbars=yes,location=no,menubar=yes,resizable=yes','center');
	//pageP = window.open('print.html','print','width=800, height=600, scrollbars=yes,location=no, menubar=yes, resizable=yes');
}
function sendMe()
{
	popwin('sendP.php','friendwin',400,300,'scrollbars=no,location=no,menubar=no,resizable=no','center');
	//pageS = window.open('mail_ami.php','ami','width=400, height=300, scrollbars=no,location=no, menubar=no, resizable=no');	
}
function enfants()
{
	//popwin('.php','enfants',400,300,'scrollbars=no,location=no,menubar=no,resizable=no','center');
	window.open('enfants/frameset1-enfants.htm','ami','width=780, height=550, top=10, left=10, scrollbars=no,location=no, menubar=no, resizable=yes');	
}

function checkContact(f)
{
	if(f.nom.value.length == 0)
	{
		alert('Veuillez saisir vos nom et prénom.');
		return false;
	}
	if(f.prenom.value.length == 0)
	{
		alert('Veuillez saisir vos nom et prénom.');
		return false;
	}
	if(f.message.value.length == 0)
	{
		alert('Veuillez saisir un message pour compléter votre courrier.');
		return false;
	}
	if(f.email.value.length == 0)
	{
		alert('Veuillez saisir votre adresse email afin que nous puissions vous répondre.');
		return false;
	}
	if(f.fonction.value.length == 0)
	{
		alert('Veuillez saisir votre fonction.');
		return false;
	}
	if(f.societe.value.length == 0)
	{
		alert('Veuillez saisir le nom de votre société/entreprise.');
		return false;
	}
}

function setform(tr1,tr2)
{
	document.getElementById('form_'+tr1).style.cssText = "display: normal";
	document.getElementById('form_'+tr2).style.cssText = "display: none";
}

function TousLesChampsTexteRemplis(f)
{
	var j=0;
	var tr_id = f.inscription[0].checked ? 'form_inscription' : 'form_desinscription';
	var reg_nom = /^email/;
	var reg_mail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	for(var i=0;i<f.length;i++)
	{
		var trId = f.elements[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
		var emailPasOk = reg_nom.test(f.elements[i].name) && !reg_mail.test(f.elements[i].value);
		if(trId == tr_id && ((f.elements[i].type == 'text' && f.elements[i].value.length == 0) || emailPasOk))
		{
			j++;
		}
	}
	if(j!=0)
	{
		alert("Il y a "+j+" champ(s) mal rempli(s).\nVérifiez votre saisie.");
		return false;
	}
}

function affiche(lien,type,id)
{
	if(id != 0)
	{
		window.location.href=lien+"&affiche="+type+"&id="+id;
	}
}

function setMargin()
{
	if(screen.width > 1200)
	{
		table = document.getElementById("main");
		table.style.setAttribute("margin-left","auto","false");
		table.style.cssText = "margin-left : auto";
	}
}

function deplie(id) {
	eval ('var var1=document.getElementById("tr_'+id+'");');
	etat = var1.style.cssText == "DISPLAY: block" ? "DISPLAY: none" : "DISPLAY: block" ;
	var1.style.cssText = etat;
}

function depliedoc(id) {
	var var1 = document.getElementById(id);
	var etat = var1.style.cssText == "DISPLAY: block" ? "DISPLAY: none" : "DISPLAY: block" ;
	var1.style.cssText = etat;
}

function repondre(id) {
	popwin('pages/reserve/message.php?id='+id,'message',500,480,'status=yes,scrollbars=yes,location=no,menubar=no,resizable=no','center');
}

function suppMessage(id) {
	if(id>0) {
		
		var getVars = new Array();
		var locvartemp = ( window.location.href.indexOf( "?" ) + 1 ) ? window.location.href.substr( window.location.href.indexOf( "?" ) + 1 ) : "";
		locvartemp = locvartemp.split( "&" );
		for( var x = 0; x < locvartemp.length; x++ ) {
			var lvTempVar = locvartemp[x].split( "=" );
			getVars[ unescape( lvTempVar[0] ) ] = unescape( lvTempVar[1] );
		}
		
		if(confirm('Etes-vous sûr(e) de vouloir supprimer\nce message (et ses réponses) ?')) {
			window.location.href='pages/reserve/suppMessage.php?id='+id+'&d='+getVars["d"];
		}
	}
}

function nouveau_message() {
	repondre(0);
}