function buttonChange(functName) {

  main_map_frame.document.measuredot1.style.visibility = 'hidden'
  main_map_frame.document.measuredot2.style.visibility = 'hidden'
  //distancediv.style.visibility = 'hidden'
  distancereadout.innerHTML = '0'
  main_map_frame.myCanvas.innerHTML = "&nbsp"

  document.zoomin.src="buttons/zoomin_1.gif"
  document.zoomout.src="buttons/zoomout_1.gif"
  document.pan.src="buttons/pan_1.gif"
  document.identify.src="buttons/identify_1.gif"
  document.measure.src="buttons/measure_1.gif"
  document.navtoolsform.measurephase.value="not"

  if (functName=="zoominfunction") {
    document.zoomin.src="buttons/zoomin_2.gif"
    document.navtoolsform.buttonsetting.value="zoomin"
    main_map_frame.document.map.style.cursor = "url(images/cursors/ZoomIn.cur)"
  }
  if (functName=="zoomoutfunction") {
    document.zoomout.src="buttons/zoomout_2.gif"
    document.navtoolsform.buttonsetting.value="zoomout"
    main_map_frame.document.map.style.cursor = "url(images/cursors/ZoomOut.cur)"
  }
  if (functName=="panfunction") {
    document.pan.src="buttons/pan_2.gif"
    document.navtoolsform.buttonsetting.value="pan"
    main_map_frame.document.map.style.cursor = "url(images/cursors/Pan.cur)"
  }
  if (functName=="identifyfunction") {
    document.identify.src="buttons/identify_2.gif"
    document.navtoolsform.buttonsetting.value="identify"
    main_map_frame.document.map.style.cursor = "url(images/cursors/Identify.cur)"
  }
  if (functName=="measurefunction") {
    document.measure.src="buttons/measure_2.gif"
    document.navtoolsform.buttonsetting.value="measure"
    document.navtoolsform.measurephase.value="step1"
    main_map_frame.document.map.style.cursor = "url(images/cursors/Measure.cur)"
  }
  
  main_map_frame.document.map.style.cursor = "url(images/cursors/" + document.navtoolsform.buttonsetting.value + ".cur)"

}

function refresh(val) {

  if (val == 'first') {
    newRight = document.basemaplayersform.theMaxRight.value / 1
    newLeft = document.basemaplayersform.theMaxLeft.value / 1
    newTop = document.basemaplayersform.theMaxTop.value / 1
    newBottom = document.basemaplayersform.theMaxBottom.value / 1
    }
  else {
    newRight = main_map_frame.document.mainmapform.theRight.value / 1
    newLeft = main_map_frame.document.mainmapform.theLeft.value / 1
    newTop = main_map_frame.document.mainmapform.theTop.value / 1
    newBottom = main_map_frame.document.mainmapform.theBottom.value / 1
  }
  specifiedlocationURL = '&zoomtype=interactive&theLeft=' + newLeft + '&theRight=' + newRight + '&theTop=' + newTop + '&theBottom=' + newBottom

  sendMapURL(specifiedlocationURL)

}

function mapActionDown() {

  if (parent.document.navtoolsform.buttonsetting.value=="zoomin") {
    startMouseX = event.clientX
    startMouseY = event.clientY
  }

  if (parent.document.navtoolsform.buttonsetting.value=="pan") {
      panfromX = event.clientX
      panfromY = event.clientY
  }

}

function mapActionDragEnd() {

  if (parent.document.navtoolsform.buttonsetting.value=="zoomin") {
    endMouseX = event.clientX
    endMouseY = event.clientY

    mainmapXsize = document.mainmapform.mapWidth.value / 1
    mainmapYsize = document.mainmapform.mapHeight.value / 1

    if (startMouseX==endMouseX) {endMouseX+=3}
    if (startMouseY==endMouseY) {endMouseY+=3}
    if (startMouseX < endMouseX) {
      leftPixel = startMouseX
      rightPixel = endMouseX
    }
    if (endMouseX < startMouseX) {
      leftPixel = endMouseX
      rightPixel = startMouseX
    }
    if (startMouseY < endMouseY) {
      topPixel = startMouseY
      bottomPixel = endMouseY
    }
    if (endMouseY < startMouseY) {
      topPixel = endMouseY
      bottomPixel = startMouseY
    }

    boxpixelwidth = rightPixel - leftPixel
    boxpixelheight = bottomPixel - topPixel

    rightCoord = document.mainmapform.theRight.value / 1
    leftCoord = document.mainmapform.theLeft.value / 1
    topCoord = document.mainmapform.theTop.value / 1
    bottomCoord = document.mainmapform.theBottom.value / 1

    notsquarerectLeft = (((leftPixel-1)/mainmapXsize)*(rightCoord-leftCoord) / 1) + (leftCoord / 1)
    notsquarerectRight = (((rightPixel-1)/mainmapXsize)*(rightCoord-leftCoord) / 1) + (leftCoord / 1)
    notsquarerectTop = (topCoord / 1) - (((topPixel-1)/mainmapYsize)*(topCoord-bottomCoord) / 1)
    notsquarerectBottom = (topCoord / 1) - (((bottomPixel-1)/mainmapYsize)*(topCoord-bottomCoord) / 1)

    diffX = notsquarerectRight - notsquarerectLeft
    diffY = notsquarerectTop - notsquarerectBottom
    if (boxpixelwidth > boxpixelheight) {
      largestBoxSide = "x"
    }else{
      largestBoxSide = "y"
    }

    centerX = (diffX / 2) + notsquarerectLeft
    centerY = (diffY / 2) + notsquarerectBottom
    if (largestBoxSide == "x") {
      newLeft = centerX - (diffX / 2)
      newRight = centerX + (diffX / 2)
      newTop = centerY + (((mainmapYsize/mainmapXsize) * diffX)/2)
      newBottom = centerY - (((mainmapYsize/mainmapXsize) * diffX)/2)
    }
    if (largestBoxSide == "y") {
      newLeft = centerX - (((mainmapXsize/mainmapYsize) * diffY)/2)
      newRight = centerX + (((mainmapXsize/mainmapYsize) * diffY)/2)
      newTop = centerY + (diffY / 2)
      newBottom = centerY - (diffY / 2)
    }

    action = "locationchange"
    specifiedlocationURL = '&zoomtype=interactive&theLeft=' + newLeft + '&theRight=' + newRight + '&theTop=' + newTop + '&theBottom=' + newBottom + '&largestboxside=' + largestBoxSide + '&boxpixelwidth=' + boxpixelwidth + '&boxpixelheight=' + boxpixelheight
    parent.sendMapURL (specifiedlocationURL)
  }

  if (parent.document.navtoolsform.buttonsetting.value=="pan") {
    pantoX = event.clientX
    pantoY = event.clientY

    mainmapXsize = document.mainmapform.mapWidth.value / 1
    mainmapYsize = document.mainmapform.mapHeight.value / 1
    
    rightCoord = document.mainmapform.theRight.value / 1
    leftCoord = document.mainmapform.theLeft.value / 1
    topCoord = document.mainmapform.theTop.value / 1
    bottomCoord = document.mainmapform.theBottom.value / 1

    newLeft = leftCoord - (((pantoX - panfromX)/mainmapXsize) * (rightCoord - leftCoord))
    newRight = rightCoord - (((pantoX - panfromX)/mainmapXsize) * (rightCoord - leftCoord))
    newTop = topCoord - (((panfromY - pantoY)/mainmapYsize) * (topCoord - bottomCoord))
    newBottom = bottomCoord - (((panfromY - pantoY)/mainmapYsize) * (topCoord - bottomCoord))

    action = "locationchange"
    specifiedlocationURL = '&zoomtype=interactive&theLeft=' + newLeft + '&theRight=' + newRight + '&theTop=' + newTop + '&theBottom=' + newBottom
    parent.sendMapURL(specifiedlocationURL)
  }

}

function mapActionUp() {

  if (parent.document.navtoolsform.buttonsetting.value=="zoomout") {

    pixelX = event.clientX
    pixelY = event.clientY

    mainmapXsize = document.mainmapform.mapWidth.value / 1
    mainmapYsize = document.mainmapform.mapHeight.value / 1

    rightCoord = document.mainmapform.theRight.value / 1
    leftCoord = document.mainmapform.theLeft.value / 1
    topCoord = document.mainmapform.theTop.value / 1
    bottomCoord = document.mainmapform.theBottom.value / 1

    centerX = (((pixelX / mainmapXsize) * (rightCoord - leftCoord)) + leftCoord/1)
    centerY = (topCoord/1 - ((pixelY / mainmapYsize) * (topCoord - bottomCoord)))

    zoomfactor = 2
    newRight = (centerX + ((zoomfactor * (rightCoord - leftCoord)) / 2))
    newLeft = (centerX - ((zoomfactor * (rightCoord - leftCoord)) / 2))
    newTop = (centerY + ((zoomfactor * (topCoord - bottomCoord)) / 2))
    newBottom = (centerY - ((zoomfactor * (topCoord - bottomCoord)) / 2))

    action = "locationchange"
    specifiedlocationURL = '&zoomtype=interactive&theLeft=' + newLeft + '&theRight=' + newRight + '&theTop=' + newTop + '&theBottom=' + newBottom
    parent.sendMapURL(specifiedlocationURL)
  }

  if (parent.document.navtoolsform.buttonsetting.value=="identify") {

    pixelX = event.clientX
    pixelY = event.clientY

    rightCoord = document.mainmapform.theRight.value / 1
    leftCoord = document.mainmapform.theLeft.value / 1
    topCoord = document.mainmapform.theTop.value / 1
    bottomCoord = document.mainmapform.theBottom.value / 1
    mainmapXsize = document.mainmapform.mapWidth.value / 1
    mainmapYsize = document.mainmapform.mapHeight.value / 1
    idwidth = document.mainmapform.idWidth.value / 1
    idheight = document.mainmapform.idHeight.value / 1

    Xcoord = ((pixelX/mainmapXsize)*(rightCoord-leftCoord))+leftCoord
    Ycoord = topCoord-((pixelY/mainmapYsize)*(topCoord-bottomCoord))

    specifiedlayersURL = parent.selectedDataLayers ()

    specifiedlocationURL = '&theLeft=' + leftCoord + '&theRight=' + rightCoord + '&theTop=' + topCoord + '&theBottom=' + bottomCoord
   
    sendidentifyURL = 'map_functions.asp?task=identify&zoomtype=interactive&Xcoord=' + Xcoord + '&Ycoord=' + Ycoord + specifiedlayersURL + specifiedlocationURL

    identifyWindow = window.open(sendidentifyURL,'identifyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=' + idwidth + ',height=' + idheight) 
    identifyWindow.focus()
  }

  if (parent.document.navtoolsform.buttonsetting.value=="weather") {

    pixelX = event.clientX
    pixelY = event.clientY

    rightCoord = document.mainmapform.theRight.value / 1
    leftCoord = document.mainmapform.theLeft.value / 1
    topCoord = document.mainmapform.theTop.value / 1
    bottomCoord = document.mainmapform.theBottom.value / 1
    mainmapXsize = document.mainmapform.mapWidth.value / 1
    mainmapYsize = document.mainmapform.mapHeight.value / 1
    idwidth = document.mainmapform.idWidth.value / 1
    idheight = document.mainmapform.idHeight.value / 1

    Xcoord = ((pixelX/mainmapXsize)*(rightCoord-leftCoord))+leftCoord
    Ycoord = topCoord-((pixelY/mainmapYsize)*(topCoord-bottomCoord))

    specifiedlayersURL = parent.selectedDataLayers ()

    specifiedlocationURL = '&theLeft=' + leftCoord + '&theRight=' + rightCoord + '&theTop=' + topCoord + '&theBottom=' + bottomCoord
   
    sendweatherURL = 'map_functions.asp?task=weather&zoomtype=interactive&Xcoord=' + Xcoord + '&Ycoord=' + Ycoord + specifiedlayersURL + specifiedlocationURL

    weatherWindow = window.open(sendweatherURL,'weatherWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=320,height=230') 
    weatherWindow.focus()
  }


  if (parent.document.navtoolsform.buttonsetting.value=="measure") {
      
    if (parent.document.navtoolsform.measurephase.value=="stepmiddle") {
      parent.document.navtoolsform.measurephase.value = "step1"
    }
    if (parent.document.navtoolsform.measurephase.value=="step2") {
      measuretoX = event.clientX
      measuretoY = event.clientY
      document.measuredot2.style.top = measuretoY - 5
      document.measuredot2.style.left = measuretoX - 5
      document.measuredot2.style.width = 6
      document.measuredot2.style.height = 6
      document.measuredot2.style.visibility = 'visible'
      mainmapXsize = document.mainmapform.mapWidth.value / 1
      mainmapYsize = document.mainmapform.mapHeight.value / 1
      rightCoord = document.mainmapform.theRight.value / 1
      leftCoord = document.mainmapform.theLeft.value / 1
      topCoord = document.mainmapform.theTop.value / 1
      bottomCoord = document.mainmapform.theBottom.value / 1
      utmX = (((rightCoord - leftCoord)/mainmapXsize) * measuretoX) + leftCoord
      utmY = (((topCoord - bottomCoord)/mainmapYsize) * (mainmapYsize - measuretoY)) + bottomCoord
      startX = parent.document.navtoolsform.measureX.value / 1
      startY = parent.document.navtoolsform.measureY.value / 1
      startutmX = (((rightCoord - leftCoord)/mainmapXsize) * startX) + leftCoord
      startutmY = (((topCoord - bottomCoord)/mainmapYsize) * (mainmapYsize - startY)) + bottomCoord
      distance = Math.floor(100*(Math.sqrt(Math.pow((startutmX - utmX),2) + Math.pow((startutmY - utmY),2))))/100
      //parent.distancereadout.innerHTML = distance
      parent.document.navtoolsform.lastdistancemeasured.value = distance
      mapunits = document.mainmapform.mapUnits.value
      distanceunits = parent.document.distanceform.distanceunits.value
      if (mapunits == "meters") {
        if (distanceunits == 'ft') { conversionfactor = 3.281 }
        if (distanceunits == 'mi') { conversionfactor = 0.0006214 }
        if (distanceunits == 'm') { conversionfactor = 1 }
        if (distanceunits == 'km') { conversionfactor = 0.001 }
      }
      if (mapunits == "feet") {
        if (distanceunits == 'ft') { conversionfactor = 1 }
        if (distanceunits == 'mi') { conversionfactor = 0.0001894 }
        if (distanceunits == 'm') { conversionfactor = 0.3048 }
        if (distanceunits == 'km') { conversionfactor = 0.0003048  }
      }
      distancereadout = Math.floor(100*distance * conversionfactor)/100
      parent.distancereadout.innerHTML = distancereadout
      parent.document.navtoolsform.measurephase.value = "stepmiddle"
      var jg = new jsGraphics("myCanvas")
      jg.setStroke(2)
      jg.drawLine(startX-3, startY-3, measuretoX-3, measuretoY-3)
      jg.paint()


    }

    if (parent.document.navtoolsform.measurephase.value=="step1") {
      document.measuredot2.style.visibility = 'hidden'
      myCanvas.innerHTML = "&nbsp"
      measurefromX = event.clientX
      measurefromY = event.clientY
      parent.document.navtoolsform.measureX.value = measurefromX
      parent.document.navtoolsform.measureY.value = measurefromY
      document.measuredot1.style.top = measurefromY - 5
      document.measuredot1.style.left = measurefromX - 5
      document.measuredot1.style.width = 6
      document.measuredot1.style.height = 6
      document.measuredot1.style.visibility = 'visible'
      //parent.distancediv.style.visibility = 'visible'
      parent.distancereadout.innerHTML = '0'
      parent.document.navtoolsform.measurephase.value = "step2"
    }


  }

}


function mapActionDrag() {

  //document.map.style.cursor = "url(images/cursors/" + parent.document.navtoolsform.buttonsetting.value + ".cur)"

  MouseX = event.clientX
  MouseY = event.clientY

  mainmapXsize = document.mainmapform.mapWidth.value / 1
  mainmapYsize = document.mainmapform.mapHeight.value / 1

  if (parent.document.navtoolsform.buttonsetting.value=="zoomin") {
 
//    start Y horizontal
      boxwidth = MouseX - startMouseX
      if (boxwidth < 0) {
        document.dotbottom.style.top = startMouseY
        document.dotbottom.style.left = startMouseX + boxwidth
        endMouseX = startMouseX + boxwidth
        document.dotbottom.style.width = -1 * boxwidth
        document.dotbottom.style.height = 2
        document.dotbottom.style.visibility = 'visible'
      }
      if (boxwidth >= 0) {
        document.dotbottom.style.left = startMouseX
        endMouseX = startMouseX + boxwidth
        document.dotbottom.style.top = startMouseY
        document.dotbottom.style.visibility = 'visible'
        document.dotbottom.style.width = boxwidth
        document.dotbottom.style.height = 2
      }

//    start X vertical
      boxheight = MouseY - startMouseY
      if (boxheight < 0) {
        document.dotleft.style.left = startMouseX
        document.dotleft.style.top = startMouseY + boxheight
        endMouseY = startMouseY + boxheight
        document.dotleft.style.height = -1 * boxheight
        document.dotleft.style.width = 2
        document.dotleft.style.visibility = 'visible'
      }
      if (boxheight >= 0) {
        document.dotleft.style.left = startMouseX
        document.dotleft.style.top = startMouseY
        endMouseY = startMouseY + boxheight
        document.dotleft.style.visibility = 'visible'
        document.dotleft.style.height = boxheight
        document.dotleft.style.width = 2
      }

//    end Y horizontal
      if (boxwidth < 0) {
        document.dottop.style.top = endMouseY
        document.dottop.style.left = startMouseX + boxwidth
        document.dottop.style.width = -1 * boxwidth
        document.dottop.style.height = 2
        document.dottop.style.visibility = 'visible'
      }
      if (boxwidth >= 0) {
        document.dottop.style.left = startMouseX
        document.dottop.style.top = endMouseY
        document.dottop.style.visibility = 'visible'
        document.dottop.style.width = boxwidth
        document.dottop.style.height = 2
      }

//    end X vertical
      boxheight = MouseY - startMouseY
      if (boxheight < 0) {
        document.dotright.style.left = endMouseX
        document.dotright.style.top = startMouseY + boxheight
        endMouseY = startMouseY + boxheight
        document.dotright.style.height = -1 * boxheight
        document.dotright.style.width = 2
        document.dotright.style.visibility = 'visible'
      }
      if (boxheight >= 0) {
        document.dotright.style.left = endMouseX
        document.dotright.style.top = startMouseY
        endMouseY = startMouseY + boxheight
        document.dotright.style.visibility = 'visible'
        document.dotright.style.height = boxheight
        document.dotright.style.width = 2
      }

    }

  rightCoord = document.mainmapform.theRight.value / 1
  leftCoord = document.mainmapform.theLeft.value / 1
  topCoord = document.mainmapform.theTop.value / 1
  bottomCoord = document.mainmapform.theBottom.value / 1

  utmX = (((rightCoord - leftCoord)/mainmapXsize) * MouseX) + leftCoord
  utmY = (((topCoord - bottomCoord)/mainmapYsize) * (mainmapYsize - MouseY)) + bottomCoord

  parent.coordreadout.innerHTML = 'X,Y:' + Math.floor(utmX) + ',' + Math.floor(utmY)

  if (parent.document.navtoolsform.buttonsetting.value=="pan") {
      document.mainmapform.map.style.left = MouseX - panfromX
      document.mainmapform.map.style.top = MouseY - panfromY
  }

}    

function mapActionMove() {

  MouseX = event.clientX
  MouseY = event.clientY

  mainmapXsize = document.mainmapform.mapWidth.value / 1
  mainmapYsize = document.mainmapform.mapHeight.value / 1

  rightCoord = document.mainmapform.theRight.value / 1
  leftCoord = document.mainmapform.theLeft.value / 1
  topCoord = document.mainmapform.theTop.value / 1
  bottomCoord = document.mainmapform.theBottom.value / 1

  utmX = (((rightCoord - leftCoord)/mainmapXsize) * MouseX) + leftCoord
  utmY = (((topCoord - bottomCoord)/mainmapYsize) * (mainmapYsize - MouseY)) + bottomCoord

  parent.coordreadout.innerHTML = 'X,Y:' + Math.floor(utmX) + ',' + Math.floor(utmY)

  if (parent.document.navtoolsform.buttonsetting.value=="measure") {
    if (parent.document.navtoolsform.measurephase.value=="step2") {
      startX = parent.document.navtoolsform.measureX.value / 1
      startY = parent.document.navtoolsform.measureY.value / 1
      startutmX = (((rightCoord - leftCoord)/mainmapXsize) * startX) + leftCoord
      startutmY = (((topCoord - bottomCoord)/mainmapYsize) * (mainmapYsize - startY)) + bottomCoord
      distance = Math.floor(100*(Math.sqrt(Math.pow((startutmX - utmX),2) + Math.pow((startutmY - utmY),2))))/100
      parent.document.navtoolsform.lastdistancemeasured.value = distance

      mapunits = document.mainmapform.mapUnits.value
      distanceunits = parent.document.distanceform.distanceunits.value
      if (mapunits == "meters") {
        if (distanceunits == 'ft') { conversionfactor = 3.281 }
        if (distanceunits == 'mi') { conversionfactor = 0.0006214 }
        if (distanceunits == 'm') { conversionfactor = 1 }
        if (distanceunits == 'km') { conversionfactor = 0.001 }
      }
      if (mapunits == "feet") {
        if (distanceunits == 'ft') { conversionfactor = 1 }
        if (distanceunits == 'mi') { conversionfactor = 0.0001894 }
        if (distanceunits == 'm') { conversionfactor = 0.3048 }
        if (distanceunits == 'km') { conversionfactor = 0.0003048  }
      }
      distancereadout = Math.floor(100*distance * conversionfactor)/100
      parent.distancereadout.innerHTML = distancereadout
    }
  }
  
}

function mapActionPanOvMap() {

  pixelX = event.clientX
  pixelY = event.clientY

  ovmapwidth = parent.main_map_frame.document.mainmapform.ovmapWidth.value / 1
  ovmapheight = parent.main_map_frame.document.mainmapform.ovmapHeight.value / 1
  ovtopcoord = parent.document.basemaplayersform.theOVTop.value / 1
  ovbottomcoord = parent.document.basemaplayersform.theOVBottom.value / 1
  ovleftcoord = parent.document.basemaplayersform.theOVLeft.value / 1
  ovrightcoord = parent.document.basemaplayersform.theOVRight.value / 1
  themapextentTop = parent.main_map_frame.document.mainmapform.theTop.value / 1
  themapextentBottom = parent.main_map_frame.document.mainmapform.theBottom.value / 1
  themapextentRight = parent.main_map_frame.document.mainmapform.theRight.value / 1
  themapextentLeft = parent.main_map_frame.document.mainmapform.theLeft.value / 1

  theOldCenterX = themapextentLeft + ((themapextentRight - themapextentLeft)/2)
  theOldCenterY = themapextentBottom + ((themapextentTop - themapextentBottom)/2)
  theNewCenterX = ovleftcoord + ((ovrightcoord - ovleftcoord) * (pixelX / ovmapwidth))
  theNewCenterY = ovbottomcoord + ((ovtopcoord - ovbottomcoord) * ((ovmapheight - pixelY) / ovmapheight)) 

  mapshiftX = theNewCenterX - theOldCenterX
  mapshiftY = theNewCenterY - theOldCenterY
  
  newRight = themapextentRight + mapshiftX
  newLeft = themapextentLeft + mapshiftX
  newTop = themapextentTop + mapshiftY
  newBottom = themapextentBottom + mapshiftY

  specifiedlocationURL = '&zoomtype=interactive&theLeft=' + newLeft + '&theRight=' + newRight + '&theTop=' + newTop + '&theBottom=' + newBottom
  parent.sendMapURL(specifiedlocationURL)

}

function imagePageLoaded() {

  main_map_frame.pleasewait.innerHTML = ''
  mapscale = main_map_frame.document.mainmapform.theScale.value

  scaleunit = document.navtoolsform.scaleunit.value

  if (scaleunit == 'ft') { conversionfactor = 12 }
  if (scaleunit == 'mi') { conversionfactor = 63360 }
  if (scaleunit == 'me') { conversionfactor = 39.37 }
  if (scaleunit == 'km') { conversionfactor = 39370 }

  if (scaleunit != 'in') { newscalenumber = mapscale / conversionfactor }
  if (scaleunit == 'in') { newscalenumber = mapscale }

  document.navtoolsform.scalenumber.value = newscalenumber

  updateScaleDependency()

  ovmapwidth = main_map_frame.document.mainmapform.ovmapWidth.value
  ovmapheight = main_map_frame.document.mainmapform.ovmapHeight.value
  ovtopcoord = document.basemaplayersform.theOVTop.value
  ovbottomcoord = document.basemaplayersform.theOVBottom.value
  ovleftcoord = document.basemaplayersform.theOVLeft.value
  ovrightcoord = document.basemaplayersform.theOVRight.value
  themapextentTop = main_map_frame.document.mainmapform.theTop.value
  themapextentBottom = main_map_frame.document.mainmapform.theBottom.value
  themapextentRight = main_map_frame.document.mainmapform.theRight.value
  themapextentLeft = main_map_frame.document.mainmapform.theLeft.value

  ovmapTopPixel = (ovmapheight - (((themapextentTop - ovbottomcoord)/(ovtopcoord - ovbottomcoord))*ovmapheight)) - 2
  ovmapBottomPixel = (ovmapheight - (((themapextentBottom - ovbottomcoord)/(ovtopcoord - ovbottomcoord))*ovmapheight)) + 2
  ovmapLeftPixel = (((themapextentLeft - ovleftcoord)/(ovrightcoord - ovleftcoord))*ovmapwidth) - 2
  ovmapRightPixel = (((themapextentRight - ovleftcoord)/(ovrightcoord - ovleftcoord))*ovmapwidth) + 2
  boxPixelWidth = ovmapRightPixel - ovmapLeftPixel + 2
  boxPixelHeight = ovmapBottomPixel - ovmapTopPixel + 2

  location_map_frame.document.dottop.style.top = ovmapTopPixel 
  location_map_frame.document.dottop.style.left = ovmapLeftPixel
  location_map_frame.document.dottop.style.width = boxPixelWidth
  location_map_frame.document.dottop.style.height = 2
  location_map_frame.document.dottop.style.visibility = 'visible'

  location_map_frame.document.dotbottom.style.top = ovmapBottomPixel 
  location_map_frame.document.dotbottom.style.left = ovmapLeftPixel
  location_map_frame.document.dotbottom.style.width = boxPixelWidth
  location_map_frame.document.dotbottom.style.height = 2
  location_map_frame.document.dotbottom.style.visibility = 'visible'

  location_map_frame.document.dotleft.style.top = ovmapTopPixel 
  location_map_frame.document.dotleft.style.left = ovmapLeftPixel
  location_map_frame.document.dotleft.style.width = 2
  location_map_frame.document.dotleft.style.height = boxPixelHeight
  location_map_frame.document.dotleft.style.visibility = 'visible'

  location_map_frame.document.dotright.style.top = ovmapTopPixel 
  location_map_frame.document.dotright.style.left = ovmapRightPixel
  location_map_frame.document.dotright.style.width = 2
  location_map_frame.document.dotright.style.height = boxPixelHeight
  location_map_frame.document.dotright.style.visibility = 'visible'

  main_map_frame.document.map.style.cursor = "url(images/cursors/" + document.navtoolsform.buttonsetting.value + ".cur)"

//  next_slide()
//alert('test')

}

function zoomfullfunction() {

  action = "locationchange"

  refresh('first')

}

function reCalculateScalenumber() {

  oldscaleunit = document.navtoolsform.oldscaleunit.value
  newscaleunit = document.navtoolsform.scaleunit.value
  oldscalenumber = document.navtoolsform.scalenumber.value

  if (oldscaleunit == 'ft') { conversionfactor = 12 }
  if (oldscaleunit == 'mi') { conversionfactor = 63360 }
  if (oldscaleunit == 'me') { conversionfactor = 39.37 }
  if (oldscaleunit == 'km') { conversionfactor = 39370 }

  if (oldscaleunit != 'in') { proportionalscalenumber = oldscalenumber * conversionfactor }
  if (oldscaleunit == 'in') { proportionalscalenumber = oldscalenumber }

  if (newscaleunit == 'ft') { conversionfactor = 12 }
  if (newscaleunit == 'mi') { conversionfactor = 63360 }
  if (newscaleunit == 'me') { conversionfactor = 39.37 }
  if (newscaleunit == 'km') { conversionfactor = 39370 }

  if (newscaleunit != 'in') { newscalenumber = proportionalscalenumber / conversionfactor }
  if (newscaleunit == 'in') { newscalenumber = proportionalscalenumber }

  document.navtoolsform.scalenumber.value = newscalenumber
  document.navtoolsform.oldscaleunit.value = document.navtoolsform.scaleunit.value

}

function reCalculateDistancenumber() {

  mapunits = main_map_frame.document.mainmapform.mapUnits.value
  distanceunits = document.distanceform.distanceunits.value
  if (mapunits = "meters") {
    if (distanceunits == 'ft') { conversionfactor = 3.281 }
    if (distanceunits == 'mi') { conversionfactor = 0.0006214 }
    if (distanceunits == 'm') { conversionfactor = 1 }
    if (distanceunits == 'km') { conversionfactor = 0.001 }
  }
  if (mapunits = "feet") {
    if (distanceunits == 'ft') { conversionfactor = 1 }
    if (distanceunits == 'mi') { conversionfactor = 0.0001894 }
    if (distanceunits == 'm') { conversionfactor = 0.3048 }
    if (distanceunits == 'km') { conversionfactor = 0.0003048 }
  }
  distance = document.navtoolsform.lastdistancemeasured.value / 1

  newdistancereadout = Math.floor(100*distance * conversionfactor)/100

  distancereadout.innerHTML = newdistancereadout

}

function changeScale() {

  scaleunit = document.navtoolsform.scaleunit.value
  scalenumber = document.navtoolsform.scalenumber.value
  if (scalenumber > 0) {
    document.navtoolsform.scalenumber.value = scalenumber
  }
  if (isFloat(scalenumber,false)) {

  if (scaleunit == 'ft') { conversionfactor = 12 }
  if (scaleunit == 'mi') { conversionfactor = 63360 }
  if (scaleunit == 'me') { conversionfactor = 39.37 }
  if (scaleunit == 'km') { conversionfactor = 39370 }

  if (scaleunit != 'in') { proportionalscalenumber = scalenumber * conversionfactor }
  if (scaleunit == 'in') { proportionalscalenumber = scalenumber }

  rightCoord = main_map_frame.document.mainmapform.theRight.value / 1
  leftCoord = main_map_frame.document.mainmapform.theLeft.value / 1
  topCoord = main_map_frame.document.mainmapform.theTop.value / 1
  bottomCoord = main_map_frame.document.mainmapform.theBottom.value / 1
  oldscalenumber = main_map_frame.document.mainmapform.theScale.value / 1

  newLeft = ((rightCoord - leftCoord)/2 + leftCoord) - (((rightCoord - leftCoord) * (proportionalscalenumber/oldscalenumber))/2)
  newRight = ((rightCoord - leftCoord)/2 + leftCoord) + (((rightCoord - leftCoord) * (proportionalscalenumber/oldscalenumber))/2)
  newBottom = ((topCoord - bottomCoord)/2 + bottomCoord) - (((topCoord - bottomCoord) * (proportionalscalenumber/oldscalenumber))/2)
  newTop = ((topCoord - bottomCoord)/2 + bottomCoord) + (((topCoord - bottomCoord) * (proportionalscalenumber/oldscalenumber))/2)

  action = "locationchange"
  specifiedlocationURL = '&zoomtype=interactive&theLeft=' + newLeft + '&theRight=' + newRight + '&theTop=' + newTop + '&theBottom=' + newBottom
  sendMapURL(specifiedlocationURL)
  }
}


function currentScale() {

  scaleunit = document.navtoolsform.scaleunit.value
  scalenumber = document.navtoolsform.scalenumber.value

  if (scaleunit == 'ft') { conversionfactor = 12 }
  if (scaleunit == 'mi') { conversionfactor = 63360 }
  if (scaleunit == 'me') { conversionfactor = 39.37 }
  if (scaleunit == 'km') { conversionfactor = 39370 }

  if (scaleunit != 'in') { proportionalscalenumber = scalenumber * conversionfactor }
  if (scaleunit == 'in') { proportionalscalenumber = scalenumber }

  specifiedScaleURL = '&theScale=' + proportionalscalenumber

}


function createFigure(reportID,season,xyear) {

  createFigureWindow = window.open('create_figure.asp?reportID=' + reportID,'createFigureWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=470,height=380,left=100,top=100') 
  createFigureWindow.focus()

}


function geocodefunction() {

  geocodeWindow = window.open('geocode.html','geocodeWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=430,height=180,left=100,top=100') 
  geocodeWindow.focus()

}


function sendPrintMapURL() {

	projectname = createfigureform.projectname.value
	projectlocation = createfigureform.projectlocation.value
	title1 = createfigureform.title1.value
	title2 = createfigureform.title2.value
	prjnum = createfigureform.prjnum.value
	figdate = createfigureform.figdate.value
	fignum = createfigureform.fignum.value
	scalebarunit = createfigureform.scalebarunit.value
	theFigureOptionsURL = "&theProjectName=" + projectname + "&theProjectLocation=" + projectlocation + "&theTitle1=" + title1 + "&theTitle2=" + title2 + "&thePrjnum=" + prjnum + "&theFigdate=" + figdate + "&theFignum=" + fignum + "&theScalebarunit=" + scalebarunit

	specifiedlayersURL = opener.document.navtoolsform.printlayersurl.value

	theScale = opener.main_map_frame.document.mainmapform.theScale.value
	theTop = opener.main_map_frame.document.mainmapform.theTop.value
	theBottom = opener.main_map_frame.document.mainmapform.theBottom.value
	theLeft = opener.main_map_frame.document.mainmapform.theLeft.value
	theRight = opener.main_map_frame.document.mainmapform.theRight.value
	theSpecifiedLocationURL = "&theTop=" + theTop + "&theBottom=" + theBottom + "&theLeft=" + theLeft + "&theRight=" + theRight + "&theScale=" + theScale

	thePrintPageWindow = window.open('map_functions.asp?task=printmap&zoomtype=interactive' + specifiedlayersURL + theSpecifiedLocationURL + theFigureOptionsURL,'thePrintPageWindow','toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=yes,width=800,height=600,left=150,top=150') 
	thePrintPageWindow.focus()

}

