﻿function $(obj){return document.getElementById(obj);}
function AjaxPost(m,posturl,data,callback){
	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() {
		if (req.readyState == 4 && req.status == 200) {
			var reqtext=req.responseText;
			if(callback=="chkUser"){
				if(reqtext=="0"){top.location.href="http://cn.kefid.com/";}
			}else{
				if(callback!="vPros"){$(callback).innerHTML=reqtext;}
			}
		}
	}	
}
AjaxPost(1,"/Hits.asp","Act=chkUser","chkUser");
function showTip(nID){
	for(var i=0;i<9;i++){
		if(i==nID){
			$("tip_"+i).style.display="block";
			$("a_"+i).style.background="url(/i/nav_on.png) repeat-x";
			$("a_"+i).style.color="#FFF";
		}else{
			$("tip_"+i).style.display="none";
			$("a_"+i).style.background="none";
			$("a_"+i).style.color="#FFF";
		}
	}
}
function showDiv(sID,oID){
	$("ilnc_"+sID).style.display="block";
	$("ilnt_"+sID).className="ilnta1";
	$("ilnc_"+oID).style.display="none";
	$("ilnt_"+oID).className="ilnta2";
}

function showLi(iID){
	if($("li_"+iID).style.display=="block"){$("li_"+iID).style.display="none"}else{$("li_"+iID).style.display="block"}
}

function showCon(cID,tID){
	$("nv_"+cID).className="crta crta1";$("nc_"+cID).style.display="block";
	for(var i=0;i<tID;i++){if(i!=cID){$("nv_"+i).className="crta crta0";$("nc_"+i).style.display="none";}}
}
function showCon2(cID,tID){
	$("nv_"+cID).className="crta crta1 h24";$("nc_"+cID).style.display="block";
	for(var i=0;i<tID;i++){if(i!=cID){$("nv_"+i).className="crta crta0 h24";$("nc_"+i).style.display="none";}}
}

function oCopy(obj){obj.select();js=obj.createTextRange();js.execCommand("Copy");}

function showImg(imgS,obj){$(imgS).src=obj.src.replace("_s","");}

function chkInquiry(){
	$("bgName").style.background="";
	$("bgCountry").style.background="";
	$("bgTel").style.background="";
	$("bgEMail").style.background="";
	$("bgMessage").style.background="";
	if($("userName").value==""){$("bgName").style.background="#EEE";alert("Please input your Name ! ");$("userName").focus();return false;}
	//if($("uCountry").value==""){$("bgCountry").style.background="#EEE";alert("Please input or select your Country ! ");$("uCountry").focus();return false;}
	if($("userTel").value==""){$("bgTel").style.background="#EEE";alert("Please input your Tel ! ");$("userTel").focus();return false;}
	if($("userEMail").value==""){$("bgEMail").style.background="#EEE";alert("Please input your E-Mail ! ");$("userEMail").focus();return false;}else{if(!isEmail($("userEMail").value)){$("bgEMail").style.background="#EEE";alert("Your E-Mail is error ! ");$("userEMail").focus();return false;}}
	if($("Message").value==""){$("bgMessage").style.background="#EEE";alert("Please input your Message ! ");$("Message").focus();return false;}
}

function chkFaq(){
	$("bgCls").style.background="";
	$("bgTitle").style.background="";
	$("bgName").style.background="";
	$("bgEMail").style.background="";
	$("bgQuestion").style.background="";
	if($("faqCls").value==""){$("bgCls").style.background="#EEE";alert("Please select Categories ! ");$("faqCls").focus();return false;}
	if($("faqTitle").value==""){$("bgTitle").style.background="#EEE";alert("Please input Title ! ");$("faqTitle").focus();return false;}
	if($("faqName").value==""){$("bgName").style.background="#EEE";alert("Please input your name ! ");$("faqName").focus();return false;}
	if($("faqEMail").value==""){$("bgEMail").style.background="#EEE";alert("Please input your E-mail ! ");$("faqEMail").focus();return false;}else{if(!isEmail($("faqEMail").value)){$("bgEMail").style.background="#EEE";alert("Your E-Mail is error ! ");$("faqEMail").focus();return false;}}
	if($("faqCon").value==""){$("bgQuestion").style.background="#EEE";alert("Please input your question ! ");$("faqCon").focus();return false;}
}

function IsCheck(oID){
	var isChk=false;
	var oL=document.getElementsByName(oID);
	if(oL!=null){if(oL.length>0){for(var i=0;i<oL.length;i++){if(oL[i].checked==true){isChk=true;break;}}}}
	return isChk;
}

function chkGuide(oID){
	if(!IsCheck(oID)){alert("Please choose the item you are interested in !");return false;}
}

function openW(uSrc){window.open(uSrc);}

function setDes(obj){if(obj.value=="other"){$("mDesSpan").style.display="";}else{$("mDesSpan").style.display="none";}}
function chkPGuide(){
	$("mTypebg").style.background="";
	$("mMaxbg").style.background="";
	$("mDesbg").style.background="";
	$("mCapbg").style.background="";
	$("mNamebg").style.background="";
	$("mCountrybg").style.background="";
	$("mEmailbg").style.background="";
	if(!IsCheck("mType") && $("omType1").value=="" && $("omtype2").value==""){$("mTypebg").style.background="#EDB39D";alert("Please select or input Material Type !");return false;}
	if($("mMax").value==""){$("mMaxbg").style.background="#EDB39D";alert("Please input Maximum Feed Size !");$("mMax").focus();return false;}
	if($("aType").value!="supporting machine"){
		if($("mDes").value==""){$("mDesbg").style.background="#EDB39D";alert("Please input Products Desired !");$("mDes").focus();return false;}
	}
	if($("mCap").value==""){$("mCapbg").style.background="#EDB39D";alert("Please input Capacity of Plant required !");$("mCap").focus();return false;}
	if($("mName").value==""){$("mNamebg").style.background="#EDB39D";alert("Please input your Name !");$("mName").focus();return false;}
	if($("mCountry").value==""){$("mCountrybg").style.background="#EDB39D";alert("Please select your Country !");$("mCountry").focus();return false;}
	if($("mEmail").value==""){$("mEmailbg").style.background="#EDB39D";alert("Please input your Email !");$("mEmail").focus();return false;}else{if(!isEmail($("mEmail").value)){$("mEmailbg").style.background="#EDB39D";alert("Your E-Mail is error !");$("mEmail").focus();return false;}}
}

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 setHits(ID,aTy){
	AjaxPost(1,"/Hits.asp","Act=UpdateHits&ID="+ID+"&aTy="+aTy,aTy);
}

var flag=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;
		}
		}
	}
}
//if(document.documentElement.clientWidth>900){
//document.write('<div id="MAC_Fair" style="position:absolute;left:0;z-index:1000;"><a href="/News/Company/The-8th-China-MAC-Fair-Vietnam-2010.html" title="Please contact Kevin at 0086-18737139831" target="_blank"><img src="/i/The-8th-China-MAC-Fair.gif" width="100" height="144" alt="Please contact Kevin at 0086-18737139831" border="0"></a></div><script language="javascript">function rightBottomAd(){var abc = document.getElementById("MAC_Fair");abc.style.top = document.documentElement.scrollTop+150+"px";setTimeout(function(){rightBottomAd();},10);}rightBottomAd();</scr ipt>');
//}
if(document.documentElement.clientWidth>900){
document.write('<div id="Shanghai_Branch" style="position:absolute;left:0;z-index:1000;"><a href="http://www.kefidchina.com/" title="Welcome to Kefid (Shanghai) Machinery Co.,LTD" target="_blank"><img src="/Shanghai-Branch/i/Shanghai-Branch.gif" width="100" height="144" alt="Welcome to Kefid Shanghai Branch" border="0"></a></div><script language="javascript">function rightBottomAd(){var abc = document.getElementById("Shanghai_Branch");abc.style.top = document.documentElement.scrollTop+150+"px";setTimeout(function(){rightBottomAd();},10);}rightBottomAd();</script>');
}