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 setLangue(lg) {
	page = self.location.href.replace("&", "|");
	window.location.href='langue.php?lg='+lg+'&url='+page;;
}
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 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;
	}	
}

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 popup(id,L,H)
{
		t 		= (screen.height - H)/2;
		l 		= (screen.width - L)/2;
		addwin = window.open('popup.php?id='+id,'popup','width='+L+', height='+H+', top='+t+', left='+l+', menubar=no, scrollbars=yes, resizable=yes');
		addwin.focus();
}

function fleche(img)

{

	for(var i=1;i<=4;i++)

	{

		eval ("document.img"+i+".style.cssText='visibility:hidden'");

	}

	eval ("document."+img+".style.cssText='visibility:visible'");

	eval ("document.all.info_plan.innerText=document.all.div_"+img+".innerText");

}

