// 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['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_43'] = '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_hangye_11'] = 'act';
style_active_arr['inc_hangye_12'] = 'act';
style_active_arr['inc_hangye_21'] = 'act';
style_active_arr['inc_hangye_22'] = 'act';
style_active_arr['inc_hangye_31'] = 'act';
style_active_arr['inc_hangye_32'] = 'act';
style_active_arr['inc_hangye_41'] = 'act';
style_active_arr['inc_hangye_42'] = 'act';
style_active_arr['inc_hangye_51'] = 'act';
style_active_arr['inc_hangye_52'] = 'act';

style_active_arr['inc_warrant_11'] = 'act';
style_active_arr['inc_warrant_12'] = 'act';
style_active_arr['inc_warrant_21'] = 'act';
style_active_arr['inc_warrant_22'] = 'act';

style_active_arr['index_img_1'] = 'act';
style_active_arr['index_img_2'] = 'act';
style_active_arr['index_img_3'] = 'act';

style_active_arr['inc_news1_1'] = 'act';
style_active_arr['inc_news1_2'] = 'act';
style_active_arr['inc_news1_3'] = 'act';
style_active_arr['inc_news1_4'] = 'act';

style_active_arr['inc_blog_1'] = 'normal';
style_active_arr['inc_blog_2'] = 'normal';
style_active_arr['inc_blog_3'] = 'normal';

style_active_arr['inc_news_1'] = 'normal';
style_active_arr['inc_news_2'] = 'normal';
style_active_arr['inc_news_3'] = 'normal';
style_active_arr['inc_news_4'] = 'normal';

style_active_arr['inc_report_1'] = 'active';
style_active_arr['inc_report_2'] = 'active';

//正常的样式数组
style_normal_arr['inc_sort_11'] = '';
style_normal_arr['inc_sort_12'] = '';
style_normal_arr['inc_sort_13'] = '';
style_normal_arr['inc_sort_14'] = '';
style_normal_arr['inc_sort_21'] = '';
style_normal_arr['inc_sort_22'] = '';
style_normal_arr['inc_sort_23'] = '';
style_normal_arr['inc_sort_24'] = '';
style_normal_arr['inc_sort_31'] = '';
style_normal_arr['inc_sort_32'] = '';
style_normal_arr['inc_sort_33'] = '';
style_normal_arr['inc_sort_34'] = '';
style_normal_arr['inc_sort_41'] = '';
style_normal_arr['inc_sort_42'] = '';
style_normal_arr['inc_sort_43'] = '';
style_normal_arr['inc_sort_44'] = '';

style_normal_arr['inc_hangye_11'] = '';
style_normal_arr['inc_hangye_12'] = '';
style_normal_arr['inc_hangye_21'] = '';
style_normal_arr['inc_hangye_22'] = '';
style_normal_arr['inc_hangye_31'] = '';
style_normal_arr['inc_hangye_32'] = '';
style_normal_arr['inc_hangye_41'] = '';
style_normal_arr['inc_hangye_42'] = '';
style_normal_arr['inc_hangye_51'] = '';
style_normal_arr['inc_hangye_52'] = '';

style_normal_arr['inc_warrant_11'] = '';
style_normal_arr['inc_warrant_12'] = '';
style_normal_arr['inc_warrant_21'] = '';
style_normal_arr['inc_warrant_22'] = '';

style_normal_arr['index_img_1'] = '';
style_normal_arr['index_img_2'] = '';
style_normal_arr['index_img_3'] = '';

style_normal_arr['inc_news1_1'] = '';
style_normal_arr['inc_news1_2'] = '';
style_normal_arr['inc_news1_3'] = '';
style_normal_arr['inc_news1_4'] = '';

style_normal_arr['inc_blog_1'] = 'active';
style_normal_arr['inc_blog_2'] = 'active';
style_normal_arr['inc_blog_3'] = 'active';

style_normal_arr['inc_news_1'] = 'active';
style_normal_arr['inc_news_2'] = 'active';
style_normal_arr['inc_news_3'] = 'active';
style_normal_arr['inc_news_4'] = 'active';

style_normal_arr['inc_report_1'] = 'normal';
style_normal_arr['inc_report_2'] = 'normal';

function startviewtabs(){
	for(var i=0;i<arguments.length;i++)
    {
        var ulobj=document.getElementById(arguments[i]);
        ulist=ulobj.getElementsByTagName("li");
        alert(ulist.length);
        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("li");
        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"),ulistlink.getAttribute("mean"));
                /**********去除其他栏目的滚动效果 **************/
                 if(ulistlink.getAttribute("mean") == null && ulistlink.getAttribute("rel") == 'inc_blog')
                {
            	   document.getElementById('inc_blog').scrollTop = 0;
                }
                /*******************************************/
            }
            thelist.onmouseover=function(aEvent){       
                // add by lijie, for index data change start, 2009 2 10
                if ( this.parentNode.id == 'but_index_img' ){
                    var tmp_global_native_type = this.id.replace('index_img_', '').toString();
                    global_nation_type = tmp_global_native_type;
                    global_index_type = 1;
                }
                // add by lijie, for index data change end                
                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,mean){

    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;
                if(mean == 'miniblog') start_marque();
            }
        }
        xhttp.open("GET",url+"?rand="+Math.random(),true);
        xhttp.send(null);
    }else{
        ocontent.innerHTML=ajccache[url];
        if(mean == 'miniblog') start_marque();
    }
}
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";
}
