//------------------------------------------------------------------------------------
// Script Notice Légale
//------------------------------------------------------------------------------------
function showCPR(s) {
       var y = new Date().getYear();
       if (y<1900) y+=1900;
       if (s!=y)
          document.write(s + " - " + y);
	       else
          document.write(y);
}
//------------------------------------------------------------------------------------
// FixFlash
//------------------------------------------------------------------------------------
function fixFlash(s) { document.write(s);}
//------------------------------------------------------------------------------------
// Cache mail
//------------------------------------------------------------------------------------
function CacheMail(mail, domain) {
    this.location = 'mailto:' + mail + '@' + domain;
}

//------------------------------------------------------------------------------------
// fonction TestParam()
//------------------------------------------------------------------------------------
function isEmail(obj) 
{
       if (obj.value.indexOf(" ") + "" == "-1"
       && obj.value.indexOf("@") + "" != "-1"
       && (obj.value.lastIndexOf(".") > obj.value.indexOf("@"))
       && obj.value != "") return true;
       else return false;
}

function isTel(obj) {
	if (isNaN(obj.value)==false && obj.value.length==10)  return true;
	else return false;
}

function isCP(obj) {
	if (isNaN(obj.value)==false && obj.value.length==5)  return true;
	else return false;
}

function TestParamContact()
{
	var Form = document.forms["FormContact"]; //forms = tous les formulaires du document
	if (Form.eNom.value == "")
		{ alert("Merci d'indiquer votre nom"); Form.eNom.focus(); return; }
	if (Form.ePrenom.value == "")
		{ alert("Merci d'indiquer votre prénom'"); Form.ePrenom.focus(); return; }
	if (Form.eEmail.value == "")
		{ alert("Merci d'indiquer votre adresse e-mail"); Form.eEmail.focus(); return; }
	if (!isEmail(Form.eEmail))
		{ alert("Merci de renseigner une adresse e-mail correcte"); Form.eEmail.focus(); return; }
	if (Form.eCodePostal.value=="" || !isCP(Form.eCodePostal))
		{ alert("Merci de renseigner correctement le champ 'Code postal'"); Form.eCodePostal.focus(); return; }
	if (Form.eVille.value == "")
		{ alert("Merci d'indiquer votre Ville"); Form.eVille.focus(); return; }
	if (Form.eTel.value != "" && !isTel(Form.eTel))
		{ alert("Merci de renseigner correctement le champ 'Téléphone'"); Form.eTel.focus(); return; }
	if (Form.eMessage.value == "")
		{ alert("Merci de renseigner le champ 'Message'"); Form.eMessage.focus(); return; }
	if (Form.eCaptcha.value == "")
		{ alert("Merci de saisir les caractères indiqués par l'image"); Form.eCaptcha.focus(); return; }
	Form.submit();															
}

//-------------------------------------------------------------------------------
// Fonction Captcha()
//-------------------------------------------------------------------------------
function RefreshCaptcha() {
	var i = new Image();
	var d = new Date();
	i.src = 'Includes/modCaptcha.asp?Type=4&Dt=' + d.getHours().toString() + d.getMinutes().toString() + d.getSeconds().toString() ;
    var obj = document.getElementById("Captcha");
    obj.src =  i.src;
}

// *****************************************
// PIZZAS
// *****************************************
var sel_pizzas = 1;

function moverPizzas(obj, index) {
   var strImg = obj.src;
   obj.src = strImg.replace("_off","_on");

   obj = document.getElementById("pizzasLine");
   obj.src = "images/pizzas/line"+index+".jpg";
}
function moutPizzas(obj, index) {
   if (sel_pizzas!=index) {
	   var strImg = obj.src;
	   obj.src = strImg.replace("_on","_off");

	   obj = document.getElementById("pizzasLine");
	   obj.src = "images/pizzas/line"+sel_pizzas+".jpg";
	}
}
function getPizzas(index, bgel) {
	var obj = document.getElementById("pizzas_"+sel_pizzas);
    var strImg = obj.src;
	obj.src = strImg.replace("_on","_off");

	obj = document.getElementById("pizzasPage"+sel_pizzas);
    obj.style.display = "none";

	sel_pizzas = index;
	obj = document.getElementById("pizzas_"+index);
	moverPizzas(obj, index);
	obj = document.getElementById("pizzasPage"+sel_pizzas);
    obj.style.display = "block";

	obj = document.getElementById("pizzasLine");
    obj.src = "images/pizzas/line"+index+".jpg";

	obj = document.getElementById("pizzasHeader");
	if (index==4) { 
      obj.style.backgroundImage = "url(images/pizzas/pmg_2_1.jpg)";
	} else {
      obj.style.backgroundImage = "url(images/pizzas/pmg_"+bgel+".jpg)";
	}
	
	obj = document.getElementById("pizzasFooter");
    obj.style.backgroundImage = "url(images/pizzas/bottom_col_"+bgel+".jpg)";

/*
	obj = document.getElementById("PizzasFond");
	if (bgel==2) obj.style.display = "block";
	  else  obj.style.display = "none";
*/
}


// *****************************************
// PLATS
// *****************************************
var sel_plats = 1;

function moverPlats(obj, index) {
   var strImg = obj.src;
   obj.src = strImg.replace("_off","_on");

   obj = document.getElementById("platsLine");
   obj.src = "images/plats/line"+index+".jpg";
}
function moutPlats(obj, index) {
   if (sel_plats!=index) {
	   var strImg = obj.src;
	   obj.src = strImg.replace("_on","_off");

	   obj = document.getElementById("platsLine");
	   obj.src = "images/plats/line"+sel_plats+".jpg";
   }
}

function getPlats(index) {
	var obj = document.getElementById("plats_"+sel_plats);
    var strImg = obj.src;
	obj.src = strImg.replace("_on","_off");

	obj = document.getElementById("platsPage"+sel_plats);
    obj.style.display = "none";

	sel_plats = index;
	obj = document.getElementById("plats_"+index);
	moverPlats(obj, index);
	obj = document.getElementById("platsPage"+sel_plats);
    obj.style.display = "block";

	obj = document.getElementById("platsLine");
    obj.src = "images/plats/line"+index+".jpg";
}


function rand(toVal) {
	var val = toVal*Math.random()+1;
	if (val>toVal) val = toVal;
	return (parseInt(val)).toString();
}

function showDivs() {
	var obj = document.getElementById("MenuL" + rand(2));
	if (obj) obj.style.display = "block";
	obj = document.getElementById("MenuR" + rand(3));
	if (obj) obj.style.display = "block";
}

function setShadow(bln) {
	var obj = document.getElementById("idTrouver");
	//var str = "background-image:url(images/Pictos/arrow4.png); background-position: top right; background-repeat: no-repeat; padding-right: 13px;";
	if (bln) { 
	  obj.style.backgroundImage = "url(images/Pictos/arrow4_on.png)";
	  obj.style.textDecoration = "none";
	} else {
	  obj.style.backgroundImage = "url(images/Pictos/arrow4.png)";
	  obj.style.textDecoration = "underline";
	}
}

function setShadow1(bln, id) {
	var obj = document.getElementById(id);
	//var str = "background-image:url(images/Pictos/arrow4.png); background-position: top right; background-repeat: no-repeat; padding-right: 13px;";
	if (bln) { 
	  obj.style.backgroundImage = "url(images/Pictos/arrow4_on.png)";
	  obj.style.textDecoration = "none";
	} else {
	  obj.style.backgroundImage = "url(images/Pictos/arrow4.png)";
	  obj.style.textDecoration = "underline";
	}
}

function openPopup1(url, width, height, scrollbars, resizeable){
    window.open(url,'popup','width='+width+', height='+height+', scrollbars='+scrollbars+', resizeable='+resizeable+'')
}
function openPopup(url, width, height, scrollbars, resizeable){
  if (document.all) posX = (document.body.clientWidth-width)/2;
   else { posX = (window.innerWidth-width)/2; }
  if (document.all) heightA = document.body.clientHeight;
   else heightA = window.innerHeight;
  if (heightA < height) height = heightA;
  window.open(url,'popup','top=20, left='+ posX + ', width='+width+', height='+height+', scrollbars='+scrollbars+', resizeable='+resizeable+'')
}

function myPopup2(url) {
window.open(url, "myWindow", "status = 1, height = 450, width = 450, resizable = 0" )
}
