var str_choose_photo="Please, choose your picture.";var str_processing="Processing...";var str_findSimilar="Similar&hellip;";var str_findSimilarGroup="Similar&nbsp;(%SIMILAR_COUNT%)";var str_searchDefaultText="Enter your request here";var str_fileSearch_photoTip='URL - your image address in the Internet. Image will not be uploaded if the remote server is not available or the image is set as private.<br>To achieve best result, upload a&nbsp;high-quality photo with frontal facial portraits, or&nbsp;insert a&nbsp;web link to it\'s source. <a href="/en/faq#ideal">Read&nbsp;more</a>.';var isWebMode=document.body.id=="web";var nophoto=isWebMode?"/img/webnophoto.png":"/img/nophoto.png";var part_fileSearch_photoTip='<div class="question"><div class="tooltip">'+str_fileSearch_photoTip+"</div></div>";document.jsDomEditable=true;var urlSuffix=urlSuffix||"";var bigPreview=bigPreview||"";var previewData=$H(previewData||{});function toggleSearchForm(){var B=$("fileSearchPart");var C=$("urlSearchPart");var D=$("imgUrl");var A=$("imgFile");if(B.visible()){B.hide();D.disabled=false;C.show();B.value="";A.value="";A.disabled=true}else{A.disabled=false;C.hide();B.show();D.value="";D.disabled=true}}Prototype.Browser.FF3=navigator.userAgent.indexOf("Firefox/3.0")>-1;Prototype.Browser.IE8=Prototype.Browser.IE&&navigator.userAgent.indexOf("MSIE 8.0")>-1;Prototype.Browser.FF2=Prototype.Browser.Gecko&&!Prototype.Browser.FF3;function search(){var A=$("searchForm");A.target="uploadFrame";$$("#searchMode a").first().observe("click",function(O){O.stop();var N=$("searchForm");N.action=(isWebMode?"/search":"/web/search")+urlSuffix;N.submit();return false});var K=$("imgFile");var M=$("imgUrl");if(Prototype.Browser.FF2){M.value=K.value}document.jsDomEditable=false;var F=$("searchBtn");F.disabled=true;var B=$("searchInProgress");B.style.visibility="visible";var G=$("no_images_found");if(G){G.style.visibility="hidden"}if(M.value||K.value){var D=$$("#searchPreview img").first();D.src=nophoto;var I=D.up(".c");if(I){I.style.width="144px";I.style.height="144px";var J=I.up(".padding");if(J){J.style.paddingTop="3px"}}var L=$("pom");if(L){L.hide()}var H=$("pom2");if(H){H.hide()}}var C=$("textInput");if(C.value==str_searchDefaultText){C.value="";C.className=""}if(!K.value&&!M.value){B.innerHTML=str_processing}if(Prototype.Browser.Opera&&K.value&&!K.disabled&&(K.value.startsWith("http://")||K.value.startsWith("https://")||K.value.startsWith("ftp://")||K.value.startsWith("ftp://"))){M.disabled=false;M.value=K.value;K.value="";K.disabled=true}try{A.submit()}catch(E){if((Prototype.Browser.IE&&!Prototype.Browser.IE8)|Prototype.Browser.Opera){M.disabled=false;M.value=K.value;K.value="";K.disabled=true;return true}else{alert(str_choose_photo);F.disabled=false;B.style.visibility="hidden";document.jsDomEditable=true}}return false}function processing(){var A=$("searchInProgress");A.innerHTML=str_processing}function similar(B,E){B=$(B);var A=$("searchInProgress");if(A){A.innerHTML=str_processing;A.style.visibility="visible"}if(E){var D=$$("#searchPreview img").first();var I="144px";var C="144px";if(B){var H=B.up(".imgItem,.popup,.imagePreview,.webEl");if(H){var J=H.select(".preview").first();D.src=J.src;var L=J.up(".c");if(L){I=L.style.width;C=L.style.height}}else{D.src=nophoto}}else{D.src=nophoto}if(isWebMode){I=(144/110*parseInt(I,10)).round()+"px";C=(144/110*parseInt(C,10)).round()+"px"}$("textInput").value="";var M=$("pom");if(M){M.hide()}var G=$("pom2");if(G){G.hide()}var F=D.up(".c");if(F){F.style.width=I;F.style.height=C;var K=F.up(".padding");if(K){K.style.paddingTop=(Math.round((144-parseInt(C,10))/2)+3)+"px"}}}document.jsDomEditable=false;if(!isWebMode){$$("#searchMode a").first().observe("click",function(O){O.stop();var N=new RegExp("([0-9A-F]+).jpg$");var P=N.exec(D.src)[1];document.location="/web/searchByImage/"+P+urlSuffix;return false})}}function fs(A){return similar(A,true)}function ungroup(A){return similar(A,false)}RegExp.prototype.allResults=function(C){var A=this.exec(C);var B=[];while(A){B.push(A[1]);A=this.exec(C)}return B};var ImagePreview=Class.create({initialize:function(){this.showDelay=0.75;this.hideDelay=0.01;this.wrapper=new Element("div",{"class":"imagePreviewWrapper"}).setStyle({display:"none",zIndex:2000});document.body.appendChild(this.wrapper);this.wrapper.identify();this.wrapper.appendChild(new Element("div",{"class":"imagePreview"}));this.content=this.wrapper.firstChild.appendChild(new Element("div",{"class":"content"}));this.wrapper.observe("mouseout",this.blur.bindAsEventListener(this));this.wrapper.observe("mouseover",this.hover.bindAsEventListener(this))},templateDefault:'<div class="popup"><div class="aimg"><div class="rel" style="width:%P_WIDTH%px"><img src="'+bigPreview+'" alt="" style="width:%P_WIDTH%px;height:%P_HEIGHT%px;"></div></div></div><div class="ltext"><a href="%SIMILAR_URL%'+urlSuffix+'" target="_blank">%SIMILAR_STR%</a><br><a href="/gotoSrcPage?url=%PAGE_URL%" target="_blank">%SITE%</a></div><div class="rtext">%WIDTH%x%HEIGHT%<br>%KEYWORDS%</div><div class="text"></div>',templateWithFaces:'<div class="popup"><table class="layout"><tr><td class="searchImg"><div class="rel" style="width:%TOP_P_WIDTH%px"><img src="%TOP_IMG_SRC%" alt="" style="width:%TOP_P_WIDTH%px;height:%TOP_P_HEIGHT%px;"></div></td><td class="spacer"></td><td class="resultsImg"><div class="rel" style="width:%P_WIDTH%px"><img src="'+bigPreview+'" alt="" style="width:%P_WIDTH%px;height:%P_HEIGHT%px;"></div></td></tr></table><div class="ltext"><a href="%SIMILAR_URL%'+urlSuffix+'" target="_blank">%SIMILAR_STR%</a><br><a href="/gotoSrcPage?url=%PAGE_URL%" target="_blank">%SITE%</a></div><div class="rtext">%WIDTH%x%HEIGHT%<br>%KEYWORDS%</div>',isTwoImagesMode:function(C){var A=!!document.faces;if(A){var B=$H(document.faces.results).get(C);A=!!B.length}return A},createHTMLPart:function(E,C){var A=null;if(this.isTwoImagesMode(E)){var B=document.faces.topImg;A=this.templateWithFaces.gsub("%TOP_IMG_SRC%",B.imgSrc).gsub("%TOP_P_WIDTH%",B.pw).gsub("%TOP_P_HEIGHT%",B.ph)}else{A=this.templateDefault}var D;if(C.similarCount>1){D=str_findSimilarGroup.gsub("%SIMILAR_COUNT%",C.similarCount)}else{D=str_findSimilar}return A.gsub("%IMAGE_ID%",E).gsub("%SITE%",C.siteName).gsub("%WIDTH%",C.width).gsub("%HEIGHT%",C.height).gsub("%P_WIDTH%",C.pwidth).gsub("%P_HEIGHT%",C.pheight).gsub("%PAGE_URL%",C.pageURL).gsub("%SIMILAR_URL%",C.similarURL).gsub("%SIMILAR_STR%",D).gsub("%KEYWORDS%",C.keywords.map(function(F){var G;if(F.startsWith("<b>")){G=F.substring(3,F.length-4)}else{G=F}return'<a href="/tags/'+encodeURIComponent(G)+"/1"+urlSuffix+'" target="_blank">'+F+"</a>"}).join(" "))},show:function(D){if(!document.jsDomEditable){return }this.content.innerHTML=D.html;var A=this.isTwoImagesMode(D.id);this.content.className=A?"content withFaces":"content";var J=Prototype.Browser.IE?($("box11").offsetLeft/100):1;var H=$(D.el).up(".imgItem").getDimensions().width*J;var C=Position.cumulativeOffset(D.el);var F=this.wrapper.getDimensions();F.width=Math.round(F.width*J);F.height=Math.round(F.height*J);var G={left:C.left+Math.round((H-F.width)/2),top:C.top+Math.round((H-F.height)/2)};var I=document.viewport.getScrollOffsets();var E=document.viewport.getDimensions();var B=10;if(G.left-I.left+F.width>E.width-B){G.left=E.width+I.left-F.width-B}if(G.top-I.top+F.height>E.height-B){G.top=E.height+I.top-F.height-B}if(G.left-I.left<B){G.left=I.left+B}if(G.top-I.top<B){G.top=I.top+B}G.left=Math.round(G.left/J);G.top=Math.round(G.top/J);this.wrapper.setStyle({left:G.left+"px",top:G.top+"px"}).show()},hide:function(){if(!document.jsDomEditable){return }this.wrapper.hide()},hover:function(){if(!document.jsDomEditable){return }if(!this.hideTimer){return }window.clearTimeout(this.hideTimer);this.hideTimer=undefined},blur:function(){if(!document.jsDomEditable){return }if(this.hideTimer){return }this.hideTimer=this.hide.bind(this).delay(this.hideDelay)}});var imagePreview;var ImagePreviewHoverTimer=Class.create({initialize:function(A){A.el.observe("mouseover",this.hover.bind(this,A));A.el.observe("mouseout",this.blur.bind(this,A))},hover:function(A){if(!document.jsDomEditable){return }if(this.showTimer){return }this.showTimer=imagePreview.show.bind(imagePreview).delay(imagePreview.showDelay,A)},blur:function(){if(!document.jsDomEditable){return }if(!this.showTimer){return }window.clearTimeout(this.showTimer);this.showTimer=undefined}});function initImagePreview(){imagePreview=new ImagePreview();$$("div.frame[d]").each(function(B){var D=B.readAttribute("d");var A=previewData.get(D);var C={id:D,el:B,html:imagePreview.createHTMLPart(D,A)};(new ImagePreviewHoverTimer(C))});if(Prototype.Browser.Gecko||Prototype.Browser.WebKit){Event.observe(window,"blur",function(){imagePreview.hide()})}}function initKeyboard(){Event.observe(document,"keydown",function(D){if(!D.ctrlKey){return }var A=D.which||D.keyCode;if(A==Event.KEY_LEFT){var B=$("prev");if(B){document.location=B.href}}else{if(A==Event.KEY_RIGHT){var C=$("next");if(C){document.location=C.href}}else{if(A==Event.KEY_HOME){document.location="/"}}}})}function initPlaceholder(A){A.observe("focus",function(C){var B=C.element();if(B.value==str_searchDefaultText){B.value="";B.className=""}});A.observe("blur",function(C){var B=C.element();if(B.value.blank()||B.value==str_searchDefaultText){B.value=str_searchDefaultText;B.className="placeholder"}else{B.className=""}});if(A.value.blank()){A.value=str_searchDefaultText;A.className="placeholder"}}function initSearchForm(){var A=$("textInput");if(!A){return }(new Ajax.Autocompleter(A,"textInput_auto_complete","/keywordsAutoComplete"));initPlaceholder(A)}function initPom(){var C=$("pom");var B=$("pom2");var A=$("pomValue");if(!C||!B||!A){return }if(A.value=="true"){C.className="";B.hide()}else{C.className="passive";B.show()}C.show();C.observe("click",function(E){var D=E.element();if(A.value!="true"){D.className="";B.hide();A.value="true"}else{D.className="passive";B.show();A.value="false"}})}if(typeof (preInitHook)=="function"){preInitHook()}initSearchForm();initPom();initImagePreview();initKeyboard();