 
    
 
	//< ![CDATA[
	var markerGroups = { "fotos": [], "videos": [], "fotos3D": []};
	var panoramio = new GLayer("com.panoramio.all"); // Tambien existe com.panoramio.popular
	var wiki_ja = new GLayer("org.wikipedia.ja");
	var map = new GMap2(document.getElementById("map")); // nombre de la capa (div)
	
	function load() {
	  var mark;
	  var pointA;

	  if (GBrowserIsCompatible()) {
		// Creamos el mapa
		
		map.addControl(new GLargeMapControl()); // Botones zoom,...
		//map.addControl(new GOverviewMapControl()); // Vista previa abajo dcha
		//map.addControl(new GMapTypeControl()); // Mapa, satelite, hibrido
		// G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP

        // Incrustar un control de busqueda dentro del mapa
        map.addControl(new google.maps.LocalSearch());
		
		map.setCenter(new GLatLng(41.39432450769634, 2.1636199951171875), 15, G_NORMAL_MAP);

		// Mostramos la capa de fotos de panoramio
		map.addOverlay(panoramio);

		// Mostramos la capa de la wikipedia en japones
		map.addOverlay(wiki_ja);
		
/*		// lectura del archivo marcadores.fotos.xml con jQuery
		$.get('marcadores.fotos.xml',function(data) {  
			$(data).find('marker').each(function(){
				var lat    = $(this).attr('lat');  
				var lng    = $(this).attr('lng'); 
				
				var html   = '<span style="font-size:12px; font-family:Verdana">'; 
				html      += '<span style="font-size:14px; font-weight:bold">';
				html      += $(this).attr('titulo')+" </span><br />";
				html      += $(this).attr('texto')+"<br />";
				html      += '</span> <a href="';
				html      += $(this).attr('URLfotoGra');
				html      += '" target="_self"><img src="'+$(this).attr('URLfotoPeq')
				html      += '" border="0"  width="240" height="180" /></a>';

				var icon = new GIcon();
				icon.image = $(this).attr('URLfotoMiniatura');
				icon.iconSize = new GSize(40 ,40);
				icon.shadow = 'http://www.totteokiinfo.com/comunes/BotonesIzquierda/mapas/miniaturas/miniatura.shadow.40x40.png';
				icon.shadowSize=new GSize(80, 40);
				icon.iconAnchor = new GPoint(40/2, 1);
				icon.infoWindowAnchor = new GPoint(40/2, 15);
		
				var point  = new GLatLng(lat,lng);  
				var marker = new GMarker(point,icon);  

				map.addOverlay(marker);  
				markerGroups['fotos'].push(marker);

				GEvent.addListener(marker, "click", function() {  
				marker.openInfoWindowHtml(html);  
				});

			});

		});

*/
		
		// lectura del archivo marcadores.videos.xml con jQuery
		$.get('marcadores.videos.xml',function(data) {  
			$(data).find('marker').each(function(){
				var lat    = $(this).attr('lat');  
				var lng    = $(this).attr('lng'); 
				
				var html   = '<span style="font-size:12px; font-family:Verdana">'; 
				html      += '<span style="font-size:14px; font-weight:bold">';
				html      += $(this).attr('titulo')+" </span><br />";
				html      += $(this).attr('texto')+"<br />";
				html      += '</span> <embed src="';
				html      += $(this).attr('URLVideo');
				html      += '" type="application/x-shockwave-flash" wmode="transparent"'
				html      += 'width="320" height="265"></embed>'

				var icon = new GIcon();
				icon.image = $(this).attr('URLfotoMiniatura');
				icon.iconSize = new GSize(40 ,40);
				icon.shadow = 'http://www.totteokiinfo.com/comunes/BotonesIzquierda/mapas/miniaturas/miniatura.shadow.40x40.png';
				icon.shadowSize=new GSize(80, 40);
				icon.iconAnchor = new GPoint(40/2, 1);
				icon.infoWindowAnchor = new GPoint(40/2, 15);
		
				var point  = new GLatLng(lat,lng);  
				var marker = new GMarker(point,icon);  

				map.addOverlay(marker);
				markerGroups['videos'].push(marker);

				GEvent.addListener(marker, "click", function() {  
					marker.openInfoWindowHtml(html);  
				});

			});

		});

		// lectura del archivo marcadores.3D.xml con jQuery
		$.get('marcadores.3D.xml',function(data) {  
			$(data).find('marker').each(function(){
				var lat    = $(this).attr('lat');  
				var lng    = $(this).attr('lng'); 
				var URLDestino = $(this).attr('URLfotoGra');

				var icon = new GIcon();
				icon.image = $(this).attr('URLfotoMiniatura');
				icon.iconSize = new GSize(40 ,40);
				icon.shadow = 'http://www.totteokiinfo.com/comunes/BotonesIzquierda/mapas/miniaturas/miniatura.shadow.40x40.png';
				icon.shadowSize=new GSize(80, 40);
				icon.iconAnchor = new GPoint(40/2, 1);
				icon.infoWindowAnchor = new GPoint(40/2, 15);

		
				var point  = new GLatLng(lat,lng);  
				var marker = new GMarker(point,icon);  

				map.addOverlay(marker);
				markerGroups['fotos3D'].push(marker);

				GEvent.addListener(marker, "click", function() {  
					//marker.openInfoWindowHtml(html);
					window.location=URLDestino;
				});

			});

		});


	  }		
	}



    function toggleGroup(type,checked) {
      if (type == 'panoramio'){
  	     if (checked) {
		    map.addOverlay(panoramio);
		 } else {
		    map.removeOverlay(panoramio);
		 }

	  } else if (type == 'wiki_ja'){
  	     if (checked) {
		    map.addOverlay(wiki_ja);
		 } else {
		    map.removeOverlay(wiki_ja);
		 }	  
	  } else {
	  
		  for (var i = 0; i < markerGroups[type].length; i++) {
			var marker = markerGroups[type][i];
			if (checked) {
			  marker.show();
			} else {
			  marker.hide();
			}
		  } 
	  }
    }
	
	//]]>
	load();
