		function showAlert(URL) {
			
			alert('value is : ' + URL );
			}
				
		function popitup(url) {
			newwindow=window.open(url,'name','height=600,width=500');
			if (window.focus) {newwindow.focus()}
			return false;
				}
			
		function Left(str, n){
		
			if (n <= 0)
			return "";
			else if (n > String(str).length)
			return str;
			else
			return String(str).substring(0,n);
			}
			
		function Right(str, n){
			if (n <= 0)
			return "";
			else if (n > String(str).length)
			return str;
			else
			{
          var iLen = String(str).length;
          return String(str).substring(iLen, iLen - n);
      }
}	
		
		function getParameter( name ) {
		
        name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var regexS = "[\\?&]"+name+"=([^&#]*)";
        var regex = new RegExp( regexS );
        var results = regex.exec( window.location.href );
        if( results == null )
          return "";
        else
          return results[1];
      }
		
		function showFeature2(feature,evt) {
            map.graphics.clear();
  			 
  			curFeature = feature;
            var fExtent = feature.geometry.getExtent();
  			var centerPt = fExtent.getCenter();
  			var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NONE, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
  			feature.setSymbol(symbol);

            map.graphics.add(feature);
            centerPt = fExtent.getCenter();
            map.centerAt(centerPt);
        }  
	  	
		function centerMap(feature, ddValue){
		   
            var fExtent = feature.geometry.getExtent();
            var centerPt = new esri.geometry.Point;
            //toggleProgressBar();
			centerPt = fExtent.getCenter();
           // map.centerAt(centerPt);
			map.setExtent(fExtent, true);
			
			 
        } 
	
		function FindMBL(searchText){
				       			
			//build query task
			
			//queryTask_MBL = new esri.tasks.QueryTask("http://74.93.16.209:4444/ArcGIS/rest/services/Southington/South_Parcels/MapServer/1");			 
            //zero out the query Geometry
  			//alert('value is : ' + searchText );
  			 
  			//build query filter
			query_MBL = new esri.tasks.Query();
			query_MBL.geometry = null;
			query_MBL.returnGeometry = true;
			query_MBL.outFields = ["OWNER_NAME", "LOCATION", "ACRES", "MBL" ];
			//query_MBL.where = "MBL = '110-125'";
			query_MBL.where = "MBL = '" + searchText + "'";
  			
  				//show the progress bar.
    			//dojo.byId("progresstext").innerHTML = "Locating Parcel...";
               // toggleProgressBar();
  			 
  			    //Execute the queryTask and call showResults on completion
  			queryTask.execute(query_MBL, function(fset) {
  			    if (fset.features.length === 1) {
				centerMap(fset.features[0],searchText);
  				showFeature2(fset.features[0], null);
  				download();
  			    } else if (fset.features.length !== 0) {
                showFeatureSet(fset,null);
  			    } else{
  				alert ("No features returned from server.")}
  			    });
				dijit.byId("search_results").hide();
				dijit.byId("search").hide();
        }
		
		function showMBLSearchResults(searchMBL) {
		    //the synchronous call to a GP service automatically sends all messages and results to a pre-defined function.
  			var reportURL = "./searchMBL.asp" + "?mbl="+ searchMBL;
  	 	    dojo.byId("resultFrame").src = reportURL;
            dijit.byId("search_results").show();
			//toggleProgressBar();
        }
		
		function showNameSearchResults(searchName) {
		    //the synchronous call to a GP service automatically sends all messages and results to a pre-defined function.
  			var reportURL = "./searchName.asp" + "?name="+ searchName;
  	 	    dojo.byId("resultFrame").src = reportURL;
            dijit.byId("search_results").show();
			//toggleProgressBar();
        }
		
		function showAddrSearchResults(searchAddr) {
		    //the synchronous call to a GP service automatically sends all messages and results to a pre-defined function.
  			var reportURL = "./searchAddr.asp" + "?addr="+searchAddr;
  	 	    dojo.byId("resultFrame").src = reportURL;
            dijit.byId("search_results").show();
			//toggleProgressBar();
        }
		
		function showWebDetail(MBL) {
		    //alert('value is : ' + PARID );
  			
			var reportURL = "./detail_AGS.asp?MBL="+ MBL;
  	 	    dojo.byId("resultFrame2").src = reportURL;
            dijit.byId("WebDetail").show();
			
        }
		
		function showHelp() {
		   // alert('value is : ' + MBL );
  			
			var reportURL = "http://74.93.16.209/HelpFrames/default.htm";
  	 	    dojo.byId("HelpFrame").src = reportURL;
            dijit.byId("WebHelp").show();
			
        }
		
		function showVEDetail(LAT,LON) {
		    //alert('value is : ' + PARID );
  			
			var reportURL = "./vemap.asp?lat=+"+LAT+"+&lon="+LON;
						
  	 	    dojo.byId("VEFRAME").src = reportURL;
            dijit.byId("VE").show();
			
        }
		
		function showAbutterDetail(MBL,HOUSENO,STREET,X,Y,DIST) {
		    //alert('value is : ' + PARID );
  			
			var reportURL = "./abutter_dynamic.asp?parid="+ MBL + "&buffer="+DIST+"&HOUSENO="+HOUSENO+"&STREET="+STREET+"&x="+X+"&y="+Y+"&zoomx=1";
  	 	   //alert('value is : ' + reportURL );
			dojo.byId("AbutterResult").src = reportURL;
            dijit.byId("AbutterDetail").show();
		
		
		
        }
		
		function showAbutter(COUNT,SQL,MBL,HOUSENO,STREET,LOCATION,DIST,ACCOUNT) {
		   	
			var scaleinfo = document.getElementById("scaleoption").options[document.getElementById("scaleoption").selectedIndex].text;
			//alert(scaleinfo);
			var reportURL = "./abutter.asp?COUNT="+COUNT+"&SQL="+SQL+"&MBL="+MBL+"&HOUSENO="+HOUSENO+"&STREET="+STREET+"&LOCATION="+LOCATION+"&DIST="+DIST+"&ACCOUNT='"+ACCOUNT+"'&SCALE='"+scaleinfo+"'";
  	 	    //alert('value is : ' + reportURL );
			
			dojo.byId("AbutterResult").src = reportURL;
            dijit.byId("AbutterDetail").show();
			
		}
		
		function showPropertyCard(parid) {
		    //the synchronous call to a GP service automatically sends all messages and results to a pre-defined function.
  			var reportURL = "http://www.cogcnvgis.com/oxford/AGS_Map/property_card.asp?maplot=" + MBL;
  	 	    //dojo.byId("resultFrame").src = reportURL;
            //dijit.byId("search_results").show();
			//toggleProgressBar();
        }
	
		function showSearch() {
		
			var reportURL = "./search.asp";
  	 	    dojo.byId("searchFrame").src = reportURL;
            dijit.byId('search').show()
			
        }
	
		function setinfoclickon (){
				
				objectconnections[0] = dojo.connect(map, "onClick", executeQueryTask);
				}

		function setinfoclickoff (){
				dojo.disconnect(objectconnections[0]);
				}
	
		function executeQueryTask(evt) {
        map.infoWindow.hide();
        map.graphics.clear();
        featureSet = null;

		
  			 
  			//build query filter
			query = new esri.tasks.Query();
			query.geometry = null;
			query.returnGeometry = true;
			query.outFields = ["IMAGE_LINK", "OWNER_NAME", "ACRES", "ACCOUNT", "HOUSE_NUM", "STREET", "BEDROOMS", "CLASS", "LOCATION", "YR_BLT", "UNIQUE_ID", "MBL", "MBL2", "X","Y","LAT","LON","GIS_LINK","HOUSENO"];
			
		
		//onClick event returns the evt point where the user clicked on the map.
        //This is contains the mapPoint (esri.geometry.point) and the screenPoint (pixel xy where the user clicked).
        //set query geometry = to evt.mapPoint Geometry
        query.geometry = evt.mapPoint;
;
        //Execute task and call showResults on completion
        queryTask.execute(query, function(fset) {
          if (fset.features.length === 1) {
            showFeature(fset.features[0],evt);
          } else if (fset.features.length !== 0) {
            showFeatureSet(fset,evt);
          }
        });
		
		
      }

		function showFeature(feature,evt) {
        map.graphics.clear();
		
        //set symbol 'javascript:showWebDetail(" + attr.parid +")'
        var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.5]));
        feature.setSymbol(symbol);

        //construct infowindow title and content
        var attr = feature.attributes;
		var title = ""+ attr.LOCATION
		
		
		var length_test = attr.IMAGE_LINK.length;
		//alert('initial value is : ' + attr.MBL);
		//alert('initial value is : ' +  length_test );
        
		if (length_test < 4)
			{
			IMAGELINK = "nopic"
			}
			else 
			{
			IMAGELINK = attr.IMAGE_LINK
			}

		var content = "<table>"
					+ "<tr><td><a href=\"./Bldgphotos/" + IMAGELINK  + "\" class=\"highslide\" onclick=\"return hs.expand(this)\">"
					+ "<IMG height='100' width='130' src='./BldgPhotos/" + IMAGELINK + "' </IMG></td></a>"
					+ "<td><b>MBL : " + attr.MBL2 +"</b>"
					+ "<br /><b>Owner :</b> " + attr.OWNER_NAME
                    + "<br /><b>Acres :</b> " + attr.ACRES 
					+ "<br /><b>Year Built :</b> " + attr.YR_BLT 
					+ "<br /><b>Bedrooms :</b> " + attr.BEDROOMS
					+ "<br /><b>Class :</b> " + attr.CLASS +"</td></tr></table>"
					+ "<td><a href=javascript:showWebDetail('" + attr.MBL2 + "')>Parcel Details</a>"
					+ "&nbsp;&nbsp;&nbsp;<a href=\"http://74.93.16.209/webdata/Oxford/parcelmaps/" + attr.MBL + ".pdf\" onclick=\"return popitup('http://74.93.16.209/webdata/Oxford/parcelmaps/" + attr.MBL2 + ".pdf')\" >Quick Map</a>"
					+ "&nbsp;&nbsp;&nbsp;<a href=http://www.cogcnvgis.com/Oxford/ags_map/property_card.asp?maplot=" + attr.MBL2 + " TARGET='_blank' >Property Card </a>"
					+ "&nbsp;&nbsp;&nbsp;<a href=javascript:showVEDetail('" + attr.LAT + "','"+ attr.LON +"')>BirdsEye Photo</a>"
					//+ "<br /><br/><b>Generate Mailing List: </b><input id='txtgpdist' width='30px' type='text' name='txtgpdist' value='100'>&nbsp; Ft:&nbsp;<input id='btnGP' type='button' onclick='showAbutterDetail(&#39 "+ attr.MBL2 +"&#39,"+ attr.HOUSE_NUM +",&#39 " + attr.STREET + "&#39, " + attr.X + ","+attr.Y+",dojo.byId(&#39txtgpdist&#39).value)' value='Submit' >"
					+ "<br/><br/><input id='txtgpdist' width='30px' type='text' name='txtgpdist' value='100'>&nbsp; Ft:&nbsp;<input id='btnGP' type='button' onclick='Buffer( dojo.byId(&#39txtgpdist&#39).value,&#39 " + attr.ACCOUNT +"&#39,&#39 "+ attr.MBL2+ "&#39,&#39 " + attr.HOUSENO + "&#39,&#39" + attr.STREET + "&#39,&#39 " + attr.LOCATION + "&#39 )' value='Submit'> </form>"
       
					//alert('initial value is : ' + attr.HOUSENO );			
        map.graphics.add(feature);
		map.infoWindow.resize(410,200);
        map.infoWindow.setTitle(title);
        map.infoWindow.setContent(content);
		
        (evt) ? map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint)) : null;
		
      }

		function showFeatureSet(fset,evt) {
        //remove all graphics on the maps graphics layer
        map.graphics.clear();
		
        var screenPoint = evt.screenPoint;

        featureSet = fset;

        var numFeatures = featureSet.features.length;
		
        //QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the infowindow.
        var title = "You have selected " + numFeatures + " fields.";
        var content = "Please select desired field from the list below.<br />";

        for (var i=0; i<numFeatures; i++) {
          var graphic = featureSet.features[i];
		  //alert('hi '+ numFeatures );
          content = content + graphic.attributes.FIELD_NAME + " Field (<A href='javascript:showFeature(featureSet.features[" + i + "]);'>show</A>)<br/>";
        }
        map.infoWindow.setTitle(title);
        map.infoWindow.setContent(content);
        map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
      }
		
		function Buffer(DIST,ACCOUNT,MBL2,HOUSENO,STREET,LOCATION){
			
			map.infoWindow.hide()
			map.graphics.clear();
			dojo.disconnect(objectconnections[2]);
			dojo.disconnect(objectconnections[3]);
			
			var str = ACCOUNT;
			var length = (str.length);
						
			ACCOUNT = Right(ACCOUNT,length-1);
				
			var querySurroundingParcels, queryTaskSurroundingParcels;
			
			queryTaskSurroundingParcels = new esri.tasks.QueryTask("http://74.93.16.209:443/ARCSERVER/rest/services/Oxford/Parcels_V/MapServer/0");
			queryTaskBuffer = new esri.tasks.QueryTask("http://74.93.16.209:443/ARCSERVER/rest/services/Oxford/Parcels_V/MapServer/0");
		
			// Set up query for surrounding parcels
			querySurroundingParcels = new esri.tasks.Query();
			querySurroundingParcels.outFields = ["ACCOUNT", "MBL2"];
			querySurroundingParcels.returnGeometry = true;
			querySurroundingParcels.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;

			var query_buffer = new esri.tasks.Query();
			
			query_buffer.returnGeometry = true;
			query_buffer.outFields = ["ACCOUNT", "LOCATION", "MBL2" ];
			query_buffer.where = "ACCOUNT = '" + ACCOUNT + "'";
  			
			queryTaskBuffer.execute(query_buffer, function(fset) {
  			    
				if (fset.features.length === 1) {

				var params = new esri.tasks.BufferParameters();
				params.features = [ fset.features[0] ];
				params.distances = [ DIST ];
				params.unit = esri.tasks.BufferParameters.UNIT_FOOT;
				params.bufferSpatialReference = new esri.SpatialReference({wkid: 2234});
				geometryService.buffer(params);	
				
				} else {
  				alert ("Error Processing Buffer")};
  			    });
		  
		  // +++++Listen for GeometryService onBufferComplete event+++++		
		  
		  objectconnections[2] = dojo.connect(geometryService, "onBufferComplete", function(graphics) {
          
		  var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
          var graphic = new esri.Graphic(graphics[0].geometry,symbol);
          
		  map.graphics.add(graphic);
	
		// Set the query geometry equal to the buffer
          querySurroundingParcels.geometry = graphic.geometry;
          
          // Query for parcels within the buffer
          queryTaskSurroundingParcels.execute(querySurroundingParcels); 
			
         });
		  
		// +++++Listen for surrounding parcels query onComplete event+++++
		objectconnections[3] = dojo.connect(queryTaskSurroundingParcels, "onComplete", function(fset) {         
          // Create symbols for result features
		  
          var symbol = new esri.symbol.SimpleFillSymbol();
		   	
			// Get result features
			var resultFeatures = fset.features;
                   
          // Add result features to map and table
          for (var i=0, il=resultFeatures.length; i<il; i++) {
            var graphic = resultFeatures[i];
            
            //Add result feature to map
            graphic.setSymbol(symbol);
			map.graphics.add(graphic);  
			}
		//set up SQL for trip to 'showAbutterDetail'
			
		var numFeatures, AbutterSQL_ADD, AbutterSQL, text;
		var attr = resultFeatures.attributes;
		
		numFeatures = resultFeatures.length;		
		
		AbutterSQL = ""
		for (var i=1, il=numFeatures; i<il; i++) {
		AbutterSQL_ADD = " OR [MBL2] like '" + resultFeatures[i].attributes.MBL2 + "'"
		AbutterSQL = AbutterSQL + AbutterSQL_ADD
		}
		
		SQL = "SELECT * FROM CAMA_COMPOSITE WHERE [MBL2] like '" + resultFeatures[0].attributes.MBL2 + "'" + AbutterSQL + "and [SUPPRESS] <> '1' " 
		//alert(SQL);
		map.graphics.clear();
		showAbutter(numFeatures,SQL,MBL,HOUSENO,STREET,LOCATION,DIST,ACCOUNT)
	
		 });
		 	 
		 }
	 
		function Print_I(MI) {
		
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number

		ieversion = 1
		}
		else
		ieversion = 0
		
		var URL, scale, layers, basemap, mwidth, mheight, mwidth2, mheight2, percentw, percenth, centerx, centery, extentXmax, extentXmin, extentYmax, extentYmin
		
		//print map size: 670x650
		 URL = MI.href
		 scale = MI.scale
		 layers = map.layerIds
		
		
		mwidth = map.extent.xmax - map.extent.xmin
		mheight = map.extent.ymax - map.extent.ymin
		
		mwidth2 = map.width
		mheight2 = map.height
		
		percentw = 670/mwidth2
		percenth = 650/mheight2
		
		centerx = map.extent.xmax - (mwidth/2)
		centery = map.extent.ymax - (mheight/2)
		
		extentXmax = centerx + ((mwidth*percentw)/2)
		extentXmin = centerx - ((mwidth*percentw)/2)
		extentYmax = centery + ((mheight*percenth)/2)
		extentYmin = centery - ((mheight*percenth)/2)
		
		//alert (extentXmin);
		//alert (extentXmax);
		//alert (extentYmin);
		//alert (extentYmax);
		
		//alert('value is : ' + mwidth );
		//alert('value is : ' + scale );
		//alert('value is : ' + map.width );
		//alert('value is : ' + map.height );
		//alert('value is : ' + map.extent.xmax );
		//alert('value is : ' + map.extent.xmin );
		//alert('value is : ' + map.extent.ymin );
		//alert('value is : ' + map.extent.ymax );
		
				
		//Test for layer visibility
		
		var inputs_print = dojo.query(".list_item"), input;
		var printlayers = ''
        for (var i=0, il=inputs_print.length; i<il; i++) {
          if (inputs_print[i].checked) {
            printlayers = printlayers + inputs_print[i].id +",";
			}
		}
				
		//Test for base map
		var curBase = map.getLayer('photo')
			if (curBase.visible){
				basemap = curBase.id
				}
				else{
				basemap = 'base';
				}
		
		//alert(printlayers);
		
		var PrintURL = "./printmap.asp?extentYmin="+ extentYmin +"&extentXmin=" + extentXmin +"&extentXmax="+ extentXmax +"&extentYmax=" + extentYmax +"&printlayers=" + printlayers +"&layercount=" + il +"&scale=" + scale +"&MBL=" + MBL +"&ieversion=" + ieversion +"&basemap=" + basemap;
		//alert('value is : ' + PrintURL );	
			
			dojo.byId("printframe").src = PrintURL;
            dijit.byId("printdialog").show();		
		}
		
		function Print_Buffer(DIST,ACCOUNT,SCALE) {
		
			if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
			var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
			
			ieversion = 1
			}
			else
			ieversion = 0
			
	
	var URL, scale, layers, basemap, mwidth, mheight, mwidth2, mheight2, percentw, percenth, centerx, centery, extentXmax, extentXmin, extentYmax, extentYmin
		
		//print map size: 670x650
		//URL = MI.href
		// scale = MI.scale
		//layers = map.layerIds
		map=parent.map
		
		mwidth = map.extent.xmax - map.extent.xmin
		mheight = map.extent.ymax - map.extent.ymin
		
		mwidth2 = map.width
		mheight2 = map.height
		
		percentw = 670/mwidth2
		percenth = 650/mheight2
		
		centerx = map.extent.xmax - (mwidth/2)
		centery = map.extent.ymax - (mheight/2)
		
		extentXmax = centerx + ((mwidth*percentw)/2)
		extentXmin = centerx - ((mwidth*percentw)/2)
		extentYmax = centery + ((mheight*percenth)/2)
		extentYmin = centery - ((mheight*percenth)/2)
		

		//Test for layer visibility
		
		var inputs_print = parent.dojo.query(".list_item"), input;
		var printlayers = ''
        for (var i=0, il=inputs_print.length; i<il; i++) {
          if (inputs_print[i].checked) {
            printlayers = printlayers + inputs_print[i].id +",";
			}
		}
		
		//Test for base map
		var curBase = map.getLayer('photo')
			if (curBase.visible){
				basemap = curBase.id
				}
				//else if (map.getLayer('photo2').visible) {
					//	basemap = map.getLayer('photo2').id
			//	}
				else{
				basemap = 'base';
				}
		
		var PrintURL = "./printbuffermap.asp?extentYmin="+ extentYmin +"&extentXmin=" + extentXmin +"&extentXmax="+ extentXmax +"&extentYmax=" + extentYmax +"&printlayers=" + printlayers +"&layercount=" + il +"&ieversion=" + ieversion +"&basemap=" + basemap+"&DIST=" + DIST+"&ACCOUNT=" + ACCOUNT +"&SCALE=" + SCALE;

		//alert('value is : ' + PrintURL ); 	
			
			parent.dojo.byId("printframe").src = PrintURL;
            parent.dijit.byId("printdialog").show();		
		}
		
		function Export_I(MI) {
		
		sbip = new esri.layers.ImageParameters()
		
		//sbip.bbox = startExtent;
		//sbip.height = 300;
		//sbip.width= 300;
		
		sbip.bbox = map.extent
		sbip.height = map.height
		sbip.width = map.width
		//sbip.layerIds = [7]
		//sbip.layerOption = 'LAYER_OPTION_SHOW'
		
		ParcelBaseLayer.exportMapImage(sbip);
		
		}
	  
	    function showCoordinates(evt) {
        //get mapPoint from event
        var mp = evt.mapPoint;
        //display mouse coordinates
        dojo.byId("info").innerHTML = Math.round(mp.x) + ", " + Math.round(mp.y);
      }
	  
		function RefreshMap() {
		
		xmax = map.extent.xmax
		xmin = map.extent.xmin
		ymax = map.extent.ymax
		ymin = map.extent.ymin
		
		self.location.href='./default.htm?dis=N&xmax='+xmax+'&xmin='+xmin+'&ymax='+ymax+'&ymin='+ymin
		}
	  
		function changescale(option) {
			//showAlert(option)
			map.setLevel(option)		
		}
		
		function MapInfo(extent, delta, levelChange, lod) {

        //display scale info
        var scaleinfo = (lod.scale)/15
		var maplevel = (lod.level)
			var selectmenu=document.getElementById("scaleoption")
			selectmenu.selectedIndex = 14-maplevel
		//dojo.byId("scaleinfo").innerHTML = "Scale: 1 in = " + scaleinfo + " Feet";
      }
	  
		function updateLayerVisibility() {
        var inputs = dojo.query(".list_item"), input;
        //these are the layers which will always be on unless controlled by scale factors
        visible = [];
        for (var i=0, il=inputs.length; i<il; i++) {
          if (inputs[i].checked) {
            visible.push(inputs[i].id);
          }
        }
        //mydynamicMapServiceLayer.setVisibleLayers(visible);
		AdminLayer.setVisibleLayers(visible);
      }
	  	  		
        function changeMap(layerid) {
		//Switch between the basemap layers, or toggle the parcel layer
		
  		    var curLayer = map.getLayer(layerid);
  			toggleLayer(curLayer);
			//alert('initial value is : ' + curLayer );
        }

		function toggleLayer(layer) {
		//if the layer is visible, turn it off and update the control panel. If invisible, do the same.
         		 
   			switch (layer.id)
  			{
  			    case "photo":
  				if(dojo.byId("rdphoto").Checked){
                    //do nothing
                }
  			else{
                if (layer.visible){
                    layer.hide();
  				    map.getLayer("basemap").show();
  				    dojo.byId("rdbase").Checked = true;
  				    dojo.byId("rdphoto").Checked = false;
                }
   			    else{
                    layer.show();
   				    map.getLayer("basemap").hide();
					
					
   				    dojo.byId("rdbase").Checked = false;
   				    dojo.byId("rdphoto").Checked = true;
                }
            }
             
                break;
  			    case "basemap":
  				if(dojo.byId("rdbase").Checked){
                    //do nothing
  				}
  				else{
                    if (layer.visible){
						layer.hide();
                        map.getLayer("photo").show();
    				    dojo.byId("rdphoto").Checked = true;
                        dojo.byId("rdbase").Checked = false;
    				    
                    }
    				else{
                    layer.show();
					map.getLayer("basemap").show();
   				    map.getLayer("photo").hide();
   				    dojo.byId("rdphoto").Checked = false;
   				    dojo.byId("rdbase").Checked = true;
    				    
                    }
                }
                break;
  			    
  			}
        }
		
		function toggleProgressBar() {
		    var progressbar_container = dojo.byId("progressbar_container");
			//var control_panel = dojo.byId("control_panel");
				
			if (progressbar_container.style.display=="block") {
			    progressbar_container.style.display="none";
            }
            else {
                progressbar_container.style.display="block";
            }
        }
		
        function download(){
            // Split up bar into 5% segments
			       
            numParts = Math.floor(100/2);
            jsProgress.update({ maximum: numParts, progress:0 });
            for (var i=0; i<=numParts; i++){
                // This plays update({progress:0}) at 1nn milliseconds,
                // update({progress:1}) at 2nn milliseconds, etc.
                setTimeout("jsProgress.update({ progress: " + i + " })",(i+1)*100 + Math.floor(Math.random()*100));
            }	
			numParts = Math.floor(100/2);
			jsProgress.update({ maximum: numParts, progress:0 });

			
        }
	
	    function initMeasure(map,tb) {
        
		dojo.disconnect(objectconnections[0]);
		dojo.disconnect(objectconnections[1]);
		navToolbar.deactivate();
		
        //on draw end add graphic, project it, and get new length
        objectconnections[1] = dojo.connect(tb, "onDrawEnd", function(geometry) {
          map.graphics.clear();
          var graphic = map.graphics.add(new esri.Graphic(geometry, new esri.symbol.SimpleLineSymbol()));
          //add graphic to the map and then call GeometryService.project() to get graphic into a coordinate system that
          //can be used to generate an accurate length.
          geometryService.project([graphic],new esri.SpatialReference({"wkid":2234}));
        });
        tb.activate(esri.toolbars.Draw.POLYLINE);		
      }
	  
	    function initMeasure2(map,tb) {
        
		dojo.disconnect(objectconnections[0]);
		dojo.disconnect(objectconnections[1]);
		navToolbar.deactivate();
		
        //on draw end add graphic, project it, and get new length
        objectconnections[1] = dojo.connect(tb, "onDrawEnd", function(geometry) {
          map.graphics.clear();
          var graphic = map.graphics.add(new esri.Graphic(geometry, new esri.symbol.SimpleLineSymbol()));
          //add graphic to the map and then call GeometryService.project() to get graphic into a coordinate system that
          //can be used to generate an accurate length.
          geometryService.project([graphic],new esri.SpatialReference({"wkid":2234}));
        });
        tb.activate(esri.toolbars.Draw.LINE);
		}
	  
	  	function initMeasure3(map,tb) {
        
		dojo.disconnect(objectconnections[0]);
		dojo.disconnect(objectconnections[1]);
		navToolbar.deactivate();
		
        //on draw end add graphic, project it, and get new length
        objectconnections[1] = dojo.connect(tb, "onDrawEnd", function(geometry) {
          map.graphics.clear();
          var graphic = map.graphics.add(new esri.Graphic(geometry, new esri.symbol.SimpleLineSymbol()));
          //add graphic to the map and then call GeometryService.project() to get graphic into a coordinate system that
          //can be used to generate an accurate length.
          geometryService.project([graphic],new esri.SpatialReference({"wkid":2234}));
        });
        tb.activate(esri.toolbars.Draw.FREEHAND_POLYLINE);		
      }
	  
		function initArea(map,tb) {
        
		dojo.disconnect(objectconnections[0]);
		dojo.disconnect(objectconnections[1]);
		navToolbar.deactivate();
		
        //on draw end add graphic, project it, and get new length
        objectconnections[1] = dojo.connect(tb, "onDrawEnd", function(geometry) {
          map.graphics.clear();
          var graphic = map.graphics.add(new esri.Graphic(geometry, new esri.symbol.SimpleFillSymbol()));
		  geometryService.simplify([graphic], function(graphics) {
          geometryService.areasAndLengths(graphics);
			});
        });
        tb.activate(esri.toolbars.Draw.POLYGON);		
      }
	  
	    function ZoomIn(map,tb) {
	   
        endFunctionality(map,tb)
		navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN);
      }
			  
	    function ZoomOut(map,tb) {
	   
        endFunctionality(map,tb)
		navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT);
      }
	    
		function Pan(map,tb) {
	   
        endFunctionality(map,tb)
		navToolbar.activate(esri.toolbars.Navigation.PAN);
      }
				
		function outputDistance(result) {
        //dojo.byId("distance").innerHTML = dojo.number.format(result.lengths[0] ) + " Feet";

		
		alert('Distance = ' + dojo.number.format((result.lengths[0]), {places : 1}) + " Feet");
		map.graphics.clear();	
		//alert('This is a custom alert dialog that was created by over-riding the window.alert method.');
		
      }
	  
	    function outputAreaAndLength(result) {
        //console.log(dojo.toJson(result));
        //dojo.byId("distance").innerHTML = result.areas[0]/43560 + " Acres";
		alert('Area = ' + dojo.number.format((result.areas[0]/43560), {places : 2}) + " Acres");
		map.graphics.clear();
        //dojo.byId("length").innerHTML = result.lengths[0] + " feet";
      }
		
		function endFunctionality(map,tb) {
		
		map.graphics.clear();
		dojo.disconnect(objectconnections[0]);
		dojo.disconnect(objectconnections[1]);
		tb.deactivate();
		objectconnections[0] = dojo.connect(map, "onClick", executeQueryTask);
		navToolbar.deactivate()
		}
		
		function advancedsearch() {
		
			//dijit.byId("search").hide();
			var searchURL = "./advancedsearch.asp";
  	 	    dojo.byId("searchframe").src = searchURL;
            dijit.byId("Advanced_Search").show();
			dijit.byId("search").hide();
			
        }
			
		
