﻿
        var map = null;
        var mapUser = null;
        var SLMain = null;
        var shape=null;   
        
        function GetMap() 
        {
           document.getElementById("loader").style.display = "none";
           document.getElementById("ctl00_CuerpoMarco_SLPluggin").style.display = "block";
           map = new VEMap('divMap');
           map.LoadMap();
           mapUser = new VEMap('divMapUser');
           mapUser.LoadMap();
        }

        function innerGoToLatLong(lat, lon, zoom, objMap, fn) {
            objMap.SetMapStyle(VEMapStyle.Road);
            objMap.SetCenterAndZoom(new VELatLong(lat, lon), zoom);   
            var timeOut = null;
            while (!objMap.AllTilesLoaded()) 
            {
                if (timeOut != null)
                    clearTimeout(timeOut);
                timeout = setTimeout("doNothing()", 1);
            }
            setTimeout(fn, 2000);
         }

        function innerZoom(objMap, zoomLevel, fn) {
            objMap.SetZoomLevel(zoomLevel);
            var timeOut = null;
            while (!objMap.AllTilesLoaded()) 
            {
                if (timeOut != null)
                    clearTimeout(timeOut);
                timeout = setTimeout("doNothing()", 1);
            }
            setTimeout(fn, 2000);
        }
        
         function innerCambiarEstiloMapa(objMap, fn) 
         {
             objMap.SetMapStyle(objMap.GetMapStyle()==VEMapStyle.Road ? VEMapStyle.Aerial : VEMapStyle.Road);
             var timeOut = null;
             while (!objMap.AllTilesLoaded()) 
             {
                 if (timeOut != null)
                     clearTimeout(timeOut);
                 timeout = setTimeout("doNothing()", 1);
             }
             setTimeout(fn, 2000);
         }
         
         function goToLatLong(lat, lon, zoom)
         {
            innerGoToLatLong(lat, lon, zoom, mapUser, updateMap);            
         }
                  
         function goToLatLongIzq(lat, lon, zoom)
         {
            innerGoToLatLong(lat, lon, zoom, mapUser, updateMapIzq);
         }

         function goToLatLongPeriodista(lat, lon, zoom) 
         {
            innerGoToLatLong(lat, lon, zoom, map, updateMapPeriodista);
         }

        function Zoom(zoomLevel)
        {
            innerZoom(mapUser, zoomLevel, updateMap);
        }
        
        function ZoomIzq(zoomLevel)
        {
            innerZoom(mapUser, zoomLevel, updateMapIzq);
        }
                
        function ZoomPeriodista(zoomLevel) 
        {
            innerZoom(map, zoomLevel, updateMapPeriodista);
        }
               
         function updateMap()
         {
           document.getElementById("ctl00_CuerpoMarco_SLPluggin").content.SLMain.updateMap();
         }
         
         function updateMapIzq()
         {
           document.getElementById("ctl00_CuerpoMarco_SLPluggin").content.SLMain.updateMapIzq();
         }
         
         function updateMapPeriodista()
         {            
           document.getElementById("ctl00_CuerpoMarco_SLPluggin").content.SLMain.updateMapPeriodista();
         }

         function reportAbuse(userName, id) 
         {
             var subject = "Reporte de imagen indebida";
             var body = "Ruego revisen la imagen del usuario " + userName + " con id " + id;
             location.href = "mailto:incidenciasafrica@vivelive.com?subject=" + escape(subject) + "&body=" + escape(body);
         }

         function MostrarImagen(id) 
         {
             window.open("amaneceres/" + id + "_grande.jpg");
         }

         
         function CambiarEstiloMapaPeriodista() 
         {
             innerCambiarEstiloMapa(map, updateMapPeriodista);
         }

         function CambiarEstiloMapa() 
         {
             innerCambiarEstiloMapa(mapUser, updateMap);
         }

         function CambiarEstiloMapaIzq() 
         {
             innerCambiarEstiloMapa(mapUser, updateMapIzq);
         }
         
         function doNothing() { }
 
 