var SHOW_POPUP_LABELS=false;function id(C){if(arguments.length>1){for(var D=0,A=[],B=arguments.length;D<B;D++){A.push(id(arguments[D]))}return A}if(typeof C=="string"){C=document.getElementById(C)}return C}Array.prototype.contains=function(C){for(var B=0,A=this.length;B<A;B++){if(C==this[B]){return true}if(C.equals){if(C.equals(this[B])){return true}}}return false};Array.prototype.remove=function(D){var B=-1;for(var C=0,A=this.length;C<A;C++){if(D==this[C]){B=C}else{if(D.equals){if(D.equals(this[C])){B=C}}}if(B!=-1){return this.splice(B,1)}}};var Obj={toQueryString:function(D){assert(D,"Obj.toQueryString: Argument is undefined.");var C=[];for(var B in D){var A=D[B];if(!A){if((typeof A=="undefined")||(A===null)){A=""}if(A===false){A="false"}}C.push(B+"="+encodeURIComponent(A))}return C.join("&")}};function toQueryObject(B){var A={};$A(B.replace(/(^.*\?)|(#.*$)/g,"").split("&")).each(function(C){C=C.split("=");A[decodeURIComponent(C[0])]=decodeURIComponent(C[1])});return A}var E={hide:function(A){A=id(A);if(A){A.style.display="none"}return A},show:function(A){A=id(A);if(A){A.style.display=""}return A},getElementsByClassName:function(D,H){H=id(H)||document.body;if(H.getElementsByClassName){return H.getElementsByClassName(D)}var F=H.getElementsByTagName("*");var B=[],A;for(var G=0,C=F.length;G<C;G++){A=F[G];if(E.hasClassName(A,D)){B.push(A)}}return B},getElement:function(G,B,D){G=id(G)||document.body;var C=G.getElementsByTagName(B);if(C.length){if(!D){return C[0]}for(var F=0,A=C.length;F<A;F++){var H=C[F];if(E.hasClassName(H,D)){return H}}}return null},nodeBefore:function(A){function B(D){return !(/[^\t\n\r ]/.test(D.data))}function C(D){return(D.nodeType==8)||((D.nodeType==3)&&B(D))}while((A=A.previousSibling)){if(!C(A)){return A}}return null},childOf:function(B,A){B=id(B),A=id(A);while(B=B.parentNode){if(B==A){return true}}return false},hasClassName:function(B,A){B=id(B);assert(B,"hasClassName: no element.");var C=B.className;if(C.length==0){return false}if(C==A||C.match(new RegExp("(^|\\s)"+A+"(\\s|$)"))){return true}return false},addClassName:function(B,A){B=id(B);var D=B.className.trim();if(!E.hasClassName(B,A)){if(D.length==0){B.className=A}else{var C=D.split(" ");assert(!C.contains(A),"addClassName: Element already has class: "+A);C.push(A);B.className=C.join(" ")}}return B},removeClassName:function(B,A){B=id(B);var D=B.className.trim();if(E.hasClassName(B,A)){if(D==A){B.className=""}else{var C=D.split(" ");assert(C.contains(A),"removeClassName: Element doesn't have class: "+A);C.remove(A);B.className=C.join(" ")}}return B},cumulativeOffset:function(A){var B=0,C=0;do{B+=A.offsetTop||0;C+=A.offsetLeft||0;A=A.offsetParent}while(A);return[C,B]}};var Evt={KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,target:function(A){return A.target||A.srcElement},stop:function(A){A.preventDefault();A.stopPropagation()},observe:function(B,D,C){if(B.addEventListener){B.addEventListener(D,C,false)}else{if(!C.$$guid){C.$$guid=Evt.guid++}if(!B.events){B.events={}}var A=B.events[D];if(!A){A=B.events[D]={};if(B["on"+D]){A[0]=B["on"+D]}}A[C.$$guid]=C;B["on"+D]=handleEvent}},unobserve:function(A,C,B){if(A.removeEventListener){A.removeEventListener(C,B,false)}else{if(A.events&&A.events[C]){delete A.events[C][B.$$guid]}}}};Evt.guid=1;function handleEvent(D){var B=true;D=D||fixEvent(((this.ownerDocument||this.document||this).parentWindow||window).event);var A=this.events[D.type];for(var C in A){this.$$handleEvent=A[C];if(this.$$handleEvent(D)===false){B=false}}return B}function fixEvent(A){A.preventDefault=fixEvent.preventDefault;A.stopPropagation=fixEvent.stopPropagation;return A}fixEvent.preventDefault=function(){this.returnValue=false};fixEvent.stopPropagation=function(){this.cancelBubble=true};var Cookie={get:function(B,F){var H=document.cookie;if(H){var G=H.split(";");for(var C=0,A=G.length;C<A;C++){var D=G[C].trim().split("=");if(D[0]==B){return D[1]}}}return F||null},set:function(B,D,F){var C="";if(F){var A=new Date();A.setTime(A.getTime()+(F*24*60*60*1000));C="; expires="+A.toGMTString()}document.cookie=B+"="+D+C}};var Params={get:function(B,C,G){if(!B){B=location.search}if(B){B=B.substring(1);var H=B.split("&");for(var D=0,A=H.length;D<A;D++){var F=H[D].trim().split("=");if(F[0]==C){return F[1]||G}}}return G||null}};if(typeof XMLHttpRequest=="undefined"){XMLHttpRequest=function(){return new ActiveXObject(navigator.userAgent.indexOf("MSIE 5")>=0?"Microsoft.XMLHTTP":"Msxml2.XMLHTTP")}}function ajax(F){F={type:F.type||"POST",url:F.url||"",params:F.params||"",timeout:F.timeout||5000,onComplete:F.onComplete||function(){},onError:F.onError||function(){},onSuccess:F.onSuccess||function(){},data:F.data||""};var D=new XMLHttpRequest();var C=F.url;if(F.params){C+="?"+F.params}D.open(F.type,C,true);var A=F.timeout;var G=false;setTimeout(function(){G=true},A);D.onreadystatechange=function(){if(D.readyState==4&&!G){if(B(D)){F.onSuccess(D)}else{F.onError()}F.onComplete();D=null}};if(F.type=="POST"){if(D.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){D.setRequestHeader("Connection","close")}}D.setRequestHeader("Cache-Control","no-cache");D.send(null);function B(H){try{return !H.status&&location.protocol=="file:"||(H.status>=200&&H.status<300)||H.status==304||navigator.userAgent.indexOf("Safari")>=0&&typeof H.status=="undefined"}catch(I){}return false}return D}var Layout={width:0,height:0,_scratch:[0,0],getSize:function(A){if(!A){A=[]}if(typeof (window.innerWidth)=="number"){A[0]=window.innerWidth;A[1]=window.innerHeight}else{if(document.documentElement&&document.documentElement.clientWidth){A[0]=document.documentElement.clientWidth;A[1]=document.documentElement.clientHeight}else{if(document.body&&document.body.clientWidth){A[0]=document.body.clientWidth;A[1]=document.body.clientHeight}else{assert(false,"Don't know how to get window w x h")}}}return A},checkSize:function(){Layout.getSize(Layout._scratch);if((Layout.width==Layout._scratch[0])&&(Layout.height==Layout._scratch[1])){return }Layout.width=Layout._scratch[0];Layout.height=Layout._scratch[1];if(typeof Layout.resized=="function"){Layout.resized()}},init:function(){Evt.observe(window,"resize",this.checkSize);this.checkSize()}};if(typeof HTMLElement!="undefined"){if(HTMLElement.prototype.__defineGetter__){HTMLElement.prototype.__defineGetter__("innerText",function(){return(this.textContent)});HTMLElement.prototype.__defineSetter__("innerText",function(A){this.textContent=A})}}function assert(A,B){if(typeof (gDebug)=="undefined"){return }if(!A){alert("Assertion Failed: "+B)}}function isDebug(){return typeof (gDebug)!="undefined"}function isIE(){return !!(window.attachEvent&&!window.opera)}function isIE7(){return navigator.userAgent.indexOf("MSIE 7")>-1}function isGecko(){return navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1}function isFlock(){return !!navigator.userAgent.match(/Flock/)}function isWebKit(){return navigator.userAgent.indexOf("AppleWebKit/")>-1}function isSafari(){return !!navigator.userAgent.match(/Safari/)}function isMobileSafari(){return !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)}function isKonqueror(){return !!navigator.userAgent.match(/Konqueror/)}function isOpera(){return !!navigator.userAgent.match(/Opera/)}String.prototype.trim=function(){var A=this;A=A.replace(/^\s*(.*)/,"$1");A=A.replace(/(.*?)\s*$/,"$1");return A};String.prototype.htmlEncode=function(){var B=this;var A=B.length;var D="";for(var C=0;C<A;C++){var F=B.charAt(C);if(F=="&"){D+="&amp;"}else{if(F=="<"){D+="&lt;"}else{if(F==">"){D+="&gt;"}else{D+=F}}}}return D};function create(B,A){var C=document.createElement(B);if(A){C.className=A}return C}function createMeaning(A){A.toElement=function(){var B=create("LI");assert(this.display,"Meaning has no display property: "+this.query);B.innerHTML=this.display.htmlEncode();B.query=this.query;return B};return A}var gAjaxReq=null;function send(C){if(gAjaxReq){return }var B=C.q.trim();var A=Obj.toQueryString(C);location.href="/search?"+A}function doNav(A){var C=E.getElementsByClassName("url",A)[0];gPopup.cancelSubmit=true;var B={u:C.innerText};track(logstr("nav",B));location.href="http://"+C.innerText}function track(B){if(!isDebug()){server="http://www.cuilimg.com"}else{server=""}if(document.images){var A=parseInt((new Date()).valueOf()/1000);(new Image).src=server+"/static/images/log.gif?"+B+"&time="+A}}function logstr(B,C){assert(typeof B=="string","Parameter 'type' should be a string.");assert(typeof C=="object","Parameter 'info' should be an object.");var D={};for(var A in C){D[A]=C[A]}D.ty=B;return Obj.toQueryString(D)}function linkDownHandler(A){track(this.track)}function attachLinkTracking(F,B,H){var C=$$(B);for(var D=0,A=C.length;D<A;D++){var G=C[D];if(typeof H!="function"){var I={q:true,t:G,a:G.get("text")}}else{var I=H(G)}if(I.q){I.q=gQuery}if(I.s){I.s=A}if(I.mn==true){I.mn=Params.get(null,"m");if(I.mn){I.mn=decodeURIComponent(I.mn)}}if(I.prov==true){I.prov=Params.get(null,"prov");if(I.prov){I.prov=decodeURIComponent(I.prov)}}if(I.t){I.t=I.t.href.replace(/#.*/,"")}oo={};for(prop in I){if(I[prop]){oo[prop]=I[prop]}}G.track=logstr(F,oo);Evt.observe(G,"mousedown",linkDownHandler)}}function Controller(nDocs,pSize,pIndex){var bodyDiv=id("bdy");E.hide("td_no_js");this.doQuery=function(q,prov){id("fld_q").value=q;if(prov){var o={q:q,prov:prov}}else{var o={q:q}}track(logstr("suggest",o));send(o)};function initDrilldownTrack(){attachLinkTracking("drill",".explore_link",function(link){return{q:true,t:link,mn:true,d:link.get("text")}})}function initTrack(){attachLinkTracking("res",".web_result a",function(link){if($(link.parentNode).hasClass("web_result")){var pos=link.parentNode.id.substr(1)}else{var pos=link.parentNode.parentNode.id.substr(1)}var drill=Params.get(null,"d");if(drill){drill=decodeURIComponent(drill);drill=gQuery.slice(drill.length+1)}return{q:true,t:link,p:pos,klass:link.className,mn:true,prov:true,d:drill}})}function initBreadcrumbTrack(){attachLinkTracking("bc","a.breadcrumb_link",function(link){return{q:true,t:link,d:link.get("text"),s:true}})}function initMediaBarTrack(){attachLinkTracking("prov_tab",".media_bar a",function(link){return{q:true,t:link,mn:true,prov:link.get("text")}})}function initSpellingTrack(){attachLinkTracking("spelling","#spell a",function(link){var sugg=link.get("text");return{q:true,t:link,suggestion:sugg}})}function initTabs(){attachLinkTracking("tab",".tab a",function(link){var m=Params.get(link.search,"m");if(m){m=decodeURIComponent(m)}return{q:true,mn:m,prov:true}})}function initPopup(popup,trigger){popup.innerHTML="";var moreSelect=id("sel_more");if(moreSelect){E.hide("td_no_js");var opts=moreSelect.options;var len=opts.length;for(var i=0;i<len;i++){var opt=opts[i];if(opt.value===""){continue}var m=createMeaning({display:opt.text,query:opt.value});popup.appendChild(m.toElement())}addEndcap(popup);E.show(trigger)}trigger.onclick=function(){var pos=E.cumulativeOffset(trigger);var w=popup.offsetWidth;var dl=1;var dt=1;if(isSafari()){dl=0;dt=4}popup.style.left=(pos[0]+trigger.offsetWidth-w-dl)+"px";popup.style.top=(pos[1]+trigger.offsetHeight-dt)+"px";popup.activate();return false};var _keydown=function(e){popup.deactivate();Evt.stop(e)};var _click=function(e){var elem=Evt.target(e);if((elem==trigger)||E.childOf(elem,trigger)||(elem==popup)||E.childOf(elem,popup)){return }popup.deactivate();Evt.stop(e)};var selected=null;var _mouseover=function(e){var elem=Evt.target(e);if(elem.tagName=="UL"){return }while(elem.tagName!="LI"){elem=elem.parentNode}if(E.hasClassName(elem,"cap")){return }E.addClassName(elem,"focused");if(selected){E.removeClassName(selected,"focused")}selected=elem};popup.activate=function(){this.style.visibility="visible";Evt.observe(document,"keydown",_keydown);Evt.observe(document,"click",_click);Evt.observe(this,"mouseover",_mouseover)};popup.deactivate=function(){selected=null;this.style.visibility="hidden";Evt.unobserve(document,"keydown",_keydown);Evt.unobserve(document,"click",_click);Evt.unobserve(this,"mouseover",_mouseover);for(var i=0,len=this.childNodes.length;i<len;i++){var li=this.childNodes[i];if(li.tagName!="LI"){continue}E.removeClassName(li,"focused")}};popup.onclick=function(e){e=e||window.event;var target=Evt.target(e);if(target.tagName!="LI"||!target.query){this.deactivate();return false}var o={q:gQuery,m:target.query,prov:true};track(logstr("tab",o));send(o);this.deactivate();return false}}function initKeys(){var enableScroll=!isMobileSafari();var enableNav=!isMobileSafari();var enableSpace=!isMobileSafari();var SCROLL_DIST=16;function keyEvent(e){var target=Evt.target(e);if(target.tagName=="INPUT"){return }var code=e.code;var bodyDiv=id("bdy");switch(code){case Evt.KEY_UP:if(enableScroll){bodyDiv.scrollTop-=SCROLL_DIST;Evt.stop(e)}return ;case Evt.KEY_DOWN:if(enableScroll){bodyDiv.scrollTop+=SCROLL_DIST;Evt.stop(e)}return ;case Evt.KEY_LEFT:if(enableNav){var prev=id("a_prev");if(!E.hasClassName(prev,"off")){location.href=prev.href}}return ;case Evt.KEY_RIGHT:if(enableNav){var next=id("a_next");if(!E.hasClassName(next,"off")){location.href=next.href}}return ;case 32:if(enableSpace){bodyDiv.scrollTop+=6*SCROLL_DIST;Evt.stop(e)}return }}var docKeyEvent="keypress";if(isSafari()||isIE()){docKeyEvent="keydown"}document.addEvent(docKeyEvent,keyEvent)}function initTooltips(){var tt=new ExploreTips($$(".explore_link"),{interactable:true})}var loaded=false;var cookieCols=Cookie.get("cols",3);var numColPref=Params.get(location.search,"cols",cookieCols);if(numColPref!="1"&&numColPref!="2"&&numColPref!="3"){numColPref=cookieCols}var numCols=numColPref;var morePopup=id("ul_more");var moreLink=id("td_more");document.body.style.overflow="hidden";bodyDiv.style.overflowY="auto";if(isIE()){bodyDiv.style.height="10px"}Layout.resized=function(){if(isMobileSafari()){return }var winH=this.height;var headerH=id("hdr").offsetHeight;var footerH=id("ftr").offsetHeight;var h=(winH-footerH-headerH);bodyDiv.style.height=h+"px";if(!loaded){return }var w=bodyDiv.offsetWidth;if(3==numColPref){if((numCols==3)&&(w<986)){cols(2)}else{if((numCols!=3)&&(w>986)){cols(3)}}}morePopup.style.visibility="hidden"};Layout.recalcLayout=Layout.resized;Layout.init();if(moreLink){initPopup(morePopup,moreLink)}var explore=new ExploreController();explore.init();initField(id("fld_q"));initTrack();initDrilldownTrack();initBreadcrumbTrack();initMediaBarTrack();initSpellingTrack();initTooltips();if(!curr_media){initPageLinks()}id("form_q").onsubmit=function(){if(gPopup){gPopup.hide();if(gPopup.cancelSubmit){gPopup.cancelSubmit=false;return false}}var o={q:id("fld_q").value};track(logstr("sub",o));return true};function accordion_switch_cols(col){assert(col==1||col==2||col==3,"Invalid column option. Valid options are 1, 2, 3.");var acc=id("accordion");if(!acc){return }id("accordion").parentNode.removeChild(acc);switch(parseInt(col)){case 1:col1=id("col1_r");col1.appendChild(acc);break;case 2:var col2=id("col2_r");col2.insertBefore(acc,col2.firstChild);break;case 3:var col3=id("col3_r");col3.insertBefore(acc,col3.firstChild)}}function cols(nc,save){var tb2=id("tbl_2");var tb3=id("tbl_3");if(!tb2||!tb3){return }if(nc==1){assert(false,"Shouldn't get here because 1	column mode has	been disabled.");E.hide(tb2);E.hide(tb3)}else{if(nc==2){E.show(tb2);E.hide(tb3)}else{E.show(tb3);E.hide(tb2)}}numCols=nc;c2Link.select(nc==2);c3Link.select(nc==3);accordion_switch_cols(nc);if(save){numColPref=nc;Cookie.set("cols",nc,60)}}function initPageLinks(){$$("#pages a.pagelink").addEvent("click",function(e){e.stop();gotoPage(this.get("text"))});$("a_next").addEvent("click",function(e){if(!$("a_next").hasClass("off")){e.stop();nextpage=parseInt($$("#pages .sel").get("text"))+1;gotoPage(nextpage)}});$("a_prev").addEvent("click",function(e){if(!$("a_prev").hasClass("off")){e.stop();nextpage=parseInt($$("#pages .sel").get("text"))-1;gotoPage(nextpage)}})}function gotoPage(pagenum){params=toQueryObject($("a_p"+(pagenum-1)).get("href"));params["formatted"]=1;pageReq=ajax({url:"/search",type:"POST",params:Obj.toQueryString(params),onSuccess:function(o){var text=o.responseText;if(text&&text.trim()!=""){eval("var data = "+text)}$("bdy").scrollTo(0);$$(".result_columns").destroy();$("tbl_3").grab(new Element("text",{"html":data.results}),"top");$("pages").destroy();$("ftr").grab(new Element("text",{"html":data.pagination}));initPageLinks()}})}mobilelink=id("mobile")||false;if(mobilelink){mobilelink.onclick=function(){Cookie.set("mobile_override","0","30")}}initTabs();cols(numCols);showPlugin();initKeys();loaded=true}function initField(A){if(!isSafari()){return }Evt.observe(A,"focus",function(B){E.addClassName(A,"fld_focused")});Evt.observe(A,"blur",function(B){E.removeClassName(A,"fld_focused")})}function showPlugin(){var D=id("span_add_ext");var C=id("add_ext");if(!D){return }if(isGecko()||isIE7()){var B=false;var A="Firefox";if(isIE7()){A="Internet Explorer";if(isDebug()){B=true}else{B=window.external&&(window.external.IsSearchProviderInstalled("http://www.cuil.com")==0)}}else{if(isFlock()){A="Flock"}B=window.external&&window.external.IsSearchProviderInstalled&&(window.external.IsSearchProviderInstalled("http://www.cuil.com")==0)}if(B){C.onclick=function(){window.external.AddSearchProvider("http://www.cuil.com/static/plugin.xml");return false};C.innerHTML="Add Cuil to "+A;E.show(D)}}}var MsgBox={show:function(A){id("msg").innerHTML=A;E.show("msgbox");Layout.recalcLayout()},clear:function(){id("msg").innerHTML="";E.hide("msgbox");Layout.recalcLayout()}};var gAutoReq=null;function Popup(fld){var ul=create("UL","popup");ul.id="menu_auto";E.hide(ul);document.getElementsByTagName("BODY")[0].appendChild(ul);var self=this;var val=fld.value;var selected=null;function _keydown(e){var code=e.which||e.keyCode;switch(code){case Evt.KEY_ESC:self.hide();Evt.stop(e);return ;case Evt.KEY_UP:if(self.up()){Evt.stop(e)}return ;case Evt.KEY_DOWN:if(self.down()){Evt.stop(e)}return ;case Evt.KEY_RIGHT:if(selected&&selected.className.indexOf("nav")==-1){fld.value=selected.innerHTML;Evt.stop(e)}return }}function _keypress(e){var code=e.which||e.keyCode;if(code==Evt.KEY_RETURN){if(self.pick()){Evt.stop(e)}}else{if((code==Evt.KEY_UP)||(code==Evt.KEY_DOWN)){if(!e.charCode&&isGecko()){Evt.stop(e)}}}}function _keyup(e){var code=e.which||e.keyCode;if(code==Evt.KEY_RETURN){return }if(this.value!=val){val=this.value;if(val.length<2){self.hide();return }if(gAutoReq){return }var params=Obj.toQueryString({q:this.value});var server=gUseProxy?"/suggestproxy":"/suggest";gAutoReq=ajax({url:server,type:"GET",params:params,onSuccess:function(r){var text=r.responseText;if(text&&text.trim()!=""){eval("var data = "+text);self.set(data.suggests,data.navs)}gAutoReq=null},onError:function(){gAutoReq=null}})}}function getTargetLI(e){var elem=Evt.target(e);if(elem.tagName=="UL"){return elem}while(elem.tagName!="LI"){elem=elem.parentNode}assert(elem.tagName=="LI","elem is not LI: "+elem.tagName);return elem}function isItem(elem){return(elem.tagName=="LI")&&!E.hasClassName(elem,"heading")&&!E.hasClassName(elem,"cap")}function isHeading(elem){return E.hasClassName(elem,"heading")}this.itemType=function(item){return E.hasClassName(item,"nav")?"nav":"suggest"};function getFirst(){var lis=ul.childNodes;if(!lis.length){return null}var li=lis[0];if(isHeading(li)){li=li.nextSibling}assert(li,"GetFirst: li is null.");return li}ul.onclick=function(e){e=e||window.event;var target=getTargetLI(e);if(!isItem(target)){return false}_keyEvent=true;self.pick(target);return false};ul.onmouseover=function(e){e=e||window.event;var target=getTargetLI(e);if(!isItem(target)){return false}self.select(target);return false};this.show=function(){if(this.visible()){return }var fld=id("fld_q");var pos=E.cumulativeOffset(fld);ul.style.left=(pos[0]+11)+"px";ul.style.top=(pos[1]+fld.offsetHeight-7)+"px";ul.style.display="";Evt.observe(fld,"keydown",_keydown);Evt.observe(fld,"keypress",_keypress)};this.hide=function(){if(!this.visible()){return }ul.style.display="none";selected=null;Evt.unobserve(fld,"keydown",_keydown);Evt.unobserve(fld,"keypress",_keypress)};this.visible=function(){return"none"!=ul.style.display};this.set=function(items,navs){var restore=null;if(selected){restore=selected.innerText}selected=null;var html="";var hasItems=false;var hasNav=false;if(navs.length){hasNav=true;html="";if(SHOW_POPUP_LABELS){html+='<li class="heading">Go directly to...</li>'}for(var j=0,nlen=navs.length;j<nlen;j++){var nav=navs[j];var url=nav[0];var fave="http://"+url+"/favicon.ico";html+='<li class="nav">';html+='<img src="'+fave+'" />';html+="<div>"+nav[1].htmlEncode()+"</div>";html+='<div class="url">'+url+"</div>";html+="</li>"}}if(items.length){hasItems=true;var index=-1;if(SHOW_POPUP_LABELS){html+='<li class="heading">Others have tried...</li>'}for(var i=0,ilen=items.length;i<ilen;i++){var item=items[i];if(restore==item){index=i}html+="<li>"+item+"</li>"}}ul.innerHTML=html;this.show();addEndcap(ul);if(!hasItems&&!hasNav){ul.innerHTML="";this.hide()}};var _keyEvent=false;this.select=function(li,keyEvent){if(li==selected){return }assert(!isHeading(li),"Can't select a heading.");E.addClassName(li,"focused");if(selected){E.removeClassName(selected,"focused")}selected=li;if(keyEvent){_keyEvent=true}};this.up=function(){assert(this.visible(),"Shouldn't be getting an up request when menu is hidden.");var li=selected;if(!li){return true}var prev=li.previousSibling;if(!prev){return true}else{if(isHeading(prev)){prev=prev.previousSibling;if(!prev){return true}}}assert(prev,"Previous item is null.");this.select(prev,true);return true};this.down=function(){assert(this.visible(),"Shouldn't be getting a down request when menu is hidden.");var li=selected;if(!li){li=getFirst();if(!li){return false}this.select(li,true);return true}var next=li.nextSibling;if(!next){return true}else{if(isHeading(next)){next=next.nextSibling}else{if(E.hasClassName(next,"cap")){return true}}}assert(next,"Next item is null.");this.select(next,true);return true};this.pick=function(item){assert(this.visible(),"Picked shouldn't be called when menu is hidden.");if(!_keyEvent){if(selected){return true}return false}_keyEvent=false;item=item||selected;if(!item){return }assert(isItem(item),"Trying to pick something that's not item.");if(typeof this.itemPicked=="function"){this.itemPicked(item)}this.hide();return true};Evt.observe(fld,"keyup",_keyup);Evt.observe(fld,"blur",function(e){setTimeout(function(){self.hide()},300);Evt.stop(e)});Evt.observe(fld,"keydown",function(){self.cancelSubmit=false})}function addEndcap(D){var H=create("LI","cap");var C=create("CANVAS");var F=D.offsetWidth;if(!(F>0)){return }var A=7;C.setAttribute("width",F);C.setAttribute("height",2*A);if(C.getContext){var B=C.getContext("2d");B.beginPath();B.arc(A,-2,A,Math.PI,Math.PI/2,true);var G=F-A;B.lineTo(G,5);B.arc(G,-2,A,Math.PI/2,0,true);B.closePath();B.fillStyle="#f5f5f5";B.fill();B.strokeStyle="#a8a8a8";B.stroke()}H.appendChild(C);D.appendChild(H)}function ExploreController(){this.toggle_state=0;var C=this;this.init=function D(){var G=$("show_more");if(G){G.addEvent("click",C.toggle_tiles.bind(C))}C.tiles=$$(".tile");C.hidden_tiles=$$(".tile.hidden");var F=$$(".show_more_meanings");F.each(function(H){H.store("toggled",0);H.addEvent("click",C.toggle_meanings)})};this.toggle_tiles=function A(){var F=$("show_more");if(this.toggle_state==1){this.hidden_tiles.each(function(G){G.setStyle("display","none")});this.toggle_state=0;if(F){F.innerHTML="More Categories"}}else{this.hidden_tiles.each(function(G){G.setStyle("display","block")});this.toggle_state=1;if(F){F.innerHTML="Fewer Categories"}}};this.toggle_meanings=function B(){if(this.retrieve("toggled")){var F=$(this.parentNode).getElement(".hidden");F.setStyle("display","none");this.store("toggled",0);this.innerHTML="See more&nbsp;&raquo;"}else{var F=$(this.parentNode).getElement(".hidden");F.setStyle("display","inline");this.store("toggled",1);this.innerHTML="&laquo;&nbsp;See fewer"}}}var Tips=new Class({Implements:[Events,Options],options:{onShow:function(A){if(A.element.retrieve("tip:title")=="No description"){A.tip.addClass("disabled")}else{A.tip.removeClass("disabled")}A.tip.setStyle("visibility","visible")},onHide:function(A){A.tip.setStyle("visibility","hidden")},showDelay:250,hideDelay:300,className:"tip_wrapper",offsets:{x:0,y:1},fixed:true,interactable:false,direction:"down"},initialize:function(){var A=Array.link(arguments,{options:Object.type,elements:$defined});this.setOptions(A.options||null);this.tip=new Element("div").setStyle("display","none").inject(document.body);if(this.options.className){this.tip.addClass(this.options.className)}this.container=new Element("div",{"class":"tip"}).inject(this.tip);this.tip.setStyles({position:"absolute",top:0,left:0,visibility:"hidden",display:""});if(A.elements){this.attach(A.elements)}},attach:function(A){$$(A).each(function(F){var I=F.retrieve("tip:title",(F.get("title"))?F.get("title"):"No description");var H=F.retrieve("tip:enter",this.elementEnter.bindWithEvent(this,F));var D=F.retrieve("tip:leave",this.elementLeave.bindWithEvent(this,F));F.addEvents({mouseenter:H,mouseleave:D});if(this.options.interactable){var G=this.tipEnter.bindWithEvent(this,F);var B=this.tipLeave.bindWithEvent(this,F);this.tip.addEvents({mouseenter:G,mouseleave:B})}if(!this.options.fixed){var C=F.retrieve("tip:move",this.elementMove.bindWithEvent(this,F));F.addEvent("mousemove",C)}F.store("tip:native",F.get("title"));F.erase("title")},this);return this},detach:function(A){$$(A).each(function(B){B.removeEvent("mouseenter",B.retrieve("tip:enter")||$empty);B.removeEvent("mouseleave",B.retrieve("tip:leave")||$empty);B.removeEvent("mousemove",B.retrieve("tip:move")||$empty);B.eliminate("tip:enter").eliminate("tip:leave").eliminate("tip:move");var C=B.retrieve("tip:native");if(C){B.set("title",C)}});return this},elementEnter:function(B,A){this.event=B;$clear(this.timer);if(A==this.element){return }this.timer=this.show.delay(this.options.showDelay,this,A)},elementLeave:function(B,A){$clear(this.timer);this.timer=this.hide.delay(this.options.hideDelay,this,A)},tipEnter:function(B,A){$clear(this.timer)},tipLeave:function(B,A){this.elementLeave(B,A)},elementMove:function(A){this.position(A)},position:function(C){var A=window.getSize(),F=window.getScroll();var D={x:this.tip.offsetWidth,y:this.tip.offsetHeight};var B={x:"left",y:"top"};for(var G in B){var H=C.page[G]+this.options.offsets[G];if((H+D[G])>A[G]||(G=="y"&&this.options.direction=="up")){H=C.page[G]-D[G]-this.options.offsets[G]}this.tip.setStyle(B[G],H)}},fill:function(B,A){(typeof A=="string")?B.set("html",A):B.adopt(A)},setContent:function(A){this.fill(this.container,A)},show:function(A){this.element=A;$A(this.container.childNodes).each(Element.dispose);var B=A.retrieve("tip:title");if(B){this.setContent(B)}this.position(this.event);this.fireEvent("show",{"tip":this.tip,"element":A})},hide:function(A){this.element=null;this.fireEvent("hide",{"tip":this.tip,"element":A})}});var ExploreTips=new Class({Extends:Tips,initialize:function(){this.options.ajaxDelay=0;this.options.img_box=50;this.parent.apply(this,arguments)},setContent:function(){var D=category_attributes[this.element.id];var G=(D.desc!="No description");this.more_link="/search?q="+encodeURIComponent(D.query)+"&d="+encodeURIComponent(gQuery);var B=new Element("a",{href:this.more_link,html:D.title});var I=new Element("h3",{"class":"title"});I.grab(B);I.inject(this.container);if(D.img&&G){if(D.img){var C=D.img.x;var F=D.img.y;if(D.img.x>this.options.img_box||D.img.y>this.options.img_box){var H=this.options.img_box/Math.max(D.img.x,D.img.y);C=Math.floor(D.img.x*H);F=Math.floor(D.img.y*H)}}var A=new Element("img",{"src":D.img.url,"width":C,"height":F});A.inject(this.container)}if(G){this.container.appendText(D.desc)}this.loading=new Element("div",{"class":"loading"});this.loading.inject(this.container);this.fetchHits(D.query)},fetchHits:function(A){if($type(this.ajax_timer)=="number"){$clear(this.ajax_timer)}if(this.request){this.request.cancel()}this.request=new Request({url:"/search?num_results=3&drilldown=1&q="+A,onSuccess:this.appendHits.bind(this)});this.ajax_timer=this.request.send.delay(this.options.ajaxDelay,this.request)},appendHits:function(response){eval("var hits = "+response);var that=this;this.loading.dispose();if(hits.results.length==0){return }this.hit_container=new Element("div",{"class":"hits","html":"<h4>Top Results</h4>"});this.hit_container.inject(this.container);hits.results.each(function(hit){var short_url=hit.url.replace(/http:\/\//i,"");if(short_url.length>=45){short_url=short_url.substr(0,44)+"..."}var div=new Element("div",{"class":"hit"});var a=new Element("a",{"class":"title","href":hit.url,"html":hit.title});var br=new Element("br");var a2=new Element("a",{"class":"url","href":hit.url,"html":short_url});div.adopt([a,br,a2]);that.hit_container.grab(div)});var more=new Element("a",{href:this.more_link,html:"More results","class":"more_link"});more.inject(this.hit_container);var coords=this.tip.getCoordinates();var win=window.getSize();if(coords.bottom>=win.y){this.tip.setStyle("top",win.y-coords.height-10)}if(coords.right>=win.x){this.tip.setStyle("left",win.x-coords.width-10)}}});var SERPCompare={q:"",googleResults:{},googleSet:0,urlregex:/www\./i,init:function(){SERPCompare.q=id("fld_q").value;SERPCompare.fetchGoogle()},markResults:function(){$each($$(".web_result"),function(D,C,F){url=D.getElement(".url").href.replace(SERPCompare.urlregex,"");if(typeof (SERPCompare.googleResults[url])=="undefined"){new Fx.Tween(D.getElement(".onlyoncuil"),{"duration":1000}).start("opacity",0,1)}});var B={offsets:{x:5,y:10},direction:"up",hideDelay:100,className:"tip_wrapper onlycuil"};var A=new Tips($$(".onlyoncuil"),B)},fetchGoogle:function(){body=$$("#bdy");switch(SERPCompare.googleSet){case 0:rsz="large";start=0;break;case 1:rsz="large";start=8;break;case 2:rsz="small";start=16;break}var A=Element("script",{"type":"text/javascript","src":"http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz="+rsz+"&start="+start+"&callback=SERPCompare.processGoogle&context=context&q="+encodeURIComponent(SERPCompare.q)});SERPCompare.googleSet++;A.inject("bdy")},processGoogle:function(A,C,B){$each(C.results,function(F,D,G){SERPCompare.googleResults[F.url.replace(SERPCompare.urlregex,"")]=true});if(SERPCompare.googleSet>2){SERPCompare.markResults()}else{SERPCompare.fetchGoogle()}}}