// JavaScript By Lapoz => thanks Bro' !!
// http://www.lapoz.info

function Show(zone) {
   if (zone != '') {
	  var item = null;
	  if (document.getElementById)
		 item = document.getElementById(zone);
	  else if (document.all)
		 item = document.all[zone];
	  else if (document.layers)
		 item = document.layers[zone];
	  if (!item) {}
	  else if (item.style) {
		if (item.style.display == "none")
		   item.style.display = "";
	  }else item.visibility = "show";
 	}
}

function Hide(zone) {
   if (zone != '') {
	  var item = null;
	  if (document.getElementById)
		 item = document.getElementById(zone);
	  else if (document.all)
		 item = document.all[zone];
	  else if (document.layers)
		 item = document.layers[zone];
	  if (!item) {}
	  else if (item.style) {
		item.style.display = "none";
	  }else item.visibility = "show";
 	}
}

function ShowOrHide(zone) {
   if (zone != '') {
	  var item = null;
	  if (document.getElementById)
		 item = document.getElementById(zone);
	  else if (document.all)
		 item = document.all[zone];
	  else if (document.layers)
		 item = document.layers[zone];
	  if (!item) {}
	  else if (item.style) {
		if (item.style.display == "none")
		   item.style.display = "";
		else item.style.display = "none";
	  }else item.visibility = "show";
 	}
}

function verif_remplissage(champs) {
   var i = "0", j;
   for(j=0; j<champs.length; j++) {
      if(!champs[j].value && i == "0") {
	     alert("Vous n'avez pas rempli tous les champs obligatoires !");
		  i = "1";
		  return false;
	  }
   }
   return true;
}

function verif_cases(champs) {
   var failure = false; 
   var j=0; 
   var i=0;
   for(j=0; j<champs.length; j++)
      if(!champs[j].checked)
		  i++;
	if(i==champs.length){
		alert("Vous n'avez pas répondu à toutes les questions...");
		return true;
	}
   return false;
}



function verif_mail(champ) {
   if(!bad)
      var bad = "0";
   var syntaxe_mail = new RegExp("^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\._]*@[\-a-zA-Z0-9\._]+[\.]{1}[a-zA-Z]{2,4}$", "");

   if(!syntaxe_mail.test(champ.value) && bad == "0") {
      bad = "1";
	  alert("Erreur de syntaxe dans l'adresse mail !");
	  return false;
   }
	return true;
}

function verif_tel(champ, descriptif) {
   var pilepoil = "0";
	if(!bad)
      var bad = "0";
   // var syntaxe_tel = new RegExp("^[0-9.()+ ]*$", ""); // Syntaxe Internationale, pas de vérif poussée
	var syntaxe1 = new RegExp("^0[1-8]{1}[.]{1}[0-9]{2}[.]{1}[0-9]{2}[.]{1}[0-9]{2}[.]{1}[0-9]{2}$", "");
   if(!syntaxe1.test(champ.value) && bad=="0") {
		var syntaxe2 = new RegExp("^0[1-8]{1}[0-9]{8}$", "");
		if(!syntaxe2.test(champ.value) && bad=="0") {
			bad = "1";
			alert("Erreur de syntaxe dans le numéro de "+descriptif+" !\nSyntaxe : 0x.xx.xx.xx.xx ou 0xxxxxxxxx");
			return false;
		}
	}
	else pilepoil = "1";
	if(pilepoil=="0") {
		champ.value = champ.value.substring(0, 2)+"."+champ.value.substring(2, 4)+"."+champ.value.substring(4, 6)+"."+
		              champ.value.substring(6, 8)+"."+champ.value.substring(8, 10);
	}
	return true;
}

function verif_cp(champ) {
   if(!bad)
      var bad = "0";
   var syntaxe_cp = new RegExp("^[0-9]{5}$", "");
   if(!syntaxe_cp.test(champ.value) && bad=="0") {
      bad = "1";
	  alert("Erreur de syntaxe dans le code postal !");
	  return false;
   }
	return true;
}

function verif_login_pwd(champ) {
   if(!bad)
      var bad = "0";
   var syntaxe_login_pwd = new RegExp("^[a-zA-Z0-9]{4,}$", "");
   if(!syntaxe_login_pwd.test(champ.value) && bad=="0") {
      bad = "1";
	  alert("Le login comme le mot de passe doivent être composés d'au moins 4 caractères alphanumériques !");
	  return false;
   }
	return true;
}

function verif_jour(champ) {
	if(!bad)
		var bad = false;
	if(isNaN(champ.value) || champ.value > 31 || champ.value < 1) {
		bad = true;
		alert("Erreur dans la date !");
		return false;
	}
	return true;
}

function verif_mois(champ) {
	if(!bad)
		var bad = false;
	if(isNaN(champ.value) || champ.value > 12 || champ.value < 1) {
		bad = true;
		alert("Erreur dans la date !");
		return false;
	}
	return true;
}

function verif_annee(champ) {
	if(!bad)
		var bad = false;
	if(isNaN(champ.value) || champ.value < 2005) {
		bad = true;
		alert("Erreur dans la date !");
		return false;
	}
	return true;
}

function verif_heure(champ) {
	if(!bad)
		var bad = false;
	if(isNaN(champ.value) || champ.value > 23 || champ.value < 0) {
		bad = true;
		alert("Erreur dans l'heure !");
		return false;
	}
	return true;
}

function verif_minute(champ) {
	if(!bad)
		var bad = false;
	if(isNaN(champ.value) || champ.value > 59 || champ.value < 0) {
		bad = true;
		alert("Erreur dans l'heure !");
		return false;
	}
	return true;
}

function verif_float(champ, descriptif) {
   if(!bad)
	   var bad = "0";
   var syntaxe_float = new RegExp("^[0-9.]*$", "");
   if(!syntaxe_float(champ.value) && bad=="0") {
      bad = "1";
	  alert(descriptif+" doit être un nombre !");
	  return false;
   }
	return true;
}

function majuscules(champ) {
	champ.value = champ.value.toUpperCase();
}

function minuscules(champ) {
	champ.value = champ.value.toLowerCase();
}

function majFirst(champ) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	
	tmpStr = champ.value.toLowerCase();
	strLen = tmpStr.length;
	
	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}
			else {
				tmpChar = tmpStr.substring(index, index+1);
				if ((tmpChar == " " || tmpChar == "-") && 
					  (tmpStr.substring(index+1, index+3) != "le" && tmpStr.substring(index+1, index+3) != "la" && 
						tmpStr.substring(index+1, index+3) != "du" && tmpStr.substring(index+1, index+3) != "de" && 
						tmpStr.substring(index+1, index+4) != "des" && tmpStr.substring(index+1, index+4) != "rue" && index < (strLen-1)))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	champ.value = tmpStr;
}

function majFirstOnly(champ) {
	champ.value = champ.value.substring(0, 1).toUpperCase() + champ.value.substring(1).toLowerCase();
}

function verif_temp(f) {
	var bad = "0";
	
	var champs = Array(f.mail);
	if(!verif_remplissage(champs))
		return false;
	
	if(!verif_mail(f.mail))
		return false;
}

window.onload=montre; function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

ejs_banurl = new Array;
ejs_banimageUrl=new Array;

ejs_banimageUrl[0] = "http://www.immo-bois.com/pics/pub468.gif";
ejs_banurl[0] = "http://www.bois.org";

ejs_banimageUrl[1] = "http://www.immo-bois.com/pics/natoora.gif";
ejs_banurl[1] = "http://www.cibleclick.com/cibles/clicks/symp.cfm?site_id=391998445&friend_id=882074031";


affiche = false;

function AffichePub()
   {
   if(!affiche)
      {
      numimage= Math.round(Math.random()*(ejs_banurl.length-1));
      document.write ('<A HREF="#" onClick="window.open(ejs_banurl[numimage],\'_blank\')"><IMG SRC="' + ejs_banimageUrl[numimage] + '" BORDER=0 NAME=ejs_banpub></A>')
      affiche = true;
      }
   else
      {
      if(numimage == (ejs_banurl.length-1))
         numimage = 0;
      else
         numimage++;
      document.ejs_banpub.src=ejs_banimageUrl[numimage];
      }
   setTimeout("AffichePub()",3000);
   }
/*
var a, s, n;
function Crypt(s) {r='';for(i=0;i<s.length;i++){n=s.charCodeAt(i); if (n>=8364) {n = 128;} r += String.fromCharCode( n - 3 ); }return r;}
a ="pdlowr=";
m='&#64;';d=unescape(m);
var nom = "commercial";
var domaine = "immo-bois.com";
var aro = nom + d + domaine;
document.write('<a href='+Crypt(a) + aro + '>');
document.write(aro + '</a>');
*/