﻿var icon = '<img src="js/icon2.gif" width="22" height="22" border="0" align="absmiddle">';
var icon2='<img src="js/icon3.gif" width="22" height="22" border="0" align="absmiddle">';
var ns = ["usr","pwd","repwd","eml","name","mobile"];
function WriteFlash(flash,_width,_height) {
document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"" + _width + "\" height=\"" + _height + "\">");
document.writeln("   <param name=\"movie\" value=\"" + flash + "\" />");
document.writeln("   <param name=\"quality\" value=\"high\" />");
document.writeln("   <param name=\"wmode\" value=\"transparent\" />");
document.writeln("   <param name=\"menu\" value=\"false\" />");
document.writeln("   <embed src=\"" + flash + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + _width + "\" height=\"" + _height + "\" wmode=\"transparent\"></embed>");
document.writeln("</object>");
}

function Vote(i){
		 var url = "Vote.asp?userid="+i+"&timeStamp="+ new Date().getTime();
     	 var myAjax = new Ajax.Request(url,{method:'get',onSuccess:function(originalRequest){ var result = originalRequest.responseText;
		  var result_old=result.split("#")[1];
		  var result1=result_old.split(",")[0];
		  var result2=result_old.split(",")[1];
          if(result1=="1") {
		  alert('请登录后再投票！')
		  return;
		  }	
		  else if(result1=="2")	{
		  alert('每天最多可以给5个宝宝投票！');
		  return;
		  }
		  else if(result1=="3")	{
		  alert('每天只能给一个宝宝投10票！');
		  return;
		  }
		  else if(result1=="7")	{
		  alert('投票时间间隔过短！');
		  return;
		  }
		  else if(result1=="4")	{

		   alert('谢谢您的投票！')
		   $("ssc"+i).innerHTML=result2;

		  }

}});
}

var checkusername = false;
var checkuseremail = false;
var checkusercode = false;
function checkka(obj)
{   //alert(obj);
	usrInput=obj.usrInput.value;
	pwdInput=obj.pwdInput.value;
	repwdInput=obj.repwdInput.value;
	emlInput=obj.emlInput.value;
	nameInput=obj.nameInput.value;
	mobileInput=obj.mobileInput.value;

		  

	if(!checkUsr(usrInput)) {
		
		obj.usrInput.focus();
		return false;
	}
			  	if (!checkusername)
	  {
	document.getElementById("usrInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0"></td><td>该用户已存在,请您更换用户名！</td></tr></table>';
	  		//obj.usrInput.focus();
		     return false;
		  }
		  

	if(!checkPwd(pwdInput)) {
		obj.pwdInput.focus();
		return false;
	}
	if(!checkPwd2(repwdInput)) {
		obj.repwdInput.focus();
		return false;
	}
	
	if(!checkEml(emlInput)) {
		obj.emlInput.focus();
		return false;
	}
//		if (!checkuseremail)
//	  {
//	document.getElementById("emlInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0"></td><td>该邮箱已存在，请您更换其它邮箱！</td></tr></table>';
//	  		//obj.emlInput.focus();
//		     return false;
//		  }
//
	if(!checkName(nameInput)) {
		obj.nameInput.focus();
		return false;
	}
    if (!checkMobile(mobileInput)) {
		
	    obj.mobileInput.focus();
		return false;
	}
		if (!checkusercode)
	  {
	document.getElementById("checkcodeInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0"></td><td>验证码输入错误！</td></tr></table>';
	  		//obj.emlInput.focus();
		     return false;
		  }
		  

	//alert("ssssssss");
		obj.submit();
		 
}
function changeUsr(){
	if($("checkBtn").disabled) $("checkBtn").disabled = false;		
}
function checkUsr(s){		
	//var ma = ["用户名（3-16位）！","用户名由数字、英文、下划线、中杠线组成！","用户名不能为数字"];
	
	if (document.reg.username.value==""){
	            document.getElementById("usrInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0"></td><td>用户名不能为空！</td></tr></table>';
		return false;
	}
	if(!limitLen(s,4,20)){
	            document.getElementById("usrInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0"></td><td>用户名（4-20位）！</td></tr></table>';
		return false;
	}
	if(!hasAccountChar(s)){
	 document.getElementById("usrInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>用户名由数字、英文、下划线、中杠线组成！</td></tr></table>';
		return false;
	}
	if(isNumber(s)){
	 document.getElementById("usrInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0"></td><td>用户名不能为数字！</td></tr></table>';
		return false;
	}
	 document.getElementById("usrInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
	return true;
}
function checkPwd(s){
	//var ma = ["密码（4-20位）！","密码不能包含中文或全角符号！","两次输入的密码不一致！"];
	if(!limitLen(s,4,20)){
	    document.getElementById("pwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>密码（4-20位）！</td></tr></table>';
		return false;
	}
	if(hasChineseChar(s)){
	    document.getElementById("pwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>密码不能包含中文或全角符号！</td></tr></table>';
		return false;
		return false;
	}
	if(limitLen($F("repwdInput"),4,20)){
		if(trim($F("repwdInput")) == trim(s)){
	    document.getElementById("pwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
	    document.getElementById("repwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
			return true;
		}else{
	    document.getElementById("pwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>两次输入的密码不一致！</td></tr></table>';
			return false;
		}
	}
	    document.getElementById("pwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
	return true;
}
function checkPwd2(s){
	//var ma = ["确认密码（4-20位）！","密码不能包含中文或全角符号！","两次输入的密码不一致！"];
	if(!limitLen(s,4,20)){
	    document.getElementById("repwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>确认密码（4-20位）！</td></tr></table>';
		return false;
	}
	if(hasChineseChar(s)){
	    document.getElementById("repwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>密码不能包含中文或全角符号！</td></tr></table>';
		return false;
	}
	if(limitLen($F("pwdInput"),4,20)){
		if(trim($F("pwdInput")) == trim(s)){
	    document.getElementById("pwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
	    document.getElementById("repwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
			return true;
		}else{
	    document.getElementById("repwdInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>两次输入的密码不一致！</td></tr></table>';
			return false;
		}
	}
	showInfo("repwd");
	return true;
}
function checkCpwd(s){
	var ma = ["超级密码（5-16位）！","密码不能包含中文或全角符号！","超级密码不能为数字"];
	if(!limitLen(s,5,16)){
		showInfo("cpwd",ma[0]);
		return false;
	}
	if(hasChineseChar(s)){
		showInfo("cpwd",ma[1]);
		return false;
	}
	if(isNumber(s)){
		showInfo("cpwd",ma[2]);
		return false;
	}
	showInfo("cpwd");
	return true;
}
function checkEml(s){
	//var ma = ["请输入常用邮件！","邮件格式不正确！"];
	if(s.length < 5){
	    document.getElementById("emlInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>请输入常用邮件！</td></tr></table>';
		return false;
	}
	if(!isEmail(s)){
	    document.getElementById("emlInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>邮件格式不正确！</td></tr></table>';
		return false;
	}
	    document.getElementById("emlInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
	return true;
}
//function checkTelphone(s){
//	var ma = ["请输入常用电话号码！","电话号码格式不正确！"];
//	if(!limitLen(s,5,16)){
//		showInfo("tel",ma[0]);
//		return false;
//	}
//	if(!isTelphone(s)){
//		showInfo("tel",ma[1]);
//		return false;
//	}
//	showInfo("tel");
//	return true;
//}
function checkMobile(s){
	//var ma = ["请输入常用电话号码！","电话号码格式不正确！"];
	if(!limitLen(s,8,15)){
	    document.getElementById("mobileInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>手机号码位数不对！</td></tr></table>';
		return false;
	}
	if(!isNumber(s)){
	    document.getElementById("mobileInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>手机号码格式不对！</td></tr></table>';
		return false;
	}
	    document.getElementById("mobileInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
	return true;
}

function checkName(s){
	//var ma = ["请输入常用电话号码！","电话号码格式不正确！"];
	if(!limitLen(s,2,10)){
	    document.getElementById("NameInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>真实姓名[2-10]位！</td></tr></table>';
		return false;
	}
	if(isNumber(s)){
	    document.getElementById("NameInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>真实姓名不能为数字！</td></tr></table>';
		return false;
	}
	    document.getElementById("NameInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>输入正确！</td></tr></table>';
	return true;
}


function showInfo(n,s){
	var fdo = $(n+"FrameDiv");
	var ido = $(n+"InfoDiv");
	if(typeof s == 'undefined'){
		fdo.className = "FrameDivPass";
		ido.innerHTML = icon2+"填写正确！";
	}else{
		fdo.className = "FrameDivWarn";
		ido.innerHTML = icon + s;
	}
}
  function initPage(){
	for(var i=0;i<ns.length;i++){
		$(ns[i]+"Input").value = "";
	}
}
 function createxmlhttprequest(){
		var A=null; 
	 try { 
		 A=new ActiveXObject("Msxml2.XMLHTTP");
	 } 
	 catch(e) { 
		 try { 
		 A=new ActiveXObject("Microsoft.XMLHTTP");
	 } 
	 catch(oc) { 
		 A=null;
	 } 
	 } 
	
	 if ( !A && typeof XMLHttpRequest != "undefined" ) { 
		 A=new XMLHttpRequest();
	 } 
	 return A;

 }
    function TrueCheck(URL,Parem)
    {   
	   	if($("userName").value==""){
		alert('请填写用户名');
	
		return;
		
	}else if(!limitLen($("userName").value,4,12)){
		alert('用户名长度应该大于等于4小于等于12');
		
		return;
	}
	    var xmlhttp=createxmlhttprequest();
        xmlhttp.open('get',URL+'?'+Parem,true);
        xmlhttp.onreadystatechange=function()
        {				    
		   if(xmlhttp.readyState==4)
            {
                if(xmlhttp.status==200)
                {    
                    if(xmlhttp.responseText== "1")
                    {   
						alert('此用户名已经被占用！');
						return false;
                     }
					else if (xmlhttp.responseText== "0")
                    {
						//alert('恭喜您，可以用此用户名注册！');
				  	   return true;
                    }
                }
            }
        }
        xmlhttp.send(null);
		 
    }
    function CodeCheck()
    {   
	 
        var xmlhttp=createxmlhttprequest();
        var checkCode=document.getElementById('checkcodeInput');
         xmlhttp.open('get','CheckCodeIs.asp?checkCode='+escape(checkCode.value),true);
        xmlhttp.onreadystatechange=function()
        {
            if(xmlhttp.readyState==4)
            {
            
                if(xmlhttp.status==200)
                {    
				    //alert(xmlhttp.responseText);
                    if(xmlhttp.responseText== "1")
                    {   
document.getElementById("checkcodeInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0"></td><td>验证码输入错误！</td></tr></table>';

                         return false;
                     }
                    else
                    {
						
						document.getElementById("checkcodeInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0"></td><td>填写正确！</td></tr></table>';
                    checkusercode = true;
 	                return true;
                    }
                }
            }
        }
        xmlhttp.send(null);
		 
    }

function checkemail()
    {
			if (!checkEml($("emlInput").value))
	     {
		   return false;
		 }

        var xmlhttp=createxmlhttprequest();
        var email=document.getElementById('emlInput');
        xmlhttp.open('get','CheckUserEmail.asp?email='+email.value,true);
        xmlhttp.onreadystatechange=function()
        {
            if(xmlhttp.readyState==4)
            {
            
                if(xmlhttp.status==200)
                {
                    if(xmlhttp.responseText== "1")
                    {   
					   	    document.getElementById("emlInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon2.gif" width="22" height="22" border="0" ></td><td>该邮箱已存在，请您更换其它邮箱！</td></tr></table>';

                         return false;
                     }
                    else
                    {
				 document.getElementById("emlInfoDiv").innerHTML='<table cellSpacing=0 cellPadding=0 border=0><tr><td><img src="js/icon3.gif" width="22" height="22" border="0" ></td><td>恭喜您，此邮箱可以使用！</td></tr></table>';
				checkuseremail = true;
				return true;
				
                    }
                }
            }
        }
        xmlhttp.send(null);
    }
function userLogin(userName,passWord){
		if(userName==""||passWord==""){
				alert('请将登陆信息填写完整！');
				return false;
			}
	    var xmlhttp=createxmlhttprequest();
        xmlhttp.open('get','userLogin.asp?userName='+escape(userName)+'&passWord='+escape(passWord),true);
        xmlhttp.onreadystatechange=function()
        {
            if(xmlhttp.readyState==4)
            {
            
                if(xmlhttp.status==200)
                {    
                    if(xmlhttp.responseText!= "-1"){   
						$("lgBefore").style.display="none";
						$("lgAfter").style.display="";
						$("tdName").style.textAlign="center";
						$("tdName").innerHTML="<a href='geren.asp?personName="+userName+"' title='进入我的个人照片集' target='_blank'><font color='#FF0000'>"+userName+"</font></a>,欢迎您";
						$("tdRecord").style.textAlign="center";
						$("tdRecord").innerHTML="您现在的积分:<b>"+xmlhttp.responseText+"</b>分";	
					}
                    else{
					  alert('登陆失败请重试');	
                    }
                }
            }
        }
        xmlhttp.send(null);
	}
function sscLogin(username,password) //本站登录
 {     
  
        var url = "/2008/flashuser.asp?userName="+username+"&passWord="+password+"&timeStamp="+ new Date().getTime();
     	 var myAjax = new Ajax.Request(url,{method:'get',onSuccess:function(originalRequest){var result = originalRequest.responseText;
		 //alert(result);

}});

 }

function bbsLogin(username,password) //论坛登录
 {     
  
         var url = "../login.asp?action=chk&username="+username+"&password="+password+"&CookieDate=1&timeStamp="+ new Date().getTime();
     	 var myAjax = new Ajax.Request(url,{method:'get',onSuccess:function(originalRequest){var result = originalRequest.responseText;
		 //alert(result);

}});

 }
 
function netLogin(username,password) //net登录
 {     
  
         var url = "/babyStar/netLogin.aspx?userName="+username+"&passWord="+password+"&timeStamp="+ new Date().getTime();
     	 var myAjax = new Ajax.Request(url,{method:'get',onSuccess:function(originalRequest){var result = originalRequest.responseText;
		 //alert(result);

}});

 }
 
 function bbsLogout() //注销bbs登录
 {     
        var url = "../logout.asp?timeStamp="+ new Date().getTime();
     	 var myAjax = new Ajax.Request(url,{method:'post',onSuccess:function(originalRequest){var result = originalRequest.responseText;
		 //alert(result);

}});

 }



 function createxmlhttprequest()
 {
	var A=null; 
	 try { 
		 A=new ActiveXObject("Msxml2.XMLHTTP");
	 } 
	 catch(e) { 
		 try { 
		 A=new ActiveXObject("Microsoft.XMLHTTP");
	 } 
	 catch(oc) { 
		 A=null;
	 	} 
	 } 
	
	 if ( !A && typeof XMLHttpRequest != "undefined" ) { 
		 A=new XMLHttpRequest();
	 } 
	 return A;

 }