$(document).ready( function() {
	
	
	$('#leftNav_web .navImage').mouseover(function() {
		if($(this).attr('class').indexOf('activeNav') == -1) $(this).attr('src','assets/leftNav_web_on.png');
	});
	
	$('#leftNav_mktg .navImage').mouseover(function() {
		if($(this).attr('class').indexOf('activeNav') == -1) $(this).attr('src','assets/leftNav_mktg_on.png');
	});
	
	$('#leftNav_copy .navImage').mouseover(function() {
		if($(this).attr('class').indexOf('activeNav') == -1) $(this).attr('src','assets/leftNav_copy_on.png');
	});
	
	$('#leftNav_web .navImage').mouseout(function() {
		if($(this).attr('class').indexOf('activeNav') == -1) $(this).attr('src','assets/leftNav_web.png');
	});
	
	$('#leftNav_mktg .navImage').mouseout(function() {
		if($(this).attr('class').indexOf('activeNav') == -1) $(this).attr('src','assets/leftNav_mktg.png');
	});
	
	$('#leftNav_copy .navImage').mouseout(function() {
		if($(this).attr('class').indexOf('activeNav') == -1) $(this).attr('src','assets/leftNav_copy.png');
	});
	
	var $last = $([]);//save the last link
	$('#leftNav, .portfolioItemContent').localScroll({ 
		target:'#portfolioSections',
		axis:'xy',
		queue:true,
		duration:1000,
		onBefore:function( e, el, $target ){
			$target.queue('fx',[]).stop();//to avoid queueing animations
			//$target.find('h2').css('visibility','hidden !important');
			this.blur();//remove the awful outline
		},
		onAfter:function($target){
			//$target.find('h2').css('visibility','visible !important');
		}
	});
	/*
	var $portTarget;
	function setTarget(arrow) {
		$portTarget = arrow.parents('.portfolioImagesContainer:first');
		//alert($portTarget.attr('class'));
	}
	
	var $lastArrow = $([]);
	$('.portfolioArrows').localScroll({ 
		target:'.portfolioImagesContainer',
		axis:'xy',
		queue:true,
		duration:1000,
		onBefore:function( e, el, $target ){
			$target.queue('fx',[]).stop();//to avoid queueing animations
			this.blur();//remove the awful outline
		},
		onAfter:function($target){
			//$target.find('h2').css('visibility','visible !important');
		}
	});
	*/
	/*var zIndex1 = 1;
	$('body').find('.sub_section').each(function() {
		zIndex1++;
		$(this).css('zIndex',zIndex1);
	});
	
	var zIndex2 = 1;
	$('body').find('.portfolioImagesContainer').each(function() {
		zIndex2++;
		$(this).css('zIndex',zIndex2);
	});
	
	var zIndex3 = 1;
	$('body').find('.portfolioImagesWrapper').each(function() {
		zIndex3++;
		$(this).css('zIndex',zIndex3);
	});*/
	
	
	$('.project_links').mouseover(function() {
		$(this).parent().addClass('projectLinkActive');		
	});
	
	$('.project_links').click(function() {
		$(this).parents('.leftNav_section').find('.projectLink').each(function() {
			$(this).removeClass('projectLinkClicked');
		});
		$(this).parent().addClass('projectLinkClicked');		
	});
	
	$('.project_links').mouseout(function() {
		$(this).parent().removeClass('projectLinkActive');		
	});
	
	if(location.href.indexOf('#section')!=-1) {
		var targetSection = location.href.substring(location.href.indexOf('#') + 1, location.href.length);
		$('#nav_'+targetSection+' a.project_links').triggerHandler('click');	
	} else {
		$('#nav_section0 a.project_links').triggerHandler('click');	
	}
	
	$('.inlineProjectNavigation').click(function() {
		var targetString = $(this).attr('href');
		targetString = targetString.substring(1);
		var $projectLink = $('#nav_'+targetString);
		$projectLink.parents('.leftNav_section').find('.projectLink').each(function() {
			$(this).removeClass('projectLinkClicked');
		});
		$projectLink.addClass('projectLinkClicked');
	});
	
	
});

