// JavaScript Document

//#######################
//### INITIALISIERUNG ###
//#######################

//Einzelbreite
var myWidth = 285;

//Anzahl der Elemente
numberOfSlides = jQuery('.topOffer').size();
//Automatische Groessenanpassung
$('#slideInner').css('width', myWidth * numberOfSlides);

var myPos = 0;
var slidesShown = 3;
var scrollBack = numberOfSlides - slidesShown;


//#############################
//### FUNKTIONEN ZUM SLIDEN ###
//#############################

function getRight () {
	
	if(myPos == scrollBack){
		$('#slideInner').animate({
			marginLeft: 0
		}, 1000)
		myPos = 0;
 	 }else{
		myPos++;
		$('#slideInner').animate({
			marginLeft: myWidth*(-myPos)
		}, 1000)
	}
}


function getLeft () {
	
	if(myPos == 0){  
		$('#slideInner').animate({
		marginLeft: -myWidth * (scrollBack)
		}, 1000)
		myPos = scrollBack;
	}else{
    	myPos--;
  		$('#slideInner').animate({
			marginLeft: myWidth*(-myPos)
		}, 1000)
  	}
}


//####################
//### CLICK AUFRUF ###
//####################
	   
$('#arrowRight').click(function() {
	getRight();	
	clearInterval(changeMe);
});

$('#arrowLeft').click(function() {					  
	getLeft();
	clearInterval(changeMe);
});


//############################
//### AUTOMATISCHER AUFRUF ###
//############################
	   
var changeMe = setInterval("getRight()", 5000);
