$(document).ready(function() {
	oIndexpage = new indexpage();
	oIndexpage.fetchNextScreen();
});

function indexpage()
{
	var timerID = null;
	var timerRunning = false;
	var delay = 5000;
	var screenIndex = 0;
	
	var screenPaths = ["/images/press/start.png",
	                   "/images/startScreen.png",
	                   "/images/IMG_0389.PNG",
	                   "/images/IMG_0391.PNG",
	                   "/images/IMG_0392.PNG",
	                   "/images/IMG_0312.png",
	                   "/images/news-img002.png"];
	                   
	var screenMax = screenPaths.length;                   

	this.fetchNextScreen = function()
	{
		if(screenIndex < screenMax - 1)
			screenIndex++;
		else
			screenIndex = 0;		
		
		this.animate();		
	};
	
	this.animate = function() 
	{
		var that = this;
		$('.iPhoneScreen').fadeOut('slow', function() { that.show(); });
	};

	this.show = function() 
	{
		var that = this;
		var sSnippet = "<img src=\""+screenPaths[screenIndex]+"\" width=\"270px\"/>";
		
		$('.iPhoneScreen').html(sSnippet).fadeIn(1000, function() {that.startTimer();} );		
	};
	
	this.startTimer = function()
	{
		that = this;
		timerID = self.setTimeout('that.fetchNextScreen()', delay);
	};
}