
//Variables
var ns4;
var ie4;

if (navigator.appName == 'Netscape') {
  ns4 = true;
  ie4 = false;
} else {
  ie4 = true;
  ns4 = false;
}



// Pour le formulaire registerOnLine01Form
function registerOnLine01FormIsOK($message) {
  var formPrefix;

  if (ie4){
    formPrefix = document.registerOnLine01Form;
  }
  if (ns4){
    formPrefix = document.registerOnLine01Form;
    // Mozilla semble ne plus supporter cette syntaxe
    // formPrefix = document.layer03.document;
  }

  if (document.registerOnLine01Form.serialNumber.value == '')
    {
     alert($message);
    }
  else { formPrefix.submit(); }
}


// Pour le formulaire registerOnLine04Form
function registerOnLine04FormIsOK($message) {
  //var formPrefix = '';
  var formPrefix;
  
  
  if (ie4){      
    formPrefix = document.registerOnLine04Form;
  }
  
  if (ns4){
    formPrefix = document.registerOnLine04Form;
    // Mozilla ne semble plus supporter cette syntaxe
    //formPrefix = document.layer03.document.registerOnLine04Form;  
  }
  
  if (formPrefix.serialNumber.value == ''){
    alert($message);
  }
  else {
    formPrefix.submit();
  }
}



// Pour le formulaire registerOnLine05Form
function registerOnLine05FormIsOK() {
   var formPrefix = '';
    if (ie4){
      formPrefix = document.registerOnLine05Form;
   }
   if (ns4){
      formPrefix = document.registerOnLine05Form;
      // Mozilla ne semble plus supporter cette syntaxe
      //formPrefix = document.layer03.document.registerOnLine05Form;
   }
   formPrefix.submit();
}


// Pour le formulaire myNewLicence
function registerLicenceOnLine01FormIsOK($err) {
  var formPrefix   = document.registerLicenceOnLine01Form;
  
  if (formPrefix.licenceNumber.value == '')
    {
      alert($err);
      return false;
    }
  else 
    {
      formPrefix.submit();
    }
}


//NEW TICKET sur un contrat
function myNewTicketFormIsOK(tab){
 var formPrefix = '';
   if (ie4){
      formPrefix = document.myNewTicketForm;
   }
   if (ns4){
      formPrefix = document.myNewTicketForm;
      // mozilla ne semble plus supporter cette syntaxe
      //formPrefix = document.layer03.document.myProfileForm;
   }
   if (formPrefix.problem.value == ''){
     alert(tab[0]);
   }
   else if (formPrefix.detailedProblem.value == ''){
     alert(tab[1]);
   }
   else if (formPrefix.eyebox.value == ''){
     alert(tab[2]);
   }
   else if (formPrefix.lan1.value == ''){
     alert(tab[3]);
   }
   else {
     formPrefix.submit();
   }
}

//NEW TICKET sur un numero de serie
function myNewTicketFormSNIsOK(tab){
 var formPrefix = '';
   if (ie4){
      formPrefix = document.myNewTicketFormSN;
   }
   if (ns4){
      formPrefix = document.myNewTicketFormSN;
      // mozilla ne semble plus supporter cette syntaxe
      //formPrefix = document.layer03.document.myProfileForm;
   }
   if (formPrefix.problem.value == ''){
     alert(tab[0]);
   }
   else if (formPrefix.detailedProblem.value == ''){
     alert(tab[1]);
   }
   else if (formPrefix.lan1.value == ''){
     alert(tab[2]);
   }
   else {
     formPrefix.submit();
   }

}

// Pour le formulaire myProfileForm 
function myProfileFormIsOK(tab) 
{
  
  var formPrefix = '';
  if (ie4){
    formPrefix = document.myProfileForm;
  }
  if (ns4){
    formPrefix = document.myProfileForm;
     //alert(formPrefix);
     // mozilla ne semble plus supporter cette syntaxe
     //formPrefix = document.layer03.document.myProfileForm;
  }
  if (formPrefix.company.value == ''){
    alert(tab[0]);
  }
  else if (formPrefix.fullname.value == ''){
    alert(tab[1]);
   }
  else if (formPrefix.adresse.value == ''){
    alert(tab[2]);
  }
  else if (formPrefix.ville.value == ''){
    alert(tab[3]);
  }
  else if (formPrefix.postal.value == ''){
    alert(tab[4]);
  }
   else if (formPrefix.pays.value == ''){
     alert(tab[5]);
   }
   else if (formPrefix.email.value == '' || isAnEmail(formPrefix.email.value) == false){
     alert(tab[6]);
   }
   else {
     formPrefix.submit();
   }
}


// Cette fonction permet de savoir si on a une email syntaxiquement correcte
function isAnEmail(myEmail){
   re = /([_a-zA-Z0-9\-\.]+@[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)+)/
   return (re.test(myEmail))
}



function newPassIsOK(lg) {
  var formPrefix = '';
  if (ie4){
    formPrefix = document.newPassForm;
  }
  if (ns4){
    formPrefix = document.newPassForm;
    // mozilla ne semble plus supporter cette syntaxe
    //formPrefix = document.layer03.document.myProfileForm;
  }
  
  
  var l;
  var new_pass = document.newPassForm.nmdp.value;
  // Verifications
  var errmsgs ="";
  
   l=new_pass.length;
   if (l<8)
     {
       //errmsgs += mkErrMsgNoValue("length");
       //popup('templates/rv/aide_passwd.php?lg='+lg);
       var pp='templates/rv/aide_passwd.php?lg='+lg;
       //alert (pp);
       popup(pp);
     }
   if(errmsgs != "")
     {
       alert(" \n"
	       +errmsgs
	     );
     }
   else if (formPrefix.nmdp.value == ''){
     //alert("....");
     //popup('templates/rv/aide_passwd.php?lg=english');
   }
   else {
     formPrefix.submit();
   }
}


function mkErrMsgNoValue(field_name) {
var msg;
if (field_name == "length") msg="Bad syntaxe or Too short password  !!! \n";
return msg;
}


function popup(page)
{
// ouvre une fenetre sans barre d'etat, ni d'ascenceur
  window.open(page,'popup','width=300,height=150,toolbar=no,scrollbars=no');
}

//<A HREF='javascript:PopupCentrer("bantjs3.gif",500,70,"menubar=no,scrollbars=no,statusbar=no")'>Cliquez sur ce lien</A>
function PopupCentrer(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);
}

//Kill popup
function kill(page) {
	window.close(page,'popup','width=300,height=150,toolbar=false,scrollbars=false');
}
