var delayLength = 9000;
var globalID = 1;
var curItem = "";
var prevItem = "";

function doMove() {
	if($(curItem).attr("id")==$('#sidebarklant a:last').attr("id")){
		curItem = $('#sidebarklant a:first');	
		prevItem = $('#sidebarklant a:last');	
	}else{
		if (curItem==""){
			curItem = $('#sidebarklant a').next('a:first');	
		}else{
			curItem = $(curItem).next('a:first');
		}
		prevItem = curItem.prev();
	}
	
	$(prevItem).find('h3').fadeOut(1000);
	$(prevItem).find('img').fadeOut(1000, function(){
				$(curItem).find('img').fadeIn(2000);
				$(curItem).find('h3').fadeIn(2000);
		});
	
	/*
	$(prevItem).find('h3').animate({
					"marginTop": 0					
				}, "slow", function(){
					$(this).hide("fast");
					$(prevItem).find('img').fadeOut(2000, function(){
							$(curItem).find('img').fadeIn("slow", function(){
    						    $(curItem).find('h3').show("fast");
								$(curItem).find('h3').animate({
											"marginTop": 90
										}, "slow");								
							});
						});
				}
				
	);
	*/
}

$(function(){
	/*
	if ($("#sidebarklant").length > 0 ) { 	   
		$('#sidebarklant a:first img').fadeIn("slow", function(){
			$('#sidebarklant a:first h3').show("fast");										  
			$('#sidebarklant a:first h3').animate({
						"marginTop": 90
					}, { "duration": "slow"});
		});
		
		sliderIntervalID = setInterval(function(){
			doMove();
		}, delayLength);	
	}
	*/
	
	if ($("#sidebarklant").length > 0 ) { 	   
		$('#sidebarklant a:first img').fadeIn(2000); 
		$('#sidebarklant a:first h3').fadeIn(2000);
		
		sliderIntervalID = setInterval(function(){
			doMove();
		}, delayLength);	
	}
	
	$(".sb-fill h2").css("cursor", "pointer");
	$(".sb-fill h2").click(function(){
		if($(this).parent().find('a').length>0){
			url = $(this).parent().find('a').attr('href');
			window.location = url;
		}
	});
});