      var gmarkers = [];     
      var map;


	// === This function picks up the click and opens the corresponding info window ===
      function myclick() {
      	sayi = rastgele(markers.length);		
        GEvent.trigger(gmarkers[sayi-1], "click");
      }

   // === A function to create the marker and set up the event window ===



      function createMarker(point,name,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);          
			//new Ajax.Updater('ilan_'+ilan_id, '/ilan/ilanajax/ilan_id/'+ilan_id, {asynchronous:true, evalScripts:false}); return false;          
        });
        // save the info we need to use later for the side_bar
        gmarkers.push(marker);
		
        return marker;
      }


	function init() {
      // === Create the map ===
      map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.setCenter(new GLatLng(centerLatitude, centerLongitude), 12);
      
      	for(id in markers) {
			var point = new GLatLng(markers[id].latitude, markers[id].longitude);
			var marker = createMarker(point,"Marker " + id , markers[id].isim);
			map.addOverlay(marker);			
		}
		myclick();	
		anim();
}

function anim(){

	idx=setInterval('myclick()',10000);
}

function rastgele(sayi){
var rand_no = Math.random();
rand_no = rand_no * sayi;
rand_no = Math.ceil(rand_no);
	return rand_no;
}

window.onload = init;    
window.onunload = GUnload;