//<![CDATA[

	var map = null;
    var geocoder = null;

    function initializeMap(Clat, Clng, Zoom) {
      if (GBrowserIsCompatible()) {
       
	   	// -- info window color change -- 
		function colourWindow() {
        // Change any <imgs> that use iw2.png
        var imgs = document.getElementsByTagName("IMG")
        for (var n = 0 ; n < imgs.length ; n++ ){
          var a=imgs[n].src;
          if (a.indexOf("iw2.png") > -1) {
            imgs[n].src="images/212121iw.png";
          }
		  else if (imgs[n].src=="http://maps.google.com/intl/en_us/mapfiles/iw_close.gif" || imgs[n].src=="http://maps.google.com/intl/en_ALL/mapfiles/iw_close.gif") {
            imgs[n].src="images/kiwi_iw_close.gif";
          }
		  
        }  
        // Change any <divs> that use "white"
        var divs = document.getElementsByTagName("DIV")
        for (var n = 0 ; n < divs.length ; n++ ){
          if (divs[n].style.backgroundColor == "white") {
            divs[n].style.backgroundImage="URL(images/212121.png)";
          }
		  //if (divs[n].style.borderTop == "1px solid rgb(171, 171, 171)") {
		  if (divs[n].style.borderTop != "") {
            divs[n].style.borderTop="1px solid rgb(0,0,0)";
          }
		  if (divs[n].style.borderBottom != "") {
            divs[n].style.borderBottom="1px solid rgb(0,0,0)";
          }
		  if (divs[n].style.borderLeft != "") {
            divs[n].style.borderLeft="1px solid rgb(0,0,0)";
          }
		  if (divs[n].style.borderRight != "") {
            divs[n].style.borderRight="1px solid rgb(0,0,0)";
          }
        } 
		
      }

		map = new GMap2(document.getElementById("map_canvas"));
		
       
	   map.setCenter(new GLatLng(Clat, Clng), Zoom);
      
	  
				
		for (var i=0; i<m.length; i++) 
		{
			var point = new GLatLng(m[i][1],m[i][2]);
			var marker = createMarker(point,m[i][0]);
			map.addOverlay(marker);
		}
		
		
		
		
      tl_cnr = new GScreenOverlay('images/map_cnr_tl.png',
        new GScreenPoint(0, 1,'fraction', 'fraction'),  
        new GScreenPoint(0, 1,'fraction', 'fraction'),
        new GScreenSize(5, 5)  
      );
	  map.addOverlay(tl_cnr);
	
	bl_cnr = new GScreenOverlay('images/map_cnr_bl.png',
        new GScreenPoint(0, 0,'fraction', 'fraction'), 
        new GScreenPoint(0, 0,'fraction', 'fraction'), 
        new GScreenSize(5, 5) 
      );
	  map.addOverlay(bl_cnr);
	  
	tr_cnr = new GScreenOverlay('images/map_cnr_tr.png',
        new GScreenPoint(1, 1,'fraction', 'fraction'), 
        new GScreenPoint(1, 1,'fraction', 'fraction'),  
        new GScreenSize(5, 5)  
      );
	  map.addOverlay(tr_cnr);  
	
	br_cnr = new GScreenOverlay('images/map_cnr_br.png',
        new GScreenPoint(1, 0,'fraction', 'fraction'),  
        new GScreenPoint(1, 0,'fraction', 'fraction'), 
        new GScreenSize(5, 5) 
      );
	  map.addOverlay(br_cnr);
	  
	  
	  
	  GEvent.addDomListener(document.getElementById("CENTERbutton"), "click", function() {
       map.setCenter(new GLatLng(Clat+0.00033, Clng), Zoom);
      });
		
	GEvent.addDomListener(document.getElementById("UPbutton"), "click", function() {
      map.panDirection(0,1);
      }); 

	GEvent.addDomListener(document.getElementById("DOWNbutton"), "click", function() {
      map.panDirection(0,-1);
      }); 
	
	GEvent.addDomListener(document.getElementById("LEFTbutton"), "click", function() {
      map.panDirection(1,0);
      }); 
	  
	GEvent.addDomListener(document.getElementById("RIGHTbutton"), "click", function() {
      map.panDirection(-1,0);
      });
	  
	GEvent.addDomListener(document.getElementById("NORMALbutton"), "click", function() {
     map.setMapType(G_NORMAL_MAP);
	  })
    
	GEvent.addDomListener(document.getElementById("SATELLITEbutton"), "click", function() {
     map.setMapType(G_SATELLITE_MAP);
	  })
	  
	GEvent.addDomListener(document.getElementById("HYBRIDbutton"), "click", function() {
     map.setMapType(G_HYBRID_MAP);
	  })
	  
	  var iw=map.getInfoWindow();
      colourWindow();	
	  } 
   
		
	} //---------------
	 
	 
	   function createMarker(point,html) {
      	//var marker = new GMarker(point);
		var newIcon = MapIconMaker.createMarkerIcon({width: 14, height: 24, primaryColor: "#77AD00"});
		var marker = new GMarker(point, {icon: newIcon});
        GEvent.addListener(marker, "click", function() {
          get_map_property("PR"+html, marker);
		  
        });
        return marker;
      }

	  
	 
	 
	 function showAddress(address) {
   
	  if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 12);
			  map.setZoom(zoom);
			  
            }
          }
        );
      }
    }

    //]]>


function toggleGmap(Clat, Clng, Zoom) { // toggle gmap on/off   
	
	if(document.getElementById("map_container").style.display!='block')  // open
	{
	   if(intro==1)
	   { document.getElementById("map_on").style.display="block";
		 document.getElementById("no_map").style.display="none";
	   }
		document.getElementById("map_container").style.display='block';
		
	   document.getElementById("gmap_toggle").innerHTML='<img src=\"'+r+'/images/map_mag.gif\" border=\"0\" alt=\"\">&nbsp;HIDE MAP';	
	   
	   if(document.getElementById("blw_map"))
	   {
	     document.getElementById("blw_map").style.display='block';
	   }	
	

	   
	   var thisTop = setTopMap(document.getElementById("rt").style.top, "down");
		document.getElementById("rt").style.top=thisTop+'px';
		
		var thisTop2 = setTopMap(document.getElementById("kcover").style.top, "down");
		document.getElementById("kcover").style.top=thisTop2+'px';
		
		var thisTop3 = setTopMap(document.getElementById("list").style.top, "down");
		document.getElementById("list").style.top=thisTop3+'px';
	   
	   
	
		initializeMap(Clat, Clng, Zoom);	
	}
	else   // close
	{   if(intro==1)
		{ document.getElementById("map_on").style.display="none";
		  document.getElementById("no_map").style.display="block";
		}
		document.getElementById("map_container").style.display='none';
		document.getElementById("rt").style.display='block';
		document.getElementById("gmap_toggle").innerHTML='<img src=\"'+r+'/images/map_mag.gif\" border=\"0\" alt=\"\">&nbsp;VIEW MAP';
		

		
		if(document.getElementById("blw_map"))
		{
		  document.getElementById("blw_map").style.display='none';
		}
		
		if(document.getElementById("map_link"))
		{
		  document.getElementById("map_link").innerHTML='View Hotels on a Map';
		}
	
	    var thisTop = setTopMap(document.getElementById("rt").style.top, "up");
		document.getElementById("rt").style.top=thisTop+'px';
		
		var thisTop2 = setTopMap(document.getElementById("kcover").style.top, "up");
		document.getElementById("kcover").style.top=thisTop2+'px';
		
		var thisTop3 = setTopMap(document.getElementById("list").style.top, "up");
		document.getElementById("list").style.top=thisTop3+'px';
	
	}
	
}

function setTopMap(findTop, up_down)
{
	
	if(up_down=='down')
	{
	  findTop = findTop.substring(0,3);
	  findTop = eval(parseInt(findTop)+323);
	  if(intro==0)
	  { findTop=findTop+66;
	  }
	  //alert(findTop);
	  return findTop; 
	}
	else if(up_down=='up')
	{
	  findTop = findTop.substring(0,3);
	  findTop = eval(parseInt(findTop)-323);
	  if(intro==0)
	  { findTop=findTop-66;
	  }

	  //alert(findTop);
	  return findTop; 
	}
}
