$(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.length==11)
			{
				tbEmail.removeClass();
				tbEmail.addClass("tskInputBox");
				$.post("/user/publicFile/checkRenZhen.aspx?type=phone&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("手机号码长度必须为11位！");		
				btnOk.attr("disabled","disabled");	
			}
		}
		else
		{
			tbEmail.addClass("tskInputError");
			tbEmail.val("手机号码不能为空！");
			btnOk.attr("disabled","disabled");
		}		
	});
	tbEmail.focus(function(){
		tbEmail.val(tbEmail.data("value"));
	});
	
	//////++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	btnOk.click(function(){		
		var tbEmailVal=tbEmail.val();
		if(tbEmailVal!="")
		{
			if(tbEmailVal.length!=11)
			{				
				tbEmail.addClass("tskInputError");
				tbEmail.val("手机号码长度必须为11位！");	
				return false;						
			}
		}
		else
		{
			tbEmail.addClass("tskInputError");
			tbEmail.val("手机号码不能为空！");
			return false;				
		}
	});
});