function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function popupcentree(page,largeur,hauteur,options)
{
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function EmailValide(email)
{   
   var atIndex     = email.indexOf('@')
   var dotIndex    = email.indexOf('.',atIndex)

         // check 0 < atIndex < dotindex < length
   if( (0 < atIndex) && (atIndex < dotIndex) && (dotIndex < email.length-1) )
   { 
           // first character is a letter and all other are not whitespace
      var firstChar = email.charAt(0)
      
      if( (firstChar>='a' && firstChar<='z') ||  
          (firstChar>='A' && firstChar<='Z') ||
          (firstChar>='0' && firstChar<='9') )
      { 
         for(var i=1;i<email.length;++i){
            if(email.charCodeAt(i) <= 0x20){
               if(email.charAt(i) == ' ')
                  alert("Votre adresse e-mail ne doit pas contenir d'espaces.")
               else 
                  alert("Votre adresse e-mail ne doit pas contenir les caractères \"" + email.charAt(i))
               return false;
            }    
         }
         return true;
          
      }
      alert("Le caractère \"" + firstChar + "\" de votre adresse e-mail est incorrect.")
   }
   alert("L'adresse email que vous avez fourni comporte une erreur.")
   return false;
}

function changeBox(cbox)
{
box = eval(cbox);
box.checked = !box.checked;
}

function Validation_formulaire(){ 
var c=0;
for (var i=0; i<Commande.elements.length; i++) 
{ 
if (Commande.elements[i].name=="quantite[]") c++; 
} 

var elts=Commande.elements['quantite[]']; 
var compteur=0; 

if (c==1)
{
if (Commande.elements['quantite[]'].value!='0')
{
compteur++;
}
}
else
{
for (var i=0; i<c; i++) 
{
if (Commande.elements['quantite[]'][i].value!='0')
{
compteur++;
}
}
}

if (compteur==0)
{ 
alert("Vous devez choisir une quantité."); 
return false; 
} 
}

function ChangeUrlRubrique(formulaire)
{
location.href = formulaire.Rubrique.options[formulaire.Rubrique.selectedIndex].value;
}

function showSelect(isOn,divName) {
   var theSelect = null;
   if(document.getElementById) {
      theSelect=document.getElementById(divName);
      if(theSelect) theSelect.style.visibility = isOn ? "visible" : "hidden";
   } else if (document.all) {
      theSelect=document.all(divName);
      if(theSelect) theSelect.style.visibility = isOn ? "visible" : "hidden";
   } else if (document.layers) {
      theSelect=document[divName];
      if(theSelect) theSelect.visibility = isOn ? "show" : "hide";
   }
}

function removeLayer(_layerName)
{
	if (isNetscape4()){
		calc=document.layers[_layerName];
		if (calc.visibility=='hidden'){
			calc.visibility='visible';
		}
	} else if (isOtherBrowser()){
		calc=document.getElementById(_layerName);
		if (calc.style.display=='block'){
			calc.style.display='none';
		}
	}
}

function isNetscape4() {
	ns4 = (document.layers) ? true : false;
	return ns4;
}

function isOtherBrowser() {
	other = (document.getElementById) ? true : false;
	return other;
}

function showLayer(_layerName)
{
if (isNetscape4()){
	calc=document.layers[_layerName];
	if (calc.visibility=='hidden'){
		calc.visibility='visible';
	}
} else if (isOtherBrowser()){
	calc=document.getElementById(_layerName);
	if (calc.style.display=='none'){
		calc.style.display='block';
	}
}
}

function hideLayer(_layerName)
{
	if (isNetscape4()){
		calc=document.layers[_layerName];
		if (calc.visibility=='visible'){
			calc.visibility='hidden';
		}
	} else if (isOtherBrowser()){
		calc=document.getElementById(_layerName);
		if (calc.style.visibility=='visible'){
			calc.style.visibility='hidden';
		}
	}
}
