	var map;
	var mapZoom = 1;
	var infoWinTimeout = null;
	var infoWinDelay = 2000;
	var infoWinList = new Array();
	
	function initialize() {
		var opts = {
			zoom: mapZoom,
			center: new google.maps.LatLng(20,0),
			mapTypeId: google.maps.MapTypeId.SATELLITE
		}
		map = new google.maps.Map(document.getElementById("theMap"), opts);
		renderMarkers();
	}

	function renderMarkers() {
		for(var i in gmapJsData) {
			addMarker(map, i);
		}
	}

	function addMarker(map, idx) {
		var latlng = new google.maps.LatLng(gmapJsData[idx].lat, gmapJsData[idx].lng);
		gmapJsData[idx].marker = new google.maps.Marker({
			icon: './suscriptores/img/marker.png',
			map: map, 
			position: latlng
		});
		var marker = gmapJsData[idx].marker;
		google.maps.event.addListener(marker, 'mouseover', function() {
			showInfoWindow(idx, marker);
		});
	}
	
	function createHTML(idx) {
		var html = "<h1 style='display: block; width: 100%; line-height: 30px; font: bold 14px tahoma,verdana,sans-serif; text-decoration: underline'>";
		html += gmapJsData[idx].country;
		html += "</h1>";
		html += "<p style='font: 12px tahoma,verdana,sans-serif'>"; 
		html += gmapJsData[idx].subscribers;
		html +=" suscriptores</p>";
		return html;
	}
	
	function showInfoWindow(idx, marker) {
		closeInfoWindows();
		var html = createHTML(idx);
		var infoWinOpts = {content: html}
		var infoWin = new google.maps.InfoWindow(infoWinOpts); 
		infoWinList.push(infoWin);
		infoWin.open(map, marker);
		infoWinTimeout = setTimeout(
			function(){
				infoWin.close();
				clearTimeout(infoWinTimeout);
			}, infoWinDelay
		);
	}
	
	function closeInfoWindows() {
		clearTimeout(infoWinTimeout);
		if(infoWinList.length>0) {
			if(Array.shift) {
				var win = infoWinList.shift();
				win.close();
			} else {	
				for(var i in infoWinList) {
					infoWinList[i].close();
					infoWinList.splice(i, 1);
				}
			}	
		}
	}

