function YW(){this.UW=new Array();}YW.prototype.assignArray=function(VVV){this.UW=VVV;};YW.prototype.getMatches=function(str,VVV,YV){for(var VV=0;VV<this.UW.length;VV++){VVV.push(this.UW[VV]);}};function VU(UW,U,W,YV){this.U=U;this.W=W;this.W.onblur=this.hideSuggest;this.YV=YV;this.UV=-1;this.db=new YW();this.db.assignArray(UW);};VU.prototype.assignEvents=function(){if(!complete_closed){this.U.onkeyup=this.keyUp;this.U.onkeydown=this.keyDown;this.U.VU=this;this.U.onblur=this.hideSuggest;}};VU.prototype.unassignEvents=function(){this.U.onkeyup=null;this.U.onkeydown=null;this.U.VU=null;this.U.onblur=null;};VU.prototype.hideSuggest=function(){try{complete.W.style.visibility="hidden";}catch(e){}};VU.prototype.selectText=function(WY,iEnd){if(this.U.createTextRange){var oRange=this.U.createTextRange();oRange.moveStart("character",WY);oRange.moveEnd("character",iEnd-this.U.value.length);oRange.select();}else if(this.U.setSelectionRange){this.U.setSelectionRange(WY,iEnd);}this.U.focus();};VU.prototype.textComplete=function(sFirstMatch){if(this.U.createTextRange||this.U.setSelectionRange){var WY=this.U.value.length;this.U.value=sFirstMatch;this.selectText(WY,sFirstMatch.length);}};VU.prototype.keyDown=function(VY){VY=window.event||VY;WV=VY.keyCode;switch(WV){case 38:this.VU.VVY();break;case 40:this.VU.VVW();break;case 27:this.VU.W.style.visibility="hidden";break;case 13:this.VU.hideSuggest();StartSearch();break;}};VU.prototype.VVW=function(){if(this.W.childNodes.length>0&&this.UV<(this.W.childNodes.length-1-1)){++this.UV;}else{this.UV=0;}for(var VV=0;VV<this.W.childNodes.length-1;VV++){if(VV==this.UV){this.W.childNodes[VV].className="over";this.U.value=this.W.childNodes[VV].innerHTML;}else{this.W.childNodes[VV].className="";}}};VU.prototype.VVY=function(){if(this.W.childNodes.length>0&&this.UV>0){--this.UV;}else{this.UV=this.W.childNodes.length-2;}for(var VV=0;VV<this.W.childNodes.length-1;VV++){if(VV==this.UV){this.W.childNodes[VV].className="over";this.U.value=this.W.childNodes[VV].innerHTML;}else{this.W.childNodes[VV].className="";}}};VU.prototype.keyUp=function(VY){VY=VY||window.event;var WV=VY.keyCode;if(WV==8||WV==46){this.VU.onTextChange(false);}else if(WV<32||(WV>=33&&WV<=46)||(WV>=112&&WV<=123)){}else{this.VU.onTextChange(true);}};VU.prototype.positionSuggest=function(){var WU=this.U;var x=0,y=WU.offsetHeight;while(WU.offsetParent&&WU.offsetParent.tagName.toUpperCase()!='BODY'){x+=WU.offsetLeft;y+=WU.offsetTop;WU=WU.offsetParent;}x+=WU.offsetLeft;y+=WU.offsetTop;this.W.style.top=y+"px";this.W.style.left=x+"px";};var bTextComplete=true;VU.prototype.drawDiv=function(){var YU=this.U.value;var oThis=this;this.UV=-1;this.W.innerHTML="";var aStr=new Array();this.db.getMatches(YU,aStr,this.YV);if(!aStr.length){this.hideSuggest;return}this.positionSuggest();for(VV in aStr){sss=aStr[VV].replace(/(^\s+)|(\s+$)/g,"");if(sss!=''){this.W.innerHTML+="<div onmousedown=\"click_suggestion(event)\" onmouseout=\"click_suggestion(event)\"  onmouseover=\"click_suggestion(event)\">"+sss+"</div>"}}this.W.innerHTML+="<span id=spansug id=onmousedown=\"close_complete(event)\">закрыть подсказку</div>";this.W.style.visibility="visible";};function close_complete(event){complete_closed=true;complete.unassignEvents();complete.hideSuggest();};function click_suggestion(VY){VY=window.event||VY;oSrcDiv=VY.target||VY.srcElement;if(VY.type=="mousedown"){complete.U.value=oSrcDiv.innerHTML;StartSearch();}else if(VY.type=="mouseover"){oSrcDiv.className="over";}else if(VY.type=="mouseout"){oSrcDiv.className="";}else{complete.U.focus();}};VU.prototype.onTextChange=function(abTextComplete){var YU=this.U.value;var oThis=this;this.UV=-1;bTextComplete=abTextComplete;if(YU.length>0){this.unassignEvents();MakeDiv();}else{this.W.innerHTML="";this.W.style.visibility="hidden";}};var complete;function createAutoComplete(){var UW=[];complete=new VU(UW,document.getElementById('word'),document.getElementById('suggest'),10);complete.assignEvents();};var WW=getXMLHttpRequest();var url="dict-suggest-api.php?word=";var complete_closed=false;function MakeDiv(){if(WW.readyState==4||WW.readyState==0){WW.open("GET",url+encodeURIComponent(document.getElementById("word").value,true));WW.onreadystatechange=setDataArray;WW.send(null);}else{}}function atranslate(text){document.getElementById('word').value=text;MakeDiv();}function setDataArray(){if(WW.readyState==4){var UW=new Array();if(WW.responseText){UW=eval("("+WW.responseText+")");}complete.db.assignArray(UW);complete.drawDiv();complete.assignEvents();}}var UU=getXMLHttpRequest();var dataArray=new Array();function getXMLHttpRequest(){if(window.XMLHttpRequest){try{_xhrs=new XMLHttpRequest()}catch(e){}}else if(window.ActiveXObject){try{_xhrs=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}if(!_xhrs)try{_xhrs=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}}return _xhrs;}function StartSearch(){if(UU.readyState==4||UU.readyState==0){UU.open("GET","dict-search-api.php?word="+encodeURIComponent(document.getElementById("word").value),true);UU.onreadystatechange=setDataArrayRes;UU.send(null);}else{}}function atranslate(text){document.getElementById('word').value=text;StartSearch();}function byId(name){return document.getElementById(name);}function setDataArrayRes(){var tag1="word";var tag2="suggest";var tag2="trans";if(UU.readyState==4){if(UU.responseText){var UY=eval("("+UU.responseText+")");byId("TransBlock").innerHTML='';VW="<h2>"+UY.word+"</h2> ";if(UY.subjlist.length<=0){VW+=' перевод не найден.'}else{VW+="<ul>";for(is=0;is<UY.subjlist.length;is++){subj=UY.subjlist[is];subjname=UY.subjects[subj].name;VW+='<li><span class="subject" title="'+subjname+'"><b>'+subj+'</b></span><ul><li>';VVU=0;for(VV=0;VV<UY.subjects[subj].rows.length;VV++){r=UY.subjects[subj].rows[VV];YY='';if(r.ref){YY='<span class="ref">'+r.ref+'</span>';}YY+='<span  style="cursor: pointer;" onclick="atranslate(\''+r.tr+'\')">'+r.tr+'</span>';if(r.comm){YY+=' <span class="comment">('+r.comm.replace(/@/,'')+')</span>';}if((VVU==0)||(VVU==Math.floor(r.we/100))){VW+=YY+', ';}else{if(VW.substr(-2,2)==', ')VW=VW.substr(0,VW.length-2);VW+='</li><li> '+YY+', ';}VVU=Math.floor(r.we/100);}if(VW.substr(-2,2)==', ')VW=VW.substr(0,VW.length-2);VW+='</li></ul>';}VW+="</ul>";}byId("TransBlock").innerHTML=VW;byId("time").innerHTML=' найдено переводов:'+UY.transcount+', время поиска: '+UY.time+' секунд.';}else if(UU.responseXML){alert(UU.responseXML);}}}
