common.js 1.1 KB
/*
 * This should become a kind of abstraction for browser specific
 * stuff.
 */
function browserGlobals ()
{
	if(navigator.appName=='Netscape' &&
		navigator.appVersion.charAt(0)=='4')
	{
		this.browser     = 'NS';
		this.innerWidth  = function () { return window.innerWidth; }
		this.innerHeight = function () { return window.innerHeight; }
	}
	else
	if(navigator.appName=='Microsoft Internet Explorer' &&
		navigator.appVersion.charAt(0)>='4')
	{
		this.browser     = 'IE';
		this.innerWidth  = function () { return document.body.offsetWidth; }
		this.innerHeight = function () { return document.body.offsetHeight; }
	}
	else
	{
		this.browser     = 'DOM';
		this.innerWidth  = function () { return window.innerWidth; }
		this.innerHeight = function () { return window.innerHeight; }
	}
}

var bGlobals = new browserGlobals ();

function objectPos (id, posX, posY)
{
	var ob = document.getElementById (id);
	var offsetX = (posX < 0) ? bGlobals.innerWidth () : 0;
	var offsetY = (posY < 0) ? bGlobals.innerHeight () : 0;

	if (posX != 0)
		ob.style.left = offsetX + posX;

	if (posY != 0)
		ob.style.top = offsetY + posY;
}