var isHover = false;
var masterTimeout;
var count;
$(document).ready(function(){	
	//Change Scene every 5 seconde
		setInterval("ChangeScene();", 5000);
	//Don't do animation when mouse is over...
		$(".pics").hover(function(){isHover = true;}, function(){isHover = false;});
});
	 
//Animate the scenes from right to left	 
	function ChangeScene(){
		if (!isHover) {		
			var scenes = $(".scrobbler");
			var currentMargin = parseInt(scenes.css("marginLeft").replace("px", ""));			
			if (count == null)
			{				
				var marAndPad = parseInt($(".scrobbler .pics").css('padding-right'))+parseInt($(".scrobbler .pics").css('padding-left'))+parseInt($(".scrobbler .pics").css('margin-right'))+parseInt($(".scrobbler .pics").css('margin-left'));			
				count = Math.floor(($(".viewer").width())/($(".scrobbler .pics").width()+marAndPad));	
			}				
			scenes.animate({
				
				"marginLeft": (currentMargin - $(".viewer").width())
			}, 4000, switchScenes);
		}
	}

//Take the first 5 scenes and put it at the end. 
	function switchScenes(){
		$(".scrobbler").css("marginLeft", 0);
		$(".scrobbler .pics:lt("+count+")").appendTo(".scrobbler");	
	} 
