        String.prototype.isempty=isempty;
        String.prototype.isemailid=isemailid;
        String.prototype.istelephone=istelephone;
        String.prototype.isdate=isdate;
        String.prototype.isnumber=isnumber;
        String.prototype.trim=trim;
        String.prototype.replicateatstart=replicateatstart;
        String.prototype.replicateatend=replicateatend;
        Date.prototype.getDateTime=getDateTime;

        function trim()
                {
                        var i = new Number();
                        var pSpace = new Boolean();
                        var pStart = new Number();
                        var pEnd = new Number();

                        for(i=0;i<=this.length-1;i++)
                                {
                                        if(this.charAt(i)!=" ")
                                                {
                                                        pStart=i;
                                                        pSpace=true;
                                                        break;
                                                }
                                }
                        for(i=this.length-1;i>=0;i--)
                                {
                                        if(this.charAt(i)!=" ")
                                                {
                                                        pEnd=i+1;
                                                        pSpace=true;
                                                        break;
                                                }
                                }
                        if(pStart==0 && pEnd==0 && pSpace==true)
                                {
                                        return this;
                                }
                        else
                                {
                                        return this.substring(pStart,pEnd);
                                }
                }
        function isempty(pmessage)
                {
                        if (this.trim()=="")
                                {
                                        if(pmessage.trim()!="")
                                        {
                                                alert(pmessage);
                                        }
                                        return true;
                                }
                        return false;
                }
        function isselected(pobj, pmessage)
        {
                if(pobj.selectedIndex<=0)
                        {
                                if(pmessage.trim()!="")
                                {
                                        alert(pmessage);
                                }
                                return false;
                        }
                return true;
        }
        function isemailid(pmessage)
        {
                if(this.trim()!="")
                {
                        if((this.indexOf("@",0) == -1)||(this.indexOf(".",0) == -1)||(this.indexOf("@",0) == 0)||(this.indexOf(".",0) == 0)||(this.indexOf(".",0) == this.length-1))
                        {
                                if(pmessage.trim()!="")
                                {
                                        alert(pmessage);
                                }
                                return false;
                        }
                }
                return true;
        }
        function isexisting(pobj, pval, pmessage)
        {
                var i = Number();
                var x = new String();
                for(i=0;i<=pobj.options.length-1;i++)
                        {
                                if(pobj.options[i].value.split("|")[0]==pval.split("|")[0])
                                {
                                        if(pmessage.trim()!="")
                                        {
                                                alert("'" + pmessage + "'");
                                        }
                                        return true;
                                }
                        }
                return false;
        }
        function istelephone(pmessage)
        {
                var i = new Number();
                for(i=0;i<=this.trim().length-1;i++)
                {
                        if((this.trim().charCodeAt(i)<48 || this.trim().charCodeAt(i)>57) && (this.trim().charAt(i) != " " && this.trim().charAt(i) != "+" && this.trim().charAt(i) != "-" && this.trim().charAt(i) != "/"))
                        {
                                alert(pmessage);
                                return false;
                        }
                }
                return true;
        }
        function isdate()
        {
                if(this=="//" || this=="")
                {
                        return true;
                }
                /* Checks for the following valid date formats:
                MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
                Also separates date into month, day, and year variables
                var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/; */

                /* To require a 4 digit year entry, use this line instead: */
                var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
                var matchArray = this.match(datePat); // is the format ok?
                if (matchArray == null)
                {
                        alert("The date entered is not correct !(day/Month/Year)")
                        return false;
                }
                mois = matchArray[1]; // parse date into variables
                day = matchArray[3];
                year = matchArray[4];
                if (mois < 1 || mois > 12)
                {
                        alert("The month entered must be between 1 and 12 !");
                        return false;
                }
                if (day < 1 || day > 31)
                {
                        alert("The day entered must be between 1 et 31 !");
                        return false;
                }
                if ((mois==4 || mois==6 || mois==9 || mois==11) && day==31)
                {
                        alert("the month "+mois+" doesn't have 31 days !")
                        return false;
                }
                if (mois == 2)
                { // check for february 29th
                        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
                        if (day>29 || (day==29 && !isleap))
                        {
                                alert("The month of february of he year " + year + " doesn't have " + day + " days !");
                                return false;
                        }
                }
                if(year<=1752)
                {
                        alert("Verify the entered date");
                        return false
                }
                return true;
        }
        function isnumber(pmessage)
        {
                var i = new Number();
                for(i=0;i<=this.trim().length-1;i++)
                {
                        if(this.trim().charCodeAt(i)<48 || this.trim().charCodeAt(i)>57)
                        {
                                alert(pmessage);
                                return false;
                        }
                }
                return true;
        }
        function getDateTime(pFormat)
        {
                var pVal = new String();
                if (pFormat=="dmy")
                {
                        pVal=this.getDate() + "/" + (this.getMonth()+1) + "/" + this.getFullYear() + " " + this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
                }
                else
                {
                        pVal=this.getDate() + "/" + (this.getMonth()+1) + "/" + this.getFullYear() + " " + this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
                }
                return pVal;
        }
        function replicateatend(pChar, pLength)
        {
                var pVal = new String();
                var pI = new Number();

                pVal=this;
                if (pLength>=1)
                {
                        for (pI=1;pI<=pLength;pI++)
                        {
                                pVal = pVal + pChar
                        }
                }
                return pVal;
        }
        function replicateatstart(pChar, pLength)
        {
                var pVal = new String();
                var pI = new Number();

                if (pLength>=1)
                {
                        for (pI=1;pI<=pLength;pI++)
                        {
                                pVal = pVal + pChar
                        }
                }
                pVal= pVal + this;
                return pVal;
        }

                function SelectDsg()
        {
                var pCode = new Number(); //Variable to hold designation code of selected designation
                var pVal = new String(); //Variable to hold designation name of selected designation
                var pItemNumber = new Number(); //Variable to hold index of selected item in combo box

                var pForm=window.document.frmCv; //Variable to hold form object

                if(pForm.cboDesignations.selectedIndex>0)
                {
                        if (pForm.lstDesignations.options.length==4)
                        {
                                alert("Select 3 titles max.!");
                                return false;
                        }
                        pCode=pForm.cboDesignations.options[pForm.cboDesignations.selectedIndex].value;
                        pVal=pForm.cboDesignations.options[pForm.cboDesignations.selectedIndex].text;
                        if (isexisting(pForm.lstDesignations, pCode, "")==false)
                        {
                                pItemNumber=pForm.lstDesignations.options.length;
                                pForm.lstDesignations.options[pItemNumber]=new Option(pVal, pCode);
                        }
                }
                return false;
        }

function companycheck()
{
        var pForm=window.document.com; //Variable to hold form object

        if(pForm.name.value.isempty("Your Organization Name, please.")==true)
        {
                pForm.name.focus();
                return false;
        }
       if( pForm.linhvuc.value.isempty("Your Organization Type, please.")==true )
        {
               pForm.linhvuc.focus();
               return false;
       }
       if( pForm.section.value.isempty("Activity Sector, please.")==true )
        {
               pForm.section.focus();
               return false;
       }
  //      if(pForm.address.value.isempty("Your Address, please.")==true)
  //      {
  //             pForm.address.focus();
   //             return false;
   //     }
        if(pForm.city.value.isempty("Your City & State, please.")==true)
        {
                pForm.city.focus();
                return false;
        }
        if(pForm.zipcode.value.isempty("Your Postal Code, please.")==true)
        {
                pForm.zipcode.focus();
                return false;
        }
        if(pForm.region.value.isempty("Your Country, please.")==true)
       {
               pForm.region.focus();
                return false;
       }
    //    if(pForm.tel.value.isempty("Votre Tél, SVP.")==true)
    //    {
    //            pForm.tel.focus();
   //             return false;
    //    }
        if ((pForm.email.value.isempty("Your Email, please.")==true) || (pForm.email.value.isemailid("Your Email, please.")==false))
        {
                pForm.email.focus();
                return false;
        }
        if(pForm.contact.value.isempty("Your Name, please.")==true)
        {
                pForm.contact.focus();
                return false;
        }
 //      if(pForm.gender.value.isempty("Your Gender, please.")==true)
  //      {
   //             pForm.gender.focus();
  //              return false;
   //     }
   //     if(pForm.chucvu.value.isempty("Votre Fonction, SVP.")==true)
   //     {
   //             pForm.chucvu.focus();
  //              return false;
   //     }
   //     if(pForm.tel_contact.value.isempty("Votre tél.professionnel direct, SVP.")==true)
   //     {
   //             pForm.tel_contact.focus();
    //            return false;
   //     }
     //   if ( !(pForm.abonement[0].checked || pForm.abonement[1].checked || pForm.abonement[2].checked || pForm.abonement[3].checked || pForm.abonement[4].checked || pForm.abonement[5].checked) )
     //   {
     //           alert("Sélectionner une option d\'abonnement, SVP.") ;
    //            return false;
    //    }
   //     if ( !(pForm.cgv.checked) )
    //    {
    //            alert("Do you agree to the Terms of Service ?") ;
   //             return false;
   //     }

        pForm.submit();
        return false;
}

function print_companycheck()
{
        var pForm=window.document.com; //Variable to hold form object

        if(pForm.name.value.isempty("Your Organization Name, please.")==true)
        {
                pForm.name.focus();
                return false;
        }
        if( pForm.linhvuc.value.isempty("Your Organization Type, please.")==true )
        {
                pForm.linhvuc.focus();
                return false;
        }
        if( pForm.section.value.isempty("Activity Sector, please.")==true )
        {
                pForm.section.focus();
                return false;
        }
        if(pForm.address.value.isempty("Your Address, please.")==true)
        {
                pForm.address.focus();
                return false;
        }
        if(pForm.city.value.isempty("Your City & State, please.")==true)
        {
                pForm.city.focus();
                return false;
        }
        if(pForm.zipcode.value.isempty("Your Postal Code, please.")==true)
        {
                pForm.zipcode.focus();
                return false;
        }
        if(pForm.region.value.isempty("Your Country, please.")==true)
        {
                pForm.region.focus();
                return false;
        }
     //   if(pForm.tel.value.isempty("Votre tél., SVP.")==true)
    //    {
     //           pForm.tel.focus();
    //            return false;
     //  }
         if ((pForm.email.value.isempty("Your Email, please.")==true) || (pForm.email.value.isemailid("Your Email, please.")==false))
        {
                pForm.email.focus();
                return false;
        }
        if(pForm.contact.value.isempty("Your Name, please.")==true)
        {
                pForm.contact.focus();
                return false;
        }
    //    if(pForm.gender.value.isempty("Your Gender, please.")==true)
  //     {
    //            pForm.gender.focus();
  //              return false;
   //     }
    //    if(pForm.chucvu.value.isempty("Votre fonction, SVP.")==true)
  //      {
  //              pForm.chucvu.focus();
   //             return false;
   //     }
     //   if(pForm.tel_contact.value.isempty("Votre tél. professionnel direct, SVP.")==true)
    //    {
    //            pForm.tel_contact.focus();
   //             return false;
   //     }
  //      if ( !(pForm.abonement[0].checked || pForm.abonement[1].checked) )
  //      {
   //             alert("Option d'abonnement, SVP.") ;
   //             return false;
  //      }
        if ( !(pForm.cgv.checked) )
        {
                alert("Do you agree to the Terms of Service?") ;
                return false;
        }

        document.getElementById("header").style.display = "none";
        document.getElementById("footer").style.display = "none";
        document.getElementById("left").style.display = "none";
        document.getElementById("menubody").style.display = "none";
        window.print();

        document.getElementById("header").style.display = "";
        document.getElementById("footer").style.display = "";
        document.getElementById("menubody").style.display = "";
        document.getElementById("left").style.display = "";
        pForm.submit();
        return false;
}


function vacancyform()
{
        var pForm=window.document.frmCv; //Variable to hold form object

        if(pForm.job.value.isempty("Titre de l\'offre, SVP.")==true)
        {
                pForm.job.focus();
                return false;
        }

        pForm.principal.value="";
        for(pI=1;pI<=pForm.lstStates1.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates1.options[pI].value;
        }
        for(pI=1;pI<=pForm.lstStates2.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates2.options[pI].value;
        }
        for(pI=1;pI<=pForm.lstStates3.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates3.options[pI].value;
        }
        pForm.principal.value=pForm.principal.value.substring(1,pForm.principal.value.length)

   //     if(pForm.dd.value.isempty("\"Offre valable jusqu'au\" : Date?")==true)
   //     {
   //             pForm.dd.focus();
   //             return false;
   //     }
  //      if(pForm.mm.value.isempty("\"Offre valable jusqu'au\" : Moins?")==true)
  //      {
   //             pForm.mm.focus();
   //             return false;
   //     }
   //     if(pForm.yyyy.value.isempty("\"Offre valable jusqu'au\" : Année?")==true)
   //     {
   //             pForm.yyyy.focus();
   //             return false;
   //     }
        pForm.submit();
        return false;
}
function searchvacancy()
{
        var pForm=window.document.frmCv; //Variable to hold form object

        pForm.principal.value="";
        for(pI=1;pI<=pForm.lstStates1.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates1.options[pI].value;
        }
        for(pI=1;pI<=pForm.lstStates2.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates2.options[pI].value;
        }
        for(pI=1;pI<=pForm.lstStates3.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates3.options[pI].value;
        }
        pForm.principal.value=pForm.principal.value.substring(1,pForm.principal.value.length)

        pForm.submit();
        return false;
}

function searchcandidate()
{
        var pForm=window.document.frmCv; //Variable to hold form object

        pForm.principal.value="";
        for(pI=1;pI<=pForm.lstStates1.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates1.options[pI].value;
        }
        for(pI=1;pI<=pForm.lstStates2.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates2.options[pI].value;
        }
        for(pI=1;pI<=pForm.lstStates3.options.length-1;pI++)
        {
            pForm.principal.value = pForm.principal.value + "," + pForm.lstStates3.options[pI].value;
        }
        pForm.principal.value=pForm.principal.value.substring(1,pForm.principal.value.length)

        pForm.ValSkill.value="";
        for(pI=1;pI<=pForm.lstSkills.options.length-1;pI++)
        {
            pForm.ValSkill.value = pForm.ValSkill.value + "," + pForm.lstSkills.options[pI].value;
        }
        for(pI=1;pI<=pForm.lstSkill.options.length-1;pI++)
        {
            pForm.ValSkill.value = pForm.ValSkill.value + "," + pForm.lstSkill.options[pI].value;
        }
        pForm.ValSkill.value=pForm.ValSkill.value.substring(1,pForm.ValSkill.value.length)

        pForm.valLng.value="";
        for(pI=1;pI<=pForm.lstLanguages.options.length-1;pI++)
        {
            pForm.valLng.value = pForm.valLng.value + "," + pForm.lstLanguages.options[pI].value;
        }
        pForm.valLng.value=pForm.valLng.value.substring(1,pForm.valLng.value.length) ;
        pForm.submit();
        return false;
}


function SelectSkills(pType)
{
        var pI = new Number();        //Counter variable
        var pCode = new Number(); //Variable to hold code of selected skill
        var pVal = new String(); //Variable to hold description of selected skill
        var pItemNumber = new Number(); //Variable to hold index of selected skill from combo box
        var pForm=window.document.frmCv; //Variable to hld form object
        if (pForm.lstSkills.options.length==16)
        {
                alert("Select 15 skills max.!");
                return false;
        }
        if(pForm.cboSkills.selectedIndex>=0)
        {
                for(pI=0;pI<=pForm.cboSkills.options.length-1;pI++)
                {
                        if(pForm.cboSkills.options[pI].selected==true)
                        {
                                if(pForm.lstSkills.options.length==16)
                                {
                                        break;
                                }
                                pCode=pForm.cboSkills.options[pI].value;
                                switch(pType)
                                {
                                        case "Expert" :
                                                pCode=pCode + "1";
                                                break;
                                        case "Senior" :
                                                pCode=pCode + "2";
                                                break;
                                        case "Junior" :
                                                pCode=pCode + "3";
                                                break;
                                        case "Basics" :
                                                pCode=pCode + "4";
                                                break
                                }
                                pVal=pForm.cboSkills.options[pI].text + "[" + pType + "]" ;
                                if (isexisting(pForm.lstSkills, pCode, "")==false)
                                {
                                        pItemNumber=pForm.lstSkills.options.length;
                                        pForm.lstSkills.options[pItemNumber]=new Option(pVal, pCode);
                                }
                        }
                }
        }
        return false;
}

function SelectLng(pType)
{
        var pI = new Number(); //Counter variable
        var pCode = new Number(); //Variable to hold code of selected language
        var pVal = new String(); //Variable to hold description of selected language
        var pItemNumber = new Number(); //Variable to hold index of selected language
        var pForm=window.document.frmCv; //Variable to hold form object
        if (pForm.lstLanguages.options.length==11)
        {
                alert("10 langues max.");
                return false;
        }
        if(pForm.cboLanguages.selectedIndex>=0)
        {
                for(pI=0;pI<=pForm.cboLanguages.options.length-1;pI++)
                {
                        if(pForm.cboLanguages.options[pI].selected==true)
                        {
                                if(pForm.lstLanguages.options.length==11)
                                {
                                        break;
                                }
                                pCode=pForm.cboLanguages.options[pI].value;
                                switch(pType)
                                {
                                        case "Bilingual" :
                                                pCode=pCode + "1";
                                                break;
                                        case "Fluent" :
                                                pCode=pCode + "2";
                                                break;
                                        case "Average" :
                                                pCode=pCode + "3";
                                                break;
                                        case "Basics" :
                                                pCode=pCode + "4";
                                                break;
                                }
                                pVal=pForm.cboLanguages.options[pI].text + "[" + pType + "]";
                                if (isexisting(pForm.lstLanguages, pCode, "")==false)
                                {
                                        pItemNumber=pForm.lstLanguages.options.length;
                                        pForm.lstLanguages.options[pItemNumber]=new Option(pVal, pCode);
                                }
                        }
                }
        }
        return false;
}

function SelectSkill(pType)
{
        var pI = new Number(); //Counter variable
        var pCode = new Number(); //Variable to hold code of selected state
        var pVal = new String(); //Variable to hold description of selected state
        var pItemNumber = new Number(); //Variable to hold index of selected state
        var pForm=window.document.frmCv; //Variable to hold form object
        if(pForm.cboSkill.selectedIndex>=0)
        {
                if (pForm.lstSkill.options.length==16)
                {
                        alert("15 locations max.");
                        return false;
                }
                pCode=pForm.cboSkill.options[pForm.cboSkill.selectedIndex].value;
                pVal=pForm.cboSkill.options[pForm.cboSkill.selectedIndex].text;

                if (isexisting(pForm.lstSkill, pCode, "")==false)
                {
                        pItemNumber=pForm.lstSkill.options.length;
                        pForm.lstSkill.options[pItemNumber]=new Option(pVal, pCode);
                }
        }
        return false;
}
function DeleteOptions(pObj)
{
        var pI = new Number();
        if(pObj.selectedIndex>=0)
        {
                for(pI=pObj.options.length-1;pI>=0;pI--)
                {
                        if(pObj.options[pI].selected==true)
                        {
                                if(pI!=0)
                                {
                                        pObj.options[pI]=null;
                                }
                        }
                }
        }
        return false;
}
function SelectStates3(pType)
{
        var pI = new Number(); //Counter variable
        var pCode = new Number(); //Variable to hold code of selected state
        var pVal = new String(); //Variable to hold description of selected state
        var pItemNumber = new Number(); //Variable to hold index of selected state
        var pForm=window.document.frmCv; //Variable to hold form object
        if(pForm.cboStates3.selectedIndex>=0)
        {
                if (pForm.lstStates3.options.length>10)
                {
                        alert("10 locations max.");
                        return false;
                }
                pCode=pForm.cboStates3.options[pForm.cboStates3.selectedIndex].value;
                pVal=pForm.cboStates3.options[pForm.cboStates3.selectedIndex].text;

                if (isexisting(pForm.lstStates3, pCode, "")==false)
                {
                        pItemNumber=pForm.lstStates3.options.length;
                        pForm.lstStates3.options[pItemNumber]=new Option(pVal, pCode);
                }
        }
        return false;
}

function SelectStates2(pType)
{
        var pI = new Number(); //Counter variable
        var pCode = new Number(); //Variable to hold code of selected state
        var pVal = new String(); //Variable to hold description of selected state
        var pItemNumber = new Number(); //Variable to hold index of selected state
        var pForm=window.document.frmCv; //Variable to hold form object
        if(pForm.cboStates2.selectedIndex>=0)
        {
                if (pForm.lstStates2.options.length>10)
                {
                        alert("10 locations max.");
                        return false;
                }
                pCode=pForm.cboStates2.options[pForm.cboStates2.selectedIndex].value;
                pVal=pForm.cboStates2.options[pForm.cboStates2.selectedIndex].text;

                if (isexisting(pForm.lstStates2, pCode, "")==false)
                {
                        pItemNumber=pForm.lstStates2.options.length;
                        pForm.lstStates2.options[pItemNumber]=new Option(pVal, pCode);
                }
        }
        return false;
}
function SelectStates1(pType)
{
        var pI = new Number(); //Counter variable
        var pCode = new Number(); //Variable to hold code of selected state
        var pVal = new String(); //Variable to hold description of selected state
        var pItemNumber = new Number(); //Variable to hold index of selected state
        var pForm=window.document.frmCv; //Variable to hold form object
        if(pForm.cboStates1.selectedIndex>=0)
        {
                if (pForm.lstStates1.options.length>10)
                {
                        alert("10 locations max.");
                        return false;
                }
                pCode=pForm.cboStates1.options[pForm.cboStates1.selectedIndex].value;
                pVal=pForm.cboStates1.options[pForm.cboStates1.selectedIndex].text;

                if (isexisting(pForm.lstStates1, pCode, "")==false)
                {
                        pItemNumber=pForm.lstStates1.options.length;
                        pForm.lstStates1.options[pItemNumber]=new Option(pVal, pCode);
                }
        }
        return false;
}
