
// Fonctions liées au site G-Meffre
		function envoi_contact(lg) { 
		if (checkValues(document.saisie_contact,lg)){
			document.saisie_contact.submit();
			}
		}		
		function ouverture_contact() { 
			var wcontact = window.open('contact.php','Contact',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=505,height=455,left=10,top=10');
			wcontact.focus();
		}
		function ouverture_rejoindre() { 
			var wrejoindre = window.open('rejoindre.php','Rejoindre',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=530,height=660,left=20,top=20');
				wrejoindre.focus();
		}
		function ouverture_cnil() { 
			var wcnil = window.open('cnil.php','Cnil',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=530,height=600,left=30,top=30');
				wcnil.focus();
		}
		function ouverture_plan_caveau(lg) { 
			var wplan = window.open('plan_caveau.php?langue='+lg,'Plancaveau',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=530,height=570,left=30,top=30');
				wplan.focus();
		}
		function ouverture_plan_gigondas(lg) { 
			var wplan = window.open('plan_gigondas.php?langue='+lg,'Plangigondas',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=530,height=570,left=30,top=30');
				wplan.focus();
		}
		function ouverture_plan_oustalet(lg) { 
			var wplan = window.open('plan_oustalet.php?langue='+lg,'Plangigondas',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=530,height=570,left=30,top=30');
				wplan.focus();
		}
		function ouverture_resa_chateau_canet(lg) { 
			var wresacc = window.open('reservations_canet.php?langue='+lg,'ResaCanet',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=590,height=680,left=30,top=10');
				wresacc.focus();
		}
		function ouverture_plan_chateau_canet(lg) { 
			var wplancc = window.open('plan_chateau_canet.php?langue='+lg,'Plancanet',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=590,height=600,left=30,top=30');
				wplancc.focus();
		}
		
		function ouverture_boutique(){
			var wpart = window.open('http://www.gabrielmeffre.fr','Boutique',
	   			'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,copyhistory=0,width=850,height=800,left=10,top=10');
				wpart.focus();
		}
		
		function ouverture_image(nom_image){
			var wimage = window.open('image.php?nom_image='+nom_image,'Image',
	       	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=640,height=480,left=10,top=10');
			wimage.focus();
		}
		function ouverture_vinl(ref,lg){
			var wvin = window.open('affichage_vin.php?products_id='+ref,'FicheVin',
	   		'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=700,height=600,left=20,top=20');
			wvin.focus();
		}
		function ouverture_vincc(ref,lg){
			var wvincc = window.open('../affichage_vin.php?langue='+lg+'&num_id='+ref,'FicheVin',
	   		'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=700,height=600,left=20,top=20');
			wvincc.focus();
		}
		
		function ouverture_reservation_soiree(lg) { 
			var wresaso = window.open('reservation_soiree.php?langue='+lg,'ResaSoiree',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=505,height=480,left=10,top=10');
			wresaso.focus();
		}
		
		function ouverture_reservation_event(lg) { 
			var wresaevent = window.open('reservation_event.php?langue='+lg,'ResaEvent',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=505,height=480,left=10,top=10');
			wresaevent.focus();
		}
		
		function ouverture_detail_gite(gite) { 
			var wopenwin = window.open('http://www.gabrielmeffre.eu/gite/'+gite,'fichier',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=620,height=600,left=20,top=20');
		}
		
		function ouverture_fenetre(fenetre) { 
			var wopenfen = window.open('http://www.gabriel-meffre.fr/'+fenetre,'fichier',
		      	'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=auto,copyhistory=0,width=620,height=600,left=20,top=20');
		}
		
		
		
		// traitement de la visibilité des couches id="a" et id="f" dans toutes les pages du site
		function init(){
			if (lg == 'f' ){
				f.style.visibility = "visible";
				a.style.visibility = "hidden";
			} 
			if (lg == 'a' ){
				a.style.visibility = "visible";
				f.style.visibility = "hidden";
			} 
		}


	//fonction pour ouvrir une nouvelle fenetre en cliquant sur un objet flash	
		function openNewWindow(URLtoOpen, windowName, windowFeatures) { 
  newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}
		

// Fonctions liées aux survole des images de bouton : générées par macromedia
// permet de les retirer de chaque programme ou elles sont générées automatiquement par Dreamweaver

		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_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_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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
		  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
		  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
		}
		MM_reloadPage(true);
		
function containsOneOf(inStr,what) {
  for (car = 0; car < what.length; car++) {
    if (inStr.indexOf(what.charAt(car)) > -1)
      return true;
  }
  return false;
}

function checkMail(email,lg) {

	if (lg == "fr") {
		var msg1 = "Vous avez oublié de saisir votre Email ...";
		var msg2 = "Votre adresse e-mail doit contenir le caractère @ ";
		var msg3 = "Votre adresse e-mail doit contenir du texte de part et d'autre du caractère @ ";
		var msg4 = "Votre adresse e-mail ne doit pas contenir les caractères suivants : ";
		var msg5 = "Le caractère : ";
		var msg6 = "est interdit dans une adresse e-mail";
	}
	if (lg == "en") {
		var msg1 = "You forgot to type your email...";
		var msg2 = "Your address e-mail must contain the character @";
		var msg3 = "Your address e-mail must contain text on both sides character @ ";
		var msg4 = " Your address e-mail should not contain the following characters:  ";
		var msg5 = "Caracter : ";
		var msg6 = "is interdict in an address e-mail";
	}
  pos = email.indexOf("@");
if (email.value == ""){
    window.alert(msg1);
    email.focus();
    email.select();
    return false;
  }
  if ( (pos < 1) || (pos == (email.length - 1)) ) {
    if (pos < 0)
      window.alert(msg2);
    else
      window.alert(msg3);
    return false;
  }
  before = email.substring(0, pos);
  after = email.substring(pos+1);
  badCharsBase = "() <>,;:\\\"[]*'|&^¨\!?";  
  badChars = badCharsBase;

  if (containsOneOf(after,badChars)) {
    window.alert(msg4 + badCharsBase + "");
    return false;
  }

 if ( (before.charAt(0) == '\"') && (before.charAt(before.length - 1) == '\"') )
    before = before.substring(1, before.length - 2);
  if (containsOneOf(before,badChars)) {
    window.alert(msg4 + badChars + " ");
    return false;
  }

  for (pos = 0; pos < email.length; pos++) if ( (email.charAt(pos) < " ") || (email.charAt(pos) >= "~") ) {
    window.alert(msg5 + email.charAt(pos) + msg6);
    return false;
  }
  
  return true;
}

function checkTel(tel,lg) {
 	if (lg == "fr" ) {
	   	var msg1 = "Vous avez oublié de saisir votre Téléphone ...";
		var msg2 = "Le Numéro de téléphone ne doit être composé que de chiffres, espace, tiret et \(\) ...";
		var msg3 = "Le Numéro de téléphone doit être composé au moins de 10 chiffres ..."
	}
	if (lg == "en") {
	   	var msg1 = "You forgot to type your Telephone number ...";
		var msg2 = "The Telephone number should be made up only of digits, spaces, dash and \ (\)..."; 
		var msg3 = "The Telephone number must be made up at least of 10 digits... "; 
	}
	if (tel.value == ""){
		window.alert(msg1);
		tel.focus();
		tel.select();
		return false;
  	}
	liste_car_val = "() -0123456789";
	liste_num = "0123456789";
	compteur = 0;
	for (car = 0; car < tel.length; car++) {
    	if (liste_car_val.indexOf(tel.charAt(car)) < 0){
		   	window.alert("Le Numéro de téléphone ne doit être composé que de chiffres, espace, tiret et \(\) ...");
  	  		return false;
  	  	}
		if (liste_num.indexOf(tel.charAt(car)) > -1){
			compteur++;
		}
	}
	if (compteur < 10){
		window.alert("le Numéro de téléphone doit être composé au moins de 10 chiffres ...");
  	  	return false;
  	 }
	return true;
}

function checkValues(form,lg) {
  if (form.nom.value == ""){
  	if (lg == "fr" ) {
    	window.alert("Vous avez oublié de saisir votre nom ...");
	}
	if (lg == "en") {
    	window.alert("You forgot to type your name ...");	
	}
    form.nom.focus();
    form.nom.select();
    return false;
  }
  if (form.prenom.value == ""){
  	if (lg == "fr" ) {
    	window.alert("Vous avez oublié de saisir votre prénom ...");
	}
	if (lg == "en") {
    	window.alert("You forgot to type your first name ...");	
	}
    form.prenom.focus();
    form.prenom.select();
    return false;
  }
  if (form.societe.value == ""){
  	if (lg == "fr" ) {
    	window.alert("Vous avez oublié de saisir le nom de votre société...");
	}
	if (lg == "en") {
    	window.alert("You forgot to enter the name of your company ...");	
	}
    form.societe.focus();
    form.societe.select();
    return false;
  }
  if (checkTel(form.tel.value,lg) == false) {
    form.tel.focus();
    form.tel.select();
    return false;
  }

  if (checkMail(form.email.value,lg) == false) {
    form.email.focus();
    form.email.select();
    return false;
  }
  return true;

}
function checkResaOustalet(form,lg) {
  if (form.nom.value == ""){
  	if (lg == "f" ) {
    	window.alert("Vous avez oublié de saisir votre nom ...");
	}
	if (lg == "a") {
    	window.alert("You forgot to type your name ...");	
	}
    form.nom.focus();
    form.nom.select();
    return false;
  }

  if (checkMail(form.email.value,lg) == false) {
    form.email.focus();
    form.email.select();
    return false;
  }
  
  if (checkTel(form.tel.value,lg) == false) {
    form.tel.focus();
    form.tel.select();
    return false;
  }
  return true;

}
function checkResaCanet(form,lg) {
  if (form.nom.value == ""){
  	if (lg == "f" ) {
    	window.alert("Vous avez oublié de saisir votre nom ...");
	}
	if (lg == "a") {
    	window.alert("You forgot to type your name ...");	
	}
    form.nom.focus();
    form.nom.select();
    return false;
  }
  
  if (checkTel(form.tel.value,lg) == false) {
    form.tel.focus();
    form.tel.select();
    return false;
  }

  if (checkMail(form.email.value,lg) == false) {
    form.email.focus();
    form.email.select();
    return false;
  }
  
  return true;

}
function checkResaSoiree(form,lg) {
  if (form.nom.value == ""){
  	if (lg == "f" ) {
    	window.alert("Vous avez oublié de saisir votre nom ...");
	}
	if (lg == "a") {
    	window.alert("You forgot to type your name ...");	
	}
    form.nom.focus();
    form.nom.select();
    return false;
  }
  
  if (checkTel(form.tel.value,lg) == false) {
    form.tel.focus();
    form.tel.select();
    return false;
  }

  if (checkMail(form.email.value,lg) == false) {
    form.email.focus();
    form.email.select();
    return false;
  }
  
  return true;

}
  
function checkResaEvent(form,lg) {
  if (form.nom.value == ""){
  	if (lg == "f" ) {
    	window.alert("Vous avez oublié de saisir votre nom ...");
	}
	if (lg == "a") {
    	window.alert("You forgot to type your name ...");	
	}
    form.nom.focus();
    form.nom.select();
    return false;
  }
  
  if (checkTel(form.tel.value,lg) == false) {
    form.tel.focus();
    form.tel.select();
    return false;
  }

  if (checkMail(form.email.value,lg) == false) {
    form.email.focus();
    form.email.select();
    return false;
  }
  
  return true;

}
 	// Spécifique pour IE7 nécessaire pour appeler des objet flash : suite à brevet Eolas Microsoft gère l'appel de plugin de cette façon sans ajout de code supplémentaire
	function flash(tag) {
		document.write(tag);
	}
	
	
	function view_wine(id,lgid,lg) {
		var win1 = window.open('wiew_wine.php?products_id='+id+'&language_id='+lgid+'&language='+lg,'Vins',
		'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=720,height=750,left=10,top=10');
	}
	function imp_vin(id,lgid,lg) {
		var win1 = window.open('imp_vin.php?products_id='+id+'&language_id='+lgid+'&language='+lg,'Vins',
		'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=720,height=750,left=10,top=10');
	}
	//Bulle
	
			function getLeft(obj)
		//Fonction permettant de connaître la position d'un objet
		//par rapport au bord gauche de la page.
		//Cet objet peut être à l'intérieur d'un autre objet.
			{
			if (obj.offsetParent)
				return (obj.offsetLeft + getLeft(obj.offsetParent));
			else
				return (obj.offsetLeft);
			}
		function getTop(obj)
		//Fonction permettant de connaître la position d'un objet
		//par rapport au bord haut de la page.
		//Cet objet peut être à l'intérieur d'un autre objet.
			{
			if (obj.offsetParent)
				return (obj.offsetTop + getTop(obj.offsetParent));
			else
				return (obj.offsetTop);
			}
	
	
	
	
	var IB=new Object;
	var IB_NbPixel= 0;
	var posX=0;posY=0;
	//var xOffset=230;yOffset=-200;
function AffBulle(texte,obj,variante) {
if(obj.id.substring(0,2) == "bs"){
	if (obj.id.substring(0,3) == "bs1"){xOffset=200;yOffset=-200;lg_fenetre=500;trait=1;space=3;}
	if (obj.id.substring(0,3) == "bs2"){xOffset=300;yOffset=-200;lg_fenetre=500;trait=1;space=3;}
	if (obj.id.substring(0,3) == "bs3"){xOffset=-300;yOffset=230;lg_fenetre=500;trait=1;space=3;}
}else{ 
	if(typeof(timeOutID)!="undefined") {window.clearTimeout(timeOutID);}
	xOffset=0;yOffset=0;
	lgObj = obj.width;
	htObj = obj.height;
	posX = getLeft(obj);
	posY = getTop(obj);
	//if (obj.id.substring(0,3) == "bg1"){xOffset=0;yOffset=-20;lg_fenetre=200} // 
	if (obj.id.substring(0,3) == "bg1"){
		if (variante == "1"){xOffset=50;yOffset=-100;lg_fenetre=260;trait=1;space=0;} // 
		if (variante == "2"){xOffset=100;yOffset=-100;lg_fenetre=260;trait=1;space=0;} // 
		if (variante == "3"){xOffset=-100;yOffset=-100;lg_fenetre=260;trait=1;space=0;} //
		if (variante == "4"){xOffset=-160;yOffset=10;lg_fenetre=260;trait=1;space=0;} // 
		if (variante == "5"){xOffset=-160;yOffset=10;lg_fenetre=260;trait=1;space=0;} // 
		if (variante == "6"){xOffset=-100;yOffset=-100;lg_fenetre=260;trait=1;space=0;} // 
		if (variante == "7"){xOffset=-120;yOffset=10;lg_fenetre=260;trait=1;space=0;} //
		if (variante == "8"){xOffset=-160;yOffset=10;lg_fenetre=260;trait=1;space=0;} // 
		if (variante == "9"){xOffset=100;yOffset=-100;lg_fenetre=260;trait=1;space=0;} // 
		if (variante == "10"){xOffset=100;yOffset=-100;lg_fenetre=260;trait=1;space=0;} // 
	}
	if (obj.id.substring(0,3) == "bg2"){
		if (variante == "1"){xOffset=-300;yOffset=10;lg_fenetre=200;trait=0;space=0;} // languedoc
		if (variante == "2"){xOffset=-300;yOffset=10;lg_fenetre=200;trait=0;space=0;} // provence
		if (variante == "3"){xOffset=-140;yOffset=-5;lg_fenetre=200;trait=0;space=0;} // septentrionale
		if (variante == "4"){xOffset=-140;yOffset=-5;lg_fenetre=200;trait=0;space=0;} // meridionale
	}
}
  	contenu="<TABLE border=0 width="+lg_fenetre+" cellspacing=0 cellpadding="+trait+"><TR bgcolor='"+IB.ColContour+"'><TD><TABLE border=0 cellpadding="+space+" cellspacing="+space+" width=100\% bgcolor='"+IB.ColFond+"'><TR><TD align=left>"+texte+"</TD></TR></TABLE></TD></TR></TABLE>&nbsp;";
  	var finalPosX=posX-xOffset;
  	if (finalPosX<0) finalPosX=0;
  if (document.layers) {
    document.layers["bulle"].document.write(contenu);
    document.layers["bulle"].document.close();
    document.layers["bulle"].top=posY+yOffset+"px";
    document.layers["bulle"].left=finalPosX+"px";
    document.layers["bulle"].visibility="show";}
  if (document.all) {
    //var f=window.event;
    //doc=document.body.scrollTop;
    bulle.innerHTML=contenu;
    document.all["bulle"].style.top=posY+yOffset+"px";
    document.all["bulle"].style.left=finalPosX+"px";//f.x-xOffset;
    document.all["bulle"].style.visibility="visible";
  }
  //modif CL 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
  else if (document.getElementById) {
    document.getElementById("bulle").innerHTML=contenu;
    document.getElementById("bulle").style.top=posY+yOffset+"px";
    document.getElementById("bulle").style.left=finalPosX+"px";
    document.getElementById("bulle").style.visibility="visible";
  }
}
function getMousePos(e) {
  if (document.all) {
  posX=event.x+document.body.scrollLeft;
  posY=event.y+document.body.scrollTop;
  }
  else {
  posX=e.pageX;
  posY=e.pageY; 
  }

}
function getMousePos_old(e) {
  if (document.all) {
  posX=event.x+document.body.scrollLeft; //modifs CL 09/2001 - IE : regrouper l'évènement
  posY=event.y+document.body.scrollTop;
  if(document.documentElement.clientWidth>0){posX=document.documentElement.clientWidth/2;}else{posX=0;}
  if(document.documentElement.clientHeight>0){posY=document.documentElement.clientHeight/2;}else{posY=0;}
  posX=document.documentElement.clientWidth/2;
  posY=document.documentElement.clientHeight/2;
  //alert(document.documentElement.clientHeight+":"+document.documentElement.clientWidth);
  }
  else {
  posX=e.pageX; //modifs CL 09/2001 - NS6 : celui-ci ne supporte pas e.x et e.y
  posY=e.pageY; 
  }
  //posX=0;posY=0;
}	   
function Timer() {
	var dt=new Date()
	timeOutID= window.setTimeout("HideBulle()",3000);
   }

function HideBulle() {
	if (document.layers) {document.layers["bulle"].visibility="hide";}
	if (document.all) {document.all["bulle"].style.visibility="hidden";}
	else if (document.getElementById){document.getElementById("bulle").style.visibility="hidden";}
}

function InitBulle(ColTexte,ColFond,ColContour,NbPixel) {
	IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
	if (document.layers) {
		window.captureEvents(Event.MOUSEMOVE);
		window.onMouseMove=getMousePos;
		document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
	}
	if (document.all) {
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
		document.onmousemove=getMousePos;
	}
	//modif CL 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
	else if (document.getElementById) {
	        document.onmousemove=getMousePos;
	        document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
	}

}
