UBACTO.require("http://larochelle.ubacto.com/JS/app/lib/prototype/1.6.0.3/prototype.js", function(){UBACTO.SearchText.initialize();});UBACTO.SearchText = (function(){    var selection, selectionText, selectionButton, newRange;    function handleClick(event) {    if (selectionButton){      cleanUp();    }        selection = getSelection();    selectionText = selection && selection.toString();    if (selectionText) {      window.setTimeout(insertButton, 0);      event.stop();    }  }    function getSelection() {    return Try.these(      function() { return window.getSelection() },      function() { return document.getSelection() },      function() {         var selection = document.selection && document.selection.createRange();        selection.toString = function() { return this.text };        return selection;      }    ) || false;  }    function insertButton() {        selectionButton = new Element(        'span', {          'className':'ubacto_selection_button',          'id':'ubacto_selection_button',          'title':'retrouver plus d\'informations sur ce terme avec ubacto ...',          'style': 'margin:-20px 0 0 -20px; position:absolute; background:url(http://larochelle.ubacto.com/img/global/word_reference/ref_bubble.png);width:25px;height:29px;cursor:pointer;_background-image: none;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="http://larochelle.ubacto.com/img/global/word_reference/ref_bubble.png", sizingMethod="image");'        }    )          if (Prototype.Browser.IE) {      var tmp = new Element('div');      tmp.appendChild(selectionButton);      newRange = selection.duplicate();      newRange.setEndPoint( "StartToEnd", selection);      newRange.pasteHTML(tmp.innerHTML);      selectionButton = $('ubacto_selection_button');    }    else {      var range = selection.getRangeAt(0);      newRange = document.createRange();      newRange.setStart(selection.focusNode, range.endOffset);      newRange.insertNode(selectionButton);    }        Element.observe(selectionButton, 'mouseup', exportSelection, true);      }    function cleanUp() {    selection = null;    selectionButton.stopObserving('mouseup', exportSelection);    newRange && newRange.pasteHTML && newRange.pasteHTML('');    newRange = null;    selectionButton.remove();    selectionButton = null;    selectionText = '';  }    function exportSelection(event) {    var url = 'http://ubacto.com/cgi-bin/zzou/search.cgi?query=' + encodeURIComponent(selectionText) + '&cs=5';    var newwin = window.open(url,'ubacto','');    if (newwin) newwin.focus();    event.stop();  }    return {    initialize: function() {      document.observe('mouseup', handleClick, false);    }  };  })();
