﻿//========================
// Define frame variables.
//========================
var CurElement;
var ClassName;
document.onmouseup = mouseUp;
document.onmouseover = mouseOver;
document.onmouseout = mouseOut;

//============
// Init title.
//============
function initTit() {
   if (!top.IeFilters) {
      document.getElementById("title_div").className = "titleDivNN";
   }
}
//=======================
// Init identify webform.
//=======================
function initIdentify() {
   if (!top.IeFilters) {
      document.getElementById("title_div").className = "titleDivNN";
   }
   var wForm = top.data_frame.document.getElementById("identify_form");
   idHighlight(wForm);

   if (top.VmlObjectId > 0 || top.main_frame.NumSelect > 0) {
      top.main_frame.enableRow("selectionClearSelectedFeatures");
   } else {
      top.main_frame.disableRow("selectionClearSelectedFeatures");
   }
}
//====================
// Init parcel search.
//====================
function initParcelSearch() {
   var search_Button = document.getElementById("search_Button");
   if (search_Button) {
      initTit();
      document.getElementById("govUser_hid").value = top.GovUser;
      document.getElementById("validUser_hid").value = top.ValidUser;
      document.body.className = "blueToGreen";
      var textbox0 = document.getElementById("textbox0");
      if (textbox0) {
         textbox0.focus();
      }

   } else {
      document.body.className = "whiteBackground";
      var objectID = document.getElementById("vmlObjectID_hid").value;
      var layerID = document.getElementById("vmlLayerID_hid").value;
      if (objectID != 0) {
         top.zoomToFeature(layerID, objectID);
      }
   }
}
//=============================
// Init zoom to parcel webform.
//=============================
function initZoomToParcel() {
   var wForm = document.getElementById("zoomToParcel_form");
   var objectID = wForm.vmlObjectID_hid.value;
   if (objectID != 0) {
      top.zoomToFeature(wForm.vmlLayerID_hid.value, objectID);
   }
}
//================
// Init find form.
//================
function initFind_form() {
   var wForm = top.data_frame.document.getElementById("find_form");
   var findTextBox = document.getElementById("find_TextBox");
   document.getElementById("govUser_hid").value = top.GovUser;
   document.getElementById("validUser_hid").value = top.ValidUser;

   if (findTextBox) {
      initTit();
      document.body.className = "blueToGreen";
      findTextBox.focus();
      document.getElementById("activeLayerId_hid").value = top.ActiveLayerId;

   } else {
      document.body.className = "whiteBackground";
      wForm.find1_TextBox.value = wForm.findText_hid.value;
      wForm.find2_TextBox.value = wForm.findText_hid.value;

      var objectID = wForm.vmlObjectID_hid.value;
      if (objectID != 0) {
         top.zoomToFeature(wForm.vmlLayerID_hid.value, objectID);
      }
   }
}
//=====================================
// Find results textbox onchange event.
//=====================================
function setFindText(element) {
   var wForm = top.data_frame.document.getElementById("find_form");
   wForm.findText_hid.value = element.value;
}
//=====================
// Init find addresses.
//=====================
function initFindAddress() {
   if (!top.IeFilters) {
      document.getElementById("title_div").className = "titleDivNN";
   }
   document.getElementById("geocode_textbox").focus();
}
//========================
// Process sort by column.
//========================
function sortByColumn(element) {
   if (opener) {
      if (!opener.closed) {
         opener.top.main_frame.SortField = element.id;
         opener.top.openAtrTable();
      }
   }
}
//=======================
// Highlight the feature.
//=======================
function idHighlight(wForm) {
   //Update highlighted feature global variables.
   top.VmlLayerId = wForm.vmlLayerID_hid.value;
   top.VmlObjectId = wForm.vmlObjectID_hid.value;

   var vmlGeometry = "";

   if (top.IeFilters) {
      vmlGeometry += wForm.vmlGeometry1_hid.value;
      vmlGeometry += wForm.vmlGeometry2_hid.value;
      vmlGeometry += wForm.vmlGeometry3_hid.value;
      vmlGeometry += wForm.vmlGeometry4_hid.value;
      vmlGeometry += wForm.vmlGeometry5_hid.value;
      vmlGeometry += wForm.vmlGeometry6_hid.value;

      // Display the VML
      var featureClass = wForm.vmlFeatureClass_hid.value;
      top.main_frame.displayVML(featureClass, vmlGeometry);
   }

   // Enable parcel specific tools
   top.main_frame.enableSelectTools();
   top.setPostBackDone();
}
//==================
// Mouse over event.
//==================
function mouseOver(e) {
   if (e) {
      CurElement = e.target;
   } else {
      e = window.event;
      CurElement = e.srcElement;
   }
   ClassName = CurElement.className;
   if (ClassName == "hIC" || ClassName == "iIC" || ClassName == "sh2" || ClassName == "sh3") {
      CurElement = CurElement.parentNode;
      ClassName = CurElement.className;
   }
   if (ClassName == "iNC" || ClassName == "iNC2" || ClassName == "hC" || ClassName == "zoomToWhite" || ClassName == "zoomToWhite2" || ClassName == "zoomToGray" || ClassName == "zoomToGreen") {
      CurElement.style.backgroundColor = top.HoverBackgroundColor;
      CurElement.style.borderColor = top.HoverBorderColor;
   }
   if (ClassName == "zoomToGray2" || ClassName == "zoomToGreen2") {
      if (opener) {
         if (!opener.closed) {
            CurElement.style.backgroundColor = opener.top.HoverBackgroundColor;
            CurElement.style.borderColor = opener.top.HoverBorderColor;
         }
      }
   }
}
//=================
// Mouse out event.
//=================
function mouseOut(e) {
   if (e) {
      CurElement = e.target;
   } else {
      e = window.event;
      CurElement = e.srcElement;
   }
   ClassName = CurElement.className;
   if (ClassName == "hIC" || ClassName == "iIC" || ClassName == "sh2" || ClassName == "sh3") {
      CurElement = CurElement.parentNode;
      ClassName = CurElement.className;
   }
   if (ClassName == "iNC" || ClassName == "iNC2" || ClassName == "hC") {
      CurElement.style.backgroundColor = top.DataFrameBackgroundColor;
      CurElement.style.borderColor = top.DataFrameBackgroundColor;
   }
   if (ClassName == "zoomToWhite" || ClassName == "zoomToWhite2") {
      CurElement.style.backgroundColor = top.MouseOutWhite;
      CurElement.style.borderColor = top.DataFrameBackgroundColor;
   }
   if (ClassName == "zoomToGray") {
      CurElement.style.backgroundColor = top.MouseOutGray;
      CurElement.style.borderColor = top.DataFrameBackgroundColor;
   }
   if (ClassName == "zoomToGreen") {
      CurElement.style.backgroundColor = top.MouseOutGreen;
      CurElement.style.borderColor = top.DataFrameBackgroundColor;
   }
   if (ClassName == "zoomToGray2") {
      if (opener) {
         if (!opener.closed) {
            CurElement.style.backgroundColor = opener.top.MouseOutGray;
            CurElement.style.borderColor = opener.top.DataFrameBackgroundColor;
         }
      }
   }
   if (ClassName == "zoomToGreen2") {
      if (opener) {
         if (!opener.closed) {
            CurElement.style.backgroundColor = opener.top.MouseOutGreen;
            CurElement.style.borderColor = opener.top.DataFrameBackgroundColor;
         }
      }
   }
}
//================
// Mouse up event.
//================
function mouseUp(e) {
   if (!CurElement) {
      return;
   }
   if (ClassName == "iNC" || ClassName == "iNC2" || ClassName == "hC") {
      if (ClassName == "iNC2") {
         ob_t23(CurElement.parentNode);
      } else {
         ob_t23(CurElement);
      }
   }
   ClassName = CurElement.className;
   if (ClassName == "zoomToWhite" || ClassName == "zoomToWhite2" || ClassName == "zoomToGray" || ClassName == "zoomToGreen") {
      CurElement.style.color = "purple";
   }
}
