$(document).ready( function() {
			
	// Purple background for side navigation rollover
	// Changes arrow if second level is present
	function purpleBackground() {
		$(this).parent().addClass("sideNavRollover");
		if ($(this).parent().hasClass("more")) {
			$(this).css("background", "url(/images/consistent/gray_arrow.gif) 204px no-repeat");
		}
	}
	
	// Removes purple background if second level is not present
	function purpleBackgroundRemove() {
		if ($(this).parent().hasClass("more")) {
			$(this).css("background", "url(/images/consistent/gray_arrow.gif) 204px no-repeat");
		} else {
			$(this).parent().not(".more").removeClass("sideNavRollover");
		}
	}
	
	// Multi-use selectors
	$webToolsDropDown = $("#searchBar ul ul.webToolsDropDown");
	$dropDown = $("#dropDown");
	$sideNavLink = $("#sideNav ul li a");
	
	// Global image rollover, files must be named accordingly
	$(".rollover").hover( function() {
		this.src = this.src.replace("_off", "_roll");
	}, function() {
		this.src = this.src.replace("_roll", "_off");
	});
	
	// Web Tools drop down menu
	$dropDown.mouseover( function() {
		$webToolsDropDown.addClass("showWebToolsDropDown");
	});
	
	$("#searchBar ul li a").focus( function() {
		$webToolsDropDown.addClass("showWebToolsDropDown");
	});

	$dropDown.mouseout( function() {
		$webToolsDropDown.removeClass("showWebToolsDropDown");
	});
	
	$(".webToolsDropDown li.last a").blur( function() {
		$webToolsDropDown.removeClass("showWebToolsDropDown");
	});
	
	// Searchbox default text replace
	$("input.searchTextbox").focus( function() {
		if ( $(this).val() == "Search WIU" ) {
			$(this).val("");
			$("#searchBar input.searchTextbox").css("font-style", "normal");
		}
	});
	
	// Side navigation rollover
	$sideNavLink.hover(purpleBackground, purpleBackgroundRemove);
	$sideNavLink.focus(purpleBackground);
	$sideNavLink.blur(purpleBackgroundRemove);
	
	// Side navigation second level
	$("#sideNav ul li.more").hover(function() {
		$(this).children("ul").css("left", "214px");
                $(this).children("ul").css("top", "0px");
	}, function() {
		$(this).children("ul").css("left", "-9999px");
                $(this).children("ul").css("top", "-9999px");
		$(this).removeClass("sideNavRollover");
		$(this).children("a").css("background", "url(/images/consistent/black_arrow.gif) 204px no-repeat");
	});
	
	$("#sideNav ul li.more a").focus(function() { 
		$(this).next().css("left", "214px");
                $(this).next().css("top", "0px");
	});
				
	$("#sideNav ul li.more ul li:last-child a").blur( function() {
		$(this).closest("ul").css("left", "-9999px");
                $(this).closest("ul").css("top", "-9999px");
		$(this).closest(".more").removeClass("sideNavRollover");
		$(this).closest(".more").children("a").css("background", "url(/images/consistent/black_arrow.gif) 204px no-repeat");
	});
});

function clickclear(thisfield, defaulttext) {
   if (thisfield.value == defaulttext) {
       thisfield.value = "";
   }
}


