<?php
// JS File generated by PHP

$local_server = false;
$DEV_server 	= "phanganisland.phangan.net";

if (stristr($SERVER_NAME, $DEV_server)) {
	// Home Development
	$local_server = true;
}



// change header data to fake a jscript
$doc_date = date("D, d M Y H:i:s ", time()-86400)."GMT"; 
header('X-Powered-By: JS Menu Maker');
header('Last-Modified: '.$doc_date);
header('Content-Type: application/x-javascript');

include(dirname(__file__)."/../../../re_db/inc/config.inc.php");
// Multi Cache Class
require_once(dirname(__file__)."/../../../re_db/inc/cache.class.php");

// City Index 
$city_cache = new cache("picityindex", false, 604800); // one week ttl


if (!$city_cache->is_cached("cities")) {

	$city_index = get_city_index(5, "english", 12); // 5 = Thailand, 12 = KPG
	$city_cache->store_data("cities", serialize($city_index));	
	
} else {

	$city_index = unserialize($city_cache->get_data("cities"));
}


// Bungalow Resorts from PhanganBungalows.com
$pb_cache = new cache("phbungalows", false, 604800);

if (!$pb_cache->is_cached('bungalowexportlist')) {
	
	
	if ($local_server) {
		$resorts_import = file('http://phanganbungalows.com.phangan.net/external/export.php?layout=phanganisland.phanganbungalows.com');
	} else {
		$resorts_import = file('http://www.phanganbungalows.com/external/export.php?layout=phanganisland.phanganbungalows.com');
	}
	$resorts = array();
	
	
	if ($resorts_import) {
	
		for($i=0; $i<sizeof($resorts_import); $i++) {
			$r = split("\|", $resorts_import[$i]);
			$resorts[$r[2]][trim($r[1])] = trim($r[0]);			
		}
		
		$pb_cache->store_data('bungalowexportlist', serialize($resorts));
		
	}
	
} else {
	
	$resorts = unserialize($pb_cache->get_data('bungalowexportlist'));

}


?>
	bC = null;

	startMenu(1, 175);
	menuItem('Search', null, null, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/index.php?interface=search&banner=true', null);
	menuItem('Area on Koh Phangan', 4, null, '#ffffff', '#ffffff', '', 'right');
	menuItem('Price Rages', 5, null, '#ffffff', '#ffffff', '', 'right');
	menuItem('Photo Gallery', null, null, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/visual_index/', null);
	endMenu();

	startMenu(2, 170);
	

	menuItem('Information about', null, 150, '#ffffff', '#ffffff', 'http://www.PhanganBungalows.com/', null);
	menuItem('Bungalow Resorts', null, 150, '#ffffff', '#ffffff', 'http://www.PhanganBungalows.com/', null);
	menuItem('and Guesthouses', null, 150, '#ffffff', '#ffffff', 'http://www.PhanganBungalows.com/', null);
	menuItem('you can find on our', null, 150, '#ffffff', '#ffffff', 'http://www.PhanganBungalows.com/', null);
	menuItem('new website', null, 150, '#ffffff', '#ffffff', 'http://www.PhanganBungalows.com/', null);
	menuItem('<b>PhanganBungalows.com</b>', null, 150, '#ffffff', '#ffffff', 'http://www.PhanganBungalows.com/', null);
	
	endMenu();
		
	startMenu(3, 145);
	menuItem('About Us', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/about_us/', null);
	menuItem('Online Payment', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/paypal/', null);
	menuItem('Report Problem', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/about_us/contact_us.php', null);
	menuItem('Meetingpoint', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/meetingpoint/', null);
	menuSpacer(150, '#FFFFFF');	
	menuItem('Classifieds', null, 150, '#ffffff', '#ffffff', 'http://www.phanganisland.com/classifieds/index.php?&method=showhtmllist&list=advertisement_active&clearoff=1', null);
	menuItem('Yellow Pages', null, 150, '#ffffff', '#ffffff', 'http://phanganisland.com/services/', null);
	menuItem('Thailand News', null, 150, '#ffffff', '#ffffff', 'http://www.phanganisland.com/news/', null);
	menuItem('Currency Rates', null, 150, '#ffffff', '#ffffff', 'http://www.phanganisland.com/currency/', null);
	menuItem('Weather', null, 150, '#ffffff', '#ffffff', 'http://www.phanganisland.com/weather/', null);
	menuItem('How to come here', null, 150, '#ffffff', '#ffffff', 'http://www.phanganisland.com/koh_phan_gan/#howtocome', null);
	menuItem('Map of Koh Phangan', null, 150, '#ffffff', '#ffffff', 'http://maps.phanganisland.com', null);
	menuSpacer(150, '#FFFFFF');	
	menuItem('Phangan Chat', null, 150, '#ffffff', '#ffffff', 'http://www.phanganisland.com/irc_chat/', null);
	menuItem('Message Board', null, 150, '#ffffff', '#ffffff', 'http://phanganisland.com/guest_book/', null);
	menuItem('Discussion Forum', null, 150, '#ffffff', '#ffffff', 'http://phanganisland.com/mboard/', null);
	
	endMenu();
	
	startMenu(4, null);
	<?php
	while (list($id, $name) = each($city_index)) {
		$num = count_objects("where city_id = $id and type = 2");
		if ($num > 0) {
	?>menuItem('<?php echo $name; ?> (<?php echo $num; ?>)', null, null, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/index.php?action=simple_search&location=<?php echo $id;?>&type=2', null);
	  <?php
		}
	}
	?>
	endMenu();
	
	startMenu(5, 275);
	menuItem(' 3000 -  5000 Baht rent per month', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/index.php?action=simple_search&type=2&min_price=3000&max_price=5000', null);
	menuItem(' 5000 -  8000 Baht rent per month', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/index.php?action=simple_search&type=2&min_price=5000&max_price=8000', null);
	menuItem(' 8000 - 12000 Baht rent per month', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/index.php?action=simple_search&type=2&min_price=8000&max_price=12000', null);
	menuItem('12000 - 18000 Baht rent per month', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/index.php?action=simple_search&type=2&min_price=12000&max_price=18000', null);
	menuItem('18000 - 30000 Baht rent per month', null, 150, '#ffffff', '#ffffff', 'http://<?php echo $_SERVER['SERVER_NAME']; ?>/index.php?action=simple_search&type=2&min_price=18000&max_price=30000', null);
	endMenu();
	<?php 
	$c = 6;
	reset($resorts);
	
	while(list($location, $a) = each($resorts)) {
	if (sizeof($a)>1) {
	?>
	startMenu(<?php echo $c; ?>, 175);
	<?php
		if (sizeof($a)) {
		while(list($resort, $url) = each($a)) {
	?>
	menuItem('<?php echo $resort; ?>', null, 175, '#ffffff', '#ffffff', '<?php echo $url; ?>', null);
	<?php 
	
		}
		
		$c++;
		}
	?>
	endMenu();
	
	<?php
	}
	}
	?>