//////////////////////////////////////////////////////////////////////////////////////////////////////////
//File:     jsfun.php
//Author:   TZNKTG
//Purpose:  This page is display javascript function  
///////////////////////////////////////////////////////////////////////////////////////////////////////////

//确定下拉列表的值
function js_set_sel(obj, val)
{
    for (i=0; i<obj.length; i++)
    {
        if (obj.options[i].value == val)
        {
            obj.options[i].selected = true;
            break;
        }
    }
}

function linkjump(url)
{
	if(url != null && url != "")
	{     
      window.open(url, '' , 'toolbar=yes,menubar=yes, location=yes, directories=no, status=yes, scrollbars=yes, resizable=yes, width=800, height=600, ' + 'left=' + (screen.width - 800) / 2 + ', ' + 'top=' + (screen.height - 600) / 2);
    }    
 }

function doZoom(size)
{
	var zoom=document.all?document.all['Zoom']:document.getElementById('Zoom');
	zoom.style.fontSize=size+'px';
}

//搜索类型
function gettype()
{
	document.search.action=document.search.type.value;
	return true;
}


//会员登陆检测
function chklogin()
{
	var username=document.mlogin.username;
	var userpwd=document.mlogin.userpwd;
	if(username.value=="")
	{
		alert("请您输入用户名！");
		username.focus();
		return false;
	}
    if(userpwd.value=="")
	{
		alert("请您输入用户密码！");
		userpwd.focus();
		return false;
	}
	return true;	
}

//首页搜索检测
function chkms()
{
	var type=document.msearch.type;
	var startage=document.msearch.startage;
	var endage=document.msearch.endage;

	if (type[0].checked==false & type[1].checked==false) 
	{
		alert("请您选择搜索的性别");
		type[0].focus();	
		return false; 
	}
	if(startage.value=="" || isNaN(startage.value))
	{
		alert("请您填写搜索的年龄范围！");
		startage.focus();
		return false;
	} 
	if(endage.value=="" || isNaN(startage.value))
	{
		alert("请您填写搜索的年龄范围！");
		endage.focus();
		return false;
	} 
	if(startage.value>endage.value)
	{
		alert("请您有效地填写搜索的年龄范围！");
		startage.focus();
		return false;
	}
	return true;	
}


//高级搜索检测
function chkhs()
{
	var sex=document.hsearch.sex;
	var startage=document.hsearch.startage;
	var endage=document.hsearch.endage;

	if (sex[0].checked==false & sex[1].checked==false) 
	{
		alert("请您选择搜索的性别");
		sex[0].focus();	
		return false; 
	}
	if(startage.value=="")
	{
		alert("请您填写搜索的年龄范围！");
		startage.focus();
		return false;
	} 
	if(endage.value=="")
	{
		alert("请您填写搜索的年龄范围！");
		endage.focus();
		return false;
	} 
	return true;	
}

//昵称搜索检测
function chknk()
{
	var nickname=document.nksearch.nickname;
	if(nickname.value=="")
	{
		alert("请您填写昵称！");
		nickname.focus();
		return false;
	}   
	return true;	
}

//同生缘搜索检测
function chkym()
{
	var bym=document.ymsearch.bym;
	if(bym.value=="")
	{
		alert("请您填写同生缘！");
		bym.focus();
		return false;
	}   
	return true;	
}

//会员号搜索检测
function chkuid()
{
	var mid=document.uidsearch.mid;
	if(mid.value=="")
	{
		alert("请您填写会员号！");
		mid.focus();
		return false;
	}   
	return true;	
}

//找回密码检测
function chkbp()
{
	var username=document.backpwd.username;
	var email=document.backpwd.email;
	
	if(!isStr(username.value) || username.value.length > 20 || username.value.length < 5)
	{
		alert("对不起,用户名必须为英文字母、数字或下划线，长度为5~20。");
		username.focus();
		return false;
	}
	if (email.value=="")
	{
		alert("对不起,请您完整并正确地填写电子邮件Email!");
		email.focus();
		return false;
	}
	if(!isEmail(email.value)) {
        alert("对不起,您填写的电子邮件可能不正确!\n如果，您使用的是我们系统无法识别的电子邮件地址，请和我们联系!");
        email.focus();
        return false;
    }
	return true;	
}

//同生缘搜索检测
function chksd()
{
	var way=document.searchd.way;
	var keys=document.searchd.keys;
	if(way.value=="0")
	{
		alert("请您选择心情日记搜索方式！");
		way.focus();
		return false;
	}   
	if(keys.value=="")
	{
		alert("请您填写心情日记关键词！");
		keys.focus();
		return false;
	}   
	return true;	
}

//友情连接检测
function chklinks()
{
	var sitename=document.applylinks.sitename;
	var siteurl=document.applylinks.siteurl;
	//var sitelogo=document.applylinks.sitelogo;
	if(sitename.value=="")
	{
		alert("请您输入网站名称！");
		sitename.focus();
		return false;
	} 
    if(siteurl.value=="" || siteurl.value=="http://")
	{
		alert("请您输入网站地址！");
		siteurl.focus();
		return false;
	}
	/*if(sitelogo.value=="" || sitelogo.value=="http://")
	{
		alert("请您输入网站logo地址！");
		sitelogo.focus();
		return false;
	}*/
	return true;	
}

//联系电话检测
function check_telnum(str)
{
	var digits="1234567890-/";
	var i=0;
	var strlen=str.length;
	while((i<strlen))
	{
		var char=str.charAt(i);
		if(digits.indexOf(char)==-1)
		return false;i++;
	}
	return true;
}

//在线留言反馈信息发布检测
function chkmsg()
{
	var username=document.msgback.username;
	var address=document.msgback.address;
	var linktel=document.msgback.linktel;
	var title=document.msgback.title;
	var content=document.msgback.content;
		
	if(username.value=="")
	{
		alert("请您填写您的姓名！");
		username.focus();
		return false;
	}
	if(address.value=="")
	{
		alert("请您填写您的联系地址！");
		address.focus();
		return false;
	}

   	if(linktel.value.length==0)
	{
		alert ("请您填写您的联系电话！");		
        linktel.focus()       
		return false
	}
	/*if(linktel.value.length>0)
	{
		if(!check_telnum(linktel.value))
		{
			alert("请您填写有效的电话号码，格式如：0576-88698991");		
			linktel.focus();
			return false;
		}
    }*/
   	if(title.value==0)
	{
		alert("请您填写留言反馈的标题！");
		title.focus();
		return false;
	}
	if(content.value=="")
	{
		alert("请您填写留言反馈的内容！");
		content.focus();
		return false;
	}
	return true;	
}

//心情日记信息发布检测
function getContentValue()
{
        var oEditor = FCKeditorAPI.GetInstance('dcontent') ;
        var acontent=oEditor.GetXHTML();
        return acontent;
}

function chkdiary()
{
	var dsort=document.diaryshow.dsort;
	var dtitle=document.diaryshow.dtitle;
	var dcontent=document.diaryshow.dcontent;
		
	if(dsort.value==0)
	{
		alert("请您选择心情日记分类！");
		dsort.focus();
		return false;
	}
	if(dtitle.value=="")
	{
		alert("请您填写心情日记标题！");
		dtitle.focus();
		return false;
	}

   	if(getContentValue()=="")
	{
		alert("请您填写心情日记内容！");		
        return false;
	}	
	
	return true;	
}

//会员密码修改检测
function chkpwdedit()
{
	var oldpwd=document.pwdedit.oldpwd;
	var newpwd=document.pwdedit.newpwd;
	var renewpwd=document.pwdedit.renewpwd;
	if(oldpwd.value=="")
	{
		alert("请您输入原先的旧密码！");
		oldpwd.focus();
		return false;
	}
    if(newpwd.value=="")
	{
		alert("请您输入新的密码！");
		newpwd.focus();
		return false;
	}
	if(renewpwd.value=="")
	{
		alert("请您输入新的确认密码！");
		renewpwd.focus();
		return false;
	}
	if(newpwd.value != renewpwd.value)
	{
		alert("对不起，您的新密码与新的确认密码不一致！");
		renewpwd.focus();
		return false;
	}
	return true;	
}

//会员详细信息修改检测
function chkdinfo()
{
	var height = document.detialinfo.height;
	var weight = document.detialinfo.weight;

	if (height.value==0 || isNaN(weight.value))
	{
		alert("请您填写有效的身高!");		
		height.focus();
		return false;

	}
	if (weight.value=="" || isNaN(weight.value))
	{
		alert("请您正确填写体重!");		
		weight.focus();
		return false;
	}
}

//会员联系方式修改检测
function chklink()
{
	var cardtype = document.linkinfo.cardtype;
	var cardid = document.linkinfo.cardid;
	var linkaddress = document.linkinfo.linkaddress;
	var postcode = document.linkinfo.postcode;
	var tel = document.linkinfo.tel;
	var mobile = document.linkinfo.mobile;
	var email = document.linkinfo.email;
	var qq = document.linkinfo.qq;

	if (cardtype.value==0)
	{
		alert("请您选择证件号码类型");		
		cardtype.focus();
		return false;
	}
	if (cardid.value=="" || isNaN(cardid.value))
	{
		alert("证件号码只能为数字!");		
		cardid.focus();
		return false;
	}
	if (!(cardid.value.length==15 || cardid.value.length==18))
	{
		alert ("您的证件号码必须为15位或18位!")			
		cardid.focus();
		return false;
	}
	if (linkaddress.value=="")
	{
		alert("对不起,请您正确填写详细具体通讯地址!");
		linkaddress.focus();
		return false;
	}
	if (postcode.value=="")
	{
		alert("对不起,请您正确填写邮政编码!");
		postcode.focus();
		return false;
	}
	if(isNaN(postcode.value) || postcode.value.length !=6)
	{
		alert("请您填写有效的邮政编码!");
		postcode.focus();
		return false;
	}
	if (tel.value.length==0 && mobile.value.length==0) 
	{
		alert ("对不起！联系电话和手机必填一项！");		
		tel.focus();
		return false;
	}
	if(tel.value.length>0 )
	{
		if(!check_telnum(tel.value))
		{
			alert("请输入电话号码格式如：0576-88698996");
			tel.focus();
			return false;
		}
	} 	
	if(isNaN(mobile.value))
	{
		alert("请您填写有效的手机号码!");
		mobile.focus();
		return false;
	}
	if (email.value=="")
	{
		alert("对不起,请您完整并正确地填写电子邮件Email!");
		email.focus();
		return false;
	}
	if(!isEmail(email.value))
	{
		alert("对不起,您填写的电子邮件可能不正确!\n如果，您使用的是我们系统无法识别的电子邮件地址，请和我们联系!");
		email.focus();
		return false;
	}
	if(qq.value=="" || isNaN(qq.value))
	{
		alert("请您填写有效的QQ号码!");
		qq.focus();
		return false;
	}
	
	return true;
}

//会员征友条件修改检测
function chkfrd()
{
	var agestart = document.frdinfo.agestart;
	var ageend = document.frdinfo.ageend;
	var heightstart = document.frdinfo.heightstart;	
	var heightend = document.frdinfo.heightend;
	var cfwkaddress = document.frdinfo.cfwkaddress;
	var cfcalling = document.frdinfo.cfcalling;
	var cfwktype = document.frdinfo.cfwktype;
	var cfavgmpay = document.frdinfo.cfavgmpay;	
	var cfedustatus = document.frdinfo.cfedustatus;
	var cfmarraystatus = document.frdinfo.cfmarraystatus;

	if(agestart.value=="" || isNaN(agestart.value))
	{
		alert("请您正确填写征友的年龄!");
		agestart.focus();
		return false;
	}
	if(ageend.value=="" || isNaN(ageend.value))
	{
		alert("请您正确填写征友的年龄!");
		ageend.focus();
		return false;
	}
	if(heightstart.value=="" || isNaN(heightstart.value))
	{
		alert("请您正确填写征友的身高!");
		heightstart.focus();
		return false;
	}
	if(heightend.value=="" || isNaN(heightend.value))
	{
		alert("请您正确填写征友的身高!");
		heightend.focus();
		return false;
	}
	if (cfwkaddress.value=="")
	{
		alert("对不起,请您选择征友的工作所在地!");
		cfwkaddress.focus();
		return false;
	}
	if (cfcalling.value=="")
	{
		alert("对不起,请您选择征友的所在行业!");
		cfcalling.focus();
		return false;
	}
	if (cfwktype.value=="")
	{
		alert("对不起,请您选择征友的职业类别!");
		cfwktype.focus();
		return false;
	}
	if (cfavgmpay.value=="")
	{
		alert("对不起,请您选择征友的平均月收入!");
		cfavgmpay.focus();
		return false;
	}
	if (cfedustatus.value=="")
	{
		alert("对不起,请您选择征友的教育程度!");
		cfedustatus.focus();
		return false;
	}
	if (cfmarraystatus.value==0)
	{
		alert("对不起,请您选择征友的婚姻状况!");
		cfmarraystatus.focus();
		return false;
	}
	
	return true;	
}

//个人形象照片检测
function chkpshow()
{
	var uploadfile=document.photoshow.upload_file;	
	if(uploadfile.value=="")
	{
		alert("请您输入个人形象照片！");
		uploadfile.focus();
		return false;
	}   
	return true;	
}


function chkadminer($type)
{
	var adminname=document.adminer.adminname;
	if($type==1 && adminname.value)
	{
		if(adminname.value)
		{
			document.getElementById("adminname").innerHTML='<font color="#FF0000"><strong>×( 请重新输入,用户名必须为英文字母、数字或下划线，长度为6~32。 )</strong></font>';
		}		
	}
	else
	{
		document.getElementById("adminname").innerHTML='<font color="#624B35">( 请输入英文字母、数字或下划线，长度为6~32个字符，不区分大小写。) </font>';
	}
}
//password
function imlpassword($type){
	var password=document.thisForm.password;
	if($type==1 && password.value)
	{
		if(len(password.value) > 32 || len(password.value) < 6 || !isStr(password.value))
		{
			document.getElementById("divpassword").innerHTML='<font color="#FF0000"><strong>×( 密码必须为英文字母、数字或下划线，长度为6~32。 )</strong></font>';
		}
		else
		{
			document.getElementById("divpassword").innerHTML='<strong><font color="#009900">√</font></strong>';
		}
	}else{
		document.getElementById("divpassword").innerHTML='<FONT color=#624b35>( 6~32个字符 )</FONT>';
	}
}
//password2
function imlconfirmPassword($type){
	var confirmPassword=document.thisForm.confirmPassword;
	var password=document.thisForm.password;
	if($type==1 && confirmPassword.value)
	{
		if(password.value != confirmPassword.value)
		{
			document.getElementById("divconfirmPassword").innerHTML='<font color="#FF0000"><strong>×( 密码与重复密码不一致! )</strong></font>';
		}
		else
		{
			document.getElementById("divconfirmPassword").innerHTML='<strong><font color="#009900">√</font></strong>';
		}
	}else{
		document.getElementById("divconfirmPassword").innerHTML='<FONT color=#624b35>( 请再输入一遍密码 ) </FONT>';
	}
}
//email
function imlemail($type){
	var email=document.thisForm.email;
	if($type==1 && email.value)
	{
		if(!isEmail(email.value))
		{
			document.getElementById("divemail").innerHTML='<font color="#FF0000"><strong>×( 请正确填写邮箱地址! 例如：phpsp@163.com)</strong></font>';
		}
		else
		{
			document.getElementById("divemail").innerHTML='<strong><font color="#009900">√</font></strong>';
		}
	}else{
		document.getElementById("divemail").innerHTML='<FONT color=#624b35>( 例如：phpsp@163.com )</FONT>';
	}
}

//companyName
function imlcompanyName($type){
	var companyName=document.thisForm.companyName;
	if($type==1 && companyName.value)
	{
		if(len(trim(companyName.value)) < 6 || len(companyName.value)>100)
		{
			document.getElementById("divcompanyName").innerHTML='<font color="#FF0000"><strong>×( 公司名称不能少于6大于100个字符(不包括字符内的空格))</strong></font>';
		}
		else
		{
			document.getElementById("divcompanyName").innerHTML='<strong><font color="#009900">√</font></strong>';
		}
	}else{
		document.getElementById("divcompanyName").innerHTML='<FONT color=#624b35>( 请准确填写公司名称。 )</FONT>';
	}
}

//contactPerson
function imlcontactPerson($type){
	var contactPerson=document.thisForm.contactPerson;
	if($type==1 && contactPerson.value)
	{
		if(len(trim(contactPerson.value)) < 1 || len(trim(contactPerson.value))>50)
		{
			document.getElementById("divcontactPerson").innerHTML='<font color="#FF0000"><strong>×( 请输入正确联系人，以方便求职者与贵公司联系。例如：张先生或张雨荣 )</strong></font>';
		}
		else
		{
			document.getElementById("divcontactPerson").innerHTML='<strong><font color="#009900">√</font></strong>';
		}
	}else{
		document.getElementById("divcontactPerson").innerHTML='<FONT color=#624b35>( 请输入正确联系人，以方便求职者与贵公司联系。例如：王小姐或王学而 )</FONT>';
	}
}

/*/contactTel
function imlcontactTel($type){
	var contactTel=document.thisForm.contactTel;
	var tel;
	tel = document.thisForm.contactTel_Z.value + document.thisForm.contactTel.value + document.thisForm.contactTel_E.value;
	if($type==1 && contactTel.value)
	{
		if(!isNum(tel) || tel.indexOf(".")!="-1")
		{
			document.getElementById("divcontactTel").innerHTML='<font color="#FF0000"><strong>×( 您输入的电话号码不合法,必须输入数字符号且不含小数点! )</strong></font>';
		}
		else
		{
			document.getElementById("divcontactTel").innerHTML='<strong><font color="#009900">√</font></strong>';
		}
	}else{
		document.getElementById("divcontactTel").innerHTML='<FONT color=#624b35>( 例如：0576-2441111-8000 )</FONT>';
	}
}*/


//userajax
function divuserhtml()
{
	var result = this.req.responseText;
	if(result!='true')
	{
		document.getElementById("divuserName").innerHTML='<font color="#FF0000"><strong><font color="#009900">√</font></strong></font>';
	}
	else
	{
		document.getElementById("divuserName").innerHTML='<font color="#FF0000"><strong>×( 此用户名已被他人使用！请修改! )</strong></font>';
	}
}
//
function checkThisForm() {
	if(!isStr(document.thisForm.userName.value) || len(document.thisForm.userName.value) > 32 || len(document.thisForm.userName.value) < 6)
	{
		alert("对不起,用户名必须为英文字母、数字或下划线，长度为6~32。");
		document.thisForm.userName.focus();
		return false;
	}
	if(len(document.thisForm.password.value) > 32 || len(document.thisForm.password.value) < 6 || !isStr(document.thisForm.password.value))
	{
		alert("对不起,密码必须为英文字母、数字或下划线，长度为6~32。");
		document.thisForm.password.focus();
		return false;
	}
	if (document.thisForm.password.value != document.thisForm.confirmPassword.value)
	{
		alert("对不起,密码与重复密码不一致!");
		document.thisForm.confirmPassword.focus();
		return false;
	}
	if(!isEmail(document.thisForm.email.value))
	{
		alert("请正确填写邮箱地址!");
		document.thisForm.email.focus();
		return false;
	}
	if (len(trim(document.thisForm.companyName.value)) < 6)
	{
		alert("对不起,公司名称不能少于6个字符(不包括字符内的空格)!");
		document.thisForm.companyName.focus();
		return false;
	}
	if (len(document.thisForm.companyName.value)>100)
	{
		alert("对不起,公司名称描述过长(最大100个字符,50位中文),请更正!");
		document.thisForm.companyName.focus();
		return false;
	}
	if (len(trim(document.thisForm.contactPerson.value)) < 1)
	{
		alert("对不起,联系人不能为空!");
		document.thisForm.contactPerson.focus();
		return false;
	}
	if (len(trim(document.thisForm.contactPerson.value))>50)
	{
		alert("联系人资料描述过长(最大50个字符,25位中文)!");
		document.thisForm.contactPerson.focus();
		return false;
	}
	if (len(trim(document.thisForm.contactTel_Z.value))>20 || len(trim(document.thisForm.contactTel_Z.value)) < 3)
	{
		alert("对不起,电话区号长度不合法,请更正!");
		document.thisForm.contactTel_Z.focus();
		return false;
	}
	if (len(trim(document.thisForm.contactTel.value))>50 || len(trim(document.thisForm.contactTel.value)) < 5)
	{
		alert("对不起,电话号码长度不合法,请更正!");
		document.thisForm.contactTel.focus();
		return false;
	}
	var tel;
	tel = document.thisForm.contactTel_Z.value + document.thisForm.contactTel.value + document.thisForm.contactTel_E.value;
	if(!isNum(tel) || tel.indexOf(".")!="-1")
	{
		alert("对不起,您输入的电话号码不合法,必须输入数字符号且不含小数点!");
		document.thisForm.contactTel_E.focus();
		return false;
	}
	if(tel.indexOf("'")!="-1")
	{
		alert("对不起,您输入的电话号码不合法,请更正!");
		document.thisForm.contactTel_Z.focus();
		return false;
	}
	document.thisForm.submit();
	document.thisForm.Submit.disabled = true;
    document.thisForm.Submit.value = "  请稍候...  ";
}

//打开新窗口函数
function MM_openBrWindow(theURL,winName,features)
{ //v2.0
  window.open(theURL,winName,features);
}


