// JavaScript Document
function XmlGetAndReplace()
{
	this.receiveidValueOk = false;
	this.value = "";
	this.XmlHttp = false;
	this.CreateXmlHttp();
}

XmlGetAndReplace.prototype.ReplaceElementContent = function(id, url)
{
	document.getElementById(id).innerHTML = this.GetPageContent(url);
}

XmlGetAndReplace.prototype.GetPageContent = function(url)
{
	this.XmlHttp.open("GET", url, false);
	this.XmlHttp.send(null);
	return this.XmlHttp.responseText;
}

XmlGetAndReplace.prototype.CreateXmlHttp = function()
{
	if ((this.XmlHttp === false) && window.XMLHttpRequest) {
	  this.XmlHttp = new window.XMLHttpRequest();
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function BoutonSur(Id) {
	document.getElementById(Id).style.backgroundColor = "#990000";
	document.getElementById(Id).style.color = "#FFFFFF";
}

function BoutonOff(Id) {
	document.getElementById(Id).style.backgroundColor = "";
	document.getElementById(Id).style.color = "";
}

function VarForm(IdForm) {
	DebForm = document.forms[IdForm].elements;
	var Variables = "";
	var Val = "";
	for (i = 0; i < DebForm.length; i++) {
		if (DebForm[i].type == "select-one") { Val = DebForm[i].options[DebForm[i].selectedIndex].value; }
		else if (DebForm[i].type == "checkbox") { if (DebForm[i].checked == true) { Val = DebForm[i].value; } else { Val = ""; } }
		else { Val = DebForm[i].value; }
		if (Val == "choisissez" || Val == "Choisissez") { Val = ""; }
		Variables += "&" + DebForm[i].name + "=" + encodeURIComponent(Val);
	}
	return Variables
}

function Resa() {
	Req = new XmlGetAndReplace;
	Req.ReplaceElementContent("aff_resa", "ajax.php?act=resa");
	document.getElementById('aff_resa').style.display = "inline";
}

function AfficheResa(zone) {
	if (zone == 'email') { document.getElementById('email').style.display='inline'; document.getElementById('tel').style.display='none'; document.forms['resa'].elements['rep_tel'].value=''; }
	if (zone == 'tel') { document.getElementById('email').style.display='none'; document.getElementById('tel').style.display='inline'; document.forms['resa'].elements['rep_email'].value=''; }
}

function ResaTrait() {
	Req = new XmlGetAndReplace;
	Req.ReplaceElementContent("resa_res", "ajax.php?act=resa_trait" + VarForm('resa'));
}

function CarteRestau() {
	Req = new XmlGetAndReplace;
	Req.ReplaceElementContent("aff_carte_restau", "ajax.php?act=carte_restau");
	document.getElementById('aff_carte_restau').style.display = "inline";
}

function EmailContact() {
	document.write('<a  href="&#109;&#');document.write('97;&#105;&#108;');document.write('&#116;&#111;&#58;%69');document.write('%6e%66%6f%40%6d%');document.write('61%69%73%6f%6e%72%6f');document.write('%75%67%65%2d%63%6c%');document.write('75%62%2e%66%72">&#1');document.write('05;&#110;&#102;&#111');document.write(';&#64;&#109;&#9');document.write('7;&#105;&#115;&#111');document.write(';&#110;&#114;&#111');document.write(';&#117;&#103;&#');document.write('101;&#45;&#99;&#108;');document.write('&#117;&#98;&#46;&');document.write('#102;&#114;</a>');
}

function AffErreur(Div) {
	document.getElementById(Div).style.backgroundColor = "#ff9900";
	document.getElementById(Div).style.color = "#000000";
}

function EffErreur(Div) {
	document.getElementById(Div).style.backgroundColor = "";
	document.getElementById(Div).style.color = "";
}

function touche(e) {
	return window.event ? e.keyCode : e.which;
}

function Valider(Fonc, e) {
	if (touche(e) == 13) {
		if (Fonc == "entete_news") { AffFormNews(); }
		if (Fonc == "newsletter") { EnrNews(); }
		if (Fonc == "form_contact") { EnvContact(); }
	}	
}

function AffFormNews() {
	var Erreur = "";
	var Email = document.forms['entete_news'].elements['email'].value;
	var Tel = document.forms['entete_news'].elements['no_tel'].value;
	if ((Email == "INSCRIVEZ VOTRE EMAIL" || Email == "") && (Tel == "INSCRIVEZ VOTRE N&deg; DE T&Eacute;L&Eacute;PHONE" || Tel == "")) { Erreur = "Vous devez indiquez votre email ou votre num&deg; de portable."; }
	if (Erreur) { document.getElementById('resultat_news').innerHTML = Erreur; }
	else {
		if (Email == "INSCRIVEZ VOTRE EMAIL") { Email = ""; }
		if (Tel == "INSCRIVEZ VOTRE N&deg; DE T&Eacute;L&Eacute;PHONE") { Tel = ""; }
		document.getElementById('insc_aff_news').style.display = "inline";
		ReqFormNews = new XmlGetAndReplace;
		ReqFormNews.ReplaceElementContent("insc_aff_news", "ajax.php?act=form_news&email=" + Email + "&no_tel=" + Tel);
	}
}

function EnrNews() {
	var Deb = document.forms['newsletter'].elements;
	var variables = "";
	for (i = 0; i < Deb.length; i++) {
		variables += "&" + Deb[i].name + "=" + Deb[i].value;
	}
	ReqEnrNews = new XmlGetAndReplace;
	ReqEnrNews.ReplaceElementContent("insc_aff_news", "ajax.php?act=insc_news" + variables);
}

function VerifCheck() { 
	var DebCont = document.forms['form_contact'].elements['cont_check'];
	var ImgCheck = document.getElementById('cont_img_check');
	if (DebCont.value == "non") { ImgCheck.src = "images/contact-case-check.png"; DebCont.value = "oui"; }
	else { ImgCheck.src = "images/contact-case-non-check.png"; DebCont.value = "non"; }
}

function Ouvrir(Div) {
	document.getElementById(Div).style.display = "inline";
}

function Fermer(Div) {
	document.getElementById(Div).style.display = "none";
}

function EnvContact() {
	var Erreur = "";
	var Deb = document.forms['form_contact'].elements;
	if (Deb['cont_nom'].value == "" || Deb['cont_nom'].value == "Nom*") {
		Erreur += "votre nom, ";
		AffErreur('cont_nom');
		Deb['cont_nom'].value = "Nom*";
	}
	if (Deb['cont_prenom'].value == "" || Deb['cont_prenom'].value == "Prénom*") {
		Erreur += "votre pr&eacute;nom, ";
		AffErreur('cont_prenom');
		Deb['cont_prenom'].value = "Prénom*";
	}
	if (Deb['cont_email'].value == ""|| Deb['cont_email'].value == "Email*") {
		Erreur += "votre email, ";
		AffErreur('cont_email');
		Deb['cont_email'].value = "Email*";
	}
	if (Deb['cont_message'].value == ""|| Deb['cont_message'].value == "Votre message*...") {
		Erreur += "votre message, ";
		AffErreur('cont_message');
		Deb['cont_message'].value = "Votre message*...";
	}
	if (Erreur) { document.getElementById('resultat_contact').innerHTML = "Vous n'avez pas compl&eacute;t&eacute; les champs : " + Erreur.substr(0,Erreur.length - 2); }
	else {
		if (Deb['cont_nom'].value == "Nom*") { Deb['cont_nom'].value = ""; }
		if (Deb['cont_prenom'].value == "Pr&eacute;nom*") { Deb['cont_prenom'].value = ""; }
		if (Deb['cont_email'].value == "Email*") { Deb['cont_email'].value = ""; }
		if (Deb['cont_adresse'].value == "Adresse") { Deb['cont_adresse'].value = ""; }
		if (Deb['cont_code_postal'].value == "Code postal") { Deb['cont_code_postal'].value = ""; }
		if (Deb['cont_ville'].value == "Ville") { Deb['cont_ville'].value = ""; }
		if (Deb['cont_no_tel'].value == "Num&eacute;ro de portable" || Deb['cont_no_tel'].value == "Numéro de portable") { Deb['cont_no_tel'].value = ""; }
		if (Deb['cont_message'].value == "Votre message*...") { Deb['cont_message'].value = ""; }
		var variables = "";
		for (i = 0; i < Deb.length; i++) {
			variables += "&" + Deb[i].name + "=" + encodeURIComponent(Deb[i].value);
		}
		ReqEnvCont = new XmlGetAndReplace;
		ReqEnvCont.ReplaceElementContent("resultat_contact", "ajax.php?act=env_contact" + variables);
	}
}


function AffDates(Per) {
	if (Per == "venir") { Eff = "passe"; }
	else if (Per == "passe") { Eff = "venir"; }
	AffLien = "agenda_liens_" + Per;
	AffInf = "agenda_dates_" + Per;
	EffLien = "agenda_liens_" + Eff;
	EffInf = "agenda_dates_" + Eff;
	document.getElementById(AffLien).style.display = "inline";
	document.getElementById(AffInf).style.display = "inline";
	document.getElementById(EffLien).style.display = "none";
	document.getElementById(EffInf).style.display = "none";
}

function SurvolGallerie (id) {
	var DivP = "div_" + id;
	var ImgSur = document.getElementById(id);
	ImgSur.src = "images/galerie-" + id + "-sur.jpg";
	document.getElementById(DivP).style.backgroundColor = "#cc9999";
}

function OffGallerie (id) {
	var DivP = "div_" + id;
	var ImgSur = document.getElementById(id);
	ImgSur.src = "images/galerie-" + id + "-off.jpg";
	document.getElementById(DivP).style.backgroundColor = "";
}

function AffGalerie(Photo) {
	Ouvrir('galerie_photos');
	ReqAffGalerie = new XmlGetAndReplace;
	ReqAffGalerie.ReplaceElementContent("galerie_photos", "ajax.php?act=aff_galerie&photo=" + Photo);
}

function AffPlay() {
	Req = new XmlGetAndReplace;
	Req.ReplaceElementContent("div_play", "ajax.php?act=playlist");
	document.getElementById('div_play').style.display = "inline";
}

function AffPhoto(No) {
	ReqAffPhoto = new XmlGetAndReplace;
	ReqAffPhoto.ReplaceElementContent("galerie_photos", "ajax.php?act=aff_galerie&no=" + No);
}


function Illus(Nb, Nbt) {
	if (Nbt > 1) {
		Nb = parseFloat(Nb);
		/*
		if (Nb == 0) {
			Nb = document.getElementById('ref_index_' + TypeRef).value;
		}
		*/
		if (!Nb || Nb == Nbt) {
			Nb = 0;
		}
		NbP = Nb + 1;
		if (Nb == (Nbt - 1)) {
			NbP = 0;
		}
		//document.getElementById("_" + Nb).style.zIndex = 2;
		//Debug("_" + Nb + " / " + "_" + NbP);
		Effect.Fade("illus_" + Nb, {duration:4});
		Effect.Appear("illus_" + NbP, {duration:4});
		Nb++;
		//if (Nb > 0) { 
		setTimeout("Illus('" + Nb + "', '" + Nbt + "')", 4000); 
		//}
	}
	else { Effect.Appear("illus_0", {duration:4}); }
}



