  /**************************************************/
 /********* FONCTIONS COMMUNES JAVASCRIPT *********/
/************************************************/
function makearray(n) {
	this.length = n;
	for(var i = 1; i <= n; i++)
		this[i] = 0;
	return this;
}

hexa = new makearray(16);
function fade(sr, sg, sb, er, eg, eb, step){
	for(var i = 0; i < 10; i++)
	hexa[i] = i;
	hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
	hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
	for(var i = 0; i <= step; i++){
		setbgColor(
		Math.floor(sr * ((step-i)/step) + er * (i/step)),
		Math.floor(sg * ((step-i)/step) + eg * (i/step)),
		Math.floor(sb * ((step-i)/step) + eb * (i/step)));
	}
}
function persplus(pers)
{
document.formulaire.pers.value = pers ;
document.formulaire.submit();
}

function semplus(opti_debut)
{
document.formulaire.opti_debut.value = opti_debut
document.formulaire.submit();
}
function EnableSS(){
	/* active les zones samedi-samedi et desactive periode spec  */
	document.forms[0].date_spec.disabled = 1;
	document.forms[0].pers_spec.disabled = 1;
	document.forms[0].opti_debut.disabled = 0;
	document.forms[0].opti_fin[0].disabled = 0;
	document.forms[0].opti_fin[1].disabled = 0;
	document.forms[0].opti_fin[2].disabled = 0;
	document.forms[0].opti_fin[3].disabled = 0;
	document.forms[0].pers.disabled = 0;
	document.forms[0].periode_spec[0].checked = 1;

}

function DisableSS(){
	/* active les zones samedi-samedi et desactive periode spec  */
	document.forms[0].date_spec.disabled = 0;
	document.forms[0].pers_spec.disabled = 0;
	document.forms[0].opti_debut.disabled = 1;
	document.forms[0].opti_fin[0].disabled = 1;
	document.forms[0].opti_fin[1].disabled = 1;
	document.forms[0].opti_fin[2].disabled = 1;
	document.forms[0].opti_fin[3].disabled = 1;
	document.forms[0].pers.disabled = 1;
}

function customfade(){
/*si fonction customfade() désactivé (return) -> activer la couleur de fond sur BODY (arkiane.css) */
/* background: #5035AE;*/
return
	sr = 255
	sg = 255
	sb = 255
	er = 80
	eg = 53
	eb = 174
	step = 64
	for(var i = 0; i < 10; i++)
		hexa[i] = i;
		hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
		hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
		for(var i = 0; i <= step; i++)
		{
			setbgColor(
			Math.floor(sr * ((step-i)/step) + er * (i/step)),
			Math.floor(sg * ((step-i)/step) + eg * (i/step)),
			Math.floor(sb * ((step-i)/step) + eb * (i/step)));
		}
}

function hex(i) {
	if (i < 0)
		return "00";
	else if (i > 255)
		return "ff";
		else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setbgColor(r, g, b) {
	var hr = hex(r), hg = hex(g), hb = hex(b);
	document.bgColor = "#"+hr+hg+hb;
}

function DisableBtnSuite(){
/* pour éviter les clicks successifs */
	/* le formulaire est référencé */
	document.forms[0].b_next.disabled = 1;
	document.forms[0].submit();
	/* si on veut nommer le formulaire */
	/*document.nom_du_formulaire.nom_du_bouton.disabled = 1;
	document.nom_du_formulaire.submit();*/
}

function EnableCC(){
/* active les zones de saise CB  */
	document.forms[0].num_cb.disabled = 0;
	document.forms[0].mois_exp.disabled = 0;
	document.forms[0].an_exp.disabled = 0;
	document.forms[0].crypto.disabled = 0;
	document.forms[0].num_cb.className = "coord";
	document.forms[0].mois_exp.className = "coord";
	document.forms[0].an_exp.className = "coord";
	document.forms[0].crypto.className = "coord";
}
function DisableCC(){
/* desactive les zones de saise CB  */
	document.forms[0].num_cb.disabled = 1;
	document.forms[0].mois_exp.disabled = 1;
	document.forms[0].an_exp.disabled = 1;
	document.forms[0].crypto.disabled = 1;
	document.forms[0].num_cb.value = "";
	document.forms[0].mois_exp.value = "";
	document.forms[0].an_exp.value = "";
	document.forms[0].crypto.value = "";
	document.forms[0].num_cb.className = "disabled";
	document.forms[0].mois_exp.className = "disabled";
	document.forms[0].an_exp.className = "disabled";
	document.forms[0].crypto.className = "disabled";
}

function currentpage(numpage){
	document.form_dispo.no_appel.value = numpage;
	document.form_dispo.submit();
}

function envoiMail(){
	action="mailto:";
	document.courrier.action=action;
}

function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) {
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


function verif_coord(lang,mailconf,top_no){
	if(document.form_coord.cc_accept.checked == false){
		switch (lang){
			case "FR" :
				msg = "Vous devez accepter les conditions générales pour poursuivre ! Cliquer dans J'accepte les conditions générales";
				break;
			default :
				msg="You don't have accepted booking conditions !";
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.cc_accept.focus();
		return false;
		
	}
	zone=document.form_coord.nom.value;
	if ((zone.length<1) || (zone == "" || (zone == " "))){
		switch (lang)	{
			case "FR" :
				msg="Veuillez entrer votre nom !";
				break;
			default :
				msg="Enter your surname !";
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.nom.focus();
		return false;
	}
	zone=document.form_coord.prenom.value;
	if ((zone.length<1) || (zone == "")){
		if (top_no == '.' || top_no == '' || top_no == ''  ){
			switch (lang)	{
			case "FR" :
				msg="Veuillez entrer votre prénom !" + top_no ;
				break;
			default :
				msg="Enter your first name !";
			}
		}else{
			switch (lang)	{
			case "FR" :
				msg="Veuillez entrer le nom du client !";
				break;
			default :
				msg="Enter the client name !";
			}
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.prenom.focus();
		return false;
	}
	zone=document.form_coord.adr1.value;
	if ((zone.length<1) || (zone == "") || (zone == " ") ){
		switch (lang)	{
			case "FR" :
				msg="Veuillez entrer votre adresse !";
				break;
			default :
				msg="Enter your address !";
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.adr1.focus();
		return false;
	}
	zone=document.form_coord.cp.value;
	if ((zone.length<1) || (zone == "")){
		switch (lang)	{
			case "FR" :
				msg="Veuillez entrer votre code postal !";
				break;
			default :
				msg="Enter your zip code !";
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.cp.focus();
		return false;
	}
	zone=document.form_coord.ville.value;
	if ((zone.length<1) || (zone == "")){
		switch (lang)	{
			case "FR" :
				msg="Veuillez entrer votre ville !";
				break;
			default :
				msg="Enter your city !";
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.ville.focus();
		return false;
	}
	zone=document.form_coord.pays.value;
	if ((zone.length<1) || (zone == "")){
		switch (lang)	{
			case "FR" :
				msg="Veuillez entrer votre pays !";
				break;
			default :
				msg="Enter your country !";
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.pays.focus();
		return false;
	}
	zone=document.form_coord.tel.value;
	if ((zone.length<1) || (zone == "")){
		switch (lang)	{
			case "FR" :
				msg="Veuillez entrer votre téléphone !";
				break;
			default :
				msg="Enter your phone number !";
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.tel.focus();
		return false;
	}
	zone=document.form_coord.email.value;
	if ((zone.length>0) && (zone != "")){
		pos_arro = -1;
		pos_point = -1;
		pos_arro = zone.indexOf('@');
		if (pos_arro > -1){pos_point = zone.substring(pos_arro+1).indexOf('.');}
		if ((pos_arro == -1) || (pos_point == -1)) {
			switch (lang)	{
				case "FR" :
					msg="Ce n'est pas une adresse électronique valable !";
					break;
				default :
					msg="Wrong email !";
			}
			setTimeout('Flash(msg)', speed);
			document.form_coord.email.focus();
			return false;
	    }
    }else{
		switch (lang)	{
		case "FR" :
			msg="Veuillez entrer votre email !";
			break;
		default :
			msg="Enter your email !";
		}
		setTimeout('Flash(msg)', speed);
		document.form_coord.email.focus();
		return false;
	}

	cc_secure_cheked = document.form_coord.cc_secure[1].checked + "";
	
	if(cc_secure_cheked == "true"){
	  zone=document.form_coord.num_cb.value;
	  // if ((zone.length>0) && (zone != "")){
			indexe_espace=zone.indexOf(" ");
		
		if ( (zone.length!=16) || (indexe_espace!=-1 ) || isNaN(zone) || zone == "" || zone.length == 0 ) {
			switch (lang)	{
				case "FR" :
					msg="Le numéro de carte de crédit doit comporter 16 chiffres sans espaces.";
					break;
				default :
					msg="Card number is 16 digits without spaces.";
			}
			setTimeout('Flash(msg)', speed);
			document.form_coord.num_cb.focus();
			return false;
		}
		mois_exp = document.form_coord.mois_exp.value;
		an_exp   = document.form_coord.an_exp.value;
		if ( isNaN(mois_exp) || isNaN(an_exp)  ) {
			switch (lang)	{
				case "FR" :
					msg="Le date d'expiration doit être renseignée";
					break;
				default :
					msg="Expiration date must be selected.";
			}
			setTimeout('Flash(msg)', speed);
			document.form_coord.mois_exp.focus();
			return false;
		}		
	  // }
	  
	 	zone=document.form_coord.crypto.value;
	  	 if ((zone.length!=3) || (zone == "")){
	  		switch (lang)	{
	  		case "FR" :
	  			msg="Veuillez entrer votre Cryptogramme visuel";
	  			break;
	  		default :
	  			msg="Enter your Three-digit CVV number";
	  	  	}
	  	  	setTimeout('Flash(msg)', speed);
	  	  	document.form_coord.crypto.focus();
	  	  	return false;
	}
	  
    }
	document.form_coord.cc_accept.checked = false;
	
}

function Flash(mess) {
	if (visible == 0) {
		alert(msg);
		window.status=mess;
		visible=1;
	} else {
		alert(msg); // am 01/09/2003
		window.status="";
		visible=0;
	}
}

function verif_prest(){
return true
// à faire
alert(document.form_prest.rubr_qte.value);
	if (document.form_prest.rubr_qte.value < 0){
		alert("erreur");
		return false;
	}
	var chkZ = 1;
	for(i=0;i<document.form_prest.rubr_qte.value.length;++i)
		if(document.form_prest.rubr_qte.value.charAt(i) < "0"
			|| document.form_prest.rubr_qte.value.charAt(i) > "9")
			chkZ = -1;
		if(chkZ == -1) {
			switch (lang){
				case "FR" :
					alert("Quantité non autorisée !");
					break;
			default :
					alert("Quantity is incorrect !");
			}
			document.form_prest.rubr_qte.focus();
			return false;
		}
}

/*
The Arguments for windows.open

You have a number of options for the third argument. When you define any of them, the remaining Boolean values (which can be true/false or yes/no or 1/0) are all set to false/no/0. Whichever you choose to use, all of your options go into the same quoted string, with commas between the values, and no spaces are allowed between them.

height
    Defines the height of the window in pixels. Percentage values don t work.
width
    Defines the width. Again, you ll have no joy with percentages.
left
    Supported by version 4 browsers and above, this sets how far removed the window appears from the left of the screen. In pixels.
top
    Partner to left, this pushes the window off the top of the screen.
resizable
    Set to true or false, this may allow the user to resize the window.
scrollbars
    Another Boolean value, this adds scrollbars to the new window. If your content may be longer then the dimensions you ve specified, make sure this is set to yes.
toolbar
    Specifies whether the basic back/forward toolbar should be visible. If there are links to follow in your new page, set this to yes.
menubar
    Specifies whether the main toolbar (File, Edit, ...) is shown.
location
    Specifies whether the location toolbar (address bar) is shown.
status
    Specifies whether the new window can have a status bar. Best set to yes.
directories
    Specifies whether the directories toolbar is shown (Links toolbar in IE).
fullscreen
    Internet Explorer-only Boolean attribute which may open the window in fullscreen. It s annoying don t use it.
dependant
    Netscape 4-only attribute which makes the popup dependant on the status of the main window. If the main window is closed, the popup closes with it.
screenX & screenY
    Old Netscape attributes for defining the window s position on the page. Use left and top in their place.

*/

var newwindow;
function openpopup(url, width, height)
{
	newwindow=window.open(url,'name','height='+height+',width='+width+',left=0, top=0,resizable=yes,scrollbars=yes,toolbar=no,status=no')
	if (window.focus) {newwindow.focus()}
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function fill_lot_ref()
{
	lot_ref_text  = document.form_ref.lot_ref_text.value
	lot_ref_text  = lot_ref_text.toUpperCase()

	if (lot_ref_text.substring(1,2) != " " && lot_ref_text.length > 1 ){
		lot_ref_text = lot_ref_text.substring(0,1) + lot_ref_text.substring(1,10)
	}

	document.form_ref.lot_ref_text.value = lot_ref_text
	// alert(lot_ref_text);
	for(var i = 1; i < document.form_ref.lot_ref.length ; i++){
		// alert(i);
		document.form_ref.lot_ref.selectedIndex = i;
		cur_lot_ref = document.form_ref.lot_ref.value;
		// alert(cur_lot_ref.substring(0,1) );
		if ( lot_ref_text ==  cur_lot_ref.substring(0,lot_ref_text.length ) ){
			// alert(cur_lot_ref);
			i = document.form_ref.lot_ref.length
		}
	}
}

function fill_lot_ref_text()
{
	document.form_ref.lot_ref_text.value  = document.form_ref.lot_ref.value;
}


function verif_prest(){
return true
// à faire
alert(document.form_prest.rubr_qte.value);
	if (document.form_prest.rubr_qte.value < 0){
		alert("erreur");
		return false;
	}
	var chkZ = 1;
	for(i=0;i<document.form_prest.rubr_qte.value.length;++i)
		if(document.form_prest.rubr_qte.value.charAt(i) < "0"
			|| document.form_prest.rubr_qte.value.charAt(i) > "9")
			chkZ = -1;
		if(chkZ == -1) {
			switch (lang){
				case "FR" :
					alert("Quantité non autorisée !");
					break;
			default :
					alert("Quantity is incorrect !");
			}
			document.form_prest.rubr_qte.focus();
			return false;
		}
}

var newwindow;
/*---------------------------------*/
function openpopup(url, width, height)
/*---------------------------------*/
{
	newwindow=window.open(url,'name','height='+height+',width='+width+',left=0, top=0,resizable=yes,scrollbars=yes,toolbar=no,status=no')
	if (window.focus) {newwindow.focus()}
}
function recomandeCettePage(param1, param2, param3, lang) {
	if( lang == "FR" ) {
		mail_str = "mailto:?subject=Regardez " + param1;
		mail_str += "&body=Bonjour,";
		//mail_str += "<br /><br />Nous avons pensé que ce document peut vous intéresser : " + param1;
		mail_str += "%0d%0a%0d%0aNous avons pense que ce document peut vous interesser :%0d%0a";
		//mail_str += " <a href=\""+ encodeURIComponent(document.location)+ "\">"+ param2 +"-"+ param3 +"</a> !";
		mail_str += "%0d%0a " + param1 + " " + param2 + " - " + param3 + "%0d%0a%0d%0a";
		mail_str += "Copiez cette adresse dans votre navigateur internet pour voir le document : %0d%0a%0d%0a";
		mail_str += escape(location.href);
		//mail_str += " <a href=\""+ escape(location.href)+ "\">"+ param2 +"-"+ param3 +"</a> !";
		//mail_str += "<br /><br />A bientôt.";
		mail_str += "%0d%0a%0d%0aA bientot.";
		//location.href = mail_str; 
	} else {
		/*
		mail_str = "mailto:?subject=Take a look " + param1;
		mail_str += "&body=Hello,";
		mail_str += "<br /><br />We thought that you may be interested by this proposal : " + param1;
		mail_str += " <b><a href=\""+ encodeURIComponent(document.location)+ "\">"+ param2 +"-"+ param3 +"</a></b> !";
		mail_str += "<br /><br />Goodbye";
		*/
		mail_str = "mailto:?subject=Take a look " + param1;
		mail_str += "&body=Hello,";
		mail_str += "%0d%0a%0d%0aWe thought that you may be interested by this proposal :%0d%0a";
		mail_str += "%0d%0a " + param1 + " " + param2 + " - " + param3 + "%0d%0a%0d%0a";
		mail_str += "Copy this web adress in your internet browser to see the proposal : %0d%0a%0d%0a";
		mail_str += escape(location.href);
		mail_str += "%0d%0a%0d%0aGoodbye.";
	}
	location.href = mail_str;
}
/*---------------------------------------
| Recherche dans les critères textes
| les différents éléments pour afficher
| un picto associé
---------------------------------------*/
function LotCritTxt(as_valeur_liste, as_valeur_recherchee, as_span_style, as_lang) {

	if ( as_valeur_liste.indexOf(as_valeur_recherchee.toUpperCase())>0 && as_valeur_recherchee.length>0 ) {

		as_span_style = as_span_style.length==0 ? "" : " style=\""+as_span_style+"\"";
		as_lang = as_lang.toUpperCase();

		switch ( as_valeur_recherchee.toUpperCase() ) {
			case "SAPINS" :
				nb_sapins	= as_valeur_liste.substring(0, 1);
				lib_s		= nb_sapins > 1 ? "s" : "";
				img_src		= LotClassement(nb_sapins);
				img_alt		= as_lang=="FR" ? nb_sapins +" sapin"+ lib_s +"" : nb_sapins +" fir tree"+ lib_s +"";
				span_text	= as_lang=="FR" ? "Classement "+ nb_sapins +" sapin"+ lib_s +"" : "Classification "+ nb_sapins +" fir tree"+ lib_s +"";
				break;
			case "WIFI" :
				img_src		= "transmit_blue.png";
				img_alt		= as_lang=="FR" ? "Wi-Fi !" : "Wi-Fi!";
				span_text	= as_lang=="FR" ? "Possibilité de connexion Internet par Wi-Fi !" : "Possibility of connection Internet by Wi-Fi!";
				break;
			case "TVP" :
				img_src		= "television.png";
				img_alt		= as_lang=="FR" ? "Télévision" : "Television";
				span_text	= as_lang=="FR" ? "Présence d’une télévision " : "A television is present";
				break;
			case "DVD" :
				img_src		= "dvd.png";
				img_alt		= as_lang=="FR" ? "DVD" : "DVD";
				span_text	= as_lang=="FR" ? "Présence d'un lecteur de DVD" : "A DVD player is present";
				break;
			case "CHE" :
				img_src		= "cheminee.png";
				img_alt		= as_lang=="FR" ? "Cheminée" : "Fire place";
				span_text	= as_lang=="FR" ? "Présence d'une cheminée" : "A fire place is present";
				break;
		}
		var ls_https	= Request.ServerVariables("SERVER_PORT")==80 ? PICTO : PICTOS;

		var ls_mod_img	= "";
		if ( as_valeur_recherchee.toUpperCase() == "SAPINS" ) { /* Pour les sapins, la constuction est différente */
			ls_mod_img	= img_src
		} else {
			ls_mod_img	= "<img src=\"" +ls_https+ "/" +img_src+ "\" alt=\"" +img_alt+ "\" onClick=\"return false;\" />";
		}

		var ls_modele	= "<a href=\"#\" class=\"infobulle\">"+ ls_mod_img +"<span class=\"infobulle\"" +as_span_style+ ">" +span_text+ "</span> </a>";
		return ls_modele;
	} else {
		return '';
	}
}


/* Change image suivant état checkbox */
function switchImg(idChbox,idImg) {
	var chbox	= document.getElementById(idChbox);
	if (chbox.checked==false) {
		document.images[idImg].src = "images/cross.gif";
	} else {
		document.images[idImg].src = "images/tick.gif";
	}
}