window.autoRotateDelay = 4000;
window.needsAutoRoll = true;

var rollerData = new Array(
								{'src':'/images/rotation/main.png', 'text':'The Main Window'},
								{'src':'/images/rotation/pointer.png', 'text':'OneTouch translation'},
								{'src':'/images/rotation/addons.png', 'text':'Lots of free dictionaries for a great number of languages'},
								{'src':'/images/rotation/online.png', 'text':'Online Engines Integration'},
								{'src':'/images/rotation/services.png', 'text':'Customizable External Services'},
								{'src':'/images/rotation/history.png', 'text':'The Translation History'},
								{'src':'/images/rotation/quiz.png', 'text':'Words Quiz Game'},
								{'src':'/images/rotation/cards.png', 'text':'Detachable Cards'}
								);
						
var imgArr = new Array;		    
var oldDemoFrame = 0;
var c_lock = 0;

function autoRoll()
{
	if (window.needsAutoRoll)
		showDemoFrameNext(1, true);
}

	
function preload ()
{
	var img = new Image();
	for(var i=0; i<rollerData.length; i++)
	{
		img.src	= rollerData[i].src;
		imgArr[i] = img;
	}
	if (window.needsAutoRoll)
		setTimeout('autoRoll()',window.autoRotateDelay);
}    

function showDemoFrameNext(n, continueAuto) 
{
	if (continueAuto != undefined)
	{
		if (!continueAuto)
		window.needsAutoRoll = false;
	}
	else
		window.needsAutoRoll = false;

	if (window.needsAutoRoll)
		setTimeout('autoRoll()',window.autoRotateDelay);

 var nf = oldDemoFrame + n;
 if (nf<0)
		nf=rollerData.length-1;
	else if (nf>rollerData.length-1)
		nf = 0;
 showDemoFrame(nf, n);
 return false;
}

function showDemoFrame(n, o)
{
 if (oldDemoFrame != n && !c_lock)
	{
 	c_lock = 1;
  var bpDemoLeft1, bpDemoLeft2;
  var slideOfset = $('.con').css('width');
  if (o == undefined || o == 1)
		{
   Left1 = "+="+slideOfset;
			Left2 = "-"+slideOfset;
  }
		else
		{
   Left1 = "-="+slideOfset;
			Left2 = slideOfset;
            }
			$(".con").animate({"left": Left1 ,opacity:"0"}, 400, function(){//left1
                $(".con img").attr("src", rollerData[n].src);
                $(".con span").html('<center>' + rollerData[n].text + '</center>');
                $(".con").css({"left": Left2});//left2
                oldDemoFrame = n;
                $(".con").animate({"left": Left1 ,opacity:"1"}, 400, function(){
                	c_lock = 0;
                });//left1
            });
        }
 return false;
}

preload();

