﻿
var ROOT = "";
$(document).ready(function () {

    setBlackoutSize();

    $(window).bind('resize', function () {
        if (resizeTimer)
            clearTimeout(resizeTimer);

        resizeTimer = setTimeout(setBlackoutSize, 100);
    });

    $("#page-content-holder").find("a").each(function () {
        if ($(this).hasClass("load-overlay")) {
            $(this).click(function () { return loadContent(this.href, 'overlay-content'); });
        }
    });
});

toggleDiv = function (divId) {
    var obj = document.getElementById(divId);

    if (obj.style.display == "block")
        obj.style.display = "none";
    else
        obj.style.display = "block";
}

showDiv = function (divId) {
    $("#" + divId).fadeIn('slow');

    return false;
};

hideDiv = function (divId) {
    $("#" + divId).fadeOut('slow');

    return false;
};

toggleContent = function (divId, aObj) {
    if ($(aObj).html() == "[+]") {
        $("#content" + divId).slideToggle("slow");
        $(aObj).html("[-]");
    } else {
        $("#content" + divId).slideToggle("slow");
        $(aObj).html("[+]");
    }
};

closeOverlay = function (sId) {
    $("#overlay-blackout-holder").fadeOut('slow');
    $("#" + sId).fadeOut('slow');

    return false;
};

setBlackoutSize = function () {

    var iTop = $(document).scrollTop();

    if ($(window).height() > $(document).height())
        $("#overlay-blackout-holder").css("height", $(window).height());
    else
        $("#overlay-blackout-holder").css("height", $(document).height());

    $("#overlay-blackout-holder").css("top", iTop);

    centerMessageBox($("#overlay-holder"));
}

centerMessageBox = function ($msgBox) {
    var iLeft = (($(window).width() / 2) - ($msgBox.width() / 2));
    var iTop = (($(window).height() / 2) - (($msgBox.height() / 2) + 50)) + $(document).scrollTop(); ;

    if (iTop < 10) { iTop = 25; }

    $msgBox.css("left", iLeft);
    $msgBox.css("top", iTop);
}


