function post_requete_serveur(url, donnees)
{
 if (window.XMLHttpRequest)
 {
   xmlhttp = new XMLHttpRequest();
   //alert(url);
   xmlhttp.open("POST", url, false);
   xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
   //xmlhttp.setRequestHeader("charset", "UTF-8") ;
   xmlhttp.send('validation=1&'+donnees);
 }
 else if (window.ActiveXObject)
 {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   if (xmlhttp)
   {
     xmlhttp.open("POST", url, false);
     xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     //xmlhttp.setRequestHeader("charset", "ISO-8859-1") ;
     xmlhttp.send('validation=1&'+donnees);
   }
 }
 //alert('_'+xmlhttp.status+'_'+xmlhttp.statusText) ;
 if (xmlhttp.status == 200)
 {
   if (xmlhttp.responseText == '_#_perte_de_session_#_') window.location.href = 'index.php' ;
   else return (xmlhttp.responseText);
 }
 else
 {
   alert("Problème pour retrouver les données sur le serveur:\n" + xmlhttp.statusText);
 }
} 

//impression
function PSR_imprimer () {
	var PSR_f1 = null;
	var PSR_content=document.getElementById('Impression').parentNode.innerHTML;
	var PSR_title=document.getElementsByTagName('title')[0].innerText;
	if (PSR_f1) {if(!PSR_f1.closed) PSR_f1.close();}
	PSR_f1 = window.open ('',"PSR_f1", "height=500,width=600,menubar=yes,scrollbars=yes,resizable=yes,,left=10,top=10");
	PSR_f1.document.open();
	PSR_f1.document.write("<html><head><title>" + PSR_title + "</title><link href=\"../fileadmin/ha2009/templates/css/print.css\" rel=\"stylesheet\" type=\"text/css\"></head><body bgcolor='#ffffff' onload='window.print()'>"+PSR_content+"</body></html>");
	PSR_f1.document.close();
	PSR_f1.focus();

}



function filepanier(iddoc,titredoc) {
	if (document.formdoc.caddy[1].checked == false ) {
		document.formdoc.caddy[1].checked = true;
		document.formdoc.caddy[1].value = "+"+iddoc;
		document.getElementById('votrepanier').value = titredoc;
	}
	else
	{
		if (document.formdoc.caddy[2].checked == false ) {
			document.formdoc.caddy[2].checked = true;
			document.formdoc.caddy[2].value = "+"+iddoc;
			document.getElementById('votrepanier2').value = titredoc;
		}
		else 
		{
			if (document.formdoc.caddy[3].checked == false ) {
				document.formdoc.caddy[3].checked = true;
				document.formdoc.caddy[3].value = "+"+iddoc;
				document.getElementById('votrepanier3').value = titredoc;
			}
			else
			{
				alert('(3 documents au maximun) consultez votre panier en bas de page');
			}
		}
	}
}

//affiche ou cache un div exemple: formulaire sejour
function deroul_div(id_div) {
 if(document.getElementById(id_div).className=='aff_div')
   {document.getElementById(id_div).className='cache_div'}
  else if(document.getElementById(id_div).className=='cache_div')
   {document.getElementById(id_div).className='aff_div'}
}



//FONCTION VERIFICATION DU FORMULAIRE POUR EVITER LE WWW2/VALID DE CACHAT  *******A amélioré******

function verifFormulaire() {

	var valid=0;
	if (document.getElementById('nom').value == "") { document.getElementById('nom').className="selectfalse";valid=1; }
	else { document.getElementById('nom').className="select"; }
	if (document.getElementById('prenom').value == "") { document.getElementById('prenom').className="selectfalse";valid=1; }
	else { document.getElementById('prenom').className="select"; }
	if (document.getElementById('adresse').value == "") { document.getElementById('adresse').className="selectfalse";valid=1; }
	else document.getElementById('adresse').className="select";
	if (document.getElementById('codePoste').value == "") {	document.getElementById('codePoste').className="selectfalse";valid=1; }
	else document.getElementById('codePoste').className="select";
	if (document.getElementById('ville').value == "") { document.getElementById('ville').className="selectfalse";valid=1; }
	else document.getElementById('ville').className="select";

	
	var adresse = document.getElementById('email').value;
	var place = adresse.indexOf("@",1);
	var point = adresse.indexOf(".",place+1);
	if ((place > -1)&&(adresse.length >2)&&(point > 1))	{ document.getElementById('email').className="select"; }
	else { document.getElementById('email').className="selectfalse";valid=1; }
	 
	var verdat = document.getElementById('sejour_debut').value;
	datej= new Date()
	anneej=datej.getFullYear()+"*";
	anneej=anneej.substring(0,2);
	if (!isValidDate(verdat)) { document.getElementById('sejour_debut').className="selectfalse";valid=1; }
	else document.getElementById('sejour_debut').className="select";
	
	if (valid=="0") { return true;}
	else { return false; }
}
function isValidDate(d) {
var dateRegEx = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
return d.match(dateRegEx);
	} 


	


//FONCTION FORMULAIRE POUR SEJOUR
function masqueformulaire() {
document.getElementById('conteneur').style.display='none';
document.getElementById('ejs_logo2').style.display='none';
}

function formulaire(idsejour) {
var PageUrl=self.location.href
if (navigator.appName=="Microsoft Internet Explorer") {
w2=document.body.scrollTop;
ful_scx = (window.document.body.clientWidth);
ful_scy = ((window.document.body.clientHeight)+w2);
}
else
{
ful_scx = window.innerWidth;
ful_scy = window.innerHeight;
}
var sTop = document.documentElement.scrollTop;
var cont_scx = ful_scx/2;
var cont_scy = ful_scy/2;
ful_scy = ful_scy + sTop;
cont_scy = cont_scy + sTop;



toto="<a href=\""+PageUrl+"\">";

info="<div id='ejs_logo2' style='position:absolute;z-index:100;width:"+ful_scx+"px;height:"+ful_scy+"px;background:#000000;filter:alpha(opacity=80);opacity:0.8;top:0px;left:0px;'></div>";
info+="<div id='conteneur' style='position: absolute;z-index: 102;left:"+cont_scx+"px;top:"+cont_scy+"px;width:558px;height:300px;margin-top:-150px;margin-left:-279px;background-color:#999999;padding:10px;padding-top:60px;background-image:url(/fileadmin/ha2009/templates/images/mondevis.gif);background-repeat:no-repeat;background-position:left top;display:block;'>";
info+="<div style='position:relative;float:right;top:-50px;'><span onclick=\"masqueformulaire();\" style=\"cursor:pointer;\"><b>X</b></span></div>";
info+="<table cellspacing=0 cellpadding=0 border=0 width=538><tR><td>";
info+="<form method=\"post\" action=\"http://www2.hautes-alpes.net/valid\" name=\"form\">";
info+="<input type=\"hidden\" name=\"meta\" id=\"name\" value=\"contactCdtWeb 2003-04-24\">";
info+="<input type=\"hidden\" name=\"nextpage\" id=\"name\" value=\""+PageUrl+"\">";

info+="<font class=\"formtexte\"><u><b>Vos coordonn&eacute;es</B></u></font>";
info+="<table><tR>";
info+="<tD class=\"formtexte\" align=right>Civilite :</tD>";
info+="<tD><select name=\"civilite\" id=\"civilite\" class=\"select\"><option value=\"MMm\">Mme et Mr</option><option value=\"M\">Monsieur</option><option value=\"Mme\">Madame</option><option value=\"Mlle\">Mademoiselle</option><option value=\"Vide\">------------------------</option></select></tD>";
info+="<tD class=\"formtexte\" align=right>Nom :</td>";
info+="<tD><input name=\"nom\" id=\"nom\" type=\"text\" size=14 class=\"select\"></td>";
info+="<td class=\"formtexte\" align=right>Pr&eacute;nom :</td>";
info+="<td><input name=\"prenom\" id=\"prenom\" type=\"text\" size=14 class=\"select\"></tD>";
info+="</tR><tR>";
info+="<tD class=\"formtexte\" align=right>Adresse :</tD>";
info+="<tD><input name=\"adresse\" id=\"adresse\" type=\"text\" size=18 class=\"select\"></tD>";
info+="<tD class=\"formtexte\" align=right>Code Postal :</td>";
info+="<tD><input name=\"codePoste\" id=\"codePoste\" type=\"text\" size=14 class=\"select\"></td>";
info+="<td class=\"formtexte\" align=right>Ville :</td>";
info+="<td><input name=\"ville\" id=\"ville\" type=\"text\" size=14 class=\"select\"></tD>";
info+="</tR><tR>";
info+="<tD class=\"formtexte\" align=right>Pays :</tD>";
info+="<tD><select name=\"pays\" id=\"pays\" class=\"select\">";
info+="<option value=\"FR\">France</option><option value=\"DE\">Allemagne</option><option value=\"AD\">Andorre</option><option value=\"BE\">Belgique</option><option value=\"DK\">Danemark</option>";
info+="<option value=\"CA\">Canada</option><option value=\"ES\">Espagne</option><option value=\"US\">&eacute;tats-unis</option><option value=\"FI\">Finlande</option><option value=\"GB\">Grande Bretagne</option>";
info+="<option value=\"IT\">Italie</option><option value=\"LU\">Luxembourg</option><option value=\"MC\">Monaco</option><option value=\"NO\">Norv&egrave;ge</option><option value=\"NL\">Pays-bas</option>";
info+="<option value=\"PT\">Portugal</option><option value=\"RU\">Russie</option><option value=\"SE\">Su&egrave;de </option><option value=\"CH\">Suisse</option>";
info+="</select></tD>";
info+="<tD class=\"formtexte\" align=right>T&eacute;l&eacute;phone :</td>";
info+="<tD><input name=\"tel\" id=\"tel\" type=\"text\" size=14 class=\"select\"></td>";
info+="<td class=\"formtexte\" align=right>E-mail :</td>";
info+="<td><input name=\"email\" id=\"email\" type=\"text\" size=14 class=\"select\"></tD>";
info+="</tr></table>";

info+="<bR><bR><font class=\"formtexte\"><u><b>Votre demande</B></u></font><br>";

info+="<table cellspacing=0 cellpadding=0 border=0 width=538><tR>";
info+="<tD class=\"formtexte\" align=right>D&eacute;but du s&eacute;jour :&nbsp;</td>";
info+="<tD><input name=\"sejour_debut\" id=\"sejour_debut\" type=\"text\" size=14 value=\"jj/mm/aaaa\" class=\"select\"></td>";
info+="<tD class=\"formtexte\" align=right>Nb adultes :&nbsp;</td>";
info+="<tD><select name=\"nbre_adulte\" id=\"nbre_adulte\" class=\"select\">";
info+="<option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>20</option><option>30</option><option>40</option><option>50</option>";
info+="</select></td>";
info+="<tD class=\"formtexte\" align=right>Nb enfants :&nbsp;</td>";
info+="<tD><Select name=\"nbre_enfants\" id=\"nbre_enfants\" class=\"select\">";
info+="<option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option><option>20</option><option>30</option><option>40</option><option>50</option>";
info+="</select></td>";
info+="</tR><tr>";
info+="<tD class=\"formtexte\" valign=top align=right>Commentaires :&nbsp;</td>";
info+="<td colspan=5>";
if (navigator.appName=="Microsoft Internet Explorer") {
info+="<textarea name=\"notes\" class=\"select\" cols=80 rows=3>";
}
else
{
info+="<textarea name=\"notes\" class=\"select\" cols=75 rows=3>";
}
info+="</textarea></tD>";
info+="</tr><tR>";
info+="<tD class=\"formtexte\" colspan=6>Abonnement &agrave; la NewsLetter : <input type=\"radio\" name=\"newsletter\" id=\"newsletter\" value=\"OUI\">Oui&nbsp;&nbsp;&nbsp;<input type=\"radio\" name=\"newsletter\" id=\"newsletter\" value=\"NON\" checked>Non</tD>";
info+="</tR></table>";

info+="<input type=\"hidden\" name=\"dateContact\" value=\"\">";
info+="<input type=\"hidden\" name=\"idCree\" id=\"idCree\" value=\"\">";
info+="<input type=\"hidden\" name=\"idModifie\" id=\"idModifie\" value=\"\">";
info+="<input type=\"hidden\" name=\"etat\" id=\"etat\" value=\"TER\">";
info+="<input type=\"hidden\" name=\"caddy\" value=\"+"+idsejour+"\">";
info+="<input type=\"hidden\" name=\"sejour_duree\" value=\"0\">";

info+="<table width=100%><tR><td valign=top>";
info+="<input type=\"button\" value=\"Valider\" class=\"select\" onClick=\"if (verifFormulaire()) document.form.submit()\"><td>&nbsp;</tD> ";
info+="<td class=\"formtexte\">";
info+="<font style=\"font-size:9px;\">Selon la loi informatique et libert&eacute;s du 06/01/78, vous b&eacute;n&eacute;ficiez d'un droit d\'acc&egrave;s aux informations qui vous concernent aupr&egrave;s du CDT05-service Consommateurs - BP 46 -05002 GAP Cedex</font>";
info+="</tD></tR></table>";
info+="</form>";

info+="</tD></tr></table>";
info+="</div>"; 


if (navigator.appName=="Microsoft Internet Explorer") {
document.getElementById('balise').outerHTML=info;
}
else {
document.getElementById('balise').innerHTML=info;
}

}	
//FIN FONCTION FORMULAIRE POUR SEJOUR




//fonction de message centre et grisement de la page en vue d'une redirection (url next page, contenu du message, couleur du div message)
function message(url,contenu,couleur) {
urlsuite=url

if (navigator.appName=="Microsoft Internet Explorer") {
w2=document.body.scrollTop;
ful_scx = (window.document.body.clientWidth);
ful_scy = ((window.document.body.clientHeight)+w2);
}
else
{
ful_scx = window.innerWidth;
ful_scy = window.innerHeight;
}
var sTop = document.documentElement.scrollTop;
var cont_scx = ful_scx/2;
var cont_scy = ful_scy/2;
ful_scy = ful_scy + sTop;
cont_scy = cont_scy + sTop;

info="<div id='ejs_logo2' style='position:absolute;z-index:100;width:"+ful_scx+"px;height:"+ful_scy+"px;background:#000000;filter:alpha(opacity=80);opacity:0.8;top:0px;left:0px;'></div>";
info+="<div id='conteneur' style='position: absolute;z-index: 102;left:"+cont_scx+"px;top:"+cont_scy+"px;width:250px;height:100px;margin-top:-50px;margin-left:-125px;background-color:"+couleur+";vertical-align:middle;text-align:center;font-family:Arial;font-size:17px;color:#ffffff;font-weight:bold;padding-top:30px;'>"+contenu+"</div>"; 


if (navigator.appName=="Microsoft Internet Explorer") {
document.getElementById('balise').outerHTML=info;
}
else {
document.getElementById('balise').innerHTML=info;
}


setTimeout("ClickOnItem(urlsuite)",2000);

}	
	
function ClickOnItem(indexItem) 
{ 
window.location.href=indexItem;  
}


//fonction qui permet de zoomer une images d'un id1 de div1 vers un id2 de div2
function Zoom(id,id2) 
{ 
document.getElementById(id).src = document.getElementById(id2).src;
document.getElementById(id).alt = document.getElementById(id2).alt;
document.getElementById(id).title = document.getElementById(id2).title;
}


	




