﻿$(function() {

    var TopImgtimer;

    $(window).resize(function() {
        $("#TopImg").hide();
    });

    window.onscroll = function() {
        $("#TopImg").hide();
        clearTimeout(TopImgtimer);
        TopImgtimer = setTimeout("FixTopImg()", 100);

    };
    GetCount();
})

function FixTopImg() {

    var t = $(window).scrollTop();
    var offset = $("#TOP").offset();
    var window_height = (window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight));


    if (t > 400) {

        $("#TopImg").show();
        
        TopImgtop = t + (window_height / 2);
        var TopImgLeft = parseInt(offset.left) + 964 + 5;

        $("#TopImg").attr("style", "position:absolute; top:" + TopImgtop + "px;left:" + TopImgLeft + "px");
    }
    else {
        $("#TopImg").hide("slow");
    }
 }

function GetCount() {
    var UserID = $("#Hi_MasterPage_MeID").val();
    if (UserID == "0") return;
    $.get("/Exc/Exe.aspx?ac=GetCount", "", function(data) {

        var datas = data.split('|');
        var UserMsgCount = datas[0];
        var SysMsgCount = datas[1];
        var WhoAddMeCount = datas[2];
        $("#MasterSysMsgCount").text(SysMsgCount);
        $("#MasterUserMsgCount").text(UserMsgCount);
        $("#MasterWhoAddMeCount").text(WhoAddMeCount);
        if (UserMsgCount > 0) {
            $("#MasterUserMsgCount").parent().attr("style", "background-image: url('/images/icon/UserMsg_d.gif')");
        }
        else {
            $("#MasterUserMsgCount").parent().attr("style", "background-image: url('/images/icon/UserMsg.gif')");
        }

        if (SysMsgCount > 0) {
            $("#MasterSysMsgCount").parent().attr("style", "background-image: url('/images/icon/SysMsg_d.gif')");
        }
        else {
            $("#MasterSysMsgCount").parent().attr("style", "background-image: url('/images/icon/SysMsg.gif')");
        }

        if (WhoAddMeCount > 0) {
            $("#MasterWhoAddMeCount").parent().attr("style", "background-image: url('/images/icon/WhoAddMe_d.gif')");
        }
        else {
            $("#MasterWhoAddMeCount").parent().attr("style", "background-image: url('/images/icon/WhoAddMe.gif')");
        }
    })
    setTimeout("GetCount()", 1000 * 60 * 10);
}

function GetUserHistroy() {

    MsgNoButtomNoBackDivUnclose("#LayerMeHistroy", "我的浏览历史（保留10条记录）", "");
    $("#LayerMeHistroy_clone").width("550px");
    if ($("#LayerMeHistroy_clone").find('.tabcontent').html() == "") {
       
        $("#LayerMeHistroy_clone").find(".tabcontent").html("<div style='width:200px; margin:5px auto 5px auto'>正在读取，请稍等...<br><img src='/images/loading/load-page.gif'/></div>");
        $.post("/user/msg/FootListSimple.aspx?ac=GetMyFoot", "", function(data) {
       
            $("#LayerMeHistroy_clone").find(".tabcontent").html(data);
            $("#LayerMeHistroy_clone").find(".tabcontent").find("a").each(function() {

                $(this).attr("target", "_top");
            });
        })
    
     }
    
 }


