//------------------------------------------------------
// Thanx Media - SuggestAhead(TM) - Copyright (C) 2008
//------------------------------------------------------
function bj(f,aZ){

/* ---- Public Variables ---- */
this.typeahead_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out)
this.typeahead_lim = 10;    // Number of elements autocomplete can show (-1: no limit)
this.typeahead_firstText = true; // should the auto complete be limited to the beginning of keyword?
this.typeahead_mouse = true; // Enable Mouse Support
this.typeahead_delimiter = new Array(';',',');  // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete
this.typeahead_startcheck = 1; // Show widget only after this number of characters is typed in.
this.typeahead_formname = 'searchSite'; // Name of form to submit
/* ---- Public Variables ---- */

/* --- Styles --- */
this.typeahead_bgColor = '#FFFFFF';
this.typeahead_textColor = '#660033';
this.typeahead_border = '1px solid #EA892B';
this.typeahead_hColor = '#FFE597';
this.typeahead_fFamily = 'Arial';
this.typeahead_fSize = '15px';
this.typeahead_hStyle = 'text-decoration:none;font-weight="bold"';
this.typeahead_Width = '327px';
this.typeahead_Zindex = '20';
/* --- Styles --- */

var C=new Array();var U=0;var ax=new Array();var I=false;var k=0;var af=0;var v=null;var L=0;var O=0;var 
ac=new Array();var aq=0;var B;var ay=false;var bk="";var D=1;var au=0;var ab=false;this.J=new Array();
this.J=aZ;var d=this;v=f;ae(v,"focus",ba);
function ba(){ae(document,"keydown",aI);ae(v,"blur",aK);ae(document,"keypress",aJ);};
function aK(A){if(!A)A=event;al(document,"keydown",aI);al(v,"blur",aK);al(document,"keypress",aJ);G();};
function aA(n)
{if(d.typeahead_delimiter.length>0)
{var P=C[U].ak().ad();var as=C[U].ak().length;}
else{var P=v.value.ad();var as=v.value.length;}
var aa='';var i;
if(d.typeahead_firstText){var ah=new RegExp("^"+P,"i");}else{var ah=new RegExp(P,"i");}
var p=n.search(ah);for(i=0;i<p;i++){aa+=n.substr(i,1);}aa+="<font style='"+(d.typeahead_hStyle)+"'>";
for(i=p;i<as+p;i++){aa+=n.substr(i,1);}aa+="</font>";for(i=as+p;i<n.length;i++){aa+=n.substr(i,1);}return aa;};function aQ(){if(document.getElementById('tat_table')){I=false;document.body.removeChild(document.getElementById('tat_table'));}if(au==0){I=false;return;}a=document.createElement('table');a.cellSpacing='1px';a.cellPadding='2px';a.style.position='absolute';a.style.zIndex=d.typeahead_Zindex;a.style.border=d.typeahead_border;a.style.width=d.typeahead_Width;a.style.top=eval(aG(v)+v.offsetHeight)+"px";a.style.left=aH(v)+"px";a.style.backgroundColor=d.typeahead_bgColor;a.id='tat_table';document.body.appendChild(a);var i;var first=true;var o=1;if(d.typeahead_mouse){a.onmouseout=aL;a.onmouseover=aD;}var aP=0;for(i=0;i<d.J.length;i++){if(ac[i]){aP++;F=a.insertRow(-1);F.style.backgroundColor=d.typeahead_bgColor;F.id='tat_tr'+(o);g=F.insertCell(-1);g.style.color=d.typeahead_textColor;g.style.fontFamily=d.typeahead_fFamily;g.style.fontSize=d.typeahead_fSize;g.innerHTML=aA(d.J[i]);g.id='tat_td'+(o);g.setAttribute('pos',o);if(d.typeahead_mouse){g.style.cursor='pointer';g.onclick=aB;g.onmouseover=aN;}o++;}if(o-1==d.typeahead_lim&&o<af){F=a.insertRow(-1);F.style.backgroundColor=d.typeahead_bgColor;g=F.insertCell(-1);g.style.color=d.typeahead_textColor;g.style.fontFamily='arial narrow';g.style.fontSize=d.typeahead_fSize;g.align='center';am(g,'\\/');if(d.typeahead_mouse){g.style.cursor='pointer';g.onclick=aF;}break;}}L=1;O=o-1;I=true;};function aE(){document.body.removeChild(document.getElementById('tat_table'));a=document.createElement('table');a.cellSpacing='1px';a.cellPadding='2px';a.style.position='absolute';a.style.zIndex=d.typeahead_Zindex;a.style.border=d.typeahead_border;a.style.width=d.typeahead_Width;a.style.top=eval(aG(v)+v.offsetHeight)+"px";a.style.left=aH(v)+"px";a.style.backgroundColor=d.typeahead_bgColor;a.id='tat_table';if(d.typeahead_mouse){a.onmouseout=aL;a.onmouseover=aD;}document.body.appendChild(a);var i;var first=true;var o=1;if(L>1){F=a.insertRow(-1);F.style.backgroundColor=d.typeahead_bgColor;g=F.insertCell(-1);g.style.color=d.typeahead_textColor;g.style.fontFamily='arial narrow';g.style.fontSize=d.typeahead_fSize;g.align='center';am(g,'/\\');if(d.typeahead_mouse){g.style.cursor='pointer';g.onclick=aY;}}for(i=0;i<d.J.length;i++){if(ac[i]){if(o>=L&&o<=O){F=a.insertRow(-1);F.style.backgroundColor=d.typeahead_bgColor;F.id='tat_tr'+(o);g=F.insertCell(-1);g.style.color=d.typeahead_textColor;g.style.fontFamily=d.typeahead_fFamily;g.style.fontSize=d.typeahead_fSize;g.innerHTML=aA(d.J[i]);g.id='tat_td'+(o);g.setAttribute('pos',o);if(d.typeahead_mouse){g.style.cursor='pointer';g.onclick=aB;g.onmouseover=aN;}o++;}else{o++;}}if(o>O)break;}if(o-1<af){F=a.insertRow(-1);F.style.backgroundColor=d.typeahead_bgColor;g=F.insertCell(-1);g.style.color=d.typeahead_textColor;g.style.fontFamily='arial narrow';g.style.fontSize=d.typeahead_fSize;g.align='center';am(g,'\\/');if(d.typeahead_mouse){g.style.cursor='pointer';g.onclick=aF;}}};function bf(){if(!I)return;if(k==null||k==0){k=1;}if(k==1)return;document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_bgColor;k--;if(k<L)at();document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_hColor;if(B)clearTimeout(B);if(d.typeahead_timeOut>0)B=setTimeout(function(){D=0;G();},d.typeahead_timeOut);};function be(){if(!I)return;if(k==af)return;if(k>0){document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_bgColor;}k++;if(k>O)an();document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_hColor;if(B)clearTimeout(B);if(d.typeahead_timeOut>0)B=setTimeout(function(){D=0;G();},d.typeahead_timeOut);};function an(){L++;O++;aE();};function at(){L--;O--;aE();};function aF(){document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_bgColor;k++;an();document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_hColor;v.focus();D=0;if(B)clearTimeout(B);if(d.typeahead_timeOut>0)B=setTimeout(function(){D=0;G();},d.typeahead_timeOut);};function aY(A){if(!A)A=event;if(A.stopPropagation){A.stopPropagation();}else{A.cancelBubble=true;}document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_bgColor;k--;at();document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_hColor;v.focus();D=0;if(B)clearTimeout(B);if(d.typeahead_timeOut>0)B=setTimeout(function(){D=0;G();},d.typeahead_timeOut);};function aB(A){if(!A)A=event;if(!I)return;D=0;k=this.getAttribute('pos');aC();};function aD(){D=1;};function aL(){D=0;if(B)clearTimeout(B);if(d.typeahead_timeOut>0)B=setTimeout(function(){D=0;G();},d.typeahead_timeOut);};function aN(){D=1;if(k==null||k==0){k=1;}document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_bgColor;k=this.getAttribute('pos');while(k<L)at();while(k>O)an();document.getElementById('tat_tr'+k).style.backgroundColor=d.typeahead_hColor;if(B)clearTimeout(B);if(d.typeahead_timeOut>0)B=setTimeout(function(){D=0;G();},d.typeahead_timeOut);};function bc(a){if(d.typeahead_delimiter.length>0){Q='';H=0;for(i=0;i<C.length;i++){if(U==i){aw=av='';az=false;for(o=0;o<C[i].length;++o){if(C[i].charAt(o)!=' '){az=true;break;}aw+=' ';}for(o=C[i].length-1;o>=0;--o){if(C[i].charAt(o)!=' ')break;av+=' ';}Q+=aw;Q+=a;H=Q.length;if(az)Q+=av;}else{Q+=C[i];}if(i!=C.length-1){Q+=ax[i];}}v.value=Q;aW(v,H);}else{v.value=a;}D=0;G();};function aC(){if(!I)return;I=false;var word='';var g=0;for(var i=0;i<=d.J.length;i++){if(ac[i])g++;if(g==k){word=d.J[i];break;}}bc(word);H=ao(v);aR();};function aR(){if(document.getElementById(d.typeahead_formname)!=null){var aT=document.getElementById(d.typeahead_formname);aT.submit();}};function G(){if(D==0){I=0;if(document.getElementById('tat_table')){document.body.removeChild(document.getElementById('tat_table'));}if(B)clearTimeout(B);}};function aJ(e){if(ab)aV(e);return!ab;};function aI(A){if(!A)A=event;a=A.keyCode;bd=ao(v);ab=0;switch(a){case 38:bf();ab=1;return false;break;case 40:be();ab=1;return false;break;case 13:case 9:if(I&&k>0){ab=1;aC();return false;}else{return true;}break;default:setTimeout(function(){bb(a)},50);break;}};function bb(ap){if(ap==38||ap==40||ap==13)return;var i;if(I){var word=0;var g=0;for(var i=0;i<=d.J.length;i++){if(ac[i])g++;if(g==k){word=i;break;}}aq=word;}else{aq= -1};if(v.value==''){D=0;G();return;}if(d.typeahead_delimiter.length>0){bd=ao(v);aO=aU(v);aj='';for(i=0;i<d.typeahead_delimiter.length;i++){aj+=d.typeahead_delimiter[i];}aj=aj.ad();aM=new RegExp("(["+aj+"])");g=0;C=new Array();C[0]='';for(i=0,o=v.value.length;i<v.value.length;i++,o--){if(v.value.substr(i,o).search(aM)==0){aX=v.value.substr(i,o).match(aM);ax[g]=aX[1];g++;C[g]='';}else{C[g]+=v.value.charAt(i);}}var H=0;U= -1;for(i=0;i<C.length;i++){if(aO>=H&&aO<=H+C[i].length){U=i;}H+=C[i].length+1;}var ar=C[U].ak();var P=C[U].ad().ak();}else{var ar=v.value;var P=v.value.ad();}if(ar.length==0){D=0;G();}if(ar.length<d.typeahead_startcheck)return this;if(d.typeahead_firstText){var ah=new RegExp("^"+P,"i");}else{var ah=new RegExp(P,"i");}af=0;ay=false;au=0;for(i=0;i<d.J.length;i++){ac[i]=false;if(ah.test(d.J[i])){af++;ac[i]=true;au++;if(aq==i)ay=true;}}if(B)clearTimeout(B);if(d.typeahead_timeOut>0)B=setTimeout(function(){D=0;G();},d.typeahead_timeOut);aQ();};return this;};function ae(f,T,V){if(f.attachEvent){f.attachEvent("on"+T,V);}else if(f.addEventListener){f.addEventListener(T,V,true);}else{f["on"+T]=V;}};function al(f,T,V){if(f.detachEvent){f.detachEvent("on"+T,V);}else if(f.removeEventListener){f.removeEventListener(T,V,true);}else{f["on"+T]=null;}};function aV(A){A||window.event;if(A.stopPropagation){A.stopPropagation();A.preventDefault();}else if(typeof A.cancelBubble!="undefined"){A.cancelBubble=true;A.returnValue=false;}return false;};function bh(A){if(window.event){return window.event.srcElement;}else{return A.currentTarget;}};function bg(A){if(window.event){return window.event.srcElement;}else{return A.target;}};function bi(f){if(typeof f.onselectstart!='undefined'){ae(f,"selectstart",function(){return false;});}};function aU(f){if(typeof f.selectionEnd!="undefined"){return f.selectionEnd;}else if(document.selection&&document.selection.createRange){var M=document.selection.createRange();try{var K=M.duplicate();K.moveToElementText(f);}catch(e){var K=f.createTextRange();}K.setEndPoint("EndToEnd",M);var ai=K.text.length;if(ai>f.value.length){return-1;}return ai;}};function ao(f){if(typeof f.selectionStart!="undefined"){return f.selectionStart;}else if(document.selection&&document.selection.createRange){var M=document.selection.createRange();try{var K=M.duplicate();K.moveToElementText(f);}catch(e){var K=f.createTextRange();}K.setEndPoint("EndToStart",M);var ai=K.text.length;if(ai>f.value.length){return-1;}return ai;}};function aW(f,H){f.focus();if(f.setSelectionRange){f.setSelectionRange(H,H);}else if(f.createTextRange){R=f.createTextRange();R.moveStart('character',H);R.collapse();R.select();}};function bm(f,s,e){f.focus();if(f.setSelectionRange){f.setSelectionRange(s,e);}else if(f.createTextRange){R=f.createTextRange();R.moveStart('character',s);R.moveEnd('character',e);R.select();}};String.prototype.ad=function(){return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g,'\\$1');};String.prototype.ak=function(){return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1");};function aG(f){ag=0;while(f){ag+=f.offsetTop;f=f.offsetParent;}return ag;};function aH(f){ag=0;while(f){ag+=f.offsetLeft;f=f.offsetParent;}return ag;};function bl(a){return typeof a=='number'&&isFinite(a);};function am(f,text){while(aS=f.childNodes[0]){f.removeChild(aS);};f.appendChild(document.createTextNode(text));}