/**
 * Applies effects/events to various CSS classes within the given element.
 *
 * @param DOMElement|jQuery element
 * @return void
 */
// On page load
$(document).ready(function() {
guiPrep();
});
						   
function guiPrep(element)
{
	$(function() {
	
		/* PRELOAD IMAGES */
		$(window).bind("load", function() {
		$(".menu img").each(function(key, elm) {
		$().attr( "src", $(this).attr("src").replace(".png", "_on.png"));
		});
		});
		
        /*MENU GUI*/
        $(".menu").hover(function() {
			if ($(this).attr("src").indexOf("_on") == -1) {
			var newSrc = $(this).attr("src").replace(".png","_on.png");
			$(this).attr("src",newSrc);
			}
		},
		function() {
			if($(this).attr("src").indexOf("_on.png") != -1) {
			var oldSrc = $(this).attr("src").replace("_on.png",".png");
			$(this).attr("src",oldSrc);
			}
		});
		
		
        /*SWITCH GUI*/
       	$(".switch").hover(function() {
		$(this).addClass("switchon");					
		},
		function() {
		$(this).removeClass("switchon");
		});
		
			
        /*BUTTON GUI*/
       	$(".button, .buttongreen, .bodybutton").hover(function() {
		$(this).addClass("buttonon");					
		},
		function() {
		$(this).removeClass("buttonon");
		});
		
		
		/*REQUIRED FORM FIELDS*/
		$(element).find(".requiredfield, .requiredfield2").each(function(i){
			$(this).parent().prev().prepend("<span class=\"highlight\">*</span> ");
		});
        
    });
}