//######################################################################################################
//                                            CAROUSELLE ANIMATIONS
// BE SURE TO START THE CAROUSELLE AND END THE CAROUSELLE WITH A DIV THAT CONTAINS THE EXACT SAME CONTENT
// THIS IS REQUIRED IN ORDER FOR THE LOOPING TO WORK SMOOTHLY AND CONTINUOUSELY
//########################################################################################################
count=1;
timer=false; //-------------------------used for animations
caro="scrollerDiv"; //-------------the name of the panel to scroll
direction = "left";
jump=10;				//-------------------------------how many pixels the panel will move per call
panelWidth = 750;		//-------------------------------the pixel width of an individual panel
numberOfPanels = 7;		//-------------------------------how many panels that are in the carouselle
carouselleABSLeft = 0 ;//- panelWidth;		//----------this is the starting position of the scroller
carouselleWidth = (panelWidth*numberOfPanels)+1; //-panelWidth; // - carouselleABSRight;		//----------typically this is the width of the entire scrolling div
carouselleABSRight = carouselleWidth - panelWidth;	//----------typically this is the width of one of the panels in the carouselle
padding=0;
scrollDelay = 8000;
startPos = 0 ;
function moveImageDir()
{
	document.getElementById(caro).style.width = (carouselleWidth*numberOfPanels)+"px";
	imgobj = document.getElementById(caro).style;
	objectX = document.getElementById(caro).style.left;
	objectX = Number(objectX.replace("px",""));
	//-------------------------------------------------------updates the text in the info panel
	document.getElementById('infoPanel').innerHTML = objectX;
	if(direction=="left" && objectX>=carouselleABSLeft)
		{
		if(objectX <=carouselleABSLeft)
			{
				document.getElementById(caro).style.left = carouselleABSLeft+"px";
				stopAnimation();
				}else{
				currentPix=objectX-jump;
				imgobj.left=currentPix+"px";
				count=count+jump;
			}
		}else if(direction=="right" && objectX<=carouselleABSRight)
		{
			if(objectX >=carouselleABSRight )
			{
				document.getElementById(caro).style.left =carouselleABSRight+"px"; 
				stopAnimation();
				}else{
				currentPix=objectX+jump;
				imgobj.left=currentPix+"px";
				count=count+jump;
			}
		}
		if(count%panelWidth==1){stopAnimation();}
		if(currentPix>0 && direction=="right")
			{
				document.getElementById(caro).style.left =(0-carouselleWidth)+panelWidth+"px";
				//stopAnimation();
				currentPix=-(carouselleWidth -1);
				count=count-jump;
			}
		if(currentPix==-carouselleWidth && direction=="left")
			{
				document.getElementById(caro).style.left=startPos+"px";
				stopAnimation();
				currentPix=(carouselleWidth-1);
				count=count+jump;
			}
}
function startAnimation() {
  if (!timer) timer = setInterval("moveImageDir()",10);
}
function stopAnimation() {
  if (!timer) return false;
  clearInterval(timer);
  timer = null;
  obj = document.getElementById(caro).style.left;
}
function startCarouselle()
{
	count=1;
	carouselleAnimation = setInterval("direction='right';startAnimation();moveImageDir();",scrollDelay);
}
function clearCarouselle()
{
	clearInterval(carouselleAnimation);
	carouselleAnimation= null;
}
function setCarouselle(pos)
{
	clearCarouselle();
	document.getElementById(caro).style.left=pos+"px";
	
	setTimeout("startCarouselle()",scrollDelay);
}