﻿var comm = {
    ajaxForJsonasync: function(url, type, data, successfn, errorfn) {
        $.ajax({
            contentType: "application/json",
            url: url, type: type, cache: false,
            dataType: "json", data: data, async: false,
            success: successfn != undefined ? successfn : function(o) {
                alert(o.d.toString());
            },
            error: errorfn != undefined ? errorfn : function(XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.responseText); }
        });
    },
    ajaxForJson: function(url, type, data, successfn, errorfn) {
        $.ajax({
            contentType: "application/json",
            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); }
        });
    },
    DialogDiv: function(dialogName, dialogTitle, iframeSrc, isScrolling, srcParams, iframeWidth, iframeHeight, isOk, isExit, isDrag) {
        JqueryDialog.OpenDialog(dialogName, dialogTitle, iframeSrc, isScrolling, srcParams, iframeWidth, iframeHeight, isOk, isExit, isDrag);
    }

};

comm.Admin = {
    //创建管理员面板层
    CreateAdminDiv: function(u) {

        var str = "<div class=\"admin_menu\" style=\"display:none\">"
        + "<div class=\"admin_btn\"><a href=\"javascript:comm.Admin.IntoAdmin('" + u + "');\"  >" + Page_js_qhdpbms + "</a></div>"
        + "<div class=\"admin_tip\">" + Page_js_ts + "</div>"
        + "<div class=\"admin_close\"><a href=\"javascript:comm.Admin.Close();\" >" + com_close + "</a></div>"
        + "<div class=\"admin_hide\"><a href=\"javascript:comm.Admin.Hide();\" >" + Page_Component_HidePanel + "</a></div>"
        + "</div><div class=\"admin_play\" id=\"admin_play\" style=\"display:none; z-index:999; position: relative;\"><div class=\"play_btn\"><div class=\"admin_hide\"><a href=\"javascript:comm.Admin.Show()\">" + Page_Component_ShowPanel + "</a></div></div></div>";
        $("body").prepend(str);
        comm.Admin.Show();
    },
    //检查管理员
    CheckAdmin: function() {
        //$(window).load(function() { comm.GetPageHight.GetPageHights(); });
        $(document).ready(function() {
            comm.GetPageHight.GetPageHights();
            var Paramurl = $("body").attr("Paramurl");
            var query = "{Paramurl:'" + Paramurl + "'}";
            comm.ajaxForJson("/WebUI/GetPageData.asmx/IsShowDropAdmin", "post", query, function(d) {
                var q = d.d;
                if (q != 0) {
                    var url = new String();
                    if (q == 1)
                        url = "/Admin/Main/Pages/ComponentManager.aspx";
                    if (q == 2)
                        url = "/Admin/Sites/Pages/ComponentManager.aspx";
                    comm.Admin.CreateAdminDiv(url);
                }

            });
        });
    },
    //关闭面板层
    Close: function() {
        if ($(".admin_menu").html() != undefined && $(".admin_menu").html() != null) {
            $(".admin_menu").slideUp("slow");
        }
    },
    //隐藏面板层
    Hide: function() {
        if ($(".admin_menu").html() != undefined && $(".admin_menu").html() != null) {
            $(".admin_menu").slideUp("slow");
        }
        $("#admin_play").show();
    },
    //显示面板层
    Show: function() {
        if ($(".admin_menu").html() != undefined && $(".admin_menu").html() != null) {
            $(".admin_menu").slideDown("slow");
        }
        $("#admin_play").hide();
    },
    //进入面板层
    IntoAdmin: function(u) {
        var Param = $("body").attr("Param");
        var url = window.location.href;
        var regurl = url;
        if (Param != null && Param != "") u = u + "?" + Param;
        if (url.indexOf("?") > -1) {
            u += "&" + url.substring(url.indexOf("?") + 1);
            regurl = url.substring(0, url.indexOf("?"));
        }
        var strreg = /([a-z0-9A-Z]{8}\-([a-z0-9A-Z]{4}\-){3}[a-z0-9A-Z]{12})/g
        var m = strreg.exec(regurl);
        if (m != null)
            u += "&oid=" + m[0];
        window.location = u + "&u=" + escape(window.location.href);
    }
};

comm.CompontPage = {
    //获取URL参数;
    parse_url: function(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;

    },
    SearchPageOnkeypress: function(id, conststring, type, url, e) {
        var key = window.event ? e.keyCode : e.which;
        if (key == 13) {
            comm.CompontPage.SearchPage(id, conststring, type, url)
        }
    },
    SearchPage: function(id, conststring, type, url, openway) {
        if (type == 0) {
            ///带类型的搜索
            var typeid = "#" + conststring + "Type_" + id;
            var keyword = "#" + conststring + "Text_" + id;
            if ($(typeid).val() == "-1") {
                alert(Page_js_choosetype);
                return;
            }

            if ($(keyword).val() == "") {
                alert(Page_js_contents);
                return;
            }

            var urls = url + "?tid=" + $(typeid).val() + "&kw=" + escape($(keyword).val());
            if (openway == "_blank")
                window.open(urls);
            else
                window.location.href = urls;
        }
        else if (type == 1) {
            ///不带类型的搜索
            var keyword = "#" + conststring + "Text_" + id;

            if ($(keyword).val() == "") {
                alert(Page_js_contents);
                return;
            }

            var urls = url + "?kw=" + escape($(keyword).val());
            
            if (openway == "_blank")
                window.open(urls);
            else
                window.location.href = urls;
        }
        else {
            ///全站搜索
            var keyword = "#" + conststring + "Text_" + id;
            if ($(keyword).val() == "") {
                alert(Page_js_contents);
                return;
            }

            var urls = url + "?kw=" + escape($(keyword).val());

            if (openway == "_blank")
                window.open(urls);
            else
                window.location.href = urls;
        }
    },
    //获取翻页列表数据
    GetPagesList: function(passid, id, ComponentDataTypeId, currentpage, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf) {
        var setpageshowname = "comm.ShowPages.First";
        if (showf != undefined) {
            setpageshowname = showf;
        }
        var setpageshow = eval(setpageshowname);
        var setpageshow_Init = eval(setpageshowname + "_Init");
        var pageint = $("#" + id).find("font[name*='PageInt']").html();
        PageCount = $("#" + id).find("font[name*='PageCount']").html();
        var oldpageint = pageint;
        if (currentpage < 0) {
            switch (currentpage) {
                case -1:
                    pageint--;
                    break;
                case -2:
                    pageint++;
                    break;
            };
        }
        else {
            if (isdefault == undefined) {
                if (pageint == currentpage)
                    return;
            }
            pageint = currentpage;
        }
        if (isdefault == undefined) {
            if (pageint < 1 || pageint > PageCount)
                return;
        }
        $("#" + id).find("font[name*='PageInt']").html(pageint);
        setpageshow(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf);


        var tid = "";
        var keywords = "";
        var oid = "";
        if (comm.CompontPage.parse_url('tid') != null)
            tid = comm.CompontPage.parse_url('tid');
        if (comm.CompontPage.parse_url('kw') != null)
            keywords = comm.CompontPage.parse_url('kw');

        if (ComponentType == 14 && qv == "1") {
            var regurl = window.location.href;
            if (regurl.indexOf("?") > -1) regurl = regurl.substring(0, regurl.indexOf("?"));
            var strreg = /([a-z0-9A-Z]{8}\-([a-z0-9A-Z]{4}\-){3}[a-z0-9A-Z]{12})/g
            var m = strreg.exec(regurl);
            if (m != null)
                oid = m[0];
        }

        var query = "{ComponentDataTypeId:'" + ComponentDataTypeId + "'";
        query += ",ComponentType:'" + ComponentType + "'";
        query += ",currentpage:'" + pageint + "'";
        query += ",passid:'" + passid + "'";
        query += ",pagesize:'" + pagesize + "'";
        query += ",orderasc:'" + orderasc + "'";
        query += ",orderfield:'" + orderfield + "'";
        query += ",q:'" + q + "'";
        query += ",qv:'" + qv + "'";
        query += ",tid:'" + tid + "'";
        query += ",kw:'" + keywords + "'";
        query += ",oid:'" + oid + "'";
        query += "}";
        if (isdefault != undefined) {
            $("#" + id + " .list").hide();
        }
        var f = eval(fn);

        comm.ajaxForJson("/WebUI/GetPageData.asmx/GetDesignDataPager", "post", query, function(o) {

            var t = o;
            var count = o.d.count;
            $("#" + id).find("font[name*='ListCount']").html(count);
            t.d = o.d.DesignData;
            f(id, t);
            var newPageCount = parseInt(count / pagesize);
            if (count % pagesize != 0)
                newPageCount++;
            if (newPageCount != PageCount) {
                PageCount = newPageCount;
                setpageshow_Init(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf);
                $("#" + id).find("font[name*='PageCount']").html(PageCount);
                setpageshow(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf);
            }
            $("#" + id + " .list").show();
            switch (fn) {
                case "comm.OPCompontPage.newlist1":
                case "comm.OPCompontPage.newlist2":
                case "comm.OPCompontPage.newlist3":
                case "comm.OPCompontPage.newlist4":
                case "comm.OPCompontPage.newlist5":
                case "comm.OPCompontPage.sd_supplydemandlist1":
                case "comm.OPCompontPage.sd_supplydemandlist2":
                    $("#" + id + " .list .content li a").attr("target", $("#" + id + " .list .content").attr("t"));
                    break;
                case "comm.OPCompontPage.search_results1":
                case "comm.OPCompontPage.search_results2":
                case "comm.OPCompontPage.search_results3":
                case "comm.OPCompontPage.search_results4":
                    $("#" + id + " .list .content a").attr("target", $("#" + id + " .list div[con='content']").attr("t"));
                    break;
            }
            if ($("#" + id).find("div[name*='div_visible']").html() != null) {
                comm.GetPageHight.GetPageHights();
            }
        }, function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest.responseText);
            $("#" + id + " .list").show();

        });

    }
};

comm.ShowPages = {
    First_Init: function(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf) {
        var temple = "";
        for (var j = 1; j < PageCount + 1; j++) {
            temple += "<option>" + j + "</option>";
        }
        $("#" + id).find("select[name*='SelectPage']").empty().append(temple);
        $("#" + id).find(".showpages .opt").prev().find("a").click(function() {
            comm.CompontPage.GetPagesList(passid, id, ComponentDataTypeId, PageCount, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType);
        });
    },
    //设置新闻翻页列表目录
    First: function(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf) {
        var showpagessize = 5;
        var temple = "";
        $("#" + id).find("li[name*='Numberli']").remove();

        var scale = parseInt(pageint / showpagessize);
        if (pageint % showpagessize == 0)
            scale = scale - 1;
        for (var j = 1; j < showpagessize + 1; j++) {
            var i = j + scale * showpagessize;
            if (i > PageCount)
                break;
            if (i == pageint)
                temple += "<li name=\"Numberli\" class=\"pagesnow\">" + i + "</li>";
            else
                temple += "<li name=\"Numberli\"><a href=\"javascript:void(0);\" onclick=\"comm.CompontPage.GetPagesList('" + passid + "','" + id + "','" + ComponentDataTypeId + "'," + i + "," + PageCount + ",'" + pagesize + "','" + orderasc + "','" + orderfield + "','" + q + "','" + qv + "','" + fn + "'," + ComponentType + ")\">" + i + "</a></li>";
        }
        $("#" + id).find("li[name*='pbutton']").after(temple);
        $("#" + id).find("select[name*='SelectPage']").val(pageint);
    },
    Second_Init: function(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf) {
        $("#" + id).find(".showpages .home:last").click(function() {
            comm.CompontPage.GetPagesList(passid, id, ComponentDataTypeId, PageCount, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, undefined, showf);
        });
    },
    Second: function(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf) {
        var showpagessize = 5;
        var temple = "";
        $("#" + id).find("a[name*='Numberli']").remove();
        var scale = parseInt(pageint / showpagessize);
        if (pageint % showpagessize == 0)
            scale = scale - 1;
        for (var j = 1; j < showpagessize + 1; j++) {
            var i = j + scale * showpagessize;
            if (i > PageCount)
                break;
            if (i == pageint)
                temple += "<a name=\"Numberli\" class=\"currentbg\">" + i + "</a>";
            else
                temple += "<a href=\"javascript:void(0);\" name=\"Numberli\" onclick=\"comm.CompontPage.GetPagesList('" + passid + "','" + id + "','" + ComponentDataTypeId + "'," + i + "," + PageCount + ",'" + pagesize + "','" + orderasc + "','" + orderfield + "','" + q + "','" + qv + "','" + fn + "','" + ComponentType + "',undefined,'" + showf + "')\">" + i + "</a>";
        }

        $("#" + id).find("li[name*='pbutton']").empty().append(temple);
    }
};

comm.OPCompontPage = {
    newlist1: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            temple += "<li><div class=\"divicon\"></div><div class=\"news\"><a href=\""
            + o.d[j].OverrideUrl + "\">" + o.d[j].Title + " </a></div><div class=\"time\">"
            + o.d[j].DateTime + "</div></li>";
        }
        $("#" + id).find(".content ul").empty().append(temple);
    },
    newlist2: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            temple += "<li><div class=\"time\">"
            + o.d[j].DateTime + "</div><div class=\"news\"><a href=\""
            + o.d[j].OverrideUrl + "\">" + o.d[j].Title + " </a></div></li>";
        }

        $("#" + id).find(".content ul").empty().append(temple);
    },
    newlist3: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            temple += "<li><div class=\"news\"><a href=\""
            + o.d[j].OverrideUrl + "\">" + o.d[j].Title + " </a></div></li>";
        }
        $("#" + id).find(".content ul").empty().append(temple);
    },
    newlist4: function(id, o) {
        comm.OPCompontPage.newlist3(id, o);
    },
    newlist5: function(id, o) {
        comm.OPCompontPage.newlist3(id, o);
    },
    joblist1: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            temple += "<li><div class=\"bt\"><a href=\""
            + o.d[j].OverrideUrl + "\">" + o.d[j].Title + " </a></div><div class=\"c1\"><a href=\""
            + o.d[j].OverrideUrl + "\">" + Page_js_xq + "</a></div><div class=\"au\">"
            + o.d[j].Number + "人</div><div class=\"bk\">"
            + o.d[j].Address + "</div></li>";
        }
        $("#" + id).find(".content").find(".queryul").empty().append(temple);
    },
    joblist2: function(id, o) {
        comm.OPCompontPage.joblist1(id, o);
    },
    joblist3: function(id, o) {
        comm.OPCompontPage.joblist1(id, o);
    },
    joblist4: function(id, o) {
        comm.OPCompontPage.joblist1(id, o);
    },
    joblist5: function(id, o) {
        comm.OPCompontPage.joblist1(id, o);
    },
    file_newlist1: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            temple += "<dl><dt class=\"listlb\"><a href=\"" + o.d[j].OverrideUrl + "\">" + o.d[j].Title + "</a></dt><dd class=\"app_desc\">" + o.d[j].Remark + "</dd><dd class=\"app_info\">" + Page_js_rjlb + "：<em>\r\n" + o.d[j].TypeName + "</em>\r\n" + Page_js_cjsj + "：\r\n<em><font>" + o.d[j].DateTime + "</font></em>\r\n" + Page_js_rjdx + "：\r\n<em>" + o.d[j].FileSize + "MB</em>\r\n<em><a href=\"" + o.d[j].OverrideUrl + "\">" + Page_js_ljxz + "</a></em></dd></dl>";
        }
        $("#" + id).find(".content").empty().append(temple);
    },
    file_newlist2: function(id, o) {
        comm.OPCompontPage.file_newlist1(id, o);
    },
    file_newlist3: function(id, o) {
        comm.OPCompontPage.file_newlist1(id, o);
    },
    file_newlist4: function(id, o) {
        comm.OPCompontPage.file_newlist1(id, o);
    },
    file_newlist5: function(id, o) {
        comm.OPCompontPage.file_newlist1(id, o);
    },
    video_list1: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            temple += "<div class=\"video_diy\"><div class=\"fang\"><div class=\"picfit\"><a href=\"" + o.d[j].OverrideUrl + "\"><img width=\"125px\" height=\"95px\" src=\"" + o.d[j].ImagePath + "\"></img></a></div></div><div class=\"txt_info\"><span class=\"info_title\">" + o.d[j].Title + "</span><br/>" + Page_js_splx + ":<span class=\"info_actor\">" + o.d[j].TypeName + "</span><br/>" + Page_js_djcs + ": <span class=\"info_time\">" + o.d[j].Hits + "</span><br/>" + Page_js_cjsj + ":<span class=\"info_time\">" + o.d[j].DateTime + "</span><br/></div></div>";
        }
        $("#" + id).find(".content").empty().append(temple);
    },
    video_list2: function(id, o) {
        comm.OPCompontPage.video_list1(id, o);
    },
    sd_supplydemandlist1: function(id, o) {
        var i = o.d.length;
        var temple = "<ul>";
        for (var j = 0; j < i; j++) {
            temple += "<li><div class=\"divicon\"></div><div class=\"news\">[" + o.d[j].IsSupply + "]<a href=\"" + o.d[j].OverrideUrl + "\">" + o.d[j].Title + "</a></div><div class=\"time\">" + o.d[j].DateTime + "</div></li>";
        }
        temple += "</ul>";
        $("#" + id).find(".content").empty().append(temple);
    },
    sd_supplydemandlist2: function(id, o) {
        comm.OPCompontPage.sd_supplydemandlist1(id, o);
    },
    search_results1: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            temple += "<div class=\"content\"><p><a href=\"" + o.d[j].OverrideUrl + "\">" + o.d[j].Title + "</a></p><p><span>" + o.d[j].Remark + "</span></p><p><em>" + o.d[j].DateTime + "</em></p></div>";
        }
        $("#" + id).find("div[con='content']").empty().append(temple);
    },
    search_results2: function(id, o) {
        comm.OPCompontPage.search_results1(id, o);
    },
    search_results3: function(id, o) {
        comm.OPCompontPage.search_results1(id, o);
    },
    search_results4: function(id, o) {
        comm.OPCompontPage.search_results1(id, o);
    },
    search_results5: function(id, o) {
        comm.OPCompontPage.search_results1(id, o);
    },
    shop_productlist1: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            var imgpath = "";

            if (o.d[j].ImageArr.length > 0)
                imgpath = "<img src=\"" + o.d[j].ImageArr[0] + "\" />";

            temple += "<li><div class=\"pic\"><a href=\"" + o.d[j].OverrideUrl + "\">" + imgpath + "</a></div><h3><a href=\"" + o.d[j].OverrideUrl + "\">" + o.d[j].Title + "</a></h3><p><span>￥" + o.d[j].Price + "</span></p></li>";
        }
        $("#" + id).find(".product_list ul").empty().append(temple);
    },
    product_list1: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            var imgpath = "";

            if (o.d[j].ImageArr.length > 0)
                imgpath = "<img src=\"" + o.d[j].ImageArr[0] + "\" />";

            temple += "<div class=\"p_list\"><div class=\"fang\"><a href=\"" + o.d[j].OverrideUrl + "\">" + imgpath + "</a></div><div class=\"txt_info\"><a href=\"" + o.d[j].OverrideUrl + "\">" + o.d[j].Title + "</a></div></div>";
        }
        $("#" + id).find(".content").empty().append(temple);
    },
    comment1: function(id, o) {
        var i = o.d.length;
        var temple = "";

        for (var j = 0; j < i; j++) {
            var author = o.d[j].Author;
            if (o.d[j].Url != '')
                author = "<a href=\"" + o.d[j].Url + "\">" + o.d[j].Author + "</a>";
            temple += "<tr><td><p class=\"rate\">" + o.d[j].Content + "</p><span class=\"date\">[" + o.d[j].DateTime + "]</span></td><td>" + author + "</td></tr>";
        }
        $("#" + id).find(".content tbody[name*=listcont]").empty().append(temple);
        //alert($("#" + id).find(".content tbody[name*=listcont]").html());
    },
    comment2: function(id, o) {
        var i = o.d.length;
        var temple = "";
        for (var j = 0; j < i; j++) {
            var author = o.d[j].Author;
            if (o.d[j].Url != '')
                author = "<a href=\"" + o.d[j].Url + "\">" + o.d[j].Author + "</a>";
            temple += "<table class=\"border\"><tr><td bgcolor=\"#ffffff\"><span>用户： " + author + "　　　　时间：" + o.d[j].DateTime + "　　　　IP： " + o.d[j].UserIP + "</span><br/><br/><strong>" + o.d[j].Content + "</strong></td></tr></table>";
        }
        $("#" + id).find(".content .border").remove();

        $("#" + id).find(".content").prepend(temple);
    },
    comment3: function(id, o) {
        var i = o.d.length;
        var temple = "";

        for (var j = 0; j < i; j++) {
            var author = o.d[j].Author;
            if (o.d[j].Url != '')
                author = "<a href=\"" + o.d[j].Url + "\">" + o.d[j].Author + "</a>";
            temple += "<table class=\"table_juli\"><tr><td class=\"td10\"><div class=\"userpic\"><img width=\"140\" height=\"140\" src=\"" + o.d[j].ImagePath + "\"></div><br/><span class=\"name\">" + author + " <br/>IP：" + o.d[j].UserIP + "</td><td class=\"td90\"><span class=\"fadate\">发表于 " + o.d[j].DateTime + "</span><span class=\"line\"></span><br/>" + o.d[j].Content + "</td></tr></table>";
        }
        $("#" + id).find(".content .table_juli").remove();
        $("#" + id).find(".content").prepend(temple);
    }
};
var myUpdate = new Array();
var intpage = 0;
var errstring = "";
comm.Login = {

    BackPassGetQu: function(id) {
        var name = $("#back_username" + id).val();
        var query = "{AccountName:'" + name + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/AccountGetQuestion", "post", query, function(o) {
            if (o.d != "") {
                $("#a_" + id).hide();
                $("#q_" + id).show();
                $("#back_q" + id).val(o.d);
            }
            else {
                alert(Page_js_usernameerror);
            }
        });
    },

    BackPassCheckAnEmail: function(pid, id) {
        var name = $("#back_username" + id).val();
        var qu = $("#back_q" + id).val();
        var an = $("#back_a" + id).val();

        var query = "{AccountName:'" + name + "'";
        query += ",Question:'" + qu + "'";
        query += ",Answer:'" + an + "'";
        query += ",SiteAccountId:'" + pid + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/AccountGetPwdSendEmail", "post", query, function(o) {
            if (o.d == "true") {
                $("#a_" + id).hide();
                $("#q_" + id).hide();
                $("#f_" + id).show();
            }
            else {
                alert(Page_js_jccw + o.d.toString());
            }
        });
    },

    CheckUserLogin: function(id, pid, fn) {
        var query = "{name:'-1'";
        query += ",pid:'" + pid + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/CheckUserLogin", "post", query, function(o) {
            if (o.d != "") {
                if (fn == undefined) {
                    $("#list_" + id).hide();
                    var sp = o.d;
                    $("#showlogin_" + id).show();
                    var ht = $("#showlogin_" + id).html();
                    ht = ht.replace("{Name}", sp.split('|')[0]);
                    var hrefurl = sp.split('|')[1].split(",");
                    var hrefTitle = sp.split('|')[2].split(",");
                    var hrefhtml = "";
                    for (var i = 0; i < hrefurl.length; i++) {
                        hrefhtml += '<a  target="_blank"  href="' + hrefurl[i] + '">' + hrefTitle[i] + '</a>';
                    }
                    ht = ht.replace("{hrefTitle}", hrefhtml);
                    $("#showlogin_" + id).html(ht);
                }
                else {
                    var f = eval(fn);
                    f(id, pid, o.d);
                }

            }
        });
    },
    LogoutLogin: function(id) {
        var query = "{currenturl:'" + document.location.href + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/Logout", "post", query, function(o) {
            if (o.d != "")
                window.location.href = o.d;
        });
    },
    subForm: function(id, pid, e) {
        var key = window.event ? e.keyCode : e.which;
        if (key == 13) {
            comm.Login.UserLogin(id, pid);
        }
    },
    UserLogin: function(id, pid, fn) {
        var name = $("#login_username" + id).val();
        var pass = $("#login_password" + id).val();

        var query = "{name:'" + name + "'";
        query += ",pass:'" + pass + "',pid:'" + pid + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/AccountLogin", "post", query, function(o) {
            if (o.d != "") {
                if (fn == undefined) {
                    $("#list_" + id).hide();
                    var sp = o.d;
                    $("#showlogin_" + id).show();
                    var ht = $("#showlogin_" + id).html();
                    ht = ht.replace("{Name}", sp.split('|')[0]);
                    var hrefurl = sp.split('|')[1].split(",");
                    var hrefTitle = sp.split('|')[2].split(",");
                    var hrefhtml = "";
                    for (var i = 0; i < hrefurl.length; i++) {
                        hrefhtml += '<a  target="_blank"  href="' + hrefurl[i] + '">' + hrefTitle[i] + '</a>';
                    }
                    ht = ht.replace("{hrefTitle}", hrefhtml);
                    $("#showlogin_" + id).html(ht);
                }
                else {
                    var f = eval(fn);
                    f(id, pid, o.d);
                }

            }
            else {
                alert(Page_js_dlsb);
            }

        });
    },
    Login_reg: function(lan, passname) {
        var pathurl = "register_zh-cn.html";
        var pathdir = "/";
        if (passname != "") {
            var pf = passname.toString().substring(0, 1);
            pathdir = "/Files/Sites/" + pf + "/" + passname + "/Html/";
        }
        if (lan != undefined & lan != "")
            pathurl = "register_" + lan + ".html";
        window.location.href = pathdir + pathurl;
    },
    RegUser: function(PSID, id) {

        var AccountName = $("#" + id).find("input[name*='uesrname']").val();
        var AccountPassWord = $("#" + id).find("input[name*='password']").val();
        var AccountPassWordr = $("#" + id).find("input[name*='passwordr']").val();
        var NickName = $("#" + id).find("input[name*='nikename']").val();
        var Email = $("#" + id).find("input[name='email']").val();
        var Question = $("#" + id).find("input[name='question']").val();
        var Answer = $("#" + id).find("input[name='answer']").val();
        if (AccountPassWord != AccountPassWordr) {
            alert(Page_js_lcmmbyz);
            return;
        }
        var query = "{FAccountId:'" + PSID + "'";
        query += ",AccountName:'" + AccountName + "'";
        query += ",AccountPassWord:'" + AccountPassWord + "'";
        query += ",NickName:'" + NickName + "'";
        query += ",Email:'" + Email + "'";
        query += ",Question:'" + Question + "'";
        query += ",Answer:'" + Answer + "'";
        query += "}";
        var dividt = "<div id=\"reguserdiv\" style=\"position: absolute; width: 200px; height: 50px; display: none; z-index: 99999;\"><div id=\"box\" style=\"width:200px; height:50px; background:#fff; border:3px solid #cfdde9;\"><div class=\"toptext\" style=\"line-height:20px; font-size:12px; color:#2f73ac; margin:10px;\"><img  src=\"/Image/Header/zoomloader.gif\"/>" + Page_js_reging + "</div></div></div>";
        comm.MarkDiv.Show('reguserdiv', '', dividt);
        comm.ajaxForJson("/WebUI/GetPageData.asmx/AccountReg", "post", query, function(o) {

            switch (o.d.regtype) {
                case 2:
                    comm.Login.copydir(AccountName, "0001/");
                    comm.Login.checkSelectall(o.d.returnUrl);
                    break;
                case 4:
                    alert(Page_js_zccg);
                    window.location = o.d.returnUrl;
                    break;
                default:
                    comm.MarkDiv.Close('reguserdiv');
                    alert(o.d.message);
                    break;
            }
        });

    },
    copydir: function(AccountName, url) {
        var query = "{AccountName:'" + AccountName + "'";
        query += ",url:'" + url + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/copydir", "post", query, function(o) { });
    },
    checkSelectall: function(url) {
        comm.ajaxForJson("/WebUI/GetData.asmx/GetAllPages", "post", '{}', function(o) {
            var PAGESDATE = o.d;
            myUpdate = new Array();
            intpage = 0;
            for (var k = 0; k < PAGESDATE.length; k++) {
                var query = "{PageID:'" + PAGESDATE[k].PageID + "'";
                query += ",PAAID:'" + PAGESDATE[k].PAAID + "'";
                query += ",Lang:'" + PAGESDATE[k].LanguageMark + "'";
                query += ",Tid:''";
                query += ",KeyWords:''";
                query += ",Oid:''";
                query += "}";
                myUpdate.push(query);
            }
            errstring = "";
            if (myUpdate.length > 0) {
                $("#reguserdiv .toptext").html("<img  src=\"/Image/Header/zoomloader.gif\"/>" + Page_js_initpageing);
                comm.Login.doupdateHtml(url);
            }
            else {
                alert(Page_js_zccg);
                window.location = url;
            }

        });
    },
    doupdateHtml: function(url) {

        if (intpage < myUpdate.length) {
            comm.ajaxForJson("/WebUI/GetData.asmx/CreatePage", "post", myUpdate[intpage], function(o) {
                if (!o.d) {
                    errstring += myUpdate[intpage];
                }
                intpage++;
                comm.Login.doupdateHtml(url);
            });
        }
        else {
            alert(Page_js_zccg);
            window.location = url;
        }
    },

    Reg_returnpsw: function(lan) {
        pathurl = "/login_zh-cn.html";
        if (lan != undefined & lan != "")
            pathurl = "/login_" + lan + ".html";
        window.location.href = pathurl;
    },
    Reg_Agreement: function(id) {
        $("#" + id + " div[name='userreg']").show();
        $("#" + id + " div[name='useragreement']").hide();
    },
    Reg_GetAgreement: function(id, FAccountId) {
        var query = "{FAccountId:'" + FAccountId + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/GetRegAgreement", "post", query, function(o) {
            if (o.d != null && o.d != '') {
                $("#" + id + " div.J_TBAgreement").html(o.d);
            }
            else {
                $("#" + id + " div[name='userreg']").show();
                $("#" + id + " div[name='useragreement']").hide();
            }
        });
    }
};
comm.Column = {
    column_Secondary1: function(id, oid, obj) {

        $("#" + id).find(".menu_sb ul").hide();
        var fo = $("#" + id + "_" + oid);
        var fw = fo.width();
        var padleft = $(obj).position().left - 20;
        var divw = $("#" + id).width();
        if (divw < padleft + fw) {
            padleft = divw - fw;
            if (padleft < 0)
                padleft = 0;
        }
        $("#" + id + "_" + oid).css("padding-left", padleft);
        $("#" + id + "_" + oid).show();
    },
    column_Secondary2: function(id, oid, obj, type) {
        if (type > 0) {
            $("#" + id + "_" + oid + " li").removeClass();
            $(obj).addClass("sb_current");
        }
        else {
            $("#" + id).find(".menu_sb").hide();
            if ($("#" + id + "_" + oid).html() != null) {
                $("#" + id + "_" + oid).show();
                $("#" + id + "_" + oid).css("left", $(obj).position().left - 1);
                $("#" + id + "_" + oid + " li").removeClass();
            }
        }
    },
    column_Secondary3: function(id, oid, obj) {

        comm.Column.column_Secondary1(id, oid, obj);
    },
    column_Secondary4: function(id, oid, obj) {

        comm.Column.column_Secondary1(id, oid, obj);
    },
    column_Secondary5: function(id, oid, obj, type) {
        if (type > 0) {
            $("#" + id + "_" + oid + " li").removeClass();
            var ot = $("#" + id + "_" + oid + " li[name='bunone']");
            if ($(obj).attr("name") != "bunone")
                ot.addClass("bgnone");
            $(obj).addClass("sb_current");
        }
        else {
            $("#" + id).find(".menu_sb").hide();
            if ($("#" + id + "_" + oid).html() != null) {
                $("#" + id + "_" + oid).show();
                $("#" + id + "_" + oid).css("left", $(obj).position().left - 6);
                $("#" + id + "_" + oid + " li").removeClass();
                $("#" + id + "_" + oid + " li[name='bunone']").addClass("bgnone");
            }
        }
    }
};
comm.Shop = {
    shop_qrdd: function(id, pid) {
        var query = "{PId:'" + id + "',passportId:'" + pid + "'}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/CreateShopOrder", "post", query, function(o) {
            if (o.d) {
                parent.window.location.href = "/users/main.aspx?t=qrdd";
                parent.JqueryDialog.Close();
            }
            else {
                parent.JqueryDialog.Close();
            }

        });
    },
    shop_producttype1: function(f, obj, id, oid) {
        switch (f) {
            case 1:
                $(obj).parent().find("dl").removeClass();
                $(obj).addClass("curr_col");
                break;
            case 2:
                $("#" + id + " .list ul li").removeClass();
                $("#" + id + " .list ul li b").show();
                $(obj).addClass("curr");
                $(obj).find("b").hide();
                $("#" + id).find(".menuListBox").hide();
                if ($("#" + id + "_" + oid).html() != null) {
                    $("#" + id + "_" + oid).show();
                    $("#" + id + "_" + oid).css("top", $(obj).position().top - 15);
                    $("#" + id + "_" + oid).css("left", $(obj).position().left + $(obj).width() - 2);
                    $("#" + id + "_" + oid + " dl").removeClass();
                }
                else {
                    $("#" + id + " #nosontype  dd").html(oid);
                    $("#" + id + " #nosontype").show();
                    $("#" + id + " #nosontype").css("top", $(obj).position().top - 15);
                    $("#" + id + " #nosontype").css("left", $(obj).position().left + $(obj).width() - 2);
                }
                break;
            case 3:
                if (oid == undefined)
                    oid = $("#" + id + " #nosontype  dd").html();
                $(obj).show();
                $("#" + id + " .list ul li[name='" + id + "_" + oid + "']").addClass("curr");
                $("#" + id + " .list ul li[name='" + id + "_" + oid + "'] b").hide();
                break;
            case 4:
                $(obj).find(".list ul li").removeClass();
                $(obj).find(".list ul li b").show();
                $(obj).find(".menuListBox").hide();
                break;
            default:
                break;

        }
    },
    shop_commproductlist: function(obj) {
        $(obj).parent().find("dt").hide();
        $(obj).parent().find("dd").show();
        $(obj).find("dt").show();
        $(obj).find("dd").hide();
    },
    shop_product1: function(f, obj, id, oid) {

        switch (f) {
            case 1:
                if ($(obj).attr("class") == "") {
                    $(obj).parent().find("li").removeClass();
                    $(obj).addClass("current_bg");
                    var pathurl = $(obj).find("img").attr("src");
                    $(obj).parent().parent().parent().find(".bigPic img").attr("src", pathurl);
                    $(obj).parent().parent().parent().find(".bigPic a").attr("href", pathurl);
                }
                break;
            case 2:
                if ($(obj).attr("class") == "") {
                    $(obj).parent().find("li").removeClass();
                    $(obj).addClass("curr");
                    $("#" + id).find(".tab_content").hide();
                    $("#" + id).find("#" + oid + "_" + id).show();
                }
                break;
            case 3:
                $(document).ready(function() {
                    var o = $("#" + id);
                    var ob = $("#" + id + " ." + obj);
                    var oob = $("#" + id + " ." + oid);
                    ob.height(o.height() - ob.position().top - 60);
                    oob.height(ob.height() - 50);
                    var options5 =
                    {
                        zoomWidth: 350,
                        zoomHeight: 350,
                        showEffect: 'show',
                        hideEffect: 'fadeout',
                        fadeoutSpeed: 'slow',
                        position: 'right',
                        showPreload: true,
                        title: false

                    };
                    $(".jqzoom").jqzoom(options5);

                });
                $("#" + id + " span[name=data]").each(function() {

                    $(this).parent().find("img").attr("src", $(this).html());
                    $(this).remove();

                });
                break;
            case 4:
                if ($(obj).attr("class") == "") {
                    $(obj).parent().parent().find("a").removeClass();
                    $(obj).parent().parent().find("b").hide();
                    $(obj).addClass("curr");
                    $(obj).children("b").show();
                }
                break;
            default:
                break;
        }
    }

};
comm.photo = {
    Init: function(id, oid) {
        $("#" + id + " span").each(function() {
            $(this).parent().find("img").attr("src", $(this).html());
            $(this).remove();
        });
        $(document).ready(function() {
            window.Lightbox = new jQuery().visualLightbox({
                autoPlay: true,
                borderSize: 21,
                classNames: id + '_img,.vlightbox1',
                descSliding: true,
                enableRightClick: false,
                enableSlideshow: true,
                overlayOpacity: 0.7,
                resizeSpeed: 7,
                slideTime: 4,
                startZoom: true
            })
        });
    }
};
comm.ProductPage = {
    Init: function(id, path) {
        var _showlayer = "#" + id + " .Divquery_1p .Divquery_1p_left .fang .picfit";
        var _pagelayer = "#" + id + " .Divquery_1p_left .pages ul";
        var ImagePath = path;
        var Images = ImagePath.split(",");
        var imagelist = "";
        var page = '<li class="cbutton" onclick="comm.ProductPage.Pre(\'' + id + '\');">上一张</li>';
        $(Images).each(function(i) {
            imagelist += '<a rel="clearbox" href=' + Images[i] + '><img width="188px" height="136px" src="' + Images[i] + '" style="display:none;"></img></a>';
            page += '<li class="pagesnow">' + (i + 1) + '</li>';
        });
        page += '<li class="cbutton" onclick="comm.ProductPage.Next(\'' + id + '\');">下一张</li>';
        var _currentimg = $(_showlayer);
        _currentimg.empty().append(imagelist);
        var _pagesul = $(_pagelayer);
        _pagesul.empty().append(page);
        var _imgs = _currentimg.find("img");
        _imgs.eq(0).show();
        var _pagesli = _pagesul.children("li:not(:first,:last)");
        _pagesli.eq(0).removeClass("pagesnow").addClass("pagestwo");
        _pagesli.click(function() {
            var currentpage = _pagesul.children("li.pagestwo");
            currentpage.removeClass("pagestwo").addClass("pagesnow");
            $(this).removeClass("pagesnow").addClass("pagestwo");
            _imgs.hide();
            _imgs.eq(_pagesli.index(this)).show();
        });
    },
    Pre: function(id) {
        comm.ProductPage.PageChange(id, 0);
    },
    Next: function(id) {
        comm.ProductPage.PageChange(id, 1);
    },
    PageChange: function(id, type) {
        var _imgs = $("#" + id + " .Divquery_1p .Divquery_1p_left .fang .picfit a").children("img");
        var _pagesul = $("#" + id + " .Divquery_1p_left .pages ul");
        var _pagesli = _pagesul.children("li:not(:first,:last)");
        var currentpage = _pagesul.children("li.pagestwo");
        var currentindex = _pagesli.index(currentpage);
        switch (type) {
            case 0:
                if (currentindex > 0) {
                    currentpage.removeClass("pagestwo").addClass("pagesnow");
                    _pagesli.eq(currentindex - 1).removeClass("pagesnow").addClass("pagestwo");
                    _imgs.hide();
                    _imgs.eq(currentindex - 1).show();
                }
                break;
            case 1:
                if (currentindex < _pagesli.size() - 1) {
                    currentpage.removeClass("pagestwo").addClass("pagesnow");
                    _pagesli.eq(currentindex + 1).removeClass("pagesnow").addClass("pagestwo");
                    _imgs.hide();
                    _imgs.eq(currentindex + 1).show();
                }
                break;
        }
    },
    InitImg: function(id) {
        var _img = $("#" + id + " .list_diy .fang .picfit a img");
        _img.each(function() {
            if ($(this).attr("src").split(",")[0] != null || $(this).attr("src").split(",")[0] != '') {
                $(this).attr("src", $(this).attr("src").split(",")[0]);
                $(this).width(100);
                $(this).height(98);
                $(this).show();
            }
        });
    }
};
comm.AddFavorite = {
    //加入收藏
    AddFav: function() {

        var sURL = location.href;
        var sTitle = document.title;
        try {
            window.external.addFavorite(sURL, sTitle);
        }
        catch (e) {
            try {
                window.sidebar.addPanel(sTitle, sURL, "");
            }
            catch (e) {
                alert(Page_js_jrsc);
            }
        }
    },
    //设置首页
    SetHome: function(obj) {
        var h = location.href;
        try {

            obj.style.behavior = 'url(#default#homepage)';
            obj.setHomePage(h);
            return false;
        }
        catch (e) {
            if (window.netscape) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                    return false;
                }
                catch (e) {
                    alert(Page_js_bqczllq);
                }
            }
            else {
                alert(Page_js_bqczllqsbsd.replace("{0}", h));
            }

        }
    }
};
comm.GetPageHight = {
    GetPageHights: function() {
        var div_parent = $(".pdv_class  div[name*='div_visible']").parent().parent();
        div_parent.each(function() {
            var height = 0;
            var dvarr = new Array();
            var tempdv = $(this).find(".pdv_class");
            tempdv.each(function() {

                var tureheight = $(this).height();
                var ischange = 0;
                if ($(this).find("div[name*='div_visible']").html() != null) {
                    tureheight = $(this).find("div[name*='div_visible']").height();
                    ischange = 1;
                }
                var temarr = [$(this).position().top, $(this).position().left, $(this).height(), $(this).width(), tureheight, $(this).position().top, $(this).attr("id"), ischange];
                if (tureheight != $(this).height()) {
                    $(this).height(tureheight);
                }
                dvarr.push(temarr);
            });
            for (var i = 0; i < dvarr.length - 1; i++) {
                var temp;
                for (var j = 0; j < dvarr.length - i - 1; j++) {
                    if (dvarr[j][0] > (dvarr[j + 1][0])) {
                        temp = dvarr[j + 1];
                        dvarr[j + 1] = dvarr[j];
                        dvarr[j] = temp;
                    }
                }
            }
            for (var t = 0; t < dvarr.length; t++) {
                var turetop = -2;
                for (var i = 0; i < t; i++) {
                    if (dvarr[i][7] > 0) {
                        if ((dvarr[t][1] > dvarr[i][1] && dvarr[t][1] < (dvarr[i][1] + dvarr[i][3])) || (dvarr[t][1] < dvarr[i][1] && dvarr[i][1] < (dvarr[t][1] + dvarr[t][3])) || (dvarr[t][1] == dvarr[i][1])) {
                            var thistop = dvarr[i][5] + dvarr[i][4];
                            if (thistop > turetop)
                                turetop = thistop;
                        }
                    }
                }

                if (turetop > -1) {
                    dvarr[t][5] = turetop + 5;
                    $("#" + dvarr[t][6]).css("top", dvarr[t][5]);
                    dvarr[t][7] = 1;
                }
                if (height < dvarr[t][4] + dvarr[t][5])
                    height = dvarr[t][4] + dvarr[t][5];
            }
            $(this).height(height);
        });
    }
};

comm.Jobs = {
    //职位申请页跳转
    JobsPost: function(PID) {
        var Posturl = $("#" + PID + " #url").html();
        if (Posturl != "") {
            window.location.href = Posturl + "&returnurl=" + self.location.href;
        }
    },
    //职位申请数据提交
    JobsDataPost: function(PID) {
        var username = $("#" + PID + " input[name='username']").val();
        var sex = $("#" + PID + " select[name='sex']").val();
        var birthday = $("#" + PID + " input[name='birthday']").val();
        var maritalstatus = $("#" + PID + " select[name='maritalstatus']").val();
        var School = $("#" + PID + " input[name='School']").val();
        var education = $("#" + PID + " select[name='education']").val();
        var Major = $("#" + PID + " input[name='Major']").val();
        var GraduationTime = $("#" + PID + " input[name='GraduationTime']").val();
        var phone = $("#" + PID + " input[name='phone']").val();
        var tel = $("#" + PID + " input[name='tel']").val();
        var address = $("#" + PID + " input[name='address']").val();
        var email = $("#" + PID + " input[name='email']").val();
        var Specialty = $("#" + PID + " input[name='Specialty']").val();
        var EducationResume = $("#" + PID + " textarea[name='EducationResume']").val();
        var workexperience = $("#" + PID + " textarea[name='workexperience']").val();
        var code = $("#" + PID + " input[name='code']").val();
        var JobStates = $("#" + PID + " select[name='JobStates']").val();
        var jobid = "";
        if (comm.CompontPage.parse_url('oid') != null)
            jobid = comm.CompontPage.parse_url('oid');

        var query = "{username:'" + username + "',tel:'" + tel + "'";
        query += ",sex:'" + sex + "',birthday:'" + birthday + "'";
        query += ",maritalstatus:'" + maritalstatus + "',School:'" + School + "'";
        query += ",education:'" + education + "',Major:'" + Major + "'";
        query += ",GraduationTime:'" + GraduationTime + "',phone:'" + phone + "'";
        query += ",address:'" + address + "',email:'" + email + "'";
        query += ",Specialty:'" + Specialty + "',EducationResume:'" + EducationResume + "'";
        query += ",workexperience:'" + workexperience + "',code:'" + code + "'";
        query += ",jobid:'" + jobid + "',JobStates:'" + JobStates + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/JobsDataPost", "post", query, function(o) {
            if (o.d == "") {
                alert(com_operationsucceed);
                if (comm.CompontPage.parse_url('returnurl') != null)
                    window.location.href = comm.CompontPage.parse_url('returnurl');
                else
                    self.location.href = self.location.href;
            }
            else
                alert(o.d);
        });

    }
};

comm.Votes = {
    Vote: function(PID) {
        var VoteItem = $("#" + PID + " input[type='radio']:checked");
        if (VoteItem.size() == 0) {
            alert(Page_js_qxzytpdx);
            return;
        }

        var VoteItemIDList = new Array();
        for (var i = 0; i < VoteItem.size(); i++) {
            VoteItemIDList[i] = $(VoteItem[i]).val();
        }
        var VoteItemID = VoteItemIDList.join(",");
        var query = "{VoteItemIDList:'" + VoteItemID + "'}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/Vote", "post", query, function(o) {
            if (o.d != "") {
                comm.Votes.ChangeVoteResult(o.d);
                alert(Page_js_tpcg);
            }
            else {
                alert(Page_js_tpsb);
            }
            VoteItem.attr("checked", "");
        });
    },
    InitVoteResult: function(PID) {
        var Votes = $("#" + PID + " table[voteitem='" + PID + "']");
        var VoteItem = $("#" + PID + " img");
        VoteItem.hide();
        var VoteIDList = "";
        for (var i = 0; i < Votes.size(); i++) {
            VoteIDList += $(Votes[i]).attr("voteid") + ",";
        }
        var query = "{VoteIDList:'" + VoteIDList + "'}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/GetVoteResult", "post", query, function(o) {
            if (o.d) {
                comm.Votes.ChangeVoteResult(o.d);
            }
        });
        VoteItem.show();
    },
    ChangeVoteResult: function(item) {
        for (var i = 0; i < item.length; i++) {
            var itemlist = "";
            var count = 0;
            for (var j = 0; j < item[i].VoteItem.length; j++) {
                count += item[i].VoteItem[j].Count != "null" ? item[i].VoteItem[j].Count : 0;
            }
            for (var j = 0; j < item[i].VoteItem.length; j++) {
                var w = count != 0 ? parseFloat(item[i].VoteItem[j].Count != "null" ? item[i].VoteItem[j].Count : 0) / count * 200 : 1;
                w = w != 0 ? w : 1;
                itemlist += "<tr><td>" + item[i].VoteItem[j].VoteItemName + "：</td><td><img src=\"/Image/Component/vote_result/style1/result_pic.jpg\" count=\"" + item[i].VoteItem[j].Count + "\" name=\"" + item[i].VoteItem[j].VoteID + "\" width=\"" + w + "px\" height=\"7px\"/></td><td><span>" + item[i].VoteItem[j].Count + Page_js_p + "</span></td></tr>";
            }
            $("table[name='Vote_" + item[i].VoteItem[0].VoteID + "']").empty().html(itemlist);
        }
    }
};

comm.PreAndNext = {
    News: function(newid, pid, lanid, uid) {
        var pre = $("#pre_" + pid);
        var next = $("#next_" + pid);
        var query = "{NewID:'" + newid + "'";
        query += ",Lan:'" + lanid + "'";
        query += ",AccountId:'" + uid + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/GetNewsPreAndNext", "post", query, function(o) {
            if (o.d) {
                switch (o.d.TypeID) {
                    case 1:
                        pre.remove();
                        next.children("a").attr("href", o.d.Nn[0].LinkUrl);
                        next.children("a").text(o.d.Nn[0].LinkTitle);
                        break;
                    case 2:
                        next.remove();
                        pre.children("a").attr("href", o.d.Nn[0].LinkUrl);
                        pre.children("a").text(o.d.Nn[0].LinkTitle);
                        break;
                    case 3:
                        pre.remove();
                        next.remove();
                        break;
                    default:
                        pre.children("a").attr("href", o.d.Nn[0].LinkUrl);
                        pre.children("a").text(o.d.Nn[0].LinkTitle);
                        next.children("a").attr("href", o.d.Nn[1].LinkUrl);
                        next.children("a").text(o.d.Nn[1].LinkTitle);
                        break;
                }
                if ($("#" + id).find("div[name*='div_visible']").html() != null) {
                    comm.GetPageHight.GetPageHights();
                }
            }
        });
    },
    Photo: function(photoid, pid, lanid, uid) {
        var pre = $("#pre_" + pid);
        var next = $("#next_" + pid);
        var query = "{PhotoID:'" + photoid + "'";
        query += ",Lan:'" + lanid + "'";
        query += ",AccountId:'" + uid + "'";
        query += "}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/GetPhotoPreAndNext", "post", query, function(o) {
            if (o.d) {
                switch (o.d.TypeID) {
                    case 1:
                        pre.remove();
                        next.children("a").attr("href", o.d.Nn[0].LinkUrl);
                        next.children("a").text(o.d.Nn[0].LinkTitle);
                        break;
                    case 2:
                        next.remove();
                        pre.children("a").attr("href", o.d.Nn[0].LinkUrl);
                        pre.children("a").text(o.d.Nn[0].LinkTitle);
                        break;
                    case 3:
                        pre.remove();
                        next.remove();
                        break;
                    default:
                        pre.children("a").attr("href", o.d.Nn[0].LinkUrl);
                        pre.children("a").text(o.d.Nn[0].LinkTitle);
                        next.children("a").attr("href", o.d.Nn[1].LinkUrl);
                        next.children("a").text(o.d.Nn[1].LinkTitle);
                        break;
                }
                if ($("#" + id).find("div[name*='div_visible']").html() != null) {
                    comm.GetPageHight.GetPageHights();
                }
            }
        });
    }
};

comm.News = {
    RelatedNews: function(pid, pagesize) {
        if ($("ul[news='news_related']").html() != null) {
            var NewsID = $.trim($("ul[news='news_related'] li[news='news_related_ObjectId']").text());
            var TypeId = $.trim($("ul[news='news_related'] li[news='news_related_TypeId']").text());
            var KeyWord = $.trim($("ul[news='news_related'] li[news='news_related_KeyWords']").text());
            var Lan = $.trim($("ul[news='news_related'] li[news='news_related_LanguageId']").text());
            var AccountId = $.trim($("ul[news='news_related'] li[news='news_related_AccountId']").text());
            var query = "{NewsID:'" + NewsID + "'";
            query += ",NewsTypeId:'" + TypeId + "'";
            query += ",KeyWords:'" + KeyWord + "'";
            query += ",lan:'" + Lan + "'";
            query += ",AccountId:'" + AccountId + "'";
            query += ",pagesize:'" + pagesize + "'";
            query += "}";
            comm.ajaxForJson("/WebUI/GetPageData.asmx/GetRelatedNews", "post", query, function(o) {
                if (o.d.length > 0) {
                    var relatednews = "";
                    for (var i = 0; i < o.d.length; i++) {
                        relatednews += "<p><u></u><a href=\"" + o.d[i].LinkUrl + "\">" + o.d[i].LinkTitle + "</a><span>" + o.d[i].DateTime + "</span></p>";
                    }
                    $("#" + pid + " .list").empty().html(relatednews);
                    if ($("#" + id).find("div[name*='div_visible']").html() != null) {
                        comm.GetPageHight.GetPageHights();
                    }
                }
            });
        }
    }
};
comm.video = {
    play: function(id, furl) {
        $(document).ready(function() {
            var h = $("#" + id).height() - 60;
            $("#" + id + "_play").empty();
            $("#" + id + "_play").height(h);
            flowplayer(id + "_play", { src: '/webui/Javascript/flowplayer/flowplayer.swf', wmode: "transparent" },
            {
                clip: {
                    url: furl,
                    autoPlay: false
                }
            });
        });
    }
};
comm.language = {
    setLanguage: function(lm) {
        var query = "{lm:'" + lm + "',url:'" + window.location.pathname + "'}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/SetLanguage", "post", query, function(o) {
            window.location.href = o.d.toString();
        });
    }
};
comm.currentPosition = {
    LoadPostition: function(id, openway) {
        var Param = $("body").attr("Param");
        var Paramurl = $("body").attr("Paramurl");
        var query = "{pi:'" + Param + "',pid:'" + Paramurl + "'}";
        comm.ajaxForJson("/WebUI/GetPageData.asmx/LoadPostition", "post", query, function(o) {
            $("#" + id).html(o.d.toString());
            $("#" + id).find("a").attr("target", openway);
        });
    }
};
var lr = 1;
var Marquee = function(id) {
    try { document.execCommand("BackgroundImageCache", false, true); } catch (e) { };
    var container = document.getElementById("marquee" + id),
  slide = container.getElementsByTagName("li")[0],
  options = arguments[1] || {},
  speed = options.speed || 10,
  direction = options.direction || "left";
    slide.innerHTML += slide.innerHTML;
    var item = slide.getElementsByTagName("a"),
  critical, delta, rolling, field;
    if (direction == "left" || direction == "right") {
        slide.style.cssText = "width:1000%";
        for (var i = 0, l = item.length; i < l; i++) {
            item[i].style.cssText = "float:left";
        }
        field = "left";
        critical = item[item.length / 2].offsetLeft;
    } else if (direction == "up" || direction == "down") {
        field = "top";
        critical = item[item.length / 2].offsetTop;
    }
    if (direction == "up" || direction == "left") {
        delta = 0;
        rolling = function() {
            if (lr == 1)
                delta == 0 ? delta = -critical : delta++;
            else
                delta == -critical ? delta = 0 : delta--;
            slide.style[field] = delta + "px";
        }
    } else if (direction == "down" || direction == "right") {
        delta = -critical;
        rolling = function() {
            if (lr == 1)
                delta == 0 ? delta = -critical : delta++;
            else
                delta == -critical ? delta = 0 : delta--;
            slide.style[field] = delta + "px";
        }
    }
    var timer = setInterval(rolling, speed)

    document.getElementById("rightbar" + id).onmouseout = function() {
        clearInterval(timer);
    }

    document.getElementById("leftbar" + id).onmouseout = function() {
        clearInterval(timer);
    }

    document.getElementById("rightbar" + id).onmouseover = function() {
        lr = 1;
        timer = setInterval(rolling, speed)
    }
    document.getElementById("leftbar" + id).onmouseover = function() {
        lr = 0;
        timer = setInterval(rolling, speed)
    }
};


comm.ads = {
    luboint: function(id, obj) {

        $(document).ready(function() {
            var o = $("#" + id);
            var os = $("#" + id + "_slider");
            var osl = os.find(".contents li");
            var osli = osl.find("img");
            os.width(o.width());
            os.height(o.height());
            osl.width(o.width());
            osl.height(o.height());
            osli.width(o.width());
            osli.height(o.height());
            os.show();
            os.Xslider({ effect: 'scrolly' });
        });
    },
    play: function(id, furl) {
        $(document).ready(function() {
            var h = $("#" + id).height();
            $("#" + id + "_play").empty();
            $("#" + id + "_play").height(h);
            flowplayer(id + "_play", { src: '/webui/Javascript/flowplayer/flowplayer.swf', wmode: "transparent" },
            {
                clip: {
                    url: furl,
                    autoPlay: false
                }
            });
        });
    }
};
comm.Comment = {
    send: function(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf) {
        var oid = "";
        var pid = $("body").attr("Paramurl");
        var conent = $("#" + id + " textarea[name*='conent']").val();
        if (conent == '') {
            alert(com_ContentNotNull);
            return;
        }
        if (qv == "1") {
            var regurl = window.location.href;
            if (regurl.indexOf("?") > -1) regurl = regurl.substring(0, regurl.indexOf("?"));
            var strreg = /([a-z0-9A-Z]{8}\-([a-z0-9A-Z]{4}\-){3}[a-z0-9A-Z]{12})/g
            var m = strreg.exec(regurl);
            if (m != null)
                oid = m[0];
        }
        var query = "{";
        query += "qv:'" + qv + "'";
        query += ",oid:'" + oid + "'";
        query += ",pid:'" + pid + "'";
        query += ",conent:'" + conent + "'";
        query += ",pagesize:'" + pagesize + "'";
        query += "}";
        var f = eval(fn);
        var setpageshowname = "comm.ShowPages.First";
        if (showf != undefined) {
            setpageshowname = showf;
        }
        var setpageshow = eval(setpageshowname);
        var setpageshow_Init = eval(setpageshowname + "_Init");
        comm.ajaxForJson("/WebUI/GetPageData.asmx/commentsend", "post", query, function(o) {
            var t = o;
            var count = o.d.count;
            if (count > -1) {
                alert(com_operationsucceed);

                $("#" + id).find("font[name*='ListCount']").html(count);
                t.d = o.d.DesignData;
                f(id, t);
                var newPageCount = parseInt(count / pagesize);
                if (count % pagesize != 0)
                    newPageCount++;
                if (newPageCount != PageCount) {
                    PageCount = newPageCount;
                    setpageshow_Init(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf);
                    $("#" + id).find("font[name*='PageCount']").html(PageCount);
                    setpageshow(passid, id, ComponentDataTypeId, pageint, PageCount, pagesize, orderasc, orderfield, q, qv, fn, ComponentType, isdefault, showf);
                }
                if ($("#" + id).find("div[name*='div_visible']").html() != null) {
                    comm.GetPageHight.GetPageHights();
                }
                $("#" + id + " textarea[name*='conent']").val("");
            }
            else {
                alert(com_operationfailure);
            }
        }, function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest.responseText);

        });

    },
    check: function(id, pid, o) {
        $("#" + id + " div[name*=login]").hide();
        var ht = $("#" + id + " div[name*=logined]").html();
        ht = ht.replace("{Name}", o.split('|')[3]);
        $("#" + id + " div[name*=logined]").html(ht);
        $("#" + id + " div[name*=logined]").show();
    }
};

comm.MarkDiv = {
    CreateMark: function(ct, exitcontent) {

        if ($("#fullbg").html() == undefined || $("#fullbg").html() == null) {
            var divid = "<div id=\"fullbg\" style=\"background-color: Gray; display: none; z-index: 99999; position: absolute; left: 0px; top: 0px; filter: Alpha(Opacity=30); /* IE */ -moz-opacity: 0.4; /* Moz + FF */ opacity: 0.4; } #dialog { position: absolute; width: 200px; height: 61px; display: none; z-index: 99999;\"></div>";
            $("body").append(divid);
        }
        if (exitcontent != undefined) {
            if ($("#" + ct).html() == undefined || $("#" + ct).html() == null) {
                $("body").append(exitcontent);
            }
            else {
                $("#" + ct).show();
            }
        }
    },
    Show: function(ct, content, exitcontent) {
        comm.MarkDiv.CreateMark(ct, exitcontent);
        var bH = $("body").height();
        var bW = $("body").width();
        var objWH = comm.MarkDiv.getObjWh(ct);
        $("#fullbg").css({ width: parseInt(bW), height: parseInt(bH), display: "block", opacity: 0.5, zindex: 99999 });
        var tbT = objWH.split("|")[0] + "px";
        var tbL = objWH.split("|")[1] + "px";
        $("#" + ct).css({ top: tbT, left: tbL, display: "block" });
        $(window).scroll(function() { comm.MarkDiv.resetBg(ct) });
        $(window).resize(function() { comm.MarkDiv.resetBg(ct) });
        $("#fullbg").show();
        $("#" + ct).show();
    },
    Close: function(ct) {

        $("#fullbg").fadeOut(2000);
        $("#" + ct).fadeOut(2000);
    },
    getObjWh: function(obj) {
        var st = document.documentElement.scrollTop; //滚动条距顶部的距离
        var sl = document.documentElement.scrollLeft; //滚动条距左边的距离
        var ch = document.documentElement.clientHeight; //屏幕的高度
        var cw = document.documentElement.clientWidth; //屏幕的宽度
        var objH = $("#" + obj).height(); //浮动对象的高度
        var objW = $("#" + obj).width(); //浮动对象的宽度
        var objT = Number(st) + (Number(ch) - Number(objH)) / 2;
        var objL = Number(sl) + (Number(cw) - Number(objW)) / 2;
        return objT + "|" + objL;
    },
    resetBg: function(obj) {
        var fullbg = $("#fullbg").css("display");
        if (fullbg == "block") {
            var bH2 = $("body").height();
            var bW2 = $("body").width() + 16;
            $("#fullbg").css({ width: bW2, height: bH2 });
            var objV = comm.MarkDiv.getObjWh(obj);
            var tbT = objV.split("|")[0] + "px";
            var tbL = objV.split("|")[1] + "px";
            $("#" + obj).css({ top: tbT, left: tbL });
        }
    }
};
comm.Admin.CheckAdmin();

