$.fn.extend({
    /** checking and unchecking funcitons **/
    check: function() {
        return this.each(function() { this.checked = true; });
    },
    uncheck: function() {
        return this.each(function() { this.checked = false; });
    },
    checkToggle: function() {
        return this.each(function() { this.checked != this.checked; });
    },
    /** extension to jquery to allow for the use of the checked property **/
    checked: function() {
        if (this.length > 1) {
            return this.get(0).attr('checked');
        } else if (this.length == 1) {
            return this.attr('checked');
        } else {
            return false;
        }
    },
    tagName: function() {
        return (this.length > 0 ? this.get(0).tagName : 'No Element Found');
    },
    /** adding and removing a message formated with the jquery ui classes **/
    addErrorMsg: function(msg) {
        $(this).html('<div class="ui-widget"><div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"><p><span class="ui-icon ui-icon-alert" style="float:left; margin-right: .3em;"></span>' + msg + '</p></div></div>').slideDown(300);
    },
    removeErrorMsg: function() {
        $(this).slideUp(300);
    }
});

var selectedMenus = new Array();

/** rotate images for hp **/
$(document).ready(function() {
    PreloadImages();
    // set the menu items to the over src that are in the selected menus array
    $(selectedMenus).each(function(i, image) {
        imgSelector = 'img[src$="images/' + image + '"]';
        if ($(imgSelector).length > 0) {
            newSrc = $(imgSelector).attr('current') ? $(imgSelector).attr('current') : $(imgSelector).attr('over');
            $(imgSelector).attr('src', newSrc).removeAttr('over').removeAttr('current');
        }
    });
});

/** image roll over **/
function PreloadImages() {
    $('img[over], input[over]').each(function() {
        $('<img />').attr('src', $(this).attr('over'));
        $(this).mouseover(function() {
            $(this).attr('out', $(this).attr('src'));
            $(this).attr('src', $(this).attr('over'));
        });
        $(this).mouseout(function() {
            $(this).attr('src', $(this).attr('out'));
        });
    });
}
