var IE = document.all ? true : false;
var aPos = null;
var oTarget = null;

if (!IE) document.captureEvents(Event.ONCLICK);
document.onclick = get_click_pos;

function get_click_pos(e) {
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	oTarget = targ;
	if (oTarget.className.indexOf('definition') < 0) {
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
		return;
	}
	
	var xPos = 0; var yPos = 0;
	if (e.pageX || e.pageY) {
		xPos = e.pageX;
		yPos = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		xPos = e.clientX + document.body.scrollLeft;
		yPos = e.clientY + document.body.scrollTop;
	}
	else {}
	aPos = new Array(xPos, yPos)
	return aPos;
}

function dictionary_open(e) {
	oDictionary = document.getElementById('dictionaryBox');
	oDictionary.style.display = 'block';
	if (window.pageYOffset) {yPos = window.pageYOffset;}
	else {yPos = oTarget.offsetTop;}

	if (!IE) {oDictionary.style.top = yPos+100+'px';}
	else oDictionary.style.top = yPos;
	oTerm = document.getElementById('dictionaryTerm');
	oTerm.innerHTML = oTarget.name.replace(/_/, ' ');
	
	oDefinition = document.getElementById('definition');
	oDefinition.innerHTML = oTarget.title;
}

function dictionary_close() {
	oDictionary = document.getElementById('dictionaryBox');
	oDictionary.style.display = 'none';
}
