// aimsDHTML.js
var aimsDHTMLPresent=true;
		// Create a DHTML layer
		function createLayer(name, left, _top, width, height, visible, content) {
			if((isNav5up) && (visible == true)) {
				document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + left + 'px; top:' + _top + 'px; visibility:' + (visible ? 'visible;' : 'hidden;') + '">');
			} else {
				document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + left + 'px; top:' + _top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
			}
			document.writeln(content);
			document.writeln('</div>');
		}

		function createOnClickLayer(name, left, _top, width, height, visible, content) {
			if((isNav5up) && (visible == true)) {
				document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + left + 'px; top:' + _top + 'px; visibility:' + (visible ? 'visible;' : 'hidden;') + '">');
			} else {
				document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + left + 'px; top:' + _top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') +  '" onclick="window.open(\'about:blank\', \'popupWindow\', \'width=\' + popupIdentifyWidth + \',height=\' + popupIdentifyHeight + \',scrollbars=auto,toolbar=no,directories=no,status=no,menubar=no,resizable=yes\'); identify();">');
			}
			document.writeln(content);
			document.writeln('</div>');
		}

		

		// get the layer object called "name"
		function getLayer(name) {
			if(isIE) {
				layer = eval('document.all.' + name + '.style');
			    	return(layer);
			} else if(isNav) {
				var theElements = document.getElementsByTagName("DIV");
				var theObj;
				var j = -1;
				for (i=0;i<theElements.length;i++) {
					if (theElements[i].id==name) theObj = theElements[i].style;
				}
				return theObj
			}
			else
				return(null);
		}


function isVisible(name) {
	  var layer = getLayer(name);
	  if (isNav && layer.visibility == "show")
	    return(true);
	  if (isIE && layer.visibility == "visible")
	    return(true);
	  return(false);
}

// move layer to x,y
function moveLayer(name, x, y) {
  	var layer = getLayer(name);
  	layer.left = x;
   	layer.top  = y;
}

// set layer background color
function setLayerBackgroundColor(name, color) {
  	var layer = getLayer(name);
 	layer.backgroundColor = color;
}

// toggle layer to invisible
function hideLayer(name) {
  	var layer = getLayer(name);
  	layer.visibility = "hidden";
}

// toggle layer to visible
function showLayer(name) {
  	var layer = getLayer(name);
	layer.visibility = "visible";
}

// clip layer display to clipleft, cliptip, clipright, clipbottom
// Not working with Mozilla Milestone 12 (Nav5)
function clipLayer(name, clipleft, cliptop, clipright, clipbottom) {
	var layer = getLayer(name);
	layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
}

// replace layer's content with new content
// not working with Mozilla Milestone 12 (Nav5)
function replaceLayerContent(name, content) {
	if(isIE) {
		var str = "document.all." + name + ".innerHTML = '" + content + "'";
		eval(str);
	}
}

/*
// get window width
function getWinWidth() {
  //koodi poistettu tarpeettomana 21.12.2001 / Jani
}

// get window height
function getWinHeight() {
  //koodi poistettu tarpeettomana 21.12.2001 / Jani}
*/

// toggle Overview Map display
function toggleOVMap() {
	if (imsURL!="") {
		ovIsVisible = !ovIsVisible;
		if (ovIsVisible) {
			//showRetrieveMap();
			//var theString = writeOVXML();
			putExtentOnOVMap();
			showLayer("ovLayer");
			//showLayer("ovShadow");

			showLayer("zoomOVBoxTop");
			showLayer("zoomOVBoxLeft");
			showLayer("zoomOVBoxRight");
			showLayer("zoomOVBoxBottom");
			//sendToServer(imsOVURL,theString,2);

		} else {
			hideLayer("ovLayer");
//			hideLayer("ovShadow");
			hideLayer("zoomOVBoxTop");
			hideLayer("zoomOVBoxLeft");
			hideLayer("zoomOVBoxRight");
			hideLayer("zoomOVBoxBottom");
			//hideLayer("ovBox");
		}
		if (isIE) {
			document.all.theTop.style.cursor = theCursor;
		}
	} else {
		alert("A MapService must be loaded");
	}

}

// plot extent box on overview map
function putExtentOnOVMap() {
	var ovXincre = fullOVWidth / i2Width;
	var ovYincre = fullOVHeight / i2Height;
	var vleft = (left - fullOVLeft) / ovXincre + ovBorderWidth;
	var vright = (right - fullOVLeft) / ovXincre + ovBorderWidth;
	var vtop = (fullOVTop - _top) / ovYincre + ovBorderWidth;
	var vbottom = (fullOVTop - bottom) / ovYincre + ovBorderWidth;

	if(isNav5up) {
		moveLayer("zoomOVBoxTop",vleft,vtop);
		moveLayer("zoomOVBoxBottom",vright-cornerOffset,vbottom-cornerOffset);
		moveLayer("zoomOVBoxLeft",vleft,vbottom-cornerOffset);
		moveLayer("zoomOVBoxRight",vright-cornerOffset,vtop);
	} else {
		clipLayer("zoomOVBoxTop",vleft,vtop-ovExtentBoxSize,vright,vtop);
		clipLayer("zoomOVBoxLeft",vleft-ovExtentBoxSize,vtop-ovExtentBoxSize,vleft,vbottom);
		clipLayer("zoomOVBoxRight",vright,vtop-ovExtentBoxSize,vright+ovExtentBoxSize,vbottom);
		clipLayer("zoomOVBoxBottom",vleft,vbottom-ovExtentBoxSize,vright,vbottom);
	}

}

function boxIt(theLeft,theTop,theRight,theBottom) {
	if (isNav5up) {
		moveLayer("zoomBoxTop",theLeft,theTop);
		moveLayer("zoomBoxBottom",theRight-cornerOffset,theBottom-cornerOffset);
		moveLayer("zoomBoxLeft",theLeft,theBottom-cornerOffset);
		moveLayer("zoomBoxRight",theRight-cornerOffset,theTop);

	} else {
		clipLayer("zoomBoxTop",theLeft,theTop,theRight,theTop+ovBoxSize);
		clipLayer("zoomBoxLeft",theLeft,theTop,theLeft+ovBoxSize,theBottom);
		clipLayer("zoomBoxRight",theRight-ovBoxSize,theTop,theRight,theBottom);
		clipLayer("zoomBoxBottom",theLeft,theBottom-ovBoxSize,theRight,theBottom);

	}
}

