jQuery(document).ready(function($) {
	
	// hide the link text, replace with a spacer image
	$(".topNav a.replace").each(
		function(i) {
			var width = $(this).parent().width();
			var text = $(this).html();
			$(this).html('<img width="' + width + '" height="43" src="wp-content/themes/connections/images/spacer.gif" alt="' + text + '" />');
		}
	);
	
	// highlight the current menu state if necessary
	$(".topNav.active").css('background-position', '0px -42px');
	
	// Handle navigation mouseover/mouseout
	$(".topNav.inactive").bind("mouseover", function(){
		
		// adjust background position
		$(this).css('background-position', '0px -42px');
		
	});
	
	$(".topNav.inactive").bind("mouseout", function(){

		// move background back
		$(this).css('background-position', '0px 0px');
		
	});
	
	// if 'letter from the editor' or 'this edition' is active,
	// make them unclickable
	$("#navHome.active").bind("click", function() { return false; } );
	$("#navLetter.active").bind("click", function() { return false; } );
	
	// Handle category dropdown
	$("#navArticles").bind("mouseover", function(){
		
		// reveal category dropdown
		$(".categoryDropdown").show();
		
	});
	$("#navArticles").bind("mouseout", function(){

		// hide category dropdown
		$(".categoryDropdown").hide();
		
	});
	
	// make whole div clickable for category dropdown
	$(".categoryDropdown .category").each(
		function(i) {
			$(this).bind("click", function(){ window.location = "category/" + $(this).attr("id") + "/"; });
		}
			
	);
	
	
	// Handle offer dropdown
	$(".offerDropdown").bind("mouseover", function(){
		
		// reveal category dropdown
		$(".offerForm").show();
		
	});
	$(".offerDropdown").bind("mouseout", function(){

		// hide category dropdown
		$(".offerForm").hide();
		
	});
	
	// homepage article pods - make the entire div clickable
	$(".topArticleTitle").bind("click", function(){

		// make the entire title div clickable
		window.location = $(this).attr("id");
		
	});

	
});




