$(document).ready(function()
{
	////////////// this is for login ///////////////////////
	$("#Login").submit(function()
	{
		//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
		$("#msgDisplay").show();
		$.post("loginCheck.php",{ user_name:$('#memUsername').val(),password:$('#memPassword').val(),type:"memLogin"} ,function(data)
        {
		  if(data=='yes') //if correct login detail
		  {
		  	$("#msgDisplay").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.....').fadeTo(900,1,
              function()
			  { 
			  	 //redirect to secure page
				 document.location='my_account.php';
			  });
			});
		  }
		   else if(data=='notActive')
		  {
		  	$("#msgDisplay").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('The email sent to this users account has not been validated..').fadeTo(900,1,function()
				{																									  
			  		$("#msgDisplay").fadeTo(2000,0);
				});
			});		
		  }
		   else if(data=='empty')
		  {
		  	$("#msgDisplay").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Please enter username and password..').fadeTo(900,1,function()
				{																									  
			  		$("#msgDisplay").fadeTo(2000,0);
				});
			});		
		  }
		  else 
		  {
		  	$("#msgDisplay").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Incorrect user name or password - please try again...').fadeTo(900,1,function()
				{																									  
			  		$("#msgDisplay").fadeTo(2000,0);
				});
			});		
          }
	  });
 	  return false; //not to post the  form physically
	});
	//now call the ajax also focus move from 
	$("#memPassword").blur(function()
	{
		$("#Login").trigger('submit');
		
	});
	
	
	$("#memUsername").focus(function()
	{
		$("#memUsername").val('');		
	});
	
	$("#memUsername").blur(function()
	{
		var value = $("#memUsername").val();	
		if(value=="")
			$("#memUsername").val('Username..');	
	});
	
	
	$("#skeyword").focus(function()
	{
		$("#skeyword").val('');		
	});
	
	$("#skeyword").blur(function()
	{
		var value1 = $("#skeyword").val();	
		if(value1=="")
			$("#skeyword").val('search..');	
	});
	
	$("#SearchStores").click(function()
	{
		var value2 = $("#skeyword").val();
		document.location='search_stores.php?keyword='+value2;	
	});
	
});
