/* Author: J. Hite Billes
			hbilles@gmail.com

*/

$(window).load(function() {
	//start slideshow
    $('#slider').nivoSlider({
	    pauseTime: 6000
    });
    
    //start main nav behavior
    $("#navigation ul li a").hover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul:first").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});

	});
	
	//start jquery sponsor scroller
	$("#scroller").simplyScroll({
		autoMode: 'loop'
	});
	
	//start jquery tooltips
	$(".trigger").tooltip({position: "top center", effect: "fade"});
	
	//add span to buttons to animate links
    $("#social_links a").append("<span class='hover'></span>");
    
    //animate action buttons
    $("#social_links a").hover(
		function() {
			$(".hover", this).stop().animate({"opacity": 1}, {"duration": 700}, {"easing": "easeOutSine"})
		},
		function() {
			$(".hover", this).stop().animate({"opacity": 0}, {"duration": 700}, {"easing": "easeOutQuad"})
	});
	
	// set width of figcaptions on page to match the width of their associated images
	$("figure.inline figcaption").each(function () {
		var img_width = $(this).prev().width();
		$(this).width(img_width);
	});
	
});






















