//==================			
function FireOffAJAXRequest(id)
{
    var myXMLHttpRequest = GET_XMLHTTPRequest();
    if (myXMLHttpRequest)
    {
     	myXMLHttpRequest.open("GET", "infow.php?id=" + id, true);
        myXMLHttpRequest.onreadystatechange = function (aEvt) {
	    	if(myXMLHttpRequest.readyState == 4){
    			html = myXMLHttpRequest.responseText;
		 	}
		};
		myXMLHttpRequest.send(null);
	}else
    {
        alert("A problem occurred instantiating the XMLHttpRequest object.");
    }
return html;
}
//==================

//==================			
function movietimes(id)
{	


    var myXMLHttpRequest = GET_XMLHTTPRequest();
	
	myXMLHttpRequest.open("GET", "mozien.php?mid=" + id, true);
	myXMLHttpRequest.setRequestHeader("Content-Type","text/html; charset=utf-8");

   	
   if (myXMLHttpRequest)
    { 
	myXMLHttpRequest.onreadystatechange = function (aEvt) {
	if(myXMLHttpRequest.readyState == 4 && myXMLHttpRequest.status == 200)
	 {
     document.getElementById("mcontent").innerHTML = myXMLHttpRequest.responseText;
	 } else {
	 document.getElementById("mcontent").innerHTML = "<div style=\"text-align:center;font-family: Calibri; font-size:12px; font-weight:bold; margin-top:100px;\"><img src=\"ajax-loader.gif\" /></div>";
     }
	};
		
		myXMLHttpRequest.send(null);
	}else
    {
        alert("A problem occurred instantiating the XMLHttpRequest object.");
    }
document.getElementById("movietimes").style.visibility="visible";

//return html;
}
//==================

function closemt() {
	document.getElementById("movietimes").style.visibility="hidden";
	document.getElementById("mcontent").innerHTML = "";
}

function openmt(id) {
	document.getElementById("mcontent").innerHTML = "";
	//html1 ="";
	//html1 = movietimes(id);
	movietimes(id);

} 



// A function to create the marker and set up the event window
	function createMarkerMovie(point,name,html,x) {

		var marker = new GMarker(point,gicons["movie"]);                 
        marker.myname = name;
		marker.id = x;
        GEvent.addListener(marker, "click", function() {
			//==========================
			//html = FireOffAJAXRequest(x);
			//==========================			
			marker.openInfoWindowHtml(html);
        });
        gmarkersMovie.push(marker);

		//=====TOOLTIP===============
		marker.tooltip = '<div class="tooltip"><nobr>'+name+'</nobr></div>';
		//  ======  The new marker "mouseover" and "mouseout" listeners  ======
        GEvent.addListener(marker,"mouseover", function() {
          showTooltip(marker);
        });        
        GEvent.addListener(marker,"mouseout", function() {
		tooltip.style.visibility="hidden"
        });        

		//===========================
	
		return marker;
		
      }

function myclickMovie(i) {
	GEvent.trigger(gmarkersMovie[i],"click");
	map.setCenter(new GLatLng(gmarkersMovie[i].getPoint().lat(),gmarkersMovie[i].getPoint().lng()), 14);
}

function closedivmovie() {
	document.getElementById("overlaymovie").style.visibility="hidden";
	document.getElementById("openmovie").style.visibility="visible";
	for (var i=0; i<gmarkersMovie.length; i++) {
		map.removeOverlay(gmarkersMovie[i]);
		}
	}  

	function opendivmovie() {
	      // Read the data for Movie points
      GDownloadUrl("xmlmovie.php?dummy="+(new Date()).getTime(), function(doc) {
        var xmlDoc = GXml.parse(doc);
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");

        for (var f = 0; f < markers.length; f++) {
          
		  // obtain the attribues of each marker
          var lat = parseFloat(markers[f].getAttribute("lat"));
          var lng = parseFloat(markers[f].getAttribute("lng"));
          var point = new GLatLng(lat,lng);
		  var idf = markers[f].getAttribute("id");
          var address = markers[f].getAttribute("address");
		  

          var name = markers[f].getAttribute("name");
          var html = '<b>'+name+'</b><p>' + address +'<br /><a href="javascript:openmt('+ idf +')">Mai M&#369;sor</a>' ;
          // create the marker

          var marker = createMarkerMovie(point,name,html,idf);
          map.addOverlay(marker);
		  	 
        }
		makeSidebarMovie();				
      });

	document.getElementById("overlaymovie").style.visibility="visible";
	document.getElementById("openmovie").style.visibility="hidden";

	closediv();
	closedivsearch();
	
	} 
	
	
 // == rebuilds the sidebar to match the markers currently displayed ==
      function makeSidebarMovie() {
        var html = "";
        var html1 = "";		

        for (var i=0; i<gmarkersMovie.length; i++) {
            
			
			//====DROP DOWN====
			html1 += '<option value="' + i + '">' + gmarkersMovie[i].myname + '</option>';
			//=================
        }
		
		
			html += '<select name="id2" id="drop2" onchange="javascript:myclickMovie(this.options[this.selectedIndex].value)" style="width:200px; font-family:Verdana; font-size:9px; size:auto; color: #0066FF;">';
			html += html1;
			html += '</select>';
        document.getElementById("moviecontent").innerHTML = html;
      }