﻿arcgisLogisControl = null;

ESRI.ADF.UI.LogisControl = function(element) {
  ESRI.ADF.UI.LogisControl.initializeBase(this);

  this._icon = null;
  this._waitIcon = null;
  this._contentPanelId = null;
  this._hasDetails = false;
  this._currentName = null;
  this._currentGroup = null;
  this._currentFilter = null;
  this._progressContent = "";
  this._SelectGFID = null;
  arcgisLogisControl = this;
  
   //BEGIN  ----------------------

  // Override Graphics:Canvas code that creates spikes that run across screen
  
  ESRI.ADF.Graphics.__Canvas.prototype._createPntArray = 
    function(geom,transformFunc,symbol){
      var tol = 0; //Pixel tolerance for generalization
      if (ESRI.ADF.Geometries.Polygon.isInstanceOfType(geom)) {
        var parray = [];
        var length = geom.getRingCount();
        for (var j=0; j<length; j++) {
          var ring = geom.getRing(j);
          var pntCount = ring.get_count();   
          for (var idx=0; idx<pntCount; idx++) {
            var obj = transformFunc(ring.get(idx));
            if (parray.length<2 || 
                Math.abs(parray[parray.length-2] - obj.offsetX) > tol ||
                Math.abs(parray[parray.length-1] - obj.offsetY) > tol || 
                idx===pntCount-1) { //simple generalize
              Array.add(parray, obj.offsetX);
              Array.add(parray, obj.offsetY);
            }
          }
          if(j<length-1) {
           Array.add(parray,null);
          }
        }
        return parray;
      } else if(ESRI.ADF.Geometries.Polyline.isInstanceOfType(geom)) {        
        var larray = [];
        var pathCount = geom.getPathCount();
        for(var k=0; k<pathCount; k++) {
          var path = geom.getPath(k);
          var pCount = path.get_count();   
          for(var l=0; l<pCount; l++) {
            var lobj = transformFunc(path.get(l));
            if(larray.length<2 || 
               Math.abs(larray[larray.length-2]-lobj.offsetX)>tol ||
               Math.abs(larray[larray.length-1]-lobj.offsetY)>tol || 
               l===pCount-1) { //simple generalize
              Array.add(larray, lobj.offsetX);
              Array.add(larray, lobj.offsetY);
            }
          }
          if (k<pathCount-1) {
            Array.add(larray,null); 
          }
        }
        return larray;
      } 
      else if(ESRI.ADF.Geometries.Point.isInstanceOfType(geom)) {       
        var pobj = transformFunc(geom);     
        return [pobj.offsetX, pobj.offsetY];
      }
      else if(ESRI.ADF.Geometries.Oval.isInstanceOfType(geom)) {
        var center = transformFunc(geom.get_center());
        var size = transformFunc(new ESRI.ADF.Geometries.Point(geom.get_center().get_x()+geom.get_width()*0.5,geom.get_center().get_y()-geom.get_height()*0.5));
        return [center.offsetX,center.offsetY,Math.abs(size.offsetX-center.offsetX),Math.abs(size.offsetY-center.offsetY)];
      }
      else if(ESRI.ADF.Geometries.Envelope.isInstanceOfType(geom)) {
        var ll = transformFunc(new ESRI.ADF.Geometries.Point(geom.get_xmin(),geom.get_ymin()));
        var ur = transformFunc(new ESRI.ADF.Geometries.Point(geom.get_xmax(),geom.get_ymax()));
        return [ll.offsetX,ll.offsetY,ur.offsetX,ur.offsetY];
      }
      else if(ESRI.ADF.Geometries.GeometryCollection.isInstanceOfType(geom)) {
        Error.argumentType(Object.getTypeName(geom) + ' not yet supported');
      }
      else { throw Error.argumentType('geom', Object.getType(geom), ESRI.ADF.Geometries.Geometry); }
    };
     
    //END ---------------------
    
  
  };

  ESRI.ADF.UI.LogisControl.prototype = {

      // call to this is written server-side in pre_render
      sendRequest: function(mode, argument1, argument2, argument3) {
          arcgisLogisControl = this;

          //Mode is tab mode 1,2,or 3
          //arg1 is always group or search categorie like Parks
          //arg2 is the location for which to return details for tab three
          //arg3 is 
          //arg4 (NOT ADDED) is current map extent  //this._map.getGeometry(ESRI.ADF.Graphics.ShapeType.Envelope, this._dragBox, null, 'black', 'gray', 'pointer', false);
          //map = arcgisWebApp.map;

          if (map != null) {
              var Extent = map._extent._xmin + " ," + map._extent._ymin + " ," + map._extent._xmax + " ," + map._extent._ymax;
          } else {
              var Extent = ""
          }
          //var argument = "mode=" + mode + "&arg1=" + argument1 + "&arg2=" + argument2 + "&arg3=" + argument3; 
          //this.doCallback(argument,this);

          if (mode == "tab2") {
              var pnl = $get('Logis_Panel2_Body');
              var html = "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\"><tr><td style=\"font-family: Verdana; font-size: 12px; font-weight: bold; color: #336699;\">Querying Items for " + argument1 + " ...</td></tr></table>"
              pnl.innerHTML = html;
          }
          if (mode == "tab3") {
              var pnl = $get('Logis_Panel3_Body');
              var html = "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\"><tr><td style=\"font-family: Verdana; font-size: 12px; font-weight: bold; color: #336699;\">Querying Details for " + argument2 + " ...</td></tr></table>"
              pnl.innerHTML = html;
          }
          var webMethod = 'GetFeatureInfo';
          var webServicePath = 'LOGISService.asmx';
          this.progress(true, "Calling Back");
          Sys.Net.WebServiceProxy.invoke(webServicePath, webMethod, true, { "mode": mode, "Category": argument1, "PlaceName": argument2, "FilterBy": argument3, "Extent": Extent }, OnSucceeded, OnFailed, mode);
          this.progress(true, "Calling Back Done");
          //    

      },



      // this gets invoked when server-side callback is returned in getcallbackresults
      processCallbackResult: function(action, params) {
          if (this.waitIcon) {
              map.removeGraphic(this.waitIcon);
          }


          // The action indicates what type of responce is being returned from the 
          // server.  Either a table as html or an array of objects.
          if (action == "tab1") {
              // server sends back table
              theDiv = $get(this._contentPanelId);
              if (theDiv) {
                  //KAA theDiv.innerHTML = "<B>" + action + "</B><HR>" + params[0];
                  theDiv.innerHTML = "<B>" + action + "</B>" + params[0];
              }

          } else if (action == 'tab2') {
              //Server sent back a list of places as an array 
              this.addGraphicFeatureGroupNew(params[0], params[1]);

          } else if (action == 'tab3') {
              //Server sent back a table for Tab3
              // server sends back table
              theDiv = $get('Logis_Panel3_Body');
              if (theDiv) {
                  //KAA theDiv.innerHTML = "<HR>" + params[0];
                  theDiv.innerHTML = params[0];
              }

          } else if (action == 'error') {
              alert("Error: " + params[0]);
              Sys.Debug.trace('Error: ' + params[0]);
          }
      },

      processCallbackResultFromService: function(params, action) {
          // this.progress(true, "Processing CallBack");
          if (this.waitIcon) {
              map.removeGraphic(this.waitIcon);
          }


          // The action indicates what type of responce is being returned from the 
          // server.  Either a table as html or an array of objects.
          if (action == "tab1") {
              // server sends back table
              theDiv = $get(this._contentPanelId);
              if (theDiv) {
                  theDiv.innerHTML = "<B>" + action + "</B>" + params[0];
                  //KAA theDiv.innerHTML = "<B>" + action + "</B><HR>" + params[0];
              }

          } else if (action == 'tab2') {
              //Server sent back a list of places as an array

              this.addGraphicFeatureGroupNew(params[0], params[1], params[2]);

          } else if (action == 'tab3') {
              //Server sent back a table for Tab3
              // server sends back table
              // this.progress(true, "Updating details.");
              theDiv = $get('Logis_Panel3_Body');
              if (theDiv) {
                  var strhtml = params[0];
                  //KAA var strhtml = "<HR>" + params[0];
                  //KAA strhtml = strhtml.stripHex(true);
                  theDiv.innerHTML = strhtml;
                  ////                  this.addForButton(this._currentName)
              }
              if (params[1]) {
                  if (params[1].length > 0) {
                      this.addAssociatedGraphicFeatureGroup(params[1], '');
                  }
              }
              //      setTimeout("arcgisLogisControl.progress(true, 'Updating details..')",750);
              //      setTimeout("arcgisLogisControl.progress(true, 'Updating details.....')",1550);
              //      setTimeout("arcgisLogisControl.progress(false, '')",2000);

          } else if (action == 'error') {
              alert("Error: " + params[0]);
              Sys.Debug.trace('Error: ' + params[0]);
              //this.progress(false, "");
          }
      },

      //ShowRowData returns the list of all locations in the current group/category as an array and 
      //process callbackresult creates maptips and the list of parks on Tab2
      showRowData: function(theCell) {
          var cellval = theCell.firstChild.nodeValue;
          this.set_currentGroup(cellval)
          this.set_currentFilter()
          LogisSend('tab2', cellval, '', 'None'); //show matches by extent/
      },

      //filterRowData returns the list of all locations in group/category that have a particular ammenity (filterVal)
      //called from dropdown on change
      filterRowData: function(filterVal) {
          this.set_currentFilter(filterVal)
          LogisSend('tab2', '', '', filterVal); //show matches by extent/
      },

      ////////      addForButton: function(currentName) {
      ////////          var mytable = document.getElementById("topTab2");
      ////////          var cell = mytable.rows[1].cells[1]; //insert new cell to end of 2nd row
      ////////          //cell.innerhtml = "<a href='#' onclick='javascript:GGTabs.expandit(2);',this);'>To Details</a><img src='images/smforarrow.png' />";
      ////////          cell.innerhtml = 'Back to Park Details';
      ////////      },


      //===========================================================================
      //======== Handles Point Line or Polygon  ===================================
      //===========================================================================

      addGraphicFeatureGroupNew: function(arrFeatures, arrAmen, groupInfo) {
          this.progress(true, "Creating graphics");
          // determine geometry type, create symbols
          if (arrFeatures == null) {
              return;
          }
          if (arrFeatures.length == 0) {
              return;
          }


          var uPtId = this.get_uniqueID() + '_PtGFG';
          var uLnId = this.get_uniqueID() + '_LnGFG';
          var uPlId = this.get_uniqueID() + '_PlGFG';

          var testPTGfg = $find(uPtId);
          if (testPTGfg) {
              this.get_map().removeGraphic(testPTGfg);
              testPTGfg.dispose();
          }

          var testLnGfg = $find(uLnId);
          if (testLnGfg) {
              this.get_map().removeGraphic(testLnGfg);
              testLnGfg.dispose();
          }

          var testPlGfg = $find(uPlId);
          if (testPlGfg) {
              this.get_map().removeGraphic(testPlGfg);
              testPlGfg.dispose();
          }

          //===========================================================================
          //======== Test for Associated Features and dispose   =======================
          //===========================================================================
          var uAssPtId = this.get_uniqueID() + '_PtAssGFG';
          var uAssLnId = this.get_uniqueID() + '_LnAssGFG';
          var uAssPlId = this.get_uniqueID() + '_PlAssGFG';

          var testAssPTGfg = $find(uPtId);
          if (testAssPTGfg) {
              this.get_map().removeGraphic(testAssPTGfg);
              testAssPTGfg.dispose();
          }

          var testAssLnGfg = $find(uLnId);
          if (testAssLnGfg) {
              this.get_map().removeGraphic(testAssLnGfg);
              testAssLnGfg.dispose();
          }

          var testAssPlGfg = $find(uPlId);
          if (testAssPlGfg) {
              this.get_map().removeGraphic(testAssPlGfg);
              testAssPlGfg.dispose();
          }
          //===========================================================================   
          //=========================================================================== 

          //Same Maptip for all feature types
          var newMapTips = new ESRI.ADF.UI.MapTips();
          newMapTips.set_hoverTemplate('<table bgcolor="" border="0" cellpadding="2" cellspacing="1">' +
                              '<tr><td>Place: </td><th>{@Id}</th></tr><tr><td></td><td><a style="font-size: 80%;" href"#">click to expand...</a></td></tr></table>');
          newMapTips.set_contentTemplate('<table bgcolor="white" border="0" cellpadding="2" cellspacing="2">' +
          //                                '<tr><td colspan="2">' + 'geomType' + '</td></tr>' +
                                '<tr><td>Place Name:</td><td><b>{@Id}</b></td></tr>' +
                                '<tr><td></td><td><b>{@Addr}</b></td></tr>' +
                                '<tr><td colspan="2"><a href="javascript: showlocationdetails(' + "'" + '{@Id}' + "'" +
                                '); javascript: GGTabs.expandit(2);' +
                                'javascript:arcgisLogisControl.addSelectedGF(' + "'" + '{@GFId}' + "'" + ');' +
                                '">Show Details</a></td></tr>' +
                                '<tr><td colspan="2"><a href="javascript: arcgisLogisControl.doZoom(' + "'" + '{@XMIN}' + "', '" + '{@YMIN}' + "', '" + '{@XMAX}' + "', '" + '{@YMAX}' + "'" +
                                '); ">Zoom To This Place</a></td></tr>' +
                                '</table>');
          newMapTips.set_animate(false); // don't flicker in and out

          // create appropriate symbol/highlightsymbol
          var lnSymbol;
          var polySymbol;
          var ptHighSymbol;
          var lnHighSymbol;
          var polyHighSymbol;

          //if (geomType == "POINT") {
          ////// not currently implementing different symbols 1,2,3...
          //////symbol = new ESRI.ADF.Graphics.MarkerSymbol("images/0Item.png", 0, 16);
          ptHighSymbol = new ESRI.ADF.Graphics.MarkerSymbol("images/0ItemSelected.png", 0, 16);
          //} else if (geomType == "LINESTRING") {
          lnSymbol = new ESRI.ADF.Graphics.LineSymbol("#FF0000", 2);
          lnHighSymbol = new ESRI.ADF.Graphics.LineSymbol("#00FFFF", 3);
          //} else if (geomType == "POLYGON") {
          polySymbol = new ESRI.ADF.Graphics.FillSymbol(null, "#FF0000", 2);
          polyHighSymbol = new ESRI.ADF.Graphics.FillSymbol("white", "#00FFFF", 3);
          polyHighSymbol.set_opacity(0.5);
          // } else {
          //   return;
          // }

          ////////////////////////////////////////////////////////////////
          ////////////////////////////////////////////////////////////////
          ////////////////////////////////////////////////////////////////
          var newGF;
          var geom;
          var geomEnv;
          var geomType;

          for (idx in arrFeatures) {

              //GET THE GEOMETRY TYPE OF THE ITEM
              geomType = arrFeatures[idx].gT;
              if (geomType.indexOf("MULTI") > -1) {
                  geomType = geomType.substring(5);
              }

              if (geomType == "POINT") {
                  //IF THERE ISN'T A LINE FEATURE GROUP CREATE ONE ELSE ADD TO IT
                  if (newPtGFG == null) {
                      var newPtGFG = $create(ESRI.ADF.Graphics.GraphicFeatureGroup,
                                          { "id": uPtId,
                                              "highlightSymbol": ptHighSymbol,
                                              "mapTips": newMapTips
                                          });
                  } //end if (newPtGFG == NULL)

                  var png = "images/" + idx + "Item.png"
                  geom = this._getGeomFromString(geomType, arrFeatures[idx].gC);

                  newGf = $create(ESRI.ADF.Graphics.GraphicFeature,
                              { "id": idx + "_GF",
                                  "geometry": geom,
                                  "symbol": new ESRI.ADF.Graphics.MarkerSymbol(png, 8, 8),
                                  "attributes": { 'Id': arrFeatures[idx].gI,
                                      'GFId': idx,
                                      'Addr': arrFeatures[idx].gA,
                                      'XMIN': geom.coordinates[0] - 200,
                                      'YMIN': geom.coordinates[1] - 200,
                                      'XMAX': geom.coordinates[0] + 200,
                                      'YMAX': geom.coordinates[1] + 200
                                  }
                              });
                  newPtGFG.add(newGf);
                  window.status = "Create CF " + i;



              } else if (geomType == "LINESTRING") {
                  //IF THERE ISN'T A LINE FEATURE GROUP CREATE ONE ELSE ADD TO IT
                  if (newLnGFG == null) {
                      var newLnGFG = $create(ESRI.ADF.Graphics.GraphicFeatureGroup,
                                          { "id": uLnId,
                                              "symbol": lnSymbol,
                                              "highlightSymbol": lnHighSymbol,
                                              "mapTips": newMapTips
                                          });
                  } //end if (newLNGFG == NULL)

                  geom = this._getGeomFromString(geomType, arrFeatures[idx].gC);
                  geomEnv = geom.getEnvelope()

                  newGf = $create(ESRI.ADF.Graphics.GraphicFeature,
                              { "id": idx + "_GF",
                                  "geometry": geom,
                                  "attributes": { 'Id': arrFeatures[idx].gI,
                                      'GFId': idx,
                                      'Addr': arrFeatures[idx].gA,
                                      'XMIN': geomEnv.get_xmin(),
                                      'YMIN': geomEnv.get_ymin(),
                                      'XMAX': geomEnv.get_xmax(),
                                      'YMAX': geomEnv.get_ymax()
                                  }
                              });


                  newLnGFG.add(newGf);



              } else if (geomType == "POLYGON") {

                  //IF THERE ISN'T A LINE FEATURE GROUP CREATE ONE ELSE ADD TO IT
                  if (newPlGFG == null) {
                      var newPlGFG = $create(ESRI.ADF.Graphics.GraphicFeatureGroup,
                                          { "id": uPlId,
                                              "symbol": polySymbol,
                                              "highlightSymbol": polyHighSymbol,
                                              "mapTips": newMapTips
                                          });

                  } //end if (newLNGFG == NULL)

                  geom = this._getGeomFromString(geomType, arrFeatures[idx].gC);
                  geomEnv = geom.getEnvelope()

                  newGf = $create(ESRI.ADF.Graphics.GraphicFeature,
                              { "id": idx + "_GF",
                                  "geometry": geom,
                                  "attributes": { 'Id': arrFeatures[idx].gI,
                                      'GFId': idx,
                                      'Addr': arrFeatures[idx].gA,
                                      'XMIN': geomEnv.get_xmin(),
                                      'YMIN': geomEnv.get_ymin(),
                                      'XMAX': geomEnv.get_xmax(),
                                      'YMAX': geomEnv.get_ymax()
                                  }
                              });


                  newPlGFG.add(newGf);


              } //end if (geomType == )

          } // end for   


          ///POLYGONS ARE DRAWN FIRST SO THEY WILL BE UNDER POINTS AND LINES 
          ///THIS WAY MAPTIPS WILL WORK FOR LINES THAT ARE ONTOP OF POLYGONS
          if (typeof (newPlGFG) == "undefined") {
          } else {
              this.get_map().addGraphic(newPlGFG);
          }
          if (typeof (newLnGFG) == "undefined") {
          } else {
              this.get_map().addGraphic(newLnGFG);
          }
          if (typeof (newPtGFG) == "undefined") {
          } else {
              this.get_map().addGraphic(newPtGFG);
          }

          this.updateTipsPanelNew(arrFeatures, arrAmen, groupInfo);


      },

      addAssociatedGraphicFeatureGroup: function(arrFeatures) {

          // determine geometry type, create symbols
          if (arrFeatures == null) {
              return;
          }
          if (arrFeatures.length == 0) {
              return;
          }


          var uPtId = this.get_uniqueID() + '_PtAssGFG';
          var uLnId = this.get_uniqueID() + '_LnAssGFG';
          var uPlId = this.get_uniqueID() + '_PlAssGFG';

          var testPTGfg = $find(uPtId);
          if (testPTGfg) {
              this.get_map().removeGraphic(testPTGfg);
              testPTGfg.dispose();
          }

          var testLnGfg = $find(uLnId);
          if (testLnGfg) {
              this.get_map().removeGraphic(testLnGfg);
              testLnGfg.dispose();
          }

          var testPlGfg = $find(uPlId);
          if (testPlGfg) {
              this.get_map().removeGraphic(testPlGfg);
              testPlGfg.dispose();
          }

          //Same Maptip for all feature types
          var newMapTips = new ESRI.ADF.UI.MapTips();
          newMapTips.set_hoverTemplate('<table bgcolor="" border="0" cellpadding="2" cellspacing="2">' +
                              '<tr><td>Place: </td><th>{@Id}</th></tr></table>');
          newMapTips.set_contentTemplate('<table bgcolor="white" border="0" cellpadding="2" cellspacing="2">' +
          //                                '<tr><td colspan="2">' + 'geomType' + '</td></tr>' +
                                '<tr><td>Place Name:</td><td><b>{@Id}</b></td></tr>' +
                                '<tr><td></td><td><b>{@Addr}</b></td></tr>' +
                                '<tr><td colspan="2"><a href="javascript: showlocationdetails(' + "'" + '{@Id}' + "'" +
                                '); javascript: GGTabs.expandit(2);' +
                                'javascript:arcgisLogisControl.addSelectedGF(' + "'" + '{@GFId}' + "'" + ');' +
                                '">Show Details</a></td></tr>' +
                                '<tr><td colspan="2"><a href="javascript: arcgisLogisControl.doZoom(' + "'" + '{@XMIN}' + "', '" + '{@YMIN}' + "', '" + '{@XMAX}' + "', '" + '{@YMAX}' + "'" +
                                '); ">Zoom To This Place</a></td></tr>' +
                                '</table>');
          newMapTips.set_animate(false); // don't flicker in and out

          // create appropriate symbol/highlightsymbol
          var lnSymbol;
          var polySymbol;
          var ptHighSymbol;
          var lnHighSymbol;
          var polyHighSymbol;

          //if (geomType == "POINT") {
          ////// not currently implementing different symbols 1,2,3...
          //////symbol = new ESRI.ADF.Graphics.MarkerSymbol("images/0Item.png", 0, 16);
          ptHighSymbol = new ESRI.ADF.Graphics.MarkerSymbol("images/0ItemSelected.png", 0, 16);
          //} else if (geomType == "LINESTRING") {
          lnSymbol = new ESRI.ADF.Graphics.LineSymbol("#9933ff", 2);
          lnHighSymbol = new ESRI.ADF.Graphics.LineSymbol("#99FF33", 3);
          //} else if (geomType == "POLYGON") {
          polySymbol = new ESRI.ADF.Graphics.FillSymbol(null, "#9933ff", 2);
          polyHighSymbol = new ESRI.ADF.Graphics.FillSymbol("white", "#99FF33", 3);
          polyHighSymbol.set_opacity(0.5);
          // } else {
          //   return;
          // }

          ////////////////////////////////////////////////////////////////
          ////////////////////////////////////////////////////////////////
          ////////////////////////////////////////////////////////////////
          var newGF;
          var geom;
          var geomEnv;
          var geomType;

          for (idx in arrFeatures) {

              //GET THE GEOMETRY TYPE OF THE ITEM
              geomType = arrFeatures[idx].gT;
              if (geomType.indexOf("MULTI") > -1) {
                  geomType = geomType.substring(5);
              }

              if (geomType == "POINT") {
                  //IF THERE ISN'T A LINE FEATURE GROUP CREATE ONE ELSE ADD TO IT
                  if (newPtGFG == null) {
                      var newPtGFG = $create(ESRI.ADF.Graphics.GraphicFeatureGroup,
                                          { "id": uPtId,
                                              "highlightSymbol": ptHighSymbol,
                                              "mapTips": newMapTips
                                          });
                  } //end if (newPtGFG == NULL)

                  var png = "images/" + idx + "Item.png"
                  geom = this._getGeomFromString(geomType, arrFeatures[idx].gC);

                  newGf = $create(ESRI.ADF.Graphics.GraphicFeature,
                              { "id": idx + "_AssGF",
                                  "geometry": geom,
                                  "symbol": new ESRI.ADF.Graphics.MarkerSymbol(png, 8, 8),
                                  "attributes": { 'Id': arrFeatures[idx].gI,
                                      'GFId': idx,
                                      'Addr': arrFeatures[idx].gA,
                                      'XMIN': geom.coordinates[0] - 200,
                                      'YMIN': geom.coordinates[1] - 200,
                                      'XMAX': geom.coordinates[0] + 200,
                                      'YMAX': geom.coordinates[1] + 200
                                  }
                              });
                  newPtGFG.add(newGf);
                  window.status = "Create CF " + i;



              } else if (geomType == "LINESTRING") {
                  //IF THERE ISN'T A LINE FEATURE GROUP CREATE ONE ELSE ADD TO IT
                  if (newLnGFG == null) {
                      var newLnGFG = $create(ESRI.ADF.Graphics.GraphicFeatureGroup,
                                          { "id": uLnId,
                                              "symbol": lnSymbol,
                                              "highlightSymbol": lnHighSymbol,
                                              "mapTips": newMapTips
                                          });
                  } //end if (newLNGFG == NULL)

                  geom = this._getGeomFromString(geomType, arrFeatures[idx].gC);
                  geomEnv = geom.getEnvelope()

                  newGf = $create(ESRI.ADF.Graphics.GraphicFeature,
                              { "id": idx + "_AssGF",
                                  "geometry": geom,
                                  "attributes": { 'Id': arrFeatures[idx].gI,
                                      'GFId': idx,
                                      'Addr': arrFeatures[idx].gA,
                                      'XMIN': geomEnv.get_xmin(),
                                      'YMIN': geomEnv.get_ymin(),
                                      'XMAX': geomEnv.get_xmax(),
                                      'YMAX': geomEnv.get_ymax()
                                  }
                              });


                  newLnGFG.add(newGf);



              } else if (geomType == "POLYGON") {

                  //IF THERE ISN'T A LINE FEATURE GROUP CREATE ONE ELSE ADD TO IT
                  if (newPlGFG == null) {
                      var newPlGFG = $create(ESRI.ADF.Graphics.GraphicFeatureGroup,
                                          { "id": uPlId,
                                              "symbol": polySymbol,
                                              "highlightSymbol": polyHighSymbol,
                                              "mapTips": newMapTips
                                          });

                  } //end if (newLNGFG == NULL)

                  geom = this._getGeomFromString(geomType, arrFeatures[idx].gC);
                  geomEnv = geom.getEnvelope()

                  newGf = $create(ESRI.ADF.Graphics.GraphicFeature,
                              { "id": idx + "_AssGF",
                                  "geometry": geom,
                                  "attributes": { 'Id': arrFeatures[idx].gI,
                                      'GFId': idx,
                                      'Addr': arrFeatures[idx].gA,
                                      'XMIN': geomEnv.get_xmin(),
                                      'YMIN': geomEnv.get_ymin(),
                                      'XMAX': geomEnv.get_xmax(),
                                      'YMAX': geomEnv.get_ymax()
                                  }
                              });


                  newPlGFG.add(newGf);


              } //end if (geomType == )

          } // end for   


          ///POLYGONS ARE DRAWN FIRST SO THEY WILL BE UNDER POINTS AND LINES 
          ///THIS WAY MAPTIPS WILL WORK FOR LINES THAT ARE ONTOP OF POLYGONS
          if (typeof (newPlGFG) == "undefined") {
          } else {
              this.get_map().addGraphic(newPlGFG);
          }
          if (typeof (newLnGFG) == "undefined") {
          } else {
              this.get_map().addGraphic(newLnGFG);
          }
          if (typeof (newPtGFG) == "undefined") {
          } else {
              this.get_map().addGraphic(newPtGFG);
          }

          //     this.updateTab3TipsPanelNew(arrFeatures, arrAmen);


      },
      _getGeomFromString: function(geomType, geomString) {
          // POINT LINESTRING POLYGON
          if (geomType == "POINT") {
              return this._pointFromString(geomString);
          } else if (geomType == "LINESTRING") {
              return this._lineFromString(geomString);
          } else if (geomType == "POLYGON") {
              return this._polyFromString(geomString);
          } else {
              return null;
          }
      },

      _pointFromString: function(geomString) {
          var geom;
          var xy;
          var coords = geomString.split(";");
          if (coords.length == 0) {
              return null;
          } else if (coords.length == 1) {
              xy = coords[0].split(",");
              geom = new ESRI.ADF.Geometries.Point(new Number(xy[0]), new Number(xy[1]));
              return geom;
          } else {
              geom = new ESRI.ADF.Geometries.GeometryCollection();
              // continue below and add points to geometrycollection
          }

          var pt;
          for (c in coords) {
              xy = coords[c].split(",");
              pt = new ESRI.ADF.Geometries.Point(new Number(xy[0]), new Number(xy[1]));
              geom.add(pt);
          }
          return geom;
      },

      _lineFromString: function(geomString) {
          var geom = new ESRI.ADF.Geometries.Polyline();
          var parts = geomString.split("|");
          var coords;
          var xy;
          var cc;
          for (p in parts) {
              cc = new ESRI.ADF.Geometries.CoordinateCollection();
              coords = parts[p].split(";");
              for (c in coords) {
                  xy = coords[c].split(",");
                  cc.add(new Array(new Number(xy[0]), new Number(xy[1])));
              }
              geom.addPath(cc);
          }
          return geom;
      },


      _polyFromString: function(geomString) {
          var geom = new ESRI.ADF.Geometries.Polygon();
          var parts = geomString.split("|");
          var coords;
          var xy;
          var cc;
          for (p in parts) {
              cc = new ESRI.ADF.Geometries.CoordinateCollection();
              coords = parts[p].split(";");
              for (c in coords) {
                  xy = coords[c].split(",");
                  cc.add(new Array(new Number(xy[0]), new Number(xy[1])));
              }
              geom.addRing(cc);
          }
          return geom;
      },




      //      removeGraphicFeatureGroup: function() {
      //          var uId = this.get_uniqueID() + '_GFG';

      //          var testGfg = $find(uId);
      //          if (testGfg) {
      //              this.get_map().removeGraphic(testGfg);
      //              testGfg.dispose();
      //          }
      //      },

      removeGraphicFeatureGroup: function() {
          var uPtId = this.get_uniqueID() + '_PtGFG';
          var uLnId = this.get_uniqueID() + '_LnGFG';
          var uPlId = this.get_uniqueID() + '_PlGFG';

          var testPTGfg = $find(uPtId);
          if (testPTGfg) {
              this.get_map().removeGraphic(testPTGfg);
              testPTGfg.dispose();
          }

          var testLnGfg = $find(uLnId);
          if (testLnGfg) {
              this.get_map().removeGraphic(testLnGfg);
              testLnGfg.dispose();
          }

          var testPlGfg = $find(uPlId);
          if (testPlGfg) {
              this.get_map().removeGraphic(testPlGfg);
              testPlGfg.dispose();
          }
      },

      //  updateTipsPanel : function (arrID) {
      updateTipsPanelNew: function(arrFeatures, arrAmen, groupinfo) {
          var pnl = $get('Logis_Panel2_Body');

          if (this._currentGroup) {
              var group = this._currentGroup;
          } else {
              var group = "";
          }
          if (this._currentFilter) {
              var filter = this._currentFilter;
          } else {
              var filter = 'Select' + group + 'Amenity';
          }
          //===========================================================================
          //=========================== Tab Content ===================================
          //===========================================================================


          if (pnl) {
              html = '';
              if (groupinfo != null) {
                  html += groupinfo
              }
              html += '<table width="100%"><th colspan="2" style="text-align: Left; color: white; font-weight: bold; font-size: 16px; background-color: #336699;">' + group + ' Features and Places</th>';
              html += '<tr><td align="center" style="background-color: #CCCCCC" ><a href="#" style="font-weight: lighter; font-size: 80%" onclick="javascript:arcgisLogisControl.doZoomAll()">Zoom to all ' + group + ' on map...</a></td><td></td></tr>'
              html += '<tr><td colspan="2" align="center"><table >'
              /////////////////////////////////AMENITIES FILTER COMTROL//////////////////////////////////////
              //Create amenity filter for groups that have amenities associated.
              if (arrAmen != null) {
                  if (arrAmen.length > 0) {

                      html += '<tr><td style="font-family: Verdana; font-size: 12px; font-weight: normal; color: black;">&nbsp;</td></tr><tr><td style="color: #336699; background-color: #99FF99; font-weight:normal; font-size: 12px">Filter ' + group + ' By Amenity &nbsp;</td></tr>' +
                       '<tr><td style="color: #808080; background-color: #99FF99"><input type="text" value="' + filter + '" id="amenFilterName"></input>' +
                       '<input type="button" hidefocus="1" value="&#9660;" ' +
                       'onclick="JavaScript:filterMenuActivate(' + "'" + 'amenFilterName' + "'" + ', ' + "'" +
                       'amenFilterNameDiv' + "'" + ', ' + "'" + 'amenFilterNameSelect' + "'" +
                       ')" /><div id="amenFilterNameDiv" style="position: absolute; display: none; top: 0px; ' +
                       'left: 0px; z-index: 100000" onmouseover="javascript:oOverMenu=' + "'" +
                       'amenFilterNameDiv' + "'" + ';" onmouseout="javascript:oOverMenu=false;">' +
                       '<select size="7" id="amenFilterNameSelect" style="width: 150; border-style: ' +
                       'none" onclick="JavaScript:textSet(' + "'" + 'amenFilterName' + "'" +
                       ',this.value);" onkeypress="JavaScript:comboKey(' + "'" + 'amenFilterName' + "'" + ', this);">';
                      html += '<option value="None">None</option>';

                      for (var j = 0; j < arrAmen.length; j++) {
                          html += '<option value="' + (arrAmen[j]) + '">' + (arrAmen[j]) + '</option>';
                      }

                      html += '</select></div></td></tr>';
                  }

              }



              if (group == "Property") {
                  html += '<tr><td>&nbsp;</td></tr><tr><td align="center" style="font-family: Verdana; font-size: 10px; font-weight: normal; color: red;" >' +
                    'Parcel data is only displayed for the first 100 parcels within your current map view.  As you move around the map you may want to update the list with parcels data for your current view.' +
                    '</td></tr>' +
                    '<tr><td align="center" style="font-weight: lighter; font-size: 80%" >' +
                    '<a id="UpdateList" href="#" onclick="javascript:LogisSend(' + "'" + 'tab2' + "', '" + 'Property' + "', '', '" + 'None' + "'" + ');">' +
                    'Update Property List...<a>' +
                    '</td></tr>';

              }

              html += '</table></td></tr><tr><td>';

              /////////////////////////////////LISTINGS CONTENT TABLE//////////////////////////////////////

              var doImage = false;
              if ((arrFeatures[0].gT == "POINT") || (arrFeatures[0].gT == "MULTIPOINT")) {
                  doImage = true;
              }

              for (idx in arrFeatures) {

                  if ((arrFeatures[idx].gT == "POINT") || (arrFeatures[idx].gT == "MULTIPOINT")) {
                      html += ' <table width="100%"><tr><td>&nbsp;</td></tr><tr><td rowspan="2"><img src="images/' + idx + 'Item.png" alt="Point" /></td>';
                  } else if ((arrFeatures[idx].gT == "LINESTRING") || (arrFeatures[idx].gT == "MULTILINESTRING")) {
                  html += ' <table width="100%"><tr><td>&nbsp;</td></tr><tr><td rowspan="2" alt="Line" width="25" class="listImageLine"><font size="+1" color="#336699">' + (parseInt(idx) + 1) + '</font></td>';
                  } else if ((arrFeatures[idx].gT == "POLYGON") || (arrFeatures[idx].gT == "MULTIPOLYGON")) {
                  html += ' <table width="100%"><tr><td>&nbsp;</td></tr><tr><td rowspan="2" alt="Line" width="25" class="listImagePoly"><font size="+1" color="#336699">' + (parseInt(idx) + 1) + '</font></td>';
                  } //end if


                  html += '<td><h4><a style="font-family: Verdana; font-size: 12px; font-weight: bold; color: #336699;" href="#" onclick="' +
                    //'javascript:showlocationdetails(' + '\'' + (arrFeatures[idx].gI) + '\',' + i + ',this); ' +
                     'javascript:showlocationdetails(' + '\'' + (arrFeatures[idx].gI) + '\',' + i + ',this,' + '\'' + (arrFeatures[idx].gS) + '\'' + '); ' +
                    'javascript:arcgisLogisControl.addSelectedGF(' + idx + ',this); ' +
                    'javascript: GGTabs.expandit(2)" onmouseover="setHighlight(' + idx + ',this);" ' +
                    'onmouseout="unsetHighlight(' + idx + ',this);">' + (arrFeatures[idx].gI) + '</a></h4></td>';
                  html += '</tr><tr><td style="font-family: Verdana; font-size: 12px; font-weight: normal; color: black;" colspan="2"><span><span id="" class="info">' + (arrFeatures[idx].gA) + '</span></span><span class="phone">  ' + (arrFeatures[idx].gIF) + '</span></td></tr><tr><td></td><td colspan="1" align="left"><ul class="listingsUl">'
                  html += '<li class="listingsLftLi">'
                  html += '<a onclick="' +
                    'javascript:arcgisLogisControl.doZoom2(' + idx + ');" href="#">Zoom to...</a></li>'
                  html += '<li class="listingsRtLi">'
                  html += '<a onclick="' +
                    'javascript:showlocationdetails(' + '\'' + (arrFeatures[idx].gI) + '\',' + i + ',this,'+ '\'' + (arrFeatures[idx].gS) + '\'' + '); ' +
                    'javascript:arcgisLogisControl.addSelectedGF(' + idx + ',this); ' +
                    'javascript: GGTabs.expandit(2)" href="#" name=""><span>Highlight and view details...</span> </a></li></ul></td></tr></table>';
              } //end for

              //  html += '<tr><th colspan="2"><input type="button" onclick="purgeGraphics()" value="Remove All"></th></tr>';
              html += '</td></tr></table><input type="button" onclick="purgeGraphics()" value="Clear Map">';

              /////////////////////////////////////////////////////////////////////////////////
              pnl.innerHTML = html;
          }
      },


      //  updateAssociatedTipsPanelNew : function (arrFeatures, arrAmen) {
      //     var pnl = $get('Logis_Panel2_Body'); 
      //    if (this._currentGroup) {
      //      var group = this._currentGroup;
      //    } else{
      //      var group = "";
      //    }
      //    if (this._currentFilter) {
      //      var filter = this._currentFilter;
      //    } else {
      //      var filter = 'Select' + group + 'Amentity';
      //    }

      //===========================================================================
      //=========================== Tab Content ===================================
      //===========================================================================

      ////    
      ////    if (pnl) {

      ////        html = '<table><th colspan="2" style="color: #808080; font-weight: bold; font-size: 110%">' + group + ' Features and Places</th>';            
      ////        html +='<tr><td align="center" style="background-color: #CCCCCC" ><a href="#" style="font-weight: lighter; font-size: 80%" onclick="javascript:arcgisLogisControl.doZoomAll()">Zoom to all on map...</a></td></tr>'
      ////        html +='<tr><td colspan="2" align="center"><table>'
      ////        /////////////////////////////////AMENITIES FILTER COMTROL//////////////////////////////////////
      ////        //Create amenity filter for groups that have amenities associated.      
      ////       
      ////         
      ////        if (group == "Property") {
      ////            html += '<tr><td align="center" style="font-weight: lighter; font-size: 80%" >' +
      ////                    'FYI…. Parcel data is only displayed for the first 100 parcels within your current map view.  As you move around the map you may want to update the list with parcels data for your current view.' +
      ////                    '</td></tr>'+
      ////                    '<tr><td align="center" style="font-weight: lighter; font-size: 80%" >'+
      ////                    '<a id="UpdateList" href="#" onclick="javascript:LogisSend(' + "'" + 'tab2' + "', '" + 'Property' + "', '', '" + 'None' + "'" + ');">' +                
      ////                    'Update list...<a>' +
      ////                    '</td></tr>';

      ////        }
      ////         
      ////         html += '</table></td></tr><tr><td>';
      ////         
      ////          /////////////////////////////////LISTINGS CONTENT TABLE//////////////////////////////////////
      ////       
      ////        var doImage = false;
      ////        if ( (arrFeatures[0].gT == "POINT") || (arrFeatures[0].gT == "MULTIPOINT") ) {
      ////        doImage = true;
      ////        }

      ////        for (idx in arrFeatures) {
      ////                
      ////            if ((arrFeatures[idx].gT == "POINT") || (arrFeatures[idx].gT == "MULTIPOINT")) {
      ////                html += ' <table><tr><td rowspan="2"><img src="images/' + idx + 'Item.png" alt="Point" /></td>'; 
      ////            } else if ((arrFeatures[idx].gT == "LINESTRING") || (arrFeatures[idx].gT == "MULTILINESTRING")) {               
      ////                html += ' <table><tr><td rowspan="2" alt="Line" width="25" class="listImageLine"><font size="+1" color="blue">'+ (parseInt(idx) + 1) + '</font></td>'; 
      ////            } else if ((arrFeatures[idx].gT == "POLYGON") || (arrFeatures[idx].gT == "MULTIPOLYGON")) {                
      ////                html += ' <table><tr><td rowspan="2" alt="Line" width="25" class="listImagePoly"><font size="+1" color="blue">'+ (parseInt(idx) + 1) + '</font></td>'; 
      ////            } //end if  

      ////            // oldhtml += '<td style=""><label onclick="arcgisLogisControl.doZoom(' + (arrX[i]) + ',' + (arrY[i]) + '); ' + 
      ////            html += '<td><h4><a href="#" onclick="' + 
      ////                    'javascript:showlocationdetails(' + '\'' + (arrFeatures[idx].gI) + '\',' + i + ',this); ' + 
      ////                    'javascript:arcgisLogisControl.addSelectedGF(' + idx + ',this); ' +               
      ////                    'javascript: GGTabs.expandit(2)" onmouseover="setHighlight(' + idx + ',this);" ' + 
      ////                    'onmouseout="unsetHighlight(' + idx + ',this);">' + (arrFeatures[idx].gI) + '</a></h4></td>';   
      ////            html += '</tr><tr><td colspan="2"><span><span id="" class="info">' + (arrFeatures[idx].gA) + '</span></span><span class="phone">(555) 555-5555</span></td></tr><tr><td></td><td colspan="1" align="left"><ul class="listingsUl">'
      ////            html += '<li class="listingsLftLi">'
      ////            html += '<a onclick="' + 
      ////                    'javascript:arcgisLogisControl.doZoom2(' + idx + ');" href="#">Zoom to...</a></li>'
      ////            html += '<li class="listingsRtLi">'
      ////            html += '<a onclick="' + 
      ////                    'javascript:showlocationdetails(' + '\'' + (arrFeatures[idx].gI) + '\',' + i + ',this); ' + 
      ////                    'javascript:arcgisLogisControl.addSelectedGF(' + idx + ',this); ' +    
      ////                    'javascript: GGTabs.expandit(2)" href="#" name=""><span>Highlight and view details...</span> </a></li></ul></td></tr></table>';
      ////        } //end for

      ////        //  html += '<tr><th colspan="2"><input type="button" onclick="purgeGraphics()" value="Remove All"></th></tr>';
      ////        html += '</td></tr></table>';

      ////        /////////////////////////////////////////////////////////////////////////////////
      ////        pnl.innerHTML = html;
      ////    }
      ////  },


      clearTipsPanel: function() {
          var pnl = $get('Logis_Panel2_Body');
          if (pnl) {
              html = 'To Find more locations select another categorie on the first tab or use the test search.';
              pnl.innerHTML = html;
          }
      },

      doCallback: function(argument, context) {
          ESRI.ADF.System._doCallback(this._callbackFunctionString, this.get_uniqueID(), this.get_id(), argument, context);
      },

      progress: function(showProg, msg) {
          if (showProg) {
              var tend = "</tr></table><asp:Label bgcolor=white>" + msg + "</asp:Label>";
              var tstrt = "<table><tr>";
              this._progressContent = this._progressContent + "<td style='width:10;height:10' bgcolor=red>";
              document.getElementById("cell1").innerHTML = tstrt + this._progressContent + tend;

          } else {
              this._progressContent = ''
              document.getElementById("cell1").innerHTML = "";
          }

      },

      // ==========================================================================
      // ===========  GETTERS ABD SETTERS  ========================================
      // ==========================================================================

      get_uniqueID: function() {
          return this._uniqueID;
      },
      set_uniqueID: function(value) {
          this._uniqueID = value;
      },

      get_callbackFunctionString: function() {
          return this._callbackFunctionString;
      },
      set_callbackFunctionString: function(value) {
          this._callbackFunctionString = value;
      },

      get_map: function() {
          return this._map;
      },
      set_map: function(value) {
          this._map = value;
      },

      get_icon: function() {
          return this._icon;
      },
      set_icon: function(value) {
          this._icon = value;
      },

      get_waitIcon: function() {
          return this._waitIcon;
      },
      set_waitIcon: function(value) {
          this._waitIcon = value;
      },

      get_contentPanelId: function() {
          return this._contentPanelId;
      },
      set_contentPanelId: function(value) {
          this._contentPanelId = value;
      },

      get_hasDetails: function() {
          return this._hasDetails;
      },
      set_hasDetails: function(value) {
          this._hasDetails = value;
      },

      get_currentName: function() {
          return this._currentName;
      },
      set_currentNames: function(value) {
          this._currentName = value;
      },

      get_currentGroup: function() {
          return this._currentGroup;
      },
      set_currentGroup: function(value) {
          this._currentGroup = value;
      },

      get_currentFilter: function() {
          return this._currentFilter;
      },
      set_currentFilter: function(value) {
          this._currentFilter = value;
      },

      get_progressContent: function() {
          return this._ProgressContent;
      },
      set_progressContent: function(value) {
          this._ProgressContent = value;
      },
      get_SelectGFID: function() {
          return this._SelectGFID;
      },
      set_SelectGFID: function(value) {
          this._SelectGFID = value;
      },



      doZoomAll: function() {

          var mapGFGs = [];
          mapGFGs[0] = this.get_uniqueID() + '_PtGFG';
          mapGFGs[1] = this.get_uniqueID() + '_LnGFG';
          mapGFGs[2] = this.get_uniqueID() + '_PlGFG';


          //var mergedEnv = new ESRI.ADF.Geometries.Envelope(); 


          for (var i = 0; i < mapGFGs.length; i++) {

              var testGfg = $find(mapGFGs[i]);
              if (testGfg) {
                  if (env == null) {
                      var env = testGfg._elements[0]._envelope;
                  } // end if

                  for (id in testGfg._elements) {
                      env = env.join(testGfg._elements[id]._envelope);
                  } // end for

                  //                if  (mergedEnv == null) {
                  //                    var mergedEnv = env;   
                  //                } else {
                  //                    mergedEnv = mergedEnv.join(env);
                  //                }   // end if   

              } // end if 

          } // end for

          this.get_map().set_extent(env);
          this.get_map().refresh();
      },  // 

      doZoomSel: function() {
          var theGF = $find(this.get_SelectGFID() + "_GF");
          if (theGF) {
              var selGFEnv = theGF._envelope;
              this.get_map().set_extent(selGFEnv);
              this.get_map().refresh();
          }

      },  // 

      addSelectedGF: function(num, lbl) {
          //Deselect any thing that may be selected
          var theGF = $find(this.get_SelectGFID() + "_GF");
          if (theGF) {
              theGF.set_highlight(false);
              theGF.get_attributes().High = false;
          }

          //   Select the feature
          this.set_SelectGFID(num);
          var theGF = $find(num + "_GF");
          if (theGF) {
              theGF.set_highlight(true);
              theGF.get_attributes().High = true;
          }
          //cell = lbl.parentNode.style.backgroundColor="Magenta";
          if (num == null) {
              return;
          }

      },


      deSelectGF: function() {

          if (this.get_SelectGFID > -1) {
              var selGF = $find(this.get_SelectGFID + "_GF");

          }

          if (theGF) {
              theGF.set_highlight(false);
              theGF.get_attributes().High = false;
          }

          if (graphicFeatureID == null) {
              return;
          }

      },

      ////USED TO ZOOM FROM TAB LIST
      doZoom2: function(iD) {
          var theGF = $find(iD + "_GF");
          if (theGF) {
              var selGFEnv = theGF._envelope;
              this.get_map().set_extent(selGFEnv);
              this.get_map().refresh();
          }
      },

      //USED TO ZOOM FROM MAPTIP
      doZoom: function(xmin, ymin, xmax, ymax) {

          this.get_map().set_extent(new ESRI.ADF.Geometries.Envelope(parseInt(xmin), parseInt(ymin), parseInt(xmax), parseInt(ymax)));
          this.get_map().refresh();
      }  // NO COMMA

  };
   
ESRI.ADF.UI.LogisControl.registerClass('ESRI.ADF.UI.LogisControl', Sys.Component);

String.prototype.stripHex = function(boo) {
    var str = this;
    if (boo) {
        str = str.replace(/\&amp;/g, '&');
        str = str.replace(/\&lt;/g, '<');
        str = str.replace(/\&gt;/g, '>');
    }
    else {
        str = str.replace(/\&/g, '&amp;');
        str = str.replace(/</g, '&lt;');
        str = str.replace(/>/g, '&gt;');
    }
    return str;
};
function findAndSelect() {
  var num = window.prompt("ID",25);
  var theGF = $find(num + "_GF");
  if (theGF) {
    theGF.set_highlight(true);
    theGF.get_attributes().High = true;
  }
}

//SHOWLOCATIONDETAILS ASSUMES THAT THE GROUP HAS BEEN SET TO A SESSION VARIABLE.
  function showlocationdetails(lbltxt, id, lbl, Group) {
      var placename = lbltxt;
      var groupname = Group
      if (Group=='undefined') {
        groupname = ""
      } else {
         groupname = Group
      }
  if (placename) {
     LogisSend('tab3', groupname, placename,'');
  }
//  if (lbl)  {
//     setHighlight(id, lbl)
//     //unsetHighlight(' + i + ',this);
//  }
}
  
function setHighlight(num, lbl) {
  var theGF = $find(num + "_GF");
  if (theGF) {
    theGF.set_highlight(true);
    theGF.get_attributes().High = true;
  }
  cell = lbl.parentNode.style.backgroundColor="CCFFFF";
}

function unsetHighlight(num, lbl) {
  var theGF = $find(num + "_GF");
  if (theGF) {
    theGF.set_highlight(false);
    theGF.get_attributes().High = false;
  }
  cell = lbl.parentNode.style.backgroundColor="";
   //cell = lbl.parentNode.style.backgroundColor="Silver";
}
 function setAssHighlight(num, lbl) {
  var theGF = $find(num + "_AssGF");
  if (theGF) {
    theGF.set_highlight(true);
    theGF.get_attributes().High = true;
  }
  cell = lbl.parentNode.style.backgroundColor = "CCFFFF";
}

function unsetsetAssHighlight(num, lbl) {
  var theGF = $find(num + "_AssGF");
  if (theGF) {
    theGF.set_highlight(false);
    theGF.get_attributes().High = false;
  }
  cell = lbl.parentNode.style.backgroundColor="";
   //cell = lbl.parentNode.style.backgroundColor="Silver";
}
function bigger(num) {
  var theGF = $find(num + "_GF");
  if (theGF) {
    theGF.set_highlight(true);
    var sym = theGF.get_highlightSymbol();
    if (sym == null) {
      sym = new ESRI.ADF.Graphics.MarkerSymbol("images/flag-magenta-24x24.png",0,24);
      theGF.set_highlightSymbol(sym);
    } else {
      switch (sym.get_centerY()) {
        case 16:
          sym.set_centerY(24);
          sym.set_imageUrl("images/flag-magenta-24x24.png");
          theGF.set_highlightSymbol(sym);
          break;
        case 24:
          sym.set_centerY(32);
          sym.set_imageUrl("images/flag-magenta-32x32.png");
          theGF.set_highlightSymbol(sym);
          break;
        default:
          sym.set_centerY(16);
          sym.set_imageUrl("images/flag-magenta-16x16.png");
          theGF.set_highlightSymbol(sym);
          break;
      }
    }
    theGF.set_highlight(false);
    theGF.set_highlight(true);
  }
}  

function purgeGraphics() {
  arcgisLogisControl.removeGraphicFeatureGroup()  
  arcgisLogisControl.clearTipsPanel();
}  

function setGroupActive(num, lbl) {
  var theGF = $find(num + "_GF");
  if (theGF) {
    theGF.set_highlight(true);
    theGF.get_attributes().High = true;
  }
  cell = lbl.parentNode.style.backgroundColor = "CCFFFF";
}

function unsetGroupAcitve(num, lbl) {
  var theGF = $find(num + "_GF");
  if (theGF) {
    theGF.set_highlight(false);
    theGF.get_attributes().High = false;
  }
  cell = lbl.parentNode.style.backgroundColor="";
   //cell = lbl.parentNode.style.backgroundColor="Silver";
}

/////////////FUNCTIONS FOR AMENITY FILTER DROP DOWN/////////////////
function mouseSelect(e, text)
{
		if (oOverMenu == false)
		{
			oOverMenu = false;
			document.getElementById(fActiveMenu).style.display = "none";
			fActiveMenu = false;
			arcgisLogisControl.filterRowData(text);
			return false;
		}
		return false;
}
 
function filterMenuActivate(idPickList, idMenu, idSel)
{
	if (fActiveMenu) return mouseSelect(0);
 
	oMenu = document.getElementById(idMenu);
	oPickList = document.getElementById(idPickList);
	nTop = oPickList.offsetTop + oPickList.offsetHeight;
	nLeft = oPickList.offsetLeft;	
	
	while (oPickList.offsetTop != 0)
	{
	    
		oPickList = oPickList.offsetParent;
		nTop += oPickList.offsetTop;
		nLeft += oPickList.offsetLeft;

    }
    
    var scrollAmt = document.getElementById("Panel2").scrollTop;
    //alert(scrollAmt);
	
	nTop = nTop - scrollAmt
	
	oMenu.style.left = nLeft;
	oMenu.style.top = nTop;
	oMenu.style.display = "";
	fActiveMenu = idMenu;
	document.getElementById(idSel).focus();
	return false;
}
 
function textSet(idEdit, text)
{
	document.getElementById(idEdit).value = text;
	oOverMenu = false;
	mouseSelect(0, text);
	//document.getElementById(idEdit).focus();
}

function hideAmenOnScroll(e) {
    var element = document.getElementById("amenFilterNameDiv");
    if (element) {        
        document.getElementById("amenFilterNameDiv").style.display = "none";
        oOverMenu = false;      
        fActiveMenu = false;       
        return false;
    }       
}



/////////////END FUNCTIONS FOR AMENITY FILTER DROP DOWN/////////////////

//This function recieves the results sucessful call to a webservice
function OnSucceeded(result, eventArgs)
{
  arcgisLogisControl.processCallbackResultFromService(result, eventArgs);
  
}

// This is the callback function invoked 
// if the Web service failed.
 function OnFailed(error){
    // Display the error.    
//    var RsltElem = 
//        document.getElementById("ResultId");
//    RsltElem.innerHTML = 
//    "Service Error: " + error.get_message();

      theDiv = $get(this._contentPanelId);
     if (theDiv) {
        theDiv.innerHTML = "Service Error: " + error.get_message();
      }
}


