/****
 * Axivo Searchlight
 * This file may not be redistributed in whole or significant part.
 *
 * @category	Searchlight
 * @package		Search
 * @copyright	2006-2010 Axivo Inc. All Rights Reserved.
 * @version		1.1.0
 * @license		ef273ceb0a2fc4d2931e049a31b38984
 * @link		http://www.axivo.com
 * @since		File available since Release 1.1.0
 */
function selectionLookup(b){this.bubble=new Image();this.bubble.src=IMGDIR_MISC+"/searchlight_bubble.png";this.targetUrl="search.php?do=process&quickprocess=1&showposts="+slBit+"&q=";this.selection=this.indicator=null;var a=document.body.appendChild(document.createElement("div"));a.innerHTML='<div id="searchBox" class="quicksearch_box"><div class="quicksearch_frame"><p id="searchProgress"><img alt="" src="'+IMGDIR_MISC+'/searchlight_progress.gif" /></p><iframe id="searchFrame" frameborder="0" scrolling="auto"></iframe></div><a id="searchClose" class="quicksearch_x" href="#"><img border="0" src="'+IMGDIR_MISC+'/searchlight_close.png" alt="" /></a></div>';this.searchBox=new YAHOO.widget.Overlay("searchBox",{zIndex:1000,fixedcenter:true,visible:false,effect:((is_ie)?false:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25})});this.searchBox.render();this.searchProgress=YAHOO.util.Dom.get("searchProgress");this.searchFrame=YAHOO.util.Dom.get("searchFrame");YAHOO.util.Event.on(b,"mouseup",this.setSelection,this,true);YAHOO.util.Event.on("searchClose","click",this.hidePopup,this,true)}selectionLookup.prototype={getSelection:function(){if(window.getSelection&&(sel=window.getSelection())){return sel}else{if(document.getSelection&&(sel=document.getSelection())){return sel}else{sel=document.selection&&document.selection.createRange();sel.toString=function(){return this.text};return sel}}},setSelection:function(d){if(this.searchBubble&&this.searchBubble.parentNode){this.hideIndicator(d)}this.selection=this.getSelection();this.selectionText=(this.selection&&this.selection.toString());if(this.selectionText){this.showIndicator(d);if(this.imagesPreload===undefined){this.imagesPreload=true;var c=0,b=new Image(),a=new Array("searchlight_box.png","searchlight_bubble.png","searchlight_progress.gif");for(c=0;c<a.length;c++){b.src=IMGDIR_MISC+"/"+a[c]}}}},showContent:function(a){this.searchProgress.style.display="none";this.searchFrame.style.display="block"},hideContent:function(a){this.searchProgress.style.display="block";this.searchFrame.style.display="none"},showIndicator:function(c){if(c){YAHOO.util.Event.stopEvent(c)}this.searchBubble=document.createElement("span");this.searchBubble.id="searchBubble";this.searchBubble.className="quicksearch_bubble";if(is_ie){var b=document.createElement("div");b.appendChild(this.searchBubble);newRange=this.selection.duplicate();newRange.setEndPoint("StartToEnd",this.selection);newRange.pasteHTML(b.innerHTML);this.searchBubble=YAHOO.util.Dom.get("searchBubble")}else{var a=this.selection.getRangeAt(0);newRange=document.createRange();newRange.setStart(this.selection.focusNode,a.endOffset);newRange.insertNode(this.searchBubble)}YAHOO.util.Event.on(this.searchBubble,"mouseup",this.showPopup,this,true)},hideIndicator:function(a){this.searchBubble.parentNode.removeChild(this.searchBubble)},showPopup:function(a){this.hideIndicator();this.hideContent();this.searchFrame.src=this.targetUrl+encodeURIComponent(this.selectionText);this.searchBox.show();YAHOO.util.Event.stopEvent(a);YAHOO.util.Event.on(this.searchFrame,"load",this.showContent,this,true)},hidePopup:function(a){this.searchBox.hide();YAHOO.util.Event.stopEvent(a)}};YAHOO.util.Event.onDOMReady(function(){new selectionLookup(document)});
