﻿var ad_468_15='<script type="text/javascript">google_ad_client = "pub-7103242232698180";google_ad_slot = "3264400925";google_ad_width = 468;google_ad_height = 15;</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';

var ad_468_60='<script type="text/javascript">google_ad_client = "pub-7103242232698180";google_ad_slot = "1333125923";google_ad_width = 468;google_ad_height = 60;</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';

var ad_728_90='<script type="text/javascript">google_ad_client = "pub-7103242232698180";google_ad_slot = "9461931886";google_ad_width = 728;google_ad_height = 90;</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';

var ad_200_200='<script type="text/javascript">google_ad_client = "pub-7103242232698180";google_ad_slot = "7826541745";google_ad_width = 200;google_ad_height = 200;</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';

var ad_250_250='<script type="text/javascript">google_ad_client = "pub-7103242232698180";google_ad_slot = "3354815529";google_ad_width = 250;google_ad_height = 250;</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';

var ad_300_250='<script type="text/javascript">google_ad_client = "pub-7103242232698180";google_ad_slot = "6750895213";google_ad_width = 300;google_ad_height = 250;</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';


function $(obj){return document.getElementById(obj);}

//类似于VB中的Trim，去掉空格。调用：obj.Trim()
String.prototype.Trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function()
{
    return this.replace(/(^\s*)/g, "");
}
String.prototype.Rtrim = function()
{
    return this.replace(/(\s*$)/g, "");
}
String.prototype.UrlEncode = function()
{
	var str = this;
	str = str.replace(/./g,function(sHex)
	{
		window.EnCodeStr = "";
		window.sHex = sHex;
		window.execScript('window.EnCodeStr=Hex(Asc(window.sHex))',"vbscript");
		return window.EnCodeStr.replace(/../g,"%$&");
	});
	return str;
}

function isEmail(strEmail) {
    if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}


function DrawImage(ImgD,ImgW,ImgH){
	var image=new Image();
	var iwidth = ImgW;  //定义允许图片宽度
	var iheight = ImgH;  //定义允许图片高度
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
	flag=true;
	if(image.width/image.height>= iwidth/iheight){
		if(image.width>iwidth){  
		ImgD.width=iwidth;
		ImgD.height=(image.height*iwidth)/image.width;
		}else{
		ImgD.width=image.width;  
		ImgD.height=image.height;
		}
		}
	else{
		if(image.height>iheight){  
		ImgD.height=iheight;
		ImgD.width=(image.width*iheight)/image.height;		
		}else{
		ImgD.width=image.width;  
		ImgD.height=image.height;
		}
		}
	}
} 

function gourl(sUrl){window.location.href=""+sUrl+"";}

function setCode(){$("CodeImg").src="/Inc/GetCode.asp?s="+Math.random();}

//导航
var tID=1;
function show_nav(ID,onCls,offCls){
	if(ID!=tID){
		$("nav_"+ID).className = onCls;
		$("nav_"+tID).className = offCls;
		tID=ID;
	}else{
		$("nav_"+ID).className = onCls; 
	}
}

var sStr='<span style="color:#F00;"><img src=/i/error.gif border=0> ';
var eStr='</span>';
var okStr='<img src=/i/ok.gif border=0> ';
var vReg=true;
function ajaxData(m,posturl,data,callerror,callok)
{
	var req=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
	data=data+"&m="+Math.random();
	if (m=="1"){
		req.open("POST",posturl,true);
		req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		req.setRequestHeader("CharSet","GB2312");
		req.send(data);
	}else{
		req.open("GET",posturl+"?"+data,true);
		req.send(null);
	}
	req.onreadystatechange = function() {
		//document.write (req.responseText);
		if (req.readyState == 4 && req.status == 200) {
			var reqtext=req.responseText;
			if(isNaN(reqtext)){
				altGoto(reqtext,"");
				$("userCenter").focus();
				vReg=false;
			}else{
				if(reqtext=="0"){
					eval(callerror);
					vReg=false;
				}else{
					eval(callok);
				}
			}
		}
	}
}

function chkUser()
{
	if($("rUser").value.Trim()=="")
	{
		$("reg_1").innerHTML=sStr+"请输入用户名！"+eStr;vReg=false;
	}else{
		if($("rUser").value.Trim().length>15 || $("rUser").value.Trim().length<6)
		{
			$("reg_1").innerHTML=sStr+"用户名长度在6-15位之间！"+eStr;vReg=false;
		}else{
			//if(/^\w+$/g.test($("rUser").value.Trim())){
			if($("rUser").value.search(/^\w+$/) != -1){
				ajaxData(1,"/chk.asp","Act=chkIsReg&c=rUser&w="+escape($("rUser").value),"$(\"reg_1\").innerHTML='"+sStr+$("rUser").value+" 已经被注册！"+eStr+"';","$(\"reg_1\").innerHTML='"+okStr+"';");
			}else{
				$("reg_1").innerHTML=sStr+"用户名由字母、数字、下划线组成！"+eStr;vReg=false;
			}
		}
	}
}
function chkPwd()
{
	if($("rPwd").value=="")
	{
		$("reg_2").innerHTML=sStr+"请输入密码！"+eStr;vReg=false;
	}else{
		if($("rPwd").value.length<6 || $("rPwd").value.length>20){
			$("reg_2").innerHTML=sStr+"密码长度在6-20位之间"+eStr;vReg=false;
		}else{
			$("reg_2").innerHTML=okStr;
			if($("rePwd").value!=$("rPwd").value)
			{
				$("reg_3").innerHTML=sStr+"两次输入的密码不相同！"+eStr;vReg=false;
			}else{
				$("reg_3").innerHTML=okStr;
			}
		}
	}	
}
function chkCorp()
{
	if($("rCorp").value.Trim()=="")
	{
		$("reg_4").innerHTML=sStr+"请输入公司名称！"+eStr;vReg=false;
	}else{
		if($("rCorp").value.Trim().length<6){
			$("reg_4").innerHTML=sStr+"公司名称太短了吧！"+eStr;vReg=false;
		}else{
			$("reg_4").innerHTML=okStr;
			//ajaxData(1,"/chk.asp","Act=chkIsReg&c=rCorp&w="+escape($("rCorp").value),"$(\"reg_4\").innerHTML='"+sStr+"该公司名称已经被使用，请确认！"+eStr+"';","$(\"reg_4\").innerHTML='"+okStr+"';");
		}
	}
}
function chkTel()
{
	if($("rTel").value.Trim()=="" && $("rMobile").value.Trim()=="")
	{
		$("reg_7").innerHTML=sStr+"固定电话和手机必须填写一项！"+eStr;vReg=false;
	}else{
		if($("rTel").value.Trim()!="")
		{
			if($("rTel").value.search(/((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/) != -1){
				$("reg_6").innerHTML=okStr;
			}else{
				$("reg_6").innerHTML=sStr+"固定电话格式不正确！格式: 0371-12345678"+eStr;vReg=false;
			}
		}else{$("reg_6").innerHTML="格式: 0371-12345678";}
		if($("rMobile").value.Trim()!="")
		{
			if($("rMobile").value.search(/1[35]\d{9}$/) != -1){
				$("reg_7").innerHTML=okStr;
			}else{
				$("reg_7").innerHTML=sStr+"手机格式不正确！格式: 13000000000"+eStr;vReg=false;
			}
		}else{$("reg_7").innerHTML="格式: 13000000000";}
	}
	if($("rFax").value.Trim()!="")
	{
		if($("rFax").value.search(/((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/) != -1){
			$("reg_8").innerHTML=okStr;
		}else{
			$("reg_8").innerHTML=sStr+"传真格式不正确！格式: 0371-12345678"+eStr;vReg=false;
		}
	}else{$("reg_8").innerHTML="格式: 0371-12345678";}
}
function chkEmail()
{
	if(!isEmail($("rEmail").value.Trim()))
	{
		$("reg_9").innerHTML=sStr+"电子邮件格式不正确！"+eStr;vReg=false;
	}else{
		$("reg_9").innerHTML=okStr;
		//ajaxData(1,"/chk.asp","Act=chkIsReg&c=rEmail&w="+escape($("rEmail").value),"$(\"reg_9\").innerHTML='"+sStr+"电子邮件已经被使用，请换一个！"+eStr+"';","$(\"reg_9\").innerHTML='"+okStr+"';");
	}
}
function chkCode()
{
	if($("rCode").value.Trim()=="")
	{
		$("reg_11").innerHTML=sStr+"请输入验证码！"+eStr;vReg=false;
	}else{
		ajaxData(1,"/chk.asp","Act=chkCode&rCode="+escape($("rCode").value),"$(\"reg_11\").innerHTML='"+sStr+"验证码不正确！"+eStr+"';","$(\"reg_11\").innerHTML='"+okStr+"';");
	}
}
function chkReg()
{
	vReg=true
	chkUser();chkPwd();chkCorp();chkEmail();chkCode();
	
	if(vReg==true){
		$("reg_submit").disabled=true;
		var req=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
		var data="Act=SaveReg&rUser="+escape($("rUser").value)+"&rPwd="+escape($("rPwd").value)+"&rePwd="+escape($("rePwd").value)+"&rCorp="+escape($("rCorp").value)+"&rEmail="+escape($("rEmail").value)+"&rCode="+escape($("rCode").value)+"&n=zz&m="+Math.random();
		req.open("POST","/chk.asp",true);
		req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		req.setRequestHeader("CharSet","GB2312");
		req.send(data);
		req.onreadystatechange = function() { 
			//$("testMsg").value=unescape(req.responseText);
			if (req.readyState == 4 && req.status == 200) {
				var reqtext=req.responseText;
				if(reqtext=="注册成功"){
					altGoto("注册成功，点击“<a href=\"/Login.asp\">确认</a>”立即登陆。<br>注：您的状态是未审核，请尽快完善详细资料！","/Login.asp");
					$("tmpfocus").focus();
				}else{
					altGoto(reqtext,"");
					$("tmpfocus").focus();
					$("reg_submit").disabled=false;
				}
			}
		}
	}
}

function chkLogin(gType,bUrl)
{
	var rUser;
	var rPwd;
	var backStr;
	if(gType=="1"){
		rUser=$("lo_user").value;
		rPwd=$("lo_pwd").value;
		backStr=escape(rUser)+"　<input type=\"button\" value=\"商务中心\" class=\"btn_reg\" onclick=gourl(\"/Member/\")>　<input type=\"button\" value=\"退出登陆\" class=\"btn_reg\" onclick=\"LoginOut()\">";
		ajaxData(1,"/chk.asp","Act=chkLogin&gType="+gType+"&rUser="+escape(rUser)+"&rPwd="+escape(rPwd),"","$('userCenter').innerHTML='"+backStr+"';");
	}else{
		rUser=$("login_user").value;
		rPwd=$("login_pwd").value;
		rCode=$("login_code").value;
		if(bUrl!=""){backStr="gourl(\""+bUrl+"\");";}else{backStr="gourl(\"/Member/\");";}
		ajaxData(1,"/chk.asp","Act=chkLogin&gType="+gType+"&rUser="+escape(rUser)+"&rPwd="+escape(rPwd)+"&rCode="+escape(rCode),"",backStr);
	}
}
function LoginOut()
{
	var backStr="用户名:<input type=\"text\" name=\"lo_user\" id=\"lo_user\" class=\"l_input\" maxlength=\"15\"> 密码:<input type=\"password\" name=\"lo_pwd\" id=\"lo_pwd\" class=\"l_input\" maxlength=\"20\"> <input type=\"submit\" value=\"登陆\" class=\"btn41\" onclick=\"chkLogin(1,1)\"> <input type=\"button\" value=\"免费注册\" class=\"btn_reg\" onclick=gourl(\"/Reg.asp\")>";
	ajaxData(1,"/chk.asp","Act=LoginOut","","$('userCenter').innerHTML='"+backStr+"';");
}

//TimerUrl(3000,"tmpDiv","/Member/");
function TimerUrl(ms,TextID,GoUrl)
{
	var duration=ms;
	var timer=null;
	var endTime = new Date().getTime() + duration + 100;
	function interval(){
		var n=(endTime-new Date().getTime())/1000;
		if(n<0) return;
		if(TextID && TextID!=""){document.getElementById(TextID).innerHTML = n.toFixed(3);}    
		setTimeout(interval, 10);
	}
	window.onload=function(){
		timer=setTimeout("gourl('"+GoUrl+"')",duration);
		interval();
	}
}

function ajaxPost(purl,data,btn,burl,tmpfocus)
{
	if(btn){$(btn).disabled=true;}
	var msgDiv = document.createElement("DIV");
	msgDiv.id="msgDiv";
	msgDiv.style.position = "absolute";
	msgDiv.style.left = "50%";
	msgDiv.style.top = "50%";
	msgDiv.style.marginLeft = "-225px" ;
	msgDiv.style.marginTop = -75+document.documentElement.scrollTop+"px";
	msgDiv.style.width = "250px";
	msgDiv.style.height = "50px";
	msgDiv.style.textAlign = "center";
	msgDiv.style.lineHeight = "50px";
	msgDiv.style.background = "#DEEBF9";
	msgDiv.style.zIndex = "10001";
	strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;\"><li style=\"font-size:14px;border:1px solid #039;color:#039;\">正在提交，请稍候……</li></ul>";
	msgDiv.innerHTML = strHtml;
	document.body.appendChild(msgDiv);
	
	var req=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
	var data=data+"&m="+Math.random();
	req.open("POST",purl,true);
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	req.setRequestHeader("CharSet","GB2312");
	req.send(data);
	req.onreadystatechange = function() {
		//$("ttt").value=req.responseText;//return;
		if (req.readyState == 4 && req.status == 200) {
			var reqtext=req.responseText;
			var l_txt=reqtext.substring(0,2);
			var r_txt=reqtext.replace("OK","")
			if(msgDiv){document.body.removeChild(msgDiv);}
			if(l_txt=="OK"){
				altGoto(r_txt,burl)
				$(tmpfocus).focus();
			}else{
				altGoto(reqtext,"");
				$(tmpfocus).focus();
				if(btn){$(btn).disabled=false;	}
			}
		}
	}
}

function SaveCoMsg()
{
	if($("gUser").value==""){
		$("s_1").innerHTML=sStr+"请输入您的真实姓名！"+eStr;return;
	}else{
		if($("gUser").value.length<2){
			$("s_1").innerHTML=sStr+"真实姓名太短了吧！"+eStr;return;
		}else{$("s_1").innerHTML=okStr;}
	}
	if($("gTel").value==""){
		$("s_2").innerHTML=sStr+"请输入您的联系电话！"+eStr;return;
	}else{
		//if((/((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/g.test($("gTel").value))|| (/1[35]\d{9}$/g.test($("gTel").value)) ){
		if($("gTel").value.search(/((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/) != -1 || $("gTel").value.search(/1[35]\d{9}$/) != -1){
			$("s_2").innerHTML=okStr;
		}else{
			$("s_2").innerHTML=sStr+"电话格式不正确！格式: 0371-12345678 或者 13000000000"+eStr;return;
		}
	}
	if($("gCon").value==""){
		$("s_4").innerHTML=sStr+"请输入留言内容！"+eStr;return;
	}else{
		if($("gCon").value.length>500){
			$("s_4").innerHTML=sStr+"留言内容不能超过500个字！"+eStr;return;
		}else{$("s_4").innerHTML=okStr;}
	}
	ajaxPost("/chk.asp","Act=SaveCoMsg&gUser="+escape($("gUser").value)+"&gTel="+escape($("gTel").value)+"&gEmail="+escape($("gEmail").value)+"&gCon="+escape($("gCon").value)+"&aName="+$("aName").value+"&sName="+$("sName").value,"savebtn","Contact.asp?u="+$("aName").value,"s_1");
}

function ChkLink()
{
	if($("sWeb").value==""){$("sWeb").focus();$("s_1").innerHTML=sStr+"请输入网站名称！"+eStr;return;}else{$("s_1").innerHTML="";}
	if($("sUrl").value==""){
		$("sUrl").focus();$("s_2").innerHTML=sStr+"请输入网址！"+eStr;return;
	}else{
		if($("sUrl").value.search(/(http:\/\/)[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/) != -1){
			$("s_2").innerHTML="";
		}else{$("s_2").innerHTML=sStr+"网址格式不正确，以 http:// 开头！"+eStr;$("sUrl").focus();return;}
	}
	ajaxPost("/chk.asp","Act=SaveLink&sWeb="+escape($("sWeb").value)+"&sUrl="+escape($("sUrl").value),"savebtn","","s_1");
}

var isCreate=false;
function altGoto(msg,mUrl){
	if(isCreate==true){return;}
	//var eSrc=(document.all)?window.event.srcElement:arguments[1];
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = ((document.documentElement.clientHeight>document.documentElement.scrollHeight)?document.documentElement.clientHeight:document.documentElement.scrollHeight)+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = "50%";
	alertFram.style.top = "50%";
	alertFram.style.marginLeft = "-225px" ;
	alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
	alertFram.style.width = "450px";
	alertFram.style.height = "120px";
	alertFram.style.background = "#ccc";
	alertFram.style.textAlign = "center";
	alertFram.style.lineHeight = "120px";
	alertFram.style.zIndex = "10001";
	
	strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
	strHtml += " <li style=\"background:#DD828D;text-align:left;padding-left:20px;font-size:14px;font-weight:bold;height:25px;line-height:25px;border:1px solid #F9CADE;color:#5E0000;\">[系统提示]</li>\n";
	strHtml += " <li style=\"background:#fff;text-align:center;font-size:14px;line-height:24px;padding:20px 0;border-left:1px solid #F9CADE;border-right:1px solid #F9CADE;color:#F00;\">"+msg+"</li>\n";
	strHtml += " <li style=\"background:#FDEEF4;text-align:center;font-weight:bold;height:35px;line-height:35px; border:1px solid #F9CADE;\"> <input type=\"button\" value=\"确 认\" id=\"do_OK\" style=\"padding:5px;\" onclick=\"doOk()\" /> </li>\n";
	strHtml += "</ul>\n";
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	isCreate=true;
	this.setOpacity = function(obj,opacity){
		if(opacity>=1)opacity=opacity/100;
		try{ obj.style.opacity=opacity; }catch(e){}
		try{
			if(obj.filters.length>0&&obj.filters("alpha")){
			obj.filters("alpha").opacity=opacity*100;
		}else{
			obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
		}
		}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
		if (++c > 20){clearInterval(ad);return 0;}
		setOpacity(shield,c);
	}
	var ad = setInterval("doAlpha()",1);
	this.doOk = function(){
		document.body.removeChild(alertFram);
		document.body.removeChild(shield);
		//eSrc.focus();
		isCreate=false;
		document.body.onselectstart = function(){return true;}
		document.body.oncontextmenu = function(){return true;}
		if(mUrl!=""){gourl(mUrl);}
	}
}

//搜索
function goSearch(){
	var kw=$("kw").value.UrlEncode();
	var s=$("s").value;
	var u="";
	switch(s){
		case "2":u="Require";break;
		case "3":u="Product";break;
		case "4":u="Company";break;
		case "5":u="Info";break;
		case "6":u="Meeting";break;
		case "7":u="News";break;
		case "8":u="Article";break;
		default:u="Supply";break;
	}
	window.location.href=u+".asp?kw="+kw+"&s="+s;
}

//返回顶部
var scrollToTop = function(){ $('a[@href=#top]').click(function(){ backToTop(); return false;} ) };
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 30);
    }
}

//检查是否被选择
function chkCheck(objNam,reNam)
{ 
	var obj = document.getElementsByName(objNam);
	var objLen= obj.length; 
	var objYN;
	var i;
	objYN=false;
	for (i = 0;i<objLen;i++)
	{
		if (obj [i].checked==true)
		{
			if(reNam=="Radio"){objYN=obj[i].value;}else{objYN= true;}
			break;
		}
	}
	return objYN;
}
