runat="server"

function submitForm(){

	var temp = 0;
	

if(temp==undefined){
	 temp = "temp";
	 }
	
	
	if(document.promo_may.realname.value==""){
		alert("Votre nom est invalide.");
		return false;
	}
	
	if ((document.promo_may.email.value==null)||(document.promo_may.email.value=="")){
		alert("Veuillez entrer un courriel valide.");

		return false;
	}
	if (echeck(document.promo_may.email.value)==false){
		document.promo_may.email.value="";

		return false;
	}
	
}

function upper(postalCode){
	var temp = postalCode.value;
	postalCode.value = temp.toUpperCase();
}

function validateCanadaPostal(p)
   
      {  
		  
           //create regular expression for validate Canadian Postal
   
           reg_exp_pcode = new RegExp(/(^s*([a-z](\s)?\d(\s)?){3}$)s*/i);      
   
           if(!reg_exp_pcode.test(p))
   
           {      
   
                return(false);  
           }

			if(p.charAt(0) == " " || p.charAt(1) == " " || p.charAt(2) == " " || p.charAt(4) == " " || p.charAt(5) == " " || p.charAt(6) == " "){	
				return(false);
			}
			
		   if(p.charAt(3) == " "){	
				document.CSST.Code_P.value = p.substring(0,3)+p.substring(4,7);
				  
		   }
		   
		   
			
            return(true);
  
      } 

function validateUSAPostal(postalCode){
	var len = postalCode.length;
	var nums = /[0-9]/;
	if(len!=5){
		
		return false;
	}
	else if(!nums.test(postalCode)){
		return false;
	}
	else
		return true;
}
function getRadioButtonValue(radioButton){
	var radioButtonValue = ""
	for (var i=0; i<radioButton.length; i++) {
        if (radioButton[i].checked) {
        	radioButtonValue= radioButton[i].value;
        }
     }
    return radioButtonValue;
}

function validateRadiobutton(rButton){
			// place any other field validations that you require here
			// validate myradiobuttons
			myOption = -1;
			for (i=rButton.length-1; i > -1; i--) {
				if (rButton[i].checked) {
					myOption = i; i = -1;
				}
			}
			if (myOption == -1) {				
				return false;
			}
			else
				return true;
			
}	

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Format du courriel invalide.");
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Format du courriel invalide.");
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Format du courriel invalide.");
	    return false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Format du courriel invalide.");
	    return false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Format du courriel invalide.");
	    return false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Format du courriel invalide.");
	    return false;
	 }
	
	 if (str.indexOf(" ")!=-1){
	    alert("Format du courriel invalide.");
	    return false;
	 }
	 					
}