

function Open_Questions(camping,lang)
{
	if(camping=="siege") NewWin=window.open("../../commun/include/questions.php?camping="+camping+"&lang="+lang,'home','width=750,height=500,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,resizable=no');
	else NewWin=window.open("commun/include/questions.php?camping="+camping+"&lang="+lang,'home','width=750,height=500,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,resizable=no');
}

function efface_input(input){
	input.value = '';
}

function rollover(nom,img1,img2){
	var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? 'document'+'.'+nom : 'document.all.'+nom);
	if (nom == '')
		return;
	if (img) {
		img.altsrc = img1;
		img.src    = img2;
	}
	
	//on change le lien aussi pour le light box
	if(nom=="image_moyenne") {
		var href_new = img2.replace("moyennes","grandes");
		document.getElementById('href_image_moyenne').href=href_new;
		var href_ancien = img1.replace("moyennes","grandes");
	}
	
}


function affiche_div(div){
	document.getElementById(div).style.display="block";
}

function cache_div(div){
	document.getElementById(div).style.display="none";	
}

/*function deplace_liste_camping(gauche,haut) {
	document.getElementById("accueil-liste-campings").style.left=gauche+"px";	
	document.getElementById("accueil-liste-campings").style.top=haut+"px";	

}*/


function popup(url,width,height){
	NewWin=window.open(url,'home','width='+width+',height='+height+',scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,resizable=no');
}

function popup2(url,width,height){
	NewWin=window.open(url,'home','width='+width+',height='+height+',scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=yes');
}


function popup_img(img){
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no');	
	w.document.write("<HTML><HEAD><TITLE>Photo</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+15,document.images[0].height+60); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><center><IMG src='"+img+"' border=0 alt='grande image camping franceloc'></center>");
	//w.document.write("<p align='center'><a href='javascript:window.close()'>Fermer</a></p>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}

function Open_Previsit(PREVISIT)
{
		NewWin1=window.open("../360_degre/visite.php?site="+PREVISIT,'home','width=850,height=512,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=yes');
}


function validate(form){
	
	var Mail=trim(form.Mail.value);
	if (Mail=="")
	{
		alert("Le Champs Mail est vide");
		return false;
	}
	var reponse = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	if(!reponse.test(Mail)){
		alert("L'adresse mail n'est pas valide");
		return false;
	}
	
	var Nom=trim(form.Nom.value);
	if (Nom=="")
	{
		alert("Le Champs Nom est vide !");
		return false;
	}
	
	var Prenom=trim(form.Prenom.value);
	if (Prenom=="")
	{
		alert("Le Champs Prenom est vide");
		return false;
	}
	return true;
}

function trim (str) {
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function verif(email) {
	var arobase = email.indexOf("@")
	var point = email.lastIndexOf(".")
	if((arobase < 3)||(point + 2 > email.length)
	   ||(point < arobase+3)) return false
	return true
}

function valide_brochure(form,lang){
	return true;
	if(lang=="FR") {
		var nom=trim(form.nom.value);
		if (nom=="")
		{
			alert("Le Champ Nom est vide");
			return false;
		}
		var prenom=trim(form.prenom.value);
		if (prenom=="")
		{
			alert("Le Champ Prénom est vide");
			return false;
		}
		var adresse=trim(form.adresse.value);
		if (adresse=="")
		{
			alert("Le Champ Adresse est vide");
			return false;
		}
		var CP=trim(form.CP.value);
		if (CP=="")
		{
			alert("Le Champ CP est vide");
			return false;
		}
		var ville=trim(form.ville.value);
		if (ville=="")
		{
			alert("Le Champ Ville est vide");
			return false;
		}
		var mail=trim(form.mail.value);
		if (mail=="")
		{
			alert("Le Champs Mail est vide");
			return false;
		}
		if(!verif(mail)) {
			alert("Email invalide !");
			return false;
		}	
		return mail;
	}
	else if(lang=="NL") {
		var nom=trim(form.nom.value);
		if (nom=="")
		{
			alert("Name is empty");
			return false;
		}
		var prenom=trim(form.prenom.value);
		if (prenom=="")
		{
			alert("First name is empty");
			return false;
		}
		var adresse=trim(form.adresse.value);
		if (adresse=="")
		{
			alert("Adress is empty");
			return false;
		}
		var CP=trim(form.CP.value);
		if (CP=="")
		{
			alert("Postcode is empty");
			return false;
		}
		var ville=trim(form.ville.value);
		if (ville=="")
		{
			alert("Town is empty");
			return false;
		}
		var mail=trim(form.mail.value);
		if (mail=="")
		{
			alert("E-Mail is empty");
			return false;
		}
		if(!verif(mail)) {
			alert("Email is false !");
			return false;
		}	
		return mail;
	}
	else if(lang=="EN") {
		var nom=trim(form.nom.value);
		if (nom=="")
		{
			alert("Name is empty");
			return false;
		}
		var prenom=trim(form.prenom.value);
		if (prenom=="")
		{
			alert("First name is empty");
			return false;
		}
		var adresse=trim(form.adresse.value);
		if (adresse=="")
		{
			alert("Adress is empty");
			return false;
		}
		var CP=trim(form.CP.value);
		if (CP=="")
		{
			alert("Postcode is empty");
			return false;
		}
		var ville=trim(form.ville.value);
		if (ville=="")
		{
			alert("Town is empty");
			return false;
		}
		var mail=trim(form.mail.value);
		if (mail=="")
		{
			alert("E-Mail is empty");
			return false;
		}
		if(!verif(mail)) {
			alert("Email is false !");
			return false;
		}	
		return mail;	
	}
}

function affiche_ajax(id_div,nom,prenom,adresse1,adresse2,CP,ville,pays,mail,lang,camping){
	  texte = http_file('http://www.campings-franceloc.fr/commun/include/valid_brochure.php?mail='+mail+'&lang='+lang+'&camping='+camping+'&nom='+nom+'&prenom='+prenom+'&adresse1='+adresse1+'&adresse2='+adresse2+'&CP='+CP+'&ville='+ville+'&pays='+pays);
	  //texte = http_file('http://10.20.1.82/campings-franceloc/commun/include/valid_brochure.php?mail='+mail+'&lang='+lang+'&camping='+camping+'&Newsletter='+newsletter);
	  writediv(id_div,texte);
	  //document.getElementById(id_div).onclick="writediv("+id_div+",'') ;" ;
}

function writediv(id_div,texte)
     {
     document.getElementById(id_div).innerHTML = texte;
     }

function http_file(fichier){
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest(); 
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
     else 
          return(false); 
     //xhr_object.open("GET", fichier, true);    //asynchrone
	 xhr_object.open("GET", fichier, false);   //synchrone
	 xhr_object.send(null); 

  
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
}

function OpenCalendar(){
	document.getElementById("calrec").style.visibility="";
 	envoieRequete("commun/include/calrec.php",'calrec');
	document.getElementById("calrec2").style.visibility="hidden";
 }
 function OpenCalendar2(){
	document.getElementById("calrec2").style.visibility="";
 	envoieRequete("commun/include/calrec2.php",'calrec2');
	document.getElementById("calrec").style.visibility="hidden";
 }
 function OpenCalendar_accueil(){
	document.getElementById("calrec_accueil").style.visibility="";
 	envoieRequete("commun/include/calrec_accueil.php",'calrec_accueil');
 }
 function OpenCalendar_sejour(){
	document.getElementById("calrec_accueil").style.visibility="";
 	envoieRequete("../../commun/include/calrec_accueil2.php",'calrec_accueil');
 }
 function addDate(date){
 	document.getElementById('date_debut').value = date
	document.getElementById("calrec").style.visibility="hidden";
 }
 function addDate_accueil(date){
 	document.getElementById('date_debut').value = date
	document.getElementById("calrec_accueil").style.visibility="hidden";
 }
 function addDate2(date){
 	document.getElementById('date_fin').value = date
	document.getElementById("calrec2").style.visibility="hidden";
 }
 /*
 function launchJavascript(responseText) {
  // RegExp from prototype.sonio.net
  var ScriptFragment = '(?:<script.*?>)((\n|.)*?)(?:</script>)';
           
  var match    = new RegExp(ScriptFragment, 'img');
  var scripts  = responseText.match(match);

    if(scripts) {
        var js = '';
        for(var s = 0; s < scripts.length; s++) {
            var match = new RegExp(ScriptFragment, 'im');
            js += scripts[s].match(match)[1];
        }
        eval(js);
    }
}
*/
function launchJavascript(responseText) {
       // RegExp from prototype.sonio.net
       var ScriptFragment = '(?:<script.*?> )((\n|.)*?)(?:</script> )';
          
       var match    = new RegExp(ScriptFragment, 'img');
       var scripts  = responseText.match(match);
      
       if(scripts) {
             var js = '';
             for(var s = 0; s < scripts.length; s++) {
                   var match = new RegExp(ScriptFragment, 'im');
                   js += scripts[s].match(match)[1];
             }
             eval(js);
             return true;
        }
       return false;
 }
  
function envoieRequete(url,id) {
	var xhr_object = null;
	var position = id;
	if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
	else
	if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	// On ouvre la requete vers la page désirée
	xhr_object.open("GET", url, true);
	document.getElementById(position).innerHTML = '<br /><br /><center>Chargement ... <img src="commun/images/loading.gif" align="absmiddle"></center><br /><br />';
	xhr_object.onreadystatechange = function(){
		if ( xhr_object.readyState == 4 ) {
			// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
			var leselect = xhr_object.responseText;
			 if(launchJavascript(leselect) == false)
			  {
					  var c = document.getElementById(position);
					 c.innerHTML = leselect;
			   }
			//document.getElementById(position).innerHTML = xhr_object.responseText;
			
			
		}
	}
	// dans le cas du get
	xhr_object.send(null);
}

function envoieRequete_sans_load(url,id) {
	//alert(url+"-"+id);
	var xhr_object = null;
	var position = id;
	
	if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
	else
	if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	// On ouvre la requete vers la page désirée
	xhr_object.open("GET", url, true);
	xhr_object.onreadystatechange = function(){
		if ( xhr_object.readyState == 4 ) {
			// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
			document.getElementById(position).innerHTML = xhr_object.responseText;
		}
	}
	// dans le cas du get
	xhr_object.send(null);
}





// --------------------------- Pour virer le cadre autour des flashs ---------------------------------- //

/**
	Frédéric Saunier
	http://www.tekool.net/javascript/backtothehtml

	This program is part of a free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

**/

/*****************************************************************************
* BackToTheHtml Command
*///**************************************************************************
function BackToTheHtml(node)
{
	if(node == null)
		this.node = document; 
	else
		this.node = node; 
};
BackToTheHtml.prototype.node = null;

BackToTheHtml.prototype.execute = function()
{
	this.activateObject();
}

BackToTheHtml.prototype.activateObject = function(domObject)
{
	var aDomObject = this.node.getElementsByTagName('object');
	var activationObject;
	for(var i=0; i<aDomObject.length; i++)
		if
		(
			aDomObject[i].getAttributeNode('BackToTheHtml') == null
			&&
			(activationObject = this.getActivationObject(aDomObject[i])) != null
		)
			activationObject.execute();
};

BackToTheHtml.prototype.getActivationObject = function(domObject)
{
	var classid = domObject.classid.toUpperCase().substr('clsid:'.length);
	var mimeType = domObject.type.toLowerCase();

	switch(true)
	{
		case 
			classid == 'D27CDB6E-AE6D-11CF-96B8-444553540000' 
			||
			mimeType == 'application/x-shockwave-flash'
		:
			return new ActivateObjectFlash(domObject);

		default :
			return null;
	}
};

BackToTheHtml.uniqueID = function(prefix)
{
	var sPrefix;
	if(prefix == null)
		sPrefix = 'uniqueId';
	else
		sPrefix = prefix;
		
	var i=0;
	while(document.getElementById(sPrefix + (i++)))
		;
	return sPrefix + (i-1);
};

BackToTheHtml.isParentOf = function(parent,child)
{
	var found = false;
	for(var i=0; i<parent.childNodes.length; i++)
		if(parent.childNodes[i] == child)
			return true;
		else
			found = arguments.callee(parent.childNodes[i],child);

	return found;
}

/*****************************************************************************
* ActivateObject Command
*///**************************************************************************
function ActivateObject(domObject)
{
	this.domObject = domObject;
}

ActivateObject.prototype.domObject = null;
ActivateObject.prototype.classid = null;
ActivateObject.prototype.aHtmlAttribute = ['accessKey','align','alt','archive','border','code','codeBase','codeType','declare','dir','height','hideFocus','hspace','lang','language','name','standby','tabIndex','title','useMap','vspace','width'];
ActivateObject.prototype.aObjectProperty = null;

ActivateObject.prototype.execute = function()
{
	this.xndObjectId = BackToTheHtml.uniqueID();
	this.setTextHtml();
	this.writeObject();

	this.xndObject = document.getElementById(this.xndObjectId);
	this.setSpecialProperties();
	this.removeOriginalObject();
}

ActivateObject.prototype.setTextHtml = function()
{
	var str = '';
	str += '<object BackToTheHtml ' + '\n';
	str += ' classid="clsid:' + this.classid + '" ' + '\n';

	//Add HTML attributes to the <object> tag
	for(var i=0; i<this.aHtmlAttribute.length; i++)
	{
		var name = this.aHtmlAttribute[i];
		if(typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '')
			str += '\t' + name + '="' + this.domObject[name].toString() + '" ' + '\n';
	}

	str += 'id="' + this.xndObjectId + '" ' + '\n';
	str += '>';

	for(var i=0; i<this.aObjectProperty.length; i++)
	{
		var name = this.aObjectProperty[i];
		if(typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '' )
			str += '\t<param name="' + name + '" value="' + this.domObject[name].toString() + '"></param>' + '\n';
	}
	str += '</object>';

	this.textHtml = str;
};

ActivateObject.prototype.writeObject = function()
{
	this.domObject.insertAdjacentHTML("afterEnd",this.textHtml);
};

ActivateObject.prototype.setSpecialProperties = function()
{
	if(typeof this.domObject.className != 'undefined' && this.domObject.className.toString() != '')
		this.xndObject.className = this.domObject.className

	if(typeof this.domObject.style.cssText != 'undefined' && this.domObject.style.cssText.toString() != '')
		this.xndObject.style.cssText = this.domObject.style.cssText;

	if(typeof this.domObject.SWRemote != 'undefined' && this.domObject.SWRemote.toString() != '')
		this.xndObject.FlashVars = this.domObject.SWRemote;

	if(typeof this.domObject.codebase == 'undefined' || this.domObject.codebase.toString() == '')
		this.xndObject.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0';

	if(typeof this.domObject.id != 'undefined' && this.domObject.id.toString() != '')
		this.xndObject.id = this.domObject.id;

};

ActivateObject.prototype.removeOriginalObject = function()
{
	this.domObject.parentNode.removeChild(this.domObject);
};

/*****************************************************************************
* ActivateObjectFlash Command
*///**************************************************************************
function ActivateObjectFlash(domObject)
{
	ActivateObject.call(this,domObject);
}
ActivateObjectFlash.prototype = new ActivateObject;
ActivateObjectFlash.prototype.aObjectProperty = ['FrameNum','Playing','Quality','Quality2','Scalemode','Scale','AlignMode','SAlign','BackgroundColor','BGColor','Loop','Movie','WMode','Base','DeviceFont','EmbedMovie','SWRemote','FlashVars','AllowScriptAccess'];
ActivateObjectFlash.prototype.classid = 'D27CDB6E-AE6D-11CF-96B8-444553540000';


/*****************************************************************************
* Script initialisation
*///**************************************************************************
if(typeof ActiveXObject != 'undefined' && typeof Function.call != 'undefined')
{
	var styleId = BackToTheHtml.uniqueID();
	document.write('<style id="' + styleId + '" ></style>');
	var domStyle = document.getElementById(styleId);

	var isHead = false;
	var aHead = document.getElementsByTagName('head');
	for(var i=0; i<aHead.length; i++)
		if(BackToTheHtml.isParentOf(aHead[i],domStyle))
			isHead = true;

	if(isHead)
	{
		document.write('<style type="text/css">OBJECT{visibility:hidden;}</style>');
		document.onreadystatechange = function()
		{
			if(document.readyState == 'complete')
			{
				new BackToTheHtml().execute();
				document.styleSheets[document.styleSheets.length-1].addRule("OBJECT","visibility:visible;");
				//alert('head');
				//alert(document.body.innerHTML);
			}
		}
	}
	else
	{
		new BackToTheHtml().execute();
		//alert('body');
		//alert(document.body.innerHTML);
	}
	
	domStyle.parentNode.removeChild(domStyle);
}


function openShadowbox(url){
    Shadowbox.open({
        content:    url,
        player:     "iframe",
        title:      "visite virtuelle",
		height:     615,
        width:      830

    });
}
