function slideSwitch(sCanvasID) {
	var oCurrent = $('#'+sCanvasID+' .active');	
	var oNext = (oCurrent.next().length ? oCurrent.next('img') : $('#'+sCanvasID+' img:first') );

	oCurrent.fadeOut(600,function(){
		oCurrent.removeClass('active');
		oNext.addClass('active');
		oNext.fadeIn(600,function(){
			return true;
		});
	});
	
}
$(function() {
	/**
	* homepagina
	**/
	$('#slideshow img:first').fadeIn(500,function(){
		setInterval( "slideSwitch('slideshow')", 3000 );
	});
	
	/**
	* Portfolio
	**/
	$('#portfolio img:first').fadeIn(500,function(){
		//setInterval( "slideSwitch('portfolio')", 3000 );
	});
	$('#thumbsholder img').click(function(){
		var sID = $(this).attr('id').replace('thumb_','');
		$('.active').fadeOut(100,function(){
			$('.active').removeClass('active');
			$('#img_'+sID).fadeIn(500,function(){
				$('#img_'+sID).addClass('active');
			});
		});
	});
	
	/**
	* Next image
	**/
	$('#nextImage').click(function(){
		var oCurrent = $('.active');	
		var oNext = (oCurrent.next().length ? oCurrent.next('img') : $('#portfolio img:first') );
		
		$('.active').fadeOut(100,function(){
			oCurrent.removeClass('active');
			oNext.addClass('active');			
			$('.active').fadeIn(500);
		});
	});
	
	/**
	* Previous image
	**/
	$('#previousImage').click(function(){
		var oCurrent = $('.active');	
		var oNext = (oCurrent.prev().length ? oCurrent.prev('img') : $('#portfolio img:last') );
		
		$('.active').fadeOut(100,function(){
			oCurrent.removeClass('active');
			oNext.addClass('active');			
			$('.active').fadeIn(500);
		});
	});
	
	/**
	* previous thumbs
	**/ 
	$('#previousThumbs').click(function(){		
		var iStep = 300;
		var iLeft = ((($('#thumbholder_canvas').css('left')).replace('-','').replace('px',''))*1);
		var newPos = (iLeft<=iStep?0:((iLeft-iStep)*1));
		$('#thumbholder_canvas').animate({left: '-'+newPos+'px'},500);
	});
	
	/**
	* next thumbs
	**/ 
	$('#nextThumbs').click(function(){		
		var iStep = 300;
		var iLeft = ((($('#thumbholder_canvas').css('left')).replace('-','').replace('px',''))*1);
		var newPos = (iLeft+iStep);
		$('#thumbholder_canvas').animate({left: '-'+newPos+'px'},500);
	});
	
	
	$('#navigation').fadeTo('fast',0.7);
});

