$(document).ready(function(){
	// removes the background image for all items not active
	$(".nav").children("li").each(function() {
		var linkclass = $(this).attr("class");
		if ($("body").attr("id") != "page-" + linkclass) {
			$(this).children("a").css({backgroundImage:"none"});
		}
		attachNavEvents(".nav", linkclass);
	});	
	function attachNavEvents(parent, myClass) {
		$(parent + " ." + myClass).mouseover(function() {
			$(this).append('<div class="nav-' + myClass + '"></div>');
			$("div.nav-" + myClass).css({display:"none"}).fadeIn(300);
		}).mouseout(function() {
			// fade out & destroy pseudo-link
			$("div.nav-" + myClass).fadeOut(300, function() {
				$(this).remove();
			});
		});
	}
	
	//Resizer
	
		function containerResize(container, conFlag, maxWidth, padding) {
		$(container + "> p > a > img").each(function() {
			if (conFlag == "Y") {								  
				if($(this).width() > $(container).width()) { 
					$(this).attr({ width: ($(container).width() - padding)});
				} else { } 
			} else {
				if($(this).width() > maxWidth) { 
					$(this).attr({ width: (maxWidth - padding)});
				} else { } 
			}
		});	
	}
	
	//CUSTOM - Resize images with class 'wp-cpation'
	function wpcontainerResize(container, conFlag, maxWidth, padding) {
		if ($("div.wp-caption").width() > 500) {
			$("div.wp-caption").css({ width:"450px", fontWeight:"bolder" });
		}
		$(".wp-caption > a > img").each(function() {
				if (conFlag == "Y") {								  
				if($(this).width() > $(container).width()) { 
					$(this).attr({ width: ($(container).width() - padding)});
				} else { } 
			} else {
				if($(this).width() > maxWidth) { 
					$(this).attr({ width: (maxWidth - padding)});
				} else { } 
			}
		});	
	}
	
	//initiate any containers you would like images resized
	//----| Params | ------
	/* 
	1. Container you which to have images resized
	2. Resize based on container? If "Y", image will be the width of the container
	3. Max width, used if 2 is set to "N". Must be retained even if not actively used
	4. Padding around the image. This will add whitespace around the image while NOT adding extra width. Must be retained event if not actively used.
	*/
	containerResize(".post", "N", 480, 20);
	wpcontainerResize(".post", "N", 450, 20);
	
});