$(document).ready(function(){
	<!--Start function change on email input type -->					   
	$("#email").change(function(){
		<!--Check if email is empty -->
		if ($('#email').val().length < 1) {
			$('#buttonReg').hide();
			$("#msgbox").removeClass().addClass('messagebox').html('<img src="images/loader/ajax-loader-n.gif" align="absmiddle" style="padding-left:97px; padding-top:7px">').fadeIn("slow");		
			$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Enter your email').addClass('messageboxerror').fadeTo(900,10);
			  $('#email').focus();
			});
			return false;
		}
		<!--End checking email empty -->
		<!--Check if email valid or not -->
		function is_email(emailid){
			var pattern = new RegExp(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]+$/);
			return pattern.test(emailid);
		}
		if (!is_email($('#email').val())){
			$('#buttonReg').hide();
			$("#msgbox").removeClass().addClass('messagebox').html('<img src="images/loader/ajax-loader-n.gif" align="absmiddle" style="padding-left:97px; padding-top:7px">').fadeIn("slow");
			$("#msgbox").fadeTo(200,0.1,function(){
			  //add message and change the class of the box and start fading
			  $(this).html('Given valid email please').addClass('messageboxerror').fadeTo(900,10).fadeOut();
			  $('#email').focus();
			  $('#buttonReg').delay(1300).fadeIn('normal');
			});
			return false;
		}
		<!-- End checking email valid -->		
		<!-- Start Checking email already exist or not -->
		$('#buttonReg').hide()
		$("#msgbox").removeClass().addClass('messagebox').html('<img src="images/loader/ajax-loader-n.gif" align="absmiddle" style="padding-left:97px; padding-top:7px">').fadeIn("slow");
		//check the email exists or not from ajax
		$.post("emailCheck.php",{ email:$(this).val() } ,function(data){
		  if(data=='no'){ //if email not avaiable		  
		  	$("#msgbox").fadeTo(200,0.1,function(){ //start fading the messagebox
			  //add message and change the class of the box and start fading
			  $(this).html('An email already exist').addClass('messageboxerror').fadeTo(900,1);
			  $('#buttonReg').delay(1300).fadeIn('normal');
			  $('#email').focus();
			});		
          }else{
		  	$("#msgbox").fadeTo(200,0.1,function(){  //start fading the messagebox
			  //add message and change the class of the box and start fading
			  $(this).html('An email available').addClass('messageboxok').fadeTo(900,1).fadeOut('slow');	
			  $('#buttonReg').delay(1300).fadeIn('normal');
			});
		  }			
        });
		<!--End check email exist or not -->
	});	
	<!--End function change of email input type-->
});
