﻿if (typeof (HTMLElement) != "undefined")   //firefox define contains
{
    HTMLElement.prototype.contains = function(obj) {
        while (obj != null && typeof (obj.tagName) != "undefind") {
            if (obj == this)
                return true;
            obj = obj.parentNode;
        }
        return false;
    };
}
function o(obj) { return document.getElementById(obj); }
function addEvent(obj, btype, func) {
    if (document.all)
        obj.attachEvent("on" + btype, function() { func.call(obj) });
    else
        obj.addEventListener(btype, func, false);
}
function getElemPos(obj) {
    var w = obj.offsetWidth, h = obj.offsetHeight;
    var l = 0, t = 0;
    while (obj) {
        l += obj.offsetLeft;
        t += obj.offsetTop;
        obj = obj.offsetParent;
    }
    return { width: w, height: h, left: l, top: t };
}

function getNextS(obj) {
    if (obj.nextSibling.nodeType == 1)
        return obj.nextSibling;
    else
        return obj.nextSibling.nextSibling;
}
function getNext(obj) {
    while (obj) {
        if (obj.nextSibling && obj.nextSibling.nodeType == 1)
        { return obj.nextSibling; }
        obj = obj.nextSibling;
    }
}

function tourl(url) {
    location.href = url;
}
function openwin(url, bhtml, w, h) //弹出window
{
    var wh = 0, hn = 0;
    if (!w)
    { wh = screen.availWidth - 10; }
    else
    { wh = w; }
    if (!h)
    { hn = screen.availHeight - 50; }
    else
    { hn = h; }
    if (!bhtml)
    { bhtml = 'newhtml'; }
    window.open(url, bhtml, 'status=yes,scrollbars=yes,resizable=no,left=' + (screen.availWidth - 10 - wh) / 2 + ',top=' + (screen.availHeight - 50 - hn) / 2 + ',toolbar=no,menubar=no,location=no,width=' + wh + ',height=' + hn + '');
}
function banquan() {
    Bcalendar = new Date();
    Byear = Bcalendar.getYear();
    if (o("jinnow"))
        o("jinnow").innerHTML = Byear;
    if (o("wunow"))
        o("wunow").innerHTML = Byear + 5;
}
var MyMar = 0;
function scrolltop() {
    var speed = 40;
    if (o("scrollshow_demo")) {
        var topBox = document.getElementById("scrollshow_demo");
        var top2 = document.getElementById("scrollshow_demo2");
        var top1 = document.getElementById("scrollshow_demo1");
        if (top1.offsetHeight >= topBox.offsetHeight) {
            top2.innerHTML = top1.innerHTML;
            var offsetTopn = 0;
            function Marquee() {
                offsetTopn = offsetTop(top2);
                if (offsetTopn - topBox.scrollTop <= 0) {
                    topBox.scrollTop -= top1.offsetHeight;
                } else {
                    topBox.scrollTop++;
                }
            }
            if (MyMar == 0) {
                MyMar = setInterval(Marquee, speed);
            }
            topBox.onmouseover = function() {
                if (MyMar != 0) {
                    clearInterval(MyMar);
                    MyMar = 0;
                }
            }
            topBox.onmouseout = function() {
                if (MyMar == 0)
                    MyMar = setInterval(Marquee, speed);
            }
        }
    }
}

function offsetTop(obj) {
    if (document.all)
        return obj.offsetTop;
    else
        return (obj.offsetTop - obj.parentNode.offsetTop);
}
//获取网站虚拟目录
function getRootPath() {
    var strFullPath = window.document.location.href;
    var strPath = window.document.location.pathname;
    var pos = strFullPath.indexOf(strPath);
    var prePath = strFullPath.substring(0, pos);
    var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
    return (prePath + postPath);
}
var arrayobj = {};
var timer;
var jnb = 0;
function flashView(href, linklist, textlist, n, b) //pic
{
    if (!o("imgbnd")) { return; }
    if (!o("pictext")) { return; }
    if (!o("imghref")) { return; }
    if (!n) { n = 0; }
    else { n = parseInt(n, 10); }
    if (!b) { b = 12; }
    else { b = parseInt(b, 10); }
    var pics = href.substring(0, href.length - 1).replace(/SmallImages/g, "/");
    var pics = pics.substring(0, href.length - 1).replace(/PortalWeb/g, "/");
//alert(pics);
    if (pics == "") {
        pics = "DesktopModules/ContentShow/images/Default.gif";
    }
    else {
        pics = pics.split("|");
        for (var i = 0; i < pics.length; i++) {	    
            pics[i] = getRootPath() + pics[i];
        }
        var links = linklist.substring(0, linklist.length - 1).replace(/&/g, "^").split("|");
        var texts = textlist.substring(0, textlist.length - 1).split("|");
        arrayobj.pics = pics;
        arrayobj.links = links;
        arrayobj.texts = texts;
        arrayobj.len = b;
        o("imgbnd").src = pics[n];
        if (texts[n].length > b)
            o("pictext").innerHTML = "<a href=\"" + links[n] + "\" title=\"" + texts[n] + "\" target='_blank'>" + (texts[n].substring(0, b) + "..") + "</a>";
        else
            o("pictext").innerHTML = "<a href=\"" + links[n] + "\" title=\"" + texts[n] + "\" target='_blank'>" + texts[n] + "</a>";
        o("imghref").href = links[n];
    }
}
function settextimg(m, a) {
    if (!m) { m = 0; }
    else { m = parseInt(m, 10); }
    jnb = m;
    o("imgbnd").src = arrayobj.pics[m];
    if (arrayobj.texts[m].length > arrayobj.len)
        o("pictext").innerHTML = "<a href=\"" + arrayobj.links[m] + "\" title=\"" + arrayobj.texts[m] + "\" target='_blank'>" + (arrayobj.texts[m].substring(0, arrayobj.len) + "..") + "</a>";
    else
        o("pictext").innerHTML = "<a href=\"" + arrayobj.links[m] + "\" title=\"" + arrayobj.texts[m] + "\" target='_blank'>" + arrayobj.texts[m] + "</a>";
    o("imghref").href = arrayobj.links[m];
    var spanarr = o("picnum").getElementsByTagName("span");
    for (var i = 0; i < spanarr.length; i++) {
        spanarr[i].className = '';
        if (i == m)
            spanarr[i].className = 'sel';
    }
    if (!a)
    { window.clearInterval(timer); }
}
function setMouseEvent() {
    var str = "";
    for (var i = 0; i < arrayobj.pics.length; i++) {
        str += "<span";
        if (i == jnb)
            str += " class='sel'";
        str += " onmouseover='settextimg(" + i + ")' onmouseout='settimer();'>" + (i + 1) + "</span>"
    }
    o("picnum").innerHTML = str;
}
function setimg() {
    if (jnb < (arrayobj.pics.length - 1)) {
        jnb++;
    }
    else {
        jnb = 0;
    }
    settextimg(jnb, 1);
}
function settimer() {
    if (arrayobj.pics && arrayobj.pics.length > 1) {
        setMouseEvent();
        timer = window.setInterval("setimg()", 5000);
    }
}
var bttime;
function showli(str, obj) {
    bttime = window.setTimeout(function() {
        var liarr = obj.parentNode.getElementsByTagName("li");
        var b = 0;
        for (var i = 0; i < liarr.length; i++) {
            //liarr[i].className='';
            liarr[i].className = liarr[i].className.replace("sel", "");
            if (liarr[i] == obj)
                b = i;
        }
        if (obj.className.indexOf('') != -1) {
            obj.className += ' sel';
        }
        for (var j = 1; j <= liarr.length; j++) {
            o(str + "_" + j).style.display = 'none';
        }
        if (o(str + "_" + (b + 1))) {
            o(str + "_" + (b + 1)).style.display = 'block';
        }
        else {
            o(str + "_" + (b + 2)).style.display = 'block';
        }
    }, 200);
    obj.onmouseout = function() { clearTimeout(bttime); }
}
function childloadin() {
    var url = location.href;
    if (o("lefta")) {
        if (url.substr(url.length - 1, 1) == "#")
            url = url.substr(0, url.length - 1);
        var lefta = o("lefta").getElementsByTagName("a");
        var cont;
        for (var i = 0; i < lefta.length; i++) {
            if (lefta[i].href == url) {
                herl = url;
            }
            else {
                herl = url.split("&");
                herl = herl[0];
            }
            if (lefta[i].href == herl) {
                lefta[i].parentNode.parentNode.className = "left_linkd";
                if (lefta[i].parentNode.parentNode.parentNode.parentNode.tagName == "LI") {
                    lefta[i].parentNode.parentNode.parentNode.parentNode.style.display = '';
                    if (document.all)
                        cont = "<a href='" + url + "'>" + lefta[i].innerHTML + "</a>";
                    else
                        cont = "<a href='" + url + "'>" + lefta[i].innerHTML + "</a>";
                    if (o("site") && o("bigtitle"))
                        o("site").innerHTML = "<a href='" + lefta[0].href + "'>" + o("bigtitle").innerHTML + "</a>" + " &gt; " + cont;
                    if (o("siteD"))
                        o("siteD").innerHTML = cont;
                    if (o("bigDtitle"))
                        o("bigDtitle").innerHTML = cont;
                }
                else {
                    cont = "<a href='" + url + "'>" + lefta[i].innerHTML + "</a>";
                    if (o("site") && o("bigtitle"))
                        o("site").innerHTML = "<a href='" + lefta[0].href + "'>" + o("bigtitle").innerHTML + "</a>" + " &gt; " + cont;
                    if (o("siteD"))
                        o("siteD").innerHTML = cont;
                    if (o("bigDtitle"))
                        o("bigDtitle").innerHTML = cont;
                }
            }
            if (lefta[i].href.split("&")[0] == herl) {
                //lefta[i].parentNode.parentNode.className = "left_linkd";
                if (lefta[i].parentNode.parentNode.parentNode.parentNode.tagName == "LI") {
                    lefta[i].parentNode.parentNode.parentNode.parentNode.style.display = '';
                    if (document.all)
                        cont = "<a href='" + url + "'>" + lefta[i].innerHTML + "</a>";
                    else
                        cont = "<a href='" + url + "'>" + lefta[i].innerHTML + "</a>";
                    if (o("site") && o("bigtitle"))
                        o("site").innerHTML = "<a href='" + lefta[0].href + "'>" + o("bigtitle").innerHTML + "</a>" + " &gt; " + cont;
                    if (o("siteD"))
                        o("siteD").innerHTML = cont;
                    if (o("bigDtitle"))
                        o("bigDtitle").innerHTML = cont;
                }
                else {
                    cont = "<a href='" + url + "'>" + lefta[i].innerHTML + "</a>";
                    if (o("site") && o("bigtitle"))
                        o("site").innerHTML = "<a href='" + lefta[0].href + "'>" + o("bigtitle").innerHTML + "</a>" + " &gt; " + cont;
                    if (o("siteD"))
                        o("siteD").innerHTML = cont;
                    if (o("bigDtitle"))
                        o("bigDtitle").innerHTML = cont;
                }
            }
        }
    }
}
function createxh() {
    var rq = false;
    try {
        rq = new XMLHttpRequest();
    } catch (trymicrosoft) {
        try {
            rq = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (othermicrosoft) {
            try {
                rq = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (failed) {
                rq = false;
            }
        }
    }
    return rq;
}
function onkeypresses() {

    if (event.keyCode == 13) {

        event.keyCode = 0;

        event.cancelBubble = true;
        event.returnValue = false;

        return false;

    }

}

addEvent(window, "load", banquan);
addEvent(window, "load", scrolltop);
addEvent(window, "load", childloadin);
addEvent(window, "load", settimer);
