 		
		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.setExtent(fExtent, true);
            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){
			//set global variable for MBL
			
			MBL = searchText	       			
  				
  			//build query filter
			query_MBL = new esri.tasks.Query();
			query_MBL.geometry = null;
			query_MBL.returnGeometry = true;
			//query_MBL.outFields = ["OWN1", "FULL_ADDR", "ACRES", "ZONING", "MBL"];
			query_MBL.outFields = ["MBL,GIS_LINK"];
			query_MBL.where = "GIS_LINK = '" + 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();
				//dijit.byId("Advanced_Search").hide();
        }
		
		function showCondoSearchResults(searchMBL) {
		    //the synchronous call to a GP service automatically sends all messages and results to a pre-defined function.
  			var reportURL = "./searchCONDO.asp" + "?mbl="+ searchMBL;
  	 	    dojo.byId("resultFrame").src = reportURL;
            dijit.byId("search_results").show();
			
        }
		
		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.
			//alert(searchAddr)
  			var reportURL = "./searchAddr.asp" + "?addr="+searchAddr;
  	 	    dojo.byId("resultFrame").src = reportURL;
            dijit.byId("search_results").show();
			dijit.byId('search_results')._underlay.hide();
			//toggleProgressBar();
        }
		
		function showWebDetail(MBL) {
		    //alert('value is : ' + PARID );
  			
			var reportURL = "http://www.northstoningtongis.com/ags_map/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(PARID,HOUSENO,STREET,X,Y,DIST) {
		   		
			var reportURL = "./abutter_dynamic.asp?parid="+ PARID + "&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://74.93.16.209/southington/property_card.asp?parid=" + parid;
  	 	    //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()
			dijit.byId('search')._underlay.hide();
			
        }
	
		function setinfoclickon (){
				
				objectconnections[0] = dojo.connect(map, "onClick", executeQueryTask);
				}

		function setinfoclickoff (){
				dojo.disconnect(objectconnections[0]);
				}
	
		function initaddFeatures (){
		
  		dojo.disconnect(objectconnections[0]);
		dojo.disconnect(objectconnections[1]);
		navToolbar.deactivate();
		
		objectconnections[0] = dojo.connect(map, "onClick", addFeatures);
		objectconnections[1] = dojo.connect(map, "onDblClick", showSelection);
		}
		
		function addFeatures(evt) {
		
		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]));
        var cut
		cut = 0
        //build query task	
  			 
  			//build query filter
			query = new esri.tasks.Query();
			query.geometry = null;
			query.returnGeometry = true;
			query.outFields = ["MBL", "GIS_LINK"];			
		
		//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  
        queryTask.execute(query, function(fset) {
		

			if (featuregroup.length > 0) {			
			
			for (var i=0; i<featuregroup.length; i++){
				if (fset.features[0].attributes.MBL == featuregroup[i]){
					featuregroup.splice(i,1);
					map.graphics.remove(map.graphics.graphics[i]);
					//map.graphics.remove(map.graphics.graphics[map.graphics.graphics.length -1])
					cut = 1;
				}
				}
							
				if (cut != 1){
				featuregroup.push(fset.features[0].attributes.MBL);
					if (fset.features.length === 1) {
					//showFeature5(fset.features[0],evt);
					fset.features[0].setSymbol(symbol);
					map.graphics.add(fset.features[0]);
					} 
					else if (fset.features.length !== 0) {
					showFeatureSet5(fset,evt);
					}				
				}				
			}
			
			if (featuregroup.length <1) {
				featuregroup.push(fset.features[0].attributes.MBL);
				
				if (fset.features.length === 1) {
				//showFeature5(fset.features[0],evt);
				fset.features[0].setSymbol(symbol);
				map.graphics.add(fset.features[0]);
				} 
				else if (fset.features.length !== 0) {
				showFeatureSet5(fset,evt);
				}
			}
					 		  
        });
				
		
      }

		function showSelection(){
		
		//set up SQL for trip to 'showAbutterDetail'
			
		var numFeatures, AbutterSQL_ADD, AbutterSQL, text;
		
		numFeatures = featuregroup.length;		

		AbutterSQL = ""
		for (var i=1, il=numFeatures; i<il; i++) {
		AbutterSQL_ADD = " OR [GIS_LINK] like '" + featuregroup[i] + "'"
		AbutterSQL = AbutterSQL + AbutterSQL_ADD
		}
		
		SQL = "SELECT * FROM CAMA_COMPOSITE WHERE [GIS_LINK] like '" + featuregroup[0] + "'" + AbutterSQL

		featuregroup.length = 0;
		map.graphics.clear();
		
		var reportURL = "./selection.asp?COUNT="+numFeatures+"&SQL="+SQL;
 			
			dojo.byId("AbutterResult").src = reportURL;
            dijit.byId("AbutterDetail").show();
		
		}		
		
		function executeQueryTask(evt) {
        map.infoWindow.hide();
        map.graphics.clear();
        featureSet = null;

        ///build query task
	
  			 
  			//build query filter
			query = new esri.tasks.Query();
			query.geometry = null;
			query.returnGeometry = true;
			query.outFields = ["OWNER_NAME", "LOCATION", "HOUSENO", "STREET","GIS_LINK", "ACRES", "ZONING", "MBL", "ACCOUNT","MAP", "YR_BLT", "BEDROOMS", "X", "Y", "LAT", "LON", "IMAGE_LINK","NEG_MultiFamily" ];
			
		
		//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 condo_test = attr.NEG_MultiFamily;
		var length_test = attr.IMAGE_LINK;
		
		var HOUSENO = attr.HOUSENO
		HOUSENO = HOUSENO.toString()
		//alert('initial value is : ' + attr.ACCOUNT);
		//alert('initial value is : ' +  length_test );
        //alert('initial value is : ' + condo_test);
		if (length_test < 4)
			{
			IMAGELINK = "nopic.jpg"
			}
			else 
			{
			IMAGELINK = attr.IMAGE_LINK
			}
 		
		if (condo_test == "Yes")
			{ //alert('initial value is : ' + condo_test);
			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>MULTI OWNER COMPLEX</b><br><br><b>MBL : " + attr.MBL +"</b>"
					+"</td></tr></table>"
					+ "<td><a href=javascript:showCondoSearchResults('" + attr.GIS_LINK + "')>Multi-Owner Records</a>"
					+ "&nbsp;&nbsp;&nbsp;<a href=\"http://74.93.16.209/webdata/north_stonington/parcelmaps/" + attr.GIS_LINK + ".pdf\" onclick=\"return popitup('http://74.93.16.209/webdata/north_stonington/parcelmaps/" + attr.GIS_LINK + ".pdf')\" >Quick Map</a>"
					+ "&nbsp;&nbsp;&nbsp;<a href=javascript:showVEDetail('" + attr.LAT + "','"+ attr.LON +"')>BirdsEye Photo</a>"
					+ "<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,"+ attr.MBL + ",&#39 " + attr.HOUSENO + "&#39,&#39" + attr.STREET + "&#39,&#39 " + attr.LOCATION + "&#39 )' value='Submit'> </form>"

			}
			else 
			{  
	   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 : </b>" + attr.MBL
					+ "<br /><b>Owner: " + attr.OWNER_NAME +"</b>"
                    + "<br /><b>Acres : </b>" + attr.ACRES 
					+ "<br /><b>Zoning : </b>" + attr.ZONING 
					+ "<br /><b>Year Built :</b> " + attr.YR_BLT 
					+ "<br /><b>Bedrooms :</b> " + attr.BEDROOMS
					+ "</td></tr></table>"					
					+ "<a href=javascript:showWebDetail('" + attr.MBL + "')>Parcel Details</a>" 
					+ "&nbsp;&nbsp;&nbsp; <a href=\"http://74.93.16.209/webdata/north_stonington/parcelmaps/" + attr.MBL + ".pdf\" onclick=\"return popitup('http://74.93.16.209/webdata/north_stonington/parcelmaps/" + attr.MBL + ".pdf')\">Quick Map</a>"
					+ "&nbsp;&nbsp;&nbsp;" + "<a href=../property_card.asp?maplot=" + attr.MBL + " TARGET='_blank' >Summary Card</a>"
					+ "&nbsp;&nbsp;&nbsp;<a href=javascript:showVEDetail('" + attr.LAT + "','"+ attr.LON +"')>Birds Eye Photo</a>"
					+ "<br /><br /><b>Generate Abutter List: </b>"					
					+ "<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,"+ attr.MBL + ",&#39 " + attr.HOUSENO + "&#39,&#39" + attr.STREET + "&#39,&#39 " + attr.LOCATION + "&#39 )' value='Submit'> </form>"
       
			}
		map.graphics.add(feature);
		map.infoWindow.resize(415,220);
        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];
          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,MBL,HOUSENO,STREET,LOCATION){
			
			map.infoWindow.hide()
			map.graphics.clear();
			dojo.disconnect(objectconnections[2]);
			dojo.disconnect(objectconnections[3]);
			
			var querySurroundingParcels, queryTaskSurroundingParcels;
			
			queryTaskSurroundingParcels = new esri.tasks.QueryTask("http://74.93.16.209:443/Arcserver/rest/services/North_Stonington/Parcels_I/MapServer/6");
			queryTaskBuffer = new esri.tasks.QueryTask("http://74.93.16.209:443/Arcserver/rest/services/North_Stonington/Parcels_I/MapServer/6");
			
			// Set up query for surrounding parcels
			querySurroundingParcels = new esri.tasks.Query();
			querySurroundingParcels.outFields = ["MBL", "ACCOUNT"];
			querySurroundingParcels.returnGeometry = true;
			querySurroundingParcels.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;

			var query_buffer = new esri.tasks.Query();
			//query_buffer.geometry = null;
			query_buffer.returnGeometry = true;
			query_buffer.outFields = [ "MBL", "ACCOUNT", "LOCATION" ];
			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 [GIS_LINK] like '" + resultFeatures[i].attributes.MBL + "'"
		AbutterSQL = AbutterSQL + AbutterSQL_ADD
		}
		
		SQL = "SELECT * FROM CAMA_COMPOSITE WHERE [GIS_LINK] like '" + resultFeatures[0].attributes.MBL + "'" + AbutterSQL + "and [SUPPRESS] <> '1' " 
		
		map.graphics.clear();
		showAbutter(numFeatures,SQL,MBL,HOUSENO,STREET,LOCATION,DIST,ACCOUNT)
	
		 });
		 	 
		 }
	
		function prePrint(MI){
			
			var scale
			scale = MI.scale
			var reportURL = "./printconfigure.asp?scale="+scale;
  	 	    dojo.byId("preprintFrame").src = reportURL;
            dijit.byId("preprint").show();
				}
		
		function prePrintPDF(){

			var reportURL = "./printconfigure_PDF.asp";
  	 	    dojo.byId("preprintFrame").src = reportURL;
            dijit.byId("preprint").show();
				}
		
		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)
		

		//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 if (map.getLayer('photo2').visible){
					basemap = map.getLayer('photo2').id
				}
				else if (map.getLayer('photo3').visible){
					basemap = map.getLayer('photo3').id
				}
				else {
				basemap = 'basemap';
				}
		
		
		var PrintURL = "./printmap.asp?extentYmin="+ extentYmin +"&extentXmin=" + extentXmin +"&extentXmax="+ extentXmax +"&extentYmax=" + extentYmax +"&printlayers=" + printlayers +"&layercount=" + il +"&scale=" + scale +"&ieversion=" + ieversion +"&basemap=" + basemap;

		//alert('value is : ' + PrintURL ); 	
			
			dojo.byId("printframe").src = PrintURL;
            dijit.byId("printdialog").show();		
		}
		
		function Print_II(option,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, level, 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
		
		//var scaleinfo = parent.document.getElementById("scaleoption").options[parent.document.getElementById("scaleoption").selectedIndex].text;
		
		
		//alert(scale)
		map=parent.map
		
		mwidth = map.extent.xmax - map.extent.xmin
		mheight = map.extent.ymax - map.extent.ymin
		
		mwidth2 = map.width
		mheight2 = map.height
		
		if (option == 'A')
			{
			var imagewidth = 670;
			var imageheight = 670;
			}
		else if (option == 'B')
			{
			var imagewidth = 800;
			var imageheight = 500;
			}
		else if (option == 'C')
			{
			var imagewidth = 650;
			var imageheight = 1200;
			}
		else
			{
			var imagewidth = 1200;
			var imageheight = 670;
			}
		
		
		percentw = imagewidth/mwidth2
		percenth = imageheight/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 if (map.getLayer('photo3').visible){
					basemap = map.getLayer('photo3').id
				}
				else {
				basemap = 'basemap';
				}
		
		var PrintURL = "./printmap.asp?option="+ option +"&extentYmin="+ extentYmin +"&extentXmin=" + extentXmin +"&extentXmax="+ extentXmax +"&extentYmax=" + extentYmax +"&printlayers=" + printlayers +"&layercount=" + il +"&scale=" + scale +"&ieversion=" + ieversion +"&basemap=" + basemap;
		                    
		//alert('value is : ' + PrintURL ); 	
			
			parent.dojo.byId("printframe").src = PrintURL;
            parent.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 if (map.getLayer('photo3').visible){
					basemap = map.getLayer('photo3').id
				}
				else {
				basemap = 'basemap';
				}
		
		
	
		
		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 Export_II(option) {
		
		var URL, scale, layers, basemap, mwidth, mheight, mwidth2, mheight2, percentw, percenth, centerx, centery, extentXmax, extentXmin, extentYmax, extentYmin

		
		mwidth = map.extent.xmax - map.extent.xmin
		mheight = map.extent.ymax - map.extent.ymin
		
		mwidth2 = map.width
		mheight2 = map.height
		
		//alert(option)
		
		centerx = map.extent.xmax - (mwidth/2)
		centery = map.extent.ymax - (mheight/2)
		
		if (option == 'A')
			{
			var imagewidth = 1300;
			var imageheight = 1200;
			}
		else if (option == 'B')
			{
			var imagewidth = 800;
			var imageheight = 500;
			}
		else if (option == 'C')
			{
			var imagewidth = 650;
			var imageheight = 1200;
			}
		else
			{
			var imagewidth = 2400;
			var imageheight = 1600;
			}
		
		percentw = imagewidth/mwidth2
		percenth = imageheight/mheight2
						
		extentnewxmax = centerx + ((mwidth*percentw)/2)
		extentnewxmin = centerx - ((mwidth*percentw)/2)
		extentnewymax = centery + ((mheight*percenth)/2)
		extentnewymin = centery - ((mheight*percenth)/2)
		
		sbip = new parent.esri.layers.ImageParameters()
		
		//sbip.dpi = [200];
		//sbip.format = ["png8"];
		sbip.width = imagewidth
		sbip.height = imageheight
		
		sbip.bbox = new esri.geometry.Extent(extentnewxmin,extentnewymin,extentnewxmax,extentnewymax,new esri.SpatialReference({ wkid:2234 }));
		
		//sbip.layerIds = [0,10]
		//sbip.layerOption = 'LAYER_OPTION_SHOW'
		
		//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 +",";
			}
		}
		
		PrintLayer1.exportMapImage(sbip,Print_PDF1);
		PrintLayer2.exportMapImage(sbip,Print_PDF2);
		PrintLayer3.exportMapImage(sbip,Print_PDF3);
		
		baseLayer2.exportMapImage(sbip,Print_PDF4);
		baseLayer3.exportMapImage(sbip,Print_PDF5);
		AdminLayer.exportMapImage(sbip,Print_PDF6);
		ParcelBaseLayer.exportMapImage(sbip,Print_PDF7);
		}

		function Print_PDF1(MI) {
		
		URL1 = MI.href
	
		}
		
		function Print_PDF2(MI) {
		
		URL2 = MI.href

		 }
		
		function Print_PDF3(MI) {
		
		URL3 = MI.href		
		
		 }

		function Print_PDF4(MI) {
			
		URL4 = MI.href	
	
		 }

		function Print_PDF5(MI) {
		
		URL5 = MI.href	
		
		 }

		function Print_PDF6(MI) {
		
		URL6 = MI.href		
		
		 }

		function Print_PDF7(MI,option) {
		
		var scale, option
			
		URL7 = MI.href		
		scale = MI.scale
		width = MI.width
				
		if (width == 1300)
			{option = "A"}
		else if (width == 1)	
			{option = "B"}
		else if (width == 2)
			{option = "C"}
		else 
			{option = "D"}
			
			//alert(option)

			
		//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 if (map.getLayer('photo3').visible){
					basemap = map.getLayer('photo3').id
				}
				else {
				basemap = 'basemap';
				}
		
		
		var PrintURL = "http://74.93.16.209:443/Print_Map_PDF.asp?URL1="+ URL1 + "&URL2="+ URL2 + "&URL3="+ URL3 + "&URL4="+ URL4 + "&URL5="+ URL5 + "&URL6="+ URL6 + "&URL7="+ URL7 + "&scale=" + scale +"&basemap=" + basemap +"&option=" + option;
		//alert('value is : ' + basemap ); 	
			
		dojo.byId("printframe").src = PrintURL;
        dijit.byId("printdialog").show();	
		
		 }

		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 changescale(option) {
			//showAlert(option)
			map.setLevel(option);
		}
			
		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 MapInfo(extent, delta, levelChange, lod) {

        //display scale info
        var scaleinfo = (lod.scale)/13
		var maplevel = (lod.level)
		var selectmenu=document.getElementById("scaleoption")
			selectmenu.selectedIndex = 12-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 "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;
						dojo.byId("rdphoto2").Checked = false;
    				    
                    }
    				else{
                    layer.show();
				    map.getLayer("photo").hide();
					map.getLayer("photo2").hide();
					map.getLayer("photo3").hide();
   				    
					dojo.byId("rdphoto").Checked = false;
   				    dojo.byId("rdbase").Checked = true;
					dojo.byId("rdphoto2").Checked = false;
					dojo.byId("rdphoto3").Checked = false;
    				    
                    }
                }
                break;
					
				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;
					dojo.byId("rdphoto2").Checked = false;
                }
   			    else{
                    layer.show();
   				    map.getLayer("basemap").hide();
					map.getLayer("photo2").hide();
					map.getLayer("photo3").hide();
										
   				    dojo.byId("rdbase").Checked = false;
   				    dojo.byId("rdphoto").Checked = true;
					dojo.byId("rdphoto2").Checked = false;
					dojo.byId("rdphoto3").Checked = false;
                }
            }
             
                break;
  			    
				case "photo2":
  				if(dojo.byId("rdphoto2").Checked){
                    //do nothing
  				}
  				else{
                    if (layer.visible){
						layer.hide();
                        map.getLayer("basemap").show();
						dojo.byId("rdphoto2").Checked = false;
                        dojo.byId("rdbase").Checked = false;
						dojo.byId("rdphoto").Checked = true;
    				    
                    }
    				else{
                    layer.show();
					map.getLayer("photo3").hide();
   				    map.getLayer("photo").hide();
					map.getLayer("basemap").hide();
   				    
					dojo.byId("rdphoto").Checked = false;
   				    dojo.byId("rdbase").Checked = false;
					dojo.byId("rdphoto2").Checked = true;
					dojo.byId("rdphoto3").Checked = false;
    				    
                    }
                }
                break;
				
				 case "photo3":
  				if(dojo.byId("rdphoto3").Checked){
                    //do nothing
  				}
  				else{
                    if (layer.visible){
						layer.hide();
                        map.getLayer("photo").show();
    				    dojo.byId("rdphoto").Checked = true;
                        dojo.byId("rdbase").Checked = false;
						dojo.byId("rdphoto2").Checked = false;
						
    				    
                    }
    				else{
                    layer.show();
					map.getLayer("basemap").hide();
   				    map.getLayer("photo").hide();
					map.getLayer("photo2").hide();
					   				    
					dojo.byId("rdphoto").Checked = false;
   				    dojo.byId("rdbase").Checked = false;
					dojo.byId("rdphoto2").Checked = false;
					dojo.byId("rdphoto3").Checked = true;

    				    
                    }
                }
  			    
  			}
        }
		
		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();
			
        }	
		
		
