<!-- Menu Pop Down Manager: Copyright 2004, University at Buffalo Educational Technology Center. All rights reserved. 
//This script was written by Thomas Slomka, tslomka@buffalo.edu, to manage page navigation for staff and faculty web based teaching tools.
//reguires companion script "menuPopDown[name].js"
//You may reuse this script provided this copyright statement remains intact 
//

//manages the form action as a pop up menu
function popaplace(form) {
	//alert("popaplace = " + form);
	var formindex=form.selectedItem.selectedIndex;
	window.location=form.selectedItem.options[formindex].value;
}

//manages the form action as a go button menu
function goaplace(id) {
	//display id
	//alert("goaplace = " + id.name);
	//parse form selection based on id
	//alert("goaplace  formindex = " + id.selectedItem.selectedIndex);
	var formindex= id.selectedItem.selectedIndex;
	//alert("goaplace  selected item = " + id.selectedItem.options[formindex]);
	if (id.selectedItem.options[formindex].value != "false"){
		idArray =  id.selectedItem.options[formindex].value.split(",");
		//create path tools
		myServer = location.href.split("/");
		if (idArray[0] == "showValues") {
			//show function values
			alert("myServer[2] = " + myServer[2] + "\rcurrent document = " + location.pathname + "\r\rid Array 0 (action) = " + idArray[0] + "\rid Array 1 (location) = " + 
				idArray[1] +  "\rid Array 2 (Title) = " +  idArray[2] +  "\rid Array 3 (width) = " +  idArray[3] +  "\rid Array 4 (height) = " +  idArray[4] )
		}else{
			 // process form selection
			if (idArray[0] == "open"){
				testId = idArray[1].split("/");
				//alert(testId);
				if (testId[0] == "http:"){
					opentrece(idArray[1] +"," + idArray[2] + "," + idArray[3] + "," + idArray[4]);
				}else{
					opentrece("http://" + myServer[2] + idArray[1] +","+idArray[2] +","+idArray[3] +","+idArray[4]);
				}
			}else{
				//testId = idArray[1].split("/");
				testIdb = idArray[1].split(":");
				//alert("\"" + testId[0] + "\"");
				if (testIdb[0] == "http"){
					//alert("send url \"" + idArray[1] + "\"");
					gotrece(idArray[1]);
				}else if (testIdb[0] == "mailto"){
					//alert("send mail \"" + idArray[1] + "\"");
					gotrece(idArray[1]);
				}else{
					//alert("build url \"" + "http://" + myServer[2] + idArray[1] + "\"");
					gotrece("http://" + myServer[2] + idArray[1]);
				}
			}
		}
	}
}



// opens selected options in current window or when a go button is pushed
// To jump to location when form is interacted with: paste the [following] into option value [javascript:gotrece('YourAbsoluteURL');]
function gotrece(newUrl) {
	//alert("gotrece = \"" + newUrl + "\"");
	window.location = newUrl;
}

// opens selected options in new window or when a go button is pushed
// To jump to location when form is interacted with: paste the [following] into option value [javascript:opentrece('YourAbsoluteURL,YourWindowID[do not include spaces - should be unique],WindowWidth,WindowHeight');]
function opentrece(popUrl) {
	//alert("opentrece = " + popUrl);
	myWindow = popUrl.split(",");
	window.open(myWindow[0],myWindow[1],"toolbar=yes,status=yes,scrollbars=yes,location=yes,directories=yes,menubar=yes,resizable=yes,width="+myWindow[2]+",height="+myWindow[3]);
}

// End  Menu Pop Down Manager -->
