
// $Id: global.js,v 1.11 2004/06/18 14:02:52 standi01 Exp $

// 
// BBC Vocab
// 
// Mae'r ffeil hon yn rhan o "BBC Vocab / Geirfa".
// Hawlfraint 2003,2004 BBC.
// Gweler LICENCE.txt am fanylion llawn y drwydded.
// 
// This file is part of "BBC Vocab / Geirfa".
// Copyright 2003,2004 BBC.
// See LICENCE.txt for full licence details.
// 

var highlightColour = '#ffff99';
var activeColour = '#ffff99';

var timerId;
var lastTc;
var browserSupported = 0;
var tt;
var vocabTipText = '\'<strong>\'+arguments[1]+\'</strong>: <span>\'+arguments[2]+\'</span>\'';
document.write('<span id="vocabTT"></span>');

if (document.getElementById) {
	tt = document.getElementById('vocabTT');
	browserSupported = 1;
} else if (document.all) {
	tt = vocabTT;
	browserSupported = 1;
}

if (!browserSupported && vocabToggleURL) {
	window.location.href = vocabToggleURL;
}

function vocabShowTT(tc,dictfrom,dictto) {

	if (!browserSupported) { return false; }
	clearTimeout(timerId);

	if (document.documentElement.clientWidth && document.documentElement.clientWidth < document.body.clientWidth) {
		visibleWidth = document.documentElement.clientWidth+document.documentElement.scrollLeft;
	} else {
		visibleWidth = document.body.clientWidth+document.body.scrollLeft
	}
	if (document.documentElement.clientHeight && document.documentElement.clientHeight < document.body.clientHeight) {
		visibleHeight = document.documentElement.clientHeight+document.documentElement.scrollTop;
	} else {
		visibleHeight = document.body.clientHeight+document.body.scrollTop
	}

	if (lastTc) { lastTc.style.backgroundColor = highlightColour; }

	tc.style.backgroundColor = activeColour;
	lastTc = tc;

	if (vocabTipText) {
		tt.innerHTML = eval(vocabTipText);
	}else{
		tt.innerHTML = dictfrom+': <span>'+dictto+'</span>';
	}

	lp = tc.offsetLeft + 25;
	tp = tc.offsetTop + 25;
	while (tc.offsetParent) {
		lp += tc.offsetParent.offsetLeft;
		tp += tc.offsetParent.offsetTop;
		tc = tc.offsetParent;
	}
	if ((lp + 210) > visibleWidth) { lp = visibleWidth - 210; }
	if ((tp + 30) > visibleHeight) { tp = tp - 65; }

	tt.style.left = lp;
	tt.style.top = tp;
	tt.style.display = 'inline';
}

function vocabHideTT() {
	if (!browserSupported) { return false; }
//	timerId = setTimeout("vocabTimeoutTT()",2000);
	vocabTimeoutTT();
}

function vocabTimeoutTT() {
	if (!browserSupported) { return false; }
	if (lastTc) { lastTc.style.backgroundColor = '#ffff99'; }
	tt.style.display = 'none';
}
