function SOAP_error(frame){
	if(document.getElementById('error')){
		if(document.getElementById('error').value==1){
			if(!frame){
				window.location.href="http://www.golfe-saint-tropez-reservation.com/error.php";
			}else{
				window.parent.location.href="http://www.golfe-saint-tropez-reservation.com/error.php";
			}
		}
	}
}

function isEntier(obj){
	Expression = new RegExp("^[0-9]+$");
	return Expression.test(obj.value);
}

function ouvreFiche(){
	var code=document.getElementById('code_produit').value;
	window.location.href='http://www.golfe-saint-tropez-reservation.com/ouvre_fiche_produit.php?code_produit='+code;
}

function voirFiche(cle, cat_id){
	window.location.href='http://www.golfe-saint-tropez-reservation.com/ficheProduit.php?cle='+cle+"&cat_id="+cat_id;
}

function voirCarte(id_fourni, id_produit){
	window.open('http://www.golfe-saint-tropez-reservation.com/itineraire.php?lat='+(document.getElementById('lat_'+id_fourni+'_'+id_produit).value)+'&long='+(document.getElementById('long_'+id_fourni+'_'+id_produit).value),"carte_localisation","menubar=no, status=no, scrollbars=no, menubar=no, width=760, height=700, resizable=1");
}

function situerCarte(gps_lat, gps_long){
	window.open('http://www.golfe-saint-tropez-reservation.com/itineraire.php?lat='+gps_lat+'&long='+gps_long,"carte_localisation","menubar=no, status=no, scrollbars=no, menubar=no, width=760, height=700, resizable=1");
}

function loginVEL(){
	window.location.href='http://www.golfe-saint-tropez-reservation.com/login.php?pageretour='+document.getElementById('page_retour_identification').value+'&formLogin='+document.getElementById('identifiant_client').value+'&formPassword='+document.getElementById('motdepasse_client').value;
}

function loginVEL2(){
	window.location.href='http://www.golfe-saint-tropez-reservation.com/login.php?formLogin='+document.getElementById('identifiant_client2').value+'&formPassword='+document.getElementById('motdepasse_client2').value;
}

function fermerCalendrier(){
	document.getElementById('div_depart_cal').style.display="none";
}

function fermerCalendrier2(){
	document.getElementById('div_depart_cal2').style.display="none";
}

function popup_calendrier(lan_code){
	if(document.getElementById('val_13').value==""){
		switch(lan_code){
			case "FR" :
				alert('Vous devez s' + String.fromCharCode(233) + 'lectionner le mois de votre arriv' + String.fromCharCode(233) + 'e.');
				break;
				
			case "GB" :
				alert('You must select the month of your arrival.');
				break;
		}
	}else{
		document.getElementById('div_depart_cal').style.display="block";
	}
}

function popup_calendrier2(lan_code){
	if(document.getElementById('val_13').value==""){
		switch(lan_code){
			case "FR" :
				alert('Vous devez s' + String.fromCharCode(233) + 'lectionner le mois de votre arriv' + String.fromCharCode(233) + 'e.');
				break;
				
			case "GB" :
				alert('You must select the month of your arrival.');
				break;
		}
	}else{
		document.getElementById('div_depart_cal2').style.display="block";
	}
}

function check_mois_depart(lan_code){
	if(document.getElementById('val_13').value==""){
		switch(lan_code){
			case "FR" :
				alert('Vous devez s' + String.fromCharCode(233) + 'lectionner le mois de votre arriv' + String.fromCharCode(233) + 'e.');
				break;
				
			case "GB" :
				alert('You must select the month of your arrival.');
				break;
		}
		return false;
	}else{
		return true;
	}
}


function ValidDate(date, champ_id){
	//alert(document.getElementById(champ_id).value);
	document.getElementById(champ_id).value = date;
	//alert(document.getElementById(champ_id).value);
}

function changeBudget(val_budget){
	var budget = val_budget.split('-');
	document.getElementById('val_15').value = budget[0];
	document.getElementById('val_16').value = budget[1];
}

function updateToutesPromos(lan_code){
	var date=document.getElementById('val_13').value;
	var type=document.getElementById('val_25').value;
	
	var url='/';
	switch(lan_code){
		case "FR" :
			url = url + 'fr/';
			if(type!=""){
				url = url + type +'/toutes_promos';
			}else{
				url = url + 'toutes_promos';
			}
			if(date!=""){
				url = url + '-' + date ;
			}
			break;
			
		case "GB" :
			url = url + 'uk/';
			if(type!=""){
				url = url + type +'/all_special_offers';
			}else{
				url = url + 'all_special_offers';
			}
			if(date!=""){
				url = url + '-' + date ;
			}			
			break;
	}
	url = url + '.php' ;
	window.location.href=url;
}


/////////////////////////////////////////FONCTIONS AJAX\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

function maj_aff_produit(id_fourni, id_produit, lan_code, cat_id){
	switch(lan_code){
		case "FR" :
			var lib_carte = "Situer sur la carte";
			var lib_resa = "R&eacute;servez en ligne";
			var lib_option = "Demande de disponibilit&eacute;s";
			break;
			
		case "GB" :
			var lib_carte = "Locate on the map";
			var lib_resa = "Reserve on line";
			var lib_option = "Availability request";
			break;
	}
	document.getElementById('prix_a_partir_'+id_fourni).innerHTML = '<span class="prixresultats">'+document.getElementById('prix_'+id_fourni+'_'+id_produit).value + " &euro;</span>";
	
	if((document.getElementById('lat_'+id_fourni+'_'+id_produit).value!="") && (document.getElementById('long_'+id_fourni+'_'+id_produit).value!="")){
		var contenu_lien = '<a href="javascript:voirCarte('+ id_fourni +', document.getElementById(\'produits_' + id_fourni + '\').value);" class="resultats">' + lib_carte + '</a>';
	}else{
		var contenu_lien = '&nbsp;';
	}
	document.getElementById('liens_carte_'+id_fourni).innerHTML = contenu_lien;
	
	if(document.getElementById('request_'+id_fourni+'_'+id_produit).value!="1"){
		var contenu_bouton = '<div id="reservationresultats"><a href="javascript:voirFiche(document.getElementById(\'produits_'+ id_fourni +'\').value , \''+cat_id+'\');"><img src="images/vide.gif" width="95" height="33" border="0" alt="'+lib_resa+'" title="'+lib_resa+'"></a></div>';
	}else{
		var contenu_bouton = '<div id="optionresultats"><a href="javascript:voirFiche(document.getElementById(\'produits_'+ id_fourni +'\').value , \''+cat_id+'\');"><img src="images/vide.gif" width="95" height="33" border="0" alt="'+lib_resa+'" title="'+lib_resa+'"></a></div>';
	}
	document.getElementById('bouton_resa_'+id_fourni).innerHTML = contenu_bouton;
	
}

function maj_aff_produit_promo(id_fourni, id_produit, lan_code){
	switch(lan_code){
		case "FR" :
			var lib_carte = "Situer sur la carte";
			var lib_resa = "R&eacute;servez en ligne";
			var lib_option = "Demande de disponibilit&eacute;s";
			break;
			
		case "GB" :
			var lib_carte = "Locate on the map";
			var lib_resa = "Reserve on line";
			var lib_option = "Availability request";
			break;
	}
	document.getElementById('prix_a_partir_'+id_fourni).innerHTML = '<span class="prixresultats"><strike>'+document.getElementById('prix_avant_remise_'+id_fourni+'_'+id_produit).value + ' &euro;</strike></span><br><span class="prixresultats">'+document.getElementById('prix_'+id_fourni+'_'+id_produit).value + ' &euro;</span>';
	
	if((document.getElementById('lat_'+id_fourni+'_'+id_produit).value!="") && (document.getElementById('long_'+id_fourni+'_'+id_produit).value!="")){
		var contenu_lien = '<a href="javascript:voirCarte('+ id_fourni +', document.getElementById(\'produits_' + id_fourni + '\').value);" class="resultats">' + lib_carte + '</a>';
	}else{
		var contenu_lien = '&nbsp;';
	}
	document.getElementById('liens_carte_'+id_fourni).innerHTML = contenu_lien;
	
	if(document.getElementById('request_'+id_fourni+'_'+id_produit).value!="1"){
		var contenu_bouton = '<div id="reservationresultats"><a href="javascript:voirFiche(document.getElementById(\'produits_'+ id_fourni +'\').value);"><img src="images/vide.gif" width="95" height="33" border="0" alt="'+lib_resa+'" title="'+lib_resa+'"></a></div>';
	}else{
		var contenu_bouton = '<div id="optionresultats"><a href="javascript:voirFiche(document.getElementById(\'produits_'+ id_fourni +'\').value);"><img src="images/vide.gif" width="95" height="33" border="0" alt="'+lib_resa+'" title="'+lib_resa+'"></a></div>';
	}
	document.getElementById('bouton_resa_'+id_fourni).innerHTML = contenu_bouton;
	
}

function changePrixPromotion(id_fourni, id_produit){
	document.getElementById('prix_a_partir_'+id_fourni).innerHTML = '<span class="prixresultats"><strike>'+document.getElementById('prix_avant_remise_'+id_fourni+'_'+id_produit).value + ' &euro;</strike></span><br><span class="prixresultats">'+document.getElementById('prix_'+id_fourni+'_'+id_produit).value + ' &euro;</span>';
}

function changeLibreRequest(id_fourni, id_produit, lan_code){
	switch(lan_code){
		case "FR" :
			var lib_resa = "R&eacute;servez en ligne";
			var lib_option = "Demande de disponibilit&eacute;s";
			break;
			
		case "GB" :
			var lib_resa = "Reserve on line";
			var lib_option = "Availability request";
			break;
	}
	if(document.getElementById('request_'+id_fourni+'_'+id_produit).value!="1"){
		var contenu_bouton = '<div id="reservationresultats"><a href="javascript:voirFiche(document.getElementById(\'produits_'+ id_fourni +'\').value);"><img src="images/vide.gif" width="95" height="33" border="0" alt="'+lib_resa+'" title="'+lib_resa+'"></a></div>';
	}else{
		var contenu_bouton = '<div id="optionresultats"><a href="javascript:voirFiche(document.getElementById(\'produits_'+ id_fourni +'\').value);"><img src="images/vide.gif" width="95" height="33" border="0" alt="'+lib_resa+'" title="'+lib_resa+'"></a></div>';
	}
	document.getElementById('bouton_resa_'+id_fourni).innerHTML = contenu_bouton;
}

function UpdatePrix(nb, prix, prixParPers){
	if(prixParPers==0){
		document.getElementById('prix_produit').innerHTML = prix + " &euro;";
	}
	if(prixParPers==1){
		document.getElementById('prix_produit').innerHTML=(nb*prix)+ " &euro;";
	}
}

function change_css_ie6(){   
	var style = '';
	if(document.getElementById('lan_code')){
		if(document.getElementById('lan_code').value=='FR'){
			style += 'fr/css/';
		}else{
			style += 'uk/css/';
		}
	}else{
		style += 'fr/css/';
	}
	if(document.getElementById('cat_id').value==2){style+='locations.css'}
	if(document.getElementById('cat_id').value==3){style+='hotellerie.css'}
	if(document.getElementById('cat_id').value==4){style+='loisirs.css'}
	//alert($A($$('link[rel=stylesheet]')).first().href != style);
	
	if($A($$('link[rel=stylesheet]')).first().href != style){
		change_css(style);
	}
}  
function change_css(style){   
    $A($$('link[rel=stylesheet]')).first().setAttribute('href',style);   
}  

function changeLangue(lan_code){
	window.location.href='changeLangue.php?lang='+lan_code;
}

// Variables globales
var xmlHttp;
var xmlHttp2;
var xmlHttp3;

function Reset(PUrl, cat_id, lan_code) {
	/*var style = '';
	if(lan_code=='FR'){
		style += 'fr/css/';
	}else{
		style += 'uk/css/';
	}
	if(cat_id==2){style+='locations.css'}
	if(cat_id==3){style+='hotellerie.css'}
	if(cat_id==4){style+='loisirs.css'}
	change_css(style);
	*/
	var lParam;
	lParam = '?cat_id=' + cat_id + '&lan_code=' + lan_code + '&nouvelle_recherche=1'; 
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url = PUrl + lParam + "&nocache=" + Math.random();
	
	xmlHttp.onreadystatechange=stateVisibilityReset;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
	//donner cet id a ton img de chargement : imageLoading
	document.getElementById('imageLoading').style.visibility = 'visible';
	document.body.className = document.body.className.concat(' loading');
	
	scrollTo(0,0);
	
	Expression1 = new RegExp("^http://www.golfe-saint-tropez-reservation.com/index.php$");
	Expression2 = new RegExp("^http://www.golfe-saint-tropez-reservation.com/$");
	if(!(Expression1.test(window.parent.location.href) || Expression2.test(window.parent.location.href))){
		window.location.href="http://www.golfe-saint-tropez-reservation.com/index.php";
	}
	
}

function Update(PUrl, cat_id, lan_code, page) {
	var lParam;
	lParam = '?cat_id=' + cat_id + '&lan_code=' + lan_code; 
	
	var res_par_page = document.getElementById('res_par_page').value; 
	lParam += '&res_par_page=' + res_par_page; 
	
	var res_page = page; 
	lParam += '&res_page=' + res_page; 
	
	var i;
	for(i=0 ; i<= 24 ; i++){
		var id_elemt='val_'+i;
		if(document.getElementById(id_elemt) && document.getElementById(id_elemt).value!=-1){
		//alert(id_elemt + '=' + document.getElementById(id_elemt).value);
			lParam += '&' + id_elemt + '=' + document.getElementById(id_elemt).value;
		}
	}
		
	var j;
	for(j=0 ; j<= document.getElementById('max_id').value ; j++){
		var id_elemt='val_20_'+j;
		if(document.getElementById(id_elemt) && document.getElementById(id_elemt).checked){
		//alert(id_elemt + '=' + document.getElementById(id_elemt).value);
			lParam += '&' + id_elemt + '=' + document.getElementById(id_elemt).value;
		}
	}
			
			
	var tri = document.getElementById('tri').value; 
	lParam += '&tri=' + tri; 
	
	
	xmlHttp2=GetXmlHttpObject();
	if (xmlHttp2==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url = PUrl  + lParam + "&nocache=" + Math.random();

	xmlHttp2.onreadystatechange=stateVisibilityUpdate;
	xmlHttp2.open("GET",url,true);
	xmlHttp2.send(null);
	
	Expression = new RegExp("^http://www.golfe-saint-tropez-reservation.com/ficheProduit");
	if(Expression.test(window.location.href)){
		window.location.href="http://www.golfe-saint-tropez-reservation.com/index.php";
	}
	
	//donner cet id a ton img de chargement : imageLoading
	document.getElementById('site').style.cursor="wait";
	document.getElementById('imageLoading').style.visibility = 'visible';
	document.body.className = document.body.className.concat(' loading');
	
	scrollTo(0,0);
		
}

function UpdateByIFrame(PUrl, cat_id, lan_code, page) {
	var lParam;
	lParam = '?cat_id=' + cat_id + '&lan_code=' + lan_code; 
	
	var res_par_page = window.parent.document.getElementById('res_par_page').value; 
	lParam += '&res_par_page=' + res_par_page; 
	
	var res_page = page; 
	lParam += '&res_page=' + res_page; 
	
	
	var i;
	for(i=0 ; i<= 24 ; i++){
		var id_elemt='val_'+i;
		if(window.parent.document.getElementById(id_elemt) && window.parent.document.getElementById(id_elemt).value!=-1){
		//alert(id_elemt + '=' + document.getElementById(id_elemt).value);
			lParam += '&' + id_elemt + '=' + window.parent.document.getElementById(id_elemt).value;
		}
	}
		
	var j;
	for(j=0 ; j<= window.parent.document.getElementById('max_id').value ; j++){
		var id_elemt='val_20_'+j;
		if(window.parent.document.getElementById(id_elemt) && window.parent.document.getElementById(id_elemt).checked){
		//alert(id_elemt + '=' + document.getElementById(id_elemt).value);
			lParam += '&' + id_elemt + '=' + window.parent.document.getElementById(id_elemt).value;
		}
	}
				
	
	var tri = window.parent.document.getElementById('tri').value; 
	lParam += '&tri=' + tri; 
	
	
	xmlHttp3=GetXmlHttpObject();
	if (xmlHttp3==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url = PUrl  + lParam + "&nocache=" + Math.random();

	xmlHttp3.onreadystatechange=stateVisibilityUpdateByIFrame;
	xmlHttp3.open("GET",url,true);
	xmlHttp3.send(null);
	
	Expression = new RegExp("^http://www.golfe-saint-tropez-reservation.com/ficheProduit");
	if(Expression.test(window.location.href)){
		window.parent.location.href="http://www.golfe-saint-tropez-reservation.com/index.php";
	}
	
	//donner cet id a ton img de chargement : imageLoading
	window.parent.document.getElementById('imageLoading').style.visibility = 'visible';
	window.parent.document.body.className = window.parent.document.body.className.concat(' loading');
}


//fonctions stateVisibility
function stateVisibilityReset() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById('page').innerHTML=xmlHttp.responseText;
		//donner cet id a ton img de chargement : imageLoading
		document.getElementById('imageLoading').style.visibility = 'hidden';
		document.body.className = document.body.className.replace(' loading', '');
	} 
}

function stateVisibilityUpdate() {
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{ 
		document.getElementById('page').innerHTML=xmlHttp2.responseText;
		//donner cet id a ton img de chargement : imageLoading
		document.getElementById('imageLoading').style.visibility = 'hidden';
		document.body.className = document.body.className.replace(' loading', '');
		document.getElementById('site').style.cursor="auto";
	} 
}

function stateVisibilityUpdateByIFrame() {
	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
	{ 
		//donner cet id a ton img de chargement : imageLoading
		window.parent.document.getElementById('imageLoading').style.visibility = 'hidden';
		window.parent.document.body.className = window.top.document.body.className.replace(' loading', '');

		window.parent.document.getElementById('page').innerHTML=xmlHttp3.responseText;
	} 
}

function stateVisibilityVille() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById('ChangeVille').innerHTML=xmlHttp.responseText;
		//donner cet id a ton img de chargement : imageLoading
		document.getElementById('imageLoading').style.visibility = 'hidden';
		document.body.className = document.body.className.replace(' loading', '');
	} 
}

// Fonction retournant un objet XMLHttp
function GetXmlHttpObject() { 
 var objXMLHttp=null;
 if (window.XMLHttpRequest) {
  objXMLHttp=new XMLHttpRequest();
 }
 else if (window.ActiveXObject) {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
 return objXMLHttp;
}

