	$(document).ready(function(){

        $('#email').blur(function(){
			var email = $("#email").val();
            if(!(isValidEmailAddress(email)))
			{  
                 $("#email").addClass("exists").html();  
             }
			 else
			 {  
                 //else show the cheking_text and run the function to check 
                 verification_email();  
             }  
         }); 
		 
   
   });  
 //function to check username availability  
 function verification_email(){  
   
         //get the username  
         var email = $('#email').val();  
   
         //use ajax to run the check  
         $.post("validerEmail.php", { email: email },  
             function(result){  
                 //if the result is 1  
                 if(result == 1){  
                     //show that the username is available  
                      $("#email").addClass("avail").html();
                 }else{  
                     //show that the username is NOT available  
                     $("#email").addClass("exists").html();
                 }  
         });  
  
 }  
 
 
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}