$(document).ready(function(){
	$('#B1').attr('disabled','');
	var emailok = false;
	var boxes = $(".input_s1_normal");
	var myForm = $("#chkForm"), email = $("#email"), emailInfo = $("#emailInfo");
	
	//give some effect on focus
	boxes.focus(function(){
		$(this).addClass("input_s1_focus");
	});
	//reset on blur
	boxes.blur(function(){
		$(this).removeClass("input_s1_focus");
	});
	
	//Form Validation
	myForm.submit(function(){
		if(email.attr("value") == "")
		{
			alert("Enter Password");
			email.focus();
			return false;
		}
		if(!emailok)
		{
			alert("Check Password");
			email.attr("value","");
			email.focus();
			return false;
		}
	});
	
	//send ajax request to check email
	email.blur(function(){
		$.ajax({
			type: "POST",
			data: "email="+$(this).attr("value"),
			url: "checkp.php",
			beforeSend: function(){
				emailInfo.html("<font color='blue'>Checking Password...</font>");
			},
			success: function(data){
				if(data == "invalid")
				{
					emailok = false;
					emailInfo.html("<font color='red'>Invalid Password</font>");
				}
				else if(data == "0")
				{
					emailok = false;
					emailInfo.html("<font color='red'>Invalid Password</font>");
				}
				else
				{
					emailok = true;
					emailInfo.html("<font color='green'>Password OK</font>");
				}
			}
		});
	});
});