﻿// JavaScript Document
/**
 * step2_ABI
 */
function changePage(aeP, event, pageIndex){
	var leDIV = document.getElementById("friendInfo_ABI");
	if(leDIV){
		var lxeUL = leDIV.getElementsByTagName("ul");
		var liLen = lxeUL.length;
		if(liLen == 0){
			return false;
		}
		for(var i=0; i<liLen; i++){
			lxeUL[i].style.display = "none";
		}
		lxeUL[pageIndex].style.display = "block";
	}else{
		alert("not found element with ID 'friendInfo_ABI' ");
	}
}
function selectFriend_lj(aeP, event){
	var lxeCover = aeP.getElementsByTagName("div");
	var leCover = lxeCover.length==0? null: lxeCover[0];
	if(leCover && leCover.className == "selectedTag"){
		var lbIsSelected = aeP.getAttribute("selected");
		var lsFridID = aeP.parentNode.id.substr(4);
		var lxeFridID = aeP.parentNode.getElementsByTagName("input");
		var leFridID = lxeFridID.length==0? null: lxeFridID[0];
		if(!leFridID){
			alert( "'FridID' input is wrong!");
			return false;
		}
		if(lbIsSelected == "false"){
			leCover.style.display = "block";
			aeP.setAttribute("selected", "true");			
			leFridID.value = lsFridID;
		}else{
			leCover.style.display = "none";
			aeP.setAttribute("selected", "false");
			leFridID.value = "0";
		}
	}else{
		alert("className 'selectedTag' is wrong!");
	}
}

/**
 * old
 */
﻿// 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 checkCNName(asStr){
	for(var i=0;i<asStr.length;i++){ 
	    var code=escape(asStr.charAt(i)); 
	    if((code.length>=4)&&(code<'%uFF60'||code>'%uFF9F')){ 
			continue;
	    }else{
	    	return false;
	    }
	}
	return true;
}
var ms_realNameState = 0;
function checkRealName(aeD, event, fn){
	if(!aeD){
		return false;
	}
	var lsName = EncodeUtf8(aeD.value); 
    var lsUrl = "http://ajaxv2.myspace.cn/_common/ajaxservice/CheckNameService.svc/json/CheckName";
    var loRequest={"webservices": lsUrl,"contentType":"application/x-www-form-urlencoded","values":["name=",lsName].join("")};
	CNMS.loadAjax(loRequest, callBack);
	function callBack(aoJson){
		ms_realNameState = aoJson; 
		if(typeof fn != "undefined" && fn && fn.constructor == Function)fn(aoJson);
	}
	return ms_realNameState;
}
//setTimeout('checkRealName(document.getElementById("yourName"), null)', 10000);
/*************第一步提交时判断各输入的合法性**************/
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
var isEmailBackplatformCheck = false;
//  回调函数
/****验证电子邮箱地址****/
function validateEmailAddr(aeObj){
	var emailAddress = aeObj.value;
	var val = emailAddress.replace(/\s*$/g, "");
	//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(val)){
		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:
			//changeDisplayState('emailAddrRight', 'true');
			displayError(document.getElementById(msCheckEmailNotifyId), '', false);
			msStep1EmailTag = true;
			break;
		case 1: 
		case 2:
		case 3:		
			changeDisplayState('emailAddrRight', 'false');
			  displayError(document.getElementById(msCheckEmailNotifyId), '<div class="allIconsWrong"></div>邮件地址已被注册，请重新输入或者直接<a href="http://loginv2.myspace.cn/Modules/CNLogin/Pages/Login.aspx" target="_blank" style="color:#039">登录</a>', true);   
			msStep1EmailTag = false;
			break;
		case 4:
			changeDisplayState('emailAddrRight', 'false');
			displayError(document.getElementById(msCheckEmailNotifyId), '<div class="allIconsWrong"></div>无效的邮件地址，请重新输入', true);
			
			msStep1EmailTag = false;
			break;
		case 5:
			changeDisplayState('emailAddrRight', 'false');
			displayError(document.getElementById(msCheckEmailNotifyId), '<div class="allIconsWrong"></div>邮箱已在<a href="http://www.myspace.com" style="color:#039">Myspace.com</a>注册过，请用新邮箱<a href="http://signupv2.myspace.cn/modules/signup/pages/signupstep1.aspx" style="color:#039">注册</a>！', true);  
			msStep1EmailTag = false;
			break;
		case 6: //add by royi
			changeDisplayState('emailAddrRight', 'false');
			displayError(document.getElementById(msCheckEmailNotifyId), '<div class="allIconsWrong"></div>使用QQ邮箱可能出错，请更换其他邮箱', true);
			msStep1EmailTag = false;
			break;
		case 7: //add by kcz
			changeDisplayState('emailAddrRight', 'false');
			displayError(document.getElementById(msCheckEmailNotifyId), '<div class="allIconsWrong"></div>使用TOM邮箱可能出错，请更换其他邮箱', true);
			msStep1EmailTag = false;
			break;			
	}
	isEmailBackplatformCheck = true;
	
	if(typeof enable_qqmail == "undefined" || !enable_qqmail){
		if(val.indexOf("@qq.com") != -1){
			displayError(document.getElementById(msCheckEmailNotifyId), '<div class="allIconsWrong"></div>QQ邮箱暂时不能注册，请使用其他邮箱', true);
			return false;
		}
	}
	
	return msStep1EmailTag;
}

//  控制出错信息的显示
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.replace(/\s*$/g, "");
	//add by royi
	if(typeof enable_qqmail == "undefined" || !enable_qqmail){
		if (asEmail.toLowerCase().indexOf("@qq.com") != -1)
		{
			window[asCallback]({"Result":6, "Msg":""});
			return false;
		}
		if (asEmail.toLowerCase().indexOf("@tom.com") != -1)
		{
			window[asCallback]({"Result":7, "Msg":""});
			return false;
		}		
	}
	//
	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());
			return true;
		}else{
			loResult = window[asCallback]({"Result":4, "Msg":""});
			changeDisplayState('emailAddrRight', 'false');
			return false;
		}

	}
}


//  添加上事件句柄
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_v2(){ //当有必填项没填时返回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);

	if(!isYourSexEmpty()){
		bEmpty = true;
	}
	if(!isYourBirthday()){
		bEmpty = true;
	}
	if(document.getElementById("checkCode") || document.getElementById("captchError")) {
		if(document.getElementById("checkCode").value=="" || document.getElementById("checkCode").value=="点击获取验证码") {
			bEmpty = true;
			document.getElementById("captchError").style.display = "block";
		}
	}
	emailAddrBlur($("emailAddr"));
	if(!yourNameBlur($("yourName"))){
		bEmpty = true;
	};
	registPWBlur($("registPW"));
	if(!$("male").checked && !$("female").checked){	
		changeDisplayState('yourSexWarm', 'true');
		bEmpty = true;
	}else{
		changeDisplayState('yourSexRight', 'true');
	}	
	if(!$("cvsOnschool").checked && !$("cvsOnjob").checked){	
		changeDisplayState('cvsYourIdWarm', 'true');
		bEmpty = true;
	}else{
		changeDisplayState('cvsYourIdRight', 'true');
	}
	//修补
	var leEmailWarm = document.getElementById("emailAddrWarm");
	if(leEmailWarm){
		if(leEmailWarm.style.display == "block"){
			bEmpty = true;
		}
	}
	if(!yourBirthdayBlur(null, null)){
		changeDisplayState('yourBirthdayWarm', 'true');
		bEmpty = true;
	}
	if(!yourSettleCityBlur(null, null)){
		changeDisplayState('settleCityWarm', 'true');
		bEmpty = true;
	}else{
		changeDisplayState('settleCityRight', 'true');
	}
	
	var lePW_comfirm = document.getElementById("registPW_confirm");
	if(!(lePW_comfirm && registPWBlur_confirm(lePW_comfirm))){
		changeDisplayState('registPWWarm_confirm', 'true');
		bEmpty = true;
	}
	//resetPublicVa(returnRecord_0_mark, 0);/*=将全局变量清0=*/
	if(msStep1EmailTag==false) bEmpty=true;
	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";
		$('yourBirthdayWarm').style.display = "none";
		//resetRecord(2);
		return true;
	}else{
		//$('ctl00_ctl00_ContentPlaceHolder_ModuleBody_ContentPlaceHolder1_ucStep3_yourBirthdayWarm').style.display = "block";
		$('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 isYourSchool() {
	if(CNMS.isIE) {
		for(var i=0; i<document.getElementsByName('yourGraduteSchool').length-1; i++) {
			
			if(document.getElementsByName('yourGraduteSchool')[i].getAttribute('data') == "undefined") {
				document.getElementsByName('yourGraduteSchoolWarm')[i].innerHTML = '<img class="allIconsRed" src="http://xfiles.cdnmyspace.cn/dir/signup/v2/img/all_icons.gif"/>请从下拉列表中选择您的学校';
				document.getElementsByName('yourGraduteSchoolWarm')[i].style.display = "block";
				return false;
			} 
			else if(document.getElementsByName('yourGraduteSchool')[i].value == "" || document.getElementsByName('enterYear')[i].value == "入学年份" || document.getElementsByName('enterYear')[i].value == "") {
				document.getElementsByName('yourGraduteSchoolWarm')[i].innerHTML = '<img src="http://xfiles.cdnmyspace.cn/dir/signup/v2/img/all_icons.gif" class="allIconsRed"/>请填写您的学校名称和入学年份';
				document.getElementsByName('yourGraduteSchoolWarm')[i].style.display = "block";
				return false;
			}
			else {
				document.getElementsByName('yourGraduteSchoolWarm')[i].style.display = "none";
			}
		}
	}
	else {
		for(var i=0; i<document.getElementsByName('yourGraduteSchool').length; i++) {
			if(document.getElementsByName('yourGraduteSchool')[i].getAttribute('data') == "undefined") {
				document.getElementsByName('yourGraduteSchoolWarm')[i].innerHTML = '<img class="allIconsRed" src="http://xfiles.cdnmyspace.cn/dir/signup/v2/img/all_icons.gif"/>请从下拉列表中选择您的学校';
				document.getElementsByName('yourGraduteSchoolWarm')[i].style.display = "block";
				return false;
			} 
			else if(document.getElementsByName('yourGraduteSchool')[i].value == "" || document.getElementsByName('enterYear')[i].value == "入学年份" || document.getElementsByName('enterYear')[i].value == "") {
				document.getElementsByName('yourGraduteSchoolWarm')[i].innerHTML = '<img src="http://xfiles.cdnmyspace.cn/dir/signup/v2/img/all_icons.gif" class="allIconsRed"/>请填写您的学校名称和入学年份';
				document.getElementsByName('yourGraduteSchoolWarm')[i].style.display = "block";
				return false;
			}
			else {
				document.getElementsByName('yourGraduteSchoolWarm')[i].style.display = "none";
			}
		}
	}
	return true;
}

function judgeStep3Empty(){	 //当有必填项有没填时返回true
	//var lbValue = isYourSexEmpty();
	var lbValue = true;
	//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/v2/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 so1(wrapperid, picURL, userid, nickname, info, school, commpany, sURL, fURL) {
	var so_1 = new SWFObject("http://lads.myspace.cn/components/signup/avatarexpress.swf", "express_flash_get_avatar", "730", "480", "9.0.0", "#FFFFFF");
	so_1.addParam("wmode", "transparent");
	so_1.addParam("allowScriptAccess", "always");

	so_1.addVariable("userid", userid);
	so_1.addVariable("nickname", nickname);
	so_1.addVariable("photourl", picURL);
	so_1.addVariable("info", info);
	so_1.addVariable("school", school);
	so_1.addVariable("company", commpany);
	so_1.addVariable("successURL", sURL);
	so_1.addVariable("failURL", fURL);
	so_1.write(wrapperid);
}

function so2(wrapperid, userid, nickname, info, school, commpany, sURL, fURL) {
	var so_2 = new SWFObject("http://lads.myspace.cn/components/signup/AvatarCamera.swf", "camera_flash_get_avatar", "750", "400", "9.0.0", "#FFFFFF");
	so_2.addParam("wmode", "transparent");
	so_2.addParam("allowScriptAccess", "always");
	so_2.addVariable("userid", userid);
	so_2.addVariable("nickname", nickname);
	so_2.addVariable("info", info);
	so_2.addVariable("school", school);
	so_2.addVariable("company", commpany);
	so_2.addVariable("successURL", sURL);
	so_2.addVariable("failURL", fURL);
	so_2.write(wrapperid);
}

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");
	changeDisplayState('registPWWarm', 'false');
	changeDisplayState('registPWWarm01', 'false');
	changeDisplayState('registPWWarm02', 'false');
	changeDisplayState('registPWWarm03', 'false');
//	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) {
		changeDisplayState('registPWWarm01', 'true');
		changeDisplayState('registPWWarm02', 'false');
//		document.getElementById("registPWWarm01").style.cssText = "display:block";
//		document.getElementById("registPWWarm02").style.cssText = "display:none";
		return false;
	}else if(pwd.length >20){
		changeDisplayState('registPWWarm01', 'false');
		changeDisplayState('registPWWarm02', 'true');
//		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 onInputSelect 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" checked="checked" name="checkBoxFriendList" style="position:absolute;margin-left:-46px;margin-top:33px;*margin-left:-50px;*margin-top:29px;-margin-left:-50px;-margin-top:29px;border:0" 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[i].id + '"></div></div>';
			}
			else {
				lxInnerContent[lxInnerContent.length] = '<li>' + aoJSON[i].co + '</li></ul><div style="display:none" id="' + aoJSON[i].id + '"></div></div>';
			}
			i++;
			lxInnerContent[lxInnerContent.length] = '<div id="ssorcLeftDetail0' + (i+1) + '" class="ssorcLeftDetail onInputSelect 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" checked="checked" name="checkBoxFriendList" style="position:absolute;margin-left:-46px;margin-top:33px;*margin-left:-50px;*margin-top:29px;-margin-left:-50px;-margin-top:29px;border:0" 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[i].id + '"></div></div>';
			}
			else {
				lxInnerContent[lxInnerContent.length] = '<li>' + aoJSON[i].co + '</li></ul><div style="display:none" id="' + aoJSON[i].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 leBirthday = document.getElementById("birthday");
		if(leBirthday){
			aoConfig.birth = Math.floor((new Date(leBirthday.value + "") - new Date("1970/1/1")) / 1000); 
		}
		var leSex = document.getElementById("gender");
		if(leSex){
			aoConfig.sex = leSex.value;
		}
//		aoConfig.sex ="M";
//		aoConfig.birth = Math.floor((new Date("1990/1/1") - new Date("1970/1/1")) / 1000);
//		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/v2/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/v2/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);
	}
}

var isCheckCode = false;
function checkCodeBlur(aeP){
	if(aeP.value == ""){
		changeDisplayState('checkCodeRight', 'false');
		changeDisplayState('captchError', 'true');
		isCheckCode = false;
	}else{
		changeDisplayState('captchError', 'false');
		changeDisplayState('checkCodeRight', 'true');
		isCheckCode = true;
	}
	return;
}
function checkCodeFocus(aeP){
	if(aeP.value=='点击获取验证码'){
		aeP.value='';
		validateCheckCode('checkCode');
		changeCheckCodeState('checkCode', 'checkCodeShowUtil');
		StartTimer();
	}
}
//--------把中文字符转换成Utf8编码------------------------//
 function EncodeUtf8(s1)
  {
      var s = escape(s1);
      var sa = s.split("%");
      var retV ="";
      if(sa[0] != "")
      {
         retV = sa[0];
      }
      for(var i = 1; i < sa.length; i ++)
      {
           if(sa[i].substring(0,1) == "u")
           {
               retV += Hex2Utf8(Str2Hex(sa[i].substring(1,5)));
              
           }
           else retV += "%" + sa[i];
      }
     
      return retV;
  }
  function Str2Hex(s)
  {
      var c = "";
      var n;
      var ss = "0123456789ABCDEF";
      var digS = "";
      for(var i = 0; i < s.length; i ++)
      {
         c = s.charAt(i);
         n = ss.indexOf(c);
         digS += Dec2Dig(eval(n));
          
      }
      //return value;
      return digS;
  }
  function Dec2Dig(n1)
  {
      var s = "";
      var n2 = 0;
      for(var i = 0; i < 4; i++)
      {
         n2 = Math.pow(2,3 - i);
         if(n1 >= n2)
         {
            s += '1';
            n1 = n1 - n2;
          }
         else
          s += '0';
         
      }
      return s;
     
  }
  function Dig2Dec(s)
  {
      var retV = 0;
      if(s.length == 4)
      {
          for(var i = 0; i < 4; i ++)
          {
              retV += eval(s.charAt(i)) * Math.pow(2, 3 - i);
          }
          return retV;
      }
      return -1;
  }
  function Hex2Utf8(s)
  {
     var retS = "";
     var tempS = "";
     var ss = "";
     if(s.length == 16)
     {
         tempS = "1110" + s.substring(0, 4);
         tempS += "10" +  s.substring(4, 10);
         tempS += "10" + s.substring(10,16);
         var sss = "0123456789ABCDEF";
         for(var i = 0; i < 3; i ++)
         {
            retS += "%";
            ss = tempS.substring(i * 8, (eval(i)+1)*8);
           
           
           
            retS += sss.charAt(Dig2Dec(ss.substring(0,4)));
            retS += sss.charAt(Dig2Dec(ss.substring(4,8)));
         }
         return retS;
     }
     return "";
  }
  
  function validation_in_kn(){
	selectSinger();
	checkNameInKN();
	function checkNameInKN(){
		var dom={
			name:document.getElementById("real_name_input"),
			tip:document.getElementById("real_name_tip")
		};
		dom.name.onblur=function(){
			var lsTip = "";
			var lsName = EncodeUtf8(dom.name.value); 
			var lsUrl = "http://ajaxv2.myspace.cn/_common/ajaxservice/CheckNameService.svc/json/CheckName";
			var loRequest={"webservices": lsUrl,"contentType":"application/x-www-form-urlencoded","values":["name=",lsName].join("")};
			CNMS.loadAjax(loRequest, callBack);
			function callBack(aoJson){
				switch (aoJson) {
					case 1: {
						lsTip = "<span style='color:red'>姓不存在，建议填写真实姓名</span>";
						break; 
					 }
					case 2: {
						lsTip = "<span style='color:red'>名字太长，建议填写真实姓名</span>";
						break; 
					 }
					case 3: {
						lsTip = "<span style='color:red'>有非法字符，建议填写真实姓名</span>";
						break; 
					 }
					case 4:{
						lsTip = "<span style='color:red'>缺少名字，建议填写真实姓名</span>";
						break; 
					 }
					 default:{
						lsTip = "真实的你，真实的机会！";
						break; 
					 }
				}
				dom.tip.innerHTML = lsTip;
			}
		}
	}	
}
function selectSinger() {
	selectSinger.selected = {};
	var ul = document.getElementById("knwrapper");
	lis = ul.getElementsByTagName("li");
	for(var i=0; i<lis.length; i++) {
		selectSinger.selected[lis[i].getAttribute("uid")] = false;
	}
	selectSinger.over = function() {
		this.style.backgroundPosition='0 -84px';
	};
	selectSinger.out = function() {
		this.style.backgroundPosition='0 25px';
	};
	selectSinger.click = function() {
		var _img = this.getElementsByTagName("img")[1];
		if(selectSinger.selected[this.getAttribute('uid')]) {
			selectSinger.out.apply(this);
			this.onmouseout = function(){selectSinger.out.apply(this);}
			_img.style.display = "none";
			selectSinger.selected[this.getAttribute('uid')] = false;
			return;
		}
		selectSinger.over.apply(this);
		this.onmouseout = null;
		selectSinger.selected[this.getAttribute('uid')] = true;
		_img.style.display = "block";
	};
}
function knSubmit(v) {
	nameList = document.getElementById("nameList");
	if(v == 0){
		nameList.value = "";
	}
	else if(v == 1){
		nameList.value = "";
		for(var p in selectSinger.selected) {
			if(selectSinger.selected[p]) {
				nameList.value += p + ",";
			}
		}
		
		var lxInput = document.getElementById("detail_table").getElementsByTagName("input");
		var lxTableTip = [
			"请正确填写您的姓名",
			"请正确填写您的QQ",
			"请正确填写您的手机号码",
			"请正确填写您的通讯地址",
			"请正确填写您的邮编"
		];
		for(var i=0;i<lxInput.length;i++){
			var leInput = lxInput[i];
			if(leInput.type!="text"){
				continue;
			}
			if(i==2 && !/\S/.test(leInput.value)){
				alert(lxTableTip[i]);
				leInput.focus();
				return false;
			}			
			if(!/\S/.test(leInput.value)){
				continue;
				/*
				alert(lxTableTip[i]);
				leInput.focus();
				return false;
				*/
			}
			
			if(i==0 || i==3){
				continue;
			}
			var lsPattern;
			switch(i){
				case 1:
					lsPattern = /^[1-9]\d{4,}$/;
					break;
				case 2:
					lsPattern =  /^1\d{10}$/;
					break;
				case 4:
					lsPattern = /^\d{6}$/;
					break;
			}
			var lR=new RegExp(lsPattern);
			if(!lR.test(trim(leInput.value))){
				alert(lxTableTip[i]);
				leInput.focus();
				return false;
			}
		}
		
		
		if(nameList.value == "") {
			alert("请点击头像选择要支持的歌手！可以支持多人哦！");
			return false;
		}
	}
	document.body.getElementsByTagName("form")[0].submit();
	
	function trim(asStr){
	    asStr = asStr == null ? "" : asStr;
	    return asStr.replace(/(^\s*)|(\s*$)/g, "");
	}
}




function checkNameInExisted(asName){
	CNMS.loadJsonP("http://ajaxv2.myspace.cn/_common/AjaxService/SignupSvc.svc/json/CheckDisplayName?callback=checkNameInExistedCallback&displayName="+encodeURIComponent(asName)+"&r="+Math.random());
}
function checkNameInExistedCallback(aoData){	
	if(aoData.Result<0){
		changeDisplayState('checkNameSQL', 'true');
		var leNode = document.getElementById("checkNameSQL");		
		leNode.innerHTML='<div class="allIconsWrong"></div>'+aoData.Msg;
	}else{
		changeDisplayState('checkNameSQL', 'false');
	}

}