var sg={limit:10,address:null,dict:null,dictw:null,qwr:'utf-8',resp:'utf-8',Data:null,zeroData:new Array(),sgBox:null,jsBox:null,lineBox:new Array(),act:null,mTimer:null,dtTimer:null,sTimer:null,inpObj:null,repNum:null,useBold:false,on:true,mkSgBox:function(id){this.sgBox=sgDom.cE('div');this.sgBox.id=('sg-list');var subBox=sgDom.cE('div');this.jsBox=sgDom.cE('div');this.jsBox.id='sg-loader';this.sgBox.style.display='none';sgDom.aC(sgDom.gI(id).form,this.jsBox);subBox.className='cont';for(i=0;i<=this.limit;i++){var ln=sgDom.cE('p');ln.style.display='none';var rl=sgDom.cE('span');var tx1=sgDom.cT('-');var tx2=sgDom.cT('-');this.lineBox[i]=ln;sgDom.aC(ln,tx1);sgDom.aC(rl,tx2);sgDom.aC(ln,rl);sgDom.aC(subBox,ln);ln.onmouseover=sg._inpMouseover;ln.onmouseout=sg._inpMouseout;ln.onclick=sg._inpClick}var last=sgDom.cE('p');var lOff=sgDom.cE('a');last.id='sg-off';var lOffTxt=sgDom.cT('Vypnout našeptávač');lOff.href="http://www.seznam.cz/nastaveni-ostatni/";lOff.title="Přechod na stránku osobní nastavení, kde si můžete vypnout našeptávač";sgDom.aC(lOff,lOffTxt);sgDom.aC(last,lOff);sgDom.aC(subBox,last);sgDom.aC(this.sgBox,subBox);sgDom.aC(sgDom.gI(id).form,this.sgBox)},stopSg:function(){sg.on=false},startSg:function(){sg.on=true},getStatus:function(){return sg.on},init:function(id,dict,limit,server,dictw){sg.startSg();sg.actId=id;sg.limit=limit?limit:sg.limit;sg.address=server?server:sg.address;if(typeof(dict)=="object"&&(dict.length>1)){sg.dict=dict[0];sg.dictw=dict[1];sg.useBold=true}else{sg.dict=sg.dictw=dict}if(!sg.sgBox){sg.mkSgBox(id)}else{sg._sgBoxReplace(id)}sg.inpObj=sgDom.gI(id);sg.inpObj.onkeyup=sg._keyup;if(document.all)sg.inpObj.onkeydown=sg._keyCatch;else sg.inpObj.onkeypress=sg._keyCatch;sg.inpObj.onclick=sg._unselectItem;sg.inpObj.onblur=function(){sg.sTimer=setTimeout("sg.clearAC()",500)}},showList:function(vstup){clearTimeout(sg.sTimer);sg.sTimer=null;sg.Data=vstup;sg.repNum=vstup.length>=sg.limit?sg.limit:vstup.length;var view=false;for(i=0;i<sg.limit;i++){if(sg.Data[i]){var wrd=sg.Data[i][0];var rel=sg.Data[i][1];if(sg.useBold){sg.lineBox[i].innerHTML=sg.highlight(wrd,sg.inpObj.value)+'<span>'+rel+'</span>'}else{sg.lineBox[i].innerHTML=wrd+'<span>'+rel+'</span>'}sg.lineBox[i].plainText=wrd;sg.lineBox[i].position=i;sg.lineBox[i].style.display='block';view=true}else{sg.lineBox[i].innerHTML='-';sg.lineBox[i].plainText='-';sg.lineBox[i].position=i;sg.lineBox[i].style.display='none'}}if(view){sg._unselectItem();sg.sgBox.style.display='block'}else{sg.sgBox.style.display='none'}},highlight:function(where,what){var words=what.split(' ');var reg=null;for(var i=0;i<words.length;i++){where=where.replace(new RegExp("([^<]|^)("+words[i]+")([^>]|$)","i"),'$1<b>$2</b>$3')}return where},action:function(){sg.inpObj.form.submit();return false},_sgBoxReplace:function(ids){oldParent=sg.sgBox.parentNode;newParent=sgDom.gI(ids).form;sg.sgBox.style.display='none';sgDom.aC(newParent,sg.sgBox)},_getData:function(){if(sg.inpObj.value&&sg.getStatus()){sg.jsBox.innerHTML='';sg.Data=null;var source=sg.address+'?dict='+((sg.inpObj.value.length>1)?sg.dictw:sg.dict)+'&phrase='+sg.inpObj.value+'&encoding='+sg.qwr+'&response_encoding='+sg.resp;var loader=sgDom.cE('script');loader.type='text/javascript';loader.src=source;sgDom.aC(sg.jsBox,loader)}else{sg.showList(sg.zeroData)}},_inpMouseover:function(){clearTimeout(sg.mTimer);sg._mouseover(this)},_inpMouseout:function(){sg.mTimer=setTimeout("sg._mouseout(this)",100)},_inpClick:function(){return sg._mouseclick(this)},_mouseout:function(){sg._unselectItem()},_mouseover:function(obj){if(sg.act!=null){sg.act.className=''}sg.act=obj;sg.act.className='act'},_mouseclick:function(obj){sg.inpObj.value=obj.plainText;sg._putHiddenSug();setTimeout("sg.inpObj.focus()",10);sg.action()},_unselectItem:function(){if(sg.act){sg.act.className='';sg.act=null}},_selectItem:function(keyId){if(sg.Data&&(sg.Data.length>0)){if(sg.act){if(keyId==40){sg.act.className='';newAct=sg.act==sg.sgBox.getElementsByTagName('p')[sg.repNum-1]?sg.act:sg.act.nextSibling;newAct.className='act';sg.act=newAct}else{sg.act.className='';newAct=sg.sgBox.firstChild.firstChild==sg.act?sg.act:sg.act.previousSibling;newAct.className='act';sg.act=newAct}}else{sg.sgBox.firstChild.firstChild.className='act';sg.act=sg.sgBox.firstChild.firstChild}}},_putHiddenSug:function(){inp=document.getElementById('sug-'+sg.actId);if(!inp){var inp=document.createElement('input');inp.type='hidden';inp.name='sug';inp.id='sug-'+sg.actId;sg.inpObj.parentNode.appendChild(inp)}inp.value=(sg.act.position+1)},_putSelected:function(key){if(sg.act){sg.inpObj.value=sg.act.plainText;sg._putHiddenSug();if(key!=13){sg._getData()}return true}else return true},_getKey:function(e){if(!e)e=window.event;return e.keyCode},_keyCatch:function(e){keyId=sg._getKey(e);if((keyId==13)||(keyId==39)){return sg._putSelected(keyId)}if((keyId==38)||(keyId==40)){sg._selectItem(keyId);return false}if(keyId==27){sg.clearAC()}},_keyup:function(e){keyId=sg._getKey(e);if((keyId==8)||(keyId==46)){clearTimeout(sg.dtTimer);sg.dtTimer=null;sg._unselectItem();sg.dtTimer=setTimeout('sg._getData()',100)}else if(((keyId<33)||(keyId>39))&&(keyId!=13)&&(keyId!=27)&&(keyId!=40)&&(keyId!=44)&&(keyId!=45)&&(keyId!=17)&&(keyId!=18)){clearTimeout(sg.dtTimer);sg.dtTimer=null;sg.dtTimer=setTimeout('sg._getData()',250)}},clearAC:function(){sg._unselectItem();sg.sgBox.style.display='none';sg.showList(sg.zeroData)}};sgDom={gI:function(el){return document.getElementById(el)},cT:function(txt){return document.createTextNode(txt)},cE:function(el){return document.createElement(el)},aC:function(p,c){return p.appendChild(c)}};
