/////////////// rollover and preload images /////////////////////////////

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/////////////// generate menu bar, header and footer /////////////////////////////

function gen_footer() 
{
	document.write("<table width='100%' border='0' cellpadding='0' cellspacing='0'>")
	document.write("<tr>")
	document.write("<td width='20'><img src='images/img_footer_l.gif' width='20' height='34'></td>")
	document.write("<td background='images/img_footer_m.gif' class='footer'>")
	document.write("Updated March 2006 &copy; Mandarin Oriental Macau")
	document.write(" | ")
	document.write("<a href='#' class='footer_link'>Privacy Policy</a>")
	document.write(" | ")
	document.write("<a href='#' class='footer_link'>Term of Use</a>")
	document.write("</td>")
	document.write("<td width='20'><img src='images/img_footer_r.gif' width='20' height='34'></td>")
	document.write("</tr>")
	document.write("</table>")
}

/////////////// popup window script /////////////////////////////

function popup_terms_window(theURL,winName) {  
win_w = 780;
win_h = 520;
loc_x = (window.screen.width - win_w)/2;
loc_y = (window.screen.height - win_h)/2;
s = 1;
r = 1;
settings = 'height=' + win_h + ',width=' + win_w + ',top=' + loc_y + ',left=' + loc_x + ',scrollbars=' + s + ',resizable=' + r;
window.open(theURL,winName,settings);
}





function changeLanguage(lang)
			{  		
  			// don't need to set cookie here; it will be set on postback		
				
				// get url, strip any lang parameters out of querystring				
				var url = self.location.pathname;
				var qs = self.location.search;
				var qlang = '';
				qs = qs.replace(/lang=[a-zA-Z]{2}-[[a-zA-Z]]{2,3}/g,'');
				
				// remove current language from the path
				//alert(url.replace(/\/[a-zA-Z]{2}-[a-zA-Z]{2,3}/g, ''));
				url = url.replace(/[a-zA-Z]{2}-[a-zA-Z]{2,3}\//, '');
				// add new language to path				
				url = '/' + lang + url;
				
				self.location = url + qs;
			}

			function Set_Cookie(name,value,expires,path,domain,secure)
			{
				document.cookie = name + "=" + escape(value) +
						( (expires) ? ";expires=" + expires.toGMTString() : "") +
						( (path) ? ";path=" + path : "") +
						( (domain) ? ";domain=" + domain : "") +
						( (secure) ? ";secure" : "");
			}	