function elStyle(el)
{
	if (document.getElementById) 
	{ 
		// DOM3 = IE5, NS6
		return el.style;
	}
	else {
		if (document.layers) 
		{ 
			// Netscape 4
			return el;
		}
		else 
		{ 
			// IE 4
			return el.style;
		}
	}
}

function getEl(id)
{
	if (document.getElementById) 
	{ 
		// DOM3 = IE5, NS6
		return document.getElementById(id);
	}
	else 
	{
		if (document.layers) 
		{ 
			// Netscape 4
			return document.id;
		}
		else 
		{ 
			// IE 4
			return document.all.id;
		}
	}
}

function elStyleId(id)
{
	return elStyle(getEl(id));
}

function elHide(id)
{
	//safe function to hide an element with a specified id
	var elStyle = elStyleId(id);
	if (elStyle)
		elStyle.display = 'none';
}

function elShow(id)
{
	//safe function to show an element with a specified id
	var elStyle = elStyleId(id);
	if (elStyle)
		elStyle.display = 'block';
}

function elToggle(id)
{
	var elStyle = elStyleId(id);
	if (elStyle && elStyle.display != 'block')
		elShow(id);
	else
		elHide(id);
}

function elLeft(el)
{
    if (!el && this)                       // if argument is invalid
    {                                            // (not specified, is null or is 0)
        el = this;                         // and function is a method
    }                                            // identify the element as the method owner
    
    var nLeftPos = el.offsetLeft;          // initialize var to store calculations
    var eParElement = el.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}

function elTop(el)
{
    if (!el && this)
    {
        el = this;
    }

    var nTopPos = el.offsetTop;
    var eParElement = el.offsetParent;
    while (eParElement != null)
    {
        nTopPos += eParElement.offsetTop;
        eParElement = eParElement.offsetParent;
    }
    return nTopPos;
}

function elHeight(id) 
{
	var el = getEl(id);
	
	if (document.getElementById) 
	{	
		// DOM3 = IE5, NS6
//alert(el.offsetHeight);
		return el.offsetHeight;
	}
	else 
	{
		if (document.layers) 
		{ 
			// Netscape 4
			return el.clip.height;
		}
		else 
		{ 
			// IE 4 (opera 5)
			return el.style.pixelHeight;
		}
	}
}

function elWidth(id) 
{
	var el = getEl(id);
	
	if (document.getElementById) 
	{	
		// DOM3 = IE5, NS6
		return el.offsetWidth;
	}
	else 
	{
		if (document.layers) 
		{ 
			// Netscape 4
			return el.clip.width;
		}
		else 
		{ 
			// IE 4 (opera 5)
			return el.style.pixelWidth;
		}
	}
}

function pointFromMouse(e)
{
    var mousex = 0;
    var mousey = 0;

    if (!e) 
		e = window.event;

    if (e.pageX || e.pageY)
    {
		mousex = e.pageX;
		mousey = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
		mousex = e.clientX + document.documentElement.scrollLeft;
		mousey = e.clientY + document.documentElement.scrollTop;
    }

	return new GPoint(mousex, mousey);
}

function clientHeight() 
{
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement &&
	    ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
    {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}
function clientWidth() 
{
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
	} 
	else if( document.documentElement &&
	    ( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}


function listSelectItem(id)
{
	var item_el = document.getElementById(id);
	if (item_el)
		item_el.className = "curitem";	
}

function listClearSels(curEl)
{
	if (!curEl)
		curEl = document.documentElement;
	
	if (curEl)
	{
		if (curEl.id)
		{
			if (curEl.id.substr(0, 4) == "item")
				curEl.className = "item";
		}
	
		// Traverse the tree
		var i = 0;
		var childEl = curEl.childNodes[i];
		while (childEl)
		{
			// Recursively traverse the tree structure of the child node
			listClearSels(childEl);
			i++;
			childEl = curEl.childNodes[i];
		}
	}
}

function isValidId(id)
{
	var id2 = parseInt(id);
	if (!isNaN(id2))
	{
		if (id2 >= 0)
			return true;
	}
	return false;
}

function isNewId(id)
{
	var id2 = parseInt(id);
	if (!isNaN(id2))
	{
		if (id2 == -1)
			return true;
	}
	return false;
}

function validId(id)
{
	if (isValidId(id))
		return parseInt(id);
	else
		return -2;
}