﻿$(function () {
    $('a.lightboxImage').lightBox();
});

$(function () {
    $(window).resize(function () {
        ResizeMainDiv();
    });
});

//If any submit button is pressed, all form buttons will disable
$(function () {
    $("form").submit(function () {
        $(":submit").attr("disabled", "disabled");
    })
});

function ResizeMainDiv() {
    $("#footer").css("display", "block");
    var viewHeight = GetViewportHeight() - document.getElementById("footer").offsetHeight;
    var mainContentHeight = document.getElementById("mainContent").offsetHeight;
    var minHeight = 350;
    document.getElementById("main").style.height = Math.max(Math.max(viewHeight, mainContentHeight), minHeight) + "px";
}


function GetViewportHeight() {
    var viewportheight = 0;
    if (typeof window.innerHeight != 'undefined') {
        viewportheight = window.innerHeight
    }
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight != 0) {
        viewportheight = document.documentElement.clientHeight
    }
    else {
        viewportheight = document.getElementsByTagName('body')[0].clientHeight
    }
    return viewportheight;
}

function onHelpHover() {
    $("DIV#helpPopupMenu").fadeIn("fast");
    //document.getElementById('helpPopupMenu').style.display = "block";
}

function onHelpOut(e) {
    var toElement = GetEventTarget(e);
    if (toElement) {
        if (toElement.parentNode) {
            if (toElement.parentNode.parentNode) {
                if (toElement.parentNode.parentNode.parentNode &&
                            toElement.parentNode.parentNode.parentNode.id == "helpPopupMenu") {
                    return;
                }
            }
        }
    }
    $("DIV#helpPopupMenu").fadeOut("fast");
    //document.getElementById("helpPopupMenu").style.display = "none";
}

function GetEventTarget(e) {
    if (e.toElement)
        return e.toElement;
    else if (e.type == "mouseout")
        return e.relatedTarget;
    else
        return e.target;
}

function GetEventOrigin(e) {
    if (e.fromElement)
        return e.fromElement;
    else if (e.type == "mouseout")
        return e.target;
    else
        return e.relatedTarget;
}
