/// <reference path="jquery/jquery126.js" />
/// <reference path="jquery/JQuery.Intellisense.js" />

$(function() {
    addCount.json("Sys/AddSiteCount");
    $("#topinfo").html("今天是：" + getDateTimeInfo());
    window.setInterval(function() {
        $("#topinfo").html("今天是：" + getDateTimeInfo());
    }, 1000);

    MM_preloadImages('images/menu2_r1_c1.jpg', 'images/menu2_r1_c2.jpg', 'images/menu2_r1_c3.jpg', 'images/menu2_r1_c4.jpg', 'images/menu2_r1_c5.jpg', 'images/menu2_r1_c6.jpg', 'images/menu2_r1_c7.jpg', 'images/menu2_r1_c8.jpg', 'images/menu2_r1_c9.jpg');
    $("#banner").html(getFlash("images/top.swf", "950px", "163px"));
    $("#topmenu a").focus(function() { this.blur() });
});

function addCount(json) {
    $("#couonter").html("您是本站第 <span>" + json.Count + "</span> 位访问者。");
}

function logined() {
    return $.cookie("UserID") == null ? false : true;
}

function seachArticle() {
    var word = $("#keyword").val();
    if (word != "") {
        if (document.location.href.indexOf("souarticle.shtml") == -1)
            document.location = "souarticle.shtml?keyword=" + escape(word);
        else {
            _keyword = word;
            doPages();
        }
    }
}

Function.prototype.json = function(jsonurl, data) {
    var callback = this;
    var args = arguments;
    var method = "GET";
    var postPras = "";
    var arrPras = jsonurl.split("/");
    if (jsonurl.indexOf("/") > -1) {
        if (arrPras.length < 2) {
            alert("参数格式错误！");
            return;
        }
        postPras = "mod=" + arrPras[0] + "&action=" + arrPras[1];
        for (var i = 2; i < arrPras.length; i++) postPras += "&" + arrPras[i];
    }
    if (data && data != null && data != "") method = "POST";
    $.ajax({
        url: "api/?" + postPras,
        type: method,
        data: data,
        cache:false,
        dataType: 'json', cache: false,
        error: function(xhr) { },
        success: function(json) {
            var args2 = new Array();
            args2[0] = json;
            for (var i = 2; i < args.length; i++) args2[i - 1] = args[i];
            callback.apply(this, args2);
        }
    });
};





function getDateTimeInfo() {
    //取当前日期、时、分、秒
    today = new Date();
    var hours = today.getHours();
    var minutes = today.getMinutes();
    var seconds = today.getSeconds();
    //将小时按12小时存储
    var timeValue = (hours >= 12) ? "下午" : "上午";
    timeValue += ((hours > 12) ? hours - 12 : hours) + "时";
    timeValue += minutes + "分";
    timeValue += seconds + "秒";
    function initArray() {
        this.length = initArray.arguments.length;
        for (var i = 0; i < this.length; i++)
        //依次读取星期日至星期六7个中文名称
            this[i + 1] = initArray.arguments[i];
    }
    //建立一个数组，存储星期日到星期六7个中文名称
    var d = new initArray(
	"星期日",
	"星期一",
	"星期二",
	"星期三",
	"星期四",
	"星期五",
	"星期六");
    //格式化输出,注意这里的getFullYear()不能为getYear()，否则在Firefox将显示不太正常

    return today.getFullYear() + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日" + " " + d[today.getDay() + 1] + " " + timeValue;
}


