﻿function PopDivShow(id, title, content) {
    $("#testShowBig").hide();
    $("#demo").hide();
    $("#testShowMaster").hide(); 
    $("#pop_title").html(title);
    $("#pop_content").html(content);
    $("#shielding").show();
    setPo(id);
    $("#" + id).show();
}
function PopDivHide(id){
    $("#" + id).hide();
    $("#shielding").hide();
}

function PopDivShowBig(id, title, content) {
    $("#testShow").hide();
    $("#demo").hide();
    $("#testShowMaster").hide(); 
    $("#pop_titleBig").html(title);
    $("#pop_contentBig").html(content);
    setPo(id);
    setPo("testShowBigFollowing");
   // $("#testShowBigFollowing").show();
    $("#shielding").show();
    $("#" + id).show();
}
function PopDivHideBig(id) {
    $("#testShowBigFollowing").hide();
    $("#shielding").hide();
    $("#" + id).hide();
}

function PopDivShowMa(id) {
    setPo(id);
    $("#" + id).show();
}
function PopDivHideMa(id) {
    $("#" + id).hide();
}
 
function viewHeight() {
    var h = 0, D = document;
    if (document.compatMode != 'CSS1Compat') {
        h = D.body.clientHeight;
    } else {
        if (D.documentElement && D.documentElement.clientHeight) {
            h = D.documentElement.clientHeight;
        } else if (D.body && D.body.clientHeight) {
            h = D.body.clientHeight;
        }
    }
    return h;
} 

function setPo(id) {
    var distanceTop = $(window).scrollTop();
    var sH = viewHeight();
    var sW = viewWidth();
    var popH = $("#" + id).height();
    var popW = $("#" + id).width();
    var popTop = (sH - popH) / 2 + distanceTop;
    var popLeft = (sW - popW) / 2;
    if (sH > popH) {
        $("#" + id).css("top", popTop);
        $("#" + id).css("left", popLeft);
    }
    else
    {
        $("#" + id).css("top", distanceTop);
        $("#" + id).css("left", popLeft);
    }
}

$(window).scroll(function () {
    setPo("testShow")
    setPo("testShowBig")
})

    function viewWidth() {
    var w = 0, D = document;
    if (D.documentElement && D.documentElement.clientWidth) {
        w = D.documentElement.clientWidth;
    } else if (D.body && D.body.clientWidth) {
        w = D.body.clientWidth;
    }
    return w;
} 


