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