var debugMode = true;
jQuery(document).ready(function() {

	// --------------------------------
	// !Main Menu Animation
	// --------------------------------
	
	// grab menu items except one with .active-trail class
	var mainMenuItem = jQuery('#main-menu ul li:not(.active-trail)');
	
	// grab a tags from above set  	
	var mainMenuItemLink = jQuery("a", mainMenuItem);
	
	// prepend a span in each found item for the fx background
	mainMenuItem.prepend('<span class="main-menu-bg"><\/span>');  
	var mainMenuItemBG = jQuery("span", mainMenuItem);
	
	// hide background setup in links
	mainMenuItemLink.css("background", "none");
	
	// hide the background for now
	mainMenuItemBG.hide();
	
	// on mouse over, fade in bg
	mainMenuItem.mouseover(function() {
		jQuery("span", this).css("background-position-y", "-49px").fadeIn("fast");
	});
	
	// on mouse over, fade out bg
	mainMenuItem.mouseout(function() {
		jQuery("span", this).css("background-position-y", "-49px").fadeOut("fast");
	});
	
	// on mouse click, turn on selected bg
	mainMenuItem.mousedown(function() {
		jQuery("span", this).css("background-position", "0px -98px").fadeIn("fast");
	});


	// --------------------------------
	// !Share Links
	// --------------------------------
	var blocksRight = jQuery('div#blocks-right');	

	// if right column/blocks found
	if (blocksRight.length) {

		var currentPageUrl = encodeURIComponent(window.location.href);
		var subject = encodeURIComponent("Check out this web page.");
	
		blocksRight.prepend('<div id="share" class="dont-print"><div class="block"><h3>Share<\/h3> | <a class="share-print"><img src="\/sites\/default\/themes\/investdetroit\/images\/icon_print.gif" alt="icon_print" width="10" height="8" \/> Print<\/a> | <a href="mailto:?subject='+subject+'&body='+currentPageUrl+'" class="share-email"><img src="\/sites\/default\/themes\/investdetroit\/images\/icon_email.gif" alt="icon_email" width="13" height="8" \/> Email<\/a><\/div><\/div>');

		jQuery('.share-print').click(function() {
			window.print();
		});
		
		jQuery('div#share').show();

	}
		
	
	// --------------------------------
	// !Slideshow Setup
	// --------------------------------
	var slideShows = jQuery('div.slides');

	// if slideshows found	
	if (slideShows.length) {

		slideShows.before('<div class="slideshow-nav">').cycle({
			fx: 'fade',
			timeout: 5000,
			speed: 1000,
			pager: '.slideshow-nav'
		});

	}
	
});



// --------------------------------
// !UTILITIES
// --------------------------------

// Log output to console (firebug/safari inspector/etc.)
jQuery.log = function(message) {
	if(window.console && debugMode) {
		window.console.log(message);
	}
};
