$(function () {

    // Prevent ajax requests from being cached
    $.ajaxSetup({ cache: false });

    // Adds CSS class to menu items on hover
    $('ul#menu li').hover(function () {
        $(this).addClass('hover');
    }, function () {
        $(this).removeClass('hover');
    });

    // Target the first submenu item
    $('ul#menu li ul').each(function () {
        $(this).find('li:first').addClass('first');
    });

    // Set default textbox value from title attribute, if present
    $('input[type=text]').each(function () {
        if ($(this).attr('title') != '') {
            if ($(this).val() == '') {
                $(this).val($(this).attr('title'));
                $(this).addClass('blur');
            }
        }

        $(this).focus(function () {
            var value = $(this).val();
            var title = $(this).attr('title');
            if (value == title) {
                $(this).val('');
            }
            $(this).addClass('focus');
            $(this).removeClass('blur');
        });

        $(this).blur(function () {
            var value = $(this).val();
            var title = $(this).attr('title');
            if (value == '' || value == title) {
                $(this).val(title);
                $(this).removeClass('focus');
                $(this).addClass('blur');
            }
        });
    });

    // Apply alternating table row class
    $('table').each(function () {
        $(this).find('tr:even').addClass('alternate');
    });
  
    $('tr th:first-child').addClass('first');
    $('tr td:first-child').addClass('first');

    Cufon.replace('body:not(.access) h1');
    Cufon.replace('body:not(.access) h2');
    Cufon.replace('body:not(.access) h3');
    Cufon.replace('body:not(.access) h4');
});
