

String.prototype.Trim = function()
{return this.replace(/(^\s*)|(\s*$)/g,"");} 
function OnLogin()
{ 
			//判断用户名

			var txtUserCode = document.getElementById('txtUserCode');
			if(txtUserCode.value.Trim()==''){
				 alert('请输入用户名');
				txtUserCode.focus();
				return false;
			}
			/* if($("chkremerm").checked)
			 {
			      setCookie("d_remerber",txtUserCode.value.Trim())
			 }
			 else
			 {
			   Deletecookie("d_remerber");
			 }*/
			//判断登录密码
			var txtUserPwd = document.getElementById('txtUserPwd');
			if(txtUserPwd.value.Trim()==''){
				alert('请输入密码');
				txtUserPwd.focus();
				return false;
			} 
			//用Ajax校验用户登录存在安全隐患，应该在用户名不存在，或者密码错误，或者验证码错误时，重新生成验证码

			var backUrl = '<%=backUrl%>';
		 
			var reLogin = Credit.Clwh.Web.AjaxMethods.AjaxUser.UserLoginNoVAciton(txtUserCode.value,txtUserPwd.value,backUrl).value;
			var reArr = reLogin.split('|'); //null,undifend,''
			if(reArr.length>0)
			{
				if(reArr[0]=='true')
				{
					//alert(reArr[1]);
					window.location.href=reArr[1];
				}
				else
				{
					if(reArr[1]=='1')
					{
						document.getElementById('spanValidata').innerText='验证码错误';
						txtValidata.select();
						txtValidata.focus();
						return false;
					}
					if(reArr[1]=='2'){
						document.getElementById('spanUserCode').innerText='用户名不存在';
						txtUserCode.focus();
						return false;
					}
					if(reArr[1]=='3'){
						document.getElementById('spanUserPwd').innerText='密码错误';
						txtUserPwd.focus();
						return false;
					}
				}
			}
			else{
				alert("登录失败，请重新尝试!");
				return false;
			}
			
			return false;
			
		}
		
		function OnKeyPressLogin(){
			if(event.keyCode==13){
				return OnLogin();
			}
			
			//return false;
		}  
	  function   setCookie(name,value) 
	  {
			 var   Days   =   30;   //此   cookie   将被保存   30   天 
			 var   exp     =   new   Date();         
			 exp.setTime(exp.getTime()   +   Days*24*60*60*1000); 
			 document.cookie   =   name   +   "= "+   escape(value)   + ";expires= "+   exp.toGMTString();
		}  

		function getCookie(objName)
		{//获取指定名称的cookie的值 
			 var arrStr = document.cookie.split("; "); 
			 
			 for(var i = 0;i<arrStr.length;i++)
				 {   
					 var temp = arrStr[i].split("="); 
			 
				      if(temp[0] == objName) 
						   {
								 return unescape(temp[1]);
					    	}
					    
				 }
				 return 0;
		 }
	 
		  function Deletecookie (name) 
		  {  //删除名称为name的Cookie  
			 var exp = new Date();    
			  exp.setTime (exp.getTime() - 1);    
			  var cval = getCookie (name);    
			 document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();  
		  }   
		   function C_IsBuys(v)
		    { 
		     var restult=Credit.Clwh.Web.AjaxMethods.AjaxUser.IsBuys(v).value; 
		     if(restult==-1){
		        window.location.href="../UserLogin.aspx?backUrl=http://www.51dscj.com/class/SingUp.aspx?ID="+v;
		       }
		     else if(restult==0){ window.location.href="/class/SingUp.aspx?ID="+v;}
		     else if(restult==1) {alert("您已经报名了此课程，不能重复报名!"); }
		       else if(restult==2){alert("您不能购买自己的课程！")}
		   }
		   function C_IsLogin()
		   {
			 var restult=Credit.Clwh.Web.AjaxMethods.AjaxUser.IsLogin().value;  
			 return restult;
		   } 
		   function C_GetUserLogInfo()
		   {
		       var restult=Credit.Clwh.Web.AjaxMethods.AjaxUser.GetUserLogInfo().value;  
		       return restult;
		   }
		 