function printMap()
{
   var theMap = getMap();
   var url = "./MapPrinter.aspx?MapScale="+theMap.getScale()+"&Lat="+theMap.getLat()+"&Lon="+theMap.getLon()+"&Name="+theMap.getName();    
   var name = "MapPrinter";
   var options = "status=no,directories=no,scrollbars=no,menubar=yes,resizable=yes,width=" + window.width + ",height=" + window.height;
   openWindow(url, name,options);
}


function displayMap(theMap)
{
	parent.frames["details"].document.location.replace("./blank.htm");
	parent.frames["forms"].document.location.replace("./blank.htm");
	parent.frames["menu"].document.location.replace("./SiteNavigation.aspx?map="+theMap);
    var url = "./Viewer.aspx?map="+theMap;    
    var name = "main";
    openWindow(url, name);
}

function invokeDistance()
{
	getMap().viewDistance('M');	
}
function roundNumber(numberField) {
	var rlength = 2; // The number of decimal places to round to
	return Math.round(numberField*Math.pow(10,rlength))/Math.pow(10,rlength);
}

function displayArea()
{
	
	var selected = getMap().getSelection().getMapObjectsEx(null);
	
	var message = "";
	if(selected.size() > 10){
		message += "You have selected more than 10 objects on the map.\n";
		message += "Details will only be provided for the first 10 objects.\n";
		message += "The total area will be calculated for all objects.\n\n\n";
	}
	var total = 0;
	for(i = 0; i < selected.size(); i++){
		var item = selected.item(i);
		if(i < 10){
			message += "\n" + item.getMapLayer().getLegendLabel() +  " - ("  + item.getKey()+ ") -  " + roundNumber(item.getArea());	
		}
		total += item.getArea();
	}
    message += "\n\nTotal in " + getMap().getUnits() + ": " + roundNumber(total);
    alert(message);
    
	
}
