var MOUSE_X=0;
var MOUSE_Y=0;

var POS_LEFT=0;
var POS_TOP=0;

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousedown = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousedown = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousedown = captureMousePosition;
}

function returnWindowCenterPos2(w, h) {
	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var popW = 300, popH = 200;

	POS_LEFT = (w-popW)/2;
	POS_TOP = (h-popH)/2;
}


_movePopWindowTrigger = false;
_popWindowOffsetX = 0;
_popWindowOffsetY = 0;
_lastPopWindowLeft = 0;
_lastPopWindowTop = 0;

function returnWindowCenterPos(ww, hh) {
/*
  //var w = 480, h = 340;
  if (document.all) {
    // the following is only available after onLoad 
    w = document.body.clientWidth;
    h = document.body.clientHeight;
    x = window.screenTop;
    y = window.screenLeft;
  }
  else {
    w = window.innerWidth;
    h = window.innerHeight;
    x = window.screenX;
    y = window.screenY;
  }
  var popW = ww, popH = hh;
  var leftPos = ((w-popW)/2)+y, topPos = ((h-popH)/2)+x;
  //alert(leftPos + ", " + topPos);
  POS_LEFT = leftPos;
  POS_TOP = topPos;
  //window.open(url,'popup','width='+popW+',height='+popH+',top='+topPos+',left='+leftPos);
*/

    //resize element...
    //popwindiv.style.width = w + 'px';
    //popwindiv.style.height = (h + parseInt(popwingui.offsetHeight)) + 'px';
	//popwiniframe.style.width = w - 2 + 'px';
	////popwiniframe.style.height = h + 'px';

    //position the popup
	//alert("innerHeight=" + window.innerHeight + ", clientHeight=" + document.body.clientHeight + ", scrollTop=" + document.body.scrollTop + ", clientWidth=" + document.body.clientWidth + ", scrollLeft=" + document.body.scrollLeft);
	
	if (BrowserDetect.browser=="Safari") {
		POS_TOP = _lastPopWindowTop = (parseInt((window.innerHeight / 2) - (parseInt(hh) / 2)) + document.body.scrollTop);// + 'px';
	} else {
		POS_TOP = _lastPopWindowTop = (parseInt((document.body.clientHeight / 2) - (parseInt(hh) / 2)) + document.body.scrollTop);// + 'px';
	}
	
	//POS_TOP = _lastPopWindowTop = (parseInt((document.body.clientHeight / 2) - (parseInt(hh) / 2)) + document.body.scrollTop);// + 'px';
	POS_LEFT = _lastPopWindowLeft = (parseInt((document.body.clientWidth / 2) - (parseInt(ww) / 2)) + document.body.scrollLeft);// + 'px';
	/*
    if(document.all){
		//patch position for MSIE
		POS_TOP = _lastPopWindowTop = (parseInt((document.body.clientHeight / 2) - (parseInt(hh) / 2)) + document.body.scrollTop);// + 'px';
		POS_LEFT = _lastPopWindowLeft = (parseInt((document.body.clientWidth / 2) - (parseInt(ww) / 2)) + document.body.scrollLeft);// + 'px';
    	//emulate fixed position.
        //window.onscroll = window.onresize = _MSIEpositionPopWindow;
    } else {
		//set position other browsers
		POS_TOP = ((window.innerHeight / 2) - (hh / 2));// + 'px';
		POS_LEFT = ((window.innerWidth / 2) - (ww / 2));// + 'px';
    }
	*/
}

function captureMousePosition(e) {
	var xMousePos = 0; // Horizontal position of the mouse on the screen
	var yMousePos = 0; // Vertical position of the mouse on the screen
	var xMousePosMax = 0; // Width of the page
	var yMousePosMax = 0; // Height of the page
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }

	MOUSE_X=xMousePos;
	MOUSE_Y=yMousePos;
	//alert(MOUSE_X + ", " + MOUSE_Y);
}

function rollOver(obj) {
	obj.src = "../images/" + obj.id + "On.gif";
}

function rollOut(obj) {
	obj.src = "../images/" + obj.id + "Of.gif";
}

function goSection(s) {
	//location.replace("../" + s + "/overview.php");
	var sPage="";
	switch (s) {
		case "macao": sPage = "overview.php"; break;
		case "msc": sPage = "overview.php"; break;
		case "partners": sPage = "hotels.php"; break;
		case "retail": sPage = "overview.php"; break;
		case "taubman": sPage = "background.php"; break;
		case "home" : sPage = "index.php"; break;
		case "contactus" : sPage = "index.php"; break;
		case "signup" : sPage = "index.php"; break;
		case "signout" : s = "member"; sPage = "logout.php"; break;
		case "news" : sPage = "index.php"; break;
		case "gallery" : sPage = "index.php"; break;
	
	}
	location.replace("../" + s + "/" + sPage);
}

function showSection(s) {
	document.getElementById(s).style.display = "block";
}

function hideSection(s) {
	document.getElementById(s).style.display = "none"; 
}

function openDisclaimer() {
	popupWin(670, 670, "../home/disclaimer.php", "Disclaimer", "");
}

function openPrivacy() {
	popupWin(670, 670, "../home/privacy.php", "Privacy", "");
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
//alert(BrowserDetect.browser);

function processFlashBanner(s) {
	if (s=="show") {
		if (BrowserDetect.OS=="Mac") {
			document.getElementById("FlashBanner").style.visibility = 'visible';
		}
	} else if (s=="hide") {
		if (BrowserDetect.OS=="Mac") {
			document.getElementById("FlashBanner").style.visibility = 'hidden';
		}
	}
}







function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}



function windowSize() {
	var width = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
	var height = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
	var x = window.pageXOffset || (window.document.documentElement.scrollLeft || window.document.body.scrollLeft);
	var y = window.pageYOffset || (window.document.documentElement.scrollTop || window.document.body.scrollTop);		
	
	return {'width':width, 'height':height, 'x':x, 'y':y}
}

function setContainerPos(){	
	var left = ((windowSize().width-$('layout').offsetWidth)/2);
	var top = ((windowSize().height-$('layout').offsetHeight)/2);
	if (left < 0){left =0;}
	if (top < 0){top =0;}
	$('layout').style.left =left+'px';
	$('layout').style.top =top+'px';
}
function init(){
	setContainerPos();
}
Event.observe(window, 'resize', setContainerPos, false);
Event.observe(window, 'load', init, false);




 