var	newTitle;
var	newContent;
var displayIndex_g = 0;
var numberOfSections_g = 4;

var title1_g = "Improve your maths skills";
var text1_g = "Improve and enhance your ability to solve everyday maths questions by using simple combination of additions, subtractions, multiplications and divisions. The questions are randomly presented in a number of different formats and styles helping you to develop your analytical skills.<div class='moreInfo'>For all the family from ages of 8 and upwards.</div><br>Also parents, aunts, uncles and grandparents, now with the facility of gifting an app from iTunes (in the popup menu next to the price), give a fun educational tool to your loved ones.";
var caption1_g = "Main screen"

var title2_g = "Challenge others to a game";
var text2_g = "Play a game with a group of friends or family members, either when they are next to you, or over the internet. Alternatively you can play an open game with people from all over the world.<div class='moreInfo'>Challenge your parents, aunts or uncles and see how bad they really are.</div>";
var caption2_g = "Setting up to connect and play with others"

var title3_g = "Review your results";
var text3_g = "Your results are saved automatically, which allows you to look back on them, and see how you had done.";
var caption3_g = "List of results for a game"

var title4_g = "Compare your score";
var text4_g = "See how you had done, compared to all the others playing the same game.";
var caption4_g = "Chart comparing results"

// var title5_g = "Tile 5";
// var text5_g = "Text 5";
// 
// var title6_g = "Tile 6";
// var text6_g = "Text 6";
// 
// var title7_g = "Tile 7";
// var text7_g = "Text 7";

//: ===================================================================================== ://
function test()
{
	alert('Just saying hello');
}

//: ===================================================================================== ://
function nextSection( button ) {
	button.up();
	if( displayIndex_g < numberOfSections_g - 1 ){
		displayIndex_g ++;
		showSection();
	}
}
//: ===================================================================================== ://
function previousSection( button ) {
	button.up();
	if( displayIndex_g > 0 ){
		displayIndex_g --;
		showSection();
	}
}
//: ===================================================================================== ://
function showSection( ) {
	displayScreen( displayIndex_g );
	selectIndictor( displayIndex_g + 1 );
	var fx = new FX("textBlock", { 'opacity': { to: '0'}} , 0.3, 'easeOut', changeText, this );
	fx.start();		
}

//: ===================================================================================== ://
function displayText () {
	var theNumber = displayIndex_g + 1;
	var theTitle;
	var theText;
	var	caption;
	
	if( theNumber == 1 ){
		theTitle = title1_g;
		theText = text1_g;
		caption = caption1_g;
	}
	else if( theNumber == 2 ){
		theTitle = title2_g;
		theText = text2_g;
		caption = caption2_g;
	}
	else if( theNumber == 3 ){
		theTitle = title3_g;
		theText = text3_g;
		caption = caption3_g;
	}
	else if( theNumber == 4 ){
		theTitle = title4_g;
		theText = text4_g;
		caption = caption4_g;
	}
	
	document.getElementById('TB_title').innerHTML = theTitle;
	document.getElementById('TB_text').innerHTML = theText;
	document.getElementById('annotation').innerHTML = caption;
	showTextBox();
	
}

//: ===================================================================================== ://
function changeText () {
	displayText ();
	// document.getElementById('TB_title').innerHTML = newTitle;
	// document.getElementById('TB_text').innerHTML = newContent;
	// showTextBox();
}

//: ===================================================================================== ://
function showTextBox () {
	var fx = new FX("textBlock", { 'opacity': { to: '1'}} , 0.3, 'easeOut' );
	fx.start();
}

//: ===================================================================================== ://
function goToNextSection () {
	if( displayIndex_g < numberOfSections_g - 1 ){
		displayIndex_g ++;
		displayScreen( displayIndex_g );
	}
}

//: ===================================================================================== ://
function goToPreviousSection () {
	if( displayIndex_g > 0 ){
		displayIndex_g --;
		displayScreen( displayIndex_g );
	}
}


//: ===================================================================================== ://
function selectIndictor ( indNumber ) {
	document.images["ind1"].src = "images/dotInactive.jpg";
	document.images["ind2"].src = "images/dotInactive.jpg";
	document.images["ind3"].src = "images/dotInactive.jpg";
	document.images["ind4"].src = "images/dotInactive.jpg";
	// document.images["ind5"].src = "images/dotInactive.jpg";
	// document.images["ind6"].src = "images/dotInactive.jpg";
	// document.images["ind7"].src = "images/dotInactive.jpg";
	
	var activeIndicator = "ind"+indNumber;
	document.images[activeIndicator].src = "images/dotActive.jpg";
}

//: ===================================================================================== ://
function displayScreen ( index ) {
	var	moveBy = 0;
	if( index ){
		moveBy = -( index * 240 );
	}
	var fx = new FX("stripImage", { 'left': { to: moveBy}}, 0.6, 'cubicInOut' );
	fx.start();
	
	// body...
}


//: ===================================================================================== ://
function showElements () {
	// displayText();
	// return;
	// // && topImage.complete && stripImage.complete 
	if ( !( stripImage.complete && topImage.complete && stripImage.complete ) ){
		window.setTimeout('showElements()',100);
	}
	else{
		// displayText();
		var fx = new FX( "phoneOuter", { 'opacity': { to: '1'}} );
		fx.start();
	}
}





