﻿var sTop, sTopBottom;
var bodyHeight; 
$(window).scroll(function() {    
    var bodyTop = $(document).scrollTop();
     var y1;
     if ($.browser.msie && $.browser.version=="6.0") {
        y1 = bodyTop + $(window).height() - $(".tan").height() - 5;
      }else{
        y1 = bodyTop + parseInt(sTop);
     }

    var y2 = bodyTop + parseInt(sTopBottom);
    $(".tan").css("top", y1); 
    $("#tan_title_bottom").css("top", y2);
});
$(function() {
   $(".tan").show();
    sTop = $(".tan").offset().top;
    $(".tan").hide();
    sTopBottom = $("#tan_title_bottom").offset().top;
    bodyHeight = $(document).height();

    $("#tan_title_bottom .tan_e").click(function() {
        $(".tan").show();
    });

    $(".tan .tan_e").click(function() {
        $(".tan").hide();
    });
});

function AddToDuiBi(itemid, username) {
    var url = "handler/duibi.ashx?action=add&itemid=" + itemid + "&username=" + encodeURI(encodeURI(username)) + "&t=" + new Date().getTime();
    $.get(url, function(data) {
        if (data.indexOf("div") == -1) {
            alert(data);
        } else {
            $(".tan").html(data);
            $(".tan").show();
        }
    });
}

function ClearDuiBi(username) {
    var url = "handler/duibi.ashx?action=clear&username=" + encodeURI(encodeURI(username)) + "&t=" + new Date().getTime();
    $.get(url, function(data) {
        $(".tannr").html("");
        $(".tan_g").hide();
        $(".tan").hide();
    });
}

function Remove(id,username) {
    var url = "handler/duibi.ashx?action=remove&itemid=" + id + "&username=" + encodeURI(encodeURI(username)) + "&t=" + new Date().getTime();
    $.get(url, function(data) {
        $(".tan").html(data);
        if ($(".tan").find(".tannr").text() == "") {
            $(".tan").hide();
        }
    });
}
