this.generateParcelDetailTab = function(html_content, selected) {
  var RealFields, AliasFields, ParcelFieldName;

  if (selected.geometry.type == "point") {
    RealFields = ParcelPointFields;
    AliasFields = ParcelPointAlias;
    ParcelFieldName = ParcelPointFieldName;
  } else {
    RealFields = ParcelPolyFields;
    AliasFields = ParcelPolyAlias;
    ParcelFieldName = ParcelPolyFieldName;
  }
  
 
  dojo.xhrGet( {
    // The following URL must match that used to test the server.
    url: "parcel_detail.php?pin=" + selected.attributes[ParcelFieldName] + "&selectedcount=" + _graphicsFeatures.length, 
    handleAs: "text",

    timeout: 10000, // Time in milliseconds

    // The LOAD function will be called on a successful response.
    load: function(response, ioArgs) {
      //Vanguard Code:
      if (typeof(VanguardURL) !== 'undefined') {   
      if (typeof(VanguardField) == 'undefined') VanguardField = ParcelFieldName;
        response += "<p id=\"vanguardButton\"><button dojoType=\"dijit.form.Button\" onClick=\"window.open('" + VanguardURL + selected.attributes[VanguardField] + "').focus();\"><img src=\"" + baseURL + "images/button_vanguard.png\" border=\"0\"></button></p>";
      }

      //Governmax Code:
      if (typeof(GovernmaxURL) !== 'undefined') {   
      if (typeof(GovernmaxField) == 'undefined') GovernmaxField = ParcelFieldName;  
        response += "<p id=\"governmaxButton\"><button dojoType=\"dijit.form.Button\" onClick=\"window.open('" + GovernmaxURL + selected.attributes[GovernmaxField] + "').focus();\"><img src=\"" + baseURL + "images/button_governmax.png\" border=\"0\"></button></p>";
      }
      
      updateResultsTab("Results", html_content + response);      
      return response;
    },

    // The ERROR function will be called in an error case.
    error: function(response, ioArgs) {
      //console.error("HTTP status code: ", ioArgs.xhr.status);
      updateResultsTab("Results", html_content + "There was an error in the search parameters");
      return response;
    }
  });
};


this.executeOwnerSearch = function() {
  if (dojo.byId("txtOwnerName").value != "") {

    updateResultsTab("Results", "<img src='" + baseURL + "images/loader.gif' style=\"float: left;\"/><p class=\"aligntext\">Searching for Owner matching <b>" + dojo.byId("txtOwnerName").value + "</b>...</p>");
    
    dojo.xhrPost( { // ?
      // The following URL must match that used to test the server.
      url: "jsonGetByOwner.php", 
      handleAs: "json",
      content: { owner : dojo.byId("txtOwnerName").value },

      timeout: 10000, // Time in milliseconds

      // The LOAD function will be called on a successful response.
      load: function(response) {
        if (response.length == 0) {
          updateResultsTab("Results", "<img src='" + baseURL + "images/information.png' style=\"float: left;\"/><p class=\"aligntext\">No matching owners found.</p>");        
        } else {
          //build query filter for Address
          processQuery("IN ('" + response.join('\',\'') + "')", null, null, 0, showResults);
        }
        return response;
      },

      // The ERROR function will be called in an error case.
      error: function(response, ioArgs) {
        //console.error("HTTP status code: ", ioArgs.xhr.status);
        updateResultsTab("Results", "<img src='" + baseURL + "images/warning.png' style=\"float: left;\"/><p class=\"aligntext\">An error occured matching owner.</p>");        
        return response;
      }
    });
  }
  
  return false;
};


this.executeAddressSearch = function() {
  if (dojo.byId("txtAddress").value != "") {

    updateResultsTab("Results", "<img src='" + baseURL + "images/loader.gif' style=\"float: left;\"/><p class=\"aligntext\">Searching for Address <b>" + dojo.byId("txtAddress").value + "</b>...</p>");
    
    dojo.xhrPost( { // ?
      // The following URL must match that used to test the server.
      url: "jsonGetByAddress.php", 
      handleAs: "json",
      content: { address : dojo.byId("txtAddress").value, city : dojo.byId("cboCity").value },

      timeout: 10000, // Time in milliseconds

      // The LOAD function will be called on a successful response.
      load: function(response) {
        if (response.length == 0) {
          updateResultsTab("Results", "<img src='" + baseURL + "images/information.png' style=\"float: left;\"/><p class=\"aligntext\">No matching addresses found.</p>");        
        } else {
          //build query filter for Address          
          processQuery("IN ('" + response.join('\',\'') + "')", null, null, 0, showResults);
        }
        return response;
      },

      // The ERROR function will be called in an error case.
      error: function(response, ioArgs) {
        //console.error("HTTP status code: ", ioArgs.xhr.status);
        updateResultsTab("Results", "<img src='" + baseURL + "images/warning.png' style=\"float: left;\"/><p class=\"aligntext\">An error occured matching address.</p>");   
        return response;
      }
    });    
    
  }
  
  return false;
};


this.executeSubdivisionSearch = function() {
  if (dojo.byId("txtSubdivisionName").value != "") {

    updateResultsTab("Results", "<img src='" + baseURL + "images/loader.gif' style=\"float: left;\"/><p class=\"aligntext\">Searching for Subdivision <b>" + dojo.byId("txtSubdivisionName").value + "</b>...</p>");
    
    var queryParams = new esri.tasks.Query();
    queryParams.returnGeometry = true;
    queryParams.outFields = ["*"];
    queryParams.where = "Sub_Name LIKE '%" + dojo.byId("txtSubdivisionName").value + "%'";

    var initqueryTask = new esri.tasks.QueryTask(MapServiceURL + "/" + getLayerIDFromName("Subdivision Boundary"));  
    dojo.connect(initqueryTask, "onComplete", function(featureSet) {
      showResults(featureSet);
    });
    dojo.connect(initqueryTask, "onError", function(error) {
      showResults(new esri.tasks.FeatureSet());
    });

    initqueryTask.execute(queryParams);  
    
  }
};



this.clearForm = function(){
  dojo.byId("txtPIN").value = "";
  dojo.byId("txtOwnerName").value = "";
  dojo.byId("txtAddress").value = "";
  dojo.byId("txtSubdivisionName").value = "";
};