// $Id: jquery.js,v 1.12.2.3 2008/06/25 09:38:39 goba Exp $ 

/*
 * jQuery 1.2.6 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008)
 * Rev: 5685
 */
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}('(H(){J w=1b.4M,3m$=1b.$;J D=1b.4M=1b.$=H(a,b){I 2B D.17.5j(a,b)};J u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/,62=/^.[^:#\\[\\.]*$/,12;D.17=D.44={5j:H(d,b){d=d||S;G(d.16){7[0]=d;7.K=1;I 7}G(1j d=="23"){J c=u.2D(d);G(c&&(c[1]||!b)){G(c[1])d=D.4h([c[1]],b);N{J a=S.61(c[3]);G(a){G(a.2v!=c[3])I D().2q(d);I D(a)}d=[]}}N I D(b).2q(d)}N G(D.1D(d))I D(S)[D.17.27?"27":"43"](d);I 7.6Y(D.2d(d))},5w:"1.2.6",8G:H(){I 7.K},K:0,3p:H(a){I a==12?D.2d(7):7[a]},2I:H(b){J a=D(b);a.5n=7;I a},6Y:H(a){7.K=0;2p.44.1p.1w(7,a);I 7},P:H(a,b){I D.P(7,a,b)},5i:H(b){J a=-1;I D.2L(b&&b.5w?b[0]:b,7)},1K:H(c,a,b){J d=c;G(c.1q==56)G(a===12)I 7[0]&&D[b||"1K"](7[0],c);N{d={};d[c]=a}I 7.P(H(i){R(c 1n d)D.1K(b?7.V:7,c,D.1i(7,d[c],b,i,c))})},1g:H(b,a){G((b==\'2h\'||b==\'1Z\')&&3d(a)<0)a=12;I 7.1K(b,a,"2a")},1r:H(b){G(1j b!="49"&&b!=U)I 7.4E().3v((7[0]&&7[0].2z||S).5F(b));J a="";D.P(b||7,H(){D.P(7.3t,H(){G(7.16!=8)a+=7.16!=1?7.76:D.17.1r([7])})});I a},5z:H(b){G(7[0])D(b,7[0].2z).5y().39(7[0]).2l(H(){J a=7;1B(a.1x)a=a.1x;I a}).3v(7);I 7},8Y:H(a){I 7.P(H(){D(7).6Q().5z(a)})},8R:H(a){I 7.P(H(){D(7).5z(a)})},3v:H(){I 7.3W(19,M,Q,H(a){G(7.16==1)7.3U(a)})},6F:H(){I 7.3W(19,M,M,H(a){G(7.16==1)7.39(a,7.1x)})},6E:H(){I 7.3W(19,Q,Q,H(a){7.1d.39(a,7)})},5q:H(){I 7.3W(19,Q,M,H(a){7.1d.39(a,7.2H)})},3l:H(){I 7.5n||D([])},2q:H(b){J c=D.2l(7,H(a){I D.2q(b,a)});I 7.2I(/[^+>] [^+>]/.11(b)||b.1h("..")>-1?D.4r(c):c)},5y:H(e){J f=7.2l(H(){G(D.14.1f&&!D.4n(7)){J a=7.6o(M),5h=S.3h("1v");5h.3U(a);I D.4h([5h.4H])[0]}N I 7.6o(M)});J d=f.2q("*").5c().P(H(){G(7[E]!=12)7[E]=U});G(e===M)7.2q("*").5c().P(H(i){G(7.16==3)I;J c=D.L(7,"3w");R(J a 1n c)R(J b 1n c[a])D.W.1e(d[i],a,c[a][b],c[a][b].L)});I f},1E:H(b){I 7.2I(D.1D(b)&&D.3C(7,H(a,i){I b.1k(a,i)})||D.3g(b,7))},4Y:H(b){G(b.1q==56)G(62.11(b))I 7.2I(D.3g(b,7,M));N b=D.3g(b,7);J a=b.K&&b[b.K-1]!==12&&!b.16;I 7.1E(H(){I a?D.2L(7,b)<0:7!=b})},1e:H(a){I 7.2I(D.4r(D.2R(7.3p(),1j a==\'23\'?D(a):D.2d(a))))},3F:H(a){I!!a&&D.3g(a,7).K>0},7T:H(a){I 7.3F("."+a)},6e:H(b){G(b==12){G(7.K){J c=7[0];G(D.Y(c,"2A")){J e=c.64,63=[],15=c.15,2V=c.O=="2A-2V";G(e<0)I U;R(J i=2V?e:0,2f=2V?e+1:15.K;i<2f;i++){J d=15[i];G(d.2W){b=D.14.1f&&!d.at.2x.an?d.1r:d.2x;G(2V)I b;63.1p(b)}}I 63}N I(7[0].2x||"").1o(/\\r/g,"")}I 12}G(b.1q==4L)b+=\'\';I 7.P(H(){G(7.16!=1)I;G(b.1q==2p&&/5O|5L/.11(7.O))7.4J=(D.2L(7.2x,b)>=0||D.2L(7.34,b)>=0);N G(D.Y(7,"2A")){J a=D.2d(b);D("9R",7).P(H(){7.2W=(D.2L(7.2x,a)>=0||D.2L(7.1r,a)>=0)});G(!a.K)7.64=-1}N 7.2x=b})},2K:H(a){I a==12?(7[0]?7[0].4H:U):7.4E().3v(a)},7b:H(a){I 7.5q(a).21()},79:H(i){I 7.3s(i,i+1)},3s:H(){I 7.2I(2p.44.3s.1w(7,19))},2l:H(b){I 7.2I(D.2l(7,H(a,i){I b.1k(a,i,a)}))},5c:H(){I 7.1e(7.5n)},L:H(d,b){J a=d.1R(".");a[1]=a[1]?"."+a[1]:"";G(b===12){J c=7.5C("9z"+a[1]+"!",[a[0]]);G(c===12&&7.K)c=D.L(7[0],d);I c===12&&a[1]?7.L(a[0]):c}N I 7.1P("9u"+a[1]+"!",[a[0],b]).P(H(){D.L(7,d,b)})},3b:H(a){I 7.P(H(){D.3b(7,a)})},3W:H(g,f,h,d){J e=7.K>1,3x;I 7.P(H(){G(!3x){3x=D.4h(g,7.2z);G(h)3x.9o()}J b=7;G(f&&D.Y(7,"1T")&&D.Y(3x[0],"4F"))b=7.3H("22")[0]||7.3U(7.2z.3h("22"));J c=D([]);D.P(3x,H(){J a=e?D(7).5y(M)[0]:7;G(D.Y(a,"1m"))c=c.1e(a);N{G(a.16==1)c=c.1e(D("1m",a).21());d.1k(b,a)}});c.P(6T)})}};D.17.5j.44=D.17;H 6T(i,a){G(a.4d)D.3Y({1a:a.4d,31:Q,1O:"1m"});N D.5u(a.1r||a.6O||a.4H||"");G(a.1d)a.1d.37(a)}H 1z(){I+2B 8J}D.1l=D.17.1l=H(){J b=19[0]||{},i=1,K=19.K,4x=Q,15;G(b.1q==8I){4x=b;b=19[1]||{};i=2}G(1j b!="49"&&1j b!="H")b={};G(K==i){b=7;--i}R(;i<K;i++)G((15=19[i])!=U)R(J c 1n 15){J a=b[c],2w=15[c];G(b===2w)6M;G(4x&&2w&&1j 2w=="49"&&!2w.16)b[c]=D.1l(4x,a||(2w.K!=U?[]:{}),2w);N G(2w!==12)b[c]=2w}I b};J E="4M"+1z(),6K=0,5r={},6G=/z-?5i|8B-?8A|1y|6B|8v-?1Z/i,3P=S.3P||{};D.1l({8u:H(a){1b.$=3m$;G(a)1b.4M=w;I D},1D:H(a){I!!a&&1j a!="23"&&!a.Y&&a.1q!=2p&&/^[\\s[]?H/.11(a+"")},4n:H(a){I a.1C&&!a.1c||a.2j&&a.2z&&!a.2z.1c},5u:H(a){a=D.3k(a);G(a){J b=S.3H("6w")[0]||S.1C,1m=S.3h("1m");1m.O="1r/4t";G(D.14.1f)1m.1r=a;N 1m.3U(S.5F(a));b.39(1m,b.1x);b.37(1m)}},Y:H(b,a){I b.Y&&b.Y.2r()==a.2r()},1Y:{},L:H(c,d,b){c=c==1b?5r:c;J a=c[E];G(!a)a=c[E]=++6K;G(d&&!D.1Y[a])D.1Y[a]={};G(b!==12)D.1Y[a][d]=b;I d?D.1Y[a][d]:a},3b:H(c,b){c=c==1b?5r:c;J a=c[E];G(b){G(D.1Y[a]){2U D.1Y[a][b];b="";R(b 1n D.1Y[a])1X;G(!b)D.3b(c)}}N{1U{2U c[E]}1V(e){G(c.5l)c.5l(E)}2U D.1Y[a]}},P:H(d,a,c){J e,i=0,K=d.K;G(c){G(K==12){R(e 1n d)G(a.1w(d[e],c)===Q)1X}N R(;i<K;)G(a.1w(d[i++],c)===Q)1X}N{G(K==12){R(e 1n d)G(a.1k(d[e],e,d[e])===Q)1X}N R(J b=d[0];i<K&&a.1k(b,i,b)!==Q;b=d[++i]){}}I d},1i:H(b,a,c,i,d){G(D.1D(a))a=a.1k(b,i);I a&&a.1q==4L&&c=="2a"&&!6G.11(d)?a+"2X":a},1F:{1e:H(c,b){D.P((b||"").1R(/\\s+/),H(i,a){G(c.16==1&&!D.1F.3T(c.1F,a))c.1F+=(c.1F?" ":"")+a})},21:H(c,b){G(c.16==1)c.1F=b!=12?D.3C(c.1F.1R(/\\s+/),H(a){I!D.1F.3T(b,a)}).6s(" "):""},3T:H(b,a){I D.2L(a,(b.1F||b).6r().1R(/\\s+/))>-1}},6q:H(b,c,a){J e={};R(J d 1n c){e[d]=b.V[d];b.V[d]=c[d]}a.1k(b);R(J d 1n c)b.V[d]=e[d]},1g:H(d,e,c){G(e=="2h"||e=="1Z"){J b,3X={30:"5x",5g:"1G",18:"3I"},35=e=="2h"?["5e","6k"]:["5G","6i"];H 5b(){b=e=="2h"?d.8f:d.8c;J a=0,2C=0;D.P(35,H(){a+=3d(D.2a(d,"57"+7,M))||0;2C+=3d(D.2a(d,"2C"+7+"4b",M))||0});b-=29.83(a+2C)}G(D(d).3F(":4j"))5b();N D.6q(d,3X,5b);I 29.2f(0,b)}I D.2a(d,e,c)},2a:H(f,l,k){J e,V=f.V;H 3E(b){G(!D.14.2k)I Q;J a=3P.54(b,U);I!a||a.52("3E")==""}G(l=="1y"&&D.14.1f){e=D.1K(V,"1y");I e==""?"1":e}G(D.14.2G&&l=="18"){J d=V.50;V.50="0 7Y 7W";V.50=d}G(l.1I(/4i/i))l=y;G(!k&&V&&V[l])e=V[l];N G(3P.54){G(l.1I(/4i/i))l="4i";l=l.1o(/([A-Z])/g,"-$1").3y();J c=3P.54(f,U);G(c&&!3E(f))e=c.52(l);N{J g=[],2E=[],a=f,i=0;R(;a&&3E(a);a=a.1d)2E.6h(a);R(;i<2E.K;i++)G(3E(2E[i])){g[i]=2E[i].V.18;2E[i].V.18="3I"}e=l=="18"&&g[2E.K-1]!=U?"2F":(c&&c.52(l))||"";R(i=0;i<g.K;i++)G(g[i]!=U)2E[i].V.18=g[i]}G(l=="1y"&&e=="")e="1"}N G(f.4g){J h=l.1o(/\\-(\\w)/g,H(a,b){I b.2r()});e=f.4g[l]||f.4g[h];G(!/^\\d+(2X)?$/i.11(e)&&/^\\d/.11(e)){J j=V.1A,66=f.65.1A;f.65.1A=f.4g.1A;V.1A=e||0;e=V.aM+"2X";V.1A=j;f.65.1A=66}}I e},4h:H(l,h){J k=[];h=h||S;G(1j h.3h==\'12\')h=h.2z||h[0]&&h[0].2z||S;D.P(l,H(i,d){G(!d)I;G(d.1q==4L)d+=\'\';G(1j d=="23"){d=d.1o(/(<(\\w+)[^>]*?)\\/>/g,H(b,a,c){I c.1I(/^(aK|4f|7E|aG|4T|7A|aB|3n|az|ay|av)$/i)?b:a+"></"+c+">"});J f=D.3k(d).3y(),1v=h.3h("1v");J e=!f.1h("<au")&&[1,"<2A 7w=\'7w\'>","</2A>"]||!f.1h("<ar")&&[1,"<7v>","</7v>"]||f.1I(/^<(aq|22|am|ak|ai)/)&&[1,"<1T>","</1T>"]||!f.1h("<4F")&&[2,"<1T><22>","</22></1T>"]||(!f.1h("<af")||!f.1h("<ad"))&&[3,"<1T><22><4F>","</4F></22></1T>"]||!f.1h("<7E")&&[2,"<1T><22></22><7q>","</7q></1T>"]||D.14.1f&&[1,"1v<1v>","</1v>"]||[0,"",""];1v.4H=e[1]+d+e[2];1B(e[0]--)1v=1v.5T;G(D.14.1f){J g=!f.1h("<1T")&&f.1h("<22")<0?1v.1x&&1v.1x.3t:e[1]=="<1T>"&&f.1h("<22")<0?1v.3t:[];R(J j=g.K-1;j>=0;--j)G(D.Y(g[j],"22")&&!g[j].3t.K)g[j].1d.37(g[j]);G(/^\\s/.11(d))1v.39(h.5F(d.1I(/^\\s*/)[0]),1v.1x)}d=D.2d(1v.3t)}G(d.K===0&&(!D.Y(d,"3V")&&!D.Y(d,"2A")))I;G(d[0]==12||D.Y(d,"3V")||d.15)k.1p(d);N k=D.2R(k,d)});I k},1K:H(d,f,c){G(!d||d.16==3||d.16==8)I 12;J e=!D.4n(d),40=c!==12,1f=D.14.1f;f=e&&D.3X[f]||f;G(d.2j){J g=/5Q|4d|V/.11(f);G(f=="2W"&&D.14.2k)d.1d.64;G(f 1n d&&e&&!g){G(40){G(f=="O"&&D.Y(d,"4T")&&d.1d)7p"O a3 a1\'t 9V 9U";d[f]=c}G(D.Y(d,"3V")&&d.7i(f))I d.7i(f).76;I d[f]}G(1f&&e&&f=="V")I D.1K(d.V,"9T",c);G(40)d.9Q(f,""+c);J h=1f&&e&&g?d.4G(f,2):d.4G(f);I h===U?12:h}G(1f&&f=="1y"){G(40){d.6B=1;d.1E=(d.1E||"").1o(/7f\\([^)]*\\)/,"")+(3r(c)+\'\'=="9L"?"":"7f(1y="+c*7a+")")}I d.1E&&d.1E.1h("1y=")>=0?(3d(d.1E.1I(/1y=([^)]*)/)[1])/7a)+\'\':""}f=f.1o(/-([a-z])/9H,H(a,b){I b.2r()});G(40)d[f]=c;I d[f]},3k:H(a){I(a||"").1o(/^\\s+|\\s+$/g,"")},2d:H(b){J a=[];G(b!=U){J i=b.K;G(i==U||b.1R||b.4I||b.1k)a[0]=b;N 1B(i)a[--i]=b[i]}I a},2L:H(b,a){R(J i=0,K=a.K;i<K;i++)G(a[i]===b)I i;I-1},2R:H(a,b){J i=0,T,2S=a.K;G(D.14.1f){1B(T=b[i++])G(T.16!=8)a[2S++]=T}N 1B(T=b[i++])a[2S++]=T;I a},4r:H(a){J c=[],2o={};1U{R(J i=0,K=a.K;i<K;i++){J b=D.L(a[i]);G(!2o[b]){2o[b]=M;c.1p(a[i])}}}1V(e){c=a}I c},3C:H(c,a,d){J b=[];R(J i=0,K=c.K;i<K;i++)G(!d!=!a(c[i],i))b.1p(c[i]);I b},2l:H(d,a){J c=[];R(J i=0,K=d.K;i<K;i++){J b=a(d[i],i);G(b!=U)c[c.K]=b}I c.7d.1w([],c)}});J v=9B.9A.3y();D.14={5B:(v.1I(/.+(?:9y|9x|9w|9v)[\\/: ]([\\d.]+)/)||[])[1],2k:/75/.11(v),2G:/2G/.11(v),1f:/1f/.11(v)&&!/2G/.11(v),42:/42/.11(v)&&!/(9s|75)/.11(v)};J y=D.14.1f?"7o":"72";D.1l({71:!D.14.1f||S.70=="6Z",3X:{"R":"9n","9k":"1F","4i":y,72:y,7o:y,9h:"9f",9e:"9d",9b:"99"}});D.P({6W:H(a){I a.1d},97:H(a){I D.4S(a,"1d")},95:H(a){I D.3a(a,2,"2H")},91:H(a){I D.3a(a,2,"4l")},8Z:H(a){I D.4S(a,"2H")},8X:H(a){I D.4S(a,"4l")},8W:H(a){I D.5v(a.1d.1x,a)},8V:H(a){I D.5v(a.1x)},6Q:H(a){I D.Y(a,"8U")?a.8T||a.8S.S:D.2d(a.3t)}},H(c,d){D.17[c]=H(b){J a=D.2l(7,d);G(b&&1j b=="23")a=D.3g(b,a);I 7.2I(D.4r(a))}});D.P({6P:"3v",8Q:"6F",39:"6E",8P:"5q",8O:"7b"},H(c,b){D.17[c]=H(){J a=19;I 7.P(H(){R(J i=0,K=a.K;i<K;i++)D(a[i])[b](7)})}});D.P({8N:H(a){D.1K(7,a,"");G(7.16==1)7.5l(a)},8M:H(a){D.1F.1e(7,a)},8L:H(a){D.1F.21(7,a)},8K:H(a){D.1F[D.1F.3T(7,a)?"21":"1e"](7,a)},21:H(a){G(!a||D.1E(a,[7]).r.K){D("*",7).1e(7).P(H(){D.W.21(7);D.3b(7)});G(7.1d)7.1d.37(7)}},4E:H(){D(">*",7).21();1B(7.1x)7.37(7.1x)}},H(a,b){D.17[a]=H(){I 7.P(b,19)}});D.P(["6N","4b"],H(i,c){J b=c.3y();D.17[b]=H(a){I 7[0]==1b?D.14.2G&&S.1c["5t"+c]||D.14.2k&&1b["5s"+c]||S.70=="6Z"&&S.1C["5t"+c]||S.1c["5t"+c]:7[0]==S?29.2f(29.2f(S.1c["4y"+c],S.1C["4y"+c]),29.2f(S.1c["2i"+c],S.1C["2i"+c])):a==12?(7.K?D.1g(7[0],b):U):7.1g(b,a.1q==56?a:a+"2X")}});H 25(a,b){I a[0]&&3r(D.2a(a[0],b,M),10)||0}J C=D.14.2k&&3r(D.14.5B)<8H?"(?:[\\\\w*3m-]|\\\\\\\\.)":"(?:[\\\\w\\8F-\\8E*3m-]|\\\\\\\\.)",6L=2B 4v("^>\\\\s*("+C+"+)"),6J=2B 4v("^("+C+"+)(#)("+C+"+)"),6I=2B 4v("^([#.]?)("+C+"*)");D.1l({6H:{"":H(a,i,m){I m[2]=="*"||D.Y(a,m[2])},"#":H(a,i,m){I a.4G("2v")==m[2]},":":{8D:H(a,i,m){I i<m[3]-0},8C:H(a,i,m){I i>m[3]-0},3a:H(a,i,m){I m[3]-0==i},79:H(a,i,m){I m[3]-0==i},3o:H(a,i){I i==0},3S:H(a,i,m,r){I i==r.K-1},6D:H(a,i){I i%2==0},6C:H(a,i){I i%2},"3o-4u":H(a){I a.1d.3H("*")[0]==a},"3S-4u":H(a){I D.3a(a.1d.5T,1,"4l")==a},"8z-4u":H(a){I!D.3a(a.1d.5T,2,"4l")},6W:H(a){I a.1x},4E:H(a){I!a.1x},8y:H(a,i,m){I(a.6O||a.8x||D(a).1r()||"").1h(m[3])>=0},4j:H(a){I"1G"!=a.O&&D.1g(a,"18")!="2F"&&D.1g(a,"5g")!="1G"},1G:H(a){I"1G"==a.O||D.1g(a,"18")=="2F"||D.1g(a,"5g")=="1G"},8w:H(a){I!a.3R},3R:H(a){I a.3R},4J:H(a){I a.4J},2W:H(a){I a.2W||D.1K(a,"2W")},1r:H(a){I"1r"==a.O},5O:H(a){I"5O"==a.O},5L:H(a){I"5L"==a.O},5p:H(a){I"5p"==a.O},3Q:H(a){I"3Q"==a.O},5o:H(a){I"5o"==a.O},6A:H(a){I"6A"==a.O},6z:H(a){I"6z"==a.O},2s:H(a){I"2s"==a.O||D.Y(a,"2s")},4T:H(a){I/4T|2A|6y|2s/i.11(a.Y)},3T:H(a,i,m){I D.2q(m[3],a).K},8t:H(a){I/h\\d/i.11(a.Y)},8s:H(a){I D.3C(D.3O,H(b){I a==b.T}).K}}},6x:[/^(\\[) *@?([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,2B 4v("^([:.#]*)("+C+"+)")],3g:H(a,c,b){J d,1t=[];1B(a&&a!=d){d=a;J f=D.1E(a,c,b);a=f.t.1o(/^\\s*,\\s*/,"");1t=b?c=f.r:D.2R(1t,f.r)}I 1t},2q:H(t,o){G(1j t!="23")I[t];G(o&&o.16!=1&&o.16!=9)I[];o=o||S;J d=[o],2o=[],3S,Y;1B(t&&3S!=t){J r=[];3S=t;t=D.3k(t);J l=Q,3j=6L,m=3j.2D(t);G(m){Y=m[1].2r();R(J i=0;d[i];i++)R(J c=d[i].1x;c;c=c.2H)G(c.16==1&&(Y=="*"||c.Y.2r()==Y))r.1p(c);d=r;t=t.1o(3j,"");G(t.1h(" ")==0)6M;l=M}N{3j=/^([>+~])\\s*(\\w*)/i;G((m=3j.2D(t))!=U){r=[];J k={};Y=m[2].2r();m=m[1];R(J j=0,3i=d.K;j<3i;j++){J n=m=="~"||m=="+"?d[j].2H:d[j].1x;R(;n;n=n.2H)G(n.16==1){J g=D.L(n);G(m=="~"&&k[g])1X;G(!Y||n.Y.2r()==Y){G(m=="~")k[g]=M;r.1p(n)}G(m=="+")1X}}d=r;t=D.3k(t.1o(3j,""));l=M}}G(t&&!l){G(!t.1h(",")){G(o==d[0])d.4s();2o=D.2R(2o,d);r=d=[o];t=" "+t.6v(1,t.K)}N{J h=6J;J m=h.2D(t);G(m){m=[0,m[2],m[3],m[1]]}N{h=6I;m=h.2D(t)}m[2]=m[2].1o(/\\\\/g,"");J f=d[d.K-1];G(m[1]=="#"&&f&&f.61&&!D.4n(f)){J p=f.61(m[2]);G((D.14.1f||D.14.2G)&&p&&1j p.2v=="23"&&p.2v!=m[2])p=D(\'[@2v="\'+m[2]+\'"]\',f)[0];d=r=p&&(!m[3]||D.Y(p,m[3]))?[p]:[]}N{R(J i=0;d[i];i++){J a=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];G(a=="*"&&d[i].Y.3y()=="49")a="3n";r=D.2R(r,d[i].3H(a))}G(m[1]==".")r=D.5m(r,m[2]);G(m[1]=="#"){J e=[];R(J i=0;r[i];i++)G(r[i].4G("2v")==m[2]){e=[r[i]];1X}r=e}d=r}t=t.1o(h,"")}}G(t){J b=D.1E(t,r);d=r=b.r;t=D.3k(b.t)}}G(t)d=[];G(d&&o==d[0])d.4s();2o=D.2R(2o,d);I 2o},5m:H(r,m,a){m=" "+m+" ";J c=[];R(J i=0;r[i];i++){J b=(" "+r[i].1F+" ").1h(m)>=0;G(!a&&b||a&&!b)c.1p(r[i])}I c},1E:H(t,r,h){J d;1B(t&&t!=d){d=t;J p=D.6x,m;R(J i=0;p[i];i++){m=p[i].2D(t);G(m){t=t.8r(m[0].K);m[2]=m[2].1o(/\\\\/g,"");1X}}G(!m)1X;G(m[1]==":"&&m[2]=="4Y")r=62.11(m[3])?D.1E(m[3],r,M).r:D(r).4Y(m[3]);N G(m[1]==".")r=D.5m(r,m[2],h);N G(m[1]=="["){J g=[],O=m[3];R(J i=0,3i=r.K;i<3i;i++){J a=r[i],z=a[D.3X[m[2]]||m[2]];G(z==U||/5Q|4d|2W/.11(m[2]))z=D.1K(a,m[2])||\'\';G((O==""&&!!z||O=="="&&z==m[5]||O=="!="&&z!=m[5]||O=="^="&&z&&!z.1h(m[5])||O=="$="&&z.6v(z.K-m[5].K)==m[5]||(O=="*="||O=="~=")&&z.1h(m[5])>=0)^h)g.1p(a)}r=g}N G(m[1]==":"&&m[2]=="3a-4u"){J e={},g=[],11=/(-?)(\\d*)n((?:\\+|-)?\\d*)/.2D(m[3]=="6D"&&"2n"||m[3]=="6C"&&"2n+1"||!/\\D/.11(m[3])&&"8q+"+m[3]||m[3]),3o=(11[1]+(11[2]||1))-0,d=11[3]-0;R(J i=0,3i=r.K;i<3i;i++){J j=r[i],1d=j.1d,2v=D.L(1d);G(!e[2v]){J c=1;R(J n=1d.1x;n;n=n.2H)G(n.16==1)n.4q=c++;e[2v]=M}J b=Q;G(3o==0){G(j.4q==d)b=M}N G((j.4q-d)%3o==0&&(j.4q-d)/3o>=0)b=M;G(b^h)g.1p(j)}r=g}N{J f=D.6H[m[1]];G(1j f=="49")f=f[m[2]];G(1j f=="23")f=6u("Q||H(a,i){I "+f+";}");r=D.3C(r,H(a,i){I f(a,i,m,r)},h)}}I{r:r,t:t}},4S:H(b,c){J a=[],1t=b[c];1B(1t&&1t!=S){G(1t.16==1)a.1p(1t);1t=1t[c]}I a},3a:H(a,e,c,b){e=e||1;J d=0;R(;a;a=a[c])G(a.16==1&&++d==e)1X;I a},5v:H(n,a){J r=[];R(;n;n=n.2H){G(n.16==1&&n!=a)r.1p(n)}I r}});D.W={1e:H(f,i,g,e){G(f.16==3||f.16==8)I;G(D.14.1f&&f.4I)f=1b;G(!g.24)g.24=7.24++;G(e!=12){J h=g;g=7.3M(h,H(){I h.1w(7,19)});g.L=e}J j=D.L(f,"3w")||D.L(f,"3w",{}),1H=D.L(f,"1H")||D.L(f,"1H",H(){G(1j D!="12"&&!D.W.5k)I D.W.1H.1w(19.3L.T,19)});1H.T=f;D.P(i.1R(/\\s+/),H(c,b){J a=b.1R(".");b=a[0];g.O=a[1];J d=j[b];G(!d){d=j[b]={};G(!D.W.2t[b]||D.W.2t[b].4p.1k(f)===Q){G(f.3K)f.3K(b,1H,Q);N G(f.6t)f.6t("4o"+b,1H)}}d[g.24]=g;D.W.26[b]=M});f=U},24:1,26:{},21:H(e,h,f){G(e.16==3||e.16==8)I;J i=D.L(e,"3w"),1L,5i;G(i){G(h==12||(1j h=="23"&&h.8p(0)=="."))R(J g 1n i)7.21(e,g+(h||""));N{G(h.O){f=h.2y;h=h.O}D.P(h.1R(/\\s+/),H(b,a){J c=a.1R(".");a=c[0];G(i[a]){G(f)2U i[a][f.24];N R(f 1n i[a])G(!c[1]||i[a][f].O==c[1])2U i[a][f];R(1L 1n i[a])1X;G(!1L){G(!D.W.2t[a]||D.W.2t[a].4A.1k(e)===Q){G(e.6p)e.6p(a,D.L(e,"1H"),Q);N G(e.6n)e.6n("4o"+a,D.L(e,"1H"))}1L=U;2U i[a]}}})}R(1L 1n i)1X;G(!1L){J d=D.L(e,"1H");G(d)d.T=U;D.3b(e,"3w");D.3b(e,"1H")}}},1P:H(h,c,f,g,i){c=D.2d(c);G(h.1h("!")>=0){h=h.3s(0,-1);J a=M}G(!f){G(7.26[h])D("*").1e([1b,S]).1P(h,c)}N{G(f.16==3||f.16==8)I 12;J b,1L,17=D.1D(f[h]||U),W=!c[0]||!c[0].32;G(W){c.6h({O:h,2J:f,32:H(){},3J:H(){},4C:1z()});c[0][E]=M}c[0].O=h;G(a)c[0].6m=M;J d=D.L(f,"1H");G(d)b=d.1w(f,c);G((!17||(D.Y(f,\'a\')&&h=="4V"))&&f["4o"+h]&&f["4o"+h].1w(f,c)===Q)b=Q;G(W)c.4s();G(i&&D.1D(i)){1L=i.1w(f,b==U?c:c.7d(b));G(1L!==12)b=1L}G(17&&g!==Q&&b!==Q&&!(D.Y(f,\'a\')&&h=="4V")){7.5k=M;1U{f[h]()}1V(e){}}7.5k=Q}I b},1H:H(b){J a,1L,38,5f,4m;b=19[0]=D.W.6l(b||1b.W);38=b.O.1R(".");b.O=38[0];38=38[1];5f=!38&&!b.6m;4m=(D.L(7,"3w")||{})[b.O];R(J j 1n 4m){J c=4m[j];G(5f||c.O==38){b.2y=c;b.L=c.L;1L=c.1w(7,19);G(a!==Q)a=1L;G(1L===Q){b.32();b.3J()}}}I a},6l:H(b){G(b[E]==M)I b;J d=b;b={8o:d};J c="8n 8m 8l 8k 2s 8j 47 5d 6j 5E 8i L 8h 8g 4K 2y 5a 59 8e 8b 58 6f 8a 88 4k 87 86 84 6d 2J 4C 6c O 82 81 35".1R(" ");R(J i=c.K;i;i--)b[c[i]]=d[c[i]];b[E]=M;b.32=H(){G(d.32)d.32();d.80=Q};b.3J=H(){G(d.3J)d.3J();d.7Z=M};b.4C=b.4C||1z();G(!b.2J)b.2J=b.6d||S;G(b.2J.16==3)b.2J=b.2J.1d;G(!b.4k&&b.4K)b.4k=b.4K==b.2J?b.6c:b.4K;G(b.58==U&&b.5d!=U){J a=S.1C,1c=S.1c;b.58=b.5d+(a&&a.2e||1c&&1c.2e||0)-(a.6b||0);b.6f=b.6j+(a&&a.2c||1c&&1c.2c||0)-(a.6a||0)}G(!b.35&&((b.47||b.47===0)?b.47:b.5a))b.35=b.47||b.5a;G(!b.59&&b.5E)b.59=b.5E;G(!b.35&&b.2s)b.35=(b.2s&1?1:(b.2s&2?3:(b.2s&4?2:0)));I b},3M:H(a,b){b.24=a.24=a.24||b.24||7.24++;I b},2t:{27:{4p:H(){55();I},4A:H(){I}},3D:{4p:H(){G(D.14.1f)I Q;D(7).2O("53",D.W.2t.3D.2y);I M},4A:H(){G(D.14.1f)I Q;D(7).4e("53",D.W.2t.3D.2y);I M},2y:H(a){G(F(a,7))I M;a.O="3D";I D.W.1H.1w(7,19)}},3N:{4p:H(){G(D.14.1f)I Q;D(7).2O("51",D.W.2t.3N.2y);I M},4A:H(){G(D.14.1f)I Q;D(7).4e("51",D.W.2t.3N.2y);I M},2y:H(a){G(F(a,7))I M;a.O="3N";I D.W.1H.1w(7,19)}}}};D.17.1l({2O:H(c,a,b){I c=="4X"?7.2V(c,a,b):7.P(H(){D.W.1e(7,c,b||a,b&&a)})},2V:H(d,b,c){J e=D.W.3M(c||b,H(a){D(7).4e(a,e);I(c||b).1w(7,19)});I 7.P(H(){D.W.1e(7,d,e,c&&b)})},4e:H(a,b){I 7.P(H(){D.W.21(7,a,b)})},1P:H(c,a,b){I 7.P(H(){D.W.1P(c,a,7,M,b)})},5C:H(c,a,b){I 7[0]&&D.W.1P(c,a,7[0],Q,b)},2m:H(b){J c=19,i=1;1B(i<c.K)D.W.3M(b,c[i++]);I 7.4V(D.W.3M(b,H(a){7.4Z=(7.4Z||0)%i;a.32();I c[7.4Z++].1w(7,19)||Q}))},7X:H(a,b){I 7.2O(\'3D\',a).2O(\'3N\',b)},27:H(a){55();G(D.2Q)a.1k(S,D);N D.3A.1p(H(){I a.1k(7,D)});I 7}});D.1l({2Q:Q,3A:[],27:H(){G(!D.2Q){D.2Q=M;G(D.3A){D.P(D.3A,H(){7.1k(S)});D.3A=U}D(S).5C("27")}}});J x=Q;H 55(){G(x)I;x=M;G(S.3K&&!D.14.2G)S.3K("69",D.27,Q);G(D.14.1f&&1b==1S)(H(){G(D.2Q)I;1U{S.1C.7V("1A")}1V(3e){3B(19.3L,0);I}D.27()})();G(D.14.2G)S.3K("69",H(){G(D.2Q)I;R(J i=0;i<S.4W.K;i++)G(S.4W[i].3R){3B(19.3L,0);I}D.27()},Q);G(D.14.2k){J a;(H(){G(D.2Q)I;G(S.3f!="68"&&S.3f!="1J"){3B(19.3L,0);I}G(a===12)a=D("V, 7A[7U=7S]").K;G(S.4W.K!=a){3B(19.3L,0);I}D.27()})()}D.W.1e(1b,"43",D.27)}D.P(("7R,7Q,43,85,4y,4X,4V,7P,"+"7O,7N,89,53,51,7M,2A,"+"5o,7L,7K,8d,3e").1R(","),H(i,b){D.17[b]=H(a){I a?7.2O(b,a):7.1P(b)}});J F=H(a,c){J b=a.4k;1B(b&&b!=c)1U{b=b.1d}1V(3e){b=c}I b==c};D(1b).2O("4X",H(){D("*").1e(S).4e()});D.17.1l({67:D.17.43,43:H(g,d,c){G(1j g!=\'23\')I 7.67(g);J e=g.1h(" ");G(e>=0){J i=g.3s(e,g.K);g=g.3s(0,e)}c=c||H(){};J f="2P";G(d)G(D.1D(d)){c=d;d=U}N{d=D.3n(d);f="6g"}J h=7;D.3Y({1a:g,O:f,1O:"2K",L:d,1J:H(a,b){G(b=="1W"||b=="7J")h.2K(i?D("<1v/>").3v(a.4U.1o(/<1m(.|\\s)*?\\/1m>/g,"")).2q(i):a.4U);h.P(c,[a.4U,b,a])}});I 7},aL:H(){I D.3n(7.7I())},7I:H(){I 7.2l(H(){I D.Y(7,"3V")?D.2d(7.aH):7}).1E(H(){I 7.34&&!7.3R&&(7.4J||/2A|6y/i.11(7.Y)||/1r|1G|3Q/i.11(7.O))}).2l(H(i,c){J b=D(7).6e();I b==U?U:b.1q==2p?D.2l(b,H(a,i){I{34:c.34,2x:a}}):{34:c.34,2x:b}}).3p()}});D.P("7H,7G,7F,7D,7C,7B".1R(","),H(i,o){D.17[o]=H(f){I 7.2O(o,f)}});J B=1z();D.1l({3p:H(d,b,a,c){G(D.1D(b)){a=b;b=U}I D.3Y({O:"2P",1a:d,L:b,1W:a,1O:c})},aE:H(b,a){I D.3p(b,U,a,"1m")},aD:H(c,b,a){I D.3p(c,b,a,"3z")},aC:H(d,b,a,c){G(D.1D(b)){a=b;b={}}I D.3Y({O:"6g",1a:d,L:b,1W:a,1O:c})},aA:H(a){D.1l(D.60,a)},60:{1a:5Z.5Q,26:M,O:"2P",2T:0,7z:"4R/x-ax-3V-aw",7x:M,31:M,L:U,5Y:U,3Q:U,4Q:{2N:"4R/2N, 1r/2N",2K:"1r/2K",1m:"1r/4t, 4R/4t",3z:"4R/3z, 1r/4t",1r:"1r/as",4w:"*/*"}},4z:{},3Y:H(s){s=D.1l(M,s,D.1l(M,{},D.60,s));J g,2Z=/=\\?(&|$)/g,1u,L,O=s.O.2r();G(s.L&&s.7x&&1j s.L!="23")s.L=D.3n(s.L);G(s.1O=="4P"){G(O=="2P"){G(!s.1a.1I(2Z))s.1a+=(s.1a.1I(/\\?/)?"&":"?")+(s.4P||"7u")+"=?"}N G(!s.L||!s.L.1I(2Z))s.L=(s.L?s.L+"&":"")+(s.4P||"7u")+"=?";s.1O="3z"}G(s.1O=="3z"&&(s.L&&s.L.1I(2Z)||s.1a.1I(2Z))){g="4P"+B++;G(s.L)s.L=(s.L+"").1o(2Z,"="+g+"$1");s.1a=s.1a.1o(2Z,"="+g+"$1");s.1O="1m";1b[g]=H(a){L=a;1W();1J();1b[g]=12;1U{2U 1b[g]}1V(e){}G(i)i.37(h)}}G(s.1O=="1m"&&s.1Y==U)s.1Y=Q;G(s.1Y===Q&&O=="2P"){J j=1z();J k=s.1a.1o(/(\\?|&)3m=.*?(&|$)/,"$ap="+j+"$2");s.1a=k+((k==s.1a)?(s.1a.1I(/\\?/)?"&":"?")+"3m="+j:"")}G(s.L&&O=="2P"){s.1a+=(s.1a.1I(/\\?/)?"&":"?")+s.L;s.L=U}G(s.26&&!D.4O++)D.W.1P("7H");J n=/^(?:\\w+:)?\\/\\/([^\\/?#]+)/;G(s.1O=="1m"&&O=="2P"&&n.11(s.1a)&&n.2D(s.1a)[1]!=5Z.al){J i=S.3H("6w")[0];J h=S.3h("1m");h.4d=s.1a;G(s.7t)h.aj=s.7t;G(!g){J l=Q;h.ah=h.ag=H(){G(!l&&(!7.3f||7.3f=="68"||7.3f=="1J")){l=M;1W();1J();i.37(h)}}}i.3U(h);I 12}J m=Q;J c=1b.7s?2B 7s("ae.ac"):2B 7r();G(s.5Y)c.6R(O,s.1a,s.31,s.5Y,s.3Q);N c.6R(O,s.1a,s.31);1U{G(s.L)c.4B("ab-aa",s.7z);G(s.5S)c.4B("a9-5R-a8",D.4z[s.1a]||"a7, a6 a5 a4 5N:5N:5N a2");c.4B("X-9Z-9Y","7r");c.4B("9W",s.1O&&s.4Q[s.1O]?s.4Q[s.1O]+", */*":s.4Q.4w)}1V(e){}G(s.7m&&s.7m(c,s)===Q){s.26&&D.4O--;c.7l();I Q}G(s.26)D.W.1P("7B",[c,s]);J d=H(a){G(!m&&c&&(c.3f==4||a=="2T")){m=M;G(f){7k(f);f=U}1u=a=="2T"&&"2T"||!D.7j(c)&&"3e"||s.5S&&D.7h(c,s.1a)&&"7J"||"1W";G(1u=="1W"){1U{L=D.6X(c,s.1O,s.9S)}1V(e){1u="5J"}}G(1u=="1W"){J b;1U{b=c.5I("7g-5R")}1V(e){}G(s.5S&&b)D.4z[s.1a]=b;G(!g)1W()}N D.5H(s,c,1u);1J();G(s.31)c=U}};G(s.31){J f=4I(d,13);G(s.2T>0)3B(H(){G(c){c.7l();G(!m)d("2T")}},s.2T)}1U{c.9P(s.L)}1V(e){D.5H(s,c,U,e)}G(!s.31)d();H 1W(){G(s.1W)s.1W(L,1u);G(s.26)D.W.1P("7C",[c,s])}H 1J(){G(s.1J)s.1J(c,1u);G(s.26)D.W.1P("7F",[c,s]);G(s.26&&!--D.4O)D.W.1P("7G")}I c},5H:H(s,a,b,e){G(s.3e)s.3e(a,b,e);G(s.26)D.W.1P("7D",[a,s,e])},4O:0,7j:H(a){1U{I!a.1u&&5Z.9O=="5p:"||(a.1u>=7e&&a.1u<9N)||a.1u==7c||a.1u==9K||D.14.2k&&a.1u==12}1V(e){}I Q},7h:H(a,c){1U{J b=a.5I("7g-5R");I a.1u==7c||b==D.4z[c]||D.14.2k&&a.1u==12}1V(e){}I Q},6X:H(a,c,b){J d=a.5I("9J-O"),2N=c=="2N"||!c&&d&&d.1h("2N")>=0,L=2N?a.9I:a.4U;G(2N&&L.1C.2j=="5J")7p"5J";G(b)L=b(L,c);G(c=="1m")D.5u(L);G(c=="3z")L=6u("("+L+")");I L},3n:H(a){J s=[];G(a.1q==2p||a.5w)D.P(a,H(){s.1p(3u(7.34)+"="+3u(7.2x))});N R(J j 1n a)G(a[j]&&a[j].1q==2p)D.P(a[j],H(){s.1p(3u(j)+"="+3u(7))});N s.1p(3u(j)+"="+3u(D.1D(a[j])?a[j]():a[j]));I s.6s("&").1o(/%20/g,"+")}});D.17.1l({1N:H(c,b){I c?7.2g({1Z:"1N",2h:"1N",1y:"1N"},c,b):7.1E(":1G").P(H(){7.V.18=7.5D||"";G(D.1g(7,"18")=="2F"){J a=D("<"+7.2j+" />").6P("1c");7.V.18=a.1g("18");G(7.V.18=="2F")7.V.18="3I";a.21()}}).3l()},1M:H(b,a){I b?7.2g({1Z:"1M",2h:"1M",1y:"1M"},b,a):7.1E(":4j").P(H(){7.5D=7.5D||D.1g(7,"18");7.V.18="2F"}).3l()},78:D.17.2m,2m:H(a,b){I D.1D(a)&&D.1D(b)?7.78.1w(7,19):a?7.2g({1Z:"2m",2h:"2m",1y:"2m"},a,b):7.P(H(){D(7)[D(7).3F(":1G")?"1N":"1M"]()})},9G:H(b,a){I 7.2g({1Z:"1N"},b,a)},9F:H(b,a){I 7.2g({1Z:"1M"},b,a)},9E:H(b,a){I 7.2g({1Z:"2m"},b,a)},9D:H(b,a){I 7.2g({1y:"1N"},b,a)},9M:H(b,a){I 7.2g({1y:"1M"},b,a)},9C:H(c,a,b){I 7.2g({1y:a},c,b)},2g:H(k,j,i,g){J h=D.77(j,i,g);I 7[h.36===Q?"P":"36"](H(){G(7.16!=1)I Q;J f=D.1l({},h),p,1G=D(7).3F(":1G"),46=7;R(p 1n k){G(k[p]=="1M"&&1G||k[p]=="1N"&&!1G)I f.1J.1k(7);G(p=="1Z"||p=="2h"){f.18=D.1g(7,"18");f.33=7.V.33}}G(f.33!=U)7.V.33="1G";f.45=D.1l({},k);D.P(k,H(c,a){J e=2B D.28(46,f,c);G(/2m|1N|1M/.11(a))e[a=="2m"?1G?"1N":"1M":a](k);N{J b=a.6r().1I(/^([+-]=)?([\\d+-.]+)(.*)$/),2b=e.1t(M)||0;G(b){J d=3d(b[2]),2M=b[3]||"2X";G(2M!="2X"){46.V[c]=(d||1)+2M;2b=((d||1)/e.1t(M))*2b;46.V[c]=2b+2M}G(b[1])d=((b[1]=="-="?-1:1)*d)+2b;e.3G(2b,d,2M)}N e.3G(2b,a,"")}});I M})},36:H(a,b){G(D.1D(a)||(a&&a.1q==2p)){b=a;a="28"}G(!a||(1j a=="23"&&!b))I A(7[0],a);I 7.P(H(){G(b.1q==2p)A(7,a,b);N{A(7,a).1p(b);G(A(7,a).K==1)b.1k(7)}})},9X:H(b,c){J a=D.3O;G(b)7.36([]);7.P(H(){R(J i=a.K-1;i>=0;i--)G(a[i].T==7){G(c)a[i](M);a.7n(i,1)}});G(!c)7.5A();I 7}});J A=H(b,c,a){G(b){c=c||"28";J q=D.L(b,c+"36");G(!q||a)q=D.L(b,c+"36",D.2d(a))}I q};D.17.5A=H(a){a=a||"28";I 7.P(H(){J q=A(7,a);q.4s();G(q.K)q[0].1k(7)})};D.1l({77:H(b,a,c){J d=b&&b.1q==a0?b:{1J:c||!c&&a||D.1D(b)&&b,2u:b,41:c&&a||a&&a.1q!=9t&&a};d.2u=(d.2u&&d.2u.1q==4L?d.2u:D.28.5K[d.2u])||D.28.5K.74;d.5M=d.1J;d.1J=H(){G(d.36!==Q)D(7).5A();G(D.1D(d.5M))d.5M.1k(7)};I d},41:{73:H(p,n,b,a){I b+a*p},5P:H(p,n,b,a){I((-29.9r(p*29.9q)/2)+0.5)*a+b}},3O:[],48:U,28:H(b,c,a){7.15=c;7.T=b;7.1i=a;G(!c.3Z)c.3Z={}}});D.28.44={4D:H(){G(7.15.2Y)7.15.2Y.1k(7.T,7.1z,7);(D.28.2Y[7.1i]||D.28.2Y.4w)(7);G(7.1i=="1Z"||7.1i=="2h")7.T.V.18="3I"},1t:H(a){G(7.T[7.1i]!=U&&7.T.V[7.1i]==U)I 7.T[7.1i];J r=3d(D.1g(7.T,7.1i,a));I r&&r>-9p?r:3d(D.2a(7.T,7.1i))||0},3G:H(c,b,d){7.5V=1z();7.2b=c;7.3l=b;7.2M=d||7.2M||"2X";7.1z=7.2b;7.2S=7.4N=0;7.4D();J e=7;H t(a){I e.2Y(a)}t.T=7.T;D.3O.1p(t);G(D.48==U){D.48=4I(H(){J a=D.3O;R(J i=0;i<a.K;i++)G(!a[i]())a.7n(i--,1);G(!a.K){7k(D.48);D.48=U}},13)}},1N:H(){7.15.3Z[7.1i]=D.1K(7.T.V,7.1i);7.15.1N=M;7.3G(0,7.1t());G(7.1i=="2h"||7.1i=="1Z")7.T.V[7.1i]="9m";D(7.T).1N()},1M:H(){7.15.3Z[7.1i]=D.1K(7.T.V,7.1i);7.15.1M=M;7.3G(7.1t(),0)},2Y:H(a){J t=1z();G(a||t>7.15.2u+7.5V){7.1z=7.3l;7.2S=7.4N=1;7.4D();7.15.45[7.1i]=M;J b=M;R(J i 1n 7.15.45)G(7.15.45[i]!==M)b=Q;G(b){G(7.15.18!=U){7.T.V.33=7.15.33;7.T.V.18=7.15.18;G(D.1g(7.T,"18")=="2F")7.T.V.18="3I"}G(7.15.1M)7.T.V.18="2F";G(7.15.1M||7.15.1N)R(J p 1n 7.15.45)D.1K(7.T.V,p,7.15.3Z[p])}G(b)7.15.1J.1k(7.T);I Q}N{J n=t-7.5V;7.4N=n/7.15.2u;7.2S=D.41[7.15.41||(D.41.5P?"5P":"73")](7.4N,n,0,1,7.15.2u);7.1z=7.2b+((7.3l-7.2b)*7.2S);7.4D()}I M}};D.1l(D.28,{5K:{9l:9j,9i:7e,74:9g},2Y:{2e:H(a){a.T.2e=a.1z},2c:H(a){a.T.2c=a.1z},1y:H(a){D.1K(a.T.V,"1y",a.1z)},4w:H(a){a.T.V[a.1i]=a.1z+a.2M}}});D.17.2i=H(){J b=0,1S=0,T=7[0],3q;G(T)ao(D.14){J d=T.1d,4a=T,1s=T.1s,1Q=T.2z,5U=2k&&3r(5B)<9c&&!/9a/i.11(v),1g=D.2a,3c=1g(T,"30")=="3c";G(T.7y){J c=T.7y();1e(c.1A+29.2f(1Q.1C.2e,1Q.1c.2e),c.1S+29.2f(1Q.1C.2c,1Q.1c.2c));1e(-1Q.1C.6b,-1Q.1C.6a)}N{1e(T.5X,T.5W);1B(1s){1e(1s.5X,1s.5W);G(42&&!/^t(98|d|h)$/i.11(1s.2j)||2k&&!5U)2C(1s);G(!3c&&1g(1s,"30")=="3c")3c=M;4a=/^1c$/i.11(1s.2j)?4a:1s;1s=1s.1s}1B(d&&d.2j&&!/^1c|2K$/i.11(d.2j)){G(!/^96|1T.*$/i.11(1g(d,"18")))1e(-d.2e,-d.2c);G(42&&1g(d,"33")!="4j")2C(d);d=d.1d}G((5U&&(3c||1g(4a,"30")=="5x"))||(42&&1g(4a,"30")!="5x"))1e(-1Q.1c.5X,-1Q.1c.5W);G(3c)1e(29.2f(1Q.1C.2e,1Q.1c.2e),29.2f(1Q.1C.2c,1Q.1c.2c))}3q={1S:1S,1A:b}}H 2C(a){1e(D.2a(a,"6V",M),D.2a(a,"6U",M))}H 1e(l,t){b+=3r(l,10)||0;1S+=3r(t,10)||0}I 3q};D.17.1l({30:H(){J a=0,1S=0,3q;G(7[0]){J b=7.1s(),2i=7.2i(),4c=/^1c|2K$/i.11(b[0].2j)?{1S:0,1A:0}:b.2i();2i.1S-=25(7,\'94\');2i.1A-=25(7,\'aF\');4c.1S+=25(b,\'6U\');4c.1A+=25(b,\'6V\');3q={1S:2i.1S-4c.1S,1A:2i.1A-4c.1A}}I 3q},1s:H(){J a=7[0].1s;1B(a&&(!/^1c|2K$/i.11(a.2j)&&D.1g(a,\'30\')==\'93\'))a=a.1s;I D(a)}});D.P([\'5e\',\'5G\'],H(i,b){J c=\'4y\'+b;D.17[c]=H(a){G(!7[0])I;I a!=12?7.P(H(){7==1b||7==S?1b.92(!i?a:D(1b).2e(),i?a:D(1b).2c()):7[c]=a}):7[0]==1b||7[0]==S?46[i?\'aI\':\'aJ\']||D.71&&S.1C[c]||S.1c[c]:7[0][c]}});D.P(["6N","4b"],H(i,b){J c=i?"5e":"5G",4f=i?"6k":"6i";D.17["5s"+b]=H(){I 7[b.3y()]()+25(7,"57"+c)+25(7,"57"+4f)};D.17["90"+b]=H(a){I 7["5s"+b]()+25(7,"2C"+c+"4b")+25(7,"2C"+4f+"4b")+(a?25(7,"6S"+c)+25(7,"6S"+4f):0)}})})();',62,669,'|||||||this|||||||||||||||||||||||||||||||||||if|function|return|var|length|data|true|else|type|each|false|for|document|elem|null|style|event||nodeName|||test|undefined||browser|options|nodeType|fn|display|arguments|url|window|body|parentNode|add|msie|css|indexOf|prop|typeof|call|extend|script|in|replace|push|constructor|text|offsetParent|cur|status|div|apply|firstChild|opacity|now|left|while|documentElement|isFunction|filter|className|hidden|handle|match|complete|attr|ret|hide|show|dataType|trigger|doc|split|top|table|try|catch|success|break|cache|height||remove|tbody|string|guid|num|global|ready|fx|Math|curCSS|start|scrollTop|makeArray|scrollLeft|max|animate|width|offset|tagName|safari|map|toggle||done|Array|find|toUpperCase|button|special|duration|id|copy|value|handler|ownerDocument|select|new|border|exec|stack|none|opera|nextSibling|pushStack|target|html|inArray|unit|xml|bind|GET|isReady|merge|pos|timeout|delete|one|selected|px|step|jsre|position|async|preventDefault|overflow|name|which|queue|removeChild|namespace|insertBefore|nth|removeData|fixed|parseFloat|error|readyState|multiFilter|createElement|rl|re|trim|end|_|param|first|get|results|parseInt|slice|childNodes|encodeURIComponent|append|events|elems|toLowerCase|json|readyList|setTimeout|grep|mouseenter|color|is|custom|getElementsByTagName|block|stopPropagation|addEventListener|callee|proxy|mouseleave|timers|defaultView|password|disabled|last|has|appendChild|form|domManip|props|ajax|orig|set|easing|mozilla|load|prototype|curAnim|self|charCode|timerId|object|offsetChild|Width|parentOffset|src|unbind|br|currentStyle|clean|float|visible|relatedTarget|previousSibling|handlers|isXMLDoc|on|setup|nodeIndex|unique|shift|javascript|child|RegExp|_default|deep|scroll|lastModified|teardown|setRequestHeader|timeStamp|update|empty|tr|getAttribute|innerHTML|setInterval|checked|fromElement|Number|jQuery|state|active|jsonp|accepts|application|dir|input|responseText|click|styleSheets|unload|not|lastToggle|outline|mouseout|getPropertyValue|mouseover|getComputedStyle|bindReady|String|padding|pageX|metaKey|keyCode|getWH|andSelf|clientX|Left|all|visibility|container|index|init|triggered|removeAttribute|classFilter|prevObject|submit|file|after|windowData|inner|client|globalEval|sibling|jquery|absolute|clone|wrapAll|dequeue|version|triggerHandler|oldblock|ctrlKey|createTextNode|Top|handleError|getResponseHeader|parsererror|speeds|checkbox|old|00|radio|swing|href|Modified|ifModified|lastChild|safari2|startTime|offsetTop|offsetLeft|username|location|ajaxSettings|getElementById|isSimple|values|selectedIndex|runtimeStyle|rsLeft|_load|loaded|DOMContentLoaded|clientTop|clientLeft|toElement|srcElement|val|pageY|POST|unshift|Bottom|clientY|Right|fix|exclusive|detachEvent|cloneNode|removeEventListener|swap|toString|join|attachEvent|eval|substr|head|parse|textarea|reset|image|zoom|odd|even|before|prepend|exclude|expr|quickClass|quickID|uuid|quickChild|continue|Height|textContent|appendTo|contents|open|margin|evalScript|borderTopWidth|borderLeftWidth|parent|httpData|setArray|CSS1Compat|compatMode|boxModel|cssFloat|linear|def|webkit|nodeValue|speed|_toggle|eq|100|replaceWith|304|concat|200|alpha|Last|httpNotModified|getAttributeNode|httpSuccess|clearInterval|abort|beforeSend|splice|styleFloat|throw|colgroup|XMLHttpRequest|ActiveXObject|scriptCharset|callback|fieldset|multiple|processData|getBoundingClientRect|contentType|link|ajaxSend|ajaxSuccess|ajaxError|col|ajaxComplete|ajaxStop|ajaxStart|serializeArray|notmodified|keypress|keydown|change|mouseup|mousedown|dblclick|focus|blur|stylesheet|hasClass|rel|doScroll|black|hover|solid|cancelBubble|returnValue|wheelDelta|view|round|shiftKey|resize|screenY|screenX|relatedNode|mousemove|prevValue|originalTarget|offsetHeight|keyup|newValue|offsetWidth|eventPhase|detail|currentTarget|cancelable|bubbles|attrName|attrChange|altKey|originalEvent|charAt|0n|substring|animated|header|noConflict|line|enabled|innerText|contains|only|weight|font|gt|lt|uFFFF|u0128|size|417|Boolean|Date|toggleClass|removeClass|addClass|removeAttr|replaceAll|insertAfter|prependTo|wrap|contentWindow|contentDocument|iframe|children|siblings|prevAll|wrapInner|nextAll|outer|prev|scrollTo|static|marginTop|next|inline|parents|able|cellSpacing|adobeair|cellspacing|522|maxLength|maxlength|readOnly|400|readonly|fast|600|class|slow|1px|htmlFor|reverse|10000|PI|cos|compatible|Function|setData|ie|ra|it|rv|getData|userAgent|navigator|fadeTo|fadeIn|slideToggle|slideUp|slideDown|ig|responseXML|content|1223|NaN|fadeOut|300|protocol|send|setAttribute|option|dataFilter|cssText|changed|be|Accept|stop|With|Requested|Object|can|GMT|property|1970|Jan|01|Thu|Since|If|Type|Content|XMLHTTP|th|Microsoft|td|onreadystatechange|onload|cap|charset|colg|host|tfoot|specified|with|1_|thead|leg|plain|attributes|opt|embed|urlencoded|www|area|hr|ajaxSetup|meta|post|getJSON|getScript|marginLeft|img|elements|pageYOffset|pageXOffset|abbr|serialize|pixelLeft'.split('|'),0,{}));
// $Id: drupal.js,v 1.41.2.4 2009/07/21 08:59:10 goba Exp $

var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} };

/**
 * Set the variable that indicates if JavaScript behaviors should be applied
 */
Drupal.jsEnabled = true;

/**
 * Attach all registered behaviors to a page element.
 *
 * Behaviors are event-triggered actions that attach to page elements, enhancing
 * default non-Javascript UIs. Behaviors are registered in the Drupal.behaviors
 * object as follows:
 * @code
 *    Drupal.behaviors.behaviorName = function () {
 *      ...
 *    };
 * @endcode
 *
 * Drupal.attachBehaviors is added below to the jQuery ready event and so
 * runs on initial page load. Developers implementing AHAH/AJAX in their
 * solutions should also call this function after new page content has been
 * loaded, feeding in an element to be processed, in order to attach all
 * behaviors to the new content.
 *
 * Behaviors should use a class in the form behaviorName-processed to ensure
 * the behavior is attached only once to a given element. (Doing so enables
 * the reprocessing of given elements, which may be needed on occasion despite
 * the ability to limit behavior attachment to a particular element.)
 *
 * @param context
 *   An element to attach behaviors to. If none is given, the document element
 *   is used.
 */
Drupal.attachBehaviors = function(context) {
  context = context || document;
  // Execute all of them.
  jQuery.each(Drupal.behaviors, function() {
    this(context);
  });
};

/**
 * Encode special characters in a plain-text string for display as HTML.
 */
Drupal.checkPlain = function(str) {
  str = String(str);
  var replace = { '&': '&amp;', '"': '&quot;', '<': '&lt;', '>': '&gt;' };
  for (var character in replace) {
    var regex = new RegExp(character, 'g');
    str = str.replace(regex, replace[character]);
  }
  return str;
};

/**
 * Translate strings to the page language or a given language.
 *
 * See the documentation of the server-side t() function for further details.
 *
 * @param str
 *   A string containing the English string to translate.
 * @param args
 *   An object of replacements pairs to make after translation. Incidences
 *   of any key in this array are replaced with the corresponding value.
 *   Based on the first character of the key, the value is escaped and/or themed:
 *    - !variable: inserted as is
 *    - @variable: escape plain text to HTML (Drupal.checkPlain)
 *    - %variable: escape text and theme as a placeholder for user-submitted
 *      content (checkPlain + Drupal.theme('placeholder'))
 * @return
 *   The translated string.
 */
Drupal.t = function(str, args) {
  // Fetch the localized version of the string.
  if (Drupal.locale.strings && Drupal.locale.strings[str]) {
    str = Drupal.locale.strings[str];
  }

  if (args) {
    // Transform arguments before inserting them
    for (var key in args) {
      switch (key.charAt(0)) {
        // Escaped only
        case '@':
          args[key] = Drupal.checkPlain(args[key]);
        break;
        // Pass-through
        case '!':
          break;
        // Escaped and placeholder
        case '%':
        default:
          args[key] = Drupal.theme('placeholder', args[key]);
          break;
      }
      str = str.replace(key, args[key]);
    }
  }
  return str;
};

/**
 * Format a string containing a count of items.
 *
 * This function ensures that the string is pluralized correctly. Since Drupal.t() is
 * called by this function, make sure not to pass already-localized strings to it.
 *
 * See the documentation of the server-side format_plural() function for further details.
 *
 * @param count
 *   The item count to display.
 * @param singular
 *   The string for the singular case. Please make sure it is clear this is
 *   singular, to ease translation (e.g. use "1 new comment" instead of "1 new").
 *   Do not use @count in the singular string.
 * @param plural
 *   The string for the plural case. Please make sure it is clear this is plural,
 *   to ease translation. Use @count in place of the item count, as in "@count
 *   new comments".
 * @param args
 *   An object of replacements pairs to make after translation. Incidences
 *   of any key in this array are replaced with the corresponding value.
 *   Based on the first character of the key, the value is escaped and/or themed:
 *    - !variable: inserted as is
 *    - @variable: escape plain text to HTML (Drupal.checkPlain)
 *    - %variable: escape text and theme as a placeholder for user-submitted
 *      content (checkPlain + Drupal.theme('placeholder'))
 *   Note that you do not need to include @count in this array.
 *   This replacement is done automatically for the plural case.
 * @return
 *   A translated string.
 */
Drupal.formatPlural = function(count, singular, plural, args) {
  var args = args || {};
  args['@count'] = count;
  // Determine the index of the plural form.
  var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] == 1) ? 0 : 1);

  if (index == 0) {
    return Drupal.t(singular, args);
  }
  else if (index == 1) {
    return Drupal.t(plural, args);
  }
  else {
    args['@count['+ index +']'] = args['@count'];
    delete args['@count'];
    return Drupal.t(plural.replace('@count', '@count['+ index +']'));
  }
};

/**
 * Generate the themed representation of a Drupal object.
 *
 * All requests for themed output must go through this function. It examines
 * the request and routes it to the appropriate theme function. If the current
 * theme does not provide an override function, the generic theme function is
 * called.
 *
 * For example, to retrieve the HTML that is output by theme_placeholder(text),
 * call Drupal.theme('placeholder', text).
 *
 * @param func
 *   The name of the theme function to call.
 * @param ...
 *   Additional arguments to pass along to the theme function.
 * @return
 *   Any data the theme function returns. This could be a plain HTML string,
 *   but also a complex object.
 */
Drupal.theme = function(func) {
  for (var i = 1, args = []; i < arguments.length; i++) {
    args.push(arguments[i]);
  }

  return (Drupal.theme[func] || Drupal.theme.prototype[func]).apply(this, args);
};

/**
 * Parse a JSON response.
 *
 * The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
 */
Drupal.parseJson = function (data) {
  if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
    return { status: 0, data: data.length ? data : Drupal.t('Unspecified error') };
  }
  return eval('(' + data + ');');
};

/**
 * Freeze the current body height (as minimum height). Used to prevent
 * unnecessary upwards scrolling when doing DOM manipulations.
 */
Drupal.freezeHeight = function () {
  Drupal.unfreezeHeight();
  var div = document.createElement('div');
  $(div).css({
    position: 'absolute',
    top: '0px',
    left: '0px',
    width: '1px',
    height: $('body').css('height')
  }).attr('id', 'freeze-height');
  $('body').append(div);
};

/**
 * Unfreeze the body height
 */
Drupal.unfreezeHeight = function () {
  $('#freeze-height').remove();
};

/**
 * Wrapper around encodeURIComponent() which avoids Apache quirks (equivalent of
 * drupal_urlencode() in PHP). This function should only be used on paths, not
 * on query string arguments.
 */
Drupal.encodeURIComponent = function (item, uri) {
  uri = uri || location.href;
  item = encodeURIComponent(item).replace(/%2F/g, '/');
  return (uri.indexOf('?q=') != -1) ? item : item.replace(/%26/g, '%2526').replace(/%23/g, '%2523').replace(/\/\//g, '/%252F');
};

/**
 * Get the text selection in a textarea.
 */
Drupal.getSelection = function (element) {
  if (typeof(element.selectionStart) != 'number' && document.selection) {
    // The current selection
    var range1 = document.selection.createRange();
    var range2 = range1.duplicate();
    // Select all text.
    range2.moveToElementText(element);
    // Now move 'dummy' end point to end point of original range.
    range2.setEndPoint('EndToEnd', range1);
    // Now we can calculate start and end points.
    var start = range2.text.length - range1.text.length;
    var end = start + range1.text.length;
    return { 'start': start, 'end': end };
  }
  return { 'start': element.selectionStart, 'end': element.selectionEnd };
};

/**
 * Build an error message from ahah response.
 */
Drupal.ahahError = function(xmlhttp, uri) {
  if (xmlhttp.status == 200) {
    if (jQuery.trim(xmlhttp.responseText)) {
      var message = Drupal.t("An error occurred. \n@uri\n@text", {'@uri': uri, '@text': xmlhttp.responseText });
    }
    else {
      var message = Drupal.t("An error occurred. \n@uri\n(no information available).", {'@uri': uri });
    }
  }
  else {
    var message = Drupal.t("An HTTP error @status occurred. \n@uri", {'@uri': uri, '@status': xmlhttp.status });
  }
  return message.replace(/\n/g, '<br />');
}

// Global Killswitch on the <html> element
$(document.documentElement).addClass('js');
// Attach all behaviors.
$(document).ready(function() {
  Drupal.attachBehaviors(this);
});

/**
 * The default themes.
 */
Drupal.theme.prototype = {

  /**
   * Formats text for emphasized display in a placeholder inside a sentence.
   *
   * @param str
   *   The text to format (plain-text).
   * @return
   *   The formatted text (html).
   */
  placeholder: function(str) {
    return '<em>' + Drupal.checkPlain(str) + '</em>';
  }
};
;
// $Id: authcache.js,v 1.5 2010/02/22 06:26:08 jonahellison Exp $

var Authcache = {
  'isEnabled' : true,   // Make sure page is really cached
  'isDebug'   : false,  // Debug mode
  'json' : { },         // Holds all responses from ajaxRequest
  'ajax' : { },         // Will be extended with authcacheFooter data
  'info' : { },         // Will be extended with authcacheFooter data
  'ajax_count' : 0,     // Ajax request count
  'timeStart' : new Date().getTime() // JS Benchmark
};

/**
 * Preprocess page and do Ajax request if needed.
 * Called after all other scripts have been loaded.
 */
Authcache.init = function() {

  Authcache.init.preprocess(); // see below

  // Should Ajax request be sent?  Ignore if only 'q' key exists
  authcacheLength = 0;
  for(i in Authcache.ajax) {
    authcacheLength++;
  }
  // Will also need to send request if Authcache was disabled in mid-render of HTML ("q" key won't exist since there is no authcacheFooter)
  if(authcacheLength > 1 || (!Authcache.isEnabled && authcacheLength > 0)) {
    Authcache.ajaxRequest(Authcache.ajax);
  } else if(Authcache.isDebug) {
    $("#authcachedebug").append("Ajax request not sent.<br>");
    Authcache.debugTimer();
  }
}

/**
 * Look over HTML DOM
 */
Authcache.init.preprocess = function() {

  // Display logged-in username
  $(".authcache-user").html($.cookie("drupal_user"));
  
  // Display username linked to profile
  // Example usage: <a href="" class="authcache-user-link">Welcome, !username</a>
  $("a.authcache-user-link").each(function() {
    $this = $(this);
    $this.html($this.html().replace('!username', $.cookie("drupal_user")))
         .attr("href", Drupal.settings.basePath + 'user');
  });

  // Find forms that need tokens
  $("form input[name='form_token_id']").each(function() {
    if(Authcache.ajax["form_token_id[]"] == null) Authcache.ajax["form_token_id[]"] = new Array();
    Authcache.ajax["form_token_id[]"].push(this.form.form_token_id.value);
  });

  // On form submit, check if token has been set
  $("form").submit(function() {
    if(typeof this.form_token_id != "undefined" && !this.form_token.value) {
      // Send another Ajax request to retrieve form token
      this.form_token.className = "authcache-must-submit";
      Authcache.ajaxRequest( {"form_token_id[]" : this.form_token_id.value} );
      return false;
    }
  });

  // Set Drupal core link to user profile instead of using cached link
  $("a:contains('My account')").attr("href",Drupal.settings.basePath+"user");

  // Hide tabs
  if(Authcache.info.tab_hide != null && Authcache.info.node_author != null && Authcache.info.node_author != $.cookie("drupal_user")) {
    for(i in Authcache.info.tab_hide) {
      $("ul.primary li:contains('" + Authcache.info.tab_hide[i] + "')").remove();
    }
    if($("ul.primary li").length == 1) { // Only the "View" tab remains -- remove
      $("ul.primary").remove();
    }
  }
  
  if(Authcache.isEnabled) {

    // Theme local task tab items for author
    if(Authcache.info.node_author != null && Authcache.info.node_author == $.cookie("drupal_user") && !$("ul.primary").length) {
      ajaxJson = {
        'q' : Authcache.ajax.q,
        'menu_local_tasks' : 1,
        'max_age' : 86400
      };
      Authcache.ajaxRequest(ajaxJson);
    }

    // Forums "new" markers
    if(Authcache.info.cache_uid && Authcache.ajax.q.substring(0,5) == "forum") {

      // Check for new topics
      $(".authcache-topic-new").each(function(i, elSpan) {
        if(Authcache.ajax["forum_topic_new[]"] == null) Authcache.ajax["forum_topic_new[]"] = new Array();
        id = Authcache.getValue("forum-id-", elSpan.className);
        Authcache.ajax["forum_topic_new[]"].push(id);
      });

      // Get number of new comments or if topic node is unread
      $(".authcache-topic-info").each(function(i, elSpan) {
        timestamp = Authcache.getValue("timestamp-", elSpan.className);
        nid = Authcache.getValue("nid-", elSpan.className);

        Authcache.ajax["forum_topic_info["+nid+"]"] = new Array(timestamp);
      });
    }

    // Show "edit" comment links for user
    if(Authcache.info.comment_usertime != null) {
      $(".authcache-comment-edit.comment-uid-" + $.cookie("drupal_uid")).each(function(i, elSpan) {
        cid = Authcache.getValue("comment-id-", elSpan.className);

        $(this).parent().find(".links")
          .find(".first")
          .removeClass("first")
          .parent()
          .prepend('<li class="comment_edit first"><a href="' + Drupal.settings.basePath + 'comment/edit/' + cid + '">' + Authcache.info.t.edit + '</a></li>');
      });
    }
    
  }

  // Get poll results/form
  if($("#block-poll-0").length || $("#poll-view-voting").length) {
    $(".poll").each(function(i, el) {
      elNid = $(el).find(".authcache-poll");
      nid = Authcache.getValue("nid-", elNid.get(0).className);

      ajaxJson = {
        'poll[nid]' : nid,
        'poll[block]' : $(el).parents(".block-inner").length,
        'time' : $.cookie('nid' + nid),
        'max_age' : 600
      };

      Authcache.ajaxRequest(ajaxJson);
    });
  }

};


/**
 * Perform ajax request and callback functions
 */
Authcache.ajaxRequest = function(jsonData) {

  $.ajax({
    url: Drupal.settings.basePath, // index.php
    type: "GET",
    dataType: "json",
    data: jsonData,
    
    // If response is to be cached (max_age), then a syncronous request
    // will lock the browser & prevent jumpiness on HTML DOM updates
    async: (jsonData.max_age != null) ? false : true,
    
    success: function(data) {
      Authcache.json = jQuery.extend(true, Authcache.json, data);

      // Callback functions
      for(key in data) {
        funcName = "_authcache_" + key;
        try {
          eval(funcName + "(data[key])");
        } catch(e) { }
      }

      if(Authcache.isDebug) {
        Authcache.debug({'sent':jsonData,'received':data});
      }
    },

    // Custom header to help prevent cross-site forgery requests
    // and to flag caching bootstrap that Ajax request is being made 
    beforeSend: function(xhr) {
      xhr.setRequestHeader("Authcache","1");
    },

    error: Authcache.ajaxError
  });

}

/**
 * AjaxRequest error callback
 */
Authcache.ajaxError = function(XMLHttpRequest, textStatus, errorThrown) {
  if(Authcache.isDebug) {
    $("#authcachedebug").append(Authcache.debugFieldset("Ajax Response Error ("+textStatus+")", {"ERROR":XMLHttpRequest.responseText.replace(/\n/g,"") }));
  }
}

/**
 * Return value embedded in class string
 */
Authcache.getValue = function(needle, str) {
  matches = str.match(eval("/" + needle + "(.[^\\s]*)/"));
  return (matches == null) ? false : matches[1];
}


// Check if page is really cached
jQuery(function() {

  // Page not cached for whatever reason (such as a late status message)
  if(typeof authcacheFooter == "undefined") {
    Authcache.isEnabled = false;
  }
  // Add "ajax" and "info" keys
  else {
    Authcache = jQuery.extend(true, Authcache, authcacheFooter);
  }
});


//
// Ajax callback functions
//

/**
 * Set form token
 * @see form.inc
 */
function _authcache_form_token_id(vars) {
  for(key in vars) {
    $("form input[name='form_token_id'][value='"+key+"']").each(function() {
      oInputToken = $(this.form).find("input[name='form_token']");
      oInputToken.val(vars[key]);
      // Late retierval of token (user tried to submit but no token)
      if(oInputToken.hasClass("authcache-must-submit")) { 
        this.form.submit();
      }
    });
  }
}

/**
 * Set default contact form values
 * @see contact.module
 */
function _authcache_contact(vars) {
  $("#contact-mail-page input[name='name']").val(vars.name);
  $("#contact-mail-page input[name='mail']").val(vars.mail);
}


/**
 * Display "new" marker next to comment
 * @see comment.module, node.module
 */
function _authcache_node_history(historyTimestamp) {
  if(Authcache.info.comment_usertime != null) {
    $(".authcache-comment-new").each(function(i, elSpan) {
      timestamp = Authcache.getValue("timestamp-", elSpan.className);

      if(
        timestamp >= historyTimestamp ||
        // Also give buffer for user who accesses first cached page request
        (timestamp >= Authcache.info.comment_usertime && Authcache.info.cache_time >= historyTimestamp - 2 && Authcache.info.cache_uid == $.cookie("drupal_uid"))
        ) {
  
        $(elSpan).hide().html(Authcache.info.t["new"]).fadeIn();
      }
    })
  }
}

/**
 * Display "new" marker next to new topics
 * @see forum.module
 */
function _authcache_forum_topic_new(vars) {
  for(id in vars) {
    $(".authcache-topic-new.forum-id-" + id).before("<br />").hide().html("" + vars[id]).fadeIn();
  }
}

/**
 * Display "new" marker next to new replies/comments
 * and update icon if unread or new replies
 * @see forum.module, comment.module
 */
function _authcache_forum_topic_info(vars) {
  for(id in vars) {
    $(".authcache-topic-replies.nid-" + id).before("<br />").hide().html("" + vars[id]).fadeIn();
    oIcon = $(".authcache-topic-icon.nid-" + id);
    oIcon.html(oIcon.html().replace(/default/g, "new"));
    oIcon.html(oIcon.html().replace(/-hot/g, "-hot-new"));
  }
}

/**
 * Show poll results
 * @see poll.module
 */
function _authcache_poll(vars) {
  if(vars.block == 1) {
    $("#block-poll-0 .poll").html(vars.html);
  } else {
    $("#node-" + vars.nid + " .poll").html(vars.html);
  }
}

/**
 * Render local task tab links
 * @see menu.inc
 */
function _authcache_menu_local_tasks(vars) {
  $("#authcache-tabs").html(vars);
}



/**
 * jQuery cookie plugin
 * http://plugins.jquery.com/project/Cookie
 */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}; var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}; expires='; expires='+date.toUTCString();}; var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}; return cookieValue;}};

// Prepare Authcache
jQuery(function() { 
  // Is debug mode enabled?
  if ($.cookie('authcache_debug') || Drupal.settings.authcacheDebug != null) {
    Authcache.isDebug = true;
    Authcache.debug(false);
    $.cookie('authcache_debug', 1); // Make sure cookie is set for benchmarks
  }
})



////////////////////////////////////////////////////////////////
//
// Debug functions
//
// Everything below can be deleted if you don't want debug mode

/**
 * Display debug info, depending on phase
 */
Authcache.debug = function(ajaxData) {

  if(!ajaxData) {

    legend = ($.cookie('drupal_user')) ? " (logged in: "+$.cookie('drupal_user')+')' : '';

    if(Authcache.isEnabled) {
      // Get seconds page was last cached, using Unix Epoch (GMT/UTC timestamp)
      utc = (new Date()).toUTCString(); // Client's time
      utcTimestamp = Date.parse(utc) / 1000; // Convert to seconds

      Authcache.info["(page_age)"] =  Math.round(utcTimestamp - Authcache.info.cache_time) + " seconds";
      $("#authcache-info").html("<strong>This page was cached " + Authcache.info["(page_age)"] + " ago.</strong>");
      if(utcTimestamp - Authcache.info.cache_time < -10) {
        $("#authcache-info").append("<div style=\"font-size:85%\">Your computer's <a href=\"http://tycho.usno.navy.mil/cgi-bin/timer.pl\">time</a> may be off.</div>");
      }

      if(!$.cookie('authcache_debug')) {
        Authcache.info.cache_render = 'This is your first site visit and the debug cookie has just been set.';
      } else if(!isNaN($.cookie("cache_render"))) { // numeric?
        Authcache.info.cache_render = $.cookie("cache_render") + " ms"
        Authcache.info.cache_render += " (" + Math.round((Authcache.info.page_render - $.cookie("cache_render")) / $.cookie("cache_render") * 100).toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2') + "% increase)"
        $.cookie("cache_render",null);
      } else if($.cookie("cache_render")) {
        Authcache.info.cache_render = $.cookie("cache_render");
      } else {
        Authcache.info.cache_render = "n/a (try a different browser?)";
      }
      
      Authcache.info.page_render += " ms";

      debugInfo = Authcache.debugFieldset("Authcache.info"+legend, Authcache.info);

    } else {
      if(JSON.stringify(Authcache.info) == "{}") Authcache.info = "Authcache.info JSON is empty!";
      debugInfo = Authcache.debugFieldset("Authcache prevented caching", {"NO_CACHE" : "Page not cached.", "INFO" : Authcache.info });
    }
    
    debugInfo += '<a href="#" onclick="return Authcache.debugDisable();">Disable caching for this browser session</a>';

    $("body").prepend("<div style='z-index:100;text-align:left;font-size:11px;left:0px;position:absolute;background:#f7f7f7;color:#000;padding:5px;'><b><a href='#' id='authcachehide'>Authcache Debug</a></b><div id='authcachedebug' style='display:none;'>"+debugInfo+"</div></div>");
    $("#authcachehide").click(function() {$("#authcachedebug").toggle(); return false; })

    Authcache.debugTimer();
  } else {
    //ajaxLink = '<a href="'+Drupal.settings.basePath+'ajax_authcache.php?'+$.param(Authcache.ajax)+'">Authcache.ajax (sent)</a>';
    ajaxLink = 'Request:';
    legend = "Authcache.ajaxRequest #" + (++Authcache.ajax_count);
    if (typeof ajaxData.sent.max_age != "undefined") legend += " (Response cached for " + Math.round(ajaxData.sent.max_age / 3600) + " hour(s) -- see max_age)";
    debugInfo = 
      "<fieldset><legend><b>" + legend + "</b></legend>" + Authcache.debugFieldset(ajaxLink, ajaxData.sent) +
      Authcache.debugFieldset("Response:", ajaxData.received) +
      "</fieldset>";

    $("#authcachedebug").append(debugInfo);
    Authcache.debugTimer();
  }
}

/**
 * Disable caching by setting cookie
 */
Authcache.debugDisable = function() {
  if(confirm("Are you sure? (You can renable caching by closing and reopening your browser.)")) {
    $.cookie('nocache', 1);
    location.reload(true);
    //setTimeout("location.reload(true)", 1000);
  }
  return false;
}

/**
 * Display total JavaScript execution time for this file (including Ajax)
 */
Authcache.debugTimer = function() {
  timeMs = new Date().getTime() - Authcache.timeStart;
  $("#authcachedebug").append("HTML/JavaScript time: "+timeMs+" ms <hr size=1>");
}

/**
 * Helper function (renders HTML fieldset)
 */
Authcache.debugFieldset = function(title, jsonData) {
  fieldset = '<div style="clear:both;"></div><fieldset style="float:left;min-width:240px;"><legend>'+title+'</legend>';
  for(key in jsonData) {
    fieldset += "<b>"+key+"</b>: "+JSON.stringify(jsonData[key])+'<br>';
  }
  fieldset += '</fieldset><div style="clear:both;">';
  return fieldset;
}

/**
 * JSON to String
 * http://www.JSON.org/js.html
 */
if(!this.JSON){JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'<br>{'+partial.join(',<br>')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}})();;
/**
 * Modified Star Rating - jQuery plugin
 *
 * Copyright (c) 2006 Wil Stuckey
 *
 * Original source available: http://sandbox.wilstuckey.com/jquery-ratings/
 * Extensively modified by Lullabot: http://www.lullabot.com
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

/**
 * Create a degradeable star rating interface out of a simple form structure.
 * Returns a modified jQuery object containing the new interface.
 *   
 * @example jQuery('form.rating').fivestar();
 * @cat plugin
 * @type jQuery 
 *
 */
(function($){ // Create local scope.
    /**
     * Takes the form element, builds the rating interface and attaches the proper events.
     * @param {Object} $obj
     */
    var buildRating = function($obj){
        var $widget = buildInterface($obj),
            $stars = $('.star', $widget),
            $cancel = $('.cancel', $widget),
            $summary = $('.fivestar-summary', $obj),
            feedbackTimerId = 0,
            summaryText = $summary.html(),
            summaryHover = $obj.is('.fivestar-labels-hover'),
            currentValue = $("select", $obj).val(),
            cancelTitle = $('label', $obj).html(),
            voteTitle = cancelTitle != Drupal.settings.fivestar.titleAverage ? cancelTitle : Drupal.settings.fivestar.titleUser,
            voteChanged = false;

        // Record star display.
        if ($obj.is('.fivestar-user-stars')) {
          var starDisplay = 'user';
        }
        else if ($obj.is('.fivestar-average-stars')) {
          var starDisplay = 'average';
          currentValue = $("input[name=vote_average]", $obj).val();
        }
        else if ($obj.is('.fivestar-combo-stars')) {
          var starDisplay = 'combo';
        }
        else {
          var starDisplay = 'none';
        }

        // Smart is intentionally separate, so the average will be set if necessary.
        if ($obj.is('.fivestar-smart-stars')) {
          var starDisplay = 'smart';
        }

        // Record text display.
        if ($summary.size()) {
          var textDisplay = $summary.attr('class').replace(/.*?fivestar-summary-([^ ]+).*/, '$1').replace(/-/g, '_');
        }
        else {
          var textDisplay = 'none';
        }

        // Add hover and focus events.
        $stars
            .mouseover(function(){
                event.drain();
                event.fill(this);
            })
            .mouseout(function(){
                event.drain();
                event.reset();
            });
        $stars.children()
            .focus(function(){
                event.drain();
                event.fill(this.parentNode)
            })
            .blur(function(){
                event.drain();
                event.reset();
            }).end();

        // Cancel button events.
        $cancel
            .mouseover(function(){
                event.drain();
                $(this).addClass('on')
            })
            .mouseout(function(){
                event.reset();
                $(this).removeClass('on')
            });
        $cancel.children()
            .focus(function(){
                event.drain();
                $(this.parentNode).addClass('on')
            })
            .blur(function(){
                event.reset();
                $(this.parentNode).removeClass('on')
            }).end();

        // Click events.
        $cancel.click(function(){
            currentValue = 0;
            event.reset();
            voteChanged = false;
            // Inform a user that his vote is being processed
            if ($("input.fivestar-path", $obj).size() && $summary.is('.fivestar-feedback-enabled')) {
              setFeedbackText(Drupal.settings.fivestar.feedbackDeletingVote);
            }
            // Save the currentValue in a hidden field.
            $("select", $obj).val(0);
            // Update the title.
            cancelTitle = starDisplay != 'smart' ? cancelTitle : Drupal.settings.fivestar.titleAverage;
            $('label', $obj).html(cancelTitle);
            // Update the smart classes on the widget if needed.
            if ($obj.is('.fivestar-smart-text')) {
              $obj.removeClass('fivestar-user-text').addClass('fivestar-average-text');
              $summary[0].className = $summary[0].className.replace(/-user/, '-average');
              textDisplay = $summary.attr('class').replace(/.*?fivestar-summary-([^ ]+).*/, '$1').replace(/-/g, '_');
            }
            if ($obj.is('.fivestar-smart-stars')) {
              $obj.removeClass('fivestar-user-stars').addClass('fivestar-average-stars');
            }
            // Submit the form if needed.
            $("input.fivestar-path", $obj).each(function() {
              var token = $("input.fivestar-token", $obj).val();
              $.ajax({
                type: 'GET',
                data: { token: token },
                dataType: 'xml',
                url: this.value + '/' + 0,
                success: voteHook
              });
            });
            return false;
        });
        $stars.click(function(){
            currentValue = $('select option', $obj).get($stars.index(this) + $cancel.size() + 1).value;
            // Save the currentValue to the hidden select field.
            $("select", $obj).val(currentValue);
            // Update the display of the stars.
            voteChanged = true;
            event.reset();
            // Inform a user that his vote is being processed.
            if ($("input.fivestar-path", $obj).size() && $summary.is('.fivestar-feedback-enabled')) {
              setFeedbackText(Drupal.settings.fivestar.feedbackSavingVote);
            }
            // Update the smart classes on the widget if needed.
            if ($obj.is('.fivestar-smart-text')) {
              $obj.removeClass('fivestar-average-text').addClass('fivestar-user-text');
              $summary[0].className = $summary[0].className.replace(/-average/, '-user');
              textDisplay = $summary.attr('class').replace(/.*?fivestar-summary-([^ ]+).*/, '$1').replace(/-/g, '_');
            }
            if ($obj.is('.fivestar-smart-stars')) {
              $obj.removeClass('fivestar-average-stars').addClass('fivestar-user-stars');
            }
            // Submit the form if needed.
            $("input.fivestar-path", $obj).each(function () {
              var token = $("input.fivestar-token", $obj).val();
              $.ajax({
                type: 'GET',
                data: { token: token },
                dataType: 'xml',
                url: this.value + '/' + currentValue,
                success: voteHook
              });
            });
            return false;
        });

        var event = {
            fill: function(el){
              // Fill to the current mouse position.
              var index = $stars.index(el) + 1;
              $stars
                .children('a').css('width', '100%').end()
                .filter(':lt(' + index + ')').addClass('hover').end();
              // Update the description text and label.
              if (summaryHover && !feedbackTimerId) {
                var summary = $("select option", $obj)[index + $cancel.size()].text;
                var value = $("select option", $obj)[index + $cancel.size()].value;
                $summary.html(summary != index + 1 ? summary : '&nbsp;');
                $('label', $obj).html(voteTitle);
              }
            },
            drain: function() {
              // Drain all the stars.
              $stars
                .filter('.on').removeClass('on').end()
                .filter('.hover').removeClass('hover').end();
              // Update the description text.
              if (summaryHover && !feedbackTimerId) {
                var cancelText = $("select option", $obj)[1].text;
                $summary.html(($cancel.size() && cancelText != 0) ? cancelText : '&nbsp');
                if (!voteChanged) {
                  $('label', $obj).html(cancelTitle);
                }
              }
            },
            reset: function(){
              // Reset the stars to the default index.
              var starValue = currentValue/100 * $stars.size();
              var percent = (starValue - Math.floor(starValue)) * 100;
              $stars.filter(':lt(' + Math.floor(starValue) + ')').addClass('on').end();
              if (percent > 0) {
                $stars.eq(Math.floor(starValue)).addClass('on').children('a').css('width', percent + "%").end().end();
              }
              // Restore the summary text and original title.
              if (summaryHover && !feedbackTimerId) {
                $summary.html(summaryText ? summaryText : '&nbsp;');
              }
              if (voteChanged) {
                $('label', $obj).html(voteTitle);
              }
              else {
                $('label', $obj).html(cancelTitle);
              }
            }
        };

        var setFeedbackText = function(text) {
          // Kill previous timer if it isn't finished yet so that the text we
          // are about to set will not get cleared too early.
          feedbackTimerId = 1;
          $summary.html(text);
        };

        /**
         * Checks for the presence of a javascript hook 'fivestarResult' to be
         * called upon completion of a AJAX vote request.
         */
        var voteHook = function(data) {
          var returnObj = {
            result: {
              count: $("result > count", data).text(),
              average: $("result > average", data).text(),
              summary: {
                average: $("summary average", data).text(),
                average_count: $("summary average_count", data).text(),
                user: $("summary user", data).text(),
                user_count: $("summary user_count", data).text(),
                combo: $("summary combo", data).text(),
                count: $("summary count", data).text()
              }
            },
            vote: {
              id: $("vote id", data).text(),
              tag: $("vote tag", data).text(),
              type: $("vote type", data).text(),
              value: $("vote value", data).text()
            },
            display: {
              stars: starDisplay,
              text: textDisplay
            }
          };
          // Check for a custom callback.
          if (window.fivestarResult) {
            fivestarResult(returnObj);
          }
          // Use the default.
          else {
            fivestarDefaultResult(returnObj);
          }
          // Update the summary text.
          summaryText = returnObj.result.summary[returnObj.display.text];
          if ($(returnObj.result.summary.average).is('.fivestar-feedback-enabled')) {
            // Inform user that his/her vote has been processed.
            if (returnObj.vote.value != 0) { // check if vote has been saved or deleted 
              setFeedbackText(Drupal.settings.fivestar.feedbackVoteSaved);
            }
            else {
              setFeedbackText(Drupal.settings.fivestar.feedbackVoteDeleted);
            }
            // Setup a timer to clear the feedback text after 3 seconds.
            feedbackTimerId = setTimeout(function() { clearTimeout(feedbackTimerId); feedbackTimerId = 0; $summary.html(returnObj.result.summary[returnObj.display.text]); }, 2000);
          }
          // Update the current star currentValue to the previous average.
          if (returnObj.vote.value == 0 && (starDisplay == 'average' || starDisplay == 'smart')) {
            currentValue = returnObj.result.average;
            event.reset();
          }
        };

        event.reset();
        return $widget;
    };
    
    /**
     * Accepts jQuery object containing a single fivestar widget.
     * Returns the proper div structure for the star interface.
     * 
     * @return jQuery
     * @param {Object} $widget
     * 
     */
    var buildInterface = function($widget){
        var $container = $('<div class="fivestar-widget clear-block"></div>');
        var $options = $("select option", $widget);
        var size = $('option', $widget).size() - 1;
        var cancel = 1;
        for (var i = 1, option; option = $options[i]; i++){
            if (option.value == "0") {
              cancel = 0;
              $div = $('<div class="cancel"><a href="#0" title="' + option.text + '">' + option.text + '</a></div>');
            }
            else {
              var zebra = (i + cancel - 1) % 2 == 0 ? 'even' : 'odd';
              var count = i + cancel - 1;
              var first = count == 1 ? ' star-first' : '';
              var last = count == size + cancel - 1 ? ' star-last' : '';
              $div = $('<div class="star star-' + count + ' star-' + zebra + first + last + '"><a href="#' + option.value + '" title="' + option.text + '">' + option.text + '</a></div>');
            }
            $container.append($div[0]);
        }
        $container.addClass('fivestar-widget-' + (size + cancel - 1));
        // Attach the new widget and hide the existing widget.
        $('select', $widget).after($container).css('display', 'none');
        return $container;
    };

    /**
     * Standard handler to update the average rating when a user changes their
     * vote. This behavior can be overridden by implementing a fivestarResult
     * function in your own module or theme.
     * @param object voteResult
     * Object containing the following properties from the vote result:
     * voteResult.result.count The current number of votes for this item.
     * voteResult.result.average The current average of all votes for this item.
     * voteResult.result.summary.average The textual description of the average.
     * voteResult.result.summary.user The textual description of the user's current vote.
     * voteResult.vote.id The id of the item the vote was placed on (such as the nid)
     * voteResult.vote.type The type of the item the vote was placed on (such as 'node')
     * voteResult.vote.tag The multi-axis tag the vote was placed on (such as 'vote')
     * voteResult.vote.average The average of the new vote saved
     * voteResult.display.stars The type of star display we're using. Either 'average', 'user', or 'combo'.
     * voteResult.display.text The type of text display we're using. Either 'average', 'user', or 'combo'.
     */
    function fivestarDefaultResult(voteResult) {
      // Update the summary text.
      $('div.fivestar-summary-'+voteResult.vote.tag+'-'+voteResult.vote.id).html(voteResult.result.summary[voteResult.display.text]);
      // If this is a combo display, update the average star display.
      if (voteResult.display.stars == 'combo') {
        $('div.fivestar-form-'+voteResult.vote.id).each(function() {
          // Update stars.
          var $stars = $('.fivestar-widget-static .star span', this);
          var average = voteResult.result.average/100 * $stars.size();
          var index = Math.floor(average);
          $stars.removeClass('on').addClass('off').css('width', 'auto');
          $stars.filter(':lt(' + (index + 1) + ')').removeClass('off').addClass('on');
          $stars.eq(index).css('width', ((average - index) * 100) + "%");
          // Update summary.
          var $summary = $('.fivestar-static-form-item .fivestar-summary', this);
          if ($summary.size()) {
            var textDisplay = $summary.attr('class').replace(/.*?fivestar-summary-([^ ]+).*/, '$1').replace(/-/g, '_');
            $summary.html(voteResult.result.summary[textDisplay]);
          }
        });
      }
    };

    /**
     * Set up the plugin
     */
    $.fn.fivestar = function() {
      var stack = [];
      this.each(function() {
          var ret = buildRating($(this));
          stack.push(ret);
      });
      return stack;
    };

  // Fix ie6 background flicker problem.
  if ($.browser.msie == true) {
    try {
      document.execCommand('BackgroundImageCache', false, true);
    } catch(err) {}
  }

  Drupal.behaviors.fivestar = function(context) {
    $('div.fivestar-form-item:not(.fivestar-processed)', context).addClass('fivestar-processed').fivestar();
    $('input.fivestar-submit', context).css('display', 'none');
  }

})(jQuery);;
// $Id: googleanalytics.js,v 1.9.2.4 2010/09/19 11:39:20 hass Exp $

$(document).ready(function() {

  // Attach onclick event to document only and catch clicks on all elements.
  $(document.body).click(function(event) {
    // Catch only the first parent link of a clicked element.
    $(event.target).parents("a:first,area:first").andSelf().filter("a,area").each(function() {

      var ga = Drupal.settings.googleanalytics;
      // Expression to check for absolute internal links.
      var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
      // Expression to check for special links like gotwo.module /go/* links.
      var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
      // Expression to check for download links.
      var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");

      // Is the clicked URL internal?
      if (isInternal.test(this.href)) {
        // Is download tracking activated and the file extension configured for download tracking?
        if (ga.trackDownload && isDownload.test(this.href)) {
          // Download link clicked.
          var extension = isDownload.exec(this.href);
          _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]);
        }
        else if (isInternalSpecial.test(this.href)) {
          // Keep the internal URL for Google Analytics website overlay intact.
          _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]);
        }
      }
      else {
        if (ga.trackMailto && $(this).is("a[href^=mailto:],area[href^=mailto:]")) {
          // Mailto link clicked.
          _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]);
        }
        else if (ga.trackOutgoing && this.href) {
          // External link clicked.
          _gaq.push(["_trackEvent", "Outgoing links", "Click", this.href]);
        }
      }

    });
  });
});
;

/**
 * @file
 * Drupal to Google Maps API bridge.
 */

/*global $, Drupal, GLatLng, GSmallZoomControl, GLargeMapControl, GMap2 */
/*global GMapTypeControl, GSmallMapControl, G_HYBRID_MAP, G_NORMAL_MAP */
/*global G_PHYSICAL_MAP, G_SATELLITE_MAP, GHierarchicalMapTypeControl */
/*global GKeyboardHandler, GLatLngBounds, GMenuMapTypeControl, GEvent */
/*global GOverviewMapControl, GScaleControl, GUnload */

(function () { // BEGIN closure
  var handlers = {};
  var maps = {};
  var ajaxoffset = 0;

  Drupal.gmap = {

    /**
     * Retrieve a map object for use by a non-widget.
     * Use this if you need to be able to fire events against a certain map
     * which you have the mapid for.
     * Be a good GMap citizen! Remember to send change()s after modifying variables!
     */
    getMap: function (mapid) {
      if (maps[mapid]) {
        return maps[mapid];
      }
      else {
        // Perhaps the user passed a widget id instead?
        mapid = mapid.split('-').slice(1, -1).join('-');
        if (maps[mapid]) {
          return maps[mapid];
        }
      }
      return false;
    },

    unloadMap: function (mapid) {
      delete maps[mapid];
    },

    addHandler: function (handler, callback) {
      if (!handlers[handler]) {
        handlers[handler] = [];
      }
      handlers[handler].push(callback);
    },

    globalChange: function (name, userdata) {
      for (var mapid in Drupal.settings.gmap) {
        if (Drupal.settings.gmap.hasOwnProperty(mapid)) {
          maps[mapid].change(name, -1, userdata);
        }
      }
    },

    setup: function (settings) {
      var obj = this;

      var initcallback = function (mapid) {
        return (function () {
          maps[mapid].change("bootstrap_options", -1);
          maps[mapid].change("boot", -1);
          maps[mapid].change("init", -1);
          // Send some changed events to fire up the rest of the initial settings..
          maps[mapid].change("maptypechange", -1);
          maps[mapid].change("controltypechange", -1);
          maps[mapid].change("alignchange", -1);
          // Set ready to put the event system into action.
          maps[mapid].ready = true;
          maps[mapid].change("ready", -1);
        });
      };

      if (settings || (Drupal.settings && Drupal.settings.gmap)) {
        var mapid = obj.id.split('-');
        if (Drupal.settings['gmap_remap_widgets']) {
          if (Drupal.settings['gmap_remap_widgets'][obj.id]) {
            jQuery.each(Drupal.settings['gmap_remap_widgets'][obj.id].classes, function() {
              jQuery(obj).addClass(this);
            });
            mapid = Drupal.settings['gmap_remap_widgets'][obj.id].id.split('-');
          }
        }
        var instanceid = mapid.pop();
        mapid.shift();
        mapid = mapid.join('-');
        var control = instanceid.replace(/\d+$/, '');

        // Lazy init the map object.
        if (!maps[mapid]) {
          if (settings) {
            maps[mapid] = new Drupal.gmap.map(settings);
          }
          else {
            maps[mapid] = new Drupal.gmap.map(Drupal.settings.gmap[mapid]);
          }
          // Prepare the initialization callback.
          var callback = initcallback(mapid);
          setTimeout(callback, 0);
        }

        if (handlers[control]) {
          for (var i = 0; i < handlers[control].length; i++) {
            handlers[control][i].call(maps[mapid], obj);
          }
        }
        else {
          // Element with wrong class?
        }
      }
    }
  };

  jQuery.fn.createGMap = function (settings, mapid) {
    return this.each(function () {
      if (!mapid) {
        mapid = 'auto' + ajaxoffset + 'ajax';
        ajaxoffset++;
      }
      settings.id = mapid;
      $(this)
        .attr('id', 'gmap-' + mapid + '-gmap0')
        .css('width', settings.width)
        .css('height', settings.height)
        .addClass('gmap-control')
        .addClass('gmap-gmap')
        .addClass('gmap')
        .addClass('gmap-map')
        .addClass('gmap-' + mapid + '-gmap')
        .addClass('gmap-processed')
        .each(function() {Drupal.gmap.setup.call(this, settings)});
    });
  };

})(); // END closure

Drupal.gmap.factory = {};

Drupal.gmap.map = function (v) {
  this.vars = v;
  this.map = undefined;
  this.ready = false;
  var _bindings = {};

  /**
   * Register interest in a change.
   */
  this.bind = function (name, callback) {
    if (!_bindings[name]) {
      _bindings[name] = [];
    }
    return _bindings[name].push(callback) - 1;
  };

  /**
   * Change notification.
   * Interested parties can act on changes.
   */
  this.change = function (name, id, userdata) {
    var c;
    if (_bindings[name]) {
      for (c = 0; c < _bindings[name].length; c++) {
        if (c !== id) {
          _bindings[name][c](userdata);
        }
      }
    }
    if (name !== 'all') {
      this.change('all', -1, name, userdata);
    }
  };

  /**
   * Deferred change notification.
   * This will cause a change notification to be tacked on to the *end* of the event queue.
   */
  this.deferChange = function (name, id, userdata) {
    var obj = this;
    // This will move the function call to the end of the event loop.
    setTimeout(function () {
      obj.change(name, id, userdata);
    }, 0);
  };
};

////////////////////////////////////////
//             Map widget             //
////////////////////////////////////////
Drupal.gmap.addHandler('gmap', function (elem) {
  var obj = this;

  var _ib = {};


  // Respond to incoming zooms
  _ib.zoom = obj.bind("zoom", function () {
    obj.map.setZoom(obj.vars.zoom);
  });

  // Respond to incoming moves
  _ib.move = obj.bind("move", function () {
    obj.map.panTo(new GLatLng(obj.vars.latitude, obj.vars.longitude));
  });

  // Respond to incoming map type changes
  _ib.mtc = obj.bind("maptypechange", function () {
    var i;
    for (i = 0; i < obj.opts.mapTypeNames.length; i++) {
      if (obj.opts.mapTypeNames[i] === obj.vars.maptype) {
        obj.map.setMapType(obj.opts.mapTypes[i]);
        break;
      }
    }
  });

  // Respond to incoming width changes.
  _ib.width = obj.bind("widthchange", function (w) {
    obj.map.getContainer().style.width = w;
    obj.map.checkResize();
  });
  // Send out outgoing width changes.
  // N/A
  // Respond to incoming height changes.
  _ib.height = obj.bind("heightchange", function (h) {
    obj.map.getContainer().style.height = h;
    obj.map.checkResize();
  });
  // Send out outgoing height changes.
  // N/A

  // Respond to incoming control type changes.
  _ib.ctc = obj.bind("controltypechange", function () {
    if (obj.currentcontrol) {
      obj.map.removeControl(obj.currentcontrol);
    }
    if (obj.vars.controltype === 'Micro') {
      obj.map.addControl(obj.currentcontrol = new GSmallZoomControl());
    }
    else if (obj.vars.controltype === 'Small') {
      obj.map.addControl(obj.currentcontrol = new GSmallMapControl());
    }
    else if (obj.vars.controltype === 'Large') {
      obj.map.addControl(obj.currentcontrol = new GLargeMapControl());
    }
  });
  // Send out outgoing control type changes.
  // N/A

  obj.bind("bootstrap_options", function () {
    // Bootup options.
    var opts = {}; // Object literal GMapOptions
    obj.opts = opts;

    // Null out the enabled types.
    opts.mapTypes = [];
    opts.mapTypeNames = [];

    // Load google map types.
    if (obj.vars.baselayers.Map) {
      opts.mapTypes.push(G_NORMAL_MAP);
      opts.mapTypeNames.push('Map');
    }
    if (obj.vars.baselayers.Satellite) {
      opts.mapTypes.push(G_SATELLITE_MAP);
      opts.mapTypeNames.push('Satellite');
    }
    if (obj.vars.baselayers.Hybrid) {
      opts.mapTypes.push(G_HYBRID_MAP);
      opts.mapTypeNames.push('Hybrid');
    }
    if (obj.vars.baselayers.Physical) {
      opts.mapTypes.push(G_PHYSICAL_MAP);
      opts.mapTypeNames.push('Physical');
    }

    if (obj.vars.draggableCursor) {
      opts.draggableCursor = obj.vars.draggableCursor;
    }
    if (obj.vars.draggingCursor) {
      opts.draggingCursor = obj.vars.draggingCursor;
    }
    if (obj.vars.backgroundColor) {
      opts.backgroundColor = obj.vars.backgroundColor;
    }
  });

  obj.bind("boot", function () {
    obj.map = new GMap2(elem, obj.opts);
  });

  obj.bind("init", function () {
    var map = obj.map;

    // Map type control
    if (obj.vars.mtc === 'standard') {
      map.addControl(new GMapTypeControl());
    }
    else if (obj.vars.mtc === 'hier') {
      map.addControl(new GHierarchicalMapTypeControl());
    }
    else if (obj.vars.mtc === 'menu') {
      map.addControl(new GMenuMapTypeControl());
    }

    if (obj.vars.behavior.overview) {
      map.addControl(new GOverviewMapControl());
    }
    if (obj.vars.behavior.googlebar) {
      map.enableGoogleBar();
    }
    if (obj.vars.behavior.scale) {
      map.addControl(new GScaleControl());
    }
    if (obj.vars.behavior.nodrag) {
      map.disableDragging();
    }
    else if (!obj.vars.behavior.nokeyboard) {
      obj._kbdhandler = new GKeyboardHandler(map);
    }
    if (obj.vars.extent) {
      var c = obj.vars.extent;
      var extent = new GLatLngBounds(new GLatLng(c[0][0], c[0][1]), new GLatLng(c[1][0], c[1][1]));
      obj.vars.latitude = extent.getCenter().lat();
      obj.vars.longitude = extent.getCenter().lng();
      obj.vars.zoom = map.getBoundsZoomLevel(extent);
    }
    if (obj.vars.behavior.collapsehack) {
      // Modify collapsable fieldsets to make maps check dom state when the resize handle
      // is clicked. This may not necessarily be the correct thing to do in all themes,
      // hence it being a behavior.
      setTimeout(function () {
        var r = function () {
          map.checkResize();
          map.setCenter(new GLatLng(obj.vars.latitude, obj.vars.longitude), obj.vars.zoom);
        };
        $(elem).parents('fieldset.collapsible').children('legend').children('a').click(r);
        // Would be nice, but doesn't work.
        //$(elem).parents('fieldset.collapsible').children('.fieldset-wrapper').scroll(r);
      }, 0);
    }
    map.setCenter(new GLatLng(obj.vars.latitude, obj.vars.longitude), obj.vars.zoom);

    if (!obj.vars.nocontzoom) {
      map.enableDoubleClickZoom();
      map.enableContinuousZoom();
    }
    if (!obj.vars.behavior.nomousezoom) {
      map.enableScrollWheelZoom();
    }

    // Send out outgoing zooms
    GEvent.addListener(map, "zoomend", function (oldzoom, newzoom) {
      obj.vars.zoom = newzoom;
      obj.change("zoom", _ib.zoom);
    });

    // Send out outgoing moves
    GEvent.addListener(map, "moveend", function () {
      var coord = map.getCenter();
      obj.vars.latitude = coord.lat();
      obj.vars.longitude = coord.lng();
      obj.change("move", _ib.move);
    });

    // Send out outgoing map type changes.
    GEvent.addListener(map, "maptypechanged", function () {
      // If the map isn't ready yet, ignore it.
      if (obj.ready) {
        var type = map.getCurrentMapType();
        var i;
        for (i = 0; i < obj.opts.mapTypes.length; i++) {
          if (obj.opts.mapTypes[i] === type) {
            obj.vars.maptype = obj.opts.mapTypeNames[i];
          }
        }
        obj.change("maptypechange", _ib.mtc);
      }
    });

  });
});

////////////////////////////////////////
//            Zoom widget             //
////////////////////////////////////////
Drupal.gmap.addHandler('zoom', function (elem) {
  var obj = this;
  // Respond to incoming zooms
  var binding = obj.bind("zoom", function () {
    elem.value = obj.vars.zoom;
  });
  // Send out outgoing zooms
  $(elem).change(function () {
    obj.vars.zoom = parseInt(elem.value, 10);
    obj.change("zoom", binding);
  });
});

////////////////////////////////////////
//          Latitude widget           //
////////////////////////////////////////
Drupal.gmap.addHandler('latitude', function (elem) {
  var obj = this;
  // Respond to incoming movements.
  var binding = obj.bind("move", function () {
    elem.value = '' + obj.vars.latitude;
  });
  // Send out outgoing movements.
  $(elem).change(function () {
    obj.vars.latitude = Number(this.value);
    obj.change("move", binding);
  });
});

////////////////////////////////////////
//         Longitude widget           //
////////////////////////////////////////
Drupal.gmap.addHandler('longitude', function (elem) {
  var obj = this;
  // Respond to incoming movements.
  var binding = obj.bind("move", function () {
    elem.value = '' + obj.vars.longitude;
  });
  // Send out outgoing movements.
  $(elem).change(function () {
    obj.vars.longitude = Number(this.value);
    obj.change("move", binding);
  });
});

////////////////////////////////////////
//          Latlon widget             //
////////////////////////////////////////
Drupal.gmap.addHandler('latlon', function (elem) {
  var obj = this;
  // Respond to incoming movements.
  var binding = obj.bind("move", function () {
    elem.value = '' + obj.vars.latitude + ',' + obj.vars.longitude;
  });
  // Send out outgoing movements.
  $(elem).change(function () {
    var t = this.value.split(',');
    obj.vars.latitude = Number(t[0]);
    obj.vars.longitude = Number(t[1]);
    obj.change("move", binding);
  });
});

////////////////////////////////////////
//          Extent widget             //
////////////////////////////////////////
Drupal.gmap.addHandler('extent', function (elem) {
  var obj = this;
  // Respond to incoming extent changes.
  var binding = obj.bind("move", function () {
    var b = obj.map.getBounds();
    elem.value = '' + b.getSouthWest().lng() + ',' + b.getSouthWest().lat() + ',' + b.getNorthEast().lng() + ',' + b.getNorthEast().lat();
  });
  // Send out outgoing extent changes.
  jQuery(elem).change(function () {
    var t = this.value.split(',');
    var b = new GLatLngBounds(new GLatLng(Number(t[1]), Number(t[0])), new GLatLng(Number(t[3]), Number(t[2])));
    obj.vars.latitude = b.getCenter().lat();
    obj.vars.longitude = b.getCenter().lng();
    obj.vars.zoom = obj.map.getBoundsZoomLevel(b);
    obj.map.setCenter(new GLatLng(obj.vars.latitude, obj.vars.longitude), obj.vars.zoom);
  });
});

////////////////////////////////////////
//          Maptype widget            //
////////////////////////////////////////
Drupal.gmap.addHandler('maptype', function (elem) {
  var obj = this;
  // Respond to incoming movements.
  var binding = obj.bind("maptypechange", function () {
    elem.value = obj.vars.maptype;
  });
  // Send out outgoing movements.
  $(elem).change(function () {
    obj.vars.maptype = elem.value;
    obj.change("maptypechange", binding);
  });
});

(function () { // BEGIN CLOSURE
  var re = /([0-9.]+)\s*(em|ex|px|in|cm|mm|pt|pc|%)/;
  var normalize = function (str) {
    var ar;
    if ((ar = re.exec(str.toLowerCase()))) {
      return ar[1] + ar[2];
    }
    return null;
  };
  ////////////////////////////////////////
  //           Width widget             //
  ////////////////////////////////////////
  Drupal.gmap.addHandler('width', function (elem) {
    var obj = this;
    // Respond to incoming width changes.
    var binding = obj.bind("widthchange", function (w) {
      elem.value = normalize(w);
    });
    // Send out outgoing width changes.
    $(elem).change(function () {
      var n;
      if ((n = normalize(elem.value))) {
        elem.value = n;
        obj.change('widthchange', binding, n);
      }
    });
    obj.bind('init', function () {
      $(elem).change();
    });
  });

  ////////////////////////////////////////
  //           Height widget            //
  ////////////////////////////////////////
  Drupal.gmap.addHandler('height', function (elem) {
    var obj = this;
    // Respond to incoming height changes.
    var binding = obj.bind("heightchange", function (h) {
      elem.value = normalize(h);
    });
    // Send out outgoing height changes.
    $(elem).change(function () {
      var n;
      if ((n = normalize(elem.value))) {
        elem.value = n;
        obj.change('heightchange', binding, n);
      }
    });
    obj.bind('init', function () {
      $(elem).change();
    });
  });

})(); // END CLOSURE

////////////////////////////////////////
//        Control type widget         //
////////////////////////////////////////
Drupal.gmap.addHandler('controltype', function (elem) {
  var obj = this;
  // Respond to incoming height changes.
  var binding = obj.bind("controltypechange", function () {
    elem.value = obj.vars.controltype;
  });
  // Send out outgoing height changes.
  $(elem).change(function () {
    obj.vars.controltype = elem.value;
    obj.change("controltypechange", binding);
  });
});

// Map cleanup.
if (Drupal.jsEnabled) {
  $(document).unload(GUnload);
}

Drupal.behaviors.GMap = function (context) {
  if (Drupal.settings && Drupal.settings['gmap_remap_widgets']) {
    jQuery.each(Drupal.settings['gmap_remap_widgets'], function(key, val) {
      $('#'+ key).addClass('gmap-control');
    });
  }
  $('.gmap-control:not(.gmap-processed)', context).addClass('gmap-processed').each(function () {Drupal.gmap.setup.call(this)});
};
;

/**
 * @file
 * Common marker routines.
 */

/*global $, Drupal, GEvent, GInfoWindowTab, GLatLng, GLatLngBounds */

Drupal.gmap.addHandler('gmap', function (elem) {
  var obj = this;

  obj.bind('init', function () {
    if (obj.vars.behavior.autozoom) {
      obj.bounds = new GLatLngBounds();
    }
  });

  obj.bind('addmarker', function (marker) {
    var m = Drupal.gmap.factory.marker(new GLatLng(marker.latitude, marker.longitude), marker.opts);
    marker.marker = m;
    GEvent.addListener(m, 'click', function () {
      obj.change('clickmarker', -1, marker);
    });
    if (obj.vars.behavior.highlight) {
      GEvent.addListener(m, 'mouseover', function () {
        var highlightColor = '#' + obj.vars.styles.highlight_color;
        highlightMarker(obj.map, marker, 'hoverHighlight', highlightColor);
      });
      GEvent.addListener(m, 'mouseout', function () {
        unHighlightMarker(obj.map, marker, 'hoverHighlight');
      });
    }
    if (obj.vars.behavior.extramarkerevents) {
      GEvent.addListener(m, 'mouseover', function () {
        obj.change('mouseovermarker', -1, marker);
      });
      GEvent.addListener(m, 'mouseout', function () {
        obj.change('mouseoutmarker', -1, marker);
      });
      GEvent.addListener(m, 'dblclick', function () {
        obj.change('dblclickmarker', -1, marker);
      });
    }
    /**
     * Perform a synthetic marker click on this marker on load.
     */
    if (marker.autoclick || (marker.options && marker.options.autoclick)) {
      obj.deferChange('clickmarker', -1, marker);
    }
    if (obj.vars.behavior.autozoom) {
      obj.bounds.extend(marker.marker.getPoint());
    }
    // If the highlight arg option is used in views highlight the marker.
    if (marker.opts.highlight == 1) {
      highlightMarker(obj.map, marker, 'viewHighlight', marker.opts.highlightcolor);
    }
  });

  // Default marker actions.
  obj.bind('clickmarker', function (marker) {
    // Local/stored content
    if (marker.text) {
      // ExtInfoWindow implementation.
      if (Drupal.settings.gmap.extinfowindow) {
        marker.marker.openExtInfoWindow(
          obj.map,
          'opacity_window',
          marker.text,
          {beakOffset: 2}
        );
      }
      else {
        marker.marker.openInfoWindowHtml(marker.text);
      }
    }
    // Info Window Query / Info Window Offset
    if (marker.iwq || (obj.vars.iwq && typeof marker.iwo != 'undefined')) {
      var iwq, iwo;
      if (obj.vars.iwq) {
        iwq = obj.vars.iwq;
      }
      if (marker.iwq) {
        iwq = marker.iwq;
      }
      iwo = 0;
      if (marker.iwo) {
        iwo = marker.iwo;
      }
      // Create a container to store the cloned DOM elements.
      var el = document.createElement('div');
      // Clone the matched object, run through the clone, stripping off ids, and move the clone into the container.
      jQuery(iwq).eq(iwo).clone(false).find('*').removeAttr('id').appendTo(jQuery(el));
      marker.marker.openInfoWindow(el);
    }
    // AJAX content
    if (marker.rmt) {
      obj.rmtcache = obj.rmtcache || {};
      
      // Cached RMT.
      if (obj.rmtcache[marker.rmt]) {
        // ExtInfoWindow implementation.
        if (Drupal.settings.gmap.extinfowindow) {
          marker.marker.openExtInfoWindow(
            obj.map,
            'opacity_window',
            obj.rmtcache[marker.rmt],
            {beakOffset: 2}
          );
        }
        else {
          marker.marker.openInfoWindowHtml(obj.rmtcache[marker.rmt]);
        }
      }
      else {
        var uri = marker.rmt;
        // If there was a callback, prefix that.
        // (If there wasn't, marker.rmt was the FULL path.)
        if (obj.vars.rmtcallback) {
          uri = obj.vars.rmtcallback + '/' + marker.rmt;
        }
        // @Bevan: I think it makes more sense to do it in this order.
        // @Bevan: I don't like your choice of variable btw, seems to me like
        // @Bevan: it belongs in the map object, or at *least* somewhere in
        // @Bevan: the gmap settings proper...
        //if (!marker.text && Drupal.settings.loadingImage) {
        //  marker.marker.openInfoWindowHtml(Drupal.settings.loadingImage);
        //}
        $.get(uri, {}, function (data) {
          obj.rmtcache[marker.rmt] = data;
          // ExtInfoWindow implementation.
          if (Drupal.settings.gmap.extinfowindow) {
            marker.marker.openExtInfoWindow(
              obj.map,
              'opacity_window',
              data,
              {beakOffset: 2}
            );
          }
          else {
            marker.marker.openInfoWindowHtml(data);
          }
        });
      }
    }
    // Tabbed content
    else if (marker.tabs) {
      var infoWinTabs = [];
      for (var m in marker.tabs) {
        if (marker.tabs.hasOwnProperty(m)) {
          infoWinTabs.push(new GInfoWindowTab(m, marker.tabs[m]));
        }
      }
      marker.marker.openInfoWindowTabsHtml(infoWinTabs);
    }
    // No content -- marker is a link
    else if (marker.link) {
      open(marker.link, '_self');
    }
  });

  obj.bind('markersready', function () {
    // If we are autozooming, set the map center at this time.
    if (obj.vars.behavior.autozoom) {
      if (!obj.bounds.isEmpty()) {
        obj.map.setCenter(obj.bounds.getCenter(), Math.min(obj.map.getBoundsZoomLevel(obj.bounds), obj.vars.maxzoom));
      }
    }
  });

  obj.bind('clearmarkers', function () {
    // Reset bounds if autozooming
    // @@@ Perhaps we should have a bounds for both markers and shapes?
    if (obj.vars.behavior.autozoom) {
      obj.bounds = new GLatLngBounds();
    }
  });

  // @@@ TODO: Some sort of bounds handling for deletemarker? We'd have to walk the whole thing to figure out the new bounds...
});
;

/**
 * @file
 * Common marker highlighting routines.
 */

/**
 * Highlights marker on rollover.
 * Removes highlight on previous marker.
 *
 * Creates a "circle" using 20-sided GPolygon at the given point
 * Circle polygon object is global variable as there is only one highlighted marker at a time
 * and we want to remove the previously placed polygon before placing a new one.
 * 
 * Original code "Google Maps JavaScript API Example"
 */
highlightMarker = function (map, currentMarker, highlightID, color) {
  var markerPoint = currentMarker.marker.getPoint();
  var polyPoints = Array();

  var mapNormalProj = G_NORMAL_MAP.getProjection();
  var mapZoom = map.getZoom();
  var clickedPixel = mapNormalProj.fromLatLngToPixel(markerPoint, mapZoom);

  var polySmallRadius = 20;
  var polyNumSides = 20;
  var polySideLength = 18;

  for (var a = 0; a < (polyNumSides + 1); a++) {
    var aRad = polySideLength * a * (Math.PI/180);
    var polyRadius = polySmallRadius; 
    var pixelX = clickedPixel.x + polyRadius * Math.cos(aRad);
    var pixelY = clickedPixel.y + polyRadius * Math.sin(aRad);
    var polyPixel = new GPoint(pixelX, pixelY);
    var polyPoint = mapNormalProj.fromPixelToLatLng(polyPixel, mapZoom);
    polyPoints.push(polyPoint);
  }
  // Using GPolygon(points,  strokeColor?,  strokeWeight?,  strokeOpacity?,  fillColor?,  fillOpacity?)
  map.highlightID = new GPolygon(polyPoints, color, 2, 0, color, 0.5);
  map.addOverlay(map.highlightID);
};

unHighlightMarker = function (map, currentMarker, highlightID) {
  if (map.highlightID) {
    map.removeOverlay(map.highlightID);
    delete map.highlightID;
  }
};
;

/**
 * @file
 * GMap Markers
 * GMap API version -- No manager
 */

/*global Drupal, GMarker */

// Replace to override marker creation
Drupal.gmap.factory.marker = function (loc, opts) {
  return new GMarker(loc, opts);
};

Drupal.gmap.addHandler('gmap', function (elem) {
  var obj = this;

  obj.bind('addmarker', function (marker) {
    obj.map.addOverlay(marker.marker);
		GEvent.addListener(marker.marker, 'click', function() { 
		   obj.map.panTo(new GLatLng(marker.latitude, marker.longitude));
		});
		
  });

  obj.bind('delmarker', function (marker) {
    obj.map.removeOverlay(marker.marker);
  });

  obj.bind('clearmarkers', function () {
    // @@@ Maybe don't nuke ALL overlays?
    obj.map.clearOverlays();
  });
});
;

/**
 * @file
 * GPolyLine / GPolygon manager
 */

/*global Drupal, GLatLng, GPoint */

Drupal.gmap.map.prototype.poly = {};

/**
 * Distance in pixels between 2 points.
 */
Drupal.gmap.map.prototype.poly.distance = function (point1, point2) {
  return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
};

/**
 * Circle -- Following projection.
 */
Drupal.gmap.map.prototype.poly.computeCircle = function (obj, center, point2) {
  var numSides = 36;
  var sideInc = 10; // 360 / 20 = 18 degrees
  var convFactor = Math.PI / 180;
  var points = [];
  var radius = obj.poly.distance(center, point2);
  // 36 sided poly ~= circle
  for (var i = 0; i <= numSides; i++) {
    var rad = i * sideInc * convFactor;
    var x = center.x + radius * Math.cos(rad);
    var y = center.y + radius * Math.sin(rad);
    //points.push(obj.map.getCurrentMapType().getProjection().fromPixelToLatLng(new GPoint(x,y),obj.map.getZoom()));
    points.push(new GPoint(x, y));
  }
  return points;
};

Drupal.gmap.map.prototype.poly.calcPolyPoints = function (center, radM, numPoints, sAngle) {
  if (!numPoints) {
    numPoints = 32;
  }
  if (!sAngle) {
    sAngle = 0;
  }

  var d2r = Math.PI / 180.0;
  var r2d = 180.0 / Math.PI;
  var angleRad = sAngle * d2r;
  // earth semi major axis is about 6378137 m
  var latScale = radM / 6378137 * r2d;
  var lngScale = latScale / Math.cos(center.latRadians());

  var angInc = 2 * Math.PI / numPoints;
  var points = [];
  for (var i = 0; i < numPoints; i++) {
    var lat = parseFloat(center.lat()) + latScale * Math.sin(angleRad);
    var lng = parseFloat(center.lng()) + lngScale * Math.cos(angleRad);
    points.push(new GLatLng(lat, lng));
    angleRad += angInc;
  }

  // close the shape and return it
  points.push(points[0]);
  return points;
};
;

/**
 * @file
 * GIcon manager for GMap.
 * Required for markers to operate properly.
 */

/*global $, Drupal, GIcon, GPoint, GSize, G_DEFAULT_ICON */

/**
 * Get the GIcon corresponding to a setname / sequence.
 * There is only one GIcon for each slot in the sequence.
 * The marker set wraps around when reaching the end of the sequence.
 * @@@ TODO: Move this directly into the preparemarker event binding.
 */
Drupal.gmap.getIcon = function (setname, sequence) {
  var othimg = ['printImage', 'mozPrintImage', 'printShadow', 'transparent'];
  // If no setname, return google's default icon.
  if (!setname) {
    return G_DEFAULT_ICON;
  }
  if (!this.gicons) {
    this.gicons = {};
  }

  // If no sequence, synthesise one.
  if (!sequence) {
    // @TODO make this per-map.
    if (!this.sequences) {
      this.sequences = {};
    }
    if (!this.sequences[setname]) {
      this.sequences[setname] = -1;
    }
    this.sequences[setname]++;
    sequence = this.sequences[setname];
  }

  if (!this.gicons[setname]) {
    if (!Drupal.gmap.icons[setname]) {
      alert('Request for invalid marker set ' + setname + '!');
    }
    this.gicons[setname] = [];
    var q = Drupal.gmap.icons[setname];
    var p, t;
    for (var i = 0; i < q.sequence.length; i++) {
      t = new GIcon();
      p = Drupal.gmap.iconpath + q.path;
      t.image = p + q.sequence[i].f;
      if (q.shadow.f !== '') {
        t.shadow = p + q.shadow.f;
        t.shadowSize = new GSize(q.shadow.w, q.shadow.h);
      }
      t.iconSize = new GSize(q.sequence[i].w, q.sequence[i].h);
      t.iconAnchor = new GPoint(q.anchorX, q.anchorY);
      t.infoWindowAnchor = new GPoint(q.infoX, q.infoY);
      for (var j = 0; j < othimg.length; j++) {
        if (q[othimg[j]] !== '') {
          t[othimg[j]] = p + q[othimg[j]];
        }
      }
      // @@@ imageMap?
      this.gicons[setname][i] = t;
    }
    delete Drupal.gmap.icons[setname];
  }
  // TODO: Random, other cycle methods.
  return this.gicons[setname][sequence % this.gicons[setname].length];
};

/**
 * JSON callback to set up the icon defs.
 * When doing the JSON call, the data comes back in a packed format.
 * We need to expand it and file it away in a more useful format.
 */
Drupal.gmap.iconSetup = function () {
  Drupal.gmap.icons = {};
  var m = Drupal.gmap.icondata;
  var filef, filew, fileh, files;
  for (var path in m) {
    if (m.hasOwnProperty(path)) {
      // Reconstitute files array
      filef = m[path].f;
      filew = Drupal.gmap.expandArray(m[path].w, filef.length);
      fileh = Drupal.gmap.expandArray(m[path].h, filef.length);
      files = [];
      for (var i = 0; i < filef.length; i++) {
        files[i] = {f : filef[i], w : filew[i], h : fileh[i]};
      }

      for (var ini in m[path].i) {
        if (m[path].i.hasOwnProperty(ini)) {
          $.extend(Drupal.gmap.icons, Drupal.gmap.expandIconDef(m[path].i[ini], path, files));
        }
      }
    }
  }
};

/**
 * Expand a compressed array.
 * This will pad arr up to len using the last value of the old array.
 */
Drupal.gmap.expandArray = function (arr, len) {
  var d = arr[0];
  for (var i = 0; i < len; i++) {
    if (!arr[i]) {
      arr[i] = d;
    }
    else {
      d = arr[i];
    }
  }
  return arr;
};

/**
 * Expand icon definition.
 * This helper function is the reverse of the packer function found in
 * gmap_markerinfo.inc.
 */
Drupal.gmap.expandIconDef = function (c, path, files) {
  var decomp = ['key', 'name', 'sequence', 'anchorX', 'anchorY', 'infoX',
    'infoY', 'shadow', 'printImage', 'mozPrintImage', 'printShadow',
    'transparent'];
  var fallback = ['', '', [], 0, 0, 0, 0, {f: '', h: 0, w: 0}, '', '', '', ''];
  var imagerep = ['shadow', 'printImage', 'mozPrintImage', 'printShadow',
    'transparent'];
  var defaults = {};
  var sets = [];
  var i, j;
  // Part 1: Defaults / Markersets
  // Expand arrays and fill in missing ones with fallbacks
  for (i = 0; i < decomp.length; i++) {
    if (!c[0][i]) {
      c[0][i] = [ fallback[i] ];
    }
    c[0][i] = Drupal.gmap.expandArray(c[0][i], c[0][0].length);
  }
  for (i = 0; i < c[0][0].length; i++) {
    for (j = 0; j < decomp.length; j++) {
      if (i === 0) {
        defaults[decomp[j]] = c[0][j][i];
      }
      else {
        if (!sets[i - 1]) {
          sets[i - 1] = {};
        }
        sets[i - 1][decomp[j]] = c[0][j][i];
      }
    }
  }
  for (i = 0; i < sets.length; i++) {
    for (j = 0; j < decomp.length; j++) {
      if (sets[i][decomp[j]] === fallback[j]) {
        sets[i][decomp[j]] = defaults[decomp[j]];
      }
    }
  }
  var icons = {};
  for (i = 0; i < sets.length; i++) {
    var key = sets[i].key;
    icons[key] = sets[i];
    icons[key].path = path;
    delete icons[key].key;
    delete sets[i];
    for (j = 0; j < icons[key].sequence.length; j++) {
      icons[key].sequence[j] = files[icons[key].sequence[j]];
    }
    for (j = 0; j < imagerep.length; j++) {
      if (typeof(icons[key][imagerep[j]]) === 'number') {
        icons[key][imagerep[j]] = files[icons[key][imagerep[j]]];
      }
    }
  }
  return icons;
};

/**
 * We attach ourselves if we find a map somewhere needing markers.
 * Note: Since we broadcast our ready event to all maps, it doesn't
 * matter which one we attached to!
 */
Drupal.gmap.addHandler('gmap', function (elem) {
  var obj = this;

  obj.bind('init', function () {
    // Only expand once.
    if (!Drupal.gmap.icons) {
      Drupal.gmap.iconSetup();
    }
  });

  obj.bind('ready', function () {
    // Compatibility event.
    if (Drupal.gmap.icondata) {
      obj.deferChange('iconsready', -1);
    }
  });

  if (!obj.vars.behavior.customicons) {
    // Provide icons to markers.
    obj.bind('preparemarker', function (marker) {
      marker.opts.icon = Drupal.gmap.getIcon(marker.markername, marker.offset);
    });
  }
});
;

/**
 * @file
 * GMap Marker Loader
 * Static markers.
 * This is a simple marker loader to read markers from the map settings array.
 * Commonly used with macros.
 */

/*global Drupal */

// Add a gmap handler
Drupal.gmap.addHandler('gmap', function (elem) {
  var obj = this;
  var marker, i;
  if (obj.vars.markers) {
    // Inject markers as soon as the icon loader is ready.
    obj.bind('iconsready', function () {
      for (i = 0; i < obj.vars.markers.length; i++) {
        marker = obj.vars.markers[i];
        if (!marker.opts) {
          marker.opts = {};
        }
        // Pass around the object, bindings can change it if necessary.
        obj.change('preparemarker', -1, marker);
        // And add it.
        obj.change('addmarker', -1, marker);
      }
      obj.change('markersready', -1);
    });
  }
});
;

/**
 * @file
 * GMap Shape Loader
 * Static Shapes.
 * This is a simple marker loader to read markers from the map settings array.
 * Commonly used with macros.
 */

/*global $, Drupal */

// Add a gmap handler
Drupal.gmap.addHandler('gmap', function (elem) {
  var obj = this;
  if (obj.vars.shapes) {
    // Inject shapes during init.
    obj.bind('init', function () {
      // We need to move the incoming shapes out of the way,
      // because addshape will readd them, causing an infinate loop.
      // Store the shapes in s and reset obj.vars.shapes.
      var s = obj.vars.shapes;
      obj.vars.shapes = [];
      $.each(s, function (i, shape) {
        if (!shape.opts) {
          shape.opts = {};
        }
        // TODO: style props?
        // And add it.
        obj.change('prepareshape', -1, shape);
        obj.change('addshape', -1, shape);
      });
      obj.change('shapesready', -1);
    });
  }
});
;

/**
 * @file
 * GMap Shapes
 * GMap API version / Base case
 */

/*global $, Drupal, GEvent, GLatLng, GPolygon, GPolyline */

Drupal.gmap.addHandler('gmap', function (elem) {
  var obj = this;
/*
  obj.bind('init',function() {
    if (obj.vars.behavior.autozoom) {
      obj.bounds = new GLatLngBounds(new GLatLng(obj.vars.latitude,obj.vars.longitude),new GLatLng(obj.vars.latitude,obj.vars.longitude));
    }
  });
*/
  obj.bind('prepareshape', function (shape) {
    var pa, cargs, style;
    //var m = new GMarker(new GLatLng(marker.latitude,marker.longitude),marker.opts);
    pa = []; // point array (array of GLatLng-objects)
    var fillstyle = true;
    if (shape.type === 'circle') {
      pa = obj.poly.calcPolyPoints(new GLatLng(shape.center[0], shape.center[1]), shape.radius * 1000, shape.numpoints);
    }
    else if (shape.type === 'rpolygon') {
      shape.center = new GLatLng(shape.center[0], shape.center[1]);
      shape.point2 = new GLatLng(shape.point2[0], shape.point2[1]);
      var radius = shape.center.distanceFrom(shape.point2);
      pa = obj.poly.calcPolyPoints(shape.center, radius, shape.numpoints);
    }
    else if (shape.type === 'polygon') {
      $.each(shape.points, function (i, n) {
        pa.push(new GLatLng(n[0], n[1]));
      });
    }
    else if (shape.type === 'line') {
      $.each(shape.points, function (i, n) {
        pa.push(new GLatLng(n[0], n[1]));
      });
      fillstyle = false;
    }
    cargs = [pa];

    // Style normalization
    if (fillstyle) {
      style = obj.vars.styles.poly_default.slice();
    }
    else {
      style = obj.vars.styles.line_default.slice();
    }
    if (shape.style) {
      if (typeof shape.style === 'string') {
        if (obj.vars.styles[shape.style]) {
          style = obj.vars.styles[shape.style].slice();
        }
      }
      else {
        style = shape.style.slice();
      }
    }
    style[0] = '#' + style[0];
    style[1] = Number(style[1]);
    style[2] = style[2] / 100;
    if (fillstyle) {
      style[3] = '#' + style[3];
      style[4] = style[4] / 100;
    }
    
    if (shape.type == 'encoded_line') {
      shape.color = style[0];
      shape.weight = style[1];
      shape.opacity = style[2];
    }
    else if (shape.type == 'encoded_polygon') {
      $.each(shape.polylines, function(i, polyline) {
        polyline.color = style[0];
        polyline.weight = style[1];
        polyline.opacity = style[2];
      });
      shape.fill = true;
      shape.color = style[3];
      shape.opacity = style[4];
      shape.outline = true;
    }

    $.each(style, function (i, n) {
      cargs.push(n);
    });
    if (shape.opts) {
      cargs.push(shape.opts);
    }
    var Pg = function (args) {
      GPolygon.apply(this, args);
    };
    Pg.prototype = new GPolygon();
    var Pl = function (args) {
      GPolyline.apply(this, args);
    };
    Pl.prototype = new GPolyline();
    switch (shape.type) {
      case 'circle':
      case 'polygon':
      case 'rpolygon':
        shape.shape = new Pg(cargs);
        break;
      case 'line':
        shape.shape = new Pl(cargs);
        break;
      case 'encoded_line':
        shape.shape = GPolyline.fromEncoded(shape);        
        break;
      case 'encoded_polygon':
        shape.shape = GPolygon.fromEncoded(shape);
        break;
    }
  });

  obj.bind('addshape', function (shape) {
    if (!obj.vars.shapes) {
      obj.vars.shapes = [];
    }
    obj.vars.shapes.push(shape);
    obj.map.addOverlay(shape.shape);

    if (obj.vars.behavior.clickableshapes) {
      GEvent.addListener(shape.shape, 'click', function () {
        obj.change('clickshape', -1, shape);
      });
    }
  });

  obj.bind('delshape', function (shape) {
    obj.map.removeOverlay(shape.shape);
  });

  obj.bind('clearshapes', function () {
    if (obj.vars.shapes) {
      $.each(obj.vars.shapes, function (i, n) {
        obj.change('delshape', -1, n);
      });
    }
  });
});
;
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}('D M(d,c,b,a){3.1Y=b;3.O=d;3.Q=c;3.K=(2K a==\'2D\'||a===6)?{}:a;3.1v=3.K.3a==6?6:3.K.3a;3.36=3.K.2Z==6?6:3.K.2Z;3.2g=3.K.2S==6?6:3.K.2S;3.1i=3.2g==6?U:13;3.20=U;3.X=3.K.2E==6?0:3.K.2E;3.1F=3.K.2x==6?0+3.X:3.K.2x+3.X;3.1R=3.K.2o==6?0+3.X:3.K.2o+3.X;3.1y=3.K.38==6?3Z:3.K.38;3.3X=3.K.1S==6?U:3.K.1S;3.E=6;3.B=J.1l(\'1k\');3.B.z.1a=\'3J\';3.B.z.N=\'17\';3.I=J.1l(\'1k\');3.I.19=3.Q+\'2I\';3.I.1C=3.1Y;3.I.z.N=\'1s\';3.I.z.14=\'1r\';3.1g=J.1l(\'1k\');3.1E=U;3.22=U};M.H=R 3j();M.H.3i=D(b){3.E=b;8(3.1i){3.37=3.E.1A().C*0.9;3.39=3.E.1A().L*0.9}3.34={33:3.E.1A().C/2,3W:1};3.4={T:{t:0,l:0,w:0,h:0,A:6},t:{t:0,l:0,w:0,h:0,A:6},16:{t:0,l:0,w:0,h:0,A:6},l:{t:0,l:0,w:0,h:0,A:6},r:{t:0,l:0,w:0,h:0,A:6},15:{t:0,l:0,w:0,h:0,A:6},b:{t:0,l:0,w:0,h:0,A:6},1N:{t:0,l:0,w:0,h:0,A:6},1j:{t:0,l:0,w:0,h:0,A:6},11:{t:0,l:0,w:0,h:0,A:6}};8(3.1i){3.4.Y={t:0,l:0,w:0,h:0,A:6};3.4.1e={t:0,l:0,w:0,h:0,A:6}}1t(7 i 1d 3.4){7 g=J.1l(\'1k\');g.19=3.Q+\'1I\'+i;g.z.14=\'1r\';J.1H.1b(g);g=J.1X(3.Q+\'1I\'+i);7 e=3.4[i];e.w=29(3.1n(g,\'C\'),10);e.h=29(3.1n(g,\'L\'),10);J.1H.27(g)}1t(7 i 1d 3.4){8(i==\'11\'){3.1g.1b(3.I)}7 f=6;8(3.4[i].A==6){f=J.1l(\'1k\');3.1g.1b(f)}V{f=3.4[i].A}f.19=3.Q+\'1I\'+i;f.z.1a=\'1o\';f.z.C=3.4[i].w+\'F\';f.z.L=3.4[i].h+\'F\';f.z.Z=3.4[i].t+\'F\';f.z.1D=3.4[i].l+\'F\';3.4[i].A=f}3.E.3s(3p).1b(3.B);3.B.19=3.Q;7 d=3.1n(J.1X(3.Q),\'C\');3.B.z.C=(d==6?3.34.33:d);3.E.3o().1b(3.I);3.18=3.W(3.B).C;3.I.z.C=3.18+\'F\';3.I.z.1a=\'1o\';3.B.1b(3.1g);8(3.1i){3.3m=3.W(3.B).C}8(3.1i){21=3.E;2y=3.37;3l=3.39;3k=3.B;2v=3.2g;8(3.O){P.1m(3.O,\'2r\')}2q=3.B.z.C;2p=3.B.z.L;P.2l(3.4.Y.A,\'1x\',D(){7 a=21.G();a.B.z.C=2y+\'F\';a.1z(2v);8(3.O){P.1m(3.O,\'3b\')}a.20=13;a.2k(13);a.1Z()});P.2l(3.4.1e.A,\'1x\',D(){7 a=21.G();a.B.z.C=2q;a.B.z.L=2p;8(a.1v!=6){a.1z(3.1v)}V{a.I.1C=a.1Y}a.20=U;a.2k(13);a.2j();a.1Z()});3.1Z()}7 c=[\'43\',\'42\',\'40\',\'2i\'];1t(i=0;i<c.35;i++){P.3Y(3.B,c[i],3,3.1W)}8((1V.1U.32().1T(\'31\')!=-1&&J.30)||1V.1U.1T(\'3V\')>-1){3.B.3U(\'2i\',3.1W)}8(1V.1U.1T(\'3T/\')>-1){3.B.2i=3.1W}3.22=13;8(3.1v!=6){3.1z(3.1v)}};M.H.1W=D(e){8(1V.1U.32().1T(\'31\')!=-1&&J.30){2Y.2X.3S=13;2Y.2X.3R=U}V{e.3Q()}};M.H.2V=D(){8(3.E.G()!=6&&3.B!=6){P.1m(3.E,\'2r\');P.3P(3.B);8(3.B.2U){3.B.2U=\'\'}8(3.B.2T){3.B.2T.27(3.B)}3.B=6;P.1m(3.E,\'3b\');3.E.1P(6)}};M.H.3O=D(){S R M(3.O,3.Q,3.1Y,3.K)};M.H.2k=D(c){8(!c||3.B==6)S;8(2K 3.2f!=\'2D\')7 d=3.I.2f;V 7 d=3.I.1c;3.18=3.W(3.B).C;3.I.z.C=3.B.z.C;3.I.z.1D=3.4.l.w+\'F\';3.I.z.Z=3.4.T.h+\'F\';3.I.z.14=\'2R\';3.4.T.t=0;3.4.T.l=0;3.4.t.l=3.4.T.w;3.4.t.w=(3.4.l.w+3.18+3.4.r.w)-3.4.T.w-3.4.16.w;3.4.t.h=3.4.T.h;3.4.16.l=3.4.t.w+3.4.T.w;3.4.l.t=3.4.T.h;3.4.l.h=d;3.4.r.l=3.18+3.4.l.w;3.4.r.t=3.4.16.h;3.4.r.h=d;3.4.15.t=d+3.4.T.h;3.4.b.l=3.4.15.w;3.4.b.t=d+3.4.T.h;3.4.b.w=(3.4.l.w+3.18+3.4.r.w)-3.4.15.w-3.4.1N.w;3.4.b.h=3.4.15.h;3.4.1N.l=3.4.b.w+3.4.15.w;3.4.1N.t=d+3.4.16.h;3.4.1j.l=(3.4.l.w+3.4.r.w+3.18)/2-(3.4.1j.w/2);3.4.1j.t=3.4.15.t+3.4.15.h-3.X;3.4.11.l=3.4.16.l+3.4.16.w-3.4.11.w-3.X;3.4.11.t=3.X;8(3.1i){3.4.Y.l=3.4.11.l-3.4.Y.w-5;3.4.Y.t=3.4.11.t;3.4.1e.l=3.4.Y.l;3.4.1e.t=3.4.Y.t}1t(7 i 1d 3.4){8(i==\'11\'){3.1g.3N(3.I,3.4[i].A)}7 e=6;8(3.4[i].A==6){e=J.1l(\'1k\');3.1g.1b(e)}V{e=3.4[i].A}e.19=3.Q+\'1I\'+i;e.z.1a=\'1o\';e.z.C=3.4[i].w+\'F\';e.z.L=3.4[i].h+\'F\';e.z.Z=3.4[i].t+\'F\';e.z.1D=3.4[i].l+\'F\';3.4[i].A=e}7 a=3.O;7 b=3.E;P.2l(3.4.11.A,\'1x\',D(){b.12()});7 f=3.E.1O(3.O.3M());3.B.z.1a=\'1o\';7 g=3.O.1L();3.B.z.1D=(f.x-(3.18/2)-3.4.l.w-g.1K.x+g.1M.x)+\'F\';3.B.z.Z=(f.y-3.4.15.h-d-3.4.T.h-3.4.1j.h-g.1K.y+g.1M.y+3.X)+\'F\';3.B.z.N=\'1s\';8(3.22){P.1m(3.E,\'3L\')}8(3.E.G()!=6&&!3.1E){3.1E=13;3.2e();3.1E=U}};M.H.1Z=D(){8(3.4.Y.A!=6&&3.4.1e.A!=6){8(3.20){3.4.Y.A.z.N=\'17\';3.4.1e.A.z.N=\'1s\'}V{3.4.Y.A.z.N=\'1s\';3.4.1e.A.z.N=\'17\'}}};M.H.2j=D(){7 g=3.I.3K(13);g.19=3.Q+\'2O\';g.z.14=\'1r\';g.z.L=\'2d\';J.1H.1b(g);g=J.1X(3.Q+\'2O\');7 c=g.1c;J.1H.27(g);3.I.z.L=c+\'F\';7 f=3.B.2c;7 d=3.E.1O(3.O.2m());7 e=3.4.t.A.1c+3.4.l.A.1c+3.4.b.A.1c;7 a=3.4.t.A.2N;3.4.l.A.z.L=c+\'F\';3.4.r.A.z.L=c+\'F\';7 b=3.4.b.A.2N-c;3.4.l.A.z.Z=b+\'F\';3.4.r.A.z.Z=b+\'F\';3.I.z.Z=b+\'F\';2M=29(3.4.t.A.z.L,10);b-=2M;3.4.11.A.z.Z=b+3.X+\'F\';3.4.T.A.z.Z=b+\'F\';3.4.t.A.z.Z=b+\'F\';3.4.16.A.z.Z=b+\'F\';3.2e()};M.H.2b=D(){S 3.K};M.H.2e=D(){7 g=3.E.3I(3.E.2L());7 u=3.E.1O(3.E.2L());7 a=R 1w(u.x-g.x,u.y-g.y);7 r=3.E.1A();7 v=R 1w(a.x,a.y+r.L);7 k=R 1w(a.x+r.C,a.y);7 m=3.E.1O(3.O.2m());7 d=0;7 e=0;7 i=3.1F;7 j=3.1R;7 q=3.O.1L().1M;7 s=3.O.1L().1K;7 o=3.4.t.A;7 l=3.4.l.A;7 b=3.4.b.A;7 n=3.4.r.A;7 t=3.4.1j.A;7 h=m.y-(-q.y+s.y+3.W(t).L+3.W(b).L+3.W(l).L+3.W(o).L+3.1R);8(h<k.y){e=k.y-h}V{7 c=m.y+3.1R;8(c>=v.y){e=2a.Y(-(c-v.y),k.y-h)}}7 f=2a.2J(m.x+3.W(3.B).C/2+3.W(n).C+3.1F+q.x-s.x);8(f>k.x){d=-(f-k.x)}V{7 p=-(2a.2J((3.W(3.B).C/2-3.O.1L().2H.C/2)+3.W(l).C+3.X+3.1F)-m.x-q.x+s.x);8(p<v.x){d=v.x-p}}8((d!=0||e!=0)&&3.E.G()!=6){8((e<0-3.1y||e>3.1y)&&(d<0-3.1y||d>3.1y)){3.E.3H(3.O.2m())}V{3.E.3G(R 28(d,e))}}};M.H.1z=D(f){7 d=3.E;7 e=3.36;3F(f,D(a,c){8(d.G()!==6){7 b=J.1X(d.G().Q+\'2I\');8(a==6||c==-1){b.1C=\'<2G 3E="3D">3C: 3B 3A 3z 3y 3x 3w 3v 3u 3t "\'+f+\'"</2G>\'}V{b.1C=a}8(e!=6){e()}d.G().2j()}P.1m(d,\'3r\')})};M.H.W=D(g){7 b=3.1n(g,\'N\');8(b!=\'17\'&&b!=6){S{C:g.2c,L:g.1c}}7 f=g.z;7 c=f.14;7 e=f.1a;7 h=f.N;f.14=\'1r\';f.1a=\'1o\';f.N=\'1s\';7 a=g.3q;7 d=g.2f;f.N=h;f.1a=e;f.14=c;S{C:a,L:d}};M.H.1n=D(d,c){7 a=U;c=3.2F(c);8(d.19==3.Q&&c==\'C\'&&d.z.N==\'17\'){d.z.14=\'1r\';d.z.N=\'\'}7 b=d.z[c];8(!b){8(J.24&&J.24.2B){7 e=J.24.2B(d,6);b=e?e[c]:6}V 8(d.2C){b=d.2C[c]}}8((b==\'2d\')&&(c==\'C\'||c==\'L\')&&(3.1n(d,\'N\')!=\'17\')){8(c==\'C\'){b=d.2c}V{b=d.1c}}8(d.19==3.Q&&c==\'C\'&&d.z.N!=\'17\'){d.z.N=\'17\';d.z.14=\'2R\'}S(b==\'2d\')?6:b};M.H.2F=D(c){7 a=c.3n(\'-\'),25=a.35;8(25==1)S a[0];7 b=c.23(0)==\'-\'?a[0].23(0).2A()+a[0].2z(1):a[0];1t(7 i=1;i<25;i++){b+=a[i].23(0).2A()+a[i].2z(1)}S b};26.H.1G=6;26.H.1q=6;26.H.1p=6;1u.H.1h=D(d,b,e,c){8(d==6){1B\'1J 1d 1u.1h: 2w 2Q 2P 6\';S U}8(b==6||b==\'\'){1B\'1J 1d 1u.1h: 2u 3c a 2t\';S U}d.2s();8(d.G()!=6){d.12()}8(d.G()==6){d.1P(R M(3,b,e,c));8(d.1q==6){d.1q=P.1Q(d,\'1x\',D(a){8(!a&&d.G()!=6&&!d.G().2b().1S){d.12()}})}8(d.1p==6){d.1p=P.1Q(d,\'2W\',D(a){8(d.G()!=6){d.12()}})}d.2h(d.G())}};1f.H.1h=D(g,b,e,c){8(g==6){1B\'1J 1d 1f.1h: 3h 2Q 2P 6\';S U}8(b==6||b==\'\'){1B\'1J 1d 1f.1h: 2u 3c a 2t\';S U}3.2s();8(3.G()!=6){3.12()}8(3.G()==6){7 d=R 3g(3f);d.2H=R 28(0,0);d.3e=R 28(0,0);d.1K=R 1w(0,0);d.1M=R 1w(0,0);7 f=R 1u(g,{3d:13,41:d});3.2h(f);3.1P(R M(f,b,e,c));8(3.1q==6){3.1q=P.1Q(3,\'1x\',D(a){8(!a&&3.G()!=6&&!2w.G().2b().1S){3.12();3.2n(f)}})}8(3.1p==6){3.1p=P.1Q(3,\'2W\',D(a){8(3.G()!=6){3.12();3.2n(f)}})}3.2h(3.G())}};1u.H.12=D(a){8(a.G()!=6){a.12()}};1f.H.G=D(){S 3.1G};1f.H.1P=D(a){3.1G=a};1f.H.12=D(){8(3.G()!=6){3.1G.2V()}};',62,252,'|||this|wrapperParts||null|var|if|||||||||||||||||||||||||||style|domElement|container_|width|function|map_|px|getExtInfoWindow|prototype|contentDiv_|document|options_|height|ExtInfoWindow|display|marker_|GEvent|infoWindowId_|new|return|tl|false|else|getDimensions_|borderSize_|max|top||close|closeExtInfoWindow|true|visibility|bl|tr|none|contentWidth|id|position|appendChild|offsetHeight|in|min|GMap2|wrapperDiv_|openExtInfoWindow|maximizeEnabled_|beak|div|createElement|trigger|getStyle_|absolute|InfoWindowListener_|ClickListener_|hidden|block|for|GMarker|ajaxUrl_|GPoint|click|maxPanning_|ajaxRequest_|getSize|throw|innerHTML|left|isRepositioning|paddingX_|ExtInfoWindowInstance_|body|_|Error|iconAnchor|getIcon|infoWindowAnchor|br|fromLatLngToDivPixel|setExtInfoWindow_|addListener|paddingY_|noCloseOnClick|indexOf|userAgent|navigator|onClick_|getElementById|html_|toggleMaxMin_|isMaximized_|thisMap|triggerWindowOpenEvent|charAt|defaultView|len|GMap|removeChild|GSize|parseInt|Math|getOptions|offsetWidth|auto|repositionMap_|clientHeight|maxContent_|addOverlay|onmousewheel|resize|redraw|addDomListener|getPoint|removeOverlay|paddingY|thisMinHeight|thisMinWidth|extinfowindowbeforeclose|closeInfoWindow|cssId|must|thisMaxContent|map|paddingX|thisMaxWidth|substring|toUpperCase|getComputedStyle|currentStyle|undefined|beakOffset|camelize_|span|iconSize|_contents|round|typeof|getCenter|windowTHeight|offsetTop|_tempContents|be|cannot|visible|maxContent|parentNode|outerHTML|remove|infowindowopen|event|window|ajaxCallback|all|msie|toLowerCase|containerWidth|defaultStyles|length|callback_|maxWidth_|maxPanning|maxHeight_|ajaxUrl|extinfowindowclose|specify|hide|shadowSize|G_DEFAULT_ICON|GIcon|point|initialize|GOverlay|thisContainer|thisMaxHeight|minWidth_|split|getContainer|G_MAP_FLOAT_PANE|clientWidth|extinfowindowupdate|getPane|from|content|HTML|get|to|failed|request|Ajax|The|ERROR|error|class|GDownloadUrl|panBy|setCenter|fromLatLngToContainerPixel|relative|cloneNode|extinfowindowopen|getLatLng|insertBefore|copy|clearInstanceListeners|stopPropagation|returnValue|cancelBubble|AppleWebKit|attachEvent|Opera|borderSize|noCloseOnClick_|bindDom|500|DOMMouseScroll|icon|dblclick|mousedown'.split('|'),0,{}));
// $Id: base.js,v 1.11.2.1 2010/03/10 20:08:58 merlinofchaos Exp $
/**
 * @file base.js
 *
 * Some basic behaviors and utility functions for Views.
 */

Drupal.Views = {};

/**
 * jQuery UI tabs, Views integration component
 */
Drupal.behaviors.viewsTabs = function (context) {
  $('#views-tabset:not(.views-processed)').addClass('views-processed').each(function() {
    new Drupal.Views.Tabs($(this), {selectedClass: 'active'});
  });

  $('a.views-remove-link')
    .addClass('views-processed')
    .click(function() {
      var id = $(this).attr('id').replace('views-remove-link-', '');
      $('#views-row-' + id).hide();
      $('#views-removed-' + id).attr('checked', true);
      return false;
    });
}

/**
 * For IE, attach some javascript so that our hovers do what they're supposed
 * to do.
 */
Drupal.behaviors.viewsHoverlinks = function() {
  if ($.browser.msie) {
    // If IE, attach a hover event so we can see our admin links.
    $("div.view:not(.views-hover-processed)").addClass('views-hover-processed').hover(
      function() {
        $('div.views-hide', this).addClass("views-hide-hover"); return true;
      },
      function(){
        $('div.views-hide', this).removeClass("views-hide-hover"); return true;
      }
    );
    $("div.views-admin-links:not(.views-hover-processed)")
      .addClass('views-hover-processed')
      .hover(
        function() {
          $(this).addClass("views-admin-links-hover"); return true;
        },
        function(){
          $(this).removeClass("views-admin-links-hover"); return true;
        }
      );
  }
}

/**
 * Helper function to parse a querystring.
 */
Drupal.Views.parseQueryString = function (query) {
  var args = {};
  var pos = query.indexOf('?');
  if (pos != -1) {
    query = query.substring(pos + 1);
  }
  var pairs = query.split('&');
  for(var i in pairs) {
    var pair = pairs[i].split('=');
    // Ignore the 'q' path argument, if present.
    if (pair[0] != 'q' && pair[1]) {
      args[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
    }
  }
  return args;
};

/**
 * Helper function to return a view's arguments based on a path.
 */
Drupal.Views.parseViewArgs = function (href, viewPath) {
  var returnObj = {};
  var path = Drupal.Views.getPath(href);
  // Ensure we have a correct path.
  if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
    var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
    returnObj.view_args = args;
    returnObj.view_path = path;
  }
  return returnObj;
};

/**
 * Strip off the protocol plus domain from an href.
 */
Drupal.Views.pathPortion = function (href) {
  // Remove e.g. http://example.com if present.
  var protocol = window.location.protocol;
  if (href.substring(0, protocol.length) == protocol) {
    // 2 is the length of the '//' that normally follows the protocol
    href = href.substring(href.indexOf('/', protocol.length + 2));
  }
  return href;
};

/**
 * Return the Drupal path portion of an href.
 */
Drupal.Views.getPath = function (href) {
  href = Drupal.Views.pathPortion(href);
  href = href.substring(Drupal.settings.basePath.length, href.length);
  // 3 is the length of the '?q=' added to the url without clean urls.
  if (href.substring(0, 3) == '?q=') {
    href = href.substring(3, href.length);
  }
  var chars = ['#', '?', '&'];
  for (i in chars) {
    if (href.indexOf(chars[i]) > -1) {
      href = href.substr(0, href.indexOf(chars[i]));
    }
  }
  return href;
};
;
// $Id: dependent.js,v 1.9.2.1 2009/11/18 02:43:47 merlinofchaos Exp $
/**
 * @file dependent.js
 *
 * Written by dmitrig01 (Dmitri Gaskin) for Views; this provides dependent
 * visibility for form items in Views' ajax forms.
 *
 * To your $form item definition add:
 * - '#process' => array('views_process_dependency'),
 * - Add '#dependency' => array('id-of-form-item' => array(list, of, values, that,
     make, this, item, show),
 *
 * Special considerations:
 * - radios are harder. Because Drupal doesn't give radio groups individual ids,
 *   use 'radio:name-of-radio'
 *
 * - Checkboxes don't have their own id, so you need to add one in a div
 *   around the checkboxes via #prefix and #suffix. You actually need to add TWO
 *   divs because it's the parent that gets hidden. Also be sure to retain the
 *   'expand_checkboxes' in the #process array, because the views process will
 *   override it.
 */

Drupal.Views = Drupal.Views || {};

Drupal.Views.dependent = { bindings: {}, activeBindings: {}, activeTriggers: [] };

Drupal.Views.dependent.inArray = function(array, search_term) {
  var i = array.length;
  if (i > 0) {
   do {
    if (array[i] == search_term) {
       return true;
    }
   } while (i--);
  }
  return false;
}


Drupal.Views.dependent.autoAttach = function() {
  // Clear active bindings and triggers.
  for (i in Drupal.Views.dependent.activeTriggers) {
    jQuery(Drupal.Views.dependent.activeTriggers[i]).unbind('change');
  }
  Drupal.Views.dependent.activeTriggers = [];
  Drupal.Views.dependent.activeBindings = {};
  Drupal.Views.dependent.bindings = {};

  if (!Drupal.settings.viewsAjax) {
    return;
  }

  // Iterate through all relationships
  for (id in Drupal.settings.viewsAjax.formRelationships) {

    // Drupal.Views.dependent.activeBindings[id] is a boolean,
    // whether the binding is active or not.  Defaults to no.
    Drupal.Views.dependent.activeBindings[id] = 0;
    // Iterate through all possible values
    for(bind_id in Drupal.settings.viewsAjax.formRelationships[id].values) {
      // This creates a backward relationship.  The bind_id is the ID
      // of the element which needs to change in order for the id to hide or become shown.
      // The id is the ID of the item which will be conditionally hidden or shown.
      // Here we're setting the bindings for the bind
      // id to be an empty array if it doesn't already have bindings to it
      if (!Drupal.Views.dependent.bindings[bind_id]) {
        Drupal.Views.dependent.bindings[bind_id] = [];
      }
      // Add this ID
      Drupal.Views.dependent.bindings[bind_id].push(id);
      // Big long if statement.
      // Drupal.settings.viewsAjax.formRelationships[id].values[bind_id] holds the possible values

      if (bind_id.substring(0, 6) == 'radio:') {
        var trigger_id = "input[name='" + bind_id.substring(6) + "']";
      }
      else {
        var trigger_id = '#' + bind_id;
      }

      Drupal.Views.dependent.activeTriggers.push(trigger_id);

      if (jQuery(trigger_id).attr('type') == 'checkbox') {
        $(trigger_id).parent().addClass('hidden-options');
      }

      var getValue = function(item, trigger) {
        if (item.substring(0, 6) == 'radio:') {
          var val = jQuery(trigger + ':checked').val();
        }
        else {
          switch (jQuery(trigger).attr('type')) {
            case 'checkbox':
              var val = jQuery(trigger).attr('checked') || 0;

              if (val) {
                $(trigger).parent().removeClass('hidden-options').addClass('expanded-options');
              }
              else {
                $(trigger).parent().removeClass('expanded-options').addClass('hidden-options');
              }

              break;
            default:
              var val = jQuery(trigger).val();
          }
        }
        return val;
      }

      var setChangeTrigger = function(trigger_id, bind_id) {
        // Triggered when change() is clicked.
        var changeTrigger = function() {
          var val = getValue(bind_id, trigger_id);

          for (i in Drupal.Views.dependent.bindings[bind_id]) {
            var id = Drupal.Views.dependent.bindings[bind_id][i];

            // Fix numerous errors
            if (typeof id != 'string') {
              continue;
            }

            // This bit had to be rewritten a bit because two properties on the
            // same set caused the counter to go up and up and up.
            if (!Drupal.Views.dependent.activeBindings[id]) {
              Drupal.Views.dependent.activeBindings[id] = {};
            }

            if (Drupal.Views.dependent.inArray(Drupal.settings.viewsAjax.formRelationships[id].values[bind_id], val)) {
              Drupal.Views.dependent.activeBindings[id][bind_id] = 'bind';
            }
            else {
              delete Drupal.Views.dependent.activeBindings[id][bind_id];
            }

            var len = 0;
            for (i in Drupal.Views.dependent.activeBindings[id]) {
              len++;
            }

            var object = jQuery('#' + id + '-wrapper');
            if (!object.size()) {
              object = jQuery('#' + id).parent();
            }

            var rel_num = Drupal.settings.viewsAjax.formRelationships[id].num;
            if (typeof rel_num === 'object') {
              rel_num = Drupal.settings.viewsAjax.formRelationships[id].num[0];
            }

            if (rel_num <= len) {
              // Show if the element if criteria is matched
              object.show(0);
              object.addClass('dependent-options');
            }
            else {
              // Otherwise hide
              object.hide(0);
            }
          }
        }

        jQuery(trigger_id).change(function() {
          // Trigger the internal change function
          // the attr('id') is used because closures are more confusing
          changeTrigger(trigger_id, bind_id);
        });
        // Trigger initial reaction
        changeTrigger(trigger_id, bind_id);
      }
      setChangeTrigger(trigger_id, bind_id);
    }
  }
}

Drupal.behaviors.viewsDependent = function (context) {
  Drupal.Views.dependent.autoAttach();

  // Really large sets of fields are too slow with the above method, so this
  // is a sort of hacked one that's faster but much less flexible.
  $("select.views-master-dependent:not(.views-processed)")
    .addClass('views-processed')
    .change(function() {
      var val = $(this).val();
      if (val == 'all') {
        $('.views-dependent-all').show(0);
      }
      else {
        $('.views-dependent-all').hide(0);
        $('.views-dependent-' + val).show(0);
      }
    })
    .trigger('change');
}
;

var mejs=mejs||{};mejs.version='2.4.2';mejs.meIndex=0;mejs.plugins={flash:[{version:[9,0,124],types:['video/mp4','video/m4v','video/mov','video/flv','video/x-flv','audio/flv','audio/x-flv','audio/mp3','audio/m4a','audio/mpeg']}]};mejs.Utility={encodeUrl:function(url){return encodeURIComponent(url);},escapeHTML:function(s){return s.toString().split('&').join('&amp;').split('<').join('&lt;').split('"').join('&quot;');},absolutizeUrl:function(url){var el=document.createElement('div');el.innerHTML='<a href="'+this.escapeHTML(url)+'">x</a>';return el.firstChild.href;},getScriptPath:function(scriptNames){var
i=0,j,path='',name='',script,scripts=document.getElementsByTagName('script');for(;i<scripts.length;i++){script=scripts[i].src;for(j=0;j<scriptNames.length;j++){name=scriptNames[j];if(script.indexOf(name)>-1){path=script.substring(0,script.indexOf(name));break;}}
if(path!==''){break;}}
return path;},secondsToTimeCode:function(time,forceHours,showFrameCount,fps){if(typeof showFrameCount=='undefined'){showFrameCount=false;}else if(typeof fps=='undefined'){fps=25;}
var hours=Math.floor(time/3600)%24,minutes=Math.floor(time/60)%60,seconds=Math.floor(time%60),frames=Math.floor(((time%1)*fps).toFixed(3)),result=((forceHours||hours>0)?(hours<10?'0'+hours:hours)+':':'')
+(minutes<10?'0'+minutes:minutes)+':'+(seconds<10?'0'+seconds:seconds)
+((showFrameCount)?':'+(frames<10?'0'+frames:frames):'');return result;},timeCodeToSeconds:function(hh_mm_ss_ff,forceHours,showFrameCount,fps){if(typeof showFrameCount=='undefined'){showFrameCount=false;}else if(typeof fps=='undefined'){fps=25;}
var tc_array=hh_mm_ss_ff.split(":"),tc_hh=parseInt(tc_array[0],10),tc_mm=parseInt(tc_array[1],10),tc_ss=parseInt(tc_array[2],10),tc_ff=0,tc_in_seconds=0;if(showFrameCount){tc_ff=parseInt(tc_array[3],10)/fps;}
tc_in_seconds=(tc_hh*3600)+(tc_mm*60)+tc_ss+tc_ff;return tc_in_seconds;},removeSwf:function(id){var obj=document.getElementById(id);if(obj&&obj.nodeName=="OBJECT"){if(mejs.MediaFeatures.isIE){obj.style.display="none";(function(){if(obj.readyState==4){mejs.Utility.removeObjectInIE(id);}else{setTimeout(arguments.callee,10);}})();}else{obj.parentNode.removeChild(obj);}}},removeObjectInIE:function(id){var obj=document.getElementById(id);if(obj){for(var i in obj){if(typeof obj[i]=="function"){obj[i]=null;}}
obj.parentNode.removeChild(obj);}}};mejs.PluginDetector={hasPluginVersion:function(plugin,v){var pv=this.plugins[plugin];v[1]=v[1]||0;v[2]=v[2]||0;return(pv[0]>v[0]||(pv[0]==v[0]&&pv[1]>v[1])||(pv[0]==v[0]&&pv[1]==v[1]&&pv[2]>=v[2]))?true:false;},nav:window.navigator,ua:window.navigator.userAgent.toLowerCase(),plugins:[],addPlugin:function(p,pluginName,mimeType,activeX,axDetect){this.plugins[p]=this.detectPlugin(pluginName,mimeType,activeX,axDetect);},detectPlugin:function(pluginName,mimeType,activeX,axDetect){var version=[0,0,0],description,i,ax;if(typeof(this.nav.plugins)!='undefined'&&typeof this.nav.plugins[pluginName]=='object'){description=this.nav.plugins[pluginName].description;if(description&&!(typeof this.nav.mimeTypes!='undefined'&&this.nav.mimeTypes[mimeType]&&!this.nav.mimeTypes[mimeType].enabledPlugin)){version=description.replace(pluginName,'').replace(/^\s+/,'').replace(/\sr/gi,'.').split('.');for(i=0;i<version.length;i++){version[i]=parseInt(version[i].match(/\d+/),10);}}}else if(typeof(window.ActiveXObject)!='undefined'){try{ax=new ActiveXObject(activeX);if(ax){version=axDetect(ax);}}
catch(e){}}
return version;}};mejs.PluginDetector.addPlugin('flash','Shockwave Flash','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash',function(ax){var version=[],d=ax.GetVariable("$version");if(d){d=d.split(" ")[1].split(",");version=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10)];}
return version;});mejs.PluginDetector.addPlugin('silverlight','Silverlight Plug-In','application/x-silverlight-2','AgControl.AgControl',function(ax){var v=[0,0,0,0],loopMatch=function(ax,v,i,n){while(ax.isVersionSupported(v[0]+"."+v[1]+"."+v[2]+"."+v[3])){v[i]+=n;}
v[i]-=n;};loopMatch(ax,v,0,1);loopMatch(ax,v,1,1);loopMatch(ax,v,2,10000);loopMatch(ax,v,2,1000);loopMatch(ax,v,2,100);loopMatch(ax,v,2,10);loopMatch(ax,v,2,1);loopMatch(ax,v,3,1);return v;});mejs.MediaFeatures={init:function(){var
t=this,d=document,nav=mejs.PluginDetector.nav,ua=mejs.PluginDetector.ua.toLowerCase(),i,v,html5Elements=['source','track','audio','video'];t.isiPad=(ua.match(/ipad/i)!==null);t.isiPhone=(ua.match(/iphone/i)!==null);t.isiOS=t.isiPhone||t.isiPad;t.isAndroid=(ua.match(/android/i)!==null);t.isBustedAndroid=(ua.match(/android 2\.[12]/)!==null);t.isIE=(nav.appName.toLowerCase().indexOf("microsoft")!=-1);t.isChrome=(ua.match(/chrome/gi)!==null);t.isFirefox=(ua.match(/firefox/gi)!==null);t.isWebkit=(ua.match(/webkit/gi)!==null);t.isGecko=(ua.match(/gecko/gi)!==null)&&!t.isWebkit;t.hasTouch=('ontouchstart'in window);for(i=0;i<html5Elements.length;i++){v=document.createElement(html5Elements[i]);}
t.supportsMediaTag=(typeof v.canPlayType!=='undefined'||t.isBustedAndroid);t.hasSemiNativeFullScreen=(typeof v.webkitEnterFullscreen!=='undefined');t.hasWebkitNativeFullScreen=(typeof v.webkitRequestFullScreen!=='undefined');t.hasMozNativeFullScreen=(typeof v.mozRequestFullScreen!=='undefined');t.hasTrueNativeFullScreen=(t.hasWebkitNativeFullScreen||t.hasMozNativeFullScreen);t.nativeFullScreenEnabled=t.hasTrueNativeFullScreen;if(t.hasMozNativeFullScreen){t.nativeFullScreenEnabled=v.mozFullScreenEnabled;}
if(this.isChrome){t.hasSemiNativeFullScreen=false;}
if(t.hasTrueNativeFullScreen){t.fullScreenEventName=(t.hasWebkitNativeFullScreen)?'webkitfullscreenchange':'mozfullscreenchange';t.isFullScreen=function(){if(v.mozRequestFullScreen){return d.mozFullScreen;}else if(v.webkitRequestFullScreen){return d.webkitIsFullScreen;}};t.requestFullScreen=function(el){if(t.hasWebkitNativeFullScreen){el.webkitRequestFullScreen();}else if(t.hasMozNativeFullScreen){el.mozRequestFullScreen();}};t.cancelFullScreen=function(){if(t.hasWebkitNativeFullScreen){document.webkitCancelFullScreen();}else if(t.hasMozNativeFullScreen){document.mozCancelFullScreen();}};}
if(t.hasSemiNativeFullScreen&&ua.match(/mac os x 10_5/i)){t.hasNativeFullScreen=false;t.hasSemiNativeFullScreen=false;}}};mejs.MediaFeatures.init();mejs.HtmlMediaElement={pluginType:'native',isFullScreen:false,setCurrentTime:function(time){this.currentTime=time;},setMuted:function(muted){this.muted=muted;},setVolume:function(volume){this.volume=volume;},stop:function(){this.pause();},setSrc:function(url){var
existingSources=this.getElementsByTagName('source');while(existingSources.length>0){this.removeChild(existingSources[0]);}
if(typeof url=='string'){this.src=url;}else{var i,media;for(i=0;i<url.length;i++){media=url[i];if(this.canPlayType(media.type)){this.src=media.src;}}}},setVideoSize:function(width,height){this.width=width;this.height=height;}};mejs.PluginMediaElement=function(pluginid,pluginType,mediaUrl){this.id=pluginid;this.pluginType=pluginType;this.src=mediaUrl;this.events={};};mejs.PluginMediaElement.prototype={pluginElement:null,pluginType:'',isFullScreen:false,playbackRate:-1,defaultPlaybackRate:-1,seekable:[],played:[],paused:true,ended:false,seeking:false,duration:0,error:null,muted:false,volume:1,currentTime:0,play:function(){if(this.pluginApi!=null){if(this.pluginType=='youtube'){this.pluginApi.playVideo();}else{this.pluginApi.playMedia();}
this.paused=false;}},load:function(){if(this.pluginApi!=null){if(this.pluginType=='youtube'){}else{this.pluginApi.loadMedia();}
this.paused=false;}},pause:function(){if(this.pluginApi!=null){if(this.pluginType=='youtube'){this.pluginApi.pauseVideo();}else{this.pluginApi.pauseMedia();}
this.paused=true;}},stop:function(){if(this.pluginApi!=null){if(this.pluginType=='youtube'){this.pluginApi.stopVideo();}else{this.pluginApi.stopMedia();}
this.paused=true;}},canPlayType:function(type){var i,j,pluginInfo,pluginVersions=mejs.plugins[this.pluginType];for(i=0;i<pluginVersions.length;i++){pluginInfo=pluginVersions[i];if(mejs.PluginDetector.hasPluginVersion(this.pluginType,pluginInfo.version)){for(j=0;j<pluginInfo.types.length;j++){if(type==pluginInfo.types[j]){return true;}}}}
return false;},setSrc:function(url){if(typeof url=='string'){this.pluginApi.setSrc(mejs.Utility.absolutizeUrl(url));this.src=mejs.Utility.absolutizeUrl(url);}else{var i,media;for(i=0;i<url.length;i++){media=url[i];if(this.canPlayType(media.type)){this.pluginApi.setSrc(mejs.Utility.absolutizeUrl(media.src));this.src=mejs.Utility.absolutizeUrl(url);}}}},setCurrentTime:function(time){if(this.pluginApi!=null){if(this.pluginType=='youtube'){this.pluginApi.seekTo(time);}else{this.pluginApi.setCurrentTime(time);}
this.currentTime=time;}},setVolume:function(volume){if(this.pluginApi!=null){if(this.pluginType=='youtube'){this.pluginApi.setVolume(volume*100);}else{this.pluginApi.setVolume(volume);}
this.volume=volume;}},setMuted:function(muted){if(this.pluginApi!=null){if(this.pluginType=='youtube'){if(muted){this.pluginApi.mute();}else{this.pluginApi.unMute();}
this.muted=muted;this.dispatchEvent('volumechange');}else{this.pluginApi.setMuted(muted);}
this.muted=muted;}},setVideoSize:function(width,height){if(this.pluginElement.style){this.pluginElement.style.width=width+'px';this.pluginElement.style.height=height+'px';}
if(this.pluginApi!=null&&this.pluginApi.setVideoSize){this.pluginApi.setVideoSize(width,height);}},setFullscreen:function(fullscreen){if(this.pluginApi!=null&&this.pluginApi.setFullscreen){this.pluginApi.setFullscreen(fullscreen);}},enterFullScreen:function(){if(this.pluginApi!=null&&this.pluginApi.setFullscreen){this.setFullscreen(true);}},exitFullScreen:function(){if(this.pluginApi!=null&&this.pluginApi.setFullscreen){this.setFullscreen(false);}},addEventListener:function(eventName,callback,bubble){this.events[eventName]=this.events[eventName]||[];this.events[eventName].push(callback);},removeEventListener:function(eventName,callback){if(!eventName){this.events={};return true;}
var callbacks=this.events[eventName];if(!callbacks)return true;if(!callback){this.events[eventName]=[];return true;}
for(i=0;i<callbacks.length;i++){if(callbacks[i]===callback){this.events[eventName].splice(i,1);return true;}}
return false;},dispatchEvent:function(eventName){var i,args,callbacks=this.events[eventName];if(callbacks){args=Array.prototype.slice.call(arguments,1);for(i=0;i<callbacks.length;i++){callbacks[i].apply(null,args);}}},remove:function(){mejs.Utility.removeSwf(this.pluginElement.id);}};mejs.MediaPluginBridge={pluginMediaElements:{},htmlMediaElements:{},registerPluginElement:function(id,pluginMediaElement,htmlMediaElement){this.pluginMediaElements[id]=pluginMediaElement;this.htmlMediaElements[id]=htmlMediaElement;},initPlugin:function(id){var pluginMediaElement=this.pluginMediaElements[id],htmlMediaElement=this.htmlMediaElements[id];if(pluginMediaElement){switch(pluginMediaElement.pluginType){case"flash":pluginMediaElement.pluginElement=pluginMediaElement.pluginApi=document.getElementById(id);break;case"silverlight":pluginMediaElement.pluginElement=document.getElementById(pluginMediaElement.id);pluginMediaElement.pluginApi=pluginMediaElement.pluginElement.Content.MediaElementJS;break;}
if(pluginMediaElement.pluginApi!=null&&pluginMediaElement.success){pluginMediaElement.success(pluginMediaElement,htmlMediaElement);}}},fireEvent:function(id,eventName,values){var
e,i,bufferedTime,pluginMediaElement=this.pluginMediaElements[id];pluginMediaElement.ended=false;pluginMediaElement.paused=true;e={type:eventName,target:pluginMediaElement};for(i in values){pluginMediaElement[i]=values[i];e[i]=values[i];}
bufferedTime=values.bufferedTime||0;e.target.buffered=e.buffered={start:function(index){return 0;},end:function(index){return bufferedTime;},length:1};pluginMediaElement.dispatchEvent(e.type,e);}};mejs.MediaElementDefaults={mode:'auto',plugins:['flash'],enablePluginDebug:false,type:'',pluginPath:mejs.Utility.getScriptPath(['mediaelement.js','mediaelement.min.js','mediaelement-and-player.js','mediaelement-and-player.min.js']),flashName:'flashmediaelement.swf',enablePluginSmoothing:true,silverlightName:'silverlightmediaelement.xap',defaultVideoWidth:480,defaultVideoHeight:270,pluginWidth:-1,pluginHeight:-1,timerRate:250,startVolume:0.8,success:function(){},error:function(){}};mejs.MediaElement=function(el,o){return mejs.HtmlMediaElementShim.create(el,o);};mejs.HtmlMediaElementShim={create:function(el,o){var
options=mejs.MediaElementDefaults,htmlMediaElement=(typeof(el)=='string')?document.getElementById(el):el,tagName=htmlMediaElement.tagName.toLowerCase(),isMediaTag=(tagName==='audio'||tagName==='video'),src=(isMediaTag)?htmlMediaElement.getAttribute('src'):htmlMediaElement.getAttribute('href'),poster=htmlMediaElement.getAttribute('poster'),autoplay=htmlMediaElement.getAttribute('autoplay'),preload=htmlMediaElement.getAttribute('preload'),controls=htmlMediaElement.getAttribute('controls'),playback,prop;for(prop in o){options[prop]=o[prop];}
src=(typeof src=='undefined'||src===null||src=='')?null:src;poster=(typeof poster=='undefined'||poster===null)?'':poster;preload=(typeof preload=='undefined'||preload===null||preload==='false')?'none':preload;autoplay=!(typeof autoplay=='undefined'||autoplay===null||autoplay==='false');controls=!(typeof controls=='undefined'||controls===null||controls==='false');playback=this.determinePlayback(htmlMediaElement,options,mejs.MediaFeatures.supportsMediaTag,isMediaTag,src);playback.url=(playback.url!==null)?mejs.Utility.absolutizeUrl(playback.url):'';if(playback.method=='native'){if(mejs.MediaFeatures.isBustedAndroid){htmlMediaElement.src=playback.url;htmlMediaElement.addEventListener('click',function(){htmlMediaElement.play();},false);}
return this.updateNative(playback,options,autoplay,preload);}else if(playback.method!==''){return this.createPlugin(playback,options,poster,autoplay,preload,controls);}else{this.createErrorMessage(playback,options,poster);return this;}},determinePlayback:function(htmlMediaElement,options,supportsMediaTag,isMediaTag,src){var
mediaFiles=[],i,j,k,l,n,type,result={method:'',url:'',htmlMediaElement:htmlMediaElement,isVideo:(htmlMediaElement.tagName.toLowerCase()!='audio')},pluginName,pluginVersions,pluginInfo,dummy;if(typeof options.type!='undefined'&&options.type!==''){if(typeof options.type=='string'){mediaFiles.push({type:options.type,url:src});}else{for(i=0;i<options.type.length;i++){mediaFiles.push({type:options.type[i],url:src});}}}else if(src!==null){type=this.formatType(src,htmlMediaElement.getAttribute('type'));mediaFiles.push({type:type,url:src});}else{for(i=0;i<htmlMediaElement.childNodes.length;i++){n=htmlMediaElement.childNodes[i];if(n.nodeType==1&&n.tagName.toLowerCase()=='source'){src=n.getAttribute('src');type=this.formatType(src,n.getAttribute('type'));mediaFiles.push({type:type,url:src});}}}
if(!isMediaTag&&mediaFiles.length>0&&mediaFiles[0].url!==null&&this.getTypeFromFile(mediaFiles[0].url).indexOf('audio')>-1){result.isVideo=false;}
if(mejs.MediaFeatures.isBustedAndroid){htmlMediaElement.canPlayType=function(type){return(type.match(/video\/(mp4|m4v)/gi)!==null)?'maybe':'';};}
if(supportsMediaTag&&(options.mode==='auto'||options.mode==='native')){if(!isMediaTag){dummy=document.createElement(result.isVideo?'video':'audio');htmlMediaElement.parentNode.insertBefore(dummy,htmlMediaElement);htmlMediaElement.style.display='none';result.htmlMediaElement=htmlMediaElement=dummy;}
for(i=0;i<mediaFiles.length;i++){if(htmlMediaElement.canPlayType(mediaFiles[i].type).replace(/no/,'')!==''||htmlMediaElement.canPlayType(mediaFiles[i].type.replace(/mp3/,'mpeg')).replace(/no/,'')!==''){result.method='native';result.url=mediaFiles[i].url;break;}}
if(result.method==='native'){if(result.url!==null){htmlMediaElement.src=result.url;}
return result;}}
if(options.mode==='auto'||options.mode==='shim'){for(i=0;i<mediaFiles.length;i++){type=mediaFiles[i].type;for(j=0;j<options.plugins.length;j++){pluginName=options.plugins[j];pluginVersions=mejs.plugins[pluginName];for(k=0;k<pluginVersions.length;k++){pluginInfo=pluginVersions[k];if(pluginInfo.version==null||mejs.PluginDetector.hasPluginVersion(pluginName,pluginInfo.version)){for(l=0;l<pluginInfo.types.length;l++){if(type==pluginInfo.types[l]){result.method=pluginName;result.url=mediaFiles[i].url;return result;}}}}}}}
if(result.method===''&&mediaFiles.length>0){result.url=mediaFiles[0].url;}
return result;},formatType:function(url,type){var ext;if(url&&!type){return this.getTypeFromFile(url);}else{if(type&&~type.indexOf(';')){return type.substr(0,type.indexOf(';'));}else{return type;}}},getTypeFromFile:function(url){var ext=url.substring(url.lastIndexOf('.')+1);return(/(mp4|m4v|ogg|ogv|webm|flv|wmv|mpeg|mov)/gi.test(ext)?'video':'audio')+'/'+ext;},createErrorMessage:function(playback,options,poster){var
htmlMediaElement=playback.htmlMediaElement,errorContainer=document.createElement('div');errorContainer.className='me-cannotplay';try{errorContainer.style.width=htmlMediaElement.width+'px';errorContainer.style.height=htmlMediaElement.height+'px';}catch(e){}
errorContainer.innerHTML=(poster!=='')?'<a href="'+playback.url+'"><img src="'+poster+'" /></a>':'<a href="'+playback.url+'"><span>Download File</span></a>';htmlMediaElement.parentNode.insertBefore(errorContainer,htmlMediaElement);htmlMediaElement.style.display='none';options.error(htmlMediaElement);},createPlugin:function(playback,options,poster,autoplay,preload,controls){var
htmlMediaElement=playback.htmlMediaElement,width=1,height=1,pluginid='me_'+playback.method+'_'+(mejs.meIndex++),pluginMediaElement=new mejs.PluginMediaElement(pluginid,playback.method,playback.url),container=document.createElement('div'),specialIEContainer,node,initVars;node=htmlMediaElement.parentNode;while(node!==null&&node.tagName.toLowerCase()!='body'){if(node.parentNode.tagName.toLowerCase()=='p'){node.parentNode.parentNode.insertBefore(node,node.parentNode);break;}
node=node.parentNode;}
if(playback.isVideo){width=(options.videoWidth>0)?options.videoWidth:(htmlMediaElement.getAttribute('width')!==null)?htmlMediaElement.getAttribute('width'):options.defaultVideoWidth;height=(options.videoHeight>0)?options.videoHeight:(htmlMediaElement.getAttribute('height')!==null)?htmlMediaElement.getAttribute('height'):options.defaultVideoHeight;width=mejs.Utility.encodeUrl(width);height=mejs.Utility.encodeUrl(height);}else{if(options.enablePluginDebug){width=320;height=240;}}
pluginMediaElement.success=options.success;mejs.MediaPluginBridge.registerPluginElement(pluginid,pluginMediaElement,htmlMediaElement);container.className='me-plugin';container.id=pluginid+'_container';htmlMediaElement.parentNode.insertBefore(container,htmlMediaElement);initVars=['id='+pluginid,'isvideo='+((playback.isVideo)?"true":"false"),'autoplay='+((autoplay)?"true":"false"),'preload='+preload,'width='+width,'startvolume='+options.startVolume,'timerrate='+options.timerRate,'height='+height];if(playback.url!==null){if(playback.method=='flash'){initVars.push('file='+mejs.Utility.encodeUrl(playback.url));}else{initVars.push('file='+playback.url);}}
if(options.enablePluginDebug){initVars.push('debug=true');}
if(options.enablePluginSmoothing){initVars.push('smoothing=true');}
if(controls){initVars.push('controls=true');}
switch(playback.method){case'silverlight':container.innerHTML='<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" id="'+pluginid+'" name="'+pluginid+'" width="'+width+'" height="'+height+'">'+'<param name="initParams" value="'+initVars.join(',')+'" />'+'<param name="windowless" value="true" />'+'<param name="background" value="black" />'+'<param name="minRuntimeVersion" value="3.0.0.0" />'+'<param name="autoUpgrade" value="true" />'+'<param name="source" value="'+options.pluginPath+options.silverlightName+'" />'+'</object>';break;case'flash':if(mejs.MediaFeatures.isIE){specialIEContainer=document.createElement('div');container.appendChild(specialIEContainer);specialIEContainer.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" '+'id="'+pluginid+'" width="'+width+'" height="'+height+'">'+'<param name="movie" value="'+options.pluginPath+options.flashName+'?x='+(new Date())+'" />'+'<param name="flashvars" value="'+initVars.join('&amp;')+'" />'+'<param name="quality" value="high" />'+'<param name="bgcolor" value="#000000" />'+'<param name="wmode" value="transparent" />'+'<param name="allowScriptAccess" value="always" />'+'<param name="allowFullScreen" value="true" />'+'</object>';}else{container.innerHTML='<embed id="'+pluginid+'" name="'+pluginid+'" '+'play="true" '+'loop="false" '+'quality="high" '+'bgcolor="#000000" '+'wmode="transparent" '+'allowScriptAccess="always" '+'allowFullScreen="true" '+'type="application/x-shockwave-flash" pluginspage="//www.macromedia.com/go/getflashplayer" '+'src="'+options.pluginPath+options.flashName+'" '+'flashvars="'+initVars.join('&')+'" '+'width="'+width+'" '+'height="'+height+'"></embed>';}
break;case'youtube':var
videoId=playback.url.substr(playback.url.lastIndexOf('=')+1);youtubeSettings={container:container,containerId:container.id,pluginMediaElement:pluginMediaElement,pluginId:pluginid,videoId:videoId,height:height,width:width};if(mejs.PluginDetector.hasPluginVersion('flash',[10,0,0])){mejs.YouTubeApi.createFlash(youtubeSettings);}else{mejs.YouTubeApi.enqueueIframe(youtubeSettings);}
break;case'vimeo':pluginMediaElement.vimeoid=playback.url.substr(playback.url.lastIndexOf('/')+1);container.innerHTML='<object width="'+width+'" height="'+height+'">'+'<param name="allowfullscreen" value="true" />'+'<param name="allowscriptaccess" value="always" />'+'<param name="flashvars" value="api=1" />'+'<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+pluginMediaElement.vimeoid+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" />'+'<embed src="//vimeo.com/moogaloop.swf?api=1&amp;clip_id='+pluginMediaElement.vimeoid+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+width+'" height="'+height+'"></embed>'+'</object>';break;}
htmlMediaElement.style.display='none';return pluginMediaElement;},updateNative:function(playback,options,autoplay,preload){var htmlMediaElement=playback.htmlMediaElement,m;for(m in mejs.HtmlMediaElement){htmlMediaElement[m]=mejs.HtmlMediaElement[m];}
options.success(htmlMediaElement,htmlMediaElement);return htmlMediaElement;}};mejs.YouTubeApi={isIframeStarted:false,isIframeLoaded:false,loadIframeApi:function(){if(!this.isIframeStarted){var tag=document.createElement('script');tag.src="http://www.youtube.com/player_api";var firstScriptTag=document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);this.isIframeStarted=true;}},iframeQueue:[],enqueueIframe:function(yt){if(this.isLoaded){this.createIframe(yt);}else{this.loadIframeApi();this.iframeQueue.push(yt);}},createIframe:function(settings){var
pluginMediaElement=settings.pluginMediaElement,player=new YT.Player(settings.containerId,{height:settings.height,width:settings.width,videoId:settings.videoId,playerVars:{controls:0},events:{'onReady':function(){settings.pluginMediaElement.pluginApi=player;mejs.MediaPluginBridge.initPlugin(settings.pluginId);setInterval(function(){mejs.YouTubeApi.createEvent(player,pluginMediaElement,'timeupdate');},250);},'onStateChange':function(e){mejs.YouTubeApi.handleStateChange(e.data,player,pluginMediaElement);}}});},createEvent:function(player,pluginMediaElement,eventName){var obj={type:eventName,target:pluginMediaElement};if(player&&player.getDuration){pluginMediaElement.currentTime=obj.currentTime=player.getCurrentTime();pluginMediaElement.duration=obj.duration=player.getDuration();obj.paused=pluginMediaElement.paused;obj.ended=pluginMediaElement.ended;obj.muted=player.isMuted();obj.volume=player.getVolume()/100;obj.bytesTotal=player.getVideoBytesTotal();obj.bufferedBytes=player.getVideoBytesLoaded();var bufferedTime=obj.bufferedBytes/obj.bytesTotal*obj.duration;obj.target.buffered=obj.buffered={start:function(index){return 0;},end:function(index){return bufferedTime;},length:1};}
pluginMediaElement.dispatchEvent(obj.type,obj);},iFrameReady:function(){this.isIframeLoaded=true;while(this.iframeQueue.length>0){var settings=this.iframeQueue.pop();this.createIframe(settings);}},flashPlayers:{},createFlash:function(settings){this.flashPlayers[settings.pluginId]=settings;var specialIEContainer,youtubeUrl='http://www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid='+settings.pluginId+'&amp;version=3&amp;autoplay=0&amp;controls=0&amp;modestbranding=1&loop=0';if(mejs.MediaFeatures.isIE){specialIEContainer=document.createElement('div');settings.container.appendChild(specialIEContainer);specialIEContainer.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" '+'id="'+settings.pluginId+'" width="'+settings.width+'" height="'+settings.height+'">'+'<param name="movie" value="'+youtubeUrl+'" />'+'<param name="wmode" value="transparent" />'+'<param name="allowScriptAccess" value="always" />'+'<param name="allowFullScreen" value="true" />'+'</object>';}else{settings.container.innerHTML='<object type="application/x-shockwave-flash" id="'+settings.pluginId+'" data="'+youtubeUrl+'" '+'width="'+settings.width+'" height="'+settings.height+'" style="visibility: visible; ">'+'<param name="allowScriptAccess" value="always">'+'<param name="wmode" value="transparent">'+'</object>';}},flashReady:function(id){var
settings=this.flashPlayers[id],player=document.getElementById(id),pluginMediaElement=settings.pluginMediaElement;pluginMediaElement.pluginApi=pluginMediaElement.pluginElement=player;mejs.MediaPluginBridge.initPlugin(id);player.cueVideoById(settings.videoId);var callbackName=settings.containerId+'_callback';window[callbackName]=function(e){mejs.YouTubeApi.handleStateChange(e,player,pluginMediaElement);};player.addEventListener('onStateChange',callbackName);setInterval(function(){mejs.YouTubeApi.createEvent(player,pluginMediaElement,'timeupdate');},250);},handleStateChange:function(youTubeState,player,pluginMediaElement){switch(youTubeState){case-1:pluginMediaElement.paused=true;pluginMediaElement.ended=true;mejs.YouTubeApi.createEvent(player,pluginMediaElement,'loadedmetadata');break;case 0:pluginMediaElement.paused=false;pluginMediaElement.ended=true;mejs.YouTubeApi.createEvent(player,pluginMediaElement,'ended');break;case 1:pluginMediaElement.paused=false;pluginMediaElement.ended=false;mejs.YouTubeApi.createEvent(player,pluginMediaElement,'play');mejs.YouTubeApi.createEvent(player,pluginMediaElement,'playing');break;case 2:pluginMediaElement.paused=true;pluginMediaElement.ended=false;mejs.YouTubeApi.createEvent(player,pluginMediaElement,'pause');break;case 3:mejs.YouTubeApi.createEvent(player,pluginMediaElement,'progress');break;case 5:break;}}};function onYouTubePlayerAPIReady(){mejs.YouTubeApi.iFrameReady();}
function onYouTubePlayerReady(id){mejs.YouTubeApi.flashReady(id);}
window.mejs=mejs;window.MediaElement=mejs.MediaElement;;

if(typeof jQuery!='undefined'){mejs.$=jQuery;}else if(typeof ender!='undefined'){mejs.$=ender;}
(function($){mejs.MepDefaults={poster:'',defaultVideoWidth:480,defaultVideoHeight:270,videoWidth:-1,videoHeight:-1,defaultAudioWidth:400,defaultAudioHeight:30,audioWidth:-1,audioHeight:-1,startVolume:0.8,loop:false,enableAutosize:true,alwaysShowHours:false,showTimecodeFrameCount:false,framesPerSecond:24,autosizeProgress:true,alwaysShowControls:false,iPadUseNativeControls:false,iPhoneUseNativeControls:false,AndroidUseNativeControls:false,features:['playpause','current','progress','duration','tracks','volume','fullscreen'],isVideo:true,enableKeyboard:true,pauseOtherPlayers:true};mejs.mepIndex=0;mejs.players=[];mejs.MediaElementPlayer=function(node,o){if(!(this instanceof mejs.MediaElementPlayer)){return new mejs.MediaElementPlayer(node,o);}
var t=this;t.$media=t.$node=$(node);t.node=t.media=t.$media[0];if(typeof t.node.player!='undefined'){return t.node.player;}else{t.node.player=t;}
if(typeof o=='undefined'){o=t.$node.data('mejsoptions');}
t.options=$.extend({},mejs.MepDefaults,o);mejs.players.push(t);t.init();return t;};mejs.MediaElementPlayer.prototype={hasFocus:false,controlsAreVisible:true,init:function(){var
t=this,mf=mejs.MediaFeatures,meOptions=$.extend(true,{},t.options,{success:function(media,domNode){t.meReady(media,domNode);},error:function(e){t.handleError(e);}}),tagName=t.media.tagName.toLowerCase();t.isDynamic=(tagName!=='audio'&&tagName!=='video');if(t.isDynamic){t.isVideo=t.options.isVideo;}else{t.isVideo=(tagName!=='audio'&&t.options.isVideo);}
if((mf.isiPad&&t.options.iPadUseNativeControls)||(mf.isiPhone&&t.options.iPhoneUseNativeControls)){t.$media.attr('controls','controls');t.$media.removeAttr('poster');if(mf.isiPad&&t.media.getAttribute('autoplay')!==null){t.media.load();t.media.play();}}else if(mf.isAndroid&&t.AndroidUseNativeControls){}else{t.$media.removeAttr('controls');t.id='mep_'+mejs.mepIndex++;t.container=$('<div id="'+t.id+'" class="mejs-container">'+'<div class="mejs-inner">'+'<div class="mejs-mediaelement"></div>'+'<div class="mejs-layers"></div>'+'<div class="mejs-controls"></div>'+'<div class="mejs-clear"></div>'+'</div>'+'</div>').addClass(t.$media[0].className).insertBefore(t.$media);t.container.addClass((mf.isAndroid?'mejs-android ':'')+
(mf.isiOS?'mejs-ios ':'')+
(mf.isiPad?'mejs-ipad ':'')+
(mf.isiPhone?'mejs-iphone ':'')+
(t.isVideo?'mejs-video ':'mejs-audio '));if(mf.isiOS){var $newMedia=t.$media.clone();t.container.find('.mejs-mediaelement').append($newMedia);t.$media.remove();t.$node=t.$media=$newMedia;t.node=t.media=$newMedia[0];}else{t.container.find('.mejs-mediaelement').append(t.$media);}
t.controls=t.container.find('.mejs-controls');t.layers=t.container.find('.mejs-layers');var capsTagName=tagName.substring(0,1).toUpperCase()+tagName.substring(1);if(t.options[tagName+'Width']>0||t.options[tagName+'Width'].toString().indexOf('%')>-1){t.width=t.options[tagName+'Width'];}else if(t.media.style.width!==''&&t.media.style.width!==null){t.width=t.media.style.width;}else if(t.media.getAttribute('width')!==null){t.width=t.$media.attr('width');}else{t.width=t.options['default'+capsTagName+'Width'];}
if(t.options[tagName+'Height']>0||t.options[tagName+'Height'].toString().indexOf('%')>-1){t.height=t.options[tagName+'Height'];}else if(t.media.style.height!==''&&t.media.style.height!==null){t.height=t.media.style.height;}else if(t.$media[0].getAttribute('height')!==null){t.height=t.$media.attr('height');}else{t.height=t.options['default'+capsTagName+'Height'];}
t.setPlayerSize(t.width,t.height);meOptions.pluginWidth=t.height;meOptions.pluginHeight=t.width;}
mejs.MediaElement(t.$media[0],meOptions);},showControls:function(doAnimation){var t=this;doAnimation=typeof doAnimation=='undefined'||doAnimation;if(t.controlsAreVisible)
return;if(doAnimation){t.controls.css('visibility','visible').stop(true,true).fadeIn(200,function(){t.controlsAreVisible=true;});t.container.find('.mejs-control').css('visibility','visible').stop(true,true).fadeIn(200,function(){t.controlsAreVisible=true;});}else{t.controls.css('visibility','visible').css('display','block');t.container.find('.mejs-control').css('visibility','visible').css('display','block');t.controlsAreVisible=true;}
t.setControlsSize();},hideControls:function(doAnimation){var t=this;doAnimation=typeof doAnimation=='undefined'||doAnimation;if(!t.controlsAreVisible)
return;if(doAnimation){t.controls.stop(true,true).fadeOut(200,function(){$(this).css('visibility','hidden').css('display','block');t.controlsAreVisible=false;});t.container.find('.mejs-control').stop(true,true).fadeOut(200,function(){$(this).css('visibility','hidden').css('display','block');});}else{t.controls.css('visibility','hidden').css('display','block');t.container.find('.mejs-control').css('visibility','hidden').css('display','block');t.controlsAreVisible=false;}},controlsTimer:null,startControlsTimer:function(timeout){var t=this;timeout=typeof timeout!='undefined'?timeout:1500;t.killControlsTimer('start');t.controlsTimer=setTimeout(function(){t.hideControls();t.killControlsTimer('hide');},timeout);},killControlsTimer:function(src){var t=this;if(t.controlsTimer!==null){clearTimeout(t.controlsTimer);delete t.controlsTimer;t.controlsTimer=null;}},controlsEnabled:true,disableControls:function(){var t=this;t.killControlsTimer();t.hideControls(false);this.controlsEnabled=false;},enableControls:function(){var t=this;t.showControls(false);t.controlsEnabled=true;},meReady:function(media,domNode){var t=this,mf=mejs.MediaFeatures,autoplayAttr=domNode.getAttribute('autoplay'),autoplay=!(typeof autoplayAttr=='undefined'||autoplayAttr===null||autoplayAttr==='false'),featureIndex,feature;if(t.created)
return;else
t.created=true;t.media=media;t.domNode=domNode;if(!(mf.isAndroid&&t.options.AndroidUseNativeControls)&&!(mf.isiPad&&t.options.iPadUseNativeControls)&&!(mf.isiPhone&&t.options.iPhoneUseNativeControls)){t.buildposter(t,t.controls,t.layers,t.media);t.buildkeyboard(t,t.controls,t.layers,t.media);t.buildoverlays(t,t.controls,t.layers,t.media);t.findTracks();for(featureIndex in t.options.features){feature=t.options.features[featureIndex];if(t['build'+feature]){try{t['build'+feature](t,t.controls,t.layers,t.media);}catch(e){}}}
t.container.trigger('controlsready');t.setPlayerSize(t.width,t.height);t.setControlsSize();if(t.isVideo){if(mejs.MediaFeatures.hasTouch){t.$media.bind('touchstart',function(){if(t.controlsAreVisible){t.hideControls(false);}else{if(t.controlsEnabled){t.showControls(false);}}});}else{if(t.media.pluginType=='native'){t.$media.click(function(){if(media.paused){media.play();}else{media.pause();}});}else{$(t.media.pluginElement).click(function(){if(media.paused){media.play();}else{media.pause();}});}
t.container.bind('mouseenter mouseover',function(){if(t.controlsEnabled){if(!t.options.alwaysShowControls){t.killControlsTimer('enter');t.showControls();t.startControlsTimer(2500);}}}).bind('mousemove',function(){if(t.controlsEnabled){if(!t.controlsAreVisible){t.showControls();}
if(!t.options.alwaysShowControls){t.startControlsTimer(2500);}}}).bind('mouseleave',function(){if(t.controlsEnabled){if(!t.media.paused&&!t.options.alwaysShowControls){t.startControlsTimer(1000);}}});}
if(autoplay&&!t.options.alwaysShowControls){t.hideControls();}
if(t.options.enableAutosize){t.media.addEventListener('loadedmetadata',function(e){if(t.options.videoHeight<=0&&t.domNode.getAttribute('height')===null&&!isNaN(e.target.videoHeight)){t.setPlayerSize(e.target.videoWidth,e.target.videoHeight);t.setControlsSize();t.media.setVideoSize(e.target.videoWidth,e.target.videoHeight);}},false);}}
media.addEventListener('play',function(){for(var i=0,il=mejs.players.length;i<il;i++){var p=mejs.players[i];if(p.id!=t.id&&t.options.pauseOtherPlayers&&!p.paused&&!p.ended){p.pause();}
p.hasFocus=false;}
t.hasFocus=true;},false);t.media.addEventListener('ended',function(e){try{t.media.setCurrentTime(0);}catch(exp){}
t.media.pause();if(t.setProgressRail)
t.setProgressRail();if(t.setCurrentRail)
t.setCurrentRail();if(t.options.loop){t.media.play();}else if(!t.options.alwaysShowControls&&t.controlsEnabled){t.showControls();}},false);t.media.addEventListener('loadedmetadata',function(e){if(t.updateDuration){t.updateDuration();}
if(t.updateCurrent){t.updateCurrent();}
if(!t.isFullScreen){t.setPlayerSize(t.width,t.height);t.setControlsSize();}},false);setTimeout(function(){t.setPlayerSize(t.width,t.height);t.setControlsSize();},50);$(window).resize(function(){if(!(t.isFullScreen||(mejs.MediaFeatures.hasTrueNativeFullScreen&&document.webkitIsFullScreen))){t.setPlayerSize(t.width,t.height);}
t.setControlsSize();});if(t.media.pluginType=='youtube'){t.container.find('.mejs-overlay-play').hide();}}
if(autoplay&&media.pluginType=='native'){media.load();media.play();}
if(t.options.success){if(typeof t.options.success=='string'){window[t.options.success](t.media,t.domNode,t);}else{t.options.success(t.media,t.domNode,t);}}},handleError:function(e){var t=this;t.controls.hide();if(t.options.error){t.options.error(e);}},setPlayerSize:function(width,height){var t=this;if(t.height.toString().indexOf('%')>0){var
nativeWidth=(t.media.videoWidth&&t.media.videoWidth>0)?t.media.videoWidth:t.options.defaultVideoWidth,nativeHeight=(t.media.videoHeight&&t.media.videoHeight>0)?t.media.videoHeight:t.options.defaultVideoHeight,parentWidth=t.container.parent().width(),newHeight=parseInt(parentWidth*nativeHeight/nativeWidth,10);if(t.container.parent()[0].tagName.toLowerCase()==='body'){parentWidth=$(window).width();newHeight=$(window).height();}
t.container.width(parentWidth).height(newHeight);t.$media.width('100%').height('100%');t.container.find('object, embed, iframe').width('100%').height('100%');if(t.media.setVideoSize)
t.media.setVideoSize(parentWidth,newHeight);t.layers.children('.mejs-layer').width('100%').height('100%');}else{t.container.width(t.width).height(t.height);t.layers.children('.mejs-layer').width(t.width).height(t.height);}},setControlsSize:function(){var t=this,usedWidth=0,railWidth=0,rail=t.controls.find('.mejs-time-rail'),total=t.controls.find('.mejs-time-total'),current=t.controls.find('.mejs-time-current'),loaded=t.controls.find('.mejs-time-loaded');others=rail.siblings();if(t.options&&!t.options.autosizeProgress){railWidth=parseInt(rail.css('width'),10);}
if(railWidth===0||!railWidth){others.each(function(){if($(this).css('position')!='absolute'){usedWidth+=$(this).outerWidth(true);}});railWidth=t.controls.width()-usedWidth-(rail.outerWidth(true)-rail.outerWidth(false));}
rail.width(railWidth);total.width(railWidth-(total.outerWidth(true)-total.width()));if(t.setProgressRail)
t.setProgressRail();if(t.setCurrentRail)
t.setCurrentRail();},buildposter:function(player,controls,layers,media){var t=this,poster=$('<div class="mejs-poster mejs-layer">'+'</div>').appendTo(layers),posterUrl=player.$media.attr('poster');if(player.options.poster!==''){posterUrl=player.options.poster;}
if(posterUrl!==''&&posterUrl!=null){t.setPoster(posterUrl);}else{poster.hide();}
media.addEventListener('play',function(){poster.hide();},false);},setPoster:function(url){var t=this,posterDiv=t.container.find('.mejs-poster'),posterImg=posterDiv.find('img');if(posterImg.length==0){posterImg=$('<img width="100%" height="100%" />').appendTo(posterDiv);}
posterImg.attr('src',url);},buildoverlays:function(player,controls,layers,media){if(!player.isVideo)
return;var
loading=$('<div class="mejs-overlay mejs-layer">'+'<div class="mejs-overlay-loading"><span></span></div>'+'</div>').hide().appendTo(layers),error=$('<div class="mejs-overlay mejs-layer">'+'<div class="mejs-overlay-error"></div>'+'</div>').hide().appendTo(layers),bigPlay=$('<div class="mejs-overlay mejs-layer mejs-overlay-play">'+'<div class="mejs-overlay-button"></div>'+'</div>').appendTo(layers).click(function(){if(media.paused){media.play();}else{media.pause();}});media.addEventListener('play',function(){bigPlay.hide();loading.hide();error.hide();},false);media.addEventListener('playing',function(){bigPlay.hide();loading.hide();error.hide();},false);media.addEventListener('pause',function(){if(!mejs.MediaFeatures.isiPhone){bigPlay.show();}},false);media.addEventListener('waiting',function(){loading.show();},false);media.addEventListener('loadeddata',function(){loading.show();},false);media.addEventListener('canplay',function(){loading.hide();},false);media.addEventListener('error',function(){loading.hide();error.show();error.find('mejs-overlay-error').html("Error loading this resource");},false);},buildkeyboard:function(player,controls,layers,media){var t=this;$(document).keydown(function(e){if(player.hasFocus&&player.options.enableKeyboard){for(var i=0,il=player.options.keyActions.length;i<il;i++){var keyAction=player.options.keyActions[i];if(e.keyCode==keyAction.key){e.preventDefault();keyAction.action(player,media);return false;}}}
return true;});$(document).click(function(){if($(event.target).closest('.mejs-container').length==0){player.hasFocus=false;}});},findTracks:function(){var t=this,tracktags=t.$media.find('track');t.tracks=[];tracktags.each(function(){t.tracks.push({srclang:$(this).attr('srclang').toLowerCase(),src:$(this).attr('src'),kind:$(this).attr('kind'),entries:[],isLoaded:false});});},changeSkin:function(className){this.container[0].className='mejs-container '+className;this.setPlayerSize();this.setControlsSize();},play:function(){this.media.play();},pause:function(){this.media.pause();},load:function(){this.media.load();},setMuted:function(muted){this.media.setMuted(muted);},setCurrentTime:function(time){this.media.setCurrentTime(time);},getCurrentTime:function(){return this.media.currentTime;},setVolume:function(volume){this.media.setVolume(volume);},getVolume:function(){return this.media.volume;},setSrc:function(src){this.media.setSrc(src);},remove:function(){var t=this;if(t.media.pluginType=='flash'){t.media.remove();}else if(t.media.pluginTyp=='native'){t.media.prop('controls',true);};if(!t.isDynamic){t.$node.insertBefore(t.container);}
t.container.remove();}};if(typeof jQuery!='undefined'){jQuery.fn.mediaelementplayer=function(options){return this.each(function(){new mejs.MediaElementPlayer(this,options);});};}
$(document).ready(function(){$('.mejs-player').mediaelementplayer();});window.MediaElementPlayer=mejs.MediaElementPlayer;})(mejs.$);(function($){$.extend(mejs.MepDefaults,{playpauseText:'Play/Pause'});$.extend(MediaElementPlayer.prototype,{buildplaypause:function(player,controls,layers,media){var
t=this,play=$('<div class="mejs-button mejs-playpause-button mejs-play" >'+'<button type="button" aria-controls="'+t.id+'" title="'+t.options.playpauseText+'"></button>'+'</div>').appendTo(controls).click(function(e){e.preventDefault();if(media.paused){media.play();}else{media.pause();}
return false;});media.addEventListener('play',function(){play.removeClass('mejs-play').addClass('mejs-pause');},false);media.addEventListener('playing',function(){play.removeClass('mejs-play').addClass('mejs-pause');},false);media.addEventListener('pause',function(){play.removeClass('mejs-pause').addClass('mejs-play');},false);media.addEventListener('paused',function(){play.removeClass('mejs-pause').addClass('mejs-play');},false);}});})(mejs.$);(function($){$.extend(mejs.MepDefaults,{stopText:'Stop'});$.extend(MediaElementPlayer.prototype,{buildstop:function(player,controls,layers,media){var t=this,stop=$('<div class="mejs-button mejs-stop-button mejs-stop">'+'<button type="button" aria-controls="'+t.id+'" title="'+t.options.stopText+'></button>'+'</div>').appendTo(controls).click(function(){if(!media.paused){media.pause();}
if(media.currentTime>0){media.setCurrentTime(0);controls.find('.mejs-time-current').width('0px');controls.find('.mejs-time-handle').css('left','0px');controls.find('.mejs-time-float-current').html(mejs.Utility.secondsToTimeCode(0));controls.find('.mejs-currenttime').html(mejs.Utility.secondsToTimeCode(0));layers.find('.mejs-poster').show();}});}});})(mejs.$);(function($){$.extend(MediaElementPlayer.prototype,{buildprogress:function(player,controls,layers,media){$('<div class="mejs-time-rail">'+'<span class="mejs-time-total">'+'<span class="mejs-time-loaded"></span>'+'<span class="mejs-time-current"></span>'+'<span class="mejs-time-handle"></span>'+'<span class="mejs-time-float">'+'<span class="mejs-time-float-current">00:00</span>'+'<span class="mejs-time-float-corner"></span>'+'</span>'+'</span>'+'</div>').appendTo(controls);var
t=this,total=controls.find('.mejs-time-total'),loaded=controls.find('.mejs-time-loaded'),current=controls.find('.mejs-time-current'),handle=controls.find('.mejs-time-handle'),timefloat=controls.find('.mejs-time-float'),timefloatcurrent=controls.find('.mejs-time-float-current'),handleMouseMove=function(e){var x=e.pageX,offset=total.offset(),width=total.outerWidth(),percentage=0,newTime=0;if(x>offset.left&&x<=width+offset.left&&media.duration){percentage=((x-offset.left)/width);newTime=(percentage<=0.02)?0:percentage*media.duration;if(mouseIsDown){media.setCurrentTime(newTime);}
var pos=x-offset.left;timefloat.css('left',pos);timefloatcurrent.html(mejs.Utility.secondsToTimeCode(newTime));}},mouseIsDown=false,mouseIsOver=false;total.bind('mousedown',function(e){if(e.which===1){mouseIsDown=true;handleMouseMove(e);return false;}});controls.find('.mejs-time-total').bind('mouseenter',function(e){mouseIsOver=true;}).bind('mouseleave',function(e){mouseIsOver=false;});$(document).bind('mouseup',function(e){mouseIsDown=false;}).bind('mousemove',function(e){if(mouseIsDown||mouseIsOver){handleMouseMove(e);}});media.addEventListener('progress',function(e){player.setProgressRail(e);player.setCurrentRail(e);},false);media.addEventListener('timeupdate',function(e){player.setProgressRail(e);player.setCurrentRail(e);},false);t.loaded=loaded;t.total=total;t.current=current;t.handle=handle;},setProgressRail:function(e){var
t=this,target=(e!=undefined)?e.target:t.media,percent=null;if(target&&target.buffered&&target.buffered.length>0&&target.buffered.end&&target.duration){percent=target.buffered.end(0)/target.duration;}
else if(target&&target.bytesTotal!=undefined&&target.bytesTotal>0&&target.bufferedBytes!=undefined){percent=target.bufferedBytes/target.bytesTotal;}
else if(e&&e.lengthComputable&&e.total!=0){percent=e.loaded/e.total;}
if(percent!==null){percent=Math.min(1,Math.max(0,percent));if(t.loaded&&t.total){t.loaded.width(t.total.width()*percent);}}},setCurrentRail:function(){var t=this;if(t.media.currentTime!=undefined&&t.media.duration){if(t.total&&t.handle){var
newWidth=t.total.width()*t.media.currentTime/t.media.duration,handlePos=newWidth-(t.handle.outerWidth(true)/2);t.current.width(newWidth);t.handle.css('left',handlePos);}}}});})(mejs.$);(function($){$.extend(mejs.MepDefaults,{duration:-1});$.extend(MediaElementPlayer.prototype,{buildcurrent:function(player,controls,layers,media){var t=this;$('<div class="mejs-time">'+'<span class="mejs-currenttime">'+(player.options.alwaysShowHours?'00:':'')
+(player.options.showTimecodeFrameCount?'00:00:00':'00:00')+'</span>'+'</div>').appendTo(controls);t.currenttime=t.controls.find('.mejs-currenttime');media.addEventListener('timeupdate',function(){player.updateCurrent();},false);},buildduration:function(player,controls,layers,media){var t=this;if(controls.children().last().find('.mejs-currenttime').length>0){$(' <span> | </span> '+'<span class="mejs-duration">'+
(t.options.duration>0?mejs.Utility.secondsToTimeCode(t.options.duration,t.options.alwaysShowHours||t.media.duration>3600,t.options.showTimecodeFrameCount,t.options.framesPerSecond||25):((player.options.alwaysShowHours?'00:':'')+(player.options.showTimecodeFrameCount?'00:00:00':'00:00')))+'</span>').appendTo(controls.find('.mejs-time'));}else{controls.find('.mejs-currenttime').parent().addClass('mejs-currenttime-container');$('<div class="mejs-time mejs-duration-container">'+'<span class="mejs-duration">'+
(t.options.duration>0?mejs.Utility.secondsToTimeCode(t.options.duration,t.options.alwaysShowHours||t.media.duration>3600,t.options.showTimecodeFrameCount,t.options.framesPerSecond||25):((player.options.alwaysShowHours?'00:':'')+(player.options.showTimecodeFrameCount?'00:00:00':'00:00')))+'</span>'+'</div>').appendTo(controls);}
t.durationD=t.controls.find('.mejs-duration');media.addEventListener('timeupdate',function(){player.updateDuration();},false);},updateCurrent:function(){var t=this;if(t.currenttime){t.currenttime.html(mejs.Utility.secondsToTimeCode(t.media.currentTime,t.options.alwaysShowHours||t.media.duration>3600,t.options.showTimecodeFrameCount,t.options.framesPerSecond||25));}},updateDuration:function(){var t=this;if(t.media.duration&&t.durationD){t.durationD.html(mejs.Utility.secondsToTimeCode(t.media.duration,t.options.alwaysShowHours,t.options.showTimecodeFrameCount,t.options.framesPerSecond||25));}}});})(mejs.$);(function($){$.extend(mejs.MepDefaults,{muteText:'Mute Toggle',hideVolumeOnTouchDevices:true});$.extend(MediaElementPlayer.prototype,{buildvolume:function(player,controls,layers,media){if(mejs.MediaFeatures.hasTouch&&this.options.hideVolumeOnTouchDevices)
return;var t=this,mute=$('<div class="mejs-button mejs-volume-button mejs-mute">'+'<button type="button" aria-controls="'+t.id+'" title="'+t.options.muteText+'"></button>'+'<div class="mejs-volume-slider">'+'<div class="mejs-volume-total"></div>'+'<div class="mejs-volume-current"></div>'+'<div class="mejs-volume-handle"></div>'+'</div>'+'</div>').appendTo(controls),volumeSlider=mute.find('.mejs-volume-slider'),volumeTotal=mute.find('.mejs-volume-total'),volumeCurrent=mute.find('.mejs-volume-current'),volumeHandle=mute.find('.mejs-volume-handle'),positionVolumeHandle=function(volume){if(!volumeSlider.is(':visible')){volumeSlider.show();positionVolumeHandle(volume);volumeSlider.hide();return;}
var
totalHeight=volumeTotal.height(),totalPosition=volumeTotal.position(),newTop=totalHeight-(totalHeight*volume);volumeHandle.css('top',totalPosition.top+newTop-(volumeHandle.height()/2));volumeCurrent.height(totalHeight-newTop);volumeCurrent.css('top',totalPosition.top+newTop);},handleVolumeMove=function(e){var
railHeight=volumeTotal.height(),totalOffset=volumeTotal.offset(),totalTop=parseInt(volumeTotal.css('top').replace(/px/,''),10),newY=e.pageY-totalOffset.top,volume=(railHeight-newY)/railHeight;if(totalOffset.top==0)
return;volume=Math.max(0,volume);volume=Math.min(volume,1);if(newY<0)
newY=0;else if(newY>railHeight)
newY=railHeight;volumeHandle.css('top',newY-(volumeHandle.height()/2)+totalTop);volumeCurrent.height(railHeight-newY);volumeCurrent.css('top',newY+totalTop);if(volume==0){media.setMuted(true);mute.removeClass('mejs-mute').addClass('mejs-unmute');}else{media.setMuted(false);mute.removeClass('mejs-unmute').addClass('mejs-mute');}
volume=Math.max(0,volume);volume=Math.min(volume,1);media.setVolume(volume);},mouseIsDown=false;mute.hover(function(){volumeSlider.show();},function(){volumeSlider.hide();});volumeSlider.bind('mousedown',function(e){handleVolumeMove(e);mouseIsDown=true;return false;});$(document).bind('mouseup',function(e){mouseIsDown=false;}).bind('mousemove',function(e){if(mouseIsDown){handleVolumeMove(e);}});mute.find('button').click(function(){media.setMuted(!media.muted);});media.addEventListener('volumechange',function(e){if(!mouseIsDown){if(media.muted){positionVolumeHandle(0);mute.removeClass('mejs-mute').addClass('mejs-unmute');}else{positionVolumeHandle(media.volume);mute.removeClass('mejs-unmute').addClass('mejs-mute');}}},false);positionVolumeHandle(player.options.startVolume);if(media.pluginType==='native'){media.setVolume(player.options.startVolume);}}});})(mejs.$);(function($){$.extend(mejs.MepDefaults,{forcePluginFullScreen:false,newWindowCallback:function(){return'';},fullscreenText:'Fullscreen'});$.extend(MediaElementPlayer.prototype,{isFullScreen:false,isNativeFullScreen:false,docStyleOverflow:null,isInIframe:false,buildfullscreen:function(player,controls,layers,media){if(!player.isVideo)
return;player.isInIframe=(window.location!=window.parent.location);if(mejs.MediaFeatures.hasTrueNativeFullScreen){player.container.bind(mejs.MediaFeatures.fullScreenEventName,function(e){if(mejs.MediaFeatures.isFullScreen()){player.isNativeFullScreen=true;player.setControlsSize();}else{player.isNativeFullScreen=false;player.exitFullScreen();}});}
var t=this,normalHeight=0,normalWidth=0,container=player.container,fullscreenBtn=$('<div class="mejs-button mejs-fullscreen-button">'+'<button type="button" aria-controls="'+t.id+'" title="'+t.options.fullscreenText+'"></button>'+'</div>').appendTo(controls).click(function(){var isFullScreen=(mejs.MediaFeatures.hasTrueNativeFullScreen&&mejs.MediaFeatures.isFullScreen())||player.isFullScreen;if(isFullScreen){player.exitFullScreen();}else{player.enterFullScreen();}});player.fullscreenBtn=fullscreenBtn;$(document).bind('keydown',function(e){if(((mejs.MediaFeatures.hasTrueNativeFullScreen&&mejs.MediaFeatures.isFullScreen())||t.isFullScreen)&&e.keyCode==27){player.exitFullScreen();}});},enterFullScreen:function(){var t=this;if(t.media.pluginType!=='native'&&(mejs.MediaFeatures.isGecko||t.options.forcePluginFullScreen)){t.media.setFullscreen(true);return;}
docStyleOverflow=document.documentElement.style.overflow;document.documentElement.style.overflow='hidden';normalHeight=t.container.height();normalWidth=t.container.width();if(mejs.MediaFeatures.hasTrueNativeFullScreen){mejs.MediaFeatures.requestFullScreen(t.container[0]);}else if(mejs.MediaFeatures.hasSemiNativeFullScreen){t.media.webkitEnterFullscreen();return;}
if(t.isInIframe){var url=t.options.newWindowCallback(this);if(url!==''){if(!mejs.MediaFeatures.hasTrueNativeFullScreen){t.pause();window.open(url,t.id,'top=0,left=0,width='+screen.availWidth+',height='+screen.availHeight+',resizable=yes,scrollbars=no,status=no,toolbar=no');return;}else{setTimeout(function(){if(!t.isNativeFullScreen){t.pause();window.open(url,t.id,'top=0,left=0,width='+screen.availWidth+',height='+screen.availHeight+',resizable=yes,scrollbars=no,status=no,toolbar=no');}},250);}}}
t.container.addClass('mejs-container-fullscreen').width('100%').height('100%');if(mejs.MediaFeatures.hasTrueNativeFullScreen){setTimeout(function(){t.container.css({width:'100%',height:'100%'});},500);}
if(t.pluginType==='native'){t.$media.width('100%').height('100%');}else{t.container.find('object, embed, iframe').width('100%').height('100%');if(!mejs.MediaFeatures.hasTrueNativeFullScreen){t.media.setVideoSize($(window).width(),$(window).height());}}
t.layers.children('div').width('100%').height('100%');if(t.fullscreenBtn){t.fullscreenBtn.removeClass('mejs-fullscreen').addClass('mejs-unfullscreen');}
t.setControlsSize();t.isFullScreen=true;},exitFullScreen:function(){var t=this;if(t.media.pluginType!=='native'&&mejs.MediaFeatures.isFirefox){t.media.setFullscreen(false);return;}
if(mejs.MediaFeatures.hasTrueNativeFullScreen&&(mejs.MediaFeatures.isFullScreen()||t.isFullScreen)){mejs.MediaFeatures.cancelFullScreen();}
document.documentElement.style.overflow=docStyleOverflow;t.container.removeClass('mejs-container-fullscreen').width(normalWidth).height(normalHeight);if(t.pluginType==='native'){t.$media.width(normalWidth).height(normalHeight);}else{t.container.find('object embed').width(normalWidth).height(normalHeight);t.media.setVideoSize(normalWidth,normalHeight);}
t.layers.children('div').width(normalWidth).height(normalHeight);t.fullscreenBtn.removeClass('mejs-unfullscreen').addClass('mejs-fullscreen');t.setControlsSize();t.isFullScreen=false;}});})(mejs.$);(function($){$.extend(mejs.MepDefaults,{startLanguage:'',translations:[],translationSelector:false,googleApiKey:'',tracksText:'Captions/Subtitles'});$.extend(MediaElementPlayer.prototype,{hasChapters:false,buildtracks:function(player,controls,layers,media){if(!player.isVideo)
return;if(player.tracks.length==0)
return;var t=this,i,options='';player.chapters=$('<div class="mejs-chapters mejs-layer"></div>').prependTo(layers).hide();player.captions=$('<div class="mejs-captions-layer mejs-layer"><div class="mejs-captions-position"><span class="mejs-captions-text"></span></div></div>').prependTo(layers).hide();player.captionsText=player.captions.find('.mejs-captions-text');player.captionsButton=$('<div class="mejs-button mejs-captions-button">'+'<button type="button" aria-controls="'+t.id+'" title="'+t.options.tracksText+'"></button>'+'<div class="mejs-captions-selector">'+'<ul>'+'<li>'+'<input type="radio" name="'+player.id+'_captions" id="'+player.id+'_captions_none" value="none" checked="checked" />'+'<label for="'+player.id+'_captions_none">None</label>'+'</li>'+'</ul>'+'</div>'+'</div>').appendTo(controls).hover(function(){$(this).find('.mejs-captions-selector').css('visibility','visible');},function(){$(this).find('.mejs-captions-selector').css('visibility','hidden');}).delegate('input[type=radio]','click',function(){lang=this.value;if(lang=='none'){player.selectedTrack=null;}else{for(i=0;i<player.tracks.length;i++){if(player.tracks[i].srclang==lang){player.selectedTrack=player.tracks[i];player.captions.attr('lang',player.selectedTrack.srclang);player.displayCaptions();break;}}}});if(!player.options.alwaysShowControls){player.container.bind('mouseenter',function(){player.container.find('.mejs-captions-position').addClass('mejs-captions-position-hover');}).bind('mouseleave',function(){if(!media.paused){player.container.find('.mejs-captions-position').removeClass('mejs-captions-position-hover');}});}else{player.container.find('.mejs-captions-position').addClass('mejs-captions-position-hover');}
player.trackToLoad=-1;player.selectedTrack=null;player.isLoadingTrack=false;if(player.tracks.length>0&&player.options.translations.length>0){for(i=0;i<player.options.translations.length;i++){player.tracks.push({srclang:player.options.translations[i].toLowerCase(),src:null,kind:'subtitles',entries:[],isLoaded:false,isTranslation:true});}}
for(i=0;i<player.tracks.length;i++){if(player.tracks[i].kind=='subtitles'){player.addTrackButton(player.tracks[i].srclang,player.tracks[i].isTranslation);}}
player.loadNextTrack();media.addEventListener('timeupdate',function(e){player.displayCaptions();},false);media.addEventListener('loadedmetadata',function(e){player.displayChapters();},false);player.container.hover(function(){if(player.hasChapters){player.chapters.css('visibility','visible');player.chapters.fadeIn(200);}},function(){if(player.hasChapters&&!media.paused){player.chapters.fadeOut(200,function(){$(this).css('visibility','hidden');$(this).css('display','block');});}});if(player.node.getAttribute('autoplay')!==null){player.chapters.css('visibility','hidden');}
if(player.options.translationSelector){for(i in mejs.language.codes){options+='<option value="'+i+'">'+mejs.language.codes[i]+'</option>';}
player.container.find('.mejs-captions-selector ul').before($('<select class="mejs-captions-translations">'+'<option value="">--Add Translation--</option>'+
options+'</select>'));player.container.find('.mejs-captions-translations').change(function(){var
option=$(this);lang=option.val();if(lang!=''){player.tracks.push({srclang:lang,src:null,entries:[],isLoaded:false,isTranslation:true});if(!player.isLoadingTrack){player.trackToLoad--;player.addTrackButton(lang,true);player.options.startLanguage=lang;player.loadNextTrack();}}});}},loadNextTrack:function(){var t=this;t.trackToLoad++;if(t.trackToLoad<t.tracks.length){t.isLoadingTrack=true;t.loadTrack(t.trackToLoad);}else{t.isLoadingTrack=false;}},loadTrack:function(index){var
t=this,track=t.tracks[index],after=function(){track.isLoaded=true;t.enableTrackButton(track.srclang);t.loadNextTrack();};if(track.isTranslation){mejs.TrackFormatParser.translateTrackText(t.tracks[0].entries,t.tracks[0].srclang,track.srclang,t.options.googleApiKey,function(newOne){track.entries=newOne;after();});}else{$.ajax({url:track.src,success:function(d){track.entries=mejs.TrackFormatParser.parse(d);after();if(track.kind=='chapters'&&t.media.duration>0){t.drawChapters(track);}},error:function(){t.loadNextTrack();}});}},enableTrackButton:function(lang){var t=this;t.captionsButton.find('input[value='+lang+']').prop('disabled',false).siblings('label').html(mejs.language.codes[lang]||lang);if(t.options.startLanguage==lang){$('#'+t.id+'_captions_'+lang).click();}
t.adjustLanguageBox();},addTrackButton:function(lang,isTranslation){var t=this,l=mejs.language.codes[lang]||lang;t.captionsButton.find('ul').append($('<li>'+'<input type="radio" name="'+t.id+'_captions" id="'+t.id+'_captions_'+lang+'" value="'+lang+'" disabled="disabled" />'+'<label for="'+t.id+'_captions_'+lang+'">'+l+((isTranslation)?' (translating)':' (loading)')+'</label>'+'</li>'));t.adjustLanguageBox();t.container.find('.mejs-captions-translations option[value='+lang+']').remove();},adjustLanguageBox:function(){var t=this;t.captionsButton.find('.mejs-captions-selector').height(t.captionsButton.find('.mejs-captions-selector ul').outerHeight(true)+
t.captionsButton.find('.mejs-captions-translations').outerHeight(true));},displayCaptions:function(){if(typeof this.tracks=='undefined')
return;var
t=this,i,track=t.selectedTrack;if(track!=null&&track.isLoaded){for(i=0;i<track.entries.times.length;i++){if(t.media.currentTime>=track.entries.times[i].start&&t.media.currentTime<=track.entries.times[i].stop){t.captionsText.html(track.entries.text[i]);t.captions.show();return;}}
t.captions.hide();}else{t.captions.hide();}},displayChapters:function(){var
t=this,i;for(i=0;i<t.tracks.length;i++){if(t.tracks[i].kind=='chapters'&&t.tracks[i].isLoaded){t.drawChapters(t.tracks[i]);t.hasChapters=true;break;}}},drawChapters:function(chapters){var
t=this,i,dur,percent=0,usedPercent=0;t.chapters.empty();for(i=0;i<chapters.entries.times.length;i++){dur=chapters.entries.times[i].stop-chapters.entries.times[i].start;percent=Math.floor(dur/t.media.duration*100);if(percent+usedPercent>100||i==chapters.entries.times.length-1&&percent+usedPercent<100)
{percent=100-usedPercent;}
t.chapters.append($('<div class="mejs-chapter" rel="'+chapters.entries.times[i].start+'" style="left: '+usedPercent.toString()+'%;width: '+percent.toString()+'%;">'+'<div class="mejs-chapter-block'+((i==chapters.entries.times.length-1)?' mejs-chapter-block-last':'')+'">'+'<span class="ch-title">'+chapters.entries.text[i]+'</span>'+'<span class="ch-time">'+mejs.Utility.secondsToTimeCode(chapters.entries.times[i].start)+'&ndash;'+mejs.Utility.secondsToTimeCode(chapters.entries.times[i].stop)+'</span>'+'</div>'+'</div>'));usedPercent+=percent;}
t.chapters.find('div.mejs-chapter').click(function(){t.media.setCurrentTime(parseFloat($(this).attr('rel')));if(t.media.paused){t.media.play();}});t.chapters.show();}});mejs.language={codes:{af:'Afrikaans',sq:'Albanian',ar:'Arabic',be:'Belarusian',bg:'Bulgarian',ca:'Catalan',zh:'Chinese','zh-cn':'Chinese Simplified','zh-tw':'Chinese Traditional',hr:'Croatian',cs:'Czech',da:'Danish',nl:'Dutch',en:'English',et:'Estonian',tl:'Filipino',fi:'Finnish',fr:'French',gl:'Galician',de:'German',el:'Greek',ht:'Haitian Creole',iw:'Hebrew',hi:'Hindi',hu:'Hungarian',is:'Icelandic',id:'Indonesian',ga:'Irish',it:'Italian',ja:'Japanese',ko:'Korean',lv:'Latvian',lt:'Lithuanian',mk:'Macedonian',ms:'Malay',mt:'Maltese',no:'Norwegian',fa:'Persian',pl:'Polish',pt:'Portuguese',ro:'Romanian',ru:'Russian',sr:'Serbian',sk:'Slovak',sl:'Slovenian',es:'Spanish',sw:'Swahili',sv:'Swedish',tl:'Tagalog',th:'Thai',tr:'Turkish',uk:'Ukrainian',vi:'Vietnamese',cy:'Welsh',yi:'Yiddish'}};mejs.TrackFormatParser={pattern_identifier:/^([a-zA-z]+-)?[0-9]+$/,pattern_timecode:/^([0-9]{2}:[0-9]{2}:[0-9]{2}([,.][0-9]{1,3})?) --\> ([0-9]{2}:[0-9]{2}:[0-9]{2}([,.][0-9]{3})?)(.*)$/,split2:function(text,regex){return text.split(regex);},parse:function(trackText){var
i=0,lines=this.split2(trackText,/\r?\n/),entries={text:[],times:[]},timecode,text;for(;i<lines.length;i++){if(this.pattern_identifier.exec(lines[i])){i++;timecode=this.pattern_timecode.exec(lines[i]);if(timecode&&i<lines.length){i++;text=lines[i];i++;while(lines[i]!==''&&i<lines.length){text=text+'\n'+lines[i];i++;}
entries.text.push(text);entries.times.push({start:mejs.Utility.timeCodeToSeconds(timecode[1]),stop:mejs.Utility.timeCodeToSeconds(timecode[3]),settings:timecode[5]});}}}
return entries;},translateTrackText:function(trackData,fromLang,toLang,googleApiKey,callback){var
entries={text:[],times:[]},lines,i;this.translateText(trackData.text.join(' <a></a>'),fromLang,toLang,googleApiKey,function(result){lines=result.split('<a></a>');for(i=0;i<trackData.text.length;i++){entries.text[i]=lines[i];entries.times[i]={start:trackData.times[i].start,stop:trackData.times[i].stop,settings:trackData.times[i].settings};}
callback(entries);});},translateText:function(text,fromLang,toLang,googleApiKey,callback){var
separatorIndex,chunks=[],chunk,maxlength=1000,result='',nextChunk=function(){if(chunks.length>0){chunk=chunks.shift();mejs.TrackFormatParser.translateChunk(chunk,fromLang,toLang,googleApiKey,function(r){if(r!='undefined'){result+=r;}
nextChunk();});}else{callback(result);}};while(text.length>0){if(text.length>maxlength){separatorIndex=text.lastIndexOf('.',maxlength);chunks.push(text.substring(0,separatorIndex));text=text.substring(separatorIndex+1);}else{chunks.push(text);text='';}}
nextChunk();},translateChunk:function(text,fromLang,toLang,googleApiKey,callback){var data={q:text,langpair:fromLang+'|'+toLang,v:'1.0'};if(googleApiKey!==''&&googleApiKey!==null){data.key=googleApiKey;}
$.ajax({url:'https://ajax.googleapis.com/ajax/services/language/translate',data:data,type:'GET',dataType:'jsonp',success:function(d){callback((d.responseData!==null)?d.responseData.translatedText:'No translation');},error:function(e){callback(null);}});}};if('x\n\ny'.split(/\n/gi).length!=3){mejs.TrackFormatParser.split2=function(text,regex){var
parts=[],chunk='',i;for(i=0;i<text.length;i++){chunk+=text.substring(i,i+1);if(regex.test(chunk)){parts.push(chunk.replace(regex,''));chunk='';}}
parts.push(chunk);return parts;};}})(mejs.$);(function($){$.extend(mejs.MepDefaults,contextMenuItems=[{render:function(player){if(typeof player.enterFullScreen=='undefined')
return null;if(player.isFullScreen){return"Turn off Fullscreen";}else{return"Go Fullscreen";}},click:function(player){if(player.isFullScreen){player.exitFullScreen();}else{player.enterFullScreen();}}},{render:function(player){if(player.media.muted){return"Unmute";}else{return"Mute";}},click:function(player){if(player.media.muted){player.setMuted(false);}else{player.setMuted(true);}}},{isSeparator:true},{render:function(player){return"Download Video";},click:function(player){window.location.href=player.media.currentSrc;}}]);$.extend(MediaElementPlayer.prototype,{buildcontextmenu:function(player,controls,layers,media){player.contextMenu=$('<div class="mejs-contextmenu"></div>').appendTo($('body')).hide();player.container.bind('contextmenu',function(e){if(player.isContextMenuEnabled){e.preventDefault();player.renderContextMenu(e.clientX-1,e.clientY-1);return false;}});player.container.bind('click',function(){player.contextMenu.hide();});player.contextMenu.bind('mouseleave',function(){player.startContextMenuTimer();});},isContextMenuEnabled:true,enableContextMenu:function(){this.isContextMenuEnabled=true;},disableContextMenu:function(){this.isContextMenuEnabled=false;},contextMenuTimeout:null,startContextMenuTimer:function(){var t=this;t.killContextMenuTimer();t.contextMenuTimer=setTimeout(function(){t.hideContextMenu();t.killContextMenuTimer();},750);},killContextMenuTimer:function(){var timer=this.contextMenuTimer;if(timer!=null){clearTimeout(timer);delete timer;timer=null;}},hideContextMenu:function(){this.contextMenu.hide();},renderContextMenu:function(x,y){var t=this,html='',items=t.options.contextMenuItems;for(var i=0,il=items.length;i<il;i++){if(items[i].isSeparator){html+='<div class="mejs-contextmenu-separator"></div>';}else{var rendered=items[i].render(t);if(rendered!=null){html+='<div class="mejs-contextmenu-item" data-itemindex="'+i+'" id="element-'+(Math.random()*1000000)+'">'+rendered+'</div>';}}}
t.contextMenu.empty().append($(html)).css({top:y,left:x}).show();t.contextMenu.find('.mejs-contextmenu-item').each(function(){var $dom=$(this),itemIndex=parseInt($dom.data('itemindex'),10),item=t.options.contextMenuItems[itemIndex];if(typeof item.show!='undefined')
item.show($dom,t);$dom.click(function(){if(typeof item.click!='undefined')
item.click(t);t.contextMenu.hide();});});setTimeout(function(){t.killControlsTimer('rev3');},100);}});})(mejs.$);;
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};;
(function(F){var B,C,J,M,L,I,G,E,H,A,K;B=document.namespaces;has_canvas=!!document.createElement("canvas").getContext;if(!(has_canvas||B)){F.fn.maphilight=function(){return this};return }if(has_canvas){G=function(P,O,N){if(O<=1){P.style.opacity=O;window.setTimeout(G,10,P,O+0.1,10)}};E=function(N){return Math.max(0,Math.min(parseInt(N,16),255))};H=function(N,O){return"rgba("+E(N.substr(0,2))+","+E(N.substr(2,2))+","+E(N.substr(4,2))+","+O+")"};C=function(N){var O=F('<canvas style="width:'+N.width+"px;height:"+N.height+'px;"></canvas>').get(0);O.getContext("2d").clearRect(0,0,O.width,O.height);return O};J=function(Q,N,T,P,O){var S,R=Q.getContext("2d");R.beginPath();if(N=="rect"){R.rect(T[0],T[1],T[2]-T[0],T[3]-T[1])}else{if(N=="poly"){R.moveTo(T[0],T[1]);for(S=2;S<T.length;S+=2){R.lineTo(T[S],T[S+1])}}else{if(N=="circ"){R.arc(T[0],T[1],T[2],0,Math.PI*2,false)}}}R.closePath();if(P.fill){R.fillStyle=H(P.fillColor,P.fillOpacity);R.fill()}if(P.stroke){R.strokeStyle=H(P.strokeColor,P.strokeOpacity);R.lineWidth=P.strokeWidth;R.stroke()}if(P.fade){G(Q,0)}};M=function(N){N.getContext("2d").clearRect(0,0,N.width,N.height)}}else{C=function(N){return F('<var style="zoom:1;overflow:hidden;display:block;width:'+N.width+"px;height:"+N.height+'px;"></var>').get(0)};J=function(O,R,S,V,N){var T,U,P,Q;T='<v:fill color="#'+V.fillColor+'" opacity="'+(V.fill?V.fillOpacity:0)+'" />';U=(V.stroke?'strokeweight="'+V.strokeWidth+'" stroked="t" strokecolor="#'+V.strokeColor+'"':'stroked="f"');P='<v:stroke opacity="'+V.strokeOpacity+'"/>';if(R=="rect"){Q=F('<v:rect name="'+N+'" filled="t" '+U+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+S[0]+"px;top:"+S[1]+"px;width:"+(S[2]-S[0])+"px;height:"+(S[3]-S[1])+'px;"></v:rect>')}else{if(R=="poly"){Q=F('<v:shape name="'+N+'" filled="t" '+U+' coordorigin="0,0" coordsize="'+O.width+","+O.height+'" path="m '+S[0]+","+S[1]+" l "+S.join(",")+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+O.width+"px;height:"+O.height+'px;"></v:shape>')}else{if(R=="circ"){Q=F('<v:oval name="'+N+'" filled="t" '+U+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(S[0]-S[2])+"px;top:"+(S[1]-S[2])+"px;width:"+(S[2]*2)+"px;height:"+(S[2]*2)+'px;"></v:oval>')}}}Q.get(0).innerHTML=T+P;F(O).append(Q)};M=function(N){F(N).find("[name=highlighted]").remove()}}L=function(O){var N,P=O.getAttribute("coords").split(",");for(N=0;N<P.length;N++){P[N]=parseFloat(P[N])}return[O.getAttribute("shape").toLowerCase().substr(0,4),P]};K=function(P,O){var N=F(P);return F.extend({},O,F.metadata?N.metadata():false,N.data("maphilight"))};A=function(N){if(!N.complete){return false}if(typeof N.naturalWidth!="undefined"&&N.naturalWidth==0){return false}return true};I={position:"absolute",left:0,top:0,padding:0,border:0};var D=false;F.fn.maphilight=function(P){P=F.extend({},F.fn.maphilight.defaults,P);if(F.browser.msie&&!D){document.namespaces.add("v","urn:schemas-microsoft-com:vml");var O=document.createStyleSheet();var N=["shape","rect","oval","circ","fill","stroke","imagedata","group","textbox"];F.each(N,function(){O.addRule("v\\:"+this,"behavior: url(#default#VML); antialias:true")});D=true}return this.each(function(){var V,S,Z,R,U,W,Y,T,X;V=F(this);if(!A(this)){return window.setTimeout(function(){V.maphilight(P)},200)}Z=F.extend({},P,F.metadata?V.metadata():false,V.data("maphilight"));X=V.get(0).getAttribute("usemap");R=F('map[name="'+X.substr(1)+'"]');if(!(V.is("img")&&X&&R.size()>0)){return }if(V.hasClass("maphilighted")){var Q=V.parent();V.insertBefore(Q);Q.remove();F(R).unbind(".maphilight").find("area[coords]").unbind(".maphilight")}S=F("<div></div>").css({display:"block",background:"url("+this.src+")",position:"relative",padding:0,width:this.width,height:this.height});if(Z.wrapClass){if(Z.wrapClass===true){S.addClass(F(this).attr("class"))}else{S.addClass(Z.wrapClass)}}V.before(S).css("opacity",0).css(I).remove();if(F.browser.msie){V.css("filter","Alpha(opacity=0)")}S.append(V);U=C(this);F(U).css(I);U.height=this.height;U.width=this.width;Y=function(c){var a,b;b=K(this,Z);if(!b.neverOn&&!b.alwaysOn){a=L(this);J(U,a[0],a[1],b,"highlighted");if(b.groupBy&&F(this).attr(b.groupBy)){var d=this;R.find("area["+b.groupBy+"="+F(this).attr(b.groupBy)+"]").each(function(){if(this!=d){var f=K(this,Z);if(!f.neverOn&&!f.alwaysOn){var e=L(this);J(U,e[0],e[1],f,"highlighted")}}})}F(U).append("<v:rect></v:rect>")}};F(R).bind("alwaysOn.maphilight",function(){if(W){M(W)}if(!has_canvas){F(U).empty()}F(R).find("area[coords]").each(function(){var a,b;b=K(this,Z);if(b.alwaysOn){if(!W&&has_canvas){W=C(V.get());F(W).css(I);W.width=V.width();W.height=V.height();V.before(W)}a=L(this);if(has_canvas){J(W,a[0],a[1],b,"")}else{J(U,a[0],a[1],b,"")}}})});F(R).trigger("alwaysOn.maphilight").find("area[coords]").bind("mouseover.maphilight",Y).bind("mouseout.maphilight",function(a){M(U)});V.before(U);V.addClass("maphilighted")})};F.fn.maphilight.defaults={fill:true,fillColor:"000000",fillOpacity:0.2,stroke:true,strokeColor:"ff0000",strokeOpacity:1,strokeWidth:1,fade:true,alwaysOn:false,neverOn:false,groupBy:false,wrapClass:true}})(jQuery);;
jQuery.extend($.fn.disableTextSelect = function() {
    return this.each(function(){
        if($.browser.mozilla){//Firefox
            $(this).css('MozUserSelect','none');
        }else if($.browser.msie){//IE
            $(this).bind('selectstart',function(){return false;});
        }else{//Opera, etc.
            $(this).mousedown(function(){return false;});
        }
    });
});


/**
 * Adds a full-screen mode and switcher to a GMap
 */
// Add stuff to the map.
// This is based on other drupal gmap.module javascripts.
if (Drupal.gmap) {
	Drupal.gmap.addHandler('gmap', function(elem) {
	  var obj = this;
	  obj.bind('init', function() {
	    obj.map.addControl(new FullScreenControl());
	  });
	});			
}






var _interval;


jQuery(document).ready(function($) {

	// add blank target to any absolute links
	$('a[href^="http://"]').attr('target','_blank');
	var $body = $('body');
	
	if ($body.hasClass('node-type-route') || $body.hasClass('page-featured-route')) {
		_initPlayer();
		_initRoutePage();
	} else if ($body.hasClass('node-type-video')) {
		_initPlayer();
	}
	
	if ($body.hasClass('page-routes') || $body.hasClass('page-featured-route')) {
		//Drupal.tmber = {'updateView':function() {_initRoutesView};
		_initRoutesView();
	}
	
	if ($body.hasClass('section-shop') && $body.hasClass('page-node')) {
		_initProductPhotos();
	}
	
	_initRatingHover();	
});


function _initRatingHover() {
	$('div.fivestar-widget-static').css('cursor','pointer').hover(function() {
		$(this).parents('div.tmber-rating').find('div.field-field-rating-explanation').fadeIn(333);
	},
	function() {
		$(this).parents('div.tmber-rating').find('div.field-field-rating-explanation').fadeOut(250);
	});
}


function _initProductPhotos() {
	//create thumbnail of first image
	var $thumb = $('div.main-product-image a').clone();
	var src = $thumb.find('img').attr('src').replace('imagecache/product', 'imagecache/uc_thumbnail');
	$thumb.find('img').attr('src',src).removeAttr('width').removeAttr('height').addClass('active');

	$('div.more-product-images').prepend($thumb).find('a').click(function() {
		if ($(this).hasClass('active')) {
			return false;
		}
		$('div.more-product-images a.active').removeClass('active');
		$(this).addClass('active');
		var img = new Image();
		var src = $(this).find('img').attr('src').replace('imagecache/uc_thumbnail', 'imagecache/product');

		// setup new image
		$(img).load(function() {
			// set the image hidden by default    
      $('div.main-product-image').removeClass('image-loader').html($(this));
			$('div.main-product-image').find('img').hide().fadeIn(333);
		}).attr('src', src);

		$('div.main-product-image').addClass('image-loader').find('img').fadeTo(333, 0.25);
		return false;
	});
	
	
	
}





function _initRoutesView() {
	  // set cookie based on drupal filters
	  $.cookie('route_search_params', window.location.search);
	 
	 // init map clicking behavior
   $("map#region area").click(function() {		
		 //unset title
		$('input#edit-name').val('');				
	
	   var data = $(this).data('maphilight') || {};
	   
	   // if this isn't already on, clear the active map selection			
	   if (!data.alwaysOn) {
	   		$("map#region area.active").each(function() {
				var d = $(this).data('maphilight') || {};
			   	d.alwaysOn = false;
				d.fillOpacity = 0.33;
				$(this).data('maphilight', d).removeClass('active');
			});
			
			data.fillOpacity = 0.75;
	   } else {
			data.fillOpacity = 0.33;					
	   }
	
	   data.alwaysOn = !data.alwaysOn;
	   $(this).data('maphilight', data).toggleClass('active');
	   
		 //refresh map display
	   $('map#region').trigger('alwaysOn.maphilight');
		
		 //set value of select box
	   var region = $("map#region area.active").attr("alt");
	   if (region == undefined) {
			region = 'All';
	   }
		 $('select[name=region]').val(region);
		 if ($('body').hasClass('front')) {
				$('form#views-exposed-form-routes-default').submit();
		 }
	   return false; 
  });


  // hide select box and check for existing region and set default
	var region = $('select[name=region]').hide().val();
	
	if (region != 'All') {
		$reg = $("map#region area[alt="+region+"]");
		var data = $reg.data('maphilight') || {};
		data.alwaysOn = true;
		data.fillOpacity = 0.75;
		if (!$('body').hasClass('front')) {
			$reg.data('maphilight', data).addClass('active');			
		}
	  //$('map#region').trigger('alwaysOn.maphilight');
	}
	
	////initialize map highlight
  $('img.map').maphilight({strokeColor:'b3b3b3',fillColor:'b3b3b3',fillOpacity:0.33});

	// make title entry remove other filters
	$('input#edit-name').change(function() {
		var v = $(this).val();
		$("map#region area.active").click();
		$('form#views-exposed-form-routes-page-1 div.form-checkboxes input').attr('checked', '');
		$(this).val(v);
	});
	
	 //unset title filter
	$('form#views-exposed-form-routes-page-1 div.form-checkboxes input').click(function() {
		$('input#edit-name').val('');		
	});
	

}


function _refreshRoutesView() {
	//alert('updating routes view');
	$('v:rect, div.map canvas').remove();
	_initRoutesView();
}





function _initPlayer() {
	//$('video').mediaelementplayer();
	// FORCE IE to use flash
	var m = ($.browser.msie) ? 'shim' : 'auto';
	
	player = new MediaElementPlayer('video', {
		mode: m,
		alwaysShowControls: true,
		pluginPath: '/sites/all/themes/tmber/mediaelement-js/',
		features: ['playpause', 'progress', 'current', 'duration', 'volume', 'fullscreen'], 
			success: function (mediaElement, domObject) { 
	        // add event listener
	        mediaElement.addEventListener('ended', _completeCallback, false);
	        // call the play method
	        //mediaElement.play();
	    }
	});


	if(window.location.hash == '#watch') {
		$('video').attr('autoplay','autoplay');
		var f = function() {
			$('div.mejs-overlay').trigger('click');
		};
		setTimeout(f, 333);
	}
}


function _completeCallback(e) {
	$('div.mejs-poster').fadeIn(300);
}



function _initRoutePage() {
	// check for search filter cookie
	var q = $.cookie('route_search_params');
	if (q) {
		$('div.route-breadcrumb a').attr('href', '/routes'+q);
	}
	
	if ($('body').hasClass('page-featured-route')) {
		$('div.node div#photo-viewer, div.node div.field-field-location').slideUp(0.001);
	} else {
		$('div.node div#photo-viewer').hide();
		$('div.tmber-view-maps div.dropdown>span').addClass('active');		
	}
	
	$('div.tmber-view-maps, div.tmber-view-photos').disableTextSelect();
	$('div.tmber-view-maps').click(function() {
		var $d = $(this).find('div.dropdown>span');
		$d.toggleClass('active');
		$('div.tmber-view-photos span.active').removeClass('active');
		
		$('div.field-field-location').stop(true,true).slideToggle(333);
		if ($('div#photo-viewer:visible').length) {
			_closeSlideshow();
		}
	});



	$('div.tmber-view-photos').click(function() {
		console.log('click');
		var $d = $(this).find('div.dropdown>span');
		$d.toggleClass('active');
		$('div.tmber-view-maps span.active').removeClass('active');

		$viewer = $('div.node div#photo-viewer');
		if (!$viewer.hasClass('slideshow')) {
			_initSlideshow($viewer);
		}
		
		if ($('div#photo-viewer:visible').length) {
			_closeSlideshow();
			console.log('close pics');
		} else {
			console.log('show pics');
			_openSlideshow();
		}

		if ($('div.field-field-location:visible').length) {
			console.log('hide map');
			$('div.field-field-location').stop(true,true).slideUp(333);
		}
		// prevent images from opening in new window
		return false;
	});
	
}


function _openSlideshow() {
	$viewer = $('div.node div#photo-viewer');
	$('div#photo-viewer-controls').show();
	$viewer.stop(true,true).slideDown(333, function() {
		$(this).css('overflow','hidden');

		if ($(this).find('img').length > 1) {			
		  _interval = setInterval( "_nextSlide()", 7000 );
		}

	});	
}


function _closeSlideshow() {
	clearInterval(_interval);
	$viewer.stop(true,true).slideUp(333);
	$('div#photo-viewer-controls').hide();
}




function _initSlideshow($viewer) {
	$imgs = $('div.tmber-view-photos').find('img');

	// Clone list of thumbnails and dump inline versions onto page
	var $img;
	$imgs.each(function() {
		$img = $('<img alt="'+$(this).attr('alt')+'" src="' + $(this).attr('src').replace('tiny','inline') + '" />');
		$viewer.append($img);
	});
	
	$first = $('img:first-child', $viewer).addClass('active');
	$viewer.addClass('slideshow').append('<div class="caption"><p>'+$first.attr('alt')+'</p></div>');
	$slides = $viewer.find('img').not($first).hide();

	if ($slides.length) {
		$('div#photo-viewer img').css('cursor','pointer').click(_prevSlide);
		// add controls
		$('<div id="photo-viewer-controls"><span class="prev" href="#">< Prev</span> <span class="next" href="#">Next ></span> </div>').insertBefore($viewer);

		$('div#photo-viewer-controls span.prev').click(_prevSlide).disableTextSelect();
		$('div#photo-viewer-controls span.next').click(_nextSlide).disableTextSelect();
	}


	
}


function _nextSlide() {
	var $s = $('div#photo-viewer img.active');
	var $n = $s.next('img').length ? $s.next('img') : $('div#photo-viewer img:first-child');
	_swapSlides($s, $n);
}

function _prevSlide() {
	var $s = $('div#photo-viewer img.active');
	var $n = $s.prev('img').length ? $s.prev('img') : $('div#photo-viewer img:last');
	_swapSlides($s, $n);
}

function _swapSlides($current, $next) {
  clearInterval(_interval);
	$caption = $('div.node div#photo-viewer div.caption');

	$('div#photo-viewer').css('height', $current.height()+$caption.height()+10+'px');

	$current.stop(true,true).fadeOut(500, function() {
		$current.removeClass('active');
		$next.addClass('active').stop(true,true).fadeIn(333);
		$('div.node div#photo-viewer div.caption').html('<p>'+$next.attr('alt')+'</p>');
		$('div#photo-viewer').css('height', $next.height()+$caption.height()+10+'px');
	});
	_interval = setInterval( "_nextSlide()", 7000 );
	
	  //if ($current) $current.removeClass('active').css('z-index', 0);
	/*
		$next.addClass('active').css('z-index', 1).fadeIn(333, function() {
			if ($current) $current.hide();
		});
		*/
}


/**
 * FullScreenControl is a GControl that provides a button to change between full-screen and regular modes.
 * Based on http://code.google.com/apis/maps/documentation/controls.html#Custom_Controls and
 * http://code.google.com/apis/maps/documentation/examples/control-custom.html
 */
function FullScreenControl() {}


// To "subclass" the GControl, we set the prototype object to an instance of the GControl object.
FullScreenControl.prototype = new GControl();

// Creates a DOM element for the control. We add the control to the map container and return the element for the GMap2 API to position properly.
FullScreenControl.prototype.initialize = function(map) {
  // Get the map container with jQuery.
  var mapContainer = $('#' + map.getContainer().id);

  // Create the button.
  mapContainer.append('<div id="full-screen-container"><a id="full-screen-button"></a></div>');

  // What mode do we want to be in? (swapped because FullScreenSwitch swaps at start).
  Drupal.settings.fullScreenModeDesired = (document.location.hash != '#full-screen');

  // Initialize map and button.
  fullScreenSwitch(map);

  // Get DOM element for the button container.
  var buttonContainer = document.getElementById('full-screen-container');

  // Listen for clicks to the button.
  GEvent.addDomListener(buttonContainer, 'click', function() {
    fullScreenSwitch(map);
  });

  // Return the DOM element we appended, so that GMap2 API can position it.
  return buttonContainer;
};

// Sets the position of the button.
FullScreenControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(220, 7));
};


/**
 * Does the heavy lifting of initializing the button and changing in and out of full-screen mode.
 */
function fullScreenSwitch(map) {
  // What mode do we want to be in?
  Drupal.settings.fullScreenModeDesired = !Drupal.settings.fullScreenModeDesired;

  // Get required jQuery DOM elements.
  var button = $('#full-screen-button');
  var mapContainer = $('#' + map.getContainer().id);

  // Store the map's center before we change anything anything.
  var center = map.getCenter();

  // To change the destination (href="" attribute) of the full-screen mode 'link' (button), we need to invoke a separate event, else we end up changing the destination of the click event.  We use a basic Timeout function to invoke a separate event.  This is the time to wait:
  var clickTimeout = 100;

  // Store the hash so that we can restore it later.
  var hash = document.location.hash;
  if (hash == '' || hash == '#full-screen') {
    hash = '#';
  }

  // Are we going into full-screen mode or regular mode?
  // Fullscreen mode.
  if (Drupal.settings.fullScreenModeDesired) {

    $('div#page').fadeOut(444, function() {
	    // Move the map to be a child of the body (and sibling of the wrapper), and leave a placeholder in the map's original place.
			mapContainer.hide();
	    mapContainer.after('<div id="full-screen-placeholder" style="display:none;"></div>').appendTo('body');
			//mapContainer.width('100%');
			//mapContainer.height('100%');
			
	    // Set styles for full-screen mode.
	    mapContainer.addClass('full-screen-map');
	    // IE6 sucks.  Fix it.
	    $('body').height('100%');

	    // Make sure we're not so far zoomed out that the map is duplicated around the world (for typical screen resolutions).
			
	    if (map.getZoom() < 2) {
	       map.setZoom(2);
	    }

	    // Enable ScrollWheelZooming, since the scroll wheel doesn't serve any other purpose in this context.
	    map.enableScrollWheelZoom();

	    // Set the button text and style.
	    //Drupal.settings.t.fullScreenSwitcher.textOn = "embiggen";
	    button.empty();
	    button.append("Close");

	    // Set the destination of the button link in a separate event so that we don't break this event.
	    setTimeout(function() {
	      button.attr({
	          'href':   hash, 
	          'title':  'Close Map',//Drupal.settings.t.fullScreenSwitcher.titleOn,
	          'class':  'on'
	        });
	      }, clickTimeout);
	
			mapContainer.fadeIn(444);			
			_mapUpdate(map, center);
		});
  }
  else {
    // Not fullscreen mode.

    // Move the map back to it's original place and remove the placeholder.

    $('#full-screen-placeholder').after(mapContainer).remove();
    // Move the body's original children back to the body and remove the wrapper.
		$('div#page').fadeIn(444);

    // Restore the map's styles.
    mapContainer.removeClass('full-screen-map');

    // Zoom out a bit so that the user doesn't lose the context of the location they're viewing.
    if (map.getZoom() > 1) {
      map.zoomOut();
    }
		_mapUpdate(map,center);

    map.disableScrollWheelZoom();
    button.empty();
    button.append("Full Screen");

    //Drupal.settings.t.fullScreenSwitcher.titleOff = "off";
    setTimeout(function() {
      button.attr({
          'href':   '#full-screen', 
          'title':  'off',
          'class':  'off'
        });
      }, clickTimeout);

  }

}

function _mapUpdate(map, center) {

  // GMap API needs to that know we resized.
  map.checkResize();

  // Re-center the map.  If there is an open info window...
  var infoWindow = map.getInfoWindow();
  if (infoWindow.isHidden()) {
    // Restore the previously saved center.
    map.setCenter(center);
  }
  else {
    // Otherwise center the info window.
    map.setCenter(infoWindow.getPoint());

    // The info window is always above the point, so let's slide down a little to center the window, instead of the point.  Values are relative to half of map size.
    if (Drupal.settings.fullScreenModeDesired) {
      map.panDirection(0, 0.5);
    }
    else {
      map.panDirection(0, 1);
    }
  }

  // Save this as the starting position for this map (The 'X' button in the center of the pan buttons uses this).
  map.savePosition();
  
  	$(document).keyup(function(e) {
  		if (e.keyCode == 27) { $('#full-screen-button').click(); }   // esc
	});	
}

;

