// AJAX Tab
// update 2007.12.2
var Browser = new Object();
Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
if (Browser.isFirefox) { // entend Event Mod for FireFox
    extendEventObject();
}
function extendEventObject() {
    Event.prototype.__defineGetter__("srcElement", function () {
        var node = this.target;
        while (node.nodeType != 1) node = node.parentNode;
        return node;
    });

    Event.prototype.__defineGetter__("fromElement", function () {
        var node;
        if (this.type == "mouseover")
        node = this.relatedTarget;
        else if (this.type == "mouseout")
        node = this.target;
        if (!node) return;
        while (node.nodeType != 1) node = node.parentNode;
        return node;
    });

    Event.prototype.__defineGetter__("toElement", function () {
        var node;
        if (this.type == "mouseout")
        node = this.relatedTarget;
        else if (this.type == "mouseover")
        node = this.target;
        if (!node) return;
        while (node.nodeType != 1) node = node.parentNode;
        return node;
    });
}
function IsChild(cNode,pNode){
    while(cNode!=null){
        cNode=cNode.parentNode;
        if(cNode==pNode) return true;
    }
    return false;
}

var ajccache=new Object();
var waitInterval;
var tempref;
var MouseDelayTime=150;//鼠标感应延迟300毫秒
var style_active_arr = new Array();
var style_normal_arr = new Array();
//触发后的样式数组
style_active_arr['hot_menu_1'] = 'nor';
style_active_arr['hot_menu_2'] = 'nor';
style_active_arr['hot_menu_3'] = 'nor';

style_active_arr['inc_doc_11'] = 'nor';
style_active_arr['inc_doc_12'] = 'nor';
style_active_arr['inc_doc_13'] = 'nor';
style_active_arr['inc_doc_21'] = 'nor';
style_active_arr['inc_doc_22'] = 'nor';
style_active_arr['inc_doc_31'] = 'nor';
style_active_arr['inc_doc_32'] = 'nor';
style_active_arr['inc_doc_61'] = 'nor';
style_active_arr['inc_doc_62'] = 'nor';
style_active_arr['inc_doc_63'] = 'nor';
style_active_arr['inc_doc_71'] = 'nor';
style_active_arr['inc_doc_72'] = 'nor';

style_active_arr['inc_stock_11'] = 'nor f12b';
style_active_arr['inc_stock_12'] = 'nor f12b';
style_active_arr['inc_stock_13'] = 'nor f12b';
style_active_arr['inc_stock_14'] = 'nor f12b';
style_active_arr['inc_stock_15'] = 'nor f12b';
style_active_arr['inc_stock_16'] = 'nor f12b';
style_active_arr['inc_perstock_11'] = 'nor';
style_active_arr['inc_perstock_12'] = 'nor';
style_active_arr['inc_stock_41'] = 'nor';
style_active_arr['inc_stock_42'] = 'nor';
style_active_arr['inc_stock_61'] = 'nor';
style_active_arr['inc_stock_62'] = 'nor';
style_active_arr['inc_stock_71'] = 'nor';
style_active_arr['inc_stock_72'] = 'nor';
style_active_arr['inc_stock_73'] = 'nor';

style_active_arr['inc_sort_11'] = 'nor';
style_active_arr['inc_sort_12'] = 'nor';
style_active_arr['inc_sort_13'] = 'nor';
style_active_arr['inc_sort_14'] = 'nor';
style_active_arr['inc_sort_21'] = 'nor';
style_active_arr['inc_sort_22'] = 'nor';
style_active_arr['inc_sort_23'] = 'nor';
style_active_arr['inc_sort_24'] = 'nor';
style_active_arr['inc_sort_31'] = 'nor';
style_active_arr['inc_sort_32'] = 'nor';
style_active_arr['inc_sort_33'] = 'nor';
style_active_arr['inc_sort_34'] = 'nor';
style_active_arr['inc_sort_41'] = 'nor';
style_active_arr['inc_sort_42'] = 'nor';
style_active_arr['inc_sort_43'] = 'nor';
style_active_arr['inc_sort_44'] = 'nor';
style_active_arr['inc_sort_51'] = 'nor';
style_active_arr['inc_sort_52'] = 'nor';
style_active_arr['inc_sort_61'] = 'nor';
style_active_arr['inc_sort_62'] = 'nor';
style_active_arr['inc_sort_81'] = 'nor';
style_active_arr['inc_sort_82'] = 'nor';
style_active_arr['inc_sort_83'] = 'nor';
style_active_arr['inc_sort_84'] = 'nor';

style_active_arr['inc_forums_hot_11'] = 'nor';
style_active_arr['inc_forums_hot_12'] = 'nor';

style_active_arr['but_user_blog_hit_11'] = '';
style_active_arr['but_user_blog_hit_12'] = '';
//正常的样式数组
style_normal_arr['hot_menu_1'] = 'act lan12';
style_normal_arr['hot_menu_2'] = 'act lan12';
style_normal_arr['hot_menu_3'] = 'act lan12';

style_normal_arr['inc_doc_11'] = 'act lan12';
style_normal_arr['inc_doc_12'] = 'act lan12';
style_normal_arr['inc_doc_13'] = 'act lan12';
style_normal_arr['inc_doc_21'] = 'act lan12';
style_normal_arr['inc_doc_22'] = 'act lan12';
style_normal_arr['inc_doc_31'] = 'act lan12';
style_normal_arr['inc_doc_32'] = 'act lan12';
style_normal_arr['inc_doc_61'] = 'act lan12';
style_normal_arr['inc_doc_62'] = 'act lan12';
style_normal_arr['inc_doc_63'] = 'act lan12';
style_normal_arr['inc_doc_71'] = 'act lan12';
style_normal_arr['inc_doc_72'] = 'act lan12';

style_normal_arr['inc_stock_11'] = 'act lan12';
style_normal_arr['inc_stock_12'] = 'act lan12';
style_normal_arr['inc_stock_13'] = 'act lan12';
style_normal_arr['inc_stock_14'] = 'act lan12';
style_normal_arr['inc_stock_15'] = 'act lan12';
style_normal_arr['inc_stock_16'] = 'act lan12';
style_normal_arr['inc_perstock_11'] = 'act lan12';
style_normal_arr['inc_perstock_12'] = 'act lan12';
style_normal_arr['inc_stock_41'] = 'act lan12';
style_normal_arr['inc_stock_42'] = 'act lan12';
style_normal_arr['inc_stock_61'] = 'act lan12';
style_normal_arr['inc_stock_62'] = 'act lan12';
style_normal_arr['inc_stock_71'] = 'act lan12';
style_normal_arr['inc_stock_72'] = 'act lan12';
style_normal_arr['inc_stock_73'] = 'act lan12';

style_normal_arr['inc_sort_11'] = 'act lan12';
style_normal_arr['inc_sort_12'] = 'act lan12';
style_normal_arr['inc_sort_13'] = 'act lan12';
style_normal_arr['inc_sort_14'] = 'act lan12';
style_normal_arr['inc_sort_21'] = 'act lan12';
style_normal_arr['inc_sort_22'] = 'act lan12';
style_normal_arr['inc_sort_23'] = 'act lan12';
style_normal_arr['inc_sort_24'] = 'act lan12';
style_normal_arr['inc_sort_31'] = 'act lan12';
style_normal_arr['inc_sort_32'] = 'act lan12';
style_normal_arr['inc_sort_33'] = 'act lan12';
style_normal_arr['inc_sort_34'] = 'act lan12';
style_normal_arr['inc_sort_41'] = 'act lan12';
style_normal_arr['inc_sort_42'] = 'act lan12';
style_normal_arr['inc_sort_43'] = 'act lan12';
style_normal_arr['inc_sort_44'] = 'act lan12';
style_normal_arr['inc_sort_51'] = 'act lan12';
style_normal_arr['inc_sort_52'] = 'act lan12';
style_normal_arr['inc_sort_61'] = 'act lan12';
style_normal_arr['inc_sort_62'] = 'act lan12';
style_normal_arr['inc_sort_81'] = 'act lan12';
style_normal_arr['inc_sort_82'] = 'act lan12';
style_normal_arr['inc_sort_83'] = 'act lan12';
style_normal_arr['inc_sort_84'] = 'act lan12';

style_normal_arr['inc_forums_hot_11'] = 'act lan12';
style_normal_arr['inc_forums_hot_12'] = 'act lan12';

style_normal_arr['but_user_blog_hit_11'] = '';
style_normal_arr['but_user_blog_hit_12'] = '';
function startviewtabs(){
	for(var i=0;i<arguments.length;i++)
    {
        var ulobj=document.getElementById(arguments[i]);
        ulist=ulobj.getElementsByTagName("div");
        for(var j=0;j<ulist.length;j++)
        {
            var thelist=ulist[j];
            if(thelist.parentNode!=ulobj) continue;//只有第一层li有效 fixed 2006.9.29
            var ulistlink=thelist.getElementsByTagName("a")[0];
            var ulistlinkurl=ulistlink.getAttribute("urn");
            thelist.setActive=function(bactive){            	
            	var ocontent = document.getElementById("c_"+this.id);
                if(bactive){
                    this.status="active";
                    this.className = style_active_arr[this.id];
                    ocontent.style.display = 'block';
                }else{
                    this.status="normal";
                    this.className = style_normal_arr[this.id];              
                    ocontent.style.display = 'none';
                }
            }
            
            thelist.LoadTab=function(){
                this.setActive(true);
                this.parentNode.activetab.setActive(false);
                this.parentNode.activetab=this;
            }
            
            thelist.onmouseover=function(aEvent){
                var myEvent = window.event ? window.event : aEvent;
                var fm=myEvent.fromElement;
                if(IsChild(fm,this) || fm==this) return;//过滤子元素event
                if(this.status=="active") return;
                tempref=this;
                clearTimeout(waitInterval);
                waitInterval=window.setTimeout("tempref.LoadTab();",MouseDelayTime);
            }

            thelist.onmouseout=function(aEvent){
                var myEvent = window.event ? window.event : aEvent;
                var em=myEvent.toElement;
                if(IsChild(em,this) || em==this) return; //过滤子元素event
                if(this.status=="active") return;
                clearTimeout(waitInterval);
            }
            
            if(null!=ulistlinkurl && ulistlinkurl.indexOf("#default")!=-1){
                thelist.setActive(true);
                ulobj.activetab=thelist;
            }else{
                thelist.setActive(false);
            }
        }
    }
}

function startajaxtabs(){
    for(var i=0;i<arguments.length;i++)
    {
        var ulobj=document.getElementById(arguments[i]);
        ulist=ulobj.getElementsByTagName("div");
        for(var j=0;j<ulist.length;j++)
        {
            var thelist=ulist[j];
            if(thelist.parentNode!=ulobj) continue;//只有第一层li有效 fixed 2006.9.29
            var ulistlink=thelist.getElementsByTagName("a")[0];
            var ulistlinkurl=ulistlink.getAttribute("urn");
            var ulistlinktarget=ulistlink.getAttribute("rel");
            thelist.setActive=function(bactive){
                if(bactive){
//                    alert(this.id);
                    this.status="active";
                    this.className = style_active_arr[this.id];
                }else{
                    this.status="normal";
                    this.className = style_normal_arr[this.id];
                }
            }
            thelist.LoadTab=function(){
                this.setActive(true);
                this.parentNode.activetab.setActive(false);
                this.parentNode.activetab=this;
                var ulistlink=this.getElementsByTagName("a")[0];

                loadAJAXTab(ulistlink.getAttribute("urn"),ulistlink.getAttribute("rel"));
            }
            thelist.onmouseover=function(aEvent){
                var myEvent = window.event ? window.event : aEvent;
                var fm=myEvent.fromElement;
                if(IsChild(fm,this) || fm==this) return;//过滤子元素event
                if(this.status=="active") return;
                tempref=this;
                clearTimeout(waitInterval);
                waitInterval=window.setTimeout("tempref.LoadTab();",MouseDelayTime);
            }

            thelist.onmouseout=function(aEvent){
                var myEvent = window.event ? window.event : aEvent;
                var em=myEvent.toElement;
                if(IsChild(em,this) || em==this) return; //过滤子元素event
                if(this.status=="active") return;
                clearTimeout(waitInterval);
            }

            if(ulistlinkurl.indexOf("#default")!=-1){
                thelist.setActive(true);
                ulobj.activetab=thelist;
                ajccache[ulistlinkurl]=document.getElementById(ulistlinktarget).innerHTML;
            }else{
                thelist.setActive(false);
            }

        }
        if(ulobj.activetab==null) ulobj.activetab=ulist[0];
    }
}

function expand(s) {
  var tmp = s;
  var s = document.getElementById('menu'+s);
  var d = document.getElementById('c_menu'+tmp);

  d.style.display = "block";
  d.style.zIndex = "999";
}

function collapse(s) {
	var tmp = s;
	var s = document.getElementById('menu'+s);
	var d = document.getElementById('c_menu'+tmp);
	
	d.style.display = "none";
}

function getXmlhttp()
{
    var http_request;

    if(window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType("text/xml");
        }
    }
    else if (window.ActiveXObject) {
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        window.alert("can't create XMLHttpRequest object.");
        return null;
    }
    return http_request;
}

function loadAJAXTab(url,contentid){

    var ocontent=document.getElementById(contentid);
    if(ajccache[url]==null) {

        var xhttp=getXmlhttp();
        xhttp.onreadystatechange=function(){
            if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
            {
                ocontent.innerHTML=xhttp.responseText;
                ajccache[url]=ocontent.innerHTML;
            }
        }
        xhttp.open("GET",url+"?rand="+Math.random(),true);
        xhttp.send(null);
    }else{

        ocontent.innerHTML=ajccache[url];
    }
}
window.onerror=function(){return true}

function expand(s) {
	var tmp = s;
	var s = document.getElementById('menu'+s);
	var d = document.getElementById('c_menu'+tmp);
	
	d.style.display = "block";
	d.style.zIndex = "999";
	if(7==tmp) document.getElementById('type_id').style.display = "none";
}

function collapse(s) {
	var tmp = s;
	var s = document.getElementById('menu'+s);
	var d = document.getElementById('c_menu'+tmp);
	
	d.style.display = "none";
	if(7==tmp) document.getElementById('type_id').style.display = "block";
}