var click_block = 0;
var IE = (navigator.appName=='Microsoft Internet Explorer'?1:0);
var Domain='thefreedictionary.com';

function dictionary() {

  if (click_block) {
    click_block = 0;
    return;
  }

  if (!IE) {
    t = document.getSelection();
    opennewdictwin(t);
  } else {
    var t = document.selection.createRange();
    if(document.selection.type == 'Text' && t.text != '') {
      document.selection.empty();
      opennewdictwin(t.text);
    }
  }
}

function opennewdictwin(text) {
  
  while (text.substr(text.length-1,1) == ' ')
    text=text.substr(0, text.length - 1);
    
  while (text.substr(0,1) == ' ')
    text = text.substr(1);

  if (text > '') {
    window.open('http://www.' + Domain + '/' + escape(text));
    //document.location = 'http://www.' + Domain + '/' + escape(text);
  }
}
