/* Apply hack to cure IE6's text-selection bug. (Thanks to http://blog.tom.me.uk/2003/07/23/boie6selecta.php)
 * The original hack contained apparently superfluous code that caused hourglass thrashing on slower machines.
 * This code seems to work better. */

if (window.createPopup && document.compatMode && document.compatMode=="CSS1Compat")
{
    document.onreadystatechange = onresize = function fixIE6AbsPos()
	{
	    if (!document.body) return;
	    onresize = null;
	    //document.body.style.height = 0;
	    document.body.style.height = document.documentElement.scrollHeight+'px'; 
	    setTimeout(function(){ onresize = fixIE6AbsPos; }, 100);
	}
}

/* Now we've fixed IE6, enable dictionary look-up in the Cambridge online dictionary. */

NS = (navigator.appName == "Netscape");

if (NS) document.captureEvents(Event.DBLCLICK);

document.ondblclick = dict;

function dict() {
    if (NS) {
	/* Uses depracated but compatible method */
	t = document.getSelection();
	pass_to_dictionary(t);
    } else {
	t = document.selection.createRange();
	if(document.selection.type == 'Text' && t.text != '') {
	    document.selection.empty();
	    pass_to_dictionary(t.text); 
	}
    }
}

function pass_to_dictionary(text) {
    var dictWindow;
    if (text > '') {
	dictWindow=window.open('http://dictionary.cambridge.org/results.asp?searchword='+text,
			       'dictwindow',
			       'height=700, width=750, resizable=yes, scrollbars=yes');
	if (window.focus) { dictWindow.focus() }
    }
    
}

