$(document).ready(function() {
    //绑定鼠标事件
    var menulinks = $("div.mainnav_top > ul > li");
    menulinks.each(function(i) {
        $(this).mouseover(function() {
            $(this).siblings().removeClass("current").end().addClass("current");
            $("div.subnav_wrapper").hide().eq(i).show();
        });
    });
    //主频道设为激活状态
    var channelDir = getChannelName();
    if (channelDir) {
        var channel = $("#" + channelDir.toLowerCase() + "_nav");
        if (channel.size() > 0) {
            channel.siblings().removeClass("current").end().addClass("current");
            var idx = menulinks.index(channel);
            $("div.subnav_wrapper").hide().eq(idx).show();
        }
    }
    try {
        swfobject.embedSWF("/uploads/banner/banner970x150.swf", "ciguo_banner", "970", "150", "9.0.0", "/scripts/expressInstall.swf");
    } catch (e) { }
});

var tabview={
	init:function(){
		var elms = document.getElementsByName("sliding");
		for(var g=0; g<elms.length; g++){
			var lielms = elms[g].getElementsByTagName('LI');
			for(var i=0; i<lielms.length; i++){
				lielms[i].onmousedown = function(){
					var pnobj = this.parentNode.parentNode.nextSibling.tagName == "DIV" ? this.parentNode.parentNode.nextSibling : this.parentNode.parentNode.nextSibling.nextSibling;
					var objsx = pnobj.getElementsByTagName('UL');
					var elmsx = this.parentNode.getElementsByTagName('LI');
					var thisx = 0;
					for(var j=0; j<elmsx.length; j++){
						if(elmsx[j] == this) thisx = j;
						elmsx[j].className="";
						objsx[j].style.display="none";
					}
					this.className='on';
					objsx[thisx].style.display="";
				}
			}
		}
	}
}



function loadjscssfile(filename, filetype) {
	if (filetype == "js") {
		var fileref = document.createElement('script');
		fileref.setAttribute("type", "text/javascript");
		fileref.setAttribute("src", filename)
	} else if (filetype == "css") {
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", filename)
	}
	if (typeof fileref != "undefined") 
		document.getElementsByTagName("head")[0].appendChild(fileref)
}

function setCurrent() {
    var allPath = window.location.href.toLowerCase();
    var vPath = allPath.split("/");
    var path = vPath[vPath.length - 2];
    var path_nav = path + "_nav";
    var omenu = document.getElementById(path_nav);
    if (omenu) {
        omenu.getElementsByTagName("a")[0].className = "nav_current";
    }
}

function getChannelName() {
    try {
        var pageURL = document.URL;
        if (pageURL.indexOf("http://") != -1) {
            pageURL = pageURL.replace('http://', '');
        }
        channelDirs = pageURL.split("/");
        if (channelDirs.length < 2) {
            return null;
        }
        return channelDirs[1];
    } catch (ex) {
        return null;
    }
}

//            alert("location:" + location);
//            alert("location.host:" + location.host);
//            alert("location.hostname:" + location.hostname);
//            alert("document.domain:" + document.domain);
//            alert("document.URL:" + document.URL);