﻿// JavaScript Document
G('login').className="ontab";
function pr_creat(){pop=null;pop=new Popup({ contentType:1,isReloadOnClose:false,width:340,height:80});pop.setContent("title","刷新主页");pop.setContent("contentUrl","/my/profile.asp?action=creat");pop.build();pop.show();}
//filter keywords
function check_durty_words(thisinput)
{
	var durty_words = new Array("系统","管理","nslove","master","版主","斑竹","power","客服","root","颁奖","活动","提示","兑奖","通知");
	for(i=0;i<durty_words.length;i++)
	{
		if (thisinput.indexOf(durty_words[i])	>=	0)
		{
			return durty_words[i];
		}
	}
	return false;
}

//mouse onclick the email box
function click_email_input(thisinput)
{
	email.className = "suc";
	email.innerHTML = "请您输入常用信箱用于登录！";
}

//mouse lost the email box
function check_email_input(thisinput)
{
	var re = /^[_a-zA-Z0-9\-\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;
	if ( (thisinput.value.trim() == "") ) {
		email.className = "null";
		email.innerHTML = "系统未检测到您的输入";
	}
	else if (!thisinput.value.match(re))
	{
		email.className = "err";
		email.innerHTML = "邮件地址输入不符合规范";
	}
	else
	{
		var ajaxobj=new AJAXRequest;
		ajaxobj.method="POST"; 
		ajaxobj.url="/reg.asp?action=chk&name="+escape(thisinput.value) +"";
		ajaxobj.callback=function(xmlobj) {
			var response = xmlobj.responseText.split("@@");
			if (response[0]!='0') {
				email.className = "suc";
				email.innerHTML = response[1];
				}else{email.className = "err";
				email.innerHTML = response[1];}
			}
		ajaxobj.send();
	}
}

//mouse onclick the password box
function click_password_input(thisinput)
{
	pass.className = "suc";
	pass.innerHTML = "填写6～20位的密码";
}

//mouse lost the password box
function check_password_input(thisinput)
{
	var count = thisinput.value.trim().ByteCount();

	if (thisinput.value.trim() == "") {
		pass.className="null";
		pass.innerHTML="系统未检测到您的输入";
	}
	else if (count < 6 || count > 20)
	{
		pass.className = "err";
		pass.innerHTML = "输入不符合规范";
	}
	else
	{
		pass.className = "suc";
		pass.innerHTML = "内容符合规范，可以使用";
	}
}

//mouse onclick the chkpass box
function click_chkpass_input(thisinput)
{
	var oPass = G("password").value;
	if( oPass == "")
	{
		G("password").focus();
	}else{
		pass1.className="suc";
		pass1.innerHTML="请输入确认密码";
	}
}

//mouse lost the chkpass box
function check_chkpass_input(thisinput)
{
	var oPass = G("password").value;
	if(thisinput.value.trim() == "")
	{
		pass1.className="null";
		pass1.innerHTML = "系统未检测到您的输入";
	}
	else if(thisinput.value != oPass)
	{
		pass1.className="err";
		pass1.innerHTML = "确认密码与密码不一致";
	}
	else
	{
		pass1.className = "suc";
		pass1.innerHTML = "密码确认通过";
	}
}

//mouse onclick the nickname box
function click_nickname_input(thisinput)
{
	nickname.className="suc";
	nickname.innerHTML="昵称限制在在2-10个汉字以内";
}

//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 )
	{
		nickname.className="null";
		nickname.innerHTML="系统未检测到您的输入";
	}
	else if ((thisinput.value.trim() != "") && (count < 2 || count > 20)) {
		nickname.className="err";
		nickname.innerHTML="输入不符合规范";
	}
	else if (filter)
	{
		nickname.className = "err";
		nickname.innerHTML = "“"+filter+"”不能在昵称中使用";
	}
	else
	{
		nickname.className = "suc";
		nickname.innerHTML = "内容符合规范，可以使用";
	}
}

//mouse onclick the note textarea
function click_note_input(thisinput)
{
	noteinfo.className="suc";
	noteinfo.innerHTML="限20字到1000字之间";
}

//mouse lost the note textarea
function check_note_input(thisinput)
{
	if( thisinput.value.length == 0 )
	{
		noteinfo.className="null";
		noteinfo.innerHTML="系统未检测到您的输入";
	}
	else if((thisinput.value != "") && (thisinput.value.length < 20 || thisinput.value.length > 1000))
	{
		noteinfo.className="err";
		noteinfo.innerHTML="输入不符合规范";
	}
	else
	{
		noteinfo.className = "suc";
		noteinfo.innerHTML = "内容符合规范，可以使用";
	}
}
//mouse onclick the workprovince box
function click_province_input(thisinput)
{
	areainfo.className="suc";
	areainfo.innerHTML="请选择您所在的省份";
}

//mouse lost the workprovince box
function check_province_input(thisinput)
{
	if( thisinput.value.trim() == 0 )
	{
		areainfo.className="null";
		areainfo.innerHTML="系统未检测到您的输入";
	}
	else
	{
		areainfo.className = "null";
		areainfo.innerHTML = "请选择您所在的城市";
	}
}

//mouse onclick the workcity box
function click_city_input(thisinput)
{
	areainfo.className="suc";
	areainfo.innerHTML="请选择您所在的城市";
}

//mouse lost the workcity box
function check_city_input(thisinput)
{
	if( thisinput.value.trim() == 0 )
	{
		areainfo.className="null";
		areainfo.innerHTML="系统未检测到您的输入";
	}
	else
	{
		areainfo.className = "suc";
		areainfo.innerHTML = "内容符合规范，可以使用";
	}
}
//mouse onclick the workcity box
function click_area_input(thisinput)
{
	areainfo.className="suc";
	areainfo.innerHTML="请选择您所在的县/区";
}

//mouse lost the workcity box
function check_area_input(thisinput)
{
	if( thisinput.value.trim() == 0 )
	{
		areainfo.className="null";
		areainfo.innerHTML="系统未检测到您的输入";
	}
	else
	{
		areainfo.className = "suc";
		areainfo.innerHTML = "内容符合规范，可以使用";
	}
}
//mouse onclick the checkcode box
function click_code_input(thisinput)
{
	codeinfo.className="suc";
	codeinfo.innerHTML="请填写图片中的数字";
}


//mouse lost the checkcode box
function check_code_input(thisinput)
{
	if(thisinput	==	'codeinfo')
	{
		codeinfo.className="null";
		codeinfo.innerHTML="请重新输入验证码";	
		return;	
	}


	var count = thisinput.value.trim().ByteCount();
	var rc = /^[0-9]{4}$/;


	if (count == 0)
	{
		codeinfo.className="null";
		codeinfo.innerHTML="系统未检测到您的输入";
	}
	else if (!thisinput.value.match(rc))
	{
		codeinfo.className="err";
		codeinfo.innerHTML="输入不符合规范";
	}
	else
	{
		codeinfo.className = "suc";
		codeinfo.innerHTML = "内容符合规范，可以使用";
	}
}

//Check submit form error
function chkForm(objForm)
{
	var objForm;
	var re = /^[_a-zA-Z0-9\-\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;
	var rs = /^[0-9]{3}$/;
	var rc = /^[0-9]{4}$/;
	var objName=objForm.name;
	var email		= objForm.useremail.value;
	var password	 = objForm.password.value;
	var nickname	 = objForm.username.value;
	var year		 = objForm.year.value;
	var month	= objForm.month.value;
	var day		  = objForm.day.value;
	var height	   = objForm.height.value;
	var userfind	 = objForm.userfind.value;
	var marriage	 = objForm.marital.value;
	var degree	   = objForm.education.value;
	var Income	   = objForm.Income.value;
	var province	 = objForm.province.value;
	var city		 = objForm.city.value;
	if (objName=='RegForm'){
	var GetCode	= objForm.GetCode.value;
}
	var note		 = objForm.note.value;
	var date = new Date();
	var now  = date.getYear();
	var age  = now - year;
	var filter = check_durty_words(nickname);

	if (email == "" || (!email.match(re)))
	{
		alert("【注册邮箱】不能为空或格式不符合规范\n");
		objForm.useremail.focus();
		return false;
	}
if (objName=='RegForm'){
	if (password == "" || (password.length < 6 || password.length > 20))
	{
		alert("【登录密码】不能为空或长度不符合规范\n");
		objForm.password.focus();
		return false;
	}
	if (objForm.password.value != objForm.password1.value)
	{
		alert("【确认密码】与密码不一致\n");
		objForm.password1.focus();
		return false;
	}
}
	if (nickname == "" || (nickname.trim().ByteCount()<2 || nickname.trim().ByteCount()>20))
	{
		alert("【会员昵称】不能为空或格式不符合规范\n");
		objForm.username.focus();
		return false;
	}

	if (filter)
	{
		alert("“"+filter+"”不能在昵称中使用\n");
		objForm.username.focus();
		return false;
	}

	if(!(G("sexf").checked || G("sexm").checked))
	{
		//regsexinfo.className="show err";
		//regsexinfo.innerHTML="性别、生日、身高不能修改，请认真填写。";
		alert("请选择您的【性别】<性别、生日、身高注册后不能修改>\n");
		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 (userfind == 0)
	{
		objForm.userfind.focus();
		alert("请选择【交友目的】\n");
		return false;
	}
	if (height == "" || (!height.match(rs))  || (height < 130 || height > 260))
	{
		alert("【我的身高】不能为空或数值不符合规范\n");
		objForm.height.focus();
		return false;
	}
	
	if (marriage == 0)
	{
		objForm.marital.focus();
		alert("请选择【婚姻状况】\n");
		return false;
	}

	if (degree == 0)
	{
		alert("请选择【学历】\n");
		objForm.education.focus();
		return false;
	}

	if (Income == 0)
	{
		alert("请选择【月薪】\n");
		objForm.Income.focus();
		return false;
	}

	if (province == 0)
	{
		alert("请选择【所在地区】 - 省份\n");
		objForm.province.focus();
		return false;
	}

	if (city == 0)
	{
		alert("请选择【所在地区】 - 城市\n");
		objForm.city.focus();
		return false;
	}
	if (!G("nonote").checked){
		if (note== "" || (note.length < 20 || note.length >1000))
		{
			alert("【内心独白】长度不符合规范\n");
			objForm.note.focus();
			return false;
		}
	}
	
	if (objName=='RegForm'){
		if (GetCode == "" || (!GetCode.match(rc)))
		{
			alert("【验证码】不能为空或字符不符合规范\n");
			objForm.GetCode.focus();
			return false;
		}
		if(!G("readme").checked)
		{
			alert("请勾选【极速交友条款】才能完成注册\n");
			return false;
		}
	}
	checkform(objName);
}


function checkform(objID){
	pop=new Popup({ contentType:1, isReloadOnClose:false, width:380, height:80});
	pop.setContent("title","会员注册");
	pop.setContent("contentUrl","");
	pop.build();
	pop.show();
	G(objID).target=pop.iframeIdName;
	//setTimeout(function(){pop.close()},3000);
	return true;
}

function detail(objForm){
	var objForm;
	if (objForm.blood.value=='0'){
			alert("请选择[血型]");
			objForm.blood.focus();
			return false;
		}
	if (objForm.industry.value=='0'){
			alert("请选择[职业类型]");
			objForm.industry.focus();
			return false;
		}else{
			var industry=objForm.industry.value;
			if (industry=='1'){
				if (objForm.unienter.value=='0'){
					alert("请选择[入学年份]");
					objForm.unienter.focus();
					return false;
					}
				if (objForm.speciality.value=='0'){
					alert("请选择[专业类型]");
					objForm.speciality.focus();
					return false;
					}
				}
			
			}

	var regs = /\d/; 
	if (! regs.test(objForm.weight.value)){
		alert("请输入体重单位:公斤/Kg");
		objForm.weight.focus();
		return false;
	}else{
		var weight=objForm.weight.value;
		if (weight>150 || weight<30){
			alert("请输入体重在30-150Kg的数字！");
			objForm.weight.focus();
			return false;}
		}
	if (objForm.userFolk.value=='0'){
			alert("请选择[民族]");
			objForm.userFolk.focus();
			return false;
		}
	if (objForm.houses.value=='0'){
			alert("请选择[住房情况]");
			objForm.houses.focus();
			return false;
		}	
	if (objForm.Children.value=='0'){
			alert("请选择[有否子女]");
			objForm.Children.focus();
			return false;
		}
	if (objForm.Corptype.value=='0'){
			alert("请选择[公司类型]");
			objForm.Corptype.focus();
			return false;
		}
	if (objForm.unilocat.value=='0'){
			alert("请选择[毕业省份]");
			objForm.unilocat.focus();
			return false;
		}
	if (objForm.graduate.value=='0'){
			alert("请选择[毕业院校]");
			objForm.graduate.focus();
			return false;
		}
	if (objForm.Health.value=='0'){
			alert("请选择[健康情况]");
			objForm.Health.focus();
			return false;
		}
	if (objForm.province.value=='0'){
			alert("请选择[所有省份]");
			objForm.province.focus();
			return false;
		}
	if (objForm.city.value=='0'){
			alert("请选择[所有市区]");
			objForm.city.focus();
			return false;
		}
checkform(objForm);
}

function fondsel(sel,selectid){
	var value=G(selectid).value;
	if (value!=''){
		arr=value.split("，");
		if (arr.length<=2){//2为项目个数
		for (var i=0;i < arr.length; i++){
			if (sel!=arr[i]){
				var result=value+"，"+sel;
			}else{return;}
		}
		}else{
			alert("最多可以选择三项!")
			return;}
	}else{result=sel;}
	G(selectid).value=result;
}
function seltag(sex,utag){
	var str="";
	var fstr=new Array("孝顺是我的美德","享受小资生活","是美女也是才女","从不以貌取人","相信一见钟情","爱一个人包括缺点","我忙碌且充实","有故事的人","精于琴棋书画","贤妻良母的气质","旅行是生活一部分","我的厨艺色香味俱全","可爱野蛮女友","等待王子的灰姑娘","喜欢主动约会朋友","喜欢小动物","怀有一颗平常心","迟到是女人的特权");
	var mstr=new Array("百善孝为先","衣食无忧乐无边","家庭事业兼顾的男人","欣赏同甘共苦的爱情","从不以貌取人","相信一见钟情","每天忙忙碌碌","有故事的人","通晓天文地理","老实却不乏风趣","有很多旅行计划","我的厨艺色香味俱全","总是遵守女士优先","路见不平一声吼","喜欢主动约会朋友","逗小朋友是我拿手好戏","会大声说我爱你","从不喜欢迟到");
	var tagstr=new Array();
	utag=utag.split(',');
	if (sex!=1){tagstr=mstr;}else{tagstr=fstr;}
	for (var i=0;i<tagstr.length;i++){
		str=str+"<span><input type='checkbox' name='usertag' onclick='check_tag(this);' value='"+tagstr[i]+"' id='tag_"+(i+1)+"'";
		for (var t=0;t<utag.length;t++){
			if (utag[t]==tagstr[i])
				{str=str+"checked='true'";}
			}
		str=str+" /> "+tagstr[i]+"</span>";
	}
	document.write (str);
}

function check_tag(obj)
{
	if(obj.checked)
	{
		var k	=	0;
		var Oform	=	G('RegForm');
		for(i=0;i<Oform.elements.length;i++)
		{
			if(Oform.elements[i].type	==	'checkbox' && Oform.elements[i].name	==	'usertag' &&	Oform.elements[i].checked)
			{
				k++;
			}
			if(k	>	5)
			{
				obj.checked	=	false;
				alert('佳缘标签最多只能选择5个');
				return false;
			}
		}
	}
}
function change_ind(){
	var ind_value	=	G('industry').value;
	if(ind_value	==	'1')
	{
		G('stu_title').style.display	=	'';
		G('stu_cont').style.display	=	'';
	}
	else
	{
		G('stu_title').style.display	=	'none';
		G('stu_cont').style.display	=	'none';
	}
}
function load_ind(s){
	if (s=='1'){
		G('stu_title').style.display	=	'';
		G('stu_cont').style.display	=	'';
		}
	}
function beau_look(s){
	var str="";
	var fstr=new Array("文质彬彬型","西部牛仔型","阳光帅气型","风度翩翩型","成熟魅力型","健壮高大型","朴实无华型","内敛酷男型");
	var mstr=new Array("秀外慧中型","眉清目秀型","明眸善睐型","娇小依人型","青春活泼型","成熟魅力型","雍容华贵型","淡雅如菊型");
	var lookstr=new Array();
	if (s!=1){lookstr=fstr;}else{lookstr=mstr;}
	for (var i=0;i<lookstr.length;i++){
		str=str+"<option value='"+ (i+1) +"'>"+ lookstr[i]+"</option>";
		}
		document.write (str);
	}

function doedit(s,t){
	G("div_"+s).style.display	='none';
	G("div_"+s+"_e").style.display='block';
	G("em_"+s).innerHTML="<a href=\"javascript:s_edit('"+s+"','"+t+"');\">保存</a>&nbsp;&nbsp;<a href=\"javascript:c_edit('"+s+"','"+t+"')\">取消</a>";
}
function c_edit(s,t)
{
	G("div_"+s+"_e").style.display = 'none';
	G("div_"+s).style.display = 'block';
	G("em_"+s).innerHTML="<a href=\"javascript:doedit('"+s+"','"+t+"')\">修改</a>";
}
function s_edit(s,t){
	var v=G(s).value;
	G("div_"+s+"_e").style.display = 'none';
	G("div_"+s).style.display = 'block';
	G("div_"+s).innerHTML="正在处理中...";
	if (s=='province'){
		c=G('city').value;
		a=G('area').value;
		if (c=='0'){
			G("div_"+s).style.display = 'none';
			G("div_"+s+"_e").style.display = 'block';
			alert('请选择户籍所在市!');
			}
			else{var url="profile.asp?action=pfsave&id="+escape(t)+"&form="+escape(v)+"&form1="+c+"&form2="+a+"&field="+s;
			}
		}
	else if (s=='wprovince'){
		c=G('wcity').value;
		a=G('warea').value;
		if (c=='0'){
			G("div_"+s).style.display = 'none';
			G("div_"+s+"_e").style.display = 'block';
			alert('请选择工作所在市!');
			}
			else{var url="profile.asp?action=pfsave&id="+escape(t)+"&form="+escape(v)+"&form1="+c+"&form2="+a+"&field="+s;
			}
		}
	else if(s=='unilocat'){
		c=G('graduate').value;
		if (c=='0'){
			G("div_"+s).style.display = 'none';
			G("div_"+s+"_e").style.display = 'block';
			alert('请选择学校名称!');
			}
			else{var url="profile.asp?action=pfsave&id="+escape(t)+"&form="+escape(v)+"&form1="+c+"&field="+s;
			}
		}
	else if(s=='petlike'){
		c=G('pet').value;
		if (c=='0'){
			G("div_"+s).style.display = 'none';
			G("div_"+s+"_e").style.display = 'block';
			alert('请选择宠物种类!');
			}
			else{var url="profile.asp?action=pfsave&id="+escape(t)+"&form="+escape(v)+"&form1="+c+"&field="+s;
			}
		}
	else{var url="profile.asp?action=pfsave&id="+escape(t)+"&form="+escape(v)+"&field="+s;}
	var ajaxobj=new AJAXRequest;
	ajaxobj.method="POST"; 
	ajaxobj.url=url;
	ajaxobj.callback=function(xmlobj) {
		var response = xmlobj.responseText;
		G("div_"+s+"_e").style.display = 'none';
		G("div_"+s).innerHTML=response;
		G("em_"+s).innerHTML="<a href=\"javascript:doedit('"+s+"','"+t+"')\">修改</a>";
	}
	ajaxobj.send();
}

