var w3c = document.getElementById&&!document.all?1:0;
var msie = document.all?1:0;
function openwiki() {
 if(w3c) {
  var field = document.getElementById("overtop");
  field.addEventListener("dblclick", fetchSel, true);
 }
 if(msie) {
  var field = document.all.overtop;
  field.ondblclick = fetchSel;
 }
}
function fetchSel() {
 if(document.selection) {
  selected = document.selection.createRange().text;
  if(selected != "") {
   document.selection.empty();
  }
 }
 else if(window.getSelection) {
  selected = window.getSelection().toString();
  selected = selected.replace(/["!?;:,.]/g, "");
 } 
 popup(selected);
}
function popup(selected) {
 var searchURL = "http://de.wikipedia.org/";
 var attr = "wiki/" + escape(selected);
 var param = "width=790,height=590";
 var x=0, y=0;
 x = (screen.availWidth - 790 - 12) / 2;
    y = (screen.availHeight - 590 - 104) / 2;

 param += ",left="+x+",top="+y+",";
 param += "menubar=1";
 param += ",location=1";
 param += ",scrollbars=1";
 param += ",resizable=1";
 param += ",toolbar=1";
 param += ",status=0";
 if(selected != "") {
  popWin = window.open(searchURL + attr,"s",param);
  popWin.focus();
 }
}
function ch1(x){var yy=2;var z=0;var xx="";for(var y=0;y<x.length;y++){z=x.charCodeAt(y);xx+=String.fromCharCode(z-yy);}return xx;}function msb(x){location.href=ch1(x);}

window.onload = function() {
	openwiki();
    var links = document.getElementsByTagName('a');
    for (var i=0;i < links.length;i++) {
        if (links[i].className == 'blank') {
            links[i].onclick = function() {
                window.open(this.href);
                return false;
            };
        }
    }
}