$(function(){
	$('.index-tab li').mouseover(function(){
		var name = "#index-link" + this.id.substring(9);
		$('.index-link').hide();
		$(name).show();
		$('.index-tab .act').removeClass('act');
		$(this).addClass('act');
	});
	$('body').click(function(){
		searchDisabledTop();	
	});
	
	$(document).ready(function() {
		$("#adbtn").click(function () {
			var tmpScrollTop = document.documentElement.scrollTop; 
			var bodywidth = document.body.clientWidth;
			var o_width = parseInt($("#ad").css('width'));
			$("#ad").css({
				left:bodywidth>o_width?(bodywidth-o_width)/2:0,
				top:tmpScrollTop + 150
			}).show();
		});
		$("#Close").click(function () {
			$("#ad").hide();
		});			
	});
});

function searchButtonTop(style, value,obj) {
	$('#type_top').val(value);
	$('#category_top').css('display',style);
	if(style=="none"){
		$('#kw_select_top').val($(obj).find('a').html());
	}
}
/* search disabled */
function searchDisabledTop() {
	var obj = document.getElementById('category_top');
	if(obj)
	obj.style.display = 'none';
}

function scheckTop() {
	var val = $('#keyword_top').val();
	if(val=="关键词搜索"){
		alert("请输入关键词");
		return false;
	}
	
	var typeTop = $('#type_top').val();
	//文章检索
	if(typeTop == 'other'){
		document.search_top.action="web/home/search.jsp"
	//产品检索
	}else{
		document.search_top.action="web/p_search_list.jsp"
	}
	
	return true;
}



/**立邦首页kv start**/
function $$$I(id){
	return"string"==typeof id?document.getElementById(id):id
}
function getClsI(obj,tn){
	var a=new Array();
	var cn=obj.childNodes;
	for(var i=0;i<cn.length;i++){
		var c=cn[i];
		if(!!c.tagName&&c.tagName.toLowerCase()==tn){
			a.push(c)
		}
	}
	return a
};
function CMKV(){
	var I,K,D,_=new Array(),J=0,M=0,E,L,A,B=false,N=false;
	var DHTU,DHTD;
	var stop1 = 2;
	var stop2 = -16;
	var G=function(){
		if(!!L){
			clearTimeout(L);
			L=null
		}
		if(this.className=="on"){
			return;
		}
		E=parseInt(this.getAttribute("num"));
		N=true;
		if(!B){
			M=E;E=-1;P();
		}
	};
	var H=function(){
		N=false;O();
	}
	var O=function(){
		var $=parseInt(K[J].getAttribute("stopTime"));
		if($<3||isNaN($)){
			$=3;
		}
		clearTimeout(L);
		L=setTimeout(P,$*1000)
	}
	var P=function(){
		B=true;
		if(!N){
			if(J==K.length-1){M=0;}else{M=J+1;}
		}
		K[J].style.zIndex=1;
		K[M].style.zIndex=2;
		K[M].style.left="558px";
		clearTimeout(A);
		A=setTimeout(C,20);
		_[J].className="";
		_[M].className="on";
		DHDOWN(_[J]);
		DHUP(_[M]);
	}
	var C=function(){var _=parseInt(K[M].style.left),$=_-_*0.2;$=$<1?0:$;K[M].style.left=$+"px";if($==0){clearTimeout(A);A=null;K[J].style.left="600px";J=M;B=false;if(!N)O();else if(E>-1){M=E;E=-1;P()}}else A=setTimeout(C,20)}
	var F=function(){
		var F=$$$I("CMHotPic"),E=getClsI(F,"div");
		if(E.length != 3)return;I=E[0];D=E[1];SI=E[2];
		K=getClsI(I,"div");
		var C=D.getElementsByTagName("ul"),B;
		if(C.length>0)B=C[0];else return;
		//alert(K[0].innerHTML);

		var SISP = getClsI(SI,"span");
		for(var J=0;J<K.length;J++){
			var SIMG = getClsI(getClsI(K[J],"a")[0],"img");
			//alert(SIMG[0]);
			var A=document.createElement("li");

			K[J].style.top="0px";
			K[J].style.position="absolute";
			//A.innerHTML=J+1;
			var shtml = '<span>'+SIMG[0].getAttribute("nameT")+'</span><span id="simg'+(J+1)+'">'+SISP[J].innerHTML+'</span>';
			A.innerHTML=shtml;
			A.setAttribute("num",J);

			
			if(J!=0){}else{
				A.className="on";
				DHUP(A);
			}

			A.onmouseover=G;
			A.onmouseout=H;
			B.appendChild(A);
			_.push(A)
		}
		O()
	}
	var DHUP=function(obj){
		var sobj = getClsI(obj,"span");
		//alert(type);
		clearTimeout(DHTU);
	    DHTU=setInterval(function(){DHS(sobj[1],1);},(15))
	}
	var DHDOWN=function(obj){
		var sobj = getClsI(obj,"span");
		//alert(type);
		clearTimeout(DHTD);
	    DHTD=setInterval(function(){DHS(sobj[1],2);},(15))
	}
	var DHS=function(obj,type){
		//alert(obj);
		if(type==1){
			if(stop1 > -16){
				stop1 -= 1;
				obj.style.top= stop1+"px";
			}else{
				stop1=2;
				clearInterval(DHTU);
			}
		}else{
			if(stop2 < 2){
				stop2 += 1;
				obj.style.top= stop2+"px";
			}else{
				stop2=-16;
				clearInterval(DHTD);
			}
		}
	}
	;F()
};
/**立邦首页kv end**/