﻿function $g(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","UTF-8");
		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=="chkLog"){
				var leftTxt=reqtext.split("$")[0];
				var rightTxt=reqtext.split("$")[1];
				if(leftTxt=="0"){top.location.href=rightTxt;}
			}else{
				if(callback!="vPros"){$g(callback).innerHTML=reqtext;}
			}
		}
	}	
}
AjaxPost(1,"/v2/Hits.asp","Act=chkLog&u="+document.URL,"chkLog");

function oCopy(obj){obj.select();js=obj.createTextRange();js.execCommand("Copy");}

function showImg(imgS,obj){$g(imgS).src=obj.src.replace("_s","");}

function setDiv(cID,oID){
	for(var i=1;i<=oID;i++){
		if(i==cID){
			$g("ca"+i).className="on";
			$g("ct"+i).style.display="block";
		}else{
			$g("ca"+i).className="off";
			$g("ct"+i).style.display="none";
		}
	}
}

function chkInquiry(){
	if($g("userName").value==""){alert("Please input your Name ! ");$g("userName").focus();return false;}
	if($g("userTel").value==""){alert("Please input your Tel ! ");$g("userTel").focus();return false;}
	if($g("userEMail").value==""){alert("Please input your E-Mail ! ");$g("userEMail").focus();return false;}else{if(!isEmail($g("userEMail").value)){alert("Your E-Mail is error ! ");$g("userEMail").focus();return false;}}
	if($g("Message").value==""){alert("Please input your Message ! ");$g("Message").focus();return false;}
}

function chkFaq(){
	if($g("faqCls").value==""){alert("Please select Categories ! ");$g("faqCls").focus();return false;}
	if($g("faqTitle").value==""){alert("Please input Title ! ");$g("faqTitle").focus();return false;}
	if($g("faqName").value==""){alert("Please input your name ! ");$g("faqName").focus();return false;}
	if($g("faqEMail").value==""){alert("Please input your E-mail ! ");$g("faqEMail").focus();return false;}else{if(!isEmail($g("faqEMail").value)){alert("Your E-Mail is error ! ");$g("faqEMail").focus();return false;}}
	if($g("faqCon").value==""){alert("Please input your question ! ");$g("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 addBookmark() {
	var url=document.location.href;
	var title=document.title
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite(url,title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

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,"/v2/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 style="width:984px;margin:auto;text-align:left;"><div style="position:fixed;top:0px;_position:absolute;_top:0px;"><a href="http://www.kefid.com/Factory/" target="_blank"><img src="http://www.kefid.com/Factory/i/ru.gif" border="0"></a></div></div>');}
