
var haier = { 

//top links
	top_links : function(){
		var lv = document.getElementById("glbm");
		var lvt= document.getElementById("glb");
		var lc = document.getElementById("chlm");
		var lct= document.getElementById("chl");
        var lct= document.getElementById("chl");
		if(lv){
			lv.onmouseover= function(){	lvt.style.display = "block"; }
			lvt.onmouseout= function(){	lvt.style.display = "none";	}
			lv.onmouseout= function(){ lvt.style.display = "none"; }
		}
		if(lc){
			lc.onmouseover= function(){	lct.style.display = "block"; }
			lct.onmouseout= function(){	lct.style.display = "none";	}
			lc.onmouseout= function(){ lct.style.display = "none"; }
		}
	},

//main nav
	main_nav : function(){
		var lisp = document.getElementById("main_nav");
		if(lisp) {
			var lis = lisp.getElementsByTagName("li");
			for (var i=0; i<lis.length; i++) {
				lis[i].onmouseover=function() {	this.className+="iehover"; }
				lis[i].onmouseout=function() { this.className=" "; }
			}
		}
	},

//left nav
	left_nav : function(){
		var obj = document.getElementById("nav_l");
		if(obj) {
				obj.onclick = function(e){
				var e = e || window.event;
				var tg = e.target || e.srcElement; 
				if(tg.className==="arr"){ 
					var tp = haier.nextNode(tg);
					if(tp.tagName==="UL"){
						if(tp.style.display === "block"){
							tp.style.display = "none";
							tg.src = "http://www.haier.cn/images/ar_right.gif";
							var tpr = haier.prevNode(tg).firstChild
							var tprc= tpr.src.lastIndexOf(".gif");
							var sctpi = tpr.src.substring(tprc-3);
							if (sctpi=== "_on.gif"){
								var sctpr = tpr.src.substring(0,tprc-3);
								tpr.src = sctpr + ".gif";
							}
						}else{
							tp.style.display ="block"; 
							tg.src = "http://www.haier.cn/images/ar_down.gif";
							var tpr = haier.prevNode(tg).firstChild
							var tprc= tpr.src.lastIndexOf(".gif");
							var sctpi = tpr.src.substring(tprc-3);
							if (sctpi=== "_on.gif"){
								var sctpr = tpr.src.substring(0,tprc-3);
								tpr.src = sctpr + ".gif";
							}
							else{
								var sctpr = tpr.src.substring(0,tprc);
								tpr.src = sctpr + "_on.gif";
							}
						}
					}
				}
			}
        }
	},

//news list hover
	news_list_hover : function(){
		var objlp = document.getElementById("lt_hov");
		if(objlp) { 
			var objl = objlp.getElementsByTagName("li");
			for(var i=0,j=objl.length;i<j;i++){
					objl[i].onmouseover = function(){
						this.className = this.className=== "on"?" hov":"hov";
					}
					objl[i].onmouseout = function(){
						this.className = this.className=== "hov"?"":"on";
					}
			}
		 }
	},
	
//dl01 showhide
     dl01_showhide :function (){
       var dl01 = document.getElementById("dl01");
       if(!dl01){return;}
       var dl01_dts = dl01.getElementsByTagName("dt");
	    for(var i=0,j=dl01_dts.length;i<j;i++){
          dl01_dts[i].onclick=function (){
              for(var i=0,j=dl01_dts.length;i<j;i++){
               dl01_dts[i].className ="";
               haier.nextNode(dl01_dts[i]).className="";
			  }
            haier.nextNode(this).className ="show";
            this.className ="current";
           }

		 }
   },

//playswf
    playswf :function (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=6,0,29,0" width="'+ sWidth +'" height="'+ sHeight +'">  ');
		   document.write(' <param name="movie" value="'+ sFile +'">  ');
		   document.write(' <param name="quality" value="high">  ');
		   document.write(' <param name="wmode" value="transparent">  ');
		   document.write(' <embed src="'+ sFile +'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ sWidth +'" height="'+ sHeight +'"></embed>  ');
		   document.write('</object> ');
	  },

//products_nav
	 products_nav:function (){
		var sfEl  = document.getElementById("prolist_nav");
		if(!sfEl){return;}
		var sfEls = sfEl.getElementsByTagName("LI");
		for (var i=0,j=sfEls.length; i<j; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" show";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" show\\b"), "");
		}
	  }
	 },

//nextNode
	nextNode : function(elem) {
		do {
			elem = elem.nextSibling;
		} while ( elem && elem.nodeType != 1 );
		return elem;
	},
//prevNode
	prevNode : function( elem ) {
		do {
			elem = elem.previousSibling;
		} while ( elem && elem.nodeType != 1 );
		return elem;
	},
//firstNode
	firstNode :function ( elem ) {
		elem = elem.firstChild;
		return elem && elem.nodeType != 1 ?	next ( elem ) : elem;
	},

//addEvent
	addEvent: function(elm, evType, fn, useCapture){
		if (elm.addEventListener) 
		{
			elm.addEventListener(evType, fn, useCapture);
			return true;
		} else if (elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		} else {
			elm['on' + evType] = fn;
		}
	},
	
// location
	loca : function(){
		
		if (!document.getElementById("nav_l")) {return false}

		var h = window.location.href;
		var o = document.getElementById("nav_l").getElementsByTagName("ul");

	//about
		if( h.indexOf("about")>0){
			if( h.indexOf("about/about")>0){
				o[0].style.display = "block";
				o[0].getElementsByTagName("li")[0].className = "on";
			}
			if( h.indexOf("about/ceo")>0){
				o[0].style.display = "block";
				o[0].getElementsByTagName("li")[1].className = "on";
			}
			if( h.indexOf("about/vision")>0){
				o[0].style.display = "block";
				o[0].getElementsByTagName("li")[2].className = "on";
			}
			if( h.indexOf("about/honor")>0){
				o[0].style.display = "block";
				o[0].getElementsByTagName("li")[3].className = "on";
			}
			if( h.indexOf("about/mil")>0){
				o[0].style.display = "block";
				o[0].getElementsByTagName("li")[4].className = "on";
			}
			if( h.indexOf("about/business")>0){
				o[1].style.display = "block";
				if( h.indexOf("business_index")>0){
					o[1].getElementsByTagName("li")[0].className = "on";
				}
				if( h.indexOf("business_mobile")>0){
					o[1].getElementsByTagName("li")[1].className = "on";
				}
				if( h.indexOf("business_ithaier")>0){
					o[1].getElementsByTagName("li")[2].className = "on";
				}
				if( h.indexOf("business_home")>0){
					o[1].getElementsByTagName("li")[3].className = "on";
				}
				if( h.indexOf("business_biological")>0){
					o[1].getElementsByTagName("li")[4].className = "on";
				}
				if( h.indexOf("business_software")>0){
					o[1].getElementsByTagName("li")[5].className = "on";
				}
				if( h.indexOf("business_logistics")>0){
					o[1].getElementsByTagName("li")[6].className = "on";
				}
				if( h.indexOf("business_finance")>0){
					o[1].getElementsByTagName("li")[7].className = "on";
				}
				if( h.indexOf("business_travel")>0){
					o[1].getElementsByTagName("li")[8].className = "on";
				}
				if( h.indexOf("business_haierhouse")>0){
					o[1].getElementsByTagName("li")[9].className = "on";
				}
				if( h.indexOf("business_parts")>0){
					o[1].getElementsByTagName("li")[10].className = "on";
				}
				if( h.indexOf("business_itophome")>0){
					o[1].getElementsByTagName("li")[11].className = "on";
				}
				if( h.indexOf("business_haiermedical")>0){
					o[1].getElementsByTagName("li")[12].className = "on";
				}
			}
			if( h.indexOf("about/culture")>0||h.indexOf("about/expert_culture")>0){
				o[2].style.display = "block";
				if( h.indexOf("about/culture_index")>0){
					o[2].getElementsByTagName("li")[0].className = "on";
				}
				if( h.indexOf("about/culture_statement")>0){
					o[2].getElementsByTagName("li")[1].className = "on";
				}
				if( h.indexOf("about/culture_story")>0){
					o[2].getElementsByTagName("li")[2].className = "on";
				}
				if( h.indexOf("about/culture_paint")>0){
					o[2].getElementsByTagName("li")[3].className = "on";
				}
				if( h.indexOf("about/culture_expert")>0||h.indexOf("about/expert_culture")>0){
					o[2].getElementsByTagName("li")[4].className = "on";
				}
				if( h.indexOf("about/culture_20y")>0){
					o[2].getElementsByTagName("li")[5].className = "on";
				}
			}
			if( h.indexOf("about/worldwide")>0){
				o[3].style.display = "block";
				if( h.indexOf("worldwide_america")>0){
					o[3].getElementsByTagName("li")[0].className = "on";
				}
				if( h.indexOf("worldwide_europe")>0){
					o[3].getElementsByTagName("li")[1].className = "on";
				}
				if( h.indexOf("worldwide_SouthAsian")>0){
					o[3].getElementsByTagName("li")[2].className = "on";
				}
				if( h.indexOf("worldwide_AsianPacific")>0){
					o[3].getElementsByTagName("li")[3].className = "on";
				}
				if( h.indexOf("worldwide_ASEAN")>0){
					o[3].getElementsByTagName("li")[4].className = "on";
				}
				if( h.indexOf("worldwide_MiddleeastnAfrica")>0){
					o[3].getElementsByTagName("li")[5].className = "on";
				}
				if( h.indexOf("worldwide_china")>0){
					o[3].getElementsByTagName("li")[6].className = "on";
				}
			}
			if( h.indexOf("about/deve")>0){
				o[4].style.display = "block";
				if( h.indexOf("develop_laboratory")>0){
					o[4].getElementsByTagName("li")[0].className = "on";
				}
				if( h.indexOf("develop_technology")>0){
					o[4].getElementsByTagName("li")[1].className = "on";
				}
				if( h.indexOf("develop_rnd")>0){
					o[4].getElementsByTagName("li")[2].className = "on";
				}
			}
			if( h.indexOf("about/contribute")>0){
				o[5].style.display = "block";
				if( h.indexOf("contribute_01")>0){
					o[5].getElementsByTagName("li")[0].className = "on";
				}
				if( h.indexOf("contribute_sport")>0){
					o[5].getElementsByTagName("li")[1].className = "on";
				}
				if( h.indexOf("contribute_poverty")>0){
					o[5].getElementsByTagName("li")[2].className = "on";
				}
				if( h.indexOf("contribute_green")>0){
					o[5].getElementsByTagName("li")[3].className = "on";
				}
				if( h.indexOf("contribute_others")>0){
					o[5].getElementsByTagName("li")[4].className = "on";
				}
			}
			if( h.indexOf("about/youth")>0){
				o[6].style.display = "block";
				if( h.indexOf("youth_index")>0){
					o[6].getElementsByTagName("li")[0].className = "on";
				}
				if( h.indexOf("youth_news")>0){
					o[6].getElementsByTagName("li")[1].className = "on";
				}
				if( h.indexOf("youth_events")>0){
					o[6].getElementsByTagName("li")[2].className = "on";
				}
				if( h.indexOf("youth_links")>0){
					o[6].getElementsByTagName("li")[3].className = "on";
				}
			}
			if( h.indexOf("about/invest")>0){
				o[7].style.display = "block";
				if( h.indexOf("invest_stock_info")>0){
					o[7].getElementsByTagName("li")[0].className = "on";
				}
				if( h.indexOf("invest_archive")>0){
					o[7].getElementsByTagName("li")[1].className = "on";
				}
				if( h.indexOf("invest_financial")>0){
					o[7].getElementsByTagName("li")[2].className = "on";
				}
				if( h.indexOf("invest_management")>0){
					o[7].getElementsByTagName("li")[3].className = "on";
				}
			}
			if( h.indexOf("about/university")>0){
				o[8].style.display = "block";
				if( h.indexOf("university_overview")>0){
					o[8].getElementsByTagName("li")[0].className = "on";
				}
				if( h.indexOf("university_service")>0){
					o[8].getElementsByTagName("li")[1].className = "on";
				}
				if( h.indexOf("university_customer")>0){
					o[8].getElementsByTagName("li")[2].className = "on";
				}
				if( h.indexOf("university_news")>0){
					o[8].getElementsByTagName("li")[3].className = "on";
				}
				if( h.indexOf("university_contact")>0){
					o[8].getElementsByTagName("li")[4].className = "on";
				}
			}
			if( h.indexOf("about/index")>0){
				o[0].style.display = "block";
			}
		}
	//news
		if( h.indexOf("news/haier_news")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("news/market_news")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[1].className = "on";
		}
		if( h.indexOf("news/info_news")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[2].className = "on";
		}
		if( h.indexOf("news/leaders_news")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[3].className = "on";
		}
		if( h.indexOf("news/communication_news")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[4].className = "on";
		}
		if( h.indexOf("news/media_news")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("news/international_news")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[1].className = "on";
		}
		if( h.indexOf("news/expert_news")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[2].className = "on";
		}
		if( h.indexOf("news/video_gallery.")>0){
			o[2].style.display = "block";
			o[2].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("news/video_gallery02")>0){
			o[2].style.display = "block";
			o[2].getElementsByTagName("li")[1].className = "on";
		}
		if( h.indexOf("news/video_gallery03")>0){
			o[2].style.display = "block";
			o[2].getElementsByTagName("li")[2].className = "on";
		}
	//service
		if( h.indexOf("service/customer_sori")>0){
			document.getElementById("nav_l").getElementsByTagName("img")[7].src="../images/nav_sev_us_on.gif"
		}
		if( h.indexOf("service/ServiceStandard")>0){
			document.getElementById("nav_l").getElementsByTagName("img")[6].src="../images/nav_sev_pc_on.gif"
		}
		if( h.indexOf("service/service_system")>0){
			document.getElementById("nav_l").getElementsByTagName("img")[5].src="../images/nav_sev_pr_on.gif"
		}
		if( h.indexOf("service/video")>0){
			document.getElementById("nav_l").getElementsByTagName("img")[4].src="../images/nav_sev_vd_on.gif"
		}
		if( h.indexOf("service/knowledge")>0){
			document.getElementById("nav_l").getElementsByTagName("img")[0].src="../images/nav_sev_kl_on.gif"
		} 
		if( h.indexOf("manualSearch")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("swSearch")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[1].className = "on";
		}
		if( h.indexOf("service/ServicePolicy")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("service/ServiceFlow")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[1].className = "on";
		}
		if( h.indexOf("service/ServiceMode")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[2].className = "on";
		}
		if( h.indexOf("service/ServiceInnovation")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[3].className = "on";
		}
		if( h.indexOf("service/credit")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[4].className = "on";
		}
	//recruit
		if( h.indexOf("recruit/invite")>0 || h.indexOf("recruit/senior")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("recruit/campus")>0){
			o[0].style.display = "block";
			o[0].getElementsByTagName("li")[1].className = "on";
		}
		if( h.indexOf("recruit/society")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("recruit/social")>0){
			o[1].style.display = "block";
			o[1].getElementsByTagName("li")[1].className = "on";
		}
		if(h.indexOf("recruit/index.shtml")>0){
			document.getElementById("nav_l").getElementsByTagName("img")[0].src="../images/nav_rec_rcg_on.gif"
		}
	//hr
		if( h.indexOf("hr/inviteJob.do")>0 || h.indexOf("hr/social_guide")>0){
			o[0].style.display = "block";
		}
		if( h.indexOf("hr/inviteJob.do?exec=initQueryJob")>0){
			o[0].getElementsByTagName("li")[1].className = "on";
		}
		if( h.indexOf("hr/inviteJob.do?exec=queryInviteJob")>0){
			o[0].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("hr/social_guide.jsp")>0){
			o[0].getElementsByTagName("li")[2].className = "on";
		}
		if( h.indexOf("hr/for_wokers.jsp")>0){
			o[2].style.display = "block";
			o[2].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("hr/for_wokers_note.jsp")>0){
			o[2].style.display = "block";
			o[2].getElementsByTagName("li")[1].className = "on";
		}
		if( h.indexOf("hr/hr_review.jsp")>0){
			o[3].style.display = "block";
			o[3].getElementsByTagName("li")[0].className = "on";
		}
		if( h.indexOf("hr/career.jsp")>0){
			o[3].style.display = "block";
			o[3].getElementsByTagName("li")[3].className = "on";
		}
		if( h.indexOf("hr/welfare.jsp")>0){
			o[3].style.display = "block";
			o[3].getElementsByTagName("li")[5].className = "on";
		}
	//active parent
		var ols=o.length;
		for(var i=0;i<ols;i++){
			if(o[i].style.display == "block"){
				haier.prevNode(o[i]).src = "http://www.haier.cn/images/ar_down.gif";
				var a   = haier.firstNode(haier.prevNode(haier.prevNode(o[i])));
				var ah  = a.src;
				var ahe = ah.lastIndexOf(".gif");
				var aheu= ah.substring(0,ahe);
					a.src = aheu + "_on.gif";
			}
		}
	}

} 

haier.addEvent(window,"load",haier.top_links,false);
haier.addEvent(window,"load",haier.main_nav,false);
haier.addEvent(window,"load",haier.left_nav,false);
haier.addEvent(window,"load",haier.news_list_hover,false);
haier.addEvent(window,"load",haier.dl01_showhide,false);
haier.addEvent(window,"load",haier.products_nav,false);
haier.addEvent(window,"load",haier.loca,false);