function back()
{
	if(time != 0 && time != 6)
	{
		time--;
		walk();
	}
	if(time == 6)
	{
		 window.location = "/"
	}
}

function forward()
{
	if(time < 11 && time != 5)
	{
		time++;
		walk();
	}
	if(time == 5)
	{
		 window.location = "example.html"
	}
}

function finish()
{
	walkthrough = false;
	alert(document.location.href);
	window.location = ""
}

function loadIndex()
{
	document.searchform.searchbar.focus();
	$.post("php/causesearch.php", {partialStore:"", searchQuery:false},function(data)
	{
		$("#results").html(data);
	});
}

function walk()
{
	walkthrough = true;
	
	if(time == 0)
	{
		document.getElementById("results").innerHTML = '<span id="step1">This is Jatna.  Jatna allows you to raise money for a cause (charity, school, nonprofit organization, etc..)</span>';
		document.getElementById("walk").innerHTML = '';
		document.getElementById("walkthrough").innerHTML = '<img src="images/walkthrough/left.png" id="left" class="arrow" alt="Left" onclick="back()"/><img src="images/walkthrough/right.png" class="arrow" id="left" alt="Right" onclick="forward()"/><h3 id="progress">(1/12)</h3>';
		document.getElementById("progress").innerHTML = '(1/12)';
	}
	else if(time == 1)
	{

		document.getElementById("results").innerHTML = '<img src="images/load.gif" id="load" alt="Loading"/>';
		document.getElementById("walk").innerHTML = '<span id="step2"><p>You can search for a cause here</p></span><img src="images/walkthrough/step2.png" id="step2image"/>';
		document.getElementById("results").innerHTML = '';
		document.getElementById("progress").innerHTML = '(2/12)';		
		loadIndex();

	}
	else if(time == 2)
	{
		document.getElementById("howtospan").innerHTML = '<a href="howto.html"><img src="images/howto/postit.png" id="how" alt="How to Jatna"/></a>';
		document.getElementById("results").innerHTML = '<img src="images/load.gif" id="load" alt="Loading"/>';
		document.getElementById("walk").innerHTML = '<span id="step3"><p>Causes are displayed here</p></span><img src="images/walkthrough/step3.png" id="step3image"/>';
		document.getElementById("results").innerHTML = '';
		document.getElementById("progress").innerHTML = '(3/12)';
		loadIndex();
	}
	else if(time == 3)
	{
		document.getElementById("howtospan").innerHTML = '';
		document.getElementById("results").innerHTML = '<img src="images/load.gif" id="load" alt="Loading"/>';
		document.getElementById("walk").innerHTML = "<span id='step4'><p>You can click here to add a new cause to Jatna</p></span><img src='images/walkthrough/step4.png' id='step4image'/>";	
		document.getElementById("results").innerHTML = '';		
		document.getElementById("progress").innerHTML = '(4/12)';
		loadIndex();
	}
	else if(time == 4)
	{
		document.getElementById("howtospan").innerHTML = '<a href="howto.html"><img src="images/howto/postit.png" id="how" alt="How to Jatna"/></a>';
		document.getElementById("walk").innerHTML = "";
		document.getElementById("results").innerHTML = '<span id="step5"><p>Each time this page is loaded, this box is filled with random causes.</p></span>';
		document.getElementById("progress").innerHTML = '(5/12)';
	}
	else if(time == 5)
	{
		document.getElementById("results").innerHTML = '<img src="images/load.gif" id="load" alt="Loading"/>';
		document.getElementById("walk").innerHTML = "<span id='step3'><p>Choose any cause from this list or click the right arrow to continue</p></span><img src='images/walkthrough/step3.png' id='step3image'/>";
		document.getElementById("results").innerHTML = '';
		document.getElementById("progress").innerHTML = '(6/12)';
		loadIndex();
	}
	else if(time == 6)
	{
		document.getElementById("walk").innerHTML = "<span id='step7'><p>Click here to visit the cause's website</p></span><img src='images/walkthrough/step7.png' id='step7image'/>";
		document.getElementById("progress").innerHTML = '(7/12)';
	}
	else if(time == 7)
	{
		document.getElementById("walk").innerHTML = "<span id='step8'><p>You can search for a store here</p></span><img src='images/walkthrough/step8.png' id='step8image'/>";
		document.getElementById("progress").innerHTML = '(8/12)';
	}
	else if(time == 8)
	{
		document.getElementById("walk").innerHTML = "<span id='step9'><p>Stores are displayed here</p></span><img src='images/walkthrough/step9.png' id='step9image'/>";
		document.getElementById("progress").innerHTML = '(9/12)';
	}
	else if(time == 9)
	{
		document.getElementById("walk").innerHTML = "<span id='step10'><p>Here's the amount from your purchase that we will donate to the cause of your choice</p></span><img src='images/walkthrough/step10.png' id='step10image'/>";
		document.getElementById("progress").innerHTML = '(10/12)';
	}
	else if(time == 10)
	{
		document.getElementById("walk").innerHTML = "<span id='step11'><p>These are our 15 most popular stores</p></span><img src='images/walkthrough/step11.png' id='step11image'/>";
		document.getElementById("progress").innerHTML = '(11/12)';
		loadCause();
	}
	else if(time == 11)
	{
		var url = document.location.href.replace("&walk=true", "");
		document.getElementById("walk").innerHTML = "";
		document.getElementById("results").innerHTML = "<span id='step12'><a href='/'><img src='images/walkthrough/finish.png' alt='Finish' id='finish'/></span>";
		document.getElementById("progress").innerHTML = '';
		document.getElementById("walkthrough").innerHTML = '';
	}
}

