if(lang=='french'){
var ag = String.fromCharCode(232);
var aa = String.fromCharCode(233);

var EMAIL_FORMAT_1 ="Format d'email incorrect. \n\nLe format est'you@dom.suf'"; 
var EMAIL_FORMAT_2 ="Vous avez tapé un '.' avant le '@'\nConfirmez-vous ? "; 
var EMAIL_FORMAT_3 ="Nom de domaine manquant. \n\nLe format est 'you@site.com'"
var EMAIL_FORMAT_4 ="Moins de 2 caract"+ag+"res pour le domaine.\nConfirmez-vous ? "
var TERMS_APPROVE = "Il faut approuver les termes du contrat pour avancer.";
var MUST_SUPPLY = "Veuillez saisir "; 
var MUST_SUPPLY_URNAME = "votre pr"+aa+"nom"; 
var MUST_SUPPLY_URTITLE = "votre titre";
var MUST_SUPPLY_URJOB = "votre fonction";
var MUST_SUPPLY_URSECTEUR = "votre secteur d'activit"+aa;
var MUST_SUPPLY_URSURNAME = "votre nom"; 
var MUST_SUPPLY_URCOMPANY = "le nom de votre soci"+aa+"t"+aa; 
var MUST_SUPPLY_URCITY = "la ville de votre soci"+aa+"t"+aa; 
var MUST_SUPPLY_URCOUNTRY = "le pays de votre soci"+aa+"t"+aa; 
var MUST_SUPPLY_URCTEL = "le n° de t"+aa+"l"+aa+"phone du contact de votre soci"+aa+"t"+aa; 
var MUST_SUPPLY_URCFAX = "le fax de votre soci"+aa+"t"+aa; 
var MUST_SUPPLY_UREMAIL = "votre email"; 
var MUST_SUPPLY_URTEL = "votre t"+aa+"l"+aa+"phone"; 
var MUST_SUPPLY_EMAIL = "l'email"; 
var MUST_SUPPLY_SURNAME = "le nom"; 
var MUST_SUPPLY_NAME = "le pr"+aa+"nom"; 
var MUST_SUPPLY_USERNAME = "le nom d'utilisateur"; 
var MUST_SUPPLY_COMPANY = "la soci"+aa+"t"+aa; 
var MUST_SUPPLY_PROFIL = "le profil"; 
var MUST_SUPPLY_PASS = "le mot de passe";
var MUST_SUPPLY_VERPASS = "Il faut saisir le mot de passe de v"+aa+"rification";
var MUST_SUPPLY_URSITE = "le nom de votre site"; 
var MUST_SUPPLY_SNOS = "les num"+aa+"ros de s"+aa+"rie"; 
var SN_ERROR = "Erreur de num"+aa+"ro de s"+aa+"rie";
var MUST_SUPPLY_BC_EMAIL = "Please select the business contact to which the NFR license key will be sent";

var MUST_SUPPLY_BASE_ERROR  = "A Base product is necessary";



var MUST_SUPPLY_MODULE  = "Please select a Module";
var MUST_SUPPLY_AGENTS  = "the number of agents";


}else{
var EMAIL_FORMAT_1 ="Your email address lacks '.' or '@'. \n\nThe format is 'you@dom.suf'";
var EMAIL_FORMAT_2 ="You entered a 'dot' before the '@'\nAre you sure that is  right?";
var EMAIL_FORMAT_3 ="You may be missing your domain name. \n\nThe format is 'you@site.com'"
var EMAIL_FORMAT_4 ="You have fewer than 2 characters as a domain suffix.\nAre you sure that is right?"
var TERMS_APPROVE = "You must approve the terms and conditions to proceed.";
var MUST_SUPPLY = "You must supply the following details : ";
var MUST_SUPPLY_URNAME = "your first name";
var MUST_SUPPLY_URTITLE = "your title";
var MUST_SUPPLY_URSURNAME = "your name";
var MUST_SUPPLY_URJOB = "your function";
var MUST_SUPPLY_URSECTEUR = "your company's activity sector";
var MUST_SUPPLY_URCOMPANY = "the name of your company";
var MUST_SUPPLY_URCITY = "your company's city";
var MUST_SUPPLY_URCOUNTRY = "your company's country";
var MUST_SUPPLY_URCTEL = "the telephone number of the company";
var MUST_SUPPLY_URCFAX = "the fax number of your company";
var MUST_SUPPLY_UREMAIL = "your email";
var MUST_SUPPLY_URTEL = "your telephone number";

var MUST_SUPPLY_EMAIL = " Email address";
var MUST_SUPPLY_SURNAME = " Surname";
var MUST_SUPPLY_NAME = " First name";
var MUST_SUPPLY_USERNAME = " Username";
var MUST_SUPPLY_COMPANY = "Company";
var MUST_SUPPLY_PROFIL = "Profile";
var MUST_SUPPLY_PASS = "Password";
var MUST_SUPPLY_VERPASS = "Please verify that your password is correct ";

var MUST_SUPPLY_URSITE = "the name of your Site";
var MUST_SUPPLY_SNOS = " the serial numbers";

var SN_ERROR = "Please enter the correct S:N";
var MUST_SUPPLY_BC_EMAIL = "Please select the business contact to which the NFR license key will be sent";


var MUST_SUPPLY_CLIENT_NAME = "Client Name";
var MUST_SUPPLY_SITE_NAME = "Site Name";
var MUST_SUPPLY_CITY_NAME = "City";
var MUST_SUPPLY_COUNTRY_NAME = "Country";
var MUST_SUPPLY_EMAIL_NAME = "Email";
var MUST_SUPPLY_TEL_NAME = "Telephone";
var MUST_SUPPLY_PART_NAME = "Partner";
var MUST_SUPPLY_DIST_NAME = "Distributor";
var MUST_SUPPLY_NAME_NAME  = "First name";
var MUST_SUPPLY_LASTNAME_NAME  = "Last name";
var MUST_SUPPLY_PART_CON_NAME  = "Partner Contact";
var MUST_SUPPLY_DIST_CON_NAME  = "Distributor Contact";
var MUST_SUPPLY_BASE_ERROR  = "A Base product is necessary";
var MUST_SUPPLY_PRODUCT  = "You must have at least one product in the order.";
var MUST_SUPPLY_SKYCONTACT_NAME  = "Skyrecon Contact";
var MUST_SUPPLY_MODULE  = "Please select a Module";
var MUST_SUPPLY_AGENTS  = "the number of agents";



}


var chkDot = true;
var usEmail = true;

   function validEmail(eAddr)
   {
      trim(eAddr);
      var result = false;
      var ndxDot =  0;
      var ndxDot2 =  0;
      var ndxAt = 0;
      var tmpStr = 20;

      ndxAt  = eAddr.indexOf("@");
      ndxDot = eAddr.indexOf(".") ;
      ndxDot2 = eAddr.lastIndexOf(".") ;

        if ((ndxDot < 0) || (ndxAt <= 0)){
                alert(EMAIL_FORMAT_1);
        }
        else if ( (ndxDot2 - 2) <= ndxAt){
                alert(EMAIL_FORMAT_3);
        }
        else{
           result=true;
    }

      return result;
   }

var color='#FFB2B4';

function isNotEmpty(field, fieldName,msg)  { 

	field.value = trim(field.value);
	
        if (field.value.length == 0)  {
            alert(msg + fieldName + ".");
            field.focus();
            field.style.backgroundColor = '#FFB2B4';
            return false;
        }
        field.style.backgroundColor = '';
        return true;
}

function trim(str, chars) {
        return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

    
    

function checkAgreeTerms(form){
if(form.agree.checked==true){
    return true;
}else{
    alert(TERMS_APPROVE);
    return false;
}

}


function checkOrgLic(form){

if(form.email.value==0){
    alert(MUST_SUPPLY_BC_EMAIL);
    return false;
}

    return true;

}


function checkwp(form)  {
	try	{
		form.piege.value = 'piege';
	}
	catch(e)	{
	}

        if (!isNotEmpty(form.name, MUST_SUPPLY_URSURNAME,MUST_SUPPLY))  {
                return false;
        }
        else if (!isNotEmpty(form.fname, MUST_SUPPLY_URNAME,MUST_SUPPLY))       {
                return false;
        }
        else if (!isNotEmpty(form.company, MUST_SUPPLY_URCOMPANY,MUST_SUPPLY))  {
                return false;
        }
        else if (!isNotEmpty(form.country, MUST_SUPPLY_URCOUNTRY,MUST_SUPPLY))  {
                return false;
        }
        else if (!isNotEmpty(form.tel, MUST_SUPPLY_URTEL,MUST_SUPPLY))  {
                return false;
        }
        else if (!validEmail(form.email.value)) {
                return false;
        }
        else    {
                return true;
        }
}


function checksignup(form){


if(form.signup[0].checked){

    if (!isNotEmpty(form.title, MUST_SUPPLY_URTITLE,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.name, MUST_SUPPLY_URSURNAME,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.fname, MUST_SUPPLY_URNAME,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.company, MUST_SUPPLY_URCOMPANY,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.job, MUST_SUPPLY_URJOB,MUST_SUPPLY))
    return false;


    if (!isNotEmpty(form.secteur, MUST_SUPPLY_URSECTEUR,MUST_SUPPLY))
    return false;


    if (!isNotEmpty(form.tel, MUST_SUPPLY_URTEL,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.email, MUST_SUPPLY_UREMAIL,MUST_SUPPLY))
    return false;
    
        return true;
        
    }else{
    
    
    if (!isNotEmpty(form.email, MUST_SUPPLY_UREMAIL,MUST_SUPPLY))
    return false;
    
    
        return true;
    }
    
    
    
}

function checkDemande(form){
	try	{
		form.piege.value = 'piege';
	}
	catch(e)	{
	}

    if (!isNotEmpty(form.FIRSTNAME, MUST_SUPPLY_URNAME,MUST_SUPPLY))
    return false;
    
    if (!isNotEmpty(form.LASTNAME, MUST_SUPPLY_URSURNAME,MUST_SUPPLY))
    return false;
        
    if (!isNotEmpty(form.COMPANY, MUST_SUPPLY_URCOMPANY,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.TEL, MUST_SUPPLY_URTEL,MUST_SUPPLY))
    return false;

    if (form.COUNTRY.value==0){
    alert(MUST_SUPPLY_URCOUNTRY);
    return false;
    }
    
    if (!isNotEmpty(form.EMAIL, MUST_SUPPLY_UREMAIL,MUST_SUPPLY))
    return false;
	


	if (form.action.value==1){
		if(form.MODULEA.checked==0 &&  form.MODULEB.checked==0 &&  form.MODULEC.checked==0 &&  form.MODULED.checked==0){
		alert(MUST_SUPPLY_MODULE);return false;
}
	}

  if (!isNotEmpty(form.AGENTS, MUST_SUPPLY_AGENTS,MUST_SUPPLY))
    return false;



}




function checkaddEnv(form){
    
    if (!isNotEmpty(form.SITE_NAME, MUST_SUPPLY_URSITE,MUST_SUPPLY)){
    return false;
    }else{
        if(form.selos.length<1){
            alert(MUST_SUPPLY+MUST_SUPPLY_SNOS)
            return false;       
        }else{
            set_hidden(form.selos);
            form.send.value="Please Wait...";
            return true;
        }
    }
    
}



function checkSoc(form){
var msg = "Vous devez obligatoirement fournir: ";

    if (!isNotEmpty(form.COMPANY, MUST_SUPPLY_URCOMPANY,MUST_SUPPLY))
    return false;


   // if (!isNotEmpty(form.CITY, MUST_SUPPLY_URCITY,MUST_SUPPLY))
    //return false;


    if (!isNotEmpty(form.COUNTRY, MUST_SUPPLY_URCOUNTRY,MUST_SUPPLY))
    return false;


    if (!isNotEmpty(form.TEL, MUST_SUPPLY_URCTEL,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.FAX, MUST_SUPPLY_URCFAX,MUST_SUPPLY))
    return false;


return true;
}




function checkRegister(form){
var msg = "Vous devez obligatoirement fournir: ";
    
    if (!isNotEmpty(form.lastname, MUST_SUPPLY_SURNAME,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.firstname, MUST_SUPPLY_NAME,MUST_SUPPLY))
    return false;
    /*
    if (!isNotEmpty(form.login, MUST_SUPPLY_USERNAME,MUST_SUPPLY))
    return false;   
*/
    if (!isNotEmpty(form.mail, MUST_SUPPLY_EMAIL,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.tel, MUST_SUPPLY_TEL_NAME,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.org, MUST_SUPPLY_COMPANY,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.profil, MUST_SUPPLY_PROFIL,MUST_SUPPLY))
    return false;
    
    if (!isNotEmpty(form.password1, MUST_SUPPLY_PASS,MUST_SUPPLY))
    return false;

    if (form.password1.value!=form.password2.value){
            alert(MUST_SUPPLY_VERPASS);
            form.password2.focus();
            form.password2.style.backgroundColor = color;
            return false;
    }




return true;
}



function checkAccountVerify(form){

    if (!isNotEmpty(form.COMPANY, MUST_SUPPLY_COMPANY,MUST_SUPPLY))
    return false;
    
   
    if (!isNotEmpty(form.lastname, MUST_SUPPLY_SURNAME,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.firstname, MUST_SUPPLY_NAME,MUST_SUPPLY))
    return false;
  

    if (!isNotEmpty(form.passwd, MUST_SUPPLY_PASS,MUST_SUPPLY))
    return false;

    if (form.passwd.value!=form.password2.value){
            alert(MUST_SUPPLY_VERPASS);
            form.password2.focus();
            form.password2.style.backgroundColor = color;
            return false;
    }

return true;
}



function checkUser(form){
    
    if (!isNotEmpty(form.lastname, MUST_SUPPLY_SURNAME,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.name, MUST_SUPPLY_URNAME,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.mail, MUST_SUPPLY_EMAIL,MUST_SUPPLY))
    return false;

    if (!isNotEmpty(form.tel, MUST_SUPPLY_URTEL,MUST_SUPPLY))
    return false;



return true;
}






// client.js
function blockKeys(e){

    var key;
    var keychar;
    var reg;

    if(window.event) {
        // for IE, e.keyCode or window.event.keyCode can be used
        key = e.keyCode;
    }
    else if(e.which) {
        // netscape
        key = e.which;
    }
    else {
        // no event, so pass through
        return true;
    }

    if (key <= 32)
      return true;

    keychar = String.fromCharCode(key);
    reg = /[^a-f0-9]+/i;
    return !reg.test(keychar);
}

//distrib.js
function checkDist(){
    var msg = "Vous devez obligatoirement fournir: \n";
    var msg2 = "";
    var count = 0;
    var count2 = 0;
    var myform = document.forms['snRecord'];
    /*var product = myform.elements['product'].value;
    var distrib = myform.elements['distrib'].value;
    var number = myform.elements['number'].value;
    var snId = myform.elements['snId'].value;*/
    var mail = myform.elements['mail'].value;
    var company = myform.elements['company'].value;
    var city = myform.elements['city'].value;
    var country = myform.elements['pays'].value;
    var lastname = myform.elements['lastname'].value;
    var firstname = myform.elements['firstname'].value;
    var tel = myform.elements['tel'].value;
    //var pc = myform.elements['pc'].value;
    var support = myform.elements['support'].value;
    
    if (company == ""){
            count++;
            msg += "\tle nom de l'entreprise\n";
    }
    if(city == ""){
            count++;
            msg += "\tla ville\n";
    }
    if(country == ""){
            count++;
            msg += "\tle pays\n";
    }
    if (lastname == ""){
        count++;
        msg += "\tle nom du contact\n";
    }
    if (firstname == ""){
        count++;
        msg += "\tle prénom du contact\n";
    }
    if (tel == ""){
                count++;
                msg += "\tle n° de téléphone du contact\n";
     }
    if (mail == ""){
                count++;
                msg += "\tl'adresse e-mail du contact\n";
     }
    
    if (support == ""){
                count++;
                msg += "\tl'option pour le support et la maintenance\n";
    }
    /*if (product == ""){
                count++;
                msg += "\tle premier champ du S/N\n";
     }
    if (distrib == ""){
                count++;
                msg += "\tle second champ du S/N\n";
     }
    if (number == ""){
                count++;
                msg += "\tle troisième champ du S/N\n";
     }
    if (snId == ""){
                count++;
                msg += "\tle dernier champ du S/N\n";
    }*/
    
    /*if (pc != ""){
        if (/^[0-9]{4,5}$/.test(pc) == false){
            count2++;
            msg2 += "\nLe code postal ne doit comporter que des chiffres (4 ou 5) \n";
        }
    }*/
    
    if (mail != ""){
        /*if (/^[a-z][a-z0-9_-]+\.[a-z0-9_-]+@[a-z0-9_-]+\.([a-z]{2,3})$/i.test(mail) == false){
            count2++;
            msg2 += "\nLe format de l'adresse mail n'est pas correct \n";
        }*/
        var place = mail.indexOf("@",1);
        var point = mail.indexOf(".",place+2);
        if (!((place > -1) && (mail.length > 7) && (point > 1))){
            count2++;
            msg2 += "\nLe format de l'adresse mail n'est pas correct \n";
        }
    }
    
    /*if (product != ""){
        if (product.length < 5){
            count2++;
            msg2 += "\nLe premier champ doit comporter 5 lettres \n";
        }
    }
    if (distrib != ""){
        if (distrib.length < 5){
            count2++;
            msg2 += "Le second champ doit comporter 5 lettres \n";
        }
    }

    if (number != ""){
        if (number.length < 5){
            count2++;
            msg2 += "Le troisième champ doit comporter 5 lettres \n";
        }
    }
     
    if (snId != ""){
        if (snId.length < 5){
            count2++;
            msg2 += "Le quatrième champ doit comporter 5 lettres \n";
        }
    }
    */ 
    if (count > 0 && count2 > 0){
        var message = msg+msg2;
        alert(message);
        return false;
    }
    if (count > 0 && count2 == 0){
        alert(msg);
        return false;
    }
    if (count == 0 && count2 > 0){
        alert(msg2);
        return false;
    }
        return true;
}

// eval.js

function checkEval(){
     var msg = "Vous devez obligatoirement fournir: \n";
    var msg2 = "";
     var count = 0;
    var count2 = 0;
     var myform = document.forms['EvalRecord'];
    var company = myform.elements['company'].value;
    var country = myform.elements['country'].value;
    var tel = myform.elements['tel'].value;
    var firstname = myform.elements['firstname'].value;
    var lastname = myform.elements['lastname'].value;
    var email = myform.elements['email'].value;
    var pc = myform.elements['pc'].value;
    //var code = myform.elements['code'].value;
    
    if (company == ""){
                count++;
                msg += "\tle nom de l'entreprise\n";
     }
    if (country == ""){
                count++;
                msg += "\tle pays de la société\n";
     }
    if (firstname == ""){
                count++;
                msg += "\tle nom  du contact\n";
     }
    if (lastname == ""){
                count++;
                msg += "\tle prénom du contact\n";
     }
       
    if (email == ""){
                count++;
                msg += "\tl'adresse email du contact\n";
     }
    if (tel == ""){
                count++;
                msg += "\tle numéro de téléphone du contact\n";
     }
    /*if (code == ""){
                count++;
                msg += "\tle code revendeur\n";
     }*/
    /*if (tel != ""){
        if (/^[+0-9]/.test(tel) == false){
            count2++;
            msg2 += "\nLe format du n° de téléphone est incorrect \n";
        }
    }*/
    
    if (pc != ""){
        if (/^[0-9]{4,5}$/.test(pc) == false){
            count2++;
            msg2 += "\nLe code postal ne doit comporter que des chiffres (4 ou 5) \n";
        }
    }
    
    
    
     
    if (count > 0 && count2 > 0){
          var message = msg+msg2;
        alert(message);
                return false;
        }
    if (count > 0 && count2 == 0){
        alert(msg);
        return false;
    }
    if (count ==0 && count2 > 0){
        alert(msg2);
        return false;
    }
        return true;
}



function shiftFocus(string, len, obj)
{
    if(string.length == len)
    {
        obj.select();
    }
}


// insert_sn




function insertOldSchool(theSel, newText, newValue, newItems)
{
    if (newItems != ""){newValue = newValue + newItems;}

if(document.forms["snRecord"].serialval.value.length!=27 || document.forms["snRecord"].items.value<1){
alert(SN_ERROR);
return false;
}
    
    
    if (theSel.length == 0) {
        var newOpt1 = new Option(newText, newValue);
        theSel.options[0] = newOpt1;
        theSel.selectedIndex = 0;
    }
    else if (theSel.selectedIndex != -1) {
        var selText = new Array();
        var selValues = new Array();
        var selIsSel = new Array();
        var newCount = -1;
        var newSelected = -1;
        var i;
        var j;      
        /*
        var exists =0;
        
        alert(exists);
        for(j=0; j<=theSel.length; j++){
        
        alert(theSel.options[j].text);
        alert(newText);
        //alert(newText+' '+theSel.options[j].text);
            if(theSel.options[j].text===newText){
                exists =1;
                alert('in');
            }
    
        }
/*              alert(exists);
if(exists==1){
                alert('already');

}
*/  

        
    for(i=0; i<theSel.length; i++){
        newCount++;
            if (newCount == theSel.selectedIndex) {
                selText[newCount] = newText;
                selValues[newCount] = newValue;
                selIsSel[newCount] = false;
                newCount++;
                newSelected = newCount;
            }
            if(theSel.options[i].text==document.forms["snRecord"].serialval.value){
            alert('Vous ne pouvais pas ajouter deux produits avecs les memes numéros');
            
            document.forms["snRecord"].serialval.value='';
            document.forms["snRecord"].product.value='';
            document.forms["snRecord"].distrib.value='';
            document.forms["snRecord"].number.value='';
            document.forms["snRecord"].snId.value='';
            document.forms["snRecord"].items.value='';
            return false;
            }
            selText[newCount] = theSel.options[i].text;
            selValues[newCount] = theSel.options[i].value;
            selIsSel[newCount] = theSel.options[i].selected;
        }
        for(i=0; i<=newCount; i++){
            var newOpt = new Option(selText[i], selValues[i]);
            theSel.options[i] = newOpt;
            theSel.options[i].selected = selIsSel[i];
        }
    }// end else if

document.forms["snRecord"].serialval.value='';
document.forms["snRecord"].product.value='';
document.forms["snRecord"].distrib.value='';
document.forms["snRecord"].number.value='';
document.forms["snRecord"].snId.value='';
document.forms["snRecord"].items.value='';



}

function insertElt(theSel, newText, newValue)
{

    if (theSel.length == 0) {
        var newOpt1 = new Option(newText, newValue);
        theSel.options[0] = newOpt1;
        theSel.selectedIndex = 0;
    }
    else if (theSel.selectedIndex != -1) {
        var selText = new Array();
        var selValues = new Array();
        var selIsSel = new Array();
        var newCount = -1;
        var newSelected = -1;
        var i;
    for(i=0; i<theSel.length; i++){
        newCount++;
        if (newCount == theSel.selectedIndex) {
            selText[newCount] = newText;
            selValues[newCount] = newValue;
            selIsSel[newCount] = false;
            newCount++;
            newSelected = newCount;
        }
        if(theSel.options[i].text==document.forms["snRecord"].serialval.value){
        alert('Vous ne pouvais pas ajouter deux produits avecs les memes numéros');
        return false;
        }   
        selText[newCount] = theSel.options[i].text;
        selValues[newCount] = theSel.options[i].value;
        selIsSel[newCount] = theSel.options[i].selected;
        }
        for(i=0; i<=newCount; i++){
            var newOpt = new Option(selText[i], selValues[i]);
            theSel.options[i] = newOpt;
            theSel.options[i].selected = selIsSel[i];
        }
    }// end else if
    
document.forms["snRecord"].serialval.value='';
document.forms["snRecord"].product.value='';
document.forms["snRecord"].distrib.value='';
document.forms["snRecord"].number.value='';
document.forms["snRecord"].snId.value='';


}


function removeOldSchool(theSel){
  var selIndex = theSel.selectedIndex;
  if (selIndex != -1) {
    for(i=theSel.length-1; i>=0; i--)
    {
      if(theSel.options[i].selected)
      {
        theSel.options[i] = null;
      }
    }
    if (theSel.length > 0) {
      theSel.selectedIndex = selIndex == 0 ? 0 : selIndex - 1;
    }
  }
}



function set_hidden(theSel){
    for(i=0; i<=theSel.length; i++){   
            if (document.forms["snRecord"].serial.value == "")
                 document.forms["snRecord"].serial.value = 
         theSel.options[i].value;
            else
             document.forms["snRecord"].serial.value = 
        document.forms["snRecord"].serial.value + 
        "[end]" + theSel.options[i].value;
            
            
     }
}

function add(form){
    var f = document.getElementById(form);
    f.elements["serialval"].value =
        f.elements["product"].value+'-'+
        f.elements["distrib"].value+'-'+
        f.elements["number"].value+'-'+
        f.elements["snId"].value;
    return true;
}


//newcustomer.js
function checkOrgInfo(){
    var msg = "Vous devez obligatoirement fournir: \n";
    var msg2 = "";
    var count = 0;
    var count2 = 0;
    var myform = document.forms['orgRecord'];
    var company = myform.elements['company'].value;
    var site= myform.elements['site'].value;
    var address = myform.elements['address'].value;
    var pc = myform.elements['pc'].value;
    var city = myform.elements['city'].value;
    var state = myform.elements['state'].value;
    var country = myform.elements['country'].value;
    var tel = myform.elements['tel'].value;
    var contact = myform.elements['contact'].value;
    
    if (company == ""){
                count++;
                msg += "\tle nom de l'entreprise\n";
        }
    if (site == ""){
                count++;
                msg += "\tle site de la société\n";
        }
    if (city == ""){
                count++;
                msg += "\tla ville\n";
        }
    if (country == ""){
                count++;
                msg += "\tle pays\n";
        }   
    
    if (tel == ""){
                count++;
                msg += "\tun n° de téléphone\n";
        }
    if (contact == ""){
                count++;
                msg += "\tl'adresse email de contact\n";
     }
    /*if (tel != ""){
        if (/^[+0-9]/.test(tel) == false){
            count2++;
            msg2 += "\nLe format du n° de téléphone est incorrect \n";
        }
    }*/
    
    if (pc != ""){
        if (/^[0-9]{4,5}$/.test(pc) == false){
            count2++;
            msg2 += "\nLe code postal ne doit comporter que des chiffres (4 ou 5) \n";
        }
    }
    
    
    if (contact != ""){
        var place = contact.indexOf("@",1);
        var point = contact.indexOf(".",place+2);
        if (!((place > -1) && (contact.length > 7) && (point > 1))){
            count2++;
            msg2 += "\nLe format de l'adresse mail n'est pas correct \n";
        }
    }
    
     
    if (count > 0 && count2 > 0){
          var message = msg+msg2;
        alert(message);
                return false;
        }
    if (count > 0 && count2 == 0){
        alert(msg);
        return false;
    }
    if (count ==0 && count2 > 0){
        alert(msg2);
        return false;
    }
        return true;
}

// organization.js

function checkOrg(){
     var msg = "Vous devez obligatoirement fournir: \n";
    var msg2 = "";
     var count = 0;
    var count2 = 0;
     var myform = document.forms['OrgRecord'];
    var profil = myform.elements['profil'].value;
    var company = myform.elements['company'].value;
    var address = myform.elements['address'].value;
    var pc = myform.elements['pc'].value;
    var city = myform.elements['city'].value;
    var country = myform.elements['country'].value;
    var tel = myform.elements['tel'].value;
    var contact = myform.elements['contact'].value;
    
    if (company == ""){
                count++;
                msg += "\tle nom de l'entreprise\n";
        }
    if (profil == ""){
                count++;
                msg += "\tle profil de l'entreprise\n";
        }
    if (address == ""){
                count++;
                msg += "\tl'adresse de l'entreprise\n";
        }
    if (pc == ""){
                count++;
                msg += "\tle code postal\n";
        }
    if (city == ""){
                count++;
                msg += "\tla ville\n";
        }
    if (country == ""){
                count++;
                msg += "\tle pays\n";
        }   
    
    if (tel == ""){
                count++;
                msg += "\tun n° de téléphone\n";
        }
    if (contact == ""){
                count++;
                msg += "\tl'adresse email de contact\n";
     }
    /*if (tel != ""){
        if (/^[+0-9]/.test(tel) == false){
            count2++;
            msg2 += "\nLe format du n° de téléphone est incorrect \n";
        }
    }*/
    
    if (pc != ""){
        if (/^[0-9]{4,5}$/.test(pc) == false){
            count2++;
            msg2 += "\nLe code postal ne doit comporter que des chiffres (4 ou 5) \n";
        }
    }
    
    
    
     
    if (count > 0 && count2 > 0){
          var message = msg+msg2;
        alert(message);
                return false;
        }
    if (count > 0 && count2 == 0){
        alert(msg);
        return false;
    }
    if (count ==0 && count2 > 0){
        alert(msg2);
        return false;
    }
        return true;
}

// utils.js

function setFocus(id) {
    var elt = document.getElementById(id);
    if (elt) {
        elt.focus();
        if (elt.select)
            elt.select();
    }
    return true;
} // setFocus

function deleteElement(){
     return (confirm('Etes-vous sûr de vouloir supprimer cet élément ?'));
}

function acceptRequest(){
    return (confirm('Etes-vous sûr de vouloir accepter la demande ?'));
}

function refuseRequest(){
    return (confirm('Etes-vous sûr de vouloir refuser la demande ?'));
}

function disableAccount(){
    return (confirm('Etes-vous sûr de vouloir suspendre le compte ?'));
}
function enableAccount(){
    return (confirm('Etes-vous sûr de vouloir réactiver le compte ?'));
}
function generateSn(){
    return (confirm('Etes-vous sûr de vouloir générer les S/N ?'));
}

function ask(message){
    return (confirm(message));
}


function addOne(id){
    var elt = document.getElementById(id);
    elt.value++;
    return false;
}
        
function substractOne(id){
   var elt = document.getElementById(id);
   elt.value--;
   return false;
}
            
function gotoNextStep(){
    if (document.getElementById('acceptContract').checked)
       document.getElementById('nextStep').disabled = false;
   else
       document.getElementById('nextStep').disabled = true;
}

function gotoUrl(url){
    window.location.replace(url);
}
    

function visibilite(thingId)
    {
        var targetElement;
        targetElement = document.getElementById(thingId) ;
        if (targetElement.style.display == "none")
        {
            targetElement.style.display = "" ;
        } else {
            targetElement.style.display = "none" ;
        }
    }
    function openall(thingId)
    {
        targetElement = document.getElementById(thingId) ;
        targetElement.style.display = "" ;
    }
    function closeall(thingId)
    {
        targetElement = document.getElementById(thingId) ;
        targetElement.style.display = "none" ;
    }
    


function checkNewCustomer(form){

 if (!isNotEmpty(form.COMPANY, MUST_SUPPLY_CLIENT_NAME,MUST_SUPPLY))
    return false;

 if (!isNotEmpty(form.CITY, MUST_SUPPLY_CITY_NAME,MUST_SUPPLY))
    return false;

if(form.CONTACT.value==1 || form.CONTACT.value==2){
 if (!isNotEmpty(form.name, MUST_SUPPLY_NAME_NAME,MUST_SUPPLY))
    return false;
 if (!isNotEmpty(form.lastname, MUST_SUPPLY_LASTNAME_NAME,MUST_SUPPLY))
    return false;
}
 if (!isNotEmpty(form.email, MUST_SUPPLY_EMAIL_NAME,MUST_SUPPLY))
    return false;
 if (!isNotEmpty(form.tel, MUST_SUPPLY_TEL_NAME,MUST_SUPPLY))
    return false;

// if (!isNotEmpty(form.DIST, MUST_SUPPLY_DIST_NAME,MUST_SUPPLY))
  //  return false;

 if (!isNotEmpty(form.PART, MUST_SUPPLY_PART_NAME,MUST_SUPPLY))
    return false;

 //if (!isNotEmpty(form.DISTCON, MUST_SUPPLY_DIST_CON_NAME,MUST_SUPPLY))
   // return false;

 if (!isNotEmpty(form.PARTCON, MUST_SUPPLY_PART_CON_NAME,MUST_SUPPLY))
    return false;
}


function checkNewDistOrder(form){

 if (!isNotEmpty(form.COMPANY, MUST_SUPPLY_CLIENT_NAME,MUST_SUPPLY))
    return false;

 if (!isNotEmpty(form.CITY, MUST_SUPPLY_CITY_NAME,MUST_SUPPLY))
    return false;

 if (form.pays.value=='' || form.pays.value==0 || form.pays.value==999){
	alert(MUST_SUPPLY+' '+MUST_SUPPLY_COUNTRY_NAME);return false;
	form.pays.focus();
    return false;
	}

	if(form.CONTACTID.value==1 || form.CONTACT.value==1 || form.CONTACT.value==2){
 	
		if (!isNotEmpty(form.name, MUST_SUPPLY_NAME_NAME,MUST_SUPPLY))
    		return false;
 		if (!isNotEmpty(form.lastname, MUST_SUPPLY_LASTNAME_NAME,MUST_SUPPLY))
    		return false;


 		if (!isNotEmpty(form.email, MUST_SUPPLY_EMAIL_NAME,MUST_SUPPLY))
   			 return false;

		 if (!isNotEmpty(form.tel, MUST_SUPPLY_TEL_NAME,MUST_SUPPLY))
    		return false;
	}

 

// if (!isNotEmpty(form.DIST, MUST_SUPPLY_DIST_NAME,MUST_SUPPLY))
  //  return false;

 if (!isNotEmpty(form.PART, MUST_SUPPLY_PART_NAME,MUST_SUPPLY))
    return false;

// if (!isNotEmpty(form.DISTCON, MUST_SUPPLY_DIST_CON_NAME,MUST_SUPPLY))
  //  return false;

 if (!isNotEmpty(form.PARTCON, MUST_SUPPLY_PART_CON_NAME,MUST_SUPPLY))
    return false;

if (form.SKYCONTACT.value==0){
	alert(MUST_SUPPLY+' '+MUST_SUPPLY_SKYCONTACT_NAME);return false;
	form.SKYCONTACT.focus();
}

 if (!isNotEmpty(form.SITE, MUST_SUPPLY_SITE_NAME,MUST_SUPPLY))
    return false;

if (form.sid.value && form.id.value==''){
		return true;
}else if(form.sid.value && form.keep.value==0){

		if (form.productcount.value=='' || form.productcount.value==0){
		alert(MUST_SUPPLY_PRODUCT);
		return false;
		}

  		if (form.userbase.value==0 && form.base.value==0){
			alert(MUST_SUPPLY_BASE_ERROR);
    		return false;
		}
}

}

   
function checkNewDistSiteOrder(form){
 if (!isNotEmpty(form.SITE, MUST_SUPPLY_SITE_NAME,MUST_SUPPLY))
    return false;

}


function checkValidate(form){


 if (!isNotEmpty(form.COMPANY, MUST_SUPPLY_CLIENT_NAME,MUST_SUPPLY))
    return false;

 if (!isNotEmpty(form.CITY, MUST_SUPPLY_CITY_NAME,MUST_SUPPLY))
    return false;

if (form.userid.value!=0 && form.userid.value!=''){

 	if (!isNotEmpty(form.name, MUST_SUPPLY_NAME_NAME,MUST_SUPPLY))
    	return false;
 	if (!isNotEmpty(form.lastname, MUST_SUPPLY_LASTNAME_NAME,MUST_SUPPLY))
    	return false;

 if (!isNotEmpty(form.email, MUST_SUPPLY_EMAIL_NAME,MUST_SUPPLY))
    return false;
 if (!isNotEmpty(form.tel, MUST_SUPPLY_TEL_NAME,MUST_SUPPLY))
    return false;


    if (!isNotEmpty(form.password, MUST_SUPPLY_PASS,MUST_SUPPLY))
    return false;

    if (form.password.value!=form.passwordc.value){
            alert(MUST_SUPPLY_VERPASS);
            form.passwordc.focus();
            form.passwordc.style.backgroundColor = color;
            return false;
    }
}



return true;



}

function checkNewOemOrder(){
alert('sssss');
return false;
}

function refreshit(){location.reload(true);}

function disablebutton(obj){obj.disabled=true;}


