function position(go_to)
{
	// hide all the elements
	var x = 1;
	while(x < step_length)
	{
		document.getElementById("step" + x).style.display = "none";
		x++;
	}
	document.getElementById("next").style.display = "inline";
	document.getElementById("previous").style.display = "inline";	
	document.getElementById("new").style.display = "none";

	
	switch(go_to)
	{
		case "+":
			step++;
			break;
		case "-":
			step--;
			break;
		default:
			step = go_to;
			break;
	}

	document.getElementById("step" + step).style.display = "block";	
	window.location = "#" + step;

	if(step == 1)
	{
		document.getElementById("step1").style.display = "block";
		document.getElementById("previous").style.display = "none";
	}
	
	if(step == step_length - 1)
	{
		document.getElementById("next").style.display = "none";
		document.getElementById("new").style.display = "inline";
	}

}



window.onload = function()
{
	var location = window.location.toString();
	var location = location.split("#");
	
	if(location.length == 2)
	{
		if(location[1] == "print")
		{
			printerFriendly()
		}
		else
		{
			position(location[1]);
		}
	}
	else
	{

		document.getElementById("step1").style.display = "block";
		document.getElementById("previous").style.display = "none";
	}
}

function printerFriendly()
{
	var i = 1;
	while(i < step_length)
	{
		document.getElementById("step" + i).style.display = "block";
		i++;
	}
	document.getElementById("position").style.display = "none";
	window.location = "#print";
	window.print();
}


function linkTo() 
{
	var message = "<div><h3>Email or IM Link</h3>" +
				  "<p><input type='text' value='" + window.location + "' /></p>" + 
				  "<h3>HTML Link</h3>" +
				  "<p><input type='text' value='<a href=\"" + window.location + "\">Fraction Frog</a>' /></p>" +
				  "<p><a href='javascript:linkTo()'>Close</a></p> </div>";
	
	el = document.getElementById("overlay");
	el.innerHTML = message;
	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
	window.scrollTo(0,0);
}