function launchLightWindowWithURL(url, confirmClose) {
	myLightWindow.activateWindow({
		closeConfirmation: confirmClose,
		href: url, 
		title: '', 
		author: '', 
		caption: '', 		
		width: 750, 
		height:600
	});
}

function checkSection() {
	//var url = location.href.toLowerCase();
	var url = window.location.href.toLowerCase();
	if (url.indexOf("#business") > 0) {
		homeConf.homeSwfVars += "&section=1";
	} else if (url.indexOf("#leisure") > 0) {
		homeConf.homeSwfVars += "&section=2";
	} if (url.indexOf("#meeting") > 0) {
		homeConf.homeSwfVars += "&section=3";
	}
}

function writeSwf(id) {
	checkSection();
	
	
		genSoSwf(id, homeConf.homeSwf, 1000, 550, homeConf.homeSwfVars, null, "9.0.45", homeConf.expressInstallSwf);
		

		
	

}
function getHomePrefix() {
	return homeConf.prefix;
}
function getHomeXml() {
	return homeConf.prefix + "../showAction.do?action=landing";
}
function getSiteXml() {
	return homeConf.prefix + "swf/xml/sidemenu_home.xml";
}
//function getLoginUrl() {
//	return "login.php";
//}
//function getSearchUrl() {
//	return "search.php";
//}
//function getVirtuallyThereUrl() {
//	return "virtuallyThere.php";
//}

function onFlashCommand(cmd) {

	//add by kenneth
	var url = window.location.href.toLowerCase();
	var sectionName ="";
	if (url.indexOf("#business") > 0) {
		sectionName = "business";
	}
	if (url.indexOf("#leisure") > 0) {
		sectionName = "leisure";
	}
	if (url.indexOf("#meeting") > 0) {
		sectionName = "meeting";
	}
	
	if (sectionName == "") {
		sectionName = "leisure";
	}
	
	switch (cmd) {
		case "specialOffers":
			location.href = homeConf.prefix + "./"+sectionName+"/specialoffers/specialOffersVisitorAction.do?action=visitorSpecialOffer";
			break;
		case "logo":
		case "home":
			location.href = homeConf.prefix + "index.html";
			break;
		
		case "forgetPassword":
			location.href = homeConf.prefix + "./"+sectionName+"/membership/membership_common.jsp?launcher=forgetPassword";
			break;
		case "register":
			alert("register");
			break;

		case "virtuallyThere":
			var refno = arguments[1];
			var lastname = arguments[2];
			window.location = 'http://www.virtuallythere.com/new/homePage.html?pnr=' + refno + '&name=' + lastname + '&language=0&host=&pcc=&clocktype=12&error=&nosub=N';
			break;

		case "virtuallyTherePic":
			//location.href = "http://www.hongkongairport.com/flightinfo/eng/header.html";
			window.open("http://www.hongkongairport.com/flightinfo/eng/chkfltarr.html");
			break;

		case "destinationHighlights":
			window.location = 'leisure/destination/destinationAction.do?action=detail';
			break;

		case "inbound":
			location.href = homeConf.prefix + "meeting/inbound/servnspec.jsp";
			break;
		case "outbound":
			location.href = homeConf.prefix + "meeting/outbound/st_mice_experience.jsp";
			break;

		case "about":
			alert("about");
			break;
		case "contactus":
			myLightWindow.activateWindow({
				closeConfirmation: false,
				href: 'contact_us.jsp#' + sectionName, 
				title: '', 
				author: '', 
				caption: '', 		
				width: 750, 
				height:600
			});
			break;
		case "sitemap":
			myLightWindow.activateWindow({
				closeConfirmation: false,
				href: 'site_map_frame.jsp', 
				title: '', 
				author: '', 
				caption: '', 		
				width: 750, 
				height:600
			});
			break;
		case "disclaimer":
			myLightWindow.activateWindow({
				closeConfirmation: false,
				href: 'disclaimer_frame.jsp', 
				title: '', 
				author: '', 
				caption: '', 		
				width: 750, 
				height:600
			});
			break;
		case "copyright":
			myLightWindow.activateWindow({
				closeConfirmation: false,
				href: 'copyright_frame.jsp', 
				title: '', 
				author: '', 
				caption: '', 		
				width: 750, 
				height:600
			});
			break;
		case "anniversary":
			window.location = 'anniversary/aboutswiretravel/ourcompany.jsp';
			break;

		case "jumpSection":
			var section = arguments[1];
			fixSectionPath(section);
			break;

		case "search":
			var keyword = arguments[1];
			var type = arguments[2];
			
			var url = window.location.href.toLowerCase();
			window.location = sectionName + '/search/landingSearchAction.do?action=search&type=' + type + '&keyword=' + keyword;
			
			break;
		case "loginSuccess":
			var memberId = arguments[1];
			var memberType = arguments[2];
			
			if (memberType == "Corporate Member") {
				myLightWindow.activateWindow({
					closeConfirmation: false,
					href: sectionName + '/membership/membership_registernag_frame.jsp', 
					title: '', 
					author: '', 
					caption: '', 		
					width: 750, 
					height:600
				});
			}
			
			break;
			
		case "specialPromotions":
			var url = arguments[1];
			if (url.indexOf('airfarePromotionVisitorAction.do') == -1) {
				launchLightWindowWithURL(getSectionName() + "/" + url, true);
			}
			
			else {
				window.location = getSectionName() + "/" + url;
			}
			break;
			
		case "hotnews":
			var url = arguments[1];
			window.location = getSectionName() + "/" + url;
			break;
	}
}

function getSectionName() {
	var url = window.location.href;
	if (url.indexOf("#business") > -1) {
		return "business";
	} else if (url.indexOf("#leisure") > -1) {
		return "leisure";
	} else if (url.indexOf("#meeting") > -1) {
		return "meeting";
	}
	
	return "";
}

function fixSectionPath(section) {
	var sectionName;
	switch (section) {
		case 1:
			sectionName = "business";
			break;
		case 2:
			sectionName = "leisure";
			break;
		case 3:
			sectionName = "meeting";
			break;
		default:
			return;
	}
	//location.href = "#" + sectionName;
	window.location = "#" + sectionName;
}

