﻿// JScript File

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Function:		onSelectionChanged(MainMap)
Description:	event handler to report Parcel Selection in details frame
Arguments:		map object
Return:			none
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
function onSelectionChanged (MainMap){
	if (autoSelect == true){
	    var myMap = getMap();
		var mySelection = myMap.getSelection().getMapObjectsEx(null);
		// Make sure just one is selected
		if (mySelection.size() != 1){
			parent.details.location.href="MenuSearch.asp";
		}else{
			// Check for proper layer
			var selection = myMap.getSelection();
			var myCollection = myMap.getSelection().getMapObjectsEx(null);
			var selObject = myCollection.item(0);
	       	myKey = mySelection.item(0).getKey();
			var layerName = selObject.getMapLayer().getName();
			switch(layerName){
				case "Parcel":
						thePage="qryParcel.asp";
					break;
				case "Hydrant":
					thePage="qryHydrant.asp";
					break;
				case "HydrantValve":
					thePage="qryHydrantValve.asp";
					break;
				case "HydrantLead":
					thePage="qryHydrantLead.asp";
					break;
				case "WaterMain":
					thePage="qryWaterMain.asp";
					break;
				case "WaterValve":
					thePage="qryWaterValve.asp";
					break;
				case "WaterLat":
					thePage="qryWaterLat.asp";
					break;
				case "CurbStop":
					thePage="qryWtrStopValve.asp";
					break;
				case "CurbInl":
					thePage="qryCurbInlet.asp";
					break;
				case "ComboManhole":
				case "SanManhole":
				case "StoManhole":
					thePage="qrySewerMH.asp";
					break;
				case "ComboPipe":
				case "SanPipe":
				case "StoPipe":
					thePage="qrySewerPipe.asp";
					break;
				case "SanLat":
					thePage="qrySanLat.asp";
					break;
				case "StreetTrees":
					thePage="qryStreetTree.asp";
					break;
				case "ElectricCable":
					thePage="qryElectricCable.asp";
					break;
				case "JunctionBox":
					thePage="qryJuncBox.asp";
					break;
				case "Lamp":
					thePage="qryLamp.asp";
					break;
				default:
					top.details.location.href="MenuSearch.asp";
					myKey="";
					thePage="";
					break;
			}
			if (thePage != ""){
				top.reportForm.document.writeln("<html>");
				top.reportForm.document.writeln("<body>");
				top.reportForm.document.writeln("<form method='get' target='details' action='"+thePage+"'>");
				top.reportForm.document.writeln("<input type='hidden' name='OBJ_KEYS' value='"+myKey+"'>");
				top.reportForm.document.writeln("<input type='hidden' name='theLayer' value='"+layerName+"'>");
				top.reportForm.document.writeln("<input type='hidden' name='nozoom' value='1'>");
				top.reportForm.document.writeln("</form>");
				top.reportForm.document.writeln("</body>");
				top.reportForm.document.writeln("</html>");
				top.reportForm.document.close();
	
				top.reportForm.document.forms[0].submit();
			}
		}
	}
}

