﻿

// fix up logon form
$(document).ready(function () {

    var fetchedForm = false;

    $("div.panel_button").click(function () {

        if (!fetchedForm) {
            $('#panel_contents').load('/account/logon?partial=true', function () {
                fetchedForm = true;
            });
        }

        $("div#panel").animate({
            height: "434px"
        })
            .animate({
                height: "434px"
            }, "fast");
        $("div.panel_button").toggle();

    });

    $("div#hide_button").click(function () {
        $("div#panel").animate({
            height: "0px"
        }, "fast");
    });

    $("#registerSubmit").live('click', function () {
        switch ($("#registerSelect").val()) {
            case 'Student':
                document.location.href = "/Register/PreStudent";
                break;
            case 'Parent':
                document.location.href = "/Register/PreParent";
                break;
            case 'Buddie':
                document.location.href = "/Register/Buddie";
                break;
            case 'Tutor':
                document.location.href = "/Register/Tutor";
                break;
            default:
                document.location.href = "/Register";
                break;
        }

    });



});


// mandatory validator
(function ($) {
    $.validator.unobtrusive.adapters.addBool("mandatory", "required");
} (jQuery));

// topnav

$(function(){

    $("ul.dropdown li").hover(function(){
    
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

});
