 	var ytp;
	var map;
	var actual = -1;
	var longitud = 0;
	var actualMarker;
	var markerOptions;
	var params = { allowScriptAccess: "always", bgcolor: "#cccccc" };
	var atts = { id: "myytplayer" };
	

	function load() {
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("map"));
			map.setCenter(new GLatLng(48.86832824998009, 2.3424911499023438), 12);
			var ovcontrol = new GOverviewMapControl(new GSize(100,100));
			map.addControl(ovcontrol);
			map.addControl(new GSmallMapControl());
			
			var blueIcon = new GIcon(G_DEFAULT_ICON);
			blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png";

			markerOptions = { icon:blueIcon };

		}

		//TODO: Una comprobación más seria
		if (correctLengths()){
			longitud = lat.length;
		}
	}

	function correctLengths() {
		if ((lat.length == lon.length) &&  (lat.length == nombres.length) && (tiempo_inicial.length == nombres.length))
			return true;
		else return false;
	}

	function onYouTubePlayerReady(playerId) {
		ytp = document.getElementById("myytplayer");
		// set the video playing
		dance();
		setInterval(checkEvent, 250);
	}

	
	function dance() {
		if(ytp) {
			ytp.loadVideoById(VID, 0);
		}
	}

	function play() { if (ytp) ytp.playVideo(); }
	function pause() { if (ytp) ytp.pauseVideo(); }
	function init() {if (ytp)ytp.seekTo(0, true);}
	function back(x) {
    if (ytp) {
    	var t = parseInt(ytp.getCurrentTime());
    	if(x) t -= 10;
    	else t += 10;

    	if(t < 0) t = 0;
    	if(t > parseInt(ytp.getDuration())) t = parseInt(ytp.getDuration());
    		
    	ytp.seekTo(t, true);    	
    }
  }
	
	function checkEvent() {
		var ct = parseInt(ytp.getCurrentTime());

		for (i=0; i<longitud; i++){
			if (i == (longitud-1)){
				check(i);
				return;
			}

			if (ct>= tiempo_inicial[i] && ct< tiempo_inicial[i+1]){
				check(i);
				return;
			}
		}
	}

	function check(x) {
		if (x != actual){
			actual = x;
			draw(x);
		}
	}

	function draw (x){
		document.getElementById("info").innerHTML = nombres[x];
		if (actualMarker)
			map.removeOverlay(actualMarker);
		point = new GLatLng(lat[x], lon[x]);
		map.panTo(point);
		actualMarker = new GMarker(point, markerOptions);
        map.addOverlay(actualMarker);
	}