// JavaScript Document Portfolio

// POPUP

function PopupImage(chemin){ 
	i1 = new Image;
	i1.src = chemin;
	html = '<HTML><HEAD><TITLE>powered by WEB-Xperience.be</TITLE></HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0 BGCOLOR=#FFFFFF onBlur="window.close()"><CENTER><IMG SRC="'+chemin+'" BORDER=0 NAME=image onLoad="window.resizeTo(document.image.width+11,document.image.height+61);window.moveTo(largeurEcran = (screen.width - document.image.width) / 2 , hauteurEcran = (screen.height - document.image.height) / 2)" onClick="window.close()" style="cursor:hand" alt="FERMER LA FENETRE"></CENTER></BODY></HTML>';
	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close();
	}
	
function AfficheMaxi(chemin)
	{
	var largeurEcran = (screen.width - largeur) / 2;
	var hauteurEcran = (screen.height - hauteur) / 2;
	i1 = new Image;
	i1.src = chemin;
	html = '<HTML><HEAD><TITLE>powered by WEB-Xperience.be | &copy; WEB-Xperience.be 2004-2008 |</TITLE></HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER><IMG SRC="'+chemin+'" BORDER=0 NAME=imageTest onLoad="window.resizeTo(document.imageTest.width+14,document.imageTest.height+32)"></CENTER></BODY></HTML>';
	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,height=' + hauteur + ', width=' + largeur + ', top=' + hauteurEcran + ', left=' + largeurEcran + ', scrollbars=' + scroll + '');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close()
	};





/* AFFICHAGE/MASQUAGE CALQUES */
function AffLayer(id) {
	if (document.all) {
		document.all[id].style.display="block";
	}
	if (document.layers) {
	  	document.layers[id].display="block";
	}
	if (document.getElementById) {
		document.getElementById(id).style.display="block";
	}
}

function CacheLayer(id) {
	if (document.all) {
		document.all[id].style.display="none";
	}
	if (document.layers) {
	  	document.layers[id].display="none";
	}
	if (document.getElementById) {
		document.getElementById(id).style.display="none";
	}
}


//COMBINE LES DEUX FONCTIONS EN UN SEUL BOUTON

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

function Affiche_Cache(nObjet) {
 if(ie4) { // Internet explorer
   eval(nObjet).style.visibility = (eval(nObjet).style.visibility=='visible'?'hidden':'visible');
   eval(nObjet).style.position = (eval(nObjet).style.position=='static'?'absolute':'static');

 }
 else if(ns4) { // Netscape 4.x
   document.eval(nObjet).visibility = (document.eval(nObjet).visibility=='show'?'hidden':'show');
   document.eval(nObjet).position = (document.eval(nObjet).position=='static'?'absolute':'static');
	}
 else if(ns6) { // Netscape 6 (mozilla)
   var divns6 = document.getElementsByTagName("div")
   divns6[nObjet].style.visibility = (divns6[nObjet].style.visibility=='visible'?'hidden':'visible');
   divns6[nObjet].style.position = (divns6[nObjet].style.position=='static'?'absolute':'static');
 }
}





/* VERIFICATION FORMULAIRE */

function webxPass(nPass1,nPass2) {
  // onChange="webxPass(this.form.pass1,this);"
  if (nPass1.value != nPass2.value) {
    nPass1.value = "";
    nPass2.value = "";
    nPass1.focus();
      alert ("\nLe mot de passe de confirmation est différent du mot de passe.\n Veuillez recommencer la saisie de votre mot de passe.")
  } else return true;
}

function webxChar(nChamp,nAccepte,nbr) {
  //  onBlur="webxChar(this,'()-0123456789')"
  var ok = "oui";
  var min = "oui";
  var nChar;
  for (var i=0; i<nChamp.value.length; i++) {
    nChar = "" + nChamp.value.substring(i, i+1);
    if (nAccepte.indexOf(nChar) == "-1") ok = "non";
  }
  if (ok == "non") {
      alert ("\nUne erreur est survenue\nSeul les caractères suivant sont autorisés :\n "+nAccepte)
    nChamp.focus();
    nChamp.select();
  }
  if (nChamp.value.length < nbr&&nChamp.value.length > 0) min = "non";
  if (min == "non") {
      alert("\nUne erreur est survenue\nAssurez-vous d'avoir entré au moins " + nbr + " caractères.");
    nChamp.focus();
    nChamp.select();
  }
}

function webxEmail(nChamp) {
  //  onBlur="webxEmail(this)"
  if (nChamp.value.length > 0) {
    if ((nChamp.value.lastIndexOf(".") < nChamp.value.indexOf("@")+3 
      || nChamp.value.lastIndexOf(".") > nChamp.value.length-3 
      || nChamp.value.indexOf("@") < 1 ) 
      || nChamp.value.indexOf("@") != nChamp.value.lastIndexOf("@")) {
        alert("\nEmail incorrecte!\nAssurez-vous que votre adresse email est correctement entrée \"votrenom@domaine.xxx\".");
      nChamp.focus();
      nChamp.select();
    }
  }
}

function webxDate(nDate,nA1,nA2,nFormat) {
  //  onBlur="webxDate(this,1950,2020,'jj/mm/aaaa')"
  var ok = "oui";
  var nChar;
  var aDate;
  var nJ;
  var nM;
  var nA;
  var jMax = 31;
  nAccepte = "0123456789/";
  if (nDate.value.length > 0) {
    if (nDate.value.length < 8 || nDate.value.length > 10) ok = "non";
    for (var i=0; i<nDate.value.length; i++) {
      nChar = "" + nDate.value.substring(i, i+1);
      if (nAccepte.indexOf(nChar) == "-1") ok = "non";
    }
    if (ok == "oui") {
      aDate = nDate.value.split("/");
      if (nFormat == "jj/mm/aaaa") { nJ = aDate[0]; nM = aDate[1]; nA = aDate[2];
      } else if (nFormat == "mm/jj/aaaa") { nJ = aDate[1]; nM = aDate[0]; nA = aDate[2];
        } else if (nFormat == "aaaa/mm/jj") { nJ = aDate[2]; nM = aDate[1]; nA = aDate[0]; }
      if ((nJ < 1 || nJ > jMax) || (nM < 1 || nM > 12) || (nA < nA1 || nA > nA2)) ok = "non";
      else {
        if (nM == 2) { 
          if (AnneeBissex(nA) == true) { jMax = 29 } else { jMax = 28 }
        }
        if ((nM == 1 || nM == 3 || nM == 5 || nM == 7 || nM == 8 || nM == 10 || nM == 12)) jMax = 31
        if ((nM == 4 || nM == 6 || nM == 9 || nM == 11)) jMax = 30
        if (nJ < 1 || nJ > jMax) ok = "non";
      }
    }
    if (ok == "non") {
      nDate.focus();
      nDate.select();
        alert ("\nDate invalide!. Veuillez entrer une date valide : "+nFormat+"\nentre "+nA1+" et "+nA2)
    }
  }
}

function webxTexte(nTexte, nCompteur, nLimite) {
  // onKeyDown="webxTexte(this,this.form.compte,2000);"
  // onKeyUp="webxTexte(this,this.form.compte,2000);"
  // <input readonly="readonly" type="text" name="compte" value="2000">
  if (nTexte.value.length > nLimite)
    nTexte.value = nTexte.value.substring(0, nLimite);
  else 
    nCompteur.value = nLimite - nTexte.value.length;
}



