/******************** COMMON FUNCTIONS ********************/

//***** Get the value of a variable from the url query string ***** //
//eg. for "...index.html?color=red, getQryValue("color") will return "red";
function getQryValue(name) {
	var aryQry = window.location.search.substr(1).split("&");
	for (var i=0; i<aryQry.length; i++) {
		var aryNameValue = aryQry[i].split("=");
		if (aryNameValue[0]==name && aryNameValue[1]!='') {
			return unescape(aryNameValue[1]);	
		}
	}
	return false; //no such name found
}

//***** Embed a generic (minimal) popup page in the given dimensions ***** //
function launchPopup(url, width, height) {
	var winPopup = window.open(url, "winPopup", "height="+height+",innerHeight="+height+",width="+width+",innerWidth="+width+",left="+getPopupLeft(width)+",top="+getPopupTop(height)+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0", ""); 
	winPopup.resizeTo(width,height);
	winPopup.moveTo(getPopupLeft(width),getPopupTop(height));
	winPopup.focus();
}
function launchXmas() {
	var width = 960; var height = 740;
	var xmasPopup = window.open("/features/2007/xmas/", "xmasPopup", "height="+height+",width="+width+",left="+getPopupLeft(width)+",top="+getPopupTop(height)+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0", "");
	xmasPopup.focus();
}





//***** Embed a generic flash movie using SWFObject ***** //
//eg. usage : embedFlash("/showbiz/movietrailer/swf/movieslider.swf", 545, 190, "movieslider", "slider");
//@param "swfUrl" : full url path of the swf movie
//@param "swfWidth" : width of swf movie, in pixels
//@param "swfHeight" : height of swf movie, in pixels
//@param "trgId" : id of the HTML element to embed the swf object into
//@param "swfName" [optional] : the id to assign to this swf object after embedding
function embedFlash(swfUrl, swfWidth, swfHeight, trgId, swfName, opaque) {
	if (!swfName) var swfName = "flashObj";
	var so = new SWFObject(swfUrl, swfName, swfWidth, swfHeight, "8", "");
	if (!opaque) so.addParam("wmode", "transparent"); //eg. logo.swf needs to be opaque to cover up bgrd
	so.addParam("salign", "lt");
	so.addParam("allowScriptAccess", "always");
	if (trgId=="branding_nav") so.addVariable("mainSect", "nav_"+document.body.id);
	//so.addParam("FlashVars", "mainSect=nav_" + document.body.id); //for menu.swf
	so.useExpressInstall('/global/common/swf/expressinstall.swf');
	so.write(trgId);
}


/******************** COMMON POPUP WINDOWS ********************/
function xingdonging(){
	var width = 400; var height = 450; var url = "http://mobile.omy.sg/omy/sph/sph_landing.jsf";
	var xingdongingPopup = window.open(url, "xingdongingPopup", "height="+height+",width="+width+",left="+getPopupLeft(width)+",top="+getPopupTop(height)+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0", ""); xingdongingPopup.focus();
}
function tc_member(){
	var width = 740; var height = 600; var url = "http://www.omy.sg/login/tc_member.html";
	var loginPopup = window.open(url, "loginPopup", "height="+height+",width="+width+",left="+getPopupLeft(width)+",top="+getPopupTop(height)+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=1,toolbar=0", ""); loginPopup.focus();
}
function tc_user(){
	var width = 740; var height = 600; var url = "http://www.omy.sg/login/tc_user.html";
	var loginPopup = window.open(url, "loginPopup", "height="+height+",width="+width+",left="+getPopupLeft(width)+",top="+getPopupTop(height)+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=1,toolbar=0", ""); loginPopup.focus();
}
function copyright(){
	var width = 770; var height = 600; var url = "http://www.omy.sg/login/copyright.pdf";
	var loginPopup = window.open(url, "loginPopup", "height="+height+",width="+width+",left="+getPopupLeft(width)+",top="+getPopupTop(height)+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0", ""); loginPopup.focus();
}
function login(url) {
	var width = 400; var height = 450;
	var loginPopup = window.open(url, "loginPopup", "height="+height+",width="+width+",left="+getPopupLeft(width)+",top="+getPopupTop(height)+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0", ""); loginPopup.focus();
}


/* to center popup windows */
function getPopupLeft(width) {
	screenX = screen.width; return (screenX-width)/2;
}
function getPopupTop(height) {
	screenY = screen.height; return (screenY-height)/2;
}
function closePopup() {
	window.close();
}


//***** Browser detection - determines which stylesheet to load ***** //
function Is() {
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla') != -1) && (agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1));
	this.ns6 = (this.ns && (this.major >= 5));
	this.ie = (agent.indexOf("msie") != -1);
	this.ie55 = (agent.indexOf("msie 5.5") != -1);
	this.ie6 = (agent.indexOf("msie 6.0")!=-1);
	this.ie7 = (agent.indexOf("msie 7.0")!=-1);
}
var is = new Is();
if (is.ie) document.write('<link rel="stylesheet" type="text/css" href="http://www.omy.sg/global/common/css/styleie.css" media="all" />');
else document.write('<link rel="stylesheet" type="text/css" href="http://www.omy.sg/global/common/css/stylens.css" media="all" />'); 
/*
if (is.ie) document.write('<style type="text/css" media="all">@import "http://www.omy.sg/global/common/css/styleie.css";</style>');
else document.write('<style type="text/css" media="all">@import "http://www.omy.sg/global/common/css/stylens.css";</style>'); 
*/
//***** Used to collapse sections on all leftnav.html includes ***** //
function showHide(el,a){
	var eye=document.getElementById(el);
	var ball=(eye.className=='hidden')?"visible":"hidden";
	var see=(ball=='hidden')?'none':'block';
	eye.style.display=see;
	eye.className=ball;
	if(arguments.length == 2){
		var clss = document.getElementById(a);
		var name = (clss.className=='showLink')?'hideLink':'showLink';
		clss.className=name;
	}
}
//******************************************************* //



 

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(){
	var title = 'OMY';
	var url = 'http://www.omy.sg';
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if (window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if (document.all)// ie
		window.external.AddFavorite(url, title);
}

/*DO NOT REMOVE, THIS SCRIPT IS MEANT TO SYNCHRONISE ACROSS TWO PLATFORMS */
function logo(add, widthx, heighty){
	var add;
	var widthx;
	var heighty;
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+widthx+'" height="'+heighty+'"><param name=movie value="'+add+'"><param name=allowScriptAccess value=always><param name=quality value=high><param name=bgcolor value=#ffffff><param name=wmode value=opaque><embed src="'+add+'" quality=high scale=exactfit wmode=opaque bgcolor=#ffffff pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+widthx+'" height="'+heighty+'"></embed></object>')
}