// JavaScript Document
/**************对cookie的操作函数****************/
//写入 cookie
//不区分 cookieName 的大小写
//不考虑子键

function ResponseCookies(cookieName, cookieValue, expires)
{
    if (expires)
    {
        //指定了 expires
        document.cookie = ResponseCookies_GetCookieName(cookieName) + "=" + escape(cookieValue) + "; expires=" + expires.toGMTString();
    }
    else
    {
        document.cookie = ResponseCookies_GetCookieName(cookieName) + "=" + escape(cookieValue);
		
    }
}

//获取并返回与 cookieName 同名的 cookie 名称，允许大小写不同
//如果不存在这样的 cookie，就返回 cookieName
function ResponseCookies_GetCookieName(cookieName)
{
    var lowerCookieName = cookieName.toLowerCase();
    var cookieStr = document.cookie;
    
    if (cookieStr == "")
    {
        return cookieName;
    }
    
    var cookieArr = cookieStr.split("; ");
    var pos = -1;
    for (var i=0; i<cookieArr.length; i++)
    {
        pos = cookieArr[i].indexOf("=");
        if (pos > 0)
        {
            if (cookieArr[i].substring(0, pos).toLowerCase() == lowerCookieName)
            {
                return cookieArr[i].substring(0, pos);
            }
        }
    }
    
    return cookieName;
}

//获取并返回 cookie 值
//不区分 cookieName 的大小写
//dfltValue 为默认返回值
//不考虑子键
function RequestCookies(cookieName, dfltValue)
{
    var lowerCookieName = cookieName.toLowerCase();
    var cookieStr = document.cookie;
    
    if (cookieStr == "")
    {
        return dfltValue;
    }
    
    var cookieArr = cookieStr.split("; ");
    var pos = -1;
    for (var i=0; i<cookieArr.length; i++)
    {
        pos = cookieArr[i].indexOf("=");
        if (pos > 0)
        {
            if (cookieArr[i].substring(0, pos).toLowerCase() == lowerCookieName)
            {
                return cookieArr[i].substring(pos+1, cookieArr[i].length);
            }
        }
    }
    
    return dfltValue;
}

function ClearCookie() 
{ 
　 var strCookie = document.cookie;
　 var arrCookie = strCookie.split(";");
　 var i;
　 var expires = new Date(); 
　 //expires.setDate(expires.getDate() - 1); 
　 // document.cookie = 'c1='+ escape('c1value');
　 // alert(document.cookie);
   
　 for(i=0; i<arrCookie.length; i++)
　 {
　 　 //alert(arrCookie[i]+';expires=' + expires.toGMTString());
      
　 　 document.cookie = arrCookie[i].split('=')[0]+'=null;expires=' + expires.toGMTString(); 
      //arrCookie[i].split('=')[0]=null;
	 
　 }
　
} 

//删除cookie
function deleteCookie(name) { 
   
    var date = new Date();
   document.cookie = name + "= ; expires=" + date.toGMTString()-1;
}

//根据cookie来判断是否已经登录
function loadLogin()
{
  var str,username;
  //alert(RequestCookies("username",""));
  username = RequestCookies("username","");

  if(username=="")
  {//如果cookie不存在
      
	  
	  str = "<form action='login.asp' method='post' onsubit='return check()'>";
	  str = str+"<table class='tableform'>";
	  str = str+"<tr>";
	  str = str+"<td width='52'>用户名 :</td>";
	  str = str+"<td width='91'><input tabIndex=1 size=12 name='uid'></td>";
	  str = str+"</tr>";
	  str = str+"<tr>";
	  str = str+"<td>密码:</td>";
	  str = str+"<td><input tabIndex=1 type='password' size=12 name='pwd'></td>";
	  str = str+"</tr>";
	  str = str+"<tr>";
	  str = str+"<td height='30'><input type='image' src='entry.gif'/></td>";
	  str = str+"<td><a href='regist.asp'><img src='login.gif'/></a></td>";
	  str = str+"</tr>";
	  str = str+"</table>";
	  str = str+"</form>";
	  
	  
  }
  else
  {//如果cookie存在
	 
	  
      str = "<table border='0' cellpadding='0' cellspacing='0' class='tableform'>";
      str= str+"<tr>";
       str= str+"<td height='25' align='center'>"+escape(RequestCookies("username",""))+"欢迎您</td>";
      str = str+"</tr>";
      str = str+"<tr>";
      str = str+"<td height='25' align='center'>这是您第"+RequestCookies("loingtimes","")+"次登录本网站!</td>";
      str = str+"</tr>";
      str = str+"<tr>";
      str = str+"<td height='25'  align='center'><strong>全球泵阀资讯网</strong><br />将给您提供最有价值的信息!</td>";
      str = str+"</tr>";
	  str = str+"<tr>";
      str = str+"<td height='10'></td>";
      str = str+"</tr>";
	  str = str+"<tr>";
      str = str+"<td  align='center'><font color='#005B00'><strong>[ <a href='toNull.asp'>注销</a> ]</strong> </font></td>";
      str = str+"</tr>";
      str = str+"</table>";
      
     
  }
  document.getElementById("L_member_content").innerHTML=str;

}


function loadLogin2()
{
  var str,username;
  //alert(RequestCookies("username",""));
  username = RequestCookies("username","");
  if(username=="")
  {//如果cookie不存在
      	 
	  str = "<form action='login.asp.htm' method='post' onsubit='return check()'>";
	  str = str+"<table class='tableform'>";
	  str = str+"<tr>";
	  str = str+"<td width='52'>用户名 :</td>";
	  str = str+"<td width='91'><input tabIndex=1 size=12 name='uid'></td>";
	  str = str+"</tr>";
	  str = str+"<tr>";
	  str = str+"<td>密码:</td>";
	  str = str+"<td><input tabIndex=1 type='password' size=12 name='pwd'></td>";
	  str = str+"</tr>";
	  str = str+"<tr>";
	  str = str+"<td height='30'><input type='image' src='entry.gif'/></td>";
	  str = str+"<td><a href='regist.asp.htm'><img src='login.gif '/></a></td>";
	  str = str+"</tr>";
	  str = str+"</table>";
	  str = str+"</form>";
	  
	  
  }
  else
  {//如果cookie存在
     	   
      str = "<table border='0' cellpadding='0' cellspacing='0' class='tableform'>";
      str= str+"<tr>";
      str= str+"<td height='25' align='center'>"+escape(RequestCookies("username",""))+"欢迎您</td>";
      str = str+"</tr>";
      str = str+"<tr>";
      str = str+"<td height='25' align='center'>这是您第"+RequestCookies("loingtimes","")+"次登录本网站!</td>";
      str = str+"</tr>";
      str = str+"<tr>";
      str = str+"<td height='25'  align='center'><strong>全球泵阀资讯网</strong><br />将给您提供最有价值的信息!</td>";
      str = str+"</tr>";
	  str = str+"<tr>";
      str = str+"<td height='15'></td>";
      str = str+"</tr>";
	  str = str+"<tr>";
      str = str+"<td  align='center'><font color='#005B00'><strong>[ <a href='../toNull.asp'>注销</a> ]</strong> </font></td>";
      str = str+"</tr>";
      str = str+"</table>";
	  
  }
  document.getElementById("L_member_content").innerHTML=str;

}



//根据cookie来判断是否已经登录
function loadLogin1()
{
  var str,username;
  //alert(RequestCookies("username",""));
  username = RequestCookies("username","");
  if(username=="")
  {//如果cookie不存在
      	 
	  str = "<form action='../login.asp' method='post' onsubit='return check()'>";
	  str = str+"<table class='tableform'>";
	  str = str+"<tr>";
	  str = str+"<td width='52'>用户名 :</td>";
	  str = str+"<td width='91'><input tabIndex=1 size=12 name='uid'></td>";
	  str = str+"</tr>";
	  str = str+"<tr>";
	  str = str+"<td>密码:</td>";
	  str = str+"<td><input tabIndex=1 type='password' size=12 name='pwd'></td>";
	  str = str+"</tr>";
	  str = str+"<tr>";
	  str = str+"<td height='30'><input type='image' src='entry.gif'/></td>";
	  str = str+"<td><a href='../regist.asp'><img src='login.gif'/></a></td>";
	  str = str+"</tr>";
	  str = str+"</table>";
	  str = str+"</form>";
	  
	  
  }
  else
  {//如果cookie存在
     	   
      str = "<table border='0' cellpadding='0' cellspacing='0' class='tableform'>";
      str= str+"<tr>";
      str= str+"<td height='25' align='center'>"+escape(RequestCookies("username",""))+"欢迎您</td>";
      str = str+"</tr>";
      str = str+"<tr>";
      str = str+"<td height='25' align='center'>这是您第"+RequestCookies("loingtimes","")+"次登录本网站!</td>";
      str = str+"</tr>";
      str = str+"<tr>";
      str = str+"<td height='25'  align='center'><strong>全球泵阀资讯网</strong><br />将给您提供最有价值的信息!</td>";
      str = str+"</tr>";
	  str = str+"<tr>";
      str = str+"<td height='15'></td>";
      str = str+"</tr>";
	  str = str+"<tr>";
      str = str+"<td  align='center'><font color='#005B00'><strong>[ <a href='../toNull.asp'>注销</a> ]</strong> </font></td>";
      str = str+"</tr>";
      str = str+"</table>";
	  
  }
  document.getElementById("L_member_content").innerHTML=str;

}


function toNull()
{//外注销
	ClearCookie();
	location.href = "index.html"
}

function toNull1()
{//内注销
   ClearCookie();
   location.href = "../index.html"
   
}

//验证是否登录
function auditlogin(url)
{
    if( RequestCookies("username","") !="") 
	 {
	     window.open(url,'_blank');
	 }
	 else  
	 {   
	     window.open(url,'_blank');
		 
		 //return false;
	 }
}
//下载验证
function auditDownload(url)
{
    if( RequestCookies("username","") !="") 
	 {
		 window.open(url,'_blank');
	      //return true;
	 }
	 else  
	 {
		 alert("只有登录才能下载");
		 //return false;
	 }
}


function auditpostlogin(url)
{
    if( RequestCookies("username","") !="") 
	 {
		 window.open(url,'_blank');
	      //return true;
	 }
	 else  
	 {
		  alert("只有登录才能发表信息！");

		 //return false;
	 }
}

/***************异步的验证该用户是否已经注册************************/
var xmlHttp;
function createXMLHttpRequest()
{
     if(window.ActiveXObject){                								 //如果是IE浏览器
	    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	 }
	 else if(window.XMLHttpRequest){
		 xmlHttp = new XMLHttpRequest();
	 }
}

function createQueryString()               								 //创建查询字符串
{
     var userName =  document.getElementById("username").value;
	 var queryString = "userName="+userName;
	 
	 return queryString;
}


function startQuest()                    									//开始查询
{
    if(document.getElementById("username").value==""){
		alert("用户名不能为空!");
	}
	else
	{
		createXMLHttpRequest();              									//实例化一个xmlHttp
		var url="checkusername.asp?timeStamp=" + new Date().getTime();
		
		var queryString=createQueryString(); 									//创建查询字符串
	   
		xmlHttp.open("post",url,true);
		xmlHttp.onreadystatechange = receive; 									//接收从服务器返回值的函数
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.send(queryString);           									//发送查询字符串
	}
}

function receive()                     									//对从服务器返回的值进行处理
{
	
	 if(xmlHttp.readyState==4)
	 {
		
		 if(xmlHttp.status==200)
		 {
			if(xmlHttp.responseText=="yes")								    //如果这个用户已注册过
			 {
			   	 
				 document.getElementById("displayinfo").innerHTML =   "&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>该用户已经被注册! </font>"; document.getElementById("username").value="" 
			 
			 }
			 else                                                          //用户名重复
			 {
				
				 document.getElementById("displayinfo").innerHTML =   "&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>该用户名能正常使用! </font>";  
				 
			 }
			 
		 }
		 
	 }
	 
}



/************************对注册页面的所有元素进行较对验*****************************/
function checkuserChange(itm)
{
	
	if (itm.value != '' && !itm.value.match(/^[a-zA-Z_0-9]+$/))
	{
		document.getElementById('username_error').innerHTML ="&nbsp;<font color=red>用户名应由为数字，字母和下划线组成! </font>";
		document.reg.submit.style.display="none";
	}
	else
	{ 
	   
	    document.getElementById('username_error').innerHTML ="";
		document.reg.submit.style.display="";
	}
		
}
function bytes(str){
	if(typeof(str)!='string'){
		str = str.value;
	}
	var len = 0;
	for(var i = 0; i < str.length; i++){
		if(str.charCodeAt(i) > 127){
			len++;
		}
		len++;
	}
	return len;
}
function chkstr(str){
	if(typeof(str)!='string'){
		str = str.value;
	}
	for(var i = 0; i < str.length; i++){
		if (str.charCodeAt(i) < 127 && !str.substr(i,1).match(/^\w+$/ig)){
			return false;
		}
	}
	return true;
}
function getMsg(name){
	itm = document.getElementById('err_msg');
	for (var i=0; i<itm.childNodes.length; i++){
		if (itm.childNodes[i].id == name){
			
			return itm.childNodes[i].innerHTML;
			
		}
	}
	return -1;
}
function getItem(itm){
	if (itm.className == 'item'){
		itm1 = itm;
	}else{
		itm1 = itm.parentNode.parentNode;
	}
	for (var i=0; i<itm1.childNodes.length; i++){
		if (itm1.childNodes[i].className == 'item_error'){
			itm2 = itm1.childNodes[i];
			break;
		}
	}
	return new Array(itm1, itm2);
}
function showError(msg, itm, onclickun){
	arr = getItem(itm);
	msg2=msg;

//start 这段只能用于检查用户名！只有setUserNameUsable和onloadError中用了onclickun参数。
	if(typeof(onclickun)=="boolean" && onclickun==true)
	{
		var uname = document.getElementById("usernameforload").value;
		re=/###/gi;
		msg2 = msg.replace(re,uname);
		document.getElementById("usernameforload").value="";
	}
//end

	arr[1].innerHTML = msg2;
	arr[1].style.display = 'block';
	//arr[0].style.marginBottom = '6px';
	
}
function hideError(itm){
	arr = getItem(itm);
	arr[1].innerHTML = '';
	arr[1].style.display = 'none';
	//arr[0].style.marginBottom = '20px';
}
function checkInput(itm, blank){
	str = checkItem(itm, blank);
	return str;
}
function checkOnChange(itm){
	return checkInput(itm, false);
}
function checkOnClick(itm){
	return checkInput(itm, true);
}
function onloadError(msg,itmname){
	//alert(document.getElementById(itmname));
	if(msg=="msg_user_exists")
		showError(getMsg(msg), document.getElementById(itmname),true);
	else
		showError(getMsg(msg), document.getElementById(itmname));
}
function setUserNameUsable(bol){
	document.reg.username.readOnly = false;
	if (bol){
		showError(getMsg('msg_un_ok'), document.reg.username);
	}else{
		showError(getMsg('msg_user_exists'), document.reg.username, true);
	}
}
function checkUserName(){
	un = document.reg.username;
	if(checkOnClick(un)){
		showError(getMsg('msg_un_checking'), document.reg.username);
		if (typeof(encodeURIComponent) == 'function'){
			unstr = encodeURIComponent(un.value) + '&e=u';
		}else{
			unstr = un.value;
		}
		scr = document.createElement('script')
		scr.src = '../check/?act=check_username&un=' + unstr;
		document.getElementById('check_username_script').appendChild(scr);
	}
}
function checkItem(itm, blank){
    
	if (itm.id == 'username'){
		if (itm.value == ''){
		    document.getElementById('username_error').innerHTML ="&nbsp;<font color=red>用户名不能为空! </font>";
			err = true;
		}else if (bytes(itm) > 50){
			document.getElementById('username_error').innerHTML ="&nbsp;<font color=red>用户名不应超过25个汉字,或50个字符(数字，字母和下划线! </font>";
			err = true;																
		}else if (bytes(itm)<5){
			document.getElementById('username_error').innerHTML ="&nbsp;<font color=red>用户名不应少于2个汉字,或4个字符(数字，字母和下划线! </font>";
			err = true;																
		}
	   else if (itm.value != '' && !itm.value.match(/^[a-zA-Z_0-9]+$/))
	   {
		document.getElementById('username_error').innerHTML ="&nbsp;<font color=red>用户名应由为数字，字母和下划线组成! </font>";
		err = true;	
	   }
	
		else{ document.getElementById('username_error').innerHTML ="";}
		
   }else if (itm.id == 'loginpass'){
		if (itm.value == ''){
			document.getElementById('loginpass_error').innerHTML ="&nbsp;<font color=red>密码不能为空! </font>";
			err = true;
		}else if (bytes(itm) > 14 || bytes(itm) < 4){
			document.getElementById('loginpass_error').innerHTML ="&nbsp;<font color=red>密码应该由4到14个字符组成! </font>";
			err = true;
		}else if (itm.value != '' && !itm.value.match(/^[\x21-\x7e]{1,14}$/ig)) {
			document.getElementById('loginpass_error').innerHTML ="&nbsp;<font color=red>密码应由数字，字母和下划线组成! </font>";
			err = true;
		}
		else{ document.getElementById('loginpass_error').innerHTML ="";}
		
	}else if (itm.id == 'name'){
		if (itm.value == ''){
			document.getElementById('name_error').innerHTML ="&nbsp;<font color=red>必须填写真实姓名! </font>";
			err = true;
		}
		
    }
	else if (itm.id == 'auditcode'){
		if (itm.value == ''){
			document.getElementById('audit_error').innerHTML ="&nbsp;<font color=red>验证码不能为空! </font>";
			err = true;
		}
		
    }else if (itm.id == 'verifypass'){
	   if (itm.value != document.reg.loginpass.value){
			document.getElementById('verifypass_error').innerHTML ="&nbsp;<font color=red>密码应该一致! </font>";
			err = true;
		}
		else{ document.getElementById('verifypass_error').innerHTML ="";}
	  
	}else if (itm.id == 'email'){//电邮
		if (itm.value == ''){
		 document.getElementById('email_error').innerHTML ="&nbsp;<font color=red>请输入邮件地址! </font>";
		 err = true;
		}else if (itm.value != '' && !itm.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
		 document.getElementById('email_error').innerHTML ="&nbsp;<font color=red>邮件地址格式错误! </font>";
		 err = true;
		}
		else{ document.getElementById('email_error').innerHTML ="";}
    }else if (itm.id == 'company'){//
		if (itm.value == ''){
		   document.getElementById('company_error').innerHTML ="&nbsp;<font color=red>公司名不能为空! </font>";err = true;
		}
		else{ document.getElementById('company_error').innerHTML ="";}
    }else if (itm.id == 'tel'){//
		if (itm.value == ''){
		   document.getElementById('tel_error').innerHTML ="&nbsp;<font color=red>电话不能为空! </font>";err = true;
		}
		else{ document.getElementById('tel_error').innerHTML ="";}
		
    }else if (itm.id == 'fax'){
	   if (itm.value == ''){
		 document.getElementById('fax_error').innerHTML ="&nbsp;<font color=red>传真不能为空! </font>";
		 err = true;
		}
   }
   
   
	return err;
}

//检验注册表单
function checkForm(itm){
	//var now = new Date();
	//var lasttime = parseInt(now.getHours().toString()+now.getMinutes().toString());
	//var value = parseInt(RequestCookies("date",""))-lasttime;
																										
	//if (value<30) {
		//alert("30分钟之内，同一IP不能重复注册");
		//return false;
	//} 
	var submited = false;
    err = false;
	if (!submited){
		//alert(document.all.reg.length);
		for (var i=0; i<document.all.reg.length; i++){
				if (document.all.reg[i].type == 'text' || document.all.reg[i].type == 'password')err=checkOnChange(document.all.reg[i]);
		}
		if(err){
		     alert('注册数据不正确，请检查后重新输入。');
			 return false;
		}
		else{
			submited = true;
			document.getElementById('btn_submit').disabled = true;
			document.reg.submit();
			return false;
		}
	}else{
		alert('请勿重复提交请求');
		return false;
	}
	
	//if( RequestCookies("ip","")!=""&& RequestCookies("date","")-Date())
}


//add by wangjun

function pqchange()
{
	with(document.reg){
		if(question.selectedIndex==(question.length-1)){
			pass_question.style.display = "";
			pass_question.value = "";
			hideError(pass_question);
		}else{
			pass_question.style.display = "none";
			pass_question.value = question.options[question.selectedIndex].value;
			checkOnChange(pass_question);
		}
	}

}

function setsex(sexvalue)
{
	with(document.reg){
		if(sexvalue==2){
			sex[0].checked=false;
			sex[1].checked=true;
		}else{
			sex[0].checked=true;
			sex[1].checked=false;
		}
	}
}

function setlockmail(securevalue)
{
	if(securevalue=="N"){
		document.reg.lockmail.checked=false;
	}

}

function setprotocal(pvalue)
{
	if(pvalue=="Y"){
		document.reg.protocal.checked=true;
	}
}


function setpq(qvalue)
{


	with(document.reg){

		if(qvalue=="")
			qvalue=question.options[0].value;

		for (i=0;i<question.options.length;i++){
			if(question.options[i].value==qvalue){
				question.selectedIndex = i;
				break;
			}else{
				question.selectedIndex = question.options.length - 1;
			}
		}


		//autoSelect(question,qvalue);
		if(question.selectedIndex==(question.length-1)){
			pass_question.style.display = "";
		}
		pass_question.value = qvalue;
	}
}


function newverifypic()
{
	var timenow = new Date().getTime();
	url="../ValidCode/";
	id = url.indexOf('?');
	if(id >= 0  ){
		if(id == (url.length-1))
			url = url +"t="+ timenow;
		else 
			url = url +"&t="+ timenow;
	}else{
		url = url +"?t="+ timenow;
	}

	document.getElementById("verifypic").src=url;
}



//对需求表页面的信息进行校验
function checkdDemandForm(itm){
	
	var submited = false;
    err = false;
	
	if (!submited){
		for (var i=0; i<document.all.form1.length; i++){
				if (document.all.form1[i].type == 'text' || document.all.form1[i].type == 'textarea')err=checkDemandItem(document.all.form1[i]);
		}
		
		if(err){
		     alert('邮件数据不正确，请检查后重新输入。');
			 return false;
		}
		else{
			submited = true;
			document.getElementById('btn_submit').disabled = true;
			document.form1.submit();
			return false;
		}
	}else{
		alert('请勿重复提交请求');
		return false;
	}
}


function checkDemandItem(itm){
	
    if (itm.id == 'company'){//
		if (itm.value == ''){
		   document.getElementById('company_error').innerHTML ="&nbsp;<font color=red>公司名不能为空! </font>";err = true;
		}
		else{ document.getElementById('company_error').innerHTML ="";}
	}else if (itm.id == 'address'){//
		if (itm.value == ''){
		   document.getElementById('address_error').innerHTML ="&nbsp;<font color=red>地址不能为空! </font>";err = true;
		}
		else{ document.getElementById('address_error').innerHTML ="";}
    }else if (itm.id == 'tel'){
		
		pat=/^[0-9]{8,11}$/;   
        pat2=/^[0-9]{3,4}-[0-9]{6,8}$/;   
        pat3=/^[0-9]{3,4}-[0-9]{6,8}-[0-9]{3,5}$/;   
        pat4=/^13[0-9]{9}$/  ; 
             
       if(!pat.exec(itm.value) && (!pat2.exec(itm.value)) &&(!pat3.exec(itm.value)))
	     {document.getElementById('tel_error').innerHTML="&nbsp;<font color=red>请输入正确号码! </font>";err = true; }
	   else
	   {document.getElementById('tel_error').innerHTML ="";}
		
    }else if (itm.id == 'Contacts'){
	   if (itm.value == ''){
		 document.getElementById('Contacts_error').innerHTML ="&nbsp;<font color=red>联系人不能为空! </font>";
		 err = true;
		}
		else{ document.getElementById('Contacts_error').innerHTML ="";}
	}else if (itm.id == 'products'){
	   if (itm.value == ''){
		 document.getElementById('products_error').innerHTML ="&nbsp;<font color=red>适用产品不能为空! </font>";
		 err = true;
		}
		else{ document.getElementById('products_error').innerHTML ="";}
    }else if (itm.id == 'demand'){
	   if (itm.value == ''){
		 document.getElementById('demand_error').innerHTML ="&nbsp;<font color=red>需求描述不能为空! </font>";
		 err = true;
		}
		else{ document.getElementById('demand_error').innerHTML ="";}
    }else if (itm.id == 'email'){//电邮
		if (itm.value == ''){
		 document.getElementById('email_error').innerHTML ="&nbsp;<font color=red>请输入邮件地址! </font>";
		 err = true;
		}else if (itm.value != '' && !itm.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
		 document.getElementById('email_error').innerHTML ="&nbsp;<font color=red>邮件地址格式错误! </font>";
		 err = true;
		}
		else{ document.getElementById('email_error').innerHTML ="";}
	}
	return err;
}


////对搜索关键字进行验证
function searchcheck(){
	if (document.all.formsearch.key.value=="--请输入搜索关键字!--"){
		  alert("搜索关键字不能为空!");
		  return false;
		}
	if(document.all.formsearch.condition.value==0){
	     alert("请选择搜索分类!");
		 return false;
	}
	document.all.formsearch.submit();
}

////对贴吧回复表单值进行验证
function postcheck(){
	 err = true;       //返回的状态值
	 if(document.all.form1.content.value==""){
		 document.getElementById("content_error").innerHTML = "&nbsp;&nbsp;&nbsp;<font color=red>回复内容不能为空! </font>"
		 err = false;
	 }if(document.all.form1.auditcode.value==""){
		 document.getElementById("auditcode_error").innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>请输入验证码! </font>"
		 err = false;
	}if(document.all.form1.content.value.length > 5000){
		 document.getElementById("content_error").innerHTML = "&nbsp;&nbsp;&nbsp;<font color=red>请不要超过5000个字节! </font>"
		 err = false;
	 }
	return err;
}

////对贴吧提问表单值进行验证
function questioncheck(){
	 err = true;       //返回的状态值
	 
	 if(document.all.form1.title.value==""){
		 document.getElementById("title_error").innerHTML = "&nbsp;&nbsp;&nbsp;<font color=red>标题不能为空! </font>"
		 err = false;
	 }if(document.all.form1.auditcode.value==""){
		 document.getElementById("auditcode_error").innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>请输入验证码! </font>"
		 err = false;
	}if(document.all.form1.content.value.length > 500){
		 document.getElementById("content_error").innerHTML = "&nbsp;&nbsp;&nbsp;<font color=red>请不要超过500个字节! </font>"
		 err = false;
	 }if(document.all.form1.title.value.length > 200){
		 document.getElementById("title_error").innerHTML = "&nbsp;&nbsp;&nbsp;<font color=red>标题不要超过200个字节! </font>"
		 err = false;
	 }
	 if(document.all.form1.secondKey.value ==""){
		 document.getElementById("key_error").innerHTML = "&nbsp;&nbsp;&nbsp;<font color=red>请选择所属小类! </font>"
		 err = false;
	 }
	 
	return err;
}


////图片的特效
function enlarge(which,e,id){
var i;
//Render image code for IE 4+
for(i=1;i<4;i++){
	if (eval("showimage"+id).style.visibility=="hidden"&&i==parseInt(id)){
	eval("showimage"+id).style.left=365;
	eval("showimage"+id).style.top=550;
	eval("showimage"+id).innerHTML='<img src="'+which+'">';
	eval("showimage"+id).style.visibility="visible";
	}
	else
	{
	
	eval("showimage"+i.toString()).style.visibility="hidden";
	
	
	}
	//alert(i);
  }
  
}


//对国际泵阀商的信息进行较验
function formcheck(){
	  var err= true;
	  if(document.getElementById("company").value=="")
	  {
		document.getElementById("company_error").innerHTML = "&nbsp;&nbsp;&nbsp;<font color=red>公司名不能为空! </font>";
		err = false;
	  }
	  
	  if(document.getElementById("textarea").value=="")
	  {
		document.getElementById("textarea_error").innerHTML = "&nbsp;&nbsp;&nbsp;<font color=red>邮件内容不能为空! </font>";
		err = false;  
	  }
	 
	 
	  return err;
	}



