<!--
//(c) 2006 Zonum Solutions
//Last modified: April 6, 2007
//Digipoint library 



 function resize_map()
 {
 
  var info = new zget_winsize();
  var xw = 600;
  var xh = 500;

  if(info.clientWidth>600) {xw = info.clientWidth - 205;}
  if(info.clientHeight>300) {xh = info.clientHeight - 57;}

  
  zset_resize("toc",200,xh-37);
  zset_resize("map",xw,xh);
  document.toclist.pts.style.height = ""+(xh-155)+"px";
  //var obj =zdoc_get("disclaimer");
  //obj.style.top = ""+(xh-113)+"px";

 // var obj =zdoc_get("ptscount");
 // obj.style.top = ""+(xh-130)+"px";

  var obj =zdoc_get("adBottom");
  obj.style.top = ""+(xh-122)+"px";

 }

 function initMap()
  {
     window.resizeTo(screen.availWidth,screen.availHeight);
     window.moveTo(0, 0);
     resize_map();
     var obj =zdoc_get("message");
     if(!es_MSI()) { obj.style.left = "625px";}

     map = new GMap2(document.getElementById("map"));
     //map.addControl(new GMapTypeControl());    
     map.addControl(omc);       
     map.addControl(smc);
     map.addControl(sc);

       
      GEvent.addListener(map, "click",
                                       function(overlay, point) {
                                          zmapclick(overlay, point);
        });
      GEvent.addListener(map, "mousemove", function(point) {zmouse_move(point);}); 
      

       map.setCenter(new GLatLng(24, 0), 3);
      map.enableContinuousZoom();
     map.enableScrollWheelZoom();
       
       //GE_GetPt_Symbols_List(document.frGeo.ComboSymbol); 
       zweb_setindex(document.frGeo.ComboSymbolSize,1);
      app_setIcon(zIconId);
     appNews();
  }



 function app_changeAction()
 {
   optAction = zweb_listIndex(document.frGeo.clickopts);
   lastMensaje="";
 } 


 function app_elevationMode()
 {
  AddElevation = document.frElev.storeElev.checked;
 }


 function getcoordsMouse(point,showUTM)
 { 
   var outcoo = "";
   if(showUTM==true) {
       UTMZone = zGeo_calcUTMZone(point.lng());
       outcoo = zGeo_LatLon2UTM2(UTMZone,point.lat(),point.lng(),", ");
       outcoo = outcoo + " Zone " +UTMZone; 
   } else {outcoo = "Lat/Lon: "+point.toUrlValue();}
  return outcoo;
 } 


 function getDMS(coo)
 {
  coo = "f" + coo;
  var x = coo.indexOf('.');
  var degree = coo.substring(1,x);
  coo = coo.substring(x,coo.length);

  coo = parseFloat(coo)*60.0;
  coo = "" + coo;
  x = coo.indexOf('.');
  var min = coo.substring(1,x);
  coo = coo.substring(x,coo.length);

  coo = parseFloat(coo)*60.0;
  var seg = "" + coo.toFixed(1);
   
  degree = degree + "&deg; "+min+"' "+seg+'"';

  return degree
  
 }


 function zmouse_move(point)
 {
   if(lastMensaje=="") {
   if(optAction<2) {
   var line = "";

   if(CursorOpt==2) {
    line = getDMS(point.lat())+" &nbsp;&nbsp;"+getDMS(point.lng());
    } else {
      var showUTM = (CursorOpt==0);
      line = getcoordsMouse(point,showUTM);
   }

   document.getElementById("message").innerHTML = line; 
  }
  }
 }

 function appComments()
 { 
  zfr_comments('Digipoint');
 }

 function appAbout()
 {
   var MSG = "<center><b>DigiPoint</b><br>Digitize and export your XYZ values";
   MSG+="<br>Build: 2-5.6.07<br><br>(c) 2006-2007 Zonum Solutions</center>";
   zwin_msgbox("About",300,110,"","",MSG);
 }


 function appNews()
 {
   var MSG = "<center><b>DigiPoint 2</b>&nbsp;&nbsp;&nbsp;&nbsp;Build: 2-5.6.07<br><br>What's new...</center>";
   MSG+="<br>* New formats: SHP, GPX and KML<br>";
   MSG+="* New Features: Elevations, Point edition and deleting<br>";
   MSG+="* Pointer: Decimal degrees, Deg-Min-Sec and UTM<br>* Icons selection box, Mouse wheel zooming";
   MSG+='<br><br><center>Old version is still available <a href="digipoint1.html">DigiPoint 1</a></center>';
   zwin_msgbox("News",310,180,"","",MSG);
 }


 function app_changeicon()
 {
  document.getElementById("message").innerHTML ="Retrieving Icons List...";
  GE_SelectIcon('app_setIcon',zIconId);
  document.getElementById("message").innerHTML ="";
 }

 function app_setIcon(Id)
 { zIconId = parseInt(""+Id);
   zIconName = GE_Icon_GetUrl(zIconId);
  var obj = zdoc_get("GE_Symbol");
  obj.innerHTML = '<img border="0"  width="24px" height="24px" src="'+GE_Icon_GetUrl(zIconId)+'" alt="Click here to change Icon" />';
 }


 function appOptions()
 {
  var xwidth = 400;
  var yheight = 120;
  var wc = new zget_centerwin(xwidth,yheight);
  
  zset_win1("<b>&nbsp;Options</b>",wc.left,wc.top,xwidth,yheight,"#eff3f7","#0956A6");

  var obj = zdoc_get("zfrwin");
  var cadena ='<div style="position:absolute; left:2px; top:0px; width:395px; height:90px;font-family: Arial, Helvetica, sans-serif; font-size: 9pt;overflow:auto;"/>';

   cadena +='<form name="frCoo">';
   cadena +='<fieldset style="width:370px"><Legend> Export Coordinate System</Legend>';
   cadena +='<select name="Geosystem" onClick="enabledUTM()">';
   cadena +='<option value="item">UTM</option> <option value="item">Lat/Lon</option></select>';
   cadena +='<select name="UTMZone"></select>';
   cadena +='<input type="button" name="btUTMGrid" value="?" onClick="web_zlink(UTM_GRID)"/>';
   cadena +='&nbsp;&nbsp;<select name="Hemisp">';
   cadena +='<option value="item">Northern Hemisphere</option> <option value="item">Southern Hemisphere</option></select>';
   cadena +='</fieldset>';
  
   cadena +='<div style="position:absolute; left:3px; top:60px;">';    
   cadena +='Elevation&nbsp;<select name="Elev">';
   cadena +='<option value="item">Meters</option> <option value="item">Feet</option></select>';
   cadena +='&nbsp;Pointer&nbsp;<select name="Cursor">';
   cadena +='<option value="item">UTM</option> <option value="item">Lat/Lon</option><option value="item">D:M:S</option></select>';
   cadena +='&nbsp;&nbsp;&nbsp;';
   cadena +='<input type="button" name="btAccept" value="Accept" onClick="appAccept_Export()"/>';
   cadena +='<input type="button" name="btCancel" value="Cancel" onClick="zclose_zwin()"/></div></form></div>';

   obj.innerHTML = cadena;
   AddUTMZones();
   zweb_setindex(document.frCoo.UTMZone,UTMZoneOpt-1);
   zweb_setindex(document.frCoo.Geosystem,LatLonOpt-1);
   zweb_setindex(document.frCoo.Hemisp,HemispOpt-1);
   zweb_setindex(document.frCoo.Elev,ElevUnits-1);
   zweb_setindex(document.frCoo.Cursor,CursorOpt);
   enabledUTM();
 
 }


 function appAccept_Export()
 {
   UTMZoneOpt = zweb_listIndex(document.frCoo.UTMZone) +1;
   LatLonOpt = zweb_listIndex(document.frCoo.Geosystem) +1;
   HemispOpt = zweb_listIndex(document.frCoo.Hemisp) +1 ;
   ElevUnits = zweb_listIndex(document.frCoo.Elev) + 1;
   CursorOpt = zweb_listIndex(document.frCoo.Cursor);

   zclose_zwin();
  }


function action_renamepoint(overlay)
 {
    zfindnode(overlay.title);
    document.getElementById("message").innerHTML = "Selection: "+overlay.title;
    var index = zweb_listIndex(document.toclist.pts);
    if(index>-1) {
    
      var Pt_Name = document.toclist.pts.options[index].text;
      Pt_Name = Pt_Name.split("[")[0];    

    var xwidth = 250;
    var yheight = 95;
    var wc = new zget_centerwin(xwidth,yheight);
  
    zset_win1("<b>&nbsp;Change Point Label</b>",wc.left,wc.top,xwidth,yheight,"#eff3f7","#0956A6");

    var obj = zdoc_get("zfrwin");
    var cadena ='<div style="position:absolute; left:2px; top:0px; width:245px; height:85px;font-family: Arial, Helvetica, sans-serif; font-size: 9pt;overflow:auto;"/>';

   cadena +='<form name="frEdit">';
   cadena +='Label <input type="text" name="PointName" style="width:200px" value="'+Pt_Name+'"><br><br>';

   cadena +='<input type="button" name="btAccept" value="Accept" onClick="app_accept_name('+index+')"/>';
   cadena +='<input type="button" name="btCancel" value="Cancel" onClick="zclose_zwin()"/></form></div>';

   obj.innerHTML = cadena;

      }       
 }


 function app_accept_name(index)
 {
   var Name2 = document.frEdit.PointName.value;
   zclose_zwin();
  
   var OldName = document.toclist.pts.options[index].text;
   OldName = "["+OldName.split("[")[1];    
   Name2 = Name2+OldName;
   document.toclist.pts.options[index].text = Name2;
 }



 function AddUTMZones()
 {
  var UTMList = document.frCoo.UTMZone;
  for (i=1; i<61; i++){
  UTMList.options[UTMList.options.length]=new Option("Zone "+i,"Zone");
  }
  UTMList.options.selectedIndex = 11;
 }

 function enabledUTM()
 {
  var index = document.frCoo.Geosystem.options.selectedIndex;
  var showUTM = false;
  if(index==1) {showUTM = true;}
  
  document.frCoo.UTMZone.disabled = showUTM;
  document.frCoo.btUTMGrid.disabled = showUTM;
  document.frCoo.Hemisp.disabled = showUTM;
  if(showUTM==false) {document.getElementById("message").innerHTML = "Export Coordinates as UTM (meters)";}
  else {document.getElementById("message").innerHTML = "Export Coordinates as Lat/Lon";} 
 }

 function changeSymbol()
  {

   zIconName = GE_Icon_GetUrl(zIconId);
  }


function getcoords(text,sp,SendUTM,i,modo)
 { 
  var ylat = text.split(",")[0];
  var xlon = text.split(",")[1];
    
    ylat = parseFloat(ylat);
    xlon = parseFloat(xlon);
  
  if(SendUTM) {    
    outcoo = zGeo_LatLon2UTM(UTMZone,ylat,xlon,sp);
    xlon = parseFloat(outcoo.split(sp)[0]);
    ylat = parseFloat(outcoo.split(sp)[1]);
  } else {
   if(modo==1) {outcoo = xlon + sp +ylat}
    else {outcoo = ylat +sp+xlon;}
  }

  if(i==0){
    EXMin=xlon;
    EXMax=xlon;
    EYMin=ylat;
    EYMax=ylat;
  }else{
   if(xlon<EXMin) {EXMin=xlon}
   if(xlon>EXMax) {EXMax=xlon}
   if(ylat<EYMin) {EYMin=ylat}
   if(ylat>EYMax) {EYMax=ylat}; 
  }
  return outcoo;

 } 


function get_gpxheader()
 {
  var cadena = '<?xml version="1.0" encoding="utf-8" ?>\n';
   cadena +='<gpx version="1.0" creator="www.zonums.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
   cadena +='xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">\n';
  return cadena
 }


 function get_kmlheader()
 {
  var Linea = '<?xml version="1.0" encoding="UTF-8"?>';
   Linea +='<kml xmlns="http://earth.google.com/kml/2.0">';
   Linea +='<Document><name>DigiPoint</name>'; 

   return Linea
 }


 function get_anuncio()
 {
   var xCad = "";
 
xCad ='<div id="adBottom2" style="position:absolute; left:0px; top:300px;width:469px;height:60px;overflow:hidden;">\n<!--$begin html$-->';
   xCad += '<script type="text/javascript"><!--\n';
   xCad +='google_ad_client = "pub-3234906288040413";';
   
xCad +='google_ad_width = 468;';
xCad +='google_ad_height = 60;';
xCad +='google_ad_format = "468x60_as";';
xCad +='google_ad_type = "text_image";';
xCad +='google_ad_channel = "";';
xCad +='google_color_border = "FFFFFF";';
xCad +='google_color_bg = "E6E6E6";';
xCad +='google_color_link = "0000FF";';
xCad +='google_color_text = "000000";';
xCad +='google_color_url = "008000";';
xCad +='\n //--></script>\n';
xCad +='<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
xCad +='<!--$end html$--></div>';
   
   return xCad
 }



 function web_resultado(FormatOut,sp)
 {
   
   var data = document.toclist.pts;
   var modo = 1;
   if(FormatOut=="GPX") {SendUTM=false; modo=2;} else {SendUTM = (LatLonOpt==1);}
   if(FormatOut=="KML") {SendUTM=false;}


   UTMZone = UTMZoneOpt;

   var line = "";
   nw = window.open("","x","width=515,height=405,scrollbars");
   nw.title = "pagina";   
   nwd = nw.document;
   wn = nwd.write;
   nwd.write('<html><head><title>DigiPoint</title>');
   nwd.write('<meta name="keywords" content="Zmaps, Google Maps, Mapping, retrieve elevation, DEM, elevation, distance, ESRI">');
   nwd.write('</head>');
   nwd.write('<body  bgcolor="#f8f8f6"  style="font-family: Arial, Helvetica, sans-serif; font-size: 9pt">');
   nwd.write('<b>'+FormatOut+' Point Coordinates File</b><br>');
   nwd.write('Select all the data and copy/paste it into a textfile\n');
   nwd.write('(you could use NOTEPAD) and save the file with the '+FormatOut+' extension.\n');

  if(FormatOut=="KML") {nwd.write('This is a simple KML generator, for better results use <a href="xykml.html">xy2kml</a>');}

   //nwd.write('If you would like to receive the file by email, input your\n');
   //nwd.write('email address and click the SEND button.\n');
   nwd.write('<form name="dataform" method=POST action = "data_sendmail.php">');
   //nwd.write('&nbsp;Email &nbsp;');
   //nwd.write('<input type="text" name="email" style="width: 300px">&nbsp;');
   //nwd.write('<input type="submit" name="submit" value="Send"/>');
   

if(es_MSI()) {
   nwd.write('<textarea name="datamemo" rows="5" cols="10" style="width:470px; height:240px" >');
   } else {
   nwd.write('<textarea name="datamemo" rows="5" cols="10" style="width:490px; height:335px" >');
   }
       
   var Pt_Name ="";
   var Pt_Icon ="";
   var Elevation = "";
   if(AddElevation==true) {Elevation = "" +sp+"Elevation ("+getElevUnits()+")";}
   
   
   if(FormatOut=="DXF") {nwd.write('\n0\nSECTION\n2\nENTITIES\n');}
   if(FormatOut=="GPX") {
     sp='" lon="';
      nwd.write(""+get_gpxheader());
   }
   if(FormatOut=="KML") {nwd.write(""+get_kmlheader());}

   if(FormatOut=="TXT" || FormatOut=="TAB" || FormatOut=="CSV") {
     nwd.write('DigiPoint Export:\n');
     if(SendUTM) {
        nwd.write('Units: UTM(meters), Zone '+UTMZone+'\nDatum: WGS84\n\n');
        //nwd.write('Powered by Zonum Solutions\nwww.zonums.com\n');
        nwd.write('id'+sp+'XCoo'+sp+'YCoo'+Elevation+'\n');
       } else {
        nwd.write('Units: Lat/Lon (Decimal degrees)\nDatum: WGS84\n\n');
       // nwd.write('Powered by Zonum Solutions\nwww.zonums.com\n');
        nwd.write('id'+sp+'Longitude'+sp+'Latitude'+Elevation+'\n');
      }
     }

    

    for (i=0; i<data.options.length; i++){
      line = data.options[i].text;
      Pt_Name = line.split("]")[0]+"]";
      Pt_Icon = line.split("~")[1];

      line = line.split("]")[1];
      line = line.split("~")[0];

      if(AddElevation==false) {Elevation = "";} 
      else {Elevation = line.split(",")[2];}

      line = getcoords(line,sp,SendUTM,i,modo);
      

      if(FormatOut=="DXF" || FormatOut=="GPX" || FormatOut=="KML") {
        if(FormatOut=="DXF") {nwd.write('0\nPOINT\n8\n\zPoints\n10\n'+line+'\n30\n0.0\n');}
         else {
          if(FormatOut=="GPX") {
            if(AddElevation==false) {Elevation = '<elev>'+Elevation+'</elev>\n';} 
             nwd.write('<wpt lat="'+line+'">\n<name>'+Pt_Name+'</name>\n'+Elevation+'</wpt>\n');
          } else {
           nwd.write('<Placemark><name>'+Pt_Name+'</name><Point><coordinates>'+line+',0</coordinates></Point></Placemark>\n');
          }
       }
      } else {
        if(FormatOut=="BLN") {nwd.write('1,1,'+Pt_Name+'\n'+line+'\n');
          } else {
           if(AddElevation==true) {Elevation = sp+getElevConv(Elevation);}
           nwd.write(Pt_Name+sp+line+Elevation+'\n');
          }
     }
   }

   if(FormatOut=="DXF") {nwd.write('0\nENDSEC\n0\nEOF');}
   if(FormatOut=="GPX") {nwd.write('</gpx>');}
   if(FormatOut=="KML") {nwd.write('</Document></kml>');}

 
   nwd.write('</textarea>');
   nwd.write('</form>');

   if(es_MSI()) {nwd.write(" "+get_anuncio());}

   nwd.write('</body></html>');
 }



 function prepareSHP(sp)
 {
  hide_shp(false);
  var data = document.toclist.pts;
  var modo = 1;
 
  UTMZone = UTMZoneOpt;
  SendUTM = (LatLonOpt==1);


   var Pt_Name ="";
   var Pt_Icon ="";
   var Elevation = "";
   

  var line = "";
  var memodata = "";

  for (i=0; i<data.options.length; i++){
      line = data.options[i].text;
      Pt_Name = line.split("]")[0]+"]";
      Pt_Icon = line.split("~")[1];

      line = line.split("]")[1];
      line = line.split("~")[0];

      if(AddElevation==false) {Elevation = "";} 
      else {Elevation = line.split(",")[2];}

      line = getcoords(line,sp,SendUTM,i,modo);
      
      if(AddElevation==true) {Elevation = sp+getElevConv(Elevation);}
       else {Elevation = sp+"0.000";}

      line = Pt_Name+sp+line+sp+Pt_Icon+Elevation;

      if(memodata=="") { memodata = line;}
       else {memodata += "\n"+line;}
  }

  var xfr= window.frames['framewin'].document;
   xfr.forma.datamemo.value = memodata;
   if(SendUTM==true) { xfr.forma.co_sys.value ="WGS84, UTM (meters) Zone "+UTMZone;}
   else {xfr.forma.co_sys.value = "WGS84, Lat/Lon";}

   {xfr.forma.co_elev.value = ""+getElevUnits();}
   xfr.forma.co_box.value = ""+EXMin+"|"+EYMin+"|"+EXMax+"|"+EYMax; 

 }

 function clearnodes()
   {
     juncid = 0;
     document.toclist.pts.options.length = 0;
     document.getElementById("ptscount").innerHTML = "";
     map.clearOverlays()
     lastMensaje="";
   }

 function selectPtList()
 {
   var combolist=document.toclist.pts;  
   if(combolist.options.length>0) {
    
    var Index = combolist.options.selectedIndex
    var cadena = combolist.options[Index].text
     document.getElementById("message").innerHTML = cadena; 
   }
    
 }

 function deletenode()
  {
    var combolist=document.toclist.pts;
    var Index = combolist.options.selectedIndex
    if(Index>-1) { 
     var cadena = combolist.options[Index].text
     combolist.options[Index]=null
     document.getElementById("message").innerHTML = "Deleted: "+cadena;
     document.getElementById("ptscount").innerHTML = "&nbsp;&nbsp;Nodes: "+ combolist.options.length;
    }
   }



function exportfile(FormatOut,sp)
  {
    var combolist=document.toclist.pts;
    if(combolist.options.length>0) { 
     document.getElementById("message").innerHTML = "Processing data... Wait";
     if(FormatOut=="SHP") {prepareSHP(sp);}
     else { web_resultado(FormatOut,sp);}

     document.getElementById("message").innerHTML = "Project was processed";  
    } else {alert ("Project is empty, click over the map to add points");};
  }

function changemaptype(newtype)
 {
  map.setMapType(newtype);
  document.getElementById("message").innerHTML = "Map style has changed";
 }

 function changezscale()
  {
  var svisible = document.frGeo.scalebar.checked;
  if(svisible) {
     map.addControl(sc);
     document.getElementById("message").innerHTML = "MapScale Control: on";
   } else {
     map.removeControl(sc);
     document.getElementById("message").innerHTML = "MapScale Control: off";
   }
 }

 function changezoview()
 {
  var svisible = document.frGeo.overviewmap.checked;
  if(svisible) {
    map.addControl(omc);
    document.getElementById("message").innerHTML = "Overview Map: on";
   } else { 
    map.removeControl(omc);
    document.getElementById("message").innerHTML = "Overview Map: off";
  }
 }

 function changezzoom()
  {
  var svisible = document.frGeo.zoompan.checked;
  if(svisible) {
    map.addControl(smc);
   document.getElementById("message").innerHTML = "Zoom Control: on";
   } else { 
   document.getElementById("message").innerHTML = "Zoom Control: off";
    map.removeControl(smc);
  }
}




 function action_elevation(point)
 { 
  
  doGetElevation(point.y,point.x);
 }


 function action_addpoint(point)
 {
   var PointName = document.toclist.PointName.value;
   var output = "";

        if(PointName=="") {
            //if(zIconId=="DEFAULT") {PointName=" ";}
            // else {PointName=zIconId;};
         }
   
          icon.image = zIconName;
          GE_Icon_SetSizeCombo(document.frGeo.ComboSymbolSize,icon);
          var myMarker = new GMarker(point,icon); 
          
          juncid = juncid + 1;
          output = PointName + "[" + juncid + "]"; 
          myMarker.title = output;
          map.addOverlay(myMarker); 
          output =  output + " " + point.toUrlValue()+",Elevation~            "+zIconId;
          
          var nodelist=document.toclist.pts;
          nodelist.options[nodelist.options.length]=new Option(output,"pt");
              
          document.getElementById("ptscount").innerHTML = "&nbsp;&nbsp;Points: "+ nodelist.options.length;
          output = "Added: (" + point.toUrlValue() + ")";
          
         
    document.getElementById("message").innerHTML = output;     

 }


function action_addpoint2(point,Elev)
 {
   var PointName = document.toclist.PointName.value;
   var output = "";

        if(PointName=="") {
            //if(zIconId=="DEFAULT") {PointName=" ";}
            // else {PointName=zIconId;};
         }
   
         if(AddElevation==true) {point = new GLatLng(point.y, point.x);}
          
          icon.image = zIconName;
          GE_Icon_SetSizeCombo(document.frGeo.ComboSymbolSize,icon);
          var myMarker = new GMarker(point,icon); 
          
          juncid = juncid + 1;
          output = PointName + "[" + juncid + "]"; 
          myMarker.title = output;
          map.addOverlay(myMarker); 
          output =  output + " " + point.toUrlValue()+","+Elev+"~"+zIconId;
          
          var nodelist=document.toclist.pts;
          nodelist.options[nodelist.options.length]=new Option(output,"pt");
              
          document.getElementById("ptscount").innerHTML = "&nbsp;&nbsp;Points: "+ nodelist.options.length;
          output = "Added: (" + point.toUrlValue() + ")";
          
         
    document.getElementById("message").innerHTML = output;     

 }


 function action_delpoint(overlay)
 {
      zfindnode(overlay.title);
      document.getElementById("message").innerHTML = "Selection: "+overlay.title;
           
      var answer = confirm("Delete: "+overlay.title);
       if (answer){
               map.removeOverlay(overlay);
               deletenode();
      }
 }
 

 function zmapclick(overlay, point)
   {     
    
    app_elevationMode();
    app_changeAction();

     if(optAction==1) {
        if (overlay) {action_delpoint(overlay);}
     } else if (optAction==2) {
         if (overlay) {action_renamepoint(overlay);}
     } else if (point) {
           if(optAction==0) {
              if(AddElevation==false) {action_addpoint2(point,"0");}
              else {  
                lastpoint.x = point.x;
                lastpoint.y = point.y; 
                doGetElevation(point.y,point.x);
              }

             } else {action_elevation(point);}
     }    
     
   }



 function zmapextent()
        { 
         var center = map.getCenter();
          document.getElementById("message").innerHTML = "Hi";           
         
        }


 function zfindnode(nodeb)
 {
   var found = false;
   var nodelist=document.toclist.pts;
   var N = nodelist.options.length;
   var cadena = "";

   for(i = 0; i < N; i++){

     cadena = nodelist.options[i].text;
     a = cadena.indexOf(nodeb);
     if(a>-1) {
        found = true;
        nodelist.options.selectedIndex = i;
        break;
    }     
   }
 }
 

function zRequest(url)
{
  document.getElementById("message").innerHTML = "Wait...";
  lastMensaje="x";
  xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
else
  {document.getElementById("message").innerHTML = "Your browser does not support XMLHTTP.";
  }
}

function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
  {  
    parseElevation(xmlhttp.responseText);
    lastMensaje="";
  }
  else
  {document.getElementById("message").innerHTML = "Problem retrieving data:" + xmlhttp.statusText;
  }
  }
}

 function parseElevation_Old(TextData)
  {
  
   x = TextData.indexOf('XMLWebServices/');
   SubCad = TextData.substring(x+16,TextData.length);
   x = SubCad.indexOf('<');
   SubCad = SubCad.substring(1,x);

  if(optAction==0) {

    action_addpoint2(lastpoint,SubCad);
   } else {
     cadena = "Point Elevation = " + getElevConv(SubCad)+" "+getElevUnits();
     document.getElementById("message").innerHTML = cadena;
   }
  }
  
  function parseElevation(TextData)
  {
  
   x = TextData.indexOf('<double>');
   SubCad = TextData.substring(x+7,TextData.length);
   x = SubCad.indexOf('</');
   SubCad = SubCad.substring(1,x);

  if(optAction==0) {

    action_addpoint2(lastpoint,SubCad);
   } else {
     cadena = "Point Elevation = " + getElevConv(SubCad)+" "+getElevUnits();
     document.getElementById("message").innerHTML = cadena;
   }
  }
  


 function getElevUnits()
 {
   if(ElevUnits==1) {return "Meters";}
   else {return "Feet";}
 }

 function getElevConv(Elev)
 {
  Elev = parseFloat(Elev);

  if(ElevUnits==2) {Elev = Elev * 3.2808398950;}
  Elev = "" + Elev.toFixed(3);

  return Elev
 }




 function doGetElevation(lat,lon)
 {var Url = '';
  
  //alert("Query = "+lat+" "+lon);
var path = '/XMLWebServices2/elevation_service.asmx/getElevation?';

  path  +='X_Value='+lon+'&Y_Value='+lat+'&Elevation_Units=METERS&Source_Layer=-1&Elevation_Only=TRUE';

  Url =  'http://www.zonums.com/gmaps/elevserver2.php?yws_path=' + encodeURIComponent(path);
  //Url =  'http://www.zonums.com/prueba/gmaps/elevserver.php?yws_path=' + encodeURIComponent(path); 

  zRequest(Url);

 }

-->