var win

function mWidth(frameloc)
//#########################################################
//# FUNCTION: mWeight()
//# DESCRIPTION: Gets the available frame width (NS/IE)
//# INPUT: location of frame (parent.framename) if called from current page then leave
//# blank
//# OUTPUT: Width  available in frame
//##########################################################
{
	var iw;
	if (frameloc == null)
	{
	if (window.innerWidth == null) 
			{
				iw = document.body.clientWidth;
			}
			 else 
			{
				iw = window.innerWidth;
			}
	}
	else
	{
	if (frameloc.window.innerWidth == null) 
			{
				iw = frameloc.document.body.clientWidth;
			}
			 else 
			{
				iw = frameloc.window.innerWidth;
			}
	}
    return iw;
}

function mHeight(frameloc)
//#########################################################
//# FUNCTION: mHeight()
//# DESCRIPTION: Gets the available frame height (NS/IE)
//# INPUT: location of frame (parent.framename) if called from current page then leave
//# blank
//# OUTPUT: Height available in frame
//##########################################################
{
	var ih;
	if (frameloc == null)
	{
		if (window.innerWidth == null) 
		{
		ih=document.body.clientHeight; 
		}
		 else 
		 {
			ih = window.innerHeight;
		 }
	}
	else
	{
		if (frameloc.window.innerWidth == null) 
		{
			ih=frameloc.document.body.clientHeight; 
		}
		 else 
		{
			ih = frameloc.window.innerHeight;
		}
	 }
	return ih;
}

function loadPage(pagename,pagelocation)
//#########################################################
//# FUNCTION: loadpage()
//# DESCRIPTION: Loads a page in a give frame
//# INPUT: Page to be loaded, location where page is to be loaded (parent.framename)
//# OUTPUT: 
//##########################################################
{
	if (pagename == null)
	{
		alert('ERROR:\nfunction loadpage()\nNo value given for first parameter ')
	}
	 else
	{	
		if (pagelocation == null)
		{
			document.location.href = pagename
		}
		 else
		{
			pagelocation.location.href =  pagename
		}
	}
} 

function checkBrowser()
//#########################################################
//# FUNCTION: checkBrowser()
//# DESCRIPTION: checks the clients browser
//# INPUT: none
//# OUTPUT:  browser type - (Microsoft,Netscape,Error)
//##########################################################
{
			var version = navigator.appVersion;
			var versNum = parseFloat(version);
			var browser = navigator.appName;
			var btype = "Error";

			if (browser.indexOf("Microsoft") > -1) 
			{
				if (versNum < 4.0) 
				{
					btype = "Error";
				} 
				 else 
				{
					btype = "Microsoft";					
				}
			}
			else 
			{
				if (browser.indexOf("Netscape") >-1)
				{
					if (versNum < 4.0)					
					{
						btype = "Error";
					}
					 else 
					{
						btype = "Netscape";
					}
				 }
				 else
				 {
					if (navigator.platform == "MacPPC") 
					{
							 btype = "Error";
					}
				  }			

				}
							return btype;
     		}


			
function Xcoord(e) 
{
//#########################################################
//# FUNCTION: Xcoord()
//# DESCRIPTION: get the mouseclick x
//# INPUT: javascript event
//# OUTPUT:  X coordinates of mouseclick on image
//##########################################################
	if (window.event) 
	{
		return window.event.clientX
	}
    else 
	{
       return e.pageX
	}
}

function Ycoord(e) 
//#########################################################
//# FUNCTION: Ycoord()
//# DESCRIPTION: get the y
//# INPUT: javascript event
//# OUTPUT: Y coordinate of mouseclick on image
//##########################################################
{      
   	if (window.event) 
		{
			return window.event.clientY;
		}
    else 
		{
			return e.pageY
		}	
}

function selectTool(ActiveTool,Xval, Yval)
//#########################################################
//# FUNCTION: Xcoord()
//# DESCRIPTION: get the mouseclick x
//# INPUT: javascript event
//# OUTPUT:  X coordinates of mouseclick on image
//##########################################################
{


	if (ActiveTool == "zoomin")
	{
	panZoom(ActiveTool,Xval,Yval);
	}
	else 
	{
		if (ActiveTool =="zoomout")
		{
		panZoom(ActiveTool,Xval,Yval);
		}
		else
		{
			if (ActiveTool=="pan")
			{
				panZoom(ActiveTool,Xval,Yval)
			}
			else
			{
				if (ActiveTool=="identify")
				{
					identify(Xval,Yval);
				}
				else
				{
					if (ActiveTool=="zoomtofull")
					{

						panZoom(ActiveTool)
					}
					else 
					{
						if (ActiveTool =='measure')
						{
							measure(Xval,Yval)
						}

					}
				}
			}
		}
	}
}

function panZoom(ToolType,X1,Y1)
//#########################################################
//# FUNCTION: panZoom()
//# DESCRIPTION: handles zoomin,zoomout,pan
//# INPUT: tool name and coordinates
//# OUTPUT: refreshes asp page to update map
//##########################################################
{
	loadPage('panzoom.asp?tooltype='+ToolType+'&x1='+X1+'&y1='+Y1,parent.asp);
}

function identify(X1,Y1)
//#########################################################
//# FUNCTION: identify()
//# DESCRIPTION: handles identify
//# INPUT: coordinates
//# OUTPUT: refreshes asp page to update map
//##########################################################
{
		loadPage('identify.asp?x1='+X1+'&y1='+Y1,parent.address);
}

function measure(X1,Y1)
//#########################################################
//# FUNCTION: identify()
//# DESCRIPTION: handles identify
//# INPUT: coordinates
//# OUTPUT: refreshes asp page to update map
//##########################################################
{
		loadPage('measure0.asp?x1='+X1+'&y1='+Y1,parent.asp);
}

function layerLegend()
//#########################################################
//# FUNCTION: layerLegend()
//# DESCRIPTION: handles identify
//# INPUT: coordinates
//# OUTPUT: refreshes asp page to update map
//##########################################################
{
	if (parent.layerlegend.document.title == "Layer")
	{
		loadPage('legend.asp',parent.layerlegend)
	}
	else
	{
		loadPage('layer.asp', parent.layerlegend)
	}    
}

function createWindow(pagename,toolbarVis,locationVis,statusVis,resizableVis,scrollbarsVis,menuVis,xPos,yPos,valx,valy, Wname)
//#########################################################
//# FUNCTION: createWindow()
//# DESCRIPTION: handles creates a window
//# INPUT: width, height, page
//# OUTPUT: refreshes asp page to update map
//##########################################################
{
var wHelp, wPrintTable, wPrintMap, wMuniProfile

if (Wname=="printtable")
{
 Win2 = window.open(pagename,Wname,'toolbar='+toolbarVis+',location='+locationVis+',directories=no,status=no,menubar='+menuVis+',resizable='+resizableVis+',copyhistory=no,screenX='+xPos+',screenY='+yPos+',top='+yPos+',left='+xPos+',scrollbars='+scrollbarsVis+',width='+valx+',height='+valy);					
}
else
{
 Win = window.open(pagename,Wname,'toolbar='+toolbarVis+',location='+locationVis+',directories=no,status=no,menubar='+menuVis+',resizable='+resizableVis+',copyhistory=no,screenX='+xPos+',screenY='+yPos+',top='+yPos+',left='+xPos+',scrollbars='+scrollbarsVis+',width='+valx+',height='+valy);					
 }
}

function switchImage(ImageName,ImagePath,ImageLocation)
//#########################################################
//# FUNCTION: switchImage()
//# DESCRIPTION: 
//# INPUT: 
//# OUTPUT: 
//##########################################################
{
//alert('Flag 1');
//alert(ImageName);
//alert('Flag 2');
//alert(ImagePath);
//alert(ImageLocation);
	if (document.images == null) alert('NULL');
	if (ImageLocation == null)
		{
			document.images[ImageName].src= ImagePath;
		}
	else
		{
			//alert(ImageLocation.location.href);
			//alert(ImageName);
			//alert(ImageLocation.document.images.length);
			alert(ImageLocation.ImageName.src);
			ImageLocation.ImageName.src= ImagePath;
		}
}

function writeStatus(StatusMessage)
//#########################################################
//# FUNCTION: write Status()
//# DESCRIPTION: 
//# INPUT: 
//# OUTPUT: 
//##########################################################
{
	window.status=StatusMessage
}

function DisplayMuni(munilink)
//#########################################################
//# FUNCTION: write Status()
//# DESCRIPTION: 
//# INPUT: 
//# OUTPUT: 
//##########################################################
{
	document.location.href='data/' + munilink
	self.resizeTo(screen.width,screen.height);	
}

function passvar(pagetype)
{
loc = document.txtform;
if (pagetype=='land')
{
	if (loc.minval.value == "" && loc.maxval.value == "")
	{
		alert('The \'Minimun Size\'  and \'Maximum Size\' fields both cannot be blank.\n');
	}
	else
  	  {
		loadPage('calc_land.asp?minval='+loc.minval.value+'&maxval='+loc.maxval.value+'&zoning='+loc.zoning.value+'&muni='+loc.muni.options[loc.muni.options.selectedIndex].value,window.opener.parent.address);
		setTimeout('self.close()',500);  
    	}
}
else
{
if (loc.minval.value == "" && loc.maxval.value == "")
	{
		alert('The \'Minimun SQFT\'  and \'Maximum SQFT\' fields both cannot be blank.\n');
	}
	else
  	  {
		loadPage('calc_buildings.asp?minval='+loc.minval.value+'&maxval='+loc.maxval.value+'&usage='+loc.usage.options[loc.usage.options.selectedIndex].value+'&muni='+loc.muni.options[loc.muni.options.selectedIndex].value,window.opener.parent.address);
		setTimeout('self.close()',500);  
    	}
}
}

function updateLayers() {
	var theForm = document.toc;
	var j = 0;
	var args = ""
	for (var i=0;i<theForm.LayerVisible.length;i++)
	{
		j = theForm.LayerVisible[i].value;
		if (theForm.LayerVisible[i].checked) {
			args = args + "&" + j + "=Y";
		}
		else {
			args = args + "&" + j + "=N";
		}
	}
	parent.asp.location = 'readTOC.asp?action=layervis' + args;
}


function CheckMsg(msgname) 
{
	if (!top.msgname)
	{
	alert(msgname);
	top.msgname = true;
	}
}

function WinExists() 
{
if (window.opener.parent.showres.document == null) {
}
else
{
window.opener.parent.showres.document.showwindow.src='images/shim.gif';
window.opener.parent.top.focus();
}
}