

// Variable to set select parcel.
var parcelValue = 0;
var highLiteLayer;
function onViewChanged(MyMap) 
{

var indexMap = top.banner.indexMapFrame.getIndexMap();
	if (indexMap != null){
		setTimeout("top.banner.indexMapFrame.ShowExtent()", 1000);
		//top.banner.indexMapFrame.ShowExtent();
	}
highlite();
hideMapLoading();	 
}
	
function getMap()
{		
	if (navigator.appName == "Netscape")
		return document.MyMap;
	else
		return MyMap;		
}
function MapBusyCheck()
{
	map = getMap();
	var MapIsBusy = map.isBusy();
	if (MapIsBusy)
	{
		if (navigator.appName == "Netscape")
		{
		}
		else
		{
		alert("The Viewer is busy. Please try again in a few seconds.");
		map.stop();		
		}
	}
}
function mgSelect()
{
	getMap().selectMode();
}
function mgPan()
{
	getMap().panMode();
}
function mgZoomIn()
{
	getMap().zoomInMode();
}
function mgZoomOut()
{
	getMap().zoomOutMode();
}
function mgZoomPrevious()
{
	getMap().zoomPrevious();
}
function mgZoomGoto()
{
	getMap().zoomGotoDlg();
}
function mgZoomX()
{
	getMap().zoomOut();
}
function mgPrint()
{
	getMap().pageSetupDlg()
	getMap().printDlg()
}
function mgZoomGotoAddress(onLayer,cat,val,key,sc)
{
	MapBusyCheck();
	map = getMap();		
	layer=map.getMapLayer(onLayer);
	if(layer.isVisible() == false)
	layer.setVisibility(true);
	getMap().zoomGotoLocation(cat,val,sc);
	//Global variables
	parcelValue = key;
	highLiteLayer = onLayer;
		
}
/*function SelectObject()
{
if (parcelValue == 0)
return;
MapBusyCheck(); 
map = getMap();
alert(parcelValue);

	  //retrieve layer object
	   var layer = map.getMapLayer("Landroll Parcels");
	  
	  //Was layer found?
	   if (layer==null)
	   {
	     alert ("Error:  Layer not found!");
	     return;
	   }
	    
	  //Look for object with the specified key
	   var MapObject = layer.getMapObject('5');
	   
	   if(MapObject == null)
	   { 
	     alert ("Error:  No map object with the specified key!");
	     return;
	   }
	 
	   //Create selection collection and select object
	    var SelectedObjects = map.getSelection();
	    SelectedObjects.addObject(MapObject, false);  //no event capture
		parcelValue = 0;
}*/
function highlite()
{
	if (parcelValue != 0)
	{
	   // Get MGMap object
	   MapBusyCheck();
	   var map = getMap();   
	   var mapSel = map.getSelection();
	   var mapLayer = map.getMapLayer(highLiteLayer);
	   var mapObjects = map.createObject("MGCollection");
	   var mapObj = mapLayer.getMapObject(parcelValue);
	   
		   if (mapObj != null)
			   mapObjects.add(mapObj);
	   
	   // Add the features in the vector to the selection
	   mapSel.clear();
		 if (mapObjects.size() > 0)
			
		mapSel.addObjectsEx(mapObjects, false);
		map.viewReport('Parcel Report');
	parcelValue=0;
	
	}
}
// Detects when a selection is made and runs the mgReport() function.
function onSelectionChanged(MyMap)
{
	MyMap.viewReport('Parcel Report');
	MyMap.viewReport('Fire Hydrant');
}
function onViewChanging(MyMap)
{
//show map loading gif.
showMapLoading()
}
function showMapLoading() {
	var ie5=document.all&&document.getElementById;

	if ( ie5 ) {
		
		
			// get the frame width and height
			var frameWidth = document.body.clientWidth;
			var frameHeight = document.body.clientHeight;
			
						
			// default width and height
			var width = 159;
			var height = 33;

			// The loading comment should start half of its width from the centre of the frame ( and same for height )			
			var divX = (frameWidth / 2) - ( width / 2 );
			var divY = (frameHeight / 2) - ( height / 2 );	
			
			// use the div styles
			document.getElementById("mapLoadingDiv").style.width = width;
			document.getElementById("mapLoadingDiv").style.height = height;
			document.getElementById("mapLoadingDiv").style.left = divX;
			document.getElementById("mapLoadingDiv").style.top = divY;
			document.getElementById("mapLoadingDiv").style.display = '';
			document.getElementById("mapLoadingFrame").src = "assets/mapLoading.gif";
		
	}	
	
}
function hideMapLoading() {
	var ie5=document.all&&document.getElementById;

	if ( ie5 ) {
		
			document.getElementById("mapLoadingDiv").style.display="none";
		}
	
}
function onBusyStateChanged(MyMap, busyState)
{
	if(busyState==true){
	showMapLoading();
	}
	else{
	hideMapLoading();
	}
}
function runFunctiononIndex(){
	top.banner.indexMapFrame.ShowExtent();
}
