﻿String.prototype.trim = function ()   //去除字符串前后空格
{
    return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
var cache_data = new Array()
function TabsSelectComment(tabsParentUL, channel, ulContainer, itemCount,item) {
    var ulGroupCom = document.getElementById(tabsParentUL);
    var aTabsCom = ulGroupCom.getElementsByTagName("a");
    //var defaultParm = aTabsCom[0].parentNode.value;
    cache_data[channel + item] = document.getElementById(ulContainer).innerHTML;
    for (var i = 0; i < aTabsCom.length; i++) {
        aTabsCom[i].onmouseover = function () {
            for (var j = 0; j < aTabsCom.length; j++) {
                aTabsCom[j].className = "";
            }
            this.className = "hover";
            GetIndexData(channel, this.parentNode.value, ulContainer, itemCount);
        }
    }
}
function TabsSelect(tabsParentUL, channel, ulContainer, itemCount) {
    var ulGroup = document.getElementById(tabsParentUL);
    var aTabs = ulGroup.getElementsByTagName("a");
    var defaultParm = aTabs[0].parentNode.value;
    cache_data[channel + defaultParm] = document.getElementById(ulContainer).innerHTML;
    for (var i = 0; i < aTabs.length; i++) {
        aTabs[i].onmouseover = function () {
            for (var j = 0; j < aTabs.length; j++) {
                aTabs[j].className = "";
            }
            this.className = "hover";
            GetIndexData(channel, this.parentNode.value, ulContainer, itemCount);
        }
    }
}
function GetIndexData(channel, parm, ulContainer, itemCount) {
    if (cache_data[channel + parm] != null) {
        $("#" + ulContainer).html("");
        $("#" + ulContainer).html(cache_data[channel + parm]);
        if (parm > 5) {
            OverLi(ulContainer);
        }
    }
    else {
        $.post("/indexUserControl/getIndexData.ashx", { channel: channel, parm: parm, itemCount: itemCount },
                function (data) {
                    $("#" + ulContainer).html("");
                    $("#" + ulContainer).html(data);
                    cache_data[channel + parm] = data;
                    if (parm > 5) {
                        OverLi(ulContainer);
                    }
                });
    }
}

function OverLi(objUL) {
    var ulContainer = document.getElementById(objUL);
    var Childs = ulContainer.childNodes;
    for (var i = 0; i < Childs.length; i++) {
        if (Childs[i].nodeType == 1 && Childs[i].className != "more" && Childs[i].className != "libeigeng" && Childs[i].tagName != "SPAN") {
            switch (Childs[i].tagName) {
                case "DIV":
                    Childs[i].onmouseover = function () {
                        var parentLis = this.childNodes;
                        for (var j = 0; j < parentLis.length; j++) {
                            if (parentLis[j].nodeType == 1) {
                                parentLis[j].onmouseover = function () {
                                    for (var n = 0; n < parentLis.length; n++) {
                                        if (parentLis[n].nodeType == 1) {
                                            var liChilds = parentLis[n].getElementsByTagName("li");
                                            liChilds[0].style.display = "block";
                                            liChilds[1].style.display = "none";
                                            parentLis[n].style.height = "27px";
                                        }
                                    }
                                    var liChild = this.getElementsByTagName("li");
                                    liChild[0].style.display = "none";
                                    liChild[1].style.display = "block";
                                    this.style.height = "105px";
                                }
                            }
                        }
                    }
                    break;
                case "LI":
                    Childs[i].onmouseover = function () {
                        for (var j = 0; j < Childs.length; j++) {
                            if (Childs[j].nodeType == 1 && Childs[j].className != "more" && Childs[j].className != "libeigeng") {
                                var newLiChilds = Childs[j].getElementsByTagName("li");
                                newLiChilds[0].style.display = "block";
                                newLiChilds[1].style.display = "none";
                                Childs[j].style.height = "27px";
                            }
                        }
                        var newLiChild = this.getElementsByTagName("li");
                        newLiChild[0].style.display = "none";
                        newLiChild[1].style.display = "block";
                        this.style.height = "105px";
                    }
                    break;
            }
        }
    }
}
function getsrc() {
    var hei = $(window).height();
    var i = $("img[original]").length;
    for (var j = 0; j < i; j++) {
        var obj = $("img[original]").eq(j);
        try {
            if (obj.offset().top <= ($(document).scrollTop() + hei)) {
                obj.load(function () {
                    if (typeof $(this).attr("w") != "undefined") {
                        var w = parseInt($(this).attr("w"));
                        $(this).removeAttr("w");
                        $(this).oneTime('500ms', function () {
                            if (w < $(this).width())
                                $(this).css("width", w + "px");
                            $(this).css("display", "block");
                        });
                    }
                });
                if (typeof obj.attr("w") != "undefined") {
                    obj.css("display", "none");
                }
                obj.attr("src", obj.attr("original"));
                obj.removeAttr("original");
            }
        }
        catch (e) {
            obj.attr("src", obj.attr("original"));
            obj.removeAttr("original");
        }
    }
}
