//copyright www.soundjet.net
Object.extend(Event, {
  _domReady : function() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;

    if (this._timer)  clearInterval(this._timer);
    
    this._readyCallbacks.each(function(f) { f() });
    this._readyCallbacks = null;
},
  onDOMReady : function(f) {
    if (!this._readyCallbacks) {
      var domReady = this._domReady.bind(this);
      
      if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", domReady, false);
        
        /*@cc_on @*/
        /*@if (@_win32)
            document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
            document.getElementById("__ie_onload").onreadystatechange = function() {
                if (this.readyState == "complete") domReady(); 
            };
        /*@end @*/
        
        if (/WebKit/i.test(navigator.userAgent)) { 
          this._timer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) domReady(); 
          }, 10);
        }
        
        Event.observe(window, 'load', domReady);
        Event._readyCallbacks =  [];
    }
    Event._readyCallbacks.push(f);
  }
});

var lan_str = new Array(),f_lan="gb";
var order_page;
lan_str[0] = "提交订单";
lan_str[1] = "请输入要搜索的关键词";
lan_str[2] = "一个订单最多订购";
lan_str[3] = "种产品，请先提交订单";
lan_str[4] = "确定";
lan_str[5] = "修改";
lan_str[6] = "删除";
lan_str[7] = "订购数量";
lan_str[8] = "其他说明";
lan_str[9] = "查看及修改订购信息";
lan_str[10] = "点击订购这个规格";
lan_str[11] = "真的从订单里删除这一条吗？";
lan_str[12] = "已经将这个产品加入订单";
lan_str[13] = "修改订单信息成功！";
lan_str[14] = "已经从订单删除这个产品";
lan_str[15] = "正在更新订单信息...";
lan_str[16] = "订单中没有产品，请在产品栏目选择产品及参数，加入订单";
lan_str[17] = "点击展开订单";
lan_str[18] = "点击隐藏订单";
lan_str[19] = "jtpump.com"
lan_str[20] = "关闭"
order_page = "buy_list.asp";

document.write("<style type=\"text/css\">"); 
document.write("#content_right ul.p_cate1,ul.p_i,#content ul.i_pro li ul.plist,li.p_s_l a:hover,li.p_s_l a.ac,li.p_s_l a.ac:hover{filter:Alpha(Opacity=93)} #attension{filter:Alpha(Opacity=0);} #case ul.adown li ul li a:hover{filter:Alpha(Opacity=83);} #helpout{filter:alpha(opacity=60);} #sresult{filter:Alpha(Opacity=90);}");
document.write("#ba_index {width:expression(document.body.offsetWidth<=778?\"766px\":\"auto\");}");
document.write("div.head,#main,#nav_bottom,#copyright{width:expression(document.body.offsetWidth<=778?\"778px\":\"100%\");}");
document.write("div.ba_r,div.content{left:77%;left:expression(document.body.clientWidth<=800?\"645px\":\"77%\" )}");
document.write("div.content{width:77%;width:expression(document.body.clientWidth<=800?\"645px\":\"77%\" )}");
document.write("h1.content,h2.content,#content ul.i_pro li ul.plist li a{text-overflow:ellipsis;}");
document.write("#content_right{min-width:126px;width:23%;margin-left:-23%;width:expression(document.body.clientWidth<=800?\"134px\":\"23%\" );margin-left: expression(document.body.clientWidth<=800?\"-134px\":\"-23%\" );}");
document.write("</style>"); 

document.write("<span id=\"logon\" class=\"cls1\"><dl><dt>内部登录</dt><dd><form name=\"frmemail\" method=\"post\" action=\"http://mail.jtpump.com/WorldClient.dll?View=Main\" target=\"_blank\" onsubmit=\"return check()\"><input type=\"hidden\" name=\"User\" /><label>账号：</label><input type=\"text\" alt=\"user\" name=\"User2\" class=\"i100\" onblur=\"this.className='i100'\" onfocus=\"this.className='i100f'\" /><span class=\"en\">@jtpump.com</span><br /><label>密码：</label><input type=\"password\" alt=\"password\" name=\"PASSWORD\" class=\"i100\" onblur=\"this.className='i100'\" onfocus=\"this.className='i100f'\"  /><br /><input type=\"submit\" value=\"登录\" class=\"submit\" onmouseover=\"this.style.backgroundColor='#f7e3d4'\" onmouseout=\"this.style.backgroundColor=''\"><input type=\"reset\" value=\"重填\" class=\"reset\"></form></dd></dl><a href=\"#\" class=\"cls\"></a></span>");

function swf(sFile,sWidth,sHeight){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ sWidth +'" height="'+ sHeight +'"><param name="movie" value="images/'+ sFile +'"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"><embed src="images/'+ sFile +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noborder" wmode="transparent" menu="false" width="'+ sWidth +'" height="'+ sHeight +'"></embed></object>');
}

function trim(a_strVarContent) {
var pos1, pos2, newstring;pos1 = 0;pos2 = 0;newstring = "";
	if ( a_strVarContent.length > 0 ) {
		for( i=0; i<=a_strVarContent.length; i++) { 
			if ( a_strVarContent.charAt(i) == " " ) pos1 = pos1 + 1;
			else break;
		} 
		for( i=a_strVarContent.length; i>=0 ; i--) {
			if ( a_strVarContent.charAt(i) == " " ) pos2 = pos2 + 1;
			else break;
		}
		newstring = a_strVarContent.substring(pos1, a_strVarContent.length-pos2) 
	} 
	return newstring; 
} 

function searchinput(){
	if (trim($('frmsearch').keywords.value) == ""){
		alert(lan_str[1]);
	    $('frmsearch').keywords.focus();
		return false;
    }else{
		$('frmsearch').keywords.value = trim($('frmsearch').keywords.value);
		obj = $("sresult");
		obj.style.display = "block";
		obj.innerHTML = "<img src=\"images/loadingr.gif\" width=\"16\" height=\"16\" alt=\"正在搜索匹配的信息...\" />";
		showrequest("search_ajax.asp?keywords=" + escape($('frmsearch').keywords.value),obj.id,false);
		cls_button();
	}
return false;
}

function searchp(keywords,r,p,ttype){
	showrequest("search_ajax.asp?keywords=" + keywords + "&r=" + r + "&p=" + p + "&type=" + ttype,"sresult",false);cls_button();
	return false;
}


function check()
{
document.frmemail.User.value = document.frmemail.User2.value + "@" + lan_str[19];
if (document.frmemail.User2.value==""){
  alert("请输入账号");
  document.frmemail.User2.focus();
  return false;
  }
if (document.frmemail.PASSWORD.value==""){
  alert("请输入密码");
  document.frmemail.PASSWORD.focus();
  return false;
  }
}

function js_openpage(url) {
  var newwin=window.open(url,"","toolbar=no, top=8,left=0,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=420,height=420");
  return false;
}

function js_infopen(url) {
  var newwin=window.open(url,"open","toolbar=no, top=20,left=0,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=638,height=394");
  return false;
}

function openwin(tURL,win,features) { var newwin=window.open(tURL,win,features); return false;}

function initialize(){
	//首页
	if (document.body.id == 'index'){
		var showm = new marquumsg("newslist");showm.show();
		document.getElementsByClassName("idd",$("i_pro"))[0].style.display = "block";
		$("idpage").firstChild.style.backgroundColor = "#ccc";
		szindex("i_pro");

		nCol = document.getElementsByClassName("plist",$("i_pro"));//产品列表
		for (i=0;i<nCol.length;i++)	{
			nCol[i].onmouseover = function(){
				this.style.visibility = "visible";
				this.parentNode.childNodes[1].className = (this.parentNode.childNodes[1].getAttribute("rel").substring(9,10)>3)?"i_proa2":"i_proa";
			}
			nCol[i].onmouseout = function(){
				this.style.visibility = "hidden";
				this.parentNode.childNodes[1].className = "i_pro";
			}
		}

		nCol = document.getElementsByClassName("i_pro",$("i_pro"));//产品类链接
		for (i=0;i<nCol.length;i++)	{
			if (nCol[i].tagName.toUpperCase() == "A")
			{
				nCol[i].onmouseover = function(){
					var nColul = document.getElementsByClassName("plist",$("i_pro"));
					this.className = (this.getAttribute("rel").substring(9,10)>3)?"i_proa2":"i_proa";
					for (j=0;j<nColul.length;j++){
						nColul[j].style.visibility = "hidden";
					}
					disul(this.parentNode.childNodes[2]);
				}
				nCol[i].onmouseout = function(){
					this.className = "i_pro";
					this.parentNode.childNodes[2].style.visibility = "hidden";
				}
			}
		}

		nCol = $("idpage").getElementsByTagName("A");//说明书下载
		for (i=0;i<nCol.length;i++){
			nCol[i].onclick = function(){
				for (j=0;j<$("idpage").getElementsByTagName("A").length-1;j++){
					$("idpage").getElementsByTagName("A")[j].style.backgroundColor = "#fff";
				}
				this.style.backgroundColor = "#ccc";

				var nCol_idd = document.getElementsByClassName("idd",$("i_pro"));
				for (j=0;j<nCol_idd.length;j++)	{
					nCol_idd[j].style.display = "none";
				}
				nCol_idd[this.getAttribute("rel").substring(10,11)].style.display = "block";
			}
		}
	}

	if (document.body.id == 'product'){	//产品首页
		szindex("p_s_l",true);
		nCol = document.getElementsByClassName("p_s_l");
		for (i=0;i<nCol.length;i++){
			nCol[i].firstChild.onmouseover=function(){
				this.parentNode.childNodes[1].style.display="block";
				this.parentNode.childNodes[1].style.top=this.offsetHeight;
			}

			nCol[i].firstChild.onmouseout=function(){
				this.parentNode.childNodes[1].style.display="none";									
			}
		}
		nCol = document.getElementsByClassName("p_i");
		for (i=0;i<nCol.length;i++){
			nCol[i].onmouseover=function(){
				this.style.display = "block";
				this.parentNode.firstChild.className = "ac";
			}
			nCol[i].onmouseout=function(){
				this.style.display = "none";
				this.parentNode.firstChild.className = "";
			}
		}
	}

	document.getElementsByClassName("buylist")[0].parentNode.innerHTML = "<a href=\"order.asp\" class=\"buylist\" onclick=\"buy_list();return false\">订购助手</a>";
	$("contact").outerHTML = "<span id=\"contact\" class=\"cls1\">" + $("contact").innerHTML + "</span>";

	//参数
	if (window.location.toString().indexOf("/product_para.asp") > 0){
		var p_c_id = window.location.toString().match(/(\?pid=|&pid=)(\d+)/)[2];para(p_c_id,1);
	}
	else{buy_base();}

	if (document.body.id == 'order'){buylist();buylists();}

	if (document.body.id != 'index'){	//非首页，置于参数后
		if ($("content_right")){
			$("content_right").style.height = $("contentwrapper").offsetHeight + "px";
		}

		//右侧
		if ($("content_right")){
			nCol = $("content_right").getElementsByTagName("A");
			for (i=0;i<nCol.length;i++)	{
				if (nCol[i].parentNode.parentNode.className == "p_cate"){
					nCol[i].onmouseover = function(){
						this.parentNode.childNodes[1].style.top = "-3px"; 
						this.parentNode.childNodes[1].style.display = "block";
					}
					nCol[i].onmouseout = function(){
						this.parentNode.childNodes[1].style.display = "none";
					}
				}
			}
			nCol = document.getElementsByClassName("p_cate1");
			for (i=0;i<nCol.length;i++){
				nCol[i].onmouseover=function(){
					this.style.display = "block";
					this.parentNode.firstChild.style.backgroundColor = "#d4e9f7";
				}
				nCol[i].onmouseout=function(){
					this.style.display = "none";
					this.parentNode.firstChild.style.backgroundColor = "";
				}
			}
		}

		if ($("content_right")){

			$("d_r_b").style.bottom = "3px";

			if ($("r_p")){
				$("r_p").onclick =function(){
					this.className = (this.className == "r_p")?"r_pa":"r_p";
					var p_cate_d = document.getElementsByClassName("p_cate")[0].style.display;
					document.getElementsByClassName("p_cate")[0].style.display = (p_cate_d !="block")?"block":"none";
					if (document.getElementsByClassName("p_cate")[0].style.display == "block" && $("contentwrapper").offsetHeight <= 420){
						$("contentwrapper").style.minHeight = "420px";
						$("content_right").firstChild.style.height= "420px";
					}else{
						$("contentwrapper").style.minHeight = "250px";
						$("content_right").firstChild.style.height= "100%";
					}
				}
			}
		}

		//下载汇总，案例
		if ($("adown")){
			nCol = $("adown").getElementsByTagName("A");
			for (i=0;i<nCol.length;i++){
				if (nCol[i].parentNode.className=="content_down"||nCol[i].parentNode.className=="content_down_a"){
					nCol[i].onclick = function(){
						this.className = (this.className =="ac")?"":"ac";
						var adown_d = this.parentNode.parentNode.childNodes[1].style.display;
						this.parentNode.parentNode.firstChild.className =  (adown_d == "none")?"content_down":"content_down_a";
						this.parentNode.parentNode.childNodes[1].style.display = (adown_d == "none")?"block":"none";
						if (this.parentNode.parentNode.childNodes[2]) this.parentNode.parentNode.childNodes[2].style.display = (adown_d == "none")?"block":"none";
						$("r_p").parentNode.childNodes[1].style.display = "none";
						$("content_right").style.height = ($("adown").parentNode.offsetHeight > 150)?($("adown").parentNode.offsetHeight)+"px":"150px";
						$("content_right").firstChild.style.height = ($("adown").parentNode.offsetHeight > 150)?($("adown").parentNode.offsetHeight) + "px":"150px";
						$("d_r_b").style.bottom = "3px";
					}
				}
			}
		}
	}

	nCol = document.getElementsByTagName("A");
	for (i=0;i<nCol.length;i++)	{
		if (nCol[i].href.substring(nCol[i].href.length-1,nCol[i].href.length) =="#"){
			nCol[i].href="javascript:void(null)";
		}
	}

	cls_button();

	nCol= $("nav_bottom").getElementsByTagName("A");//底部链接
	for (i=0;i<nCol.length;i++){
		if (nCol[i].getAttribute("rel").indexOf('id[') == 0){
			nCol[i].onclick = function(){
				var rels = this.getAttribute("rel");
				disidobj(this,$(rels.substring(3,rels.length-1)));
			}
		}
	}

	Event.observe(document, 'click', rel, true);
}

function cls_button(){
	nCol = document.getElementsByClassName("cls");
	for (i=0;i<nCol.length;i++){
		if (nCol[i].tagName == "A"){
			nCol[i].onclick = function(){
				if (this.parentNode.className == "help"){$("helpout").style.visibility = "hidden";}
				if (this.parentNode.id=="buy_list"||this.parentNode.id == "sresult"){
					this.parentNode.style.display = "none";
				}
				else{
					this.parentNode.style.visibility = "hidden";
				}
			}
		}
	}
}

function disul(obj){
	var x=obj.style.left,y=obj.style.top;
	obj.style.left = (1 + obj.parentNode.offsetLeft + obj.offsetWidth <= document.body.clientWidth )?"1px":(document.body.clientWidth-10-(1 + obj.parentNode.offsetLeft + obj.offsetWidth)+1) + "px"; 
	if (obj.parentNode.childNodes[1].getAttribute("rel").substring(9,10)>3)
	{obj.style.top = (79 - obj.offsetHeight + 2) + "px";}
	else{obj.style.top=98 + "px";
	}
	szindex("i_pro");
	obj.parentNode.style.zIndex = 201;
	obj.style.visibility = "visible";
}

function disidobj(objo,obj){
	if (obj.id == "help"){
		$("helpout").style.height = document.body.clientHeight + "px";
		$("helpout").style.width = document.body.clientWidth + "px";
		$("help").style.left = (document.body.clientWidth - $("help").offsetWidth)/2 + "px";
		var ctop = (document.body.clientHeight - $("help").offsetHeight)/2,ctop2 = $("nav_bottom").offsetTop - obj.offsetHeight;
		$("help").style.top = (ctop>ctop2)?ctop + "px":ctop2 + "px";
	}
	var objv = obj.style.visibility;
	if (obj.className !='' && obj.className != 'help'){
		nCol = document.getElementsByClassName(obj.className);
		for (i=0;i<nCol.length;i++)	{
			nCol[i].style.visibility = "hidden";
		}
	}
	//内容
	if ((obj.id == "link") && (objv != "visible")){
		obj.innerHTML = "<img src=\"images/loadingr.gif\" width=\"16\" height=\"16\" alt=\"正在传送数据...\" />";
		showrequest(obj.id + "_ajax.asp",obj.id,false);
		cls_button();
	}

	//位置
	obj.style.visibility = (objv == "visible")?"hidden":"visible";
	if (obj.id != "help"){
		var objl = (document.all)?objo.offsetWidth/2 + objo.parentNode.offsetLeft + objo.parentNode.parentNode.offsetLeft - obj.offsetWidth/2:objo.offsetWidth/2 + objo.parentNode.offsetLeft - obj.offsetWidth/2;
		obj.style.left = (objl + obj.offsetWidth > document.body.clientWidth)?(document.body.clientWidth-obj.offsetWidth) + "px":objl + "px";
		obj.style.top = ($("nav_bottom").offsetTop - obj.offsetHeight)+"px";
	}
	if (obj.id == "help"){$("helpout").style.visibility = $("help").style.visibility;}
}

function szindex(cname,nochild){
	if (nochild){
		var nCol = document.getElementsByClassName(cname);
	}else{
		var nCol = document.getElementsByClassName(cname)[0].childNodes;
	}

	for (i=0;i<nCol.length;i++)	{
		nCol[i].style.zIndex = 200 - i;
	}
}
function rel(event){
	if (Event.element(event).tagName.toUpperCase() == "A" ||Event.element(event).className == "hh"){
		var rels = (!(Event.element(event).getAttribute("rel"))?Event.element(event).parentNode.getAttribute("rel"):Event.element(event).getAttribute("rel"));
		if(rels && rels.indexOf('chxcontent')==0){
			var obj = (!(Event.element(event).getAttribute("rel")))?Event.element(event).parentNode.parentNode:Event.element(event).parentNode;
			switch (obj.id)
			{
			case "i_down":
				obj.parentNode.innerHTML = '<li class="left" id="i_down" style="background-color:#fff"><span class="hha">说明书下载</span></li><li id="i_cate"><a href="javascript:void(null)" rel="chxcontent"><span class="hh">产品分类</span></a></li>';
				document.getElementsByClassName("i_pro",$("i_pro"))[0].style.display = "none";
				document.getElementsByClassName("i_prodown",$("i_pro"))[0].style.display = "block";
				break;
			case "i_cate":
				obj.parentNode.innerHTML = '<li class="left" id="i_down"><a href="javascript:void(null)" rel="chxcontent"><span class="hh">说明书下载</span></a></li><li id="i_cate" style="background-color:#fff"><span class="hha">产品分类</span></li>';
				document.getElementsByClassName("i_pro",$("i_pro"))[0].style.display = "block";
				document.getElementsByClassName("i_prodown",$("i_pro"))[0].style.display = "none";
				break;
			}
		}
	}
}

function marquumsg(id){
	this.msgs= $(id).getElementsByTagName("DL").length;
	this.i = 0;
	window.objmarquumsg=this;
	this.show = function(){ 
		var j = (objmarquumsg.i==0)?objmarquumsg.msgs-1:objmarquumsg.i-1;
		$(id).getElementsByTagName("DL")[objmarquumsg.i].style.display = "block";
		$(id).getElementsByTagName("DL")[j].style.display = "none";
		objmarquumsg.i++;
		if (objmarquumsg.i == objmarquumsg.msgs){objmarquumsg.i = 0}
		this.mtime = setTimeout("objmarquumsg.show()",3000);
	} 
	nCol = $(id).getElementsByTagName("DL");
/*	for (i=0;i<nCol.length;i++)	{
		Event.observe(nCol[i],'mouseover',function(){clearTimeout(objmarquumsg.mtime);});
		Event.observe(nCol[i],'mouseout',function(){objmarquumsg.show();});
	}
*/
}

Event.onDOMReady(initialize);

function getEvent(){
	if(document.all) return window.event;
	func=getEvent.caller;
	while(func!=null){
		var arg0=func.arguments[0];
		if(arg0){
			if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){
			return arg0;
			}
		}
		func=func.caller;
	}
	return null;
}