function paidForCIC()
{
	//on verifie si la case est coché
	if(document.getElementById("accept_cgv"))
	{
		if(document.getElementById("accept_cgv").checked)
		{
			document.PaymentRequest.submit();
			
		}
		else
		{
			alert("Vous devez accepter les conditions générales de vente");
		}
	}
}

function PopupImage(img) {
	titre="-Visionneuse-";
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE>");
	w.document.write("<SC"+"RIPT language=java"+"script> function checksize()  { if (document.images['img'].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+100); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT></HEAD>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0 name='img'>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}
function validFormMoteurRef()
{

	if(document.form_moteurref.search_ref.value == "" || document.form_moteurref.search_ref.value == "référence annonce")
	{
		alert("Vous devez renseigner une référence d'annonce");
		return false;
	}
	
	return true;
}
function validFormMoteur()
{

	if(document.form_moteur.id_destinations.value == "")
	{
		alert("Vous devez sélectionner une destination");
		return false;
	}
	
	if(document.form_moteur.id_typeoffres.value == "")
	{
		alert("Vous devez sélectionner un type d'offre");
		return false;
	}
	
	if(document.form_moteur.id_typeoffres.value != "sejour_pack")
	{
		if(document.form_moteur.id_localisations.value == "")
		{
			alert("Vous devez choisir une localisation");
			return false;
		}
		
		if(calculer(document.form_moteur.date_debut.value) <= 0)
		{
			alert("Vous devez choisir une date supérieure à aujourd'hui");
			return false;
		}
	}
	
	return true;
}

function ModifOrder(param,table)
{
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	
	
		xml = $.ajax({
	   type: "GET",
	   url: "_xml_modifolder.php",
	   data: "ordre="+param+"&table="+table+"&a="+a,
	   async: false
		});
	
}

function DrawSelectLocalisation(id_dest, zone)
{
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	
	html = $.ajax({
	   type: "GET",
	   url: "_xml_drawselectlocalisation.php",
	   data: "id_dest="+id_dest+"&a="+a,
	   async: false
		}).responseText;
		
		document.getElementById(zone).innerHTML = html;
}

function DrawSelectTypeOffreForMoteur(id_dest, zone)
{
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	
	html = $.ajax({
	   type: "GET",
	   url: "_xml_drawselecttypeoffre.php",
	   data: "id_dest="+id_dest+"&a="+a,
	   async: false
		}).responseText;
		
		document.getElementById(zone).innerHTML = html;
}

function DrawSelectTypeOffreForStat(id_dest, zone)
{
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	
	html = $.ajax({
	   type: "GET",
	   url: "_xml_drawselecttypeoffre.php",
	   data: "id_dest="+id_dest+"&zonepackage=no&a="+a,
	   async: false
		}).responseText;
		
		document.getElementById(zone).innerHTML = html;
}

function DrawSelectTypeBien(id_categorie, zone)
{
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	
	html = $.ajax({
	   type: "GET",
	   url: "_xml_drawselecttypebien.php",
	   data: "categorie="+id_categorie+"&a="+a,
	   async: false
		}).responseText;
		
		document.getElementById(zone).innerHTML = html;
}

function DrawSelectTypeActivite(zone)
{
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	
	html = $.ajax({
	   type: "GET",
	   url: "_xml_drawselecttypeactivite.php",
	    data: "a="+a,
	   async: false
		}).responseText;
		
		document.getElementById(zone).innerHTML = html;
}

function DrawSelectPrecision(categorie, zone)
{
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	
	html = $.ajax({
	   type: "GET",
	   url: "_xml_drawselectprecision.php",
	    data: "categorie="+categorie+"&a="+a,
	   async: false
		}).responseText;
		
		document.getElementById(zone).innerHTML = html;
}

function convertXml(xml){  
	if ($.browser.msie){  
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  
		xmlDoc.loadXML(xml);  
		xml = xmlDoc;  
	}  
	return xml;  
}

function getInfoForSelect(id, sel, url, promo)
{
	//initialisation du menu déroulant
	sel.length=1;
	
	//réinitialisation de l'appel xml
	haz = Math.round(Math.random()*100000000);
	
	if(promo)
	{
		arg = "id="+id+"&promo="+promo+"&a="+haz
	}
	else
	{
		arg = "id="+id+"&promo=&a="+haz
	}
	
	$.ajax({
				   type: "GET",
				   dataType: "json",
				   url: url,
				   data: arg,
				   success: function(t) 
					{
						z = 1;
						   //le traitement
						jQuery.each(t.LIGNE, function() {
							var id = this.ID;
                            var lib =  this.LIB;
							                      
							xmlNom = lib;
							xmlId = id;
							sel.options[z] = new Option(xmlNom, xmlId);
				
							z++;
						});
					}
						   
			}); 
}



function verifUniciteReference(ref, id, tbl)
{	
	//réinitialisation de l'appel xml
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
		
		xml = $.ajax({
	   type: "GET",
	    dataType: "json",
	   url: "_xml_verifunicitereference.php",
	   data: "ref="+ref+"&id="+id+"&tbl="+tbl+"&a="+a,
	   async: false,
	   success: function(t) 
			{
				z = 1;
				   //le traitement
				jQuery.each(t.LIGNE, function() {
					var val = this.REPONSE;
					return (val);
		
					z++;
				});
			}
		});

		
}


function verifControlDate(d)
{	
	//réinitialisation de l'appel xml
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	var val;
		xml = $.ajax({
	   type: "GET",
	   url: "_xml_controldate.php",
	    dataType: "json",
	   data: "date="+d,
	   async: false,
	   success: function(t) 
			{
				
				   //le traitement
				jQuery.each(t.LIGNE, function() {
					val = this.REPONSE;
					
				});
			}
		});
return val;	

}

function getTypeHeberg(id,chp,url,chpsec)
{	
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
		
		$.ajax({
				   type: "GET",
				   dataType: "json",
				   url: "_xml_gettypeheberg.php",
					data: "id="+id+"&a="+a,
					async : false,
				   success: function(t) 
					{
						z = 1;
						//le traitement
						jQuery.each(t.INFOS, function() {
							var rep = this.TYPES;
							if(chpsec != "")
							{
								chpsec.innerHTML = rep;
							}
							getInfoForSelect(rep, chp, url);
							return ;
				
							z++;
						});
					}
						   
			}); 
			
}

function getXmlNbPromo(url, arg)
{
	
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
		
	$.ajax({
				type: "GET",
				dataType: "json",
				url: url,
				data: arg,
				async : false,
				success: function(t) 
				{
					z = 1;
					   //le traitement
					jQuery.each(t.LIGNE, function() {
						var val = this.VALEUR;
						
					if(val > 1)
					{
						pluriel = "s";
					}
					else
					{
						pluriel = "";
					}
					document.getElementById("zone_s1").innerHTML = pluriel;
					document.getElementById("zone_s2").innerHTML = pluriel;
					
					document.getElementById("zone_nbPromoDispo").innerHTML = val;
			return;
						z++;
					});
				}
					   
		}); 
}

function UCword(chaine)
{
	val = chaine.charAt(0).toUpperCase() + chaine.substring(1).toLowerCase();
	
	return val;
}

function popup(page,w,h,scro, nom) {

	if(!nom)
	{
		var nom = "popup";
	}

	var w =  window.open(page,nom,'width='+w+',height='+h+',toolbar=false,scrollbars='+scro+',top=0,left=0');	
	w.document.close();
	w.focus();
}

function VerifMail(chps)
{

  var place = chps.indexOf("@",1);
  var point = chps.indexOf(".",place+1);
  if (!((place > -1)&&(chps.length >2)&&(point > 1)))
  {
	return(false);
  }
  else
  {
	return(true);
  }
}

function in_array(needle, haystack, argStrict) {
  
    var found = false, key, strict = !!argStrict;

    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }

    return found;
}


function urldecode(carac)
{

	var caractere = new Array;
	caractere["%20"] 	= " "; 
	caractere["%27"] 	= "'";
	caractere["%E7"] 	= "ç"; 
	caractere["%F4"] 	= "ô";
	caractere["%F6"] 	= "ö";
	caractere["%E0"]	= "à";
	caractere["%E2"]	= "â";
	caractere["%E4"]	= "ä";
	caractere["%E8"]	= "è";
	caractere["%E9"]	= "é";
	caractere["%EA"]	= "ê";
	caractere["%EB"]	= "ë";
	caractere["%F9"]	= "ù";
	caractere["%FB"]	= "û";
	caractere["%FC"]	= "ü";
	caractere["%EC"]	= "ì";
	caractere["%EE"]	= "î";
	caractere["%EF"]	= "ï";
	
	for(i in caractere)
	{
		var reg=new RegExp("("+i+")", "g");
		carac = carac.replace(reg, caractere[i], carac);
	}
	
	return carac;
}	
	
// Voici les 3 fonctions de gestions des cookies
////////////////////////////////////////////////
var pathname=location.pathname;
var myDomain=pathname.substring(0,pathname.lastIndexOf('/')) +'/';
var date_exp = new Date();
date_exp.setTime(date_exp.getTime()+(365*24*3600*1000));
function getCookieVal(offset) {
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1)
      		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen) {
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)
                        return getCookieVal (j);
                i=document.cookie.indexOf(" ",i)+1;
                        if (i==0) break;}
	return null;
}
function SetCookie (name, value) {
// un cookie a besoin d'un nom, d'une valeur, d'un nom de domaine, d'une date d'expiration
// 
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=name+"="+escape(value)+
		((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
		((path==null) ? "" : ("; path="+path))+
		((domain==null) ? "" : ("; domain="+domain))+
		((secure==true) ? "; secure" : "");
}
///////////////////////////////////	

function count( mixed_var, mode ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Waldo Malqui Silva
    // +      bugfixed by: Soren Hansen
    // *     example 1: count([[0,0],[0,-4]], 'COUNT_RECURSIVE');
    // *     returns 1: 6
    // *     example 2: count({'one' : [1,2,3,4,5]}, 'COUNT_RECURSIVE');
    // *     returns 2: 6
 
    var key, cnt = 0;
 
    if (mixed_var === null){
        return 0;
    } else if (mixed_var.constructor !== Array && mixed_var.constructor !== Object){
        return 1;
    }
 
    if( mode === 'COUNT_RECURSIVE' ) {
        mode = 1;
    }
    if( mode != 1 ) {
        mode = 0;
    }
 
    for (key in mixed_var){
        cnt++;
        if( mode==1 && mixed_var[key] && (mixed_var[key].constructor === Array || mixed_var[key].constructor === Object) ){
            cnt += count(mixed_var[key], 1);
        }
    }
 
    return cnt;
}
		 
function implode( glue, pieces ) {
   
    return ( ( pieces instanceof Array ) ? pieces.join( glue ) : pieces );
}

function validForm()
{	
	if(url = getUrl(document.form_moteur.pays.value, document.form_moteur.hebergement.value, document.form_moteur.ville.value))
	{
		//on valide le formulaire
		document.form_moteur.action = url;
		document.form_moteur.submit();
	}
	else
	{
		alert("Nous sommes désolé mais il n'existe aucune offre pour cette séléction dans notre catalogue");
		return false;
	}
}

function RotatePub(key)
{
	max = infopub["bloc"].length-1;
	
	DrawBlocPub(key);

	if(key == max)
	{
		i=0;
	}
	else
	{
		i=key+1;
	}

	 setTimeout("RotatePub("+i+")",cst_rota);
}

function RotateBandeauPub(key)
{
	max = infopub["popup"].length-1;
	
	DrawBandeauPub(key);
	
	if(key == max)
	{
		i=0;
	}
	else
	{
		i=key+1;
	}

	 setTimeout("RotateBandeauPub("+i+")",cst_rota);
}

function RotateSkycraper(key)
{
	max = infopub["skycraper"].length-1;
	
	DrawSkycraper(key);

	if(key == max)
	{
		i=0;
	}
	else
	{
		i=key+1;
	}

	 setTimeout("RotateSkycraper("+i+")",cst_rota);
}

/********************************************************************************************************************************/
/**	Fonction 		OpenCalk
/**	But	:		Afficher un partie de code HTML en surimpression
/**	argument :		val		-->	contenu HTML
/**
/*******************************************************************************************************************************/

function OpenCalk(val)
{
	 if(document.getElementById("zone_info_calk").style.display=="none")
	 {		
		 //on desactive la barre de defilement 	
			document.body.className= "body_gris";
		 //on recupere la taille
			var size = document.getElementsByTagName("html")[0];
		
		 //on met a jour le contenu du calque	
			document.getElementById("zone_info").innerHTML = "";
			document.getElementById("zone_info").innerHTML += val;
		 //on redimensionne le calque	
			document.getElementById("zone_info_calk").style.top = document.body.scrollTop;
			document.getElementById("zone_info_calk").style.height = size.offsetHeight+size.offsetTop;
			document.getElementById("zone_info_calk").style.width = size.offsetWidth+10;
		 //on affiche le calque
			document.getElementById("zone_info_calk").style.display="block";			
	 }
	 else
	 {
		 //on résactive la barre de defilement 	
			document.body.className= "body";
		//on met a jour le contenu du calque	
			document.getElementById("zone_info").innerHTML = "";
		//on cache le calque
			document.getElementById("zone_info_calk").style.display="none";
	 }
}

function AffPromo(pays, xVar)
{
	if(pays != "")
	{	
		if(navigator.appName == "Netscape")
		{
			getInfoMozilla(pays, xVar);
		}
		else
		{
			getInfoIE(pays, xVar);
		}
	}
}

function getInfoIE(pays, xVar)
{
	xmlDoc = tempData.XMLDocument ; 
	xmlDoc.async = false ; 
	xmlDoc.resolveExternals = false; 
	tempData.load("/xml/getDataPromoFromDestination.xml.php?lib_pays="+pays+"&id="+xVar); 
	
	temp = xmlDoc.selectNodes("DONNEE/INFO"); 
	for(i=0; i<temp.length; i++) 
	{ 
		if(document.getElementById("zone_promo_"+temp[i].selectSingleNode("CODEOFFRE").text))
		{
			document.getElementById("zone_promo_"+temp[i].selectSingleNode("CODEOFFRE").text).innerHTML = temp[i].selectSingleNode("LIGNE1").text;
			if(temp[i].selectSingleNode("LIGNE2").text != "")
			{
				document.getElementById("zone_promo_"+temp[i].selectSingleNode("CODEOFFRE").text).innerHTML += "<br>"+temp[i].selectSingleNode("LIGNE2").text;
			}
			if(temp[i].selectSingleNode("LIGNE3").text != "")
			{
				document.getElementById("zone_promo_"+temp[i].selectSingleNode("CODEOFFRE").text).innerHTML += "<br>"+temp[i].selectSingleNode("LIGNE3").text;
			}
		}
	}
}

function getInfoMozilla(pays, xVar)
{
	var httpRequest = null; 
	if(window.XMLHttpRequest) 
	{ // Mozilla, Safari, Firefox ... 
	  httpRequest = new XMLHttpRequest(); 
	  if (httpRequest.overrideMimeType) 
	  { 
		httpRequest.overrideMimeType('text/xml'); 
	  } 
	}
	
	httpRequest.open('GET', "/xml/getDataPromoFromDestination.xml.php?lib_pays="+pays+"&id="+xVar,  true);
	
	httpRequest.send(null);
	
	httpRequest.onreadystatechange = function()
	{ 
		if(httpRequest.readyState == 4) 
		{ 
			if (httpRequest.status == 200) 
			{ 
				var xml = httpRequest.responseXML; 
				
				var temp = xml.getElementsByTagName('DONNEE')[0];
				
				var info = temp.getElementsByTagName('INFO');
				
				for(i=0; i<info.length; i++) 
				{ 	
					codeoffre = info[i].getElementsByTagName('CODEOFFRE')[0].firstChild.nodeValue;
					ligne1 = info[i].getElementsByTagName('LIGNE1')[0].firstChild.nodeValue;
					ligne2 = info[i].getElementsByTagName('LIGNE2')[0].firstChild.nodeValue;
					ligne3 = info[i].getElementsByTagName('LIGNE3')[0].firstChild.nodeValue;
					
					if(document.getElementById("zone_promo_"+codeoffre))
					{
						document.getElementById("zone_promo_"+codeoffre).innerHTML = ligne1;
						if(ligne2 != "")
						{
							document.getElementById("zone_promo_"+codeoffre).innerHTML += "<br>"+ligne2;
						}
						if(ligne3 != "")
						{
							document.getElementById("zone_promo_"+codeoffre).innerHTML += "<br>"+ligne3;
						}
					}
				}
			} 
			else 
			{ 
			  // il y a un problème avec la requête 
			  alert("probleme");
			} 
		} 
	}
}

function AffPromoFiche(code_promo, xVar)
{
	
	if(code_promo != "")
	{
		if(navigator.appName == "Netscape")
		{
			AffPromoFicheMozilla(code_promo, xVar);
		}
		else
		{
			AffPromoFicheIE(code_promo, xVar);
		}
	}
}

function AffPromoFicheMozilla(code_promo, xVar)
{
	var httpRequest = null; 
	if(window.XMLHttpRequest) 
	{ // Mozilla, Safari, Firefox ... 
	  httpRequest = new XMLHttpRequest(); 
	  if (httpRequest.overrideMimeType) 
	  { 
		httpRequest.overrideMimeType('text/xml'); 
	  } 
	}
	
	httpRequest.open('GET', "/xml/getDataPromo.xml.php?code_promo="+code_promo+"&id="+xVar, true);
	
	httpRequest.send(null);
	
	httpRequest.onreadystatechange = function()
	{ 
		if(httpRequest.readyState == 4) 
		{ 
			if (httpRequest.status == 200) 
			{ 
				var xml = httpRequest.responseXML; 
				
				var temp = xml.getElementsByTagName('DONNEE')[0];
				
				var info = temp.getElementsByTagName('INFO');
				
					codeoffre = info[0].getElementsByTagName('CODEOFFRE')[0].firstChild.nodeValue;
					ligne1 = info[0].getElementsByTagName('LIGNE1')[0].firstChild.nodeValue;
					ligne2 = info[0].getElementsByTagName('LIGNE2')[0].firstChild.nodeValue;
					ligne3 = info[0].getElementsByTagName('LIGNE3')[0].firstChild.nodeValue;
				
				if(	codeoffre != "")
				{
					DisplayZoneAuto("zone_aff_promo", 'oui');
					document.getElementById("zone_ligne_promo").innerHTML = "<NOBR>"+ligne1+"</NOBR>";
						if(ligne2 != "")
						{
							document.getElementById("zone_ligne_promo").innerHTML += "<br><NOBR>"+ligne2+"</NOBR>";
						}
						if(ligne3 != "")
						{
							document.getElementById("zone_ligne_promo").innerHTML += "<br><NOBR>"+ligne3+"</NOBR>";
						}
					
				}
			} 
			else 
			{ 
			  // il y a un problème avec la requête 
			  alert("probleme");
			} 
		} 
	}
}

function AffPromoFicheIE(code_promo, xVar)
{
	xmlDoc = tempData.XMLDocument ; 
	xmlDoc.async = false ; 
	xmlDoc.resolveExternals = false; 
	tempData.load("/xml/getDataPromo.xml.php?code_promo="+code_promo+"&id="+xVar); 
	//alert("/xml/getDataPromo.xml.php?code_promo="+code_promo+"&id="+xVar); 
	temp = xmlDoc.selectNodes("DONNEE/INFO"); 
	
	if(temp[0].selectSingleNode("CODEOFFRE").text != "")
	{
		DisplayZoneAuto("zone_aff_promo", 'oui');
		document.getElementById("zone_ligne_promo").innerHTML = "<NOBR>"+temp[0].selectSingleNode("LIGNE1").text+"</NOBR>";
		if(temp[0].selectSingleNode("LIGNE2").text != "")
		{
			document.getElementById("zone_ligne_promo").innerHTML += "<br>"+temp[0].selectSingleNode("LIGNE2").text;
		}
		if(temp[0].selectSingleNode("LIGNE3").text != "")
		{
			document.getElementById("zone_ligne_promo").innerHTML += "<br>"+temp[0].selectSingleNode("LIGNE3").text;
		}
	}
}

/********************************************************************************************************************************/
/**	Fonction 		DisplayZone
/**	But	:		plier ou deplier une zone HTLM 
/**	argument :	
/**				zone	-->	la zone a cacher ou afficher
/**				action	--> hidd, open
/**
/*******************************************************************************************************************************/

function DisplayZone(zone, action)
{
	if(document.getElementById(zone))
	{
		if(action == "open")
		{
			document.getElementById(zone).className="zone_visible";
		}
		else
		{
			document.getElementById(zone).className="zone_hidden";
		}
		
	}	
}

function toggle(zone, aff)
{

if(aff == "oui")
		{
			document.getElementById(zone).style.display= "table-row-group";
		}
		else
		{
			document.getElementById(zone).style.display= "none";
		}
}

function toggle2(zone, aff)
{
	if(document.getElementById(zone))
	{
		if(aff == "oui")
		{
			document.getElementById(zone).style.display= "";
		}
		else
		{
			document.getElementById(zone).style.display= "none";
		}
	}
}
function DisplayZoneAuto(zone, aff)
{
	if(navigator.appName == "Netscape")
	{
		if(aff == "oui")
		{
			document.getElementById(zone).style.display= "table-row";
		}
		else
		{
			document.getElementById(zone).style.display= "none";
		}
	}
	else
	{
	   if(aff == "oui")
		{
			document.getElementById(zone).style.display= "block";
		}
		else
		{
			document.getElementById(zone).style.display= "none";
		}
	}
}

/********************************************************************************************************************************/
/**	Fonction 		ModifImg
/**	But	:		remplace une image par une autre
/**	argument :	
/**				src	-->	nom de l'image
/**				url	--> path de la nouvelle image
/**
/*******************************************************************************************************************************/

function ModifImg(src, url)
{
	 document.images[src].src=url;
}

/********************************************************************************************************************************/
/**	Fonction 		ModifHTML
/**	But	:		remplace un contenu HTML par un autre
/**	argument :	
/**				zone	-->	nom de la zone
/**				ctn	--> nouveau contenu
/**
/*******************************************************************************************************************************/


function ModifHTML(zone, ctn)
{
	document.getElementById(zone).innerHTML = ctn;
}

/********************************************************************************************************************************/
/**	Fonction 		AjoutFavoris
/**	But	:		ajout aux favori la page en cours
/**	argument :	
/**				nom	-->	nom de la page
/**				url	--> url de la page
/**
/*******************************************************************************************************************************/


function AjoutFavoris(nom, url) 
{
	if ( navigator.appName != 'Microsoft Internet Explorer' )
	{ 
		window.sidebar.addPanel(nom,url,""); 
	}
	else 
	{ 
		window.external.AddFavorite(url,nom); 
	} 
}

function setSelectValue(selectId, value)
{
	/*Récupération du select*/
	var elmt = document.getElementById(selectId);
	
	/*On parcourt les options du select*/
	for (var i = 0; i < elmt.options.length; i++)
	{
		/*Si l'élément à la bonne valeur on le sélectionne*/
		if(elmt.options[i].value == value)
		{
			elmt.selectedIndex = i;
			return true;
		}
	}
	/*On a pas trouvé la valeur on retourne faux*/
	return false;
}

function actionDispo(obj, idoffre)
{
	//réinitialisation de l'appel xml
	a = Math.round(Math.random()*100000000);
	
	if(obj.checked)
	{
		document.getElementById("cel_"+obj.id).className="reserve";
		act_Dispo = "add";
	}
	else
	{
		document.getElementById("cel_"+obj.id).className="disponible";
		act_Dispo = "del";
	}
	
	xml = $.ajax({
		type: "GET",
		url: "_xml_actiondispo.php",
		data: "idoffre="+idoffre+"&date="+obj.id+"&action="+act_Dispo+"&a="+a,
		async: false
	});
}

function calendarAllChecked(obj, mois, idoffre)
{
	ligne=getElementsByAttribute(document.getElementById('tabMonth'+mois), "td", "name", 'cell_'+mois);
	
	//var max=document.getElementsByName('cell_'+mois).length;
	var max=ligne.length;
	
	for(i=0; i<max; i++)
	{
		id = ligne[i].id.substring(4);
		
		if(obj.checked)
		{
			if(!document.getElementById(id).checked)
			{
				document.getElementById(id).checked = true;
				actionDispo(document.getElementById(id), idoffre);
			}
		}
		else
		{
				document.getElementById(id).checked = false;
				actionDispo(document.getElementById(id), idoffre);
		}
	}
	
	
}

function temps(date)
{
    var d = new Date(date[2], date[1] - 1, date[0]);
    return d.getTime();
}

function calculer(date)
{
	ladate=new Date();
	aujourdhui = ladate.getDate()+"/"+(ladate.getMonth()+1)+"/"+ladate.getFullYear();
	
    var debut = temps(aujourdhui.split("/"));
    var fin = temps(date.split("/"));
	
    var nb = (fin - debut) / (1000 * 60 * 60 * 24); // + " jours";
	
    return nb;
    }
	
function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;

	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}
