var sPop = null;

function $(id) {
	return document.getElementById(id);
}

document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText { font-family: Tahoma,Verdana; background-color: #FFFFDD; border: 1px #000000 solid; font-size: 11px; padding-right: 5px; padding-left: 5px; line-height: 15px; padding-top: 3px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=100)}");
document.write("</style>");
document.write("<div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>");

function showPopupText(event) {
	if(event.srcElement) o = event.srcElement; else o = event.target;
	if(!o) {
		return;
	}
	MouseX = event.clientX;
	MouseY = event.clientY;
	if(o.alt != null && o.alt != '') {
		o.pop = o.alt;
		o.alt = '';
	}
	if(o.title != null && o.title != '') {
		o.pop = o.title;
		o.title = '';
	}
	if(o.pop != sPop) {
		sPop = o.pop;
		if(sPop == null || sPop == '') {
			$('popLayer').style.visibility = "hidden";
		} else {
			popStyle = o.dyclass != null ? o.dyclass : 'cPopText';
			$('popLayer').style.visibility = "visible";
			showIt();
		}
	}
}

function showIt() {
	$('popLayer').className = popStyle;
//	$('popLayer').innerHTML = sPop.replace(/<(.*)>/g,"&lt;$1&gt;").replace(/\n/g,"<br>");
	$('popLayer').innerHTML = sPop.replace(/\n/g,"<br>");
	var popWidth = $('popLayer').clientWidth;
	var popHeight = $('popLayer').clientHeight;
	var popLeftAdjust = MouseX + 12 + popWidth > document.body.clientWidth ? -popWidth - 24 : 0;
	var popTopAdjust = MouseY + 12 + popHeight > document.body.clientHeight ? -popHeight - 24 : 0;
	$('popLayer').style.left = (MouseX + 12 + document.body.scrollLeft + popLeftAdjust) + 'px';
	$('popLayer').style.top = (MouseY + 12 + document.body.scrollTop + popTopAdjust) + 'px';
}

if(!document.onmouseover) {
	document.onmouseover = function(e) {
		var event = e ? e : window.event;
		showPopupText(event);
	};
}
