var currentFilename = jQuery.url.attr("file");
var TotalFolder = jQuery.url.segment();
if (TotalFolder !=1) {var currentCountry = jQuery.url.segment(TotalFolder-2).toUpperCase();}
else {var currentCountry  = "";}
var pageDisplayCurrency = jQuery.url.param("c");
if (pageDisplayCurrency != undefined) {
	pageDisplayCurrency = pageDisplayCurrency.toUpperCase();
}

var CountryArrayValue = new Array("au","kh","cn","hk","mo","tw","fj","gu","in","id","jp","kr","my","mv","nc","nz","sg","th","vu","vn");
var CountryLowestPriceArrayValue = new Array('165','115','360','1050','1375','5355','295','130','3000','73','12200','160000','220','204','18875','260','260','3120','11890','134');
var CountryArray_EN = new Array("Australia","Cambodia","China","Hong Kong","Macau","Taiwan","Fiji","Guam","India ","Indonesia","Japan","Korea","Malaysia","Maldives","New Caledonia","New Zealand ","Singapore","Thailand","Vanuatu","Vietnam");
var CountryArray_JP = new Array("オーストラリア","カンボジア","中国","香港","マカオ","台湾","フィジー","グアム","インド","インドネシア","日本","韩国","マレーシア","モルディブ共和国","ニューカレドニア","ニュージーランド","シンガポール","タイ","バヌアツ","ベトナム");
var CountryArray_SC = new Array("澳大利亚","柬埔寨","中国","香港","澳门","台湾","斐济","关岛","印度","印度尼西亚","日本","韩国","马来西亚","马尔代夫群岛","新喀里多尼亚","新西兰","新加坡","泰国","瓦努阿图","越南");

var currentLang, CountryArrayDisplay;
switch (currentFilename) {
	case "index.html":
		currentLang = "en";
		CountryArrayDisplay = CountryArray_EN;
		break;
	case "jp.html":
		currentLang = "jp";
		CountryArrayDisplay = CountryArray_JP;		
		break;
	case "cn.html":
		currentLang = "sc";		
		CountryArrayDisplay = CountryArray_SC;		
		break;
	default:
		currentFilename = "index.html";
		currentLang = "en";
		CountryArrayDisplay = CountryArray_EN;
		break;		
}


(function($) {
	$.fn.populateCountryNav = function(pPath) {

		if (pPath == "root") {sPath = "";} else {sPath = "../";}

		var countryContent = ""; 
		var countryDisplayName;
		
		// assemble the coding for country navigation
		for (var i=0; i<CountryArrayValue.length; i++) {
			
			// HK, MO and TW would have a bullet append behind
			if (CountryArrayValue[i]=="tw" || CountryArrayValue[i]=="hk" || CountryArrayValue[i]=="mo") {
				countryDisplayName = "&bull; " + CountryArrayDisplay[i].toUpperCase();
			}
			else {
				countryDisplayName = CountryArrayDisplay[i].toUpperCase();
			}
			
			if (CountryArrayValue[i] == currentCountry.toLowerCase()) {
				if (CountryArrayValue[i]=="tw" || CountryArrayValue[i]=="hk" || CountryArrayValue[i]=="mo") {
					countryContent = countryContent + "<li class=\"inneractive\"><a href=\"" + sPath + CountryArrayValue[i] + "/" + currentFilename + "\">" + countryDisplayName + "</a></li>";					
				}
				else {
					countryContent = countryContent + "<li class=\"active\"><a href=\"" + sPath + CountryArrayValue[i] + "/" + currentFilename + "\">" + countryDisplayName + "</a></li>";					
				}
			}
			else {
				if (CountryArrayValue[i]=="tw" || CountryArrayValue[i]=="hk" || CountryArrayValue[i]=="mo") {
					countryContent = countryContent + "<li class=\"inner\"><a href=\"" + sPath + CountryArrayValue[i] + "/" + currentFilename + "\">" + countryDisplayName + "</a></li>";
				}
				else {
					countryContent = countryContent + "<li><a href=\"" + sPath + CountryArrayValue[i] + "/" + currentFilename + "\">" + countryDisplayName + "</a></li>";
				}
			}
		}

		// append to the codes into the div in the html
		$(this).append($('<ul/>').append(countryContent));
	}
})(jQuery);

function changeLanguage(pSelectedLanguage) {
	var redirectURL;

	if (pSelectedLanguage!="") {	
	
		switch(pSelectedLanguage) {
			case "en":
				redirectURL = "index.html";
				break; 
			case "jp":
				redirectURL = "jp.html";
				break; 
			case "sc":
				redirectURL = "cn.html";				
				break; 
		}
		window.location = redirectURL;
	}
}

function populateCityList () {
	
	$('#citylist').empty();
	var drp = document.getElementById("citylist");
	
	switch(currentLang) {
		case "en":
			var xmlLocation = "../xml/city_list_en.xml";		
			drp.options[drp.options.length] = new Option('City', '');
			break;
		case "jp":
			var xmlLocation = "../xml/city_list_jp.xml";	
			drp.options[drp.options.length] = new Option('市', '');
			break;
		case "sc":
			var xmlLocation = "../xml/city_list_sc.xml";	
			drp.options[drp.options.length] = new Option('城市', '');
			break;			
	}
	
	$.ajax({
		type: "GET",
		url: xmlLocation,
		dataType: "xml",
		success: function(xml) {
			$(xml).find('country[id='+ currentCountry +']').each(function(){

				$(this).find('city').each(function(){
					var cityValue = $(this).attr('value');
					var cityName = $(this).find('name').text();
					drp.options[drp.options.length] = new Option(cityName, cityValue);
				});
			});
			$('#citylist').selectbox({debug: true, inputClass:'selectbox1', containerClass:'selectbox1-wrapper'});
		}
	});	
}

function populateCountryList () {
	
	$('#countrylist').empty();
	var drp = document.getElementById("countrylist");
	
	switch(currentLang) {
		case "en":
			drp.options[drp.options.length] = new Option('Country', '');
			break;
		case "jp":
			drp.options[drp.options.length] = new Option('国', '');
			break;
		case "sc":
			drp.options[drp.options.length] = new Option('国家', '');
			break;			
	}
	
	for (var i=0; i<CountryArrayValue.length; i++) {
		drp.options[drp.options.length] = new Option(CountryArrayDisplay[i], CountryArrayValue[i]);
	}
	$('#countrylist').selectbox({debug: true, inputClass:'selectbox1', containerClass:'selectbox1-wrapper'});
}

function updateProperties (pSelectedCity) {
	if (pSelectedCity!='') {
		displayProperties_pre(pSelectedCity)	
	}
}

function redirectCountry (pSelectedCountry) {
	if (pSelectedCountry!='') {
		var redirectURL = pSelectedCountry + "/" + currentFilename;
		window.location = redirectURL;
	}
}

function displayCountries () {

	switch(currentLang) {
		case "en":
			var headerText = "Asia Pacific";
			var fromText = "From";
			var learnText = "Learn More";
			break;
		case "jp":
			var headerText = "&#12450;&#12472;&#12450;&#22826;&#24179;&#27915;&#22320;&#22495;"		
			var fromText = "&nbsp;";			
			var learnText = "&#35443;&#32048;&#12399;&#12371;&#12385;&#12425;";			
			break;
		case "sc":
			var headerText = "&#20122;&#22826;&#22320;&#21306;"		
			var fromText = "&#20174;";
			var learnText = "&#20102;&#35299;&#26356;&#22810;";			
			break;			
	}
	
	var countryCount = 0;
	var displayCurrenyCode = getCurrencyCode(pageDisplayCurrency);	
	if (displayCurrenyCode == "") {
		displayCurrenyCode = getCurrencyCode('USD');
	}
	$('<div class="hidden" id="currentCurrency"></div>').html('USD').appendTo('#listing');

	var tmpCountryValue, tmpCountryCurrency, tmpExchangeRate, lowestPrice;
	
	for (var i=0; i<CountryArrayValue.length; i++) {
		tmpCountryValue = CountryArrayValue[i].toUpperCase();
		
		$('<div class="box" id="country_'+i+'"></div>').html('').appendTo('#listing');
		$('<div class="cityName"></div>').html(CountryArrayDisplay[i]).appendTo('#country_'+i);
		$('<p></p>').html(fromText).appendTo('#country_'+i);
		$('<div id="cp_'+i+'"></div>').html('').appendTo('#country_'+i);
		$('<div id="price_'+i+'_currency" class="currency"></div>').html(displayCurrenyCode).appendTo('#cp_'+i);		
		
		tmpCountryCurrency = getCurrencyCode(tmpCountryValue);
		if (tmpCountryCurrency == "USD") {
			lowestPrice = CountryLowestPriceArrayValue[i];
		}
		else {
			tmpExchangeRate = getExchangeRate(tmpCountryCurrency);
			lowestPrice = Math.round(CountryLowestPriceArrayValue[i] * tmpExchangeRate);
		}
		
		$('<div id="price_'+i+'" class="price"></div>').html(lowestPrice).appendTo('#cp_'+i);
		if (currentLang == "jp") {
			$('<span></span>').html('~').appendTo('#price_'+i);
		}
		$('<div id="price_'+i+'_org" class="hidden"></div>').html(lowestPrice).appendTo('#cp_'+i);	
		$('<div class="learn_now"></div>').html('<a href="#" onclick="redirectCountry(\''+CountryArrayValue[i]+'\');return false;"><img src="img/btn_learnmore_'+currentLang+'.jpg" alt="'+learnText+'" width="89" height="20" border="0" /></a>').appendTo('#country_'+i);			
		
		if (pageDisplayCurrency!=undefined && pageDisplayCurrency!="USD")
		{
			changeCurrency(pageDisplayCurrency);
		}
		
		countryCount += 1;
		if (countryCount==4) {
			$('<div class="clear"></div>').html('').appendTo('#listing');
			$('<div class="divider"></div>').html('<img src="img/spacer.gif" width="544" height="2" />').appendTo('#listing');
			countryCount = 0;
		}		
	}	

	$('#listing').jScrollPane({scrollbarWidth:8});
	$('#loadScreen').css({'display':'none'});
}

function displayCities_pre() {
	
	// some countries would skip the cities display page, and directly go to the properties listing page
	switch (currentCountry) {
		case "HK":
			displayProperties_pre('Hong Kong');			
			break;
		case "MO":
			displayProperties_pre('Macau');			
			break;			
		case "TW":
			displayProperties_pre('Taipei');			
			break;		
		case "KH":
			displayProperties_pre('Siem Reap');			
			break;		
		case "FJ":
			displayProperties_pre('Nadi');			
			break;		
		case "GU":
			displayProperties_pre('Tumon');			
			break;		
		case "NZ":
			displayProperties_pre('Auckland');			
			break;					
		case "SG":
			displayProperties_pre('Singapore');			
			break;				
		case "VU":
			displayProperties_pre('Port Vila');			
			break;	
		case "KR":
			displayProperties_pre('Seoul');			
			break;
		case "VN":
			displayProperties_pre('Vietnam');			
			break;			
		default:
			$('.jScrollPaneTrack').fadeTo(1000,0);
			//$('#listing').fadeTo(1000,0, function(){ displayCities(); });
			$('#listing').fadeOut(1000,function(){ displayCities(); });
			break;
	}
	
}

function displayCities () {

	switch(currentLang) {
		case "en":
			var xmlLocation = "../xml/city_list_en.xml";
			var fromText = "From";
			var learnText = "Learn More";
			break;
		case "jp":
			var xmlLocation = "../xml/city_list_jp.xml";	
			var fromText = "&nbsp;";			
			var learnText = "&#35443;&#32048;&#12399;&#12371;&#12385;&#12425;";			
			break;
		case "sc":
			var xmlLocation = "../xml/city_list_sc.xml";	
			var fromText = "&#20174;";
			var learnText = "&#20102;&#35299;&#26356;&#22810;";			
			break;			
	}
	
	$('#listing').empty();
	
	$.ajax({
		type: "GET",
		url: xmlLocation,
		dataType: "xml",
		success: function(xml) {
			$(xml).find('country[id='+ currentCountry +']').each(function(){
				var cityCount = 0;
				var originalCurrenyCode = getCurrencyCode(currentCountry);
				var displayCurrenyCode = getCurrencyCode(pageDisplayCurrency);	
				if (displayCurrenyCode == "") {
					displayCurrenyCode = getCurrencyCode(currentCountry);
				}
				$('<div class="hidden" id="currentCurrency"></div>').html(originalCurrenyCode).appendTo('#listing');
				
				// setup the masthead for the country
				var headerImage = $(this).find('masthead').find('image').text();
				var headerText = $(this).find('masthead').find('alt').text();
				$('#country_header').empty();
				$('#country_header').append(headerText);
				$('<div class="hidden" id="currentCountry"></div>').html(headerText).appendTo('#nav_country'); //for populating breadcrumb

				$(this).find('city').each(function(){
					var cityID = $(this).attr('id');
					var cityValue = $(this).attr('value');
					var cityName = $(this).find('name').text();
					var tmpdisplayPrice = $(this).find('price').text();
					var displayPrice = tmpdisplayPrice.replace(/(\d{1,})(\d{3})/, "$1,$2"); 	
					
					$('<div class="box" id="city_'+cityID+'"></div>').html('').appendTo('#listing');
					$('<div class="cityName"></div>').html(cityName).appendTo('#city_'+cityID);
					$('<p></p>').html(fromText).appendTo('#city_'+cityID);
					$('<div id="cp_'+cityID+'"></div>').html('').appendTo('#city_'+cityID);
					$('<div id="price_'+cityID+'_currency" class="currency"></div>').html(displayCurrenyCode).appendTo('#cp_'+cityID);
					$('<div id="price_'+cityID+'" class="price"></div>').html('&nbsp\;'+displayPrice).appendTo('#cp_'+cityID);
					if (currentLang == "jp") {
						$('<span></span>').html('~').appendTo('#price_'+cityID);
					}										
					$('<div id="price_'+cityID+'_org" class="hidden"></div>').html(tmpdisplayPrice).appendTo('#cp_'+cityID);	
					$('<div class="learn_now"></div>').html('<a href="#" onclick="displayProperties_pre(\''+cityValue+'\');return false;"><img src="../img/btn_learnmore_'+currentLang+'.jpg" alt="'+learnText+'" width="89" height="20" border="0" /></a>').appendTo('#city_'+cityID);	
					
					cityCount += 1;
					if (cityCount==4) {
						$('<div class="clear"></div>').html('').appendTo('#listing');
						$('<div class="divider"></div>').html('<img src="../img/spacer.gif" width="544" height="2" />').appendTo('#listing');
						cityCount = 0;
					}
				});

				$('#listing').jScrollPane({scrollbarWidth:8});
				$('#loadScreen').css({'display':'none'});
				//$('.jScrollPaneTrack').fadeTo(1500,1);
				$('.jScrollPaneTrack').show(1500);
				//$('#listing').fadeTo(1500,1);
				$('#listing').fadeIn(1500);				
				changeCurrency(displayCurrenyCode);
			});
		},
		complete: function(XMLHttpRequest, textStatus) {
			populateBreadCrumb();
		}
	});
}


function displayProperties_pre(pCity) {
	$('.jScrollPaneTrack').fadeTo(1000,0);
	//$('#listing').fadeTo(1000,0, function(){ displayProperties(pCity); });
	$('#listing').fadeOut(1000, function(){ displayProperties(pCity); });
}


function displayProperties(pCity) {

	switch(currentLang) {
		case "en":
			var xmlLocation = "../xml/property_list_en.xml";	
			var fromText = "From";
			var bookText = "Book Now";
			break;
		case "jp":
			var xmlLocation = "../xml/property_list_jp.xml";	
			var fromText = "&nbsp;";
			var bookText = "&#12372;&#20104;&#32004;&#12399;&#12371;&#12385;&#12425;&#12363;&#12425;";			
			break;
		case "sc":
			var xmlLocation = "../xml/property_list_sc.xml";	
			var fromText = "&#20174;";
			var bookText = "&#31435;&#21051;&#39044;&#35746;";			
			break;			
	}	
	
	$('#listing').empty();
	$('#loadScreen').css({'display':''});
	
	$.ajax({
		type: "GET",
		url: xmlLocation,
		dataType: "xml",
		success: function(xml) {
			$(xml).find('city[id='+ pCity +']').each(function(){
				var propertyCount = 0;
				var originalCurrenyCode = getCurrencyCode(currentCountry);
				var displayCurrenyCode = getCurrencyCode(pageDisplayCurrency);	
				if (displayCurrenyCode == "") {
					displayCurrenyCode = getCurrencyCode(currentCountry);
				}
				$('<div class="hidden" id="currentCurrency"></div>').html(originalCurrenyCode).appendTo('#listing');
				
				// to set the local curreny for hongkong, macau and taipei under china listing
				if (currentCountry=="CN" && pCity=="Hong Kong") {displayCurrenyCode = "HKD";}
				if (currentCountry=="CN" && pCity=="Macau") {displayCurrenyCode = "HKD";}
				if (currentCountry=="CN" && pCity=="Taipei") {displayCurrenyCode = "TWD";}

				// setup the masthead for the city
				var headerImage = $(this).find('masthead').find('image').text();
				var headerText = $(this).find('masthead').find('alt').text();
				$('#country_header').empty();
				$('#country_header').append(headerText);
					
				$(this).find('hotel').each(function(){
					var hotelID = $(this).find('hid').text();
					var hotelName = $(this).find('name').text();
					var hotelCopy = $(this).find('copy').text();
					var linkURL = $(this).find('link').text();
					var tmpdisplayPrice = $(this).find('price').text();
					var displayPrice = tmpdisplayPrice.replace(/(\d{1,})(\d{3})/, "$1,$2") 					

					$('<div class="box" id="property_'+hotelID+'"></div>').html('').appendTo('#listing');
					$('<div class="hotelName"></div>').html(hotelName).appendTo('#property_'+hotelID);
					$('<p></p>').html(fromText).appendTo('#property_'+hotelID);
					$('<div id="cp_'+hotelID+'"></div>').html('').appendTo('#property_'+hotelID);
					$('<div id="price_'+hotelID+'_currency" class="currency"></div>').html(displayCurrenyCode).appendTo('#cp_'+hotelID);
					$('<div id="price_'+hotelID+'" class="price"></div>').html(displayPrice).appendTo('#cp_'+hotelID);
					if (currentLang == "jp") {
						$('<span></span>').html('~').appendTo('#price_'+hotelID);
					}											
					$('<div id="price_'+hotelID+'_org" class="hidden"></div>').html(tmpdisplayPrice).appendTo('#cp_'+hotelID);	
					$('<div class="book_now"></div>').html('<a href="'+linkURL+'" target="_blank"><img src="../img/btn_booknow_'+currentLang+'.jpg" alt="'+bookText+'" width="89" height="20" border="0" /></a>').appendTo('#property_'+hotelID);	
					
					propertyCount += 1;
					if (propertyCount==4) {
						$('<div class="clear"></div>').html('').appendTo('#listing');
						$('<div class="divider"></div>').html('<img src="../img/spacer.gif" width="544" height="2" />').appendTo('#listing');
						propertyCount = 0;
					}
				});

				$('#listing').jScrollPane({scrollbarWidth: 8});
				//$('.jScrollPaneTrack').fadeTo(1500,1);
$('.jScrollPaneTrack').show(1500);
				//$('#listing').fadeTo(1500,1);
				$('#listing').fadeIn(1500);			
				changeCurrency(displayCurrenyCode);
			});
		},
		complete: function(XMLHttpRequest, textStatus) {
			updateBreadCrumb();
		}
	});	
}

function tncpopup(url) {
	var windowprops = "width=500, height=420, scrollbars=1";
	popup = window.open(url,"Terms",windowprops);
	popup.focus();
}

function ccpopup(url) {
	var windowprops = "width=680, height=430, scrollbars=1";
	popup = window.open(url,"Number",windowprops);
	popup.focus();
}

function updateFlashBanner (pPath) {
	var pDisplayCountry;
	if (pPath == "root") {sPath = "";} else {sPath = "../";}
	
	if (currentCountry=="AU" || currentCountry=="CN" || currentCountry=="JP" || currentCountry=="TH") {
		pDisplayCountry = currentCountry;
	}
	else {
		pDisplayCountry = "OC";
	}
	
	switch(currentLang) {
		case "en":
			var flashPath = "swf/masthead_EN.swf";	
			break;
		case "jp":
			var flashPath = "swf/masthead_JP.swf";	
			break;
		case "sc":
			var flashPath = "swf/masthead_CN.swf";	
			break;			
	}	

	var flashvars = {sCountry:pDisplayCountry};
	var params = {wmode: "transparent", allowScriptAccess: "Always", menu:"false"};
	swfobject.embedSWF(sPath+flashPath, "masthead", "830", "255", "9.0.0", "swf/expressInstall.swf", flashvars, params, "");
}

function changeCurrency (pSelectedCurrency) {

	if (pSelectedCurrency!="") {

		var originalCurrency = $('#currentCurrency').text();
		var newCurrencyCode = pSelectedCurrency;
		var originalExchangeRate = getExchangeRate(originalCurrency);
		var newExchangeRate = getExchangeRate(pSelectedCurrency);
	
		$('.price').each(function() {
			var tmpPricing = $('#'+$(this).attr('id')+'_org').text();
			var tmpUSPricing = tmpPricing * originalExchangeRate;
			var tmpnewPricing, newPricing;
	
			if (pSelectedCurrency == "USD") {
				tmpnewPricing = Math.round(tmpUSPricing);
			}
			else {
				tmpnewPricing = Math.round(tmpUSPricing / newExchangeRate);	
			}
	
			tmpnewPricing=tmpnewPricing.toString();
			tmpStringLength=tmpnewPricing.length;
			if (tmpStringLength > 6) {
				var newPricing = tmpnewPricing.replace(/(\d{1,})(\d{3,})(\d{3})/, "$1,$2,$3");		
			}
			else {
				var newPricing = tmpnewPricing.replace(/(\d{1,})(\d{3})/, "$1,$2");
			}
	
			// update the screen to reflect the selected currency and the new pricing
			$('#'+$(this).attr('id')+'_currency').text(newCurrencyCode);
			$(this).text(newPricing);
			
			if (currentLang == "jp") {
				$('<span></span>').html('~').appendTo(this);
			}			
			if (pSelectedCurrency == "IDR") {
				$('.currency').css({'margin-right': '100px'});
			}
			else {
				$('.currency').css({'margin-right': '0'});
			}
		});
	}
}

function getExchangeRate (pSelectedCurrency) {
	var exchangeRate;
	
	switch (pSelectedCurrency) {
		case "AUD":
			exchangeRate = 0.707;
			break;
		case "RMB":
			exchangeRate = 0.146;
			break;
		case "FJD":
			exchangeRate = 0.145;
			break;	
		case "HKD":
			exchangeRate = 0.129;
			break;			
		case "INR":
			exchangeRate = 0.019;
			break;			
		case "IDR":
			exchangeRate = 0.00009;
			break;			
		case "JPY":
			exchangeRate = 0.01;
			break;		
		case "KRW":
			exchangeRate = 0.00074;
			break;			
		case "MYR":
			exchangeRate = 0.275;
			break;			
		case "XPF":
			exchangeRate = 0.0108;
			break;		
		case "NZD":
			exchangeRate = 0.56;
			break;			
		case "SGD":
			exchangeRate = 0.66;
			break;		
		case "TWD":
			exchangeRate = 0.0295;
			break;			
		case "THB":
			exchangeRate = 0.028;
			break;
		case "VUV":
			exchangeRate = 0.009;
			break;	
		case "USD":
			exchangeRate = 1;
			break;				
		}

		return exchangeRate;
}

function getCurrencyCode (pCode) {
	var currencyCode;
	
	switch (pCode) {
		case "AU": case "AUD":		
			currencyCode = "AUD";
			break;
		case "KH": case "GU": case "MV": case "VN": case "USD": case "ID": case "IDR":
			currencyCode = "USD";
			break;
		case "CN": case "RMB":
			currencyCode = "RMB";
			break;			
		case "FJ": case "FJD":
			currencyCode = "FJD";
			break;
		case "HK": case "HKD": case "MO":
			currencyCode = "HKD";
			break;			
		case "IN": case "INR":
			currencyCode = "INR";
			break;
		case "JP": case "JPY":
			currencyCode = "JPY";
			break;
		case "KR": case "KRW":
			currencyCode = "KRW";
			break;
		case "MY": case "MYR":
			currencyCode = "MYR";
			break;
		case "NC": case "XPF":
			currencyCode = "XPF";
			break;
		case "NZ": case "NZD":
			currencyCode = "NZD";
			break;
		case "SG": case "SGD":
			currencyCode = "SGD";
			break;
		case "TW": case "TWD":
			currencyCode = "TWD";
			break;				
		case "TH": case "THB":
			currencyCode = "THB";
			break;
		case "VU": case "VUV":
			currencyCode = "VUV";
			break;
		default:	
			currencyCode = "";
			break;					
		}

		return currencyCode;
}

function populateBreadCrumb() {
	
	var homeTextCopy,homeLink;

	switch(currentLang) {
		case "en":
			homeTextCopy = "ASIA PACIFIC";	
			homeLink = "../index.html";
			break;
		case "jp":
			homeTextCopy = "&#12450;&#12472;&#12450;&#22826;&#24179;&#27915;&#22320;&#22495;";	
			homeLink = "../jp.html";			
			break;
		case "sc":
			homeTextCopy = "&#20122;&#22826;&#22320;&#21306;";	
			homeLink = "../cn.html";			
			break;			
	}	

	var currentCountryText = $('#currentCountry').html();
	$('#breadcrumb').empty();
	$('<span></span>').html('<a href="'+homeLink+'">'+homeTextCopy+'</a> > ').appendTo('#breadcrumb');
	$('<span id="country_breadcrumb"></span>').html(currentCountryText).appendTo('#breadcrumb');
}

function updateBreadCrumb() {
	populateBreadCrumb();
	
	var currentCountryText = $('#currentCountry').html();
	var currentCityText = $('#country_header').html();
	if (currentCountry!="HK" && currentCountry!="MO" && currentCountry!="TW" && currentCountry!="KH" && currentCountry!="FJ" && currentCountry!="GU" && currentCountry!="NZ" && currentCountry!="SG" && currentCountry!="VU" && currentCountry!="KR" && currentCountry!="VN") {
		$('#country_breadcrumb').empty();
		$('<span id="country_breadcrumb"></span>').html('<a href="#" onclick="displayCities_pre()\;return false\;">'+currentCountryText+'</a> > ').appendTo('#breadcrumb');		
	} else {
		// to do: switch country codes and append country to breadcrumb.
		var txtCountry = '';
		switch (currentCountry)
		{
			case 'HK':
				txtCountry = '';
				break;
			case 'MO':
				txtCountry = '';
				break;
			case 'TW':
				txtCountry = 'Taiwan > ';
				break;
			case 'KH':
				txtCountry = 'Cambodia > ';
				break;
			case 'FJ':
				txtCountry = '';
				break;
			case 'GU':
				txtCountry = 'Guam > ';
				break;
			case 'NZ':
				txtCountry = 'New Zealand > ';
				break;
			case 'SG':
				txtCountry = '';
				break;
			case 'VU':
				txtCountry = 'Vanuatu > ';
				break;
			case 'KR':
				txtCountry = 'Korea > ';
				break;
			case 'VN':
				txtCountry = '';
				break;
		}
		$('<span id="country_breadcrumb"></span>').text(txtCountry).appendTo('#breadcrumb');
	}
	$('<span></span>').html(currentCityText).appendTo('#breadcrumb');
}

function populateSPGBanner() {
	switch(currentLang) {
		case "en":
			var flashPath = "../swf/spg_banner_EN.swf";	
			break;
		case "jp":
			var flashPath = "../swf/spg_banner_JP.swf";	
			break;
		case "sc":
			var flashPath = "../swf/spg_banner_CN.swf";	
			break;			
	}		
	var params = {wmode: "transparent", allowScriptAccess: "Always", menu:"false"};
	//swfobject.embedSWF(flashPath, "spg_banner", "656", "95", "9.0.0", "../swf/expressInstall.swf", "", params, "");	
}

function collapseFlashBanner() {
	$("#masthead_container").animate({height:'85'}, "slow");	 
	$('#overlay_container').animate({marginTop:'48'}, "slow");	 
}

function expandFlashBanner() {
	$("#masthead_container").animate({height: '255'}, "slow");	
	$('#overlay_container').animate({marginTop:'218'}, "slow");		
}