﻿String.prototype.trim=function(){return this.replace(/(\s*$)/g, ""); }
function webservice(url, callback, pars)
{
    $.ajax({
        data: pars,
        url: url,
        type: "POST",
        contentType: "application/json;utf-8",
        dataType: 'json',
        cache: false,
        success: function(json){
            callback(json.d);
        },
        error:function(xml,status){
            if(status=='error'){
                try{
                    var json = eval('(' + xml.responseText + ')');
                    alert(json.Message + '\n' + json.StackTrace);
                }catch(e){}
            }else{
                alert(status);
            }
        },
        beforeSend:function(xml){
            if(!pars)  xml.setRequestHeader("Content-Type", "application/json;utf-8");
        }
    });
}


var PasswordStrength ={
					Level : ["极佳","较强","一般","较弱","太短"],
					LevelValue : [10,7,5,3,0],//强度值
					Factor : [1,2,5],//字符加数,分别为字母，数字，其它
					KindFactor : [2,5,7],//密码含几种组成的加数 
					Regex : [/[a-z]+|[A-Z]+|\d+/g,/[a-zA-Z0-9]+/g,/[\w\W]+/g] //字符正则数字正则其它正则
					}
				PasswordStrength.StrengthValue = function(pwd)
				{
				    var strengthValue = 0;
				    if(pwd.length<5) return 0;
				    if(pwd.length<7) return 4;
				    if(/^[\d]+$/g.test(pwd) || /^[a-z]+$/g.test(pwd)|| /^[A-Z]+$/g.test(pwd)){
				        return 6;
				    }else if(/^[a-zA-Z0-9]+$/g.test(pwd)){
				        return 8;
				    }else if(/[^a-zA-Z0-9]+/g.test(pwd)){
				        return 12;
				    }else{
				        return 3;
				    }
				    
					/*
					var ComposedKind = 0;
					if(pwd.length<5)
					{
					    return 0;
					}
					for(var i = 0 ; i < this.Regex.length;i++)
					{
						var chars = pwd.match(this.Regex[i]);
						if(chars != null)
						{
							strengthValue =this.Factor[i];
							ComposedKind ++;
						}
					}
					strengthValue += this.KindFactor[ComposedKind];
					return strengthValue;
					*/
				} 
				PasswordStrength.StrengthLevel = function(pwd)
				{
					var value = this.StrengthValue(pwd);
					for(var i = 0 ; i < this.LevelValue.length ; i ++)
					{
						if(value >= this.LevelValue[i] )
							return this.Level[i];
					}
				}
				function loadinputcontext(o)
				{
				   var showmsg =PasswordStrength.StrengthLevel(o.value);
				   switch(showmsg)
				   {
					  case "太短": showmsg+=" <img src='images/level/1.gif' width='95' height='15' />";break;
					  case "较弱": showmsg+=" <img src='images/level/2.gif' width='95' height='15' />";break;
					  case "一般": showmsg+=" <img src='images/level/3.gif' width='95' height='15' />";break;
					  case "较强": showmsg+=" <img src='images/level/4.gif' width='95' height='15' />";break;
					  case "极佳": showmsg+=" <img src='images/level/5.gif' width='95' height='15' />";break;
				   }
				   $("#showmsg").html(showmsg);
				}
				function htmlEncode(source, display, tabs)
				{
					function special(source)
					{
						var result = '';
						for (var i = 0; i < source.length; i++)
						{
							var c = source.charAt(i);
							if (c < ' ' || c > '~')
							{
								c = '&#' + c.charCodeAt() + ';';
							}
							result += c;
						}
						return result;
					}
					function format(source)
					{
						// Use only integer part of tabs, and default to 4
						tabs = (tabs >= 0) ? Math.floor(tabs) : 4;
						// split along line breaks
						var lines = source.split(/\r\n|\r|\n/);
						// expand tabs
						for (var i = 0; i < lines.length; i++)
						{
							var line = lines[i];
							var newLine = '';
							for (var p = 0; p < line.length; p++)
							{
								var c = line.charAt(p);
								if (c === '\t')
								{
									var spaces = tabs - (newLine.length % tabs);
									for (var s = 0; s < spaces; s++)
									{
										newLine += ' ';
									}
								}
								else
								{
									newLine += c;
								}
							}
							// If a line starts or ends with a space, it evaporates in html
							// unless it's an nbsp.
							newLine = newLine.replace(/(^ )|( $)/g, '&nbsp;');
							lines[i] = newLine;
						}
						// re-join lines
						var result = lines.join('<br />');
						// break up contiguous blocks of spaces with non-breaking spaces
						result = result.replace(/  /g, ' &nbsp;');
						// tada!
						return result;
					}
					var result = source;
					// ampersands (&)
					result = result.replace(/\&/g,'&amp;');
					// less-thans (<)
					result = result.replace(/\</g,'&lt;');
					// greater-thans (>)
					result = result.replace(/\>/g,'&gt;');
					if (display)
					{
						// format for display
						result = format(result);
					}
					else
					{
						// Replace quotes if it isn't for display,
						// since it's probably going in an html attribute.
						result = result.replace(new RegExp('"','g'), '&quot;');
					}
					// special characters
					result = special(result);
					// tada!
					return result;
				}
				
				var profile_username_toolong = "<font color='#ff3366'>× 对不起，您的用户名超过 20 个字符，请重新输入。";
				var profile_username_tooshort = "<font color='#ff3366'>× 对不起，您输入的用户名小于3个字符, 请重新输入。</font>";
				var profile_username_pass = "<font color='#00908E'>√</font>";
				function checkusername(username)
				{
				  if(!username)
				  {
				  $("#checkresult").html(profile_username_tooshort);
				  }
				  else
				  {
				    username=username.trim();
					var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
					if(unlen < 3 || unlen > 20) 
					{
						$("#checkresult").html("<font color='#009900'>" + (unlen < 3 ? profile_username_tooshort : profile_username_toolong) + "</font>");
						return;
					 }
					 if(username.indexOf('<')>=0)
					 {
						$("#checkresult").html("<font color='#009900'>×您输入的用户名含有非法字符！</font>");
						return;
					 }
					 if(username.indexOf('"')>=0)
					 {
						$("#checkresult").html("<font color='#009900'>×您输入的用户名含有非法字符！</font>");
						return;
					 }
					 if(username.indexOf("'")>=0)
					 {
						$("#checkresult").html("<font color='#009900'>×您输入的用户名含有非法字符！</font>");
						return;
					 }
					webservice("http://www.smartshe.com/WebService.asmx/GetResult", function(obj){showcheckresult(obj,username )}, '{type:"checkusername",str:"'+escape(username)+'"}');
					}
				}
				
				var pro_pwd_NotAll="<font color='#ff3366'>× 对不起，您两次输入的密码不一样，请重新输入。</font>";
				function checkupwd(pwd1,pwd2)
				{
				    if(pwd1.trim().length<1)
				    { 
				        $("#showpwd").html("<font color='#ff3366'>× 对不起，请输入密码。</font>");
				    }
				    else if(pwd1.trim().length>0&&pwd2.trim().length<1)
				    {
				        $("#showpwd").html("");
				        $("#showpwd1").html("<font color='#ff3366'>× 对不起，请输入重复密码。</font>");
				    }
				    else
				    {		                
				        if(pwd1.trim()!=pwd2.trim())
				        {
				            $("#showpwd").html(pro_pwd_NotAll);
				            $("#showpwd1").html(pro_pwd_NotAll);
				        }
				        else if(pwd1.trim().length<6||pwd2.trim().length<6)
		                {   
		                    $("#showpwd").html("<font color='#ff3366'>× 对不起，您输入的密码少于六位，请重新输入。</font>");
				            $("#showpwd1").html("<font color='#ff3366'>× 对不起，您输入的密码少于六位，请重新输入。</font>");
		                }
				        else
				        {
				            $("#showpwd").html(profile_username_pass);
				            $("#showpwd1").html(profile_username_pass);
				        }
				    }
				}
				var pro_email_NotAll="<font color='#ff3366'>× 对不起，您输入的Email不符合格式，请检查后重新输入。</font>";

				function checkemail(pwd1)
				{
				    if(pwd1.length>0)
				    {
				        if(!chekemail(pwd1))
				        {
				            $("#EmailErr").html(pro_email_NotAll);
				        }
				        else if(pwd1.indexOf('"')>=0)
				        {
				            $("#EmailErr").html(pro_email_NotAll);
				        }
				        else
				        {
				           webservice("http://www.smartshe.com/WebService.asmx/GetResult", function(obj){showresult(obj,pwd1)}, '{type:"checkemail",str:"'+escape(pwd1)+'"}');
				        }
				    }
				    else
				    {
				        $("#EmailErr").html("<font color='#ff3366'>× 对不起，请输入Email。</font>");
				    }
				}
				
				function chekemail(temail) {  
		    		var pattern = /^([a-zA-Z0-9_-]|.)+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;  
                     if(pattern.test(temail)) {  
                      return true;  
                     }  
                     else {  
                      return false;  
                     }  
                } 
                
                function showresult(obj, email)
				{
					var result = "";					
					if(obj.Result!=null&&obj.Result!=undefined)
					{
					    result=obj.Result;
					}
					if (result == "1")
					{
						$("#EmailErr").html("<font color='#ff3366'>× 对不起，您输入的Email已存在，请重新输入。</font>");
					}
					else if (result == "-1")
					{
						$("#EmailErr").html("<font color='#ff3366'>× 对不起，您输入的Email不符合格式，请检查后重新输入。</font>");
					}
					else
					{
						$("#EmailErr").html(profile_username_pass);
					}
				}
                

				function showcheckresult(obj, username)
				{
					//var res = obj.getElementsByTagName('result');
					var result = "";
					//注销掉DISCUZ的写法改用自己的写法
					/*if (res[0] != null && res[0] != undefined) 
					{
						if (res[0].childNodes.length > 1) {
							result = res[0].childNodes[1].nodeValue;
						} else {
							result = res[0].firstChild.nodeValue;    		
						}
					}
					*/
					if(obj.Result!=null&&obj.Result!=undefined)
					{
					    result=obj.Result;
					}
					if (result == "1")
					{
						$("#checkresult").html("<font color='#ff3366'>× 对不起，您输入的用户名已存在，请重新输入。</font>");
					}
					else if (result == "-1")
					{
						$("#checkresult").html("<font color='#ff3366'>× 对不起，用户名含有非法字符，请重新输入。</font>");
					}
					else
					{
						$("#checkresult").html(profile_username_pass);
					}
				}
				
				function checkSetting()
				{
					if ($('receiveuser').checked)
					{
					$("#showhint").attr("disabled","false");
					}
					else
					{			
						$('showhint').attr("checked","false");
						$("#showhint").attr("disabled","true");
					}
				}
				
				function changmag(obj)
				{
				    if(obj=="not")
				    {
				        $('#txtmag1').css("display","none");
				        $('#txtmag1').val("");
				        $('#txtmag2').css("display","none");
				        $('#txtmag2').val("");
				        $('#txtmag3').css("display","none");
				        $('#txtmag3').val("");
				        $('#txtwarmformag').html("");
				        $('#yzmagtxt').val("");
				    }
				    else if(obj=="dslr")
				    {
				        $('#txtmag1').css("display","inline");
				        $('#txtmag1')[0].focus();
				        $('#txtmag2').css("display","none");
				        $('#txtmag2').val("");
				        $('#txtmag3').css("display","none");
				        $('#txtmag3').val("");
				     $('#txtwarmformag').html("请输入本期《都市丽人》杂志中她时代版面提供的注册识别号。");
					$('#yzmagtxt').val("");

				    }
				    else if(obj=="pw")
				    {
				        $('#txtwarmformag1').html("");
				        $('#txtmag1').css("display","none");
				        $('#txtmag1').val("");
				        $('#txtmag2').css("display","inline");
				        $('#txtmag2')[0].focus();
				        $('#txtmag3').css("display","none");
				        $('#txtmag3').val("");
				        $('#txtwarmformag').html("请输入本期《品位》杂志中她时代版面提供的注册识别号。");
				    }
				    else if(obj=="dsxq")
				    {
				        $('#txtwarmformag1').html("");
				        $('#txtmag1').css("display","none");
				        $('#txtmag1').val("");
				        $('#txtmag2').css("display","none");
				        $('#txtmag2').val("");
				        $('#txtmag3').css("display","inline");
				        $('#txtmag3')[0].focus();
				        $('#txtwarmformag').html("请输入本期《都市心情》杂志中她时代版面提供的注册识别号。"); 
					
				        //$('#yzmagtxt').val("dsxq|0000");$('#txtwarmformag').html("")//;
				    }
				}
				
				function Ismaginnum(obj,txt)
				{
				    if(obj.trim().length==0)
				    {				       
				        if(txt=="dsxq")
				            $('#txtwarmformag').html("×请输入本期《都市心情》杂志中她时代版面提供的注册识别号。"); 
				        else if(txt=="pw")
				            $('#txtwarmformag').html("×请输入本期《品位》杂志中她时代版面提供的注册识别号。"); 
				        else 
				            $('#txtwarmformag').html("×请输入本期《都市丽人》杂志中她时代版面提供的注册识别号。"); 
				         return;
				    }
				    if(obj.trim().length!=5)
				    {				       
				         $('#txtwarmformag').html("×注册识别号错误，请重新填写！");
				         return;
				    }
				    if(/^[a-zA-Z0-9]+$/g.test(obj))
				    { 
				        $('#txtwarmformag').html("");
				        $('#yzmagtxt').val(obj+"|"+txt);
				        return ;
				    }
				    $('#txtwarmformag').html("×注册识别号错误，请重新填写！");
				}
				
				function Smt(obj,yzm)
				{
				    checkusername($("#UName").val());
				    checkupwd($("#Pwd").val(),$("#RePwd").val());
				    checkemail($("#Email").val());
				    if(yzm.length<1)
				    {
				        $("#yzmerr").html("<font color='#ff3366'>× 对不起，验证码不能为空！</font>");
				    }
				    else if(yzm.indexOf('"')>=0)
				    { 
				        $("#yzmerr").html("<font color='#ff3366'>× 对不起，验证码错误！</font>");
				    }
				    else
				    { 
				        $("#yzmerr").html("");
				    }
				    if(!$("#CheckBox1").attr("checked"))
				    {
				        $("#readerr").html("<font color='#ff3366'>× 对不起，请阅读并同意会员须知！</font>");
				    }
				    else
				    {
				        $("#readerr").html("");
				    }
				    var txt=$("#checkresult").html()+$("#showpwd").html()+$("#showpwd1").html()+$("#EmailErr").html()+ $("#yzmerr").html()+$("#readerr").html()+$('#txtwarmformag').html()+$("#MobileErr").html();
				    if(txt.indexOf("×")<0)
				    {				        
				       webservice("http://www.smartshe.com/WebService.asmx/GetYanzheng", function(obj1){yz(obj1)}, '{yzm:"'+yzm+'"}');
				    }
				    
				}
				function yz(obj)
				{
				    if(obj.Isok)
				    {
				        $("#yzmerr").html(profile_username_pass);
				        $("#sub").attr("disabled","true");
				        document.form1.submit();
				    }
				    else
				    {
				        $("#yzmerr").html("<font color='#ff3366'>× 对不起，您输入的验证码错误，请刷新后再试。</font>");
				    }
				}
				
				function login(obj,username,pwd)
				{
				    $("#mess").html("");
				    var remme=$("#remme").attr('checked');
				    var exp=$("input[@type=radio][@name=expires][@checked]").val();
				    var flat=true;
				    var message="";
				    if(username==undefined)
				    {
				        message="用户名";
				        flat=false;
				    }
				    else if(username.length<1)
				    {
				        message="用户名";
				        flat=false;
				    }
				    if(pwd==undefined)
				    {
				        if(message.length<1)
				        {
				            message="密码";
				        }
				        else
				        {
				            message +="、密码";
				        }
				        flat=false;
				    }
				    else if(pwd.length<1)
				    {
				       if(message.length<1)
				        {
				            message="密码";
				        }
				        else
				        {
				            message +="、密码";
				        }
				        flat=false
				    }
				    var allstr=username+pwd+exp+remme;
				    if(allstr.indexOf('"')>=0)
				    {
				         $("#mess").html("<font color='#ff3366'>您提交的数据有误！</font>");
					return;
				    }
				    if(flat)
				    {
				        webservice("http://www.smartshe.com/WebService.asmx/UserLogin", function(obj1){lg(obj1)}, '{username:"'+encodeURIComponent(username)+'",pwd:"'+pwd+'",expires:"'+exp+'",remme:"'+remme+'"}');
				    }
				    else
				    {
				        $("#mess").html("<font color='#ff3366'>"+message+"不能为空！</font>");
				    }
				}
				function lg(obj)
				{
				    var result = "";
				    var isok=true;
				    if(obj.Result!=null&&obj.Result!=undefined)
				    {
				        result=obj.Result;
				        isok=obj.Isok;
					}
					if (result == "-1")
					{
						$("#mess").html( "<font color='#ff3366'>您输入的Email不符合格式，请检查后重新输入。</font>");
					}
					else if(result=="用户名不存在")
					{
					    $("#mess").html("<font color='#ff3366'>您输入的用户名不存在，请检查后重新输入。</font>");
					    $("#pwd").val("");
					}
					else if(obj.Isok)
				    {
				        $("#sub").attr("disabled","true");
				        if(document.referrer!="http://www.smartshe.com/err.html"&&document.referrer!="http://www.smartshe.com/Register.aspx"&&document.referrer.indexOf("ValidateEmail.aspx")<0&&document.referrer.indexOf("usercpnewpassword.aspx")<0&&document.referrer!="")
			    	        window.location=document.referrer;
				        else
				            window.location.replace('my/my.aspx');
				    }
				    else
				    {
				        $("#pwd").val("");
				        $("#mess").html("<font color='#ff3366'>用户名或密码错误，请检查后重新输入。</font>");
				    }
				}
				
				function validateEmail(email,uid)
				{   
				    var tmpemail=$("#Email").val();
				    if(email!=tmpemail)
				    {
				        checkemail(tmpemail);
				    }
				    var jystr=$("#EmailErr").html();
				    if(jystr.indexOf("×")<0)
				    {
				        $("#EmailErr").html("");
				      webservice("http://www.smartshe.com/WebService.asmx/UpdateSendEmail", function(obj1){sendend(obj1)}, '{uid:"'+uid+'",email:"'+tmpemail+'"}');
				    }
				}
				
				function sendemail(email)
				{
				    if(email.indexOf('"')>=0)
				    {
				    	return ;
				    }
				    if(email.indexOf("'")>=0)
				    {
				    	return ;
				    }
				    webservice("http://www.smartshe.com/WebService.asmx/SendEmail", function(obj1){sendend(obj1)}, '{email:"'+email+'"}');
				}
				
				function sendend(obj)
				{
				    var result = "";
				    var isok=true;
				    if(obj.Result!=null&&obj.Result!=undefined)
				    {
				        result=obj.Result;
				        isok=obj.Isok;
					}
					else
					    isok=false;
					if(isok)
					{
					    if (result == "1")
					{
						$("#EmailErr").html("<font color='#ff3366'>× 对不起，您输入的Email已存在，请重新输入。</font>");
					}
					else if (result == "-1")
					{
						$("#EmailErr").html("<font color='#ff3366'>× 对不起，您输入的Email不符合格式，请检查后重新输入。</font>");
					}
					else
					{
					    window.location.replace('http://www.smartshe.com/my/succeed.aspx?action=email');
					    }
					}
					else
					{    
					   sAlert('激活信发送失败！请稍后再试！');
					}
				}
				
function   sAlert(str){    
    var   msgw,msgh,bordercolor;    
    msgw=400;//提示窗口的宽度    
    msgh=120;//提示窗口的高度    
    titleheight=25   //提示窗口标题高度    
    bordercolor="#333333";//提示窗口的边框颜色    
    titlecolor="#999999";//提示窗口的标题颜色     
    var   sWidth,sHeight;    
   // sWidth=document.body.offsetWidth;//浏览器工作区域内页面宽度    
    sWidth=screen.Width;
    //sHeight="100%";
    sHeight=Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) ;
    sHeight=Math.max(document.documentElement.scrollTop,sHeight) +"px";    
    var   bgObj=$("<div   id='bgDiv'   style='position:absolute;   top:0;   background:#666;filter:alpha(opacity=50);opacity:0.50;   left:0;   width:100%; height:100%;   z-index:10000;'></div>");//创建一个div对象（背景层）      
    $("body").append(bgObj);//在body内添加该div对象    
    $("#bgDiv").css("width",sWidth);        
    $("#bgDiv").css("height",sHeight);
    var msgObj=$("<div   id='msgDiv'   align='center'   style='background-color:white;   border:1px   dotted  #666666;   position:absolute;   left:50%;   top:50%;   font:12px/1.6em   Verdana,Geneva,Arial,Helvetica,sans-serif; width:400px;   height:100px;   text-align:center;  line-height:25px;   z-index:100001;'> </div>");//创建一个div对象（提示框层）    
    $("body").append(msgObj);
	$("#msgDiv").css("margin-left",0-msgw/2+"px")
    $("#msgDiv").css("margin-top",-75+document.documentElement.scrollTop+"px");   
    var title=$("<h4 id='msgTitle' align='right'   style='margin:0; width:375px;    background-color:white;   filter:progid:DXImageTransform.Microsoft.Alpha(startX=20,   startY=20,   finishX=100,   finishY=100,style=1,opacity=75,finishOpacity=100);   opacity:0.75;    height:19px;   color:titlecolor;   cursor:pointer; margin-left:23px;'  onclick='removeObj();'> <img alt='关闭' src='http://www.smartshe.com/images/xx.gif'/></h4>"); 
    var   txt=$(" <p   style='margin:1em   0;' style='color:#ff3366;'   id='msgTxt'>  </p>");     
    $("#msgDiv").append(title);  
    $("#msgDiv").append(txt);//在提示框div中添加提示信息对象txt 
    $("#msgTxt").html(str);//来源于函数调用时的参数值  
}


function   sAlertgourl(str,gotourl){  
    var   msgw,msgh,bordercolor;    
    msgw=400;//提示窗口的宽度    
    msgh=120;//提示窗口的高度    
    titleheight=25   //提示窗口标题高度    
    bordercolor="#333333";//提示窗口的边框颜色    
    titlecolor="#999999";//提示窗口的标题颜色     
    var   sWidth,sHeight;    
   // sWidth=document.body.offsetWidth;//浏览器工作区域内页面宽度    
    sWidth=screen.Width;
    //sHeight="100%";
    sHeight=Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) ;
    sHeight=Math.max(document.documentElement.scrollTop,sHeight) +"px";  
    var   bgObj=$("<div   id='bgDiv'   style='position:absolute;   top:0;  background:#666;filter:alpha(opacity=50);opacity:0.50;   left:0;   width:100%; height:100%;   z-index:10000;'></div>");//创建一个div对象（背景层）      
    $("body").append(bgObj);//在body内添加该div对象    
    $("#bgDiv").css("width",sWidth);        
    $("#bgDiv").css("height",sHeight);
    var msgObj=$("<div   id='msgDiv'   align='center'   style='background-color:white;   border:1px   dotted  #666666;   position:absolute;   left:50%;   top:50%;   font:12px/1.6em   Verdana,Geneva,Arial,Helvetica,sans-serif; width:400px;   height:100px;   text-align:center;  line-height:25px;   z-index:100001;'> </div>");//创建一个div对象（提示框层）    
    $("body").append(msgObj);
	$("#msgDiv").css("margin-left",0-msgw/2+"px")
    $("#msgDiv").css("margin-top",-75+document.documentElement.scrollTop+"px");   
    var title=$("<h4 id='msgTitle' align='right'   style='margin:0; width:375px;    background-color:white;   filter:progid:DXImageTransform.Microsoft.Alpha(startX=20,   startY=20,   finishX=100,   finishY=100,style=1,opacity=75,finishOpacity=100);   opacity:0.75;    height:19px;   color:titlecolor;   cursor:pointer; margin-left:23px;'> <img alt='关闭' src='http://www.smartshe.com/images/xx.gif'/></h4>"); 
    var   txt=$(" <p   style='margin:1em   0;' style='color:#ff3366;'   id='msgTxt'>  </p>");     
    $("#msgDiv").append(title);  
    $("#msgDiv").append(txt);//在提示框div中添加提示信息对象txt 
    $("#msgTxt").html(str);//来源于函数调用时的参数值 
    $("#msgTitle").click(function   remove(url)
{//点击标题栏触发的事件 
    //alert('1212');    
    $('#msgDiv').remove();
    $("#msgTitle").remove();      
    $("#msgDiv").remove();
    $("#bgDiv").remove(); 
	 window.location.replace(gotourl);
    });   
}
    function   removeObj()
    {   //点击标题栏触发的事件 
        //alert('1212');    
        $('#msgDiv').remove();
        $("#msgTitle").remove();      
        $("#msgDiv").remove();
        $("#bgDiv").remove(); 
    } 

function checkall()
{
    $(':checkbox').attr('checked','checked');
}

function Inverseall()
{
    $(':checkbox').each(function(i){
            if(this.checked)
            { 
            this.checked=false;
            }
            else
            {
             this.checked=true;
            }
        });
}

 function delchk(){
        var flag=false;
        $(':checkbox').each(function(i){
            if(this.checked) flag=true;
        });
        if(!flag){
            alert('请选择要删除的对象');
        }else{
            flag=confirm("您确定要删除这些对象么？");
        }
        return flag;
    }
    
    
    function chhk(yzm)
    {       
        if(yzm.length<1)
        {
       // $("#err").val("对不起！验证码不能为空！");
            $("#err").html("对不起！验证码不能为空！");
            return false;
        }
        if(yzm.indexOf('"')<0)
        {
       webservice("http://www.smartshe.com/WebService.asmx/GetYanzheng", function(obj1){yzz(obj1)}, '{yzm:"'+yzm+'"}');
       }
   }
    
    function yzz(obj)
    {
	    if(obj.Isok)
	    {
	       $("#err").html("");
	        return true
	    }
	    else
	    {
	        $("#err").html("您输入的验证码错误，请刷新后再试！");
	        return false;
	    }
	}
	
	function isok()
	{
	    if($("#theyzm").val()=="")
	    {
	        $("#err").html("对不起！验证码不能为空！");
	         return false;
	    }
	    if($("#err").html()!="")
	        return false;
	    return true;
	}
	
	function existsname(name)
	{
	    if(name.length<1)
        {
            $("#err").html("对不起！用户名不能为空！");
            return false;
        }
       webservice("http://www.smartshe.com/WebService.asmx/Exists", function(obj1){exist(obj1)}, '{username:"'+name+'"}');
   }
	
	function exist(obj)
    {
	    if(obj.Isok)
	    {
	       $("#err").html("");
	        return true
	    }
	    else
	    {
	        $("#err").html("用户名不存在！");
	        return false;
	    }
	}
	
	function isgetpwdok()
	{
	    if($("#err").html()!="")
	        return false;
	    if($("#usname").val()=="")
	    {
	        $("#err").html("对不起！用户名不能为空！");
	         return false;
	    }
	    if($("#theyzm").val()=="")
	    {
	        $("#err").html("对不起！验证码不能为空！");
	         return false;
	    }
	    chhk($("#theyzm").val());
	    if($("#err").html()!="")
	        return false;	  
	    existsname($("#usname").val());
	    if($("#err").html()!="")
	        return false;	        
	    return true;
	}
	
	function checknewpwd(pwd1,pwd2)
	{
	    if(pwd1.length<1)
	    { 
	        $("#err").html("对不起，密码不能为空！");
	    }
	    else if(pwd1.length>0&&pwd2.length<1)
	    {
	        $("#err").html("对不起，重复密码不能为空！");
	    }
	    else
	    {		                
	        if(pwd1!=pwd2)
	        {
	            $("#err").html("对不起，您两次输入的密码不一样，请重新输入！");
	        }
	        else if(pwd1.length<6||pwd2.length<6)
            {   
                $("#err").html("对不起，您输入的密码少于六位，请重新输入！");
            }
	        else
	        {
	            $("#err").html("");
	            $("#err").html("");
	        }
	    }
	}
	
	
	function isnewpwdok()
	{
	    if($("#err").html()!="")
	        return false;
	    if($("#usname").val()=="")
	    {
	        $("#err").html("对不起！用户名不能为空！");
	         return false;
	    }
	    existsname($("#usname").val());
	    if($("#err").html()!="")
	        return false;	
	    checknewpwd($("#Pwd").val(),$("#RePwd").val())   
	    if($("#err").html()!="")
	        return false;	    
	    return true;
	}

				function changmag1(obj) {
				    if (obj == "not") {
				        $('#yzmagtxt').val("");
				    }
				    else {
				        $('#yzmagtxt').val(obj+"|0000");
				    }
				}

// 检查手机号码
				function checkmobile(mobile){
				    if (mobile.length>0){
				        var reg = /^((13[0-9]{9})|((15[0|3|6|7|8|9]|18[8|9])\d{8}))$/;
				        if (!reg.test(mobile))
				            $("#MobileErr").html("<font color='#ff3366'>× 对不起，手机号码不正确。</font>");
				        else
				            webservice("http://www.smartshe.com/WebService.asmx/GetResult", function(obj){showcheckmobileresult(obj,mobile)}, '{type:"checkmobile",str:"'+escape(mobile)+'"}');
				    }
				    else
				        $("#MobileErr").html("");
				}
				
				function chekemail(temail) {  
		    		var pattern = /^([a-zA-Z0-9_-]|.)+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;  
                     if(pattern.test(temail)) {  
                      return true;  
                     }  
                     else {  
                      return false;  
                     }  
                } 
                
                function showcheckmobileresult(obj, mobile)
				{
					var result = "";
					if(obj.Result!=null && obj.Result!=undefined)
					{
					    result=obj.Result;
					}
					if (result == "0")
					{
						$("#MobileErr").html("<font color='#ff3366'>您的手机号码已存在，使用此号码将无法获得额外积分。</font>");
					}
					else if (result == "-1")
					{
						$("#MobileErr").html("<font color='#ff3366'>× 对不起，手机号码含有非法字符，请重新输入。</font>");
					}
					else
					{
						//$("#MobileErr").html(profile_username_pass);
						$("#MobileErr").html('');
					}
				}