// $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 = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;

/**
 * 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;
  if (Drupal.jsEnabled) {
    // 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).text())) {
      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, '@text': xmlhttp.responseText });
    }
  }
  else {
    var message = Drupal.t("An HTTP error @status occurred. \n@uri", {'@uri': uri, '@status': xmlhttp.status });
  }
  return message;
}

// Global Killswitch on the <html> element
if (Drupal.jsEnabled) {
  // Global Killswitch on the <html> element
  $(document.documentElement).addClass('js');
  // 'js enabled' cookie
  document.cookie = 'has_js=1; path=/';
  // 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>';
  }
};
;
/*
 * jQuery UI 1.6
 *
 * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */(function(C){var I=C.fn.remove,D=C.browser.mozilla&&(parseFloat(C.browser.version)<1.9);C.ui={version:"1.6",plugin:{add:function(K,L,N){var M=C.ui[K].prototype;for(var J in N){M.plugins[J]=M.plugins[J]||[];M.plugins[J].push([L,N[J]])}},call:function(J,L,K){var N=J.plugins[L];if(!N){return }for(var M=0;M<N.length;M++){if(J.options[N[M][0]]){N[M][1].apply(J.element,K)}}}},contains:function(L,K){var J=C.browser.safari&&C.browser.version<522;if(L.contains&&!J){return L.contains(K)}if(L.compareDocumentPosition){return !!(L.compareDocumentPosition(K)&16)}while(K=K.parentNode){if(K==L){return true}}return false},cssCache:{},css:function(J){if(C.ui.cssCache[J]){return C.ui.cssCache[J]}var K=C('<div class="ui-gen">').addClass(J).css({position:"absolute",top:"-5000px",left:"-5000px",display:"block"}).appendTo("body");C.ui.cssCache[J]=!!((!(/auto|default/).test(K.css("cursor"))||(/^[1-9]/).test(K.css("height"))||(/^[1-9]/).test(K.css("width"))||!(/none/).test(K.css("backgroundImage"))||!(/transparent|rgba\(0, 0, 0, 0\)/).test(K.css("backgroundColor"))));try{C("body").get(0).removeChild(K.get(0))}catch(L){}return C.ui.cssCache[J]},hasScroll:function(M,K){if(C(M).css("overflow")=="hidden"){return false}var J=(K&&K=="left")?"scrollLeft":"scrollTop",L=false;if(M[J]>0){return true}M[J]=1;L=(M[J]>0);M[J]=0;return L},isOverAxis:function(K,J,L){return(K>J)&&(K<(J+L))},isOver:function(O,K,N,M,J,L){return C.ui.isOverAxis(O,N,J)&&C.ui.isOverAxis(K,M,L)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(D){var F=C.attr,E=C.fn.removeAttr,H="http://www.w3.org/2005/07/aaa",A=/^aria-/,B=/^wairole:/;C.attr=function(K,J,L){var M=L!==undefined;return(J=="role"?(M?F.call(this,K,J,"wairole:"+L):(F.apply(this,arguments)||"").replace(B,"")):(A.test(J)?(M?K.setAttributeNS(H,J.replace(A,"aaa:"),L):F.call(this,K,J.replace(A,"aaa:"))):F.apply(this,arguments)))};C.fn.removeAttr=function(J){return(A.test(J)?this.each(function(){this.removeAttributeNS(H,J.replace(A,""))}):E.call(this,J))}}C.fn.extend({remove:function(){C("*",this).add(this).each(function(){C(this).triggerHandler("remove")});return I.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var J;if((C.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){J=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(C.curCSS(this,"position",1))&&(/(auto|scroll)/).test(C.curCSS(this,"overflow",1)+C.curCSS(this,"overflow-y",1)+C.curCSS(this,"overflow-x",1))}).eq(0)}else{J=this.parents().filter(function(){return(/(auto|scroll)/).test(C.curCSS(this,"overflow",1)+C.curCSS(this,"overflow-y",1)+C.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!J.length?C(document):J}});C.extend(C.expr[":"],{data:function(K,L,J){return C.data(K,J[3])},tabbable:function(L,M,K){var N=L.nodeName.toLowerCase();function J(O){return !(C(O).is(":hidden")||C(O).parents(":hidden").length)}return(L.tabIndex>=0&&(("a"==N&&L.href)||(/input|select|textarea|button/.test(N)&&"hidden"!=L.type&&!L.disabled))&&J(L))}});function G(M,N,O,L){function K(Q){var P=C[M][N][Q]||[];return(typeof P=="string"?P.split(/,?\s+/):P)}var J=K("getter");if(L.length==1&&typeof L[0]=="string"){J=J.concat(K("getterSetter"))}return(C.inArray(O,J)!=-1)}C.widget=function(K,J){var L=K.split(".")[0];K=K.split(".")[1];C.fn[K]=function(P){var N=(typeof P=="string"),O=Array.prototype.slice.call(arguments,1);if(N&&P.substring(0,1)=="_"){return this}if(N&&G(L,K,P,O)){var M=C.data(this[0],K);return(M?M[P].apply(M,O):undefined)}return this.each(function(){var Q=C.data(this,K);(!Q&&!N&&C.data(this,K,new C[L][K](this,P)));(Q&&N&&C.isFunction(Q[P])&&Q[P].apply(Q,O))})};C[L]=C[L]||{};C[L][K]=function(O,N){var M=this;this.widgetName=K;this.widgetEventPrefix=C[L][K].eventPrefix||K;this.widgetBaseClass=L+"-"+K;this.options=C.extend({},C.widget.defaults,C[L][K].defaults,C.metadata&&C.metadata.get(O)[K],N);this.element=C(O).bind("setData."+K,function(Q,P,R){return M._setData(P,R)}).bind("getData."+K,function(Q,P){return M._getData(P)}).bind("remove",function(){return M.destroy()});this._init()};C[L][K].prototype=C.extend({},C.widget.prototype,J);C[L][K].getterSetter="option"};C.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName)},option:function(L,M){var K=L,J=this;if(typeof L=="string"){if(M===undefined){return this._getData(L)}K={};K[L]=M}C.each(K,function(N,O){J._setData(N,O)})},_getData:function(J){return this.options[J]},_setData:function(J,K){this.options[J]=K;if(J=="disabled"){this.element[K?"addClass":"removeClass"](this.widgetBaseClass+"-disabled")}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(K,L,M){var J=(K==this.widgetEventPrefix?K:this.widgetEventPrefix+K);L=L||C.event.fix({type:J,target:this.element[0]});return this.element.triggerHandler(J,[L,M],this.options[K])}};C.widget.defaults={disabled:false};C.ui.mouse={_mouseInit:function(){var J=this;this.element.bind("mousedown."+this.widgetName,function(K){return J._mouseDown(K)}).bind("click."+this.widgetName,function(K){if(J._preventClickEvent){J._preventClickEvent=false;return false}});if(C.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(C.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(L){(this._mouseStarted&&this._mouseUp(L));this._mouseDownEvent=L;var K=this,M=(L.which==1),J=(typeof this.options.cancel=="string"?C(L.target).parents().add(L.target).filter(this.options.cancel).length:false);if(!M||J||!this._mouseCapture(L)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){K.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(L)&&this._mouseDelayMet(L)){this._mouseStarted=(this._mouseStart(L)!==false);if(!this._mouseStarted){L.preventDefault();return true}}this._mouseMoveDelegate=function(N){return K._mouseMove(N)};this._mouseUpDelegate=function(N){return K._mouseUp(N)};C(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);if(!C.browser.safari){L.preventDefault()}return true},_mouseMove:function(J){if(C.browser.msie&&!J.button){return this._mouseUp(J)}if(this._mouseStarted){this._mouseDrag(J);return J.preventDefault()}if(this._mouseDistanceMet(J)&&this._mouseDelayMet(J)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,J)!==false);(this._mouseStarted?this._mouseDrag(J):this._mouseUp(J))}return !this._mouseStarted},_mouseUp:function(J){C(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=true;this._mouseStop(J)}return false},_mouseDistanceMet:function(J){return(Math.max(Math.abs(this._mouseDownEvent.pageX-J.pageX),Math.abs(this._mouseDownEvent.pageY-J.pageY))>=this.options.distance)},_mouseDelayMet:function(J){return this.mouseDelayMet},_mouseStart:function(J){},_mouseDrag:function(J){},_mouseStop:function(J){},_mouseCapture:function(J){return true}};C.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);
/*
 * jQuery UI Dialog 1.6
 *
 * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Dialog
 *
 * Depends:
 *	ui.core.js
 *	ui.draggable.js
 *	ui.resizable.js
 */(function(B){var A={dragStart:"start.draggable",drag:"drag.draggable",dragStop:"stop.draggable",maxHeight:"maxHeight.resizable",minHeight:"minHeight.resizable",maxWidth:"maxWidth.resizable",minWidth:"minWidth.resizable",resizeStart:"start.resizable",resize:"drag.resizable",resizeStop:"stop.resizable"};B.widget("ui.dialog",{_init:function(){this.originalTitle=this.element.attr("title");this.options.title=this.options.title||this.originalTitle;var M=this,N=this.options,F=this.element.removeAttr("title").addClass("ui-dialog-content").wrap("<div></div>").wrap("<div></div>"),I=(this.uiDialogContainer=F.parent()).addClass("ui-dialog-container").css({position:"relative",width:"100%",height:"100%"}),E=(this.uiDialogTitlebar=B("<div></div>")).addClass("ui-dialog-titlebar").mousedown(function(){M.moveToTop()}).prependTo(I),J=B('<a href="#"/>').addClass("ui-dialog-titlebar-close").attr("role","button").appendTo(E),G=(this.uiDialogTitlebarCloseText=B("<span/>")).text(N.closeText).appendTo(J),L=N.title||"&nbsp;",D=B.ui.dialog.getTitleId(this.element),C=B("<span/>").addClass("ui-dialog-title").attr("id",D).html(L).prependTo(E),K=(this.uiDialog=I.parent()).appendTo(document.body).hide().addClass("ui-dialog").addClass(N.dialogClass).css({position:"absolute",width:N.width,height:N.height,overflow:"hidden",zIndex:N.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(O){(N.closeOnEscape&&O.keyCode&&O.keyCode==B.ui.keyCode.ESCAPE&&M.close())}).attr({role:"dialog","aria-labelledby":D}).mouseup(function(){M.moveToTop()}),H=(this.uiDialogButtonPane=B("<div></div>")).addClass("ui-dialog-buttonpane").css({position:"absolute",bottom:0}).appendTo(K),J=B(".ui-dialog-titlebar-close",E).hover(function(){B(this).addClass("ui-dialog-titlebar-close-hover")},function(){B(this).removeClass("ui-dialog-titlebar-close-hover")}).mousedown(function(O){O.stopPropagation()}).click(function(){M.close();return false});E.find("*").add(E).disableSelection();(N.draggable&&B.fn.draggable&&this._makeDraggable());(N.resizable&&B.fn.resizable&&this._makeResizable());this._createButtons(N.buttons);this._isOpen=false;(N.bgiframe&&B.fn.bgiframe&&K.bgiframe());(N.autoOpen&&this.open())},destroy:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide();this.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content").hide().appendTo("body");this.uiDialog.remove();(this.originalTitle&&this.element.attr("title",this.originalTitle))},close:function(){if(false===this._trigger("beforeclose",null,{options:this.options})){return }(this.overlay&&this.overlay.destroy());this.uiDialog.hide(this.options.hide).unbind("keypress.ui-dialog");this._trigger("close",null,{options:this.options});B.ui.dialog.overlay.resize();this._isOpen=false},isOpen:function(){return this._isOpen},moveToTop:function(F){if((this.options.modal&&!F)||(!this.options.stack&&!this.options.modal)){return this._trigger("focus",null,{options:this.options})}var E=this.options.zIndex,D=this.options;B(".ui-dialog:visible").each(function(){E=Math.max(E,parseInt(B(this).css("z-index"),10)||D.zIndex)});(this.overlay&&this.overlay.$el.css("z-index",++E));var C={scrollTop:this.element.attr("scrollTop"),scrollLeft:this.element.attr("scrollLeft")};this.uiDialog.css("z-index",++E);this.element.attr(C);this._trigger("focus",null,{options:this.options})},open:function(){if(this._isOpen){return }this.overlay=this.options.modal?new B.ui.dialog.overlay(this):null;(this.uiDialog.next().length&&this.uiDialog.appendTo("body"));this._position(this.options.position);this.uiDialog.show(this.options.show);(this.options.autoResize&&this._size());this.moveToTop(true);(this.options.modal&&this.uiDialog.bind("keypress.ui-dialog",function(E){if(E.keyCode!=B.ui.keyCode.TAB){return }var D=B(":tabbable",this),F=D.filter(":first")[0],C=D.filter(":last")[0];if(E.target==C&&!E.shiftKey){setTimeout(function(){F.focus()},1)}else{if(E.target==F&&E.shiftKey){setTimeout(function(){C.focus()},1)}}}));this.uiDialog.find(":tabbable:first").focus();this._trigger("open",null,{options:this.options});this._isOpen=true},_createButtons:function(F){var E=this,C=false,D=this.uiDialogButtonPane;D.empty().hide();B.each(F,function(){return !(C=true)});if(C){D.show();B.each(F,function(G,H){B('<button type="button"></button>').text(G).click(function(){H.apply(E.element[0],arguments)}).appendTo(D)})}},_makeDraggable:function(){var C=this,D=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content",helper:D.dragHelper,handle:".ui-dialog-titlebar",start:function(){C.moveToTop();(D.dragStart&&D.dragStart.apply(C.element[0],arguments))},drag:function(){(D.drag&&D.drag.apply(C.element[0],arguments))},stop:function(){(D.dragStop&&D.dragStop.apply(C.element[0],arguments));B.ui.dialog.overlay.resize()}})},_makeResizable:function(F){F=(F===undefined?this.options.resizable:F);var C=this,E=this.options,D=typeof F=="string"?F:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",helper:E.resizeHelper,maxWidth:E.maxWidth,maxHeight:E.maxHeight,minWidth:E.minWidth,minHeight:E.minHeight,start:function(){(E.resizeStart&&E.resizeStart.apply(C.element[0],arguments))},resize:function(){(E.autoResize&&C._size.apply(C));(E.resize&&E.resize.apply(C.element[0],arguments))},handles:D,stop:function(){(E.autoResize&&C._size.apply(C));(E.resizeStop&&E.resizeStop.apply(C.element[0],arguments));B.ui.dialog.overlay.resize()}})},_position:function(H){var D=B(window),E=B(document),F=E.scrollTop(),C=E.scrollLeft(),G=F;if(B.inArray(H,["center","top","right","bottom","left"])>=0){H=[H=="right"||H=="left"?H:"center",H=="top"||H=="bottom"?H:"middle"]}if(H.constructor!=Array){H=["center","middle"]}if(H[0].constructor==Number){C+=H[0]}else{switch(H[0]){case"left":C+=0;break;case"right":C+=D.width()-this.uiDialog.outerWidth();break;default:case"center":C+=(D.width()-this.uiDialog.outerWidth())/2}}if(H[1].constructor==Number){F+=H[1]}else{switch(H[1]){case"top":F+=0;break;case"bottom":F+=(B.browser.opera?window.innerHeight:D.height())-this.uiDialog.outerHeight();break;default:case"middle":F+=((B.browser.opera?window.innerHeight:D.height())-this.uiDialog.outerHeight())/2}}F=Math.max(F,G);this.uiDialog.css({top:F,left:C})},_setData:function(D,E){(A[D]&&this.uiDialog.data(A[D],E));switch(D){case"buttons":this._createButtons(E);break;case"closeText":this.uiDialogTitlebarCloseText.text(E);break;case"draggable":(E?this._makeDraggable():this.uiDialog.draggable("destroy"));break;case"height":this.uiDialog.height(E);break;case"position":this._position(E);break;case"resizable":var C=this.uiDialog,F=this.uiDialog.is(":data(resizable)");(F&&!E&&C.resizable("destroy"));(F&&typeof E=="string"&&C.resizable("option","handles",E));(F||this._makeResizable(E));break;case"title":B(".ui-dialog-title",this.uiDialogTitlebar).html(E||"&nbsp;");break;case"width":this.uiDialog.width(E);break}B.widget.prototype._setData.apply(this,arguments)},_size:function(){var D=this.uiDialogContainer,G=this.uiDialogTitlebar,E=this.element,F=(parseInt(E.css("margin-top"),10)||0)+(parseInt(E.css("margin-bottom"),10)||0),C=(parseInt(E.css("margin-left"),10)||0)+(parseInt(E.css("margin-right"),10)||0);E.height(D.height()-G.outerHeight()-F);E.width(D.width()-C)}});B.extend(B.ui.dialog,{version:"1.6",defaults:{autoOpen:true,autoResize:true,bgiframe:false,buttons:{},closeOnEscape:true,closeText:"close",draggable:true,height:200,minHeight:100,minWidth:150,modal:false,overlay:{},position:"center",resizable:true,stack:true,width:300,zIndex:1000},getter:"isOpen",uuid:0,getTitleId:function(C){return"ui-dialog-title-"+(C.attr("id")||++this.uuid)},overlay:function(C){this.$el=B.ui.dialog.overlay.create(C)}});B.extend(B.ui.dialog.overlay,{instances:[],events:B.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(C){return C+".dialog-overlay"}).join(" "),create:function(D){if(this.instances.length===0){setTimeout(function(){B("a, :input").bind(B.ui.dialog.overlay.events,function(){var F=false;var H=B(this).parents(".ui-dialog");if(H.length){var E=B(".ui-dialog-overlay");if(E.length){var G=parseInt(E.css("z-index"),10);E.each(function(){G=Math.max(G,parseInt(B(this).css("z-index"),10))});F=parseInt(H.css("z-index"),10)>G}else{F=true}}return F})},1);B(document).bind("keydown.dialog-overlay",function(E){(D.options.closeOnEscape&&E.keyCode&&E.keyCode==B.ui.keyCode.ESCAPE&&D.close())});B(window).bind("resize.dialog-overlay",B.ui.dialog.overlay.resize)}var C=B("<div></div>").appendTo(document.body).addClass("ui-dialog-overlay").css(B.extend({borderWidth:0,margin:0,padding:0,position:"absolute",top:0,left:0,width:this.width(),height:this.height()},D.options.overlay));(D.options.bgiframe&&B.fn.bgiframe&&C.bgiframe());this.instances.push(C);return C},destroy:function(C){this.instances.splice(B.inArray(this.instances,C),1);if(this.instances.length===0){B("a, :input").add([document,window]).unbind(".dialog-overlay")}C.remove()},height:function(){if(B.browser.msie&&B.browser.version<7){var D=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);var C=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);if(D<C){return B(window).height()+"px"}else{return D+"px"}}else{if(B.browser.opera){return Math.max(window.innerHeight,B(document).height())+"px"}else{return B(document).height()+"px"}}},width:function(){if(B.browser.msie&&B.browser.version<7){var C=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);var D=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);if(C<D){return B(window).width()+"px"}else{return C+"px"}}else{if(B.browser.opera){return Math.max(window.innerWidth,B(document).width())+"px"}else{return B(document).width()+"px"}}},resize:function(){var C=B([]);B.each(B.ui.dialog.overlay.instances,function(){C=C.add(this)});C.css({width:0,height:0}).css({width:B.ui.dialog.overlay.width(),height:B.ui.dialog.overlay.height()})}});B.extend(B.ui.dialog.overlay.prototype,{destroy:function(){B.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);
/*
 * jQuery UI Draggable 1.6
 *
 * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Draggables
 *
 * Depends:
 *	ui.core.js
 */(function(A){A.widget("ui.draggable",A.extend({},A.ui.mouse,{_init:function(){if(this.options.helper=="original"&&!(/^(?:r|a|f)/).test(this.element.css("position"))){this.element[0].style.position="relative"}(this.options.cssNamespace&&this.element.addClass(this.options.cssNamespace+"-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit()},destroy:function(){if(!this.element.data("draggable")){return }this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy()},_mouseCapture:function(B){var C=this.options;if(this.helper||C.disabled||A(B.target).is(".ui-resizable-handle")){return false}this.handle=this._getHandle(B);if(!this.handle){return false}return true},_mouseStart:function(B){var C=this.options;this.helper=this._createHelper(B);this._cacheHelperProportions();if(A.ui.ddmanager){A.ui.ddmanager.current=this}this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};A.extend(this.offset,{click:{left:B.pageX-this.offset.left,top:B.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});if(C.cursorAt){this._adjustOffsetFromHelper(C.cursorAt)}this.originalPosition=this._generatePosition(B);if(C.containment){this._setContainment()}this._propagate("start",B);this._cacheHelperProportions();if(A.ui.ddmanager&&!C.dropBehaviour){A.ui.ddmanager.prepareOffsets(this,B)}this.helper.addClass("ui-draggable-dragging");this._mouseDrag(B,true);return true},_mouseDrag:function(B,C){this.position=this._generatePosition(B);this.positionAbs=this._convertPositionTo("absolute");if(!C){this.position=this._propagate("drag",B)||this.position}if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}if(A.ui.ddmanager){A.ui.ddmanager.drag(this,B)}return false},_mouseStop:function(C){var D=false;if(A.ui.ddmanager&&!this.options.dropBehaviour){var D=A.ui.ddmanager.drop(this,C)}if((this.options.revert=="invalid"&&!D)||(this.options.revert=="valid"&&D)||this.options.revert===true||(A.isFunction(this.options.revert)&&this.options.revert.call(this.element,D))){var B=this;A(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){B._propagate("stop",C);B._clear()})}else{this._propagate("stop",C);this._clear()}return false},_getHandle:function(B){var C=!this.options.handle||!A(this.options.handle,this.element).length?true:false;A(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==B.target){C=true}});return C},_createHelper:function(C){var D=this.options;var B=A.isFunction(D.helper)?A(D.helper.apply(this.element[0],[C])):(D.helper=="clone"?this.element.clone():this.element);if(!B.parents("body").length){B.appendTo((D.appendTo=="parent"?this.element[0].parentNode:D.appendTo))}if(B[0]!=this.element[0]&&!(/(fixed|absolute)/).test(B.css("position"))){B.css("position","absolute")}return B},_adjustOffsetFromHelper:function(B){if(B.left!=undefined){this.offset.click.left=B.left+this.margins.left}if(B.right!=undefined){this.offset.click.left=this.helperProportions.width-B.right+this.margins.left}if(B.top!=undefined){this.offset.click.top=B.top+this.margins.top}if(B.bottom!=undefined){this.offset.click.top=this.helperProportions.height-B.bottom+this.margins.top}},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var B=this.offsetParent.offset();if((this.offsetParent[0]==document.body&&A.browser.mozilla)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&A.browser.msie)){B={top:0,left:0}}return{top:B.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:B.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var B=this.element.position();return{top:B.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:B.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var E=this.options;if(E.containment=="parent"){E.containment=this.helper[0].parentNode}if(E.containment=="document"||E.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,A(E.containment=="document"?document:window).width()-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),(A(E.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)]}if(!(/^(document|window|parent)$/).test(E.containment)){var C=A(E.containment)[0];var D=A(E.containment).offset();var B=(A(C).css("overflow")!="hidden");this.containment=[D.left+(parseInt(A(C).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left-this.margins.left,D.top+(parseInt(A(C).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top-this.margins.top,D.left+(B?Math.max(C.scrollWidth,C.offsetWidth):C.offsetWidth)-(parseInt(A(C).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left,D.top+(B?Math.max(C.scrollHeight,C.offsetHeight):C.offsetHeight)-(parseInt(A(C).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(D,F){if(!F){F=this.position}var C=D=="absolute"?1:-1;var B=this[(this.cssPosition=="absolute"?"offset":"scroll")+"Parent"],E=(/(html|body)/i).test(B[0].tagName);return{top:(F.top+this.offset.relative.top*C+this.offset.parent.top*C+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():(E?0:B.scrollTop()))*C+this.margins.top*C),left:(F.left+this.offset.relative.left*C+this.offset.parent.left*C+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():(E?0:B.scrollLeft()))*C+this.margins.left*C)}},_generatePosition:function(D){var G=this.options,C=this[(this.cssPosition=="absolute"?"offset":"scroll")+"Parent"],H=(/(html|body)/i).test(C[0].tagName);var B={top:(D.pageY-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():(H?0:C.scrollTop()))),left:(D.pageX-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():H?0:C.scrollLeft()))};if(!this.originalPosition){return B}if(this.containment){if(B.left<this.containment[0]){B.left=this.containment[0]}if(B.top<this.containment[1]){B.top=this.containment[1]}if(B.left>this.containment[2]){B.left=this.containment[2]}if(B.top>this.containment[3]){B.top=this.containment[3]}}if(G.grid){var F=this.originalPosition.top+Math.round((B.top-this.originalPosition.top)/G.grid[1])*G.grid[1];B.top=this.containment?(!(F<this.containment[1]||F>this.containment[3])?F:(!(F<this.containment[1])?F-G.grid[1]:F+G.grid[1])):F;var E=this.originalPosition.left+Math.round((B.left-this.originalPosition.left)/G.grid[0])*G.grid[0];B.left=this.containment?(!(E<this.containment[0]||E>this.containment[2])?E:(!(E<this.containment[0])?E-G.grid[0]:E+G.grid[0])):E}return B},_clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval){this.helper.remove()}this.helper=null;this.cancelHelperRemoval=false},_propagate:function(C,B){A.ui.plugin.call(this,C,[B,this._uiHash()]);if(C=="drag"){this.positionAbs=this._convertPositionTo("absolute")}return this.element.triggerHandler(C=="drag"?C:"drag"+C,[B,this._uiHash()],this.options[C])},plugins:{},_uiHash:function(B){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,options:this.options}}}));A.extend(A.ui.draggable,{version:"1.6",defaults:{appendTo:"parent",axis:false,cancel:":input",connectToSortable:false,containment:false,cssNamespace:"ui",cursor:"default",cursorAt:null,delay:0,distance:1,grid:false,handle:false,helper:"original",iframeFix:false,opacity:1,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:null}});A.ui.plugin.add("draggable","connectToSortable",{start:function(B,D){var C=A(this).data("draggable");C.sortables=[];A(D.options.connectToSortable).each(function(){A(this+"").each(function(){if(A.data(this,"sortable")){var E=A.data(this,"sortable");C.sortables.push({instance:E,shouldRevert:E.options.revert});E._refreshItems();E._propagate("activate",B,C)}})})},stop:function(B,D){var C=A(this).data("draggable");A.each(C.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;C.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert){this.instance.options.revert=true}this.instance._mouseStop(B);this.instance.element.triggerHandler("sortreceive",[B,A.extend(this.instance._ui(),{sender:C.element})],this.instance.options["receive"]);this.instance.options.helper=this.instance.options._helper;if(C.options.helper=="original"){this.instance.currentItem.css({top:"auto",left:"auto"})}}else{this.instance.cancelHelperRemoval=false;this.instance._propagate("deactivate",B,C)}})},drag:function(C,F){var E=A(this).data("draggable"),B=this;var D=function(I){var N=this.offset.click.top,M=this.offset.click.left;var G=this.positionAbs.top,K=this.positionAbs.left;var J=I.height,L=I.width;var O=I.top,H=I.left;return A.ui.isOver(G+N,K+M,O,H,J,L)};A.each(E.sortables,function(G){if(D.call(E,this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=A(B).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return F.helper[0]};C.target=this.instance.currentItem[0];this.instance._mouseCapture(C,true);this.instance._mouseStart(C,true,true);this.instance.offset.click.top=E.offset.click.top;this.instance.offset.click.left=E.offset.click.left;this.instance.offset.parent.left-=E.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=E.offset.parent.top-this.instance.offset.parent.top;E._propagate("toSortable",C)}if(this.instance.currentItem){this.instance._mouseDrag(C)}}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._mouseStop(C,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder){this.instance.placeholder.remove()}E._propagate("fromSortable",C)}}})}});A.ui.plugin.add("draggable","cursor",{start:function(C,D){var B=A("body");if(B.css("cursor")){D.options._cursor=B.css("cursor")}B.css("cursor",D.options.cursor)},stop:function(B,C){if(C.options._cursor){A("body").css("cursor",C.options._cursor)}}});A.ui.plugin.add("draggable","iframeFix",{start:function(B,C){A(C.options.iframeFix===true?"iframe":C.options.iframeFix).each(function(){A('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(A(this).offset()).appendTo("body")})},stop:function(B,C){A("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});A.ui.plugin.add("draggable","opacity",{start:function(C,D){var B=A(D.helper);if(B.css("opacity")){D.options._opacity=B.css("opacity")}B.css("opacity",D.options.opacity)},stop:function(B,C){if(C.options._opacity){A(C.helper).css("opacity",C.options._opacity)}}});A.ui.plugin.add("draggable","scroll",{start:function(C,D){var E=D.options;var B=A(this).data("draggable");if(B.scrollParent[0]!=document&&B.scrollParent[0].tagName!="HTML"){B.overflowOffset=B.scrollParent.offset()}},drag:function(D,E){var F=E.options,B=false;var C=A(this).data("draggable");if(C.scrollParent[0]!=document&&C.scrollParent[0].tagName!="HTML"){if((C.overflowOffset.top+C.scrollParent[0].offsetHeight)-D.pageY<F.scrollSensitivity){C.scrollParent[0].scrollTop=B=C.scrollParent[0].scrollTop+F.scrollSpeed}else{if(D.pageY-C.overflowOffset.top<F.scrollSensitivity){C.scrollParent[0].scrollTop=B=C.scrollParent[0].scrollTop-F.scrollSpeed}}if((C.overflowOffset.left+C.scrollParent[0].offsetWidth)-D.pageX<F.scrollSensitivity){C.scrollParent[0].scrollLeft=B=C.scrollParent[0].scrollLeft+F.scrollSpeed}else{if(D.pageX-C.overflowOffset.left<F.scrollSensitivity){C.scrollParent[0].scrollLeft=B=C.scrollParent[0].scrollLeft-F.scrollSpeed}}}else{if(D.pageY-A(document).scrollTop()<F.scrollSensitivity){B=A(document).scrollTop(A(document).scrollTop()-F.scrollSpeed)}else{if(A(window).height()-(D.pageY-A(document).scrollTop())<F.scrollSensitivity){B=A(document).scrollTop(A(document).scrollTop()+F.scrollSpeed)}}if(D.pageX-A(document).scrollLeft()<F.scrollSensitivity){B=A(document).scrollLeft(A(document).scrollLeft()-F.scrollSpeed)}else{if(A(window).width()-(D.pageX-A(document).scrollLeft())<F.scrollSensitivity){B=A(document).scrollLeft(A(document).scrollLeft()+F.scrollSpeed)}}}if(B!==false&&A.ui.ddmanager&&!F.dropBehaviour){A.ui.ddmanager.prepareOffsets(C,D)}if(B!==false&&C.cssPosition=="absolute"&&C.scrollParent[0]!=document&&A.ui.contains(C.scrollParent[0],C.offsetParent[0])){C.offset.parent=C._getParentOffset()}if(B!==false&&C.cssPosition=="relative"&&!(C.scrollParent[0]!=document&&C.scrollParent[0]!=C.offsetParent[0])){C.offset.relative=C._getRelativeOffset()}}});A.ui.plugin.add("draggable","snap",{start:function(B,D){var C=A(this).data("draggable");C.snapElements=[];A(D.options.snap.constructor!=String?(D.options.snap.items||":data(draggable)"):D.options.snap).each(function(){var F=A(this);var E=F.offset();if(this!=C.element[0]){C.snapElements.push({item:this,width:F.outerWidth(),height:F.outerHeight(),top:E.top,left:E.left})}})},drag:function(M,K){var E=A(this).data("draggable");var Q=K.options.snapTolerance;var P=K.absolutePosition.left,O=P+E.helperProportions.width,D=K.absolutePosition.top,C=D+E.helperProportions.height;for(var N=E.snapElements.length-1;N>=0;N--){var L=E.snapElements[N].left,J=L+E.snapElements[N].width,I=E.snapElements[N].top,S=I+E.snapElements[N].height;if(!((L-Q<P&&P<J+Q&&I-Q<D&&D<S+Q)||(L-Q<P&&P<J+Q&&I-Q<C&&C<S+Q)||(L-Q<O&&O<J+Q&&I-Q<D&&D<S+Q)||(L-Q<O&&O<J+Q&&I-Q<C&&C<S+Q))){if(E.snapElements[N].snapping){(E.options.snap.release&&E.options.snap.release.call(E.element,M,A.extend(E._uiHash(),{snapItem:E.snapElements[N].item})))}E.snapElements[N].snapping=false;continue}if(K.options.snapMode!="inner"){var B=Math.abs(I-C)<=Q;var R=Math.abs(S-D)<=Q;var G=Math.abs(L-O)<=Q;var H=Math.abs(J-P)<=Q;if(B){K.position.top=E._convertPositionTo("relative",{top:I-E.helperProportions.height,left:0}).top}if(R){K.position.top=E._convertPositionTo("relative",{top:S,left:0}).top}if(G){K.position.left=E._convertPositionTo("relative",{top:0,left:L-E.helperProportions.width}).left}if(H){K.position.left=E._convertPositionTo("relative",{top:0,left:J}).left}}var F=(B||R||G||H);if(K.options.snapMode!="outer"){var B=Math.abs(I-D)<=Q;var R=Math.abs(S-C)<=Q;var G=Math.abs(L-P)<=Q;var H=Math.abs(J-O)<=Q;if(B){K.position.top=E._convertPositionTo("relative",{top:I,left:0}).top}if(R){K.position.top=E._convertPositionTo("relative",{top:S-E.helperProportions.height,left:0}).top}if(G){K.position.left=E._convertPositionTo("relative",{top:0,left:L}).left}if(H){K.position.left=E._convertPositionTo("relative",{top:0,left:J-E.helperProportions.width}).left}}if(!E.snapElements[N].snapping&&(B||R||G||H||F)){(E.options.snap.snap&&E.options.snap.snap.call(E.element,M,A.extend(E._uiHash(),{snapItem:E.snapElements[N].item})))}E.snapElements[N].snapping=(B||R||G||H||F)}}});A.ui.plugin.add("draggable","stack",{start:function(B,C){var D=A.makeArray(A(C.options.stack.group)).sort(function(F,E){return(parseInt(A(F).css("zIndex"),10)||C.options.stack.min)-(parseInt(A(E).css("zIndex"),10)||C.options.stack.min)});A(D).each(function(E){this.style.zIndex=C.options.stack.min+E});this[0].style.zIndex=C.options.stack.min+D.length}});A.ui.plugin.add("draggable","zIndex",{start:function(C,D){var B=A(D.helper);if(B.css("zIndex")){D.options._zIndex=B.css("zIndex")}B.css("zIndex",D.options.zIndex)},stop:function(B,C){if(C.options._zIndex){A(C.helper).css("zIndex",C.options._zIndex)}}})})(jQuery);
// $Id: parent.js,v 1.1.2.24 2010/04/16 18:11:25 markuspetrux Exp $

(function ($) {

/**
 * Modal Frame object for parent windows.
 */
Drupal.modalFrame = Drupal.modalFrame || {
  dirtyFormsWarning: Drupal.t('Your changes will be lost if you close this popup now.'),
  options: {},
  iframe: { $container: null, $element: null },
  isOpen: false,

  // Flag that tells us if we have a child document loaded. Our window resize
  // handler will ignore events while no child document is loaded.
  isChildLoaded: false,

  // Flag used to control if we have already installed our custom
  // event handlers to the parent window.
  parentReady: false,

  // Provide a unique namespace for event handlers managed by this
  // Modal Frame instance.
  uniqueName: 'modalframe-'+ ((new Date()).getTime())
};

/**
 * Provide a unique name for an event handler.
 */
Drupal.modalFrame.eventHandlerName = function(name) {
  var self = this;
  return name +'.'+ self.uniqueName;
};

/**
 * Open a modal frame.
 *
 * Ensure that only one modal frame is opened ever. Use Drupal.modalFrame.load()
 * if the modal frame is already open but a new page needs to be loaded.
 *
 * @param options
 *   Properties of the modal frame to open:
 *   - url: the URL of the page to open in the modal frame.
 *   - width: width of the modal frame in pixels.
 *   - height: height of the modal frame in pixels.
 *   - autoFit: boolean indicating whether the modal frame should be resized to
 *     fit the contents of the document loaded.
 *   - onOpen: callback to invoke when the modal frame is opened.
 *   - onLoad: callback to invoke when the child document in the modal frame is
 *     fully loaded.
 *   - onSubmit: callback to invoke when the modal frame is closed.
 *     @todo: We could rename onSubmit to onClose, however we would be breaking
 *     other modules that rely on it. Maybe when doing a formal port to D7?
 *   - customDialogOptions: an object with custom jQuery UI Dialog options.
 *
 * @return
 *   If the modal frame was opened true, otherwise false.
 */
Drupal.modalFrame.open = function(options) {
  var self = this;

  // Just one modal is allowed.
  if (self.isOpen || $('#modalframe-container').size()) {
    return false;
  }

  // Make sure the modal frame is not resized until a child document is loaded.
  self.isChildLoaded = false;

  // If not ready yet, install custom event handlers to the parent window
  // for proper communication with the child window.
  if (!self.parentReady) {
    // Install a custom event handler to allow child windows to tell us they
    // have just loaded a document.
    $(window).bind(self.eventHandlerName('childLoad'), function(event, iFrameWindow, isClosing) {
      self.bindChild(iFrameWindow, isClosing);
    });

    // Install a custom event handler to allow child windows to tell us they
    // are unloading the document.
    $(window).bind(self.eventHandlerName('childUnload'), function(event, iFrameWindow) {
      self.unbindChild(iFrameWindow);
    });

    // Install a custom event handler to allow child windows to tell us they
    // want to close the Modal Frame.
    $(window).bind(self.eventHandlerName('childClose'), function(event, args, statusMessages) {
      self.close(args, statusMessages);
    });

    // Ok, so we're ready to properly communicate with child windows.
    self.parentReady = true;
  }

  // For some reason, onblur events attached by the Drupal autocomplete
  // behavior do not fire after a Modal Frame has been closed. I spent a lot
  // of time trying to figure out the cause, but I've been unable to. :(
  // Anyway, here's a temporary fix that makes sure the autocomplete popup
  // is hidden as soon as the user selects a candidate. I'm not enterily
  // happy with this solution, but it seems to solve the problem for now.
  // Please, see the following issue: http://drupal.org/node/635754
  if (Drupal.jsAC && !Drupal.jsAC.prototype.modalFrameSelect) {
    Drupal.jsAC.prototype.modalFrameSelect = Drupal.jsAC.prototype.select;
    Drupal.jsAC.prototype.select = function(node) {
      this.modalFrameSelect(node);
      this.hidePopup();
    };
  }

  // Build the modal frame options structure.
  self.options = {
    url: options.url,
    width: options.width,
    height: options.height,
    autoFit: (options.autoFit == undefined || options.autoFit),
    draggable: (options.draggable == undefined || options.draggable),
    onOpen: options.onOpen,
    onLoad: options.onLoad,
    onSubmit: options.onSubmit,
    customDialogOptions: options.customDialogOptions
  };

  // Create the dialog and related DOM elements.
  self.create();

  // Open the dialog offscreen where we can set its size, etc.
  self.iframe.$container.dialog('option', {position: ['-999em', '-999em']}).dialog('open');

  return true;
};

/**
 * Create the modal dialog.
 */
Drupal.modalFrame.create = function() {
  var self = this;

  // Note: We use scrolling="yes" for IE as a workaround to yet another IE bug
  // where the horizontal scrollbar is always rendered, no matter how wide the
  // iframe element is defined. IE also requires a few more non-std properties.
  self.iframe.$element = $('<iframe id="modalframe-element" name="modalframe-element"'+ ($.browser.msie ? ' scrolling="yes" frameborder="0" allowTransparency="true"' : '') +'/>');
  self.iframe.$container = $('<div id="modalframe-container"/>').append(self.iframe.$element);
  $('body').append(self.iframe.$container);

  // Open callback for the jQuery UI dialog.
  var dialogOpen = function() {
    // Unbind the keypress handler installed by ui.dialog itself.
    // IE does not fire keypress events for some non-alphanumeric keys
    // such as the tab character. http://www.quirksmode.org/js/keys.html
    // Also, this is not necessary here because we need to deal with an
    // iframe element that contains a separate window.
    // We'll try to provide our own behavior from bindChild() method.
    $('.modalframe').unbind('keypress.ui-dialog');

    // Adjust close button features.
    $('.modalframe .ui-dialog-titlebar-close:not(.modalframe-processed)').addClass('modalframe-processed')
      .attr('href', 'javascript:void(0)')
      .attr('title', Drupal.t('Close'))
      .unbind('click').bind('click', function() { self.close(false); return false; });

    // Adjust titlebar.
    if (!self.options.draggable) {
      $('.modalframe .ui-dialog-titlebar').css('cursor', 'default');
    }

    // Fix dialog position on the viewport.
    self.fixPosition($('.modalframe'), true);

    // Compute initial dialog size.
    var dialogSize = self.sanitizeSize({width: self.options.width, height: self.options.height});

    // Compute frame size and dialog position based on dialog size.
    var frameSize = $.extend({}, dialogSize);
    frameSize.height -= $('.modalframe .ui-dialog-titlebar').outerHeight(true);
    var dialogPosition = self.computeCenterPosition($('.modalframe'), dialogSize);

    // Adjust size of the iframe element and container.
    $('.modalframe').width(dialogSize.width).height(dialogSize.height);
    self.iframe.$container.width(frameSize.width).height(frameSize.height);
    self.iframe.$element.width(frameSize.width).height(frameSize.height);

    // Update the dialog size so that UI internals are aware of the change.
    self.iframe.$container.dialog('option', {width: dialogSize.width, height: dialogSize.height});

    // Hide the dialog, center it on the viewport and then fade it in with
    // the iframe still hidden, until the child document is loaded.
    self.iframe.$element.hide();
    $('.modalframe').hide().css({top: dialogPosition.top, left: dialogPosition.left});
    $('.modalframe').fadeIn('slow', function() {
      // Load the document on the hidden iframe (see bindChild method).
      self.load(self.options.url);
    });

    // Install the window resize event handler if autoFit option is enabled.
    if (self.options.autoFit) {
      var $window = $(window);
      self.currentWindowSize = {width: $window.width(), height: $window.height()};
      $window.bind(self.eventHandlerName('resize'), function() {
        // Prevent from resizing the modal frame while a child document is
        // loading or unloading. Note that we will resize the modal frame
        // anyway, as soon as it is loaded, so we can safely ignore these
        // events until then.
        if (!self.isChildLoaded) {
          return;
        }
        // Check that we really have a modal frame opened.
        if (!self.isOpen || !self.isObject(self.iframe.documentSize)) {
          return;
        }
        // Do not resize the modal frame if the window dimensions have not
        // changed more than a few pixels tall or wide.
        var newWindowSize = {width: $window.width(), height: $window.height()};
        if (Math.abs(self.currentWindowSize.width - newWindowSize.width) > 5 || Math.abs(self.currentWindowSize.height - newWindowSize.height) > 5) {
          self.currentWindowSize = newWindowSize;
          self.resize();
        }
      });
    }

    // Allow external modules to intervene when the modal frame is just opened.
    if ($.isFunction(self.options.onOpen)) {
      self.options.onOpen(self);
    }

    self.isOpen = true;
  };

  // BeforeClose callback for the jQuery UI dialog.
  var dialogBeforeClose = function() {
    if (self.beforeCloseEnabled) {
      return true;
    }
    if (!self.beforeCloseIsBusy) {
      self.beforeCloseIsBusy = true;
      setTimeout(function() { self.close(false); }, 1);
    }
    return false;
  };

  // Close callback for the jQuery UI dialog.
  var dialogClose = function() {
    if (self.options.autoFit) {
      $(window).unbind(self.eventHandlerName('resize'));
      delete self.currentWindowSize;
    }
    $(document).unbind(self.eventHandlerName('keydown'));
    $('.modalframe .ui-dialog-titlebar-close').unbind(self.eventHandlerName('keydown'));
    self.fixPosition($('.modalframe'), false);
    try {
      self.iframe.$element.remove();
      self.iframe.$container.dialog('destroy').remove();
    } catch(e) {};
    delete self.iframe.documentSize;
    delete self.iframe.Drupal;
    delete self.iframe.$element;
    delete self.iframe.$container;
    if (self.beforeCloseEnabled) {
      delete self.beforeCloseEnabled;
    }
    if (self.beforeCloseIsBusy) {
      delete self.beforeCloseIsBusy;
    }
    self.isOpen = false;
  };

  // Options for the jQuery UI dialog.
  var dialogOptions = {
    modal: true,
    autoOpen: false,
    closeOnEscape: true,
    draggable: self.options.draggable,
    resizable: false,
    title: Drupal.t('Loading...'),
    dialogClass: 'modalframe',
    open: dialogOpen,
    beforeclose: dialogBeforeClose,
    close: dialogClose
  };

  // Hide the contents of the dialog while dragging?
  if (self.options.draggable) {
    dialogOptions.dragStart = function() {
      self.iframe.$container.hide();
    };
    dialogOptions.dragStop = function() {
      self.iframe.$container.show('fast');
    };
  }

  // Allow external scripts to override the default jQuery UI Dialog options.
  $.extend(dialogOptions, self.options.customDialogOptions);

  // Open the jQuery UI dialog offscreen.
  self.iframe.$container.dialog(dialogOptions);
};

/**
 * Load the given URL into the dialog iframe.
 */
Drupal.modalFrame.load = function(url) {
  var self = this;
  var iframe = self.iframe.$element.get(0);
  // Get the document object of the iframe window.
  // @see http://xkr.us/articles/dom/iframe-document/
  var doc = (iframe.contentWindow || iframe.contentDocument);
  if (doc.document) {
    doc = doc.document;
  }
  // Install an onLoad event handler for the iframe element. This is a
  // last resort mechanism, in case the server-side code of the child
  // window is broken and it does not invoke modalframe_child_js().
  self.iframe.$element.bind('load', function() {
    // If the iframe is not visible, this means the bindChild() method
    // has not been invoked, hence something went wrong. If we do not
    // show the iframe now, we'll get an endless loading animation.
    // Showing the iframe is not the perfect solution, but it is better
    // than nothing. Probably, there's a bug in the server-side script.
    if (!self.iframe.$element.is(':visible')) {
      setTimeout(function() {
        try {
          self.iframe.$element.fadeIn('fast');
        } catch(e) {}
      }, 1000);
    }
  });
  doc.location.replace(url);
};

/**
 * Check if the dialog can be closed.
 */
Drupal.modalFrame.canClose = function() {
  //alert('!');
  var self = this;
  if (!self.isOpen) {
    return false;
  }
  if (self.isObject(self.iframe.Drupal)) {
    // Ignore errors that may happen here.
    try {
      // Prompt the user for confirmation to close the dialog if the child
      // window has dirty forms.
      if (self.isObject(self.iframe.Drupal.dirtyForms)) {
        if (self.iframe.Drupal.dirtyForms.isDirty() && !confirm(self.dirtyFormsWarning)) {
          return false;
        }
        self.iframe.Drupal.dirtyForms.warning = null;
      }
      // Disable onBeforeUnload behaviors on the child window.
      if (self.isObject(self.iframe.Drupal.onBeforeUnload)) {
        self.iframe.Drupal.onBeforeUnload.disable();
      }
    } catch(e) {}
  }
  return true;
};

/**
 * Close the modal frame.
 */
Drupal.modalFrame.close = function(args, statusMessages) {
  var self = this;

  // Check if the dialog can be closed.
  if (!self.canClose()) {
    delete self.beforeCloseIsBusy;
    return false;
  }

  // Hide and destroy the dialog.
  function closeDialog() {
    // Prevent double execution when close is requested more than once.
    if (!self.isObject(self.iframe.$container)) {
      return;
    }
    self.beforeCloseEnabled = true;
    self.iframe.$container.dialog('close');
    if ($.isFunction(self.options.onSubmit)) {
      self.options.onSubmit(args, statusMessages);
    }
  }
  if (!self.isObject(self.iframe.$element) || !self.iframe.$element.size() || !self.iframe.$element.is(':visible')) {
    closeDialog();
  }
  else {
    self.iframe.$element.fadeOut('fast', function() {
      $('.modalframe').animate({height: 'hide', opacity: 'hide'}, closeDialog);
    });
  }
  return true;
};

/**
 * Bind the child window.
 */
Drupal.modalFrame.bindChild = function(iFrameWindow, isClosing) {
  var self = this;
  var $iFrameWindow = iFrameWindow.jQuery;
  var $iFrameDocument = $iFrameWindow(iFrameWindow.document);
  self.iframe.Drupal = iFrameWindow.Drupal;

  // We are done if the child window is closing.
  if (isClosing) {
    return;
  }

  // Update the dirty forms warning on the child window.
  if (self.isObject(self.iframe.Drupal.dirtyForms)) {
    self.iframe.Drupal.dirtyForms.warning = self.dirtyFormsWarning;
  }

  // Update the dialog title with the child window title.
  $('.modalframe .ui-dialog-title').html($iFrameDocument.attr('title'));

  // Setting tabIndex makes the div focusable.
  // Setting outline to 0 prevents a border on focus in Mozilla.
  // Inspired by ui.dialog initialization code.
  $iFrameDocument.attr('tabIndex', -1).css('outline', 0);

  // Perform animation to show the iframe element.
  self.iframe.$element.fadeIn('slow', function() {
    // @todo: Watch for experience in the way we compute the size of the
    // iframed document. There are many ways to do it, and none of them
    // seem to be perfect. Note though, that the size of the iframe itself
    // may affect the size of the child document, specially on fluid layouts.
    // If you get in trouble, then I would suggest to choose a known dialog
    // size and disable the autoFit option.
    self.iframe.documentSize = {width: $iFrameDocument.width(), height: $iFrameWindow('body').height() + 25};

    // If the autoFit option is enabled, resize the modal frame based on the
    // size of the child document just loaded.
    if (self.options.autoFit) {
      self.currentWindowSize = {width: $(window).width(), height: $(window).height()};
      self.resize();

      // Install a custom resize handler to allow the child window to trigger
      // changes to the modal frame size.
      $(window).unbind(self.eventHandlerName('childResize')).bind(self.eventHandlerName('childResize'), function() {
        self.iframe.documentSize = {width: $iFrameDocument.width(), height: $iFrameWindow('body').height() + 25};
        self.resize();
      });
    }

    // Try to enhance keyboard based navigation of the modal dialog.
    // Logic inspired by the open() method in ui.dialog.js, and
    // http://wiki.codetalks.org/wiki/index.php/Docs/Keyboard_navigable_JS_widgets

    // Get a reference to the close button.
    var $closeButton = $('.modalframe .ui-dialog-titlebar-close');

    // Search tabbable elements on the iframed document to speed up related
    // keyboard events.
    // @todo: Do we need to provide a method to update these references when
    // AJAX requests update the DOM on the child document?
    var $iFrameTabbables = $iFrameWindow(':tabbable:not(form)');
    var $firstTabbable = $iFrameTabbables.filter(':first');
    var $lastTabbable = $iFrameTabbables.filter(':last');

    // Set focus to the first tabbable element in the content area or the
    // first button. If there are no tabbable elements, set focus on the
    // close button of the dialog itself.
    if (!$firstTabbable.focus().size()) {
      $iFrameDocument.focus();
    }

    // Unbind keyboard event handlers that may have been enabled previously.
    $(document).unbind(self.eventHandlerName('keydown'));
    $closeButton.unbind(self.eventHandlerName('keydown'));

    // When the focus leaves the close button, then we want to jump to the
    // first/last inner tabbable element of the child window.
    $closeButton.bind(self.eventHandlerName('keydown'), function(event) {
      if (event.keyCode && event.keyCode == $.ui.keyCode.TAB) {
        var $target = (event.shiftKey ? $lastTabbable : $firstTabbable);
        if (!$target.size()) {
          $target = $iFrameDocument;
        }
        setTimeout(function() { $target.focus(); }, 10);
        return false;
      }
    });

    // When the focus leaves the child window, then drive the focus to the
    // close button of the dialog.
    $iFrameDocument.bind(self.eventHandlerName('keydown'), function(event) {
      if (event.keyCode) {
        if (event.keyCode == $.ui.keyCode.TAB) {
          if (event.shiftKey && event.target == $firstTabbable.get(0)) {
            setTimeout(function() { $closeButton.focus(); }, 10);
            return false;
          }
          else if (!event.shiftKey && event.target == $lastTabbable.get(0)) {
            setTimeout(function() { $closeButton.focus(); }, 10);
            return false;
          }
        }
        else if (event.keyCode == $.ui.keyCode.ESCAPE) {
          setTimeout(function() { self.close(false); }, 10);
          return false;
        }
      }
    });

    // When the focus is captured by the parent document, then try
    // to drive the focus back to the first tabbable element, or the
    // close button of the dialog (default).
    $(document).bind(self.eventHandlerName('keydown'), function(event) {
      if (event.keyCode && event.keyCode == $.ui.keyCode.TAB) {
        setTimeout(function() {
          if (!$iFrameWindow(':tabbable:not(form):first').focus().size()) {
            $closeButton.focus();
          }
        }, 10);
        return false;
      }
    });

    // Our window resize handler can proceed while we have a document loaded.
    self.isChildLoaded = true;

    // Get rid of the loading animation.
    self.iframe.$container.addClass('modalframe-loaded');

    // Allow external modules to intervene when the child document in the modal
    // frame is fully loaded.
    if ($.isFunction(self.options.onLoad)) {
      self.options.onLoad(self, $iFrameWindow, $iFrameDocument);
    }
  });
};

/**
 * Unbind the child window.
 */
Drupal.modalFrame.unbindChild = function(iFrameWindow) {
  var self = this;

  // Lock our window resize handler until we have a new child document loaded.
  self.isChildLoaded = false;

  // Prevent memory leaks by explicitly unbinding event handlers attached
  // to the child document.
  iFrameWindow.jQuery(iFrameWindow.document).unbind(self.eventHandlerName('keydown'));
  $(window).unbind(self.eventHandlerName('childResize'));

  // Change the modal dialog title.
  $('.modalframe .ui-dialog-title').html(Drupal.t('Please, wait...'));

  // Restore the loading animation.
  self.iframe.$container.removeClass('modalframe-loaded');

  // Hide the iframe element.
  self.iframe.$element.fadeOut('fast');
};

/**
 * Check if the given variable is an object.
 */
Drupal.modalFrame.isObject = function(something) {
  return (something !== null && typeof something === 'object');
};

/**
 * Sanitize dialog size.
 */
Drupal.modalFrame.sanitizeSize = function(size) {
  var width, height;
  var $window = $(window);
  var minWidth = 300, maxWidth = $window.width() - 30;
  if (typeof size.width != 'number') {
    width = maxWidth;
  }
  else if (size.width < minWidth || size.width > maxWidth) {
    width = Math.min(maxWidth, Math.max(minWidth, size.width));
  }
  else {
    width = size.width;
  }
  var minHeight = 100, maxHeight = $window.height() - 30;
  if (typeof size.height != 'number') {
    height = maxHeight;
  }
  else if (size.height < minHeight || size.height > maxHeight) {
    height = Math.min(maxHeight, Math.max(minHeight, size.height));
  }
  else {
    height = size.height;
  }
  return {width: width, height: height};
};

/**
 * Fix the position of the modal frame within the viewport.
 *
 * Possible alternative to position:'fixed' for IE6:
 * @see http://www.howtocreate.co.uk/fixedPosition.html
 */
Drupal.modalFrame.fixPosition = function($element, isOpen) {
  var self = this, $window = $(window);
  if ($.browser.msie && parseInt($.browser.version) <= 6) {
    // IE6 does not support position:'fixed'.
    // Lock the window scrollBar instead.
    if (isOpen) {
      var yPos = $window.scrollTop();
      var xPos = $window.scrollLeft();
      $window.bind(self.eventHandlerName('scroll'), function() {
        window.scrollTo(xPos, yPos);
        // Default browser action cannot be prevented here.
      });
    }
    else {
      $window.unbind(self.eventHandlerName('scroll'));
    }
  }
  else {
    // Use CSS to do it on other browsers.
    if (isOpen) {
      var offset = $element.offset();
      $element.css({
        left: (offset.left - $window.scrollLeft()),
        top: (offset.top - $window.scrollTop()),
        position: 'fixed'
      });
    }
  }
};

/**
 * Compute the position to center an element with the given size.
 */
Drupal.modalFrame.computeCenterPosition = function($element, elementSize) {
  var $window = $(window);
  var position = {
    left: Math.max(0, parseInt(($window.width() - elementSize.width) / 2)),
    top: Math.max(0, parseInt(($window.height() - elementSize.height) / 2))
  };
  if ($element.css('position') != 'fixed') {
    var $document = $(document);
    position.left += $document.scrollLeft();
    position.top += $document.scrollTop();
  }
  return position;
};

/**
 * Resize the modal frame based on the current document size.
 *
 * This method may be invoked by:
 * - The parent window resize handler (when the parent window is resized).
 * - The bindChild() method (when the child document is loaded).
 * - The child window resize handler (when the child window is resized).
 */
Drupal.modalFrame.resize = function() {
  var self = this, documentSize = self.iframe.documentSize;

  // Compute frame and dialog size based on document size.
  var maxSize = self.sanitizeSize({}), titleBarHeight = $('.modalframe .ui-dialog-titlebar').outerHeight(true);
  var frameSize = self.sanitizeSize(documentSize), dialogSize = $.extend({}, frameSize);
  if ((dialogSize.height + titleBarHeight) <= maxSize.height) {
    dialogSize.height += titleBarHeight;
  }
  else {
    dialogSize.height = maxSize.height;
    frameSize.height = dialogSize.height - titleBarHeight;
  }

  // Compute dialog position centered on viewport.
  var dialogPosition = self.computeCenterPosition($('.modalframe'), dialogSize);

  var animationOptions = $.extend(dialogSize, dialogPosition);

  // Perform the resize animation.
  $('.modalframe').animate(animationOptions, 'fast', function() {
    // Proceed only if the dialog still exists.
    if (self.isObject(self.iframe.$element) && self.isObject(self.iframe.$container)) {
      // Resize the iframe element and container.
      $('.modalframe').width(dialogSize.width).height(dialogSize.height);
      self.iframe.$container.width(frameSize.width).height(frameSize.height);
      self.iframe.$element.width(frameSize.width).height(frameSize.height);

      // Update the dialog size so that UI internals are aware of the change.
      self.iframe.$container.dialog('option', {width: dialogSize.width, height: dialogSize.height});
    }
  });
};

/**
 * Render the throbber.
 */
Drupal.theme.prototype.modalFrameThrobber = function() {
  return '<div class="modalframe-throbber">&nbsp;</div>';
};

})(jQuery);
;
// $Id$
/**
 * Modal-frame behaviour for cstarchello
 */
(function($){
  /**
   * The Drupal.behaviors.myModule structure is used to add js to the
   * jQuery document onload event.
   * This is our onSubmit callback that will be called from the child window
   * when it is requested by a call to modalframe_close_dialog() performed
   * from server-side submit handlers.
   */
  Drupal.behaviors.cstarchelloGeneralModalframe = function(){

    /**
     * Open a modal frame with the defined url.
     *
     * @param options
     *   Properties of the modal frame to open:
     *   - url: the URL of the page to open in the modal frame.
     *   All the other default options are set internal.
     u     */
    Drupal.modalFrame.smartOpen = function(url){

      var size = getModalFrameSize(url);

      var modalOptions = {
        url: url,
        autoFit: false,
        draggable: false,
        width: size.width,
        height: size.height,
        onSubmit: onSubmitCallbackCstarchelloModalframe,
        customDialogOptions: {
          bgiframe: true,
          modal: true,
          overlay: {
            backgroundColor: '#000',
            opacity: 0.5
          }
        }
      };
      Drupal.modalFrame.open(modalOptions);
    }

    /**
     * Extend the js object
     * @param {Object} url
     */
    Drupal.modalFrame.reOpen = function(url){
      Drupal.modalFrame.close();
      setTimeout(function(){
        Drupal.modalFrame.smartOpen(Drupal.settings.basePath + url);
      }, 1000);
    }

    /**
     * Callback function to handle page refresh and new modalframes
     * @param {Object} args
     * @param {Object} statusMessages
     */
    function onSubmitCallbackCstarchelloModalframe(args, statusMessages){
      if (args && args.message) {
        // Provide a simple feedback alert deferred a little.
        setTimeout(function(){
          alert(args.message);
        }, 1000);
      }

      if (args && args.url) {
        Drupal.modalFrame.smartOpen(args.url);
      }
      //Only refresh if no other frame is opened
      // Refresh the parent page if asked for. Basically needed to refresh the page automatically after the user logged in.
      else if (args && args.refreshParentPage) {
          // Refresh by re-assigning the window location href.
          var href = window.location.href;
          if (href.lastIndexOf('?email_approved=') > 0) {
            // Remove the query part of the url to prevent repetition of email validation confirmation dialog popping up on reload.
            href = href.substring(0, href.lastIndexOf('?email_approved='));
          }
          if (href.lastIndexOf('#') > 0) {
            href = href.substring(0, href.lastIndexOf('#'));
          }

          if (args.refreshParentPageQuery) {
            if (href.lastIndexOf('?') > 0) {
              href = href + '&' + args.refreshParentPageQuery;
            }
            else {
              href = href + '?' + args.refreshParentPageQuery; // Ok, this could be done way more subtle...
            }
          }

          //Hmm this doesnt work, anchor and refresh
          /*
          if (args.anchor) {
            //Remove previous anchors
            if (href.lastIndexOf('#' + args.anchor) > 0) {
              href = href.substring(0, href.lastIndexOf('#' + args.anchor));
            }
            //href = href + '#' + args.anchor;
          }*/

        window.location.href = href;
        }
    }

    $('.cstarchello-modalframe-child:not(.cstarchello-modalframe-processed)').addClass('cstarchello-modalframe-processed').click(function(){
      var element = this;
      // Open the modal frame dialog.
      Drupal.modalFrame.smartOpen($(element).attr('href'));
      // Prevent default action of the link click event.
      return false;
    });

    // Check if the url of the current page has a specific cgi parameter added that is used
    // as a trigger to popup the dialog with a url that is passed by Drupal js settings.
    if (Drupal.settings.archello !== undefined && Drupal.settings.archello.urlModalFrame !== undefined) {
      // Open the modal frame dialog.
      Drupal.modalFrame.smartOpen(Drupal.settings.archello.urlModalFrame);
    }


  }

})(jQuery);

var sizes = [];

// fill the array[url, width, height]

//Company
sizes.push(['/add-company/', 429, 541]);
sizes.push(['/company/claim/', 421, 482]);
sizes.push(['/company/person/', 421, 543]);
sizes.push(['/company/disconnect/', 421, 278]);
sizes.push(['/company/nopermission', 421, 553]);

//Project
sizes.push(['/add-project/step/', 900, 660]);
sizes.push(['/project/add/product/', 421, 600]);
sizes.push(['/project/add/material/', 421, 600]);
sizes.push(['/add-related/', 421, 614]);
sizes.push(['/add-comment/', 421, 355]);
sizes.push(['/project/badge/', 925, 675]);
sizes.push(['/project/company/', 421, 566]);
sizes.push(['/project/passport/', 777, 693]);
sizes.push(['/edit-project/step/', 900, 650]);

//Product & Material
sizes.push(['/product/add/project/', 421, 600]);
sizes.push(['/material/add/project/', 421, 600]);
sizes.push(['/edit-product/step/', 900, 660]);
sizes.push(['/edit-material/step/', 900, 660]);
sizes.push(['/add-product/', 900, 660]);
sizes.push(['/add-material/', 900, 660]);

//Person
sizes.push(['/person/disconnect/', 421, 273]);
sizes.push(['/person/connect/', 421, 535]);
sizes.push(['/person/permission/', 421, 680]);

//Story
sizes.push(['/story/step/', 900, 660]);

//3D Model
sizes.push(['/enlarge/model/', 920, 675]);
sizes.push(['/model/', 900, 650]);

//User
sizes.push(['/archello-user/sign-up/', 900, 480]);
sizes.push(['/archello-user/login/', 415, 339]);
sizes.push(['/archello-user/password/', 415, 339]);
sizes.push(['/archello-user/sign-up-step-3/', 415, 480]);

//Media
sizes.push(['/enlarge/media/', 920, 820]);
sizes.push(['/edit/media/', 421, 588]);

//MyCompany
sizes.push(['/mycompany/profile/edit/', 900, 595]);
sizes.push(['/mycompany/profile/interest/edit/', 900, 674]);

//MyPerson
sizes.push(['/myperson/profile/interest/edit/', 900, 674]);
sizes.push(['/myperson/profile/edit/', 900, 580]);
sizes.push(['/myperson/we/edit/', 900, 638]);

//Follow
sizes.push(['/follow/', 421, 273]);
sizes.push(['/unfollow/', 421, 300]);
//Other
sizes.push(['/delete/', 421, 273]);
sizes.push(['/request-documentation/', 900, 765]); // grootte van de modalframe voor request documentation
sizes.push(['/contact-company/', 900, 765]); // grootte van de modalframe voor request documentation




/**
 * Get the width and height for the specific url
 * @param {Object} url
 */
function getModalFrameSize(url){
  for (var i = 0; i < sizes.length; i++) {
    if (url.indexOf(sizes[i][0]) >= 0) {
      return {
        width: sizes[i][1],
        height: sizes[i][2]
      }
    }
  }
  // fallback
  return {
    width: 500,
    height: 500
  }
}
;
// $Id$

(function ($) {
  // The Drupal.behaviors.MODULENAME structure is used to add js to the jQuery document onload event
  Drupal.behaviors.archelloMain = function(context) {
  
    // @todo Only add tag if the it is not there yet.
    
    // Add browser switch to body tag.
    var browser;
    if ($.browser.mozilla) {
      browser = "browser-firefox";
    }
    else if($.browser.msie) {
      browser = "browser-msie";
    }
    else if($.browser.opera) {
      browser = "browser-opera";
    }
    else if($.browser.safari) {
      browser = "browser-safari";
    }
    else {
      browser = "browser-unknown";
    }
    // @todo add versions from $.browser.version
    $('body', context).addClass(browser);
    
  };
})(jQuery);
;
/**
 * 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),
            $bottom_summary = $('.bottom-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(){
            // hack: disable anonymous votes. 
            if (Drupal.settings.fivestar.isAnonymous == 'yes') {
              $('#feedback-anonymous').removeClass('feedback-anonymous');
              return false;
            }
            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')) {
              setBottomFeedbackText(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 setBottomFeedbackText = function(text) {
          $bottom_summary.html(text);
        };

        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 
              setBottomFeedbackText(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: poormanscron.js,v 1.1.2.3 2010/01/17 00:27:52 davereid Exp $
(function ($) {

/**
 * Checks to see if the cron should be automatically run.
 */
Drupal.behaviors.cronCheck = function(context) {
  if (Drupal.settings.cron.runNext || false) {
    $('body:not(.cron-check-processed)', context).addClass('cron-check-processed').each(function() {
      // Only execute the cron check if its the right time.
      if (Math.round(new Date().getTime() / 1000.0) >= Drupal.settings.cron.runNext) {
        $.get(Drupal.settings.cron.basePath + '/run-cron-check');
      }
    });
  }
};

})(jQuery);
;
// $Id$

(function($){
  Drupal.behaviors.cstarchelloDetailpagesRelated = function(){
    $(function(){
      $('.columns-holder a[class*=external]').click(function(){
        window.open(this.href);
        return false;
      });
    });
    
  };
  Drupal.behaviors.cstarchelloProjectProduct = function(){
    $(function(){
	  $('form#cstarchello-mini-flows-project-product-form select#edit-select').change(function () {
	  	$("form#cstarchello-mini-flows-project-product-form div.scroll ul.company-products").addClass("company-products-hidden");
	  	$("#product-"+$(this).val()).removeClass("company-products-hidden").css('margin-top',0);
        return false;
      });
    });
    
  };
})(jQuery);

function connectProduct(obj, proj_id, prod_id) {
	if ($(obj).hasClass('connect')) {
		text = 'Disconnect';
	}else{
		text = 'Connect';
	}
	$(obj).html(text).toggleClass('connect').toggleClass('disconnect');
	$.getJSON(Drupal.settings.basePath + 'project/add-product/json', {proj_id:proj_id, prod_id:prod_id}, function(jso){});
}

function showCompanyItem(id) {
	$('div.search-results > ul.companies-result-list li').each(function(){
		$(this).addClass('inactive').removeClass('active');
		var temp = '' + $(this).attr('onclick'); 
		if(temp.indexOf(id) > -1){
			if ( $(this).hasClass('inactive') ) {
				$(this).removeClass('inactive').addClass('active');
			}
		}
	});
	var info = $('div.company_info').each(
	function() {
		if ( !$(this).hasClass('inactive') ) {
			$(this).addClass('inactive');
		}
	});
	$('#'+id).removeClass('inactive');
	return false;
}
function showPersonItem(id) {
	$('div.search-results > ul.people-result-list li').each(function(){
		$(this).addClass('inactive').removeClass('active');
		var temp = '' + $(this).attr('onclick'); 
		if(temp.indexOf(id) > -1){
			if ( $(this).hasClass('inactive') ) {
				$(this).removeClass('inactive').addClass('active');
			}
		}
	});
	var info = $('div.person_info').each(
	function() {
		if ( !$(this).hasClass('inactive') ) {
			$(this).addClass('inactive');
		}
	});
	$('#'+id).removeClass('inactive');
	return false;
}

$(document).ready(function(){
	$('.scroll div ul').each(function(){
		//if($(this).children('li').size() < 3) {
			$(this).children('li:last-child').addClass("stippel");
		//}
	});
});
;

(function($){

/**
 * The Drupal behavior to add the $.hint() behavior to elements.
 */
Drupal.behaviors.hint = function(content){
    // Even though it's unlikely that another class name would be used, we ensure
    // that the behavior uses the default class names used in the module.
    jQuery('input.hint-enabled, textarea.hint-enabled', content).hint({
        triggerClass: 'hint-enabled'
    });
}

/**
 * The jQuery method $.hint().
 *
 * This method can be used on any text field or password element and is not
 * Drupal-specific. Any elements using hint must have a "title" attribute,
 * which will be used as the hint.
 */
jQuery.fn.hint = function(options){
    var opts = jQuery.extend(false, jQuery.fn.hint.defaults, options);
    
    $(this).find('input').andSelf().filter('[type=text], [type=password]').each(function(){
        var $element = $(this);
        // only trigger if title is set and no default value
        if ($element.attr('title') != '' && ($element.val() == '' || $element.val() == $element.attr('title'))) {
            // set the hint text
            $element.addClass('hint-active');
            $element.val($element.attr('title'));
            
            $element.focus(function(){
                if ($element.val() == $element.attr('title')) {
                    $element.val('');
                    $element.removeClass('hint-active');
                }
            });
            
            $element.blur(function(){
                if ($element.val() == '') {
                    $element.val($element.attr('title'));
		            $element.addClass('hint-active');
                }
            });
        }
    });

    $(this).find('textarea').andSelf().each(function(){
        var $element = $(this);
        // only trigger if title is set and no default value
        if ($element.attr('title') != '' && ($element.val() == '' || $element.val() == $element.attr('title'))) {
            // set the hint text
            $element.val($element.attr('title'));
            $element.addClass('hint-active');
            
            $element.focus(function(){
                if ($element.val() == $element.attr('title')) {
                    $element.val('');
                    $element.removeClass('hint-active');
                }
            });
            
            $element.blur(function(){
                if ($element.val() == '') {
                    $element.val($element.attr('title'));
                    $element.addClass('hint-active');
                }
            });
        }
    });
    
};

jQuery.fn.hint.defaults = {
    // A class that will trigger the hint if $.hint() is used on multiple
    // elements or the entire page.
    triggerClass: 'hint-enabled'
};

})(jQuery);
;
// $Id: modalframe_filter_tips.js,v 1.1.2.1 2010/01/01 20:19:39 markuspetrux Exp $
// $Id$

(function ($) {
Drupal.behaviors.cstarchelloWorkflowMedia = function () {
  // The Drupal.behaviors.myModule structure is used to add js to the jQuery document onload event
  // This is our onSubmit callback that will be called from the child window
  // when it is requested by a call to modalframe_close_dialog() performed
  // from server-side submit handlers.

  $('.cstarchello-workflow-media-enlarge-child:not(.cstarchello-workflow-media-enlarge-processed)').addClass('cstarchello-workflow-media-enlarge-processed').click(function () {
    var element = this;

    // Hide the messages are before opening a new dialog.
    $('.cstarchello-workflow-media-messages').hide('fast');

    // Build modal frame options.
    var modalOptions = {
      url: $(element).attr('href'),
      autoFit: false,
      draggable: false,
      customDialogOptions: {
        bgiframe: true,  // This option is needed to fix another bug in IE6 with selectboxes poking through overlay.
        modal: true,
        overlay: {
          backgroundColor: '#000',
          opacity: 0.5
        }
      }
    };

    // Try to obtain the dialog size from the className of the element.
    var regExp = /^.*cstarchello-workflow-media-enlarge-size\[\s*([0-9]*\s*,\s*[0-9]*)\s*\].*$/;
    if (typeof element.className == 'string' && regExp.test(element.className)) {
      var size = element.className.replace(regExp, '$1').split(',');
      modalOptions.width = parseInt(size[0].replace(/ /g, ''));
      modalOptions.height = parseInt(size[1].replace(/ /g, ''));
    }

    // Open the modal frame dialog.
    Drupal.modalFrame.open(modalOptions);

    // Prevent default action of the link click event.
    return false;
  });
};

})(jQuery);
;
// $Id$

(function ($) {
  // The Drupal.behaviors.myModule structure is used to add js to the jQuery document onload event.
  Drupal.behaviors.cstarchelloDetailpages = function (context) {

    // Add a click event for the 'add tags' link.
    $('.story-free-tagging a.add-tags').click(function (event) {
      event.preventDefault();
      $('.story-free-tagging .hidden').removeClass('hidden');
      $('.story-free-tagging .button-add-tags').hide('fast');
      // @todo Maybe hide the delete buttons too, to avoid users loosing their input.
    });

    // Add a click event for the 'save tags' link.
    $('.story-free-tagging a.save-tags').click(function (event) {
      event.preventDefault();
      var nid  = $('.story-free-tagging #field-story-nid').val();
      var tags = $('.story-free-tagging #field-add-tags.hint-cleared').val();

      if (nid && tags) {
        $.getJSON(Drupal.settings.basePath + 'en/cstarchello-story/json/add-tags', {'nid': nid, 'tags': tags}, function (jso, textStatus) {
          if (textStatus == 'success') {
            $('.story-free-tagging').replaceWith(jso['html']);
            Drupal.attachBehaviors('.story-free-tagging');
          }
        });
      }
    });

    // Add a click event for the 'delete tag' link.
    $('.story-free-tagging a.delete-tag').click(function (event) {
      event.preventDefault();
      var nid  = $('.story-free-tagging #field-story-nid').val();
      var segments = $(this).parents('.tag').attr('id').split('-');
      var tid = segments[1];

      if (tid && confirm(Drupal.t('Delete this tag?'))) {
        $.getJSON(Drupal.settings.basePath + 'cstarchello-story/json/delete-tag', {'nid': nid, 'tid': tid}, function (jso, textStatus) {
          if (textStatus == 'success') {
            $('.story-free-tagging').replaceWith(jso['html']);
            Drupal.attachBehaviors('.story-free-tagging');
          }
        });
      }
    });

    // Add a focus event for deleting the hint from the tags input form field.
    $('.story-free-tagging #field-add-tags.hint').focus(function (event) {
      $('.story-free-tagging #field-add-tags:not(.hint-cleared)').val('').addClass('hint-cleared');
    });

  };
})(jQuery);
;

(function($){$.toJSON=function(o)
{if(typeof(JSON)=='object'&&JSON.stringify)
return JSON.stringify(o);var type=typeof(o);if(o===null)
return"null";if(type=="undefined")
return undefined;if(type=="number"||type=="boolean")
return o+"";if(type=="string")
return $.quoteString(o);if(type=='object')
{if(typeof o.toJSON=="function")
return $.toJSON(o.toJSON());if(o.constructor===Date)
{var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
if(o.constructor===Array)
{var ret=[];for(var i=0;i<o.length;i++)
ret.push($.toJSON(o[i])||"null");return"["+ret.join(",")+"]";}
var pairs=[];for(var k in o){var name;var type=typeof k;if(type=="number")
name='"'+k+'"';else if(type=="string")
name=$.quoteString(k);else
continue;if(typeof o[k]=="function")
continue;var val=$.toJSON(o[k]);pairs.push(name+":"+val);}
return"{"+pairs.join(", ")+"}";}};$.evalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);return eval("("+src+")");};$.secureEvalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,'@');filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']');filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered))
return eval("("+src+")");else
throw new SyntaxError("Error parsing JSON, source is not valid.");};$.quoteString=function(string)
{if(string.match(_escapeable))
{return'"'+string.replace(_escapeable,function(a)
{var c=_meta[a];if(typeof c==='string')return c;c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
return'"'+string+'"';};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var _meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};})(jQuery);;
/*
 * ----------------------------- JSTORAGE -------------------------------------
 * Simple local storage wrapper to save data on the browser side, supporting
 * all major browsers - IE6+, Firefox2+, Safari4+, Chrome4+ and Opera 10.5+
 *
 * Copyright (c) 2010 Andris Reinman, andris.reinman@gmail.com
 * Project homepage: www.jstorage.info
 *
 * Licensed under MIT-style license:
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/**
 * $.jStorage
 * 
 * USAGE:
 *
 * jStorage requires Prototype, MooTools or jQuery! If jQuery is used, then
 * jQuery-JSON (http://code.google.com/p/jquery-json/) is also needed.
 * (jQuery-JSON needs to be loaded BEFORE jStorage!)
 *
 * Methods:
 *
 * -set(key, value)
 * $.jStorage.set(key, value) -> saves a value
 *
 * -get(key[, default])
 * value = $.jStorage.get(key [, default]) ->
 *    retrieves value if key exists, or default if it doesn't
 *
 * -deleteKey(key)
 * $.jStorage.deleteKey(key) -> removes a key from the storage
 *
 * -flush()
 * $.jStorage.flush() -> clears the cache
 * 
 * -storageObj()
 * $.jStorage.storageObj() -> returns a read-ony copy of the actual storage
 * 
 * -storageSize()
 * $.jStorage.storageSize() -> returns the size of the storage in bytes
 *
 * -index()
 * $.jStorage.index() -> returns the used keys as an array
 * 
 * -storageAvailable()
 * $.jStorage.storageAvailable() -> returns true if storage is available
 * 
 * -reInit()
 * $.jStorage.reInit() -> reloads the data from browser storage
 * 
 * <value> can be any JSON-able value, including objects and arrays.
 *
 **/

(function($){
    if(!$ || !($.toJSON || Object.toJSON || window.JSON)){
        throw new Error("jQuery, MooTools or Prototype needs to be loaded before jStorage!");
    }
    
    var
        /* This is the object, that holds the cached values */ 
        _storage = {},

        /* Actual browser storage (localStorage or globalStorage['domain']) */
        _storage_service = {jStorage:"{}"},

        /* DOM element for older IE versions, holds userData behavior */
        _storage_elm = null,
        
        /* How much space does the storage take */
        _storage_size = 0,

        /* function to encode objects to JSON strings */
        json_encode = $.toJSON || Object.toJSON || (window.JSON && (JSON.encode || JSON.stringify)),

        /* function to decode objects from JSON strings */
        json_decode = $.evalJSON || (window.JSON && (JSON.decode || JSON.parse)) || function(str){
            return String(str).evalJSON();
        },
        
        /* which backend is currently used */
        _backend = false;
        
        /**
         * XML encoding and decoding as XML nodes can't be JSON'ized
         * XML nodes are encoded and decoded if the node is the value to be saved
         * but not if it's as a property of another object
         * Eg. -
         *   $.jStorage.set("key", xmlNode);        // IS OK
         *   $.jStorage.set("key", {xml: xmlNode}); // NOT OK
         */
        _XMLService = {
            
            /**
             * Validates a XML node to be XML
             * based on jQuery.isXML function
             */
            isXML: function(elm){
                var documentElement = (elm ? elm.ownerDocument || elm : 0).documentElement;
                return documentElement ? documentElement.nodeName !== "HTML" : false;
            },
            
            /**
             * Encodes a XML node to string
             * based on http://www.mercurytide.co.uk/news/article/issues-when-working-ajax/
             */
            encode: function(xmlNode) {
                if(!this.isXML(xmlNode)){
                    return false;
                }
                try{ // Mozilla, Webkit, Opera
                    return new XMLSerializer().serializeToString(xmlNode);
                }catch(E1) {
                    try {  // IE
                        return xmlNode.xml;
                    }catch(E2){}
                }
                return false;
            },
            
            /**
             * Decodes a XML node from string
             * loosely based on http://outwestmedia.com/jquery-plugins/xmldom/
             */
            decode: function(xmlString){
                var dom_parser = ("DOMParser" in window && (new DOMParser()).parseFromString) ||
                        (window.ActiveXObject && function(_xmlString) {
                    var xml_doc = new ActiveXObject('Microsoft.XMLDOM');
                    xml_doc.async = 'false';
                    xml_doc.loadXML(_xmlString);
                    return xml_doc;
                }),
                resultXML;
                if(!dom_parser){
                    return false;
                }
                resultXML = dom_parser.call("DOMParser" in window && (new DOMParser()) || window, xmlString, 'text/xml');
                return this.isXML(resultXML)?resultXML:false;
            }
        };

    ////////////////////////// PRIVATE METHODS ////////////////////////

    /**
     * Initialization function. Detects if the browser supports DOM Storage
     * or userData behavior and behaves accordingly.
     * @returns undefined
     */
    function _init(){
        /* Check if browser supports localStorage */
        if("localStorage" in window){
            try {
                if(window.localStorage) {
                    _storage_service = window.localStorage;
                    _backend = "localStorage";
                }
            } catch(E3) {/* Firefox fails when touching localStorage and cookies are disabled */}
        }
        /* Check if browser supports globalStorage */
        else if("globalStorage" in window){
            try {
                if(window.globalStorage) {
                    _storage_service = window.globalStorage[window.location.hostname];
                    _backend = "globalStorage";
                }
            } catch(E4) {/* Firefox fails when touching localStorage and cookies are disabled */}
        }
        /* Check if browser supports userData behavior */
        else {
            _storage_elm = document.createElement('link');
            if(_storage_elm.addBehavior){

                /* Use a DOM element to act as userData storage */
                _storage_elm.style.behavior = 'url(#default#userData)';

                /* userData element needs to be inserted into the DOM! */
                document.getElementsByTagName('head')[0].appendChild(_storage_elm);

                _storage_elm.load("jStorage");
                var data = "{}";
                try{
                    data = _storage_elm.getAttribute("jStorage");
                }catch(E5){}
                _storage_service.jStorage = data;
                _backend = "userDataBehavior";
            }else{
                _storage_elm = null;
                return;
            }
        }

        _load_storage();
    }
    
    /**
     * Loads the data from the storage based on the supported mechanism
     * @returns undefined
     */
    function _load_storage(){
        /* if jStorage string is retrieved, then decode it */
        if(_storage_service.jStorage){
            try{
                _storage = json_decode(String(_storage_service.jStorage));
            }catch(E6){_storage_service.jStorage = "{}";}
        }else{
            _storage_service.jStorage = "{}";
        }
        _storage_size = _storage_service.jStorage?String(_storage_service.jStorage).length:0;    
    }

    /**
     * This functions provides the "save" mechanism to store the jStorage object
     * @returns undefined
     */
    function _save(){
        try{
            _storage_service.jStorage = json_encode(_storage);
            // If userData is used as the storage engine, additional
            if(_storage_elm) {
                _storage_elm.setAttribute("jStorage",_storage_service.jStorage);
                _storage_elm.save("jStorage");
            }
            _storage_size = _storage_service.jStorage?String(_storage_service.jStorage).length:0;
        }catch(E7){/* probably cache is full, nothing is saved this way*/}
    }

    /**
     * Function checks if a key is set and is string or numberic
     */
    function _checkKey(key){
        if(!key || (typeof key != "string" && typeof key != "number")){
            throw new TypeError('Key name must be string or numeric');
        }
        return true;
    }

    ////////////////////////// PUBLIC INTERFACE /////////////////////////

    $.jStorage = {
        /* Version number */
        version: "0.1.5.0",

        /**
         * Sets a key's value.
         * 
         * @param {String} key - Key to set. If this value is not set or not
         *              a string an exception is raised.
         * @param value - Value to set. This can be any value that is JSON
         *              compatible (Numbers, Strings, Objects etc.).
         * @returns the used value
         */
        set: function(key, value){
            _checkKey(key);
            if(_XMLService.isXML(value)){
                value = {_is_xml:true,xml:_XMLService.encode(value)};
            }
            _storage[key] = value;
            _save();
            return value;
        },
        
        /**
         * Looks up a key in cache
         * 
         * @param {String} key - Key to look up.
         * @param {mixed} def - Default value to return, if key didn't exist.
         * @returns the key value, default value or <null>
         */
        get: function(key, def){
            _checkKey(key);
            if(key in _storage){
                if(typeof _storage[key] == "object" &&
                        _storage[key]._is_xml &&
                            _storage[key]._is_xml){
                    return _XMLService.decode(_storage[key].xml);
                }else{
                    return _storage[key];
                }
            }
            return typeof(def) == 'undefined' ? null : def;
        },
        
        /**
         * Deletes a key from cache.
         * 
         * @param {String} key - Key to delete.
         * @returns true if key existed or false if it didn't
         */
        deleteKey: function(key){
            _checkKey(key);
            if(key in _storage){
                delete _storage[key];
                _save();
                return true;
            }
            return false;
        },

        /**
         * Deletes everything in cache.
         * 
         * @returns true
         */
        flush: function(){
            _storage = {};
            _save();
            /*
             * Just to be sure - andris9/jStorage#3
             */
            try{
                window.localStorage.clear();
            }catch(E8){}
            return true;
        },
        
        /**
         * Returns a read-only copy of _storage
         * 
         * @returns Object
        */
        storageObj: function(){
            function F() {}
            F.prototype = _storage;
            return new F();
        },
        
        /**
         * Returns an index of all used keys as an array
         * ['key1', 'key2',..'keyN']
         * 
         * @returns Array
        */
        index: function(){
            var index = [], i;
            for(i in _storage){
                if(_storage.hasOwnProperty(i)){
                    index.push(i);
                }
            }
            return index;
        },
        
        /**
         * How much space in bytes does the storage take?
         * 
         * @returns Number
         */
        storageSize: function(){
            return _storage_size;
        },
        
        /**
         * Which backend is currently in use?
         * 
         * @returns String
         */
        currentBackend: function(){
            return _backend;
        },
        
        /**
         * Test if storage is available
         * 
         * @returns Boolean
         */
        storageAvailable: function(){
            return !!_backend;
        },
        
        /**
         * Reloads the data from browser storage
         * 
         * @returns undefined
         */
        reInit: function(){
            var new_storage_elm, data;
            if(_storage_elm && _storage_elm.addBehavior){
                new_storage_elm = document.createElement('link');
                
                _storage_elm.parentNode.replaceChild(new_storage_elm, _storage_elm);
                _storage_elm = new_storage_elm;
                
                /* Use a DOM element to act as userData storage */
                _storage_elm.style.behavior = 'url(#default#userData)';

                /* userData element needs to be inserted into the DOM! */
                document.getElementsByTagName('head')[0].appendChild(_storage_elm);

                _storage_elm.load("jStorage");
                data = "{}";
                try{
                    data = _storage_elm.getAttribute("jStorage");
                }catch(E5){}
                _storage_service.jStorage = data;
                _backend = "userDataBehavior";
            }
            
            _load_storage();
        }
    };

    // Initialize jStorage
    _init();

})(window.jQuery || window.$);;
var initialize = false;
var count_current = 0;
var fps_current = 0;
var fps_clicks = 0;
var fps_left = 0;
var fps_active = false;
var cstcounter = 0;
var timer = null;
var templen = 0;
var done = false;
var tempIE = 0;

/**
 * because the load / error event don't trigger when a image has been cached
 * check for alt text, if an image has an alt text it will also have an height / width greater than 0
 * if it has an alt text, check for src if it is set then the image is loaded.
 */
_scan_images = function() {
  var scanCount = 0;
  templen = $('#fps .view ul li').length;
  for( i = 0; i < 3; i++ ){
    image = $('#fps .view ul li:nth-child(' + (templen - i) + ') > img');
    if(image.attr('alt')){
      if(image.attr('alt') == '' || image.attr('alt') == ' '){
        if(image.height() > 0 && image.width() > 0){
          scanCount++;
        }else{
          if(image.attr('src')){
            if(image.attr('src') !== '' && image.attr('src') !== null && image.attr('src') !== undefined){
              scanCount++;
            }
          }
        }
      }else{
        if(image.attr('src')){
          if(image.attr('src') !== '' && image.attr('src') !== null && image.attr('src') !== undefined){
            scanCount++;
          }
        }
      }
    }else{
      if(image.attr('src')){
       if(image.attr('src') !== '' && image.attr('src') !== null && image.attr('src') !== undefined){
          scanCount++;
        }
      }
    }
  }
  if(scanCount > 2){
    return true;
  }
}

_init = function(){
  $('#fps .view ul li > img').each(function(){
    if ( $(this).complete || $(this).readyState === 4 ) {
      cstcounter++;
    }else{
      $(this).bind('load error', function(){
        cstcounter++;
      });
    }
  });
  verifyImages();
}


verifyImages = function(){
  var total = $('#fps .view ul li > img').length;
  if(cstcounter == total || _scan_images()) {
    clearInterval(timer);
    timer = null;
    done = false;
    $('.fp-preloader').hide();
  }else{
    if(done == false){
      if($.browser.msie){
        timer = setInterval( "verifyImages()", 100 );
      }else{
        timer = setInterval( verifyImages, 100 );
      }
      done = true;
    }
  }
};

waitForLoad = function(){
  if(done == false){
    if($.browser.msie){
      timer = setInterval( "waitForLoad()", 100 );
    }else{
      timer = setInterval( waitForLoad, 100 );
    }
    done = true;
  }
  if(templen == $('#fps .view ul li').length){
    $('#fps .view ul li:nth-child(' + templen + ') > img').bind('load error', function(){
      cstcounter++;
    });
    $('#fps .view ul li:nth-child(' + ( templen - 1 ) + ') > img').bind('load error', function(){
      cstcounter++;
    });
    $('#fps .view ul li:nth-child(' + (templen - 2)+ ') > img').bind('load error', function(){
      cstcounter++;
    });
    clearInterval(timer);
    timer = null;
    done = false;
    verifyImages();
  }
}

$.fn.hasAncestor = function(a) {
  return this.filter(function() {
    return !!$(this).closest(a).length;
  });
};

function getUrlVars() {
  var vars = {};
  var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
    vars[key] = value;
  });
  return vars;
}

$(document).ready(function(){  // No Drupal.behaviours() used ? Please comment why !
  if($.jStorage.get('HIDEBLUE')){
    $('.groot-blauw').remove();
  }else{
    if($('.groot-blauw').length > 0) {
      $('#wrapper').css({'padding-top' : '349px'});
      $('.groot-blauw').show();
    }
  }
  /**
   * functionality for hidden following
   */
  if($('.hidden-follow').length > 0){
    $('.hidden-follow').bind('click', function(e){
      e.stopPropagation(); // prevent opening tabs
      mynode = $(this).attr('title');
      $.getJSON(Drupal.settings.basePath + 'hiddenfollow', {node : mynode}, function (jso, textStatus) { // posts to hook in cstarchello_follow.module
        if(jso == true){// if you're following
          $('.hidden-follow').each(function(){
            $(this).addClass('following');
            $(this).html('<span class="left"></span><span class="no-hover-follow">Following</span><span class="hover-follow">Unfollow</span><span class="right"></span> </a>');
          });
          $('span.num-follow').each(function(){
            temp = (parseInt($(this).html()) + 1);
            $(this).html(temp + '');
          });
        }
        if(jso == 'unfollow'){//als je stopt met volgen
          $('.hidden-follow').each(function(){
            $(this).removeClass('following');
            $(this).html('<span class="left"></span>Follow<span class="right"></span>');
          });
          $('span.num-follow').each(function(){
            temp = (parseInt($(this).html()) - 1);
            $(this).html(temp + '');
          });
        }
      });
      return false; // prevent opening tabs
    });
  }
  /**
   * IE BUG http://intranet.luciuswebsystems.nl/archello/node/4257
   */
  if( $.browser.msie ){
    $('#pictures2 .gallery2 div ul li img').bind('click', function(){
      pathArray = window.location.href.split( '/' );
       window.location = 'http://' + pathArray[2] + $(this).parents().children('a').attr('href');
    })
  }
  
  /*fixes the paging*/
  if($('.paging').width()){
    var center = (($('.paging').width() / 2) - ($('.paging ul').width() / 2) );
    if($('.paging .btn-prev').length != 0){
      $('.paging .btn-prev').css({'margin-left' : (center - $('.paging .btn-prev').width())});
    }else{
      $('.paging ul').css({'margin-left' : center});
    }
  }else{
    var center = (($('.content').width() / 2) - ($('.content ul').width() / 2) );
    if($('.content .btn-prev').length != 0){
      $('.content .btn-prev').css({'margin-left' : (center - $('.content .btn-prev').width())});
    }
  }
  $('.hide-blue').click(function(){
   //$(this).parents('.groot-blauw').animate({height : '0', opacity : '0'}, 5000, function() {
     $('.groot-blauw').remove();
     $('#wrapper').css({'padding-top' : '138px'});
   //});
  });
  $('.i-r-gone').change(function(){
    $('.groot-blauw').remove();
    $.jStorage.set('HIDEBLUE', true);
    $('#wrapper').css({'padding-top' : '138px'});
  });
  /* for custom tabslider */
  if($.jStorage.get('topic') == $('h2.check-markup').text() && decodeURI($.jStorage.get('tabslider')) !== 'null'){
    $('div.refresh-on-next .gallery-frame ul').html(decodeURI($.jStorage.get('tabslider')));
  }

  if($('.fp-preloader').length > 0){
    if($.browser.msie){
      setTimeout("_init()", 1000);
    }else{
      _init();
    }
  }

  $('.image-holder a').each(function(){
    if($(this).text() == 'add'){
      temp = $(this).parents('.image-holder').parents('.r');
      temp.children('.about').html(' ');
      temp.children('.about').append('<span class="spec-and-span">Add Story</span>');
    }
  });
  
  cst_slide_next = function( mytype, myself ){
    if(mytype != 'stories'){
      tab = myself.parent().parent().attr('id');
      crnt = $('.rec-added-th li#' + tab + ' div.e-gallery ul > li').length;
      $.getJSON(Drupal.settings.basePath + 'en/json/slider-items', {type: mytype, current: crnt}, function (jso, textStatus) {
        $('.rec-added-th li#' + tab + ' div.e-gallery ul').append(jso[1]);
        $('.rec-added-th li#' + tab + ' div.e-gallery ul').animate({ left: '-=600' }, 1500, function() {});
      });
    }else{
      if(fps_active == false){
        fps_active = true;
        crnt = $('#fps .view ul > li').length - 1;
        twidth = 0;
        if(crnt + 3 <= 29){ // if there is room for 3 more images
          $('.fp-preloader').show();
          for(i = fps_current; i < crnt; i++ ){ // for all images in between current and max
            if(i >= fps_current && ( twidth + ( $('#fps .view ul > li').eq(i).width() + 3 )) <= 961 ){
              fps_current++;
              twidth += ( $('#fps .view ul > li').eq(i).width() + 3 );
            }else{
              break;
            }
          }
          $('#fps .view ul').animate({left : "-=" + twidth}, 1500, function(){
            $.getJSON(Drupal.settings.basePath + 'en/json/front-stories', { current : ( crnt + 1 ) }, function (jso, textStatus) {
              $('#fps .view ul').append(jso[1]);
              templen = $('#fps .view ul li').length;
              timer = setTimeout( waitForLoad, 100 );
              fps_active = false;
            });
          });
        }else{
          if( fps_current == crnt ){
            fps_current = 0;
            $('#fps .view ul').animate({left : 0}, 1500, function(){ fps_active = false; });
          }
          else{
            for(i = fps_current; i < crnt; i++ ){ // for all images in between current and max
              if(i >= fps_current && ( twidth + ( $('#fps .view ul > li').eq(i).width() + 3 )) <= 961 ){
                fps_current++;
                twidth += ( $('#fps .view ul > li').eq(i).width() + 3 );
              }else{
                break;
              }
            }
            if(fps_current == crnt - 1){
              twidth = 0;
              for(i = 0; i <= crnt; i++ ){
                twidth += ( $('#fps .view ul > li').eq(i).width() + 3 );
              }
              $('#fps .view ul').animate({left : -(twidth - 961)}, 1500, function(){ fps_active = false; });
            }else{
              $('#fps .view ul').animate({left : "-=" + twidth}, 1500, function(){ fps_active = false; });
            }
          }
        }
      }else{
        return false;
      }
    }
    return false;
  };
  
  cst_slide_prev = function( myself, extra ){
    if(extra != 'stories'){
      tab = myself.parent().parent().attr('id');
      crnt = $('.rec-added-th li#' + tab + ' div.e-gallery ul > li').length;
      if(parseInt($('.rec-added-th li#' + tab + ' div.e-gallery ul').css('left')) < 0){
        $('.rec-added-th li#' + tab + ' div.e-gallery ul').animate({ left: '+=600' }, 1500, function() {});
      }else{ // goto last 3
        amount = (crnt - 3) * 200;
        $('.rec-added-th li#' + tab + ' div.e-gallery ul').animate({ left: -amount }, 1500, function() {});
      }
    }else{
      if(fps_active == false){
        fps_active = true;
        crnt = $('#fps .view ul > li').length - 1;
        twidth = 0;
        if(fps_current <= 0){
          for(i = 0; i < crnt; i++){
            twidth += $('#fps .view ul > li').eq(i).width() + 3;
          }
          $('#fps .view ul').animate({ left: -( twidth - 961 ) }, 1500, function(){ fps_active = false; });
          fps_current = crnt;
        }else{
          for(i = fps_current; i > 0; i--){
            if(i <= fps_current && ( ( twidth + ( $('#fps .view ul > li').eq(i).width() + 3 ) ) ) <= 961 ){
              twidth += ( $('#fps .view ul > li').eq(i).width() + 3 );
              fps_current -= 1;
            }else{
              break;
            }
          }
          if(fps_current <= 1){
            $('#fps .view ul').animate({left : 0}, 1500, function(){ fps_active = false; });
            fps_current = 0;
          }else{
            $('#fps .view ul').animate({left : "+=" + twidth}, 1500, function(){ fps_active = false; });
          }
        }
      }else{
        return false;
      }
    }
  };
  
  $('.next-proj').click(function(){
    cst_slide_next('projects', $(this));
    $('.prev-proj').show("slow")
    return false;
  });
  $('.prev-proj').click(function(){
    cst_slide_prev($(this));
    return false;
  });
  $('.next-prod').click(function(){
    cst_slide_next('products', $(this));
    $('.prev-prod').show("slow")
    return false;
  });
  $('.prev-prod').click(function(){
    cst_slide_prev($(this));
    return false;
  });
  $('.next-mat').click(function(){
    cst_slide_next('materials', $(this));
    $('.prev-mat').show("slow")
    return false;
  });
  $('.prev-mat').click(function(){
    cst_slide_prev($(this));
    return false;
  });
  $('.next-peo').click(function(){
    cst_slide_next('people', $(this));
    $('.prev-peo').show("slow")
    return false;
  });
  $('.prev-peo').click(function(){
    cst_slide_prev($(this));
    return false;
  });
  $('.next-com').click(function(){
    cst_slide_next('company', $(this));
    $('.prev-com').show("slow")
    return false;
  });
  $('.prev-com').click(function(){
    cst_slide_prev($(this));
    return false;
  });
  $('.next-stor').click(function(){
    if(fps_active == false){
      cst_slide_next('stories', $(this));
      $('.prev-stor').show("slow");
    }
    return false;
  });
  $('.prev-stor').click(function(){
    if(fps_active == false){
      cst_slide_prev($(this), 'stories');
    }
    return false;
  });

  /** quick hack for double tabs **/

  if($('.tab-content #tab2-2').length != 0){
    $('.tab-content #tab2-2').css({'visibility' : 'visible'});
  }
  if($('.tab-content #tab2-3').length != 0){
    $('.tab-content #tab2-3').css({'visibility' : 'visible'});
  }

  /**
   * voor het openen en sluiten van de masquerade
   */
  $('span.switch-span').bind('click', function(){
    $('div.switch-div').toggle();
  })

  /***
   * xhtml valid url opening in new tab
   */

  $("a[rel='external']").click(function(){
    window.open(this.href);
    return false;
  });

  $('#edit-submit-1').click(function(){
    if($('#slider1').length != 0){
      $('#edit-stories-min').val( $.trim($('#slider1').parents('div.slider-holder').children('span.num').children('em.min').text()));
      $('#edit-stories-max').val( $.trim($('#slider1').parents('div.slider-holder').children('span.num').children('em.max').text()));
    }
    if($('#slider2').length != 0){
      $('#edit-conn-min').val( $.trim($('#slider2').parents('div.slider-holder').children('span.num').children('em.min').text()));
      $('#edit-conn-max').val( $.trim($('#slider2').parents('div.slider-holder').children('span.num').children('em.max').text()));
    }
    if($('#slider3').length != 0){
      $('#edit-cons-yr-min').val( $.trim($('#slider3').parents('div.slider-holder').children('span.num').children('em.min').text()));
      $('#edit-cons-yr-max').val( $.trim($('#slider3').parents('div.slider-holder').children('span.num').children('em.max').text()));
    }
  });


  if($('#edit-ss-author-type :selected').val() == 'person'){
    $('#edit-ss-author-role-company-wrapper').hide();
  }
  else if($('#edit-ss-author-type :selected').val() == 'company'){
    $('#edit-ss-author-role-person-wrapper').hide();
  }
  else {
    $('#edit-ss-author-role-person-wrapper').hide();
    $('#edit-ss-author-role-company-wrapper').hide();
  }
  $('#edit-ss-author-type').change(function(){
    switch($(this).val()){
      case '0':
        $('#edit-ss-author-role-person-wrapper').hide();
        $('#edit-ss-author-role-company-wrapper').hide();
        break;

      case 'company':
        $('#edit-ss-author-role-person-wrapper').hide();
        $('#edit-ss-author-role-company-wrapper').show();
        break;

      case 'person':
        $('#edit-ss-author-role-person-wrapper').show();
        $('#edit-ss-author-role-company-wrapper').hide();
        break;

      default:
        break;
    }
  });


  $('.hit-me-adv').click(function(){
    if($(this).hasClass('is-close')){
      $(this).removeClass('is-close').addClass('is-open');
      $('div.advanced').show();
      //$(this).text('close advanced search');
      $('#edit-use-advanced').val('true');
      if(initialize == false){
        if (typeof initSlider == 'function') {
          initSlider();
        }
        initialize = true;
      }
    }else{
      $(this).removeClass('is-open').addClass('is-close');
      $('div.advanced').hide();
      //$(this).text('advanced search');
      $('#edit-use-advanced').val('false');
    }
  })

  $('#edit-product-type').bind('change',function(){
    $('.quickhide-th').hide();
    $('.custom-div-' + $(this).val()).show();
  });

  if($('#edit-use-advanced').val() == true){
    $('.hit-me-adv').trigger('click');
  }
  /**
   * stukje javascript om de opbouw van het menu te omzeilen voor masquerade CASE 2284
   **/

  $('.add-nav a.active2').each(function(){
    $(this).parents('li').children('form.disconnect-th').removeClass('disconnect-th').addClass('add-hover-active-form');
  });

  /**
   * Thomas Dik, added 5 november
   * solution to the tab problem case:1725
   */

  //$('.switch-span').remove();
  //$('a.join-link-person').parents('li').remove();
  if($('.inner-page').length != 0){
    if($('a.join-link-person').length != 0 ){
      if($('.switch-span').length != 0){
        if($('.inner-page .add-nav ul li:nth-child(2) a').hasClass('notablueclass') === false){
          $('div.nav-holder ul.menu li').each(function(){
            $(this).children('a').text('my ' + $(this).children('a').text());
          })
        }else{
          $('div.nav-holder ul li').each(function(){
            $(this).children('a').css({'padding' : '11px 0px 0px 0px'});
          });
        }
      }else{
        if($('.inner-page .add-nav ul li:nth-child(1) a').hasClass('notablueclass') === false){
          $('div.nav-holder ul.menu li').each(function(){
            $(this).children('a').text('my ' + $(this).children('a').text());
          })
        }else{
          $('div.nav-holder ul li').each(function(){
            $(this).children('a').css({'padding' : '11px 0px 0px 0px'});
          });
        }
      }
    }else{
      $('div.nav-holder ul li').each(function(){
        $(this).children('a').css({'padding' : '11px 0px 0px 0px'});
      });
    }
  }
  if($('.program-type-selectors').length != 0){
    $('.program-type-values .form-checkboxes').hide();
    $('.program-type-values .form-checkboxes:nth-child(1)').show();
    $('.program-type-selectors span:nth-child(1)').addClass('active');
    $('.program-type-selectors span').click(function(){
      $('.program-type-selectors span').removeClass('active');
      $(this).addClass('active');
      $('.program-type-values .form-checkboxes').hide();
      $('.program-type-values .form-checkboxes:nth-child('+ $(this).attr('title')+')').show();
      //alert('.program-type-selectors .form-checkboxes:nth-child('+ $(this).attr('title')+')');
    })
  }

  /**
   * voor een perfecte uitlijning van de submenu's
   * */
  var formSubmitClicked = false;
  var hwstring = 'height:'+ ($(document).height() - 20) +'px; width:'+ $('body').width() +'px;';
  $('input[type="submit"].show-loading').bind('click', function(){

    if(this.formSubmitClicked === true){
      return false;
    }
    $('body').prepend('<div class="loading-splash" style="' + hwstring + '"><span style="' + hwstring + '"class=" form-submit-loading-splash"></span></div>');
    this.formSubmitClicked = true;
  });

  $('ul.sub_menu').each(function(){
    if($(this).hasClass('align_unfixed')){
      if ($.browser.msie && $.browser.version.substr(0,1) < 8) { //to fix the IE7 bug
        $(this).css({'margin-left' : '-150px' });
      }else{
        $(this).css({'margin-left' : ($(this).parent('li').width() - 150)});
      }
    }
  });
  if(location.pathname.indexOf('mycompany') > 0){
    $('ul.tabset li').each(function(){
      if($(this).children('a').attr('href') == '#tab12'){
        $(this).remove();
      }
    });
    $('div.tab-content .tab-frame div.tab').each(function(){
      if($(this).attr('id') == 'tab12'){
        $(this).remove();
      }
    });
  }

  /*
   * override default onKey up function if workflow add-company is open
   * */
  if($('.company-big-wrapper').length !== 0){
    $("#edit-title").keydown(function() {
      $("select[name='country']").removeAttr("disabled");
         $("select[name='edit-province']").removeAttr("disabled");
         $("input[name='city']").removeAttr("disabled");
         $('.form-submit').val('Add Your Company');
         $('.form-submit').addClass('submit-company').removeClass('override_button');
    });
    /**
     *tijdelijke oplossing, moet eigenlijk met ahah
     **/
    $('.form-submit').click(function(){
      $("select[name='country']").removeAttr("disabled");
         $("select[name='edit-province']").removeAttr("disabled");
         $("input[name='city']").removeAttr("disabled");
    });
    /**
     * Override default drupal function
     * case: 1386
     */
    Drupal.jsAC.prototype.select = function (node) {
      this.input.value = node.autocompleteValue;
       $('.form-submit').val('Connect me');
         $('.form-submit').removeClass('submit-company').addClass('override_button');
         $("select[name='country']").attr("disabled", "disabled");
         $("select[name='edit-province']").attr("disabled", "disabled");
         $("input[name='city']").attr("disabled", "disabled");
    };

    Drupal.jsAC.prototype.onkeyup = function (input, e) {
    if (!e) {
      e = window.event;
    }
    switch (e.keyCode) {
      case 16: // shift
      case 17: // ctrl
      case 18: // alt
      case 20: // caps lock
      case 33: // page up
      case 34: // page down
      case 35: // end
      case 36: // home
      case 37: // left arrow
      case 38: // up arrow
      case 39: // right arrow
      case 40: // down arrow
        return true;

      case 9:  // tab
      case 13: // enter
      case 27: // esc
        this.hidePopup(e.keyCode);
        return true;

      default: // all other keys
        if (input.value.length > 2)
        this.populatePopup();
        else
        this.hidePopup(e.keyCode);
        return true;
      }
    };
  };

  /**
   * override default found function of drupal adding an extra list item
   * called tiny suggestion, which is a grey item at the top which can't be selected.
   * case: can't remember (a) Thomas Dik
   */

  if ( Drupal.jsAC ) {

    Drupal.jsAC.prototype.found = function (matches) {
        // If no value in the textfield, do not show the popup.
        if (!this.input.value.length) {
          return false;
        }

        // Prepare matches
        var ul = document.createElement('ul');
        var ac = this;
        if( matches != ""){
          $(ul).append('<li class="tiny-suggestion">suggestions</li>');
        }
        for (key in matches) {
          var li = document.createElement('li');
          $(li)
            .html('<div>'+ matches[key] +'</div>')
            .mousedown(function () { ac.select(this); })
            .mouseover(function () { ac.highlight(this); })
            .mouseout(function () { ac.unhighlight(this); });
          li.autocompleteValue = key;
          $(ul).append(li);
        }

        // Show popup with matches, if any
        if (this.popup) {
          if (ul.childNodes.length > 0) {
            $(this.popup).empty().append(ul).show();
          }
          else {
            $(this.popup).css({visibility: 'hidden'});
            this.hidePopup();
          }
        }
      };
    };

  // init ********************************************************************
  if (typeof VSA_initScrollbars == 'function') {
    VSA_initScrollbars();
  }
  if (typeof initCustomForms == 'function') {
    initCustomForms();
  }

  $('div.vscroll-down').hover(function(){
    $(this).addClass('vscroll-down-hover');
  }, function(){
    $(this).removeClass('vscroll-down-hover');
  });
  $('div.vscroll-up').hover(function(){
    $(this).addClass('vscroll-up-hover');
  }, function(){
    $(this).removeClass('vscroll-up-hover');
  });

  // search ******************************************************************
  var _searchLinkMain = $('a.adv-search');
  var _search1 = $('#search1');
  var _search2 = $('#search2');

  _searchLinkMain.click(function(){
    if (_search1.is(':visible')) {
      _search2.slideDown(300);
      _search1.slideUp(300, function(){
        _searchLinkMain.text('Close refine results').addClass('adv-search-active');
      });
    } else {
      _search1.slideDown(300);
      _search2.slideUp(300, function(){
        _searchLinkMain.text('advanced search').removeClass('adv-search-active');
      });
    }
    return false;
  });

  var _searchLink = $('div.top-area a.close-results');
  var _searchSlide = $('#search-block');

  _searchLink.click(function(){
    if (_searchSlide.is(':visible')) {
      _searchSlide.slideUp(300, function(){
        _searchLink.text('Open refine results').addClass('close');
      });
    } else {
      _searchLink.text('Close refine results').removeClass('close');
      _searchSlide.slideDown(300);
    }
    return false;
  });

  _search2.hide();



  // tooltip *****************************************************************
  $('div.gallery, ul.image-list').each(function(){
    var _lis = $('li', this);
    _lis.each(function(i,li){
      var _tip = $('div.popup',li).hide(), _timer, _dif = 0;
      $('body').append(_tip);
      if ($(li).parents('div.sidebar').length) _dif = -10;
      if (_tip.length) {
        $(li).mouseover(function(){
          if (_timer) clearTimeout(_timer);
          _tip.css({
            'top':$(li).offset().top + _dif - 42,
            'left':$(li).offset().left + $(li).width()/2 - _tip.outerWidth()/2 + parseInt($(li).css('paddingLeft'))
          }).show();
        }).mouseout(function(){
          _timer = setTimeout(function(){
            _tip.hide();
          },30);
        });
        _tip.mouseover(function(){
          if (_timer) clearTimeout(_timer);
        }).mouseout(function(){
          _timer = setTimeout(function(){
            _tip.hide();
          },30);
        });
      }
    });
  });

  // promo *******************************************************************
  $('div.visual-holder .visual-tab').each(function(i, tabset){
    var _tabLinks = $('a',tabset), _active;
    _tabLinks.each(function(j, link){
      var _id = $(link.href.substr(link.href.indexOf('#')));
      if ($(link).hasClass('active')){
        _id.css({'position':'static', 'left':0});
        _active = _id;
        if(link.href.substr(link.href.indexOf('#')) == "#pictures2") $(".grey-box").css({'top':-9999});
        else $(".grey-box").css({'top':54});
      } else{
        _id.hide();
      };

      $(link).click(function(){

        _tabLinks.removeClass('active');
        _active.hide();
        $(link).addClass('active');
        _id.css({'position':'static', 'left':0}).show();
        if(this.href.substr(link.href.indexOf('#')) == "#pictures2") $(".grey-box").css({'top':-9999});
        else $(".grey-box").css({'top':54});
        _active = _id;

        _greyBox.each(function(){
          var _gb = $(this);
          var _btns = $('a.btn-up, a.btn-down','div.scroll');
          var _postsList = $('ul.posts-list', _gb);
          var _btns = $('a.btn-up, a.btn-down','div.scroll');
          if (_gb.hasClass('close')) {
            _gb.removeClass('close');
            _gb.animate({'width':403},{queue:false, duration:500});
            _postsList.animate({'width':403},{queue:false, duration:500});
            _btns.animate({'left':'50%'},{queue:false, duration:500});
          }
        });
        return false;
      });
    });
  });

  var _greyBox = $('div.grey-box');
  _greyBox.each(function(){
    var _link = $('p.btn-open-close > a', this);
    var _gb = $(this);
    var _postsList = $('ul.posts-list', _gb);
    var _btns = $('a.btn-up, a.btn-down','div.scroll');

  /**
  *maximize button
  */
    _link.click(function(){
      if (_gb.hasClass('close')) {
        _gb.removeClass('close');
        _gb.animate({'width':403},{queue:false, duration:500});
        _postsList.animate({'width':403},{queue:false, duration:500});
        _btns.animate({'left':'50%'},{queue:false, duration:500});
      } else {
        _gb.addClass('close');
        _gb.animate({'width':100},{queue:false, duration:500});
        _postsList.animate({'width':91},{queue:false, duration:500});
        _btns.animate({'left':'13%'},{queue:false, duration:500});
      }
      return false;
    });
  });

  // ajax
  var _ajaxLinks = $('div.gallery2 a.story-link');
  var _contentHolder = $('#ajax-holder');
  var _load = $('.load');
  var _current = 0;
  //Martijn disabled, causes our html to collapse
  //if (!_ajaxLinks.parent().hasClass('active')) _contentHolder.empty();

  _ajaxLinks.each(function(i){
    var _link = $(this);
    if (_link.parent().hasClass('active')) {
      _contentHolder.children('div').attr('rel',_link.attr('href')).addClass('loadContent');
      _current = i;
    }
    _link.click(function(){
    loadPage(_link);
      _current = i;
      return false;
    });
  });

  function loadPage(link){
    _ajaxLinks.parent().removeClass('active');
    link.parent().addClass('active');
    var _url = link.attr('href');
    var _loadTab = _contentHolder.find('[rel="'+_url+'"]');

    _contentHolder.find('.loadContent:visible').css('opacity',0.5);

    if (!_loadTab.length) {
      _load.show();
      $.ajax({
        url:_url,
        success:function(_msg){
          var _content = $(_msg).addClass('loadContent').hide().attr('rel',_url);
          _contentHolder.append(_content);
          _contentHolder.find('.loadContent:visible').hide();
          $(_content).fadeIn();
          _load.hide();
          moreSory(_content);
        }
      });
    } else {
      _contentHolder.find('.loadContent:visible').fadeOut(100, function(){
        _loadTab.css('opacity',1).fadeIn(300);
      });
    }
  }

  function moreSory(_this){
    var _moreStory = $('a.more-slide', _this);
    var _storySlide = $('div.more-content',_this);

    if (_storySlide.is(':visible')) {
      _moreStory.addClass('close');
    }
    _moreStory.click(function(){
      if (_storySlide.is(':visible')) {
        _storySlide.slideUp(300, function(){
          _moreStory.text(Drupal.t('Read More')).addClass('close');
          _moreStory.css('background-image', 'url(\'' + Drupal.settings.basePath + 'sites/all/themes/archello/images/arrow-down.gif\')');
        });
      } else {
        _moreStory.text(Drupal.t('Read Less')).removeClass('close');
        _storySlide.slideDown(300);
        _moreStory.css('background-image', 'url(\'' + Drupal.settings.basePath + 'sites/all/themes/archello/images/arrow-up.gif\')');
      }
      return false;
    });
  }
  $('> div',_contentHolder).each(function(i,_obj){
    moreSory(_obj);
  });

  //custom slider ***********************************************************
  var _gallery2 = $('div.gallery2:has(div.gallery-frame)');
  if($.jStorage.get('topic') == $('h2.check-markup').text() && decodeURI($.jStorage.get('tabslider')) !== 'null'){
    $('div.refresh-on-next .gallery-frame ul').html(decodeURI($.jStorage.get('tabslider')));
  }else{
    if($.jStorage.get('tabslider')){
      $.jStorage.deleteKey('tabslider'); // replaced caused case http://intranet.luciuswebsystems.nl/archello/node/4376
    }
  }
  _gallery2.each(function(){
    var _duration = 250;
    var _gal = $(this);
    var _step = [], _liSum = 0, _click = true;
    var _current = 0;
    var _mover = $('div.gallery-frame > ul', this);
    var _lis = $('> li', _mover);
    var _next = $('a.link-next',this), _prev = $('a.link-prev',this);
    var first = 0;
    var _active = _lis.filter('.active');
    _active.removeClass('active');
    var _current_temp;
    _active.addClass('active');

    _lis.each(function(i){
      var _li = $(this);
      if (_li.hasClass('active')) _li.trigger('click');
      var _more = $('a.more', _li);
      var _close = $('a.btn-close', _li);
      var _fixlink = $(this).find('.image-holder').children('a.blank').bind('click', function(){
        if(!$(this).parent().parent().parent().parent().hasClass('active')){
          //alert($(this).attr('href'));
          document.location.href = $(this).attr('href');
        }
      return false;
      });
      _more.click(function(){
        _click = false;
        $(this).hide();
        _li.addClass('mark');
        _mover.css('zIndex',11);
        return false;
      });
      _close.click(function(){
        _click = true;
        _more.show();
        _li.removeClass('mark');
        _mover.css('zIndex',9);
        return false;
      });

      $('.frame', this).each(function(i, tabset){
        var _tabLinks = $('ul.tabs a',tabset), _active;
        var _tabs = $('div.tab',tabset);

        _tabLinks.each(function(j, link){
          if ($(link).hasClass('subactive')){_tabs.eq(j).show();_active = _tabs.eq(j);}
          else _tabs.eq(j).hide();

          $(link).click(function(){
          //alert('I wuz clicked');
            _tabLinks.removeClass('subactive');
            _active.hide();
            $(link).addClass('subactive');
            _tabs.eq(j).show();
            _active = _tabs.eq(j);
            return false;
          });
        });
      });

    });
    $('.refresh-on-next .gallery-frame li div.image-holder a:not(btn-add)').bind('click', function() {
      $.jStorage.set('topic', 'leeg'); // Voor case http://intranet.luciuswebsystems.nl/archello/node/3448.
    });

    _next.click(function(){
      if (!_click) return false;
      _active = $('div.gallery-frame > ul > li').eq(0);
      _active.removeClass('active');
      $('div.gallery-frame > ul').append('<li>'+_active.html()+'</li>');
      _active.remove();
      _active = $('div.gallery-frame > ul > li').eq(0).addClass('active');


      /*var _mover = $('div.gallery-frame > ul', $('div.gallery2:has(div.gallery-frame)'));
      var _lis = $('> li', _mover);*/

      $.jStorage.set('tabslider', encodeURI($('div.refresh-on-next .gallery-frame ul').html()));
      $.jStorage.set('topic', $('h2.check-markup').text());

      /*_lis.each(function(i){
          var _li = $(this);
          if (_li.hasClass('active')) _li.trigger('click');
          var _more = $('a.more', _li);
          var _close = $('a.btn-close', _li);

          _more.click(function(){
            _click = false;
            $(this).hide();
            _li.addClass('mark');
            _mover.css('zIndex',11);
            return false;
          });
          _close.click(function(){
            _click = true;
            _more.show();
            _li.removeClass('mark');
            _mover.css('zIndex',9);
            return false;
          });

          $('.frame', this).each(function(i, tabset){
            var _tabLinks = $('ul.tabs a',tabset), _active;
            var _tabs = $('div.tab',tabset);

            _tabLinks.each(function(j, link){
              if ($(link).hasClass('subactive')){_tabs.eq(j).show();_active = _tabs.eq(j);}
              else _tabs.eq(j).hide();

              $(link).click(function(){
                _tabLinks.removeClass('subactive');
                _active.hide();
                $(link).addClass('subactive');
                _tabs.eq(j).show();
                _active = _tabs.eq(j);
                return false;
              });
            });
          });
        });*/
      //if (_current < _lis.length) _current = ( _current + 1);
      //else _current = 0;
      //_lis.eq(_current).trigger('click');
      if(!$('.refresh-on-next .gallery-frame li.active div.image-holder a').hasClass('btn-add'))
      {window.location.href = $('.refresh-on-next .gallery-frame li.active div.image-holder a').attr('href');}
      return false;
    });
    _prev.click(function(){
      if (!_click) return false;
      _active = $('div.gallery-frame > ul > li').eq(0);
      _active.removeClass('active');
      _last = $('div.gallery-frame > ul > li').eq($('div.gallery-frame > ul > li').length - 1);
      $('div.gallery-frame > ul').prepend('<li>'+_last.html()+'</li>');
      _last.remove();
      _active = $('div.gallery-frame > ul > li').eq(0).addClass('active');

      /*var _mover = $('div.gallery-frame > ul', $('div.gallery2:has(div.gallery-frame)'));
      var _lis = $('> li', _mover);*/

      $.jStorage.set('tabslider', encodeURI($('div.refresh-on-next .gallery-frame ul').html()));
      $.jStorage.set('topic', $('h2.check-markup').text());

      /*_lis.each(function(i){
          var _li = $(this);
          if (_li.hasClass('active')) _li.trigger('click');
          var _more = $('a.more', _li);
          var _close = $('a.btn-close', _li);

          _more.click(function(){
            _click = false;
            $(this).hide();
            _li.addClass('mark');
            _mover.css('zIndex',11);
            return false;
          });
          _close.click(function(){
            _click = true;
            _more.show();
            _li.removeClass('mark');
            _mover.css('zIndex',9);
            return false;
          });

          $('.frame', this).each(function(i, tabset){
            var _tabLinks = $('ul.tabs a',tabset), _active;
            var _tabs = $('div.tab',tabset);

            _tabLinks.each(function(j, link){
              if ($(link).hasClass('subactive')){_tabs.eq(j).show();_active = _tabs.eq(j);}
              else _tabs.eq(j).hide();

              $(link).click(function(){
                _tabLinks.removeClass('subactive');
                _active.hide();
                $(link).addClass('subactive');
                _tabs.eq(j).show();
                _active = _tabs.eq(j);
                return false;
              });
            });
          });

        });*/
      window.location.href = $('.refresh-on-next div.image-holder a.active').attr('href');
      return false;
    });

  });

  $('ul.search-browse-tabs li a').click(function(){
    $('ul.search-browse-tabs li a').removeClass('active');
    $(this).addClass('active');
    if($(this).attr('href') == '#tabb02'){
      $('form.search-form').hide();
      $('div.browse-form').show();
    }else{
      $('div.browse-form').hide();
      $('form.search-form').show();
    }
  });

  $('.browse-set li').click(function(){
    $('.browse-set li').removeClass('active');
    $(this).addClass('active');
    if($(this).hasClass('tab-location')){
      $('.conceal-program').hide();
      $('.th-location').show();
    }else if($(this).hasClass('tab-progtype')){
      $('.th-location').hide();
      $('.conceal-program').show();
    }else if($(this).hasClass('tab-material')){
      $('.conceal-property-sen').hide();
      $('.conceal-property-tec').hide();
      $('.prod_mat_conceal').show();
    }else if($(this).hasClass('tab-sensorial')){
      $('.prod_mat_conceal').hide();
      $('.conceal-property-tec').hide();
      $('.conceal-property-sen').show();
    }else{
      $('.prod_mat_conceal').hide();
      $('.th-location').hide();
      $('.conceal-program').hide();
      $('.conceal-property-sen').hide();
      $('.conceal-property-tec').show();
    }
  });

  $('.browse-item span').click(function(){
    _clicked = $(this);
    $(this).parents('.browse-item').children('span').each(function(){
      $(this).removeClass('selected');
    });
    _clicked.addClass('selected');
    str = _clicked.parents('.browse-wrapper').parent().attr('class');
    if(_clicked.hasClass('choice-th')){
      switch(str.replace(/selected/g, "")){
        case 'conceal-program':
          $('#edit-program').val(_clicked.attr('title'));
        break;
        case 'prod_mat_conceal':
          $('#edit-type').val(_clicked.attr('title'));
        break;
        case 'conceal-property-sen':
          $('#edit-mat-1').val(_clicked.attr('title'));
        break;
        case 'conceal-property-tec':
          $('#edit-mat-2').val(_clicked.attr('title'));
        break;
      }
    }else{
      if(str.replace(/selected/g, "") == 'th-location'){
        ctr = _clicked.parent().parent().attr('class');
        switch(ctr.replace(/browse-wrapper /g, "")){
          case 'count-wrapper':
            $.getJSON(Drupal.settings.basePath + 'add-project/json/provinces', {country_code: _clicked.attr('title')}, function (jso, textStatus) {
              var options = '';
              for (var i = 0; i < jso.length; i++) {
                options += '<span title="' + jso[i].optionValue + '">' + jso[i].optionDisplay + '</span>';
              }
              $('.prov-wrapper .browse-item').html(options);
              //createCookie('prov-wrapper', options, 1);
              $('.city-wrapper .browse-item').html('');
              $('.prov-wrapper .browse-item span').bind('click', function(){
                _clicked = $(this);
                $(this).parents('.browse-item').children('span').each(function(){
                  $(this).removeClass('selected');
                });
                _clicked.addClass('selected');
                selectors = $('.count-wrapper .browse-item span.selected').attr('title') + '-' + $('.prov-wrapper .browse-item span.selected').attr('title');
                $.getJSON(Drupal.settings.basePath + 'add-project/json/cities', {'selectors': selectors}, function (jso, textStatus) {
                  var options2 = '';
                  if(jso.length == 0){
                    $('#edit-city-1').val(_clicked.attr('title'));
                  }
                  for (var i = 0; i < jso.length; i++) {
                    if(jso[i] != ""){
                      options2 += '<span title="' + jso[i] + '">' + jso[i] + '</span>';
                    }
                  }
                  $('.city-wrapper .browse-item').html(options2);
                  //createCookie('prov-wrapper', options2, 1);
                  $('.city-wrapper .browse-item span').bind('click', function(){
                    _clicked = $(this);
                    $(this).parents('.browse-item').children('span').each(function(){
                      $(this).removeClass('selected');
                    });
                    _clicked.addClass('selected');
                    $('#edit-city-1').val(_clicked.attr('title'));
                  });
                });
              })
            });
          break;

          default:
          break;
        }
      }else{
        $('.base-inviz').hide();
        str = _clicked.attr('class');
        $('#'+str.replace(/selected/g, "")).show();
      }
    }
  })

  vars = getUrlVars();
  if(vars['filter']){
    if(vars['filter'].indexOf('browse:1') > -1 || vars['filter'].indexOf('browse%3A1') > -1){
      //alert(vars['filter'].indexOf('browse:1'));
      $('.search-browse-tabs li a').removeClass('active');
      $('.search-browse-tabs li:nth-child(1) a').addClass('active');
      $('.search-form').hide();
      $('.browse-form').show();
    }
  }

  if($('.gallery ul li img').length > 0){
    $('.gallery ul li img').mouseover(function(){
      if($(this).hasClass('on') || $(this).hasClass('off') || $(this).hasClass('slider_item_author_off') || $(this).hasClass('slider_item_author_on')){
        return;
      }else{
        temp = $(this).attr('src');
        if($(this).attr('src').indexOf('lucius_helpers') > -1 && ($(this).attr('title') != "Standard")){
          $(this).attr('src', temp.substring(0, temp.length - 4) + '_hover.png');
          $(this).bind('mouseout', function(){
            $(this).attr('src', temp);
          });
        }
      }
    });
  }

  if($('#edit-sort').length > 0 && $('#edit-sort').attr('type') !== 'hidden'){// prevents bug on highlighted
    var first = false;
    t = $('#edit-sort');
    t.css({'visibility' : 'hidden', 'position' : 'absolute'}); // still able to target yet not visible for the eye
    currentsel = t.attr('name');
    clickabledrop ='<ul class="cst-clickable-drop" style="padding:0px; margin: 0px 0px 10px;" name="'+ currentsel +'"><li><a href="#" class="selected" onclick="return false">';
    $("select[name=" + currentsel +"] option").each(function() {// foreach option in select
      if(first == false){
      clickabledrop += ( $('select[name=' + currentsel + '] option:selected').text() + '</a><ul>');
      first = true;
    }
    clickabledrop += '<li><a href="#" title="' + $(this).val() + '">'+ $(this).text()+'</a></li>';// add item to unsorted list
    });
    clickabledrop += '</ul></li></ul>';//close clickable drop
    t.parent().append(clickabledrop);// append the clickable drop
  }

  $('.cst-clickable-drop > li > ul > li > a').bind('click', function(){ //bind a function to each selectable option in clickable drop
    option = $(this).attr('title'); // store the title, we need this for selecting the correct option in the real select
    name = $(this).parents('.cst-clickable-drop').attr('name'); //get the name of the clickable drop to select the correct select element
    $('.cst-clickable-drop[name='+ name +'] > li > a').text($(this).text()); // replace the visible text, to show which option is selected
    $('select[name='+ name +'] option[value=' + option +']').attr('selected', 'selected');// select the option in the real select element
    $(this).parents('form').submit();
  });

});

$(window).bind('load', function(){
  //fix width addthis facebook button
  $("a.addthis_button_facebook_like").children('iframe').width(120);
  //alert($("a.addthis_button_facebook_like").children('iframe').width());
  $('div.gallery-holder2').each(function(){
    var _wraper = $(this),
      _holder = $('div.gallery2 > div', _wraper),
      _mover = $('div.mover', _holder),
      _slide = $('li', _mover),
      _prev = $('a.link-prev', _wraper),
      _next = $('a.link-next', _wraper),
      _length = _slide.length-1;

    var _duration = 500,
      _loadDuration = 4000,
      _current = 0,
      _margin = 0,
      _step = [], _stepSum = 0;

    _step[0] = 0;
    _slide.each(function(i){
      _stepSum += $(this).outerWidth(true);
      $(this).find('div.title').width($(this).width());
      _step[i+1] = _stepSum;
    });
    var _maxMargin = _step[_slide.length] - _holder.innerWidth();

    _next.click(function(){
      if ($(this).hasClass('back')) {
        $(this).removeClass('back');
        _current = 0;
      } else _current++;
      if (_current > _length) _current = 0;
      _margin = _step[_current];
      if (_margin >= _maxMargin) {
        _margin = _maxMargin;
        _next.addClass('back');
      }
      _mover.animate({'marginLeft': -_margin}, {duration:_duration, queue:false});
      return false;
    });
    _prev.click(function(){
      _current--;
      if (_current < 0) _current = _length;
      if (_margin == _maxMargin) {
        for (var i=_length; i > 0; i--) {
          if (_step[i] < _maxMargin) {
            _current = i;
            break;
          }
        }
      }
      _margin = _step[_current];
      if (_margin > _maxMargin) {
        _margin = _maxMargin;
        _next.addClass('back');
      }
      _mover.animate({'marginLeft': -_margin}, {duration:_duration, queue:false});
      return false;
    });

  });
  $('#postal-adress-th').bind('click', function(){
    if($(this).attr('class') == 'inactive'){
      $(this).addClass("active").removeClass("inactive");
      $('#main-adress-th').addClass("inactive").removeClass("active");
      $('#adress2-th').removeClass('adress_inactive').addClass('adress_active');
      $('#adress1-th').removeClass('adress_active').addClass('adress_inactive');
    }
  });

  $('#main-adress-th').bind('click', function(){
    if($(this).attr('class') == 'inactive'){
      $(this).addClass("active").removeClass("inactive");
      $('#postal-adress-th').addClass("inactive").removeClass("active");
      $('#adress1-th').removeClass('adress_inactive').addClass('adress_active');
      $('#adress2-th').removeClass('adress_active').addClass('adress_inactive');
    }
  });


  /* centreren van de afbeelding van de sponsor */
  if($('.sponsor-block .sponsor-th .sponsor-top img.imagecache-sponsor_switch')){
    var Hcenter = ($('.sponsor-block .sponsor-th .sponsor-top dt').width() / 2) - ( $('.sponsor-block .sponsor-th .sponsor-top img.imagecache-sponsor_switch').width() / 2 );
    var Vcenter = ($('.sponsor-block .sponsor-th .sponsor-top dt').height() / 2) - ( $('.sponsor-block .sponsor-th .sponsor-top img.imagecache-sponsor_switch').height() / 2 );
    $('.sponsor-block .sponsor-th .sponsor-top img.imagecache-sponsor_switch').css({'margin-left' : Hcenter, 'margin-top' : Vcenter});
  }
});


;
function initTabs()
{
	var sets = document.getElementsByTagName("div");
	for (var i = 0; i < sets.length; i++)
	{
		if (sets[i].className.indexOf("tabs") != -1)
		{
			var tabs = [];
			var links = sets[i].getElementsByTagName("a");
			for (var j = 0; j < links.length; j++)
			{
				if (links[j].className.indexOf("tab") != -1)
				{
					tabs.push(links[j]);
					links[j].tabs = tabs;
					var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));

					//reset all tabs on start
					if (c) if (links[j].className.indexOf("active") != -1) c.style.display = "block";
					else c.style.display = "none";

					links[j].onclick = function ()
					{
						tm = $(this).attr('href').substring(1, 5); //fetch the active tab
						//get the amount of pages
						chld = $('li#' + tm + '').children('.block01').children('.c').children('.paging').children('ul').children('li').length; 
						//calculate width of the pager
						wdt = 26 + ( chld * 26);
						//get lock on the pager
						var _pag = $('li#' + tm + '').children('.block01').children('.c').children('.paging');
						//calculate center 559 is the maxwidth of the element
						center = (( 559 / 2 ) - (wdt / 2));
						//place it in the center
						_pag.css({ 'margin-left' : center });
												
						var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
						if (c)
						{
							//reset all tabs before change
							for (var i = 0; i < this.tabs.length; i++)
							{
								var tab = document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1));
								if (tab)
								{
									tab.style.display = "none";
								}
								this.tabs[i].className = this.tabs[i].className.replace("active", "");
							}
							this.className += " active";
							c.style.display = "block";
						/*	if (typeof VSA_handleResize == 'function')
								VSA_handleResize()*/
							return false;
						}
					}
				}
			}
		}
	}
}

/*if (window.addEventListener)
	window.addEventListener("load", initTabs, false);
else if (window.attachEvent && !window.opera)
	window.attachEvent("onload", initTabs);*/
;
/*
 * jQuery galleryScroll v1.2.0
 */
jQuery.fn.galleryScroll = function(_options){
	// defaults options	
	var _options = jQuery.extend({
		btPrev: 'a.prev',
		btNext: 'a.next',
		holder: 'div',
		mover: 'ul',
		scrollEl: 'li',
		duration : 1000,
		tabset: false,
		step: false,
		autoRotation:false,
		stopARbyHover:false,
		startARafterClick:false,
		generateNumLinks:false,
		currentNum:false,
		fixed_step:0,
		fixed_width:0,
		allNum:false,
		disable:false
	},_options);

	return this.each(function(){
		var _wraper = jQuery(this),
			_holder = jQuery(_options.holder, _wraper),
			_mover = jQuery(_options.mover, _holder),
			_lis = jQuery(_options.scrollEl, _mover.eq(0)),
			_links = _options.tabset ? jQuery(_options.tabset, _wraper) : null,
			_prev = jQuery(_options.btPrev, _wraper),
			_next = jQuery(_options.btNext, _wraper),
			_step = _options.step ? (_lis.eq(0).outerWidth(true) * _options.step) : _holder.outerWidth(),
			_duration = _options.duration,
			_allNum = jQuery(_options.allNum, _wraper),
			_currentNum = jQuery(_options.currentNum, _wraper);

		_mover.css('position','relative');
		
		var _sumWidth = 0;
    var count = 0;
		_lis.each(function(){
           count++;
		   _sumWidth += $(this).outerWidth(true);
		});
		//alert(_mover.parent().parent().parent().attr('id'));
		//alert(_mover.css('display'));
		var _maxMargin = _sumWidth-_holder.outerWidth(),
			_length = Math.floor(_maxMargin/_step)+1,
			_current = 0, _margin = 0;

		if ($(this).hasClass('fixed-size')){
			_maxMargin = _lis.length * _options.fixed_step - _options.fixed_width;
			_step = _options.fixed_width;
			_length = Math.floor(_maxMargin/_options.fixed_width)+1;
		}
		
		if (_maxMargin < 0) {
			_prev.css('visibility','hidden');
			_next.css('visibility','hidden');
		}
		if (_maxMargin%_step == 0) _length -= 1;
		
		// generate Number Links
		if (_options.generateNumLinks) {
			var _linkHolder = jQuery(_options.generateNumLinks, _wraper),
				_numLinksStr = '<ul class="numLinks">';
			for (var i=0; i<_length+1; i++) {
				_numLinksStr += '<li><a href="#">'+(i+1)+'</a></li>';
			}
			_numLinksStr += '</ul>';
			_options.tabset = true;
			_linkHolder.append(_numLinksStr);
			_links = _linkHolder.find('a');
			_links.eq(_current).addClass('active');
		}
		// init timer
		var _timer = false;
		if (_options.autoRotation) {
			_timer = setInterval(function(){nextSlides()},_options.autoRotation);
			if (_options.stopARbyHover)
				_holder.hover(function(){
					if (_timer) clearInterval(_timer);
				}, function(){
					_timer = setInterval(function(){nextSlides()},_options.autoRotation);
				});
		}
		
		// click events
		if (_options.tabset) {
			_links.each(function(i, link){
				jQuery(link).click(function(){
					_links.parent().removeClass('active');
					_margin = _step*i;
					if (i >= _length) _margin = _maxMargin;
					_mover.animate({'left': -_margin}, {duration:_duration, queue:false})
					_current = i;
					jQuery(this).parent().addClass('active');
					return false;
				});
			});
		}
		_next.click(function(){
			if (_timer) clearInterval(_timer);
			if (_options.autoRotation && _options.startARafterClick) {
				setTimeout(function(){
					_timer = setInterval(function(){nextSlides()},_options.autoRotation);
				},_options.startARafterClick-_options.autoRotation)
			}
			nextSlides();
			return false;
		});
		if (_options.disable && _current == 0) _prev.addClass('prev-disable').addClass('disable');
		_prev.click(function(){
			
			if (_timer) clearInterval(_timer);
			if (_options.autoRotation && _options.startARafterClick) {
				setTimeout(function(){
					_timer = setInterval(function(){nextSlides()},_options.autoRotation);
				},_options.startARafterClick-_options.autoRotation)
			}
			_current -= 1;
			if (_options.disable && _current < _length) _next.removeClass('next-disable').removeClass('disable');
			if (_options.disable && _current == 0) _prev.addClass('prev-disable').addClass('disable');
			if (_current < 0) _current = _length;
			_margin = _step*_current;
			if (_current >= _length) _margin = _maxMargin;
			_mover.animate({'left': -_margin}, {duration:_duration, queue:false});
			setActive();
			return false;
		});
		function nextSlides(){
			_current += 1;
			if (_options.disable && _current > 0) _prev.removeClass('next-disable').removeClass('disable');
			if (_options.disable && _current >= _length) _next.addClass('next-disable').addClass('disable');
			if (_current > _length) _current = 0;
			_margin = _step*_current;
			if (_current >= _length){ 
				_margin = _maxMargin;
			}
			//alert(_maxMargin);
			//alert('_current(' + _current +') >= lenght(' + _lenght + ') _margin = ' + _maxMargin);
			_mover.animate({'left': -_margin}, {duration:_duration, queue:false});
			//alert('mover animate left: ' + -_margin);
			setActive();
			//alert('moving next');
		}
		function setActive () {
			if (_options.tabset && _links) {
				_links.parent().removeClass('active');
				_links.eq(_current).parent().addClass('active');
			}
			currentNum();
		}
		if (_options.currentNum && _currentNum.length) {
			_allNum.html(_length+1);
			currentNum();
		}
		
		function currentNum() {
			if (_currentNum.length && _options.currentNum)
				_currentNum.html(_current+1);
		}
	});
}

$(document).ready(function(){
	jQuery('.gallery:not(.e-gallery)').galleryScroll({
		btPrev: 'a.link-prev',
		btNext: 'a.link-next',
		holder: 'div',
		mover: 'ul',
		scrollEl: '> li',
		duration : 1500
	});
	$('div.tab-content div.gallery-holder').galleryScroll({
		btPrev: 'a.link-prev',
		btNext: 'a.link-next',
		holder: 'div',
		mover: 'ul',
		scrollEl: '> li',
		duration : 1500
	});
	
	$('div.side-area div.gallery-holder, div.side-area2 div.gallery-holder').galleryScroll({
		btPrev: 'a.prev',
		btNext: 'a.next',
		holder: 'div.gallery',
		mover: 'ul',
		scrollEl: '> li',
		duration : 1500
	});
	
	$('.sponsor-bottom').galleryScroll({
		btPrev: 'a.link-prev',
		btNext: 'a.link-next',
		holder: 'div.story-chomper',
		mover: 'ul',
		scrollEl: '> li',
		duration : 1500
	});
	
	if (typeof initTabs == 'function') {
	  initTabs();
	}
});


;
var _global_currentLi;
var scrollStopped;
/*
 * jQuery galleryScrollV v1.0.0
 */

jQuery.fn.galleryScrollV = function(_options){
	// defaults options	
	var _options = jQuery.extend({
		btUp: 'a.up-arrow',
		btDown: 'a.down-arrow',
		holder: 'div',
		mover: 'ul',
		scrollEl: 'li',
		duration : 1000,
		tabset: false,
		step: false
	},_options);

	return this.each(function(){
		var _wraper = $(this);
		var _holder = $(_options.holder, _wraper);
		var _mover = $(_options.mover, _holder);
		var _lis = $(_options.scrollEl, _mover);
		var _links = $(_options.tabset, _wraper);
		var _prev = $(_options.btUp, _wraper);
		var _next = $(_options.btDown, _wraper);
		var _step = _options.step ? (_lis.eq(0).outerHeight(true) * _options.step) : _holder.outerHeight();
		var _duration = _options.duration;
		
		var _maxMargin = _lis.length*_lis.eq(0).outerHeight(true)-_holder.outerHeight();
		var _length = Math.floor(_maxMargin/_step)+1;
		var _current = 1;
		var _margin = 0;
		
		var _currentLi = 1;
		if (_maxMargin%_step == 0) {
		  _length -= 1;
		}
		
		//alert(_global_currentLi); //ach ja debug
		
		_global_currentLi = _currentLi;
		if (_wraper.hasClass('story-slider') && !scrollStopped){
			setInterval( function() {
				_currentLi = _global_currentLi;
				_currentLi++;
				if (_currentLi > _lis.length) {
					_currentLi = 1;
				}
				if (scrollStopped) {
				  	scrollStopped = false;
				  	return ;
				}
				_lis.removeClass('current');
				_lis.eq(_currentLi-1).addClass('current');
				
				el = $('.story-pictures .visual-list li');
				el.removeClass('active').fadeOut(400);
  			    el.eq(_currentLi-1).addClass('active').fadeIn(400);

				el = $('.story-pictures .badge-list li');
				el.removeClass('active').fadeOut(400);
				el.eq(_currentLi-1).addClass('active').fadeIn(400);

				if (((_currentLi-1) % 3) == 0) {
					_current = Math.round(_currentLi / 3);
					if (_current > _length) {
						_current = 0;
					}
					_margin = _step*_current;
					if (_current >= _length) {
						_margin = _maxMargin;
					}
					_mover.animate( {'marginTop': -_margin}, {duration:_duration, queue:false} );
				}

				_global_currentLi = _currentLi;
			} , 5000);
		}
		
		if (_options.tabset) {
			_links.each(function(link, i){
				$(link).click(function(){
					_links.removeClass('active');
					_margin = _step*i;
					if (i >= _length) _margin = _maxMargin;
					_mover.animate({'marginTop': -_margin}, {duration:_duration, queue:false})
					_current = i;
					$(this).addClass('active');
					return false;
				});
			});
		}
		_next.click(function(){
			if (_options.tabset) {_links.removeClass('active');}
			_current++;
			if (_current > _length) _current = 0;
			_margin = _step*_current;
			if (_current >= _length) _margin = _maxMargin;
			_mover.animate({'marginTop': -_margin}, {duration:_duration, queue:false})
			if (_options.tabset) {_links.eq(_current).addClass('active');}
			return false;
		});
		_prev.click(function(){
			if (_options.tabset) {_links.removeClass('active');}
			_current--;
			if (_current < 0) _current = _length;
			_margin = _step*_current;
			if (_current >= _length) _margin = _maxMargin;
			_mover.animate({'marginTop': -_margin}, {duration:_duration, queue:false})
			if (_options.tabset) {_links.eq(_current).addClass('active');}
			return false;
		});
	});
}

$(document).ready(function(){
	$('div.grey-box-in div.scroll').galleryScrollV({
		btUp: 'a.btn-up',
		btDown: 'a.btn-down',
		holderList: 'div',
		scrollElParent: 'ul',
		scrollEl: 'li',
		duration : 1000
	});
	
	$('.mini-content  div.center div.bottom div.bottom-white div.scroll').galleryScrollV({
		btUp: 'a.btn-up',
		btDown: 'a.btn-down',
		holderList: 'div',
		scrollElParent: 'ul',
		scrollEl: 'li',
		duration : 1000
	});
	
	$('.model-enlarged div.scroll').galleryScrollV({
    btUp: 'a.btn-up',
    btDown: 'a.btn-down',
    holderList: 'div',
    scrollElParent: 'ul',
    scrollEl: 'li',
    duration : 1000
  });
  
  /***
   * Override for the bug in case: 2070
   **/
	
  $(".story-slider .posts-list > li > a").click(function () {
    var index = $(".story-slider .posts-list > li > a").index(this);
    if (index != -1){
        _global_currentLi = index+1;
        el = $('.story-pictures .visual-list li');
        el.removeClass('active').fadeOut(400);
        el.eq(_global_currentLi - 1).addClass('active').fadeIn(400);
        el = $('.story-pictures .badge-list li');
        el.removeClass('active').fadeOut(400);
        el.eq(_global_currentLi - 1).addClass('active').fadeIn(400);
        
        $('.posts-list li.current').removeClass('current');
        $('.posts-list li').eq(_global_currentLi - 1).addClass('current');
    }
  });
  $('div.tab-slideshow').slideShow({
    slideEl:'ul.visual-list > li',		
    numElement:'div.grey-box ul.posts-list li a:not(.sign-in-link)',		
    duration:400
  });

})
scrollStopped = false;;
/* 
* jQuery slideShow v1.2.2
*/

jQuery.fn.slideShow = function(_options){    
	// defaults options	    
	var _options = jQuery.extend({		
		slideEl:'div.slide',		
		linkNext:'a.next',		
		linkPrev:'a.prev',		
		linkPause:'a.pause',		
		numElement:'div.slideNav li a',		
		duration:500,		
		autoSlideShow:false,		
		switchTime:3000,
		noCicle:false,
		disableClass:'no-active',
		event:'click',		
		currentEl:'span.cur',		
		allEl:'span.all',
		hideBeforeShow: false
	},_options);
    return this.each(function(){
	    var _THIS = jQuery(this),
			_slideEl = $(_options.slideEl, _THIS),
			_linkNext = $(_options.linkNext, _THIS),
			_linkPrev = $(_options.linkPrev, _THIS),
			_linkPause = $(_options.linkPause, _THIS),
			_numElement = $(_options.numElement, _THIS),
			_currentEl = $(_options.currentEl, _THIS),
			_allEl = $(_options.allEl, _THIS),
			_duration = _options.duration,
			_switchTime = _options.switchTime,
			_numElActive, _timer = false, _hover = false, _current = 0, _next = 0, _pause = true;
		
		if (!_slideEl.filter('.active').length) {
			_slideEl.eq(0).addClass('active');
			_current = 0;
		} else {
			_current = _slideEl.index(_slideEl.filter('.active'));
		}
		_slideEl.not(".active").hide();
		
		if ($(_numElement).length && _options.numElement) activeNumEl();
		if (_options.autoSlideShow) {
			_pause = false;
			_timer = setTimeout(function(){nextEl()},_switchTime);
			if (_linkPause.length && _options.linkPause) _linkPause.addClass('play')	
			contentHover();
		}
		if (_options.currentEl && _currentEl.length) {
			_allEl.html(_slideEl.length);
			currentNum();
		}
		if (_linkNext.length && _options.linkNext) {
			_linkNext.click(function(){
				nextEl();
				return false;
			});
		}
		if (_options.noCicle) {
			_linkPrev.addClass('prev-'+_options.disableClass);
		}
		if (_linkPrev.length && _options.linkPrev) {	
			_linkPrev.click(function(){
				_linkNext.removeClass('next-'+_options.disableClass);
				if (!_slideEl.is(':animated') && !$(this).hasClass('prev-'+_options.disableClass)) {
					if (_timer) clearTimeout(_timer);
					_next = _current-1;
					if (_next < 0) _next = _slideEl.length-1;
					if (_options.noCicle && _next-1 < 0) {
						$(this).addClass('prev-'+_options.disableClass);
					}
					fadeElement();
					activeNumEl();
					pauseCode();
				}
				return false;
			});
		}
		if (_numElement.length && _options.numElement) {
			_numElement.bind(_options.event, function(){
			    
				if (!_slideEl.is(':animated')) {
					_next = _numElement.index($(this));
					_linkNext.removeClass('next-'+_options.disableClass);
					_linkPrev.removeClass('prev-'+_options.disableClass);
					if (_options.noCicle && _next+1 >= _slideEl.length) _linkNext.addClass('next-'+_options.disableClass);
					if (_options.noCicle && _next-1 < 0) _linkPrev.addClass('prev-'+_options.disableClass);
					if (_timer) clearTimeout(_timer);
					if (!_slideEl.eq(_next).hasClass("active")){
						fadeElement();
						activeNumEl();
						pauseCode();
					}
				}
				return false;
			});
		}
		if (_linkPause.length && _options.linkPause) {
			_linkPause.click(function(){
				if (!_pause) {
					$(this).removeClass('play');
					clearTimeout(_timer);
					_pause = true;
				} else {
					$(this).addClass('play');
					_timer = setTimeout(function(){nextEl()},_switchTime);
					_pause = false;
				}
				return false;
			});
		}
		function fadeElement(){
			if (_current != _next) {
        // readded for case 752
        if(_slideEl.parents('#map').length != 0){
           return;
        }
				_slideEl.removeClass('active');
				_slideEl.eq(_current).addClass('hide');
				
				if (!_options.hideBeforeShow) {
					_slideEl.eq(_next).fadeIn(_duration, function(){
						_slideEl.filter('.hide').hide().removeClass('hide');
					}).addClass('active');
				} else {
					_slideEl.filter('.hide').fadeOut(_duration, function(){
						_slideEl.eq(_next).fadeIn(_duration);
					}).removeClass('hide');
				}
				_current = _next;
				if (_options.currentEl && _currentEl.length) currentNum();
			}
		};
		function currentNum() {
			_currentEl.html(_current+1);
		}
		function activeNumEl() {
			_numElement.parent().removeClass("active");
			_numElement.eq(_current).parent().addClass("active");
		};
		function nextEl(){
			_linkPrev.removeClass('prev-'+_options.disableClass);
			if (!_slideEl.is(':animated') && !_linkNext.hasClass('next-'+_options.disableClass)) {
				if (_timer) clearTimeout(_timer);
				_next = _current+1;
				if (_next == _slideEl.length) _next = 0;
				if (_options.noCicle && _next+1 >= _slideEl.length) {
					_linkNext.addClass('next-'+_options.disableClass);
				}
				fadeElement();
				activeNumEl();
				pauseCode();
			}
		};
		function pauseCode(){
			if (!_pause) {
				if (_linkPause.length && _options.linkPause) {
					if (_linkPause.hasClass('play')) {
						_timer = setTimeout(function(){nextEl()},_switchTime);
					}					
				} else {
					_timer = setTimeout(function(){nextEl()},_switchTime);
				}
			}
		}
		function contentHover() {
			_hover = true;
			_slideEl.mouseenter(function() {
				if (_timer) clearTimeout(_timer);
			}).mouseleave(function(){
				pauseCode();
			});			
		}
    });
}


;
/*
 * jQuery UI 1.7.2
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
jQuery.ui||(function(c){var i=c.fn.remove,d=c.browser.mozilla&&(parseFloat(c.browser.version)<1.9);c.ui={version:"1.7.2",plugin:{add:function(k,l,n){var m=c.ui[k].prototype;for(var j in n){m.plugins[j]=m.plugins[j]||[];m.plugins[j].push([l,n[j]])}},call:function(j,l,k){var n=j.plugins[l];if(!n||!j.element[0].parentNode){return}for(var m=0;m<n.length;m++){if(j.options[n[m][0]]){n[m][1].apply(j.element,k)}}}},contains:function(k,j){return document.compareDocumentPosition?k.compareDocumentPosition(j)&16:k!==j&&k.contains(j)},hasScroll:function(m,k){if(c(m).css("overflow")=="hidden"){return false}var j=(k&&k=="left")?"scrollLeft":"scrollTop",l=false;if(m[j]>0){return true}m[j]=1;l=(m[j]>0);m[j]=0;return l},isOverAxis:function(k,j,l){return(k>j)&&(k<(j+l))},isOver:function(o,k,n,m,j,l){return c.ui.isOverAxis(o,n,j)&&c.ui.isOverAxis(k,m,l)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(d){var f=c.attr,e=c.fn.removeAttr,h="http://www.w3.org/2005/07/aaa",a=/^aria-/,b=/^wairole:/;c.attr=function(k,j,l){var m=l!==undefined;return(j=="role"?(m?f.call(this,k,j,"wairole:"+l):(f.apply(this,arguments)||"").replace(b,"")):(a.test(j)?(m?k.setAttributeNS(h,j.replace(a,"aaa:"),l):f.call(this,k,j.replace(a,"aaa:"))):f.apply(this,arguments)))};c.fn.removeAttr=function(j){return(a.test(j)?this.each(function(){this.removeAttributeNS(h,j.replace(a,""))}):e.call(this,j))}}c.fn.extend({remove:function(){c("*",this).add(this).each(function(){c(this).triggerHandler("remove")});return i.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var j;if((c.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){j=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(c.curCSS(this,"position",1))&&(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}else{j=this.parents().filter(function(){return(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!j.length?c(document):j}});c.extend(c.expr[":"],{data:function(l,k,j){return !!c.data(l,j[3])},focusable:function(k){var l=k.nodeName.toLowerCase(),j=c.attr(k,"tabindex");return(/input|select|textarea|button|object/.test(l)?!k.disabled:"a"==l||"area"==l?k.href||!isNaN(j):!isNaN(j))&&!c(k)["area"==l?"parents":"closest"](":hidden").length},tabbable:function(k){var j=c.attr(k,"tabindex");return(isNaN(j)||j>=0)&&c(k).is(":focusable")}});function g(m,n,o,l){function k(q){var p=c[m][n][q]||[];return(typeof p=="string"?p.split(/,?\s+/):p)}var j=k("getter");if(l.length==1&&typeof l[0]=="string"){j=j.concat(k("getterSetter"))}return(c.inArray(o,j)!=-1)}c.widget=function(k,j){var l=k.split(".")[0];k=k.split(".")[1];c.fn[k]=function(p){var n=(typeof p=="string"),o=Array.prototype.slice.call(arguments,1);if(n&&p.substring(0,1)=="_"){return this}if(n&&g(l,k,p,o)){var m=c.data(this[0],k);return(m?m[p].apply(m,o):undefined)}return this.each(function(){var q=c.data(this,k);(!q&&!n&&c.data(this,k,new c[l][k](this,p))._init());(q&&n&&c.isFunction(q[p])&&q[p].apply(q,o))})};c[l]=c[l]||{};c[l][k]=function(o,n){var m=this;this.namespace=l;this.widgetName=k;this.widgetEventPrefix=c[l][k].eventPrefix||k;this.widgetBaseClass=l+"-"+k;this.options=c.extend({},c.widget.defaults,c[l][k].defaults,c.metadata&&c.metadata.get(o)[k],n);this.element=c(o).bind("setData."+k,function(q,p,r){if(q.target==o){return m._setData(p,r)}}).bind("getData."+k,function(q,p){if(q.target==o){return m._getData(p)}}).bind("remove",function(){return m.destroy()})};c[l][k].prototype=c.extend({},c.widget.prototype,j);c[l][k].getterSetter="option"};c.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled")},option:function(l,m){var k=l,j=this;if(typeof l=="string"){if(m===undefined){return this._getData(l)}k={};k[l]=m}c.each(k,function(n,o){j._setData(n,o)})},_getData:function(j){return this.options[j]},_setData:function(j,k){this.options[j]=k;if(j=="disabled"){this.element[k?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",k)}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(l,m,n){var p=this.options[l],j=(l==this.widgetEventPrefix?l:this.widgetEventPrefix+l);m=c.Event(m);m.type=j;if(m.originalEvent){for(var k=c.event.props.length,o;k;){o=c.event.props[--k];m[o]=m.originalEvent[o]}}this.element.trigger(m,n);return !(c.isFunction(p)&&p.call(this.element[0],m,n)===false||m.isDefaultPrevented())}};c.widget.defaults={disabled:false};c.ui.mouse={_mouseInit:function(){var j=this;this.element.bind("mousedown."+this.widgetName,function(k){return j._mouseDown(k)}).bind("click."+this.widgetName,function(k){if(j._preventClickEvent){j._preventClickEvent=false;k.stopImmediatePropagation();return false}});if(c.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(c.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(l){l.originalEvent=l.originalEvent||{};if(l.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(l));this._mouseDownEvent=l;var k=this,m=(l.which==1),j=(typeof this.options.cancel=="string"?c(l.target).parents().add(l.target).filter(this.options.cancel).length:false);if(!m||j||!this._mouseCapture(l)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){k.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(l)&&this._mouseDelayMet(l)){this._mouseStarted=(this._mouseStart(l)!==false);if(!this._mouseStarted){l.preventDefault();return true}}this._mouseMoveDelegate=function(n){return k._mouseMove(n)};this._mouseUpDelegate=function(n){return k._mouseUp(n)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(c.browser.safari||l.preventDefault());l.originalEvent.mouseHandled=true;return true},_mouseMove:function(j){if(c.browser.msie&&!j.button){return this._mouseUp(j)}if(this._mouseStarted){this._mouseDrag(j);return j.preventDefault()}if(this._mouseDistanceMet(j)&&this._mouseDelayMet(j)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,j)!==false);(this._mouseStarted?this._mouseDrag(j):this._mouseUp(j))}return !this._mouseStarted},_mouseUp:function(j){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(j.target==this._mouseDownEvent.target);this._mouseStop(j)}return false},_mouseDistanceMet:function(j){return(Math.max(Math.abs(this._mouseDownEvent.pageX-j.pageX),Math.abs(this._mouseDownEvent.pageY-j.pageY))>=this.options.distance)},_mouseDelayMet:function(j){return this.mouseDelayMet},_mouseStart:function(j){},_mouseDrag:function(j){},_mouseStop:function(j){},_mouseCapture:function(j){return true}};c.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);;/*
 * jQuery UI Slider 1.7.2
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Slider
 *
 * Depends:
 *	ui.core.js
 */
(function(a){a.widget("ui.slider",a.extend({},a.ui.mouse,{_init:function(){var b=this,c=this.options;this._keySliding=false;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all");this.range=a([]);if(c.range){if(c.range===true){this.range=a("<div></div>");if(!c.values){c.values=[this._valueMin(),this._valueMin()]}if(c.values.length&&c.values.length!=2){c.values=[c.values[0],c.values[0]]}}else{this.range=a("<div></div>")}this.range.appendTo(this.element).addClass("ui-slider-range");if(c.range=="min"||c.range=="max"){this.range.addClass("ui-slider-range-"+c.range)}this.range.addClass("ui-widget-header")}if(a(".ui-slider-handle",this.element).length==0){a('<a href="#"></a>').appendTo(this.element).addClass("ui-slider-handle")}if(c.values&&c.values.length){while(a(".ui-slider-handle",this.element).length<c.values.length){a('<a href="#"></a>').appendTo(this.element).addClass("ui-slider-handle")}}this.handles=a(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(d){d.preventDefault()}).hover(function(){if(!c.disabled){a(this).addClass("ui-state-hover")}},function(){a(this).removeClass("ui-state-hover")}).focus(function(){if(!c.disabled){a(".ui-slider .ui-state-focus").removeClass("ui-state-focus");a(this).addClass("ui-state-focus")}else{a(this).blur()}}).blur(function(){a(this).removeClass("ui-state-focus")});this.handles.each(function(d){a(this).data("index.ui-slider-handle",d)});this.handles.keydown(function(i){var f=true;var e=a(this).data("index.ui-slider-handle");if(b.options.disabled){return}switch(i.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:f=false;if(!b._keySliding){b._keySliding=true;a(this).addClass("ui-state-active");b._start(i,e)}break}var g,d,h=b._step();if(b.options.values&&b.options.values.length){g=d=b.values(e)}else{g=d=b.value()}switch(i.keyCode){case a.ui.keyCode.HOME:d=b._valueMin();break;case a.ui.keyCode.END:d=b._valueMax();break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(g==b._valueMax()){return}d=g+h;break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(g==b._valueMin()){return}d=g-h;break}b._slide(i,e,d);return f}).keyup(function(e){var d=a(this).data("index.ui-slider-handle");if(b._keySliding){b._stop(e,d);b._change(e,d);b._keySliding=false;a(this).removeClass("ui-state-active")}});this._refreshValue()},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy()},_mouseCapture:function(d){var e=this.options;if(e.disabled){return false}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();var h={x:d.pageX,y:d.pageY};var j=this._normValueFromMouse(h);var c=this._valueMax()-this._valueMin()+1,f;var k=this,i;this.handles.each(function(l){var m=Math.abs(j-k.values(l));if(c>m){c=m;f=a(this);i=l}});if(e.range==true&&this.values(1)==e.min){f=a(this.handles[++i])}this._start(d,i);k._handleIndex=i;f.addClass("ui-state-active").focus();var g=f.offset();var b=!a(d.target).parents().andSelf().is(".ui-slider-handle");this._clickOffset=b?{left:0,top:0}:{left:d.pageX-g.left-(f.width()/2),top:d.pageY-g.top-(f.height()/2)-(parseInt(f.css("borderTopWidth"),10)||0)-(parseInt(f.css("borderBottomWidth"),10)||0)+(parseInt(f.css("marginTop"),10)||0)};j=this._normValueFromMouse(h);this._slide(d,i,j);return true},_mouseStart:function(b){return true},_mouseDrag:function(d){var b={x:d.pageX,y:d.pageY};var c=this._normValueFromMouse(b);this._slide(d,this._handleIndex,c);return false},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._handleIndex=null;this._clickOffset=null;return false},_detectOrientation:function(){this.orientation=this.options.orientation=="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(d){var c,h;if("horizontal"==this.orientation){c=this.elementSize.width;h=d.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{c=this.elementSize.height;h=d.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}var f=(h/c);if(f>1){f=1}if(f<0){f=0}if("vertical"==this.orientation){f=1-f}var e=this._valueMax()-this._valueMin(),i=f*e,b=i%this.options.step,g=this._valueMin()+i-b;if(b>(this.options.step/2)){g+=this.options.step}return parseFloat(g.toFixed(5))},_start:function(d,c){var b={handle:this.handles[c],value:this.value()};if(this.options.values&&this.options.values.length){b.value=this.values(c);b.values=this.values()}this._trigger("start",d,b)},_slide:function(f,e,d){var g=this.handles[e];if(this.options.values&&this.options.values.length){var b=this.values(e?0:1);if((this.options.values.length==2&&this.options.range===true)&&((e==0&&d>b)||(e==1&&d<b))){d=b}if(d!=this.values(e)){var c=this.values();c[e]=d;var h=this._trigger("slide",f,{handle:this.handles[e],value:d,values:c});var b=this.values(e?0:1);if(h!==false){this.values(e,d,(f.type=="mousedown"&&this.options.animate),true)}}}else{if(d!=this.value()){var h=this._trigger("slide",f,{handle:this.handles[e],value:d});if(h!==false){this._setData("value",d,(f.type=="mousedown"&&this.options.animate))}}}},_stop:function(d,c){var b={handle:this.handles[c],value:this.value()};if(this.options.values&&this.options.values.length){b.value=this.values(c);b.values=this.values()}this._trigger("stop",d,b)},_change:function(d,c){var b={handle:this.handles[c],value:this.value()};if(this.options.values&&this.options.values.length){b.value=this.values(c);b.values=this.values()}this._trigger("change",d,b)},value:function(b){if(arguments.length){this._setData("value",b);this._change(null,0)}return this._value()},values:function(b,e,c,d){if(arguments.length>1){this.options.values[b]=e;this._refreshValue(c);if(!d){this._change(null,b)}}if(arguments.length){if(this.options.values&&this.options.values.length){return this._values(b)}else{return this.value()}}else{return this._values()}},_setData:function(b,d,c){a.widget.prototype._setData.apply(this,arguments);switch(b){case"disabled":if(d){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.attr("disabled","disabled")}else{this.handles.removeAttr("disabled")}case"orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue(c);break;case"value":this._refreshValue(c);break}},_step:function(){var b=this.options.step;return b},_value:function(){var b=this.options.value;if(b<this._valueMin()){b=this._valueMin()}if(b>this._valueMax()){b=this._valueMax()}return b},_values:function(b){if(arguments.length){var c=this.options.values[b];if(c<this._valueMin()){c=this._valueMin()}if(c>this._valueMax()){c=this._valueMax()}return c}else{return this.options.values}},_valueMin:function(){var b=this.options.min;return b},_valueMax:function(){var b=this.options.max;return b},_refreshValue:function(c){var f=this.options.range,d=this.options,l=this;if(this.options.values&&this.options.values.length){var i,h;this.handles.each(function(p,n){var o=(l.values(p)-l._valueMin())/(l._valueMax()-l._valueMin())*100;var m={};m[l.orientation=="horizontal"?"left":"bottom"]=o+"%";a(this).stop(1,1)[c?"animate":"css"](m,d.animate);if(l.options.range===true){if(l.orientation=="horizontal"){(p==0)&&l.range.stop(1,1)[c?"animate":"css"]({left:o+"%"},d.animate);(p==1)&&l.range[c?"animate":"css"]({width:(o-lastValPercent)+"%"},{queue:false,duration:d.animate})}else{(p==0)&&l.range.stop(1,1)[c?"animate":"css"]({bottom:(o)+"%"},d.animate);(p==1)&&l.range[c?"animate":"css"]({height:(o-lastValPercent)+"%"},{queue:false,duration:d.animate})}}lastValPercent=o})}else{var j=this.value(),g=this._valueMin(),k=this._valueMax(),e=k!=g?(j-g)/(k-g)*100:0;var b={};b[l.orientation=="horizontal"?"left":"bottom"]=e+"%";this.handle.stop(1,1)[c?"animate":"css"](b,d.animate);(f=="min")&&(this.orientation=="horizontal")&&this.range.stop(1,1)[c?"animate":"css"]({width:e+"%"},d.animate);(f=="max")&&(this.orientation=="horizontal")&&this.range[c?"animate":"css"]({width:(100-e)+"%"},{queue:false,duration:d.animate});(f=="min")&&(this.orientation=="vertical")&&this.range.stop(1,1)[c?"animate":"css"]({height:e+"%"},d.animate);(f=="max")&&(this.orientation=="vertical")&&this.range[c?"animate":"css"]({height:(100-e)+"%"},{queue:false,duration:d.animate})}}}));a.extend(a.ui.slider,{getter:"value values",version:"1.7.2",eventPrefix:"slide",defaults:{animate:false,delay:0,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null}})})(jQuery);;;
var initial = false;

function initSlider(){
	var _sliderHolder = $('div.slider-holder');
	
	_sliderHolder.each(function(i,_sh){
		var _pos = $(_sh).offset(),
			_sliderHWidth = $(_sh).find('div.ui-slider').innerWidth(),
			_sliderMax = $('a.button-right', _sh),
			_sliderMin = $('a.button-left', _sh),
			_sliderMaxInp = $('em.max input', _sh),
			_sliderMinInp = $('em.min input', _sh),
			_sliderMaxVis = $('em.max strong', _sh),
			_sliderMinVis = $('em.min strong', _sh),
			_sliderWidth = _sliderMax.innerWidth(),
			_sliderBar = $('div.ui-slider-range', _sh),
			_step = $('span.step', _sh),
			_posMin = 0, _posMax = 0;
			
		var _valMin = parseInt(_sliderMinVis.text()),
			_valDif = parseInt(_sliderMaxVis.text()) - parseInt(_sliderMinVis.text()),
			_valStep = _valDif / 100,
			_valStepSlide = parseInt(_step.text());
			
		_step.remove();		
		
		var _totalPercentage = _sliderHWidth - _sliderWidth;
		var _percent = 0;
		_posMin = (parseInt(_sliderMinInp.val()) - _valMin)/_valStep * _totalPercentage/100;
		_posMax = (parseInt(_sliderMaxInp.val()) - _valMin)/_valStep * _totalPercentage/100;
		if (!_posMax) _posMax = 100 * _totalPercentage/100;
		if (!_posMin) _posMin = 0;
		_sliderMax.css({left: _posMax});
		_sliderMin.css({left: _posMin});
		_sliderBar.css({'left':_posMin, 'width':_posMax-_posMin});
		
		$([_sliderMax, _sliderMin]).each(function(i,slider){
			var _slider = $(slider);
			_slider.css({'cursor':'pointer'});
			_slider.click(function(){return false});
			_slider.mousedown(function(e){
				var _dif = e.pageX - _pos.left;
				var _sl = parseInt(_slider.css('left'));
				if (!_sl) _sl = 0;
				var _if = (_slider.get(0) == _sliderMax.get(0));
				if (_if) _posMax = _sl;
				else _posMin = _sl;
				
				$(document).bind('mousemove', function(e){
					_left = e.pageX - _pos.left - _dif + _sl;
					if (_left < 0) {
						_left = 0;
					}
					if (_left > _sliderHWidth-_sliderWidth) {
						_left = _sliderHWidth-_sliderWidth;
					}
					if (_if) {
						if (_left - _sliderWidth <= _posMin) 
							_left = _posMin + _sliderWidth;
						_posMax = _left;
						setMaxVal();
					} else {
						if (_left + _sliderWidth >= _posMax) 
							_left = _posMax - _sliderWidth;
						_posMin = _left;
						setMinVal();
					}
					_slider.css({left: _left});
					return false;
				});
				$('body').bind('mouseup', leaveScroll);
				
				function leaveScroll(){
					$(document).unbind('mousemove');
					$('body').unbind('mouseup', leaveScroll);
					return false;
				}
				return false;
			});
		});
		
		function setMaxVal(_f){
			_sliderBar.css('width',_posMax-_posMin);
			_percent = Math.round((_posMax-_sliderWidth)/(_totalPercentage-_sliderWidth)*10000)/100;
			var _val = _percent*_valStep + _valMin;
			if (_val%_valStepSlide) {
				_val = _valStepSlide * Math.floor(_val/_valStepSlide);
			}
			if (!_f)
				_sliderMaxInp.val(Math.round(_val));
			if ($(_sh).is('.dec')) _val = dec(Math.round(_val));
			_sliderMaxVis.text(Math.round(_val));
		}
		function setMinVal(_f){
			_sliderBar.css({'left':_posMin, 'width':_posMax-_posMin});
			_percent = Math.round(_posMin/(_totalPercentage-_sliderWidth)*10000)/100;
			var _val = _percent*_valStep + _valMin;
			if (_val%_valStepSlide) {
				_val = _valStepSlide * Math.floor(_val/_valStepSlide);
			}
			if (!_f)
				_sliderMinInp.val(Math.round(_val));
			if ($(_sh).is('.dec')) _val = dec(Math.round(_val));
			_sliderMinVis.text(Math.round(_val));
		}
		setMinVal(true);
		setMaxVal(true);
	});
	
	if(window.attachEvent && !window.opera) document.body.attachEvent("onselectstart", function(){ if(_move) return false;});
}

function dec(_num){
	var _a = [];
	var _string = _num.toString();
	for (var i=0;i<_string.length; i++) {
		_a.push(_string.charAt(i));
	}
	_a.reverse();
	var _k = 0;
	var _resultRevers = '', _result = '';
	for (var i=0;i<_string.length; i++) {
		_k++;
		if (_k == 4) {
			_resultRevers += '.';
			_k = 1;
		}
		_resultRevers += _a[i];
	}
	for (var i=_resultRevers.length-1;i>=0; i--) {
		_result += _resultRevers.charAt(i);
	}
	return _result;
};
/**
 * Simple javascript to create, read and delete cookies
 * All credit for the script goes to quirksmode
 * @author www.quirksmode.org
 * http://www.quirksmode.org/js/cookies.html
 */

/**
 * Function to create a Cookie
 * @param name
 * @param value
 * @param days
 * @return
 */
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
/**
 * function to read a Cookie
 * @param name
 * @return
 */
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

/**
 * function to remove a cookie
 * @param name
 * @return
 */

function eraseCookie(name) {
  createCookie(name,"",-1);
};

