

var startx;
var starty;
var flag =0;
var currentx ;
var currenty ;
var x1 =0;
var x2=0;
var y1=0;
var y2=0;
var vls;


var factor=0;
var counter=1;
var numsteps ;
var widthStep ;
var heightStep ;
var leftStep;
var topStep ;
var dynwidth
var dynheight;
var dyntop;
var dynleft;
var img;
var bdy;
var box;
var firstFlag=0;
var path = "m";
var ItemX = new Array(0);
var ItemY = new Array(0);
var dashed;
var areaFlag=0;
var ptx;
var pty;
var tlength=0;
var lastx=0;
var lasty=0;
var mapimage;
var img;
var vs;
var shadow;
var selectpath="";
var vMap;
//var coordArray = new Array();
var parcelArray = new Array();


//determines whether the points are drawn on a zoom or pan function, false means not to draw the points
var zoomQueryResults = false;
//this is set to true once the user clicks the maps results button, set to false when user clicks clear results button
var drawPoints = false;
//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   



	function showmap(imageURL)
	{
		mapimage = this.document.getElementById('mapImage');
		mapimage.src = "images/blank.gif";
		mapimage.src =imageURL;
		document.getElementById('dyn').style.visibility = "hidden"

		mapimage.style.visibility = "visible"
		
		hideLoading();

         checkMarkups(vMap,markupObjects,45);
		//if (drawPoints == true)
		// {
			createPoints();
		// }
		// else if(singlePoint!=null)
		// {
		    createPoints();
		// }
	}
	
	
	
	function changeOpac(opacity,id)
	{
		var object = document.getElementById(id).style;
		object.opacity = (opacity/100);
		object.MozOpacity = (opacity/100);
		object.KhtmlOpacity = (opacity/100);
		object.filter = "alpha(opacity="+ opacity +")";
	}
	
	
	function buildVMap()
	{
		var mapxmax = parseFloat(parent.postbackframe.document.getElementById("mapxmax").value);
		var mapxmin = parseFloat(parent.postbackframe.document.getElementById("mapxmin").value);
		var mapymax = parseFloat(parent.postbackframe.document.getElementById("mapymax").value);
		var mapymin = parseFloat(parent.postbackframe.document.getElementById("mapymin").value);
		var imagewidth = 0
		var imageheight = 0
		
		//firefox does not like the image widths to be zero...
		
		imagewidth = parent.postbackframe.document.getElementById("txtMapWidth").value; 
		imageheight = parent.postbackframe.document.getElementById("txtMapHeight").value;
		vMap = new geo.vMap(mapxmax,mapxmin,mapymax,mapymin,imagewidth,imageheight);
		//alert(vMap.xFact)
	
	}
	
	//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   

	
	function hideLoading()
	{
	parent.mapframe.document.getElementById('loading').style.visibility = "hidden";
	if(parent.postbackframe.document.myform)
		{ 

		if(parent.postbackframe.document.getElementById('txtzoomprev').value != ",,,")
			{
			 document.getElementById('zoomprev').style.display = "inline";
			 }
		else{
			document.getElementById('zoomprev').style.display = "none";
			}
		}
		checkTool();
	}
	
	
	//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   

	
	function zoomext(){
	parent.postbackframe.document.getElementById('btnextent').click();
	}
	
	//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   
    
	function zoomPrevious(){
	parent.postbackframe.document.getElementById('btnzoomprev').click();
//	zoomQueryResults=true;
	}
	
	
	//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   


function imgSize()
{

var mapwidth;
var mapheight;
var mapimage = this.document.getElementById('mapImage');
if (window.innerWidth || window.innerHeight)
{ 

mapwidth = self.innerWidth ;
mapheight = self.innerHeight-45;


}
else if (document.body.offsetWidth || document.body.offsetHeight)
{ 

mapwidth = window.document.body.offsetWidth;
mapheight = (window.document.body.offsetHeight)-45;

}

 


mapimage.width = mapwidth;
mapimage.height = mapheight
document.getElementById('toolRow').width = mapwidth;


if(top.postbackReady)
{ 

parent.postbackframe.document.getElementById('txtMapWidth').value = mapwidth;
parent.postbackframe.document.getElementById('txtMapHeight').value = mapheight ;
}
else{wait('imgSize');
}

if(top.browserName != "Microsoft Internet Explorer")
 {
	 document.getElementById('measureDist').style.display ="none"
	 document.getElementById('markup').style.display ="none"
 }

var vwest2 = this.document.getElementById('vwest2');
var vnorth = this.document.getElementById('vnorth');
var veast = this.document.getElementById('veast');
var vsouth = this.document.getElementById('vsouth');
var loading = this.document.getElementById('loading');
vwest2.style.left = 0;
vwest2.style.top = mapimage.height/2;
vnorth.style.top = 0;
vnorth.style.left = mapimage.width/2;
veast.style.top = (mapimage.height/2);
veast.style.left = mapimage.width-23;
vsouth.style.top = (mapimage.height)-20;
vsouth.style.left = mapimage.width/2;
loading.style.top = (mapimage.height/2)+25;
loading.style.left = (mapimage.width/2)-60;
vls = document.getElementById("myshape");
dashed = document.getElementById("dashed_line");
//fpath = document.getElementById("vpath");
//checkTool();

}


//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   


function loadPostback()
{
var mapwidth 
var mapheight 

if (window.innerWidth || window.innerHeight)
{ 

mapwidth = self.innerWidth ;
mapheight = self.innerHeight-45;


}
else if (document.body.offsetWidth || document.body.offsetHeight)
{ 

mapwidth = window.document.body.offsetWidth;
mapheight = (window.document.body.offsetHeight)-45;

}

parent.postbackframe.location.href = 'parcel_results.aspx?width='+mapwidth+'&height='+mapheight;

}


//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   

function setTool(tool)
{
 parent.currenttool = tool;
    if(tool=="measure")
	{
		parent.dataframe.location = "measure.htm";
			
	}

		
    else if(tool=="id")
	{
			if(parent.dataframe.document.title!='ActiveLayer')
			{
			    parent.dataframe.location = "activeLayer.htm";
			}
	}

else if(tool=="select")
	{
	if(parent.dataframe.document.title!='Selection')
	    {		
           parent.dataframe.location="selection.aspx";
        }
	}
	
else if(tool=="markup")
	{
		if(parent.dataframe.document.title!='Markup')
	    {
		    im = document.getElementById('mapImage')
		    parent.dataframe.location="markup.htm";	
		 }
	
	}


checkTool();
}





//Check to see which tool is current
function checkTool()
{

	if(parent.currenttool=="zoomWindow")
	{
		document.getElementById('zoomwindow').src = "images/zoomins.jpg";
		var map = document.getElementById("img");
		map.style.cursor='crosshair';
	}
	else
	{
		document.getElementById('zoomwindow').src = "images/zoomin.jpg"
	}
	
	
	if(parent.currenttool=="panWindow")
	{
	document.getElementById('panwindow').src = "images/pans.jpg";
		var map = document.getElementById("img");
		map.style.cursor='move';
	}
	
	else
	{
		document.getElementById('panwindow').src = "images/pan.jpg";
	}
	
	if(parent.currenttool=="measure")
	{
	document.getElementById('measureDist').src = "images/measures.jpg";
		var map = document.getElementById("img");
		map.style.cursor='crosshair';
	}
	
	else
	{
		document.getElementById('measureDist').src = "images/measure.jpg";
	}
	
	if(parent.currenttool=="id")
	{
	document.getElementById('ident').src = "images/ids.jpg";
		var map = document.getElementById("img");
		map.style.cursor='hand';
	}
	else
	{
		document.getElementById('ident').src = "images/id.jpg";
	}
	
	if(parent.currenttool=="select")
	{
	document.getElementById('select').src = "images/selects.jpg";
		var map = document.getElementById("img");
		map.style.cursor='hand';
	}
	else
	{
		document.getElementById('select').src = "images/select.jpg";
	}
	
	if(parent.currenttool=="zoomOut")
	{
	document.getElementById('zoomout').src = "images/zoomouts.jpg";
		var map = document.getElementById("img");
		map.style.cursor='crosshair';
	}
	else
	{
		document.getElementById('zoomout').src = "images/zoomout.jpg";
	}
	
	
	if(parent.currenttool=="markup")
	{
		document.getElementById('markup').src = "images/layouts.jpg";
		var map = document.getElementById("img");
		map.style.cursor='hand';
	}
	else
	{
		document.getElementById('markup').src = "images/layout.jpg";
	}
	
	
if (parent.postbackframe.document.getElementById('Layer1').checked==true)
	{
		document.getElementById('aerial').src = "images/aerials.jpg";
    }
	else
	{
		document.getElementById('aerial').src = "images/aerial.jpg";
	}

}

//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   




//_______________________________________________________________
    //
    // Handles the mouse click evants
    //_______________________________________________________________   
 function mClick(e)
 {
    if(parent.currenttool == "measure" || parent.currenttool == "select" && top.mode =="polygon")
		{
           if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

           if (e)
            { 
             if (e.pageX || e.pageY)
                { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
                  ptx = e.pageX;
                  pty = e.pageY;
                 }
             else if (e.clientX || e.clientY)
                { // works on IE6,FF,Moz,Opera7
                 ptx = e.clientX + document.body.scrollLeft;
                 pty = e.clientY + document.body.scrollTop;
     
             }
     }
  
  	if(firstFlag==0)
  	    {
  	
  	    	clear()
	    	if(parent.dataframe.document.title =="measure")
	        	{
	         	parent.dataframe.tclear()
	        	}
  	
  	
	 	    startx = ptx;
		    starty = pty;
		    path +=ptx+","+pty +" l";
		    firstFlag =1;
	    }
	else
	    {
	       areaFlag = 1;
	       path += " "+ptx+","+pty;
	       vls.path = path;
	    }
	
	    pty = pty-45;
	    if(selectpath !=""){
	    selectpath +="-";
	
	}
	 var mpt = new geo.vPoint();
    mpt = vMap.toWorldPoint(ptx,pty);
	selectpath +=mpt.X+","+mpt.Y;
	
	}
	
	
	if(parent.currenttool =="id"){
	getInfo(e)
	}
	
	if(parent.currenttool =="select"&& top.mode=="point"){
	selectParcels(e)
	}
	
	if(parent.currenttool == "markup")
		{
			layout_checkButton(e);
		}
}



//_______________________________________________________________
    //
    // Handles the mouse double click events
    //_______________________________________________________________   


function dblclk()
{
if(parent.currenttool=="measure")
	{
	path +="xe"
	vls.fill.opacity = ".35";
	dashed.path = "m0,0 l0,0";
	areaFlag = 0;
	firstFlag = 0;
	
	} 
if(parent.currenttool == "select" && top.mode =="polygon")
{
	parent.postbackframe.document.getElementById("txtselectpoint").value = "";
    parent.postbackframe.document.getElementById("txtselectpoly").value = "";
	var postback = parent.postbackframe.document.getElementById('myform');
	if(parent.dataframe.document.title != "Selection"){
    parent.dataframe.document.location = "selection.aspx";
    }
    parent.dataframe.document.getElementById("txtselect").value = selectpath;
    parent.dataframe.document.getElementById("Form1").goSearch.click();
    
	parent.postbackframe.document.getElementById("txtselectpoly").value = selectpath;
	postback.btnselect.click()
	selectpath = "";
	clear();
	}
	
if(parent.currenttool == "markup")
	{
	    layout_doubleClick();
	}
}


//_______________________________________________________________
    //
    // Handles the mouse up event
    //_______________________________________________________________   


function drop()
{ 

    flag = 0;

 if(parent.currenttool=="zoomWindow" || parent.currenttool=="zoomOut")
  {
		var box = document.getElementById('box');
		
		box.style.visibility ="hidden";
		
		clear()
		
		//alert(Math.abs(x2-x1))
		if ((Math.abs(x2 - x1) <20)) {//testing...((Math.abs(x2 - x1) <20)) 
		return;
			}
		document.onmousedown = null;  
		
		//zoomMap();
		
		//alert(x1+","+y1+","+x2+","+y2)
		
		 var env = x1+","+y1+","+x2+","+y2
		parent.postbackframe.document.getElementById('txtenvelope').value = env;
		
		if (parent.currenttool=="zoomWindow") { 
		 parent.postbackframe.document.getElementById('btnZoomWindow').click();
		 }
		if (parent.currenttool=="zoomOut") {
		 parent.postbackframe.document.getElementById('btnZoomOut').click()
		 }
		clearPoints()
			
	}
	
	
	if(parent.currenttool=="panWindow")
		{
		var txtpan = parent.postbackframe.document.getElementById('txtpandirection');
		var dx = currentx-startx;
		mapimage = document.getElementById('mapImage');
		var dy = currenty-starty;
		var imagex = mapimage.width/2;
		var imagey = mapimage.height/2;
		var x = imagex - dx;
		var y = imagey -dy;
  		txtpan.value = x+","+y;
        parent.postbackframe.document.getElementById('btnPan').click();
		}
		
	if(parent.currenttool == "markup")
		{
			layout_drdrop();
		}
		
		
}

//_______________________________________________________________
    //
    // //Handle the mousedown event of the map object
    //_______________________________________________________________   


function startdraw(e)
{

if(parent.currenttool=="zoomWindow" || parent.currenttool=="panWindow" || parent.currenttool=="zoomOut")
{ 

	img = document.getElementById('mapImage');
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

 if (e)
  { 
    if (e.pageX || e.pageY)
   { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
     startx = e.pageX;
      starty = e.pageY;
    }
    else if (e.clientX || e.clientY)
   { // works on IE6,FF,Moz,Opera7
    startx = e.clientX + document.body.scrollLeft;
     starty = e.clientY + document.body.scrollTop;
     
    }
  }


 if(parent.currenttool=="zoomWindow")
  {
			flag=1;
  }
  
  if(parent.currenttool=="panWindow")
  {
			flag=1;
  }
  
  if(parent.currenttool=="zoomOut")
  {
			flag=1;
  }

    return false;
    }
    if(top.currenttool == "measure")
    {vls = document.getElementById("myshape");
    }
    
}



//_______________________________________________________________
    //
   //Handle the mousemove event of the map object
    //_______________________________________________________________   



function drawBox(e)

{

  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

 if (e)
  { 
    if (e.pageX || e.pageY)
   { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
     currentx = e.pageX;
      currenty = e.pageY;
     
   }
    else if (e.clientX || e.clientY)
   { // works on IE6,FF,Moz,Opera7
   
    currentx = e.clientX + document.body.scrollLeft;
     currenty = e.clientY + document.body.scrollTop;
    
    }
  }
  
  if(parent.currenttool=="measure"|| parent.currenttool == "select" && top.mode =="polygon")
  {
	if(areaFlag == 1)
	 {
		dashed.path = "m"+startx+","+starty+" l"+currentx+","+currenty;
		
	  }
	 if(firstFlag ==1)
	 
	 { 
	     vls.path = path + " "+currentx+","+currenty;
	     if(parent.currenttool=="measure")
	     {
	       var pt = vMap.toWorldPoint(ptx,pty)
	       var wpt = vMap.toWorldPoint(currentx,currenty)
	       var xpow = Math.pow(Math.abs(pt.X-wpt.X),2)
           var ypow = Math.pow(Math.abs(pt.Y-wpt.Y),2)
           var length = Math.sqrt(xpow+ypow); 
	     parent.dataframe.document.getElementById('txtsegment').innerHTML = length.toFixed(0)+ " feet";
    	}
	}
}
  
  
 
if(flag==1)
	{ 
  
	if(parent.currenttool=="panWindow")
		{ 
		//Added to clear request pins-------------------------------------------
            top.mapframe.clearPoints();

//------------------------------------------------------------------------
		var mapimage = document.getElementById('mapImage');
		var dyn = document.getElementById('dyn');
		var layout = document.getElementById('layouts');//added to pan markup objects
			dynheight = img.height;
			dynwidth = img.width;
			dyntop = 45;
			dynleft = 0;
			dyn.src = mapimage.src;
			dyn.width = img.width
			dyn.height = img.height
			dyn.style.visibility = "visible"
			img.style.visibility = "hidden"
		    
			var dx = currentx - startx;
			var dy = currenty - starty;
			dyn.style.left = dx;
			dyn.style.top = dy+40;
			layout.style.left = dx;//added to pan markup objects
			layout.style.top = dy;//added to pan markup objects
		}
  
  
	if(parent.currenttool=="zoomWindow" || parent.currenttool=="zoomOut")
		{

		// determin the drag direction

			if(startx <currentx)
				{
					vleft = startx;
					x1 = currentx
					x2 = startx
				}
			else{
					vleft = currentx;
					x1 = startx
					x2= currentx
				}
	
			if (starty <currenty)
				{
					vtop = starty;
					y1 = currenty-40
					y2 = starty-40
				}
			else{
					vtop = currenty;
					y1 = starty-40
					y2 = currenty-40
				}
	
			
			
			//vls.path = "m" + startx+","+starty+" l"+ startx +","+currenty+" "+currentx+","+currenty+" "+currentx+","+starty+"xe";
			
			if(top.browserName == "Microsoft Internet Explorer")
		 {
	  
		  vls.path = "m" + startx+","+starty+" l"+ startx +","+currenty+" "+currentx+","+currenty+" "+currentx+","+starty+"xe";
			return  false;
		}
		else
		{
		var box = document.getElementById('box');
		 box.style.visibility = "visible";
		var width = Math.abs(startx-currentx);
		var height = Math.abs(starty-currenty);
		box.style.top = vtop;
		box.style.left = vleft;
		box.style.width = width;
		box.style.height=height;
		
			}
		}
	}
	updatecoordinates(currentx,currenty);
}



 //_______________________________________________________________
    //
    // 
    //_______________________________________________________________   

 
 function clear(){
 vls.path = "m"
 dashed.path = "m";
 path = "m";
 areaFlag =0;
 firstFlag =0;
 tlength = 0;
 ItemX = new Array(0);
 ItemY = new Array(0);
}
 
 
 
 //_______________________________________________________________
    //
    // 
    //_______________________________________________________________   


function checkVisible(){
if (parent.postbackframe.myform.vLayer1.checked==false){
alert("Aerial imagery is not available at this level.  Please zoom in to view imagery");
	}
}


//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   

function zoomMap(){

 //calculate the center of the zoom window
 var X1 = startx
 var Y1 = starty
 var X2 = currentx
 var Y2 = currenty
 var temp
 var img = document.getElementById('mapImage');
var zoomFactor = 4;
 
 if (X1 > X2)
 {
 temp = X1
 X1 = X2
 X2 = temp
 }
 
 if (Y1 > Y2)
 {
 temp = Y1
 Y1 = Y2
 Y2 = temp
 }
 
 var zWidth = (X2 - X1);
 var zHeight = (Y2 - Y1);
 
 if (((Y2 - Y1) < 2) || ((X2 - X1) < 2)) {
      return;
   }
 
 
 	var x = (X1 + X2) / 2; 
      var y = (Y1 + Y2) / 2; 
     var  fX = img.width / (zoomFactor * 2);
     var  fY = img.height / (zoomFactor * 2);
     
	
      temp = img.width / zWidth;
      if (temp > zoomFactor) {
         X1 = x - fX;
         X2 = x + fX;
      }
      temp = img.height / zHeight;
      if (temp > zoomFactor) {
         Y1 = y - fY;
         Y2 = y + fY;
      }
	  
factor = img.width/zWidth;
 //Calculate the zoom step values, we will use 25 steps
//zoomStep = factor;

 var vWidth = img.width * factor
 var vHeight= img.height * factor
 var vTop =  -Y1 * factor
 var vLeft = -X1 * factor
// alert(factor)
 zoomSetup(vWidth,vHeight,vTop,vLeft)
 
 }
 
 //_______________________________________________________________
    //
    // 
    //_______________________________________________________________   
 
 function zoomSetup(vWidth,vHeight,vTop,vLeft)
 {
 var dyn = document.getElementById('dyn')
 var inc = 200;
	numsteps = Math.round(Math.abs(vWidth-img.width)/inc);
if (numsteps<5){
	numsteps = 5
	}

if(numsteps>15){
numsteps = 15
}
//alert(numsteps);
counter = 0;
widthStep = (vWidth - img.width)/numsteps;
heightStep = (vHeight-img.height)/numsteps;
leftStep = vLeft/numsteps;
topStep = vTop/numsteps;
dynheight = img.height;
dynwidth = img.width;
dyntop = 40;
dynleft = 0;
dyn.src = document.getElementById('mapImage').src;
dyn.width = img.width;
dyn.height = img.height;
dyn.style.visibility = "visible";
img.style.visibility = "hidden";


//Added to clear request pins-------------------------------------------
top.mapframe.clearPoints();
//------------------------------------------------------------------------

//Added to clear Layouts-------------------------------------------
top.mapframe.clearMarkups();
//------------------------------------------------------------------------

zoomAnim();
}

//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   

 function zoomAnim(){
 var dyn = document.getElementById('dyn');
 counter +=1
if(counter <= numsteps){
	
	dynwidth += widthStep ;
	dynheight +=heightStep ;
	dyntop += topStep;
	dynleft += leftStep ;
	
	
 	dyn.height =Math.round(dynheight) ;
	dyn.width = Math.round(dynwidth) ;
	dyn.style.left = Math.round(dynleft) ;
	dyn.style.top = Math.round(dyntop);
	
   window.setTimeout("zoomAnim()",100);

	}

}


	//_______________________________________________________________
    //
    // 
    //_______________________________________________________________   

function setPan(dir)
{
var txtpan = parent.postbackframe.myform.txtpandirection;
var x;
var y;
 switch(dir){
            case "west":
                x = mapimage.width / 2 - mapimage.height / 4;
                y = mapimage.height / 2;
                break;

            case "east":
                x = mapimage.width / 2 + mapimage.height / 4;
                y = mapimage.height / 2;
				break;
				
            case "north":
                x = mapimage.width / 2;
                y = mapimage.height / 2 - mapimage.height / 4;
				break;
				
            case "south":
                x = mapimage.width / 2;
                y = mapimage.height / 2 + mapimage.height / 4;
				break;	
       }
		txtpan.value = x+","+y
		
		//Added to clear request pins-------------------------------------------
top.mapframe.clearPoints();
//------------------------------------------------------------------------


       parent.postbackframe.myform.btnPan.click();
    }
    
    
    
    //---------------------------------------------------------------------------------------------------------------------------------------------------
    
    //_______________________________________________________________
    //
    // Calculate the area selected on the map
    //_______________________________________________________________   
    
function calcArea(e){

if(parent.currenttool =="measure")
{
// This section gets the screen location of the mouse clicks---------------------------------------------------
var test ="";
if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

 if (e)
  { 
    if (e.pageX || e.pageY)
   { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
     ptx = e.pageX;
      pty = e.pageY;
    }
    else if (e.clientX || e.clientY)
   { // works on IE6,FF,Moz,Opera7
    ptx = e.clientX + document.body.scrollLeft;
     pty = e.clientY + document.body.scrollTop;
     
    }
  }
//create a World point from the screen click----------------------------------------------------------------
wpt = vMap.toWorldPoint(ptx,pty)

ItemX.push(wpt.X);
ItemY.push(wpt.Y);

 var FArea=0;
 var i;
 var vArea;
 //calculate the area------------------------------------
if(ItemX.length >2)
{
	
    FArea =ItemX[ItemX.length-1] * ItemY[0] - ItemX[0] * ItemY[ItemY.length-1];
    for (i = 0;i!=ItemX.length-1;i++)
     { 
      FArea = FArea + ItemX[i] * ItemY[i+1] - ItemX[i+1] * ItemY[i];
     }
			   
    vArea = Math.abs(FArea * 0.5);
   dispArea = vArea 

  if(dispArea> 43560)
    {
       aString = (dispArea/43560).toFixed(2) +" Ac"
    }
    else
    {
      aString = Math.round(dispArea) +" Sf"
    }
  
  parent.dataframe.document.getElementById('txtarea').innerHTML = aString;

}

//calculate the length
if(lastx !=0 && lasty!= 0)
{
    
     var xpow = Math.pow(Math.abs(wpt.X-lastx),2)
     var ypow = Math.pow(Math.abs(wpt.Y-lasty),2)
      var length = Math.sqrt(xpow+ypow);

	var seglength = length
	tlength += seglength
	parent.dataframe.document.getElementById('txttotal').innerHTML = tlength.toFixed(0) +" feet";
}
		
//fpath.value = db

//}
lastx = wpt.X;
lasty = wpt.Y;
//alert(vArea);
//}



}
}





//--------------------------------------------------------------------------------------------------------------------------------------------------------------

function getInfo(e)
{
 if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

 if (e)
  { 
    if (e.pageX || e.pageY)
	  { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
	  idx = e.pageX;
      idy = e.pageY-45;
	 }
    else if (e.clientX || e.clientY)
	{ // works on IE6,FF,Moz,Opera7
    idx = e.clientX + document.body.scrollLeft;
     idy = e.clientY + document.body.scrollTop-45;
    }

var extents = parent.postbackframe.document.getElementById('mapxmin').value+"-"+parent.postbackframe.document.getElementById('mapxmax').value+"-"+
	parent.postbackframe.document.getElementById('mapymin').value+"-"+parent.postbackframe.document.getElementById('mapymax').value;
	
var size = parent.postbackframe.document.getElementById('txtMapWidth').value+"-"+parent.postbackframe.document.getElementById('txtMapHeight').value;

var activelayer = parent.postbackframe.document.getElementById('txtactivelayer').value
mapServices.information( idx, idy,size, extents, activelayer,callGetInformation,ontimeout,onerror)
	}
}

function showInfo()//open the information window
	{
	vs = document.getElementById('information');
	vs.style.visibility="visible";
	vs.style.left=top.lastLeft;
	vs.style.top = top.lastTop;//e.clientY +20;
	}
	
	function closeInfo()//close the information window
	{
	vs = document.getElementById('information');
	vs.style.visibility="hidden"
	var sp = document.getElementById("info")
	sp.innerHTML="";
	}


function callGetInformation(response)
{
	if(response && response!=""){
	showInfo();
	var sp = document.getElementById("info") 
	sp.innerHTML=response;
	 }
}


function findParcel(pid){

var postback = parent.postbackframe.document.getElementById('myform');
//var pt = new vPoint();
if(postback.txtPid.value != pid){
	postback.txtPid.value = pid;
	postback.zoomFlag.value = 1;
   postback.txtbuffer.value = "";
   top.mapframe.clearPoints();
  postback.btnFind.click();
  }
  }
  
  
  function selectParcels(e){
  var postback = parent.postbackframe.document.getElementById('myform');
 if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

 if (e)
  { 
    if (e.pageX || e.pageY)
	  { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
	  idx = e.pageX;
     idy = e.pageY - 45;
	 }
    else if (e.clientX || e.clientY)
	{ // works on IE6,FF,Moz,Opera7
    idx = e.clientX + document.body.scrollLeft;
    idy = e.clientY + document.body.scrollTop -45;
    }
    parent.postbackframe.document.getElementById("txtselectpoint").value = "";
    parent.postbackframe.document.getElementById("txtselectpoly").value = "";
    var mpt = new geo.vPoint();
    mpt = vMap.toWorldPoint(idx,idy);
    if(parent.dataframe.document.title != "Selection"){
    parent.dataframe.document.location = "selection.aspx";
    }
    parent.dataframe.document.getElementById("txtselect").value = mpt.X+","+mpt.Y;
    parent.dataframe.document.getElementById("Form1").goSearch.click();
    
	parent.postbackframe.document.getElementById("txtselectpoint").value = mpt.X+","+mpt.Y;
	postback.btnselect.click();
	
	}
}

function wait(caller){

    window.setTimeout(caller+"()",500);
    }
    
    
    
    
function resultsGrab(context)
{ 
  getMouseXY()
  document.onmousedown = falsefunc; // in NS this prevents cascading of events, thus disabling text selection
  if(context.id=="reqheader")
  {
 	dragobj = context.parentNode.parentNode.parentNode.parentNode;
  }
  else
  {
	  dragobj = this;
  }
  dragobj.style.zIndex = 200; // move it to the top
  document.onmousemove = drag;
  document.onmouseup = drdrop;
  grabx = mousex;
  graby = mousey;
  elex = orix = dragobj.offsetLeft;
  eley = oriy = dragobj.offsetTop;

}

function drdrop()
{
  if (dragobj)
  {
    top.lastLeft = dragobj.style.left;
    top.lastTop = dragobj.style.top;
   dragobj.style.zIndex = 0;
    dragobj = null;
  }


  document.onmouseup = null;
  document.onmousedown = null;   // re-enables text selection on NS
}


function ontimeout(arg)
{

   var msg = arg.get_message() 
   alert(msg);

}

function onerror(arg)
{
     var msg = arg.get_message() 
   alert(msg);
}


function showAerials()
{ 
var postback ;
    if(parent.postbackframe.document.myform)
        {
           postback = parent.postbackframe.myframe;
        }
        
	        if(checkVisible() && parent.postbackframe.document.getElementById('Layer1').checked==false)
	        {
	        parent.postbackframe.document.getElementById('Layer1').checked=true;
	        if(top.dataframe.document.title=="layers")
	            {
	                top.dataframe.document.getElementById("Layer1").checked = true;
	            }
	        }
	        else
	        {
	        parent.postbackframe.document.getElementById('Layer1').checked=false;
	        if(top.dataframe.document.title=="layers")
	            {
	                top.dataframe.document.getElementById("Layer1").checked = false;
	            }
	        }

	        parent.postbackframe.document.getElementById('btnrefresh').click();
	 
	  checkTool()  
}

	
	
	
function checkVisible()
{
  if (parent.postbackframe.document.getElementById('vlayer1').checked==false)
  {
    alert("Aerial imagery is not available at this level.  Please zoom in to view imagery");
    return false;
  }
  else
	{
	return true;
	}
}



function updatecoordinates(idx,idy)
{

pt = vMap.toWorldPoint(idx,idy-45);

window.status = "Coordinates: Northing "+pt.Y + " , Easting "+ pt.X+" Feet  (NAD83 State Plane Connecticut)"; 
return true;



}
