	// evaluate MapFrame for easy editing of frame source.
	var MapFrame = eval(parent.frames.MapFrame);
	var TextFrame = eval(parent.frames.TextFrame);
	if(parent.browser){
		mapTipdiv = eval(parent.frames.MapTips.document.all.tips);
	}else{
		mapTipdiv = eval(parent.frames.MapTips.document);
	}
	var arrSelection = new Array();
		Array.prototype.remove = remove;
		Array.prototype.add = push;

function layerActivation(frm){
	document.forms[0].ActiveLayerName.value = MapFrame.document.forms[0].ActiveLayerName.value;
	document.forms[0].ActiveLayerId.value = MapFrame.document.forms[0].ActiveLayerID.value;
	MapFrame.showLayer('LoadData');
	frm.submit();
}	
	var glbArrLine = new Array();
	var glbArrPoint = new Array();	
	
function DynamicLayerActivation(control,layer,visible,type){
	var nuLst;
	if(type == "line"){
		nuLst = layer + "||" + visible;
		addMeLine(control,nuLst);
		//MapFrame.document.forms[0].DynamicLayerToggleName.value = layer;
		//MapFrame.document.forms[0].DynamicLayerToggleVisible.value = visible;
	}else{
		nuLst = layer + "||" + visible;
		addMePoint(control,nuLst);
		//MapFrame.document.forms[0].DynamicPointToggleName.value = layer;
		//MapFrame.document.forms[0].DynamicPointToggleVisible.value = visible;
	}	
	//MapFrame.document.forms[0].Tool2.value = MapFrame.document.forms[0].Tool.value;
	//MapFrame.document.forms[0].Tool.value = 'ToggleDynamicLayer';	
	//MapFrame.showLayer('LoadData');
	//MapFrame.document.forms[0].runMap.value = 1;	
	//MapFrame.document.forms[0].submit();
}	
function processLayerSubmit(){
	var lstLine = array2List(glbArrLine);
	var lstPoint = array2List(glbArrPoint);
	if(lstLine !=""){
		MapFrame.document.forms[0].DynamicLayerToggleName.value = lstLine;
	}
	if(lstPoint !=""){
		MapFrame.document.forms[0].DynamicPointToggleName.value = lstPoint;
	}
	MapFrame.showLayer('LoadData');
	MapFrame.document.forms[0].runMap.value = 1;	
	MapFrame.document.forms[0].submit();
}
function addMeLine(control,val){
	if(control.checked){
		glbArrLine = glbArrLine.add(val);
	}else{
		glbArrLine = glbArrLine.remove(val);
	}
}
function addMePoint(control,val){
	if(control.checked){
		glbArrPoint = glbArrPoint.add(val);
	}else{
		glbArrPoint = glbArrPoint.remove(val);
	}
}	
function chkMouseUp(e) { 
	if(browser && event.button==2){	
		return false;
	}
	setSize()
	var Tool = document.MapForm.Tool.value
	if(Tool=="ZoomOut"){
		MapFrame.showLayer('LoadData');
		processZoomOut();
		return false;		
	}else if (Tool=="Identify"){
		MapFrame.showLayer('LoadData');
		zooming = false;
		processIdentify();
		return false;
	}else if (Tool=="Buffer"){
		MapFrame.showLayer('LoadData');
		processBuffer();
		return false;
	}else if (Tool =="ZoomLast"){
		MapFrame.showLayer('LoadData');
		processZoomLast();
		return false;	
	}else if (zooming || Tool=="SBR"){
		stopZoomBox(e);
		processZoomin();
		return false;
	}else if (Tool=="Pan"){
		stopPan(e);
		//alert("showLayer");
		MapFrame.showLayer('LoadData');
		processMap('envelope',document.forms[0].MinX.value-xOffset,document.forms[0].MinY.value-yOffset,document.forms[0].MaxX.value-xOffset,document.forms[0].MaxY.value-yOffset);
		return false;
	}else if(Tool=="GetLatLong"){
		parent.frames[9].getLatLong(mouseLat,mouseLong);
		self.blur();
		return false;
	}else if(Tool=="ClickSelect"){
		processClickSelect();
		return false;
	}else if(Tool=="SelectClick"){
		processSelectClick();
		return false;		
	}else if(Tool=="AddNote"){
		processAddNote();		
		return false;
	}else{
		stopZoomBox(e);
		return false;
	}
}
function processZoomin(){
	if(toLong+""=="undefined"){
		MapFrame.document.forms[0].MapX.value = x2;
		MapFrame.document.forms[0].MapY.value = y2;
		processMap('envelope',mouseLong,mouseLat,0,0);
	}else{
		if(x1>x2 && y2>y1){
			processMap('envelope',toLong,toLat,fromLong,fromLat)
		}else{
			processMap('envelope',fromLong,fromLat,toLong,toLat)
		}
	}
}
function processZoomLast(){
	if(MapFrame.document.forms[0].lastExtent.value == ""){
		alert("There is no last extent available for showing.");
	}else{
		MapFrame.document.forms[0].runMap.value = 1;
		MapFrame.document.forms[0].Tool2.value = MapFrame.document.forms[0].Tool.value;
		MapFrame.document.forms[0].Tool.value = "ZoomLast";
		MapFrame.document.forms[0].submit();
	}
}

function processZoomSelected(){

	if(MapFrame.document.forms[0].SelectedEnvelope.value == ""){
		alert("There are no selections to zoom to.");
	}else{
		MapFrame.document.forms[0].runMap.value = 1;
		MapFrame.document.forms[0].Tool2.value = MapFrame.document.forms[0].Tool.value;
		MapFrame.document.forms[0].Tool.value = "ZoomSelected";
		MapFrame.document.forms[0].submit();
	}
}

function processAddNote(){
	var clickMapX = RoundValue(ScreenToGeo( "Longitude", (mouseX-hspc)),5);
	var clickMapY =RoundValue(ScreenToGeo( "Latitude", (mouseY-vspc)),5);
	if(parent.TextFrame.document.title = "AddNote"){
		TextFrame.document.forms[0].X.value = clickMapX;
		TextFrame.document.forms[0].Y.value = clickMapY;		
	}	
	MapFrame.document.forms[0].NoteX.value = clickMapX;
	MapFrame.document.forms[0].NoteY.value = clickMapY;	
	MapFrame.document.forms[0].runMap.value = 1;	
	MapFrame.document.forms[0].Tool.value = "AddNote";
	MapFrame.document.forms[0].submit();
	return false;

}

function processIdentify(){
	
	MapFrame.document.forms[0].runMap.value = 1;
	MapFrame.document.forms[0].MapX.value = (mouseX+0);
	MapFrame.document.forms[0].MapY.value = (mouseY+0);
	MapFrame.document.forms[0].Tool.value = "Identify";
	MapFrame.document.forms[0].ident_Lat.value = mouseLat;
	MapFrame.document.forms[0].ident_Long.value = mouseLong;
	MapFrame.document.forms[0].submit();

	//var actLayerID = MapFrame.document.forms[0].ActiveLayerID.value;
	//var actLayerName = MapFrame.document.forms[0].ActiveLayerName.value;
	//parent.frames.TextFrame.location = "identify/identify.cfm?layer=" + actLayerID + "&Layername=" +actLayerName + "&X=" + mouseLat + "&Y=" + mouseLong + "&pixX=" + mouseX + "&pixY=" + mouseY;
	return false;

}
function processBuffer(){
	var actLayerID = MapFrame.document.forms[0].ActiveLayerID.value;
	var actLayerName = MapFrame.document.forms[0].ActiveLayerName.value;
	MapFrame.document.forms[0].ident_Lat.value = mouseLat;
	MapFrame.document.forms[0].ident_Long.value = mouseLong;
	MapFrame.document.forms[0].runMap.value = 1;
	MapFrame.document.forms[0].submit();
	return false;

}
function processPan(e){
	stopPan(e);
	MapFrame.document.forms[0].MapX.value = x2;
	MapFrame.document.forms[0].MapY.value = y2;
	MapFrame.document.forms[0].runMap.value =1;
	alert("here")
	MapFrame.document.forms[0].submit();
}

function processZoomOut(e){
	//alert("left: " + left + " right: " + right + " top: " + top + " bottom: " + bottom);
	stopZoomBox(e);
	var zDebug = false;
	var zWidth = Math.abs(x2 -x1);
		
	var zHeight = Math.abs(y2-y1);
		
	//var xRatio = zWidth / iWidth;		
	//var yRatio = zHeight / iHeight;
	if (zWidth < 10) zWidth = 250;
	if (zHeight < 10) zHeight = 250;
	
	var xRatio = iWidth / zWidth;		
	var yRatio = iHeight / zHeight;
	
	var xAdd = (xRatio * xDistance) / 2;
	var yAdd = (yRatio * yDistance) / 2;
	var eLeft =parseInt(left) - parseInt(xAdd)
	var eRight = parseInt(right) + parseInt(xAdd)
	var eTop = parseInt(top) + parseInt(yAdd)
	var eBottom = parseInt(bottom) - parseInt(yAdd);
	
	if(zDebug){
		alert("zWidth: " + zWidth);	
		alert("ZHeight: " + zHeight);
		alert("iWidth: " + iWidth);
		alert("iHeight: " + iHeight);
		alert("XRatio: " + xRatio);
		alert("YRatio: " + yRatio);
		alert("Left: " + left);
		alert("Right: " + right)
		alert("Top: " + top);
		alert("Bottom: " + bottom);
		alert("XDistance " + xDistance);
		alert("YDistance: " +yDistance)
		alert("XADD: " + RoundValue(xAdd,3) + "\nYADD: " + RoundValue(yAdd,3));
		alert("ELeft: " + eLeft + "\nERight: " + eRight + "\nETop: " + eTop + "\nEBottom: " + eBottom)
	}
	processMap('envelope',eLeft,eBottom,eRight,eTop);
	return false;
	
	
	/*
	
	MapFrame.document.forms[0].MapX.value = mouseX;
	MapFrame.document.forms[0].MapY.value = mouseY;
	MapFrame.document.forms[0].runMap.value =1;
	MapFrame.document.forms[0].submit();*/
}

function processClickSelect(){
	MapFrame.document.forms[0].MapX.value = (mouseX+0);
	MapFrame.document.forms[0].MapY.value = (mouseY+0);
	MapFrame.document.forms[0].ident_Lat.value = mouseLat;
	MapFrame.document.forms[0].ident_Long.value = mouseLong;
	MapFrame.document.forms[0].runMap.value =1;
	MapFrame.document.forms[0].submit();
}

function processSelectClick(){
	MapFrame.document.forms[0].MapX.value = (mouseX+0);
	MapFrame.document.forms[0].MapY.value = (mouseY+0);
	MapFrame.document.forms[0].ident_Lat.value = mouseLat;
	MapFrame.document.forms[0].ident_Long.value = mouseLong;
	MapFrame.document.forms[0].runMap.value =1;
	MapFrame.document.forms[0].Tool.value = "SelectClick";
	MapFrame.document.forms[0].submit();
}

function processMap(type){
	switch(type){
		case 'point':
			if(arguments.length < 3){
				alert("There are not enough arguments passed to perform this function");
				return false;
			}
			var intX = arguments[1];
			var intY = arguments[2];
			
			MapFrame.document.forms[0].myMinX.value = intX;
			MapFrame.document.forms[0].myMinY.value = intY;
			MapFrame.document.forms[0].myMaxX.value = intX;
			MapFrame.document.forms[0].myMaxY.value=  intY;
			MapFrame.document.forms[0].Tool2.value = document.forms[0].Tool.value;
			MapFrame.document.forms[0].Tool.value="ZoomTo";
			
			
			break;
		case 'envelope':
			if(arguments.length < 5){
				alert("There are not enough arguments passed to perform this function");
				return false;
			}
			var intX = arguments[1];
			var intY = arguments[2];
			var intX2 = arguments[3];
			var intY2 = arguments[4];

			MapFrame.document.forms[0].myMinX.value = intX;
			MapFrame.document.forms[0].myMinY.value = intY;
			MapFrame.document.forms[0].myMaxX.value = intX2;
			MapFrame.document.forms[0].myMaxY.value = intY2;
	}
		document.forms[0].runMap.value = 1;

		document.forms[0].submit();
}
function changeTool(btn){
	var measFlag = false;
	var flag = false;
	var msg = "";
	switch(btn){
		case "ZoomExtent":
			MapFrame.document.forms[0].Tool2.value=MapFrame.document.forms[0].Tool.value;
			MapFrame.document.forms[0].Tool.value='ZoomExtent';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
			}
			
			MapFrame.document.forms[0].submit();
			MapFrame.showLayer('LoadData');
		break;
		case "ZoomIn":
			MapFrame.document.forms[0].Tool.value='ZoomIn';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
			msg = "Click and hold mouse button to draw a rectangle on map to zoom in";
			flag = true;
		break;
		case "ZoomOut":
			MapFrame.document.forms[0].Tool.value='ZoomOut';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
			msg = "Click a single point on the map to zoom out"
			flag = true;
		break;
		case "Pan":
			MapFrame.document.forms[0].Tool.value='Pan';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
		break;
		case "Identify":
			MapFrame.document.forms[0].Tool.value='Identify';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
		break;
		case "ClickSelect":
			MapFrame.document.forms[0].Tool.value='ClickSelect';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
		break;
		case "SelectClick":
			MapFrame.document.forms[0].Tool.value='SelectClick';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
		break;
		case "Buffer":
			MapFrame.document.forms[0].Tool.value='Buffer';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
			parent.TextFrame.location = 'clk_buffer.cfm';
			msg = "Click feature around which to buffer";
			flag = true;
		break;
		case "SBR":
			MapFrame.document.forms[0].Tool.value='SBR';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
			msg = "Click and hold mouse button to draw a selection rectangle";
			flag = true;
		break;
		case "ClearSession":
			MapFrame.document.forms[0].Tool.value='ClearSession';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
			MapFrame.document.forms[0].Tool2.value=MapFrame.document.forms[0].Tool.value;
			MapFrame.document.forms[0].Tool.value='ClearSession';
			MapFrame.document.forms[0].runMap.value=1;
			MapFrame.document.forms[0].SelectionLayer.value='';
			MapFrame.document.forms[0].SelectionField.value='';
			MapFrame.document.forms[0].SelectionFieldValuesList.value='';
			MapFrame.document.forms[0].HighlightedProject.value='';
			MapFrame.document.forms[0].SelectedProjects.value='';
			MapFrame.document.forms[0].SelectedCount.value='0';
			MapFrame.document.forms[0].SDDEF_GC.value='';
			MapFrame.document.forms[0].SOFTCOPY_GC.value='';
			MapFrame.document.forms[0].HISTORIC_GC.value='';
			MapFrame.document.forms[0].COMPOSITE_GC.value='';
			MapFrame.document.forms[0].SelMinY.value='';
			MapFrame.document.forms[0].SelMaxY.value='';
			MapFrame.document.forms[0].SelMinX.value='';
			MapFrame.document.forms[0].SelMaxX.value='';
			MapFrame.showLayer('LoadData');
			MapFrame.document.forms[0].submit()			
		break;
		case "ZoomSelected":
		//alert("in here");
		if(MapFrame.document.forms[0].SelectedCount.value != 0){
			MapFrame.document.forms[0].Tool2.value=MapFrame.document.forms[0].Tool.value;
			MapFrame.document.forms[0].runMap.value=1;
			MapFrame.document.forms[0].Tool.value='ZoomSelected';
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
			}			
			MapFrame.document.forms[0].submit();
			MapFrame.showLayer('LoadData');
		}else{
			alert("You must first add projects to your selection set before using this tool.");
		}
		break;
		case "ZoomLast":
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
				MapFrame.measureTool = false;
			}
			MapFrame.showLayer('LoadData');
			processZoomLast();
		break;
		case "ZoomSelection":
			if(MapFrame.document.forms[0].selectionSet.value ==""){
				alert("You do not have built a selection set yet.");
				return false;
			}else{
				var zMinX = parent.MapFrame.document.forms[0].SelMinX.value;
				var zMinY = parent.MapFrame.document.forms[0].SelMinY.value;
				var zMaxX = parent.MapFrame.document.forms[0].SelMaxX.value;
				var zMaxY = parent.MapFrame.document.forms[0].SelMaxY.value;

				parent.MapFrame.document.forms[0].Tool2.value = parent.MapFrame.document.forms[0].Tool.value
				parent.MapFrame.document.forms[0].Tool.value= "ZoomEnvelope";
				MapFrame.processMap('envelope',zMinX,zMinY,zMaxX,zMaxY);
				return false;
			}
		
		
		
		break;
		case "Measure":
			measureOnMapOff(1);
			MapFrame.document.forms[0].runMap.value = 0;
			MapFrame.document.forms[0].Tool.value = "Measure";
			MapFrame.measureTool = true;
			msg = "Click on map to place a point, then click a second time to plot second point for measure";
			flag = true;
			
			MapFrame.showMeasure = !MapFrame.showMeasure;
			//alert(MapFrame.showMeasure)
			//alert("OverviewMapValue: " +MapFrame.document.forms[0].OverViewMap.value);
			if(MapFrame.showMeasure){
				return false;
				//alert("oi")
					//MapFrame.document.forms[0].Tool.value='ZoomIn';
					//MapFrame.hideMeasure();
					//MapFrame.hideLayer('Measurebox');
					//MapFrame.measureTool = false
				}else{	
					if(MapFrame.measFlag){
						//MapFrame.showMeasure = !MapFrame.showMeasure
						//MapFrame.document.forms[0].Tool.value='ZoomIn';
						//MapFrame.measureTool = false
						MapFrame.hideMeasure();
						MapFrame.showMeasure =true
						changeTool('Measure');
					}else{
						MapFrame.showLayer('Measurebox');
						MapFrame.measFlag = true;
					}
				MapFrame.showMeasure = true//!MapFrame.showMeasure
				//alert(measFlag)
			}
			return false;
			break;
		case "Tips":
			MapFrame.document.forms[0].Tool.value ="";
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
			}
			var tipWin = window.open('','remote','width=200,height=250');
			tipWin.location = "tipwin.cfm?layer=" + MapFrame.document.forms[0].ActiveLayerName.value;		
		break;
		case "AddNote":		
			MapFrame.document.forms[0].Tool.value ="AddNote";			
			if(MapFrame.measureTool){
				MapFrame.hideMeasure();
				MapFrame.hideLayer('Measurebox');
			}				
		break;
			default:
			return false;
		break;
	}
		if(flag){
		mapTipmsg = msg;
		writeTip(msg);
	}
	//alert(MapFrame.document.forms[0].Tool.value)
}

function panClick(direction){
	MapFrame.showLayer('LoadData');
	MapFrame.setSize();
	MapFrame.document.forms[0].Tool2.value = MapFrame.document.forms[0].Tool.value;
	MapFrame.document.forms[0].Tool.value= direction;
	MapFrame.document.forms[0].submit()
}

function changeStatus(msg){
	if(msg !=''){
		window.status = msg;
		return true;
	}else{
		window.status = "TerraVerge";
	}
} 
var mapTipmsg = "Click and hold mouse button to draw a rectangle on map to zoom in";
function mapTips(btn){
	var msg = "";
	switch(btn){
		case "ZoomExtent":
			msg = "Click to return map to it's original envelope";
		break;
		case "ZoomIn":
			msg = "Click and hold mouse button to draw a rectangle on map to zoom in";
		break;
		case "ZoomOut":
			msg = "Click a single point on the map to zoom out";
		break;
		case "ZoomLast":
			msg = "Click to zoom to the previous map image";
		break;
		case "Pan":
			msg = "Click a single point on the map to center to that point";
		break;
		case "Identify":
			msg = "Click a single point on the map to <b>Identify</b> that active layer";
		break;
		case "Maptips":
			msg = "Click to activate MapTips";
		break;
		case "SBR":
			msg = "Click and hold mouse button to draw a selection rectangle";
		break;
		case "ClearSession":
			msg = "Click once to clear session variables";
		break;
		case "LocMap":
			msg = "Click to toggle location map on/off";
		break;
		case "Measure":
			msg = "Click on map to place a point, then click a second time to plot second point for measure";
		break;
		case "Print":
			msg = "Click to print a Terra-MapCard &trade;";
		break;
		case "Buffer":
			msg = "Click to create a buffer around a feature;";
		break;
		default:
			return false;
		break;
	}
	writeTip(msg);
}
function writeTip(msgVar){
	if(parent.mapTipInfo){
		if(parent.browser){
			mapTipdiv.innerHTML = msgVar;
		}else{
			var content = "<html><head><title>MapTips</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";
				content += "</head><body bgcolor=\"#3366FF\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">";
				content += "<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">";
				content += "<tr><td width=100% align=center><div id=\"tips\" style=\"font-size:10px;font-family:tahoma;color:white\">";
				content += msgVar;
				content += "</div></td></tr></table></body></html>"
			mapTipdiv.open();
			mapTipdiv.write(content);
			mapTipdiv.close();
		}
	}else{
		return false;
	}
}

function mapTiporig(){
	writeTip( mapTipmsg);
}

function menuToggle(whichone){
	switch (whichone){
                case "Intro_med":
                        TextFrame.location = "intro_medium.cfm";
                break;

		case "Search_med":
			TextFrame.location = "search/search_medium.cfm";
		break;
		case "Search":
			TextFrame.location = "search/search.cfm";
		break;
		case "Layers":
			TextFrame.location = "layers.cfm?MapScale=" + parent.MapFrame.document.forms[0].MapScale.value;
		break;
		case "Intro":
			TextFrame.location = "intro.cfm";
		break;
		case "Help":
			TextFrame.location = "help.cfm";
		break;
		case "Legend":
			TextFrame.location = "legend.cfm";
		break;
		case "Selection":
			parent.frames.TextFrame.location= "selection.cfm";
		break;
		case "Notes":
			parent.frames.TextFrame.location= "notes_options.cfm";
		break;
	}
}

function saveSelection(id){
	var item = arrSelection.length;
	arrSelection[item] = id;
	window.status = id + " has been saved to your selection set.";
}

function array2List(arr){
	var rtnList = ",";
	for(i=0;i<arr.length;i++){
		rtnList += arr[i] + ",";
	}
	rtnList = rtnList.substring(1,rtnList.length);
	rtnList = rtnList.substring(0,rtnList.length-1);
	return rtnList;
}

function switchActiveLayer(control){
	MapFrame.document.forms[0].ActiveLayerID.value= control.options[control.selectedIndex].value;
	MapFrame.document.forms[0].ActiveLayerName.value= control.options[control.selectedIndex].text;
}

function toggleOVMap(){
	//alert(MapFrame.document.forms[0].Tool.value + "\n|||||||||")
	if(MapFrame.document.forms[0].Tool.value == "Measure"){
		return false;
	}
	MapFrame.ovIsVisible = !MapFrame.ovIsVisible;
	
		if (MapFrame.ovIsVisible) {
			MapFrame.measIsHere = false;
			MapFrame.showLayer("ovLayer");
			if(parent.browser){
				MapFrame.showLayer("ovShadow");
			}
			MapFrame.document.forms[0].OverViewMap.value = "true";
			
		} else {
			MapFrame.measIsHere = true;
			MapFrame.hideLayer("ovLayer");
			if(parent.browser){
				MapFrame.hideLayer("ovShadow");
			}
			MapFrame.document.forms[0].OverViewMap.value = "false";
			
		}
}

function measureOnMapOff(){
	MapFrame.ovIsVisible = !MapFrame.ovIsVisible;
		if (!MapFrame.ovIsVisible) {
			MapFrame.measIsHere = false;
			MapFrame.hideLayer("ovLayer");
			if(parent.browser){
				MapFrame.hideLayer("ovShadow");
			}
			
		}
}

function zoomTo(layer,fieldName,fieldValue){
	MapFrame.showLayer('LoadData');
	MapFrame.document.forms[0].zoomToLayer.value = layer;
	MapFrame.document.forms[0].zoomToFieldName.value = fieldName;
	MapFrame.document.forms[0].zoomToFieldValue.value = fieldValue;
	MapFrame.document.forms[0].Tool2.value = MapFrame.document.forms[0].Tool.value;
	MapFrame.document.forms[0].Tool.value="ZoomTo";
	MapFrame.document.forms[0].runMap.value =1;
	MapFrame.document.forms[0].submit();
}

function remove(num){
		var str="";
		for(i=0;i<this.length;i++){
			str+= this[i].toString()+","
		}
		str = str.replace(num+",","");
		if(str!=""){
			str = str.substr(0,str.length-1);
			str = str.split(",");
			
		}else{
			str = new Array();
		}return str
	}
	function push(num){
		var str="";
		for(i=0;i<this.length;i++){
			str+=this[i].toString()+","
		}
		str+=num;
		str = str.split(",");
		return (str)
	}

function toggleSelection(control){
		if(control.checked){
			arrSelection = arrSelection.add(control.value);
		}else{
			arrSelection = arrSelection.remove(control.value);
		}
	}	
	
function highlightProject(projectID){
	
	var projectCount = MapFrame.document.forms[0].SelectedCount.value;
	//currentProjectList = (eval(MapFrame.document.forms[0].SelectedProjects.value));
	if(projectCount > 4){
		alert("You may only have a maximum of 5 projects selected at once.   You must remove at least one project from the selection set before adding this project");
	}else{
		MapFrame.showLayer('LoadData');
		MapFrame.document.forms[0].HighlightedProject.value = projectID;
		if(MapFrame.document.forms[0].SelectedProjects.value == ""){
			MapFrame.document.forms[0].SelectedProjects.value = "'" + projectID + "'";
		}else{
			MapFrame.document.forms[0].SelectedProjects.value = MapFrame.document.forms[0].SelectedProjects.value + ",'" + projectID + "'";
		}	
		MapFrame.document.forms[0].submit();
		parent.TextFrame.location = "../layers.cfm?MapScale=" + parent.MapFrame.document.forms[0].MapScale.value;
		//alert(MapFrame.document.forms[0].CurrentMapScale.value);
		if (MapFrame.document.forms[0].CurrentMapScale.value > 0.3){
		alert("Your selected projects have been added to the map, but are not currently visible at this scale.  Please zoom into the map to see the vector shoreline data.");
		}
		//parent.TextFrame.location="../layers.cfm";
		//parent.TextFrame.recallPage(projectID);
	}
}
function zoomToProject(projectID,minX,maxX,minY,maxY,type,value){
//add tool2
	MapFrame.showLayer('LoadData');
	MapFrame.document.forms[0].myMinX.value = minX;
	MapFrame.document.forms[0].myMinY.value = minY;
	MapFrame.document.forms[0].myMaxX.value = maxX;
	MapFrame.document.forms[0].myMaxY.value = maxY;
	MapFrame.document.forms[0].SearchType.value = type;
	MapFrame.document.forms[0].SearchValue.value = value;
	if(projectID == "none"){
		MapFrame.document.forms[0].Tool.value='ZoomToCoordsNoLayers';
	}else{
	MapFrame.document.forms[0].Tool.value='ZoomToCoords';
	}
	MapFrame.document.forms[0].runMap.value = 1;	
	MapFrame.document.forms[0].submit();	
}

function deleteKapp(projectID,from,type,value){

        myString = new String(MapFrame.document.forms[0].SelectedProjects.value);
        rExp = new RegExp( projectID , "gi");
        newString = new String ("");
        results = myString.replace(rExp, newString);
        rExp = new RegExp(",,", "gi");
        newString = ",";
        results = results.replace(rExp, newString);
        resultsLength = results.length - 1;
        var position = results.lastIndexOf(",");
        if(position == resultsLength){
                results = results.substr(0,resultsLength);
        }
        position = results.indexOf(",");
        if (position == 0){
                results = results.substr(1,results.length);
        }
        MapFrame.showLayer('LoadData');
        MapFrame.document.forms[0].SelectedProjects.value = results;
        MapFrame.document.forms[0].SearchType.value = type;
        MapFrame.document.forms[0].SearchValue.value = value;
        if(results == ''){
        MapFrame.document.forms[0].resetLayers.value = 'true';
        }


        MapFrame.document.forms[0].submit();
        if(from == "selectionList"){
        }else{
        }

}


function deleteProject(projectID,from,type,value){
	
	myString = new String(MapFrame.document.forms[0].SelectedProjects.value);
	rExp = new RegExp("'" + projectID + "'", "gi");	
	newString = new String ("");
	results = myString.replace(rExp, newString);	
	rExp = new RegExp(",,", "gi");	
	newString = ",";
	results = results.replace(rExp, newString);	
	resultsLength = results.length - 1;	
	var position = results.lastIndexOf(",");	
	if(position == resultsLength){
		results = results.substr(0,resultsLength);		
	}
	position = results.indexOf(",");
	if (position == 0){
		results = results.substr(1,results.length);
	}
	MapFrame.showLayer('LoadData');	
	MapFrame.document.forms[0].SelectedProjects.value = results;
	MapFrame.document.forms[0].SearchType.value = type;
	MapFrame.document.forms[0].SearchValue.value = value;	
	if(results == ''){
	MapFrame.document.forms[0].resetLayers.value = 'true';	
	}
	
	
	MapFrame.document.forms[0].submit();	
	if(from == "selectionList"){		
	}else{		
	}
	
}

function extractProject(projectID){
	window.open("../extract/options.cfm?project=" + projectID + "",'DownloadOptions','resizable=yes,width=350,height=450');
	//alert("A new window will open asking the user if they want to download the entire project, or just the portion of the project within their view.   Could even prompt them to choose which feature classes/layers as well.");
}

function extractProjectSelection(projectID){
	window.open("extract/options.cfm?project=" + projectID + "",'DownloadOptions','resizable=yes,width=350,height=450');
	//alert("A new window will open asking the user if they want to download the entire project, or just the portion of the project within their view.   Could even prompt them to choose which feature classes/layers as well.");
}


function extractProjectMain(){
	if(MapFrame.document.forms[0].SelectedProjects.value == ""){
		alert("There are no shoreline projects in your selection set.   You must have at least one project in the selection set before using this tool.");
	}else{
		window.open("extract/options_main.cfm",'DownloadOptions','resizable=yes,width=350,height=450');
	}
	//alert("A new window will open asking the user if they want to download the entire project, or just the portion of the project within their view.   Could even prompt them to choose which feature classes/layers as well.");
}

function DynamicLayerActivation(layer,visible,type){
	alert("type: " + type + " layer: " + layer + " visible: " + visible);
	
	if(type == "line"){	
		if(MapFrame.document.forms[0].VisibleLine.value == ""){
			MapFrame.document.forms[0].VisibleLine.value = "'" + layer + "'";
		}else{
			MapFrame.document.forms[0].VisibleLine.value = MapFrame.document.forms[0].VisibleLine.value + ",'" + layer + "'";
		}	
	}else{
		if(MapFrame.document.forms[0].VisiblePoint.value == ""){
			MapFrame.document.forms[0].VisiblePoint.value = "'" + layer + "'";
		}else{
			MapFrame.document.forms[0].VisiblePoint.value = MapFrame.document.forms[0].VisiblePoint.value + ",'" + layer + "'";
		}	
	}
	
	
	/*if(type == "line"){
	MapFrame.document.forms[0].DynamicLayerToggleName.value = layer;
	MapFrame.document.forms[0].DynamicLayerToggleVisible.value = visible;
	}else{
	MapFrame.document.forms[0].DynamicPointToggleName.value = layer;
	MapFrame.document.forms[0].DynamicPointToggleVisible.value = visible;
	}	
	MapFrame.document.forms[0].Tool2.value = MapFrame.document.forms[0].Tool.value;
	MapFrame.document.forms[0].Tool.value = 'ToggleDynamicLayer';	
	MapFrame.showLayer('LoadData');
	MapFrame.document.forms[0].runMap.value = 1;	
	MapFrame.document.forms[0].submit(); */
}	

