//////////////////////////////////////////////////////////////////////////////////////////////////////////
//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 chkuser()
{
	var username=document.ulogin.username;
	var password=document.ulogin.userpwd;
	if(username.value=="")
	{
			alert("请您输入用户名！");
			username.focus();
			return false;
	}
    if(password.value=="")
	{
			alert("请您输入用户密码！");
			password.focus();
			return false;
	}
	return true;	
}

function chkmlogin()
{
	var username=document.mlogin.username;
	var password=document.mlogin.password;
	var getcode=document.mlogin.getcode;
	if(username.value=="")
	{
		alert("请您输入用户名！");
		username.focus();
		return false;
	}
    if(password.value=="")
	{
		alert("请您输入用户密码！");
		password.focus();
		return false;
	}
	if(getcode.value=="")
	{
		alert("请您输入验证码！");
		getcode.focus();
		return false;
	}	
	if(isNaN(getcode.value))
	{
		alert("请您输入有效的验证码！");
		getcode.focus();
		return false;
	}	
	if(getcode.value.length!=4)
	{
		alert("请您输入准确有效的验证码！");
		getcode.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 chkfpwd()
{
	var username=document.fpwd.username;
	var question=document.fpwd.question;
	var answer=document.fpwd.answer;
	if(username.value=="")
	{
			alert("请您输入您登陆的用户名！");
			username.focus();
			return false;
	}
	if(question.value=="0")
	{
			alert("请您输入选择密码提示问题！");
			question.focus();
			return false;
	}
    if(answer.value=="")
	{
			alert("请您输入密码提示答案！");
			answer.focus();
			return false;
	}
	return true;	
}

function chkcglogin()
{
	var adminname=document.login.adminname;
	var adminpwd=document.login.adminpwd;
	var appendcode=document.login.appendcode;

	if(adminname.value=="")
	{
			alert("请您输入客户号!");
			adminname.focus();
			return false;
	}
    if(adminpwd.value=="")
	{
			alert("请您输入登陆的密码!");
			adminpwd.focus();
			return false;
	}	
	if(appendcode.value.length!=4)
	{
			alert("请您输入正确的登陆验证码!");
			appendcode.focus();
			return false;
	}
	else
	{
		   return true;
	}
}

//货源信息发布检测
function chkfinfo()
{
	var go_time=document.search.go_time;
	var goodsname=document.search.goodsname;
	var tel=document.search.tel;
	var mobile=document.search.mobile;
	var paid=document.search.paid;
	var caid=document.search.caid;
	var address1=document.search.address1;
	var pbid=document.search.pbid;
	var cbid=document.search.cbid;
	var address2=document.search.address2;
	var weight=document.search.weight;
	var tklength=document.search.tklength;
	var payway=document.search.payway;	
	
	if(go_time.value=="")
	{
		alert("请您输入发货时间！");
		go_time.focus();
		return false;
	}
    if(goodsname.value=="")
	{
		alert("请您输入货物名称！");
		goodsname.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-88698991");		
			tel.focus();
			return false;
		}
    }
    if(mobile.value.length>0 && isNaN(mobile.value))
	{
		alert("手机号只能为数字且位数为11");		
		mobile.focus()		
		return false;
    }
	if(paid.value==0)
	{
		alert("请您选择出发省份！");
		paid.focus();
		return false;
	}
	if(caid.value=="")
	{
		alert("请您选择出发地级市！");
		caid.focus();
		return false;
	}
	if(address1.value=="")
	{
		alert("请您输入装货地点具体地址！");
		address1.focus();
		return false;
	}
	if(pbid.value==0)
	{
		alert("请您选择到达省份！");
		pbid.focus();
		return false;
	}
	if(cbid.value=="")
	{
		alert("请您选择到达地级市！");
		cbid.focus();
		return false;
	}
	if(address2.value=="")
	{
		alert("请您输入卸货地点具体地址！");
		address2.focus();
		return false;
	}
	if(weight.value=="")
	{
		alert("请您输入吨位大小！");
		weight.focus();
		return false;
	}
	if(tklength.value=="")
	{
		alert("请您输入货车长度！");
		tklength.focus();
		return false;
	}
	if(payway.value==0)
	{
		alert("请您选择付款方式！");
		payway.focus();
		return false;
	}
	return true;	
}

//车源信息发布检测
function chktkinfo()
{
	var go_time=document.search.go_time;
	var driver=document.search.driver;
	var card_number=document.search.card_number;
	var tel=document.search.tel;
	var mobile=document.search.mobile;
	var paid=document.search.paid;
	var caid=document.search.caid;
	var address1=document.search.address1;
	var pbid=document.search.pbid;
	var cbid=document.search.cbid;
	var address2=document.search.address2;
	var weight=document.search.weight;
	var tklength=document.search.tklength;
	
	if(go_time.value=="")
	{
		alert("请您输入发车时间！");
		go_time.focus();
		return false;
	}
    if(driver.value=="")
	{
		alert("请您输入驾驶员的姓名！");
		driver.focus();
		return false;
	}
	if(card_number.value=="")
	{
		alert("请您输入车牌号码！");
		card_number.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-88698991");		
			tel.focus();
			return false;
		}
    }
    if(mobile.value.length>0 && isNaN(mobile.value))
	{
		alert("手机号只能为数字且位数为11");		
		mobile.focus()		
		return false;
    }
	if(paid.value==0)
	{
		alert("请您选择出发省份！");
		paid.focus();
		return false;
	}
	if(caid.value=="")
	{
		alert("请您选择出发地级市！");
		caid.focus();
		return false;
	}
	if(address1.value=="")
	{
		alert("请您输入出发地点具体地址！");
		address1.focus();
		return false;
	}
	if(pbid.value==0)
	{
		alert("请您选择到达省份！");
		pbid.focus();
		return false;
	}
	if(cbid.value=="")
	{
		alert("请您选择到达地级市！");
		cbid.focus();
		return false;
	}
	if(address2.value=="")
	{
		alert("请您输入目的地点具体地址！");
		address2.focus();
		return false;
	}
	if(weight.value=="")
	{
		alert("请您输入吨位大小！");
		weight.focus();
		return false;
	}
	if(tklength.value=="")
	{
		alert("请您输入货车长度！");
		tklength.focus();
		return false;
	}
	return true;	
}

//二手交易信息发布检测
function chkshbinfo()
{
	var pname=document.search.pname;
	var detail=document.search.detail;
	var connector=document.search.connector;
	var tel=document.search.tel;
	var mobile=document.search.mobile;
	
	if(pname.value=="")
	{
		alert("请您输入二手名称！");
		pname.focus();
		return false;
	}
    if(detail.value=="")
	{
		alert("请您输入二手详细描述！");
		detail.focus();
		return false;
	}
	if(connector.value=="")
	{
		alert("请您输入联系人！");
		connector.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-88698991");		
			tel.focus();
			return false;
		}
    }
    if(mobile.value.length>0 && isNaN(mobile.value))
	{
		alert("手机号只能为数字且位数为11");		
		mobile.focus()		
		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 chkshb()
{
	var shbtitle=document.shbmsg.shbtitle;
	var shbcontent=document.shbmsg.shbcontent;
	
	if(shbtitle.value=="")
	{
		alert("请您输入留言标题！");
		shbtitle.focus();
		return false;
	}
    if(shbcontent.value=="")
	{
		alert("请您输入留言内容！");
		shbcontent.focus();
		return false;
	}	
	return true;	
}

//货运企业搜索检测
function chkfcsearch()
{
	var keys=document.search.keys;
	//var password=document.search.password;
	if(keys.value=="")
	{
			alert("请您输入搜索关键词！");
			keys.focus();
			return false;
	}
   
	return true;	
}

//资讯搜索检测
function chknewssearch()
{
	var keys=document.search.keys;
	//var password=document.search.password;
	if(keys.value=="")
	{
			alert("请您输入搜索关键词！");
			keys.focus();
			return false;
	}
   
	return true;	
}

//在线留言反馈信息发布检测
function chkmsgs()
{
	var username=document.msgs.username;
	var company=document.msgs.company;
	var address=document.msgs.address;
	var tel=document.msgs.tel;
	var title=document.msgs.title;
	var content=document.msgs.content;
		
	if(username.value=="")
	{
		alert("请您输入您的姓名！");
		username.focus();
		return false;
	}
	if(company.value=="")
	{
		alert("请您输入公司名称或者个人！");
		company.focus();
		return false;
	}
	if(address.value=="")
	{
		alert("请您输入您的联系地址！");
		address.focus();
		return false;
	}
   	if(tel.value.length==0)
	{
		alert ("请您输入您的联系电话！");		
        tel.focus()       
		return false
	}
	if(tel.value.length>0)
	{
		if(!check_telnum(tel.value))
		{
			alert("请您输入有效的电话号码，格式如：0576-88698991");		
			tel.focus();
			return false;
		}
    }
   	if(title.value==0)
	{
		alert("请您输入留言反馈的标题！");
		title.focus();
		return false;
	}
	if(content.value=="")
	{
		alert("请您输入留言反馈的内容！");
		content.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);
}

