﻿/*
*  Copyright (c) 2009 iPow(www.iPow.cn)
*/

jQuery.fn.cssradio = function (A) {
    A = jQuery.extend({ val: null, name: "", over: "lblRadio2", out: "lblRadio1" }, A);
    return this.each(function () {
        var B = $(this); if (A.val == B.val()) { B.next().attr("class", A.over); B.attr("checked", "checked") } B.next().click(function () {
            $("input[name='" + A.name + "']").next().attr("class", A.out); B.next().attr("class", A.over); B.attr("checked", "checked")
        })
    })
};
jQuery.extend(jQuery.easing, { easeInOutExpo: function (E, B, C, D, A) {
    if (B == 0) return C; if (B == A) return C + D; if ((B /= A / 2) < 1) return D / 2 * Math.pow(2, 10 * (B - 1)) + C;
    return D / 2 * (-Math.pow(2, -10 * --B) + 2) + C
}, easeInCirc: function (E, B, C, D, A) { return -D * (Math.sqrt(1 - (B /= A) * B) - 1) + C },
    easeInSine: function (E, B, C, D, A) { return -D * Math.cos(B / A * (Math.PI / 2)) + D + C }, easeInCubic: function (E, B, C, D, A) {
        return D * (B /= A) * B * B + C
    }, easeOutCubic: function (E, B, C, D, A) { return D * ((B = B / A - 1) * B * B + 1) + C }
});
function iPowUi() {
    this.developer = "\u6df1\u5733\u5e02\u4e92\u52a8\u529b\u79d1\u6280\u6709\u9650\u516c\u53f8\uff08http://www.ipow.cn\uff09"
}
iPowUi.prototype = {
    init: function () {
        this.guestbook();
        var A = 1;
        if (location.hash != "")
            A = location.hash.replace("#", "");
        this.loadbook(A)
    }, guestbook: function () {
        var A = this;
        $("input[name='raSex']").cssradio({ val: "GG", name: "raSex" });
        $("#btnShowBook").unbind().click(function () {
            $("#guestPanel").slideDown()
        });
        $("#btnCloseAddBook").unbind().click(function () {
            $("#guestPanel").slideUp()
        }); $("#opAddGuest").unbind().click(function () {
            A.addbook()
        });
        $("#btnClear").unbind().click(function () {
            A.clearInput();
            $("#txtUserName").focus()
        })
    }, addbook: function () {
        var E = this
    , C = $("#txtUserName").val().trim()
    , F = $("#txtTitle").val().trim()
    , G = $("input[name='raSex']:checked").val().trim()
    , D = $("#txtFrom").val().trim()
    , B = $("#txtCommContent").val().trim()
    , A = $("#txtPhone").val().trim();
        if (C == "") {
            alert("\u8bf7\u8f93\u5165\u60a8\u7684\u6635\u79f0\uff1a\uff09");
            $("#txtUserName").focus();
            return false
        } if (D == "") {
            alert("\u8bf7\u8f93\u5165\u60a8\u6765\u81ea\u54ea\u91cc\uff1f\n\u4e0d\u77e5\u9053\u5c31\u5199\u706b\u661f\uff1a\uff09");
            $("#txtFrom").focus();
            return false;
        } if (A == "") {
            alert("\u8bf7\u8f93\u5165\u60a8\u8054\u7cfb\u65b9\u5f0f\uff1a\uff09");
            $("#txtPhone").focus();
            return false
        } if (F == "") {
            alert("\u8bf7\u8f93\u5165\u7559\u8a00\u4e3b\u9898\uff1a\uff09");
            $("#txtTitle").focus();
            return false
        } if (B == "") {
            alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u7559\u8a00\u5185\u5bb9\uff1a\uff09");
            $("#txtCommContent").focus();
            return false
        }
        /*
        添加留言
        */
        $("#guestPanel").slideUp("fast", function () {
            $.ajax({
                type: "POST",
                url: "/admin/messagemanage/VisitorMessage.aspx?type=AddMessage&temp" + Math.random(),
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                data: "txtTitle=" + F + "&txtName=" + C + "&txtContent=" + B + "&txtEmail=" + A + "&txtSex=" + G + "&txtAddress=" + D + "",
                dataType: "string",
                success: function (a) {
                    if (a != null) {
                        if (a.toString() == "1") {
                            alert("留言成功，请等待管理员的回复！");
                            E.loadbook(1)
                            E.clearInput();
                        } else {
                            alert("对不起，服务器繁忙，请您稍后再试！");
                        }
                    }
                }
            })
        })
    },
    /*
    显示游客留言
    */
    loadbook: function (A) {
        var C = this, B = "/admin/messagemanage/ShowVisitorMessage.aspx?type=getComm&pageIndex=" + A + "&pageSize=5&temp" + Math.random();
        $.getJSON(B, function (E) {
            C.pageUi(A, E.PageTotal);
            var B = "", F = parseInt(A - 1) * 10 + 1,
            D = "#a9a9a9";
            $.map(E.List, function (E) {
                D = "#a9a9a9";
                var C = "", A = "";
                D = "#f3c200";
                C = "<a href=\"javascript:;\" rel=\"reply" + E.MessageID + "\"></a>";
                A = "<span class=\"reply\"  id=\"reply" + E.MessageID + "\"><h4><strong>\u82cf\u5dde\u4e50\u56ed</strong><em>\u56de\u590d\u4e8e\uff1a" + E.ReplyData + "</em></h4><p>" + E.ReplyContent + "</p></span>"
                B += "<li><h2 id=\"title" + E.MessageID + "\" style=\"background-color:" + D + ";\">\u4e3b\u9898\uff1a" + E.MessageTitle + "</h2>";
                B += A; B += "<span class=\"bookinfo\" id=\"guestbook" + E.MessageID + "\"><h4><em>\u6765\u81ea</em><strong>" + E.VisitorAddress + "\u7684" + E.VisitorName + "</strong><em>\u53d1\u5e03\u4e8e\uff1a" + E.VisitorData + "</em>" + C + "</h4><p>" + E.MessageContent + "</p></span></li>";
                F++
            });
            $("#bookList").html(B);
            C.bindReplay()
        })
    }, pageUi: function (A, D) {
        var C = this, B = UiPage(A, D); $("#guestbookPage").html(B); $("#guestbookPage1").html(B);
        $("#guestbookPage a").unbind().click(function () {
            var B = $(this).text(), D = A; switch (B) {
                case "\u4e0a\u4e00\u9875": D = parseInt(D - 1); C.loadbook(D); break; case "\u4e0b\u4e00\u9875": D = parseInt(D + 1);
                    C.loadbook(D); break; default: C.loadbook(parseInt($(this).text())); break
            }
        }); $("#guestbookPage1 a").unbind().click(function () {
            var B = $(this).text(), D = A; switch (B) {
                case "\u4e0a\u4e00\u9875": D = parseInt(D - 1); C.loadbook(D);
                    break; case "\u4e0b\u4e00\u9875": D = parseInt(D + 1); C.loadbook(D); break; default: C.loadbook(parseInt($(this).text())); break
            }
        })
    }, bindReplay: function () {
        var A = this; $("#bookList li a").bind("mouseenter", function () {
            var G = $(this).attr("rel"), E = $("#" + G).attr("id"), C = $("#" + G).next(), F = C.attr("id"), H = E.replace("reply", "title");
            $("#" + H).css("background-color", "#f34d00");
            var D = document.getElementById("" + F + "").scrollHeight > document.getElementById("" + F + "").offsetHeight ? document.getElementById("" + F + "").scrollHeight : document.getElementById("" + F + "").offsetHeight,
        B = document.getElementById("" + E + "").scrollHeight > document.getElementById("" + E + "").offsetHeight ? document.getElementById("" + E + "").scrollHeight : document.getElementById("" + E + "").offsetHeight;
            if (B > D) $(C).animate({ height: B + "px"
            }, 200, function () {
                A.changeM(C, E, D, B)
            }); else A.changeM(C, E, D, B)
        })
    }, changeM: function (C, D, B, A) {
        if (A > B) {
            $("#" + D).css("margin-bottom", -A + "px"); $("#" + D).unbind(); $("#" + D).bind("mouseleave", function () {
                $(this).animate({
                    height: 0 + "px"
                }, 300, "easeOutCubic", function () { $(C).animate({ "height": B + "px" }, 200) })
            });
            $("#" + D).animate({ height: A + "px" }, 300, "easeInCubic")
        } else {
            $("#" + D).css("margin-bottom", -B + "px");
            $("#" + D).unbind(); $("#" + D).bind("mouseleave", function () { $(this).animate({ height: 0 + "px" }, 300, "easeOutCubic") });
            $("#" + D).animate({ height: B + "px" }, 300, "easeInCubic")
        }
    }, clearInput: function () {
        $("#txtUserName").val("");
        $("#txtTitle").val(""); $("#txtFrom").val(""); $("#txtCommContent").val(""); $("#txtPhone").val("")
    }
};
function getAllPosition(D) {
    var A = []; if (D != undefined) {
        var E = $(D).offset(); A.offLeft = E.left; A.offTop = E.top
    } A.offWidth = document.documentElement.clientWidth; A.offHeight = document.documentElement.clientHeight;
    var C, B, F; if (typeof window.pageYOffset != "undefined") { C = window.pageYOffset; B = 0 }
    else if (typeof document.compatMode != "undefined" && document.compatMode != "BackCompat") {
        C = document.documentElement.scrollTop; B = document.documentElement.scrollLeft
    } else if (typeof document.body != "undefined") {
        C = document.body.scrollTop; B = document.body.scrollLeft
    } if (A.offWidth > 1003) F = parseFloat(A.offWidth - 1003) / 2; else F = 0; A.scrTop = C;
    A.scrLeft = B; A.offsetLeft = F; return A
} jQuery.fn.backTop = function (A) {
    A = jQuery.extend({}, A); return this.each(function () {
        $scrollDom = $(this);
        var B = function () {
            A($scrollDom); loadOrbitFlash();
            var B = insertFlash("/flash/tip.swf", "100%", "100%", "tipFlash"); $("#tipFlash").html(B);
            $(window).scroll(function () { A($scrollDom) }); $(window).resize(function () { A($scrollDom) })
        }, A = function (D) {
            try {
                var B = getAllPosition(D), E = (B.offWidth - 1003) / 2 + 880, C = 0; D.css({ left: E }).show();
                if (parseInt(B.scrTop) < 450) D.css({ top: 450 }); else { C = parseInt(B.scrTop); D.css({ top: C }) }
            } catch (A) { }
        }; B()
    })
}; function insertFlash(C, B, E, A) {
    var D = "";
    D += "<object classid=\"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000\" id=\"" +
    A + "\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" border=\"0\" width=\"" +
    B + "\" height=\"" + E + "\">"; D += "<param name=\"movie\" value=\"" + C + "\">";
    D += "<param name=\"quality\" value=\"high\"> ";
    D += "<param name=\"wmode\" value=\"transparent\">"; D += "<param name=\"menu\" value=\"false\">";
    D += "<embed src=\"" + C + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" name=\""
                                      + A + "\" width=\"" + B + "\" height=\"" + E + "\" quality=\"High\" wmode=\"transparent\">";
    D += "</embed>"; D += "</object>"; return D
} jQuery.fn.showTrip = function (A) {
    A = jQuery.extend({ fx: "easeInSine", speed: 300, startItem: "no", setOnClick: true
    }, A || {}); return this.each(function () {
        var P = this,
         O = location.pathname + location.search + location.hash, L = new Object, E, Q, J = jQuery("ul li[class!=noPlan]", this),
         F = jQuery("ul li", this).size(); jQuery("ul", this).css("width", parseInt(F * 110) + "px");
        jQuery("#ph ul").css("width", parseInt(F * 620) + "px"); var H = 0, D = location.hash,
                                        B = jQuery("#ph li[rel='" + D + "']").length, K = 0; if (A.startItem == "no" && D != "" && B > 0) {
            var I = ""; L = jQuery("ul li a[href$=\"" + D + "\"]", this).parent("li");
            H = (jQuery("ul li", this).index(L)); I = D; A.startItem = H; G(I)
        } else {
            A.startItem = iPlan.index; H = iPlan.index; G(iPlan.name)
        } var M = (6 - F + H);
        H = M < 1 ? H - 1 : H - M; $("#phlist").iRoll({ start: H }); var N = A.startItem;
        if (L.length == 0 && A.startItem == "no") L = jQuery("ul li a[href$=\"" +
                                             location.pathname.substring(location.pathname.lastIndexOf("/") + 1) + location.search + location.hash + "\"]", this).parent("li");
        if (L.length == 0 || A.startItem != "no") {
            if (A.startItem == "no") A.startItem = 0; L = jQuery(J[A.startItem])
        } Q = jQuery("ul li.selectedPlan", this)[0] || jQuery(L).addClass("selectedPlan")[0];
        E = jQuery("<li class=\"backPlan\"><ins></ins></li>").appendTo($("ul", this));
        E.css("margin-left", parseInt(N) * 110 + "px"); J.click(function (A) {
            jQuery(Q).removeClass("selectedPlan"); Q = this; N = jQuery("ul li", P).index(Q);
            if (jQuery("a", this).html() != null) { var B = jQuery("a", Q).attr("href"); R(N, Q, B) }
        });
        function R(B, C, D) {
            var F = parseInt(B) * 110; E.stop().animate({ marginLeft: F }, A.speed, A.fx, function () {
                jQuery(C).addClass("selectedPlan"); G(D)
            })
        } function G(D) {
            var A = $("#ph"), B = jQuery("ul li[rel='" + D + "']", A);
            B = jQuery("ul li", A).index(B); C(B)
        } function C(B) {
            var C = parseInt(B * 620); jQuery("#ph ul").animate({
                marginLeft: -C
            }, A.speed, "easeInOutExpo", function () { })
        }
    })
};
$.fn.iRoll = function (A) {
    A = $.extend({ btnPrev: "#rollLeft", btnNext: "#rollRight", speed: 200, easing: "easeInOutExpo", visible: 5, start: 0, scroll: 1, beforeStart: null, afterEnd: null,
        width: 110
    }, A || {}); return this.each(function () {
        var H = false, K = 0, D = $(this), M = $("#phulshow ul"), N = $("#phulshow ul li"), C = A.visible, Q = N.size(), P = A.start,
     F = A.width * A.visible, R = A.width * Q,
     J = document.getElementById("phulshow").scrollWidth > document.getElementById("phulshow").offsetWidth ? document.getElementById("phulshow").scrollWidth : document.getElementById("phulshow").offsetWidth,
      O = parseFloat(parseInt(J - 550) / parseInt(595 - 50)); if (J <= 550) { $("#ldt").hide(); return false } else $("#ldt").show();
        var L = 595 - 50, E = parseFloat(550 / (6 * O));
        if (A.btnPrev) $(A.btnPrev).click(function () { return B(P - A.scroll) }); if (A.btnNext) $(A.btnNext).click(function () {
            return B(P + A.scroll)
        });
        function I() { return N.slice(P).slice(0, A.visible) } if (A.start > 0) { P = A.start; B(P + A.scroll) } if (P == 0) $(A.btnPrev).css("background-position", "left top");
        function B(B) {
            if (!H) {
                if (A.beforeStart) A.beforeStart.call(this, I()); if (B < 0 || B > Q - A.visible) return; else P = B; H = true;
                M.animate({ marginLeft: -(P * A.width) }, A.speed, A.easing, function () {
                    K = P * 110 / O; $("#scrSlide").animate({ marginLeft: K }, 100, "easeInCirc");
                    if (A.afterEnd) A.afterEnd.call(this, I()); H = false; S()
                })
            } return false
        } function S() {
            $(A.btnPrev).css("background-position", "-15px top");
            $(A.btnNext).css("background-position", "-15px top"); $(P - A.scroll < 0 && A.btnPrev).css("background-position", "left top");
            $(P + A.scroll > Q - A.visible && A.btnNext).css("background-position", "left top")
        } if ($.browser.msie) document.execCommand("BackgroundImageCache", false, true);
        $("#scrSlide").bind("mousedown", function (B) {
            var A = this, D = B.pageX, C = parseInt($(this).css("margin-left")); $(document).mousemove(function (A) {
                K = parseInt(C + A.pageX - D); G()
            }); $(document).mouseup(function () { $(document).unbind() }); return false
        }); function G() {
            if (K < L && K > 0) K = K;
            else if (K > L) K = L; else if (K < 0) K = 0; $("#scrSlide").css("margin-Left", "" + K + "px"); var A = parseInt(O * K);
            $("#phulshow ul").css("margin-left", -A + "px"); P = Math.ceil(A / 101); S()
        }
    })
};
function UiPage(A, C) {
    var B = ""; if (A < 1) A = 1; if (A > C) A = C; if (A <= 1);
    else B += "<a href=\"javascript:;\" class=\"prev\" id=\"turnPrev\">\u4e0a\u4e00\u9875</a>"; var D;
    if (A <= 10 && C <= 10) {
        for (D = 1; D <= C; D++) if (D == A) B += "    <span>" + D + "</span>";
        else B += "<a href=\"#" + D + "\" id=\"bookpage" + D + "\">" + D + "</a>"
    } else if (C >= 10 && A <= 5) {
        for (D = 1; D <= 10; D++) if (D == A) B += "    <span>" + D + "</span>"; else B += "<a href=\"#" +
   D + "\" id=\"bookpage" + D + "\">" + D + " </a>"
    } else if ((A + 5) <= C) {
        for (D = (A - 4);
    D <= (A + 5); D++) if (D == A) B += "    <span>" + D + "</span>"; else B += "<a href=\"#" +
    D + "\" id=\"bookpage" + D + "\">" + D + " </a>"
    } else for (D = (A - 4); D <= C; D++)
        if (D == A) B += "    <span>" + D + "</span>"; else B += "<a href=\"#" + D + "\" id=\"bookpage" + D + "\">" +
     D + " </a>"; if (A >= C); else B += "<a href=\"javascript:;\" class=\"next\" id=\"turnNext\">\u4e0b\u4e00\u9875</a>"; return B
} jQuery.fn.iNews = function (A) {
    return this.each(function () {
        var A = this; $("li", A).bind("mouseenter", function () {
            var D = $(this).attr("id"), C = $(this).attr("class"); if (C == "") {
                var B = document.getElementById("" + D + "").scrollHeight > document.getElementById("" + D + "").offsetHeight ? document.getElementById("" + D + "").scrollHeight : document.getElementById("" + D + "").offsetHeight;
                $("li", A).removeClass("current"); $(this).addClass("current")
            }
        })
    })
}; jQuery.fn.FontZoom = function (A) {
    A = jQuery.extend({ oClass: ".aZoom", cClass: ".thenewscon", dSize: "\u4e2d" }, A); return this.each(function () {
        var C = $(this), D = $(A.cClass, C), B = $(A.oClass, C); $(B).click(function () {
            var A = $(this).text(); $(B).css({ "font-size": "12px", "font-weight": "normal" });
            $(this).css({ "font-size": "14px", "font-weight": "700" }); switch (A) {
                case "\u5927": $("*", D).css({ "font-size": "14px", "line-height": "24px" });
                    break; case "\u4e2d": $("*", D).css({ "font-size": "12px", "line-height": "22px" }); break; case "\u5c0f": $("*", D).css({
                        "font-size": "10px", "line-height": "20px"
                    });
                    break; default: $("*", D).css({ "font-size": "12px", "line-height": "22px" }); break
            }
        }); $("a[rel='" + A.dSize + "']", C).trigger("click")
    })
};
jQuery.fn.iTip = function (A) {
    A = jQuery.extend({ tm: "", tc: "", tw: "", tclass: "", callback: function () { } }, A);
    return this.each(function () {
        var E = $("#" + A.tm), C = A.tclass, B = location.hash; $("li a", E).unbind().click(function (B) {
            $("li a", E).removeClass(C); $(this).addClass(C); A.callback.apply(this, [B, this])
        }); if (B != "") {
            var D = jQuery("li a[href$=\"" + B + "\"]", E); if (D.length > 0) D.trigger("click")
        }
    })
}; function iGuideTip() {
    var B = $("#tipMenu li a[class='abg']").parent(), A = $("#tipMenu li").index(B), C = parseInt(A) * 590;
    $("#tipContent").animate({ marginLeft: -C + "px" }, 200, "easeInOutExpo")
} function loadOrbitFlash() {
    var B = insertFlash("/flash/orbit1.swf", "100%", "100%", "orbitf1"), C = insertFlash("/flash/orbit2.swf", "100%", "100%", "orbitf2"),
          A = insertFlash("/flash/orbit3.swf", "100%", "100%", "orbitf3"); $("#lbFlash").html(B); $("#lmFlash").html(C); $("#lrFlash").html(A)
}
