﻿// JavaScript Document

/****获根据id获得节点****/
function $(asId) {
	if(document.getElementById(asId)) {
		return document.getElementById(asId);
	}
	else {
		return null;
	}
}
/**判断浏览器类型**/
function isSignupIE(){
   var navigatorName = "Microsoft Internet Explorer";
   var isIE = false;
   if( navigator.appName == navigatorName ){
    isIE = true;    
   } 
   return isIE; 
}
/****获根据name获得节点****/
function getByName(name){
	return document.getElementsByName(name);
}
/***************清除所有表单信息************/
function resetForm(){
	var forms = document.getElementsByTagName("form");
	for(var i=0; i<forms.length; i++){
		forms[i].reset();
	}
}
/*********判断输入是否为空并处理********/
function judgeEmpty(inputId, showId, otherId){
	var inputValue = $(inputId).value;
	if(inputValue == ""){
		if(showId != ""){changeDisplayState(showId, "true");}
		if(otherId != ""){changeDisplayState(otherId, "false");}
	}else{
		if(showId != ""){changeDisplayState(showId, "true");}
		if(otherId != ""){changeDisplayState(otherId, "false");}
	}
}

/********根据类名改变样式*********/
function changeStyle(id, clName){
	$(id).className = clName;
}

/********返回空信息*********/
function isValueEmpty(id){
	var inputValue = $(id).value;
	if(inputValue == ""){return true;}
}

/**********改变显示状态************/
function changeDisplayState(id, bln){
	var objState = $(id).style.display;
	if(bln == "true" && objState == "none")$(id).style.display = "block"; //显示
	else if(bln == "false" && objState != "none")$(id).style.display = "none";//消失
	else if(bln == "auto"){ //状态翻转
		var eleState = $(id).style.display;
		if(eleState == "block")$(id).style.display = "none";
		if(eleState == "none")$(id).style.display = "block";
	}
}

/**********验证名字长度************/
function limitWardLength(chars,limitLen){
	if(chars.length>limitLen)return false; //已超过
	else return true;
}
function limitNameLength(objId,limitLen){
	var obj = document.getElementById(objId);
	if(limitWardLength(obj.value,20)){
		changeDisplayState('yourNameWarm02', 'false');
		return false;
	}else{//截掉
		changeDisplayState('yourNameWarm02', 'true');
		return true;
	}
}
/*************第一步提交时判断各输入的合法性**************/
function judgeYourNameEmpty(){
	var isReturnFalse = true; 
	var inputId = new Array("yourName", "emailAddr", "registPW");
	var displayWarmId = new Array("yourNameWarm", "emailAddrWarm", "registPWWarm");
	var displayRemindId = new Array("yourNameRemind", "emailAddrRemind", "registPWRemind");
	//是否为空判断
	for(var i=0; i<displayWarmId.length; i++){
		if(isValueEmpty(inputId[i])){
			changeDisplayState(displayWarmId[i], 'true');
			changeDisplayState(displayRemindId[i], 'false');
			isReturnFalse = false;
		}
	}
	if(document.getElementById(inputId[2]).value.length < 6 || document.getElementById(inputId[2]).value.length > 20) {
		changeDisplayState(displayWarmId[2], 'true');
		changeDisplayState(displayRemindId[2], 'false');
		sReturnFalse = false;
	}
	//身分判断
	var cvsYourIdRadils = getByName("cvsYourId");
	var tag = false;
	for(var i=0; i<cvsYourIdRadils.length; i++){
		if(cvsYourIdRadils[i].checked){tag = true; break;}
	}
	if(!tag){
		changeDisplayState("cvsYourIdWarm", 'true');
		changeDisplayState("cvsYourIdRemind", 'false');
		sReturnFalse = false;
	}
	//电子邮件合法性判断
	if(!validateEmailAddr("emailAddr")){
		changeDisplayState("emailAddrWarm", 'true');
		changeDisplayState("emailAddrRemind", 'false');	
		sReturnFalse = false;
	}
	return isReturnFalse; //如果验证通不过反回false,否则返回true	
}
/*
  *  checkEmail By SQL_LiuJing
  */

var msCheckEmailNotifyId = "emailAddrWarm"; //  提示框的id值，暂时作为全局变量
var msStep1EmailTag = false; //  状态标志位，记录Email是否已通过验证
var isEmailRemind = false; //yu07.09
var isEmailPageMouseout = false; //yu07.17
//  回调函数
/****验证电子邮箱地址****/
function validateEmailAddr(aeObj){
	var emailAddress = aeObj.value;
	//var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+\.([a-zA-Z0-9_-])+$/i;//XXX@XXX.XXX 才是合格的样
	var pattern = /[^\s]+@[^\s]+\.[^\s]+/i;
	if(!pattern.test(emailAddress)){
		return false;
	}
	return true;
}
function callbackCheckEmail(aoJSON) {
	var loResult = aoJSON;
	if(typeof loResult == 'undefined') { //前端校验失败则直接提交后台校验
		displayError(document.getElementById(msCheckEmailNotifyId), '校验失败', false);
		msStep1EmailTag = true;
	}
		
	switch(loResult.Result) {
		case 0:
			displayError(document.getElementById(msCheckEmailNotifyId), '', false);
			msStep1EmailTag = true;
			break;
		case 1: 
		case 2:
		case 3:
			displayError(document.getElementById(msCheckEmailNotifyId), '邮件地址已被注册，请重新输入或者直接<a href="http://www.jkdykd.com" target="_blank" style="color:#039">登录</a>', true);
			msStep1EmailTag = false;
			break;
		case 4:
			displayError(document.getElementById(msCheckEmailNotifyId), '你的邮箱格式有错误，请重新输入', true);
			msStep1EmailTag = false;
			break;
		case 5:
			displayError(document.getElementById(msCheckEmailNotifyId), '您填写的邮箱地址已经在<a href="http://www.jkdykd.com" style="color:#039">jkdykd.com</a>注册过了，请您用新的邮箱<a href="http://www.jkdykd.com" style="color:#039">注册</a>！', true);
			msStep1EmailTag = false;
			break;
	}
}

//  控制出错信息的显示
function displayError(aeTag, asError, abDisplay) {
	if (abDisplay == true) {
		if(!isEmailRemind){ //yu07.09
			aeTag.style.display = "block";
			aeTag.innerHTML = asError;
			setTimeout(function(){}, 5);	
		}
	}
	else {
		aeTag.style.display = "none";
	}
}

//  检测邮件地址
function checkEmail(aeEmail, asCallback) {
	var asEmail = aeEmail.value;
	displayError(document.getElementById(msCheckEmailNotifyId), "", false);
	var loResult = null;
	/**
	if (asEmail != null && asCallback != null) {
		var aa = validateEmailAddr(aeEmail);
		if(validateEmailAddr(aeEmail)){//接口不稳定的备用方案0725 by yjz
			msStep1EmailTag = true;
			CNMS.loadJsonP("http://ajaxv2.myspace.cn/_Common/AjaxService/SignupSvc.svc/json/CheckEmailExist?email=" + asEmail + "&callback=" + asCallback+"&r="+Math.random());
		}else{
			loResult = window[asCallback]({"Result":4, "Msg":""});
		}
		
		//if (asEmail.indexOf("@") < 0){//原验证 by SOL
		//	loResult = window[asCallback]({"Result":4, "Msg":""});
		//} 
		//else {
			//var emailUrl = "http://ajaxv2.myspace.cn/_Common/AjaxService/SignupSvc.svc/json/CheckEmailExist?email=" + asEmail + "&callback=" + asCallback + "&r={W:random}";
		//	CNMS.loadJsonP("http://ajaxv2.myspace.cn/_Common/AjaxService/SignupSvc.svc/json/CheckEmailExist?email=" + asEmail + "&callback=" + asCallback);
		//}
	}
	*/
}


//  添加上事件句柄
function addEventS(aeTag, asEvt, afHandler){
	if(aeTag == null)return;
	afHandler = afHandler == null ? asEvt+"Handler" : afHandler;
	if(CNMS.isIE){
		aeTag.attachEvent("on"+asEvt,afHandler);
	}else{		
		aeTag.addEventListener(asEvt,afHandler,false);
	}
}
	
/* --------------------------------------------------------- checkEmail Done By SQL --------------------------------------------------------- */
//当某个事件发生时用一个全局变量记录其发生情况次数
var returnRecord_0_mark = 0;/*=全局变量:请用完后将其清0=*/
function returnRecord(num){	//不合法时相应位置0:num的值是1,2,4,8,...即二进制数位上只有一个1 ;为1时表示已填东西
	returnRecord_0_mark &= (~num);
}
function resetRecord(num){//合法时相应位置1
	returnRecord_0_mark |= 	num;
}
function resetPublicVa(publicArg, value){
	return publicArg = value;
}
function judgeStep1Empty(){ //当有必填项没填时返回true
   
	checkName($('yourName'));
	 
	var bEmpty = false; //为false时表示没有空的
	if(isRadiosEmpty('cvsYourId'))returnRecord(4);
	else resetRecord(4)

	if(validateEmailAddr($("emailAddr")))msStep1EmailTag = true;//接口不稳定的备用方案0725 by yjz
	if(!msStep1EmailTag || isChinese($("emailAddr").value))returnRecord(8);
	else resetRecord(8);
	
	var returnRecordMark = returnRecord_0_mark;
	if(returnRecordMark != 15){
		bEmpty = true;
		//不合法时相应位置0:
		for(var i=0; i<4; i++){
			if(!(returnRecordMark & 1)){
				switch(i){
				case 0:changeDisplayState('yourNameWarm', 'true');break;
				case 3:changeDisplayState('emailAddrWarm', 'true');break;
				case 1:{
					changeDisplayState('registPWRemind', 'false');
					changeDisplayState('registPWWarm01', 'true');
				}break;
				case 2:changeDisplayState('cvsYourIdWarm', 'true');break;
				}
			}	
			returnRecordMark >>>=1;
		}	
	}else{
		bEmpty = false;
	}
	if(document.getElementById("checkCode") || document.getElementById("captchError")) {
		if(document.getElementById("checkCode").value=="" || document.getElementById("checkCode").value=="点击获取验证码") {
			bEmpty = true;
			document.getElementById("captchError").style.display = "block";
		}
	}
	//resetPublicVa(returnRecord_0_mark, 0);/*=将全局变量清0=*/
	return bEmpty;
}
/************判断字符串中是否存在中文字符,存在则返回true,否则返回false*************/
function isChinese(asValue){
	var sMatch = /[\u4e00-\u9fa0]+/;
	if(sMatch.test(asValue))return true;
	else return false;
}
/***********判断姓名是否全为空格或&nbsp或不可见字符************/
function checkNameAllSpace(obj){//false是合法的情况
	var bAllApace = false;
	var valueN =  obj.value;
	//var iAfterLen = valueN.replace(/[\s|&nbps;|　]*/i,"").length	;
	var iAfterLen = valueN.replace(/\s*/i,"").replace(/&nbsp;*/i,"").replace(/　*/i,"").length;
	if(iAfterLen == 0) bAllApace = true;
	 
	return bAllApace;
}


/******************* 判断单选框是否为空******************/
function isRadiosEmpty(radioName){
	var radioObj = getByName(radioName);	
	for(var i=0; i<radioObj.length; i++){
		if(radioObj[i].checked)return false;	
	}
	return true;
}

/*************第三步提交时判断各输入的合法性**************/
function isYourSexEmpty(){
	if($('male').checked == false && $('female').checked == false) {
		$('yourSexWarm').style.display = "block";
		returnRecord(1);
	}else{
		$('yourSexWarm').style.display = "none";
		resetRecord(1);
		return true;
	}
	return false;
}
function isYourBirthday(){
	if(checkSelect($('yourBirthdayYear')) && checkSelect($('yourBirthdayMonth')) && checkSelect($('yourBirthdayDay'))) {
		$('ctl00_ctl00_ContentPlaceHolder_ModuleBody_ContentPlaceHolder1_ucStep3_yourBirthdayWarm').style.display = "none";
		resetRecord(2);
		return true;
	}else{
		$('ctl00_ctl00_ContentPlaceHolder_ModuleBody_ContentPlaceHolder1_ucStep3_yourBirthdayWarm').style.display = "block";
		returnRecord(2);
	}
	return false;
}
function isCityEmpty(){
	if((($('settleCountry').value!="" && ($('settleCityName').value!="" && $('settleCountry').value=="CN")) || $('settleCountry').value != "CN")) {
		$('settleCityWarm').style.display = "none";
		resetRecord(4);
		return true;
	}else{
		$('settleCityWarm').style.display = "block";
		returnRecord(4);
	}
	return false;
}
function isYourCompany(){
	if($('yourCompany').value == "") {
		$('ctl00_ctl00_ContentPlaceHolder_ModuleBody_ContentPlaceHolder1_ucStep3_yourCompanyWarm').style.display = "block";
		returnRecord(8);
	}else{
		$('ctl00_ctl00_ContentPlaceHolder_ModuleBody_ContentPlaceHolder1_ucStep3_yourCompanyWarm').style.display = "none";
		resetRecord(8);
		return true;
	}
	return false;
}

function changeStyleNotify(tag){
	if(tag==1){
		$('upLoadPicRemind').style.cssText = "display:none;margin-left:120px;"
	}
}
 

function judgeStep3Empty(){	 //当有必填项有没填时返回true
	var lbValue = isYourSexEmpty();
	lbValue = isYourBirthday() && lbValue;
	lbValue = isCityEmpty() && lbValue;
	if($('yourCompany')!=null) {
		lbValue = isYourCompany() && lbValue;
		if(document.getElementsByName('yourGraduteSchool')[0].value != ""||document.getElementsByName('enterYear')[0].value != "入学年份") {
			lbValue = isYourSchool() && lbValue;
		}
		else {
		}
	}
	else {
		lbValue = isYourSchool() && lbValue;
	}
	return lbValue;
}

function checkSelect(aeP) {
	for(var i=1; i<aeP.options.length; i++) {
		if(aeP.options[i].selected == true) return true;
	}
}


/*********************添加毕业学校信息*********************/
function addGraduteSchool(containerId){
	gsElement = document.createElement("div");
	gsElement.className = "graduteSchoolElement graduteSchoolElementAdd";
	gsElement.innerHTML = "<input type=\"text\" name=\"yourGraduteSchool\" id=\"textfield\" /><select name=\"enterYear\"><option>入学年份</option></select><span class=\"yourGraduteSchoolDel\" onclick=\"delGraduteSchool('cvsGsContainer', this)\"><img src=\"http://xfiles.cdnmyspace.cn/dir/signup/v1/img/all_icons.gif\">删除</span>";
	$(containerId).appendChild(gsElement); 
}
/**************删除本节点的父节点*******************/
function delGraduteSchool(containerId, delObj){										
	var obj = delObj.parentNode;
	$(containerId).removeChild(obj);
}

//  tab页面切换By SQL
function tabChange (aeTab, aeContent, asClassName) {
	if(aeTab == null) {return false;}
	for(var i=0; i<aeTab.childNodes.length; i++) {
		if(aeTab.childNodes[i].nodeValue == null) {
			aeTab.childNodes[i].onclick = cTabChange(aeTab, aeContent, asClassName);
		}
	}

	function cTabChange (aeTab, aeContent, asClassName) {
		return function() {
			var lxTabTitle = new Array();
			var lxTabContent = new Array();
			var tempPosition = 0;
			lxTabTitle = aeTab.childNodes;
			lxTabContent = aeContent.childNodes;
			
			for(var i=0; i<lxTabTitle.length; i++) {
				lxTabTitle[i].className="";
				if(lxTabTitle[i] == this) {
					tempPosition = i;
				}
			}
			
			for(var i=0; i<lxTabContent.length; i++) {
				if(lxTabContent[i].nodeValue == null) {
					lxTabContent[i].style.display="none";
				}
				else {
					
				}
			}
			
			this.className = asClassName;
			lxTabContent[tempPosition].style.display = "block";
			
			lxTabTitle = null;
			lxTabContent = null;
		}
	}
}


  
function hiddenNoSheXiangTou(aeP1, aeP2) {
	aeP1.style.cssText = "display:none";
	aeP2.style.cssText = "display:block;margin-top:5px;text-align:center";
}

function formSubmit(asId) {
	if(document.getElementById(asId).submit()) {
		return true;
	}
	else {
		return false;
	}
}

function subNavHover(aeNav, asCurrentClassName) {
	var lxSubNav3Children = new Array();
	lxSubNav3Children = aeNav.childNodes;
	for(var i=0; i<lxSubNav3Children.length; i++) {
		if(lxSubNav3Children[i].nodeValue == null) {
			lxSubNav3Children[i].onmouseover = onHover();
			lxSubNav3Children[i].onmouseout = onOut();
		}
	}
	
	function onHover() {
		return function() {
			if(this.className.toString().indexOf(asCurrentClassName) == -1) {
				this.style.color = "#005aff";
			}
			else {
				this.style.color = "#fff";
			}
		}
	}
	
	function onOut() {
		return function() {
			if(this.className.toString().indexOf(asCurrentClassName) == -1) {
				this.style.color = "#039";
			}
			else {
				this.className = asCurrentClassName;
				this.style.color = "#fff"
			}
		}
	}
}

//CharMode函数
//测试某个字符是属于哪一类
function CharMode(iN) {
   if (iN>=48 && iN <=57) //数字
    return 1;
   if (iN>=65 && iN <=90) //大写字母
    return 2;
   if (iN>=97 && iN <=122) //小写
    return 4;
   else
    return 8; //特殊字符
}
//bitTotal函数
//计算出当前密码当中一共有多少种模式
function bitTotal(num) {
   var modes=0;
   for (var i=0;i<4;i++) {
    if (num & 1) modes++;
     num>>>=1;
    }
   return modes;
}

//checkStrong函数
//返回密码的强度级别
function checkStrong(sPW) {
   if (sPW.length<6)
    return 0; //密码太短
    var Modes=0;
    for (i=0;i<sPW.length;i++) {
     //测试每一个字符的类别并统计一共有多少种模式
     Modes|=CharMode(sPW.charCodeAt(i));
   }
   return bitTotal(Modes);
}
//判断密码不能全为空格,是返回true
function checkAllInputSpace(pwd){
	if(pwd.length<6 || pwd.length>20){
		document.getElementById("registPWWarm03").style.cssText = "display:none";
		return true;
	}
	for(var i=0; i<=pwd.length; i++){
		if(i == pwd.length){
			document.getElementById("registPWWarm03").style.cssText = "display:block";
			document.getElementById("registPWWarm01").style.cssText = "display:none";
			document.getElementById("registPWWarm02").style.cssText = "display:none";
			document.getElementById("registPWRemind").style.cssText = "display:none";
			return true;	
		}
		if(pwd.charCodeAt(i) != 32) break;
	}
	return false;
}

//pwStrength函数
//当用户放开键盘或密码输入框失去焦点时,根据不同的级别显示不同的颜色
function pwStrength(pwd) {
	var strong = document.getElementById("registPWRemind");
	var lxStrong = strong.getElementsByTagName("p");
	document.getElementById("registPWWarm01").style.cssText = "display:none";
	document.getElementById("registPWWarm02").style.cssText = "display:none";
	document.getElementById("registPWWarm03").style.cssText = "display:none";
	strong.style.cssText = "display:none";	
	if(pwd.length < 6) {
		document.getElementById("registPWWarm01").style.cssText = "display:block";
		document.getElementById("registPWWarm02").style.cssText = "display:none";
		return false;
	}else if(pwd.length >20){
		document.getElementById("registPWWarm02").style.cssText = "display:block";
		document.getElementById("registPWWarm01").style.cssText = "display:none";
		return false;
	}else {
		var S_level = checkStrong(pwd);
		strong.style.cssText = "display:block";
		switch(S_level) {
			case 0:{
				return;
			}break;
			case 1:{
				lxStrong[0].style.cssText = "background-color:#00baff;display:block";
				lxStrong[1].style.cssText = "background-color:#fff;display:block";
				lxStrong[2].style.cssText = "background-color:#fff;display:block";
				lxStrong[3].innerHTML = "密码强度：弱";
			}break;
			case 2:{
				lxStrong[0].style.cssText = "background-color:#00baff;display:block";
				lxStrong[1].style.cssText = "background-color:#52dd4b;display:block";
				lxStrong[2].style.cssText = "background-color:#fff;display:block";
				lxStrong[3].innerHTML = "密码强度：中";
			}break;
			default:{
				lxStrong[0].style.cssText = "background-color:#00baff;display:block";
				lxStrong[1].style.cssText = "background-color:#52dd4b;display:block";
				lxStrong[2].style.cssText = "background-color:#ff6c2b;display:block";
				lxStrong[3].innerHTML = "密码强度：强";
			};
		}
	}
	return true;
}

/*
  *  IDialog By SQL
  */

function callbackLayerInner(aoJSON) {
	if(aoJSON.length == 0) {
		document.getElementsByTagName('form')[0].submit();
	}
	else {
		var lxInnerContent = [];
		lxInnerContent[lxInnerContent.length] = '<div class="ssoRemind" style="opacity:1;background-color:#fff;z-index: 20; display: block; position: absolute; left: 381px; top: 190.5px;" id="sqlLayoutInner"><div class="ssoRemindTitle clearfix"><span style="height:18px;line-height:18px">您可能认识下面这些人</span><label style=""></label><div></div></div><div class="ssoRemindContent clearfix">';
		for(var i=0; i<aoJSON.length; i++) {
			lxInnerContent[lxInnerContent.length] = '<div id="ssorcLeftDetail0' + (i+1) + '" class="ssorcLeftDetail clearfix" onmouseover="changeCNCon($(\'personSel0' + (i+1) + '\'), \'open\', this, \'ssorcLeftDetail onLDMounseover\')" onmouseout="changeCNCon($(\'personSel0' + (i+1) + '\'), \'close\', this, \'ssorcLeftDetail\')"><div id="ssorcdPic0' + (i+1) + '" class="ssorcdPic"><img src="' + aoJSON[i].img + '" style="border:1px solid #c7c7c7;padding:2px;width:40px;height:40px;" /><input id="personSel0' + (i+1) + '" class="aaa" type="checkbox" name="checkBoxFriendList" style="display:none" onclick="changeSelectState(this, \'ssorcLeftDetail0' + (i+1) + '\', \'ssorcLeftDetail onInputSelect\', \'ssorcdPic0' + (i+1) + '\', \'ssorcdPic\')" value="' + aoJSON[i].id + '"/></div><ul><li class="ssorcName">' + aoJSON[i].name + '</li><li>' + aoJSON[i].school.replace(" ", "<br />") + '</li>';
			if(aoJSON[i].co == "") {
				lxInnerContent[lxInnerContent.length] = '</ul><div style="display:none" id="' + aoJSON.id + '"></div></div>';
			}
			else {
				lxInnerContent[lxInnerContent.length] = '<li>' + aoJSON[i].co + '</li></ul><div style="display:none" id="' + aoJSON.id + '"></div></div>';
			}
			i++;
			lxInnerContent[lxInnerContent.length] = '<div id="ssorcLeftDetail0' + (i+1) + '" class="ssorcLeftDetail clearfix" onmouseover="changeCNCon($(\'personSel0' + (i+1) + '\'), \'open\', this, \'ssorcLeftDetail onLDMounseover\')" onmouseout="changeCNCon($(\'personSel0' + (i+1) + '\'), \'close\', this, \'ssorcLeftDetail\')"><div id="ssorcdPic0' + (i+1) + '" class="ssorcdPic"><img src="' + aoJSON[i].img + '" style="border:1px solid #c7c7c7;padding:2px;width:40px;height:40px;" /><input id="personSel0' + (i+1) + '" class="aaa" type="checkbox" name="checkBoxFriendList" style="display:none" onclick="changeSelectState(this, \'ssorcLeftDetail0' + (i+1) + '\', \'ssorcLeftDetail onInputSelect\', \'ssorcdPic0' + (i+1) + '\', \'ssorcdPic\')" value="' + aoJSON[i].id + '" /></div><ul><li class="ssorcName">' + aoJSON[i].name + '</li><li>' + aoJSON[i].school.replace(" ", "<br />") + '</li>';
			if(aoJSON[i].co == "") {
				lxInnerContent[lxInnerContent.length] = '</ul><div style="display:none" id="' + aoJSON.id + '"></div></div>';
			}
			else {
				lxInnerContent[lxInnerContent.length] = '<li>' + aoJSON[i].co + '</li></ul><div style="display:none" id="' + aoJSON.id + '"></div></div>';
			}
			lxInnerContent[lxInnerContent.length] = '<div style="height:0;margin:0;padding:0;line-height:0;clear:both;"></div>'
		}
		lxInnerContent[lxInnerContent.length] = '</div><div id="errorSpace" style="visibility:hidden;margin-left:-60px;margin-top:5px;color:red;text-align:center;">请选择用户头像添加</div><div class="ssoRemindButton"><a href="#this" class="cnViBtnSilver" onclick="getCheckedUserAndSubmit(document.getElementsByName(\'checkBoxFriendList\'), 1);"><b><i>加为好友</i></b></a><a href="#this" onclick="getCheckedUserAndSubmit(document.getElementsByName(\'checkBoxFriendList\'), 0);" class="cnViBtnOrange"><b><i>暂时放弃</i></b></a></div></div>';
		var lsInnerHTML = lxInnerContent.join("");
		$('maskerLayerInner').innerHTML = lsInnerHTML;
		mbchecklongtime=0;
	}
}

var popUpClickTag = 0;
function getCheckedUserAndSubmit(axPerson, aiTag) {
	$('errorSpace').style.visibility = "hidden";
	if(aiTag == 1) {
		if(axPerson.length > 0) {
			var lxString = [];
			var lbCheckTag = false;
			for(var i=0; i<axPerson.length; i++) {
				if(axPerson[i].checked) {
					lxString[lxString.length] = axPerson[i].value;
					lbCheckTag = true;
				}
			}
			if(!lbCheckTag) {
				$('errorSpace').style.visibility = "visible";
				return false;
			}
			$('friendIdF').value = lxString.join(',');
		}
	}
	if(popUpClickTag==0) {
		popUpClickTag+=1;
		document.getElementsByTagName('form')[0].submit();
	}
	else {
		return false;
	}
}

function switchSpecialElements(aoP, asVisibility) {
	var lxObjIn6=["SELECT","IFRAME","OBJECT","EMBED"];
	for (var i = 0; i < lxObjIn6.length; i++) {
		var lxTemp = document.getElementsByTagName(lxObjIn6[i]);
		for(var j = 0; j < lxTemp.length; j++){
			var el = lxTemp[j];
			var lbhidden = true;
			while (el != null) {
				if(el == aoP) {
					lbhidden = false;
					break;
				}
				el = el.parentNode;
			}
			if(lbhidden) {
				if(asVisibility == "hidden") {
					lxTemp[j].setAttribute("visible", lxTemp[j].style.visibility || "");   //隐藏时保留原有的显示/隐藏的属性
					lxTemp[j].style.visibility = asVisibility;
				}
				else {
					lxTemp[j].style.visibility = lxTemp[j].getAttribute("visible") || "";  //显示时恢复原有的显示/隐藏属性
				}
			}
		}
	}
}

function generateLayer(aoP, aoInner, aoConfig) {
	aoP.style.display = "block";
	aoInner.style.display = "block";
	loLayerWrapper = aoP;
	var lsWidth = document.documentElement.scrollWidth + "px";
	var lsHeight = (document.documentElement.scrollHeight + 50) + "px";
	loLayerWrapper.style.cssText = "display:block;position:absolute;left:0;top:0;z-index:10;width:100%;height:100%;background:black;-moz-opacity:0.5;filter:alpha(opacity=50);";
	loLayerWrapper.style.width = lsWidth;
	loLayerWrapper.style.height = lsHeight;
	var ls123=encodeURI("http://ajaxv2.myspace.cn/_Common/AjaxService/SignupSvc.svc/json/FriendsCommend?sex="+aoConfig.sex+"&birth="+aoConfig.birth+"&region="+aoConfig.region+"&city="+aoConfig.city+"&co="+aoConfig.co+"&school="+aoConfig.school+"&callback=callbackLayerInner&r={W:random}");
	setTimeout("CNMS.loadJsonP(\""+ls123+"\")", 20);
}

function showLayer(aoP, aoInner, aoConfig) {
	switchSpecialElements(aoP, "hidden");
	setTimeout("checklongtime()",50000);
	generateLayer(aoP, aoInner, aoConfig);
}
var mbchecklongtime=1;
function checklongtime(){
	if (mbchecklongtime){
		document.getElementsByTagName('form')[0].submit();
	}
}

function changeClassName(obj, newClass){
	if(obj != null){
		obj.className = newClass;
	}else{return;}
}
function changeCNCon(personSelObj, bDisplay, obj, newClass){
	if(personSelObj != null && !personSelObj.checked){
		changeClassName(obj, newClass);
		if(bDisplay == "close") {
			personSelObj.style.display = "none";
		}
		if(bDisplay == "open") {
			personSelObj.style.cssText = "display:;position:absolute;margin-left:-46px;margin-top:33px;*margin-left:-50px;*margin-top:29px;-margin-left:-50px;-margin-top:29px;border:0";
		}
	}
}
function changeSelectState(obj, objLDId1, newClass1, objPicId2, newClass2){
	var obj1 = $(objLDId1);
	var obj2 = $(objPicId2);
	if(obj != null && obj.checked){
		if(obj1 != null)changeClassName(obj1, newClass1);
		if(obj2 != null)changeClassName(obj2, newClass2);
	} else {
		if(obj1 != null)changeClassName(obj1, 'ssorcLeftDetail onLDMounseover');
		if(obj2 != null)changeClassName(obj2, 'ssorcdPic');
	}
}

function step35() {
	if(!judgeStep3Empty()) {
		return false;
	} 
	else {
		var aoConfig = {};
		if($('male').checked == true) {
			aoConfig.sex = "M";
		}
		else if($('female').checked == false) {
			aoConfig.sex = "F";
		}
		var lsBirth = new Date("" + $('yourBirthdayYear').value + "/" + $('yourBirthdayMonth').value +"/" + $('yourBirthdayDay').value);
		aoConfig.birth = Math.floor((lsBirth - new Date("1970/1/1")) / 1000);
		aoConfig.region = $('settleCityArea').options[$('settleCityArea').selectedIndex].text;
		aoConfig.city = $('settleCityName').options[$('settleCityName').selectedIndex].text;
		if($('yourCompany')!=null) {
			aoConfig.co = new Date().getFullYear() + $('yourCompany').value;
		}
		else {
			aoConfig.co = "";
		}
		if(document.getElementsByName("yourGraduteSchool")[0].value == "") {
			aoConfig.school = "";
		}
		else {
			aoConfig.school = "";
			var lxSchool = document.getElementsByName("yourGraduteSchool");
			var lxSchoolGYear = document.getElementsByName("enterYear");
			if(CNMS.isIE) {
				for(var i=0; i<lxSchool.length-1; i++) {
					if(i != (lxSchool.length-2)) {
						aoConfig.school += lxSchoolGYear[i].value + lxSchool[i].value + ",";
					}
					else {
						aoConfig.school += lxSchoolGYear[i].value + lxSchool[i].value;
					}
				}
				
				for(var i=0; i<(lxSchool.length - 1); i++) {
					document.getElementsByName('yourGraduteSchoolWarm')[i].style.display = "none";
				}
				for(var i=0; i<(lxSchool.length - 1); i++) {
					for(var j=i+1; j<lxSchoolGYear.length; j++) {
						if(lxSchool[i].value==lxSchool[j].value && lxSchoolGYear[i].value==lxSchoolGYear[j].value){
							document.getElementsByName('yourGraduteSchoolWarm')[j].style.display = "block";
							document.getElementsByName('yourGraduteSchoolWarm')[j].innerHTML = '<img class="allIconsRed" src="http://xfiles.cdnmyspace.cn/dir/signup/v1/img/all_icons.gif"/>入学年份不能相同，请重新输入';
							return false;
						}
					}
				}
			}
			else {
				for(var i=0; i<lxSchool.length; i++) {
					if(i != (lxSchool.length-1)) {
						aoConfig.school += lxSchoolGYear[i].value + lxSchool[i].value + ",";
					}
					else {
						aoConfig.school += lxSchoolGYear[i].value + lxSchool[i].value;
					}
				}
				for(var i=0; i<lxSchool.length; i++){
					document.getElementsByName('yourGraduteSchoolWarm')[i].style.display = "none";
				}
				for(var i=0; i<lxSchool.length; i++) {
					for(var j=i+1; j<lxSchool.length; j++) {
						if(lxSchool[i].value==lxSchool[j].value && lxSchoolGYear[i].value==lxSchoolGYear[j].value){
							document.getElementsByName('yourGraduteSchoolWarm')[j].style.display = "block";
							document.getElementsByName('yourGraduteSchoolWarm')[j].innerHTML = '<img class="allIconsRed" src="http://xfiles.cdnmyspace.cn/dir/signup/v1/img/all_icons.gif"/>入学年份不能相同，请重新输入';
							return false;
						}
					}
				}
			}
		}
		var lxSchools = document.getElementsByName("yourGraduteSchool");
		var lxoSchools = [];
		var lxEnterYear = document.getElementsByName("enterYear");
		var lxsEnterYear = [];
		var lxSId = [];
		var lxSN = [];
		var lxTI = [];
		var lxL = [];
		if(CNMS.isIE) {
			for(var i=0; i<lxSchools.length-1; i++) {
				lxoSchools[i] = CNMS.json2Obj(lxSchools[i].getAttribute('data'));
				if(lxoSchools[i] != null) {
					lxSId[i] = lxoSchools[i].id;
					lxSN[i] = lxoSchools[i].school;
					lxTI[i] = lxoSchools[i].typeid;
					lxL[i] = lxoSchools[i].location;
				}
				lxsEnterYear[lxsEnterYear.length] = lxEnterYear[i].value;
			}
		}
		else {
			for(var i=0; i<lxSchools.length; i++) {
				lxoSchools[i] = CNMS.json2Obj(lxSchools[i].getAttribute('data'));
				if(lxoSchools[i] != null) {
					lxSId[i] = lxoSchools[i].id;
					lxSN[i] = lxoSchools[i].school;
					lxTI[i] = lxoSchools[i].typeid;
					lxL[i] = lxoSchools[i].location;
				}
				lxsEnterYear[lxsEnterYear.length] = lxEnterYear[i].value;
			}
		}
		$('schoolIdF').value = lxSId.join(",");
		$('typeIdF').value = lxTI.join(",");
		$('schoolNameF').value = lxSN.join(",");
		$('locationF').value = lxL.join(",");
		$('enterYearF').value = lxsEnterYear.join(",");
		showLayer($('maskerLayer'), $('maskerLayerInner'), aoConfig);
	}
}
/* --------------------------------------------------------- IDialog Done By SQL --------------------------------------------------------- */
/* --------------------------------------------------------- CheckName Done By SQL --------------------------------------------------------- */
function callBackCheckName(aoJSON) {
	$('checkNameSQL').style.display = "block";
	if(aoJSON.result == 0) {
		$('checkNameSQL').style.display = "none";
		return true;
	}
	return false;
}

function checkName(aoI) {
	return function() {
		setTimeout("CNMS.loadJsonP(\""+encodeURI("http://ajaxv2.myspace.cn/_Common/AjaxService/SignupSvc.svc/json/checkBannedName?name="+aoI.value+"&callback=callBackCheckName&r={W:random}")+"\")", 20);
	}
}
if($('yourName') != null) {
	addEventS($('yourName'), "blur", checkName($('yourName')));
}

var addStarTag = 0;
function addStar() {
	if($('yourCompany') == null && $('sqlMarkTextSchool') != null){
		$('sqlMarkTextSchool').className = "starMark";
		$('sqlMarkTextSchool').innerHTML = "您的学校：";
		addStarTag = 1;
	}
	if(addStarTag == 0){
		setTimeout('addStar()', 20);
	}
}
setTimeout('addStar()', 20);
	
var addEnterYearSelectTag = 0;
function addEnterYearSelect() {
	if($('enterYear')) {
		$('enterYear').options.length = 0;
		$('enterYear').options[$('enterYear').options.length] = new Option("入学年份", "入学年份");
		for(var i=parseInt(new Date().getFullYear()); i>1949;i--){
			$('enterYear').options[$('enterYear').options.length] = new Option(""+i, ""+i);
		}
		addEnterYearSelectTag = 1; 
	}
 	if(addEnterYearSelectTag == 0) {
		setTimeout("addEnterYearSelect()", 20);
	} 
}
setTimeout("addEnterYearSelect()", 200);
/* --------------------------------------------------------- CheckName Done By SQL Done -------------------------------------------------- */

var forbidFormSubmitTag = 0;
function forbidFormSubmit() {
	if(document.getElementsByName('yourGraduteSchool')[0] != null) {
		addEventS(document.getElementsByName('yourGraduteSchool')[0], "focus", function(){for(var i=0;i<document.getElementsByTagName('form').length;i++){document.getElementsByTagName('form')[i].onsubmit = function(){return false;}}});
		addEventS(document.getElementsByName('yourGraduteSchool')[0], "blur", function(){for(var i=0;i<document.getElementsByTagName('form').length;i++){document.getElementsByTagName('form')[i].onsubmit = function(){return true;}}});
		forbidFormSubmitTag = 1;
	}
	if(forbidFormSubmitTag==0) {
		setTimeout("forbidFormSubmit()", 20);
	}
}
setTimeout("forbidFormSubmit()", 20);

/************************************邮箱提示 yjz*************************************/
var mxDomains = [{"name":"163.com", "type":"@@@.com", "point":0}, {"name":"qq.com", "type":"@@.com", "point":0}, {"name":"126.com", "type":"@@@.com", "point":0}, {"name":"sina.com", "type":"@@@@.com", "point":0}, {"name":"yahoo.com.cn", "type":"@@@@@.com.cn", "point":0}, {"name":"hotmail.com", "type":"@@@@@@@.com", "point":0}, {"name":"yahoo.cn", "type":"@@@@@.cn", "point":0}, {"name":"yeah.net", "type":"@@@@.net", "point":0}, {"name":"sohu.com", "type":"@@@@.com", "point":0}, {"name":"tom.com", "type":"@@@.com", "point":0}, {"name":"gmail.com", "type":"@@@@@.com", "point":0}, {"name":"vip.qq.com", "type":"@@@@@@.com", "point":0}, {"name":"live.cn", "type":"@@@@.cn", "point":0}, {"name":"21cn.com", "type":"@@@@.com", "point":0}, {"name":"yahoo.com", "type":"@@@@@.com", "point":0}, {"name":"msn.com", "type":"@@@.com", "point":0}, {"name":"sina.com.cn", "type":"@@@@.com.cn", "point":0}];
var mbIsPromtWindow = false;
var msBodyPosition = "";
if(document.getElementById("emailAddr")!=null && mxDomains!=null){
	var meEmail = document.getElementById("emailAddr");
	createPromtElem(meEmail);
	addEvent(meEmail, "blur", promtEmail, meEmail, mxDomains);
	addEvent(meEmail, "blur", resetDomains, mxDomains);
}
function createPromtElem(aeRefObj){
	var newEmailDiv = document.createElement("div");
	newEmailDiv.setAttribute("id", "emailPromtList");
	newEmailDiv.style.cssText = "position:absolute;background:#fff;display:none;border:1px solid #b7b7b7";
	var loDivPos = getElePagepos(aeRefObj);
	newEmailDiv.style.left = loDivPos.l+"px";
	newEmailDiv.style.top = (loDivPos.t + loDivPos.h)+"px";
	document.body.appendChild(newEmailDiv);
	return document.getElementById("emailPromtList");
}
function getElePagepos(aeP){
	var pos = {"l":0, "t":0, "w":0, "h":0};
	var leObj = aeP;
	pos.w = leObj.offsetWidth;
	pos.h = leObj.offsetHeight;

	do{
		pos.l += leObj.offsetLeft;
		pos.t += leObj.offsetTop;
	}while(leObj = leObj.offsetParent);

	if(navigator.userAgent.indexOf("Apple") != -1){
		pos.t += 22;//根据页面而定，safari不认没有定高的img
	}
	return pos;
}
//即时提示
function promtEmailIntel(aeP, axSrcBuf){
	var lsEmail =  aeP.value;
	var liElLen = lsEmail.length;
	var liAddrIdx = lsEmail.indexOf("@");

	if(liAddrIdx != -1 && liAddrIdx<liElLen-1){
		lsValue = lsEmail.substring(liAddrIdx+1, liElLen);
		var lcCheckChar = lsValue.charAt(lsValue.length-1);
		promtIntel(lcCheckChar, lsValue.length-1, axSrcBuf);
		return true;
	}else{
		return false;
	}
	
}
//一次性提示
function promtEmail(aeP, axSrcBuf){
	
	var lsEmail =  aeP.value;
	var liElLen = lsEmail.length;
	var lsValue = "";
	var liAddrIdx = lsEmail.indexOf("@");
	for(var i=0; i<axSrcBuf.length; i++){
		if(axSrcBuf[i].name == lsEmail.substring(liAddrIdx+1, liElLen)){
			return false;
		}
	}
	if(liAddrIdx != -1 && liAddrIdx<liElLen-1){		
		lsValue = lsEmail.substring(liAddrIdx+1, liElLen);
		for(var i=0; i<(liElLen-liAddrIdx-1); i++){
			promtIntel(lsValue.charAt(i), i, axSrcBuf);
		}
		var lxResult = findKeys(axSrcBuf);
		
		var lePromtDiv = document.getElementById("emailPromtList");
		if(lxResult.length == 0){
			return false;
		}

		lePromtDiv.innerHTML = "";
		lePromtDiv.style.display = "block";
		var lsCSSText = "padding:2px;border-bottom:1px solid #b7b7b7;font-size:12px;color:#039;cursor:pointer";
		for(var i=0; i<lxResult.length; i++){
			var leDiv = document.createElement("div");
			leDiv.setAttribute("id", "promtListCon"+i);
			leDiv.style.cssText = lsCSSText;
			leDiv.innerHTML = "&nbsp;<b>"+lsEmail.substring(0, liAddrIdx+1)+lxResult[i].name+"</b>&nbsp;纠错建议。";
			lePromtDiv.appendChild(leDiv);
			var lePromtListCon = document.getElementById("promtListCon"+i);
			addEvent(lePromtListCon, "click", clickSelect, lsEmail.substring(0, liAddrIdx+1)+lxResult[i].name, lePromtDiv);
		}
		mbIsPromtWindow = false;
		addEvent(document, "click", function(){
			if(mbIsPromtWindow)lePromtDiv.style.display="none";
		});
		setTimeout(function(){mbIsPromtWindow = true;}, 500);
		//setTimeout(function(){lePromtDiv.style.display = "none";}, 5000);//5秒钟后自动消失
		return true;
	}else{
		return false;
	}
	function clickSelect(as, aeThisP){
		aeP.value = as;
		aeThisP.style.display = "none";
	}
}
//智能提示:给库里的域加分设权重法
function promtIntel(asVal, aiIndex, axSrcBuf){
	var lsValue =  asVal; 
	var lxScDom = [];
	var lxMaxVal = [];
	//遍历所有有域名
	for(var i=0; i<axSrcBuf.length; i++){
		var liIndex = axSrcBuf[i].name.indexOf(asVal);
		var liIndexDo =  axSrcBuf[i].type.indexOf(asVal);
		//查找是否存在新输入的字符,这里默认为最后一个字符,存在则加3分
		if(liIndex != -1 && liIndexDo!=liIndex){
			axSrcBuf[i].point += 3; 
			//如果位置匹配则追加3分,如果位置差为1则追加1分,其它不加分
			if(liIndex == aiIndex){
				axSrcBuf[i].point += 3;
			}else if(Math.abs(aiIndex - liIndex) < 2){
				axSrcBuf[i].point += 1;
			}else if(Math.abs(aiIndex - liIndex) > 2){
				axSrcBuf[i].point -= 3;
			}
		}
	}
}
//分析最高分找出所需值
function findKeys(axVals){
	var lxMaxVal = [];
	axVals.sort(function (a, b){
 		return b.point-a.point;
	});
	if(axVals[0] != null){
		lxMaxVal.push(axVals[0]);
	}
	//如果最大值和最小值相等则表示没有权重值
	if(axVals[0].point == axVals[axVals.length-1].point){
		return [];
	}
	//如果最高分小于7分则不符合要求：也即要达到存在两个字母，并有一个位置差小于1的水平之上
	if(axVals[0].point<7){
		return [];
	}
	for(var i=1; i<axVals.length; i++){
		if(axVals[0].point == axVals[i].point){
			lxMaxVal.push(axVals[i]);
		}else{
			break;
		}
	}
	return lxMaxVal;
}
//重置域库
function resetDomains(axDomains){
	for(var i=0; i<axDomains.length; i++){
		axDomains[i].point = 0;	
	}
}
function getStyle(aeP, asName){
	if(aeP.style[asName]){
		return aeP.style[asName];
	}else if(aeP.currentStyle){
		return aeP.currentStyle[asName];
	}else if(document.defaultView && document.defaultView.getComputedStyle){
		asName = asName.replace(/([A-Z])/g, "-$1");
		asName = asName.toLowerCase();
		
		var s = document.defaultView.getComputedStyle(aeP, "");
		return s && s.getPropertyValue(asName);
	}else{
		return null;
	}
	
}
/**
 *绑定事件, 可传参数
 */
function addEvent(aeP, asEvent, aoHandler, axParam){
	var args = Array.prototype.slice.call(arguments,3);
	var handler =  function(){
		aoHandler.apply(null, args);
	}
	
	if(navigator.appName.indexOf("Microsoft Internet Explorer") != -1){
		aeP.attachEvent("on"+asEvent, handler);
	}else{
		aeP.addEventListener(asEvent, handler, false);
	}
}

//////////new add///////////
function checkreq(){
 
	if(document.formreg.yourName.value=="")
	{
		alert("请输入姓名");
		document.formreg.yourName.focus();
		return false
	}
	
 	 if (document.formreg.yourName.value.length>4)
   {
    alert("姓名不能超过4个汉字！");
    document.formreg.yourName.focus();
    return false;
   }
   
   var nnname=document.formreg.yourName.value;
  
   var reg = /^([\u4E00-\u9FA5])*$/;
   if(arr=nnname.match(reg))
   {
    if(!check_surname(nnname))
    {
     alert("请输入你的真实姓名！");
     document.formreg.yourName.focus();
     return false;
    }
   }
   else
   {
    alert("真实姓名必须全部为中文");
    document.formreg.yourName.focus();
    return false;
   }
  
	if(document.formreg.emailAddr.value=="")
	{
		alert("请输入邮箱地址");
		document.formreg.emailAddr.focus();
		return false
	}	 
	if(!(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/g.test(document.formreg.emailAddr.value)))
	{
		alert("请输入你正确的邮箱地址！");
		document.formreg.emailAddr.focus();
		return false;
	}
	  
	if(document.formreg.registPW.value=="")
	{
	
		alert("请输入密码！");
		document.formreg.registPW.focus();
		return false
	}
	
		if(document.formreg.registPW2.value=="")
	{
	
		alert("请输入确认密码！");
		document.formreg.registPW2.focus();
		return false
	}
	
		if(document.formreg.registPW.value!=document.formreg.registPW2.value)
	{
	
		alert("两次输入的密码不一致");
		document.formreg.registPW.focus();
		return false
	}
	 
	return true;
}

function changeDisplayState(id, bln){   
	//if(bln == "true")$(id).style.display = ""; 
     if(bln == "true")document.getElementById(id).style.display = ""; 
	//else if(bln == "false")$(id).style.display = "none";
    else if(bln == "false")document.getElementById(id).style.display = "none";
	else if(bln == "auto"){ 

		//var eleState = $(id).style.display;
          var eleState =document.getElementById(id).style.display;
		//if(eleState = "")$(id).style.display = "none";
          if(eleState = "")document.getElementById(id).style.display = "none";
	//	if(eleState = "none")$(id).style.display = "";
           if(eleState = "none")document.getElementById(id).style.display = "";
	}
 
}
function yourNameFocus(){
	changeDisplayState('yourNameRemind', 'true');
	changeDisplayState('yourNameWarm01', 'false');
	changeDisplayState('yourNameWarm', 'false');
	changeDisplayState('yourNameWarm02', 'false');
}
function yourNameKeyup(e){
	if(e.keyCode != 9)judgeEmpty('yourName', '', 'yourNameRemind');
	limitNameLength('yourName',20);
}
function yourNameBlur(obj){
	changeDisplayState('yourNameRemind', 'false');
	if(isValueEmpty('yourName')){
		changeDisplayState('yourNameWarm01', 'false');
		changeDisplayState('yourNameWarm', 'true');
		returnRecord(1);}
	if(checkNameAllSpace(obj)){
		changeDisplayState('yourNameWarm01', 'true');
		changeDisplayState('yourNameWarm', 'false');
		returnRecord(1);
	}
	if(limitNameLength('yourName',20)){
		changeDisplayState('yourNameWarm02', 'true');
		changeDisplayState('yourNameWarm', 'false');
		returnRecord(1);
	}
	if(!isValueEmpty('yourName') && !checkNameAllSpace(document.getElementById('yourName')) && !limitNameLength('yourName',20))resetRecord(1);
}

function emailAddrFocus(){
	isEmailPageMouseout = false;
	changeDisplayState('emailAddrRemind', 'true');
	changeDisplayState('emailAddrWarm', 'false');
	changeDisplayState('emailAddrWarm01', 'false');
}
function emailAddrKeyup(e, aeObj){
	if(e.keyCode != 9)judgeEmpty('emailAddr', '', 'emailAddrRemind');
	if(isChinese(aeObj.value))changeDisplayState('emailAddrWarm01', 'true');
	else changeDisplayState('emailAddrWarm01', 'false');
}
function emailAddrBlur(aeObj){
	isEmailPageMouseout = true;
	if(!isEmailRemind){
		changeDisplayState('emailAddrRemind', 'false');
		changeDisplayState('emailAddrWarm', 'false');
		
		if(isChinese(aeObj.value))changeDisplayState('emailAddrWarm01', 'true');
		else changeDisplayState('emailAddrWarm01', 'false');
	}
}

function registPWFocus(obj){
	if(obj.value==""){
		changeDisplayState('registPWRemind01', 'true');
		changeDisplayState('registPWWarm01', 'false');
	}
}
function registPWKeyup(obj){
	changeDisplayState('registPWRemind01', 'false');
}
function registPWBlur(obj){
	changeDisplayState('registPWRemind01', 'false');
	if(checkAllInputSpace(obj.value)){
		returnRecord(2);
	}else{
		resetRecord(2);
	}
	if(isValueEmpty('registPW')){
		changeDisplayState('registPWWarm01', 'true');
		returnRecord(2);
	}else{
		resetRecord(2);
	}
}

//判断姓名是否真实
function check_surname(str)
{  
var str=str.substr(0,1); //截取用户提交的用户名的前两字节，也就是姓。 
var surname="赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯昝管卢莫柯房裘缪干解应宗丁宣贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊于惠甄曲家封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭历戎祖武符刘景詹束龙叶幸司韶郜黎蓟溥印宿白怀蒲邰从鄂索咸籍赖卓蔺屠蒙池乔阳郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庾终暨居衡步都耿满弘匡国文寇广禄阙东欧殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后荆红游竺权逮盍益桓公上赫皇澹淳太轩令宇长盖况闫肖麦";
r = surname.search(str);            // 查找字符串。
if(r==-1)
   return false
else 
   return true
 
}

function validate() {
   
   if (document.getElementById('username').value.length==1)
   {
    alert("请输入你的真实姓名！");
    document.getElementById('username').focus();
    return false;
   }
  if (document.getElementById('username').value.length>10)
   {
    alert("姓名不能超过10个汉字！");
    document.getElementById('username').focus();
    return false;
   }
   var nnname=document.getElementById('username').value;
   
   var reg = /^([\u4E00-\u9FA5])*$/;
   if(arr=nnname.match(reg))
   {
    if(!check_surname(nnname))
    {
     alert("请输入你的真实姓名！");
     document.getElementById('username').focus();
     return false;
    }
   }
   else
   {
    alert("真实姓名必须全部为中文");
    document.getElementById('username').focus();
    return false;
   }
 
return true;
}

//预约开户
function checkyuyuedata(){
  var crack='345';
	if(document.openform.username.value=="")
	{
		alert("请输入姓名");
		document.openform.username.focus();
		return false	  
	}
	if(!validate()){
		return false;
	}
    //中信建投才需要
 
	if(document.openform.cardid!=undefined&&document.openform.cardid.value=="")
	{
		alert("请输入正确的身份证号码");
		document.openform.cardid.focus();
		return false
	}
	if(document.openform.cardid!=undefined&&!checkIdcard(document.openform.cardid.value)){
		return false;
	}
	 
	//判断身份证号码是否对
	if(document.openform.email.value=="")
	{
		alert("请输入你的qq号码");
		document.openform.email.focus();
		return false   
	}
 
 
	if(document.openform.phone.value=="")
	{ 
		alert("请填写手机号码以便我们联系您！");
		document.openform.phone.focus();
		return false
	} 
	
 
		/**
	if(document.openform.phone.value!=""){
		if(!document.openform.phone.value.isMobile()&&!document.openform.phone.value.isTel()){
		 alert("手机/座机电话号码错误！座机格式如：020-84112873");
		 document.openform.phone.focus();
		 return false	
		}
	}

	if(document.openform.familyphone.value!=""){
		if(!document.openform.familyphone.value.isTel()){
		 alert("家庭电话号码错误！格式为:区号-号码，如: 020-84112873");
		 document.openform.familyphone.focus();
		 return false	
		}
	}	
	 if(document.openform.address.value==""||document.openform.address.value.length<6)
	{ 
		alert("请填写详细的通讯地址！");
		document.openform.address.focus();
		return false
	} 
 if(document.openform.zipcode.value=="")
	{
		alert("请输入邮政编码");
		document.openform.zipcode.focus();
		return false
	}	  
	
 if(checknumber(document.openform.zipcode.value,"邮编要为数字！")){
			  return false;
 }
 if(checkcode(document.openform.zipcode.value)){
			  return false;
 }
 */
 document.getElementById("from").value=crack;
 
	return true;
 
}


function checkIdcard(idcard1){
 var idcard=idcard1;
 /**
 var Errors=new Array(
 "验证通过!",
 "身份证号码位数不对!",
 "身份证号码出生日期超出范围或含有非法字符!",
 "身份证号码校验错误!",
 "身份证地区非法!"
 );
 */
 var area={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"} 
 
 var idcard,Y,JYM;
 var S,M;
 var idcard_array = new Array();
 idcard_array = idcard.split("");
 /*地区检验*/
 if(area[parseInt(idcard.substr(0,2))]==null) 
 {
  alert("身份证地区非法"); 
  return false;
 }
 /*身份号码位数及格式检验*/
 switch(idcard.length){
  case 15:
  if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
   ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
  } else {
   ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
  }
  if(ereg.test(idcard)){
	  
   // alert(Errors[0]+"15"); 
    //return false;
	return true;
   }
  else {
    alert("身份证号码出生日期超出范围或含有非法字符!");
     return false;
    }
  break;
  
  case 18:
  //18位身份号码检测
  //出生日期的合法性检查 
  //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
  //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
  if ( parseInt(idcard.substr(6,4)) % 4 == 0 || (parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))%4 == 0 )){
  ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式
  } else {
  ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式
  }
  if(ereg.test(idcard)){//测试出生日期的合法性
   //计算校验位
   S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
   + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
   + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
   + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
   + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
   + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
   + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
   + parseInt(idcard_array[7]) * 1 
   + parseInt(idcard_array[8]) * 6
   + parseInt(idcard_array[9]) * 3 ;
   Y = S % 11;
   M = "F";
   JYM = "10X98765432";
   M = JYM.substr(Y,1);/*判断校验位*/
   if(M == idcard_array[17]){
    //alert(Errors[0]+"18"); 
    //return false; /*检测ID的校验位*/
	return true;
   }
   else {
    alert("身份证号码不对!"); 
    return false;
   }
  }
  else {
   alert("身份证号码出生日期超出范围或含有非法字符!"); 
   return false;
  }
  break;
  
  default:
   alert("身份证号码位数不对!"); 
   return false;
   
 } 
}
 
 //手机号码 
String.prototype.Trim = function() {  
var m = this.match(/^\s*(\S+(\s+\S+)*)\s*/);  
return (m == null) ? "" : m[1];  
} 

String.prototype.isMobile = function() {  
return (/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})/.test(this.Trim()));  
}  

String.prototype.isTel = function() 
{ 
//"兼容格式: 国家代码(2到3位)-区号(2到3位)-电话号码(7到8位)-分机号(3位)" 
//return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?/.test(this.Trim())); 
return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?/.test(this.Trim())); 
} 

//检查邮政编码
function checkcode(code)
{
if(code.length==0)
		{
			return 0;
		}
var regcode = /^\d{6}$/;
if(!regcode.test(code))
		{
			alert("请正确输入邮编");
			return 1;
		}
return 0;
}

//检查数字
function checknumber(value,errmessage)
{
if(value.length==0)
		{
			return 0;
		}
var regcode = /^\d{1,}$/;
if(!regcode.test(value))
		{
			alert(errmessage);
			return 1;
		}
return 0;
}


//咨询
function checkconsultdata(){

	if(document.consultform.remarks.value=="")
	{
		alert("请输入咨询事情");
		document.consultform.remarks.focus();
		return false	  
	}
 
	if(document.consultform.cardid.value=="")
	{
		alert("请输入您联系方式");
		document.openform.cardid.focus();
		return false
	}
return true;


}
