function getElement( id){
	if( document.all)
		return document.all( id);
	if( document.getElementById)
		return document.getElementById( id);
}

function getElementInWindow( win, id){
	if( win.document.all) {
		return win.document.all( id);
	}
	if( win.document.getElementById) {
		return win.document.getElementById( id);
	}
}

function getElementsByClassName( classname) { 
	var result = new Array(); 
	var elem = document.getElementsByTagName( '*');
	var thiselem;
	for( var i = 0; i < elem.length; i++)	{
		thiselem = elem[i];
		if( thiselem.className == classname) {
			result[result.length] = thiselem;
		}
	}
	return result;
}

function openNewWindow( location, w, h) {
	window.open( location, '', 'menubar=0,resizable=1,width=' + w + ',height=' + h); 
}

function openNewWindow( location, w, h, options) {
	window.open( location, '', (options == '' ? '' : options + ',') + 'menubar=0,resizable=1,width=' + w + ',height=' + h); 
}

function findPosX( 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 findPosY( 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;
}

function showTooltip( show, divid, e) {
	var tooltip = getElement( 'tooltip');
	var aligndiv = getElement( divid);
	if( show) {
		if( tooltip.style.visibility != 'visible') {
			tooltip.innerHTML = itemdesc[divid];
			tooltip.style.left = (findPosX( aligndiv) + ((aligndiv.offsetWidth - tooltip.offsetWidth) / 2)) + 'px';
			tooltip.style.top = (findPosY( aligndiv) + aligndiv.offsetHeight + 5) + 'px';
			tooltip.style.visibility = 'visible';
		}
	} else {
		tooltip.style.visibility = 'hidden';
	}
}

