﻿
/*! _Layout.js

Contains scripts specific to the main layout page

*/

function CloseRegister() {
    $("#GuestRegister").slideUp();
    $("#dimmer").fadeOut();
}

function CloseResults() {
    $("#RegisterResults").hide();
    $("#dimmer").fadeOut();
}

$('[placeholder]').parents('form').submit(function () {
    $(this).find('[placeholder]').each(function () {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
            input.val('');
        }
    })
});

$(document).ready(function () {

    $("#GuestRegister").validate();

    $('#GuestRegister').ajaxComplete(function () {
        $("#GuestRegister").slideUp();
        $("#RegisterResults").show();
    });

    $("#RegisterResultsCloseButton").click(function () {
        CloseResults();
    });

    //Adjust height of overlay to fill screen when page loads
    $("#dimmer").css("height", $(document).height());
    $("#dimmer").css("filter", "alpha(opacity=80)");

    //When the link that triggers the message is clicked fade in overlay/msgbox
    $("#GuestRegisterButton").click(function () {
        $("#dimmer").fadeIn();
        $("#GuestRegister").slideDown();
        return false;
    });

    //When the message box is closed, fade out
    $("#GuestRegister .closeButton").click(CloseRegister);

    $("#RegisterResults .closeButton").click(CloseResults);

    $('[placeholder]').focus(function () {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
            input.val('');
            input.removeClass('placeholder');
        }
    }).blur(function () {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('placeholder')) {
            input.addClass('placeholder');
            input.val(input.attr('placeholder'));
        }
    }).blur();
});

//Adjust height of overlay to fill screen when browser gets resized
$(window).bind("resize", function () {
    $("#dimmer").css("height", $(window).height());
});    

