//////////////////////////////////////////////////////////////////////////////////////////////////////////
//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;
}


//会员登陆检测chklogin
function chkuser()
{
	var username=document.ulogin.username;
	var cnscpassword=document.ulogin.cnscpassword;
	if(username.value=="")
	{
			alert("请您输入用户名！");
			username.focus();
			return false;
	}
    if(cnscpassword.value=="")
	{
			alert("请您输入用户密码！");
			cnscpassword.focus();
			return false;
	}
	return true;	
}

function chklogin()
{
	var username=document.mlogin.username;
	var cnscpassword=document.mlogin.cnscpassword;
	var getcode=document.mlogin.getcode;
	if(username.value=="")
	{
		alert("请您输入用户名！");
		username.focus();
		return false;
	}
    if(cnscpassword.value=="")
	{
		alert("请您输入用户密码！");
		cnscpassword.focus();
		return false;
	}
	if(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 cnscanswer=document.fpwd.cnscanswer;
	if(username.value=="")
	{
			alert("请您输入您登陆的用户名！");
			username.focus();
			return false;
	}
	if(question.value==0)
	{
			alert("请您输入选择密码提示问题！");
			question.focus();
			return false;
	}
    if(cnscanswer.value=="")
	{
			alert("请您输入密码提示答案！");
			cnscanswer.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 chksell()
{
	var bcid=document.show.bcid;
	var scid=document.show.scid;
	var proname=document.show.proname;
	//var probrand=document.show.probrand;
	var upyear=document.show.upyear;
	var upmonth=document.show.upmonth;
	var upday=document.show.upday;
	var mktprice=document.show.mktprice;
	var mbrprice=document.show.mbrprice;
	var nownum=document.show.nownum;
	var leavingnum=document.show.leavingnum;
	var prorank=document.show.prorank;
	var proshow=document.show.proshow;	
	
	if(bcid.value==0)
	{
		alert("请您选择商品的大类！");
		bcid.focus();
		return false;
	}
    if(scid.value=="")
	{
		alert("请您选择商品的小类！");
		scid.focus();
		return false;
	}
	if(proname.value=="")
	{
		alert("请您输入商品名称！");
		proname.focus();
		return false;
	}
	/*if(probrand.value=="")
	{
		alert("请您输入商品品牌！");
		probrand.focus();
		return false;
	}*/
	if(upyear.value==0)
	{
		alert("请您选择上市年份！");
		upyear.focus();
		return false;
	}
	if(upmonth.value==0)
	{
		alert("请您选择上市月份！");
		upmonth.focus();
		return false;
	}
	if(upday.value==0)
	{
		alert("请您选择上市日份！");
		upday.focus();
		return false;
	}
	if(mktprice.value=="")
	{
		alert("请您输入市场价格！");
		mktprice.focus();
		return false;
	}
	if(mbrprice.value=="")
	{
		alert("请您输入会员价格！");
		mbrprice.focus();
		return false;
	}
	if(mktprice.value=="")
	{
		alert("请您输入市场价格！");
		mktprice.focus();
		return false;
	}
	if(mbrprice.value=="")
	{
		alert("请您输入会员价格！");
		mbrprice.focus();
		return false;
	}
	if(nownum.value=="")
	{
		alert("请您输入库存件数！");
		nownum.focus();
		return false;
	}
	if(leavingnum.value=="")
	{
		alert("请您输入剩余件数！");
		leavingnum.focus();
		return false;
	}
	if(prorank.value==0)
	{
		alert("请您输入商品等级！");
		prorank.focus();
		return false;
	}
	if(proshow.value=="")
	{
		alert("请您输入商品的详细说明！");
		proshow.focus();
		return false;
	}
	
	return true;	
}

//求购信息发布检测
function chkbuy()
{
	var bcid=document.show.bcid;
	var scid=document.show.scid;
	var proname=document.show.proname;
	var upyear=document.show.upyear;
	var upmonth=document.show.upmonth;
	var upday=document.show.upday;
	var consprice=document.show.consprice;
	var buynum=document.show.buynum;
	var prorank=document.show.prorank;
	var proshow=document.show.proshow;	
	
	if(bcid.value==0)
	{
		alert("请您选择商品的大类！");
		bcid.focus();
		return false;
	}
    if(scid.value=="")
	{
		alert("请您选择商品的小类！");
		scid.focus();
		return false;
	}
	if(proname.value=="")
	{
		alert("请您输入商品名称！");
		proname.focus();
		return false;
	}
	/*if(probrand.value=="")
	{
		alert("请您输入商品品牌！");
		probrand.focus();
		return false;
	}*/
	if(upyear.value==0)
	{
		alert("请您选择上市年份！");
		upyear.focus();
		return false;
	}
	if(upmonth.value==0)
	{
		alert("请您选择上市月份！");
		upmonth.focus();
		return false;
	}
	if(upday.value==0)
	{
		alert("请您选择上市日份！");
		upday.focus();
		return false;
	}
	if(consprice.value=="")
	{
		alert("请您输入市场价格！");
		consprice.focus();
		return false;
	}	
	if(buynum.value=="")
	{
		alert("请您输入商品数量！");
		buynum.focus();
		return false;
	}	
	if(prorank.value==0)
	{
		alert("请您输入商品等级！");
		prorank.focus();
		return false;
	}
	if(proshow.value=="")
	{
		alert("请您输入商品的详细说明！");
		proshow.focus();
		return false;
	}
	
	return true;	
}

//产品信息发布检测
function chkpro()
{
	var bcid=document.show.bcid;
	var scid=document.show.scid;
	var proname=document.show.proname;
	//var protype=document.show.protype;	
	var proshow=document.show.proshow;
	var profrom=document.show.profrom;
	var consprice=document.show.consprice;
	var pronum=document.show.pronum;
	var upload_file=document.show.upload_file;
	
	if(bcid.value==0)
	{
		alert("请您选择产品的大类！");
		bcid.focus();
		return false;
	}
    if(scid.value=="")
	{
		alert("请您选择产品的小类！");
		scid.focus();
		return false;
	}
	if(proname.value=="")
	{
		alert("请您输入产品名称！");
		proname.focus();
		return false;
	}	
	if(proshow.value=="")
	{
		alert("请您输入产品简介！");
		proshow.focus();
		return false;
	}
	if(profrom.value=="")
	{
		alert("请您输入产品原产地！");
		profrom.focus();
		return false;
	}	
	if(consprice.value=="")
	{
		alert("请您输入产品参考价格！");
		consprice.focus();
		return false;
	}	
	if(pronum.value=="")
	{
		alert("请您输入产品数量！");
		pronum.focus();
		return false;
	}	
	if(upload_file.value==0)
	{
		alert("请您输产品图片！");
		upload_file.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 cnscpassword=document.search.cnscpassword;
	if(keys.value=="")
	{
			alert("请您输入搜索关键词！");
			keys.focus();
			return false;
	}
   
	return true;	
}

//资讯搜索检测
function chknewssearch()
{
	var keys=document.search.keys;
	//var cnscpassword=document.search.cnscpassword;
	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 email=document.msgs.email;	
	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=="")
	{
		alert ("请您输入您的联系电话！");		
        tel.focus()       
		return false
	}
	if(email.value=="")
	{
		alert ("请您填写有效电子邮件地址！");		
        email.focus()       
		return false
	}	
	if(email.value.indexOf("@") == -1 || email.value.indexOf(".") == -1)
	{ 
		alert("请您填写有效电子邮件地址！格式如：chianshuichan@163.com"); 
		email.focus();
		return false;
	}	
   	if(title.value=="")
	{
		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>';
	}
}
//cnscpassword
function imlcnscpassword($type){
	var cnscpassword=document.thisForm.cnscpassword;
	if($type==1 && cnscpassword.value)
	{
		if(len(cnscpassword.value) > 32 || len(cnscpassword.value) < 6 || !isStr(cnscpassword.value))
		{
			document.getElementById("divcnscpassword").innerHTML='<font color="#FF0000"><strong>×( 密码必须为英文字母、数字或下划线，长度为6~32。 )</strong></font>';
		}
		else
		{
			document.getElementById("divcnscpassword").innerHTML='<strong><font color="#009900">√</font></strong>';
		}
	}else{
		document.getElementById("divcnscpassword").innerHTML='<FONT color=#624b35>( 6~32个字符 )</FONT>';
	}
}
//cnscpassword2
function imlconfirmcnscpassword($type){
	var confirmcnscpassword=document.thisForm.confirmcnscpassword;
	var cnscpassword=document.thisForm.cnscpassword;
	if($type==1 && confirmcnscpassword.value)
	{
		if(cnscpassword.value != confirmcnscpassword.value)
		{
			document.getElementById("divconfirmcnscpassword").innerHTML='<font color="#FF0000"><strong>×( 密码与重复密码不一致! )</strong></font>';
		}
		else
		{
			document.getElementById("divconfirmcnscpassword").innerHTML='<strong><font color="#009900">√</font></strong>';
		}
	}else{
		document.getElementById("divconfirmcnscpassword").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.cnscpassword.value) > 32 || len(document.thisForm.cnscpassword.value) < 6 || !isStr(document.thisForm.cnscpassword.value))
	{
		alert("对不起,密码必须为英文字母、数字或下划线，长度为6~32。");
		document.thisForm.cnscpassword.focus();
		return false;
	}
	if (document.thisForm.cnscpassword.value != document.thisForm.confirmcnscpassword.value)
	{
		alert("对不起,密码与重复密码不一致!");
		document.thisForm.confirmcnscpassword.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);
}


