﻿
function SetMenu(page) {
    $("#nav-menu li a").addClass("menu");
    $("#nav-" + page).removeClass("menu");
    $("#nav-" + page).addClass("menuSelected");

    // Set no border for last menu item
    $("#nav-contact").attr("style", "border:0px");
}

function showModal(contentType, contentPath, rsvp, rsvpType, rsvpControl, width, height) {

    hideModal();

    if (contentType != "none") {

        if (contentType == "Link") {
            window.open(contentPath); 
        }
        else {
            if (contentType == "html") $("#modalContentHTML").load("../HTML/" + contentPath);
            else $("#modalContentHTML").html(contentPath);

            if (rsvp == "True") {
                $("#rsvpType").val(rsvpType);
                if (rsvpControl == "RsvpNoKids")
                    $("#modalRsvpDivNoKids").show();
                if (rsvpControl == "RsvpGolf")
                    $("#modalRsvpDivGolf").show();
                else
                    $("#modalRsvpDiv").show();
            }

            if (contentType == "appRequest") {
                $("#modalAppRequestDiv").show();
            }

            if (height == 0) height = 500;
            if (width == 0) width = 500;

            var topPadding = document.documentElement.clientHeight * .2;
            var clientWidth = document.documentElement.clientWidth;

            var screenTop = $(window).scrollTop();
            var top = Math.round(topPadding + screenTop);
            var left = Math.round(clientWidth / 2) - Math.round(width / 2);


            //$("#modalContent").attr("style", "height: 1px; width: 1px; left: " + left + "px; top: " + top + "px");
            $("#modalContent").attr("style", "height: " + height + "px; width: " + width + "px; left: " + left + "px; top: " + top + "px");
            //$("#modalContent").animate({ width: width, height: height }, 500);
            $("#modalBackground").show();
            //$("#modalContent").hide();
            $("#modal").show();
            $("#modalContent").fadeIn(1000);

            //$("#modal").fadeIn(1000);
            //setTimeout(ShowModalContent, 1000);
            //$("#modal").show();
        }
    }
}

function ShowModalContent() {
    $("#modalContent").show();
}

function hideModal() {

    $("#modalBackground").hide();
    $("#modal").hide();
    $("#modalContent").hide();
    $("#modalRsvpDiv").hide();
    $("#modalRsvpDivNoKids").hide();
    $("#modalRsvpDivGolf").hide();
    $("#modalAppRequestDiv").hide();
    $("#modalContentHTML").html = "";
}
