// form validation function //
	function trim(a)
	{
           
	  return a.replace(/^\s+|\s+$/,'');
	}

    
	
	
	
	
	
$(document).ready(function()
{

$("#username").blur(function()
	{
	var username = document.register_form.username.value;
       //alert(username);
	var user_nulla = trim(username);
	var emailRegex = /^[""]+/;
	var spaceRegex = /[\s]/;
	var error=0;
   
	 if(user_nulla == "" || username.match(spaceRegex)) 
	{
	// alert(user_nulla);
		$("#userbox").removeClass();
		$("#userbox").addClass('messageboxemailerror');
		$("#userbox").html('<img align="absmiddle" src="images/Error.png" /> Invalid username or username is empty...').show().fadeTo(1900,1);
		error=1;
            	// inlineMsg('passcode','Invalid passcode format',4);
		
	}   
	if(error!=1)
	{
		//remove all the class add the messagebox classes and start fading
		$("#userbox").removeClass();
		$("#userbox").addClass('messagebox');
		$("#userbox").html('<img align="absmiddle" src="images/loader.gif" /> Checking Username availability...').show().fadeTo(1900,1);
		//check the username exists or not from ajax
		$.post("ajax/user_public_register_check.php",{ username:$('#username').val() } ,function(data)
        {
		//alert(trim(data));
		  if(trim(data)=='no') //if username not avaiable
		  {
		  	$("#userbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			   $(this).removeClass();
			  $(this).addClass('messageboxerror');
			  $(this).html('<img align="absmiddle" src="images/Error.png" />This username is not Usable ...').show().fadeTo(1900,1);
			  });		
          }
		  else
		  {
		  	$("#userbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).removeClass();
			  $(this).addClass('messageboxok');
			  $(this).html('<img align="absmiddle" src="images/accepted.png" />Username  Available...').show().fadeTo(1900,1);
			  //enable();
			});
		  }
				
        });
 }
	});



	$("#phone").keypress(function (e)  
	{
	
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 &&  (e.which<48 || e.which>57))
	  {
		//display error message
		$("#errmsg3").html("<font color='red'><b>Digits Only...</b></font> ").show().fadeOut(2500,0); 
	   return false;
      }	
	});

	
	
	});







