<!--
//
//


 function zGeo_WGS84_a()
 {
   return 6378137;
 }

 function zGeo_WGS84_f()
 {
  return 1/298.2572236;
 }

 function zGeo_Datumb(a,f)
 {
  return a-(a*f);
 }

 function zGeo_Datume2(f)
 {
  return 2*f-(f*f);
 }

 function zGeo_GetUTMZones(UTMList,Cad)
 {  
  if(Cad=="") {Cad = "UTM Zone ";}
  for (i=1; i<61; i++){
   UTMList.options[UTMList.options.length]=new Option(Cad+i,"Zone");
  }
  UTMList.options.selectedIndex = 11;
 }


function zGeo_calcUTMZoneOld(Longitude)
 {
  var Zone = 12;
  if(Longitude<0) {Zone=Math.round((180+Longitude)/6)+1}
    else {Zone=Math.round(Longitude/6)+31};



  if(Zone>60) {Zone =60;}
  if(Zone<1) {Zone=1;}
  return Zone
 }

function zGeo_calcUTMZone(Longitude)
 {
  var Zone = 12;
  var cadTXT = ""
  cadTXT = " "+Longitude;
  Longitude = Longitude + 180;
  if(Longitude<=0) {Longitude = 1;}
  if(Longitude>359) {Longitude = 359;}

  cadTXT +=" "+Longitude;

   Zone=""+ ((Longitude/6)+1);

   
   //x = Zone.indexOf('.');
   //Zone = Zone.substring(1,x-1);
   //document.getElementById("message").innerHTML = cadTXT+ " Zone = " +Zone;
   Zone = parseInt(Zone);
  
  if(Zone>60) {Zone =60;}
  if(Zone<1) {Zone=1;}

  return Zone
 }

function zGeo_LatLon2UTM_pt(UTMZone,Lat,Long)
 {
   var X = 0;
   var Y = 0;
     var isNorth = (Lat>0);
     

     ZoneCM=6*UTMZone-183;
     p=(Long-ZoneCM)*3600/10000;
     Lat=Lat*Math.PI/180;  
     Long=Long*Math.PI/180;  
     
     b=Datum_b;
     a=Datum_a;

     e2=Datum_e2;

     e=Math.sqrt(e2);
     e2p=e2/(1-e2);
     k0=0.9996;
     sin1=Math.PI/(180*60*60);
     nu=a/Math.sqrt(1-e2*Math.pow(Math.sin(Lat),2));

     n=(a-b)/(a+b);

     Ap=a*(1-n+(5/4)*(Math.pow(n,2)-Math.pow(n,3))+(81/64)*(Math.pow(n,4)-Math.pow(n,5)));
     Bp=(3*a*n/2)*(1-n+(7/8)*(Math.pow(n,2)-Math.pow(n,3))+(55/64)*(Math.pow(n,4)-Math.pow(n,5)));
     Cp=(15*a*Math.pow(n,2)/16)*(1-n+(3/4)*(Math.pow(n,2)-Math.pow(n,3)));
     Dp=(35*a*Math.pow(n,3)/48)*(1-n+(11/16)*(Math.pow(n,2)-Math.pow(n,3)));
     Ep=(315*a*Math.pow(n,4)/51)*(1-n);
     S=Ap*Lat-Bp*Math.sin(2*Lat)+Cp*Math.sin(4*Lat)-Dp*Math.sin(6*Lat)+Ep*Math.sin(8*Lat);
   
     K1=S*k0;
     K2=k0*Math.pow(sin1,2)*nu*Math.sin(Lat)*Math.cos(Lat)*100000000/2;
     K3=(k0*Math.pow(sin1,4)*nu*Math.sin(Lat)*Math.pow(Math.cos(Lat),3)/24)*(5-Math.pow(Math.tan(Lat),2)+9*e2p*Math.pow(Math.cos(Lat),2)+4*e2p*e2p*Math.pow(Math.cos(Lat),4))*10000000000000000;
   
     Y=K1+K2*Math.pow(p,2)+K3*Math.pow(p,4);
     if(isNorth==false) {Y=10000000+Y};
     
     K4=k0*sin1*nu*Math.cos(Lat)*10000;
     K5=(k0*Math.pow(sin1,3)*nu*Math.pow(Math.cos(Lat),3)/6)*(1-Math.pow(Math.tan(Lat),2)+e2p*Math.pow(Math.cos(Lat),2))*1000000000000;

     X=500000+K4*p+K5*Math.pow(p,3);

    this.CY = Y;
    this.CX = X;
  }
  

function zGeo_LatLon2UTM(UTMZone,Lat,Long,csp)
 {
   var X = 0;
   var Y = 0;

     ZoneCM=6*UTMZone-183;
     p=(Long-ZoneCM)*3600/10000;
     Lat=Lat*Math.PI/180;  
     Long=Long*Math.PI/180;  
     
     b=Datum_b;
     a=Datum_a;

     e2=Datum_e2;

     e=Math.sqrt(e2);
     e2p=e2/(1-e2);
     k0=0.9996;
     sin1=Math.PI/(180*60*60);
     nu=a/Math.sqrt(1-e2*Math.pow(Math.sin(Lat),2));

     n=(a-b)/(a+b);

     Ap=a*(1-n+(5/4)*(Math.pow(n,2)-Math.pow(n,3))+(81/64)*(Math.pow(n,4)-Math.pow(n,5)));
     Bp=(3*a*n/2)*(1-n+(7/8)*(Math.pow(n,2)-Math.pow(n,3))+(55/64)*(Math.pow(n,4)-Math.pow(n,5)));
     Cp=(15*a*Math.pow(n,2)/16)*(1-n+(3/4)*(Math.pow(n,2)-Math.pow(n,3)));
     Dp=(35*a*Math.pow(n,3)/48)*(1-n+(11/16)*(Math.pow(n,2)-Math.pow(n,3)));
     Ep=(315*a*Math.pow(n,4)/51)*(1-n);
     S=Ap*Lat-Bp*Math.sin(2*Lat)+Cp*Math.sin(4*Lat)-Dp*Math.sin(6*Lat)+Ep*Math.sin(8*Lat);
   
     K1=S*k0;
     K2=k0*Math.pow(sin1,2)*nu*Math.sin(Lat)*Math.cos(Lat)*100000000/2;
     K3=(k0*Math.pow(sin1,4)*nu*Math.sin(Lat)*Math.pow(Math.cos(Lat),3)/24)*(5-Math.pow(Math.tan(Lat),2)+9*e2p*Math.pow(Math.cos(Lat),2)+4*e2p*e2p*Math.pow(Math.cos(Lat),4))*10000000000000000;
   
     Y=K1+K2*Math.pow(p,2)+K3*Math.pow(p,4);
     
     K4=k0*sin1*nu*Math.cos(Lat)*10000;
     K5=(k0*Math.pow(sin1,3)*nu*Math.pow(Math.cos(Lat),3)/6)*(1-Math.pow(Math.tan(Lat),2)+e2p*Math.pow(Math.cos(Lat),2))*1000000000000;

     X=500000+K4*p+K5*Math.pow(p,3);

    return X+csp+Y;
  }

function zGeo_LatLon2UTM2(UTMZone,Lat,Long,csp)
 {
     
     var pt =  new zGeo_LatLon2UTM_pt(UTMZone,Lat,Long);
     var X = parseInt(""+pt.CX);
     var Y = parseInt(""+pt.CY);

     var isNorth = (Lat>0);
     var isWest = (Long<0);

    if(isWest==true) {X= "" + X +" W"; } else {X=""+X+" E";} 
    if(isNorth==true) {Y="" + Y +" N";} else {Y=""+Y+" S";}
    return X+csp+Y;
  }
-->