var NS = (navigator.appName == "Netscape") ? 1 : 0;
if (NS) {
	if (parseInt(navigator.appVersion) == 5) 
		document.addEventListener("dblclick", dict, true);
	else 
		document.captureEvents(Event.DBLCLICK); 
}
document.ondblclick = dict;

var newwin;

function dict() {
	if (NS) {
		// should replace with NS 5 DOM window.getSelection()
		selection = document.getSelection();
		opendicwin(selection);
	}
	else {
		selection = document.selection.createRange();
	if(document.selection.type == 'Text' && selection.text != '') {
		document.selection.empty();
		opendicwin(selection.text);
	}
	}
}

function opendicwin(text) {
if (text > '') {
	dicwin = window.open('http://cancerweb.ncl.ac.uk/cgi-bin/omd?query='+text+'&action=Search', 'define_word', 'width=640,height=440,resizable,scrollbars,status');
	setTimeout('dicwin.focus()', 50);
  }
}
