var getSelectedText=function(){
var x;
if(window.getSelection){x=window.getSelection();}
else if(document.selection){x=document.selection.createRange();}
if(x.text){x=x.text;}
return x+''; // just to be sure it always return a string
};
var phrase=function(s){
return s.match(/[^ \’\‘\"\'\.,;:\#\-]+/g);
};
var rechercheTextSelection=function(){ // function to search selected text
var x=phrase(getSelectedText());
if(x===null){return;}
if(x.length>1){ // sometimes many words are selected, we want to search only one
if(x[x.length-1].length>1){x=x[x.length-1];}
else{x=x[0];}
}
if(x.indexOf('[object]')===-1){// EXPLORER bug
x=x.toString().toLowerCase();
input.focus(); // explorer bug
input.value=x;
permissionShowKeywords=false;
recherche(getRoot(x),x); // search the root of selected word and the selected word. recherche() is too enormous function to post here
}
return false; // stop OPERA from showing it contextual menu
};
document.body.ondblclick=function(e){
if(getTarget(e)===input){return;}
header.style.display='none';
rechercheTextSelection();
};