// Navigation Drop Downs
$(document).ready(function(){
	// About Image Rollover
	$('div#about_img').hover(
		function() {
			$('img', this).stop().animate({top: -500}, 1000);
		},
		function() {
			$('img', this).stop().animate({top: 0}, 1000);
		});
	$('body').addClass('js');
	// Setup Nav Selected States
	var href = document.location.pathname;
	if(href.match('/work/')) {
		$('#portfolio').addClass('selected');
	}
	else if(href.match('/contact/')) {
		$('#contact_nav').addClass('selected');
	}
	else if(href.match('/about/')) {
		$('#about_nav').addClass('selected');
	}
	else if(href.match('/services/')) {
		$('#serv_nav').addClass('selected');
	}
	// Nav Hiding and Showing
	$('#nav ul li ul').hide();
	$('li.main_list').hover(
		function() { $('ul', this).fadeIn('fast'); $(this).addClass('selected') },
		function() { $('ul', this).fadeOut('fast'); $(this).removeClass('selected') });
		return false;
	// External Links
	$('a[rel="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	 });
});

// Work Section
$(window).load(function() {
	var hash = window.location.hash;
	if(hash != "" && hash != "#all") {
		// Fade Out All Divs
		$('div.summary').fadeTo('fast', .5);
		// Replace Hash
		hash = hash.replace('#', '');
		// Subnav
		$('#subnav a').removeClass('hilite');
		$('#subnav a#'+hash).addClass('hilite');
		// Bring In Div and Scroll to it
		$('div.'+hash).fadeTo('slow', 1.0).css({'border-color': '#CC6600'});
		$(window).scrollTo('div.'+hash, 800);
	}
	else if (hash == "#all") {
		hash = hash.replace('#', '');
		// Subnav
		$('#subnav a').removeClass('hilite');
		$('#subnav a#'+hash).addClass('hilite');
	}
	$(window).bind('hashchange', function() {
	hash = window.location.hash;
	if(hash != "" && hash != "#all") {
		$('#subnav a').removeClass('hilite');
		$('#subnav a#'+hash).addClass('hilite');
		$('div.summary').fadeTo('fast', .5).css('border-color', '#CCC');
		hash = hash.replace('#', '');
		$('div.'+hash).fadeTo('slow', 1.0).css({'border-color': '#CC6600'});
		$(document).scrollTo('.'+hash, 800);
	}
	else if(hash == "#all") {
		hash = hash.replace('#', '');
		$('#subnav a').removeClass('hilite');
		$('#subnav a#'+hash).addClass('hilite');
		$('div.summary').fadeTo('fast', 1.0).css({'border-color': '#CC6600'});
	}
});
});
/* Additions to Pages */
$(window).load(function() {
	$('#services .tab').last().css('border', 'none');
});

