// Sprite
$(document).ready(function(){						   
    $('#nav li a').append('<span class="hover"></span>')		   
	$('#nav li a').hover(function() {
	// Stuff that happens when you hover on + the stop()
	$('.hover', this).stop().animate({
		'opacity': 1
		}, 700,'easeOutSine')
	
	},function() {	
	// Stuff that happens when you unhover + the stop()
	$('.hover', this).stop().animate({
		'opacity': 0
		}, 1200, 'easeOutQuad')
	})
});










// Horizontal Subnav
$(document).ready(function() {

	$("ul#topnav li").hover(function() { //Hover over event on list item
		$(this).css({ 'background' : '#d31d2a url(topnav_active.gif) repeat-x'}); //Add background color and image on hovered list item
		$(this).find("span").show(); //Show the subnav
	} , function() { //on hover out...
		$(this).css({ 'background' : 'none'}); //Ditch the background
		$(this).find("span").hide(); //Hide the subnav
	});

});












// Automatic Image Slider w/ CSS & jQuery by Tanaka
$(document).ready(function() {
//Show the paging and activate its first link
$(".paging").show();
$(".paging a:first").addClass("active");

//Get size of the image, how many images there are, then determin the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;

//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});

//Paging  and Slider Function
rotate = function(){
    var triggerID = $active.attr("rel") - 1; //Get number of times to slide
    var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

    $(".paging a").removeClass('active'); //Remove all active class
    $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

    //Slider Animation
    $(".image_reel").animate({
        left: -image_reelPosition
    }, 500 );

}; 

//Rotation  and Timing Event
rotateSwitch = function(){
    play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
        $active = $('.paging a.active').next(); //Move to the next paging
        if ( $active.length === 0) { //If paging reaches the end...
            $active = $('.paging a:first'); //go back to first
        }
        rotate(); //Trigger the paging and slider function
    }, 7000); //Timer speed in milliseconds (7 seconds)
};

rotateSwitch(); //Run function on launch

//On Hover
$(".image_reel a").hover(function() {
    clearInterval(play); //Stop the rotation
}, function() {
    rotateSwitch(); //Resume rotation timer
});	

//On Click
$(".paging a").click(function() {
    $active = $(this); //Activate the clicked paging
    //Reset Timer
    clearInterval(play); //Stop the rotation
    rotate(); //Trigger rotation immediately
    rotateSwitch(); // Resume rotation timer
    return false; //Prevent browser jump to link anchor
});

});










// jQuery SmoothScroll | Version 09-11-02  - Source: http://blog.medianotions.de/en/articles/2009/smoothscroll-for-jquery
$(document).ready(function(){
$('a[href*=#]').click(function() {

   // duration in ms
   var duration=1000;

   // easing values: swing | linear
   var easing='swing';

   // get / set parameters
   var newHash=this.hash;
   var target=$(this.hash).offset().top;
   var oldLocation=window.location.href.replace(window.location.hash, '');
   var newLocation=this;

   // make sure it's the same location      
   if(oldLocation+newHash==newLocation)
   {
      // animate to target and set the hash to the window.location after the animation
      $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {

         // add new hash to the browser location
         window.location.href=newLocation;
      });

      // cancel default click action
      return false;
   }

});
});







// Sliding Boxes
$(document).ready(function(){
	$(".cover", this).stop().animate({top:'150px'},{queue:false,duration:160});
	//Caption Sliding (Partially Hidden to Visible)
	$('.boxgrid.caption').hover(function(){
	$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
	}, function() {
	$(".cover", this).stop().animate({top:'150px'},{queue:false,duration:160});
	});
});
$(document).ready(function(){
	$(".cover2", this).stop().animate({top:'310px'},{queue:false,duration:160});
	//Caption Sliding (Partially Hidden to Visible)
	$('.boxgrid2.caption').hover(function(){
	$(".cover2", this).stop().animate({top:'40px'},{queue:false,duration:160});
	}, function() {
	$(".cover2", this).stop().animate({top:'310px'},{queue:false,duration:160});
	});
});












// Expand / Collapse

$(document).ready(function(){
	
	$(".toggle_container").hide();

	$("h2.expand_heading").toggle(function(){
		$(this).addClass("active"); 
		}, function () {
		$(this).removeClass("active");
	});
	
	$("h2.expand_heading").click(function(){
		$(this).next(".toggle_container").slideToggle("slow,");
	});
	

});






// jQuery Like Flash Animation
$(document).ready(function() {
	$('#fade').innerfade({
		speed: 2400,
		timeout: 5600,
		type: 'sequence',
		containerheight: '127px'
	});
});




//EOF
