//<![CDATA[
if (GBrowserIsCompatible()) {
	var gmarkers = [];
    var htmls = [];
	var html2s = [];
	var progressBar;
	var markersArray = [];
	var num = 0;
	function createMarker(point,i,name,html,logo,link2,icontype) {
        var marker = new GMarker(point, {icon:gicons[icontype]});
		//alert(icontype);
        GEvent.addListener(marker, "mouseover", function() {
		var txt = "<div class='txt1'><h1>"+name+"</h1>";
		if(logo != ''){
			txt += "<a href='"+link2+"'><img src='"+logo+"' border=0/></a>";
		}
		txt += "<p><a href='"+link2+"'>"+html+"</p></a></div>";
          marker.openInfoWindowHtml(txt);
        });  
		
        GEvent.addListener(marker,"mouseout", function() {
		tooltip.style.visibility="hidden"
        });
		//alert(html);
        return marker;
    }
	
	///////////////////////// :: Doy 20-10-52 :: ////////////////////////////
	var map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(7.908866949601111,98.34857940673828), 12);
	progressBar = new ProgressbarControl(map, {width:150}); 

	function readMap(url,area) {
		var end = new Date();
	  	var url= "http://"+location.host+"/_kml.php"+url+"&ts="+end.getTime();
        var request = GXmlHttp.create();
		//alert(url);
        request.open("GET", url, true);
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            var xmlDoc = request.responseXML;
            // obtain the array of markers and loop through it
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
            
            // hide the info window, otherwise it still stays open where the removed marker used to be
            map.getInfoWindow().hide();
            
            map.clearOverlays();
            
            // empty the array
            gmarkers = [];
			
			var maxNum = markers.length;
			progressBar.start(maxNum);
			
            // reset the side_bar
            for (var i = 0; i < markers.length; i++) {
				 num++;
				//sleep(5);
				  progressBar.updateLoader(1);
              // obtain the attribues of each marker
              var lat = parseFloat(markers[i].getAttribute("lat"));
              var lng = parseFloat(markers[i].getAttribute("lng"));
              var point = new GLatLng(lat,lng);			  
              var html = markers[i].getAttribute("html");			 
			  var name = markers[i].getAttribute("name");			 
			  var icontype = markers[i].getAttribute("icontype");
			  var logo = markers[i].getAttribute("logo");		
			  var link2 = markers[i].getAttribute("link");	
			  				
			  var marker = createMarker(point,i,name,html,logo,link2,icontype);
              map.addOverlay(marker);
            }
			
			 progressBar.remove();
			//document.getElementById("logo_side").innerHTML = side_logo_html;
          }
        }
        request.send(null);
		
      }

      // When initially loaded, use the data from "map11.php?q=a"
      //readMap(url,null);
	
}else{
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
//]]>
