/* When the window loads, call the initForm() function. */
window.onload = initForm;
/* When the window unloads (browser goes to manother location), we call an anonymous function 
without a name and nothing in it. That is because we need to set onunload to something. If not set,
the page is cached and using the back button will not trigger the onload again. */
window.onunload = function() {};

/* Declare function initForm(). */
function initForm() {
	/* Id "newLocation" is used in HTML on the select field. It sets it's property selectedIndex
	to zero, which is the first entry in the select options in HTML. */
	document.getElementById("newLocation").selectedIndex = 0;
	/* Call the function jumpPage() when the menu selection changes. */
	document.getElementById("newLocation").onchange = jumpPage;
}

/* Declare function jumpPage(). */
function jumpPage() {
	/* A variable newLoc gets defined inside the function jumpPage(). 
	It looks up the value chosen in the menu by the user. */
	var newLoc = document.getElementById("newLocation");
	/* New variable. The object newLoc.selectedIndex will be a number from 0 to 5 (because of the choices in HTML). 
	We then get the value of the corresponding menu option (name of the web page). Assign this to the variabl newPage. */
	var newPage = newLoc.options[newLoc.selectedIndex].value;

	/* Conditional that the variable newPage is not empty. If newPage has a value -> go there. */
	if (newPage != "") {
		window.location = newPage;
	}
}
