/*

  Script copyrighted Cambridge university press 2000
  Do *not* modify without written permission to do so..

   Usage of script :

   * Place dictionary.js in the directory on your website
   * Add following to your html file(s)
     <script language="javascript1.2" src="dictionary.js" ></script>

  When a people doubleclick on a word that word will be looked up in our
  online dictionary.

*/

//alert(navigator.appname);
var NS = (navigator.appName == "Netscape" || navigator.product == 'Gecko') ? 1 : 0;
 if (NS) document.captureEvents(Event.DBLCLICK);
 document.ondblclick = dict;

var dictvar;
function dict() {
if (NS) {
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) {
 //alert(text);
 if (text > '') {
 window.open('http://dictionary.cambridge.org/learnenglish/results.asp?searchword='+text+ '&dict=L', 'dict_win', 'width=600,height=445,resizable=yes,scrollbars=yes');
   }
}
