
// ---------------
// --- Browser ---
// ---------------

var browser = new Object();

browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
browser.notIE = (browser.isMozilla  ||  browser.isMozilla  ||  browser.isOpera);
browser.isIE = window.ActiveXObject ? true : false;


// ----------------------
// --- Object / DHTML ---
// ----------------------

var DHTML = (document.getElementById != null || document.all != null || document.layers != null);

function getObj(id)
{
	if (document.getElementById)
		return document.getElementById(id);

	else if (document.all)
		return document.all[id];

	else if (document.layers)
		// if using nested layers in Netscape 4:
		// return getObjNN4(document,id);
		// comment-out if using line above:
		return document.layers[id];
}

/* if using nested layers in Netscape 4:
function getObjNN4(obj,id)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == id)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],id);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}
*/


// -------------
// --- Style ---
// -------------

function setVisi(item, flag)
{  // 1 - show, 0 - hide
	if (!DHTML) return;
	if (typeof item == 'string') {
		var e = new getObj(item);
		e.className = (flag) ? 'visible' : 'hidden';
	}
	else
		item.className = (flag) ? 'visible' : 'hidden';
}

function setColor(item, col)
{  // 1 - show, 0 - hide
	if (!DHTML) return;
	if (typeof item == 'string') {
		var e = new getObj(item);
		e.style.color = col;
	}
	else
		item.style.color = col;
}

function setBgColor(item, col)
{  // 1 - show, 0 - hide
	if (!DHTML) return;
	if (typeof item == 'string') {
		var e = new getObj(item);
		e.style.backgroundColor = col;
	}
	else
		item.style.backgroundColor = col;
}

function getStyle(id)
{
	if (document.getElementById)
		return document.getElementById(id).style;

	else if (document.all)
		return document.all[id].style;

	else if (document.layers)
		return document.layers[id].style;
}

function getStyleProp(e,styleProp) {
	// Explorer: fontSize, fontFamily, backgroundColor, margin, padding, backgroundImage, etc.
	if (e.currentStyle)  // Explorer
		return e.currentStyle[styleProp];
	// Mozilla: font-size, font-family and background-color
	else if (window.getComputedStyle)  // Mozilla, Opera
		return document.defaultView.getComputedStyle(e,null).getPropertyValue(styleProp);
}

function getSize(e) {
	if (browser.notIE)
		return getStyleProp(e,'font-size');
	else  // browser.isIE
		return getStyleProp(e,'fontSize');
}

function getFamily(e) {
	if (browser.notIE)
		return getStyleProp(e,'font-family');
	else  // browser.isIE
		return getStyleProp(e,'fontFamily');
}

function getIsBold(e) {
	var b;
	if (browser.notIE)
		b = getStyleProp(e,'font-weight');
	else  // browser.isIE
		b = getStyleProp(e,'fontWeight');
	if (b == 'bold')
		return true;
	else if (b == '401')
		return true;
	else
		return false;
}


// ----------------
// --- Position ---
// ----------------

function getPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function getPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}