﻿function ShowMsgDemo()
{
	alert("Demonstration only.\nFor playing 'Peter Answers' please visit www.peteranswers.com");
}

function Slide(text, peticion, pregunta, respuesta, truco, paso)
{
	this.text = text;
	this.peticion = peticion;
	this.pregunta = pregunta;
	this.respuesta = respuesta;
	this.truco = truco;
	this.paso = paso;
}

function SlideShow()
{
	this.slides		= new Array();
	this.current	= 0;

	this.AddSlide = function(slide)
	{
		var i = this.slides.length;
		this.slides[i] = slide;
	}

	this.Update = function()
	{
		var slide = this.slides[this.current];
		document.getElementById("txtPeticion").value = this.slides[this.current].peticion;
		document.getElementById("txtPregunta").value = this.slides[this.current].pregunta;
		document.getElementById("pDescTruco").innerHTML = this.slides[this.current].text;
		document.getElementById("pAnswer").innerHTML = this.slides[this.current].respuesta;
		document.getElementById("pNroPaso").innerHTML = this.slides[this.current].paso;
	}

	this.Next = function()
	{
		if (this.current < this.slides.length - 1)
			this.current++;
		else if (this.repeat)
			this.current = 0;

		this.Update();
	}

	this.Previous = function()
	{
		if (this.current > 0)
			this.current--;
		else if (this.repeat)
			this.current = this.slides.length - 1;

		this.Update();
	}
}

Slides = new SlideShow();
Slides.repeat = true;

sld = new Slide("Enter to \"Peter Answers\". As you can see, the engine is based on making a petition before we ask the question:", "Peter, please answer the following question:", "What’s on the table?", "Peter answers: Two remote controllers.", "", "Step 1 to 8");
Slides.AddSlide(sld);

sld = new Slide("For this example we are going to ask: \"What’s on the table?\", what \"Peter\" will answer: \"Two remote controllers\".", "Peter, please answer the following question:", "What’s on the table?", "Peter answers: Two remote controllers.", "", "Step 2 to 8");
Slides.AddSlide(sld);

sld = new Slide("Let’s start with the trick: Instead of writing the petition, we will insert a \"dot\" (.). This is the key to indicate to the program that we are going to write the answer.", ".", "", "", "", "Step 3 to 8");
Slides.AddSlide(sld);

sld = new Slide("But on screen, a \"P\" will appear even if we inserted a \".\"", "P", "", "", "", "Step 4 to 8");
Slides.AddSlide(sld);

sld = new Slide("Now we have to type the answer (two remote controllers). The program hides what we are actually typing and in its place it shows the sentence: \"Peter, please answer the following question\"", "Peter, please answer th", "", "", "", "Step 5 to 8");
Slides.AddSlide(sld);

sld = new Slide("Now we indicate to the program that we finished typing the answer. To do this we insert another \"dot\" (on screen, another letter appears).", "Peter, please answer the", "", "", "", "Step 6 to 8");
Slides.AddSlide(sld);

sld = new Slide("Then we complete the phrase \"Peter, please answer the following question\" (or \"Peter, please answer\" if the answer was shorter) with whatever is missing, in this case: \"following question\". Then we insert colon ( : ) to enable the question space:", "Peter, please answer the following question:", "", "", "", "Step 7 to 8");
Slides.AddSlide(sld);

sld = new Slide("Now we insert the question in the question space, what in this case would be: \"What’s on the table?\". Be sure to put a question mark (?) at the end of the phrase: In that moment, the program shows the answer:", "Peter, please answer the following question:", "What’s on the table?", "Peter answers: Two remote controllers.", "", "Step 8 to 8");
Slides.AddSlide(sld);
