//----vietnamese--type-----------------------------------------------

function btnVietkey_onclick()
{var srcStr=document.getElementById('btnVietkey').src;obj=getCookieUniKey('HIM_on_off');
if(obj==1)
{setMethod(-1);setCookie('HIM_on_off',0,365);document.getElementById('btnVietkey').src=wgStylePath+'images/E.png';}
else
{setMethod(1);setCookie('HIM_on_off',1,365);document.getElementById('btnVietkey').src=wgStylePath+'images/V.png';}
return true;}


va="email".split(',')
method=0
on_off=0
dockspell=1
dauCu=1
useCookie=1
radioID="him_auto,him_telex,him_vni,him_viqr,him_viqr2,him_off,him_ckspell,him_daucu".split(",")
var agt=navigator.userAgent.toLowerCase(),alphabet="QWERTYUIOPASDFGHJKLZXCVBNM\ ",them,spellerr,setCookie,getCookie
var is_ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1)),S,F,J,R,X,D,oc,sk,saveStr,wi,frame,is_opera=false,D2,isKHTML=false
var ver=0,support=true,changed=false,specialChange=false,uni,uni2,g,h,SFJRX,DAWEO,Z,AEO,moc,trang,kl=0,tw5,range=null,doc,fID=document.getElementsByTagName("iframe")
skey=new Array(97,226,259,101,234,105,111,244,417,117,432,121,65,194,258,69,202,73,79,212,416,85,431,89)
var skey2="a,a,a,e,e,i,o,o,o,u,u,y,A,A,A,E,E,I,O,O,O,U,U,Y".split(','),A,E,O,whit=false,english="ĐÂĂƠƯÊÔ",lowen="đâăơưêô",ds1="d,D".split(","),db1=new Array(273,272)
os1="o,O,ơ,Ơ,ó,Ó,ò,Ò,ọ,Ọ,ỏ,Ỏ,õ,Õ,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ".split(","),ob1="ô,Ô,ô,Ô,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ".split(",")
mocs1="o,O,ô,Ô,u,U,ó,Ó,ò,Ò,ọ,Ọ,ỏ,Ỏ,õ,Õ,ú,Ú,ù,Ù,ụ,Ụ,ủ,Ủ,ũ,Ũ,ố,Ố,ồ,Ồ,ộ,Ộ,ổ,Ổ,ỗ,Ỗ".split(",");mocb1="ơ,Ơ,ơ,Ơ,ư,Ư,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ,ứ,Ứ,ừ,Ừ,ự,Ự,ử,Ử,ữ,Ữ,ớ,Ớ,ờ,Ờ,ợ,Ợ,ở,Ở,ỡ,Ỡ".split(",")
trangs1="a,A,â,Â,á,Á,à,À,ạ,Ạ,ả,Ả,ã,Ã,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ".split(",");trangb1="ă,Ă,ă,Ă,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ".split(",")
as1="a,A,ă,Ă,á,Á,à,À,ạ,Ạ,ả,Ả,ã,Ã,ắ,Ắ,ằ,Ằ,ặ,Ặ,ẳ,Ẳ,ẵ,Ẵ,ế,Ế,ề,Ề,ệ,Ệ,ể,Ể,ễ,Ễ".split(",");ab1="â,Â,â,Â,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ,ấ,Ấ,ầ,Ầ,ậ,Ậ,ẩ,Ẩ,ẫ,Ẫ,é,É,è,È,ẹ,Ẹ,ẻ,Ẻ,ẽ,Ẽ".split(",")
es1="e,E,é,É,è,È,ẹ,Ẹ,ẻ,Ẻ,ẽ,Ẽ".split(",");eb1="ê,Ê,ế,Ế,ề,Ề,ệ,Ệ,ể,Ể,ễ,Ễ".split(",")
arA="á,à,ả,ã,ạ,a,Á,À,Ả,Ã,Ạ,A".split(',');mocrA="ó,ò,ỏ,õ,ọ,o,ú,ù,ủ,ũ,ụ,u,Ó,Ò,Ỏ,Õ,Ọ,O,Ú,Ù,Ủ,Ũ,Ụ,U".split(',');erA="é,è,ẻ,ẽ,ẹ,e,É,È,Ẻ,Ẽ,Ẹ,E".split(',');orA="ó,ò,ỏ,õ,ọ,o,Ó,Ò,Ỏ,Õ,Ọ,O".split(',')
aA="ấ,ầ,ẩ,ẫ,ậ,â,Ấ,Ầ,Ẩ,Ẫ,Ậ,Â".split(',');mocA="ớ,ờ,ở,ỡ,ợ,ơ,ứ,ừ,ử,ữ,ự,ư,Ớ,Ờ,Ở,Ỡ,Ợ,Ơ,Ứ,Ừ,Ử,Ữ,Ự,Ư".split(',');trangA="ắ,ằ,ẳ,ẵ,ặ,ă,Ắ,Ằ,Ẳ,Ẵ,Ặ,Ă".split(',');eA="ế,ề,ể,ễ,ệ,ê,Ế,Ề,Ể,Ễ,Ệ,Ê".split(',');oA="ố,ồ,ổ,ỗ,ộ,ô,Ố,Ồ,Ổ,Ỗ,Ộ,Ô".split(',')
function notWord(w){var str="\ \r\n#,\\;.:-_()<>+-*/=?!\"$%{}[]\'~|^\@\&\t"+fcc(160)
return(str.indexOf(w)>=0)}
function nan(w){if((isNaN(w))||(w=='e'))return true
else return false}
function mozGetText(obj){var v,pos,w="";g=1
v=(obj.data)?obj.data:obj.value
if(v.length<=0)return false
if(!obj.data){if(!obj.setSelectionRange)return false
pos=obj.selectionStart}else pos=obj.pos
if(obj.selectionStart!=obj.selectionEnd)return new Array("",pos)
while(1){if(pos-g<0)break
else if(notWord(v.substr(pos-g,1))){if(v.substr(pos-g,1)=="\\")w=v.substr(pos-g,1)+w;break}
else w=v.substr(pos-g,1)+w;g++}
return new Array(w,pos)}
function start(obj,key){var w="",nnc;oc=obj;uni2=false
if(method==0){uni="D,A,E,O,W,W".split(',');uni2="9,6,6,6,7,8".split(',');D2="DAWEO6789"}
else if(method==1){uni="D,A,E,O,W,W".split(',');D2="DAWEO"}
else if(method==2){uni="9,6,6,6,7,8".split(',');D2="6789"}
else if(method==3){uni="D,^,^,^,+,(".split(',');D2="D^+("}
else if(method==4){uni="D,^,^,^,*,(".split(',');D2="D^*("}
if(!is_ie){key=fcc(key.which)
w=mozGetText(obj)
if(D2.indexOf(up(key))>=0)nnc=true
else nnc=false
if((!w)||(obj.sel))return
main(w[0],key,w[1],uni,nnc)
if(!dockspell)w=mozGetText(obj)
if((w)&&(uni2)&&(!changed))main(w[0],key,w[1],uni2,nnc)}else{obj=ieGetText(obj)
if(obj){var sT=obj.cW.text
w=main(obj.cW.text,key,0,uni,false)
if((uni2)&&((w==sT)||(typeof(w)=='undefined')))w=main(obj.cW.text,key,0,uni2,false)
if(w)obj.cW.text=w}}
if(D2.indexOf(up(key))>=0){if(!is_ie){w=mozGetText(obj)
if(!w)return
normC(w[0],key,w[1])}else if(typeof(obj)=="object"){obj=ieGetText(obj)
if(obj){w=obj.cW.text
if(!changed){w+=key;changed=true}
obj.cW.text=w
w=normC(w,key,0)
if(w){obj=ieGetText(obj);obj.cW.text=w}}}}}
function ieGetText(obj){var caret=obj.document.selection.createRange(),w=""
if(caret.text)caret.text=""
else{while(1){caret.moveStart("character",-1)
if(w.length==caret.text.length)break
w=caret.text
if(notWord(w.charAt(0))){if(w.charCodeAt(0)==13)w=w.substr(2)
else if(w.charAt(0)!="\\")w=w.substr(1)
break}}}
if(w.length){caret.collapse(false)
caret.moveStart("character",-w.length)
obj.cW=caret.duplicate()
return obj}else return false}
function ie_replaceChar(w,pos,c){var r="",uc=0
if(isNaN(c))uc=up(c)
if((whit)&&(up(w.substr(w.length-pos-1,1))=='U')&&(pos!=1)&&(up(w.substr(w.length-pos-2,1))!='Q')){whit=false
if((up(unV(fcc(c)))=="Ơ")||(uc=="O")){if(w.substr(w.length-pos-1,1)=='u')r=fcc(432)
else r=fcc(431)}
if(uc=="O"){if(c=="o")c=417
else c=416}}
if(!isNaN(c)){changed=true;r+=fcc(c)
return w.substr(0,w.length-pos-r.length+1)+r+w.substr(w.length-pos+1)}else return w.substr(0,w.length-pos)+c+w.substr(w.length-pos+1)}
function tr(k,w,by,sf,i){var r,pos=findC(w,k,sf)
if(pos){if(pos[1]){if(is_ie)return ie_replaceChar(w,pos[0],pos[1])
else return replaceChar(oc,i-pos[0],pos[1])}else{var c,pC=w.substr(w.length-pos,1),cmp;r=sf
for(g=0;g<r.length;g++){if((nan(r[g]))||(r[g]=="e"))cmp=pC
else cmp=pC.charCodeAt(0)
if(cmp==r[g]){if(!nan(by[g]))c=by[g]
else c=by[g].charCodeAt(0)
if(is_ie)return ie_replaceChar(w,pos,c)
else return replaceChar(oc,i-pos,c)}}}}
return false}
function main(w,k,i,a,nnc){var uk=up(k),bya=new Array(db1,ab1,eb1,ob1,mocb1,trangb1),got=false,t="d,D,a,A,a,A,o,O,u,U,e,E,o,O".split(",")
var sfa=new Array(ds1,as1,es1,os1,mocs1,trangs1),by=new Array(),sf=new Array()
if((method==2)||((method==0)&&(a[0]=="9"))){DAWEO="6789";SFJRX="12534";S="1";F="2";J="5";R="3";X="4";Z="0";D="9";FRX="234";AEO="6";moc="7";trang="8";them="678";A="^";E="^";O="^"}else if(method==3){DAWEO="^+(D";SFJRX="'`.?~";S="'";F="`";J=".";R="?";X="~";Z="-";D="D";FRX="`?~";AEO="^";moc="+";trang="(";them="^+(";A="^";E="^";O="^"}else if(method==4){DAWEO="^*(D";SFJRX="'`.?~";S="'";F="`";J=".";R="?";X="~";Z="-";D="D";FRX="`?~";AEO="^";moc="*";trang="(";them="^*(";A="^";E="^";O="^"}else if((method==1)||((method==0)&&(a[0]=="D"))){SFJRX="SFJRX";DAWEO="DAWEO";D='D';S='S';F='F';J='J';R='R';X='X';Z='Z';FRX="FRX";them="AOEW";trang="W";moc="W";A="A";E="E";O="O"}
if(SFJRX.indexOf(uk)>=0){var ret=sr(w,k,i);got=true
if(ret)return ret}else if(uk==Z){sf=repSign(null)
for(h=0;h<english.length;h++){sf[sf.length]=lowen.charCodeAt(h)
sf[sf.length]=english.charCodeAt(h)}
for(h=0;h<5;h++)for(g=0;g<skey.length;g++)by[by.length]=skey[g]
for(h=0;h<t.length;h++)by[by.length]=t[h]
got=true}
else for(h=0;h<a.length;h++)if(a[h]==uk){got=true;by=by.concat(bya[h]);sf=sf.concat(sfa[h])}
if(uk==moc)whit=true;if(!got){if(nnc)return
return normC(w,k,i)}
return DAWEOZ(k,w,by,sf,i,uk)}
function DAWEOZ(k,w,by,sf,i,uk){if((DAWEO.indexOf(uk)>=0)||(Z.indexOf(uk)>=0))return tr(k,w,by,sf,i)}
function normC(w,k,i){var uk=up(k),u=repSign(null),fS,c,j,space=(k.charCodeAt(0)==32)?true:false
if((!is_ie)&&(space))return
for(j=1;j<=w.length;j++){for(h=0;h<u.length;h++){if(u[h]==w.charCodeAt(w.length-j)){if(h<=23)fS=S
else if(h<=47)fS=F
else if(h<=71)fS=J
else if(h<=95)fS=R
else fS=X
c=skey[h%24];if((alphabet.indexOf(uk)<0)&&(D2.indexOf(uk)<0))return w;w=unV(w)
if((!space)&&(!changed))w+=k
if(!is_ie){var sp=oc.selectionStart,pos=sp
if(!changed){var sst=oc.scrollTop;pos+=k.length
if(!oc.data){oc.value=oc.value.substr(0,sp)+k+oc.value.substr(oc.selectionEnd);changed=true;oc.scrollTop=sst}
else{oc.insertData(oc.pos,k);oc.pos++;range.setEnd(oc,oc.pos);specialChange=true}}
if(!oc.data)oc.setSelectionRange(pos,pos)
if(!ckspell(w,fS)){replaceChar(oc,i-j,c)
if(!oc.data){var a=new Array(D)
main(w,fS,pos,a,false)}else{var ww=mozGetText(oc)
var a=new Array(D)
main(ww[0],fS,ww[1],a,false)}}}else{var ret=sr(w,fS,0)
if((space)&&(ret))ret+=fcc(32)
if(ret)return ret}}}}}
function nospell(w,k){return false}
function ckspell(w,k){w=unV(w);var exc="UOU,IEU".split(','),z,next=true,noE="UU,UOU,UOI,IEU,AO,IA,AI,AY,AU,AO".split(','),noBE="YEU",test,a,b
var check=true,noM="UE,UYE,IU,EU,UY".split(','),noMT="AY,AU".split(','),noT="UA",t=-1,notV2="IAO"
var uw=up(w),tw=uw,update=false,gi="IO",noAOEW="OE,OO,AO,EO,IA,AI".split(','),noAOE="OA"
var notViet="AA,AE,EE,OU,YY,YI,IY,EY,EA,EI,II,IO,YO,YA,OOO".split(','),uk=up(k),twE,uw2=unV2(uw)
var vSConsonant="B,C,D,G,H,K,L,M,N,P,Q,R,S,T,V,X".split(','),vDConsonant="CH,GI,KH,NGH,GH,NG,NH,PH,QU,TH,TR".split(',')
var vDConsonantE="CH,NG,NH".split(','),sConsonant="C,P,T,CH".split(','),vSConsonantE="C,M,N,P,T".split(',')
var noNHE="O,U,IE,Ô,Ơ,Ư,IÊ,Ă,Â,UYE,UYÊ,UO,ƯƠ,ƯO,UƠ,UA,ƯA,OĂ,OE,OÊ".split(','),oMoc="UU,UOU".split(',')
if(FRX.indexOf(uk)>=0)for(a=0;a<sConsonant.length;a++)if(uw.substr(uw.length-sConsonant[a].length,sConsonant[a].length)==sConsonant[a])return true
for(a=0;a<uw.length;a++){if("FJZW1234567890".indexOf(uw.substr(a,1))>=0)return true
for(b=0;b<notViet.length;b++){if(uw2.substr(a,notViet[b].length)==notViet[b]){for(z=0;z<exc.length;z++)if(uw2.indexOf(exc[z])>=0)next=false
if((next)&&((gi.indexOf(notViet[b])<0)||(a<=0)||(uw2.substr(a-1,1)!='G')))return true}}}
for(b=0;b<vDConsonant.length;b++)if(tw.indexOf(vDConsonant[b])==0){tw=tw.substr(vDConsonant[b].length);update=true;t=b;break}
if(!update)for(b=0;b<vSConsonant.length;b++)if(tw.indexOf(vSConsonant[b])==0){tw=tw.substr(1);break}
update=false;twE=tw
for(b=0;b<vDConsonantE.length;b++){if(tw.substr(tw.length-vDConsonantE[b].length)==vDConsonantE[b]){tw=tw.substr(0,tw.length-vDConsonantE[b].length)
if(b==2){for(z=0;z<noNHE.length;z++)if(tw==noNHE[z])return true
if((uk==trang)&&((tw=="OA")||(tw=="A")))return true}
update=true;break}}
if(!update)for(b=0;b<vSConsonantE.length;b++)if(tw.substr(tw.length-1)==vSConsonantE[b]){tw=tw.substr(0,tw.length-1);break}
if(tw){for(a=0;a<vDConsonant.length;a++){for(b=0;b<tw.length;b++){if(tw.substr(b,vDConsonant[a].length)==vDConsonant[a])return true}}
for(a=0;a<vSConsonant.length;a++){if(tw.indexOf(vSConsonant[a])>=0)return true}}
test=tw.substr(0,1)
if((t==3)&&((test=="A")||(test=="O")||(test=="U")||(test=="Y")))return true
if((t==5)&&((test=="E")||(test=="I")||(test=="Y")))return true
uw2=unV2(tw)
if(uw2==notV2)return true
if(tw!=twE)for(z=0;z<noE.length;z++)if(uw2==noE[z])return true
if((tw!=uw)&&(uw2==noBE))return true
if(uk!=moc)for(z=0;z<oMoc.length;z++)if(tw==oMoc[z])return true
if((uw2.indexOf('UYE')>0)&&(uk=='E'))check=false
if((them.indexOf(uk)>=0)&&(check)){for(a=0;a<noAOEW.length;a++)if(uw2.indexOf(noAOEW[a])>=0)return true
if(uk!=trang)if(uw2==noAOE)return true
if((uk==trang)&&(trang!='W'))if(uw2==noT)return true
if(uk==moc)for(a=0;a<noM.length;a++)if(uw2==noM[a])return true
if((uk==moc)||(uk==trang))for(a=0;a<noMT.length;a++)if(uw2==noMT[a])return true}
tw5=tw
if((uw2.charCodeAt(0)==272)||(uw2.charCodeAt(0)==273)){if(uw2.length>4)return true}
else if(uw2.length>3)return true
return false}
function DAWEOF(cc,k){var ret=new Array(),kA=new Array(A,moc,trang,E,O),z,a;ret[0]=g
var ccA=new Array(aA,mocA,trangA,eA,oA),ccrA=new Array(arA,mocrA,arA,erA,orA)
for(a=0;a<kA.length;a++)if(k==kA[a])for(z=0;z<ccA[a].length;z++)if(cc==ccA[a][z])ret[1]=ccrA[a][z]
if(ret[1])return ret
else return false}
function findC(w,k,sf){if(((method==3)||(method==4))&&(w.substr(w.length-1,1)=="\\"))return new Array(1,k.charCodeAt(0))
var str="",res,cc="",pc="",tE="",vowA=new Array(),s="ÂĂÊÔƠƯêâăơôư",c=0,dn=false,uw=up(w),tv
var DAWEOFA=aA.join()+eA.join()+mocA.join()+trangA.join()+oA.join()+english;DAWEOFA=up(DAWEOFA)
for(g=0;g<sf.length;g++){if(nan(sf[g]))str+=sf[g]
else str+=fcc(sf[g])}
var uk=up(k),i=w.length,uni_array=repSign(k),w2=up(unV2(unV(w))),dont="ƯA,ƯU".split(',')
if(DAWEO.indexOf(uk)>=0){if(uk==moc){if((w2.indexOf("UU")>=0)&&(tw5!=dont[1])){if(w2.indexOf("UU")==(w.length-2))res=2
else return false}else if(w2.indexOf("UOU")>=0){if(w2.indexOf("UOU")==(w.length-3))res=2
else return false}}
if(!res){for(g=1;g<=w.length;g++){cc=w.substr(w.length-g,1)
pc=up(w.substr(w.length-g-1,1))
uc=up(cc)
for(h=0;h<dont.length;h++)if((tw5==dont[h])&&(tw5==unV(pc+uc)))dn=true
if(dn){dn=false;continue}
if(str.indexOf(uc)>=0){if(((uk==moc)&&(unV(uc)=="U")&&(up(unV(w.substr(w.length-g+1,1)))=="A"))||((uk==trang)&&(unV(uc)=='A')&&(unV(pc)=='U'))){if(unV(uc)=="U")tv=1
else tv=2
ccc=up(w.substr(w.length-g-tv,1))
if(ccc!="Q")res=g+tv-1
else if(uk==trang)res=g
else if(moc!=trang)return false}else res=g
if((!whit)||(uw.indexOf("Ư")<0)||(uw.indexOf("W")<0))break}else if(DAWEOFA.indexOf(uc)>=0){if(uk==D){if(cc=="đ")res=new Array(g,'d')
else if(cc=="Đ")res=new Array(g,'D')}else res=DAWEOF(cc,uk)
if(res)break}}}}
if((uk!=Z)&&(DAWEO.indexOf(uk)<0)){var tEC=retKC(uk);for(g=0;g<tEC.length;g++)tE+=fcc(tEC[g])}
for(g=1;g<=w.length;g++){if(DAWEO.indexOf(uk)<0){cc=up(w.substr(w.length-g,1))
pc=up(w.substr(w.length-g-1,1))
if(str.indexOf(cc)>=0){if(cc=='U'){if(pc!='Q'){c++;vowA[vowA.length]=g}}else if(cc=='I'){if((pc!='G')||(c<=0)){c++;vowA[vowA.length]=g}}else{c++;vowA[vowA.length]=g}}else if(uk!=Z){for(h=0;h<uni_array.length;h++)if(uni_array[h]==w.charCodeAt(w.length-g)){if(spellerr(w,k))return false
return new Array(g,tEC[h%24])}
for(h=0;h<tEC.length;h++)if(tEC[h]==w.charCodeAt(w.length-g))return new Array(g,fcc(skey[h]))}}}
if((uk!=Z)&&(typeof(res)!='object'))if(spellerr(w,k))return false
if(DAWEO.indexOf(uk)<0){for(g=1;g<=w.length;g++){if((uk!=Z)&&(s.indexOf(w.substr(w.length-g,1))>=0))return g
else if(tE.indexOf(w.substr(w.length-g,1))>=0){for(h=0;h<tEC.length;h++){if(w.substr(w.length-g,1).charCodeAt(0)==tEC[h])return new Array(g,fcc(skey[h]))}}}}
if(res)return res
if((c==1)||(uk==Z))return vowA[0]
else if(c==2){var v=2
if(w.substr(w.length-1)==" ")v=3
var ttt=up(w.substr(w.length-v,2))
if((dauCu==0)&&((ttt=="UY")||(ttt=="OA")||(ttt=="OE")))return vowA[0]
var c2=0,fdconsonant,sc="BCD"+fcc(272)+"GHKLMNPQRSTVX",dc="CH,GI,KH,NGH,GH,NG,NH,PH,QU,TH,TR".split(',')
for(h=1;h<=w.length;h++){fdconsonant=false
for(g=0;g<dc.length;g++){if(up(w.substr(w.length-h-dc[g].length+1,dc[g].length)).indexOf(dc[g])>=0){c2++;fdconsonant=true
if(dc[g]!='NGH')h++
else h+=2}}
if(!fdconsonant){if(sc.indexOf(up(w.substr(w.length-h,1)))>=0)c2++
else break}}
if((c2==1)||(c2==2))return vowA[0]
else return vowA[1]}else if(c==3)return vowA[1]
else return false}
function unV(w){var u=repSign(null),b,a
for(a=1;a<=w.length;a++){for(b=0;b<u.length;b++){if(u[b]==w.charCodeAt(w.length-a)){w=w.substr(0,w.length-a)+fcc(skey[b%24])+w.substr(w.length-a+1)}}}
return w}
function unV2(w){var a,b
for(a=1;a<=w.length;a++){for(b=0;b<skey.length;b++){if(skey[b]==w.charCodeAt(w.length-a))w=w.substr(0,w.length-a)+skey2[b]+w.substr(w.length-a+1)}}
return w}
function repSign(k){var t=new Array(),u=new Array(),a,b
for(a=0;a<5;a++){if((k==null)||(SFJRX.substr(a,1)!=up(k))){t=retKC(SFJRX.substr(a,1))
for(b=0;b<t.length;b++)u[u.length]=t[b]}}
return u}
function sr(w,k,i){var sf=getSF()
pos=findC(w,k,sf)
if(pos){if(pos[1]){if(!is_ie)replaceChar(oc,i-pos[0],pos[1])
else return ie_replaceChar(w,pos[0],pos[1])}else{var c=retUni(w,k,pos)
if(!is_ie)replaceChar(oc,i-pos,c)
else return ie_replaceChar(w,pos,c)}}
return false}
function retUni(w,k,pos){var u=retKC(up(k)),uC,lC,c=w.charCodeAt(w.length-pos),a
for(a=0;a<skey.length;a++)if(skey[a]==c){if(a<12){lC=a;uC=a+12}
else{lC=a-12;uC=a}
t=fcc(c);if(t!=up(t))return u[lC]
return u[uC]}}
function replaceChar(o,pos,c){var bb=false;if(!nan(c)){var replaceBy=fcc(c),wfix=up(unV(fcc(c)));changed=true}
else{var replaceBy=c;if((up(c)=="O")&&(whit))bb=true}
if(!o.data){var savePos=o.selectionStart,sst=o.scrollTop
if((up(o.value.substr(pos-1,1))=='U')&&(pos<savePos-1)&&(up(o.value.substr(pos-2,1))!='Q')){if((wfix=="Ơ")||(bb))
{if(o.value.substr(pos-1,1)=='u')var r=fcc(432)
else var r=fcc(431)}
if(bb){changed=true;if(c=="o")replaceBy="ơ"
else replaceBy="Ơ"}}
o.value=o.value.substr(0,pos)+replaceBy+o.value.substr(pos+1)
if(r)o.value=o.value.substr(0,pos-1)+r+o.value.substr(pos)
o.setSelectionRange(savePos,savePos);o.scrollTop=sst}else{if((up(o.data.substr(pos-1,1))=='U')&&(pos<o.pos-1)){if((wfix=="Ơ")||(bb))
{if(o.data.substr(pos-1,1)=='u')var r=fcc(432)
else var r=fcc(431)}
if(bb){changed=true;if(c=="o")replaceBy="ơ"
else replaceBy="Ơ"}}
o.deleteData(pos,1);o.insertData(pos,replaceBy)
if(r){o.deleteData(pos-1,1);o.insertData(pos-1,r)}}
if(whit)whit=false}
function retKC(k){if(k==S)return new Array(225,7845,7855,233,7871,237,243,7889,7899,250,7913,253,193,7844,7854,201,7870,205,211,7888,7898,218,7912,221)
if(k==F)return new Array(224,7847,7857,232,7873,236,242,7891,7901,249,7915,7923,192,7846,7856,200,7872,204,210,7890,7900,217,7914,7922)
if(k==J)return new Array(7841,7853,7863,7865,7879,7883,7885,7897,7907,7909,7921,7925,7840,7852,7862,7864,7878,7882,7884,7896,7906,7908,7920,7924)
if(k==R)return new Array(7843,7849,7859,7867,7875,7881,7887,7893,7903,7911,7917,7927,7842,7848,7858,7866,7874,7880,7886,7892,7902,7910,7916,7926)
if(k==X)return new Array(227,7851,7861,7869,7877,297,245,7895,7905,361,7919,7929,195,7850,7860,7868,7876,296,213,7894,7904,360,7918,7928)}
function getEL(id){return document.getElementById(id)}
function getSF(){var sf=new Array(),x;for(x=0;x<skey.length;x++)sf[sf.length]=fcc(skey[x]);return sf}
function statusMessage(){var str='Kiểu gõ: '
if(on_off==0)str+='Tắt'
else if(method==1)str+='TELEX'
else if(method==2)str+='VNI'
else if(method==3)str+='VIQR'
else if(method==4)str+='VIQR*'
else if(method==0)str+='Tự động'
if(isKHTML)str+=" [Alt-F9]"
else str+=" [F9]"
str+=" | Chính tả: "
str+=(dockspell==0)?"Tắt":"Bật"
if(isKHTML)str+=" [Alt-F8]"
else str+=" [F8]"
str+=" | Bỏ dấu: "
str+=(dauCu==1)?"Cũ":"Mới"
if(isKHTML)str+=" [Alt-F7]"
else str+=" [F7]"
str+=" | Bật/Tắt [F12] - AVIM 20070522"
window.status=str}
function updateInfo(){setCookie();if(support)statusMessage()}
function setMethod(m){if(m==-1){on_off=0;if(getEL(radioID[5]))getEL(radioID[5]).checked=true}
else{on_off=1;method=m;if(getEL(radioID[m]))getEL(radioID[m]).checked=true}
setSpell(dockspell);setDauCu(dauCu);updateInfo()}
function setDauCu(box){if(typeof(box)=="number"){dauCu=box;if(getEL(radioID[7]))getEL(radioID[7]).checked=box}else dauCu=(box.checked)?1:0
updateInfo()}
function setSpell(box){if(typeof(box)=="number"){spellerr=(box==1)?ckspell:nospell
if(getEL(radioID[6]))getEL(radioID[6]).checked=box}
else{if(box.checked){spellerr=ckspell;dockspell=1}
else{spellerr=nospell;dockspell=0}}
updateInfo()}
function onKeyDown(e){if(e=='iframe'){frame=findF();var key=frame.event.keyCode}
else var key=(!is_ie)?e.which:window.event.keyCode
if((key==120)||(key==123)||(key==119)||(key==118)){if(key==120){on_off=1;setMethod(((method==4)?0:++method))}
else if(key==118){setDauCu(((dauCu==1)?0:1))}
else if(key==119){dockspell=(dockspell==0)?1:0;setSpell(dockspell)}
else if(key==123){on_off=(on_off==0)?1:0
if(on_off==0)setMethod(-1)
else setMethod(method)}
updateInfo()}}
function ifInit(w){var sel=w.getSelection()
range=sel?sel.getRangeAt(0):document.createRange()}
function ifMoz(e){var code=e.which,cwi=e.target.parentNode.wi
if(typeof(cwi)=="undefined")cwi=e.target.parentNode.parentNode.wi
if((e.ctrlKey)||((e.altKey)&&(code!=92)&&(code!=126)))return;ifInit(cwi)
var node=range.endContainer,newPos;sk=fcc(code);saveStr=""
if(checkCode(code)||(!range.startOffset)||(typeof(node.data)=='undefined'))return;node.sel=false
if(node.data){saveStr=node.data.substr(range.endOffset)
if(range.startOffset!=range.endOffset)node.sel=true
node.deleteData(range.startOffset,node.data.length)}
range.setEnd(node,range.endOffset)
range.setStart(node,0)
if(!node.data)return
node.value=node.data;node.pos=node.data.length;node.which=code
start(node,e)
node.insertData(node.data.length,saveStr)
newPos=node.data.length-saveStr.length+kl
range.setEnd(node,newPos);range.setStart(node,newPos);kl=0
if(specialChange){specialChange=false;changed=false;node.deleteData(node.pos-1,1)}
if(changed){changed=false;e.preventDefault()}}
function FKeyPress(){var obj=findF()
sk=fcc(obj.event.keyCode)
if(checkCode(obj.event.keyCode)||((obj.event.ctrlKey)&&(obj.event.keyCode!=92)&&(obj.event.keyCode!=126)))return
start(obj,fcc(obj.event.keyCode))}
function checkCode(code){if(((on_off==0)||((code<45)&&(code!=42))||(code==145)||(code==255))&&(code!=32)&&(code!=39)&&(code!=40)&&(code!=43))return true;return false}
function fcc(x){return String.fromCharCode(x)}
if(useCookie==1){setCookie=doSetCookie;getCookie=doGetCookie}
else{setCookie=noCookie;getCookie=noCookie}
function noCookie(){}
function doSetCookie(){var exp=new Date(11245711156480).toGMTString()
document.cookie='HIM_on_off='+on_off+';expires='+exp+"; path=/"
document.cookie='HIM_method='+method+';expires='+exp+"; path=/"
document.cookie='HIM_ckspell='+dockspell+';expires='+exp+"; path=/"
document.cookie='HIM_daucu='+dauCu+';expires='+exp+"; path=/"}
function doGetCookie(){var ck=document.cookie,res=/HIM_method/.test(ck)
if((!res)||(ck.indexOf('HIM_ckspell')<0)){setCookie();return}
var p,ckA=ck.split(';')
for(var i=0;i<ckA.length;i++){p=ckA[i].split('=');p[0]=p[0].replace(/^\s+/g,"");p[1]=parseInt(p[1])
if(p[0]=='HIM_on_off')on_off=p[1]
else if(p[0]=='HIM_method')method=p[1]
else if(p[0]=='HIM_ckspell'){if(p[1]==0){dockspell=0;spellerr=nospell}
else{dockspell=1;spellerr=ckspell}}else if(p[0]=='HIM_daucu')dauCu=parseInt(p[1])}}
if(!is_ie){if(agt.indexOf("opera")>=0){operaV=agt.split(" ");operaVersion=parseInt(operaV[operaV.length-1])
if(operaVersion>=8)is_opera=true
else{operaV=operaV[0].split("/");operaVersion=parseInt(operaV[1])
if(operaVersion>=8)is_opera=true}}else if(agt.indexOf("khtml")>=0)isKHTML=true
else{ver=agt.substr(agt.indexOf("rv:")+3)
ver=parseFloat(ver.substr(0,ver.indexOf(" ")))
if(agt.indexOf("mozilla")<0)ver=0}}
function up(w){w=w.toUpperCase()
if(isKHTML){str="êôơâăưếốớấắứềồờầằừễỗỡẫẵữệộợậặự",rep="ÊÔƠÂĂƯẾỐỚẤẮỨỀỒỜẦẰỪỄỖỠẪẴỮỆỘỢẶỰ"
for(z=0;z<w.length;z++){io=str.indexOf(w.substr(z,1))
if(io>=0)w=w.substr(0,z)+rep.substr(io,1)+w.substr(z+1)}}
return w}
function findIgnore(el){for(i=0;i<va.length;i++)if((el.id==va[i])&&(va[i].length>0))return true}
if((is_ie)||(ver>=1.3)||(is_opera)||(isKHTML)){getCookie()
if(on_off==0)setMethod(-1)
else setMethod(method)
setSpell(dockspell);setDauCu(dauCu);statusMessage()}else support=false
document.onkeydown=function(e){onKeyDown(e)}
document.onkeypress=function(e){if(!support)return
if(!is_ie){var el=e.target,code=e.which;if(e.ctrlKey)return;if((e.altKey)&&(code!=92)&&(code!=126))return}
else{var el=window.event.srcElement,code=window.event.keyCode;if((event.ctrlKey)&&(code!=92)&&(code!=126))return}
if(((el.type!='textarea')&&(el.type!='text'))||checkCode(code))return
sk=fcc(code);if(findIgnore(el))return
if(!is_ie)start(el,e)
else start(el,sk)
if(changed){changed=false;return false}}



function change_btnVietkey(m){var srcStr=document.getElementById('btnVietkey').src;if(m==1)
{setMethod(-1);setCookie('HIM_on_off',0,365);document.getElementById('btnVietkey').src=wgStylePath+'images/E.png';}
else
{setMethod(1);setCookie('HIM_on_off',1,365);document.getElementById('btnVietkey').src=wgStylePath+'images/V.png';}
return true;}
function getCookieUniKey(c_name)
{if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=")
if(c_start!=-1)
{c_start=c_start+c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if(c_end==-1)c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))}}
return""}
function checkBtnUnikey(){obj=getCookieUniKey('HIM_on_off');if(obj==1){document.getElementById('btnVietkey').src=wgStylePath+'images/V.png';}
else{document.getElementById('btnVietkey').src=wgStylePath+'images/E.png';}}
function pgOnload(){var dict=readCookie('dictCookie');if(dict!=null&&dict.indexOf('vn_')!=-1){setMethod(1);setCookie('HIM_on_off',1,365);document.getElementById('btnVietkey').src=wgStylePath+'images/V.png';}else{setMethod(-1);setCookie('HIM_on_off',0,365);document.getElementById('btnVietkey').src=wgStylePath+'images/E.png';}
if(document.searchform.search)document.searchform.search.focus();showBottomBox();}

function bb_bookmarksite(title,url)
{if(document.all)
window.external.AddFavorite(url,title);else if(window.sidebar)
window.sidebar.addPanel(title,url,"")}
function bb_bookmarksite(title,url)
{if(document.all)
window.external.AddFavorite(url,title);else if(window.sidebar)
window.sidebar.addPanel(title,url,"")}


/////------ONCLICK--SHOW--WORD---------------------------------
function vd_noErrorMessages () { return true; }
window.onerror = vd_noErrorMessages;
if(typeof dictionaries == "undefined") 
{
	var dictionaries = "ev_ve";
}
var placeholderwritten=0;
var vdict_offsetfromcursorX=12;
var vdict_offsetfromcursorY=10;
var vdict_ie=document.all;
var vdict_ns6=document.getElementById && !document.all;
var vdict_enabletip=false;
var vdict_tipobj;
document.write("<div id='addVdictOnYourWeb'  style='position: absolute;left: -300px;width: 300px;border: 1px solid black;padding: 2px;background-color: lightyellow;visibility: hidden;z-index: 100;'>VDict quick lookup</div>");
function vdict_ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function vdict_positiontip(e){

if (vdict_ie||vdict_ns6)
vdict_tipobj=document.all? document.all["addVdictOnYourWeb"] : document.getElementById? document.getElementById("addVdictOnYourWeb") : "";

	if (vdict_enabletip){
		var nondefaultpos=false;
		var curX=(vdict_ns6)?e.pageX : event.clientX+vdict_ietruebody().scrollLeft;
		var curY=(vdict_ns6)?e.pageY : event.clientY+vdict_ietruebody().scrollTop;
		var winwidth=vdict_ie&&!window.opera? vdict_ietruebody().clientWidth : window.innerWidth-20;
		var winheight=vdict_ie&&!window.opera? vdict_ietruebody().clientHeight : window.innerHeight-20;
		var rightedge=vdict_ie&&!window.opera? winwidth-event.clientX-vdict_offsetfromcursorX : winwidth-e.clientX-vdict_offsetfromcursorX;
		var bottomedge=vdict_ie&&!window.opera? winheight-event.clientY-vdict_offsetfromcursorY : winheight-e.clientY-vdict_offsetfromcursorY;
		var leftedge=(vdict_offsetfromcursorX<0)? vdict_offsetfromcursorX*(-1) : -1000;
		if (rightedge<vdict_tipobj.offsetWidth){
			vdict_tipobj.style.left=curX-vdict_tipobj.offsetWidth+"px";
			nondefaultpos=true;
		}
		else if (curX<leftedge) {
				vdict_tipobj.style.left="5px";
		}
		else{
				vdict_tipobj.style.left=curX+vdict_offsetfromcursorX+"px";
		}
		if (bottomedge<vdict_tipobj.offsetHeight){
			vdict_tipobj.style.top=curY-vdict_tipobj.offsetHeight-vdict_offsetfromcursorY+"px";
			nondefaultpos=true;
		}
		else{
			vdict_tipobj.style.top=curY+vdict_offsetfromcursorY+"px";
		}
		vdict_tipobj.style.visibility="visible";
	}
}
var base_url = "http://vndic.net/";
var text = "";
function calldict(word, dict ){

///urlencode
var ret = word;
ret = ret.toString();
ret = encodeURIComponent(ret);
ret = ret.replace(/%20/g, '+');


	vdict_url	=	base_url+'fast_dict.php?word='+ret+'&dict='+dict+'&m=yes';
	str	=	"<div style='float: left; border-bottom: 1px solid #000000; background: #ffffff;'>";
	str	+=	" <div style='float:left;'><a href='"+base_url+"' target='_blank'><img src='"+base_url+"images/small_logo.gif' border=0 /></a> <span name='vdict_dictionary_name' id='vdict_dictionary_name'></span> </div>";
	str	+=	" <div style='float:right;'><a href='#' onclick=\"doCloseVdict();return false;\"><img src='"+base_url+"images/close.gif' border=0 /></a></div>";
	str	+=	"</div>";
	str	+=	"<div>";
	str	+=	"<iframe id='myIframe' src='"+vdict_url+"' style='width: 100%; height: 200px; border: 0px;'></iframe>";
	str	+=	"</div>";
	document.getElementById('addVdictOnYourWeb').innerHTML = str;
}
function doCloseVdict()
{
	document.getElementById('addVdictOnYourWeb').innerHTML='';
	document.getElementById('addVdictOnYourWeb').style.visibility="hidden";
}

function ctrlrightclick(evt) {
	evt = (evt) ? evt : ((window.event) ? window.event : "");
	if (!evt.ctrlKey) {return true;}
	return false;
}

function detectKey(evt) 
{
    evt = (evt) ? evt : ((window.event) ? window.event : "");
	if(evt.type == 'keydown' && ( (evt.keyCode == "A".charCodeAt(0)) || (evt.keyCode == "a".charCodeAt(0)) ) )
	{
		if ( (evt.ctrlKey) && (evt.shiftKey) )
		{
			text = (document.all) ? document.selection.createRange().text : document.getSelection();
			if (text.length > 1)
			{
				vdict_enabletip=true;
				vdict_positiontip(evt);
				calldict(text, dictionaries);
			}
		}
	}
	return true
}
function doDblClick(evt) 
{
    evt = (evt) ? evt : ((window.event) ? window.event : "");
	text = (document.all) ? document.selection.createRange().text : document.getSelection();
	if (text.length > 1)
	{
		vdict_enabletip=true;
		vdict_positiontip(evt);
		calldict(text, dictionaries);
	}
	return true;
}
function getWordFromEvent (evt) {
  if (document.body && document.body.createTextRange) {
    var range = document.body.createTextRange();
    range.moveToPoint(evt.clientX, evt.clientY);
    range.expand('word');
    return range.text;
  }
  else if (evt.rangeParent && document.createRange) {
    var range = document.createRange();
    range.setStart(evt.rangeParent, evt.rangeOffset);
    range.setEnd(evt.rangeParent, evt.rangeOffset);
    expandRangeToWord(range);
    var word = range.toString();
    range.detach();
    return word;    
  }
  else {
    return null;
  }
}
function expandRangeToWord (range) {
  var startOfWord 	= 	/^\s\S+$/;
  var endOfWord 	= 	/^\S+\s$/;
  var whitespace 	= 	/^\s+$/;
  range.setStart(range.startContainer, range.startOffset - 1);
  while (whitespace.test(range.toString())) {
    range.setEnd(range.endContainer, range.endOffset + 1);
    range.setStart(range.startContainer, range.startOffset + 1);
  }
  while (!startOfWord.test(range.toString())) {
    range.setStart(range.startContainer, range.startOffset - 1);
  }
  range.setStart(range.startContainer, range.startOffset + 1);
  while (!endOfWord.test(range.toString())) {
    range.setEnd(range.endContainer, range.endOffset + 1);
  }
  range.setEnd(range.endContainer, range.endOffset - 1);
  return range.toString();
}
function testSelectText(evt)
{
	evt = (evt) ? evt : ((window.event) ? window.event : "")
	text =	getWordFromEvent(evt);
	alert(text);
	vdict_enabletip=true;
	vdict_positiontip(evt);
	calldict(text, dictionaries);
}
document.ondblclick = 	doDblClick;
document.onkeydown 	= 	detectKey;

//----AUTO--LOOKUP-----------------------------------------
if(typeof(bsn)=="undefined")
_b=bsn={};if(typeof(_b.Autosuggest)=="undefined")
_b.Autosuggest={};else
alert("Autosuggest is already set!");_b.AutoSuggest=function(id,param)
{if(!document.getElementById)
return 0;this.fld=_b.DOM.gE(id);if(!this.fld)
return 0;this.sInp="";this.nInpC=0;this.aSug=[];this.iHigh=0;this.oP=param?param:{};var k,def={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(k in def)
{if(typeof(this.oP[k])!=typeof(def[k]))
this.oP[k]=def[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");};_b.AutoSuggest.prototype.onKeyPress=function(ev)
{var key=(window.event)?window.event.keyCode:ev.keyCode;var RETURN=13;var TAB=9;var ESC=27;var bubble=1;switch(key)
{case RETURN:this.setHighlightedValue();bubble=0;break;case ESC:this.clearSuggestions();break;}
return bubble;};_b.AutoSuggest.prototype.onkeyup=function(ev)
{var key=(window.event)?window.event.keyCode:ev.keyCode;var ARRUP=38;var ARRDN=40;var bubble=1;switch(key)
{case ARRUP:this.changeHighlight(key);bubble=0;break;case ARRDN:this.changeHighlight(key);bubble=0;break;default:this.getSuggestions(this.fld.value);}
return bubble;};_b.AutoSuggest.prototype.getSuggestions=function(val)
{if(val==this.sInp)
return 0;_b.DOM.remE(this.idAs);this.sInp=val;if(val.length<this.oP.minchars)
{this.aSug=[];this.nInpC=val.length;return 0;}
var ol=this.nInpC;this.nInpC=val.length?val.length:0;var l=this.aSug.length;if(this.nInpC>ol&&l&&l<this.oP.maxentries&&this.oP.cache)
{var arr=[];for(var i=0;i<l;i++)
{if(this.aSug[i].value.substr(0,val.length).toLowerCase()==val.toLowerCase())
arr.push(this.aSug[i]);}
this.aSug=arr;this.createList(this.aSug);return false;}
else
{var pointer=this;var input=this.sInp;clearTimeout(this.ajID);this.ajID=setTimeout(function(){pointer.doAjaxRequest(input)},this.oP.delay);}
return false;};_b.AutoSuggest.prototype.doAjaxRequest=function(input)
{if(input!=this.fld.value)
return false;var pointer=this;if(typeof(this.oP.script)=="function")
var url=this.oP.script(encodeURIComponent(this.sInp));else
var url=this.oP.script+this.oP.varname+"="+encodeURIComponent(this.sInp);if(!url)
return false;var meth=this.oP.meth;var input=this.sInp;var onSuccessFunc=function(req){pointer.setSuggestions(req,input)};var onErrorFunc=function(status){return true;};var myAjax=new _b.Ajax();myAjax.makeRequest(url,meth,onSuccessFunc,onErrorFunc);};_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});}}
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});}}
this.idAs="as_"+this.fld.id;this.createList(this.aSug);};_b.AutoSuggest.prototype.createList=function(arr)
{var pointer=this;_b.DOM.remE(this.idAs);this.killTimeout();if(arr.length==0&&!this.oP.shownoresults)
return false;var div=_b.DOM.cE("div",{id:this.idAs,className:this.oP.className});var hcorner=_b.DOM.cE("div",{className:"as_corner"});var hbar=_b.DOM.cE("div",{className:"as_bar"});var header=_b.DOM.cE("div",{className:"as_header"});header.appendChild(hcorner);header.appendChild(hbar);div.appendChild(header);var ul=_b.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.sInp.toLowerCase());var output=val.substring(0,st)+"<em>"+val.substring(st,st+this.sInp.length)+"</em>"+val.substring(st+this.sInp.length);var span=_b.DOM.cE("span",{},output,true);if(arr[i].info!="")
{var br=_b.DOM.cE("br",{});span.appendChild(br);var small=_b.DOM.cE("small",{},arr[i].info);span.appendChild(small);}
var a=_b.DOM.cE("a",{href:"#"});var tl=_b.DOM.cE("span",{className:"tl"}," ");var tr=_b.DOM.cE("span",{className:"tr"}," ");a.appendChild(tl);a.appendChild(tr);a.appendChild(span);a.name=i+1;a.onclick=function(){pointer.setHighlightedValue();return false;};a.onmouseover=function(){pointer.setHighlight(this.name);};var li=_b.DOM.cE("li",{},a);ul.appendChild(li);}
if(arr.length==0&&this.oP.shownoresults)
{var li=_b.DOM.cE("li",{className:"as_warning"},this.oP.noresults);ul.appendChild(li);}
div.appendChild(ul);var fcorner=_b.DOM.cE("div",{className:"as_corner"});var fbar=_b.DOM.cE("div",{className:"as_bar"});var footer=_b.DOM.cE("div",{className:"as_footer"});footer.appendChild(fcorner);footer.appendChild(fbar);div.appendChild(footer);var pos=_b.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(){pointer.killTimeout()};div.onmouseout=function(){pointer.resetTimeout()};document.getElementsByTagName("body")[0].appendChild(div);this.iHigh=0;var pointer=this;this.toID=setTimeout(function(){pointer.clearSuggestions()},this.oP.timeout);};_b.AutoSuggest.prototype.changeHighlight=function(key)
{var list=_b.DOM.gE("as_ul");if(!list)
return false;var n;if(key==40)
n=this.iHigh+1;else if(key==38)
n=this.iHigh-1;if(n>list.childNodes.length)
n=list.childNodes.length;if(n<1)
n=1;this.setHighlight(n);};_b.AutoSuggest.prototype.setHighlight=function(n)
{var list=_b.DOM.gE("as_ul");if(!list)
return false;if(this.iHigh>0)
this.clearHighlight();this.iHigh=Number(n);list.childNodes[this.iHigh-1].className="as_highlight";this.killTimeout();};_b.AutoSuggest.prototype.clearHighlight=function()
{var list=_b.DOM.gE("as_ul");if(!list)
return false;if(this.iHigh>0)
{list.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 pointer=this;this.toID=setTimeout(function(){pointer.clearSuggestions()},1000);};_b.AutoSuggest.prototype.clearSuggestions=function()

{this.killTimeout();var ele=_b.DOM.gE(this.idAs);var pointer=this;if(ele)
{var fade=new _b.Fader(ele,1,0,250,function(){_b.DOM.remE(pointer.idAs)});}};if(typeof(_b.Ajax)=="undefined")
_b.Ajax={};_b.Ajax=function()
{this.req={};this.isIE=false;};_b.Ajax.prototype.makeRequest=function(url,meth,onComp,onErr)
{if(meth!="POST")
meth="GET";this.onComplete=onComp;this.onError=onErr;var pointer=this;if(window.XMLHttpRequest)
{this.req=new XMLHttpRequest();this.req.onreadystatechange=function(){pointer.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(){pointer.processReqChange()};this.req.open(meth,url,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(type,attr,cont,html)
{var ne=document.createElement(type);if(!ne)
return 0;for(var a in attr)
ne[a]=attr[a];var t=typeof(cont);if(t=="string"&&!html)
ne.appendChild(document.createTextNode(cont));else if(t=="string"&&html)
ne.innerHTML=cont;else if(t=="object")
ne.appendChild(cont);return ne;};_b.DOM.gE=function(e)
{var t=typeof(e);if(t=="undefined")
return 0;else if(t=="string")
{var re=document.getElementById(e);if(!re)
return 0;else if(typeof(re.appendChild)!="undefined")
return re;else
return 0;}
else if(typeof(e.appendChild)!="undefined")
return e;else
return 0;};_b.DOM.remE=function(ele)
{var e=this.gE(ele);if(!e)
return 0;else if(e.parentNode.removeChild(e))
return true;else
return 0;};_b.DOM.getPos=function(e)
{var e=this.gE(e);var obj=e;var curleft=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curleft+=obj.offsetLeft;obj=obj.offsetParent;}}
else if(obj.x)
curleft+=obj.x;var obj=e;var curtop=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curtop+=obj.offsetTop;obj=obj.offsetParent;}}
else if(obj.y)
curtop+=obj.y;return{x:curleft,y:curtop};};if(typeof(_b.Fader)=="undefined")
_b.Fader={};_b.Fader=function(ele,from,to,fadetime,callback)
{if(!ele)
return 0;this.e=ele;this.from=from;this.to=to;this.cb=callback;this.nDur=fadetime;this.nInt=50;this.nTime=0;var p=this;this.nID=setInterval(function(){p._fade()},this.nInt);};_b.Fader.prototype._fade=function()
{this.nTime+=this.nInt;var ieop=Math.round(this._tween(this.nTime,this.from,this.to,this.nDur)*100);var op=ieop/100;if(this.e.filters)
{try
{this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity=ieop;}catch(e){this.e.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';}}
else
{this.e.style.opacity=op;}
if(this.nTime==this.nDur)
{clearInterval(this.nID);if(this.cb!=undefined)
this.cb();}};_b.Fader.prototype._tween=function(t,b,c,d)
{return b+((c-b)*(t/d));};