﻿/*

	Created By: Eddie Giese
	03.24.10
	
*/
/*
	jQuery Scroll (via CSS-Tricks Snippets)
*/
$(function(){
	//initialize "Home" as current-nav
	$('#nav li a.home').addClass('current-nav');
	
	$('a[href*=#]').click(function() {
	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			// define target based on hash call
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			
			//save $section for use in applying class to active navigation
			$section = (this.hash);
			$section = $section.replace('#','');
			$section += '-nav'; //add -nav to id name
			
			if ($target.length) {
				// define target's distance from top of body
				var targetOffset = $target.offset().top;
				
				//append class of current-nav to element
					// remove class of current-nav on all nav elements
					// find li that matches $target
					// select the nav element
					// append class of current-nav
				$('#nav li a').each(function() {
					$(this).removeClass('current-nav', '300');
					
					if( $(this).attr('id').match($section) ) {
						$(this).addClass('current-nav', '300');
				    }
				});	

				//animate scroll to top of target
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
								
			}
		}
	});
});	

/*
	END OF FILE
*/
