var useBSNns;
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.onfocus=function(ev){return p.onFocus(ev);};
		this.fld.setAttribute("autocomplete","off");};
		_bsn.AutoSuggest.prototype.onFocus=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.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 _19=this.oP.meth;
			var _1a=function(req){_16.setSuggestions(req);};
			var _1c=function(_1d){alert("AJAX error: "+_1d);};
			var _1e=new _bsn.Ajax();
			_1e.makeRequest(url,_19,_1a,_1c);
		};
		_bsn.AutoSuggest.prototype.setSuggestions=function(req){
			this.aSuggestions=[];
			if(this.oP.json){
				var _20=eval("("+req.responseText+")");
				for(var i=0;i<_20.results.length;i++){
					this.aSuggestions.push({"id":_20.results[i].id,"value":_20.results[i].value,"info":_20.results[i].info,"tipo":_20.results[i].tipo,"idserie":_20.results[i].idserie});
				}
			}else{
				var xml=req.responseXML;
				var _23=xml.getElementsByTagName("results")[0].childNodes;
				for(var i=0;i<_23.length;i++){
					if(_23[i].hasChildNodes()){this.aSuggestions.push({"id":_23[i].getAttribute("id"),"value":_23[i].childNodes[0].nodeValue,"info":_23[i].getAttribute("info"),"tipo":_23[i].getAttribute("tipo"),"idserie":_23[i].getAttribute("idserie")});
				}
			}
		}
			this.idAs="as_"+this.fld.id;
			this.createList(this.aSuggestions);
		};
		_bsn.AutoSuggest.prototype.createList=function(arr){
			var _26=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 _28=_bsn.DOM.cE("div",{className:"as_corner"});
			var _29=_bsn.DOM.cE("div",{className:"as_bar"});
			var _2a=_bsn.DOM.cE("div",{className:"as_header"});
			_2a.appendChild(_28);
			_2a.appendChild(_29);
			div.appendChild(_2a);
			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 _2f=val.substring(0,st)+"<em>"+val.substring(st,st+this.sInput.length)+"</em>"+val.substring(st+this.sInput.length);
				var _30=_bsn.DOM.cE("span",{},_2f,true);
				if(arr[i].info!=""){
					var br=_bsn.DOM.cE("br",{});
					_30.appendChild(br);
					var _32=_bsn.DOM.cE("small",{},arr[i].info);
					_30.appendChild(_32);
				}
				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(_30);
				a.name=i+1;
				a.onclick=function(){
					_26.setHighlightedValue();
					return false;
				};
				a.onmouseover=function(){_26.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 _38=_bsn.DOM.cE("div",{className:"as_corner"});
			var _39=_bsn.DOM.cE("div",{className:"as_bar"});
			var _3a=_bsn.DOM.cE("div",{className:"as_footer"});
			_3a.appendChild(_38);
			_3a.appendChild(_39);
			div.appendChild(_3a);
			var pos=_bsn.DOM.getPos(this.fld);
			div.style.left=pos.x-150+"px";			
			div.style.top=(pos.y+this.fld.offsetHeight+this.oP.offsety)+"px";
			div.style.width=this.fld.offsetWidth*4+"px";
			div.onmouseover=function(){_26.killTimeout();};
			div.onmouseout=function(){_26.resetTimeout();};
			document.getElementsByTagName("body")[0].appendChild(div);
			this.iHighlighted=0;
			var _3c=this;this.toID=setTimeout(function(){_3c.clearSuggestions();},this.oP.timeout);
		};
			
		_bsn.AutoSuggest.prototype.changeHighlight=function(key){
			var _3e=_bsn.DOM.gE("as_ul");
			if(!_3e){return false;}
			var n;
			if(key==40){n=this.iHighlighted+1;}	else{if(key==38){n=this.iHighlighted-1;}}
			if(n>_3e.childNodes.length){n=_3e.childNodes.length;}
			if(n<1){n=1;}
			this.setHighlight(n);
		};
		
		_bsn.AutoSuggest.prototype.setHighlight=function(n){
			var _41=_bsn.DOM.gE("as_ul");
			if(!_41){return false;}
			if(this.iHighlighted>0){this.clearHighlight();}
			this.iHighlighted=Number(n);
			_41.childNodes[this.iHighlighted-1].className="as_highlight";
			this.killTimeout();
		};
		_bsn.AutoSuggest.prototype.clearHighlight=function(){
			var _42=_bsn.DOM.gE("as_ul");
			if(!_42){return false;}
			if(this.iHighlighted>0){_42.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 _43=this;
			this.toID=setTimeout(function(){_43.clearSuggestions();},1000);
		};
		_bsn.AutoSuggest.prototype.clearSuggestions=function(){
			this.killTimeout();
			var ele=_bsn.DOM.gE(this.idAs);
			var _45=this;
			if(ele){var _46=new _bsn.Fader(ele,1,0,250,function(){_bsn.DOM.remE(_45.idAs);});}
		};
		if(typeof (_bsn.Ajax)=="undefined"){_bsn.Ajax={};}
		_bsn.Ajax=function(){this.req={};
		this.isIE=false;};
		_bsn.Ajax.prototype.makeRequest=function(url,_48,_49,_4a){
			if(_48!="POST"){_48="GET";}
			this.onComplete=_49;
			this.onError=_4a;
			var _4b=this;
			if(window.XMLHttpRequest){
				this.req=new XMLHttpRequest();			
				this.req.onreadystatechange=function(){_4b.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(){_4b.processReqChange();};	
						this.req.open(_48,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(_4c,_4d,_4e,_4f){
			var ne=document.createElement(_4c);
			if(!ne){return false;}
			for(var a in _4d){ne[a]=_4d[a];}
			if(typeof (_4e)=="string"&&!_4f){ne.appendChild(document.createTextNode(_4e));}
			else{
				if(typeof (_4e)=="string"&&_4f){ne.innerHTML=_4e;}
				else{if(typeof (_4e)=="object"){ne.appendChild(_4e);}}
			}
			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 _59=0;
			if(obj.offsetParent){
				while(obj.offsetParent){
					_59+=obj.offsetLeft;
					obj=obj.offsetParent;
				}
			}else{
				if(obj.x){_59+=obj.x;}
			}
			var obj=e;
			var _5b=0;
			if(obj.offsetParent){
				while(obj.offsetParent){
					_5b+=obj.offsetTop;
					obj=obj.offsetParent;
				}
			}else{
				if(obj.y){_5b+=obj.y;}
			}
			return {x:_59,y:_5b};
		};
		if(typeof (_bsn.Fader)=="undefined"){_bsn.Fader={};}
		_bsn.Fader=function(ele,_5d,to,_5f,_60){
			if(!ele){return false;}
			this.ele=ele;
			this.from=_5d;
			this.to=to;
			this.callback=_60;
			this.nDur=_5f;
			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 _62=Math.round(this._tween(this.nTime,this.from,this.to,this.nDur)*100);
			var op=_62/100;
			if(this.ele.filters){
				try{this.ele.filters.item("DXImageTransform.Microsoft.Alpha").opacity=_62;}
				catch(e){this.ele.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+_62+")";}
			}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));};
