$(document).ready(function(){
	var btnOk=$("#ImageButton1");
	var showMsg=$("#showMsg");
	var tbEmail=$("#tbEmail");
	
	///////////////////////////////////////
	tbEmail.keyup(function(){
		var tbEmailVal=tbEmail.val();
		if(tbEmailVal!="")
		{
			tbEmail.removeClass();
			tbEmail.addClass("tskInputBox");	
		}
	});							
	
	tbEmail.blur(function(){
		var tbEmailVal=tbEmail.val();
		tbEmail.data("value",tbEmailVal);
		if(tbEmailVal!="")
		{
			if(tbEmailVal.indexOf("@")>0 && tbEmailVal.indexOf(".")>0)
			{
				tbEmail.removeClass();
				tbEmail.addClass("tskInputBox");
				$.post("/user/publicFile/checkRenZhen.aspx?type=email&STxt="+tbEmailVal,function(data){
						if(data.length>2)
						{
							showMsg.html("<font color='red'><img src='/templates/images/err.gif' /> 很遗憾，该邮箱已被占用。</font>");
							btnOk.attr("disabled","disabled");
						}
						else
						{
							showMsg.html("");
							btnOk.attr("disabled","");
						}
				 });
			}
			else
			{	
				tbEmail.addClass("tskInputError");
				tbEmail.val("邮箱格式好像不对！");			
			}
		}
		else
		{
			tbEmail.addClass("tskInputError");
			tbEmail.val("邮箱不能为空！");
		}		
	});
	tbEmail.focus(function(){
		tbEmail.val(tbEmail.data("value"));
	});
	
	//////++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	btnOk.click(function(){		
		var tbEmailVal=tbEmail.val();
		if(tbEmailVal!="")
		{
			if(tbEmailVal.indexOf("@")<1 || tbEmailVal.indexOf(".")<1)
			{				
				tbEmail.addClass("tskInputError");
				tbEmail.val("邮箱格式好像不对！");	
				return false;						
			}
		}
		else
		{
			tbEmail.addClass("tskInputError");
			tbEmail.val("邮箱不能为空！");
			return false;				
		}
	});
});