now = new Date(); 
year = now.getYear(); 
if (year < 200){ year = year + 1900 };
document.write(year);

document.onkeypress = keyhandler;

function findSelection(){
	if (document.getSelection){ txt = document.getSelection();}
	else if (document.selection){ txt = document.selection.createRange().text;}
	else {return "";}
	return txt;
}
function keyhandler(e) {
    if (window.event) { 
	Key = window.event.keyCode; 
	ctrlPressed =event.ctrlKey;
	shiftPressed = event.shiftKey;
	altPressed = event.altKey;
    } else { 
	Key = e.which;
	var mString =(e.modifiers+32).toString(2).substring(3,6);
	ctrlPressed =(mString.charAt(1)=="1");
	shiftPressed=(mString.charAt(0)=="1");
	altPressed=(mString.charAt(2)=="1");
    }

    
    if (Key == 100) { 
		var result = findSelection();
		if (result != "") {
			var toast = window.open('http://www.websters-online-dictionary.org/search/?s='+encodeUTF(result),'0','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=900,height=510,left=100 top=80');
		}
    }
}
function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeUTF(s) {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}
