// JavaScript Document

$(document).ready(function() {
	navSetup();
	$(".accordion li a").click(function() {
    	if( $(this).css("background-color") == "#30A5E8" || 
        	$(this).css("background-color") == "rgb(48, 165, 232)" )
                {
                 $(this).css("background-color","#0f89ce");
                }
                else{
                   $(this).css("background-color","#30A5E8");  
               }

		$(this).next().toggle("fast");
	}).next().hide();
	
	$(".navItem").each(function () {
		var current = $(this);
		var count = $(this).children("ul").length;
		if (count == 0) {
			current.mouseover(function() { $(".navItem ul").css({display: "none"}); });
		} else {
				current.children("a:first").mouseover(function() {
				$(".navItem ul").css({display: "none", zIndex: "5"});
			
				$(this).next("ul").css({display: "block", zIndex: "99"}).mouseleave(function () { 
					$(this).css({display: "none"}).unbind("mouseleave");
				});
			});
		}
	});
	
	

	
});


function navSetup() {
	$(".navImage").each(function () {
		var img = $(this);
		if (img.length > 0) {
			var src = img.attr("src");
			var pos = src.lastIndexOf(".");
			var str1 = src.substr(0, pos);
			var str2 = src.substr(pos, src.length);
			var roll = str1+"_f2"+str2;
			img.mouseover(function () { swapImage(img, roll) });
			img.mouseout(function () { swapImage(img, src); });
		}
	});
}

function swapImage(image, src) {
	$(image).attr("src", src);
}