﻿/// <reference path="../../Jscripts/Jquery.js" />
/// <reference path="../../Jscripts/Jquery.Cookie.js" />
var comm = {
    ajaxForJson: function (url, type, data, successfn, errorfn) {
        $.ajax({
            url: url, type: type, cache: false,
            dataType: "json", data: data,
            success: successfn != undefined ? successfn : function (o) {
                alert(o.d.toString());
            },
            error: errorfn != undefined ? errorfn : function (XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.responseText); }
        });
    },
    ajaxForHTML: function (url, type, data, successfn, errorfn) {
        $.ajax({
            url: url, type: type, cache: false,
            dataType: "html", data: data,
            success: successfn != undefined ? successfn : function (o) {
                alert(o);
            },
            error: errorfn != undefined ? errorfn : function (XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.responseText); }
        });
    },
    showDiv: function (o, left, top) {
        if (o.length > 0) {
            o.css("left", left);
            o.css("top", top);
            o.show();
        }
    }
}

comm.customSet = {
    isLoading: false,
    init: function () {

        if ($(".customize").length > 0) {
            $(".customize").hide();
            comm.customSet.hideItem();
            $(".capitalinp").click(function () { comm.customSet.hideItem($(this).parents(".capital").attr("id")); });
            $(".cusmenu li").click(function () {
                comm.customSet.hideItem();
                comm.customSet.createLocation($(this));
                comm.customSet.showItem($(this));
            });
            setTimeout(comm.customSet.openOrCloseCustomSet, 500);
            $(".loading").css("left", parseInt($(".cusmenu").css("width")) - parseInt($(".loading").css("width")));
            $(".loading").css("top", 65);
        }
    },
    openOrCloseCustomSet: function () { $(".customize").slideToggle("slow"); comm.customSet.hideItem(); },
    showItem: function (o) {
        if (undefined != o && null != o) {
            o.addClass("current");
            $("#" + o.find("a").attr("rid")).show(); $("select").hide();
        }
    },
    hideItem: function (id) {
        if (undefined != id && null != id) {
            $("a[rid='" + id + "']").parent().removeClass("current"); $("#" + id).hide();
        }
        else {
            $(".cusmenu li").removeClass("current"); $(".capital").hide();
        }
        $("select").show();
    },
    createLocation: function (o) {
        if (undefined != o && null != o) {
            var left = $(o).position().left;
            $("#" + o.find("a").attr("rid")).css("left", left);
        }
    },
    postStaticBody: function () {
        //debugger;
        var containersave = document.getElementById("container"); //容器
        var columns_john = [];
        var values = "";
        var count = 0;
        var colgroupNum = [];

        for (var i = 0; i < containersave.children.length; i++) {
            var columnDiv = containersave.children[i];
            for (var j = 0; j < columnDiv.children.length; j++) {
                if (columnDiv.children[j].className == "column") {
                    columns_john.push(columnDiv.children[j]); //所有列
                    colgroupNum.push(i);
                }
            }

        }

        for (var i = 0; i < columns_john.length; i++) {
            var column = columns_john[i];
            var columnid = column.id;

            if (column.children.length > 0) {
                count++; //该列的组件数
            }
            var colgroup = colgroupNum[i]

            for (var j = 0; j < column.children.length; j++) {
                var item = column.children[j]; //取单个组件
                if (column.style.width == "982px") {//是984   

                    if (item.getAttribute('id') == null || item.getAttribute('id') == "") //跳过提示层
                        continue;
                    var itemid = item.id;
                    var layoutwidth = "3";
                    // var colgroup = "0";
                    var columnid = itemid.split('|')[0];

                    values += columnid.split('_')[0] + "_" + columnid.split('_')[1] + "|" + itemid.split('|')[0] + "|" + layoutwidth + "|" + colgroup + "^" + itemid.split('|')[1] + ",";
                }
                else {

                    var itemid = item.id;
                    var layoutwidth;
                    var collayout = column.getAttribute('layout');
                    // var colgroup = column.getAttribute('group');
                    var columnid = itemid.split('|')[0];
                    if (collayout == "left")
                        layoutwidth = 0;
                    else if (collayout == "center")
                        layoutwidth = 1;
                    else if (collayout == "right")
                        layoutwidth = 2;
                    else
                        layoutwidth = 3;

                    if (columnid.split('_')[0] != "")
                        values += columnid.split('_')[0] + "_" + columnid.split('_')[1] + "|" + itemid.split('|')[0] + "|" + layoutwidth + "|" + colgroup + "^" + itemid.split('|')[1] + ",";
                }
            }
        }
        //显示
        //var val = values.split(',');
        // var str = "";
        //for (var i = 0; i < val.length; i++) {
        //    str += val[i] + "\r\n";
        //}
        // alert(str);
        // return false;
        comm.customSet.SavePage(values, count, $("#skinpanlHidden").val(), $("#layoutpanlHidden").val());
    },
    changeLoadToTwo: function (css) {
        comm.customSet.checkLayout(css);

        var containerjs = document.getElementById("container");

        ///取出非984组件
        var columns_john = [];
        for (var i = 0; i < containerjs.children.length; i++) {
            var columnDiv = containerjs.children[i];

            for (var j = 0; j < columnDiv.children.length; j++) {
                if (columnDiv.children[j].className == "column" && columnDiv.children[j].style.width != "982px") {
                    columns_john.push(columnDiv.children[j]);
                }
                else {
                    break;
                }

            }
        }
        //debugger;
        ///改变宽度
        for (var i = 0; i < columns_john.length; i++) {
            var column = columns_john[i];
            switch (column.getAttribute('layout')) {
                case "left":
                    column.style.width = layout[0] + "px";
                    break;
                case "center":
                    column.style.width = layout[1] + "px";
                    column.style.overflow = "hidden";
                    column.style.height = layout[1] + "px";
                    column.style.lineHeight = layout[1] + "px";
                    column.style.paddingRight = "0px";
                    break;
                case "right":
                    column.style.width = layout[2] + "px";
                    break;
                default:
                    return;
            }
        }

        ///中间列转移左边列
        for (var i = 0; i < columns_john.length; i++) {
            var column = columns_john[i];
            var g = column.getAttribute('group');
            var l = column.getAttribute('layout');
            if (l == "left") {
                for (var j = 0; j < columns_john.length; j++) {
                    var columnc = columns_john[j];
                    if (g == columnc.getAttribute('group') && columnc.getAttribute('layout') == "center") {
                        if (columnc.children.length > 0) {
                            while (columnc.children.length > 0) {
                                var item = columnc.children[0];
                                if (item.style.width != "982px") {
                                    var contentid = "content_" + item.id.split('|')[1];
                                    var object = document.getElementById(contentid);
                                    if (object != null) {
                                        var old = object.className.replace('489', '').replace('756', '').replace('222', '').replace('528', '').replace('375', '');
                                        var newclass = old + column.style.width.replace('px', '');
                                        $("#" + contentid).addClass(newclass);

                                        ///切换新组件
                                        Component.ComponentNew(item.id.split('|')[1], column.style.width.replace('px', ''), item, columnc);
                                    }
                                }

                                columnc.removeChild(item);
                                column.appendChild(item);
                            }
                        }
                    }
                }
            }
        }
        //  debugger;

        onreset();

    },
    changeLoadToThree: function (css) {

        comm.customSet.checkLayout(css);

        var containerjs = document.getElementById("container");

        ///取出非984组件
        var columns_john = [];
        for (var i = 0; i < containerjs.children.length; i++) {
            var columnDiv = containerjs.children[i];

            for (var j = 0; j < columnDiv.children.length; j++) {
                if (columnDiv.children[j].className == "column" && columnDiv.children[j].style.width != "982px") {
                    columns_john.push(columnDiv.children[j]);
                }
                else {
                    break;
                }
            }
        }

        ///改变宽度
        for (var i = 0; i < columns_john.length; i++) {
            var column = columns_john[i];
            switch (column.getAttribute('layout')) {
                case "left":
                    column.style.width = layout[0] + "px";
                    break;
                case "center":
                    column.style.width = layout[1] + "px";
                    column.style.overflow = "";
                    column.style.height = "auto";
                    column.style.lineHeight = "";
                    break;
                case "right":
                    column.style.width = layout[2] + "px";
                    break;
                default:
                    return;
            }
        }

        onreset();
    },
    checkLayout: function (css) {
        switch (css) {
            case 'S22.css':
                layout = S22;
                break;
            case 'S31.css':
                layout = S31;
                break;
            case 'S13.css':
                layout = S13;
                break;
            case 'S113.css':
                layout = S113;
                break;
            case 'S212.css':
                layout = S212;
                break;
            case 'S311.css':
                layout = S311;
                break;
            case 'S122.css':
                layout = S122;
                break;
            case 'S221.css':
                layout = S221;
                break;
            case 'S131.css':
                layout = S131;
                break;
            default:
                return;
        }
    },
    changeLoading: function () {
        comm.customSet.isLoading = !comm.customSet.isLoading;
        $(".loading").toggle();
    },
    changeLayout_next: function (laycss, o) {
        //debugger;
        $(".layoutwarp button").each(function () {
            $(this).attr("class", $(this).attr("datacss"));
        });

        $(o).attr("class", "h" + $(o).attr("datacss"));
        var filename = laycss.substring(laycss.lastIndexOf("/") + 1, laycss.length);

        if (filename.length > 7)
        { comm.customSet.changeLoadToThree(filename); }
        else
        { comm.customSet.changeLoadToTwo(filename); }
        $("#layoutpanlHidden").val($(o).attr("layoutid"));
        comm.customSet.changeLoading();
    },
    changeLayout: function (laycss, o) {
        if (comm.customSet.isLoading) {
            alert("正在加载");
        }
        else {
            comm.customSet.changeLoading();
            if ($.browser.msie) {
                document.getElementById("mainlayout").onreadystatechange = function () {
                    if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
                        comm.customSet.changeLayout_next(laycss, o);
                    }
                }
            }
            if ($("#mainlayout").length > 0) { $("#mainlayout").attr("href", laycss); }
            if (!$.browser.msie) {
                comm.customSet.changeLayout_next(laycss, o);
            }
        }
    },
    changeSkin_next: function (skin, o) {
        $(".module button").attr("class", "modulelink");
        $(o).attr("class", "modulehover");
        $("#skinpanlHidden").val($(o).attr("skinid"));
        comm.customSet.changeLoading();
    },
    changeSkin: function (skin, o) {
        if (comm.customSet.isLoading) {
            alert("正在加载");
        }
        else {
            comm.customSet.changeLoading();
            document.getElementById("mainstyle").onreadystatechange = function () {
                if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
                    comm.customSet.changeSkin_next(skin, o);
                }
            }
            if ($("#mainstyle").length > 0) $("#mainstyle").attr("href", skin);
            if (!$.browser.msie) {
                comm.customSet.changeSkin_next(skin, o);
            }
        }
    },
    SavePage: function (values, colcount, skin, csslayout) {
        var columStr = "";
        var xmlStr = "";
        var val = values.split(',');
        var str = "";

        for (var i = 0; i < (val.length - 1); i++) {
            str += val[i] + "\r\n"; //测试用的
            if (columStr.indexOf("'" + val[i].split('|')[0] + "'") == -1) {
                columStr = columStr + "," + "'" + val[i].split('|')[0] + "'";
            }
            xmlStr += "<com>";
            xmlStr = xmlStr + "<Position>" + val[i].split('^')[0] + "</Position>";
            xmlStr = xmlStr + "<Id>" + val[i].split('^')[1] + "</Id>";
            xmlStr += "</com>";

        }
        xmlStr = "<root>" + xmlStr + "</root>";
        columStr = columStr.substring(1);
        var params = "xmltxt=" + xmlStr + "&columnsvalue=" + columStr + "&skin=" + skin + "&layout=" + csslayout + "&xpath=/root/com";
        //  alert(params);
        // var params = "values=" + values + "&colcount=" + colcount + "&skin=" + skin + "&lay=" + csslayout;
        //document.write(params);
        //alert(str);
        // return;
        comm.ajaxForHTML("/Sites/ComponentCommon/ReleaseIndex.ashx", "post", params, function (o) {
            if (o == "ok") {
                alert("保存成功...");
                window.location = "http://" + document.domain + "/index.aspx";
            } else {
                alert(o);
            }
        });
    },
    SetNavigationShowOrHide: function (navigationId, type) {  //设置导航显示或隐藏
        var params = "id=" + navigationId + "&type=" + type;
        if (!confirm("你确定执行此操作吗？")) return;
        comm.ajaxForHTML("/ComponentCommon/ParamSet.aspx", "get", params, function (data) {
            if (data == "no") {
                alert("参数错误，修改失败...");
            }
            else {
                $("#nav_" + navigationId).html($("#nav_" + navigationId).html() == "取消导航" ? "加入导航" : "取消导航");
                var str = data.split('&&');
                if (str != "" || str != null) {
                    if (str[0] != "") {
                        $("#ulNaviList li").remove();
                        $("#ulNaviList").html(str[0]);
                    }
                    if (str[1] != "") {
                        $("#ulMoreList li").remove();
                        $("#ulMoreList").html(str[1]);
                    }
                }
            }
        });
    },
    AddNavigation: function (scId, type) {  //添加导航 
        var params = "id=" + scId + "&type=" + type;
        if (!confirm("你确定执行此操作吗？")) return;
        comm.ajaxForHTML("/ComponentCommon/ParamSet.aspx", "get", params, function (data) {
            if (data == "no") {
                alert("参数错误，加入导航失败...");
            }
            else {
                var str = data.split('&&');
                if (str != "" || str != null) {
                    if (str[0] != "") {
                        var title = $("#" + scId).html();
                        $("#nav_" + scId).html(title == "取消导航" ? "加入导航" : "取消导航");
                        $("#nav_" + scId).attr("href", "javascript:comm.customSet.SetNavigationShowOrHide('" + str[0] + "','isNavi');");
                        $("#nav_" + scId).attr("id", "nav_" + str[0]);
                    }
                    if (str[1] != "") {
                        $("#ulNaviList li").remove();
                        $("#ulNaviList").html(str[1]);
                    }
                    if (str[2] != "") {
                        $("#ulMoreList li").remove();
                        $("#ulMoreList").html(str[2]);
                    }
                }
            }
        });
    },
    AddComponen: function (scId, type) {     //新增定制组件
        var params = "id=" + scId + "&type=" + type;
        if (!confirm("你确定执行此操作吗？")) return;
        comm.ajaxForHTML("/ComponentCommon/ParamSet.aspx", "get", params, function (data) {
            if (data == "no") {
                alert("参数错误，增加组件失败...");
            }
            else {
                var str = data.split('&&');
                if (str != "" || str != null) {
                    if (str[0] != "") {
                        $("#" + scId + " span").remove();
                        $("#" + scId).html(str[0]);
                    }
                    if (str[1] != "") {
                        Module.CreateNewDiv(str[1]);
                    }
                }
            }
        });
    },

    SetIndexShow: function (param, type, mid) {
        var params = "id=" + param + "&type=" + type;
        if (!confirm("你确定执行此操作吗？")) return;
        comm.ajaxForHTML("/ComponentCommon/ParamSet.aspx", "get", params, function (data) {
            if (data == "no") { alert("参数错误，修改失败！"); } else { $("#" + mid).hide(); }
        });
    },

    SetIndexShowAndHide: function (param, type, mid) {
        var params = "id=" + param + "&type=" + type;
        if (!confirm("你确定执行此操作吗？")) return;
        comm.ajaxForHTML("/ComponentCommon/ParamSet.aspx", "get", params, function (data) {
            if (data == "no") {
                alert("参数错误，修改失败，请稍后再试...");
            }
            else {                
                $("#ind_" + param).html($("#ind_" + param).html() == "隐藏组件" ? "显示组件" : "隐藏组件");
                var str = data.split('&');
                if (str != "" || str != null) {
                    if (str[0] == "Y") {
                        var tempStr = str[1].split('|');
                        var t_colnum = document.getElementById("container");
                        for (var t_id = 0; t_id < t_colnum.children.length; t_id++) {//遍历组
                            var colgroup = t_colnum.children[t_id].getAttribute('group');
                            if (colgroup == tempStr[3]) { break; }
                        }
                        if (t_id == t_colnum.children.length) {//不存在归到第一组
                            tempStr[3] = "1";
                            str[1] = tempStr[0] + "|" + tempStr[1] + "|" + tempStr[2] + "|" + tempStr[3] + "|" + tempStr[4] + "|" + tempStr[5] + "|" + tempStr[6] + "|" + tempStr[7];
                        }
                        layoutdiv.push(str[1]);
                        $("#container").html("");
                        Component.initColumn();
                        setTimeout("onreset()", 2000);
                    }
                    else if (str[0] == "N") {
                        var cid = "T_" + str[1].split('|')[5];
                        var div = document.getElementById(cid).parentNode;
                        div.parentNode.removeChild(div);
                        for (var i = 0; i < layoutdiv.length; i++) {
                            if ((data.split('|')[5] + data.split('|')[6]) == (layoutdiv[i].split('|')[5] + layoutdiv[i].split('|')[6])) {
                                layoutdiv.splice(i, 1);
                            }
                        }
                    }
                }
            }
        });
    },

    AddComp: function (id) {
        comm.ajaxForHTML("/ComponentCommon/ParamSet.aspx", "get", "id=" + id + "&type=add", function (data) {
            if (data != "no") {
                var p = {
                    title: '信息提示',
                    info: '<ul>' + data + '</ul>',
                    width: 748, height: 220,
                    onClosed: function () { },
                    onCallback: function (r) {
                        document.getElementById('d').innerHTML = r.id + ':' + r.name;
                    }
                };
                Pop.show(p);
            }
            else {
                alert("参数错误,不能新增此组件...");
            }
        });
    }

}

comm.navigation = {
    indexNav: function () {
        comm.navigation.clickNav();
        var i = $.cookie("navindex");

        if (i != undefined && i != null) {
            $("#" + i).attr("class", "current");
        }
        else {
            $("#navlist_0").attr("class", "current");
        }
    },
    clickNav: function () {
        $(".nav > ul  li").each(function () {
            $(this).attr("class", "");
            $(this).click(function () {
                $.cookie("navindex", null);
                $.cookie("navindex", $(this).attr("id"), { expires: 1, path: '/', domain: '', secure: false });
            }
        );
        });
    },
    showMore: function (e) {
        var left = parseInt($("#navmove").offset().left);
        $(".moredroplist").css("left", left - 70 + "px");
        $(".moredroplist").slideDown();
        javascript: comm.navigation.setShowTime();
    },
    hideMore: function () {
        $(".moredroplist").slideUp();
    },
    setShowTime: function () {
        timeId = setTimeout("javascript:comm.navigation.hideMore()", 3000);
    },
    clearShowTime: function () {
        clearTimeout(timeId);
    },
    setShowTime_li: function () {
        timeId = setTimeout("javascript:comm.navigation.hideMore()", 500);
    }
}

comm.component = {
    ComponentLoad: function (o, id) {
        comm.ajaxForHTML("/Component/ReleaseComponent.aspx", "get", "c=" + id, function (data) { o.content.innerHTML = data; });
    },
    SearchRedirect: function () {
        if ($("#searchsel").val() == "0") {
            alert("请选择搜索类别");
            return;
        }
        window.location.href = "/Pages/Sreach/Sreach.aspx?st=" + $("#searchsel").val() + "&sn=" + $("#searchtext").val() + "&page=1";
    },
    pagePrv: function (o) {
        comm.component.nextOutTime();
        var thisp = $(o).parents(".album_main").children(".album_page");
        var thisc = $(o).parents(".album_main");
        var pageIndex = thisp.find("INPUT[cid='pageIndex']").val();
        var pageCount = thisp.find("INPUT[cid='pageCount']").val();
        if (pageIndex == "1") {
            alert("已经是第一个相册了");
            return;
        } else {
            var page = parseInt(pageIndex) - 1;
            var allCount = thisp.find("INPUT[cid='allCount_" + page + "']").val(); //下一个相册的相片数
            var albumName = thisp.find("INPUT[cid='albumName_" + page + "']").val(); //下一个相册的名字

            var showNum = "0"; //相片数
            var showImage = "<img src='/Sites/Images/310x310.gif' />"; //显示相片
            var showName = "<a href='javascript:void(0);' title='暂无相片'>" + albumName + "</a>"; //相册名称
            if (allCount > 0) {
                var current = thisp.find("INPUT[cid='all_" + page + "_1']").val().split("|");
                showNum = "1"; //相片数
                showImage = "<img src='" + current[1] + "' onclick='comm.component.next(this);' title=\"点击下一张\"/>"; //显示相片
                showName = "<a href='/Pages/Albums/AlbumDetail.aspx?id=" + current[0] + "' title='点击查看详情'>" + albumName + "</a>"; //相册名称
            }
            thisc.find("span[cid='show1']").empty(); //相片显示清理          
            thisc.find("span[cid='show1']").html(showImage);
            thisc.find("span[cid='show2']").empty(); //清理相册名称
            thisc.find("span[cid='show2']").html(showName);
            thisc.find("span[cid='show3']").html(showNum); //第几张相片
            thisc.find("span[cid='show4']").html(allCount); //共相片数
            thisc.find("span[cid='show5']").html(page); //第几个相册
            thisp.find("INPUT[cid='allCurrent_" + page + "']").val(showNum); //第几张相片参数
            thisp.find("INPUT[cid='pageIndex']").val(page); //第几个相册参数
            thisp.find("INPUT[cid='allCount_" + page + "']").val(allCount); //共相片数参数
        }
    },
    pageNext: function (o) {
        comm.component.nextOutTime();
        var thisc = $(o).parents(".album_main");
        var thisp = $(o).parents(".album_main").children(".album_page");
        var pageIndex = thisp.find("INPUT[cid='pageIndex']").val();
        var pageCount = thisp.find("INPUT[cid='pageCount']").val();
        if (pageIndex == pageCount) {
            alert("已经是最后一个相册了");
            return;
        } else {
            var page = parseInt(pageIndex) + 1;
            var allCount = thisp.find("INPUT[cid='allCount_" + page + "']").val(); //下一个相册的相片数
            var albumName = thisp.find("INPUT[cid='albumName_" + page + "']").val(); //下一个相册的名字

            var showNum = "0"; //相片数
            var showImage = "<img src='/Sites/Images/310x310.gif' />"; //显示相片
            var showName = "<a href='javascript:void(0);' title='暂无相片'>" + albumName + "</a>"; //相册名称
            if (allCount > 0) {
                var current = thisp.find("INPUT[cid='all_" + page + "_1']").val().split("|");
                showNum = "1"; //相片数
                showImage = "<img src='" + current[1] + "' onclick='comm.component.next(this);' title=\"点击下一张\"/>"; //显示相片
                showName = "<a href='/Pages/Albums/AlbumDetail.aspx?id=" + current[0] + "' title='点击查看详情'>" + albumName + "</a>"; //相册名称
            }
            thisc.find("span[cid='show1']").empty(); //相片显示清理          
            thisc.find("span[cid='show1']").html(showImage);
            thisc.find("span[cid='show2']").empty(); //清理相册名称
            thisc.find("span[cid='show2']").html(showName);
            thisc.find("span[cid='show3']").html(showNum); //第几张相片
            thisc.find("span[cid='show4']").html(allCount); //共相片数
            thisc.find("span[cid='show5']").html(page); //第几个相册
            thisp.find("INPUT[cid='allCurrent_" + page + "']").val(showNum); //第几张相片参数
            thisp.find("INPUT[cid='pageIndex']").val(page); //第几个相册参数
            thisp.find("INPUT[cid='allCount_" + page + "']").val(allCount); //共相片数参数
        }
    },
    prv: function (o) {
        var thisp = $(o).parents(".album_main").children(".album_page");
        var thisc = $(o).parents(".album_main");
        var pageIndex = thisp.find("INPUT[cid='pageIndex']").val();
        var allCount = thisp.find("INPUT[cid='allCount_" + pageIndex + "']").val();
        var allCurrent = thisp.find("INPUT[cid='allCurrent_" + pageIndex + "']").val();
        if (allCount < 2 || allCurrent == "1") {
            //alert("已经是第一张了");
            return;
        }
        else {
            var currenttext = parseInt(allCurrent) - 1;
            var current = thisp.find("INPUT[cid='all_" + pageIndex + "_" + currenttext + "']").val().split("|");
            thisc.find("span[cid='show1']").empty(); //相片显示清理
            thisc.find("span[cid='show1']").html("<img src=\"" + current[1] + "\" onclick=\"comm.component.next(this);\" onmouseover=\"comm.component.nextStopTime('1')\" onmouseout=\"comm.component.nextStopTime('2')\" title=\"点击下一张\" />");
            thisc.find("span[cid='show3']").html(currenttext); //第几张相片
            thisp.find("INPUT[cid='allCurrent_" + pageIndex + "']").val(currenttext); //第几张相片参数
        }
    },
    next: function (o) {
        var thisc = $(o).parents(".album_main");
        var thisp = $(o).parents(".album_main").children(".album_page");
        var pageIndex = thisp.find("INPUT[cid='pageIndex']").val();
        var allCount = thisp.find("INPUT[cid='allCount_" + pageIndex + "']").val();
        var allCurrent = thisp.find("INPUT[cid='allCurrent_" + pageIndex + "']").val();
        if (allCount < 2) {
            return;
        }
        else {
            if (allCurrent == allCount) { allCurrent = 0; }
            var currenttext = parseInt(allCurrent) + 1;
            var current = thisp.find("INPUT[cid='all_" + pageIndex + "_" + currenttext + "']").val().split("|");
            thisc.find("span[cid='show1']").empty(); //相片显示清理
            thisc.find("span[cid='show1']").html("<img src=\"" + current[1] + "\" onclick=\"comm.component.next(this);\" onmouseover=\"comm.component.nextStopTime('1')\" onmouseout=\"comm.component.nextStopTime('2')\" title=\"点击下一张\" />");
            thisc.find("span[cid='show3']").html(currenttext); //第几张相片
            thisp.find("INPUT[cid='allCurrent_" + pageIndex + "']").val(currenttext); //第几张相片参数
        }
    },
    setStopTime: "2",
    setNextTime: "",
    nextTime: function () {
        var lista = $(".stop a");
        if (lista.length > 0) {
            if (comm.component.setStopTime == "2") {
                for (var i = 0; i < lista.length; i++) {
                    comm.component.next(lista[i]);
                }
            }
            comm.component.setNextTime = setTimeout("comm.component.nextTime()", 2000);
        }
        //        for (var i = 0; i < lista.length; i++) {
        //            var thisp = $(lista[i]).parents(".album_main").children(".album_page");
        //            var thisc = $(lista[i]).parents(".album_main");
        //            var pageIndex = thisp.find("INPUT[cid='pageIndex']").val();
        //            var allCount = thisp.find("INPUT[cid='allCount_" + pageIndex + "']").val();
        //            var allCurrent = thisp.find("INPUT[cid='allCurrent_" + pageIndex + "']").val();
        //            if (allCount < 2 || allCurrent == "1") {
        //                clearTimeout(setNextTime);
        //            }
        //        }
    },
    nextSetTime: function () {
        if (comm.component.setNextTime == "") comm.component.nextTime();
    },
    nextStopTime: function (o) {
        comm.component.setStopTime = o;
    },
    nextOutTime: function () {
        if (comm.component.setNextTime != "") {
            clearTimeout(comm.component.setNextTime);
            comm.component.setNextTime = "";
        }
    },
    mobileclick: function () {
        window.open("/ComponentCommon/Navigation.aspx?mobile=" + $("#mobile").val());
    },
    queryccclick: function () {
        window.open('/ComponentCommon/Navigation.aspx?train=' + $("#kaishi").val() + '|' + $('#zhongdian').val());
    },
    area2zipFormclick: function () {
        window.open('/ComponentCommon/Navigation.aspx?pcdm=' + $("#area").val());
    },
    area2zoneFormclick: function () {
        window.open('/ComponentCommon/Navigation.aspx?acdm=' + $("#area1").val());
    },
    zipformclick: function () {
        window.open('/ComponentCommon/Navigation.aspx?pc=' + $("#zip").val());
    },
    zoneformclick: function () {
        window.open('/ComponentCommon/Navigation.aspx?ac=' + $("#zone").val());
    }

}

comm.site = {
    AddBookmark: function (title, url) {
        if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) {
            window.sidebar.addPanel(title, url, "");
        }
        else {
            window.external.AddFavorite(url, title);
        }
    },
    VideoSize: function () {
        $("#popLayer").hide();
        var o = $("#21videoplayer");
        if (o == null || o == "undefined" || o.length < 1) {
            return;
        }
        else {
            var origHeight = $(".video .album_view").css("height");
            var origWidth = $(".video .album_view").css("width");
            $("#21videoplayer object").attr("height", origHeight.substring(0, origHeight.length - 2));
            $("#21videoplayer object").attr("width", origWidth.substring(0, origHeight.length - 2));
            $("#21videoplayer embed").attr("height", origHeight.substring(0, origHeight.length - 2));
            $("#21videoplayer embed").attr("width", origWidth.substring(0, origHeight.length - 2));
        }
    }
}

comm.RenewedlyLoad = {
    LoadSecond: function () {
        comm.ajaxForHTML("/Component/ReleaseComponent.aspx", "get", "layout=2&fresh=" + Math.random(), function (data) {
            eval(data);
            var wc = new CDrag();
            resethtml();
            wc.del_cookie();

            wc.parse(json);

            wc.set_cookie();

            wc = null;
        });
    },
    LoadThree: function () {
        comm.ajaxForHTML("/Component/ReleaseComponent.aspx", "get", "layout=3&fresh=" + Math.random(), function (data) {
            eval(data);
            var wc = new CDrag();
            resethtml();
            wc.del_cookie();

            wc.parse(json);

            wc.set_cookie();

            wc = null;
        });
    }
}

