$(document).ready(function(){

	$('.slideContent span').slantedText({
		reverse: true,
		increment: 0.45
	});

	var nbSelected = "";
	$("#slideWrap img.bg").not(".active").css({ opacity: 0 }).show();
	
	$("#slideNav a").each(function() {
		
		//$(this).removeAttr("title"); // <--- remove title attribute from links if JS enabled - interferes with ability to see animation/content
		
		$(this).hover(function() {
			if($(this).attr("id") != nbSelected) { $(this).removeClass("dim"); }
			if(nbSelected != "")
				$("#slideNav a").not(this).not("#" + nbSelected).addClass("dim");	
			else
				$("#slideNav a").not(this).addClass("dim");	
			nbSelected = $(this).attr("id");
			$("#slideNav a").not(this).addClass("dim");	
			
			var imgID = '#' + $(this).parents().siblings('img').filter('.active').attr('id');
			var linkID = this.hash + '-bg';
			if (imgID != linkID) {
				$(this).parents().siblings('img').stop().animate({opacity:0},500,function(){$(this).hide();}).filter(this.hash + '-bg').stop().show().animate({opacity:1},500);
			}
			
			$('.slide').stop().animate({ left: '-660px' });
			$(this).parents().siblings('div.slide').filter(this.hash).stop().animate({ left: '180px' });
			return false;
				
		}, function() {
			if(nbSelected != "")
				$(this).not("#" + nbSelected).addClass("dim");
			else
				$(this).addClass("dim");
		});
		
		$(this).bind("click", function() {
			return false;
		});
		
	});
	
	$("#slideWrap").mouseleave(function() {
		nbSelected = "";
		$("#slideNav a").removeClass("dim");
		$('.slide').stop().animate({ left: '-660px' });

		$("#slideWrap img.bg").not(".active").stop().animate({opacity:0},500,function(){$(this).hide();});
		$("#slideWrap img.active").stop().show().animate({opacity:1},500);
	});


});
