﻿/// <reference path="jquery_v1.6.2.js" />

(function ($) {
    //栏目导航
    menu = function () {
        var menuid = $("#menuID").val();
        var menu_f = $(".menu_line");
        var menu_t = $(".menu_two");

        menu_f.each(function (i) {
            $(this).click(function () {
                $(this).addClass("menu_ico");
                $(".menu_line:not(.menu_line:eq(" + i + "))").removeClass("menu_ico");

                $(".menu_two:eq(" + i + ")").css("display", "block");
                $(".menu_two:not(.menu_two:eq(" + i + "))").css("display", "none");

            });
        });
        $(".menu_line:eq(" + menuid + ")").addClass("menu_ico");
        $(".menu_two:eq(" + menuid + ")").css("display", "block");

        $(".menu_two div").each(function () {
            $(this).mouseover(function () { $(this).animate({ paddingLeft: "10px" }, 150); });
            $(this).mouseout(function () { $(this).animate({ paddingLeft: "0px" }, 150); });
        });

        $(".menu_two div a").each(function () {
            $(this).mouseover(function () { $(this).css("color", "#0a1237"); });
            $(this).mouseout(function () { $(this).css("color", "#aaaaaa"); });
        });
    }

    //新闻 通知 常见问题 问答

    news = function () {
        var new_btns = $(".btns_panel .btns");
        new_btns.each(function (i) {
            $(this).click(function () {
                $(".btns_content").html("<div style='width: 240px; text-align: center; line-height: 60px; color: #aaaaaa;'>正在加载数据......</div>");
                $(this).addClass("btns_hover");
                $(".btns_panel .btns:not(.btns_panel .btns:eq(" + i + "))").removeClass("btns_hover");
                var name = $(this).attr("title");
                setTimeout(function () {
                    $.ajax({
                        type: "post",
                        url: "index.aspx/LoadNew",
                        contentType: "application/json",
                        dataType: "json",
                        async: false,
                        data: "{name:'" + name + "'}",
                        success: function (r) {
                            var dt = jQuery.parseJSON(r.d);
                            var table = "<table cellpadding='0' cellspacing='0' border='0'>";
                            $.each(dt, function (i, item) {
                                var title = item.title;
                                if (title.length > 12) {
                                    title = title.substring(0, 12) + "...";
                                }
                                if (i == 0) {
                                    $("#first_new").text(item.title.length > 25 ? item.title : item.title.substring(0, 25));
                                }
                                table += "<tr>";
                                if (name = "新 闻") {
                                    table += "<th><a href='#' onclick=shownew(" + item.ID + ",'" + item.title + "') >" + title + "</a></th>";
                                } else {
                                    table += "<th><a href='#' onclick=shownew(" + item.ID + ",'" + item.title + "') >" + title + "</a></th>";
                                }

                                table += "<td>" + ChangeDateFormat(item.insertdate) + "</td>";
                                table += "</tr>";



                            });
                            table += "</table>";
                            $(".btns_content").html(table);
                        },
                        error: function (data, status, r) {
                            alert(r);
                        }
                    });
                }, 500);
            });
        });

        $(".btns_panel .btns:first").click();
    }

    //展会图片
    show = function () {
        var showImg = $(".show_panel ul .img");
        showImg.each(function () {
            $(this).fadeTo(500 + (3000 * (Math.random())), 0.4).hover(function () {
                $(this).fadeTo('slow', 1);
                return false;
            }, function () {
                $(this).fadeTo('slow', 0.4);
                return false;
            });
        });
    }

    //banner
    banner = function () {
        $(".banner_col").each(function () {
            $(this).mouseover(function () { $(this).animate({ lineHeight: "18px" }, 300); $(this).children().css("color", "#ffffff"); });
            $(this).mouseout(function () { $(this).animate({ lineHeight: "14px" }, 300); $(this).children().css("color", "#bd8dc8"); });
        });
    }


    //获取参数
    request = function (paras) {
        var url = location.href;
        var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
        var paraObj = {}
        for (i = 0; j = paraString[i]; i++) {
            paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
        }
        var returnValue = paraObj[paras.toLowerCase()];
        if (typeof (returnValue) == "undefined") {
            return "";
        } else {
            return returnValue;
        }
    }

    //转化日期
    ChangeDateFormat = function (cellval) {
        var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
        var year = date.getFullYear() - 2000;
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        return "[" + year + "." + month + "." + currentDate + "]";
    }


    shownew = function (id, title) {
        $(".div_mask").fadeTo("show", 0.6);
        $.ajax({
            type: "post",
            contentType: "application/json",
            dataType: "json",
            url: "notice.aspx/GetContent",
            async: false,
            data: "{id:'" + id + "'}",
            success: function (r) {
                var html = "<div id='div_show' style='position:absolute;z-index:1000; '>";
                html += "<div style='width:514px; margin-left:3px; height:1px; overflow:hidden; background-color:#0a1237;'></div>";
                html += "<div style='width:516px; margin-left:2px; height:1px; overflow:hidden; background-color:#0a1237;'></div>";
                html += "<div style='width:518px; margin-left:1px; height:1px; overflow:hidden; background-color:#0a1237;'></div>";
                html += "<div style='width:500px; padding:10px; background-color:#0a1237;'>";
                html += "<div style='color:#e60012; text-align:center; line-height:25px;'>" + title + "</div>";
                html += "<div style='color:#b3d465; line-height:18px;'>" + r.d + "</div>";
                html += "<div class='div_close' style='text-align:center; line-height:30px; width:80px; margin-left:210px; margin-top:10px; cursor:pointer;color:#7d0000;'>关闭</div>";
                html += "</div>";
                html += "<div style='width:518px; margin-left:1px; height:1px; overflow:hidden; background-color:#0a1237;'></div>";
                html += "<div style='width:516px; margin-left:2px; height:1px; overflow:hidden; background-color:#0a1237;'></div>";
                html += "<div style='width:514px; margin-left:3px; height:1px; overflow:hidden; background-color:#0a1237;'></div>";
                html += "</div>";
                $(html).prependTo($("body"));
                $("#div_show").css({ top: ($(window).height() - $("#div_show").height() - 20) / 2, left: ($(window).width() - 520) / 2 });


                $(".div_close").click(function () {
                    $(".div_mask").css("display", "none");
                    $("#div_show").remove();
                });
            },
            error: function (data, status, r) {
                jAlert(r, "错误信息");
            }
        });
    }


})(jQuery);
