$(document).ready(function(){

	$('.projectLink').mouseover(function(){

		$('#opacityOverLayer').html($(this).parent().find('div').html());
		$('.projectLink').each(function(){
			
			$(this).attr('src', $(this).attr('rev'));
		});
			
		$(this).attr('src', $(this).attr('rel'));


	});

	$('#prevSpan a').click(function(){

		var photoCounter = $('.jsImages').size();

		if($('#jsImagePos').val() <= 1){
			$('#nextSpan').hide();
			return false;
		}
		var inc = $('#jsImagePos').val();
		inc--;
		$('#jsImagePos').val(inc);
		$('#jsImgPos').text(inc);
		$('#leftBarOver').hide();
		$('#leftBar').hide();

		$('#bigImg').fadeOut("normal", function(){
					$('#bigImg').attr('src', $('.jsImages:eq(' + (inc - 1) + ')').val());
					$('#bigImg').fadeIn("normal", function(){
						$('#leftBar').show();
						$('#leftBarOver').show();
					});
		});
		$('#nextSpan').show();
		if($('#jsImagePos').val() <= 1){
			$('#prevSpan').hide();
			$('#divideDiv').hide();
		}
		else{
			$('#divideDiv').show();
		}
		return false;
	});


	$('#nextSpan a').click(function(){



		var photoCounter = $('.jsImages').size();

		if($('#jsImagePos').val() >= photoCounter){
			$('#nextSpan').hide();
			return false;
		}
		var inc = $('#jsImagePos').val();
		inc++;
		$('#jsImagePos').val(inc);
		$('#jsImgPos').text(inc);
		$('#leftBarOver').hide();
		$('#leftBar').hide();
	
		$('#bigImg').fadeOut("normal", function(){
					$('#bigImg').attr('src', $('.jsImages:eq(' + (inc - 1) + ')').val());
					$('#bigImg').fadeIn("normal", function(){
						$('#leftBar').show();
						$('#leftBarOver').show();
					});
		});
		$('#prevSpan').show();

		if($('#jsImagePos').val() >= photoCounter){
			$('#nextSpan').hide();
			$('#divideDiv').hide();
		}
		else{
			$('#divideDiv').show();
		}
	
		return false;
	});

	$('#bigImg').load(function(){

	});

	$('#leftArrow,#leftBar,#leftBarOver').click(function(){
		$('#leftBar').fadeOut("fast", function(){
			
		});
		$('#leftBarOver').hide();
		$('#slideLayer').css('position', 'absolute');
		$('#slideLayer').css('right', '0px');
		$('#slideLayer').fadeIn('normal');
		$('#slideOverLayer').css('visibility', 'visible');		
		
		
		
	});

	var parentArrow = $('#rightArrow').parent();
	
	parentArrow.click(function(){
		$('#slideLayer, ').fadeOut('normal');
		$('#slideOverLayer').css('visibility', 'hidden');
		$('#leftBar').show();
		$('#leftBarOver').show();
	});
	
	$('#rightArrow', parentArrow).click(function(){
		$('#slideLayer, ').fadeOut('normal');
		$('#slideOverLayer').css('visibility', 'hidden');
		$('#leftBar').show();
		$('#leftBarOver').show();
	});

	$('#showKeyFacts a').click(function(){

		$('#pContent').parent().fadeOut('fast', function(){
			$('#showKeyFacts').hide();
			$('#showContent').show();
			$('#pKeyFacts').show();
			$('#pKeyFacts').parent().fadeIn('fast');
		});

		return false;
	});

	$('#showContent a').click(function(){

		$('#pKeyFacts').parent().fadeOut('fast', function(){
			$('#showKeyFacts').show();
			$('#showContent').hide();
			$('#pContent').show();
			$('#pContent').parent().fadeIn('fast');
		});

		return false;
	});
	
	$('#pContent, #pKeyFacts').jScrollPane({showArrows:true});
	
	$('#pKeyFacts').parent().hide();
	

});