/*
 * jQuery 1.1.3.1 - New Wave Javascript
 *
 * Copyright (c) 2007 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2009-05-14 10:44:18 $
 * $Rev: 2243 $
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7(1g 18.6=="I"){18.I=18.I;u 6=q(a,c){7(18==9||!9.3X)v 14 6(a,c);v 9.3X(a,c)};7(1g $!="I")6.1I$=$;u $=6;6.11=6.8r={3X:q(a,c){a=a||P;7(6.16(a))v 14 6(P)[6.11.1G?"1G":"1W"](a);7(1g a=="1s"){u m=/^[^<]*(<(.|\\s)+>)[^>]*$/.1V(a);7(m)a=6.31([m[1]]);B v 14 6(c).1L(a)}v 9.4E(a.15==2b&&a||(a.3C||a.C&&a!=18&&!a.1q&&a[0]!=I&&a[0].1q)&&6.2L(a)||[a])},3C:"1.1.3.1",7W:q(){v 9.C},C:0,1M:q(a){v a==I?6.2L(9):9[a]},1Z:q(a){u b=6(a);b.5q=9;v b},4E:q(a){9.C=0;[].R.O(9,a);v 9},F:q(a,b){v 6.F(9,a,b)},2p:q(a){u b=-1;9.F(q(i){7(9==a)b=i});v b},1b:q(f,d,e){u c=f;7(f.15==33)7(d==I)v 9.C&&6[e||"1b"](9[0],f)||I;B{c={};c[f]=d}v 9.F(q(a){E(u b V c)6.1b(e?9.T:9,b,6.4H(9,c[b],e,a,b))})},1f:q(b,a){v 9.1b(b,a,"2z")},2A:q(e){7(1g e=="1s")v 9.2Y().3e(P.66(e));u t="";6.F(e||9,q(){6.F(9.2S,q(){7(9.1q!=8)t+=9.1q!=1?9.5R:6.11.2A([9])})});v t},8b:q(){u a,1S=19;v 9.F(q(){7(!a)a=6.31(1S,9.2O);u b=a[0].3s(K);9.L.2K(b,9);1v(b.1d)b=b.1d;b.4g(9)})},3e:q(){v 9.2F(19,K,1,q(a){9.4g(a)})},5w:q(){v 9.2F(19,K,-1,q(a){9.2K(a,9.1d)})},5t:q(){v 9.2F(19,N,1,q(a){9.L.2K(a,9)})},5s:q(){v 9.2F(19,N,-1,q(a){9.L.2K(a,9.1X)})},2U:q(){v 9.5q||6([])},1L:q(t){u b=6.3k(9,q(a){v 6.1L(t,a)});v 9.1Z(/[^+>] [^+>]/.17(t)||t.J("..")>-1?6.5g(b):b)},7x:q(e){u d=9.1A(9.1L("*"));d.F(q(){9.1I$1a={};E(u a V 9.$1a)9.1I$1a[a]=6.1c({},9.$1a[a])}).3U();u r=9.1Z(6.3k(9,q(a){v a.3s(e!=I?e:K)}));d.F(q(){u b=9.1I$1a;E(u a V b)E(u c V b[a])6.S.1A(9,a,b[a][c],b[a][c].W);9.1I$1a=H});v r},1i:q(t){v 9.1Z(6.16(t)&&6.2s(9,q(b,a){v t.O(b,[a])})||6.2x(t,9))},4Y:q(t){v 9.1Z(t.15==33&&6.2x(t,9,K)||6.2s(9,q(a){v(t.15==2b||t.3C)?6.2w(a,t)<0:a!=t}))},1A:q(t){v 9.1Z(6.1T(9.1M(),t.15==33?6(t).1M():t.C!=I&&(!t.Q||t.Q=="6Z")?t:[t]))},37:q(a){v a?6.2x(a,9).C>0:N},6R:q(a){v a==I?(9.C?9[0].2v:H):9.1b("2v",a)},3F:q(a){v a==I?(9.C?9[0].27:H):9.2Y().3e(a)},2F:q(f,d,g,e){u c=9.C>1,a;v 9.F(q(){7(!a){a=6.31(f,9.2O);7(g<0)a.6E()}u b=9;7(d&&6.Q(9,"1r")&&6.Q(a[0],"2V"))b=9.3R("1z")[0]||9.4g(P.5h("1z"));6.F(a,q(){e.O(b,[c?9.3s(K):9])})})}};6.1c=6.11.1c=q(){u c=19[0],a=1;7(19.C==1){c=9;a=0}u b;1v((b=19[a++])!=H)E(u i V b)c[i]=b[i];v c};6.1c({6n:q(){7(6.1I$)$=6.1I$;v 6},16:q(a){v!!a&&1g a!="1s"&&!a.Q&&a.15!=2b&&/q/i.17(a+"")},40:q(a){v a.4z&&a.2O&&!a.2O.4y},Q:q(b,a){v b.Q&&b.Q.1D()==a.1D()},F:q(a,b,c){7(a.C==I)E(u i V a)b.O(a[i],c||[i,a[i]]);B E(u i=0,4x=a.C;i<4x;i++)7(b.O(a[i],c||[i,a[i]])===N)1F;v a},4H:q(c,b,d,e,a){7(6.16(b))b=b.3D(c,[e]);u f=/z-?2p|5Y-?8p|1e|5U|8i-?1u/i;v b&&b.15==3y&&d=="2z"&&!f.17(a)?b+"4o":b},12:{1A:q(b,c){6.F(c.2R(/\\s+/),q(i,a){7(!6.12.3w(b.12,a))b.12+=(b.12?" ":"")+a})},1E:q(b,c){b.12=c!=I?6.2s(b.12.2R(/\\s+/),q(a){v!6.12.3w(c,a)}).5M(" "):""},3w:q(t,c){v 6.2w(c,(t.12||t).3v().2R(/\\s+/))>-1}},4m:q(e,o,f){E(u i V o){e.T["2N"+i]=e.T[i];e.T[i]=o[i]}f.O(e,[]);E(u i V o)e.T[i]=e.T["2N"+i]},1f:q(e,p){7(p=="1u"||p=="29"){u b={},3r,3p,d=["83","81","80","7Y"];6.F(d,q(){b["7V"+9]=0;b["7T"+9+"7S"]=0});6.4m(e,b,q(){7(6(e).37(\':4f\')){3r=e.7Q;3p=e.7O}B{e=6(e.3s(K)).1L(":4b").5v("2B").2U().1f({48:"1y",3i:"7L",U:"2h",7K:"0",7I:"0"}).5o(e.L)[0];u a=6.1f(e.L,"3i")||"3n";7(a=="3n")e.L.T.3i="7G";3r=e.7E;3p=e.7D;7(a=="3n")e.L.T.3i="3n";e.L.3q(e)}});v p=="1u"?3r:3p}v 6.2z(e,p)},2z:q(e,a,d){u g;7(a=="1e"&&6.M.1h){g=6.1b(e.T,"1e");v g==""?"1":g}7(a.3t(/3x/i))a=6.1U;7(!d&&e.T[a])g=e.T[a];B 7(P.3f&&P.3f.3Y){7(a.3t(/3x/i))a="3x";a=a.1o(/([A-Z])/g,"-$1").2H();u b=P.3f.3Y(e,H);7(b)g=b.57(a);B 7(a=="U")g="1P";B 6.4m(e,{U:"2h"},q(){u c=P.3f.3Y(9,"");g=c&&c.57(a)||""})}B 7(e.3S){u f=a.1o(/\\-(\\w)/g,q(m,c){v c.1D()});g=e.3S[a]||e.3S[f]}v g},31:q(a,c){u r=[];c=c||P;6.F(a,q(i,b){7(!b)v;7(b.15==3y)b=b.3v();7(1g b=="1s"){u s=6.2C(b).2H(),1x=c.5h("1x"),1N=[];u a=!s.J("<1H")&&[1,"<2y>","</2y>"]||!s.J("<7g")&&[1,"<52>","</52>"]||(!s.J("<7c")||!s.J("<1z")||!s.J("<7a")||!s.J("<78"))&&[1,"<1r>","</1r>"]||!s.J("<2V")&&[2,"<1r><1z>","</1z></1r>"]||(!s.J("<75")||!s.J("<74"))&&[3,"<1r><1z><2V>","</2V></1z></1r>"]||!s.J("<73")&&[2,"<1r><4W>","</4W></1r>"]||[0,"",""];1x.27=a[1]+b+a[2];1v(a[0]--)1x=1x.1d;7(6.M.1h){7(!s.J("<1r")&&s.J("<1z")<0)1N=1x.1d&&1x.1d.2S;B 7(a[1]=="<1r>"&&s.J("<1z")<0)1N=1x.2S;E(u n=1N.C-1;n>=0;--n)7(6.Q(1N[n],"1z")&&!1N[n].2S.C)1N[n].L.3q(1N[n])}b=6.2L(1x.2S)}7(0===b.C&&(!6.Q(b,"34")&&!6.Q(b,"2y")))v;7(b[0]==I||6.Q(b,"34")||b.71)r.R(b);B r=6.1T(r,b)});v r},1b:q(c,d,a){u e=6.40(c)?{}:6.3H;7(e[d]){7(a!=I)c[e[d]]=a;v c[e[d]]}B 7(a==I&&6.M.1h&&6.Q(c,"34")&&(d=="70"||d=="6Y"))v c.6W(d).5R;B 7(c.4z){7(a!=I)c.6U(d,a);7(6.M.1h&&/4M|2u/.17(d)&&!6.40(c))v c.35(d,2);v c.35(d)}B{7(d=="1e"&&6.M.1h){7(a!=I){c.5U=1;c.1i=(c.1i||"").1o(/4L\\([^)]*\\)/,"")+(39(a).3v()=="6M"?"":"4L(1e="+a*4X+")")}v c.1i?(39(c.1i.3t(/1e=([^)]*)/)[1])/4X).3v():""}d=d.1o(/-([a-z])/6K,q(z,b){v b.1D()});7(a!=I)c[d]=a;v c[d]}},2C:q(t){v t.1o(/^\\s+|\\s+$/g,"")},2L:q(a){u r=[];7(1g a!="6I")E(u i=0,26=a.C;i<26;i++)r.R(a[i]);B r=a.51(0);v r},2w:q(b,a){E(u i=0,26=a.C;i<26;i++)7(a[i]==b)v i;v-1},1T:q(a,b){E(u i=0;b[i];i++)a.R(b[i]);v a},5g:q(a){u r=[],3P=6.1k++;E(u i=0,4G=a.C;i<4G;i++)7(3P!=a[i].1k){a[i].1k=3P;r.R(a[i])}v r},1k:0,2s:q(c,b,d){7(1g b=="1s")b=14 45("a","i","v "+b);u a=[];E(u i=0,30=c.C;i<30;i++)7(!d&&b(c[i],i)||d&&!b(c[i],i))a.R(c[i]);v a},3k:q(c,b){7(1g b=="1s")b=14 45("a","v "+b);u d=[];E(u i=0,30=c.C;i<30;i++){u a=b(c[i],i);7(a!==H&&a!=I){7(a.15!=2b)a=[a];d=d.6v(a)}}v d}});14 q(){u b=6u.6t.2H();6.M={4D:(b.3t(/.+(?:6s|6q|6o|6m)[\\/: ]([\\d.]+)/)||[])[1],20:/5l/.17(b),2a:/2a/.17(b),1h:/1h/.17(b)&&!/2a/.17(b),3j:/3j/.17(b)&&!/(6h|5l)/.17(b)};6.6g=!6.M.1h||P.6f=="6c";6.1U=6.M.1h?"1U":"5x",6.3H={"E":"68","67":"12","3x":6.1U,5x:6.1U,1U:6.1U,27:"27",12:"12",2v:"2v",2r:"2r",2B:"2B",65:"63",2T:"2T",62:"5Z"}};6.F({4v:"a.L",4p:"6.4p(a)",8o:"6.22(a,2,\'1X\')",8n:"6.22(a,2,\'4t\')",8k:"6.4q(a.L.1d,a)",8h:"6.4q(a.1d)"},q(i,n){6.11[i]=q(a){u b=6.3k(9,n);7(a&&1g a=="1s")b=6.2x(a,b);v 9.1Z(b)}});6.F({5o:"3e",8g:"5w",2K:"5t",8f:"5s"},q(i,n){6.11[i]=q(){u a=19;v 9.F(q(){E(u j=0,26=a.C;j<26;j++)6(a[j])[n](9)})}});6.F({5v:q(a){6.1b(9,a,"");9.8d(a)},8c:q(c){6.12.1A(9,c)},88:q(c){6.12.1E(9,c)},87:q(c){6.12[6.12.3w(9,c)?"1E":"1A"](9,c)},1E:q(a){7(!a||6.1i(a,[9]).r.C)9.L.3q(9)},2Y:q(){1v(9.1d)9.3q(9.1d)}},q(i,n){6.11[i]=q(){v 9.F(n,19)}});6.F(["5Q","5P","5O","5N"],q(i,n){6.11[n]=q(a,b){v 9.1i(":"+n+"("+a+")",b)}});6.F(["1u","29"],q(i,n){6.11[n]=q(h){v h==I?(9.C?6.1f(9[0],n):H):9.1f(n,h.15==33?h:h+"4o")}});6.1c({4n:{"":"m[2]==\'*\'||6.Q(a,m[2])","#":"a.35(\'2m\')==m[2]",":":{5P:"i<m[3]-0",5O:"i>m[3]-0",22:"m[3]-0==i",5Q:"m[3]-0==i",2Q:"i==0",2P:"i==r.C-1",5L:"i%2==0",5K:"i%2","2Q-3u":"a.L.3R(\'*\')[0]==a","2P-3u":"6.22(a.L.5J,1,\'4t\')==a","86-3u":"!6.22(a.L.5J,2,\'4t\')",4v:"a.1d",2Y:"!a.1d",5N:"(a.5H||a.85||\'\').J(m[3])>=0",4f:\'"1y"!=a.G&&6.1f(a,"U")!="1P"&&6.1f(a,"48")!="1y"\',1y:\'"1y"==a.G||6.1f(a,"U")=="1P"||6.1f(a,"48")=="1y"\',84:"!a.2r",2r:"a.2r",2B:"a.2B",2T:"a.2T||6.1b(a,\'2T\')",2A:"\'2A\'==a.G",4b:"\'4b\'==a.G",5F:"\'5F\'==a.G",4l:"\'4l\'==a.G",5E:"\'5E\'==a.G",4k:"\'4k\'==a.G",5D:"\'5D\'==a.G",5C:"\'5C\'==a.G",1J:\'"1J"==a.G||6.Q(a,"1J")\',5B:"/5B|2y|82|1J/i.17(a.Q)"},"[":"6.1L(m[2],a).C"},5A:[/^\\[ *(@)([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(\\[)\\s*(.*?(\\[.*?\\])?[^[]*?)\\s*\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,14 3o("^([:.#]*)("+(6.2J=6.M.20&&6.M.4D<"3.0.0"?"\\\\w":"(?:[\\\\w\\7Z-\\7X*1I-]|\\\\\\\\.)")+"+)")],2x:q(a,c,b){u d,1K=[];1v(a&&a!=d){d=a;u f=6.1i(a,c,b);a=f.t.1o(/^\\s*,\\s*/,"");1K=b?c=f.r:6.1T(1K,f.r)}v 1K},1L:q(t,l){7(1g t!="1s")v[t];7(l&&!l.1q)l=H;l=l||P;7(!t.J("//")){l=l.4h;t=t.2G(2,t.C)}B 7(!t.J("/")&&!l.2O){l=l.4h;t=t.2G(1,t.C);7(t.J("/")>=1)t=t.2G(t.J("/"),t.C)}u b=[l],2j=[],2P;1v(t&&2P!=t){u r=[];2P=t;t=6.2C(t).1o(/^\\/\\//,"");u k=N;u g=14 3o("^[/>]\\\\s*("+6.2J+"+)");u m=g.1V(t);7(m){u o=m[1].1D();E(u i=0;b[i];i++)E(u c=b[i].1d;c;c=c.1X)7(c.1q==1&&(o=="*"||c.Q.1D()==o.1D()))r.R(c);b=r;t=t.1o(g,"");7(t.J(" ")==0)7R;k=K}B{g=/^((\\/?\\.\\.)|([>\\/+~]))\\s*([a-z]*)/i;7((m=g.1V(t))!=H){r=[];u o=m[4],1k=6.1k++;m=m[1];E(u j=0,2e=b.C;j<2e;j++)7(m.J("..")<0){u n=m=="~"||m=="+"?b[j].1X:b[j].1d;E(;n;n=n.1X)7(n.1q==1){7(m=="~"&&n.1k==1k)1F;7(!o||n.Q.1D()==o.1D()){7(m=="~")n.1k=1k;r.R(n)}7(m=="+")1F}}B r.R(b[j].L);b=r;t=6.2C(t.1o(g,""));k=K}}7(t&&!k){7(!t.J(",")){7(l==b[0])b.4e();2j=6.1T(2j,b);r=b=[l];t=" "+t.2G(1,t.C)}B{u h=14 3o("^("+6.2J+"+)(#)("+6.2J+"+)");u m=h.1V(t);7(m){m=[0,m[2],m[3],m[1]]}B{h=14 3o("^([#.]?)("+6.2J+"*)");m=h.1V(t)}m[2]=m[2].1o(/\\\\/g,"");u f=b[b.C-1];7(m[1]=="#"&&f&&f.4d){u p=f.4d(m[2]);7((6.M.1h||6.M.2a)&&p&&1g p.2m=="1s"&&p.2m!=m[2])p=6(\'[@2m="\'+m[2]+\'"]\',f)[0];b=r=p&&(!m[3]||6.Q(p,m[3]))?[p]:[]}B{E(u i=0;b[i];i++){u a=m[1]!=""||m[0]==""?"*":m[2];7(a=="*"&&b[i].Q.2H()=="7P")a="2E";r=6.1T(r,b[i].3R(a))}7(m[1]==".")r=6.4c(r,m[2]);7(m[1]=="#"){u e=[];E(u i=0;r[i];i++)7(r[i].35("2m")==m[2]){e=[r[i]];1F}r=e}b=r}t=t.1o(h,"")}}7(t){u d=6.1i(t,r);b=r=d.r;t=6.2C(d.t)}}7(t)b=[];7(b&&l==b[0])b.4e();2j=6.1T(2j,b);v 2j},4c:q(r,m,a){m=" "+m+" ";u b=[];E(u i=0;r[i];i++){u c=(" "+r[i].12+" ").J(m)>=0;7(!a&&c||a&&!c)b.R(r[i])}v b},1i:q(t,r,h){u d;1v(t&&t!=d){d=t;u p=6.5A,m;E(u i=0;p[i];i++){m=p[i].1V(t);7(m){t=t.7N(m[0].C);m[2]=m[2].1o(/\\\\/g,"");1F}}7(!m)1F;7(m[1]==":"&&m[2]=="4Y")r=6.1i(m[3],r,K).r;B 7(m[1]==".")r=6.4c(r,m[2],h);B 7(m[1]=="@"){u g=[],G=m[3];E(u i=0,2e=r.C;i<2e;i++){u a=r[i],z=a[6.3H[m[2]]||m[2]];7(z==H||/4M|2u/.17(m[2]))z=6.1b(a,m[2])||\'\';7((G==""&&!!z||G=="="&&z==m[5]||G=="!="&&z!=m[5]||G=="^="&&z&&!z.J(m[5])||G=="$="&&z.2G(z.C-m[5].C)==m[5]||(G=="*="||G=="~=")&&z.J(m[5])>=0)^h)g.R(a)}r=g}B 7(m[1]==":"&&m[2]=="22-3u"){u e=6.1k++,g=[],17=/(\\d*)n\\+?(\\d*)/.1V(m[3]=="5L"&&"2n"||m[3]=="5K"&&"2n+1"||!/\\D/.17(m[3])&&"n+"+m[3]||m[3]),2Q=(17[1]||1)-0,d=17[2]-0;E(u i=0,2e=r.C;i<2e;i++){u j=r[i],L=j.L;7(e!=L.1k){u c=1;E(u n=L.1d;n;n=n.1X)7(n.1q==1)n.4a=c++;L.1k=e}u b=N;7(2Q==1){7(d==0||j.4a==d)b=K}B 7((j.4a+d)%2Q==0)b=K;7(b^h)g.R(j)}r=g}B{u f=6.4n[m[1]];7(1g f!="1s")f=6.4n[m[1]][m[2]];49("f = q(a,i){v "+f+"}");r=6.2s(r,f,h)}}v{r:r,t:t}},4p:q(c){u b=[];u a=c.L;1v(a&&a!=P){b.R(a);a=a.L}v b},22:q(a,e,c,b){e=e||1;u d=0;E(;a;a=a[c])7(a.1q==1&&++d==e)1F;v a},4q:q(n,a){u r=[];E(;n;n=n.1X){7(n.1q==1&&(!a||n!=a))r.R(n)}v r}});6.S={1A:q(d,e,c,b){7(6.M.1h&&d.3m!=I)d=18;7(!c.1Q)c.1Q=9.1Q++;7(b!=I){u f=c;c=q(){v f.O(9,19)};c.W=b;c.1Q=f.1Q}7(!d.$1a)d.$1a={};7(!d.$1p)d.$1p=q(){u a;7(1g 6=="I"||6.S.47)v a;a=6.S.1p.O(d,19);v a};u g=d.$1a[e];7(!g){g=d.$1a[e]={};7(d.46)d.46(e,d.$1p,N);B d.7M("5r"+e,d.$1p)}g[c.1Q]=c;7(!9.Y[e])9.Y[e]=[];7(6.2w(d,9.Y[e])==-1)9.Y[e].R(d)},1Q:1,Y:{},1E:q(b,c,a){u d=b.$1a,1Y,2p;7(d){7(c&&c.G){a=c.44;c=c.G}7(!c){E(c V d)9.1E(b,c)}B 7(d[c]){7(a)3l d[c][a.1Q];B E(a V b.$1a[c])3l d[c][a];E(1Y V d[c])1F;7(!1Y){7(b.43)b.43(c,b.$1p,N);B b.7J("5r"+c,b.$1p);1Y=H;3l d[c];1v(9.Y[c]&&((2p=6.2w(b,9.Y[c]))>=0))3l 9.Y[c][2p]}}E(1Y V d)1F;7(!1Y)b.$1p=b.$1a=H}},1t:q(c,b,d){b=6.2L(b||[]);7(!d)6.F(9.Y[c]||[],q(){6.S.1t(c,b,9)});B{u a,1Y,11=6.16(d[c]||H);b.5p(9.42({G:c,1O:d}));7(6.16(d.$1p)&&(a=d.$1p.O(d,b))!==N)9.47=K;7(11&&a!==N&&!6.Q(d,\'a\'))d[c]();9.47=N}},1p:q(b){u a;b=6.S.42(b||18.S||{});u c=9.$1a&&9.$1a[b.G],1S=[].51.3D(19,1);1S.5p(b);E(u j V c){1S[0].44=c[j];1S[0].W=c[j].W;7(c[j].O(9,1S)===N){b.2d();b.2D();a=N}}7(6.M.1h)b.1O=b.2d=b.2D=b.44=b.W=H;v a},42:q(c){u a=c;c=6.1c({},a);c.2d=q(){7(a.2d)v a.2d();a.7H=N};c.2D=q(){7(a.2D)v a.2D();a.7F=K};7(!c.1O&&c.5n)c.1O=c.5n;7(6.M.20&&c.1O.1q==3)c.1O=a.1O.L;7(!c.41&&c.4j)c.41=c.4j==c.1O?c.7C:c.4j;7(c.5k==H&&c.5j!=H){u e=P.4h,b=P.4y;c.5k=c.5j+(e&&e.5i||b.5i);c.7z=c.7y+(e&&e.5f||b.5f)}7(!c.3h&&(c.5e||c.5d))c.3h=c.5e||c.5d;7(!c.5c&&c.5b)c.5c=c.5b;7(!c.3h&&c.1J)c.3h=(c.1J&1?1:(c.1J&2?3:(c.1J&4?2:0)));v c}};6.11.1c({3g:q(c,a,b){v c=="3z"?9.3Z(c,a,b):9.F(q(){6.S.1A(9,c,b||a,b&&a)})},3Z:q(d,b,c){v 9.F(q(){6.S.1A(9,d,q(a){6(9).3U(a);v(c||b).O(9,19)},c&&b)})},3U:q(a,b){v 9.F(q(){6.S.1E(9,a,b)})},1t:q(a,b){v 9.F(q(){6.S.1t(a,b,9)})},1R:q(){u a=19;v 9.5a(q(e){9.4u=0==9.4u?1:0;e.2d();v a[9.4u].O(9,[e])||N})},7w:q(f,g){q 3W(e){u p=e.41;1v(p&&p!=9)2g{p=p.L}25(e){p=9};7(p==9)v N;v(e.G=="3V"?f:g).O(9,[e])}v 9.3V(3W).59(3W)},1G:q(f){7(6.3d)f.O(P,[6]);B 6.2q.R(q(){v f.O(9,[6])});v 9}});6.1c({3d:N,2q:[],1G:q(){7(!6.3d){6.3d=K;7(6.2q){6.F(6.2q,q(){9.O(P)});6.2q=H}7(6.M.3j||6.M.2a)P.43("58",6.1G,N);7(!18.7v.C)6(18).1W(q(){6("#3T").1E()})}}});14 q(){6.F(("7u,7t,1W,7s,7r,3z,5a,7q,"+"7p,7o,7n,3V,59,7m,2y,"+"4k,7l,7k,7j,2c").2R(","),q(i,o){6.11[o]=q(f){v f?9.3g(o,f):9.1t(o)}});7(6.M.3j||6.M.2a)P.46("58",6.1G,N);B 7(6.M.1h){P.7i("<7h"+"7f 2m=3T 7e=K "+"2u=//:><\\/3b>");u a=P.4d("3T");7(a)a.7d=q(){7(9.3a!="1n")v;6.1G()};a=H}B 7(6.M.20)6.3N=3m(q(){7(P.3a=="79"||P.3a=="1n"){3M(6.3N);6.3N=H;6.1G()}},10);6.S.1A(18,"1W",6.1G)};7(6.M.1h)6(18).3Z("3z",q(){u a=6.S.Y;E(u b V a){u c=a[b],i=c.C;7(i&&b!=\'3z\')77 c[i-1]&&6.S.1E(c[i-1],b);1v(--i)}});6.11.1c({76:q(c,b,a){9.1W(c,b,a,1)},1W:q(g,d,c,e){7(6.16(g))v 9.3g("1W",g);c=c||q(){};u f="3K";7(d)7(6.16(d)){c=d;d=H}B{d=6.2E(d);f="50"}u h=9;6.2Z({1C:g,G:f,W:d,2t:e,1n:q(a,b){7(b=="28"||!e&&b=="4V")h.1b("27",a.3c).3J().F(c,[a.3c,b,a]);B c.O(h,[a.3c,b,a])}});v 9},72:q(){v 6.2E(9)},3J:q(){v 9.1L("3b").F(q(){7(9.2u)6.4U(9.2u);B 6.3I(9.2A||9.5H||9.27||"")}).2U()}});6.F("4T,4I,4S,4R,4Q,4P".2R(","),q(i,o){6.11[o]=q(f){v 9.3g(o,f)}});6.1c({1M:q(e,c,a,d,b){7(6.16(c)){a=c;c=H}v 6.2Z({G:"3K",1C:e,W:c,28:a,3G:d,2t:b})},6X:q(d,b,a,c){v 6.1M(d,b,a,c,1)},4U:q(b,a){v 6.1M(b,H,a,"3b")},6V:q(c,b,a){v 6.1M(c,b,a,"4N")},6T:q(d,b,a,c){7(6.16(b)){a=b;b={}}v 6.2Z({G:"50",1C:d,W:b,28:a,3G:c})},6S:q(a){6.36.21=a},6Q:q(a){6.1c(6.36,a)},36:{Y:K,G:"3K",21:0,4O:"6P/x-6O-34-6N",4K:K,38:K,W:H},32:{},2Z:q(s){s=6.1c({},6.36,s);7(s.W){7(s.4K&&1g s.W!="1s")s.W=6.2E(s.W);7(s.G.2H()=="1M"){s.1C+=((s.1C.J("?")>-1)?"&":"?")+s.W;s.W=H}}7(s.Y&&!6.3L++)6.S.1t("4T");u f=N;u h=18.4Z?14 4Z("6L.6J"):14 4J();h.7b(s.G,s.1C,s.38);7(s.W)h.3Q("6H-6G",s.4O);7(s.2t)h.3Q("6F-3O-6D",6.32[s.1C]||"6C, 6B 6A 6z 4r:4r:4r 6y");h.3Q("X-6x-6w","4J");7(s.56)s.56(h);7(s.Y)6.S.1t("4P",[h,s]);u g=q(d){7(h&&(h.3a==4||d=="21")){f=K;7(i){3M(i);i=H}u c;2g{c=6.54(h)&&d!="21"?s.2t&&6.4F(h,s.1C)?"4V":"28":"2c";7(c!="2c"){u b;2g{b=h.3E("53-3O")}25(e){}7(s.2t&&b)6.32[s.1C]=b;u a=6.55(h,s.3G);7(s.28)s.28(a,c);7(s.Y)6.S.1t("4Q",[h,s])}B 6.2X(s,h,c)}25(e){c="2c";6.2X(s,h,c,e)}7(s.Y)6.S.1t("4S",[h,s]);7(s.Y&&!--6.3L)6.S.1t("4I");7(s.1n)s.1n(h,c);7(s.38)h=H}};u i=3m(g,13);7(s.21>0)4C(q(){7(h){h.6r();7(!f)g("21")}},s.21);2g{h.6p(s.W)}25(e){6.2X(s,h,H,e)}7(!s.38)g();v h},2X:q(s,a,b,e){7(s.2c)s.2c(a,b,e);7(s.Y)6.S.1t("4R",[a,s,e])},3L:0,54:q(r){2g{v!r.23&&7A.7B=="4l:"||(r.23>=5u&&r.23<6l)||r.23==5m||6.M.20&&r.23==I}25(e){}v N},4F:q(a,c){2g{u b=a.3E("53-3O");v a.23==5m||b==6.32[c]||6.M.20&&a.23==I}25(e){}v N},55:q(r,b){u c=r.3E("6k-G");u a=!b&&c&&c.J("4B")>=0;a=b=="4B"||a?r.6j:r.3c;7(b=="3b")6.3I(a);7(b=="4N")a=49("("+a+")");7(b=="3F")6("<1x>").3F(a).3J();v a},2E:q(a){u s=[];7(a.15==2b||a.3C)6.F(a,q(){s.R(2l(9.6i)+"="+2l(9.2v))});B E(u j V a)7(a[j]&&a[j].15==2b)6.F(a[j],q(){s.R(2l(j)+"="+2l(9))});B s.R(2l(j)+"="+2l(a[j]));v s.5M("&")},3I:q(a){7(18.4A)18.4A(a);B 7(6.M.20)18.4C(a,0);B 49.3D(18,a)}});6.11.1c({1m:q(b,a){v b?9.1w({1u:"1m",29:"1m",1e:"1m"},b,a):9.1i(":1y").F(q(){9.T.U=9.2i?9.2i:"";7(6.1f(9,"U")=="1P")9.T.U="2h"}).2U()},1j:q(b,a){v b?9.1w({1u:"1j",29:"1j",1e:"1j"},b,a):9.1i(":4f").F(q(){9.2i=9.2i||6.1f(9,"U");7(9.2i=="1P")9.2i="2h";9.T.U="1P"}).2U()},5G:6.11.1R,1R:q(a,b){v 6.16(a)&&6.16(b)?9.5G(a,b):a?9.1w({1u:"1R",29:"1R",1e:"1R"},a,b):9.F(q(){6(9)[6(9).37(":1y")?"1m":"1j"]()})},6e:q(b,a){v 9.1w({1u:"1m"},b,a)},6d:q(b,a){v 9.1w({1u:"1j"},b,a)},6b:q(b,a){v 9.1w({1u:"1R"},b,a)},6a:q(b,a){v 9.1w({1e:"1m"},b,a)},69:q(b,a){v 9.1w({1e:"1j"},b,a)},7U:q(c,a,b){v 9.1w({1e:a},c,b)},1w:q(d,h,f,g){v 9.1l(q(){u c=6(9).37(":1y"),1H=6.5z(h,f,g),5y=9;E(u p V d){7(d[p]=="1j"&&c||d[p]=="1m"&&!c)v 6.16(1H.1n)&&1H.1n.O(9);7(p=="1u"||p=="29"){1H.U=6.1f(9,"U");1H.2f=9.T.2f}}7(1H.2f!=H)9.T.2f="1y";9.2k=6.1c({},d);6.F(d,q(a,b){u e=14 6.2M(5y,1H,a);7(b.15==3y)e.2W(e.1K(),b);B e[b=="1R"?c?"1m":"1j":b](d)})})},1l:q(a,b){7(!b){b=a;a="2M"}v 9.F(q(){7(!9.1l)9.1l={};7(!9.1l[a])9.1l[a]=[];9.1l[a].R(b);7(9.1l[a].C==1)b.O(9)})}});6.1c({5z:q(b,a,c){u d=b&&b.15==64?b:{1n:c||!c&&a||6.16(b)&&b,1B:b,2I:c&&a||a&&a.15!=45&&a||(6.2I.4i?"4i":"4w")};d.1B=(d.1B&&d.1B.15==3y?d.1B:{61:60,89:5u}[d.1B])||8a;d.2N=d.1n;d.1n=q(){6.5I(9,"2M");7(6.16(d.2N))d.2N.O(9)};v d},2I:{4w:q(p,n,b,a){v b+a*p},4i:q(p,n,b,a){v((-5W.5X(p*5W.8e)/2)+0.5)*a+b}},1l:{},5I:q(b,a){a=a||"2M";7(b.1l&&b.1l[a]){b.1l[a].4e();u f=b.1l[a][0];7(f)f.O(b)}},3B:[],2M:q(f,e,g){u z=9;u y=f.T;z.a=q(){7(e.3A)e.3A.O(f,[z.2o]);7(g=="1e")6.1b(y,"1e",z.2o);B{y[g]=8m(z.2o)+"4o";y.U="2h"}};z.5V=q(){v 39(6.1f(f,g))};z.1K=q(){u r=39(6.2z(f,g));v r&&r>-8l?r:z.5V()};z.2W=q(c,b){z.4s=(14 5T()).5S();z.2o=c;z.a();6.3B.R(q(){v z.3A(c,b)});7(6.3B.C==1){u d=3m(q(){u a=6.3B;E(u i=0;i<a.C;i++)7(!a[i]())a.8j(i--,1);7(!a.C)3M(d)},13)}};z.1m=q(){7(!f.24)f.24={};f.24[g]=6.1b(f.T,g);e.1m=K;z.2W(0,9.1K());7(g!="1e")y[g]="8q";6(f).1m()};z.1j=q(){7(!f.24)f.24={};f.24[g]=6.1b(f.T,g);e.1j=K;z.2W(9.1K(),0)};z.3A=q(a,c){u t=(14 5T()).5S();7(t>e.1B+z.4s){z.2o=c;z.a();7(f.2k)f.2k[g]=K;u b=K;E(u i V f.2k)7(f.2k[i]!==K)b=N;7(b){7(e.U!=H){y.2f=e.2f;y.U=e.U;7(6.1f(f,"U")=="1P")y.U="2h"}7(e.1j)y.U="1P";7(e.1j||e.1m)E(u p V f.2k)6.1b(y,p,f.24[p])}7(b&&6.16(e.1n))e.1n.O(f);v N}B{u n=t-9.4s;u p=n/e.1B;z.2o=6.2I[e.2I](p,n,a,(c-a),e.1B);z.a()}v K}}})}',62,524,'||||||jQuery|if||this|||||||||||||||||function||||var|return||||||else|length||for|each|type|null|undefined|indexOf|true|parentNode|browser|false|apply|document|nodeName|push|event|style|display|in|data||global|||fn|className||new|constructor|isFunction|test|window|arguments|events|attr|extend|firstChild|opacity|css|typeof|msie|filter|hide|mergeNum|queue|show|complete|replace|handle|nodeType|table|string|trigger|height|while|animate|div|hidden|tbody|add|duration|url|toUpperCase|remove|break|ready|opt|_|button|cur|find|get|tb|target|none|guid|toggle|args|merge|styleFloat|exec|load|nextSibling|ret|pushStack|safari|timeout|nth|status|orig|catch|al|innerHTML|success|width|opera|Array|error|preventDefault|rl|overflow|try|block|oldblock|done|curAnim|encodeURIComponent|id||now|index|readyList|disabled|grep|ifModified|src|value|inArray|multiFilter|select|curCSS|text|checked|trim|stopPropagation|param|domManip|substr|toLowerCase|easing|chars|insertBefore|makeArray|fx|old|ownerDocument|last|first|split|childNodes|selected|end|tr|custom|handleError|empty|ajax|el|clean|lastModified|String|form|getAttribute|ajaxSettings|is|async|parseFloat|readyState|script|responseText|isReady|append|defaultView|bind|which|position|mozilla|map|delete|setInterval|static|RegExp|oWidth|removeChild|oHeight|cloneNode|match|child|toString|has|float|Number|unload|step|timers|jquery|call|getResponseHeader|html|dataType|props|globalEval|evalScripts|GET|active|clearInterval|safariTimer|Modified|num|setRequestHeader|getElementsByTagName|currentStyle|__ie_init|unbind|mouseover|handleHover|init|getComputedStyle|one|isXMLDoc|relatedTarget|fix|removeEventListener|handler|Function|addEventListener|triggered|visibility|eval|nodeIndex|radio|classFilter|getElementById|shift|visible|appendChild|documentElement|swing|fromElement|submit|file|swap|expr|px|parents|sibling|00|startTime|previousSibling|lastToggle|parent|linear|ol|body|tagName|execScript|xml|setTimeout|version|setArray|httpNotModified|fl|prop|ajaxStop|XMLHttpRequest|processData|alpha|href|json|contentType|ajaxSend|ajaxSuccess|ajaxError|ajaxComplete|ajaxStart|getScript|notmodified|colgroup|100|not|ActiveXObject|POST|slice|fieldset|Last|httpSuccess|httpData|beforeSend|getPropertyValue|DOMContentLoaded|mouseout|click|ctrlKey|metaKey|keyCode|charCode|scrollTop|unique|createElement|scrollLeft|clientX|pageX|webkit|304|srcElement|appendTo|unshift|prevObject|on|after|before|200|removeAttr|prepend|cssFloat|self|speed|parse|input|reset|image|password|checkbox|_toggle|textContent|dequeue|lastChild|odd|even|join|contains|gt|lt|eq|nodeValue|getTime|Date|zoom|max|Math|cos|font|maxLength|600|slow|maxlength|readOnly|Object|readonly|createTextNode|class|htmlFor|fadeOut|fadeIn|slideToggle|CSS1Compat|slideUp|slideDown|compatMode|boxModel|compatible|name|responseXML|content|300|ie|noConflict|ra|send|it|abort|rv|userAgent|navigator|concat|With|Requested|GMT|1970|Jan|01|Thu|Since|reverse|If|Type|Content|array|XMLHTTP|ig|Microsoft|NaN|urlencoded|www|application|ajaxSetup|val|ajaxTimeout|post|setAttribute|getJSON|getAttributeNode|getIfModified|method|FORM|action|options|serialize|col|th|td|loadIfModified|do|colg|loaded|tfoot|open|thead|onreadystatechange|defer|ipt|leg|scr|write|keyup|keypress|keydown|change|mousemove|mouseup|mousedown|dblclick|scroll|resize|focus|blur|frames|hover|clone|clientY|pageY|location|protocol|toElement|clientWidth|clientHeight|cancelBubble|relative|returnValue|left|detachEvent|right|absolute|attachEvent|substring|offsetWidth|object|offsetHeight|continue|Width|border|fadeTo|padding|size|uFFFF|Left|u0128|Right|Bottom|textarea|Top|enabled|innerText|only|toggleClass|removeClass|fast|400|wrap|addClass|removeAttribute|PI|insertAfter|prependTo|children|line|splice|siblings|10000|parseInt|prev|next|weight|1px|prototype'.split('|'),0,{}));

// Add the 'contents' method, for retrieving the contents of an iframe, as found in jQuery 1.2
// (We need this for refreshing the recaptcha widget when commenting as a not-logged-in user)
// TODO:WV:20090512:This can't cope with > 1 element in the jquery collection, so could be adapated for that.  No need atm.
jQuery.fn.contents = function() {
	var el = this.get(0);
	if (el.tagName.toLowerCase() == "iframe") {
		return jQuery(el.contentDocument||el.contentWindow.document);
	} else {
		return this;
	}
}
jQuery.fn.height = function() {
	if ( this.get(0) == window )
		return self.innerHeight ||
			jQuery.boxModel && document.documentElement.clientHeight ||
			document.body.clientHeight;
	
	if ( this.get(0) == document )
		return Math.max( document.body.scrollHeight, document.body.offsetHeight );
	
	return this.css("height", arguments[0]);
};
jQuery.fn.width = function() {
	if ( this.get(0) == window )
		return self.innerWidth ||
			jQuery.boxModel && document.documentElement.clientWidth ||
			document.body.clientWidth;
	
	if ( this.get(0) == document )
		return Math.max( document.body.scrollWidth, document.body.offsetWidth );
	
	return this.css("width", arguments[0]);
};
jQuery.fn.innerHeight = function() {
	return this.get(0) == window || this.get(0) == document ?
		this.height() :
		this.get(0).offsetHeight - parseInt(this.css("borderTop") || 0) - parseInt(this.css("borderBottom") || 0);
};
jQuery.fn.innerWidth = function() {
	return this.get(0) == window || this.get(0) == document ?
		this.width() :
		this.get(0).offsetWidth - parseInt(this.css("borderLeft") || 0) - parseInt(this.css("borderRight") || 0);
};
jQuery.fn.outerHeight = function() {
	return this.get(0) == window || this.get(0) == document ?
		this.height() :
		this.get(0).offsetHeight;	
};
jQuery.fn.outerWidth = function() {
	return this.get(0) == window || this.get(0) == document ?
		this.width() :
		this.get(0).offsetWidth;	
};
jQuery.fn.scrollLeft = function() {
	if ( this.get(0) == window || this.get(0) == document )
		return self.pageXOffset ||
			jQuery.boxModel && document.documentElement.scrollLeft ||
			document.body.scrollLeft;
	
	return this.get(0).scrollLeft;
};
jQuery.fn.scrollTop = function() {
	if ( this.get(0) == window || this.get(0) == document )
		return self.pageYOffset ||
			jQuery.boxModel && document.documentElement.scrollTop ||
			document.body.scrollTop;

	return this.get(0).scrollTop;
};
jQuery.fn.offset = function(refElem) {
	if (!this[0]) throw 'jQuery.fn.offset requires an element.';

	refElem = (refElem) ? jQuery(refElem)[0] : null;
	var x = 0, y = 0, elem = this[0], parent = this[0], sl = 0, st = 0;
	do {
		if (parent.tagName == 'BODY' || parent.tagName == 'HTML') {
			// Safari and IE don't add margin for static and relative
			if ((jQuery.browser.safari || jQuery.browser.msie) && jQuery.css(parent, 'position') != 'absolute') {
				x += parseInt(jQuery.css(parent, 'marginLeft')) || 0;
				y += parseInt(jQuery.css(parent, 'marginTop'))  || 0;
			}
			break;
		}

		x += parent.offsetLeft || 0;
		y += parent.offsetTop  || 0;

		// Mozilla and IE do not add the border
		if (jQuery.browser.mozilla || jQuery.browser.msie) {
			x += parseInt(jQuery.css(parent, 'borderLeftWidth')) || 0;
			y += parseInt(jQuery.css(parent, 'borderTopWidth'))  || 0;
		}

		// Mozilla removes the border if the parent has overflow hidden
		if (jQuery.browser.mozilla && jQuery.css(parent, 'overflow') == 'hidden') {
			x += parseInt(jQuery.css(parent, 'borderLeftWidth')) || 0;
			y += parseInt(jQuery.css(parent, 'borderTopWidth'))  || 0;
		}

		// Need to get scroll offsets in-between offsetParents
		var op = parent.offsetParent;
		do {
			sl += parent.scrollLeft || 0;
			st += parent.scrollTop  || 0;
			parent = parent.parentNode;
		} while (parent != op);
	} while (parent);

	if (refElem) { // Get the relative offset
		var offset = jQuery(refElem).offset();
		x  = x  - offset.left;
		y  = y  - offset.top;
		sl = sl - offset.scrollLeft;
		st = st - offset.scrollTop;
	}

	// Safari and Opera do not add the border for the element
	if (jQuery.browser.safari || jQuery.browser.opera) {
		x += parseInt(jQuery.css(elem, 'borderLeftWidth')) || 0;
		y += parseInt(jQuery.css(elem, 'borderTopWidth'))  || 0;
	}

	return {
		top:  y - st,
		left: x - sl,
		width:  elem.offsetWidth,
		height: elem.offsetHeight,
		borderTop:  parseInt(jQuery.css(elem, 'borderTopWidth'))  || 0,
		borderLeft: parseInt(jQuery.css(elem, 'borderLeftWidth')) || 0,
		marginTop:  parseInt(jQuery.css(elem, 'marginTopWidth'))  || 0,
		marginLeft: parseInt(jQuery.css(elem, 'marginLeftWidth')) || 0,
		scrollTop:  st,
		scrollLeft: sl,
		pageYOffset: window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop  || 0,
		pageXOffset: window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0
	};
};/*
 * Interface elements for jQuery - http://interface.eyecon.ro
 *
 * Copyright (c) 2006 Stefan Petre
 * Dual licensed under the MIT (MIT-LICENSE.txt) 
 * and GPL (GPL-LICENSE.txt) licenses.
 */
 
 /* Assanka change: not the full interface plugin, but downloaded from http://interface.eyecon.ro/download
  * with the following options:
  *  - Resizables
  *  - Everything from the Effects column
  */
  
 eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('6.1w={4Q:d(e){G x=0;G y=0;G 2D=1k;G 1c=e.1r;f(6(e).D(\'18\')==\'1i\'){2T=1c.1T;4R=1c.O;1c.1T=\'2A\';1c.18=\'2I\';1c.O=\'23\';2D=22}G 8=e;48(8){x+=8.6t+(8.3I&&!6.5t.6v?R(8.3I.2F)||0:0);y+=8.6n+(8.3I&&!6.5t.6v?R(8.3I.2t)||0:0);8=8.6p}8=e;48(8&&8.4q&&8.4q.4y()!=\'1F\'){x-=8.3R||0;y-=8.3b||0;8=8.3M}f(2D){1c.18=\'1i\';1c.O=4R;1c.1T=2T}E{x:x,y:y}},7J:d(8){G x=0,y=0;48(8){x+=8.6t||0;y+=8.6n||0;8=8.6p}E{x:x,y:y}},30:d(e){G w=6.D(e,\'T\');G h=6.D(e,\'L\');G 1s=0;G 1u=0;G 1c=e.1r;f(6(e).D(\'18\')!=\'1i\'){1s=e.4K;1u=e.4O}M{2T=1c.1T;4R=1c.O;1c.1T=\'2A\';1c.18=\'2I\';1c.O=\'23\';1s=e.4K;1u=e.4O;1c.18=\'1i\';1c.O=4R;1c.1T=2T}E{w:w,h:h,1s:1s,1u:1u}},7G:d(8){E{1s:8.4K||0,1u:8.4O||0}},7C:d(e){G h,w,3y;f(e){w=e.4f;h=e.4d}M{3y=1a.2j;w=3v.5M||5b.5M||(3y&&3y.4f)||1a.1F.4f;h=3v.5H||5b.5H||(3y&&3y.4d)||1a.1F.4d}E{w:w,h:h}},5V:d(e){G t,l,w,h,2Q,2V;f(e&&e.4n.4y()!=\'1F\'){t=e.3b;l=e.3R;w=e.5F;h=e.5P;2Q=0;2V=0}M{f(1a.2j&&1a.2j.3b){t=1a.2j.3b;l=1a.2j.3R;w=1a.2j.5F;h=1a.2j.5P}M f(1a.1F){t=1a.1F.3b;l=1a.1F.3R;w=1a.1F.5F;h=1a.1F.5P}2Q=5b.5M||1a.2j.4f||1a.1F.4f||0;2V=5b.5H||1a.2j.4d||1a.1F.4d||0}E{t:t,l:l,w:w,h:h,2Q:2Q,2V:2V}},77:d(e,3J){G 8=6(e);G t=8.D(\'3U\')||\'\';G r=8.D(\'46\')||\'\';G b=8.D(\'41\')||\'\';G l=8.D(\'3Z\')||\'\';f(3J)E{t:R(t)||0,r:R(r)||0,b:R(b)||0,l:R(l)};M E{t:t,r:r,b:b,l:l}},8H:d(e,3J){G 8=6(e);G t=8.D(\'34\')||\'\';G r=8.D(\'2K\')||\'\';G b=8.D(\'35\')||\'\';G l=8.D(\'2M\')||\'\';f(3J)E{t:R(t)||0,r:R(r)||0,b:R(b)||0,l:R(l)};M E{t:t,r:r,b:b,l:l}},8y:d(e,3J){G 8=6(e);G t=8.D(\'2t\')||\'\';G r=8.D(\'2Z\')||\'\';G b=8.D(\'32\')||\'\';G l=8.D(\'2F\')||\'\';f(3J)E{t:R(t)||0,r:R(r)||0,b:R(b)||0,l:R(l)||0};M E{t:t,r:r,b:b,l:l}},4h:d(4m){G x=4m.8z||(4m.8J+(1a.2j.3R||1a.1F.3R))||0;G y=4m.8K||(4m.8L+(1a.2j.3b||1a.1F.3b))||0;E{x:x,y:y}},5N:d(2r,5R){5R(2r);2r=2r.6W;48(2r){6.1w.5N(2r,5R);2r=2r.8P}},88:d(2r){6.1w.5N(2r,d(8){1E(G 1U 1m 8){f(1l 8[1U]===\'d\'){8[1U]=17}}})},87:d(8,1D){G 2H=$.1w.5V();G 5Q=$.1w.30(8);f(!1D||1D==\'38\')$(8).D({J:2H.t+((V.3m(2H.h,2H.2V)-2H.t-5Q.1u)/2)+\'14\'});f(!1D||1D==\'3i\')$(8).D({H:2H.l+((V.3m(2H.w,2H.2Q)-2H.l-5Q.1s)/2)+\'14\'})},8a:d(8,6P){G 6b=$(\'73[@52*="4X"]\',8||1a),4X;6b.2u(d(){4X=q.52;q.52=6P;q.1r.5O="86:84.7Y.7X(52=\'"+4X+"\')"})}};[].2i||(8d.8e.2i=d(v,n){n=(n==17)?0:n;G m=q.2B;1E(G i=n;i<m;i++)f(q[i]==v)E i;E-1});6.2g=d(e){f(/^8q$|^8r$|^8i$|^8k$|^8h$|^8f$|^81$|^8c$|^89$|^1F$|^8M$|^8R$|^7v$|^7x$|^7j$|^7B$|^7O$/i.45(e.4n))E 1k;M E 22};6.B.4o=d(e,2P){G c=e.6W;G 2R=c.1r;2R.O=2P.O;2R.3U=2P.2z.t;2R.3Z=2P.2z.l;2R.41=2P.2z.b;2R.46=2P.2z.r;2R.J=2P.J+\'14\';2R.H=2P.H+\'14\';e.3M.6d(c,e);e.3M.7S(e)};6.B.4P=d(e){f(!6.2g(e))E 1k;G t=6(e);G 1c=e.1r;G 2D=1k;G F={};F.O=t.D(\'O\');f(t.D(\'18\')==\'1i\'){2T=t.D(\'1T\');1c.1T=\'2A\';1c.18=\'\';2D=22}F.P=6.1w.30(e);F.2z=6.1w.77(e);G 5u=e.3I?e.3I.6f:t.D(\'7k\');F.J=R(t.D(\'J\'))||0;F.H=R(t.D(\'H\'))||0;G 7f=\'7u\'+R(V.7r()*6I);G 3k=1a.66(/^73$|^8Y$|^8C$|^8B$|^8w$|^8v$|^44$|^8x$|^8A$|^8W$|^8S$|^8N$|^8O$|^8Q$/i.45(e.4n)?\'68\':e.4n);6.1U(3k,\'82\',7f);3k.61=\'8p\';G 1K=3k.1r;G J=0;G H=0;f(F.O==\'1I\'||F.O==\'23\'){J=F.J;H=F.H}1K.18=\'1i\';1K.J=J+\'14\';1K.H=H+\'14\';1K.O=F.O!=\'1I\'&&F.O!=\'23\'?\'1I\':F.O;1K.2p=\'2A\';1K.L=F.P.1u+\'14\';1K.T=F.P.1s+\'14\';1K.3U=F.2z.t;1K.46=F.2z.r;1K.41=F.2z.b;1K.3Z=F.2z.l;f(6.5t.8l){1K.6f=5u}M{1K.8j=5u}e.3M.6d(3k,e);1c.3U=\'3s\';1c.46=\'3s\';1c.41=\'3s\';1c.3Z=\'3s\';1c.O=\'23\';1c.8g=\'1i\';1c.J=\'3s\';1c.H=\'3s\';f(2D){1c.18=\'1i\';1c.1T=2T}3k.8s(e);1K.18=\'2I\';E{F:F,1A:6(3k)}};6.B.3W={8n:[0,1f,1f],8o:[6q,1f,1f],83:[6k,6k,7Z],8b:[0,0,0],8t:[0,0,1f],8u:[6y,42,42],8X:[0,1f,1f],8V:[0,0,3u],8T:[0,3u,3u],8U:[5w,5w,5w],8I:[0,1q,0],8G:[8F,7W,6G],8D:[3u,0,3u],8E:[85,6G,47],7K:[1f,6o,0],7t:[7p,50,7o],7l:[3u,0,0],7m:[7w,6V,7V],7P:[7A,0,4x],7N:[1f,0,1f],7M:[1f,7Q,0],7R:[0,3j,0],7L:[75,0,7E],7D:[6q,6u,6o],7H:[7I,7F,6u],7T:[6w,1f,1f],7U:[6x,7n,6x],7z:[4x,4x,4x],7q:[1f,7y,7s],8m:[1f,1f,6w],9r:[0,1f,0],aL:[1f,0,1f],aM:[3j,0,0],aG:[0,0,3j],ad:[3j,3j,0],aa:[1f,6y,0],a4:[1f,4u,a6],a8:[3j,0,3j],ah:[1f,0,0],ai:[4u,4u,4u],as:[1f,1f,1f],ar:[1f,1f,0]};6.B.3a=d(27,6A){f(6.B.3W[27])E{r:6.B.3W[27][0],g:6.B.3W[27][1],b:6.B.3W[27][2]};M f(1y=/^3r\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)$/.4s(27))E{r:R(1y[1]),g:R(1y[2]),b:R(1y[3])};M f(1y=/3r\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)$/.4s(27))E{r:1o(1y[1])*2.55,g:1o(1y[2])*2.55,b:1o(1y[3])*2.55};M f(1y=/^#([a-3S-3C-9])([a-3S-3C-9])([a-3S-3C-9])$/.4s(27))E{r:R("3O"+1y[1]+1y[1]),g:R("3O"+1y[2]+1y[2]),b:R("3O"+1y[3]+1y[3])};M f(1y=/^#([a-3S-3C-9]{2})([a-3S-3C-9]{2})([a-3S-3C-9]{2})$/.4s(27))E{r:R("3O"+1y[1]),g:R("3O"+1y[2]),b:R("3O"+1y[3])};M E 6A==22?1k:{r:1f,g:1f,b:1f}};6.B.6N={32:1,2F:1,2Z:1,2t:1,an:1,2L:1,L:1,H:1,ao:1,am:1,41:1,3Z:1,46:1,3U:1,4c:1,4U:1,3V:1,4W:1,1z:1,al:1,aj:1,35:1,2M:1,2K:1,34:1,21:1,ak:1,J:1,T:1,56:1};6.B.6H={43:1,ap:1,aq:1,av:1,au:1,27:1,at:1};6.B.4e=[\'a9\',\'a5\',\'ab\',\'ag\'];6.B.5z={\'5s\':[\'4l\',\'6F\'],\'4M\':[\'4l\',\'5B\'],\'51\':[\'51\',\'\'],\'5d\':[\'5d\',\'\']};6.1M.1J({65:d(2O,A,k,u){E q.U(d(){G 4Y=6.A(A,k,u);G e=I 6.6L(q,4Y,2O)})},5g:d(A,u){E q.U(d(){G 4Y=6.A(A,u);G e=I 6.5g(q,4Y)})},4w:d(1L){E q.2u(d(){f(q.2N)6.5A(q,1L)})},af:d(1L){E q.2u(d(){f(q.2N)6.5A(q,1L);f(q.U&&q.U[\'B\'])q.U.B=[]})}});6.1J({5g:d(1e,16){G z=q,6M;z.1L=d(){f(6.6i(16.1b))16.1b.1C(1e)};z.2h=54(d(){z.1L()},16.Q);1e.2N=z},k:{5i:d(p,n,19,Z,Q){E((-V.2Y(p*V.1H)/2)+0.5)*Z+19}},6L:d(1e,16,2O){G z=q,6M;G y=1e.1r;G 6l=6.D(1e,"2p");G 3q=6.D(1e,"18");G 1h={};z.53=(I 3z()).3A();16.k=16.k&&6.k[16.k]?16.k:\'5i\';z.4H=d(1n,1Y){f(6.B.6N[1n]){f(1Y==\'1B\'||1Y==\'2W\'||1Y==\'1O\'){f(!1e.3f)1e.3f={};G r=1o(6.1G(1e,1n));1e.3f[1n]=r&&r>-6I?r:(1o(6.D(1e,1n))||0);1Y=1Y==\'1O\'?(3q==\'1i\'?\'1B\':\'2W\'):1Y;16[1Y]=22;1h[1n]=1Y==\'1B\'?[0,1e.3f[1n]]:[1e.3f[1n],0];f(1n!=\'1z\')y[1n]=1h[1n][0]+(1n!=\'56\'&&1n!=\'5v\'?\'14\':\'\');M 6.1U(y,"1z",1h[1n][0])}M{1h[1n]=[1o(6.1G(1e,1n)),1o(1Y)||0]}}M f(6.B.6H[1n])1h[1n]=[6.B.3a(6.1G(1e,1n)),6.B.3a(1Y)];M f(/^51$|5d$|4l$|4M$|5s$/i.45(1n)){G m=1Y.37(/\\s+/g,\' \').37(/3r\\s*\\(\\s*/g,\'3r(\').37(/\\s*,\\s*/g,\',\').37(/\\s*\\)/g,\')\').6r(/([^\\s]+)/g);2c(1n){11\'51\':11\'5d\':11\'5s\':11\'4M\':m[3]=m[3]||m[1]||m[0];m[2]=m[2]||m[0];m[1]=m[1]||m[0];1E(G i=0;i<6.B.4e.2B;i++){G 31=6.B.5z[1n][0]+6.B.4e[i]+6.B.5z[1n][1];1h[31]=1n==\'4M\'?[6.B.3a(6.1G(1e,31)),6.B.3a(m[i])]:[1o(6.1G(1e,31)),1o(m[i])]}1d;11\'4l\':1E(G i=0;i<m.2B;i++){G 5n=1o(m[i]);G 4J=!ae(5n)?\'6F\':(!/79|1i|2A|ac|ax|aw|aC|aK|aJ|aQ|aO/i.45(m[i])?\'5B\':1k);f(4J){1E(G j=0;j<6.B.4e.2B;j++){31=\'4l\'+6.B.4e[j]+4J;1h[31]=4J==\'5B\'?[6.B.3a(6.1G(1e,31)),6.B.3a(m[i])]:[1o(6.1G(1e,31)),5n]}}M{y[\'aI\']=m[i]}}1d}}M{y[1n]=1Y}E 1k};1E(p 1m 2O){f(p==\'1r\'){G 2G=6.5x(2O[p]);1E(3E 1m 2G){q.4H(3E,2G[3E])}}M f(p==\'61\'){f(1a.4L)1E(G i=0;i<1a.4L.2B;i++){G 3F=1a.4L[i].3F||1a.4L[i].aB||17;f(3F){1E(G j=0;j<3F.2B;j++){f(3F[j].aA==\'.\'+2O[p]){G 3x=I ay(\'\\.\'+2O[p]+\' {\');G 2X=3F[j].1r.4C;G 2G=6.5x(2X.37(3x,\'\').37(/}/g,\'\'));1E(3E 1m 2G){q.4H(3E,2G[3E])}}}}}}M{q.4H(p,2O[p])}}y.18=3q==\'1i\'?\'2I\':3q;y.2p=\'2A\';z.1L=d(){G t=(I 3z()).3A();f(t>16.Q+z.53){4V(z.2h);z.2h=17;1E(p 1m 1h){f(p=="1z")6.1U(y,"1z",1h[p][1]);M f(1l 1h[p][1]==\'44\')y[p]=\'3r(\'+1h[p][1].r+\',\'+1h[p][1].g+\',\'+1h[p][1].b+\')\';M y[p]=1h[p][1]+(p!=\'56\'&&p!=\'5v\'?\'14\':\'\')}f(16.2W||16.1B)1E(G p 1m 1e.3f)f(p=="1z")6.1U(y,p,1e.3f[p]);M y[p]="";y.18=16.2W?\'1i\':(3q!=\'1i\'?3q:\'2I\');y.2p=6l;1e.2N=17;f(6.6i(16.1b))16.1b.1C(1e)}M{G n=t-q.53;G 4j=n/16.Q;1E(p 1m 1h){f(1l 1h[p][1]==\'44\'){y[p]=\'3r(\'+R(6.k[16.k](4j,n,1h[p][0].r,(1h[p][1].r-1h[p][0].r),16.Q))+\',\'+R(6.k[16.k](4j,n,1h[p][0].g,(1h[p][1].g-1h[p][0].g),16.Q))+\',\'+R(6.k[16.k](4j,n,1h[p][0].b,(1h[p][1].b-1h[p][0].b),16.Q))+\')\'}M{G 5r=6.k[16.k](4j,n,1h[p][0],(1h[p][1]-1h[p][0]),16.Q);f(p=="1z")6.1U(y,"1z",5r);M y[p]=5r+(p!=\'56\'&&p!=\'5v\'?\'14\':\'\')}}}};z.2h=54(d(){z.1L()},13);1e.2N=z},5A:d(1e,1L){f(1L)1e.2N.53-=aF;M{3v.4V(1e.2N.2h);1e.2N=17;6.1v(1e,"B")}}});6.5x=d(2X){G 2G={};f(1l 2X==\'2k\'){2X=2X.4y().5X(\';\');1E(G i=0;i<2X.2B;i++){3x=2X[i].5X(\':\');f(3x.2B==2){2G[6.6h(3x[0].37(/\\-(\\w)/g,d(m,c){E c.aH()}))]=6.6h(3x[1])}}}E 2G};6.1J({k:{5i:d(p,n,19,Z,Q){E((-V.2Y(p*V.1H)/2)+0.5)*Z+19},aE:d(p,n,19,Z,Q){E Z*(n/=Q)*n*n+19},6U:d(p,n,19,Z,Q){E-Z*((n=n/Q-1)*n*n*n-1)+19},aD:d(p,n,19,Z,Q){f((n/=Q/2)<1)E Z/2*n*n*n*n+19;E-Z/2*((n-=2)*n*n*n-2)+19},4a:d(p,n,19,Z,Q){f((n/=Q)<(1/2.75)){E Z*(7.4T*n*n)+19}M f(n<(2/2.75)){E Z*(7.4T*(n-=(1.5/2.75))*n+.75)+19}M f(n<(2.5/2.75)){E Z*(7.4T*(n-=(2.25/2.75))*n+.az)+19}M{E Z*(7.4T*(n-=(2.aP/2.75))*n+.aR)+19}},5C:d(p,n,19,Z,Q){f(6.k.4a)E Z-6.k.4a(p,Q-n,0,Z,Q)+19;E 19+Z},aN:d(p,n,19,Z,Q){f(6.k.5C&&6.k.4a)f(n<Q/2)E 6.k.5C(p,n*2,0,Z,Q)*.5+19;E 6.k.4a(p,n*2-Q,0,Z,Q)*.5+Z*.5+19;E 19+Z},a7:d(p,n,19,Z,Q){G a,s;f(n==0)E 19;f((n/=Q)==1)E 19+Z;a=Z*0.3;p=Q*.3;f(a<V.5p(Z)){a=Z;s=p/4}M{s=p/(2*V.1H)*V.5o(Z/a)}E-(a*V.5e(2,10*(n-=1))*V.5c((n*Q-s)*(2*V.1H)/p))+19},a2:d(p,n,19,Z,Q){G a,s;f(n==0)E 19;f((n/=Q/2)==2)E 19+Z;a=Z*0.3;p=Q*.3;f(a<V.5p(Z)){a=Z;s=p/4}M{s=p/(2*V.1H)*V.5o(Z/a)}E a*V.5e(2,-10*n)*V.5c((n*Q-s)*(2*V.1H)/p)+Z+19},9l:d(p,n,19,Z,Q){G a,s;f(n==0)E 19;f((n/=Q/2)==2)E 19+Z;a=Z*0.3;p=Q*.3;f(a<V.5p(Z)){a=Z;s=p/4}M{s=p/(2*V.1H)*V.5o(Z/a)}f(n<1){E-.5*(a*V.5e(2,10*(n-=1))*V.5c((n*Q-s)*(2*V.1H)/p))+19}E a*V.5e(2,-10*(n-=1))*V.5c((n*Q-s)*(2*V.1H)/p)*.5+Z+19}}});6.1M.1J({9m:d(A,u,k){E q.U(\'N\',d(){I 6.B.3h(q,A,u,\'2d\',k)})},9k:d(A,u,k){E q.U(\'N\',d(){I 6.B.3h(q,A,u,\'26\',k)})},9j:d(A,u,k){E q.U(\'N\',d(){I 6.B.3h(q,A,u,\'6Y\',k)})},9h:d(A,u,k){E q.U(\'N\',d(){I 6.B.3h(q,A,u,\'H\',k)})},9i:d(A,u,k){E q.U(\'N\',d(){I 6.B.3h(q,A,u,\'21\',k)})},9n:d(A,u,k){E q.U(\'N\',d(){I 6.B.3h(q,A,u,\'6Q\',k)})}});6.B.3h=d(e,A,u,1x,k){f(!6.2g(e)){6.1v(e,\'N\');E 1k}G z=q;z.8=6(e);z.4E=6.1w.30(e);z.k=1l u==\'2k\'?u:k||17;f(!e.24)e.24=z.8.D(\'18\');f(1x==\'6Y\'){1x=z.8.D(\'18\')==\'1i\'?\'26\':\'2d\'}M f(1x==\'6Q\'){1x=z.8.D(\'18\')==\'1i\'?\'21\':\'H\'}z.8.1B();z.A=A;z.u=1l u==\'d\'?u:17;z.B=6.B.4P(e);z.1x=1x;z.1b=d(){f(z.u&&z.u.2m==39){z.u.1C(z.8.S(0))}f(z.1x==\'26\'||z.1x==\'21\'){z.8.D(\'18\',z.8.S(0).24==\'1i\'?\'2I\':z.8.S(0).24)}M{z.8.2W()}6.B.4o(z.B.1A.S(0),z.B.F);6.1v(z.8.S(0),\'N\')};2c(z.1x){11\'2d\':2S=I 6.B(z.B.1A.S(0),6.A(z.A,z.k,z.1b),\'L\');2S.12(z.B.F.P.1u,0);1d;11\'26\':z.B.1A.D(\'L\',\'5l\');z.8.1B();2S=I 6.B(z.B.1A.S(0),6.A(z.A,z.k,z.1b),\'L\');2S.12(0,z.B.F.P.1u);1d;11\'H\':2S=I 6.B(z.B.1A.S(0),6.A(z.A,z.k,z.1b),\'T\');2S.12(z.B.F.P.1s,0);1d;11\'21\':z.B.1A.D(\'T\',\'5l\');z.8.1B();2S=I 6.B(z.B.1A.S(0),6.A(z.A,z.k,z.1b),\'T\');2S.12(0,z.B.F.P.1s);1d}};6.1M.9o=d(2C,u){E q.U(\'N\',d(){f(!6.2g(q)){6.1v(q,\'N\');E 1k}G e=I 6.B.7b(q,2C,u);e.5q()})};6.B.7b=d(e,2C,u){G z=q;z.8=6(e);z.8.1B();z.u=u;z.2C=R(2C)||40;z.F={};z.F.O=z.8.D(\'O\');z.F.J=R(z.8.D(\'J\'))||0;z.F.H=R(z.8.D(\'H\'))||0;f(z.F.O!=\'1I\'&&z.F.O!=\'23\'){z.8.D(\'O\',\'1I\')}z.1P=5;z.2E=1;z.5q=d(){z.2E++;z.e=I 6.B(z.8.S(0),{Q:9t,1b:d(){z.e=I 6.B(z.8.S(0),{Q:80,1b:d(){z.2C=R(z.2C/2);f(z.2E<=z.1P)z.5q();M{z.8.D(\'O\',z.F.O).D(\'J\',z.F.J+\'14\').D(\'H\',z.F.H+\'14\');6.1v(z.8.S(0),\'N\');f(z.u&&z.u.2m==39){z.u.1C(z.8.S(0))}}}},\'J\');z.e.12(z.F.J-z.2C,z.F.J)}},\'J\');z.e.12(z.F.J,z.F.J-z.2C)}};6.1M.1J({9u:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'26\',\'28\',k)})},9s:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'26\',\'1m\',k)})},a3:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'26\',\'1O\',k)})},9p:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'2d\',\'28\',k)})},9q:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'2d\',\'1m\',k)})},9g:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'2d\',\'1O\',k)})},9f:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'H\',\'28\',k)})},95:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'H\',\'1m\',k)})},96:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'H\',\'1O\',k)})},94:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'21\',\'28\',k)})},93:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'21\',\'1m\',k)})},90:d(A,u,k){E q.U(\'N\',d(){I 6.B.1R(q,A,u,\'21\',\'1O\',k)})}});6.B.1R=d(e,A,u,1x,Y,k){f(!6.2g(e)){6.1v(e,\'N\');E 1k}G z=q;z.8=6(e);z.k=1l u==\'2k\'?u:k||17;z.F={};z.F.O=z.8.D(\'O\');z.F.J=z.8.D(\'J\');z.F.H=z.8.D(\'H\');f(!e.24)e.24=z.8.D(\'18\');f(Y==\'1O\'){Y=z.8.D(\'18\')==\'1i\'?\'1m\':\'28\'}z.8.1B();f(z.F.O!=\'1I\'&&z.F.O!=\'23\'){z.8.D(\'O\',\'1I\')}z.Y=Y;u=1l u==\'d\'?u:17;49=1;2c(1x){11\'2d\':z.e=I 6.B(z.8.S(0),6.A(A-15,z.k,u),\'J\');z.2U=1o(z.F.J)||0;z.4r=z.71;49=-1;1d;11\'26\':z.e=I 6.B(z.8.S(0),6.A(A-15,z.k,u),\'J\');z.2U=1o(z.F.J)||0;z.4r=z.71;1d;11\'21\':z.e=I 6.B(z.8.S(0),6.A(A-15,z.k,u),\'H\');z.2U=1o(z.F.H)||0;z.4r=z.74;1d;11\'H\':z.e=I 6.B(z.8.S(0),6.A(A-15,z.k,u),\'H\');z.2U=1o(z.F.H)||0;z.4r=z.74;49=-1;1d}z.5y=I 6.B(z.8.S(0),6.A(A,z.k,d(){z.8.D(z.F);f(z.Y==\'28\'){z.8.D(\'18\',\'1i\')}M z.8.D(\'18\',z.8.S(0).24==\'1i\'?\'2I\':z.8.S(0).24);6.1v(z.8.S(0),\'N\')}),\'1z\');f(Y==\'1m\'){z.e.12(z.2U+1q*49,z.2U);z.5y.12(0,1)}M{z.e.12(z.2U,z.2U+1q*49);z.5y.12(1,0)}};6.1M.1J({91:d(A,L,u,k){E q.U(\'N\',d(){I 6.B.4D(q,A,L,u,\'70\',k)})},92:d(A,L,u,k){E q.U(\'N\',d(){I 6.B.4D(q,A,L,u,\'4F\',k)})},97:d(A,L,u,k){E q.U(\'N\',d(){I 6.B.4D(q,A,L,u,\'1O\',k)})}});6.B.4D=d(e,A,L,u,Y,k){f(!6.2g(e)){6.1v(e,\'N\');E 1k}G z=q;z.8=6(e);z.k=1l u==\'2k\'?u:k||17;z.u=1l u==\'d\'?u:17;f(Y==\'1O\'){Y=z.8.D(\'18\')==\'1i\'?\'4F\':\'70\'}z.A=A;z.L=L&&L.2m==8Z?L:20;z.B=6.B.4P(e);z.Y=Y;z.1b=d(){f(z.u&&z.u.2m==39){z.u.1C(z.8.S(0))}f(z.Y==\'4F\'){z.8.1B()}M{z.8.2W()}6.B.4o(z.B.1A.S(0),z.B.F);6.1v(z.8.S(0),\'N\')};f(z.Y==\'4F\'){z.8.1B();z.B.1A.D(\'L\',z.L+\'14\').D(\'T\',\'5l\');z.1t=I 6.B(z.B.1A.S(0),6.A(z.A,z.k,d(){z.1t=I 6.B(z.B.1A.S(0),6.A(z.A,z.k,z.1b),\'L\');z.1t.12(z.L,z.B.F.P.1u)}),\'T\');z.1t.12(0,z.B.F.P.1s)}M{z.1t=I 6.B(z.B.1A.S(0),6.A(z.A,z.k,d(){z.1t=I 6.B(z.B.1A.S(0),6.A(z.A,z.k,z.1b),\'T\');z.1t.12(z.B.F.P.1s,0)}),\'L\');z.1t.12(z.B.F.P.1u,z.L)}};6.1M.1J({98:d(A,u,k){E q.U(\'N\',d(){I 6.B.3g(q,A,1,1q,22,u,\'7g\',k)})},9d:d(A,u,k){E q.U(\'N\',d(){I 6.B.3g(q,A,1q,1,22,u,\'5K\',k)})},9e:d(A,u,k){E q.U(\'N\',d(){G k=k||\'6U\';I 6.B.3g(q,A,1q,6V,22,u,\'2J\',k)})},3g:d(A,2w,2e,3G,u,k){E q.U(\'N\',d(){I 6.B.3g(q,A,2w,2e,3G,u,\'3g\',k)})}});6.B.3g=d(e,A,2w,2e,3G,u,Y,k){f(!6.2g(e)){6.1v(e,\'N\');E 1k}G z=q;z.8=6(e);z.2w=R(2w)||1q;z.2e=R(2e)||1q;z.k=1l u==\'2k\'?u:k||17;z.u=1l u==\'d\'?u:17;z.Q=6.A(A).Q;z.3G=3G||17;z.1g=6.1w.30(e);z.F={T:z.8.D(\'T\'),L:z.8.D(\'L\'),2L:z.8.D(\'2L\')||\'1q%\',O:z.8.D(\'O\'),18:z.8.D(\'18\'),J:z.8.D(\'J\'),H:z.8.D(\'H\'),2p:z.8.D(\'2p\'),2t:z.8.D(\'2t\'),2Z:z.8.D(\'2Z\'),32:z.8.D(\'32\'),2F:z.8.D(\'2F\'),34:z.8.D(\'34\'),2K:z.8.D(\'2K\'),35:z.8.D(\'35\'),2M:z.8.D(\'2M\')};z.T=R(z.F.T)||e.4K||0;z.L=R(z.F.L)||e.4O||0;z.J=R(z.F.J)||0;z.H=R(z.F.H)||0;P=[\'9c\',\'14\',\'9b\',\'%\'];1E(i 1m P){f(z.F.2L.2i(P[i])>0){z.7c=P[i];z.2L=1o(z.F.2L)}f(z.F.2t.2i(P[i])>0){z.7h=P[i];z.5h=1o(z.F.2t)||0}f(z.F.2Z.2i(P[i])>0){z.6j=P[i];z.5k=1o(z.F.2Z)||0}f(z.F.32.2i(P[i])>0){z.7e=P[i];z.5W=1o(z.F.32)||0}f(z.F.2F.2i(P[i])>0){z.7i=P[i];z.5T=1o(z.F.2F)||0}f(z.F.34.2i(P[i])>0){z.7d=P[i];z.5Z=1o(z.F.34)||0}f(z.F.2K.2i(P[i])>0){z.7a=P[i];z.64=1o(z.F.2K)||0}f(z.F.35.2i(P[i])>0){z.6X=P[i];z.5S=1o(z.F.35)||0}f(z.F.2M.2i(P[i])>0){z.6R=P[i];z.5J=1o(z.F.2M)||0}}f(z.F.O!=\'1I\'&&z.F.O!=\'23\'){z.8.D(\'O\',\'1I\')}z.8.D(\'2p\',\'2A\');z.Y=Y;2c(z.Y){11\'7g\':z.1W=z.J+z.1g.h/2;z.2n=z.J;z.1X=z.H+z.1g.w/2;z.2q=z.H;1d;11\'5K\':z.2n=z.J+z.1g.h/2;z.1W=z.J;z.2q=z.H+z.1g.w/2;z.1X=z.H;1d;11\'2J\':z.2n=z.J-z.1g.h/4;z.1W=z.J;z.2q=z.H-z.1g.w/4;z.1X=z.H;1d}z.5j=1k;z.t=(I 3z).3A();z.4Z=d(){4V(z.2h);z.2h=17};z.1L=d(){f(z.5j==1k){z.8.1B();z.5j=22}G t=(I 3z).3A();G n=t-z.t;G p=n/z.Q;f(t>=z.Q+z.t){6e(d(){o=1;f(z.Y){t=z.2n;l=z.2q;f(z.Y==\'2J\')o=0}z.5m(z.2e,l,t,22,o)},13);z.4Z()}M{o=1;f(!6.k||!6.k[z.k]){s=((-V.2Y(p*V.1H)/2)+0.5)*(z.2e-z.2w)+z.2w}M{s=6.k[z.k](p,n,z.2w,(z.2e-z.2w),z.Q)}f(z.Y){f(!6.k||!6.k[z.k]){t=((-V.2Y(p*V.1H)/2)+0.5)*(z.2n-z.1W)+z.1W;l=((-V.2Y(p*V.1H)/2)+0.5)*(z.2q-z.1X)+z.1X;f(z.Y==\'2J\')o=((-V.2Y(p*V.1H)/2)+0.5)*(-0.4A)+0.4A}M{t=6.k[z.k](p,n,z.1W,(z.2n-z.1W),z.Q);l=6.k[z.k](p,n,z.1X,(z.2q-z.1X),z.Q);f(z.Y==\'2J\')o=6.k[z.k](p,n,0.4A,-0.4A,z.Q)}}z.5m(s,l,t,1k,o)}};z.2h=54(d(){z.1L()},13);z.5m=d(2a,H,J,6S,1z){z.8.D(\'L\',z.L*2a/1q+\'14\').D(\'T\',z.T*2a/1q+\'14\').D(\'H\',H+\'14\').D(\'J\',J+\'14\').D(\'2L\',z.2L*2a/1q+z.7c);f(z.5h)z.8.D(\'2t\',z.5h*2a/1q+z.7h);f(z.5k)z.8.D(\'2Z\',z.5k*2a/1q+z.6j);f(z.5W)z.8.D(\'32\',z.5W*2a/1q+z.7e);f(z.5T)z.8.D(\'2F\',z.5T*2a/1q+z.7i);f(z.5Z)z.8.D(\'34\',z.5Z*2a/1q+z.7d);f(z.64)z.8.D(\'2K\',z.64*2a/1q+z.7a);f(z.5S)z.8.D(\'35\',z.5S*2a/1q+z.6X);f(z.5J)z.8.D(\'2M\',z.5J*2a/1q+z.6R);f(z.Y==\'2J\'){f(3v.6T)z.8.S(0).1r.5O="78(1z="+1z*1q+")";z.8.S(0).1r.1z=1z}f(6S){f(z.3G){z.8.D(z.F)}f(z.Y==\'5K\'||z.Y==\'2J\'){z.8.D(\'18\',\'1i\');f(z.Y==\'2J\'){f(3v.6T)z.8.S(0).1r.5O="78(1z="+1q+")";z.8.S(0).1r.1z=1}}M z.8.D(\'18\',\'2I\');f(z.u)z.u.1C(z.8.S(0));6.1v(z.8.S(0),\'N\')}}};6.1M.99=d(A,27,u,k){E q.U(\'76\',d(){q.3N=6(q).1U("1r")||\'\';k=1l u==\'2k\'?u:k||17;u=1l u==\'d\'?u:17;G 4N=6(q).D(\'43\');G 3Y=q.3M;48(4N==\'79\'&&3Y){4N=6(3Y).D(\'43\');3Y=3Y.3M}6(q).D(\'43\',27);f(1l q.3N==\'44\')q.3N=q.3N["4C"];6(q).65({\'43\':4N},A,k,d(){6.1v(q,\'76\');f(1l 6(q).1U("1r")==\'44\'){6(q).1U("1r")["4C"]="";6(q).1U("1r")["4C"]=q.3N}M{6(q).1U("1r",q.3N)}f(u)u.1C(q)})})};6.1M.1J({9a:d(A,u,k){E q.U(\'N\',d(){I 6.B.2s(q,A,u,\'38\',\'3d\',k)})},9v:d(A,u,k){E q.U(\'N\',d(){I 6.B.2s(q,A,u,\'3i\',\'3d\',k)})},9w:d(A,u,k){E q.U(\'N\',d(){f(6.D(q,\'18\')==\'1i\'){I 6.B.2s(q,A,u,\'3i\',\'3P\',k)}M{I 6.B.2s(q,A,u,\'3i\',\'3d\',k)}})},9S:d(A,u,k){E q.U(\'N\',d(){f(6.D(q,\'18\')==\'1i\'){I 6.B.2s(q,A,u,\'38\',\'3P\',k)}M{I 6.B.2s(q,A,u,\'38\',\'3d\',k)}})},9T:d(A,u,k){E q.U(\'N\',d(){I 6.B.2s(q,A,u,\'38\',\'3P\',k)})},9R:d(A,u,k){E q.U(\'N\',d(){I 6.B.2s(q,A,u,\'3i\',\'3P\',k)})}});6.B.2s=d(e,A,u,1x,Y,k){f(!6.2g(e)){6.1v(e,\'N\');E 1k}G z=q;G 2D=1k;z.8=6(e);z.k=1l u==\'2k\'?u:k||17;z.u=1l u==\'d\'?u:17;z.Y=Y;z.A=A;z.1g=6.1w.30(e);z.F={};z.F.O=z.8.D(\'O\');z.F.18=z.8.D(\'18\');f(z.F.18==\'1i\'){2T=z.8.D(\'1T\');z.8.1B();2D=22}z.F.J=z.8.D(\'J\');z.F.H=z.8.D(\'H\');f(2D){z.8.2W();z.8.D(\'1T\',2T)}z.F.T=z.1g.w+\'14\';z.F.L=z.1g.h+\'14\';z.F.2p=z.8.D(\'2p\');z.1g.J=R(z.F.J)||0;z.1g.H=R(z.F.H)||0;f(z.F.O!=\'1I\'&&z.F.O!=\'23\'){z.8.D(\'O\',\'1I\')}z.8.D(\'2p\',\'2A\').D(\'L\',Y==\'3P\'&&1x==\'38\'?1:z.1g.h+\'14\').D(\'T\',Y==\'3P\'&&1x==\'3i\'?1:z.1g.w+\'14\');z.1b=d(){z.8.D(z.F);f(z.Y==\'3d\')z.8.2W();M z.8.1B();6.1v(z.8.S(0),\'N\')};2c(1x){11\'38\':z.3p=I 6.B(z.8.S(0),6.A(A-15,z.k,u),\'L\');z.3B=I 6.B(z.8.S(0),6.A(z.A,z.k,z.1b),\'J\');f(z.Y==\'3d\'){z.3p.12(z.1g.h,0);z.3B.12(z.1g.J,z.1g.J+z.1g.h/2)}M{z.3p.12(0,z.1g.h);z.3B.12(z.1g.J+z.1g.h/2,z.1g.J)}1d;11\'3i\':z.3p=I 6.B(z.8.S(0),6.A(A-15,z.k,u),\'T\');z.3B=I 6.B(z.8.S(0),6.A(z.A,z.k,z.1b),\'H\');f(z.Y==\'3d\'){z.3p.12(z.1g.w,0);z.3B.12(z.1g.H,z.1g.H+z.1g.w/2)}M{z.3p.12(0,z.1g.w);z.3B.12(z.1g.H+z.1g.w/2,z.1g.H)}1d}};6.1M.5D=d(A,1P,u){E q.U(\'N\',d(){f(!6.2g(q)){6.1v(q,\'N\');E 1k}G B=I 6.B.5D(q,A,1P,u);B.63()})};6.B.5D=d(8,A,1P,u){G z=q;z.1P=1P;z.2E=1;z.8=8;z.A=A;z.u=u;6(z.8).1B();z.63=d(){z.2E++;z.e=I 6.B(z.8,6.A(z.A,d(){z.1t=I 6.B(z.8,6.A(z.A,d(){f(z.2E<=z.1P)z.63();M{6.1v(z.8,\'N\');f(z.u&&z.u.2m==39){z.u.1C(z.8)}}}),\'1z\');z.1t.12(0,1)}),\'1z\');z.e.12(1,0)}};6.1M.1J({57:d(A,1D,k){o=6.A(A);E q.U(\'N\',d(){I 6.B.57(q,o,1D,k)})},9Q:d(A,1D,k){E q.2u(d(){6(\'a[@72*="#"]\',q).9O(d(e){6D=q.72.5X(\'#\');6(\'#\'+6D[1]).57(A,1D,k);E 1k})})}});6.B.57=d(e,o,1D,k){G z=q;z.o=o;z.e=e;z.1D=/6c|6g/.45(1D)?1D:1k;z.k=k;p=6.1w.4Q(e);s=6.1w.5V();z.4Z=d(){4V(z.2h);z.2h=17;6.1v(z.e,\'N\')};z.t=(I 3z).3A();s.h=s.h>s.2V?(s.h-s.2V):s.h;s.w=s.w>s.2Q?(s.w-s.2Q):s.w;z.2n=p.y>s.h?s.h:p.y;z.2q=p.x>s.w?s.w:p.x;z.1W=s.t;z.1X=s.l;z.1L=d(){G t=(I 3z).3A();G n=t-z.t;G p=n/z.o.Q;f(t>=z.o.Q+z.t){z.4Z();6e(d(){z.62(z.2n,z.2q)},13)}M{f(!z.1D||z.1D==\'6c\'){f(!6.k||!6.k[z.k]){5a=((-V.2Y(p*V.1H)/2)+0.5)*(z.2n-z.1W)+z.1W}M{5a=6.k[z.k](p,n,z.1W,(z.2n-z.1W),z.o.Q)}}M{5a=z.1W}f(!z.1D||z.1D==\'6g\'){f(!6.k||!6.k[z.k]){4v=((-V.2Y(p*V.1H)/2)+0.5)*(z.2q-z.1X)+z.1X}M{4v=6.k[z.k](p,n,z.1X,(z.2q-z.1X),z.o.Q)}}M{4v=z.1X}z.62(5a,4v)}};z.62=d(t,l){3v.9P(l,t)};z.2h=54(d(){z.1L()},13)};6.1M.5Y=d(1P,u){E q.U(\'N\',d(){f(!6.2g(q)){6.1v(q,\'N\');E 1k}G e=I 6.B.5Y(q,1P,u);e.5G()})};6.B.5Y=d(e,1P,u){G z=q;z.8=6(e);z.8.1B();z.1P=R(1P)||3;z.u=u;z.2E=1;z.F={};z.F.O=z.8.D(\'O\');z.F.J=R(z.8.D(\'J\'))||0;z.F.H=R(z.8.D(\'H\'))||0;f(z.F.O!=\'1I\'&&z.F.O!=\'23\'){z.8.D(\'O\',\'1I\')}z.5G=d(){z.2E++;z.e=I 6.B(z.8.S(0),{Q:60,1b:d(){z.e=I 6.B(z.8.S(0),{Q:60,1b:d(){z.e=I 6.B(e,{Q:60,1b:d(){f(z.2E<=z.1P)z.5G();M{z.8.D(\'O\',z.F.O).D(\'J\',z.F.J+\'14\').D(\'H\',z.F.H+\'14\');6.1v(z.8.S(0),\'N\');f(z.u&&z.u.2m==39){z.u.1C(z.8.S(0))}}}},\'H\');z.e.12(z.F.H-20,z.F.H)}},\'H\');z.e.12(z.F.H+20,z.F.H-20)}},\'H\');z.e.12(z.F.H,z.F.H+20)}};6.1M.1J({9U:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'2d\',\'1m\',k)})},9V:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'2d\',\'28\',k)})},a0:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'2d\',\'1O\',k)})},a1:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'26\',\'1m\',k)})},9Z:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'26\',\'28\',k)})},9Y:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'26\',\'1O\',k)})},9W:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'H\',\'1m\',k)})},9X:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'H\',\'28\',k)})},9N:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'H\',\'1O\',k)})},9M:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'21\',\'1m\',k)})},9C:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'21\',\'28\',k)})},9D:d(A,u,k){E q.U(\'N\',d(){I 6.B.1S(q,A,u,\'21\',\'1O\',k)})}});6.B.1S=d(e,A,u,1x,Y,k){f(!6.2g(e)){6.1v(e,\'N\');E 1k}G z=q;z.8=6(e);z.k=1l u==\'2k\'?u:k||17;z.u=1l u==\'d\'?u:17;f(Y==\'1O\'){Y=z.8.D(\'18\')==\'1i\'?\'1m\':\'28\'}f(!e.24)e.24=z.8.D(\'18\');z.8.1B();z.A=A;z.B=6.B.4P(e);z.Y=Y;z.1x=1x;z.1b=d(){f(z.Y==\'28\')z.8.D(\'1T\',\'2A\');6.B.4o(z.B.1A.S(0),z.B.F);f(z.Y==\'1m\'){z.8.D(\'18\',z.8.S(0).24==\'1i\'?\'2I\':z.8.S(0).24)}M{z.8.D(\'18\',\'1i\');z.8.D(\'1T\',\'9B\')}f(z.u&&z.u.2m==39){z.u.1C(z.8.S(0))}6.1v(z.8.S(0),\'N\')};2c(z.1x){11\'2d\':z.1t=I 6.B(z.8.S(0),6.A(z.A,z.k,z.1b),\'J\');z.3K=I 6.B(z.B.1A.S(0),6.A(z.A,z.k),\'L\');f(z.Y==\'1m\'){z.1t.12(-z.B.F.P.1u,0);z.3K.12(0,z.B.F.P.1u)}M{z.1t.12(0,-z.B.F.P.1u);z.3K.12(z.B.F.P.1u,0)}1d;11\'26\':z.1t=I 6.B(z.8.S(0),6.A(z.A,z.k,z.1b),\'J\');f(z.Y==\'1m\'){z.1t.12(z.B.F.P.1u,0)}M{z.1t.12(0,z.B.F.P.1u)}1d;11\'H\':z.1t=I 6.B(z.8.S(0),6.A(z.A,z.k,z.1b),\'H\');z.3K=I 6.B(z.B.1A.S(0),6.A(z.A,z.k),\'T\');f(z.Y==\'1m\'){z.1t.12(-z.B.F.P.1s,0);z.3K.12(0,z.B.F.P.1s)}M{z.1t.12(0,-z.B.F.P.1s);z.3K.12(z.B.F.P.1s,0)}1d;11\'21\':z.1t=I 6.B(z.8.S(0),6.A(z.A,z.k,z.1b),\'H\');f(z.Y==\'1m\'){z.1t.12(z.B.F.P.1s,0)}M{z.1t.12(0,z.B.F.P.1s)}1d}};6.9A=17;6.1M.9x=d(o){E q.2u(d(){f(!o||!o.2e){E}G 8=q;6(o.2e).2u(d(){I 6.B.67(8,q,o)})})};6.B.67=d(e,4k,o){G z=q;z.8=6(e);z.4k=4k;z.1V=1a.66(\'68\');6(z.1V).D({O:\'23\'}).9y(o.61);f(!o.Q){o.Q=9z}z.Q=o.Q;z.1b=o.1b;z.4I=0;z.4G=0;f(6.9E){z.4I=(R(6.1G(z.1V,\'2F\'))||0)+(R(6.1G(z.1V,\'2Z\'))||0)+(R(6.1G(z.1V,\'2M\'))||0)+(R(6.1G(z.1V,\'2K\'))||0);z.4G=(R(6.1G(z.1V,\'2t\'))||0)+(R(6.1G(z.1V,\'32\'))||0)+(R(6.1G(z.1V,\'34\'))||0)+(R(6.1G(z.1V,\'35\'))||0)}z.2l=6.1J(6.1w.4Q(z.8.S(0)),6.1w.30(z.8.S(0)));z.36=6.1J(6.1w.4Q(z.4k),6.1w.30(z.4k));z.2l.1s-=z.4I;z.2l.1u-=z.4G;z.36.1s-=z.4I;z.36.1u-=z.4G;z.u=o.1b;6(\'1F\').9F(z.1V);6(z.1V).D(\'T\',z.2l.1s+\'14\').D(\'L\',z.2l.1u+\'14\').D(\'J\',z.2l.y+\'14\').D(\'H\',z.2l.x+\'14\').65({J:z.36.y,H:z.36.x,T:z.36.1s,L:z.36.1u},z.Q,d(){6(z.1V).9K();f(z.1b&&z.1b.2m==39){z.1b.1C(z.8.S(0),[z.2e])}})};6.C={W:17,1N:17,1p:17,1Z:17,P:17,O:17,3L:d(e){6.C.1p=(q.4z)?q.4z:q;6.C.1Z=6.1w.4h(e);6.C.P={T:R(6(6.C.1p).D(\'T\'))||0,L:R(6(6.C.1p).D(\'L\'))||0};6.C.O={J:R(6(6.C.1p).D(\'J\'))||0,H:R(6(6.C.1p).D(\'H\'))||0};6(1a).33(\'4t\',6.C.5E).33(\'4B\',6.C.5U);f(1l 6.C.1p.K.6a===\'d\'){6.C.1p.K.6a.1C(6.C.1p)}E 1k},5U:d(e){6(1a).3o(\'4t\',6.C.5E).3o(\'4B\',6.C.5U);f(1l 6.C.1p.K.69===\'d\'){6.C.1p.K.69.1C(6.C.1p)}6.C.1p=17},5E:d(e){f(!6.C.1p){E}1Z=6.1w.4h(e);3T=6.C.O.J-6.C.1Z.y+1Z.y;3Q=6.C.O.H-6.C.1Z.x+1Z.x;3T=V.3m(V.4i(3T,6.C.1p.K.4b-6.C.P.L),6.C.1p.K.3t);3Q=V.3m(V.4i(3Q,6.C.1p.K.3X-6.C.P.T),6.C.1p.K.3w);f(1l 6.C.1p.K.6O===\'d\'){G 4g=6.C.1p.K.6O.1C(6.C.1p,[3Q,3T]);f(1l 4g==\'9L\'&&4g.2B==2){3Q=4g[0];3T=4g[1]}}6.C.1p.1r.J=3T+\'14\';6.C.1p.1r.H=3Q+\'14\';E 1k},2l:d(e){6(1a).33(\'4t\',6.C.5I).33(\'4B\',6.C.4w);6.C.W=q.W;6.C.1N=q.1N;6.C.1Z=6.1w.4h(e);f(6.C.W.K.6E){6.C.W.K.6E.1C(6.C.W,[q])}6.C.P={T:R(6(q.W).D(\'T\'))||0,L:R(6(q.W).D(\'L\'))||0};6.C.O={J:R(6(q.W).D(\'J\'))||0,H:R(6(q.W).D(\'H\'))||0};E 1k},4w:d(){6(1a).3o(\'4t\',6.C.5I).3o(\'4B\',6.C.4w);f(6.C.W.K.6C){6.C.W.K.6C.1C(6.C.W,[6.C.1N])}6.C.W=17;6.C.1N=17},3c:d(2y,5f){E V.4i(V.3m(6.C.P.T+2y*5f,6.C.W.K.4W),6.C.W.K.4U)},3e:d(2v,5f){E V.4i(V.3m(6.C.P.L+2v*5f,6.C.W.K.3V),6.C.W.K.4c)},6m:d(L){E V.4i(V.3m(L,6.C.W.K.3V),6.C.W.K.4c)},5I:d(e){f(6.C.W==17){E}1Z=6.1w.4h(e);2y=1Z.x-6.C.1Z.x;2v=1Z.y-6.C.1Z.y;X={T:6.C.P.T,L:6.C.P.L};1j={J:6.C.O.J,H:6.C.O.H};2c(6.C.1N){11\'e\':X.T=6.C.3c(2y,1);1d;11\'6B\':X.T=6.C.3c(2y,1);X.L=6.C.3e(2v,1);1d;11\'w\':X.T=6.C.3c(2y,-1);1j.H=6.C.O.H-X.T+6.C.P.T;1d;11\'59\':X.T=6.C.3c(2y,-1);1j.H=6.C.O.H-X.T+6.C.P.T;X.L=6.C.3e(2v,1);1d;11\'3H\':X.L=6.C.3e(2v,-1);1j.J=6.C.O.J-X.L+6.C.P.L;X.T=6.C.3c(2y,-1);1j.H=6.C.O.H-X.T+6.C.P.T;1d;11\'n\':X.L=6.C.3e(2v,-1);1j.J=6.C.O.J-X.L+6.C.P.L;1d;11\'58\':X.L=6.C.3e(2v,-1);1j.J=6.C.O.J-X.L+6.C.P.L;X.T=6.C.3c(2y,1);1d;11\'s\':X.L=6.C.3e(2v,1);1d}f(6.C.W.K.29){f(6.C.1N==\'n\'||6.C.1N==\'s\')2b=X.L*6.C.W.K.29;M 2b=X.T;2o=6.C.6m(2b*6.C.W.K.29);2b=2o/6.C.W.K.29;2c(6.C.1N){11\'n\':11\'3H\':11\'58\':1j.J+=X.L-2o;1d}2c(6.C.1N){11\'3H\':11\'w\':11\'59\':1j.H+=X.T-2b;1d}X.L=2o;X.T=2b}f(1j.J<6.C.W.K.3t){2o=X.L+1j.J-6.C.W.K.3t;1j.J=6.C.W.K.3t;f(6.C.W.K.29){2b=2o/6.C.W.K.29;2c(6.C.1N){11\'3H\':11\'w\':11\'59\':1j.H+=X.T-2b;1d}X.T=2b}X.L=2o}f(1j.H<6.C.W.K.3w){2b=X.T+1j.H-6.C.W.K.3w;1j.H=6.C.W.K.3w;f(6.C.W.K.29){2o=2b*6.C.W.K.29;2c(6.C.1N){11\'n\':11\'3H\':11\'58\':1j.J+=X.L-2o;1d}X.L=2o}X.T=2b}f(1j.J+X.L>6.C.W.K.4b){X.L=6.C.W.K.4b-1j.J;f(6.C.W.K.29){X.T=X.L/6.C.W.K.29}}f(1j.H+X.T>6.C.W.K.3X){X.T=6.C.W.K.3X-1j.H;f(6.C.W.K.29){X.L=X.T*6.C.W.K.29}}G 3n=1k;2x=6.C.W.1r;2x.H=1j.H+\'14\';2x.J=1j.J+\'14\';2x.T=X.T+\'14\';2x.L=X.L+\'14\';f(6.C.W.K.6J){3n=6.C.W.K.6J.1C(6.C.W,[X,1j]);f(3n){f(3n.P){6.1J(X,3n.P)}f(3n.O){6.1J(1j,3n.O)}}}2x.H=1j.H+\'14\';2x.J=1j.J+\'14\';2x.T=X.T+\'14\';2x.L=X.L+\'14\';E 1k},6z:d(16){f(!16||!16.1Q||16.1Q.2m!=9J){E}E q.2u(d(){G 8=q;8.K=16;8.K.4W=16.4W||10;8.K.3V=16.3V||10;8.K.4U=16.4U||4S;8.K.4c=16.4c||4S;8.K.3t=16.3t||-6K;8.K.3w=16.3w||-6K;8.K.3X=16.3X||4S;8.K.4b=16.4b||4S;5L=6(8).D(\'O\');f(!(5L==\'1I\'||5L==\'23\')){8.1r.O=\'1I\'}6s=/n|58|e|6B|s|59|w|3H/g;1E(i 1m 8.K.1Q){f(i.4y().6r(6s)!=17){f(8.K.1Q[i].2m==9I){3D=6(8.K.1Q[i]);f(3D.4E()>0){8.K.1Q[i]=3D.S(0)}}f(8.K.1Q[i].4q){8.K.1Q[i].W=8;8.K.1Q[i].1N=i;6(8.K.1Q[i]).33(\'3l\',6.C.2l)}}}f(8.K.2f){f(1l 8.K.2f===\'2k\'){4p=6(8.K.2f);f(4p.4E()>0){4p.2u(d(){q.4z=8});4p.33(\'3l\',6.C.3L)}}M f(8.K.2f.4q){8.K.2f.4z=8;6(8.K.2f).33(\'3l\',6.C.3L)}M f(8.K.2f==22){6(q).33(\'3l\',6.C.3L)}}})},6Z:d(){E q.2u(d(){G 8=q;1E(i 1m 8.K.1Q){8.K.1Q[i].W=17;8.K.1Q[i].1N=17;6(8.K.1Q[i]).3o(\'3l\',6.C.2l)}f(8.K.2f){f(1l 8.K.2f===\'2k\'){3D=6(8.K.2f);f(3D.4E()>0){3D.3o(\'3l\',6.C.3L)}}M f(8.K.2f==22){6(q).3o(\'3l\',6.C.3L)}}8.K=17})}};6.1M.1J({9G:6.C.6z,9H:6.C.6Z});',62,674,'||||||jQuery||el|||||function||if|||||easing||||||this||||callback||||||speed|fx|iResize|css|return|oldStyle|var|left|new|top|resizeOptions|height|else|interfaceFX|position|sizes|duration|parseInt|get|width|queue|Math|resizeElement|newSizes|type|delta||case|custom||px||options|null|display|firstNum|document|complete|es|break|elem|255|oldP|props|none|newPosition|false|typeof|in|tp|parseFloat|dragged|100|style|wb|ef|hb|dequeue|iUtil|direction|result|opacity|wrapper|show|apply|axis|for|body|curCSS|PI|relative|extend|wrs|step|fn|resizeDirection|toggle|times|handlers|DropOutDirectiont|slide|visibility|attr|transferEl|startTop|startLeft|vp|pointer||right|true|absolute|ifxFirstDisplay||down|color|out|ratio|percent|nWidth|switch|up|to|dragHandle|fxCheckTag|timer|indexOf|documentElement|string|start|constructor|endTop|nHeight|overflow|endLeft|nodeEl|OpenClose|borderTopWidth|each|dy|from|elS|dx|margins|hidden|length|hight|restoreStyle|cnt|borderLeftWidth|newStyles|clientScroll|block|puff|paddingRight|fontSize|paddingLeft|animationHandler|prop|old|iw|cs|fxh|oldVisibility|point|ih|hide|styles|cos|borderRightWidth|getSize|nmp|borderBottomWidth|bind|paddingTop|paddingBottom|end|replace|vertically|Function|parseColor|scrollTop|getWidth|close|getHeight|orig|Scale|BlindDirection|horizontally|128|wr|mousedown|max|newDimensions|unbind|eh|oldDisplay|rgb|0px|minTop|139|window|minLeft|rule|de|Date|getTime|et|F0|handle|np|cssRules|restore|nw|currentStyle|toInteger|efx|startDrag|parentNode|oldStyleAttr|0x|open|newLeft|scrollLeft|fA|newTop|marginTop|minHeight|namedColors|maxRight|parentEl|marginLeft||marginBottom||backgroundColor|object|test|marginRight||while|directionIncrement|bounceout|maxBottom|maxHeight|clientHeight|cssSides|clientWidth|newPos|getPointer|min|pr|targetEl|border|event|nodeName|destroyWrapper|handleEl|tagName|unit|exec|mousemove|192|sl|stop|211|toLowerCase|dragEl|9999|mouseup|cssText|DoFold|size|unfold|diffHeight|getValues|diffWidth|sideEnd|offsetWidth|styleSheets|borderColor|oldColor|offsetHeight|buildWrapper|getPosition|oldPosition|3000|5625|maxWidth|clearInterval|minWidth|png|opt|clear||margin|src|startTime|setInterval||zIndex|ScrollTo|ne|sw|st|self|sin|padding|pow|side|pause|borderTopSize|linear|firstStep|borderRightSize|1px|zoom|floatVal|asin|abs|bounce|pValue|borderWidth|browser|oldFloat|fontWeight|169|parseStyle|e2|cssSidesEnd|stopAnim|Color|bouncein|Pulsate|moveDrag|scrollWidth|shake|innerHeight|move|paddingLeftSize|shrink|elPosition|innerWidth|traverseDOM|filter|scrollHeight|windowSize|func|paddingBottomSize|borderLeftSize|stopDrag|getScroll|borderBottomSize|split|Shake|paddingTopSize||className|scroll|pulse|paddingRightSize|animate|createElement|itransferTo|div|onDragStop|onDragStart|images|vertical|insertBefore|setTimeout|styleFloat|horizontal|trim|isFunction|borderRightUnit|245|oldOverflow|getHeightMinMax|offsetTop|140|offsetParent|240|match|directions|offsetLeft|230|opera|224|144|165|build|notColor|se|onStop|parts|onStart|Width|107|colorCssProps|10000|onResize|1000|fxe|values|cssProps|onDrag|emptyGIF|togglehor|paddingLeftUnit|finish|ActiveXObject|easeout|150|firstChild|paddingBottomUnit|togglever|destroy|fold|topUnit|href|img|leftUnit||interfaceColorFX|getMargins|alpha|transparent|paddingRightUnit|iBounce|fontUnit|paddingTopUnit|borderBottomUnit|wid|grow|borderTopUnit|borderLeftUnit|option|float|darkred|darksalmon|238|204|153|lightpink|random|193|darkorchid|w_|frame|233|frameset|182|lightgrey|148|optgroup|getClient|khaki|130|216|getSizeLite|lightblue|173|getPositionLite|darkorange|indigo|gold|fuchsia|meta|darkviolet|215|green|removeChild|lightcyan|lightgreen|122|183|AlphaImageLoader|Microsoft|220||col|id|beige|DXImageTransform||progid|centerEl|purgeEvents|th|fixPNG|black|colgroup|Array|prototype|tfoot|listStyle|thead|tbody|cssFloat|caption|msie|lightyellow|aqua|azure|fxWrapper|tr|td|appendChild|blue|brown|textarea|select|iframe|getBorder|pageX|button|hr|input|darkmagenta|darkolivegreen|189|darkkhaki|getPadding|darkgreen|clientX|pageY|clientY|header|ul|dl|nextSibling|ol|script|table|darkcyan|darkgrey|darkblue|form|cyan|br|Number|DropToggleRight|Fold|UnFold|DropInRight|DropOutRight|DropInLeft|DropToggleLeft|FoldToggle|Grow|Highlight|CloseVertically|pt|em|Shrink|Puff|DropOutLeft|DropToggleUp|BlindLeft|BlindRight|BlindToggleVertically|BlindDown|elasticboth|BlindUp|BlindToggleHorizontally|Bounce|DropOutUp|DropInUp|lime|DropInDown|120|DropOutDown|CloseHorizontally|SwitchHorizontally|TransferTo|addClass|500|transferHelper|visible|SlideOutRight|SlideToggleRight|boxModel|append|Resizable|ResizableDestroy|String|Object|remove|array|SlideInRight|SlideToggleLeft|click|scrollTo|ScrollToAnchors|OpenHorizontally|SwitchVertically|OpenVertically|SlideInUp|SlideOutUp|SlideInLeft|SlideOutLeft|SlideToggleDown|SlideOutDown|SlideToggleUp|SlideInDown|elasticout|DropToggleDown|pink|Right|203|elasticin|purple|Top|orange|Bottom|dotted|olive|isNaN|stopAll|Left|red|silver|outlineWidth|textIndent|outlineOffset|lineHeight|bottom|letterSpacing|borderBottomColor|borderLeftColor|yellow|white|outlineColor|borderTopColor|borderRightColor|solid|dashed|RegExp|9375|selectorText|rules|double|easeboth|easein|100000000|navy|toUpperCase|borderStyle|ridge|groove|magenta|maroon|bounceboth|outset|625|inset|984375'.split('|'),0,{}));/*
 * Thickbox 3 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
var tb_pathToImage = "/lib/img/spinneronbg.gif";
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$(9).2t(8(){1o(\'a.15, 3a.15, 33.15\');1r=1s 1x();1r.P=2p});8 1o(b){$(b).o(8(){6 t=T.R||T.1U||I;6 a=T.q||T.1P;6 g=T.1F||O;1c(t,a,g);T.2l();L O})}8 1c(d,f,g){38{3(1y 9.r.J.20==="1t"){$("r","K").p({C:"1V%",v:"1V%"});$("K").p("2i","2A");3(9.1Z("1A")===I){$("r").z("<18 5=\'1A\'></18><4 5=\'F\'></4><4 5=\'7\'></4>");$("#F").o(A)}}n{3(9.1Z("F")===I){$("r").z("<4 5=\'F\'></4><4 5=\'7\'>");$("#F").o(A)}}3(d===I){d=""}$("r").z("<4 5=\'G\'><1C P=\'"+1r.P+"\' /></4>");$(\'#G\').2k();6 h;3(f.W("?")!==-1){h=f.2j(0,f.W("?"))}n{h=f}6 i=/\\.2f|\\.2d|\\.2b|\\.28|\\.26/g;6 j=h.25().24(i);3(j==\'.2f\'||j==\'.2d\'||j==\'.2b\'||j==\'.28\'||j==\'.26\'){1h="";1v="";Y="";1u="";1m="";Q="";1l="";1q=O;3(g){B=$("a[@1F="+g+"]").2Q();1T(u=0;((u<B.1b)&&(Q===""));u++){6 k=B[u].q.25().24(i);3(!(B[u].q==f)){3(1q){1u=B[u].R;1m=B[u].q;Q="<1a 5=\'1W\'>&19;&19;<a q=\'#\'>2C &2z;</a></1a>"}n{1h=B[u].R;1v=B[u].q;Y="<1a 5=\'21\'>&19;&19;<a q=\'#\'>&2w; 2u</a></1a>"}}n{1q=1O;1l="1x "+(u+1)+" 2s "+(B.1b)}}}V=1s 1x();V.1j=8(){V.1j=I;6 a=1I();6 x=a[0]-1H;6 y=a[1]-1H;6 b=V.v;6 c=V.C;3(b>x){c=c*(x/b);b=x;3(c>y){b=b*(y/c);c=y}}n 3(c>y){b=b*(y/c);c=y;3(b>x){c=c*(x/b);b=x}}Z=b+30;16=c+2r;$("#7").z("<a q=\'\' 5=\'1E\' R=\'1i\'><1C 5=\'2q\' P=\'"+f+"\' v=\'"+b+"\' C=\'"+c+"\' 1P=\'"+d+"\'/></a>"+"<4 5=\'2o\'>"+d+"<4 5=\'2n\'>"+1l+Y+Q+"</4></4><4 5=\'2m\'><a q=\'#\' 5=\'M\' R=\'1i\'>1g</a> 1f 1e 1n</4>");$("#M").o(A);3(!(Y==="")){8 X(){3($(9).S("o",X)){$(9).S("o",X)}$("#7").D();$("r").z("<4 5=\'7\'></4>");1c(1h,1v,g);L O}$("#21").o(X)}3(!(Q==="")){8 1d(){$("#7").D();$("r").z("<4 5=\'7\'></4>");1c(1u,1m,g);L O}$("#1W").o(1d)}9.14=8(e){3(e==I){E=1B.1z}n{E=e.2g}3(E==27){A()}n 3(E==39){3(!(Q=="")){9.14="";1d()}}n 3(E==37){3(!(Y=="")){9.14="";X()}}};13();$("#G").D();$("#1E").o(A);$("#7").p({N:"U"})};V.P=f}n{6 l=f.2a(/^[^\\?]+\\??/,\'\');6 m=2e(l);Z=(m[\'v\']*1)+30||36;16=(m[\'C\']*1)+35||34;12=Z-30;11=16-32;3(f.W(\'23\')!=-1){1D=f.1w(\'2Z\');$("#7").z("<4 5=\'22\'><4 5=\'1k\'>"+d+"</4><4 5=\'1G\'><a q=\'#\' 5=\'M\' R=\'1i\'>1g</a> 1f 1e 1n</4></4><18 2Y=\'0\' 2W=\'0\' P=\'"+1D[0]+"\' 5=\'1p\' 1U=\'1p\' J=\'v:"+(12+29)+"s;C:"+(11+17)+"s;\' 1j=\'1Q()\'> </18>")}n{3($("#7").p("N")!="U"){3(m[\'1X\']!="1O"){$("#7").z("<4 5=\'22\'><4 5=\'1k\'>"+d+"</4><4 5=\'1G\'><a q=\'#\' 5=\'M\'>1g</a> 1f 1e 1n</4></4><4 5=\'H\' J=\'v:"+12+"s;C:"+11+"s\'></4>")}n{$("#F").S();$("#7").z("<4 5=\'H\' 2U=\'2T\' J=\'v:"+12+"s;C:"+11+"s;\'></4>")}}n{$("#H")[0].J.v=12+"s";$("#H")[0].J.C=11+"s";$("#H")[0].2S=0;$("#1k").K(d)}}$("#M").o(A);3(f.W(\'2R\')!=-1){$("#H").K($(\'#\'+m[\'2P\']).K());13();$("#G").D();$("#7").p({N:"U"})}n 3(f.W(\'23\')!=-1){13();3(2O[\'1p\']===1t){$("#G").D();$("#7").p({N:"U"});$(9).2L(8(e){6 a=e.1z;3(a==27){A()}})}}n{$("#H").2K(f+="&2J="+(1s 2I().2H()),8(){13();$("#G").D();1o("#H a.15");$("#7").p({N:"U"})})}}3(!m[\'1X\']){9.2G=8(e){3(e==I){E=1B.1z}n{E=e.2g}3(E==27){A()}}}}2M(e){}}8 1Q(){$("#G").D();$("#7").p({N:"U"})}8 A(){$("#2N").S("o");$("#F").S("o");$("#M").S("o");$("#7").2F("2E",8(){$(\'#7,#F,#1A\').D()});$("#G").D();3(1y 9.r.J.20=="1t"){$("r","K").p({C:"1S",v:"1S"});$("K").p("2i","")}9.14="";L O}8 13(){$("#7").p({2D:\'-\'+1R((Z/2),10)+\'s\',v:Z+\'s\'});3(!(2B.2y.2V&&1y 2x==\'8\')){$("#7").p({2X:\'-\'+1R((16/2),10)+\'s\'})}}8 2e(a){6 b={};3(!a){L b}6 c=a.1w(/[;&]/);1T(6 i=0;i<c.1b;i++){6 d=c[i].1w(\'=\');3(!d||d.1b!=2){2v}6 e=1Y(d[0]);6 f=1Y(d[1]);f=f.2a(/\\+/g,\' \');b[e]=f}L b}8 1I(){6 a=9.31;6 w=1N.1M||1L.1M||(a&&a.2c)||9.r.2c;6 h=1N.1K||1L.1K||(a&&a.1J)||9.r.1J;2h=[w,h];L 2h}',62,197,'|||if|div|id|var|TB_window|function|document||||||||||||||else|click|css|href|body|px||TB_Counter|width||||append|tb_remove|TB_TempArray|height|remove|keycode|TB_overlay|TB_load|TB_ajaxContent|null|style|html|return|TB_closeWindowButton|display|false|src|TB_NextHTML|title|unbind|this|block|imgPreloader|indexOf|goPrev|TB_PrevHTML|TB_WIDTH||ajaxContentH|ajaxContentW|tb_position|onkeydown|thickbox|TB_HEIGHT||iframe|nbsp|span|length|tb_show|goNext|Esc|or|close|TB_PrevCaption|Close|onload|TB_ajaxWindowTitle|TB_imageCount|TB_NextURL|Key|tb_init|TB_iframeContent|TB_FoundURL|imgLoader|new|undefined|TB_NextCaption|TB_PrevURL|split|Image|typeof|keyCode|TB_HideSelect|event|img|urlNoQuery|TB_ImageOff|rel|TB_closeAjaxWindow|150|tb_getPageSize|clientHeight|innerHeight|self|innerWidth|window|true|alt|tb_showIframe|parseInt|auto|for|name|100|TB_next|modal|unescape|getElementById|maxHeight|TB_prev|TB_title|TB_iframe|match|toLowerCase|bmp||gif||replace|png|clientWidth|jpeg|tb_parseQuery|jpg|which|arrayPageSize|overflow|substr|show|blur|TB_closeWindow|TB_secondLine|TB_caption|tb_pathToImage|TB_Image|60|of|ready|Prev|continue|lt|XMLHttpRequest|browser|gt|hidden|jQuery|Next|marginLeft|fast|fadeOut|onkeyup|getTime|Date|random|load|keyup|catch|TB_imageOff|frames|inlineId|get|TB_inline|scrollTop|TB_modal|class|msie|hspace|marginTop|frameborder|TB_||documentElement|45|input|440|40|630|188|try|190|area'.split('|'),0,{}));(function($) {
	
	var helper, current, obj, contentbuffer, tID;
	
	// the public plugin method
	$.fn.Tooltip = function(settings) {

		// setup configuration
		settings = $.extend($.extend({}, arguments.callee.defaults), settings || {});

		// there can be only one tooltip helper
		if( !helper ) {
			// create the helper, h3 for title, div for url
			helper = $('<div id="tooltip"></div>')
				// hide it at first
				.hide()
				// move to top and position absolute, to let it follow the mouse
				.css({ position: 'absolute', zIndex: 3000 })
				// add to document
				.appendTo('body');
		}
		
		// bind events for every selected element
		$(this).each(function() {
			this.tSettings = settings;
		})
		// bind events
		.bind(settings.event, handle);
		return this;
	};
	
	// main event handler to start showing tooltips
	function handle(event) {
		
		// show helper, either with timeout or on instant
		current = this;
		if( this.tSettings.delay )
			tID = setTimeout(show, this.tSettings.delay);
		else
			show();
		
		// update at least once
		update(event);
		
		// hide the helper when the mouse moves out of the element
		$(this).bind('mouseout', hide);
	}
		
	// delete timeout and show helper
	function show() {
		tID = null;

		if (obj != current) {
			obj = current;
			$.get("/lib/ajx/tooltip?id="+obj.id, function(response) {
				helper.html(response);
				helper.show();
				update();
			});
		} else {
			helper.show();
			update();
		}
	}
	
	/**
	 * updates the helper position
	 * removes itself when no current element
	 */
	function update(event)	{
		// if no current element is available, remove this listener
		if( current == null ) {
			$('body').unbind('mousemove', update);
			return;	
		}
		
		var left = helper[0].offsetLeft;
		var top = helper[0].offsetTop;
		if(event) {
			// get the current mouse position
			function pos(c) {
				var p = c == 'X' ? 'Left' : 'Top';
				return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
			}
			// position the helper 15 pixel to bottom right, starting from mouse position
			left = pos('X') + 15;
			top = pos('Y') + 15;
			helper.css({
				left: left + 'px',
				top: top + 'px'
			});
		}
		
		var v = viewport(),
			h = helper[0];
		// check horizontal position
		if(v.x + v.cx < h.offsetLeft + h.offsetWidth) {
			left -= h.offsetWidth + 20;
			helper.css({left: left + 'px'});
		}
		// check vertical position
		if(v.y + v.cy < h.offsetTop + h.offsetHeight) {
			top -= h.offsetHeight + 20;
			helper.css({top: top + 'px'});
		}
	}
	
	function viewport() {
		var e = document.documentElement || {},
			b = document.body || {},
			w = window;

		return {
			x: w.pageXOffset || e.scrollLeft || b.scrollLeft || 0,
			y: w.pageYOffset || e.scrollTop || b.scrollTop || 0,
			cx: min( e.clientWidth, b.clientWidth, w.innerWidth ),
			cy: min( e.clientHeight, b.clientHeight, w.innerHeight )
		};

		function min() {
			var v = Infinity;
			for( var i = 0;  i < arguments.length;  i++ ) {
				var n = arguments[i];
				if( n && n < v ) v = n;
			}
			return v;
		}
	}
	
	// hide helper and restore added classes and the title
	function hide() {
		// clear timeout if possible
		if(tID)
			clearTimeout(tID);
		// no more current element
		current = null;
		helper.hide();
		
		// restore title and remove this listener
		$(this).unbind('mouseout', hide);
	}
	
	// define global defaults, editable by client
	$.fn.Tooltip.defaults = {
		delay: 250,
		event: "mouseover",
		track: false,
		showURL: true,
		showBody: null,
		extraClass: null,
		fixPNG: false
	};

})(jQuery);var uploadfileid = 0;
var viewport;
var uploadtimer = false;
var currentuploadelement = 'filupload';
var currentuploadvalue = false;
var roundupsent = false;
var uparrow = new Image();
uparrow.src = "/lib/img/blackarrow_up.png";
var tinyMCEprefs = {
	theme: "advanced",
	plugins: "sprflink,inlinepopups,sprfembedmedia,sprfimage",
	mode: "specific_textareas",
	relative_urls: false,
	editor_selector: "mceEditor",
	language: "en",
	docs_language: "en",
	theme_advanced_styles: "Subheading 1=contenthead1;Subheading 2=contenthead2;Block quote=contentblockquote;Code=contentkbd",
	theme_advanced_toolbar_location: "top",
	theme_advanced_toolbar_align: "left",
	theme_advanced_buttons1: "styleselect,bold,italic,underline,strikethrough,separator,cut,copy,paste,separator,justifyleft,justifycenter,justifyright,separator,bullist,numlist,separator,undo,redo,separator,link,unlink,separator,sprfimage,sprfembedmedia",
	theme_advanced_buttons2: "",
	theme_advanced_buttons3: "",
	onchange_callback: "testAndCleanEditorContents",	
	paste_use_dialog: false
}

if ((typeof(pagetype) != "undefined") && pagetype == "roundup") {
	tinyMCEprefs.theme_advanced_buttons1 = "bold,italic,underline,strikethrough,separator,cut,copy,paste,separator,bullist,numlist,separator,undo,redo,separator,link,unlink";
}

if (typeof(tinyMCE) != "undefined") tinyMCE.init(tinyMCEprefs);

// Workaround for bug in jquery 1.1.1 responsible for support request 5682
function onPageLoad(fnc) {
	if (document.all) {
			var oldonload = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = fnc;
			} else {
				window.onload = function() {
					oldonload();
					fnc();
				}
			}
	}
	else $(document).ready(fnc);
}


onPageLoad(function() {
	h3toImagetext();
	$("div.minicalendar").each(function() {
		var caltype = $(this).attr("id");
		var path = location.href.replace(/^.*?(\/[0-9\/]*)?$/, "$1");
		$(this).load("/lib/ajx/calendar/"+caltype+path);
	});
	if (!$("#txtusername").val()) $("#txtusername").val("Username");
	if (!$("#txtpassword").val()) $("#txtpassword").val("Password");
	if (!$("#txtregusername").val()) $("#txtregusername").val("Username");

	// Show and hide 'more options' on focus/blur of loginbox in top-right
	$("#txtusername,#txtpassword").focus(function() {
		if (typeof(moreOptsTimeout) != "undefined") window.clearTimeout(moreOptsTimeout);
		var hidden = ($('#loginformmoreopts').css('display') == "none");
		if (hidden) toggleloginboxmoreopts("in");
	}).blur(function() {
		var showing = ($('#loginformmoreopts').css('display') == "block");
		if (showing) {
			moreOptsTimeout = window.setTimeout(function() {
				toggleloginboxmoreopts("out");	
			},100);
		}
	});


	$("input.hintonblur").each(function(){
		if ($(this).val() == $(this).attr("title")) $(this).css("color", "#aaa");
	});
	$("input.hintonblur").focus(function(){
		if ($(this).val() == $(this).attr("title")) $(this).val("").css("color", "black");
	});
	$("input.hintonblur").blur(function(){
		if ($(this).val() == $(this).attr("title") || !$(this).val()) $(this).val($(this).attr("title")).css("color", "#aaa");
	});

	if (window.attachEvent) { 
		window.attachEvent("onresize", resizeHandler);
	} else {
		window.addEventListener("resize", resizeHandler, false);
	}

	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	var image = document.createElement('img');
	image.src='/lib/img/buttons/button/Upload/upload';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file hidden';
		x[i].style.filter = "alpha(opacity:0)";
		x[i].style.KHTMLOpacity = 0;
		x[i].style.MozOpacity = 0;
		x[i].style.opacity = 0;
		var clone = fakeFileUpload.cloneNode(true);
		$(x[i].parentNode).prepend(clone);
		if (!x[i].onchange) x[i].onchange = doFileUpload;
	}

	if ($("#frmpostedit")) {
		setTimeout(autoSave, 60000);
	}

	$("ul.files li").Tooltip();
	$("ul.feeds.shortindent li").Tooltip({delay:2});
	$("ul.socialbookmarking li").Tooltip();

	$("ol.versionhistory li").click(function() {
		$(this).toggleClass("selectedfordiff");
		var numsel = $("ol.versionhistory li.selectedfordiff").length;
		if (numsel > 2) {
			$(this).toggleClass("selectedfordiff");
			alert("Please select only two versions.  You can unselect one that you have already selected - just click it again");
		} else if (numsel == 2) {
			runVersionDiff();
		} else {
			$("#diffviewinfo").css("display", "block");
			$("#diffoutput").css("display", "none");
			$("#versionkey").css("top", "6");
		}
	});

	$("form.firstfocus :input").focus(displayFormHelp);
	$("form.firstfocus :input").blur(function() { $("div.formhelp").css("display", "none");} );
	if ($("form.firstfocus :input").eq(0).offsetHeight) $("form.firstfocus :input").eq(0).focus();

	$("table.actionstable tr:odd").css("background-color", "#eee");
	
	if ($.browser.safari) {
		var version = $.browser.version;
		if (version.indexOf("." > 0)) version = version.substring(0, version.indexOf("."));
		if (version < 450) {
			$("#maincontent").prepend("<div style='margin: 0 -349px 0 -165px; color: rgb(255,255,255); padding: 10px; border-top: 10px solid rgb(200,200,200); border-bottom: 10px solid rgb(200,200,200); background: rgb(100,120,180); text-align: center;'>Hello!  We notice you're browsing the site with Safari 2.  We're working hard to iron out the remaining issues with Safari, namely image and file uploads and post editing.  Until then, why not try <a href='http://www.mozilla.com/en-US/firefox/' style='color: white; text-decoration: underline;'>Firefox</a> or - if you're brave - the <a href='http://www.apple.com/safari/' style='color: white; text-decoration: underline;'>Safari 3 beta</a>?</div>");
		}
	}

	$("#frmforwardtopayment").each(function(){
		window.setTimeout(function(){
			$("#frmforwardtopayment").submit();
		}, 2500);
	});

	// Wrap post metadata on any character (not just whitespace)
	// This is handled by CSS for IE but needs to be done by javascript for FF
	if (!document.all) {
		$("tr.metadata td, ul.files li").each(function() {
			var ele;
			var lnk = $(this).find("a");
			obj = ((lnk.length)?lnk:$(this));
			obj.html(str_split(obj.html(), 1).join("&#8203;"));
		});
	}

	resizeHandler();



});


function str_split ( f_string, f_split_length){
	// http://kevin.vanzonneveld.net
	// +     original by: Martijn Wieringa
	// +     improved by: Brett Zamir
	// +     bugfixed by: Onno Marsman
	// *         example 1: str_split('Hello Friend', 3);
	// *         returns 1: ['Hel', 'lo ', 'Fri', 'end']

	f_string += '';

	if (f_split_length == undefined) {
		f_split_length = 1;
	}
	if(f_split_length > 0){
		var result = [];
		while(f_string.length > f_split_length) {
			result[result.length] = f_string.substring(0, f_split_length);
			f_string = f_string.substring(f_split_length);
		}
		result[result.length] = f_string;
		return result;
	}
	return false;
}


//TinyCME custom onchange handler
function testAndCleanEditorContents(inst) {
	var oldhtml = inst.getBody().innerHTML;
	var newhtml = cleanHTML(oldhtml);
	if (newhtml != oldhtml) {
		var marker = inst.selection.getBookmark();
		tinyMCE.setContent(newhtml);
		inst.selection.moveToBookmark(marker);
	}
	return true;
}

// Adapted from FckEditor ("cleanWord()")
function cleanHTML(html) {

	// Remove Tags with XML namespace declarations: <o:p><\/o:p>
	html = html.replace(/<\/?\w+:[^>]*>/gi, "" ) ;
	html = html.replace(/<o:p>\s*<\/o:p>/gi, "") ;
	html = html.replace(/<o:p>[\s\S]*?<\/o:p>/gi, "&nbsp;") ;

	// Remove empty spans.
	html = html.replace( /<span\s*[^>]*>\s*&nbsp;\s*<\/span>/gi, "&nbsp;" ) ;
	html = html.replace( /<span\s*[^>]*><\/span>/gi, "" ) ;

	// Replace spans with no attributes with their contained text
	html = html.replace( /<span\s*>([\s\S]*?)<\/span>/gi, "$1" ) ;

	// Remove Lang attributes
	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3" ) ;

	// Remove XML elements and declarations
	html = html.replace(/<\\?\?xml[^>]*>/gi, "" ) ;

	// Replace inline elements containing only a space with just a space
	html = html.replace( /<(u|i|strike|strong|em|b)>&nbsp;<\/\1>/gi, "&nbsp;" ) ;

	// Remove comments
	html = html.replace(/<\!--(?!\s*sprfembed)[\s\S]*?-->/gi, "" ) ;

	// Remove empty headings
	html = html.replace( /<(h\d)>\s*<\/\1>/gi, "" ) ;

	// Word likes to insert extra <em> and <font> tags, when using MSIE. (Wierd).
	html = html.replace( /<(h\d)><em>([\s\S]*?)<\/em><\/\1>/gi, "<$1>$2<\/$1>" );

	// Remove images with file:/// in the src attribute
	html = html.replace( /<img[^>]+src=[\"\']file\:.*?>/gi, "");

	// Remove <script> and <noscript> sections
	html = html.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,"");
	html = html.replace(/<noscript[^>]*>([\s\S]*?)<\/noscript>/gi,"");


	/* Attempt to recognise pasted <OBJECT> and <EMBED> content */

	var oldlength;
	oldlength = html.length;
	var regex = /(<!--\s*sprfembedstart\s*-->)?(<object.*?>.*?<\/object>)(<!--\s*sprfembedend\s*-->)?/i;
	var offsets = new Array();
	var replacements = new Array();
	for (i=0;html.search(regex) != -1;i++) {
		i++;
		var whole = html.match(regex)[0];
		var length = whole.length;
		var offset = html.search(regex);
		var sprfembedstarttag = html.match(regex)[1];
		var sprfembedendtag = html.match(regex)[3];

		// Replace OBJECT tag with placeholder
		var before = html.substring(0,offset);
		var after = html.substring(offset+length);
		html = before+"<!--sprfimportplaceholder"+i+"-->"+after;

		// Mark up with sprfembed comments (check first they are not already, just in case;
		// they should not be, but we may as well check here
		if (!sprfembedstarttag) whole = "<!-- sprfembedstart -->"+whole;
		if (!sprfembedendtag) whole = whole+"<!-- sprfembedend -->";

		// Store the marked up embed, and offset, in arrays
		offsets.push(offset);
		replacements.push(whole);
	}

	// Mark up remaining <EMBED> tags via a regex replace
	html = html.replace(/(<embed.*?)\/?\s*>/ig, "<!-- sprfembedstart -->$1/><!-- sprfembedend -->");

	// Substitute back the original <OBJECT> tags
	for (index in replacements) {
		var n = (parseInt(index)+1);
		html = html.replace("<!--sprfimportplaceholder"+n+"-->",replacements[index]);
	}

	// Clean and resize embeds
	if (html.length != oldlength) html = TinyMCE_SPRFEmbedMediaPlugin["cleanup"]("insert_to_editor", html);

	// Remove forms
	html = html.replace(/<input[\s\S]*? \/>/gi,"");
	html = html.replace(/<input[\s\S]*?><\/input>/gi,"");
	html = html.replace(/<textarea[\s\S]*?>([\s\S]*?)<\/textarea>/gi,"<p>$1</p>");

	// Remove formatting
	html = html.replace( /\s*class=[\"\'](?!(?:contenthead1[\"\']|sprfembeddedmedia[\"\']|inlinepostphoto[\"\']|contenthead2[\"\']|contentblockquote[\"\']|contentkbd[\"\']))[^\"\']*[\"\']/gi,'');
	html = html.replace( /\s*style=[\"\'][^\"]*[\"\']/gi,"");
	html = html.replace( /<font[\s\S]*?>([\s\S]*?)<\/font>/gi,"$1");

	// Convert all headings to <p class="contenthead1">
	html = html.replace( /<(h\d)[^>]*>([\s\S]*?)<\/\1\s*>/gi,"<p class='contenthead1'>$2</p>" );

	return html ;
}

function resizeHandler() {
	var e = document.documentElement || {},
		b = document.body || {},
		w = window;

	viewport = {
		width: min( e.clientWidth, b.clientWidth, w.innerWidth ),
		height: min( e.clientHeight, b.clientHeight, w.innerHeight )
	};
	
	function min() {
		var v = Infinity;
		for( var i = 0;  i < arguments.length;  i++ ) {
			var n = arguments[i];
			if( n && n < v ) v = n;
		}
		return v;
	}
}

function h3toImagetext() {
	$("h3").each(function() {
		var str = $(this).html();
		if (str) {
			$(this).html("").css("background", "url(http://convergenceconversation.com/lib/img/imagetext/11107907907925525525514/"+encodeURIComponent(str)+") no-repeat");
		}
	});
}

function displayFormHelp() {
	$("div.formhelp").css("display", "none");
	var frmelid = $(this).attr("id");
	if ($("#hlp_"+frmelid).length > 0) {
		var offset = $(this).offset();
		var leftoffset = (($.browser.msie || $.browser.safari)?0:1) + 1;
		$("#hlp_"+frmelid).css("display", "block").css({left: $("#contextnav").offset().left-$("#pagecontainer").offset().left-leftoffset, top: (offset.top+(offset.height/2)-($("#hlp_"+frmelid).outerHeight()/2))});
	}
}


function loadCal(calobj, path) {
	while(calobj.tagName != "DIV") calobj = calobj.parentNode;
	var caltype = $(calobj).attr("id");
	$(calobj).html("<div class=\"waitspinnerbig\"></div>").load("/lib/ajx/calendar/"+caltype+path);
}

function doLogin(fieldprefix) {
	var d=new Date();var lt=Math.floor(d.getTime()/1000);
	if (typeof(fieldprefix) == "undefined") fieldprefix = "";
	if (!$("#txt"+fieldprefix+"username").val() || $("#txt"+fieldprefix+"username").val() == "Username" || !$("#txt"+fieldprefix+"password").val() || $("#txt"+fieldprefix+"password").val() == "Password") {
		alert("Remember to fill in both your username (or email address) and password before you click 'Sign in'");
		$("#txt"+fieldprefix+"username").get(0).focus();
	} else {
		$("#"+fieldprefix+"logincontent1").css("display", "none");
		$("#"+fieldprefix+"logincontent2").css("display", "block");
		var redir = parseQueryString('redir');
		var curpath = window.location.pathname;
		if (redir && curpath.indexOf(redir) != 0 && redir.indexOf(curpath) != 0) {
			var targetpage = redir;
		} else if (curpath.indexOf("/register") == 0) {
			var targetpage = "/";
		} else {
			var targetpage = window.location;
		}
		$.post("/lib/ajx/login", {u:$("#txt"+fieldprefix+"username").val(),p:$("#txt"+fieldprefix+"password").val(),r:($("#chk"+fieldprefix+"rememberme").attr("checked")?"1":""),lt:lt, ajx:1,targetpage:targetpage}, function(response){
			if (response == "OK") {
				if (targetpage != window.location) {
					window.location = targetpage;
				} else {
					window.location.reload();
				}
			} else {
				alert(response);
				$("#"+fieldprefix+"logincontent1").css("display", "block");
				$("#"+fieldprefix+"logincontent2").css("display", "none");
				$("#txt"+fieldprefix+"username").get(0).focus();
			}
		});
	}
}

function doFileUpload() {
	if ($("#filupload").val()) {
		$("#frmattach").get(0).target = "uploadframe";
		$("#frmattach").get(0).submit();
		$("#uploadpanel1").css("display", "none");
		$("#uploadpanel2").css("display", "block");

		// Replace file upload field with a blank one, to allow the same file to be uploaded twice in a row.
		$('#filupload').after('<input id=\'filupload\' class=\'file hidden\' type=\'file\' size=\'9\' name=\'file\' >').remove();
		$('#filupload').css("opacity","0");
		$('#filupload').change(doFileUpload);
	}
}

function fileUploadStatus(status, msg, id) {
	if (status=="fail") {
		alert(msg);
		$("#uploadpanel1").css("display", "block");
		$("#uploadpanel2").css("display", "none");
	} else {
		uploadfileid = id;
		$("#spnuploadedfile").html(msg);
		dialogShow("copyright");
	}
}

// Function to begin a loop monitoring whether a file upload is
// being attempted.  Polling required because Safari won't upload
// files as a result of an onChange event for security reasons, but
// does allow onClick - so we start this in an onClick instead of using
// an onChange, so the upload is "triggered" via an onClick.
function beginFileUploadMonitoring(id) {
	
	// Reset tracking variables
	if (uploadtimer) clearTimeout(uploadtimer);
	if (currentuploadvalue) currentuploadvalue = false;
	if (currentuploadelement) currentuploadelement = false;
	
	// Record the initial value of the file input element
	currentuploadvalue = $("#"+id).val();
	currentuploadelement = id;
	
	// Begin the monitoring loop
	uploadtimer = window.setTimeout(fileUploadMonitoringTick, 3000);
}

function fileUploadMonitoringTick() {
	var fileinput = $("#"+currentuploadelement);

	// Reset timer variable  if necessary to avoid overzealous polling
	if (uploadtimer) clearTimeout(uploadtimer);

	if (!fileinput) return;

	// Trigger the upload if appropriate...
	if (currentuploadvalue != fileinput.val()) {
		currentuploadvalue = fileinput.val();
	
		var formelement = false;
		var currentelement = fileinput.get(0);
		while (currentelement.parentNode && !formelement) {
			currentelement = currentelement.parentNode;
			if (currentelement.tagName == "FORM") formelement = currentelement;
		}
		if (formelement) {
			formelement.submit();
		}
		
	// ...otherwise, continue the poll.
	} else {
		uploadtimer = window.setTimeout(fileUploadMonitoringTick, 300);
	}
}

function setCopyright(copyid) {
	dialogHide("copyright");
	$.post("/lib/ajx/setcopyright", {versionid:versionid,fileid:uploadfileid,copyid:copyid}, function(response) {
		$("#lstfiles li.emptylistplaceholder").remove();
		$("#lstfiles").append(response);
		$("#uploadpanel1").css("display", "block");
		$("#uploadpanel2").css("display", "none");
	});
}
function cancelUpload() {
	$("#ifrupload").get(0).src = "about:blank";
	$("#uploadpanel1").css("display", "block");
	$("#uploadpanel2").css("display", "none");
}
function removeFile(id) {
	$("#fileli_"+id).remove();
	if ($("#lstfiles li").length == 0) $("#lstfiles").append("<li class=\"emptylistplaceholder\">No files</li>");
	$.post("/lib/ajx/remfile", {versionid:versionid,fileid:id});
	$("#tooltip").hide();
}

function addTag() {
	$("#lnkaddtag").get(0).blur();
	var t = $("#txttag").val();
	if (t && t != "new tag") {
		$.post("/lib/ajx/addtag", {versionid:versionid,tag:t}, function(response) {
			if (response.substring(0,3)=="ERR") {
				alert(response.substring(3));
			} else {
				$("#lsttags li.emptylistplaceholder").remove();
				$("#lsttags").append(response);
			}
			$("#txttag").val("").get(0).focus();
		});
	}
}
function removeTag(tag) {
	$("#tagli_"+tag).remove();
	if ($("#lsttags li").length == 0) $("#lsttags").append("<li class=\"emptylistplaceholder\">No tags</li>");
	$.post("/lib/ajx/remtag", {versionid:versionid,tag:tag});
}

function addCategory() {
	$("#lnkaddcat").get(0).blur();
	var field = $("#selcat").get(0);
	var c = field.options[field.selectedIndex].value;
	if (c && c!="0") {
		$.post("/lib/ajx/addcat", {versionid:versionid,catid:c}, function(response) {
			if (response.substring(0,3)=="ERR") {
				alert(response.substring(3));
			} else {
				$("#lstcats li.emptylistplaceholder").remove();
				$("#lstcats").append(response);
			}
		});
	}
}
function removeCategory(id) {
	$("#catli_"+id).remove();
	if ($("#lstcats li").length == 0) $("#lstcats").append("<li class=\"emptylistplaceholder\">No categories</li>");
	$.post("/lib/ajx/remcat", {versionid:versionid,catid:id});
}

function dialogShow(name) {
	if (!viewport) return false;
	dialogHide();
	var id = "dlg"+name;
	if (!$("#"+id).length) {
		var baseid = "dlgbase"+name;
		$("<div id=\""+id+"\" class=\"dialogbox\"><div class=\"dialoginner\"></div></div>").appendTo(document.body);
	
		 /* If this is a comments dialog, add the recaptcha form
			without moving the script tags around in the DOM
			(which causes the window to blank) */
		 if ($("#"+baseid).find(".sprfrecaptcha").length) {
			 var recaptchaform = $("#sprfrecaptchaform");
			 $("script", recaptchaform).remove();
			 $("#"+baseid).find(".sprfrecaptcha").html($(recaptchaform).html());
			 $("#sprfrecaptchaform *:not(script)").remove();
		 }

		var dialoghtml = $("#"+baseid).html();
		$("#"+baseid).remove();
		$("#"+id+" .dialoginner").html(dialoghtml);
	}
	centreDialog($("#"+id));
	$("#mce_editor_0").css("visibility", "hidden");
	$("object, embed").css("visibility", "hidden");
	$("#"+id).css("visibility", "visible");

	// Hack to force IE6 to redraw all the elements
	// inside the dialog (it does not display buttons otherwise)
	$("#"+id+" *").each(function(){
		if ($(this).css("display") != "none") {
			$(this).hide();
			$(this).show();			
		}
	});

	return true;
}
function dialogHide() {
	$("div.dialogbox").css("visibility", "hidden");
	$("#mce_editor_0").css("visibility", "visible");
	$("object, embed").css("visibility", "visible");
}

function centreDialog(jqo) {
	jqo.css("left", ((viewport.width-jqo.outerWidth())/2)+"px").css("top", Math.max(5, $(document).scrollTop()+((viewport.height-jqo.outerHeight())/2))+"px");
}

function autoSave() {
	if (typeof(tinyMCE) != "undefined" && typeof(versionid) != "undefined") {
		testAndCleanEditorContents(tinyMCE.getInstanceById("mce_editor_0"));
		var strtext = tinyMCE.getContent();
		$("#posteditbuttonblock").append("<div id=\"autosavespin\">Autosaving</div>");
		var postobj = {versionid:versionid,text:strtext};
		$("#frmpostedit div.writefield input").each(function() { postobj[$(this).attr("name")] = $(this).val(); });
		$("#frmpostedit div.writefield select").each(function() { postobj[$(this).attr("name")] = this.options[this.selectedIndex].value; });
		$.post("/lib/ajx/autosave", postobj, function(response) {
			if (response != "OK") {
				alert(response);
			}
			$("#autosavespin").remove();
		});
		setTimeout(autoSave, 60000);
	}
}

function saveContent() {
	saveinprogress = 1;
	testAndCleanEditorContents(tinyMCE.getInstanceById("mce_editor_0"));
	if (firstdraft==1) {
		$("#txtcomment").val("Initial revision");
		editPermissions(1);
	} else if (firstdraft == 0) {
		if (dialogShow("changecomment")) {
			$("#txtcomment").get(0).focus();
			firstdraft = -1;
		}
	} else {
		$("#hidcomment").val($("#txtcomment").val());
		$("#frmpostedit").get(0).submit();
	}

}
function cancelEdit() {
	if (confirm("Are you sure you want to discard your changes and release your lock on this post?")) {
		$("#hidcancel").val("cancel");
		$("#frmpostedit").get(0).submit();
	}
}

function editPermissions(stage) {
	if (saveinprogress) {
		if (!userhascommunities) {
			$('.permissionsstage1subtitle').html("");
			$('.permissionsstage2subtitle').html("");
			$("#permissionssettitle").html("Save your post");
		} else {
			$('.permissionsstage1subtitle').html("(1 of 2 - which blogs does this post appear in?)");
			$('.permissionsstage2subtitle').html("(2 of 2 - who can see, edit and comment on this post?)");
			$("#permissionsselecttitle").html("Save your post");
			$("#permissionssettitle").html("Save your post");
		}
	} else {
		$('.permissionsstage1subtitle').html("");
		$('.permissionsstage2subtitle').html("");
		$("#permissionsselecttitle").html("Where do you want to post this?");
		$("#permissionssettitle").html("Who do you want to share this with?");
	}
	if (stage == 1 && !userhascommunities) stage=2;
	if (stage == 1) {
		$('.permissionsstage1subtitle').addClass("curstage").removeClass("othstage");
		$('.permissionsstage2subtitle').removeClass("curstage").addClass("othstage");
		$("#perms1content").css("display", "none");
		$("#perms1wait").css("display", "block");
		dialogShow("permissionsselect");
		$.post("/lib/ajx/setpermissions", {stage:1,versionid:versionid}, function(response) {
			$("#frmpermissionsselect").html(response);
			$("#perms1content").css("display", "block");
			$("#perms1wait").css("display", "none");
			dialogShow("permissionsselect");
		});
	} else if (stage == 2) {
		$('.permissionsstage1subtitle').removeClass("curstage").addClass("othstage");
		$('.permissionsstage2subtitle').addClass("curstage").removeClass("othstage");
		var selects = $("#frmpermissionsselect input");
		var selcol = "#99FF66";
		var stdcol = "#f2f2f2";
		var postvars = {versionid:versionid,stage:2};
		if (selects.length) {
			postvars["update"] = 1;
			selects.each(function() {
				postvars[$(this).attr("id")] = ($(this).get(0).checked) ? 1 : 0;
			});
		}
		dialogHide();
		$("#perms2content").css("display", "none");
		$("#perms2wait").css("display", "block");
		dialogShow("permissionsset");
		$.post("/lib/ajx/setpermissions", postvars, function(response) {
			$.get("/lib/ajx/getpermissions", {versionid:versionid}, function(response) {
				$("#lstpermissions").html(response);
			});
			$("#frmpermissionsset tbody").html(response);
			$("#perms2content").css("display", "block");
			$("#perms2wait").css("display", "none");
			$("#frmpermissionsset tbody tr").each(function() {
				var classes = $(this).attr("class");
				if (classes.indexOf("levelview") != -1) {
					$("input.view", this).check().parent().css("background-color", selcol);
				} else if (classes.indexOf("levelcomment") != -1) {
					$("input.view", this).check().parent().css("background-color", selcol);
					$("input.comment", this).check().parent().css("background-color", selcol);
				} else if (classes.indexOf("leveledit") != -1) {
					$("input", this).check().parent().css("background-color", selcol);
				}
				if (classes.indexOf("disabled") != -1) {
					$("input", this).each(function() { this.disabled = true });
				} else if (classes.indexOf("mustview") != -1) {
					$("input.view", this).each(function() { this.disabled = true });
				}
			});
			$("#frmpermissionsset input").click(function() {
				var thisrow = $(this).parent().parent();
				var inputchecked = $(this).get(0).checked;
				var editedlevel = $(this).attr("class");
				var dependencyorder = (inputchecked)?{"view":1, "comment":2, "edit":3}:{"view":3, "comment":2, "edit":1};
				var inputclass;

				$("input", thisrow).each(function() {
					inputclass = $(this).attr("class");
					if (inputclass.indexOf("disabled") == -1 && dependencyorder[editedlevel] >= dependencyorder[inputclass]) {
						$(this).check(inputchecked).parent().css("background-color", (inputchecked)?selcol:stdcol);
					}
				});
				if (thisrow.attr("id") == "permrow_all" && inputchecked) $("input", thisrow.parent()).each(function() {
					inputclass = $(this).attr("class");
					if (inputclass.indexOf("disabled") == -1 && dependencyorder[editedlevel] >= dependencyorder[inputclass]) {
						$(this).check().parent().css("background-color", selcol);
					}
				});
				if (thisrow.attr("id") != "permrow_all" && !inputchecked) $("input", $("#permrow_all")).each(function() {
					inputclass = $(this).attr("class");
					if (dependencyorder[editedlevel] >= dependencyorder[inputclass]) {
						$(this).uncheck().parent().css("background-color", stdcol);
					}
				});
			});
			dialogShow("permissionsset");
		});
	} else if (stage==3) {
		var postvars = {versionid:versionid,stage:3};
		$("#frmpermissionsset tbody tr").each(function() {
			var maxlevel = "none";
			$("input", this).each(function() { if (this.checked) maxlevel = this.className; });
			postvars[$(this).attr("id")] = maxlevel;
		});
		dialogHide();
		$.post("/lib/ajx/setpermissions", postvars, function(response) {
			$("#lstpermissions").html(response);
		});
		if (saveinprogress) {
			firstdraft = -1;
			saveContent();
		}
	}
}


function openComment() {
	if (dialogShow('commentform')) $("#txtcomment").get(0).focus();
}
function postComment() {
	if (!$("#txtcomment").val()) {
		alert("Please supply a comment before you click 'Submit'");
		$("#txtcomment").get(0).focus();
	} else {
		$("#commentpostbuttonblock").append("<div id=\"autosavespin\" class=\"inlinebigspinner\">Submitting your comment</div>");
		var postdata = {postid:$("#hidpostid").val(), comment:$("#txtcomment").val(), js:1};
		if ($("#frmcomment_email").length) {
			postdata.email = $("#frmcomment_email").val();
		}
		if ($("#frmcomment_authorname").length) {
			postdata.authorname = $("#frmcomment_authorname").val();
		}
		if ($("#frmcomment_authorurl").length) {
			postdata.authorurl = $("#frmcomment_authorurl").val();
		}
		if ($("#recaptcha_challenge_field").length) {
			postdata.recaptcha_challenge_field = $("#recaptcha_challenge_field").val();
			postdata.recaptcha_response_field = $("#recaptcha_response_field").val();
		}
		$.post("/lib/ajx/comment", postdata, function(response) {

			// Refresh recaptcha widget, if neccessary
			if (typeof(response.refreshrecaptcha) != "undefined") {

				$("#newrecaptchaform").remove();
				$("body").append("<iframe id='newrecaptchaform' src='/lib/ajx/recaptchawidget' style='width:0;height:0;'></iframe>");
				$("#newrecaptchaform").load(function() {
					var newrecaptchawidget = $(this).contents().find("#sprfrecaptchaform");
					$("script", newrecaptchawidget).remove();
					$(".sprfrecaptcha").html($(newrecaptchawidget).html());
					processResponse();
				});
			
			// If not necessary to refresh recaptcha, move straight onto next section
			} else {
				processResponse();
			}

			// Add new comment to comments section of page, or show feedback
			function processResponse() {
				if (response.result != "ok") {
					if (typeof(response.msg) != "undefined") {
						alert(response.msg);
					} else {
						alert("There was a problem posting your comment.  We're sorry for the inconvenience - please try again or contact us for assistance");
					}
				} else {
					$("#txtcomment").val("");
					var commentitem = $(response.commentitem).html();
					var randomnum = Math.round(10000 * Math.random());
					$("<li id=\"newcomment"+randomnum+"\">"+commentitem+"</li>").appendTo("ol.comments");
					$("ol.comments li.emptylistplaceholder").hide();
					$("#newcomment"+randomnum).ScrollTo("slow");
				}
				$("#autosavespin").remove();
				if (response.result != "validationerror") {
					dialogHide('commentform');
				}
			}
		}, "json");
	}
}

function getPaginatedList(type, id, start, perpage) {
	$.getJSON("/lib/ajx/getcontextlistpage", {type:type, id:id, start:start, perpage:perpage}, function (json) {
		if (json.error) {
			alert(json.error);
			return;
		}
		var moretext = '<em>...and '+json.others+' others.</em><br />';
		if (start) moretext += '<a href="javascript:getPaginatedList(\''+type+'\', '+id+', '+(start-perpage)+', '+perpage+');">&laquo; View previous '+perpage+'</a><br />';
		if (json.total > (start+perpage)) moretext += '<a href="javascript:getPaginatedList(\''+type+'\', '+id+', '+(start+perpage)+', '+perpage+');">View next '+perpage+' &raquo;</a><br />';
		$('#'+type+'moredetails').html(moretext);
		$('#'+type+'list').html(decodeURIComponent(json.listhtml));
	});
}

function runVersionDiff() {
	var ids = new Array();
	$("ol.versionhistory li.selectedfordiff").each(function() {
		ids[ids.length] = $(this).attr("id");
	});
	if (ids.length==2) {
		$.get("/lib/ajx/versioncontent?id1="+ids[0].substr(2)+"&id2="+ids[1].substr(2), function (response) {
			var texts = response.split("~~~~");
			var diffop = WDiffString(texts[1], texts[2]);
			var diffop = WDiffShortenOutput(diffop);
			$("#diffoutput").html(texts[0]+diffop).css("display", "block");
			h3toImagetext();
			$("#diffviewinfo").css("display", "none");
			$("#versionkey").css("top", "7");
		});
	}
}

function showMemberInviteDialog() {
	$('#peoplesearchnameinvite').val("");
	$('#peoplesearchagencyinvite').val("");
	$('#peoplesearchresultsinvite').html("<option style=\"display: none\">&nbsp;</option>");
	$('#peoplesearchresultsinvite').get(0).options[0].selected = false;
	if (dialogShow("peoplesearchinvite")) $('#peoplesearchnameinvite').get(0).focus();
}

function memberInvite() {
	var peopleselect = $('#peoplesearchresultsinvite').get(0);
	var peopletoinvite = new Array();
	for (i=0; i<peopleselect.options.length; i++) {
		if (peopleselect.options[i].selected) {
			if (peopleselect.options[i].title) {
				alert(peopleselect.options[i].title);
				return false;
			}
			peopletoinvite[peopletoinvite.length] = peopleselect.options[i].value;
		}
	}
	if (!peopletoinvite.length) {
		alert("Please select a user from the list to invite.");
		return false;
	}
	$.getJSON("/lib/ajx/peopleinvite/"+$('#peoplesearchexcludeinvite').val()+"/"+peopletoinvite.join("/"), function (json) {
		if (json.error) {
			alert(json.error);
			return false;
		}
		$('#peoplesearchresultstitleinvite').html("Members Invited");
		$('#peoplesearchresultstextinvite').html(((json.membersinvited == 1)?"1 member has":json.membersinvited+" members have")+" been successfully invited to join this community.");
		dialogShow("peoplesearchresultsinvite");
	});
	return false;
}

function showFriendInviteDialog() {
	$('#peoplesearchnamefindafriend').val("");
	$('#peoplesearchagencyfindafriend').val("");
	$('#peoplesearchresultsfindafriend').html("<option style=\"display: none\">&nbsp;</option>");
	$('#peoplesearchresultsfindafriend').get(0).options[0].selected = false;
	if (dialogShow("peoplesearchfindafriend")) $('#peoplesearchnamefindafriend').get(0).focus();
}

function friendInvite() {
	var peopleselect = $('#peoplesearchresultsfindafriend').get(0);
	var friendstoinvite = new Array();
	for (i=0; i<peopleselect.options.length; i++) {
		if (peopleselect.options[i].selected) {
			if (peopleselect.options[i].title) {
				alert(peopleselect.options[i].title);
				return false;
			}
			friendstoinvite[friendstoinvite.length] = peopleselect.options[i].value;
		}
	}
	if (!friendstoinvite.length) {
		alert("Please select a user from the list to send a friend request to.");
		return false;
	}
	$.getJSON("/lib/ajx/friendinvite/"+friendstoinvite.join("/"), function (json) {
		if (json.error) {
			alert(json.error);
			return false;
		}
		$('#peoplesearchresultstitlefindafriend').html("Friend Requests Sent");
		$('#peoplesearchresultstextfindafriend').html(((json.friendrequests == 1)?"1 friend request has":json.friendrequests+" friend requests have")+" been successfully sent.");
		dialogShow("peoplesearchresultsfindafriend");
	});
	return false;
}

function sendFriendRequest(userid) {
	$.getJSON("/lib/ajx/friendinvite/"+userid, function (json) {
		if (json.error) {
			alert(json.error);
			return false;
		} else if (!json.friendrequests) {
			$('#peoplesearchresultstitlefindafriend').html("Friend Request Problem");
			$('#peoplesearchresultstextfindafriend').html("Your friend request has been successfully received, but we could not mark you as a friend.  Possible reasons for this are that the member is not yet a full member of this network or that you are already friends with this member.  If you believe this message was received in error, please contact technical support.");
		} else {
			$('#peoplesearchresultstitlefindafriend').html("Friend Request Sent");
			$('#peoplesearchresultstextfindafriend').html("Your friend request has been successfully sent.");
			$('#friendrequestaction').hide();
		}
		dialogShow("peoplesearchresultsfindafriend");
	});
}

function doPeopleSearch(searchtype) {
	$.getJSON("/lib/ajx/peoplesearch", {name:$('#peoplesearchname'+searchtype).val(), agency:$('#peoplesearchagency'+searchtype).val(), type:searchtype, exclude:$('#peoplesearchexclude'+searchtype).val()}, function (json) {
		if (json.error) {
			alert(json.error);
			return;
		}
		if (json.people.length) {
			var searchresults = "";
			for (var i in json.people) {
				if (!json.people[i].name) continue;
				searchresults += "<option value=\""+json.people[i].id+"\"";
				if (json.people[i].status.length) searchresults += " class=\"optiondisabled\" title=\""+decodeURIComponent(json.people[i].name+" "+json.people[i].status)+"\"";
				searchresults += ">"+decodeURIComponent(json.people[i].name)+"</option>";
			}
			$('#peoplesearchresults'+searchtype).html(searchresults);
			var peopleselect = $('#peoplesearchresults'+searchtype).get(0);
			for (i=0; i<peopleselect.options.length; i++) {
				peopleselect.options[i].selected = false;
			}
			$('#peoplesearchwarning'+searchtype).html((json.moreresults)?"There are more results than can be displayed; try being more specific.":"")
		} else {
			if (searchtype == "invite") {
				$('#peoplesearchresults'+searchtype).html("<optgroup class=\"optionnotice\" label=\"No people were found who are not already in this community.\"><option style=\"display: none;\">&nbsp;</option></optgroup>");
			} else {
				$('#peoplesearchresults'+searchtype).html("<optgroup class=\"optionnotice\" label=\"No people were found who are not already on your friends list.\"><option style=\"display: none;\">&nbsp;</option></optgroup>");
			}				
			$('#peoplesearchresults'+searchtype).html($('#peoplesearchresults'+searchtype).html()+"<optgroup class=\"optionnotice\" label=\"Try being less specific.\"><option style=\"display: none;\">&nbsp;</option></optgroup>");
		}
	});
}

function registrationUpdate(stage) {

	switch(stage) {

		// Return to initial registration type choices
		case 0:
			$("div.formhelp").css("display", "none");
			registrationUpdateInterface(1);
			if (redirecting) $("#regloginarea").slideDown();
		break;
		
		// Personal details
		case 1:
			$("#reg1buttons").hide();
			$("#reg1wait").show();
			$("#agencyid").val("");
			$("#branchid").val("");
			$("#txtneworgname").val($("#txtagencyname").val());
			$("#txtnewofficename").val($("#txtagencybranch").val());
			if ($("#regerrors").html()) $("#regerrors").slideUp();
			$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(1), dataType:"json", success:function (json) {
				$("#reg1wait").hide();
				$("#reg1buttons").show();
				if (json.error) {
					alert(json.error);
					return;
				} else if (json.validationerror) {
					$("#regerrors").html(json.validationerrorhtml).slideDown();
					registrationUpdateErrors(json.validationerrorfields);
					return;
				}
				if (json.formfields) registrationUpdateFormFields(json.formfields);
				
				// Multiple matches - display stage 2 or 4
				if (json.orglist && json.orglist.length != 1) {
					if (json.orglist == "0") {
						$("#orgselectlist").attr("size", 3).get(0).length = 0;
						$("#regstage2none").show();
						$("#regstage2toomany").hide();
					} else {
						var orgoptions = $("#orgselectlist").attr("size", Math.max(2, Math.min(10, json.orglist.length))).get(0).options;
						orgoptions.length = 0;
						for (var i=0; i<json.orglist.length; i++) {
							orgoptions[orgoptions.length] = new Option(json.orglist[i]["name"], json.orglist[i]["id"]);
						}
						if (json.orglist.length >= 50) $("#regstage2toomany").show();
						else $("#regstage2toomany").hide();
						$("#regstage2none").hide();
					}
					$("#txtorgsearch").val(json.orgsearchstring);
					$("#hdnprevorgsearch").val(json.orgsearchstring);
					registrationUpdateInterface(2);
				} else if (json.officelist && json.officelist.length != 1) {
					if (json.officelist == "0") {
						$("#officeselectlist").attr("size", 3).get(0).length = 0;
						$("#regstage4none").show();
						$("#regstage4toomany").hide();
					} else {
						var officeoptions = $("#officeselectlist").attr("size", Math.max(2, Math.min(10, json.officelist.length))).get(0).options;
						officeoptions.length = 0;
						for (var i=0; i<json.officelist.length; i++) {
							officeoptions[officeoptions.length] = new Option(json.officelist[i]["name"], json.officelist[i]["id"]);
						}
						if (json.officelist.length >= 50) $("#regstage4toomany").show();
						else $("#regstage4toomany").hide();
						if (!json.officelist.length) $("#regstage4none").show();
						else $("#regstage4none").hide();
					}
					$("#regorgnotetext").html("The organisation <strong>"+json.orgname+"</strong> has been selected.");
					$("#txtofficesearch").val(json.officesearchstring);
					$("#hdnprevofficesearch").val(json.officesearchstring);
					registrationUpdateInterface(4);
				} else {
					if (json.orgname) $("#regorgnotetext").html("The organisation <strong>"+json.orgname+"</strong> has been selected.");

					if (json.newstage == 3) {
						agencytype = "new";
						$("#regstage2none").show();
						$("#regstage2toomany").hide();
						$("#regstage3notenone").show();
						$("#regstage3notenew").hide();
						$("#regstage3note").slideDown();
						$("#txtorgsearch").val($("#txtagencyname").val());
						registrationUpdateInterface(json.newstage);
					} else if (json.newstage == 2) {
						if (json.orglist == "0") {
							$("#orgselectlist").attr("size", 3).get(0).length = 0;
							$("#regstage2none").show();
							$("#regstage2toomany").hide();
						} else {
							var orgoptions = $("#orgselectlist").attr("size", Math.max(2, Math.min(10, json.orglist.length))).get(0).options;
							orgoptions.length = 0;
							for (var i=0; i<json.orglist.length; i++) {
								orgoptions[orgoptions.length] = new Option(json.orglist[i]["name"], json.orglist[i]["id"]);
							}
							if (json.orglist.length >= 50) $("#regstage2toomany").show();
							else $("#regstage2toomany").hide();
							$("#regstage2none").hide();
						}
						$("#txtofficesearch").val(json.officesearchstring);
						$("#hdnprevofficesearch").val(json.officesearchstring);						
						registrationUpdateInterface(json.newstage);
					} else if (json.newstage == 5) {
						branchtype = "new";
						$("#regstage5notenone").show();
						$("#regstage5notenew").hide();
						$("#regstage5note").slideDown();
						registrationUpdateInterface(json.newstage);
					} else if (json.newstage == 4) {
						if (json.officelist == "0") {
							$("#officeselectlist").attr("size", 3).get(0).length = 0;
							$("#regstage4none").show();
							$("#regstage4toomany").hide();
						} else {
							var officeoptions = $("#officeselectlist").attr("size", Math.max(2, Math.min(10, json.officelist.length))).get(0).options;
							officeoptions.length = 0;
							for (var i=0; i<json.officelist.length; i++) {
								officeoptions[officeoptions.length] = new Option(json.officelist[i]["name"], json.officelist[i]["id"]);
							}
							if (json.officelist.length >= 50) $("#regstage4toomany").show();
							else $("#regstage4toomany").hide();
							$("#regstage4none").hide();
						}
						$("#txtofficesearch").val(json.officesearchstring);
						$("#hdnprevofficesearch").val(json.officesearchstring);						
						registrationUpdateInterface(json.newstage);
					} else if (json.newstage == 8) {
						if ($("#hdninvitedby").val()) {
							$("#refereelabel").html("Referee:");
						}
						registrationUpdateInterface(json.newstage);
					} else {
						registrationUpdateInterface(json.newstage);
					}
				}
			}});
		break; 

		// Agency search
		case 2:
		
			// In order of importance: create a new agency, search again, make choice.
			if ($("#neworgtickbox").get(0).checked) {
				$("#neworgtickbox").check(false);
				$("#txtneworgname").val($("#txtorgsearch").val());
				agencytype = "new";
				$("#agencyid").val("");
				$("#regstage3notenew").show();
				$("#regstage3notenone").hide();
				$("#regstage3note").slideDown();
				registrationUpdateInterface(3);
			} else if ($("#txtorgsearch").val() != $("#hdnprevorgsearch").val() || !$("#orgselectlist").get(0).options.length) {
				$("#reg2buttons").hide();
				$("#reg2wait").show();
				agencytype = "search";
				$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(2), dataType:"json", success:function (json) {
					$("#reg2buttons").show();
					$("#reg2wait").hide();
					if (json.error) {
						alert(json.error);
						return false;
					}
					if (json.formfields) registrationUpdateFormFields(json.formfields);
					if (json.orglist) {
						if (json.orglist == "0") {
							$("#orgselectlist").attr("size", 3).get(0).length = 0;
							$("#regstage2none").show();
							$("#regstage2toomany").hide();
						} else {
							var orgoptions = $("#orgselectlist").attr("size", Math.max(2, Math.min(10, json.orglist.length))).get(0).options;
							orgoptions.length = 0;
							for (var i=0; i<json.orglist.length; i++) {
								orgoptions[orgoptions.length] = new Option(json.orglist[i]["name"], json.orglist[i]["id"]);
							}
							if (json.orglist.length >= 50) $("#regstage2toomany").show();
							else $("#regstage2toomany").hide();
							$("#regstage2none").hide();
						}
					} else {
						var orgoptions = $("#orgselectlist").attr("size", json.orglist.length).get(0).options;
						orgoptions.length = 0;
						$("#regstage2toomany").hide();
						$("#regstage2none").show();
					}
					$("#txtorgsearch").val(json.orgsearchstring);
					$("#hdnprevorgsearch").val(json.orgsearchstring);						
				}});
			} else if ($("#orgselectlist").val()) {
				agencytype = "current";
				$("#reg2buttons").hide();
				$("#reg2wait").show();
				$("#hdnagencyid").val($("#orgselectlist").val());
				$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(2), dataType:"json", success:function (json) {
					$("#reg2buttons").show();
					$("#reg2wait").hide();
					if (json.error) {
						alert(json.error);
						return false;
					}
					if (json.formfields) registrationUpdateFormFields(json.formfields);
					$("#regorgnotetext").html("The organisation <strong>"+json.orgname+"</strong> has been selected.");
					if (json.newstage == 5) {
						branchtype = "new";
						$("#regstage5notenone").show();
						$("#regstage5notenew").hide();
						$("#regstage5note").slideDown();
					}
					if (json.newstage == 4) {
						if (json.officelist == "0") {
							$("#officeselectlist").attr("size", 3).get(0).length = 0;
							$("#regstage4none").show();
							$("#regstage4toomany").hide();
						} else {
							var officeoptions = $("#officeselectlist").attr("size", Math.max(2, Math.min(10, json.officelist.length))).get(0).options;
							officeoptions.length = 0;
							for (var i=0; i<json.officelist.length; i++) {
								officeoptions[officeoptions.length] = new Option(json.officelist[i]["name"], json.officelist[i]["id"]);
							}
							if (json.officelist.length >= 50) $("#regstage4toomany").show();
							else $("#regstage4toomany").hide();
							$("#regstage4none").hide();
						}
						$("#txtofficesearch").val(json.officesearchstring);
						$("#hdnprevofficesearch").val(json.officesearchstring);						
					}
					registrationUpdateInterface(json.newstage);
				}});
			}
		break;
		
		// Creation of a new agency
		case 3:
			$("#reg3buttons").hide();
			$("#reg3wait").show();
			if ($("#regerrors").html()) $("#regerrors").slideUp();
			$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(3), dataType:"json", success:function (json) {
				$("#reg3wait").hide();
				$("#reg3buttons").show();
				if (json.error) {
					alert(json.error);
					return;
				} else if (json.validationerror) {
					$("#regerrors").html(json.validationerrorhtml).slideDown();
					registrationUpdateErrors(json.validationerrorfields);
					return;
				}
				if (json.formfields) registrationUpdateFormFields(json.formfields);
				branchtype = "new";
				$("#regorgnotetext").html("The organisation <strong>"+$("#txtneworgname").val()+"</strong> will be created when you complete registration.");
				$("#txtnewofficename").val($("#txtagencybranch").val());
				if (!$("#txtnewofficename").val()) $("#txtnewofficename").val($("#txtneworgname").val());
				$("#txtnewofficeaddress").val($("#txtneworgaddress").val());
				$("#txtnewofficepostcode").val($("#txtneworgpostcode").val());
				$("#txtnewofficecountry").val($("#txtneworgcountry").val());
				registrationUpdateInterface(json.newstage);
			}});
		break;

		// Branch search
		case 4:
		
			// In order of importance: create a new agency, search again, make choice.
			if ($("#newofficetickbox").get(0).checked) {
				$("#newofficetickbox").check(false);
				$("#txtnewofficename").val($("#txtofficesearch").val());
				branchtype = "new";
				$("#branchid").val("");
				$("#regstage5notenone").hide();
				$("#regstage5notenew").show();
				$("#regstage5note").slideDown();
				registrationUpdateInterface(5);
			} else if ($("#txtofficesearch").val() != $("#hdnprevofficesearch").val() || !$("#officeselectlist").get(0).options.length) {
				$("#reg4buttons").hide();
				$("#reg4wait").show();
				branchtype = "search";
				$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(4), dataType:"json", success:function (json) {
					$("#reg4buttons").show();
					$("#reg4wait").hide();
					if (json.error) {
						alert(json.error);
						return false;
					}
					if (json.formfields) registrationUpdateFormFields(json.formfields);
					if (json.officelist) {
						if (json.officelist == "0") {
							$("#officeselectlist").attr("size", 3).get(0).length = 0;
							$("#regstage4none").show();
							$("#regstage4toomany").hide();
						} else {
							var officeoptions = $("#officeselectlist").attr("size", Math.max(2, Math.min(10, json.officelist.length))).get(0).options;
							officeoptions.length = 0;
							for (var i=0; i<json.officelist.length; i++) {
								officeoptions[officeoptions.length] = new Option(json.officelist[i]["name"], json.officelist[i]["id"]);
							}
							if (json.officelist.length >= 50) $("#regstage4toomany").show();
							else $("#regstage4toomany").hide();
							$("#regstage4none").hide();
						}
					} else {
						var officeoptions = $("#officeselectlist").attr("size", json.officelist.length).get(0).options;
						officeoptions.length = 0;
						$("#regstage4toomany").hide();
						$("#regstage4none").show();
					}
					$("#txtofficesearch").val(json.officesearchstring);
					$("#hdnprevofficesearch").val(json.officesearchstring);						
				}});
			} else if ($("#officeselectlist").val()){
				branchtype = "current";
				$("#hdnbranchid").val($("#officeselectlist").val());
				$("#reg4buttons").hide();
				$("#reg4wait").show();
				$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(4), dataType:"json", success:function (json) {
					$("#reg4buttons").show();
					$("#reg4wait").hide();
					if (json.error) {
						alert(json.error);
						return false;
					}
					if (json.newstage == 5) {
						$("#regstage5notenone").show();
						$("#regstage5notenew").hide();
						$("#regstage5note").slideDown();
					}
				if (json.formfields) registrationUpdateFormFields(json.formfields);
					registrationUpdateInterface(json.newstage);
				}});
			}
		break;
		
		// Creation of a new branch
		case 5:
			$("#reg5buttons").hide();
			$("#reg5wait").show();
			if ($("#regerrors").html()) $("#regerrors").slideUp();
			$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(5), dataType:"json", success:function (json) {
				$("#reg5wait").hide();
				$("#reg5buttons").show();
				if (json.error) {
					alert(json.error);
					return;
				} else if (json.validationerror) {
					$("#regerrors").html(json.validationerrorhtml).slideDown();
					registrationUpdateErrors(json.validationerrorfields);
					return;
				}
				if (json.formfields) registrationUpdateFormFields(json.formfields);
				registrationUpdateInterface(json.newstage);
			}});
		break;
	
		// All done?  Check this
		case 6:
		
		break;
	}
}

function registrationUpdateInterface(stage) {
	if ($("#regerrors").css("display") == "block" && $("#regerrors").html()) {
		$("#regerrors").slideUp("normal", function() { $("#regerrors").html("") });
	}
	if (stage != 1 && $("#regstage1").css("display") == "block") $("#regstage1").slideUp();
	if (stage != 2 && $("#regstage2").css("display") == "block") $("#regstage2").slideUp();
	if (stage != 3 && $("#regstage3").css("display") == "block") $("#regstage3").slideUp();
	if (stage != 3 && $("#regstage3note").css("display") == "block") $("#regstage3note").slideUp();
	if ((stage < 4 || stage > 5) && $("#regorgnote").css("display") == "block") $("#regorgnote").slideUp();
	if (stage >= 4 && stage < 6 && $("#regorgnote").css("display") == "none") $("#regorgnote").slideDown();
	if (stage != 4 && $("#regstage4").css("display") == "block") $("#regstage4").slideUp();
	if (stage != 5 && $("#regstage5note").css("display") == "block") $("#regstage5note").slideUp();
	if (stage != 5 && $("#regstage5").css("display") == "block") $("#regstage5").slideUp();
	if (stage != 6 && $("#regstage6").css("display") == "block") $("#regstage6").slideUp();
	$("#regstage"+stage).slideDown();
}

function registrationReturnDataString(stage) {
	return "stage="+stage+"&firstname="+encodeURIComponent($("#txtfirstname").val())+"&surname="+encodeURIComponent($("#txtsurname").val())+"&displayname="+encodeURIComponent($("#txtdisplayname").val())+"&jobtitle="+encodeURIComponent($("#txtjobtitle").val())+"&orgname="+encodeURIComponent($("#txtagencyname").val())+"&branchname="+encodeURIComponent($("#txtagencybranch").val())+"&yearstarted="+encodeURIComponent($("#txtyearstarted").val())+"&invitedby="+encodeURIComponent($("#hdninvitedby").val())+"&orgsearch="+encodeURIComponent($("#txtorgsearch").val())+"&neworgname="+encodeURIComponent($("#txtneworgname").val())+"&neworgaddress="+encodeURIComponent($("#txtneworgaddress").val())+"&neworgpostcode="+encodeURIComponent($("#txtneworgpostcode").val())+"&neworgcountry="+encodeURIComponent($("#txtneworgcountry").val())+"&neworgwebsite="+encodeURIComponent($("#txtneworgwebsite").val())+"&newofficename="+encodeURIComponent($("#txtnewofficename").val())+"&newofficeaddress="+encodeURIComponent($("#txtnewofficeaddress").val())+"&newofficepostcode="+encodeURIComponent($("#txtnewofficepostcode").val())+"&newofficecountry="+encodeURIComponent($("#txtnewofficecountry").val())+"&orgid="+encodeURIComponent($("#hdnagencyid").val())+"&branchid="+encodeURIComponent($("#hdnbranchid").val())+"&officesearch="+encodeURIComponent($("#txtofficesearch").val())+"&email="+encodeURIComponent($("#txtemail").val())+"&newsletter="+(($("#chknewsletter").length)?(($("#chknewsletter").get(0).checked)?1:0):0)+"&orgtype="+agencytype+"&branchtype="+branchtype;
}

function registrationOrgSearch() {
	$("#reg3notebutton").hide();
	$("#reg3notewait").show();
	agencytype = "search";
	$("#txtorgsearch").val($("#txtneworgname").val());
	$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(2), dataType:"json", success:function (json) {
		$("#reg3notebutton").show();
		$("#reg3notewait").hide();
		if (json.formfields) registrationUpdateFormFields(json.formfields);
		if (json.orglist) {
			if (json.orglist == "0") {
				$("#orgselectlist").attr("size", 3).get(0).length = 0;
				$("#regstage2none").show();
				$("#regstage2toomany").hide();
			} else {
				var orgoptions = $("#orgselectlist").attr("size", Math.max(2, Math.min(10, json.orglist.length))).get(0).options;
				orgoptions.length = 0;
				for (var i=0; i<json.orglist.length; i++) {
					orgoptions[orgoptions.length] = new Option(json.orglist[i]["name"], json.orglist[i]["id"]);
				}
				if (json.orglist.length >= 50) $("#regstage2toomany").show();
				else $("#regstage2toomany").hide();
				$("#regstage2none").hide();
			}
		} else {
			var orgoptions = $("#orgselectlist").attr("size", json.orglist.length).get(0).options;
			orgoptions.length = 0;
			$("#regstage2toomany").hide();
			$("#regstage2none").show();
		}
		$("#txtorgsearch").val(json.orgsearchstring);
		$("#hdnprevorgsearch").val(json.orgsearchstring);
		registrationUpdateInterface(2);					
	}});
}

function registrationOfficeSearch() {
	$("#reg5notebutton").hide();
	$("#reg5notewait").show();
	branchtype = "search";
	$("#txtofficesearch").val($("#txtnewofficename").val());
	$.ajax({type:"POST", url:"/lib/ajx/register", data:registrationReturnDataString(4), dataType:"json", success:function (json) {
		$("#reg5notebutton").show();
		$("#reg5notewait").hide();
		if (json.formfields) registrationUpdateFormFields(json.formfields);
		if (json.officelist) {
			if (json.officelist == "0") {
				$("#officeselectlist").attr("size", 3).get(0).length = 0;
				$("#regstage4none").show();
				$("#regstage4toomany").hide();
			} else {
				var officeoptions = $("#officeselectlist").attr("size", Math.max(2, Math.min(10, json.officelist.length))).get(0).options;
				officeoptions.length = 0;
				for (var i=0; i<json.officelist.length; i++) {
					officeoptions[officeoptions.length] = new Option(json.officelist[i]["name"], json.officelist[i]["id"]);
				}
				if (json.officelist.length >= 50) $("#regstage4toomany").show();
				else $("#regstage4toomany").hide();
				$("#regstage4none").hide();
			}
		} else {
			var officeoptions = $("#officeselectlist").attr("size", json.officelist.length).get(0).options;
			officeoptions.length = 0;
			$("#regstage4toomany").hide();
			$("#regstage4none").show();
		}
		$("#txtofficesearch").val(json.officesearchstring);
		$("#hdnprevofficesearch").val(json.officesearchstring);
		registrationUpdateInterface(4);					
	}});
}

function registrationUpdateFormFields(formfields) {
	for (keyvar in formfields) {
		$("#"+keyvar).val(formfields[keyvar]);
	}
}

function registrationUpdateErrors(errorfields) {
	$(".field").removeClass("error");
	if (typeof(errorfields) == "undefined" || !errorfields) return;
	
	for (var i=0; i<errorfields.length; i++) {
		$("#errfield_"+errorfields[i]).addClass("error");
	}
}

function showWriteMenu() {
	$("#writemenu").css("top", $("#lnkwritepost").offset().top + $("#lnkwritepost").offset().height + 3);
	$("#writemenu").css("left", "25px");
	var menu = $('#writemenu').SlideInUp('fast');
	$('a', menu).get(0).blur();
}

function moreoptsonclick() {
	window.setTimeout(function() {
		if (typeof(moreOptsTimeout) != "undefined") window.clearTimeout(moreOptsTimeout);
		ele = document.getElementById("lnkmoreoptssidebar");
		ele.blur();
		toggleloginboxmoreopts();
	},10);
}

function toggleloginboxmoreopts(direction) {
	if (typeof(direction) == "undefined") direction = (($('#loginformmoreopts').css('display') == "none")?"in":"out");
	switch(direction) {
		case "in":
			$('#loginformmoreopts').SlideInUp('fast');
			$('#lnkmoreoptssidebar img').attr('src','/lib/img/blackarrow_up.png');

			// Prevent drop-down appearing under infobar messages and other content in IE
			if (document.all) {
				var html = $("#mainnav");
				$("#mainnav").remove();
				$("#pagecontainer").append(html);
				if (typeof(doneonce) == "undefined") {
					$("#mainnav").css("left",Number($("#mainnav").css("left").replace("px",""))+1+"px");
					doneonce = true;
				}
			}


			break;
		case "out":
			$('#loginformmoreopts').slideUp('fast');
			$('#lnkmoreoptssidebar img').attr('src','/lib/img/blackarrow_down.png');
			break;
	}
}

function toggleAllActions(tabletype, column) {
	$('td:eq('+column+')/input', '//table[@id='+tabletype+'actiontable]/tbody/tr').check();
	$('//table[@id='+tabletype+'actiontable] a.actionlink').get(0).blur();
}

function userEditBiography() {
	var biography = $('#personbiog').html();
	if (biography == "<em>You don't have a biography yet</em>") biography = "";
	if (biography == "<em>"+$("#persondisplayname").html()+" doesn't have a biography yet</em>") biography = "";
	biography = biography.replace(/\<br\s?\\?>/ig, "\n");
	if (dialogShow('editbiography')) {
		$('#biographyeditor').val(biography);
		$('#biographyeditor').get(0).focus();
	}
	$('#promptouter').hide();
}

function userEditBiographySave() {
	var biography = $('#biographyeditor').val();
	biography = biography.replace(/\n/g, "<br />");
	$.ajax({type:"POST", url:"/lib/ajx/personedit/biography", data:"biography="+encodeURIComponent(biography)+"&userid="+encodeURIComponent($('#profileuserid').val()), dataType:"json", success:function (json) {
		if (json.error) {
			alert(json.error);
			return false;
		}
		if (!biography) biography = "<em>You don't have a biography yet</em>";
		$('#personbiog').html(biography);
		dialogHide('editbiography');
	}});
}

function userEditDetails() {
	$('#editdetailserrors').hide().html("");
	if (dialogShow('editdetails')) $('#userfirstname').get(0).focus();
}

function userEditDetailsSave() {
	dialogShow("pleasewait");
	
	// Make a POST request to avoid logging details
	$.ajax({type:"POST", url:"/lib/ajx/personedit/details", data:"firstname="+encodeURIComponent($('#userfirstname').val())+"&surname="+encodeURIComponent($('#usersurname').val())+"&displayname="+encodeURIComponent($('#userdisplayname').val())+"&jobtitle="+encodeURIComponent($('#userjobtitle').val())+"&basedin="+encodeURIComponent($('#userbasedin').val())+"&userid="+encodeURIComponent($('#profileuserid').val()), dataType:"json", success:function (json) {
		if (json.error) {
			dialogHide("pleasewait");		
			dialogShow("editdetails");		
			alert(json.error);
			return false;
		} else if (json.validationerror) {
			$('#editdetailserrors').html(json.validationerror).show();
			dialogHide("pleasewait");		
			dialogShow("editdetails");		
			return false;
		}
		$('#postgrouptitle').html($('#userdisplayname').val()+"'s blog");
		if (json.ownprofile) $('#username').html($('#userdisplayname').val());
		$('#persondisplayname').html($('#userdisplayname').val());
		$('#personlocation').html($('#userbasedin').val());
		$('#basedin').css("display", ($('#userbasedin').val())?"":"none");
		$('#personjobtitle').html($('#userjobtitle').val());
		$('#newsletterstatus').html(($("#chknewsletter").get(0).checked)?"currently":"not");
		dialogHide("pleasewait");		
		if (dialogShow("done")) $('#dlgdoneokbutton').get(0).focus();
	}});
}

function userChangePassword() {
	$('#changepasserrors').hide().html("");
	if (dialogShow('changepass')) $('#usercurrentpassword').get(0).focus();
}

function userChangePasswordSave() {
	dialogShow("pleasewait");
	$.ajax({type:"POST", url:"/lib/ajx/personedit/password", data:"currentpassword="+encodeURIComponent($('#usercurrentpassword').val())+"&newpassword="+encodeURIComponent($('#usernewpassword').val())+"&confirmpassword="+encodeURIComponent($('#userconfirmpassword').val())+"&userid="+encodeURIComponent($('#profileuserid').val()), dataType:"json", success:function (json) {
		if (json.error) {
			dialogHide("pleasewait");		
			dialogShow("changepass");		
			alert(json.error);
			return false;
		} else if (json.validationerror) {
			$('#changepasserrors').html(json.validationerror).show();
			dialogHide("pleasewait");		
			dialogShow("changepass");		
			return false;
		}
		$('#usercurrentpassword').val("");
		$('#usernewpassword').val("");
		$('#userconfirmpassword').val("");
		dialogHide("pleasewait");		
		if (dialogShow("done")) $('#dlgdoneokbutton').get(0).focus();
	}});
}

function userEditAlerts() {
	$('#subserrors').hide().html("");
	dialogShow('subs');
}

function userEditAlertsSave() {
	dialogShow("pleasewait");
	var data = "commentbacn="+(($("#chkcommentbacn").get(0).checked)?1:0)+"&invitebacn="+(($("#chkinvitebacn").get(0).checked)?1:0)+"&friendreqbacn="+(($("#chkfriendreqbacn").get(0).checked)?1:0)+"&newsletter="+(($("#chknewsletter").get(0).checked)?1:0)+"&userid="+encodeURIComponent($('#profileuserid').val());
	$(".chkcommbacn").each(function(){
		var id = $(this).attr("id");
		var commid = id.replace(/[^0-9]/g,"");
		data += ("&commid"+commid+"postbacn="+(this.checked?1:0));
	});
	$(".chkcommappbacn").each(function(){
		var id = $(this).attr("id");
		var commid = id.replace(/[^0-9]/g,"");
		data += ("&commid"+commid+"appbacn="+(this.checked?1:0));
	});
	$.ajax({type:"POST", url:"/lib/ajx/personedit/alerts", data:data, dataType:"json", success:function (json) {
		if (json.error) {
			dialogHide("pleasewait");		
			dialogShow("subs");		
			alert(json.error);
			return false;
		} else if (json.validationerror) {
			$('#subserrors').html(json.validationerror).show();
			dialogHide("pleasewait");		
			dialogShow("subs");		
			return false;
		}
		dialogHide("subs");		
		if (dialogShow("done")) $('#dlgdoneokbutton').get(0).focus();
	}});
}

function userFollowBlog() {
	$('#followblogserrors').hide().html("");
	dialogShow('followblog');
}

function userFollowBlogSave() {
	dialogShow("pleasewait");
	$.ajax({type:"POST", url:"/lib/ajx/setsyndrssurl", data:"rssurl="+$("#txtrssurl").val()+"&ajx=1&userid="+encodeURIComponent($('#profileuserid').val()), dataType:"json", success:function (json) {
		if (json.error) {
			dialogHide("pleasewait");		
			dialogShow("followblog");		
			alert(decodeURIComponent(json.error));
			return false;
		} else if (json.validationerror) {
			$('#followblogerrors').html(json.validationerror).show();
			dialogHide("pleasewait");		
			dialogShow("followblog");		
			return false;
		}
		dialogHide("followblog");		
		if (dialogShow("done")) $('#dlgdoneokbutton').get(0).focus();
	}});
}

function userEditPhoto() {
	dialogShow('editphotoupload');
	$('#phototocroptrigger').load(function() { } ); // Prevent more calls
	$('#promptouter').hide();
}

function doPhotoUpload() {
	$('#waittext').html('Please wait, uploading and processing image...');
	dialogShow('pleasewait');
	$('#photouploadmaxheight').val(viewport.height);
	$('#photouploadmaxwidth').val(viewport.width);
	$('#frmprofilephotoupload').submit();
	$('#frmbranchlogoupload').submit();
	$('#frmagencylogoupload').submit();
	$('#frmlogoupload').submit();
	$('#frmimageupload').submit();

	// Replace file upload field with a blank one, to allow the same file to be uploaded twice in a row.
	$('#filupload').after('<input id=\'filupload\' class=\'file hidden\' type=\'file\' size=\'9\' name=\'file\' >').remove();
	$('#filupload').css("opacity","0");
	$('#filupload').change(doPhotoUpload);
}

function userEditPhotoUploaded(status, message, width, height) {
	if (status == "success") {
		var ratio = 122/102;
		if (height/width < ratio) {
			var cropheight = height;
			var cropwidth = Math.round(height/ratio);
		} else {
			var cropwidth = width;
			var cropheight = Math.round(width*ratio);
		}
		makeCroppable(message, width, height, cropwidth, cropheight, ratio, 102, 122);
	} else {
		dialogHide("pleasewait");
		dialogShow("editphotoupload");
		alert(message);
	}
}

function userEditPhotoCropped(status, detail) {
	if (status == "success") {
		$('#userdetailsbigphoto').attr("src", detail+"?nocache="+Math.random());
		dialogHide("pleasewait");
	} else {
		dialogHide("pleasewait");
		dialogShow("editphotocrop");
		alert(detail);
	}
}

function branchEditLogo() {
	dialogShow('editlogoupload');
	$('#phototocroptrigger').load(function() { } ); // Prevent more calls
	$('#promptouter').hide();
}

function branchEditLogoUploaded(status, message, width, height) {
	if (status == "success") {
		var ratio = 70/160;
		if (height/width < ratio) {
			var cropheight = Math.max(50, height);
			var cropwidth = Math.max(50, Math.round(height/ratio));
		} else {
			var cropwidth = Math.max(50, width);
			var cropheight = Math.max(50, Math.round(width*ratio));
		}
		makeCroppable(message, width, height, cropwidth, cropheight, ratio, 160, 70);
	} else {
		dialogHide("pleasewait");
		dialogShow("editlogoupload");
		alert(message);
	}
}

function branchEditLogoCropped(status, detail) {
	if (status == "success") {
		$('#branchlogo').attr("src", detail+"?nocache="+Math.random());
		dialogHide("pleasewait");
	} else {
		dialogHide("pleasewait");
		dialogShow("editphotocrop");
		alert(detail);
	}
}

function branchEditDescription() {
	var description = $('#branchdescription').html();
	if (description == "<em>No description is available</em>") description = "";
	if (description == "<em>No description is available.  Why not copy the About Us text from your website?</em>") description = "";
	description = description.replace(/\n/ig, "");
	description = description.replace(/\<br\s?\\?>/ig, "\n");
	dialogShow('editdescription');
	$('#descriptioneditor').val(description);
	if ($('#descriptioneditor').get(0)) $('#descriptioneditor').get(0).focus();
	$('#promptouter').hide();
}

function branchDescriptionSave() {
	var description = $('#descriptioneditor').val();
	description = description.replace(/\n/g, "<br />");
	$.ajax({type:"POST", url:"/lib/ajx/branchedit/description", data:"description="+encodeURIComponent(description)+"&id="+encodeURIComponent($('#branchid').val()), dataType:"json", success:function (json) {
		if (json.error) {
			alert(json.error);
			return false;
		}
		if (!json.description) description = "<em>No description is available</em>";
		$('#branchdescription').html(json.description);
		dialogHide('editdescription');
	}});
}

function branchEditDetails() {
	if (dialogShow('editdetails')) {
		if ($("#branchphone").val() == "unspecified") $("#branchphone").val("");
		if ($("#branchfax").val() == "unspecified") $("#branchfax").val("");
		if ($("#branchwebsite").val() == "unspecified") $("#branchwebsite").val("");
		if ($("#branchestablished").val() == "unspecified") $("#branchestablished").val("");
		if ($("#branchstaff").val() == "unspecified") $("#branchstaff").val("");
		$('#branchaddress').get(0).focus();
	}
}

function branchEditDetailsSave() {
	dialogShow("pleasewait");
	
	$.ajax({type:"POST", url:"/lib/ajx/branchedit/details", data:"address="+encodeURIComponent($('#branchaddress').val())+"&postcode="+encodeURIComponent($('#branchpostcode').val())+"&country="+encodeURIComponent($('#branchcountry').val())+"&phone="+encodeURIComponent($('#branchphone').val())+"&fax="+encodeURIComponent($('#branchfax').val())+"&website="+encodeURIComponent($('#branchwebsite').val())+"&established="+encodeURIComponent($('#branchestablished').val())+"&staff="+encodeURIComponent($('#branchstaff').val())+"&id="+encodeURIComponent($('#branchid').val()), dataType:"json", success:function (json) {
		if (json.error) {
			dialogHide("pleasewait");		
			dialogShow("editdetails");		
			alert(json.error);
			return false;
		} else if (json.validationerror) {
			$('#editdetailserrors').html(json.validationerror).show();
			dialogHide("pleasewait");		
			dialogShow("editdetails");		
			return false;
		}

		$('#branchaddresstd').html(json.address);
		$('#branchphonetd').html(json.phone);
		$('#branchfaxtd').html(json.fax);
		$('#branchwebsitetd').html(json.website);
		$('#branchyearestablishedtd').html(json.yearestablished);
		$('#branchstafftd').html(json.staff);
		$('#branchstafftotaltd').html(json.totalstaff);
		mappostcode = json.postcode;
		mapcountry = json.country;
		dialogHide("pleasewait");		
	}});
}

function agencyEditLogo() {
	dialogShow('editlogoupload');
	$('#phototocroptrigger').load(function() { } );
}

function agencyEditLogoUploaded(status, message, width, height) {
	if (status == "success") {
		var ratio = 72/160;
		if (height/width < ratio) {
			var cropheight = Math.max(50, height);
			var cropwidth = Math.max(50, Math.round(height/ratio));
		} else {
			var cropwidth = Math.max(50, width);
			var cropheight = Math.max(50, Math.round(width*ratio));
		}
		makeCroppable(message, width, height, cropwidth, cropheight, ratio, 160, 72);
	} else {
		dialogHide("pleasewait");
		dialogShow("editlogoupload");
		alert(message);
	}
}

function agencyEditLogoCropped(status, detail) {
	if (status == "success") {
		$('#agencylogo').attr("src", detail+"?nocache="+Math.random());
		dialogHide("pleasewait");
	} else {
		dialogHide("pleasewait");
		dialogShow("editphotocrop");
		alert(detail);
	}
}

function agencyEditDetails() {
	if (dialogShow('editdetails')) {
		if ($("#hqwebsite").val() == "unspecified") $("#branchwebsite").val("");
		$('#hqaddress').get(0).focus();
	}
}

function agencyEditDetailsSave() {
	dialogShow("pleasewait");
	$.ajax({type:"POST", url:"/lib/ajx/agencyedit/details", data:"address="+encodeURIComponent($('#hqaddress').val())+"&postcode="+encodeURIComponent($('#hqpostcode').val())+"&country="+encodeURIComponent($('#hqcountry').val())+"&website="+encodeURIComponent($('#hqwebsite').val())+"&id="+encodeURIComponent($('#agencyid').val())+(($('#intellectmember').length)?("&intellectmember="+encodeURIComponent($('#intellectmember').val())):""), dataType:"json", success:function (json) {
		if (json.error) {
			dialogHide("pleasewait");		
			dialogShow("editdetails");		
			alert(json.error);
			return false;
		} else if (json.validationerror) {
			$('#editdetailserrors').html(json.validationerror).show();
			dialogHide("pleasewait");		
			dialogShow("editdetails");		
			return false;
		}

		$('#hqaddresstd').html(json.address);
		mappostcode = json.postcode;
		mapcountry = json.country;
		$('#hqwebsitetd').html(json.website);
		$('#intellectmembertd').html(json.intellectmember);
		dialogHide("pleasewait");		
	}});
}

function communityEditLogo() {
	dialogShow('editphotoupload');
	$('#phototocroptrigger').load(function() { } ); // Prevent more calls
}

function communityEditLogoUploaded(status, message, width, height) {
	if (status == "success") {
		var ratio = 84/189;
		if (height/width < ratio) {
			var cropheight = height;
			var cropwidth = Math.round(height/ratio);
		} else {
			var cropwidth = width;
			var cropheight = Math.round(width*ratio);
		}
		makeCroppable(message, width, height, cropwidth, cropheight, ratio, 189, 84);
	} else {
		dialogHide("pleasewait");
		dialogShow("editphotoupload");
		alert(message);
	}
}

function communityEditLogoCropped(status, detail) {
	if (status == "success") {
		$('#logocontainerinner').css("background-image", "url("+detail+"?nocache="+Math.random()+")");
		dialogHide("pleasewait");
	} else {
		dialogHide("pleasewait");
		dialogShow("editphotocrop");
		alert(detail);
	}
}

function communityEditDetails() {
	dialogShow("editcommdetails");
}

function communityEditDetailsSave() {
	dialogShow("pleasewait");
	
	// Make a POST request to avoid logging details
	$.ajax({type:"POST", url:"/lib/ajx/communityedit", data:"name="+encodeURIComponent($('#commname').val())+"&rightsjoin="+encodeURIComponent($('#commrightsjoin').val())+"&rightsview="+encodeURIComponent($('#commrightsview').val())+"&description="+encodeURIComponent($('#commdesc').val())+"&id="+encodeURIComponent($('#commid').val()), dataType:"json", success:function (json) {
		if (json.error) {
			dialogHide("pleasewait");		
			dialogShow("editcommdetails");		
			alert(json.error);
			return false;
		} else if (json.validationerror) {
			$('#editdetailserrors').html(json.validationerror).show();
			dialogHide("pleasewait");		
			dialogShow("editcommdetails");
			return false;
		}
		$('#commtitle').html($('#commname').val());
		$('#communitydescription').html($('#commdesc').val().replace(/\n/g, "<br />") + "<br /><a href=\"javascript:communityEditDetails();\" class=\"managelink\">Manage this community</a>");
		dialogHide("pleasewait");		
		if (dialogShow("done")) $('#dlgdoneokbutton').get(0).focus();
	}});
}

function makeCroppable(imageurl, imagewidth, imageheight, cropwidth, cropheight, preserveratio, minwidth, minheight) {
	var nocache = Math.random();
	$('#phototocroptrigger').attr('src', imageurl+'?nocache='+nocache).load(function() {
		$('#photocroppreview').css('top', Math.round(((imageheight-cropheight)/2)+1)+'px').css('left', Math.round(((imagewidth-cropwidth)/2)+1)+'px').width(cropwidth).height(cropheight).css("background-image", "url("+imageurl+"?nocache="+nocache+")").css("background-position", "-"+Math.round((imagewidth-cropwidth)/2)+"px -"+Math.round((imageheight-cropheight)/2)+"px");
		$('#photocropborder').css('top', Math.round((imageheight-cropheight)/2)+'px').css('left', Math.round((imagewidth-cropwidth)/2)+'px').width(cropwidth+2).height(cropheight+2);
		$('#photocontainer').width(imagewidth).height(imageheight).css("background-image", "url("+imageurl+"?nocache="+nocache+")");
		$('#photocontainerinner').css("filter", "alpha(opacity:50)").css("KHTMLOpacity", "0.5").css("MozOpacity", "0.5").css("opacity", "0.5");
		
		$('#photoanchor').width(imagewidth+2).height(imageheight+2);
		$('#croporiginx').val(Math.round((imagewidth-cropwidth)/2));
		$('#croporiginy').val(Math.round((imageheight-cropheight)/2));
		$('#cropwidth').val(cropwidth);
		$('#cropheight').val(cropheight);
		$('#photoanchor').width(imagewidth+2);
		dialogShow("editphotocrop");
		if (document.all) {
			$("#dlgeditphotocrop").width(Math.max(600, imagewidth+50));
			centreDialog($("#dlgeditphotocrop"));
		}
		$('#photocroppreview').Resizable({ minTop: 1, minLeft: 1, minWidth: minwidth, minHeight: minheight, maxRight: imagewidth+1, maxBottom: imageheight+1, dragHandle: true, ratio:preserveratio, onDrag: function(x, y) {
				this.style.backgroundPosition = "-"+(x-1)+"px -"+(y-1)+"px";
				$('#croporiginx').val(x-1);
				$('#croporiginy').val(y-1);
				$('#photocropborder').css('left', (x-1)+'px').css('top', (y-1)+'px');
			}, handlers: { se: '#cropresizese', ne: '#cropresizene', nw: '#cropresizenw', sw: '#cropresizesw' }, onResize: function(size, position) {
				$('#croporiginx').val(position.left-1);
				$('#croporiginy').val(position.top-1);
				$('#cropwidth').val(size.width);
				$('#cropheight').val(size.height);
				this.style.backgroundPosition = "-"+(position.left-1)+"px -"+(position.top-1)+"px";
				$('#photocropborder').css('left', (position.left-1)+'px').css('top', (position.top-1)+'px').width(size.width+2).height(size.height+2);
			}
		});
	});
}

function editMapLocation(maptype) {
	$('#promptouter').hide();
	$('#maptext').hide();
	$("#mapeditlink").hide();
	$("#mapoverview").hide();
	$('#mapwait').show();
	if (!lat && !lng && mappostcode && mapcountry && lookupfailed < 3) {
		var googlelocalsearch = new GlocalSearch();
		googlelocalsearch.setSearchCompleteCallback(null, function() {
			if (googlelocalsearch.results[0]) {
				lat = googlelocalsearch.results[0].lat;
				lng = googlelocalsearch.results[0].lng;
				lookupfailed = 10;
			} else {
				lookupfailed++;
			}
			editMapLocation(maptype);
		});
		if (!lookupfailed) googlelocalsearch.execute(initialsearchval);
		else if (lookupfailed == 1) googlelocalsearch.execute(mappostcode+", "+mapcountry);
		else googlelocalsearch.execute(mapcountry);
		return;
	}
	$('#mapwait').hide();
	$('#mapplaceholder').hide();
	$('#maptext').show();
	$('#map').show();
	$('#mapactions').show();
	if (map) {
		map.enableDragging();
		navcontrol = new GLargeMapControl();
		map.addControl(navcontrol);
		mapmarker.enableDragging();
		map.setCenter(new GLatLng(lat, lng), 15);
		mapmarker.setPoint(new GLatLng(lat, lng));
	} else {
		map = new GMap2(document.getElementById("map"));
		if (!lookupfailed || lookupfailed >= 10) {
			map.setCenter(new GLatLng(lat, lng), 14);
			mapmarker = new GMarker(new GLatLng(lat, lng), {icon: icon, draggable: true});
		} else {
			map.setCenter(new GLatLng(51.500152, -0.126236), 4);
			mapmarker = new GMarker(new GLatLng(51.500152, -0.126236), {icon: icon, draggable: true});
		}
		map.addOverlay(mapmarker);
		navcontrol = new GLargeMapControl();
		map.addControl(navcontrol);
	}
}

function saveMapLocation(maptype, id) {
	$('#mapsavewait').show();
	$('#mapsavebutton').hide();
	$('#mapcancelbutton').hide();
	lat = mapmarker.getPoint().lat();
	lng = mapmarker.getPoint().lng();
	$.getJSON("/lib/ajx/savemaplocation/"+maptype, {lat:lat, lng:lng, id:id}, function (json) {
		if (json.error) {
			alert(json.error);
			$('#mapsavewait').hide();
			$('#mapsavebutton').show();
			return;
		}
		map.disableDragging();
		map.removeControl(navcontrol);
		mapmarker.disableDragging();
		map.setCenter(new GLatLng(lat, lng), 15);
		$('#mapsavewait').hide();
		$('#mapactions').hide();
		$('#mapsavebutton').show();
		$('#mapcancelbutton').show();
		$("#mapeditlink").show();
		$("#mapoverview").show();
		if (!overviewmap) {
			overviewmap = new GMap2(document.getElementById("mapoverview"));
			overviewmap.setCenter(new GLatLng(lat, lng), 9);
			overviewmapmarker = new GMarker(new GLatLng(lat, lng), icon);
			overviewmap.addOverlay(overviewmapmarker);
			overviewmap.disableDragging();
		} else {
			overviewmap.setCenter(new GLatLng(lat, lng), 9);
			overviewmapmarker.setPoint(new GLatLng(lat, lng));
		}
	});
}

function cancelMapLocation() {
	if (lookupfailed) lat = lng = lookupfailed = 0;
	if (lat || lng) {
		map.removeControl(navcontrol);
		map.setCenter(new GLatLng(lat, lng), 15);
		mapmarker.setPoint(new GLatLng(lat, lng));
		map.disableDragging();
		mapmarker.disableDragging();
		$("#mapoverview").show();
	} else {
		map.removeControl(navcontrol);
		$("#map").hide();
		$("#mapplaceholder").show();
	}
	$('#mapactions').hide();
	$("#mapeditlink").show();
}

function lookupMapLocation() {
	if (!$("#maplookuploc").val()) return false;
	$("#maplookuplocbutton").hide();
	$("#maplookupwait").show();
	var googlelocalsearch = new GlocalSearch();
	googlelocalsearch.setSearchCompleteCallback(null, function() {
		if (googlelocalsearch.results[0]) {
			var resultlat = googlelocalsearch.results[0].lat;
			var resultlng = googlelocalsearch.results[0].lng;
			map.setCenter(new GLatLng(resultlat, resultlng), map.getZoom());
			mapmarker.setPoint(new GLatLng(resultlat, resultlng));
		} else {
			alert("The location you searched for could not be found.  Try searching by postcode/zipcode and country, or for city and country.");
		}
		$("#maplookuplocbutton").show();
		$("#maplookupwait").hide();
	});
	googlelocalsearch.execute($("#maplookuploc").val());
}

var curradvsearchtype = "";
function updateAdvSearchForm() {
	if (curradvsearchtype != $("#selposttype").val()) {
		$(".advsearchextras").css("display", "none");
		$("#frmsearch .grp"+$("#selposttype").val()).SlideInUp();
		curradvsearchtype = $("#selposttype").val();
	}
}

function doFeatureImageUpload() {
	if ($("#filimage").val()) {
		$("#frmfeatureimg").get(0).target = "uploadframe";
		$("#frmfeatureimg").get(0).submit();
		$("#uploadpanel1").css("display", "none");
		$("#uploadpanel2").css("display", "block");

		// Replace file upload field with a blank one, to allow the same file to be uploaded twice in a row.
		$('#filimage').after('<input id=\'filimage\' class=\'file hidden\' type=\'file\' size=\'9\' name=\'image\' >').remove();
		$('#filimage').css("opacity","0");
		$('#filimage').change(doFeatureImageUpload);
	}
}
function featureUploadStatus(status, msg) {
	if (status=="fail") {
		alert(msg);
	} else {
		$("#imgfeature").get(0).src = "/lib/tmp/"+msg;
	}
	$("#uploadpanel1").css("display", "block");
	$("#uploadpanel2").css("display", "none");
}
function updateFeatureSettings() {
	var postid = $("#hidpostid").val();
	var featurelevel = $("#selfeaturelevel").val();
	$.post("/lib/ajx/savefeaturesettings", {postid:postid,featurelevel:featurelevel});
	dialogHide();
}

function delComment(id, el, type) {
	var isspam = false;
	
	if (!confirm("Really delete "+type+"?")) return;
	if (type != "pingback") {
		isspam = (confirm('The comment will be deleted.  Do you want to report it to Akismet as spam?')) ? 1 : 0;
	}
	$.post("/lib/ajx/delcomment", {commentid:id,isspam:isspam,type:type});
	var i=0;
	$(el).parent().fadeOut("slow", function() { 
		$(this).remove();
		$("p.commentmeta strong").each(function() { 
			i++; $(this).html(i+".");
		}); 
	});
}

function leaveCommunity(community) {
	if (confirm("Are you sure you wish to leave this community?")) {
		location.href = "/communities/"+community+"/part";
	}
}

jQuery.fn.extend({
	check: function(shouldcheck) {
		if (typeof(shouldcheck) == "undefined") shouldcheck = true;
		return this.each(function() { this.checked = shouldcheck; });
	},
	uncheck: function() {
		return this.each(function() { this.checked = false; });
	}
});

function AutoCompleteField(fieldID, urlToCheck, hideFieldsArray, minwidth, argumentinput) {
	this.acArray = new Array();
	this.prev = false;
	this.minwidth = (isNaN(minwidth)) ? 250 : minwidth;
	this.theField = document.getElementById(fieldID);
	this.fieldID = fieldID;
	if (!this.theField) return false;
	this.theField.setAttribute("autocomplete", "off");
	var acfield = this;
	this.theField.onblur = function () { acfield.blur(); };
	this.theField.onkeydown = function (e) { return acfield.keyDown(e) };
	this.theField.onkeypress = function (e) { return acfield.keyPress(e) };
	this.theField.onkeyup = function () { return acfield.lookup(); };
	this.ACDiv = false;
	this.acArray["url"] = urlToCheck;
	this.acArray["lookuponkey"] = 0;
	this.acArray["curkey"] = 0;
	this.acArray["hidefields"] = hideFieldsArray;
	this.acArray["cache"] = new Array();
	if (typeof(argumentinput) == "undefined") this.argumentInputID = false;
	else this.argumentInputID = argumentinput;
	this.cachedtree = false;
	return this;
}

AutoCompleteField.prototype.redraw = function () {
	topPos = 0;
	thisDiv = this.theField;
	while (thisDiv) {
		topPos += thisDiv.offsetTop;
		thisDiv = thisDiv.offsetParent;
	}
	leftPos = 0;
	thisDiv = this.theField;
	while (thisDiv) {
		leftPos += thisDiv.offsetLeft;
		thisDiv = thisDiv.offsetParent;
	}
	this.ACDiv.style.left = leftPos+"px";
	var acdivwidth = this.theField.offsetWidth + 2;
	if (acdivwidth < this.minwidth) acdivwidth = this.minwidth;
	if (window.XMLHttpRequest) acdivwidth = acdivwidth - 4;
	this.ACDiv.style.width = acdivwidth + "px";
	this.ACDiv.style.top = (topPos+this.theField.offsetHeight-1)+"px";
	this.ACDiv.style.display = "block";
}

// When focus is moved away from the field, obviously need to hide the
// autocomplete
AutoCompleteField.prototype.blur = function () {
	if (this.ACDiv) this.ACDiv.style.display = "none";
	for (var i=0; i<this.acArray["hidefields"].length; i++) {
		document.getElementById(this.acArray["hidefields"][i]).style.display = "block";
	}
	this.acArray["display"] = false;
}

// The keyup event occurs after the key is pressed and has been
// printed to the text box.
AutoCompleteField.prototype.lookup = function () {
	if (this.argumentInputID) {
		var arg = document.getElementById(this.argumentInputID).value;
		if (this.cachedtree != arg) {
			this.cachedtree = arg;
			this.acArray["cache"] = new Array();
		}
	}
	var seltext = getSel(this.theField);
	if (!seltext && this.acArray["lastlookup"]!=this.theField.value && this.theField.value) {
		this.acArray["usercontent"] = this.theField.value;
		this.acArray["display"] = true;
		this.acArray["lookuponkey"] = this.acArray["curkey"];
		
		// If the value has been cached, use the cache
		if (this.acArray["cache"][this.theField.value]) {
			this.acArray["lastlookup"] = this.theField.value;
			this.drawResponse(this.acArray["cache"][this.theField.value]);
			
		// Else start the xmlHttp lookup
		} else {
			var currentTime = new Date();
			if (this.acArray["req"]) delete this.acArray["req"];
			this.acArray["req"] = newXmlHttp();
			var url = this.acArray["url"]+'?field='+encodeURIComponent(this.fieldID)+'&value='+encodeURIComponent(this.theField.value);
			if (this.argumentInputID) url += "&arg="+encodeURIComponent(document.getElementById(this.argumentInputID).value);
			this.acArray["req"].open("GET", url, true);

			// When the response is received, process it
			var acfield = this;
			this.acArray["req"].onreadystatechange = function () { acfield.processResponse() };
			this.acArray["req"].send(null);
			this.acArray["lastlookup"] = this.theField.value;
		}
	}
}

AutoCompleteField.prototype.processResponse = function() {
	if (this.acArray["req"] && this.acArray["req"].readyState == 4) {
		if (this.acArray["req"].status == 200) {
			if (this.acArray["req"].responseXML) {
				var response = this.acArray["req"].responseXML.documentElement;
				if (response) {
					var nodes = response.childNodes;
					var str;
					for (var i=0; i<nodes.length; i++) {
						if (nodes[i].nodeName=="value") origQuery = nodes[i].firstChild.data;
						if (nodes[i].nodeName=="field") fieldID = nodes[i].firstChild.data;
					}
					if (nodes.length) {
						this.acArray["cache"][origQuery] = response;
						this.drawResponse(response);
					}
				}
			} else {
				alert(this.acArray["req"].responseText);
			}
		} else {
			alert(this.acArray["req"].responseText);
		}
		delete this.acArray["req"];
	}
}


// Parse the response to recreate the autosuggestion list
AutoCompleteField.prototype.drawResponse = function (theXML) {

	// Check to see if the div has been created - if not, insert it.
	if (!this.ACDiv) {
		var mybody=document.getElementsByTagName("body").item(0);
		this.ACDiv = document.createElement("DIV");
		this.ACDiv.id = "autocomdiv"+this.fieldID;
		this.ACDiv.className = "autocompletediv";
		mybody.appendChild(this.ACDiv);
	}

	if (theXML.getElementsByTagName('item').length) {
		if (this.acArray["display"] && this.acArray["lookuponkey"] == this.acArray["curkey"]) {

			this.ACDiv.innerHTML = "";
			this.acArray["values"] = new Array();
			for (var i = 0; i < theXML.getElementsByTagName('item').length; i++) {
				newDiv = document.createElement("DIV");
				newDiv.style.padding = "3px";
				newDiv.innerHTML = theXML.getElementsByTagName('item')[i].firstChild.data;
				this.acArray["values"][i] = theXML.getElementsByTagName('item')[i].getAttribute('value');
				this.ACDiv.appendChild(newDiv);
			}
			this.redraw();
			for (var i=0; i<this.acArray["hidefields"].length; i++) {
				document.getElementById(this.acArray["hidefields"][i]).style.display = "none";
			}
			if (this.acArray["backspace"] == true) {
				this.acArray["index"] = -1;
				this.acArray["backspace"] = false;
			} else if (this.theField.value && this.theField.value.toLowerCase() == this.acArray["values"][0].substring(0, this.theField.value.length).toLowerCase()) {
				this.acArray["index"] = 0;
				this.selectItem();
			} else {
				this.acArray["index"] = -1;
			}
		}
	} else {
		this.blur();
	}
}

// Handle highlighting and selection of items for visual cues
AutoCompleteField.prototype.selectItem = function () {
	currentSelLength = this.acArray["usercontent"].length;
	
	// If a previous item in the selection list was selected, deselect it by removing highlight
	if (!this.ACDiv) return;
	if (this.ACDiv.getElementsByTagName('div').length) this.prev = this.ACDiv.getElementsByTagName('div')[this.acArray["lastindex"]];
	if (this.prev) this.prev.className = "autocompletenormal";
	
	// Select the new one by highlighting it
	this.ACDiv.style.display = "block";
	this.acArray["display"] = true;
	selection = this.ACDiv.getElementsByTagName('div')[this.acArray["index"]];
	if (!selection) return;
	selection.className = "autocompleteselected";

	// Get the full text value of the suggested phrase
	newText = this.acArray["values"][this.acArray["index"]];
	this.acArray["lastindex"] = this.acArray["index"];
	if (this.theField.createTextRange) {
		this.theField.value = newText;
		var theRange = this.theField.createTextRange(); 
		theRange.moveStart("character", currentSelLength); 
		theRange.moveEnd("character", newText.length); 
		theRange.select();
	} else if (this.theField.setSelectionRange) {
		this.theField.value = newText;
		this.theField.setSelectionRange(currentSelLength, newText.length);

	}
}

// KeyDown event occurs after the key is pressed but before it is
// printed to the text box.
AutoCompleteField.prototype.keyDown = function (theevent) {
	var e = (window.event) ? event : theevent;
	if (e && e.keyCode) {
		if (!this.ACDiv) {
			return true;
		}
	
		this.acArray["curkey"]++;

		// Up arrow
		if (e.keyCode == 38 || e.keyCode == 63232) {
			if (this.acArray["index"] > 0) this.acArray["index"]--;
			else this.acArray["index"] = 0;
			this.selectItem(); 
			this.acArray["lastkey"] = "up";
			return false;
		
		// Down arrow
		} else if (e.keyCode == 40 || e.keyCode == 63233) {
			if ((this.acArray["index"] + 1) < this.ACDiv.getElementsByTagName('div').length) this.acArray["index"]++;
			this.selectItem();
			this.acArray["lastkey"] = "down";
			return false;

		// Escape
		} else if (e.keyCode == 27) {
			this.acArray["lastkey"] = "esc";
			e.returnValue = false; 
			e.cancel = true;
			this.blur();
			return false;
		
		// Enter / Tab
		} else if (e.keyCode == 13 || e.keyCode == 3 || e.keyCode == 9) {
			this.acArray["lastkey"] = "enter";
			if (this.acArray["display"]) this.selectItem();
			e.returnValue = false; 
			e.cancel = true;
			this.theField.blur();
			var parentForm = false;
			var parent = this.theField.parentNode;
			while (parent && !parentForm) {
				if (parent.tagName == "FORM") parentForm = parent;
				else parent = parent.parentNode;
			}
			if (parentForm) {
				var formNum = -1;
				var elementNum = -1;
				for (var i = 0; i < document.forms.length; i++) {
					if (document.forms[i] == parent) {
						formNum = i;
						break;
					}
				}
				if (formNum > -1) {
					for (var i = 0; i < document.forms[formNum].elements.length; i++) {
						if (document.forms[formNum].elements[i] == this.theField) {
							elementNum = i;
							break;
						}
					}
				}
				if (elementNum > -1) {
					for (var i = elementNum + 1; i < document.forms[formNum].elements.length; i++) {
						if (e.shiftKey) {
							i = i - 2;
							if (i<0) break;
						}
						if (document.forms[formNum].elements[i] && (document.forms[formNum].elements[i].type != "hidden") && !document.forms[formNum].elements[i].disabled) {
							var timerID = setTimeout("document.forms["+formNum+"].elements["+i+"].focus()", 15);
							break;
						}
					}
				}
			}
			return false;
		}
	}
}

// A further intercept to prevent safari/moz processing keys too far
AutoCompleteField.prototype.keyPress = function (theevent) {
	var e = (window.event) ? event : theevent;
	if (e && e.keyCode) {
		if (!this.ACDiv) {
			return true;
		}

		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf('applewebkit') > -1) {
			var upKeyCode = 63232;
			var downKeyCode = 63233;
		} else {
			var upKeyCode = 38;
			var downKeyCode = 40;
		}
		
		// Up arrow
		if (e.keyCode == upKeyCode) {
			return false;
		
		// Down arrow
		} else if (e.keyCode == downKeyCode) {
			return false;

		// Enter / Tab
		} else if (e.keyCode == 13 || e.keyCode == 3 || e.keyCode == 9) {
			return false;
		}
	}
}

// Cross platform function for creating XML HTTP controller objects
function newXmlHttp() {
	var xmlhttp;

	if (document.all) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function getSel(ele) {
	var str = new String();
	if (document.selection) {
		var oRange = document.selection.createRange();
		str = oRange.text;
		return str;
	} else if (ele.selectionStart) {
		if (ele.selectionEnd-ele.selectionStart > 0) {
			var str = ele.value.substring(ele.selectionStart, (ele.selectionEnd-ele.selectionStart));
			return str;
		} else {
			return false;
		}
	} else return false;
}

function communityToggleSubscribeByEmail(communityid,action) {
	var height = $('#subscribebyemail_comthis_'+communityid).height();
	$('#subscribebyemail_comthis_'+communityid).hide();
	$('#emailalertsspinner').height(height).show();
	$.getJSON("/lib/ajx/subscribebyemail",{communityid:communityid,action:(typeof(action)=="undefined"?"":action)},function(responsejson) {
		$('#emailalertsspinner').hide();
		$('#subscribebyemail_comthis_'+communityid).show();
		if (responsejson.responsecode < 0) {
			alert(responsejson.msg);
		} else switch(responsejson.responsecode) {
			case 1:
				$('#subscribebyemail_comthis_'+communityid).children('a').attr("href","javascript:communityToggleSubscribeByEmail("+communityid+",'unsubscribe')");
				$('#subscribebyemail_comthis_'+communityid).children('a').html("Stop receiving emails when someone posts to this community");
				break;
			case 2:
				$('#subscribebyemail_comthis_'+communityid).children('a').attr("href","javascript:communityToggleSubscribeByEmail("+communityid+",'subscribe')");
				$('#subscribebyemail_comthis_'+communityid).children('a').html("Receive emails when someone posts to this community");
				break;
		}
		$('#subscribebyemail_comthis_'+communityid).blur();
	});
}

function postToggleIncludeInRoundUp(postid,action) {
	var height = $('#postroundup').height();
	$('#postroundup').hide();
	$('#postroundupspinner').height(height).show();
	$.getJSON("/lib/ajx/includepostinroundup",{postid:postid,action:(typeof(action)=="undefined"?"":action)},function(responsejson){
		$('#postroundupspinner').hide();
		$('#postroundup').show();
		if (responsejson.responsecode < 0) {
			alert(responsejson.msg);
		} else {
			switch (responsejson.responsecode){
				case 1:
					$('#postroundup').children('a').attr("href","javascript:postToggleIncludeInRoundUp("+postid+",'remove')");
					$('#postroundup').children('a').html("Remove from newsletter");
					break;
				case 2:
					$('#postroundup').children('a').attr("href","javascript:postToggleIncludeInRoundUp("+postid+",'include')");
					$('#postroundup').children('a').html("Include in newsletter");
					break
			}
			switch (responsejson.numposts) {
				case "0":
					$('#roundupnotice').html("No posts are currently marked for inclusion in the newsletter");
					break;
				default:
					$('#roundupnotice').html("<a href='/generateroundup'>"+responsejson.numposts+" post"+(responsejson.numposts>1?"s":"")+" "+(responsejson.numposts>1?"are":"is")+" marked for inclusion in the newsletter</a>");
					break;
			}
		}
		$('#postroundup').blur();
	});
}

function doRoundUpGenerate() {
	if (!roundupsent) {
		$('#frmgenerateroundup').submit();
		roundupsent = true;
	}
}

function parseQueryString(key) {
	key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+key+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null ) return "";
	else return results[1];
}

function attendSubmitConfirmForms() {
	$('#waittext').html('Please wait, processing...');
	dialogShow('pleasewait');
	$("#frminviteemailevent input").each(function(){
		if (!$("#frmpurchaseconfirm input[name="+$(this).attr("name")+"]").length) {
			$("#frmpurchaseconfirm").append("<input type=\"hidden\" name=\""+$(this).attr("name")+"\" value=\""+$(this).val()+"\" />");
		}
	});
	$("#frmpurchaseconfirm").submit();
}