var useBSNns=true;
if(useBSNns){
if(typeof (bsn)=="undefined"){
bsn={};
}
_bsn=bsn;
}else{
_bsn=this;
}
if(typeof (_bsn.Autosuggest)=="undefined"){
_bsn.Autosuggest={};
}
_bsn.AutoSuggest=function(id,_2){
if(!document.getElementById){
return false;
}
this.fld=_bsn.DOM.gE(id);
if(!this.fld){
return false;
}
this.sInput="";
this.nInputChars=0;
this.aSuggestions=[];
this.iHighlighted=0;
this.oP=(_2)?_2:{};
var _3={minchars:1,meth:"get",varname:"input",className:"autosuggest",timeout:2500,delay:500,offsety:-5,shownoresults:true,noresults:"No results!",maxheight:250,cache:true};
for(k in _3){
if(typeof (this.oP[k])!=typeof (_3[k])){
this.oP[k]=_3[k];
}
}
var p=this;
this.fld.onkeypress=function(ev){
return p.onKeyPress(ev);
};
this.fld.onkeyup=function(ev){
return p.onKeyUp(ev);
};
this.fld.setAttribute("autocomplete","off");
};
_bsn.AutoSuggest.prototype.onKeyPress=function(ev){
var _8=(window.event)?window.event.keyCode:ev.keyCode;
var _9=13;
var _a=9;
var _b=27;
var _c=true;
switch(_8){
case _9:
this.setHighlightedValue();
_c=false;
break;
case _b:
this.clearSuggestions();
break;
}
return _c;
};
_bsn.AutoSuggest.prototype.onKeyUp=function(ev){
var _e=(window.event)?window.event.keyCode:ev.keyCode;
var _f=38;
var _10=40;
var _11=true;
switch(_e){
case _f:
this.changeHighlight(_e);
_11=false;
break;
case _10:
this.changeHighlight(_e);
_11=false;
break;
default:
this.getSuggestions(this.fld.value);
}
return _11;
};
_bsn.AutoSuggest.prototype.getSuggestions=function(val){
if(val==this.sInput){
return false;
}
if(val.length<this.oP.minchars){
this.sInput="";
return false;
}
if(val.length>this.nInputChars&&this.aSuggestions.length&&this.oP.cache){
var arr=[];
for(var i=0;i<this.aSuggestions.length;i++){
if(this.aSuggestions[i].value.substr(0,val.length).toLowerCase()==val.toLowerCase()){
arr.push(this.aSuggestions[i]);
}
}
this.sInput=val;
this.nInputChars=val.length;
this.aSuggestions=arr;
this.createList(this.aSuggestions);
return false;
}else{
this.sInput=val;
this.nInputChars=val.length;
var _15=this;
clearTimeout(this.ajID);
this.ajID=setTimeout(function(){
_15.doAjaxRequest();
},this.oP.delay);
}
return false;
};
_bsn.AutoSuggest.prototype.doAjaxRequest=function(){
var _16=this;
if(typeof (this.oP.script)=="function"){
var url=this.oP.script(escape(this.fld.value));
}else{
var url=this.oP.script+this.oP.varname+"="+escape(this.fld.value);
}
if(!url){
return false;
}
var _18=this.oP.meth;
var _19=function(req){
_16.setSuggestions(req);
};
var _1b=function(_1c){
alert("AJAX error: "+_1c);
};
var _1d=new _bsn.Ajax();
_1d.makeRequest(url,_18,_19,_1b);
};
_bsn.AutoSuggest.prototype.setSuggestions=function(req){
this.aSuggestions=[];
if(this.oP.json){
var _1f=eval("("+req.responseText+")");
for(var i=0;i<_1f.results.length;i++){
this.aSuggestions.push({"id":_1f.results[i].id,"value":_1f.results[i].value,"info":_1f.results[i].info});
}
}else{
var xml=req.responseXML;
var _22=xml.getElementsByTagName("results")[0].childNodes;
for(var i=0;i<_22.length;i++){
if(_22[i].hasChildNodes()){
this.aSuggestions.push({"id":_22[i].getAttribute("id"),"value":_22[i].childNodes[0].nodeValue,"info":_22[i].getAttribute("info")});
}
}
}
this.idAs="as_"+this.fld.id;
this.createList(this.aSuggestions);
};
_bsn.AutoSuggest.prototype.createList=function(arr){
var _24=this;
_bsn.DOM.remE(this.idAs);
this.killTimeout();
if(arr.length==0&&!this.oP.shownoresults){
return false;
}
var div=_bsn.DOM.cE("div",{id:this.idAs,className:this.oP.className});
var _26=_bsn.DOM.cE("div",{className:"as_corner"});
var _27=_bsn.DOM.cE("div",{className:"as_bar"});
var _28=_bsn.DOM.cE("div",{className:"as_header"});
_28.appendChild(_26);
_28.appendChild(_27);
div.appendChild(_28);
var ul=_bsn.DOM.cE("ul",{id:"as_ul"});
for(var i=0;i<arr.length;i++){
var val=arr[i].value;
var st=val.toLowerCase().indexOf(this.sInput.toLowerCase());
var _2d=val.substring(0,st)+"<em>"+val.substring(st,st+this.sInput.length)+"</em>"+val.substring(st+this.sInput.length);
var _2e=_bsn.DOM.cE("span",{},_2d,true);
if(arr[i].info!=""){
var br=_bsn.DOM.cE("br",{});
_2e.appendChild(br);
var _30=_bsn.DOM.cE("small",{},arr[i].info);
_2e.appendChild(_30);
}
var a=_bsn.DOM.cE("a",{href:"#"});
var tl=_bsn.DOM.cE("span",{className:"tl"}," ");
var tr=_bsn.DOM.cE("span",{className:"tr"}," ");
a.appendChild(tl);
a.appendChild(tr);
a.appendChild(_2e);
a.name=i+1;
a.onclick=function(){
_24.setHighlightedValue();
return false;
};
a.onmouseover=function(){
_24.setHighlight(this.name);
};
var li=_bsn.DOM.cE("li",{},a);
ul.appendChild(li);
}
if(arr.length==0&&this.oP.shownoresults){
var li=_bsn.DOM.cE("li",{className:"as_warning"},this.oP.noresults);
ul.appendChild(li);
}
div.appendChild(ul);
var _35=_bsn.DOM.cE("div",{className:"as_corner"});
var _36=_bsn.DOM.cE("div",{className:"as_bar"});
var _37=_bsn.DOM.cE("div",{className:"as_footer"});
_37.appendChild(_35);
_37.appendChild(_36);
div.appendChild(_37);
var pos=_bsn.DOM.getPos(this.fld);
div.style.left=pos.x+"px";
div.style.top=(pos.y+this.fld.offsetHeight+this.oP.offsety)+"px";
div.style.width=this.fld.offsetWidth+"px";
div.onmouseover=function(){
_24.killTimeout();
};
div.onmouseout=function(){
_24.resetTimeout();
};
document.getElementsByTagName("body")[0].appendChild(div);
this.iHighlighted=0;
var _24=this;
this.toID=setTimeout(function(){
_24.clearSuggestions();
},this.oP.timeout);
};
_bsn.AutoSuggest.prototype.changeHighlight=function(key){
var _3a=_bsn.DOM.gE("as_ul");
if(!_3a){
return false;
}
var n;
if(key==40){
n=this.iHighlighted+1;
}else{
if(key==38){
n=this.iHighlighted-1;
}
}
if(n>_3a.childNodes.length){
n=_3a.childNodes.length;
}
if(n<1){
n=1;
}
this.setHighlight(n);
};
_bsn.AutoSuggest.prototype.setHighlight=function(n){
var _3d=_bsn.DOM.gE("as_ul");
if(!_3d){
return false;
}
if(this.iHighlighted>0){
this.clearHighlight();
}
this.iHighlighted=Number(n);
_3d.childNodes[this.iHighlighted-1].className="as_highlight";
this.killTimeout();
};
_bsn.AutoSuggest.prototype.clearHighlight=function(){
var _3e=_bsn.DOM.gE("as_ul");
if(!_3e){
return false;
}
if(this.iHighlighted>0){
_3e.childNodes[this.iHighlighted-1].className="";
this.iHighlighted=0;
}
};
_bsn.AutoSuggest.prototype.setHighlightedValue=function(){
if(this.iHighlighted){
this.sInput=this.fld.value=this.aSuggestions[this.iHighlighted-1].value;
this.fld.focus();
if(this.fld.selectionStart){
this.fld.setSelectionRange(this.sInput.length,this.sInput.length);
}
this.clearSuggestions();
if(typeof (this.oP.callback)=="function"){
this.oP.callback(this.aSuggestions[this.iHighlighted-1]);
}
}
};
_bsn.AutoSuggest.prototype.killTimeout=function(){
clearTimeout(this.toID);
};
_bsn.AutoSuggest.prototype.resetTimeout=function(){
clearTimeout(this.toID);
var _3f=this;
this.toID=setTimeout(function(){
_3f.clearSuggestions();
},1000);
};
_bsn.AutoSuggest.prototype.clearSuggestions=function(){
this.killTimeout();
var ele=_bsn.DOM.gE(this.idAs);
var _41=this;
if(ele){
var _42=new _bsn.Fader(ele,1,0,250,function(){
_bsn.DOM.remE(_41.idAs);
});
}
};
if(typeof (_bsn.Ajax)=="undefined"){
_bsn.Ajax={};
}
_bsn.Ajax=function(){
this.req={};
this.isIE=false;
};
_bsn.Ajax.prototype.makeRequest=function(url,_44,_45,_46){
if(_44!="POST"){
_44="GET";
}
this.onComplete=_45;
this.onError=_46;
var _47=this;
if(window.XMLHttpRequest){
this.req=new XMLHttpRequest();
this.req.onreadystatechange=function(){
_47.processReqChange();
};
this.req.open("GET",url,true);
this.req.send(null);
}else{
if(window.ActiveXObject){
this.req=new ActiveXObject("Microsoft.XMLHTTP");
if(this.req){
this.req.onreadystatechange=function(){
_47.processReqChange();
};
this.req.open(_44,url,true);
this.req.send();
}
}
}
};
_bsn.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 (_bsn.DOM)=="undefined"){
_bsn.DOM={};
}
_bsn.DOM.cE=function(_48,_49,_4a,_4b){
var ne=document.createElement(_48);
if(!ne){
return false;
}
for(var a in _49){
ne[a]=_49[a];
}
if(typeof (_4a)=="string"&&!_4b){
ne.appendChild(document.createTextNode(_4a));
}else{
if(typeof (_4a)=="string"&&_4b){
ne.innerHTML=_4a;
}else{
if(typeof (_4a)=="object"){
ne.appendChild(_4a);
}
}
}
return ne;
};
_bsn.DOM.gE=function(e){
if(typeof (e)=="undefined"){
return false;
}else{
if(typeof (e)=="string"){
var re=document.getElementById(e);
if(!re){
return false;
}else{
if(typeof (re.appendChild)!="undefined"){
return re;
}else{
return false;
}
}
}else{
if(typeof (e.appendChild)!="undefined"){
return e;
}else{
return false;
}
}
}
};
_bsn.DOM.remE=function(ele){
var e=this.gE(ele);
if(!e){
return false;
}else{
if(e.parentNode.removeChild(e)){
return true;
}else{
return false;
}
}
};
_bsn.DOM.getPos=function(e){
var e=this.gE(e);
var obj=e;
var _54=0;
if(obj.offsetParent){
while(obj.offsetParent){
_54+=obj.offsetLeft;
obj=obj.offsetParent;
}
}else{
if(obj.x){
_54+=obj.x;
}
}
var obj=e;
var _55=0;
if(obj.offsetParent){
while(obj.offsetParent){
_55+=obj.offsetTop;
obj=obj.offsetParent;
}
}else{
if(obj.y){
_55+=obj.y;
}
}
return {x:_54,y:_55};
};
if(typeof (_bsn.Fader)=="undefined"){
_bsn.Fader={};
}
_bsn.Fader=function(ele,_57,to,_59,_5a){
if(!ele){
return false;
}
this.ele=ele;
this.from=_57;
this.to=to;
this.callback=_5a;
this.nDur=_59;
this.nInt=50;
this.nTime=0;
var p=this;
this.nID=setInterval(function(){
p._fade();
},this.nInt);
};
_bsn.Fader.prototype._fade=function(){
this.nTime+=this.nInt;
var _5c=Math.round(this._tween(this.nTime,this.from,this.to,this.nDur)*100);
var op=_5c/100;
if(this.ele.filters){
try{
this.ele.filters.item("DXImageTransform.Microsoft.Alpha").opacity=_5c;
}
catch(e){
this.ele.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+_5c+")";
}
}else{
this.ele.style.opacity=op;
}
if(this.nTime==this.nDur){
clearInterval(this.nID);
if(this.callback!=undefined){
this.callback();
}
}
};
_bsn.Fader.prototype._tween=function(t,b,c,d){
return b+((c-b)*(t/d));
};


