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)
			{
				count = Math.floor((-(currentMargin - $(".viewer").width()))/$(".scrobbler .pics").width());		
			}				
			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");	
	} 
