var isIE = false
var isNav = (navigator.appName.indexOf("Netscape")>=0)
var is5up = false
var sMapTool = "ZoomIn"
var nZoomFactor = 0

if (isNav) {
	if (parseFloat(navigator.appVersion)>5)
		is5up = true
} else {
	isIE=true
	if ((navigator.appVersion.indexOf("MSIE 5")>0)||(navigator.appVersion.indexOf("MSIE 6")>0)||(navigator.appVersion.indexOf("MSIE 7")>0)) {
		is5up = true
	}	
}

function popOut(sURL,sTitle,iHeight,iWidth,ynScroll,ynResize) {
	var objWin
	var sFeatures
	sFeatures = "height=" + iHeight + ",width=" + iWidth + ",scrollbars=" + ynScroll + ",resizable=" + ynResize
	objWin = window.open(sURL, sTitle, sFeatures)
	if (parseInt(navigator.appVersion) >=4) 
		objWin.window.focus()
}

function showLayer(name) {
	var layer = document.getElementById(name)
	if (layer != null)
		layer.style.visibility = "visible"
}

function hideLayer(name) {
	var layer = document.getElementById(name)
	if (layer != null) 
		layer.style.visibility = "hidden"
}

function showLegend() {
	if (document.getElementById("loading").style.visibility == 'hidden')
		popOut('common/legend.asp','Legend','295','250','yes','no')
}

function mapHelp() {
	popOut('help.htm','Help','450','350','yes','no')
}

function zoomFixed(n){
	if (document.getElementById("loading").style.visibility == 'hidden') {
		showLayer("loading")
		parent.MapFrame.document.location = "common/map.asp?cmd=zoomfixed&zoomfactor=" + n
	}
}

function doPan(n){
	if (document.getElementById("loading").style.visibility == 'hidden') {
		showLayer("loading")
		parent.MapFrame.document.location = "common/map.asp?cmd=pan&dir=" + n
	}
}

function setMapTool(s) {
	sMapTool = s
	if (document.getElementById("loading").style.visibility == 'hidden') {
		if (s == "ZoomIn") {
			document.frmMapTool.Tool[0].checked = true
			if (isNav)
				parent.MapFrame.document.images.MapImage.style.cursor = "pointer"
			else
				parent.MapFrame.document.images.MapImage.style.cursor = "hand"
		} else if (s == "Recenter") {
			document.frmMapTool.Tool[1].checked = true
			if (isNav)
				parent.MapFrame.document.images.MapImage.style.cursor = "pointer"
			else
				parent.MapFrame.document.images.MapImage.style.cursor = "hand"
		} else if (s == "Identify") {
			document.frmMapTool.Tool[2].checked = true
			parent.MapFrame.document.images.MapImage.style.cursor = "crosshair"
		}
	}
}

function setZoom(n) {
	document.getElementById("zoomBar" + nZoomFactor).src = "common/images/bar1.gif"
	nZoomFactor = n
	document.getElementById("zoomBar" + nZoomFactor).src = "common/images/bar2.gif"
}

function brightenZoom(t) {
	t.src = "common/images/bar2.gif"
}

function darkenZoom(t) {
	if (t.id != "zoomBar" + nZoomFactor)
		t.src = "common/images/bar1.gif"
}

function showTab(sTab){
	var LayerStyle = document.getElementById("layerstab").style
	var SearchStyle = document.getElementById("searchtab").style
	if (sTab == "layerstab") {
		SearchStyle.overflow = "hidden"
		LayerStyle.overflow = "visible"
		document.images["searchtabimage"].src = "common/images/searchtab2.gif"
		document.images["layerstabimage"].src = "common/images/layerstab1.gif"
		document.images["searchtabcorner"].src = "common/images/cnr_ltab.gif"
		document.images["layerstabcorner"].src = "common/images/cnr_ntab.gif"
	} else {
		LayerStyle.overflow = "hidden"
		SearchStyle.overflow = "visible"
		document.images["searchtabimage"].src = "common/images/searchtab1.gif"
		document.images["layerstabimage"].src = "common/images/layerstab2.gif"
		document.images["searchtabcorner"].src = "common/images/cnr_ntab.gif"
		document.images["layerstabcorner"].src = "common/images/cnr_rtab.gif"
	}
}

function showLayerMenu(sLayer){
	var aMenu = new Array()
	var iHeight
	var iTimeout = 20
	var m = document.getElementById(sLayer)
	aMenu[0]=document.getElementById("adminmenu")
	aMenu[1]=document.getElementById("basemenu")
	aMenu[2]=document.getElementById("nrmenu")
	aMenu[3]=document.getElementById("planningmenu")
	aMenu[4]=document.getElementById("transmenu")
	if (document.getElementById(sLayer).offsetHeight == 1) {
		for(var i = 0; i < aMenu.length; i++){
			if (aMenu[i].offsetHeight != 1){
				iHeight = aMenu[i].offsetHeight;
				for(var j = iHeight; j  > 0; j = j - 10){
					setTimeout("document.getElementById('" + aMenu[i].id + "').style.height = " + j, iTimeout);
					iTimeout = iTimeout + 20;
				}
				iTimeout = iTimeout + 20;
				setTimeout("document.getElementById('" + aMenu[i].id + "').style.height = 1", iTimeout);
			}
		}
	}
	if (m.offsetHeight == 1) {
		iHeight = document.getElementById('tbl' + sLayer).scrollHeight
		for(var j = 10; j < iHeight; j = j + 10){
			setTimeout("document.getElementById('" + sLayer + "').style.height = " +j, iTimeout);
			iTimeout = iTimeout + 20;
		}
		iTimeout = iTimeout + 20;
		setTimeout("document.getElementById('" + sLayer + "').style.height=" + iHeight, iTimeout);
	}
}

function sendSearch(frm) {
	if (document.getElementById("loading").style.visibility == "hidden"){
		showLayer("loading")
		switch(frm.name) {
			case "ClearSearch":
				frm.reset()
				parent.MapFrame.location = "common/map.asp?cmd=clearsearch"
				break
			case "PointOfInterest":
				if (frm("selPointOfInterest").value == "")
					hideLayer("loading")
				else 
					parent.MapFrame.location = "common/map.asp?cmd=search&searchtype=PointOfInterest&searchvalue=" +  escape(frm("selPointOfInterest").value)
				break
			case "PropertyAddress":
			case "PropertyNumber":
				document.getElementById("Parcel").checked = true
				if (frm("txt" + frm.name).value == "")
					hideLayer("loading")
				else
					popOut("search.asp?searchtype=" + frm.name + "&searchvalue=" + escape(frm("txt" + frm.name).value), "Property_Search","400","300","yes","no")
				break
			case "BenchmarkID":
			case "BenchmarkAddress":
			case "BenchmarkApn":
				document.getElementById("Benchmark").checked = true
				if (frm("txt" + frm.name).value == "")
					hideLayer("loading")
				else
					popOut("search.asp?searchtype=" + frm.name + "&searchvalue=" + escape(frm("txt" + frm.name).value), "Benchmark_Search","400","300","yes","no")
				break
			case "TrafficStreet":
			case "TAZAddress":
			case "TAZNumber":
				if (frm("txt" + frm.name).value == "")
					hideLayer("loading")
				else
					popOut("search.asp?searchtype=" + frm.name + "&searchvalue=" + escape(frm("txt" + frm.name).value), "Traffic_Search","400","300","yes","no")
				break
		}
	}
}