var cacheLocation="cache";var adCacheLocation="pcache";var textIndexLocation="/textindex/";var aoLastResults={};var oBodyDimensions={};var historyData={};var hGetParams={};var aoImages=[];var recentQueries=[];var animation=null;var loadingAnim=null;var zIndex=100;var resultSize=1;var imageMargin=4;var imgSize=125;var adSize=imgSize-20;var divWidth=(imgSize+15);var divHeight=(imgSize+15);var pageHeight=0;var pageWidth=0;var ac=null;var imagesPerPage=21;var isViewing=false;var currentMenu=null;var menuEffect=null;var isIE=navigator.userAgent.indexOf("MSIE")>=0;var zoomState=0;var lastUri="";var baseUri="";var lastQuery="";var lastRequest=null;var lastResponse=null;var lastHistoryEntry="";var currentHistoryKey="";var imageLoadId=-1;var currentOffset=0;var viewSteps=0;var updateOffset=0;var zoomDelay=null;function handleFailure(a){status(false);$("error").innerHTML=a.responseText}function status(b){var a=$("loading");a.style.left=(oBodyDimensions.width-a.getDimensions().width)/2;a.style.zIndex=zIndex++;if(b){a.style.display="inline"}else{a.style.display="none"}}function checkKey(c,b){var a;if(window.event){a=window.event.keyCode}else{if(b){a=b.which}}if(a==13){textQuery(0)}}function adCache(a){var b=a.imageid;return adCacheLocation+"/"+b.substr(0,1)+"/"+b.substr(1,1)+"/"+b+".jpg"}function cache(a){var b=a.imageid;return cacheLocation+"/"+b.substr(0,1)+"/"+b.substr(1,1)+"/"+b+".jpg"}function zoomOut(b){if(zoomState==1){var a=b==null?null:b.relatedTarget;if(a==null||a.id.indexOf("tmp")!=0){if(animation!=null){animation.cancel();animation=null}$("tmpdiv").style.display="none";$("tmpdiv").style.width=divWidth;$("tmpdiv").style.height=divHeight;$("tmpicons").style.display="none";zoomState=0}}}function zoomIn(b){var q=b.substr(3);zoomOut();if(zoomState==2){zoomDelay=q;return}if(animation!=null){animation.cancel();animation=null}zoomState=1;var o=$("d"+b).positionedOffset();$("tmpdiv").style.display="inline";$("tmpdiv").style.left=o[0]+"px";$("tmpdiv").style.top=o[1]+"px";$("tmpdiv").style.width=divWidth+"px";$("tmpdiv").style.height=divHeight+"px";currentImageIndex=q;$("tmpforward").href=aoImages[q].puri;$("tmpimg").src=$(b).src;var d=$("tmpimg").style.width=$(b).width;var s=$("tmpimg").style.height=$(b).height;var g=parseInt($(b).style.left);var u=parseInt($(b).style.top);var k=0;if(resultSize==0){k=0.8}else{if(resultSize==1){k=0.6}else{k=0}}var f=parseInt(divWidth*k);var r=d*(1+k);var n=s*(1+k);p=100*parseFloat(r)/parseFloat(d);$("tmpimg").style.top=$(b).style.top;$("tmpimg").style.left=$(b).style.left;$("tmpimg").original=[$(b).style.left,$(b).style.top,d,s];$("tmphref").href="#qbi="+aoImages[q].imageid;var c=((o[1]-f/2)+divHeight+f+1+$("tmpicons").getDimensions().height);c=c-($("bottomBar").cumulativeOffset()[1])+3;if(c<0){c=0}var a=Math.ceil(Math.max($("imageresults").cumulativeOffset()[1]-5,(o[1]-f/2-c)));var m=a+divHeight+f+1;var i=Math.ceil(o[0]-f/2);if(i<1){i=1}$("tmpicons").style.width=divWidth+f-4;$("tmpicons").style.top=m+"px";$("tmpicons").style.left=i+"px";$("tmpicons").style.display="none";var e=((divWidth+f)/divWidth);animation=new Effect.Parallel([new Effect.Morph("tmpdiv",{sync:true,style:"left:"+i+"px;top:"+a+"px;width:"+(divWidth+f)+"px;height:"+(divHeight+f)+"px;"}),new Effect.Morph("tmpimg",{sync:true,style:"left:"+((divWidth+f-r)/2)+"px;top:"+((divHeight+f-n)/2)+"px;width:"+(r)+"px;height:"+(n)+"px;"}),new Effect.Appear("tmpicons",{sync:true})],{transition:Effect.Transitions.sinoidal,duration:0.2,delay:0.2,afterFinish:function(){animation=null}})}function submitFeedback(){status(true);if(lastRequest!=null){lastRequest.transport.abort()}lastRequest=new Ajax.Request("submitfeedback.php",{method:"post",parameters:"data="+$("comment").value,onSuccess:function(a){status(false);if(a.responseText=="success"){alert("Thanks for the valuable feedback  ;)");$("comment").value="";Effect.Shrink("feedback",{direction:"top-right",duration:0.7})}},onFailure:handleFailure})}function setCookie(b,a){var c=new Date();c.setDate(c.getDate()+365*10);document.cookie=b+"="+escape(a)+";expires="+c.toGMTString()}function getCookie(a,c){if(document.cookie.length>0){var b=document.cookie.indexOf(a+"=");if(b>=0){b+=a.length+1;j=document.cookie.indexOf(";",b);if(j<0){j=document.cookie.length}return unescape(document.cookie.substring(b,j))}}return c}function hideMenu(b){var a=$(b);Effect.SlideUp(a,{duration:0.3})}var overMenu=null;var isOver=false;function disappear(){if(!isOver){if(overMenu!=null){overMenu.style.display="none"}overMenu=null}}function showMenu(a,d){if(menuEffect==null){var c=a.element();var b=c.cumulativeOffset();overMenu=$(d);overMenu.style.left=b[0]-7;overMenu.style.top=b[1]+c.getDimensions().height+5;overMenu.style.zIndex=zIndex++;isOver=true;c.observe("mouseout",function(e){isOver=false;setTimeout(disappear,1000)});overMenu.observe("mouseout",function(e){isOver=false;setTimeout(disappear,1000)});c.observe("mouseover",function(e){isOver=true});overMenu.observe("mouseover",function(e){isOver=true});menuEffect=Effect.BlindDown(overMenu,{duration:0.3,afterFinish:function(){menuEffect=null}});currentMenu=d}}function showFeedback(){var a=$("feedback");var b=$("feedbackoffset").cumulativeOffset();a.style.left=b[0]-500;a.style.top=b[1]+30;Effect.Grow("feedback",{direction:"top-right",duration:0.7})}function redirect(a){if(isIE){window.open(aoImages[a].puri,"_blank")}else{window.location.href=aoImages[a].puri}return false}function unviewImage(){isViewing=false;$("overlayBG").style.display="none";$("overlayBorder").style.display="none";$("infoContent").style.display="none";$("disclaimer").style.display="none";$("loadingImg").style.display="none";$("prevClick").style.display="none";$("nextClick").style.display="none";zoomOut();if(hGetParams.v!=null){window.history.go(-(viewSteps-1));hGetParams.v=null;addHistoryEntry()}else{window.history.go(-viewSteps)}viewSteps=0}function moveView(g){addHistoryEntry(g);viewSteps++;isViewing=true;status(true);g=imageLoadId=parseInt(g);var b=new Image();var a=aoImages[g].uri;var f=aoImages[g].puri;var e=70;if(f.length>e){f=" ... "+f.substring(f.length-e)}if(a.length>e){a=" ... "+a.substring(a.length-e)}var d=600;$("loadingImg").style.display="inline";$("overlayBorder").style.display="none";$("loadingImgSrc").src=cache(aoImages[g]);if(isIE){$("infoContent").innerHTML="Image: <a href='"+aoImages[g].uri+"'>"+a+"</a><br/>Page: <a target='_blank' href='"+aoImages[g].puri+"'>"+f+"</a>"}else{$("infoContent").innerHTML="Image: <a href='"+aoImages[g].uri+"'>"+a+"</a><br/>Page: <a href='"+aoImages[g].puri+"'>"+f+"</a>"}$("infoContent").style.display="inline";$("infoContent").style.height=58;$("infoContent").style.width=d;$("infoContent").style.left=(oBodyDimensions.width-d)/2;$("disclaimer").style.display="inline";$("disclaimer").style.width=d;$("disclaimer").style.left=(oBodyDimensions.width-d)/2;b.onerror=viewError;b.onload=function(h){if(g!=imageLoadId){return}status(false);var k=b.height;var i=b.width;var l=$("infoContent").getDimensions();if(b.height>(oBodyDimensions.height-l.height-120)){b.height=oBodyDimensions.height-l.height-120;b.width=(b.height/k)*i}if(b.width>oBodyDimensions.width){b.width=oBodyDimensions.width;b.height=(b.width/i)*k}if(loadingAnim!=null){loadingAnim.cancel()}$("overlayContent").innerHTML="<img id='viewImg' width='"+b.width+"' height='"+b.height+"' src='"+b.src+"'/><br/>";$("overlayContent").style.display="inline";$("loadingImg").style.display="none";$("overlayBorder").style.top=((oBodyDimensions.height-120-b.height)/2)+"px";$("overlayBorder").style.left=((oBodyDimensions.width-30-b.width)/2)+"px";$("overlayBorder").style.display="inline";if(!isViewing){unviewImage()}};b.src=aoImages[g].uri;var c=new Image();c.onload=function(){var l=c.height;var i=c.width;var k=86*(i/l);$("prevImg").src=c.src;$("prevImg").width=k;$("prevClick").style.left=(oBodyDimensions.width-d)/2-k-4};if(g<=0){$("prevClick").style.display="none"}else{$("prevImg").onload=function(){$("prevClick").style.display="inline"};c.src=cache(aoImages[g-1])}if((g+1)>=aoImages.length){$("nextClick").style.display="none"}else{$("nextImg").onload=function(){$("nextClick").style.display="inline";$("nextClick").style.left=(oBodyDimensions.width-d)/2+d+9};$("nextImg").src=cache(aoImages[g+1])}$("prevClick").onclick=function(){moveView(g-1);return false};$("nextClick").onclick=function(){moveView(g+1);return false}}function viewImage(a){$("overlayBG").style.zIndex=zIndex++;$("overlayBorder").style.zIndex=zIndex++;$("infoContent").style.zIndex=zIndex++;$("prevClick").style.zIndex=zIndex++;$("nextClick").style.zIndex=zIndex++;$("loadingImg").style.zIndex=zIndex++;$("overlayContent").style.zIndex=zIndex++;$("disclaimer").style.zIndex=zIndex++;$("loadingImg").style.top=((oBodyDimensions.height-256-50)/2)+"px";$("loadingImg").style.left=((oBodyDimensions.width-256)/2)+"px";loadingAnim=new Effect.Appear("loadingImg",{delay:0,duration:0.2,from:0,to:1});new Effect.Appear("overlayBG",{duration:0.2,from:0,to:0.9});zoomOut();moveView(a);return false}function viewError(){status(false);$("overlayContent").innerHTML="<img id='viewImg' src='"+$("loadingImgSrc").src+"'/><br/>";$("overlayContent").style.display="inline";$("overlayBorder").style.top=((oBodyDimensions.height-120-256)/2)+"px";$("overlayBorder").style.left=((oBodyDimensions.width-30-256)/2)+"px";$("overlayBorder").style.display="inline";$("loadingImg").style.display="none"}function getWindowSize(a){return document.viewport.getDimensions()}function resize(){zoomOut();oBodyDimensions=getWindowSize();$("topbar").style.width=oBodyDimensions.width-230;if($("imageresults")==null||lastResponse==null){return}var l=$("imageresults").cumulativeOffset()[1];var h=$("adresults").getDimensions();if(lastResponse.ads!=null&&lastResponse.ads.length>0){h.width=adSize-10}else{h.width=0}var g=0;var e=0;for(var k=0;k<aoImages.length;++k){var d=$("dimg"+k);if(e==0&&g>d.cumulativeOffset()[0]){e=k}g=d.cumulativeOffset()[0]}if(e>0){pageWidth=e}else{if(pageWidth==0){pageWidth=7}}var c=$("bottomBar").cumulativeOffset()[1];if($("dimg0")!=null){var b=$("dimg0").getHeight()+2*imageMargin;var a=l;var f=(c-a);pageHeight=Math.floor(f/b)}else{pageHeight=3}imagesPerPage=pageWidth*pageHeight;for(var k=0;k<aoImages.length;++k){var d=$("dimg"+k);if(d!=null){if(k>=imagesPerPage){d.style.display="none"}else{d.style.display="inline"}}}doAds(lastResponse.ads);if(aoImages.length>0&&imagesPerPage>aoImages.length&&((currentOffset+imagesPerPage)<lastResponse.resultcount||lastResponse.israndom)){updateOffset=aoImages.length;moveBy(0);return true}else{if(lastResponse!=null){updateStats(lastResponse);updatePages(lastResponse)}$("pages").style.width=oBodyDimensions.width-10;return false}}function recordClick(c,b){var a=new Ajax.Request("recordclick.php?cid="+c+"&imgId="+b,{method:"get",asynchronous:false});return true}function doAds(d){if(lastResponse.ads==null||lastResponse.ads.length==0){$("adresults").style.display="none";return}var c=$("adresults");if(isIE){c.style.display="block"}else{c.style.display="table-cell"}var b=adSize+40;c.style.width=b;c.style.height=(pageHeight*divHeight)+"px";var a=[];for(var g=0;g<d.length&&g<pageHeight;++g){var q="adimg"+(g);var n=d[g].width;var k=d[g].height;if(n>=k){if(n>adSize){var e=(adSize+20)/n;n=(adSize+20);k=k*e}}else{if(k>adSize){var e=(adSize)/k;k=adSize;n=n*e}}var f=parseInt((b-n)/2);var o=parseInt((divHeight-20-k)/2);add="border-left: 1px solid #aaaaaa;border-right: 1px solid #aaaaaa;border-bottom: 1px solid #aaaaaa;";a.push("<div id='d"+q+"' style='"+add+" overflow:hidden; background:#eeeeee; float: right; width:"+(b)+"px; height:"+(divHeight+8)+"px;'>");a.push("<div style='position:relative;left:"+f+"px;top:"+o+"px' >");a.push("<a href='"+d[g].uri+"' onclick='recordClick("+lastResponse.adid+',"'+d[g].imageid+"\");'>");a.push("<img id='"+q+"' border='0' width='"+n+"' height='"+k+"' src='");a.push(adCache(d[g]));a.push("' />");a.push("</a>");a.push("</div><div style='position:relative; border:1px solid black; font-size:x-small; padding:0px; overflow:hidden; width:"+(b-20)+"px; background:#eeeeee; text-align:center; left:10px; height:25px; top:"+(o+4)+"px'>");if(d[g].price>0){a.push("$");a.push(d[g].price);a.push(" - ")}a.push(d[g].name);a.push("</div></div>")}c.innerHTML="<div style='background:#eeeeee; text-align:center; float: right; border: 1px solid #aaaaaa; width:"+(b)+"px;'><font size='-2'>Sponsored Images</font></div>"+a.join("")}var toLoad=[];function signalLoad(b){if($("dimg"+b).getOpacity()>=1){toLoad[b]=true;if(zoomDelay==b){zoomState=1;zoomOut();zoomIn("img"+zoomDelay)}for(var a=0;a<toLoad.length;++a){if(!toLoad[a]){return}}if(zoomState==2){zoomState=1;zoomOut()}}}function doFullCategory(o,n){if(lastResponse.ads!=null&&lastResponse.ads.length>0){doAds(lastResponse.ads)}else{$("adresults").style.display="none"}aoImages=[];zoomDelay=null;var m="";oRoot=$("imageresults");if(o.length==0){zoomState=1;zoomOut()}if(updateOffset<=0){toLoad=[]}for(var a=0;a<o.length;++a){if(o[a]==null){continue}var k="";if(a>=updateOffset){toLoad[a]=false;var g="img"+(a);o[a].localId=g;var f=Math.max(o[a].width,o[a].height)/imgSize;var l=o[a].width/f;var b=o[a].height/f;var e=n?"onload='if (!toLoad["+a+']){new Effect.Opacity("d'+g+'",{from:0, to:1, duration:0.1, queue: { scope: "test'+a+'"},afterFinish: function() {signalLoad('+a+");}});}'":"";var d=n?("opacity:0;"+(isIE?"filter:alpha(opacity=0);":"")):"";var c=(a>=imagesPerPage)?"none":"inline";k+="<div id='d"+g+"' style='position:relative; display:"+c+"; background:#ffffff; "+d+" overflow:hidden; border: 1px solid #dddddd; margin:"+imageMargin+"px; vertical-align: middle; float: left; width:"+divWidth+"px; height:"+divHeight+"px;' onmouseover='javascript:zoomIn(\""+g+"\");'><img id='"+g+"' style='position:relative; top:"+((divHeight-b)/2)+"px; left:"+((divWidth-l)/2)+"px;' "+e+" onmouseover='javascript:zoomIn(\""+g+"\");' border='0' width='"+l+"' height='"+b+"' src='"+cache(o[a])+"' /></div>"}aoImages.push(o[a]);m+=k}if(updateOffset>0){updateOffset=0;oRoot.innerHTML+=m}else{oRoot.innerHTML=m}return resize()}function moveBy(a){currentOffset+=(imagesPerPage*a);if(currentOffset<0){currentOffset=0}if(lastRequest!=null){lastRequest.transport.abort()}status(true);lastUri=baseUri+"&s="+currentOffset+"&l="+imagesPerPage;lastRequest=new Ajax.Request(lastUri,{method:"get",onSuccess:handleQuery,onFailure:handleFailure})}function moveTo(a){currentOffset=a;if(currentOffset<0){currentOffset=0}if(lastRequest!=null){lastRequest.transport.abort()}status(true);lastUri=baseUri+"&s="+currentOffset+"&l="+imagesPerPage;lastRequest=new Ajax.Request(lastUri,{method:"get",onSuccess:handleQuery,onFailure:handleFailure})}function updatePages(a){if(a.israndom){$("pages").innerHTML="<img style='vertical-align:middle' width='0' height='26' src='images/blank.gif'/><a href='javascript:loadRandom();'>More random images</a>, please.";return}var f=[];var e=currentOffset;var d=Math.floor(e/imagesPerPage);var c=Math.max(0,(e-10*imagesPerPage));var b=Math.min(a.resultcount,e+10*imagesPerPage);if(d>0){f.push("<a href='#' onclick='moveBy(-1); return false;'>Previous Page</a> . ")}else{f.push("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ")}for(;c<b;c+=imagesPerPage){var g=Math.floor((c/imagesPerPage));if(g==d){f.push(g+1)}else{f.push("<a href='#' onclick='moveTo("+c+"); return false;'>"+(g+1)+"</a>")}}if((a.resultcount-e)<=imagesPerPage){f.push(" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ")}else{f.push(" . <a href='#' onclick='moveBy(1); return false;'>Next Page</a>")}if(f.length>3){$("pages").innerHTML="<img style='vertical-align:middle' width='0' height='26' src='images/blank.gif'/>"+f.join(" ")}else{$("pages").innerHTML=""}}function updateStats(a){if(a.israndom){$("instructions").innerHTML="<img style='vertical-align:middle' width='0' height='26' src='images/blank.gif'/>&nbsp;Click on any image below to find similar images, or enter a query above&nbsp;";$("stats").innerHTML=a.lastStats=""}else{if(a.resultcount==0){$("instructions").innerHTML="<img style='vertical-align:middle' width='0' height='26' src='images/blank.gif'/>&nbsp;Your query for "+lastQuery+" did not match any images&nbsp;";$("stats").innerHTML=a.lastStats=""}else{if(a.recentQueries.length>0){$("instructions").innerHTML="<img style='vertical-align:middle' width='0' height='26' src='images/blank.gif'/>&nbsp;Click "+a.recentQueries[0]+" to return to your initial search"}else{$("instructions").innerHTML="<img style='vertical-align:middle' width='0' height='26' src='images/blank.gif'/>&nbsp;Click on any image below to find similar images"}$("stats").innerHTML=a.lastStats="<img style='vertical-align:middle' width='0' height='26' src='images/blank.gif'/>&nbsp;Results <b>"+(currentOffset+1)+"</b> - <b>"+(Math.min(a.resultcount,currentOffset+imagesPerPage))+"</b> of <b>"+(a.resultcount)+"</b> for "+lastQuery+" (<i>"+a.time+" seconds</i>)&nbsp;"}}}function handleQuery(obj){if(ac!=null){ac.hide()}status(false);lastRequest=null;try{if(obj.responseText==""||obj.responseText==null){return}var _72=lastResponse=eval(obj.responseText);if(_72.error!=null){$("stats").innerHTML="<img style='vertical-align:middle' width='1' height='26' src='images/blank.gif'/>&nbsp;<b>"+_72.error+"</b>";$("instructions").innerHTML="";return}_72.time=(Math.round(_72.time/10)/100);aoImages=[];_72.lastUri=lastUri;_72.baseUri=baseUri;_72.lastQuery=lastQuery;_72.h=currentHistoryKey;_72.offset=currentOffset;_72.recentQueries=[];for(var i=0;i<recentQueries.length;++i){_72.recentQueries.push(recentQueries[i])}updateStats(_72);updatePages(_72);lastHistoryEntry=currentHistoryKey;if(historyData[lastHistoryEntry]==null){addHistoryEntry()}else{historyData[lastHistoryEntry]=_72}if(!doFullCategory(_72.results,true)){if(hGetParams.v!=null){viewImage(hGetParams.v)}}}catch(ex){$("error").innerHTML=ex.toString()}}function loadRandom(){baseUri="randomimages.php?&r="+Math.ceil(1000000*Math.random());lastUri=baseUri+"&s=0&l="+(imagesPerPage);currentHistoryKey="random";lastQuery="random";if(lastRequest!=null){lastRequest.transport.abort()}status(true);lastRequest=new Ajax.Request(lastUri,{method:"get",onSuccess:handleQuery,onFailure:handleFailure})}function queryByImage(f,e){if(ac!=null){ac.hide()}if(e==0&&currentHistoryKey!=""){if(currentHistoryKey!="random"){if(currentHistoryKey.indexOf("qbl=")>=0){recentQueries.push("<a href='#"+currentHistoryKey+"&o="+currentOffset+"' onclick='historyListener(\""+(currentHistoryKey+"&o="+currentOffset)+"\");'><img style='vertical-align:middle' border='0' src='images/icon.up.png' alt='Return to your first query'/></a>")}else{recentQueries.push("<a href='#"+currentHistoryKey+"&o="+currentOffset+"' onclick='historyListener(\""+(currentHistoryKey+"&o="+currentOffset)+"\");'>"+lastQuery+"</a>")}}else{recentQueries.push("<a href='#"+currentHistoryKey+"' onclick='historyListener(\""+(currentHistoryKey)+"\");'><img style='vertical-align:middle' border='0' src='images/icon.up.png' alt='Return to your first query'/></a>")}}if($("tmpdiv")!=null&&$("tmpimg")!=null&&$("dimg0")!=null){var c=$("tmpimg").original;zoomState=2;$("tmpicons").style.display="none";var h=$("dimg0").cumulativeOffset();var a=[];for(var b=0;b<aoImages.length;++b){var d="dimg"+(b);$(d).style.display="none"}if(animation!=null){animation.cancel();animation=null}animation=new Effect.Parallel([new Effect.Move("tmpdiv",{sync:true,x:h[0],y:h[1],mode:"absolute"}),new Effect.Morph("tmpimg",{sync:true,style:"left:"+c[0]+";top:"+c[1]+";width:"+c[2]+"px;height:"+c[3]+"px;"}),new Effect.Highlight("tmpdiv",{startcolor:"#ffff00",endcolor:"#ffff88",restorecolor:"#ffffff"}),new Effect.Morph("tmpdiv",{sync:true,style:"width:"+divWidth+"px;height:"+divHeight+"px;"})],{transition:Effect.Transitions.linear,duration:0.4,delay:0,afterFinish:function(){}})}var g=0;if(e!=null){currentOffset=e}else{currentOffset=0}baseUri=textIndexLocation+"?qbi="+f;currentHistoryKey="qbi="+f;lastQuery="<img border='0' height='26' style='vertical-align:middle;' src='"+cache({imageid:f})+"'/>";if(lastRequest!=null){lastRequest.transport.abort()}status(true);lastUri=baseUri+"&s="+currentOffset+"&l="+imagesPerPage;if(window.location.host=="localhost"){setTimeout(function(){lastRequest=new Ajax.Request(lastUri,{method:"get",onSuccess:handleQuery,onFailure:handleFailure})},500)}else{lastRequest=new Ajax.Request(lastUri,{method:"get",onSuccess:handleQuery,onFailure:handleFailure})}}function textQuery(a){if(ac!=null){ac.hide()}var b=$("q").value;if(a!=null){currentOffset=a}else{currentOffset=0}b=b.replace(/#/g,"");baseUri=textIndexLocation+"?qbl="+b;currentHistoryKey="qbl="+b;lastQuery="<b>"+b+"</b>";recentQueries=[];if(lastRequest!=null){lastRequest.transport.abort()}status(true);lastUri=baseUri+"&s="+currentOffset+"&l="+(imagesPerPage);lastRequest=new Ajax.Request(lastUri,{method:"get",onSuccess:handleQuery,onFailure:handleFailure})}function addHistoryEntry(b){var a=lastHistoryEntry;if(!lastResponse.israndom){a+="&o="+currentOffset}if(b!=null){a+="&v="+b}else{if(hGetParams.v!=null){a+="&v="+hGetParams.v}}historyData[a]=lastResponse;if(unFocus.History.getCurrent()==a){lastResponse.ignore=0}else{lastResponse.ignore=1}unFocus.History.addHistory(a);$("q").focus();setHistoryInfo()}function historyListener(c){if(c==""||c==null){return false}var b=historyData[c];if(b==null){loadData(c);return false}var a=getHistoryParameters(c);if(b.ignore==1){b.ignore=0;return false}if(zoomState==2){zoomState=1}zoomOut();toLoad=[];if(b!=null){lastResponse=b;currentOffset=b.offset;aoImages=[];baseUri=b.baseUri;lastUri=b.lastUri;currentHistoryKey=b.h;lastQuery=b.lastQuery;recentQueries=[];for(var d=0;d<b.recentQueries.length;++d){recentQueries.push(b.recentQueries[d])}$("stats").innerHTML=b.lastStats;setHistoryInfo();updatePages(b);doFullCategory(b.results,false)}else{loadData(c)}if(a.v!=null){hGetParams.v=a.v;viewImage(a.v);return false}else{if(isViewing){unviewImage()}}return false}function getParam(c){c=c.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+c+"=([^&#]*)");var a=b.exec(window.location.href);if(a==null){return null}else{return a[1]}}function getHistoryParameters(d){var c=d.split("&");var b={};for(var a=0;a<c.length;a++){var e=c[a].split("=");if(e.length==2){b[e[0]]=e[1]}else{b[e[0]]=""}}return b}function setHistoryInfo(){if(recentQueries.length>0){var a=7;if(recentQueries.length>a){$("history").innerHTML="History <img style='vertical-align:middle' width='1' height='26' src='images/blank.gif'/>"+recentQueries.slice(0,a).join(" | ")+" | ...&nbsp;"}else{$("history").innerHTML="History <img style='vertical-align:middle' width='1' height='26' src='images/blank.gif'/>"+recentQueries.join(" | ")+"&nbsp;"}}else{$("history").innerHTML=""}}function loadData(a){hGetParams=getHistoryParameters(a);if(hGetParams.o!=null){currentOffset=parseInt(hGetParams.o)}if(hGetParams.qbl!=null){$("q").value=hGetParams.qbl;textQuery(currentOffset)}else{if(hGetParams.qbi!=null){queryByImage(hGetParams.qbi,currentOffset)}else{loadRandom()}}}function load(){resize();$("about").observe("mouseover",function(c){showMenu(c,"menu1")});oBodyDimensions=getWindowSize();var b=getParam("index");if(b!=null){textIndexLocation=b}setThumbnailSize(parseInt(getCookie("thumbsize","1")));if($("tmpdiv")==null){$("html").style.overflowX="hidden";return}else{$("html").style.overflow="hidden"}$("tmpdiv").observe("mouseout",function(c){zoomOut(c)});$("tmpimg").observe("mouseout",function(c){zoomOut(c)});$("tmpicons").observe("mouseout",function(c){zoomOut(c)});unFocus.History.addEventListener("historyChange",historyListener);var a=unFocus.History.getCurrent();loadData(a);ac=new Ajax.Autocompleter("q","autocompleteOutput","ac.php",{paramName:"q",minChars:1,updateElement:function(d,c){if(d!=null){$("q").value=d.innerHTML}textQuery(0)}});$("q").focus();new Control.Slider("sliderHandle","sliderTrack",{range:$R(0,2),values:[0,1,2],sliderValue:resultSize,onSlide:function(c){},onChange:function(c){setThumbnailSize(c);setCookie("thumbsize",c);doFullCategory(aoImages,false)}})}function setThumbnailSize(a){switch(a){case 0:imgSize=90;break;default:case 1:imgSize=125;break;case 2:imgSize=180;break}adSize=imgSize-20;divWidth=(imgSize+10);divHeight=(imgSize+10);resultSize=a;zoomOut()}window.onresize=resize;
