    //  Form checken functions
    //  Project: EasyTicket.nl
    //  Create date: 14-09-2005
    //  Create by: Jeroen Timmers <jeroen@thinq-it.nl>
    
    //  Navigator
    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
    
    //  check the form to acticate a voucher
    function checkVoucher(e, b)
    {
        //  check the voucher
        if (b == 1)
        {
            var returnValue = true;
            
        if (isEmpty(e.VoucherCode.value)) returnValue = setWarning(e.VoucherCode, true); else reset(e.VoucherCode);
            
//            if (trim(e.VoucherCode1.value).length < 3) returnValue = setWarning(e.VoucherCode1, true); else reset(e.VoucherCode1);
//            if (trim(e.VoucherCode2.value).length < 3) returnValue = setWarning(e.VoucherCode2, true); else reset(e.VoucherCode2);
//            if (trim(e.VoucherCode3.value).length < 3) returnValue = setWarning(e.VoucherCode3, true); else reset(e.VoucherCode3);
//            if (trim(e.VoucherCode4.value).length < 3) returnValue = setWarning(e.VoucherCode4, true); else reset(e.VoucherCode4);                        
            
            //  return
            return returnValue;
        }
        //  nog logged in
        else
        {
            alert('Niet ingelogd');
            return false;
        }
    }
    
    //  check an action form
    function checkActie(e)
    {
        var returnValue = true;

        if (!isEmail(e.cEmail.value))        returnValue = setWarning(e.cEmail, true); else reset(e.cEmail);        
        if (!isMobile(e.cMobiel.value))      returnValue = setWarning(e.cMobiel, true); else reset(e.cMobiel);
        if (trim(e.cCode.value).length != 4) returnValue = setWarning(e.cCode, true); else reset(e.cCode);
        if (e.IsSubmit.value == 1)           returnValue = false;
        if (returnValue) e.IsSubmit.value = 1;
                
        return returnValue; 
    }
    
    //  function to check keyup voucher code
    function checkVoucherInput(v, nr, e)
    {
        var keyCode = (isNN) ? e.which : e.keyCode;

        //  9 is tab
        if (keyCode != 9 && keyCode != 16)
        {
            //  expression to check
            var re_Char = /^[a-zA-Z0-9]+$/;
            //  string
            var s = v.value;
            //  new string
            var ns = "";
            //  length string
            var l = s.length; 
            
            //  check each input char
            for (var i=0; i<l; i++) if (re_Char.test(s.charAt(i))) ns += s.charAt(i).toUpperCase();
            //  set new string        
            v.value = ns;
            //  check for new focus
            if (v.value.length == 3 && nr < 4)
            {
                var o = eval('document.formulier_searchvoucher.VoucherCode' + (nr+1));
                o.focus();
            }
        }
    }
    
    //  check the form sales
    function checkFormContactSales(e)
    {
        var returnValue = true;
        
        if (isEmpty(e.cVoornaam.value)) returnValue = setWarning(e.cVoornaam, true); else reset(e.cVoornaam);
        if (isEmpty(e.cAchternaam.value)) returnValue = setWarning(e.cAchternaam, true); else reset(e.cAchternaam);
        if (isEmpty(e.cBedrijfsnaam.value)) returnValue = setWarning(e.cBedrijfsnaam, true); else reset(e.cBedrijfsnaam);
        if (!isInt(e.cTelefoon.value)) returnValue = setWarning(e.cTelefoon, true); else reset(e.cTelefoon);
        if (!isInt(e.cMobiel.value)) returnValue = setWarning(e.cMobiel, true); else reset(e.cMobiel);
        if (!isEmail(e.cEmail.value)) returnValue = setWarning(e.cEmail, true); else reset(e.cEmail);
        if (isEmpty(e.cEvenement.value)) returnValue = setWarning(e.cEvenement, true); else reset(e.cEvenement);
        if (isEmpty(e.cWebsiteEvenement.value)) returnValue = setWarning(e.cWebsiteEvenement, true); else reset(e.cWebsiteEvenement);
        
        return returnValue;        
    }
    
    //  check the form voucher
    function checkFormContactVoucher(e)
    {
        var returnValue = true;
        
        if (isEmpty(e.cVoornaam.value)) returnValue = setWarning(e.cVoornaam, true); else reset(e.cVoornaam);
        if (isEmpty(e.cAchternaam.value)) returnValue = setWarning(e.cAchternaam, true); else reset(e.cAchternaam);
        if (isEmpty(e.cBedrijfsnaam.value)) returnValue = setWarning(e.cBedrijfsnaam, true); else reset(e.cBedrijfsnaam);
        if (!isInt(e.cTelefoon.value)) returnValue = setWarning(e.cTelefoon, true); else reset(e.cTelefoon);
        if (!isInt(e.cMobiel.value)) returnValue = setWarning(e.cMobiel, true); else reset(e.cMobiel);
        if (!isEmail(e.cEmail.value)) returnValue = setWarning(e.cEmail, true); else reset(e.cEmail);
        if (isEmpty(e.cEvenement.value)) returnValue = setWarning(e.cEvenement, true); else reset(e.cEvenement);
        if (isEmpty(e.cWebsiteEvenement.value)) returnValue = setWarning(e.cWebsiteEvenement, true); else reset(e.cWebsiteEvenement);
        
        return returnValue;        
    }
    
    //  check the form affiliate
    function checkFormContactAffiliate(e)
    {
        var returnValue = true;
        
        if (isEmpty(e.cVoornaam.value)) returnValue = setWarning(e.cVoornaam, true); else reset(e.cVoornaam);
        if (isEmpty(e.cAchternaam.value)) returnValue = setWarning(e.cAchternaam, true); else reset(e.cAchternaam);
        if (isEmpty(e.cBedrijfsnaam.value)) returnValue = setWarning(e.cBedrijfsnaam, true); else reset(e.cBedrijfsnaam);
        if (!isInt(e.cTelefoon.value)) returnValue = setWarning(e.cTelefoon, true); else reset(e.cTelefoon);
        if (!isInt(e.cMobiel.value)) returnValue = setWarning(e.cMobiel, true); else reset(e.cMobiel);
        if (!isEmail(e.cEmail.value)) returnValue = setWarning(e.cEmail, true); else reset(e.cEmail);
        
        return returnValue;        
    }
    
    
    //  check the form to place tickets into the session
    //  e is the form
    function checkEventDetailsAddTicket(e)
    {
        var returnValue = true;
        
        if (isEmpty(e.nTicketTypeID.value)) returnValue = setWarning(e.nTicketTypeID, true); else reset(e.nTicketTypeID);
        if (isEmpty(e.dTicket.value)) returnValue = setWarning(e.dTicket, true); else reset(e.dTicket);
        if (isEmpty(e.nCount.value)) returnValue = setWarning(e.nCount, true); else reset(e.nCount);        
        
        return returnValue;
    }  
    
    //  check the account form
    //  e is the form
    function checkAccount(e)
    {
        var returnValue = true;
        
        if (isEmpty(e.cFirstname.value)) returnValue = setWarning(e.cFirstname, true); else reset(e.cFirstname);
        if (isEmpty(e.cName.value)) returnValue = setWarning(e.cName, true); else reset(e.cName);
        if (isEmpty(e.cStreetName.value)) returnValue = setWarning(e.cStreetName, true); else reset(e.cStreetName);
        if (isEmpty(e.cStreetNumber.value)) returnValue = setWarning(e.cStreetNumber, true); else reset(e.cStreetNumber);
        if (isEmpty(e.cZipcode.value)) returnValue = setWarning(e.cZipcode, true); else reset(e.cZipcode);
        if (isEmpty(e.cCity.value)) returnValue = setWarning(e.cCity, true); else reset(e.cCity);
        if (!isTelephone(e.cMobileNumber.value)) returnValue = setWarning(e.cMobileNumber, true); else reset(e.cMobileNumber);
        if (!isEmail(e.cEmail.value)) returnValue = setWarning(e.cEmail, true); else reset(e.cEmail);
//        if (isEmpty(e.cIdentificationNumber.value)) returnValue = setWarning(e.cIdentificationNumber, true); else reset(e.cIdentificationNumber);
        if (e.bAV.checked == false) returnValue = setWarning(e.bAV, true); else reset(e.bAV);

        return returnValue;
    }
    
    function checkPosPersonal(e)
    {
        var returnValue = true;
        
        //if (isEmpty(e.PosName.value)) returnValue = setWarning(e.PosName, true); else reset(e.PosName);
        
        if (!isEmpty(e.PosEmail.value))
        {
            if (!isEmail(e.PosEmail.value)) returnValue = setWarning(e.PosEmail, true); else reset(e.PosEmail);
        }
        else reset(e.PosEmail);
        
        if (e.PosNumber.value == "06") e.PosNumber.value = '';
        if (!isEmpty(e.PosNumber.value))
        {
            if (!isMobile(e.PosNumber.value)) returnValue = setWarning(e.PosNumber, true); else reset(e.PosNumber);
        }
        else reset(e.PosNumber);
        
        return returnValue;		
	}
    
    //  check the forgotpassword form
    function checkForgotPassword(e)
    {
        var returnValue = true;
        
        if (!isEmail(e.cEmail.value)) returnValue = setWarning(e.cEmail, true); else reset(e.cEmail);

        return returnValue;
    }
    
    //  ************************************************************************
    //  Help functions for the form checkers
    //  ************************************************************************
        
    //  setWarning, set a warning on the mainpage and return always false
    //  e, the identifier of the warning page
    //  t, the bool that say if there is a warning
    function setWarning(e, t)
    {
        if (t) e.style.background = '#FEE0E0';
        return false;
    }
    
    //  reset function from warning
    function reset(e)
    {
        e.style.background = '';
    }
    
    //  isEmpty
    //  s the value to check
    function isEmpty(s)
    {
        return (trim(s).length == 0);
    }
    
    //  isEmail
    //  s the value to check
    function isEmail(s)
    {
        return (/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(s));
    }
    
    //  isTelephone
    //  s the value to check
    function isTelephone(s)
    {
        //  check for integer
        if (!isInt(s)) return false;
        return true;
        //  check for length
        return (trim(s).length == 10)
    }
    
    //  isMobile
    //  s the value to check
    function isMobile(s)
    {
        //  check for integer
        if (!isInt(s)) return false;
        
        //  check for beginning 06
        if (s.substring(0,2) != 06) return false;
        
        //  check for length
        return (trim(s).length == 10)
    }
    
    //  isInt
    //  s the value check
    function isInt(s)
    {
        var re_Int = /^[0-9]+$/;
        return re_Int.test(s);
    }
    
    //  Trim the whitespace before and after a string
    //  s the value to trim
    function trim(s)
    {
        while (s.substring(0,1) == ' ') s = s.substring(1,s.length);
        while (s.substring(s.length-1,s.length) == ' ') s = s.substring(0,s.length-1);
        return s;
    }