var carousel;
var pageLoad = function() 
{
	carousel = new YAHOO.extension.Carousel("mycarousel", 
		{
			numVisible:        1,
			animationSpeed:    0.5,
			scrollInc:         1,
			navMargin:         0,
			prevElement:     "prev-arrow",
			nextElement:     "next-arrow",
			size:              5,
			prevButtonStateHandler:   handlePrevButtonState,
			nextButtonStateHandler:   handleNextButtonState
		}
	);

};
YAHOO.util.Event.addListener(window, 'load', pageLoad);
$(document).ready(function() {
		$('#work .work-photos div p').css("display", "none");	
		$('.work-photos') 
				.before('') 
					.cycle({ 
 						fx:     'fade', 
  						speed:  '550', 
  						timeout: 0,     			 
							next: 	'.work-photos, .next',
    					prev:   '.previous',
    					pager:  '#pagination',
    					pause: 1
					});
			$('#prev').click(function() {
				$('.work-photos').cycle('stop'); });
			$('#next').click(function() {
				$('.work-photos').cycle('stop'); });
				
 
		// $("#work .work-photos div a").fancybox();
		var speed = 1050;
		var elementHeight = 103;
		var countElements = $('#thumbs ul li');
		var numberElements = countElements.length;
		var totalHeight = numberElements * elementHeight;
		var containerHeight = 515;
		
		var currentPlace = containerHeight;
		var currentDifference = 0;
		$("#up").addClass("nogo"); // Gjør "opp" uklikkbar"
    	$("#down").click(function(event) {
    		// $("#down").addClass("nogo");
    		$("#up").removeClass("nogo");
    		event.preventDefault();
    		if (currentPlace >= totalHeight) { 
    		} else { // Ellers, continue!
    		currentPlace += containerHeight;
    		currentDifference -= containerHeight; 
				$("#thumbs ul").animate({ top: currentDifference + "px"}, speed );
				if (currentPlace >= totalHeight){$("#down").toggleClass("nogo");}
    		}
			
    	});
    	$("#up").click(function(event) {
    		 $("#down").removeClass("nogo");
    		 // $("#up").addClass("nogo");
    		event.preventDefault();
 
    		if (currentPlace <= containerHeight) { 
    		} else { // Ellers, continue!
    		currentPlace -= containerHeight;
    		currentDifference += containerHeight; 
				$("#thumbs ul").animate({ top: currentDifference + "px"}, speed );
				if (currentPlace <= containerHeight){$("#up").toggleClass("nogo");}
    		}	
    	});
		});