/* ***********************************************************
viewer.js
Javascript for viewer.asp page in Map Viewer
by Howie Sternberg (howies@snet.net)

Map Viewer is placed in the public domain and is "Freeware". 
Map Viewer may be freely used and redistributed, is provided 
"AS-IS" without warranty of any kind, and there is no technical 
support provided.
--------------------------------------------------------------
History
Sep 2004, Initial code for Map Viewer 2nd Edition
May 2005, Revised for Map Viewer 3rd Edition to only support  
		  W3C DOM compatible browsers
Jul 2005, Revised for Map Viewer 3rd Edition update  
************************************************************ */

// Sets map service
function setMapService(url,mapservice,maptitle,mapaction) {
	// show download message
	showDownloadMessage()
	// submit form
	objMapForm.reset();
	objMapForm.mapserverurl.value = url;
	objMapForm.mapservice.value = mapservice;
	objMapForm.maptitle.value = maptitle;
	objMapForm.mapaction.value = mapaction;
	objMapForm.submit();	
}

// Sets form action
function loadPage(s) {
	// show download message
	showDownloadMessage()
	// submit form
	objMapEvent.cursor = "wait";
	objMapForm.reset();
	objMapForm.action = s;
	objMapForm.submit();
}

// Sets Map Option Level 2 
function setMapOptionLevel2(s) {
	// show download message
	showDownloadMessage()
	// submit form
	objMapEvent.cursor = "wait";
	objMapForm.reset();
	objMapForm.mapoptionlevel2.value = s;
	objMapForm.submit();
}

// Sets Map Option Level 3 
function setMapOptionLevel3(s) {
	// show download message
	showDownloadMessage()
	// submit form
	objMapEvent.cursor = "wait";
	objMapForm.reset();
	objMapForm.mapaction.value = "none";
	objMapForm.mapoptionlevel2.value = "none";
	objMapForm.mapoptionlevel3.value = s;
	objMapForm.submit();
}

// Clears Map Option Level 1 
function clearMapOptionLevel1() {
	// show download message
	showDownloadMessage()
	// submit form
	objMapEvent.cursor = "wait";
	objMapForm.reset();
	objMapForm.mapaction.value = "none";
	objMapForm.mapoptionlevel1.value = "none";
	objMapForm.submit();
}

// Clears Map Option Level 2 
function clearMapOptionLevel2() {
	// show download message
	showDownloadMessage()
	// submit form
	objMapEvent.cursor = "wait";
	objMapForm.reset();
	objMapForm.mapaction.value = "none";	
	objMapForm.mapoptionlevel2.value = "none";
	objMapForm.submit();
}

// Clears Map Option Level 3 
function clearMapOptionLevel3() {
	// show download message
	showDownloadMessage()
	// submit form
	objMapEvent.cursor = "wait";
	objMapForm.reset();
	objMapForm.mapaction.value = "refreshmap";
	objMapForm.mapoptionlevel3.value = "none";
	objMapForm.submit();
}

// open and refresh popup object used to describe maps 
function togglepopup() {
	if (! document.getElementById("mapPopup")) {
		// Create div for popup
		var objMapPopup = document.createElement("div");
		objMapPopup.id = "mapPopup"
		objMapPopup.style.visibility = arguments[0]
		objMapPopup.onclick = closepopup;
		var elemPopupTitle = document.createElement("span");
		elemPopupTitle.id = "mapPopupTitle";
		elemPopupTitle.innerHTML = arguments[1]
		var elemPopupContent = document.createElement("span");
		elemPopupContent.id = "mapPopupContent"
		elemPopupContent.innerHTML = arguments[2]
		objMapPopup.appendChild(elemPopupTitle);
		objMapPopup.appendChild(elemPopupContent);
		document.body.appendChild(objMapPopup)
	} else {
		// replace popup content
		document.getElementById("mapPopup").style.visibility = arguments[0];
		document.getElementById("mapPopupTitle").innerHTML = arguments[1]
		document.getElementById("mapPopupContent").innerHTML = arguments[2]
	}
}

// Remove popup object used to describe maps.
function closepopup() {
	if (document.getElementById("mapPopup")) {
		document.body.removeChild(document.getElementById("mapPopup"));
	}
}
