$(document).ready(function(){
	/* Hide subnavigation on load */
	$("#subNavContainer").hide();	
	
	/* Holder for current subnav item */
	var src = "";
	var current = "";
	
	/* Hide subnav */
    $("#nav img.hide")
        .mouseover(function() { 
			/* Rollovers */
			if(current != this.id){
				if(current != ""){
					src = $("#"+current).attr("src").replace("_over", "");
					$("#"+current).attr("src", src);
				}
				
				current = this.id;
			}
			
            src = $(this).attr("src").match(/[^\.]+/) + "_over.jpg";
            $(this).attr("src", src);
					
			/* Remove sub nav items */
			$("#subNav").html("");
			
			/* Hide sub nav */
			$("#subNavContainer").hide();		
        })
        .mouseout(function() {
			/* Rollovers */
            src = $(this).attr("src").replace("_over", "");
            $(this).attr("src", src);
			
			current = "";
        });
	/* Hide subnav end */
	
	
	/* Show subnav */
	$("#nav img.show").mouseover(function() { 
		/* Rollovers - reset then apply rollover */
		if(current != this.id){
			if(current != ""){
				src = $("#"+current).attr("src").replace("_over", "");
				$("#"+current).attr("src", src);
			}
			
			src = $(this).attr("src").match(/[^\.]+/) + "_over.jpg";
			$(this).attr("src", src);
			
			current = this.id;
		}
				
		/* Hide sub nav */
		$("#subNavContainer").hide();
			
		/* Grab correct sub nav */
		$("#subNav").load("includes/nav/"+this.id+".html");
			
		/* Show sub nav */
		$("#subNavContainer").show();	
 	})
	/* Show subnav end */
		
});
