if(typeof(bsn)=="undefined"){_b=bsn={}}if(typeof(_b.AutoSuggest)=="undefined"){_b.AutoSuggest={}}_b.AutoSuggest=function(h,i){if(!document.getElementById){return 0}this.fld=_b.DOM.gE(h);if(!this.fld){return 0}this.sInp="";this.nInpC=0;this.aSug=[];this.iHigh=0;this.oP=i?i:{};var g,f={minchars:1,meth:"get",varname:"input",className:"autosuggest",timeout:2500,delay:500,offsety:-5,shownoresults:true,noresults:"No results!",maxheight:250,cache:true,maxentries:25};for(g in f){if(typeof(this.oP[g])!=typeof(f[g])){this.oP[g]=f[g]}}var j=this;this.fld.onkeypress=function(a){return j.onKeyPress(a)};this.fld.onkeyup=function(a){return j.onKeyUp(a)};this.fld.setAttribute("autocomplete","off")};_b.AutoSuggest.prototype.onKeyPress=function(j){var k=(window.event)?window.event.keyCode:j.keyCode;var l=13;var g=9;var i=27;var h=1;switch(k){case l:this.setHighlightedValue();h=0;break;case i:this.clearSuggestions();break}return h};_b.AutoSuggest.prototype.onKeyUp=function(h){var j=(window.event)?window.event.keyCode:h.keyCode;var f=38;var i=40;var g=1;switch(j){case f:this.changeHighlight(j);g=0;break;case i:this.changeHighlight(j);g=0;break;default:this.getSuggestions(this.fld.value)}return g};_b.AutoSuggest.prototype.getSuggestions=function(j){if(j==this.sInp){return 0}_b.DOM.remE(this.idAs);this.sInp=j;if(j.length<this.oP.minchars){this.aSug=[];this.nInpC=j.length;return 0}var m=this.nInpC;this.nInpC=j.length?j.length:0;var h=this.aSug.length;if(this.nInpC>m&&h&&h<this.oP.maxentries&&this.oP.cache){var i=[];for(var l=0;l<h;l++){if(this.aSug[l].value.substr(0,j.length).toLowerCase()==j.toLowerCase()){i.push(this.aSug[l])}}this.aSug=i;this.createList(this.aSug);return false}else{var k=this;var n=this.sInp;clearTimeout(this.ajID);this.ajID=setTimeout(function(){k.doAjaxRequest(n)},this.oP.delay)}return false};_b.AutoSuggest.prototype.doAjaxRequest=function(n){if(n!=this.fld.value){return false}var j=this;if(typeof(this.oP.script)=="function"){var m=this.oP.script(encodeURIComponent(this.sInp))}else{var m=this.oP.script+this.oP.varname+"="+encodeURIComponent(this.sInp)}if(!m){return false}var h=this.oP.meth;var n=this.sInp;var i=function(a){j.setSuggestions(a,n)};var l=(j.onerror?j.onerror:function(a){});var k=new _b.Ajax();k.makeRequest(m,h,i,l)};_b.AutoSuggest.prototype.setSuggestions=function(req,input){if(input!=this.fld.value){return false}this.aSug=[];if(this.oP.json){var jsondata=eval("("+req.responseText+")");for(var i=0;i<jsondata.results.length;i++){this.aSug.push({id:jsondata.results[i].id,value:jsondata.results[i].value,info:jsondata.results[i].info})}}else{var xml=req.responseXML;var results=xml.getElementsByTagName("results")[0].childNodes;for(var i=0;i<results.length;i++){if(results[i].hasChildNodes()){this.aSug.push({id:results[i].getAttribute("id"),value:results[i].childNodes[0].nodeValue,info:results[i].getAttribute("info")})}}}this.idAs="as_"+this.fld.id;this.createList(this.aSug)};_b.AutoSuggest.prototype.createList=function(N){var B=this;_b.DOM.remE(this.idAs);this.killTimeout();if(N.length==0&&!this.oP.shownoresults){return false}var E=_b.DOM.cE("div",{id:this.idAs,className:this.oP.className});var L=_b.DOM.cE("div",{className:"as_corner"});var I=_b.DOM.cE("div",{className:"as_bar"});var z=_b.DOM.cE("div",{className:"as_header"});z.appendChild(L);z.appendChild(I);E.appendChild(z);var F=_b.DOM.cE("ul",{id:"as_ul"});for(var y=0;y<N.length;y++){var a=N[y].value;var C=a.toLowerCase().indexOf(this.sInp.toLowerCase());var H='<img src="'+N[y].info+'" border="0" align="middle" />&nbsp;'+a.substring(0,C)+"<em>"+a.substring(C,C+this.sInp.length)+"</em>"+a.substring(C+this.sInp.length);var A=_b.DOM.cE("span",{},H,true);if(N[y].info!=""){}var w=_b.DOM.cE("a",{href:"#"});var K=_b.DOM.cE("span",{className:"tl"}," ");var M=_b.DOM.cE("span",{className:"tr"}," ");w.appendChild(K);w.appendChild(M);w.appendChild(A);w.name=y+1;w.onclick=function(){B.setHighlightedValue();return false};w.onmouseover=function(){B.setHighlight(this.name)};var G=_b.DOM.cE("li",{},w);F.appendChild(G)}if(N.length==0&&this.oP.shownoresults){var G=_b.DOM.cE("li",{className:"as_warning"},this.oP.noresults);F.appendChild(G)}E.appendChild(F);var x=_b.DOM.cE("div",{className:"as_corner"});var i=_b.DOM.cE("div",{className:"as_bar"});var D=_b.DOM.cE("div",{className:"as_footer"});D.appendChild(x);D.appendChild(i);E.appendChild(D);var J=_b.DOM.getPos(this.fld);E.style.left=J.x+"px";E.style.top=(J.y+this.fld.offsetHeight+this.oP.offsety)+"px";E.style.width=this.fld.offsetWidth+"px";E.onmouseover=function(){B.killTimeout()};E.onmouseout=function(){B.resetTimeout()};document.getElementsByTagName("body")[0].appendChild(E);this.iHigh=0;var B=this;this.toID=setTimeout(function(){B.clearSuggestions()},this.oP.timeout)};_b.AutoSuggest.prototype.changeHighlight=function(e){var d=_b.DOM.gE("as_ul");if(!d){return false}var f;if(e==40){f=this.iHigh+1}else{if(e==38){f=this.iHigh-1}}if(f>d.childNodes.length){f=d.childNodes.length}if(f<1){f=1}this.setHighlight(f)};_b.AutoSuggest.prototype.setHighlight=function(c){var d=_b.DOM.gE("as_ul");if(!d){return false}if(this.iHigh>0){this.clearHighlight()}this.iHigh=Number(c);d.childNodes[this.iHigh-1].className="as_highlight";this.killTimeout()};_b.AutoSuggest.prototype.clearHighlight=function(){var b=_b.DOM.gE("as_ul");if(!b){return false}if(this.iHigh>0){b.childNodes[this.iHigh-1].className="";this.iHigh=0}};_b.AutoSuggest.prototype.setHighlightedValue=function(){if(this.iHigh){this.sInp=this.fld.value=this.aSug[this.iHigh-1].value;this.fld.focus();if(this.fld.selectionStart){this.fld.setSelectionRange(this.sInp.length,this.sInp.length)}this.clearSuggestions();if(typeof(this.oP.callback)=="function"){this.oP.callback(this.aSug[this.iHigh-1])}}};_b.AutoSuggest.prototype.killTimeout=function(){clearTimeout(this.toID)};_b.AutoSuggest.prototype.resetTimeout=function(){clearTimeout(this.toID);var b=this;this.toID=setTimeout(function(){b.clearSuggestions()},1000)};_b.AutoSuggest.prototype.clearSuggestions=function(){this.killTimeout();var e=_b.DOM.gE(this.idAs);var f=this;if(e){var d=new _b.Fader(e,1,0,250,function(){_b.DOM.remE(f.idAs)})}};if(typeof(_b.Ajax)=="undefined"){_b.Ajax={}}_b.Ajax=function(){this.req={};this.isIE=false};_b.Ajax.prototype.makeRequest=function(j,f,g,i){if(f!="POST"){f="GET"}this.onComplete=g;this.onError=i;var h=this;if(window.XMLHttpRequest){this.req=new XMLHttpRequest();this.req.onreadystatechange=function(){h.processReqChange()};this.req.open("GET",j,true);this.req.send(null)}else{if(window.ActiveXObject){this.req=new ActiveXObject("Microsoft.XMLHTTP");if(this.req){this.req.onreadystatechange=function(){h.processReqChange()};this.req.open(f,j,true);this.req.send()}}}};_b.Ajax.prototype.processReqChange=function(){if(this.req.readyState==4){if(this.req.status==200){this.onComplete(this.req)}else{this.onError(this.req.status)}}};if(typeof(_b.DOM)=="undefined"){_b.DOM={}}_b.DOM.cE=function(j,n,a,k){var i=document.createElement(j);if(!i){return 0}for(var m in n){i[m]=n[m]}var l=typeof(a);if(l=="string"&&!k){i.appendChild(document.createTextNode(a))}else{if(l=="string"&&k){i.innerHTML=a}else{if(l=="object"){i.appendChild(a)}}}return i};_b.DOM.gE=function(f){var e=typeof(f);if(e=="undefined"){return 0}else{if(e=="string"){var d=document.getElementById(f);if(!d){return 0}else{if(typeof(d.appendChild)!="undefined"){return d}else{return 0}}}else{if(typeof(f.appendChild)!="undefined"){return f}else{return 0}}}};_b.DOM.remE=function(d){var c=this.gE(d);if(!c){return 0}else{if(c.parentNode.removeChild(c)){return true}else{return 0}}};_b.DOM.getPos=function(h){var h=this.gE(h);var e=h;var g=0;if(e.offsetParent){while(e.offsetParent){g+=e.offsetLeft;e=e.offsetParent}}else{if(e.x){g+=e.x}}var e=h;var f=0;if(e.offsetParent){while(e.offsetParent){f+=e.offsetTop;e=e.offsetParent}}else{if(e.y){f+=e.y}}return{x:g,y:f}};if(typeof(_b.Fader)=="undefined"){_b.Fader={}}_b.Fader=function(g,i,j,h,k){if(!g){return 0}this.e=g;this.from=i;this.to=j;this.cb=k;this.nDur=h;this.nInt=50;this.nTime=0;var l=this;this.nID=setInterval(function(){l._fade()},this.nInt)};_b.Fader.prototype._fade=function(){this.nTime+=this.nInt;var e=Math.round(this._tween(this.nTime,this.from,this.to,this.nDur)*100);var f=e/100;if(this.e.filters){try{this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity=e}catch(d){this.e.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+e+")"}}else{this.e.style.opacity=f}if(this.nTime==this.nDur){clearInterval(this.nID);if(this.cb!=undefined){this.cb()}}};_b.Fader.prototype._tween=function(h,b,c,d){return b+((c-b)*(h/d))};