<?
	require_once('control/include/user.php');
	require_once('control/include/mysql.php');
	require_once('control/include/functions.php');
	require_once('control/include/fb.php');
	
	ob_start();
	session_start();
	
	// SETUP MYSQL HANDLERS
	$mysqldb1 = new mysql($host, $user, $pswd, $db); $mysqldb1->connect(); $mysqldb1->select();
	$mysqldb2 = new mysql($host, $user, $pswd, $db); $mysqldb2->connect(); $mysqldb2->select();
?>
<html>
<head>
<title><? print $meta_title; ?></title>
<meta name="Description" content="<? print $meta_description; ?>">
<meta name="Keywords" content="<? print $meta_keywords; ?>">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="pragma" content="no-cache">
<link type="text/css" rel="stylesheet" href="/website/styles/default/website.css">
<!--JQUERY-->
<link type="text/css" rel="stylesheet" href="/control/scripts/shadowbox/shadowbox.css">
<link type="text/css" rel="stylesheet" href="/control/styles/smoothness/jquery.ui.css">
<script type="text/javascript" src="/control/scripts/jquery.js"></script>
<script type="text/javascript" src="/control/scripts/shadowbox/shadowbox.js"></script>
<script type="text/javascript" src="/control/scripts/jquery.ui.js"></script>
<script type="text/javascript" src="/control/scripts/jquery.cycle.js"></script>
<script type="text/javascript" src="/control/scripts/jquery.charcounter.js"></script>
<script type="text/javascript" src="/control/scripts/jquery.tools.min.js"></script>
<!--/JQUERY-->
<!--CUSTOM-->
<script src="http://maps.google.com/maps?file=api&v=2&key=<? print $google_map_key; ?>&sensor=false" type="text/javascript"></script>
<script type="text/javascript" src="/control/scripts/php.js"></script>
<script type="text/javascript" src="/control/scripts/md5.js"></script>
<script type="text/javascript" src="/website/scripts/custom.js"></script>
<script type="text/javascript">
	
	$(document).ready(function() {
							   
		
	});
	
	function load() {
		if (GBrowserIsCompatible()) {
			
			// Create Map
			var map = new GMap2(document.getElementById("google_map"));
			
			// Center Map
			map.setCenter(new GLatLng(-33.396794, 24.048801), 10);
			
			// Setup Map
			map.addMapType(G_PHYSICAL_MAP);
			map.setMapType(G_NORMAL_MAP);
			//map.setMapType(G_HYBRID_MAP);
			
			// Add Controls
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			map.enableScrollWheelZoom();
			
			// Add KML
			//map.addOverlay(new GGeoXml("http://<? print $domain; ?>/kml/sample.kml"));
			<?
			$kmlDIR = 'kml/';
			
			// Read the contents of the kml directory
			if ($handle = opendir($kmlDIR)) {
				while (false !== ($file = readdir($handle))) {
					if (strstr($file, '.kml')) {
						print 'map.addOverlay(new GGeoXml("http://'.$domain.'/'.$kmlDIR.$file.'"));'."\n";
					}
				}
				closedir($handle);
			}
			?>
			
			// Add Points
			var html = "";
			
			<? $query = "
			SELECT 
				t1.*, 
				(SELECT name FROM file WHERE source='listing' AND record_id=t1.id AND type='image' AND status='enabled' ORDER BY sequence ASC LIMIT 1) AS image 
			FROM 
				listing AS t1 
			WHERE 
				t1.latitude!=0 AND
				t1.longitude!=-0 AND 
				t1.status='enabled'";
			$mysqldb1->query($query);
			while ($listing = $mysqldb1->fetchArray()) { ?>
			html =  '';
			html = html + '<a href="/listing/<? print $listing['link_name']; ?>" target="_self"><strong><? print clean($listing['name']); ?></strong></a><br/><br/>';
			html = html + '<? if ($listing['image'] != '') { ?><p class="image"><a href="/listing/<? print $listing['link_name']; ?>" target="_self"><img src="/<? print $smallDIR.$listing['image']; ?>" border="0" /></a></p><? } ?>';
			html = html + '<a href="<? print $listing['website']; ?>" target="_blank">Click for more info</a>';
			<? if ($listing['website'] != '') { ?>
			<? if ($webceo_id != '') { $listing['website'] = 'http://track.websiteceo.com/r/'.$webceo_id.'/'.str_replace('http://', '', $listing['website']); } ?>
			html =  '';
			html = html + '<a href="<? print $listing['website']; ?>" target="_blank"><strong><? print clean($listing['name']); ?></strong></a><br/><br/>';
			html = html + '<? if ($listing['image'] != '') { ?><p class="image"><a href="<? print $listing['website']; ?>" target="_blank"><img src="/<? print $smallDIR.$listing['image']; ?>" border="0" /></a></p><? } ?>';
			html = html + '<a href="<? print $listing['website']; ?>" target="_blank">Click for more info</a>';
			<? } ?>
			map.addOverlay(createMarker(new GLatLng(<? print $listing['latitude']; ?>, <? print $listing['longitude']; ?>), createIcon('accommodation.png'), html, 'click'));
			<? } ?>
			
		} else {
			alert('Your browser is not compatible with Google Maps.');
		}
	}
</script>
<!--/CUSTOM-->
<style type="text/css">
body {
	background-color: #FFFFFF;
	margin: 0;
	padding: 0;
	height: 100%; /* this is the key! */
}
#google_map {
	height: 100%;
	width: 100%;
}
.map_popup {
	margin: 0;
	padding: 0;
	width: auto;
	height: auto;
	text-align: center;
}
/*.map_popup .image {
	width: <? print $small_image_size; ?>px;
}*/
</style>
</head>
<body onLoad="load()" onUnload="GUnload()" >
<div id="google_map"></div>
</body>
</html>
<?
	$mysqldb1->close();
	$mysqldb2->close();
?>