jQuery(document).ready(function() {

	/**
	 * If we are using a side nav, then make the
	 * side nav and the content just as tall as each other
	 * Note that this has to be run once all of our page
	 * assets are loaded, so we need to bind this to
	 * a load event
	 */
	jQuery(window).load(function() {
		if (jQuery("#nav.sidenav").length > 0) {
			jQuery("#nav.sidenav, #content-navi-wrapper").equalHeights();
		}
	});

	/**
	 * Mimic the 'placeholder' attribute behavior in browsers
	 * that aren't trying hard enough.
	 *
	 * Uses Mathias Bynens's plugin, found on github:
	 * http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
	 */
	jQuery("#search input[name='terms']").placeholder();

	// Create a custom "fade" effect for the slideshow at the top of the page.
	// The jQuery Tools Tabs plugin has a built-in "fade" effect,
	// but it doesn't seem to work properly out-of-the-box;
	// when transitioning from a slide to a previous slide,
	// the first slide fades out properly, but then the second slide
	// suddenly "pops" in.  Adding the delay() here seems to fix that.
	jQuery.tools.tabs.addEffect('delayFade', function(i, done) {
		var conf  = this.getConf();
		this.getPanes().fadeOut(conf.fadeInSpeed).delay(conf.delay).eq(i).fadeIn(conf.fadeOutSpeed);
		done.call();
	});

	// Begin the slideshow.
	jQuery('div.navi').tabs('.slideshow > div', {
		effect:       'delayFade',
		fadeInSpeed:  800,
		fadeOutSpeed: 800,
		delay:        400,
		rotate:       true,
		current:      'active'
	}).slideshow({
		autoplay:     true,
		interval:     7500
	});

	// Round corners on all callout buttons (Since IE isn't smart enough to)
	jQuery('.callout').corner();
	jQuery('#content-navi-wrapper').corner("br 30px");
	jQuery('#scrollable-container .page').corner("tl 30px");
});

