﻿
$(document).ready(function() {
    var ishow = $("#isshowpop").val();
    if (ishow == "True") {
        //弹出层
        var normalHeight = $("#pop").height();
        $("#pop").height(0);
        changeHeight(normalHeight);

    }
    //$("body").addClass("skin_3"); 
});

var hidenTimeer;
function changeHeight(normalHeight) {
    var poptimer;
    
    var item = $("#pop");
    var height = item.height() + 5;
    var width = item.width();

    var bodyTop = 0;
    if (typeof window.pageYOffset != 'undefined') {
        bodyTop = window.pageYOffset;
    }
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
        bodyTop = document.documentElement.scrollTop;
    }
    else if (typeof document.body != 'undefined') {
        bodyTop = document.body.scrollTop;
    }

    var bodyHeight = $(window).height();
    var bodyWidth = $(window).width();
    var itemTop = bodyTop + bodyHeight - height + 5 + "px";
    var itemLeft = bodyWidth - width + "px";
    $("#pop").css({ position: "absolute", display: "inline", height: height, top: itemTop, left: itemLeft, overflow: "hidden" });
    if (normalHeight >= height) {
        poptimer = setTimeout("changeHeight(" + normalHeight + ")", 1);
    }
    else {
        clearTimeout(poptimer);
        hidenTimeer = setTimeout("hidePop()", 30000)
    }
}
function hidePop() {
    $("#pop").fadeOut("slow");
    clearTimeout(hidenTimeer);
}
function closePop() {
    $("#pop").hide();
}

$(this).scroll(function() {
    // 页面发生scroll事件时触发
    var bodyTop = 0;
    var bodyLeft = 0;
    if (typeof window.pageYOffset != 'undefined') {
        bodyTop = window.pageYOffset;
        bodyLeft = window.pageXOffset;
    }
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
        bodyTop = document.documentElement.scrollTop;
        bodyLeft = document.documentElement.scrollLeft;
    }
    else if (typeof document.body != 'undefined') {
        bodyTop = document.body.scrollTop;
        bodyLeft = document.documentElement.scrollLeft;
    }
    
    var item = $("#pop");
    var height = item.height();
    var width = item.width();
    var bodyHeight = $(window).height();
    var bodyWidth = $(window).width();
    var itemTop = bodyTop + bodyHeight - height + 5 + "px";
    var itemLeft = bodyLeft + bodyWidth - width + "px";
    item.css("top", itemTop);
});
