    //====================================
    //Implementing Geocoding functionality
    //====================================
	var myGC = null;
	var GeocoderSupport = {};

	/**
    * Function: geocodeLoc
    * Called whenever user uses Find a Location facility in the application.
    * Results tab.
    *
    * Parameters: Obtains the parameters street,cross street, city, zip from addSearchForm.
    *
    * Returns: Located Address, and the x,y coordinates
    *
    */
	GeocoderSupport.geocodeLoc = function(){
	     Ext.getCmp('find-a-location-panel').focus();
	     BizMap.locatedAddress = "";
	     BizMap.locX = "";
	     BizMap.locY = "";

	     if (myGC == null){
		    myGC = new OGIS.Geocoder();
		 }
		 else {
		      if (myGC.marker != null && myGC.marker.attributes.locationAddress != null){
		         myGC.marker.attributes.locationAddress = "";
		      }
		 }

         var size = new OpenLayers.Size(21,25);
		 //var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
		 var offset = new OpenLayers.Pixel(-10.5,-25);
		 var icon = new OpenLayers.Icon(OpenLayers.ImgPath + '/marker.png',size,offset);
		 icon.bkg = {};
         icon.bkg.url = OpenLayers.ImgPath + '/marker-shadow.png';
         icon.bkg.offset = new OpenLayers.Pixel(4, -size.h);
         var GC_Options = {
             street : Ext.getCmp('addSearchForm').getForm().findField('street').getValue(),
             crossStreet : Ext.getCmp('addSearchForm').getForm().findField('crossstreet').getValue(),
             city : Ext.getCmp('addSearchForm').getForm().findField('city').getValue(),
             zip : Ext.getCmp('addSearchForm').getForm().findField('zip').getValue(),
             state : "NJ", //Limiting the search to New Jersey State only. A different State can be accepted by exposing the State as a search field
             projectionID : "102711", //Limiting the map projection to New Jersey state plane coordinate system. Geographic map projection(ID being 4269) can be accepted by exposing projectionID as a choice between 102711 and 4269
             gcComponentUrl : OGIS.URLs.gcComponentUrl, //url of the geocode servlet tagged to the OIT_LocationSearch web service.
             resultsDiv : "DashBoard",
             map : map,
             zoomLevel : 9,
             icon: icon,
             afterZoomToPoint: BizMap.loadLocationInfo,
             afterZoomToPolygon: BizMap.loadLocationInfo
         };

         if (Ext.getCmp('addSearchForm').getForm().findField('locStIfAddrNotFound').getValue()){
            GC_Options.locateStreetIfAddrNotFound = true;
         }
         else {
             GC_Options.locateStreetIfAddrNotFound = false;
         }

         if (myGC.searchLocation(GC_Options) == false){
            return false;
         }
         else {
              BizMap.activateResultsTab();
         }
	}

    /**
    * Function: pointClick
    * Called whenever user uses the reverse geocoding tool (famously called the Star Locater).
    * Calls showReverseGCLocation function
    *
    * Parameters: Obtains the parameters street,cross street, city, zip from addSearchForm.
    *
    * Returns: Located Address, and the x,y coordinates
    *
    */
    GeocoderSupport.pointClick = function(){
		     map.events.register("click", map, GeocoderSupport.showReverseGCLocation);
		     document.images['gc_on_off'].src = '/oit/gis/OIT_BusinessMap/images/geocode_on1.gif';
    }

    /**
    * Function: showReverseGCLocation
    * Called from  pointClick function, makes an ajax call to ReverseGeocodeAddress.jsp
    * Calls processRVGCResponse function.
    *
    * Parameters: Coordinates based on the mouse click.
    *
    * Returns: None
    *
    */
    GeocoderSupport.showReverseGCLocation = function(e){
             //OGIS.msgAlert('','function showReverseGCLocation');
             BizMap.resetLocInfoPanel();
             var lonlat = map.getLonLatFromViewPortPx(e.xy);
        	 var theX = Math.round(lonlat.lon);
        	 var theY = Math.round(lonlat.lat);
        	 map.events.unregister("click", map, GeocoderSupport.showReverseGCLocation);
        	 document.images['gc_on_off'].src = '/oit/gis/OIT_BusinessMap/images/geocode_off1.gif';
        	 Ext.getCmp('find-a-location-panel').focus();
        	 var rvGCUrl = "ReverseGeocodeAddress.jsp?gcX=" + theX + "&gcY=" + theY + "&projId=102711";

             //Making an ajax call to ReverseGeocodeAddress.jsp
        	 OpenLayers.Request.GET({
        	        url:rvGCUrl,
        	        success:function(response){
                        GeocoderSupport.processRVGCResponse(response.responseText,theX,theY);
                    },
                    failure:function(){
                        OGIS.msgAlert('','Unable to process the Request.\nEither your browser does not support AJAX\n Or internal error!');
                        return false;
                    }
        	 });
			//does hmfa query
			//console.warn(mouseXY);
//			var xml = OGIS.makeGMLgeometry({conversionType: "PointToBBOX", geom: lonlat, pointBuffer: 1});
			//console.warn(xml);
//			OGIS.makePostFilter("Intersect", {geoXML: xml});
    }

    /**
    * Function: processRVGCResponse
    * Called from  showReverseGCLocation function, processes the results obtained
    * from ReverseGeocodeAddress.jsp and displays the result in the DashBoard.
    * Calls zoomToPoint to locate the reverse geocoded point on the map.
    *
    * Parameters: the Response from ReverseGeocodeAddress.jsp, and the x,y coordinates from  showReverseGCLocation.
    *
    * Returns: None
    *
    */
    GeocoderSupport.processRVGCResponse = function(theResponse,theX,theY){
                   var theAddress = theResponse;
                   var theDashBoardContent = '<table cellspacing="0" cellpadding="0" width="90%" id="topTable" class="OGIS_GC_Results_Table"><tr><td class="OGIS_GC_Header">Results:</td></tr>';
                   theDashBoardContent += "<tr class='OGIS_GC_Rec1 OGIS_GC_RecLast'><td>" + theAddress + "</td></tr></table>";
                   document.getElementById('DashBoard').innerHTML = theDashBoardContent;
                   BizMap.activateResultsTab();
                   if (myGC == null){
        	          myGC = new OGIS.Geocoder();
        	          myGC.map = map;
        	          var size = new OpenLayers.Size(21,25);
		              var offset = new OpenLayers.Pixel(-10.5, -25);
		              var icon = new OpenLayers.Icon(OpenLayers.ImgPath + '/marker.png',size,offset);
		              icon.bkg = {};
                      icon.bkg.url = OpenLayers.ImgPath + '/marker-shadow.png';
                      icon.bkg.offset = new OpenLayers.Pixel(4, -size.h);
        	          myGC.icon = icon;
        	          myGC.zoomLevel = 11;
        	          myGC.afterZoomToPoint = BizMap.loadLocationInfo;
        	       }
                   myGC.zoomToPoint(theX,theY,theAddress);
    }

