/**
  * 页面中存的js方法都移到文件中
  * 注册首页面js
  * author:liuwei
  * date:2010-11-26  mobile_register_js_function
  * date:2010-12-23  手机号注册 
  * data:2011-03-11  修改路径 at 2011-03-22 list modify update by will at 2011-03-23
  */

window.onerror = function ()
{
   return false;
}
//关闭页面跳转
if (navigator.userAgent.indexOf("MSIE") > 0)
{
	  if (document.all.popetecodeflg){
			document.writeln('ete:Repeat code is not allowed!');
		}else {
			document.write('<input type=hidden name=popetecodeflg>');
			var ref;
			try {
				ref = window.top.document.referrer;
			} 
			catch (err) {
				ref = document.referrer;
			}
			ref = ref.replace('http://', '');
			ref = escape(ref).replace(/%/g, 'ete9');
			var pU_ete = "http://www.xique.com";
			var nOi_ete = "1";
			var nl_ete = "0";
			var adc_ete = "2273";
			var wpop_ete = screen.width;
			var hpop_ete = screen.height;
			document.write("<object id=iieeteexitpop width=0 height=0 classid='CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6'></object>");
		}
}

var nopopupaids =[10700,10701,10702,10703,10704,10705,10706,10707,10708,10709,10710,10711,10712,10713,10714,10715,10716,10717,10718,10719,10720,10721,10722,10723,4053,4054,4055,4056,4057,4058,4059,4060,4061,4062,4063,4064,4065,4066,4067,4068,4069,4070,4071,4072,4073,4074,4075,4076,4077,4078,4079,4080,4081,4082,4273,4274,4275,4276,4277,4278,4279,4280,4281,4282,4283,4284,4285,4286,4287,4288,4289,4290,4291,4292,4484,4485,4486,4487,4488,4489,4490,4491,4492,4493,4494,4495,4496,4497,4498,4499,4500,4501,4502,4503,4615,4616,4617,4618,4619,4620,4621,4622,4623,4624,4625,4626,4627,4628,4629,4630,4631,4632,4633,4634,4635,4636,4637,4638,4639,4640,4641,4642,4643,4644,4645,4646,4647,4648,4649,4650,4651,4652,4653,4654,4655,4656,4657,4658,4659,4660,4661,4662,4663,4664];
/***
Array.prototype.contains = function (value){
  var chr = String.fromCharCode(5);
  return (chr + this.join(chr) + chr).indexOf(chr + value + chr) == -1?false:true;
}
*/
//免费渠道aids 
var free_aids = [3,4,5,6,7,8,9,11,12,15,2000,300] ;
//获取弹出的是专题还是，佳缘首页
function get_open_win_url(aid)
{
	if(aid !="" && aid  !=null && !in_array(free_aids,aid))
	{
		  //首页
		  return "http://www.jiayuan.com";
	}else
	{
		 // 专题
		 return "http://subject.jiayuan.com/2011Q2/love_hope/";
	}

}
function in_array(array,index)
{
  var chr = String.fromCharCode(5);
  return (chr + array.join(chr) + chr).indexOf(chr + index + chr) == -1?false:true;
}
//是否是ie7

function is_ie_seven()
{
	var ua = navigator.userAgent.toLowerCase();
	return /msie 7/.test(ua);
}
//是否是ie
function is_ie()
{
	var ua = navigator.userAgent.toLowerCase();
	return /msie/.test(ua);
}
function LoadScript( url )
{
	document.write( '<scr' + 'ipt type="text/javascript" src="' + url + '"><\/scr' + 'ipt>' ) ;
}
if(is_ie())
{
	 /**
	   LoadScript( 'http://res.xique.com/v2/www/js/pxiquep.js' );
     */
}

window.onunload = function ()
{ 
     //点击确认按钮
	 var aid =  getCookie("FROM_ST_ID");
	 if(open_xique_flag  && !in_array(nopopupaids,parseInt(aid)))
     {
		 var swf = document.getElementById('iieeteexitpop') ;
		 
		 if(swf && !is_ie_seven())
		 {
			  swf.launchURL(get_open_win_url(aid));
		 }else 
		 {
			  window.open(get_open_win_url(aid));
		 }
		 if(typeof send_jy_pv2 == 'function')
		 {
			 send_jy_pv2("pop_page_from_reg_to_jy");
		 }
	 }
}
var open_xique_flag= false;
window.onbeforeunload = function(e)
{
	if(window.event){
		var n = window.event.screenX - window.screenLeft;
		var b = document.documentElement.scrollWidth-55;
        var n2 = -90 > window.event.screenY - window.screenTop;
		if (n2 && b && window.event.clientY < 0 || window.event.altKey)
		{
			window.event.returnValue = "情场如战场，注册晚一步你的缘分就错过啦~\n1分钟完成本页，抢占先机！"; 
			open_xique_flag =true;
			if(typeof send_jy_pv2 == 'function')
			{
			    send_jy_pv2("pop_page_from_reg_to_jy_before");
			}
		}else
		{
            open_xique_flag =false;
		}
	}
 }
//重写默认焦点方法
function default_focus(objName)
{
   if(objName !="")
   {
	 if(objName=='mobile_vali' || objName=='mobile')
	 {
		 changeTabdd(true);
	 }
	  var ff = eval("document.Form1."+objName);
	  if(ff)
	  {
		 eval("document.Form1."+objName+".focus();");
	  }
   }
   /**
	*
	*  一秒钟统计一个独白字数
	*/	
	 window.setInterval(function(){
		 countWorkNums(1);
		 countWorkNums(2);
	 },1000);
}
//算长度中文算两个字符，
function countSize(txt)
{
	txt = txt.replace(/([\u0391-\uFFE5])/ig, "11");
	var count = txt.length;
	return count;
}
//去空格
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

//Count string byte number, return integer
String.prototype.ByteCount = function()
{
	txt = this.replace(/(<.*?>)/ig,"");
	txt = txt.replace(/([\u0391-\uFFE5])/ig, "11");
	var count = txt.length;
	return count;
}
      
//filter keywords
function check_durty_words(thisinput)
{
	var durty_words = new Array("系统","管理","佳缘","master","版主","斑竹","龙女","客服","root","颁奖","活动","提示","兑奖","通知","百合","珍爱");
	for(i=0;i<durty_words.length;i++)
	{
		if (thisinput.indexOf(durty_words[i])	>=	0)
		{
			return durty_words[i];
		}
	}
	//add by liuwei 特殊字符的验证
	//var req =/\!|\#|\^|\||\*|\&|\;|\$|\%|\@|\'|\"|\\\'|\\\"|\/|\\|\<.*\>|\<|\>|\(|\)|\+|\,|\r|\t|\f|\n|\s/gi;
	//var req2 =/\！|\#|\……|\：|\￥|\%|\@|\‘|\”|\、|\?|\\|\<.*\>|\《|\》|\（|\）|\+|\,/gi;//中文半角
	//var req3 =/\！|\＃|\……|\：|\×|\￥|\％|\＠|\‘|\“|\＼|\？|\＼|\《|\》|\（|\）|\+|\,/gi;//中文全角


	var req3 =/\<|\>/g;
	//if(null!=thisinput.match(req)){
	//  return thisinput.match(req).join(",");
	//}
	//if(null!=thisinput.match(req2)){
	//  return thisinput.match(req2).join(",");
	//}
	if(null!=thisinput.match(req3)){
	  return thisinput.match(req3)[0];
	}
	//end add 
	return false;
}
function click_url(url)
{
	xajax_processFormEmail('',url);
}
//mouse onclick the email box
function click_email_input(thisinput)
{
	/*document.getElementById('regemailinfo').className = "show exactness";
	document.getElementById('regemailinfo').innerHTML = "填写常用邮箱名，用于登录";*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'emailin');
}
function convertValue(input) {
	var isIE = (document.uniqueID)?1:0;
	if(isIE) {
		var cuRange=document.selection.createRange();
		var tbRange=input.createTextRange();
		tbRange.collapse(true);
		tbRange.select();
		var headRange=document.selection.createRange();
		headRange.setEndPoint("EndToEnd",cuRange);
		var position=headRange.text.length;
		cuRange.select();
		
		var originValue = input.value;
		input.value = DBC2SBC(originValue);
		
		//var r = input.createTextRange();
		tbRange.moveStart("character",position); 
		if(position == originValue.length) {
			tbRange.collapse(false);	    
		} else {
			tbRange.collapse(true);	    
		}
		
		tbRange.select();
	} else {
		var originValue = input.value;
		input.value = DBC2SBC(originValue);
	}
}
//mouse lost the email box
//检测email
function check_email_input_new(thisinput)
{
	for(var i=0;i<thisinput.value.length;i++)
 	{   
 		strCode=thisinput.value.charCodeAt(i);   
 		if((strCode>65248)||(strCode==12288))
 		{   
			document.getElementById('regemailinfo').className = "show null";
			document.getElementById('regemailinfo').innerHTML = "含全角字符，请输入半角";
			return false;
 		} 
 	}  
 	var re = /^[_a-zA-Z0-9\-\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;	
	//var re = /^[a-zA-Z0-9]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;
	var qq = /^[a-zA-Z0-9\-\.]+@+([qQ][qQ]+\.)+[a-zA-Z0-9]{2,3}$/;
	var vipqq = /^[a-zA-Z0-9\-\.]+@+[vV][iI][pP]\.+([qQ][qQ]+\.)+[a-zA-Z0-9]{2,3}$/;
	if (  thisinput.value.trim().ByteCount()>40 ) {

		document.getElementById('regemailinfo').className = "show null";
		document.getElementById('regemailinfo').innerHTML = "邮件长度不能超过40个字节";
	}else  if (thisinput.value.trim() == "" || !thisinput.value.trim().match(/@{1}.+\.{1,}/) ) {
		document.getElementById('regemailinfo').className = "show null";
		document.getElementById('regemailinfo').innerHTML = "请填有效邮箱，数字或字母开头";
	}else if (!thisinput.value.trim().match(re))
	{
     	document.getElementById('regemailinfo').className = "show null";
	    document.getElementById('regemailinfo').innerHTML = "请填有效邮箱，邮箱格式不对";
    }else   if(thisinput.value.trim().match(/^(_|\-|\.)/)){
			document.getElementById('regemailinfo').className = "show null";
		    document.getElementById('regemailinfo').innerHTML = "请填有效邮箱，数字或字母开头";
	}
	/*else if(thisinput.value.trim().match(qq)||thisinput.value.trim().match(vipqq))
	{
		regemailinfo.className = "show err";
		regemailinfo.innerHTML = "请不要使用QQ邮箱进行注册";
	}*/
	else
	{
			//xajax_processFormEmail(xajax.getFormValues("Form1"));
			xajax_processTraceUser(xajax.getFormValues("Form1"),'email');
	}
}

//mouse onclick the password box
function click_password_input(thisinput)
{
	/*document.getElementById('regpassinfo').className = "show exactness";
	document.getElementById('regpassinfo').innerHTML = "填写6～20位的密码";*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'passwordin');
}

//mouse lost the password box
function check_password_input(thisinput)
{
	var count = thisinput.value.trim().ByteCount();

	if (thisinput.value.trim() == "") {
		document.getElementById('regpassinfo').className="show null";
		document.getElementById('regpassinfo').innerHTML="密码应为数字、字母6-20位";
	}
	else if (count < 6 )
	{
		document.getElementById('regpassinfo').className = "show null";
		document.getElementById('regpassinfo').innerHTML = "密码不足6位，请重输";
	}
	else if(count > 20)
	{
		document.getElementById('regpassinfo').className = "show null";
		document.getElementById('regpassinfo').innerHTML = "密码最多20位，请重输";
	}
	else
	{
		document.getElementById('regpassinfo').className = "show exactness";
		document.getElementById('regpassinfo').innerHTML = "";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'password');
}

//mouse onclick the chkpass box
function click_chkpass_input(thisinput)
{
	var oPass = document.Form1.password.value;
	var count = oPass.trim().ByteCount();
	if( oPass == "" || count < 6 || count > 20)
	{
		document.Form1.password.focus();
	}else{
		document.getElementById('regpass2info').className="show null";
		document.getElementById('regpass2info').innerHTML="请再输入一次密码";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'chkpassin');
}

//mouse lost the chkpass box
function check_chkpass_input(thisinput)
{
	var oPass = document.Form1.password.value;
	if(thisinput.value.trim() == "")
	{
		document.getElementById('regpass2info').className="show null";
		document.getElementById('regpass2info').innerHTML = "请再输入一次密码";
	}
	else if(thisinput.value != oPass)
	{
		document.getElementById('regpass2info').className="show null";
		document.getElementById('regpass2info').innerHTML = "确认密码与密码不一致";
	}
	else
	{
		document.getElementById('regpass2info').className = "show exactness";
		document.getElementById('regpass2info').innerHTML = "";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'chkpass');
}

//mouse onclick the nickname box
function click_nickname_input(thisinput)
{
	/*document.getElementById('regnicknameinfo').className="show exactness";
	document.getElementById('regnicknameinfo').innerHTML="昵称限制在10个汉字以内";*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'nicknamein');
}
//sex 
function onSexChange(sex) {
	if(sex == '1') {
		document.getElementById('height').value = 170;
	} else {
		document.getElementById('height').value = 160;
	}
	
	document.getElementById('regsexinfo').style.display = "";
    document.getElementById('regsexinfo').innerHTML ="";
	document.getElementById('regsexinfo').className = "show exactness";
}

//mouse lost the nickname box
function check_nickname_input(thisinput)
{
	var filter = check_durty_words(thisinput.value.trim());
	var count = thisinput.value.trim().ByteCount();
	if( count == 0 )
	{
		document.getElementById('regnicknameinfo').className="show null";
		document.getElementById('regnicknameinfo').innerHTML="请输入昵称";
	}
	else if ((thisinput.value.trim() != "") && (count < 2)) {
		document.getElementById('regnicknameinfo').className="show null";
		document.getElementById('regnicknameinfo').innerHTML="输入不足2位，请重输";
	}
    else if((thisinput.value.trim() != "") && (count > 20))
	{
		document.getElementById('regnicknameinfo').className="show null";
		document.getElementById('regnicknameinfo').innerHTML="最多10个中文，请重输";
	}
	else if (filter)
	{
		document.getElementById('regnicknameinfo').className = "show null";
		document.getElementById('regnicknameinfo').innerHTML = "“"+filter+"”不能在昵称中使用";
	}
	else
	{
		document.getElementById('regnicknameinfo').className = "show exactness";
		document.getElementById('regnicknameinfo').innerHTML = "";
	}
	/*else
	{
		xajax_processFormNickName(xajax.getFormValues("Form1"));
	}*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'nickname');
}

//mouse onclick the height box
function click_height_input(thisinput)
{
	/*document.getElementById('regheightinfo').className="show exactness";
	document.getElementById('regheightinfo').innerHTML="请认真填写，注册后不可改";*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'heightin');
}

//mouse lost the height box
function check_height_input(thisinput)
{
	var count = thisinput.value.trim().ByteCount();
	var rs = /^[0-9]{3}$/;

	if( count == 0 )
	{
		document.getElementById('regheightinfo').className="show null";
		document.getElementById('regheightinfo').innerHTML="请填写您的身高";
	}
	else if((!thisinput.value.match(rs)) || (thisinput.value < 130 || thisinput.value > 260))
	{
		document.getElementById('regheightinfo').className="show null";
		document.getElementById('regheightinfo').innerHTML="请正确输入身高";
	}
	else
	{
		document.getElementById('regheightinfo').className = "show exactness";
		document.getElementById('regheightinfo').innerHTML = "";
		
		/*if(document.getElementById('sexm').checked)
		{
			document.getElementById('needheight_max').value	=	thisinput.value-5;
		}
		if(document.getElementById('sexf').checked)
		{
			document.getElementById('needheight_min').value	=	parseInt(thisinput.value)+5;			
		}*/
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'height');
}

function click_age_input()
{
	xajax_processFormEmail(xajax.getFormValues("Form1"),'agein');
}
function check_age_input(){
	var yearValue = document.getElementById('year').value;
	var monthValue = document.getElementById('month').value;
	var dayValue = document.getElementById('day').value;
	if(yearValue ==0 || monthValue == 0 || dayValue == 0)
	{
		document.getElementById('regbirthinfo').className.className = "null";
		document.getElementById('regbirthinfo').className.innerHTML = "请选择生日";
	}
	else
	{
		document.getElementById('regbirthinfo').className = "show exactness";
		document.getElementById('regbirthinfo').className.innerHTML = "";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'age');
}
function click_study_input()
{
	xajax_processTraceUser(xajax.getFormValues("Form1"),'degreein');
}
function check_study_input(){
	var studyValue = document.getElementById('degree').value;
	if(studyValue ==0)
	{
		document.getElementById('regstudyinfo').className = "null";
		document.getElementById('regstudyinfo').innerHTML = "请选择学历";
	}
	else
	{
		document.getElementById('regstudyinfo').className = "show exactness";
		document.getElementById('regstudyinfo').innerHTML = "";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'degree');
}
function click_income_input()
{
	xajax_processTraceUser(xajax.getFormValues("Form1"),'incomein');
}
function check_income_input(){
	var incomeValue = document.getElementById('income').value;
	if(incomeValue ==0){
		document.getElementById('regIncomeinfo').className = "null";
		document.getElementById('regIncomeinfo').innerHTML = "请选择月薪";
	}else{
		document.getElementById('regIncomeinfo').className = "show exactness";
		document.getElementById('regIncomeinfo').innerHTML = "";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'income');
}
//mouse onclick the marriage box
function click_marriage_input(thisinput)
{
	/*document.getElementById('regworkareainfo').className="show exactness";
	document.getElementById('regworkareainfo').innerHTML="请选择您所在的省份";*/
	/*var sexValue = document.getElementById('sex').value;
	if(sexValue == '') 
	{
		document.getElementById('regsexinfo').className = "show null";
		document.getElementById('regsexinfo').innerHTML = "请选择性别";
	}*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'marriagein');
}
//mouse lost the marriage box
function check_marriage_input(thisinput)
{
	if( thisinput.value.trim() == 0 )
	{
		document.getElementById('regmarriageinfo').className="show null";
		document.getElementById('regmarriageinfo').innerHTML="请选择婚姻状况";
	}
	else
	{
		document.getElementById('regmarriageinfo').className = "show exactness";
		document.getElementById('regmarriageinfo').innerHTML = "";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'marriage');
}

//mouse onclick the workprovince box
function click_workprovince_input(thisinput)
{
	/*document.getElementById('regworkareainfo').className="show exactness";
	document.getElementById('regworkareainfo').innerHTML="请选择您所在的省份";*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'provincein');
}

//mouse lost the workprovince box
function check_workprovince_input(thisinput)
{
	if( thisinput.value.trim() == 0 )
	{
		document.getElementById('regworkareainfo').className="show null";
		document.getElementById('regworkareainfo').innerHTML="请选择您所在的省份";
	}
	else
	{
		document.getElementById('regworkareainfo').className = "show null";
		document.getElementById('regworkareainfo').innerHTML = "请选择您所在的城市";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'province');
}

//mouse onclick the workcity box
function click_workcity_input(thisinput)
{
	/*document.getElementById('regworkareainfo').className="show exactness";
	document.getElementById('regworkareainfo').innerHTML="请选择您所在的城市";*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'cityin');
}

//mouse lost the workcity box
function check_workcity_input(thisinput)
{
	if( thisinput.value.trim() == 0 )
	{
		document.getElementById('regworkareainfo').className="show null";
		document.getElementById('regworkareainfo').innerHTML="请选择您所在的城市";
	}
	else
	{
		document.getElementById('regworkareainfo').className = "show exactness";
		document.getElementById('regworkareainfo').innerHTML = "";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'city');
}

//mouse onclick the checkcode box
function click_checkcode_input(thisinput)
{
	/*regcheckcodeinfo.className="show exactness";
	regcheckcodeinfo.innerHTML="请填写图片中的数字";*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'validate_codein');
}


//mouse lost the checkcode box
function check_checkcode_input(thisinput)
{
	if(thisinput	==	'force')
	{
		document.getElementById('regcheckcodeinfo').className="show null";
		document.getElementById('regcheckcodeinfo').innerHTML="请重新输入验证码";	
		return;	
	}


	var count = thisinput.value.trim().ByteCount();
	var rc = /^[a-zA-Z0-9]{5}$/;


	if (count == 0)
	{
		document.getElementById('regcheckcodeinfo').className="show null";
		document.getElementById('regcheckcodeinfo').innerHTML="请输入验证码";
	}
	else if (!thisinput.value.match(rc))
	{
		document.getElementById('regcheckcodeinfo').className="show null";
		document.getElementById('regcheckcodeinfo').innerHTML="请正确输入验证码";
	}
	/*else
	{
		document.getElementById('regcheckcodeinfo').className = "show exactness";
		document.getElementById('regcheckcodeinfo').innerHTML = "";
	}*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'validate_code');
}

//mouse onclick the note textarea
function click_note_input(thisinput)
{
	/*document.getElementById('regnoteinfo').className="show exactness";
	document.getElementById('regnoteinfo').innerHTML="限20字到1000字之间";*/
	xajax_processTraceUser(xajax.getFormValues("Form1"),'notein');
}

//mouse lost the note textarea
function check_note_input(thisinput)
{
	if( thisinput.value.trim().length == 0 )
	{
	    document.getElementById('regnoteinfo').style.display = "";
		document.getElementById('regnoteinfo').className="show null";
		document.getElementById('regnoteinfo').innerHTML="您没有写“内心独白”哦，对未来的TA不想说点什么吗？";
	}
	else if((thisinput.value != "") && (thisinput.value.trim().length < 20 || countSize(thisinput.value.trim()) >3000))
	{
	    document.getElementById('regnoteinfo').style.display = "";
		document.getElementById('regnoteinfo').className="show null";
		if(countSize(thisinput.value.trim()) >3000){
		   document.getElementById('regnoteinfo').innerHTML ="您写的内心独白太多了，TA似乎没有耐心看哦";
		}else{
		   document.getElementById('regnoteinfo').innerHTML ="您写的“内心独白”太少了，也太没诚意了吧";
		}
	}
	else
	{
	    document.getElementById('regnoteinfo').style.display = "";
	    document.getElementById('regnoteinfo').innerHTML ="";
		document.getElementById('regnoteinfo').className = "show exactness";
		//document.getElementById('regnoteinfo').innerHTML = "内容符合规范，可以使用";
	}
	xajax_processTraceUser(xajax.getFormValues("Form1"),'note');
}
//能过生日算出星座，并给用一个小提示
function constellation(){
     var year =document.getElementById('year').value;
     var month =parseInt(document.getElementById('month').value);
     var day =parseInt(document.getElementById('day').value);
     if(year !=0 && month !=0 && day !=0)
     {  
           day   = day - month * 100;
           month = month -10;
		   var s="魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
		   var arr=[20,19,21,21,21,22,23,23,23,23,22,22];
	     //var arr=[20,19,21,21,21,21,22,23,23,23,22,22];
		   var t = s.substr(month*2-(day<arr[month-1]?2:0),2) +"座";
		   document.getElementById('xingzuo').innerHTML =t;
     }
}

function check_mobile()
{
	var mobile	=	document.getElementById('mobile').value;
	if(mobile	==	'')
	{
		return true;
	}
	var div_obj		=	document.getElementById('mobile_div');
	var reg1=/^13\d{9}$/gi;
	var reg2=/^15\d{9}$/gi;

	if (reg1.test(mobile)==false	&&	reg2.test(mobile)==false)
	{
		div_obj.className	=	'show err';
		div_obj.innerHTML	=	'输入不符合规范';
		return false;
	}
	else
	{
		div_obj.className	=	'show exactness';
		div_obj.innerHTML	=	'';
		return true;
	}
}

function check_needage()
{
	var neagemin	=	document.getElementById('needage_min').value;
	var neagemax	=	document.getElementById('needage_max').value;
	
	if(neagemin	==	''	&&	neagemax	==	'')
	{
		return true;
	}
	
	if(neagemin	==	'')
	{
		neagemin	=	0;
	}
	if(neagemax	==	'')
	{
		neagemax	=	0;
	}
	
	var div_obj		=	document.getElementById('needage_div');

	neagemin	=	parseInt(neagemin);
	neagemax	=	parseInt(neagemax);

	if((neagemin	<	18	&&	neagemin	!=	0)	||	neagemax	> 99)
	{
		div_obj.className	=	'show err';
		div_obj.innerHTML	=	'输入不符合规范';
		return false;
	}

	if(neagemin	!=	0	&&	neagemax	!=	0)
	{
		if(neagemax	<	neagemin)
		{
			div_obj.className	=	'show err';
			div_obj.innerHTML	=	'输入不符合规范';
			return false;
		}
	}
	div_obj.className	=	'show exactness';
	div_obj.innerHTML	=	'';
	return true;
}

function check_needheight()
{
	var neheimin	=	document.getElementById('needheight_min').value;
	var neheimax	=	document.getElementById('needheight_max').value;
	
	if(neheimin	==	''	&&	neheimax	==	'')
	{
		return true;
	}
	
	if(neheimin	==	'')
	{
		neheimin	=	0;
	}
	if(neheimax	==	'')
	{
		neheimax	=	0;
	}
	
	var div_obj		=	document.getElementById('needheight_div');

	neheimin	=	parseInt(neheimin);
	neheimax	=	parseInt(neheimax);

	if((neheimin	<	130	&&	neheimin	!=	0)	||	neheimax	> 260)
	{
		div_obj.className	=	'show err';
		div_obj.innerHTML	=	'输入不符合规范';
		return false;
	}

	if(neheimin	!=	0	&&	neheimax	!=	0)
	{
		if(neheimax	<	neheimin)
		{
			div_obj.className	=	'show err';
			div_obj.innerHTML	=	'输入不符合规范';
			return false;
		}
	}
	div_obj.className	=	'show exactness';
	div_obj.innerHTML	=	'';
	return true;
}
//Check submit form error
//检测整个表单
function chkForm_new(objForm)
{
	var objForm;
	var re = /^[_a-zA-Z0-9\-\_\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;//验证邮箱
	var qq = /^[a-zA-Z0-9\-\.]+@+([qQ][qQ]+\.)+[a-zA-Z0-9]{2,3}$/;//验证QQ邮箱
	var vipqq = /^[a-zA-Z0-9\-\.]+@+[vV][iI][pP]\.+([qQ][qQ]+\.)+[a-zA-Z0-9]{2,3}$/;//vipQQ邮箱
	//var rs = /^[0-9]{3}$/;
	var rs = /^[0-9]{2,3}$/;//身高
	//var rc = /^[0-9]{5}$/;
	var rc = /^[a-zA-Z0-9]{5}$/;//验证码

	var email		= objForm.email.value.trim();
	var password	 = objForm.password.value;
	var nickname	 = objForm.nickname.value;
	var year		 = objForm.year.value;
	var month		= objForm.month.value;
	var day		  = objForm.day.value;
	var height	   = objForm.height.value;
	var marriage	 = objForm.marriage.value;
	var degree	   = objForm.degree.value;
	var income	   = objForm.income.value;
	var province	 = objForm.province.value;
	var city		 = objForm.city.value;
	var checkcode	= objForm.checkcode.value;
	//add by liuwei at 2010-04-21
	var note	= "" ;
	if(noteObject.index == 1 ){
	  note  = objForm.note.value;
    }else{
      if(noteObject.createNote == false){
       var v1 = document.getElementById("input1").value;	
	   var v2 = document.getElementById("input2").value;	
	   var v3 = document.getElementById("input3").value;	
	   var v4 = document.getElementById("input4").value;
       if(v1=="" && v2 == "" && v3=="" && v4==""){
	     document.getElementById("regnoteinfo").style.display ='';
         document.getElementById('regnoteinfo').className="show null"; 
         document.getElementById("regnoteinfo").innerHTML="对未来的TA不想说点什么吗？请至少输入一项吧!";
         return false;
       }else{
        // document.getElementById("regnoteinfo").innerHTML="请点击右下方“点击生成内心独白”按钮，生成独白。";
          var v5 ="";
          if(v1 !=""){
           v5 +="我喜欢"+v1+"。";
          }
          if(v2 !=""){
          v5  +="我在业余时间最大的消遣是"+v2+"。";
          }
          if(v3 !=""){
           v5 +="我憧憬的生活是"+v3+"。";
          }
          if(v4 !=""){
           v5 +="我希望我未来的另一半最好是"+v4+"。" ;
          }
           v5 +="真心希望在这里能遇到我的那个TA!" ; 
        objForm.noteHelp.value = v5;
       }
      
      }
      note  = objForm.noteHelp.value;
    }
    note = note.trim();
    
	var date = new Date();
	var now  = date.getFullYear();
	var age  = now - year;
	var filter = check_durty_words(objForm.nickname.value);
    //性别
    if(!(document.getElementById("sexf").checked || document.getElementById("sexm").checked))
	{
		//regsexinfo.className="show err";
		//regsexinfo.innerHTML="性别、生日、身高不能修改，请认真填写。";
		alert("请选择您的【性别】\n");
		document.getElementById("sexf").focus();
		return false;
	}
	//生日
		if (year == 0)
	{
		alert("请选择【出生年月】 - 年\n");
		objForm.year.focus();
		return false;
	}

	if (month == 0)
	{
		alert("请选择【出生年月】 - 月\n");
		objForm.month.focus();
		return false;
	}

	if (day == 0)
	{
		alert("请选择【出生年月】 - 日\n");
		objForm.day.focus();
		return false;
	}
	//所在地区
	if (province == 0)
	{
		alert("请选择【所在地区】 - 省份\n");
		objForm.province.focus();
		return false;
	}

	if (city == 0)
	{
		alert("请选择【所在地区】 - 城市\n");
		objForm.city.focus();
		return false;
	}
	//
 
    //手机号验证
    var is_mobile_value = document.getElementById("register_type") ;
	if(is_mobile_value && is_mobile_value.value==1)
	{ 
		   var m =document.getElementById('mobile').value;
		   if(!is_mobile(m))
		   {
			   document.getElementById('regmobileinfo').className = "show null";
			   document.getElementById('regmobileinfo').innerHTML = "请填有效手机号~";
			   alert("您填写的手机号不符合规范\n");
			   document.getElementById('mobile').focus();
			   return false;
		   }
		   //是否已经被占用
		   if(/该号已注册/.test(document.getElementById("regmobileinfo").innerHTML))
		   {
			    alert("您填写的手机号不符合规范\n");
				document.getElementById('mobile').focus();
				return false;
		   }
		   //手机验证码
		   var vali = document.getElementById('mobile_vali').value;

		   if(!/^\d{1,5}$/.test(vali))
		   {
			   document.getElementById('regmobilevalueinfo').className = "show null";
			   document.getElementById('regmobilevalueinfo').innerHTML = "请填正确格式的验证码";
			   alert("请填正确格式的验证码\n");
			   document.getElementById('mobile_vali').focus();
			   return false;
		  }
		  if(/无效验证码/.test(document.getElementById('regmobilevalueinfo').innerHTML))
		  {
			  alert("无效验证码，请重新填写\n");
			  document.getElementById('mobile_vali').focus();
			  return false;
		  }
	}else
	{
		 	for(var i=0;i<email.length;i++)
			{   
			   strCode=email.charCodeAt(i);   
			   if((strCode>65248)||(strCode==12288)){   
						 alert("【注册邮箱】含全角字符，请切换输入法，输入半角字符");
						 objForm.email.focus();
					   return false;
			   } 
			}  
			
			if (email == "" || (!email.match(re)) || email.match(/^(_|\-|\.)/))
			{
				alert("【注册邮箱】不能为空或格式不符合规范\n");
				objForm.email.focus();
				return false;
			}
			/*if (email.match(qq) || email.match(vipqq))
			{
				alert("【注册邮箱】不能为qq邮箱\n");
				objForm.email.focus();
				return false;
			}*/
			if (document.getElementById('regemailinfo').innerHTML=="您填写的邮箱已被占用")
			{
				alert("您填写的邮箱已被占用\n");
				objForm.email.focus();
				return false;
			}
	}

	if (password == "" || (password.length < 6 || password.length > 20))
	{
		alert("【佳缘密码】不能为空或长度不符合规范\n");
		objForm.password.focus();
		return false;
	}

	if (objForm.password.value != objForm.chkpass.value)
	{
		alert("【确认密码】与密码不一致\n");
		objForm.chkpass.focus();
		return false;
	}

	if (nickname == "" || (nickname.trim().ByteCount()<2 || nickname.trim().ByteCount()>20))
	{
		alert("【会员昵称】不能为空或格式不符合规范\n");
		objForm.nickname.focus();
		return false;
	}

	if (filter)
	{
		alert("“"+filter+"”不能在昵称中使用\n");
		objForm.nickname.focus();
		return false;
	}


	if (marriage == 0)
	{
		objForm.marriage.focus();
		alert("请选择【婚姻状况】\n");
		return false;
	}
		
	if (height == "" || (!height.match(rs))  || (height < 130 || height > 260))
	{
		alert("【我的身高】不能为空或数值不符合规范\n");
		objForm.height.focus();
		return false;
	}



	if (degree == 0)
	{
		alert("请选择【学历】\n");
		objForm.degree.focus();
		return false;
	}

	if (income == 0)
	{
		alert("请选择【月薪】\n");
		objForm.income.focus();
		return false;
	}

	if (age <= 19)
	{
		if(income >= 40)
		{
			alert("【出生年月】对应的【月薪】不符合实际情况\n");
			objForm.income.focus();
			return false;
		}
		if (degree >= 50)
		{
			alert("【出生年月】对应的【学历】不符合实际情况\n");
			objForm.degree.focus();
			return false;
		}		
		if (document.getElementById("sexf").checked && marriage >= 2)
		{
			alert("【出生年月】对应的【婚姻状况】不符合实际情况\n");
			objForm.year.focus();
			return false;
		}
		if (document.getElementById("sexm").checked && marriage >= 2)
		{
			alert("【出生年月】对应的【婚姻状况】不符合实际情况\n");
			objForm.year.focus();
			return false;
		}
	}
	else if (age <= 20)
	{
		if(income >= 40)
		{
			alert("【出生年月】对应的【月薪】不符合实际情况\n");
			objForm.income.focus();
			return false;
		}
		if (degree >= 50)
		{
			alert("【出生年月】对应的【学历】不符合实际情况\n");
			objForm.degree.focus();
			return false;
		}		
		if (document.getElementById("sexf").checked && marriage >= 2)
		{
			alert("【出生年月】对应的【婚姻状况】不符合实际情况\n");
			objForm.year.focus();
			return false;
		}
		if (document.getElementById("sexm").checked && marriage >= 2)
		{
			alert("【出生年月】对应的【婚姻状况】不符合实际情况\n");
			objForm.year.focus();
			return false;
		}
	}
	else if (age <= 21)
	{
		if (degree >= 60 && income >= 40)
		{
			alert("【出生年月】对应的【学历】【月薪】都不符合实际情况\n");
			objForm.degree.focus();
			return false;
		}
		if (degree >= 60)
		{
			alert("【出生年月】对应的【学历】不符合实际情况\n");
			objForm.degree.focus();
			return false;
		}
		if (income >= 40)
		{
			alert("【出生年月】对应的【月薪】不符合实际情况\n");
			objForm.income.focus();
			return false;
		}
		if (document.getElementById("sexm").checked && marriage >= 2)
		{
			alert("【出生年月】对应的【婚姻状况】不符合实际情况\n");
			objForm.year.focus();
			return false;
		}
	}
	else if (age <= 22)
	{
		if (document.getElementById("sexm").checked && marriage >= 2)
		{
			alert("【出生年月】对应的【婚姻状况】不符合实际情况\n");
			objForm.year.focus();
			return false;
		}
		if (income >= 50)
		{
			alert("【出生年月】对应的【月薪】不符合实际情况\n");
			objForm.income.focus();
			return false;
		}
	}
	else if (age <= 23 && (degree >= 70))
	{
		alert("【出生年月】对应的【学历】不符合实际情况\n");
		objForm.degree.focus();
		return false;
	}
	else if (age <= 26 && income >= 70)
	{
		alert("【出生年月】对应的【月薪】不符合实际情况\n");
		objForm.income.focus();
		return false;
	}
	else
	{
		//虚假用户判断完毕
	}
    //独白
	if (note != "" && (note.length < 20 || countSize(note) >3000 || /^您知道吗？/.test(note)))
	{
		alert("【内心独白】不能为空或长度不符合规范\n");
		document.getElementById('regnoteinfo').style.display="";
		document.getElementById('regnoteinfo').className="show null";
		if(countSize(note) >3000){
		  document.getElementById('regnoteinfo').innerHTML ="您写的内心独白太多了，TA似乎没有耐心看哦";
		}else{
		   document.getElementById('regnoteinfo').innerHTML ="您写的“内心独白”太少了，也太没诚意了吧";
		}
		objForm.note.focus();
		return false;
	}

	if (note == "")
	{
		alert("【内心独白】不能为空或长度不符合规范\n");
		//alert("请您补充【内心独白】，打动有缘人\n");
		document.getElementById('regnoteinfo').style.display="";
		document.getElementById('regnoteinfo').className="show null";
		document.getElementById('regnoteinfo').innerHTML ="您没有写“内心独白”哦，对未来的TA不想说点什么吗？";
		objForm.note.focus();
		return false;
	}

	/*if(!check_mobile())
	{
		document.getElementById('mobile').focus();
		alert("请填写正确的手机号");
		return false;
	}*/
    //验证码
	if (checkcode == "" || (!checkcode.match(rc)))
	{
		alert("【验证码】不能为空或字符不符合规范\n");
		objForm.checkcode.focus();
		return false;
	}
	if (document.getElementById('regcheckcodeinfo').innerHTML=="请输入验证码" || document.getElementById('regcheckcodeinfo').innerHTML=="请正确输入验证码")
	{
		alert("请正确输入验证码\n");
		objForm.checkcode.focus();
		return false;
	}
	if(!document.getElementById("readme").checked)
	{
		document.getElementById('regreadmeinfo').style.display = "";
	    document.getElementById('regreadmeinfo').innerHTML ="请阅读并进行选择";
		document.getElementById('regreadmeinfo').className = "show null";
		alert("您尚未阅读并同意注册条款，请阅读并选择\n");
		return false;
	}

	return true;
}
//条例验证
function click_readme(value)
{
   if(value)
   {
        document.getElementById('regreadmeinfo').style.display = "";
	    document.getElementById('regreadmeinfo').innerHTML ="";
		document.getElementById('regreadmeinfo').className = "show exactness";
   }else
   {
        document.getElementById('regreadmeinfo').style.display = "";
	    document.getElementById('regreadmeinfo').innerHTML ="请阅读并进行选择";
		document.getElementById('regreadmeinfo').className = "show null";
   }
}
//注册提交
function reg_sub()
{   
 
	var obj	=	document.getElementById('Form1');
	if(!chkForm_new(obj))
	{
		return false;
	}
    //add by liuwei at 2010-04-21
	var note	= "" ;
	if(noteObject.index == 1 ){
	  note  = obj.note.value.trim();
    }else{
      note  = obj.noteHelp.value.trim();
    }
	obj.note.value = note;
	//end add 
	//艾德 
    //try{trackRegister();}catch(e){}
	obj.submit();
}
function click_othernote() {
		xajax_processTraceUser(xajax.getFormValues("Form1"),'seenote');
}

function click_entermain() {
		xajax_processTraceUser(xajax.getFormValues("Form1"),'entermain');
}

function click_submit() {
		xajax_processTraceUser(xajax.getFormValues("Form1"),'submit');
}

function click_admain() {
		xajax_processTraceUser(xajax.getFormValues("Form1"),'clickadmain');
}

function click_adreg() {
		xajax_processTraceUser(xajax.getFormValues("Form1"),'clickadreg');
}

function click_adregpic() {
		xajax_processTraceUser(xajax.getFormValues("Form1"),'clickadregpic');
}

function click_adsearch() {
		xajax_processTraceUser(xajax.getFormValues("Form1"),'clickadsearch');
}
function click_adlogin() {
		xajax_processTraceUser(xajax.getFormValues("Form1"),'clickadlogin');
}

 // 手机号码验证，验证13系列和150-159(154除外)、180、185、186、187、188、189几种号码，长度11位 
 function is_mobile(value)   
 {   
	 if(value.match(/^13\d{9}$/g)||value.match(/^15[0-35-9]\d{8}$/g)|| value.match(/^18[05-9]\d{8}$/g)){       
		return true;   
	 }else{   
		return false;   
	 }   
}  
//验证手机号
function check_mobile_input(obj)
{
   var v = obj.value;
   if(!is_mobile(v))
   {
       document.getElementById('regmobileinfo').className = "show null";
	   document.getElementById('regmobileinfo').innerHTML = "请填有效手机号~";
   }else
   {
       document.getElementById('email').value=v+"@jiayuan.com";
       xajax_processUserMobile(xajax.getFormValues("Form1"));
   }
}
//开始填写手机号
function click_mobile_input(obj)
{
    xajax_processUserMobile(xajax.getFormValues("Form1"),"mobile");
}
//切换手机号，邮箱注册
function changeTabdd(type)
{
   var link = document.getElementById("tabname");
   if(link)
   {
	   if(document.getElementById("email_reg_dd") && document.getElementById("email_reg_dd").style.display != "none")
	   {
		   link.innerHTML="切换至邮箱注册";
		   document.getElementById("email_reg_dd").style.display="none";
		   document.getElementById("checkcode_dd").style.display="none";
		   document.getElementById("mobile_reg_dd").style.display="block";
		   document.getElementById("mobile_reg_value").style.display="block";
		   document.getElementById("checkcode").value="abcde";
		   document.getElementById("register_type").value=1;
		   document.getElementById("mobile_vali").value="";
		   if(!type)
		   {
			  document.getElementById("mobile").value="";
		   }
		   document.getElementById("mobile").focus();
		   //ajax.get("notecount.class.php",{data:'m_reg',method:'clickCloseWindow'},function(req){});
		   if(typeof send_jy_pv2 == 'function')
		   {
		     send_jy_pv2("reg_mobile_button_click_count");
		   }
	   }else
	   {
		   link.innerHTML="如果没有邮箱，可以用手机号注册";
		   document.getElementById("email_reg_dd").style.display="block";
		   document.getElementById("checkcode_dd").style.display="block";
		   document.getElementById("mobile_reg_value").style.display="none";
		   document.getElementById("mobile_reg_dd").style.display="none";
		   document.getElementById("register_type").value=0;
		   document.getElementById("checkcode").value="";
		   document.getElementById('email').value="";
		   document.getElementById("email").focus();

		  
	   }
   }
}
function sendmessage()
{
  var m = document.getElementById("mobile").value ;
  if(is_mobile(m))
  {
    xajax_processSendOrUpdateMessage(xajax.getFormValues("Form1"),"mobile");
  }
}
//验证码是否正确
function check_mobile_vali(obj)
{
    if(!/^\d{1,5}$/.test(obj.value))
	{
	   document.getElementById('regmobilevalueinfo').className = "show null";
	   document.getElementById('regmobilevalueinfo').innerHTML = "请填正确格式的验证码";
	   return ;
	}
	xajax_processValidatorMessage(xajax.getFormValues("Form1"),"mobile_vali");
}
//end at 2010-10-25 with will 
