﻿/// <reference name="MicrosoftAjax.js"/>

// Global init
$(function() {
    // Initialize main menu
    var mainMenu = $('ul.sf-menu')
    mainMenu.superfish();

    // Set the menu to the current page: get the menu item where the link location
    // matches the end of the current URL, and highlight that menu block
    var regEx;
    var currBlock;
    $.each(mainMenu.find('a'), function() {
        regEx = new RegExp($(this).attr('href') + '$');
        if (window.location.toString().match(regEx) != null) {
            
            // Since this could be an inner menu, need to bubble up the link heirarchy
            // until reaching the top.
            currBlock = $(this).parent();
            while (!currBlock.hasClass('sf-menu')) {
                // Only style the li items
                if (currBlock.get(0).tagName.toUpperCase() == 'LI') {
                    currBlock.addClass('activelink');
                }
                currBlock = currBlock.parent();
            }
        }
    });

    // Make curvy corners curvy
    $('.corner10').corner();
});