// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var MiSituacion = null;
var Directions = null;
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var IconoLocalizacion = new GIcon();
IconoLocalizacion.image = "http://www.adeje.es/esp/img/icoadeje_maps.png";
IconoLocalizacion.iconSize = new GSize(39, 39);
IconoLocalizacion.iconAnchor = new GPoint(12, 39);
IconoLocalizacion.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var IconoEvento = new GIcon();
IconoEvento.image = "http://www.adeje.es/esp/img/icoadeje_maps.png";
IconoEvento.iconSize = new GSize(39, 39);
IconoEvento.iconAnchor = new GPoint(12, 39);
IconoEvento.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var IconoCalle = new GIcon();
//IconoCalle.image = "http://www.adeje.es/esp/img/icoadeje_maps_calles.png";
IconoCalle.image = "http://www.adeje.es/esp/img/11.png";
IconoCalle.iconSize = new GSize(39, 39);
IconoCalle.iconAnchor = new GPoint(12, 39);
IconoCalle.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var IconoMiSituacion = new GIcon();
IconoMiSituacion.image = "http://www.adeje.es/esp/img/maps_human.png";
IconoMiSituacion.iconSize = new GSize(33, 33);
IconoMiSituacion.iconAnchor = new GPoint(10, 33);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_1 = new GIcon();
Icono_1.image = "http://www.adeje.es/esp/img/1.png";
Icono_1.iconSize = new GSize(39, 39);
Icono_1.iconAnchor = new GPoint(12, 39);
Icono_1.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_2 = new GIcon();
Icono_2.image = "http://www.adeje.es/esp/img/2.png";
Icono_2.iconSize = new GSize(39, 39);
Icono_2.iconAnchor = new GPoint(12, 39);
Icono_2.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_3 = new GIcon();
Icono_3.image = "http://www.adeje.es/esp/img/3.png";
Icono_3.iconSize = new GSize(39, 39);
Icono_3.iconAnchor = new GPoint(12, 39);
Icono_3.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_4 = new GIcon();
Icono_4.image = "http://www.adeje.es/esp/img/4.png";
Icono_4.iconSize = new GSize(39, 39);
Icono_4.iconAnchor = new GPoint(12, 39);
Icono_4.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_5 = new GIcon();
Icono_5.image = "http://www.adeje.es/esp/img/5.png";
Icono_5.iconSize = new GSize(39, 39);
Icono_5.iconAnchor = new GPoint(12, 39);
Icono_5.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_6 = new GIcon();
Icono_6.image = "http://www.adeje.es/esp/img/6.png";
Icono_6.iconSize = new GSize(39, 39);
Icono_6.iconAnchor = new GPoint(12, 39);
Icono_6.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_7 = new GIcon();
Icono_7.image = "http://www.adeje.es/esp/img/7.png";
Icono_7.iconSize = new GSize(39, 39);
Icono_7.iconAnchor = new GPoint(12, 39);
Icono_7.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_8 = new GIcon();
Icono_8.image = "http://www.adeje.es/esp/img/8.png";
Icono_8.iconSize = new GSize(39, 39);
Icono_8.iconAnchor = new GPoint(12, 39);
Icono_8.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_9 = new GIcon();
Icono_9.image = "http://www.adeje.es/esp/img/9.png";
Icono_9.iconSize = new GSize(39, 39);
Icono_9.iconAnchor = new GPoint(12, 39);
Icono_9.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_10 = new GIcon();
Icono_10.image = "http://www.adeje.es/esp/img/10.png";
Icono_10.iconSize = new GSize(39, 39);
Icono_10.iconAnchor = new GPoint(12, 39);
Icono_10.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_11 = new GIcon();
Icono_11.image = "http://www.adeje.es/esp/img/11.png";
Icono_11.iconSize = new GSize(39, 39);
Icono_11.iconAnchor = new GPoint(12, 39);
Icono_11.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Icono_12 = new GIcon();
Icono_12.image = "http://www.adeje.es/esp/img/12.png";
Icono_12.iconSize = new GSize(39, 39);
Icono_12.iconAnchor = new GPoint(12, 39);
Icono_12.infoWindowAnchor = new GPoint(12, 1);
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function BuscarCalle(){
	if ($('#busqueda_calle').val() != ''){
		if ($('#busqueda_calle').val().length >= 4){
			$.get('ajax_buscador_callejero.asp?calle=' + $('#busqueda_calle').val(), 
			      function(data){
					  $('#capa_resultados_buscador_calles').html(data);				  
					  $('#capa_resultados_buscador_calles').slideDown('fast');
			});		
		}else{
			alert('Mínimo 4 carácteres.');
			$('#busqueda_calle').focus();
		}
	}
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function MostrarCalle(calle, TipoVia){
	$('#map').jmap('SearchAddress', {
            'query': TipoVia + ' ' + calle + ', Adeje, España',
            'returnType': 'getLocations'
    }, function(result, options) {            
            var valid = Mapifies.SearchCode(result.Status.code);
            if (valid.success) {
            	$.each(result.Placemark, function(i, point){
                $('#map').jmap('AddMarker',{
                        'pointLatLng':[point.Point.coordinates[1], point.Point.coordinates[0]],
                        'pointHTML':point.address,
						'centerMap':true,
						'centerMoveMethod':'pan',
						'pointIcon': IconoCalle
                        });
                });				
            } else {
                alert('No se ha encontrado la dirección');
            }
    });
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var capa_panoramio = new GLayer("com.panoramio.all"); 
var capa_wikipedia = new GLayer("org.wikipedia.es"); 
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function MostrarPanoramio(){
	var thisMap = Mapifies.MapObjects.Get('#map');
	thisMap.addOverlay(capa_panoramio); 
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function OcultarPanoramio(){
	var thisMap = Mapifies.MapObjects.Get('#map');
	thisMap.removeOverlay(capa_panoramio); 
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function MostrarWikipedia(){
	var thisMap = Mapifies.MapObjects.Get('#map');
	thisMap.addOverlay(capa_wikipedia); 
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function OcultarWikipedia(){
	var thisMap = Mapifies.MapObjects.Get('#map');
	thisMap.removeOverlay(capa_wikipedia); 
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function MostrarEventos(){
	OcultarEventos();
	$.getScript('ajax_eventos_en_callejero.asp');
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function OcultarEventos(){
	var thisMap = Mapifies.MapObjects.Get('#map');	
	thisMap.clearOverlays();
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function MostrarLoc(idcat){
	OcultarEventos();
	
	if (idcat != ''){
		$.getScript('ajax_localizaciones_en_callejero.asp?idcat=' + idcat);
	}
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
function UbicarMiSituacion(){
	var thisMap = Mapifies.MapObjects.Get('#map');
	
	if (MiSituacion != null){		
		thisMap.removeOverlay(MiSituacion);
		MiSituacion = null;
	}
	
	MiSituacion = new GMarker(thisMap.getCenter(), {icon:IconoMiSituacion, draggable: true});	
	thisMap.addOverlay(MiSituacion);
	
	Directions = new GDirections(thisMap);
	var txt = 'from: ' + MiSituacion.getLatLng() + ' to: 28.122752,-16.724217';
	txt = txt.replace('(', '');
	txt = txt.replace(')', '');
	alert(txt);
    Directions.load(txt);

}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
