function allInit() {
	$("#login_form").submit(function()
	{ //alert($('#username').val());
		if ($('#username').val() == '') {
			$('#username').focus();
	  	$("#msgbox").removeClass().addClass('messageboxerror').text('User Name empty...').fadeIn(1000);
			return false;
		}
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("ajaxLogin.php",{ user_name:$('#username').val(),password:$('#password').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='yes') //if correct login detail
		  {
		  	//logit("login succesful");
		  	$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
					//add message and change the class of the box and start fading
					$(this).html('Logging in.....').addClass('messageboxok').fadeTo(900,1,
            function()  { 
					  //redirect to secure page
				    document.location='indexLogin.php';
			  	});
				});
		  }
		  else {
		  	//logit("login NOT succesful");
		  	$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
				  //add message and change the class of the box and start fading
				  $(this).html('Login not Succesfull...').addClass('messageboxerror').fadeTo(900,1);
				});		
       }
    });
 		return false; //not to post the  form physically
	});
	//now call the ajax also focus move from 
	$("#password").blur(function()
	{
		$("#login_form").trigger('submit');
	});

	$("#register_form").submit(function()
	{ 
		if ($('#username').val() == '') {
			$('#username').focus();
	  	$("#msgbox").removeClass().addClass('messageboxerror').text('User Name empty...').fadeIn(1000);
			return false;
		}
		if ($('#email').val() == '') {
			$('#email').focus();
	  	$("#msgbox").removeClass().addClass('messageboxerror').text('Please enter E-mail...').fadeIn(1000);
			return false;
		}

		if ($('#password').val().length < 6) {
			$('#password').focus();
	  	$("#msgbox").removeClass().addClass('messageboxerror').text('Password minimal 6 long...').fadeIn(1000);
			return false;
		}


		if ($('#password').val() != $('#password2').val()) {
			$('#password').focus();
	  	$("#msgbox").removeClass().addClass('messageboxerror').text('Passwords not same...').fadeIn(1000);
			return false;
		}
		
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Registering....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("ajaxRegister.php",{ user_name:$('#username').val(),email:$('#email').val(),password:$('#password').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='yes') //if correct login detail
		  { 
		  	$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
					//add message and change the class of the box and start fading
					$(this).html('Registered.....').addClass('messageboxok').fadeTo(900,1,
            function()  { 
					  //redirect to secure page
				    document.location='indexLogin.php';
			  	});
				});
		  }
		  else {
		  	if (data=='double') {
		  		$('#username').focus();
		  		msg = 'User already exists...';
		  	}
		  	else { 
		  		msg = 'Register failed...';
		  	}
		  	$("#msgbox").fadeTo(200,0.1,function() { //start fading the messagebox
				  //add message and change the class of the box and start fading
				  $(this).html(msg).addClass('messageboxerror').fadeTo(900,1);
				});		
       }
    });
 		return false; //not to post the  form physically
	});
}

