﻿function updateEarthOptions() 
{
  if (gEarth != null)
  {
    var options = gEarth.getOptions();
    options.setGridVisibility($get('mec1').checked);
    options.setOverviewMapVisibility($get('mec2').checked);
  }
}

function updateEarthBuildings() 
{
  if (gEarth != null)
  {
    gEarth.getLayerRoot().enableLayerById(gEarth.LAYER_BUILDINGS, $get('mec3').checked);
  }
}  

function updateEarthBorders() 
{
  if (gEarth != null)
  {
    gEarth.getLayerRoot().enableLayerById(gEarth.LAYER_BORDERS, $get('mec4').checked);
  }
}  

function updateEarthClose()
{
  if (map != null)
  {
    map.setMapType(G_NORMAL_MAP);
    map.enableScrollWheelZoom();
    var z = map.getZoom();
    if (z > 17) map.setZoom(17);
  }
  
  var mec = $get('mec');
  if (mec != null)
  {
    mec.style.display = 'none';
  }
}  
  
  
function updateEarthGoto(ind)
{
  if (gEarth != null)
  {
    $get('mec3').checked = true;
    updateEarthBuildings();
    
    var cameraAt = gEarth.getView().copyAsCamera(gEarth.ALTITUDE_ABSOLUTE);
    switch (ind)
    {
      case 2:
        cameraAt.setLatitude(41.8905);
        cameraAt.setLongitude(12.4885);
        cameraAt.setAltitude(250);
        cameraAt.setTilt(50);
        cameraAt.setHeading(100);
        cameraAt.setRoll(0);
        break;
      case 3:
        cameraAt.setLatitude(40.6968);
        cameraAt.setLongitude(-74.0125);
        cameraAt.setAltitude(600);
        cameraAt.setTilt(50);
        cameraAt.setHeading(0);
        cameraAt.setRoll(0);
        break;
      default:
        cameraAt.setLatitude(46.077062810304885);
        cameraAt.setLongitude(18.223642623901367);
        cameraAt.setAltitude(300);
        cameraAt.setTilt(50);
        cameraAt.setHeading(0);
        cameraAt.setRoll(0);
        break;
      case 0:
        cameraAt.setLatitude(39.995);
        cameraAt.setLongitude(116.39);
        cameraAt.setAltitude(400);
        cameraAt.setTilt(50);
        cameraAt.setHeading(180);
        cameraAt.setRoll(0);
        break;
    }
    gEarth.getView().setAbstractView(cameraAt);
  }
}