function getBrowserWidth() {
    if (navigator.userAgent.indexOf("MSIE") > 0)
        return document.body.clientWidth
    else
        return window.outerWidth
}

function getBrowserHeight() {
    if (navigator.userAgent.indexOf("MSIE") > 0)
        return document.body.clientHeight
    else
        return window.outerHeight
}

function getBrowserLeft() {
    if (window.screenLeft)
        return window.screenLeft
    else
        return window.screenX
}

function getBrowserTop() {
    if (window.screenTop)
        return window.screenTop
    else
        return window.screenY
}

function displayElementCentered(element) { 
	// Get center of browser window
    var X = getBrowserWidth() / 2
    var Y = getBrowserHeight() / 2
 
	element.style.position = 'absolute'
	// Element has to have it's width and height set in CSS. clientWidth and clientHeight are 0
    element.style.left = X - (element.style.width.substr(0,element.style.width.length-2) / 2)
    element.style.top = Y - (element.style.height.substr(0,element.style.height.length-2) / 2)
    element.style.display = ''
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		curleft = obj.offsetLeft
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop
			curleft += obj.offsetLeft
		}
	}
	return [curtop, curleft];
}