absoluteUrl = "http://www.litchfieldbeach.com/";


function loadmap() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("largeMap"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(33.48509771078912, -79.09420251846313), 14,G_HYBRID_MAP);

    // Create our meetingstreetinn marker icon
    var houseicon = new GIcon();
	houseicon.image = "media/mm_20_blue.png";
	houseicon.shadow ="media/mm_20_shadow.png";
	houseicon.iconSize = new GSize(12, 20);
	houseicon.shadowSize = new GSize(22, 20);
	houseicon.iconAnchor = new GPoint(6, 20);
	houseicon.infoWindowAnchor = new GPoint(5, 1);
	
	
	var rentals = new Array();
	GDownloadUrl("mapdata.cfm", function(data, responseCode) {
	  var xml = GXml.parse(data) ;
	  
	  var markers = xml.documentElement.getElementsByTagName("marker");
	  
	  for (var i = 0; i < markers.length; i++) {
	    rentals[i] = new Object();
	    rentals[i].point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
			rentals[i].gdetail = clickedhtml(markers[i].getAttribute("src"), markers[i].getAttribute("name"), markers[i].getAttribute("address"), markers[i].getAttribute("idkey"), markers[i].getAttribute("info"))
	    rentals[i].marker = new GMarker(rentals[i].point, houseicon);
	    map.addOverlay(rentals[i].marker);
		GEvent.bind(rentals[i].marker, "click", rentals[i], function(){
			this.marker.openInfoWindowHtml(this.gdetail);
		});
		GEvent.bindDom(document.getElementById("jid" + i), "click", rentals[i], function() {
			this.marker.openInfoWindowHtml(this.gdetail);
		});
	  }
	});
  }
}

function clickedhtml(imgsrc, name, address, id, info) {
	return "<div class='infoWindow'><h3>" + name + "</h3><p>" + address + "</p><p>" + info + "</p><p><a href='http://maps.google.com/?hl=en&q=" + address.replace(' ', '+') + "' target='_blank'>Get Directions Here</a></p></div>";
}

// will add target to external links
function externalLinks() {
	if (!document.getElementsByTagName){
		return;
	}
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") &&  anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank"; 
		}
	}
}
window.onload = externalLinks;

// popup function for the tee times system
function openit(UID,SiteID,PID,RedLine,urlCourseID,showRates){
	myhandle=window.open('https://secure.guestdesk.com/teetimes/?UID='+UID+'&SiteID='+SiteID+'&PID='+PID+'&ShowRedLine='+RedLine+'&urlCourseID='+urlCourseID+'&showRates='+showRates,'windowName','toolbar=no,scrollbars=no,location=no,resizable=no,directories=no,status=yes,menubar=no,width=800,height=505,titlebar=TeeTimes,left=2,top=2');
}

// used on accommodations.cfm for image rollovers
function showImg(imgName,theImageWidth,theImageHeight){
	document.getElementById('roomImageDisplay').src = imgName;
	document.getElementById('roomImageDisplay').width = theImageWidth;	
	document.getElementById('roomImageDisplay').height = theImageHeight;	
}
// Show a DIV
function show(id){
	if (document.getElementById){
		obj = document.getElementById(id);
		obj.style.display = "";
	}	
}
// Hide a DIV
function hide(id){
	if (document.getElementById){
		obj = document.getElementById(id);
		obj.style.display = "none";
	}	
}

window.onload = function() {
	try { loadmap(); externalLinks();}
	catch(err) { }
}

window.onunload = function() {
	try { GUnload(); }
	catch(err) { }
}