var spellcheck = function (data) {
	var found = false;
    var url='';
	var text = data [0];

	if (text != $('spellcheckinput').value)
		return;

	for (i=0; i<data [1].length; i++) {
		if (text.toLowerCase () == data [1] [i].toLowerCase ()) {
			found = true;
            url ='http://en.wikipedia.org/wiki/' + text;
			$('spellcheckresult').innerHTML = '<b class=green>Correct</b>';
			document.getElementById('wikisub').disabled = false;
		}
	}

	if (! found){
		$('spellcheckresult').innerHTML = '<b class=red>No Article</b>';
		document.getElementById('wikisub').disabled = true;}
};

var getwikijs = function (value) {
	if (! value)
		return;

	url = 'http://en.wikipedia.org/w/api.php?action=opensearch&search='+value+'&format=json&callback=spellcheck';

	$('spellcheckresult').innerHTML = 'Checking ...';
	var elem = document.createElement ('script');
	elem.setAttribute ('src', url);
	elem.setAttribute ('type','text/javascript');
	document.getElementsByTagName ('head') [0].appendChild (elem);
	elem = null;
};



var Prototip = {
  Version: '2.0.5'
};

var Tips = {
  options: {
    images: '../images/icons/', // image path, can be relative to this file or an absolute url	
    zIndex: 100                   // raise if required
  }
};

Prototip.Styles = {
  // The default style every other style will inherit from.
  // Used when no style is set through the options on a tooltip.
  'default': {
    border: 1,
    borderColor: '#d0e5fb',
    className: 'default',
    closeButton: true,
    hideAfter: 1,
	hideOn: false,
	hideOthers: true,
    hook: false,
    radius: 4,
	showOn: 'mousemove',
	width: false,
	height: 'auto',
    stem: {
      position: 'topLeft',       // Example: optional default stem position, this will also enable the stem
      height: 19,
      width: 32
    }	
  }
};

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}('P.11(X,{5V:"1.6.0.3",3U:c(){8.3C("25");b(/^(6x?:\\/\\/|\\/)/.6i(e.9.W)){e.W=e.9.W}13{h A=/1P(?:-[\\w\\d.]+)?\\.4G(.*)/;e.W=(($$("4C 4y[2b]").3t(c(B){O B.2b.2k(A)})||{}).2b||"").3j(A,"")+e.9.W}b(25.2r.3e&&!17.3X.v){17.3X.34("v","5L:5y-5r-5k:5d");17.1f("3G:32",c(){17.4P().4I("v\\\\:*","4H: 30(#2Z#4D);")})}e.2p();r.1f(2S,"2R",8.2R)},3C:c(A){b((4v 2S[A]=="4p")||(8.2P(2S[A].4l)<8.2P(8["4i"+A]))){4g("X 6p "+A+" >= "+8["4i"+A]);}},2P:c(A){h B=A.3j(/4c.*|\\./g,"");B=6h(B+"0".6e(4-B.3g));O A.66("4c")>-1?B-1:B},62:$w("43 60"),1U:c(A){b(25.2r.3e){O A}A=A.2s(c(E,D){h B=P.2A(8)?8:8.m,C=D.5J;5E(C&&C!=B){5x{C=C.5t}5q(F){C=B}}b(C==B){O}E(D)});O A},37:c(A){O(A>0)?(-1*A):(A).5g()},2R:c(){e.4j()}});P.11(e,{1D:[],1c:[],2p:c(){8.2G=8.1t},1p:(c(A){O{1k:(A?"29":"1k"),1a:(A?"1S":"1a"),29:(A?"29":"1k"),1S:(A?"1S":"1a")}})(25.2r.3e),3D:{1k:"1k",1a:"1a",29:"1k",1S:"1a"},2f:{k:"31",31:"k",i:"1s",1s:"i",1Y:"1Y",1e:"1h",1h:"1e"},3A:{q:"1e",p:"1h"},2U:c(A){O!!23[1]?8.2f[A]:A},1n:(c(B){h A=s 4x("4w ([\\\\d.]+)").4u(B);O A?(3u(A[1])<7):10})(4n.4m),2N:(25.2r.4k&&!17.6w),34:c(A){8.1D.2L(A)},1J:c(A){h B=8.1D.3t(c(C){O C.m==$(A)});b(B){B.4f();b(B.1b){B.o.1J();b(e.1n){B.1v.1J()}}8.1D=8.1D.4b(B)}A.1P=2a},4j:c(){8.1D.3m(c(A){8.1J(A.m)}.1j(8))},2J:c(C){b(C==8.49){O}b(8.1c.3g===0){8.2G=8.9.1t;3i(h B=0,A=8.1D.3g;B<A;B++){8.1D[B].o.f({1t:8.9.1t})}}C.o.f({1t:8.2G++});b(C.T){C.T.f({1t:8.2G})}8.49=C},47:c(A){8.3f(A);8.1c.2L(A)},3f:c(A){8.1c=8.1c.4b(A)},46:c(){e.1c.1Q("V")},Y:c(B,F){B=$(B),F=$(F);h K=P.11({1g:{x:0,y:0},R:10},23[2]||{});h D=K.1z||F.2t();D.k+=K.1g.x;D.i+=K.1g.y;h C=K.1z?[0,0]:F.3H(),A=17.1E.2D(),G=K.1z?"20":"15";D.k+=(-1*(C[0]-A[0]));D.i+=(-1*(C[1]-A[1]));b(K.1z){h E=[0,0];E.q=0;E.p=0}h I={m:B.21()},J={m:P.2c(D)};I[G]=K.1z?E:F.21();J[G]=P.2c(D);3i(h H 3Q J){3O(K[H]){U"5w":U"5u":J[H].k+=I[H].q;18;U"5s":J[H].k+=(I[H].q/2);18;U"5p":J[H].k+=I[H].q;J[H].i+=(I[H].p/2);18;U"5o":U"5m":J[H].i+=I[H].p;18;U"5l":U"5j":J[H].k+=I[H].q;J[H].i+=I[H].p;18;U"5h":J[H].k+=(I[H].q/2);J[H].i+=I[H].p;18;U"5f":J[H].i+=(I[H].p/2);18}}D.k+=-1*(J.m.k-J[G].k);D.i+=-1*(J.m.i-J[G].i);b(K.R){B.f({k:D.k+"j",i:D.i+"j"})}O D}});e.2p();h 5c=59.3J({2p:c(C,E){8.m=$(C);b(!8.m){4g("X: r 58 56, 55 3J a 1b.");O}e.1J(8.m);h A=(P.2F(E)||P.2A(E)),B=A?23[2]||[]:E;8.1u=A?E:2a;b(B.28){B=P.11(P.2c(X.33[B.28]),B)}8.9=P.11(P.11({1m:10,1i:0,3k:"#4R",1o:0,u:e.9.u,19:e.9.4L,1B:!(B.1d&&B.1d=="1Z")?0.14:10,1C:10,1x:"1S",3B:10,Y:B.Y,1g:B.Y?{x:0,y:0}:{x:16,y:16},1K:(B.Y&&!B.Y.1z)?1l:10,1d:"2q",n:10,28:"2Z",15:8.m,12:10,1E:(B.Y&&!B.Y.1z)?10:1l,q:10},X.33["2Z"]),B);8.15=$(8.9.15);8.1o=8.9.1o;8.1i=(8.1o>8.9.1i)?8.1o:8.9.1i;b(8.9.W){8.W=8.9.W.2Y("://")?8.9.W:e.W+8.9.W}13{8.W=e.W+"4F/"+(8.9.28||"")+"/"}b(!8.W.4E("/")){8.W+="/"}b(P.2F(8.9.n)){8.9.n={R:8.9.n}}b(8.9.n.R){8.9.n=P.11(P.2c(X.33[8.9.28].n)||{},8.9.n);8.9.n.R=[8.9.n.R.2k(/[a-z]+/)[0].2e(),8.9.n.R.2k(/[A-Z][a-z]+/)[0].2e()];8.9.n.1I=["k","31"].3z(8.9.n.R[0])?"1e":"1h";8.1r={1e:10,1h:10}}b(8.9.1m){8.9.1m.9=P.11({2V:25.4B},8.9.1m.9||{})}8.1p=$w("4A 43").3z(8.m.4z.2e())?e.3D:e.1p;b(8.9.Y.1z){h D=8.9.Y.1q.2k(/[a-z]+/)[0].2e();8.20=e.2f[D]+e.2f[8.9.Y.1q.2k(/[A-Z][a-z]+/)[0].2e()].2B()}8.3y=(e.2N&&8.1o);8.3x();e.34(8);8.3w();X.11(8)},3x:c(){8.o=s r("S",{u:"1P"}).f({1t:e.9.1t});b(8.3y){8.o.V=c(){8.f("k:-3v;i:-3v;1O:2o;");O 8};8.o.Q=c(){8.f("1O:1c");O 8};8.o.1c=c(){O(8.2Q("1O")=="1c"&&3u(8.2Q("i").3j("j",""))>-4t)}}8.o.V();b(e.1n){8.1v=s r("4s",{u:"1v",2b:"4r:10;",4q:0}).f({2m:"2i",1t:e.9.1t-1,4o:0})}b(8.9.1m){8.24=8.24.2s(8.2O)}8.1q=s r("S",{u:"1u"});8.12=s r("S",{u:"12"}).V();b(8.9.19||(8.9.1x.m&&8.9.1x.m=="19")){8.19=s r("S",{u:"2j"}).26(8.W+"2j.2l")}},2H:c(){b(17.32){8.3r();8.3s=1l;O 1l}13{b(!8.3s){17.1f("3G:32",8.3r);O 10}}},3r:c(){$(17.2M).N(8.o);b(e.1n){$(17.2M).N(8.1v)}b(8.9.1m){$(17.2M).N(8.T=s r("S",{u:"6v"}).26(8.W+"T.6t").V())}h G="o";b(8.9.n.R){8.n=s r("S",{u:"6r"}).f({p:8.9.n[8.9.n.1I=="1h"?"p":"q"]+"j"});h B=8.9.n.1I=="1e";8[G].N(8.3p=s r("S",{u:"6q 2K"}).N(8.4e=s r("S",{u:"6o 2K"})));8.n.N(8.1T=s r("S",{u:"6n"}).f({p:8.9.n[B?"q":"p"]+"j",q:8.9.n[B?"p":"q"]+"j"}));b(e.1n&&!8.9.n.R[1].4d().2Y("6m")){8.1T.f({2m:"6l"})}G="4e"}b(8.1i){h D=8.1i,F;8[G].N(8.1W=s r("6j",{u:"1W"}).N(8.1V=s r("3n",{u:"1V 3l"}).f("p: "+D+"j").N(s r("S",{u:"2n 6g"}).N(s r("S",{u:"1X"}))).N(F=s r("S",{u:"6f"}).f({p:D+"j"}).N(s r("S",{u:"4a"}).f({1w:"0 "+D+"j",p:D+"j"}))).N(s r("S",{u:"2n 6d"}).N(s r("S",{u:"1X"})))).N(8.2W=s r("3n",{u:"2W 3l"}).N(8.2T=s r("S",{u:"2T"}).f("2I: 0 "+D+"j"))).N(8.48=s r("3n",{u:"48 3l"}).f("p: "+D+"j").N(s r("S",{u:"2n 6c"}).N(s r("S",{u:"1X"}))).N(F.6b(1l)).N(s r("S",{u:"2n 69"}).N(s r("S",{u:"1X"})))));G="2T";h C=8.1W.2X(".1X");$w("68 67 65 63").3m(c(I,H){b(8.1o>0){X.45(C[H],I,{1L:8.9.3k,1i:D,1o:8.9.1o})}13{C[H].2E("44")}C[H].f({q:D+"j",p:D+"j"}).2E("1X"+I.2B())}.1j(8));8.1W.2X(".4a",".2W",".44").1Q("f",{1L:8.9.3k})}8[G].N(8.1b=s r("S",{u:"1b "+8.9.u}).N(8.27=s r("S",{u:"27"}).N(8.12)));b(8.9.q){h E=8.9.q;b(P.61(E)){E+="j"}8.1b.f("q:"+E)}b(8.n){h A={};A[8.9.n.1I=="1e"?"i":"1s"]=8.n;8.o.N(A);8.2g()}8.1b.N(8.1q);b(!8.9.1m){8.3d({12:8.9.12,1u:8.1u})}},3d:c(E){h A=8.o.2Q("1O");8.o.f("p:1M;q:1M;1O:2o").Q();b(8.1i){8.1V.f("p:0");8.1V.f("p:0")}b(E.12){8.12.Q().42(E.12);8.27.Q()}13{b(!8.19){8.12.V();8.27.V()}}b(P.2A(E.1u)){E.1u.Q()}b(P.2F(E.1u)||P.2A(E.1u)){8.1q.42(E.1u)}8.1b.f({q:8.1b.41()+"j"});8.o.f("1O:1c").Q();8.1b.Q();h C=8.1b.21(),B={q:C.q+"j"},D=[8.o];b(e.1n){D.2L(8.1v)}b(8.19){8.12.Q().N({i:8.19});8.27.Q()}b(E.12||8.19){8.27.f("q: 3c%")}B.p=2a;8.o.f({1O:A});8.1q.2E("2K");b(E.12||8.19){8.12.2E("2K")}b(8.1i){8.1V.f("p:"+8.1i+"j");8.1V.f("p:"+8.1i+"j");B="q: "+(C.q+2*8.1i)+"j";D.2L(8.1W)}D.1Q("f",B);b(8.n){8.2g();b(8.9.n.1I=="1e"){8.o.f({q:8.o.41()+8.9.n.p+"j"})}}8.o.V()},3w:c(){8.3b=8.24.1y(8);8.40=8.V.1y(8);b(8.9.1K&&8.9.1d=="2q"){8.9.1d="1k"}b(8.9.1d==8.9.1x){8.1R=8.3Z.1y(8);8.m.1f(8.9.1d,8.1R)}b(8.19){8.19.1f("1k",c(E){E.26(8.W+"5Y.2l")}.1j(8,8.19)).1f("1a",c(E){E.26(8.W+"2j.2l")}.1j(8,8.19))}h C={m:8.1R?[]:[8.m],15:8.1R?[]:[8.15],1q:8.1R?[]:[8.o],19:[],2i:[]},A=8.9.1x.m;8.39=A||(!8.9.1x?"2i":"m");8.1N=C[8.39];b(!8.1N&&A&&P.2F(A)){8.1N=8.1q.2X(A)}h D={29:"1k",1S:"1a"};$w("Q V").3m(c(H){h G=H.2B(),F=(8.9[H+"3Y"].38||8.9[H+"3Y"]);8[H+"3W"]=F;b(["29","1S","1k","1a"].2Y(F)){8[H+"3W"]=(8.1p[F]||F);8["38"+G]=X.1U(8["38"+G])}}.1j(8));b(!8.1R){8.m.1f(8.9.1d,8.3b)}b(8.1N){8.1N.1Q("1f",8.5X,8.40)}b(!8.9.1K&&8.9.1d=="1Z"){8.2u=8.R.1y(8);8.m.1f("2q",8.2u)}8.3V=8.V.2s(c(G,F){h E=F.5P(".2j");b(E){E.5N();F.5M();G(F)}}).1y(8);b(8.19||(8.9.1x&&(8.9.1x.m==".2j"))){8.o.1f("1Z",8.3V)}b(8.9.1d!="1Z"&&(8.39!="m")){8.2C=X.1U(c(){8.1G("Q")}).1y(8);8.m.1f(8.1p.1a,8.2C)}h B=[8.m,8.o];8.36=X.1U(c(){e.2J(8);8.2v()}).1y(8);8.35=X.1U(8.1C).1y(8);B.1Q("1f",8.1p.1k,8.36).1Q("1f",8.1p.1a,8.35);b(8.9.1m&&8.9.1d!="1Z"){8.2z=X.1U(8.3T).1y(8);8.m.1f(8.1p.1a,8.2z)}},4f:c(){b(8.9.1d==8.9.1x){8.m.1A(8.9.1d,8.1R)}13{8.m.1A(8.9.1d,8.3b);b(8.1N){8.1N.1Q("1A")}}b(8.2u){8.m.1A("2q",8.2u)}b(8.2C){8.m.1A("1a",8.2C)}8.o.1A();8.m.1A(8.1p.1k,8.36).1A(8.1p.1a,8.35);b(8.2z){8.m.1A(8.1p.1a,8.2z)}},2O:c(C,B){b(!8.1b){b(!8.2H()){O}}8.R(B);b(8.2y){O}13{b(8.3S){C(B);O}}8.2y=1l;h D={2h:{1F:22.1F(B),1H:22.1H(B)}};h A=P.2c(8.9.1m.9);A.2V=A.2V.2s(c(F,E){8.3d({12:8.9.12,1u:E.5I});8.R(D);(c(){F(E);h G=(8.T&&8.T.1c());b(8.T){8.1G("T");8.T.1J();8.T=2a}b(G){8.Q()}8.3S=1l;8.2y=2a}.1j(8)).1B(0.6)}.1j(8));8.5H=r.Q.1B(8.9.1B,8.T);8.o.V();8.2y=1l;8.T.Q();8.5F=(c(){s 5B.5A(8.9.1m.30,A)}.1j(8)).1B(8.9.1B);O 10},3T:c(){8.1G("T")},24:c(A){b(!8.1b){b(!8.2H()){O}}8.R(A);b(8.o.1c()){O}8.1G("Q");8.5z=8.Q.1j(8).1B(8.9.1B)},1G:c(A){b(8[A+"3N"]){5v(8[A+"3N"])}},Q:c(){b(8.o.1c()){O}b(e.1n){8.1v.Q()}b(8.9.3B){e.46()}e.47(8);8.1b.Q();8.o.Q();b(8.n){8.n.Q()}8.m.3M("1P:5C")},1C:c(A){b(8.9.1m){b(8.T&&8.9.1d!="1Z"){8.T.V()}}b(!8.9.1C){O}8.2v();8.5D=8.V.1j(8).1B(8.9.1C)},2v:c(){b(8.9.1C){8.1G("1C")}},V:c(){8.1G("Q");8.1G("T");b(!8.o.1c()){O}8.3L()},3L:c(){b(e.1n){8.1v.V()}b(8.T){8.T.V()}8.o.V();(8.1W||8.1b).Q();e.3f(8);8.m.3M("1P:2o")},3Z:c(A){b(8.o&&8.o.1c()){8.V(A)}13{8.24(A)}},2g:c(){h C=8.9.n,B=23[0]||8.1r,D=e.2U(C.R[0],B[C.1I]),F=e.2U(C.R[1],B[e.2f[C.1I]]),A=8.1o||0;8.1T.26(8.W+D+F+".2l");b(C.1I=="1e"){h E=(D=="k")?C.p:0;8.3p.f("k: "+E+"j;");8.1T.f({"2w":D});8.n.f({k:0,i:(F=="1s"?"3c%":F=="1Y"?"50%":0),5G:(F=="1s"?-1*C.q:F=="1Y"?-0.5*C.q:0)+(F=="1s"?-1*A:F=="i"?A:0)+"j"})}13{8.3p.f(D=="i"?"1w: 0; 2I: "+C.p+"j 0 0 0;":"2I: 0; 1w: 0 0 "+C.p+"j 0;");8.n.f(D=="i"?"i: 0; 1s: 1M;":"i: 1M; 1s: 0;");8.1T.f({1w:0,"2w":F!="1Y"?F:"2i"});b(F=="1Y"){8.1T.f("1w: 0 1M;")}13{8.1T.f("1w-"+F+": "+A+"j;")}b(e.2N){b(D=="1s"){8.n.f({R:"3P",5n:"5K",i:"1M",1s:"1M","2w":"k",q:"3c%",1w:(-1*C.p)+"j 0 0 0"});8.n.28.2m="3K"}13{8.n.f({R:"3R","2w":"2i",1w:0})}}}8.1r=B},R:c(B){b(!8.1b){b(!8.2H()){O}}e.2J(8);b(e.1n){h A=8.o.21();b(!8.2x||8.2x.p!=A.p||8.2x.q!=A.q){8.1v.f({q:A.q+"j",p:A.p+"j"})}8.2x=A}b(8.9.Y){h J,H;b(8.20){h K=17.1E.2D(),C=B.2h||{};h G,I=2;3O(8.20.4d()){U"5O":U"5i":G={x:0-I,y:0-I};18;U"5Q":G={x:0,y:0-I};18;U"5R":U"5S":G={x:I,y:0-I};18;U"5T":G={x:I,y:0};18;U"5U":U"5e":G={x:I,y:I};18;U"5W":G={x:0,y:I};18;U"5b":U"5a":G={x:0-I,y:I};18;U"5Z":G={x:0-I,y:0};18}G.x+=8.9.1g.x;G.y+=8.9.1g.y;J=P.11({1g:G},{m:8.9.Y.1q,20:8.20,1z:{i:C.1H||22.1H(B)-K.i,k:C.1F||22.1F(B)-K.k}});H=e.Y(8.o,8.15,J);b(8.9.1E){h M=8.3a(H),L=M.1r;H=M.R;H.k+=L.1h?2*X.37(G.x-8.9.1g.x):0;H.i+=L.1h?2*X.37(G.y-8.9.1g.y):0;b(8.n&&(8.1r.1e!=L.1e||8.1r.1h!=L.1h)){8.2g(L)}}H={k:H.k+"j",i:H.i+"j"};8.o.f(H)}13{J=P.11({1g:8.9.1g},{m:8.9.Y.1q,15:8.9.Y.15});H=e.Y(8.o,8.15,P.11({R:1l},J));H={k:H.k+"j",i:H.i+"j"}}b(8.T){h E=e.Y(8.T,8.15,P.11({R:1l},J))}b(e.1n){8.1v.f(H)}}13{h F=8.15.2t(),C=B.2h||{},H={k:((8.9.1K)?F[0]:C.1F||22.1F(B))+8.9.1g.x,i:((8.9.1K)?F[1]:C.1H||22.1H(B))+8.9.1g.y};b(!8.9.1K&&8.m!==8.15){h D=8.m.2t();H.k+=-1*(D[0]-F[0]);H.i+=-1*(D[1]-F[1])}b(!8.9.1K&&8.9.1E){h M=8.3a(H),L=M.1r;H=M.R;b(8.n&&(8.1r.1e!=L.1e||8.1r.1h!=L.1h)){8.2g(L)}}H={k:H.k+"j",i:H.i+"j"};8.o.f(H);b(8.T){8.T.f(H)}b(e.1n){8.1v.f(H)}}},3a:c(C){h E={1e:10,1h:10},D=8.o.21(),B=17.1E.2D(),A=17.1E.21(),G={k:"q",i:"p"};3i(h F 3Q G){b((C[F]+D[G[F]]-B[F])>A[G[F]]){C[F]=C[F]-(D[G[F]]+(2*8.9.1g[F=="k"?"x":"y"]));b(8.n){E[e.3A[G[F]]]=1l}}}O{R:C,1r:E}}});P.11(X,{45:c(G,H){h F=23[2]||8.9,B=F.1o,E=F.1i,D=s r("57",{u:"64"+H.2B(),q:E+"j",p:E+"j"}),A={i:(H.3I(0)=="t"),k:(H.3I(1)=="l")};b(D&&D.3h&&D.3h("2d")){G.N(D);h C=D.3h("2d");C.54=F.1L;C.53((A.k?B:E-B),(A.i?B:E-B),B,0,6a.52*2,1l);C.51();C.3F((A.k?B:0),0,E-B,E);C.3F(0,(A.i?B:0),E,E-B)}13{G.N(s r("S").f({q:E+"j",p:E+"j",1w:0,2I:0,2m:"3K",R:"3P",4Z:"2o"}).N(s r("v:4Y",{4X:F.1L,4W:"4V",4U:F.1L,4T:(B/E*0.5).4S(2)}).f({q:2*E-1+"j",p:2*E-1+"j",R:"3R",k:(A.k?0:(-1*E))+"j",i:(A.i?0:(-1*E))+"j"})))}}});r.6k({26:c(C,B){C=$(C);h A=P.11({3E:"i k",3q:"4Q-3q",3o:"4O",1L:""},23[2]||{});C.f(e.1n?{4N:"4M:6s.4K.6u(2b=\'"+B+"\'\', 3o=\'"+A.3o+"\')"}:{4J:A.1L+" 30("+B+") "+A.3E+" "+A.3q});O C}});X.4h={Q:c(){e.2J(8);8.2v();h D={};b(8.9.Y){D.2h={1F:0,1H:0}}13{h A=8.15.2t(),C=8.15.3H(),B=17.1E.2D();A.k+=(-1*(C[0]-B[0]));A.i+=(-1*(C[1]-B[1]));D.2h={1F:A.k,1H:A.i}}b(8.9.1m){8.2O(D)}13{8.24(D)}8.1C()}};X.11=c(A){A.m.1P={};P.11(A.m.1P,{Q:X.4h.Q.1j(A),V:A.V.1j(A),1J:e.1J.1j(e,A.m)})};X.3U();',62,406,'||||||||this|options||if|function||Tips|setStyle||var|top|px|left||element|stem|wrapper|height|width|Element|new||className|||||||||||||||||||insert|return|Object|show|position|div|loader|case|hide|images|Prototip|hook||false|extend|title|else||target||document|break|closeButton|mouseout|tooltip|visible|showOn|horizontal|observe|offset|vertical|border|bind|mouseover|true|ajax|fixIE|radius|useEvent|tip|stemInverse|bottom|zIndex|content|iframeShim|margin|hideOn|bindAsEventListener|mouse|stopObserving|delay|hideAfter|tips|viewport|pointerX|clearTimer|pointerY|orientation|remove|fixed|backgroundColor|auto|hideTargets|visibility|prototip|invoke|eventToggle|mouseleave|stemImage|capture|borderTop|borderFrame|prototip_Corner|middle|click|mouseHook|getDimensions|Event|arguments|showDelayed|Prototype|setPngBackground|toolbar|style|mouseenter|null|src|clone||toLowerCase|_inverse|positionStem|fakePointer|none|close|match|png|display|prototip_CornerWrapper|hidden|initialize|mousemove|Browser|wrap|cumulativeOffset|eventPosition|cancelHideAfter|float|iframeShimDimensions|ajaxContentLoading|ajaxHideEvent|isElement|capitalize|eventCheckDelay|getScrollOffsets|addClassName|isString|zIndexTop|build|padding|raise|clearfix|push|body|WebKit419|ajaxShow|convertVersionString|getStyle|unload|window|borderCenter|inverseStem|onComplete|borderMiddle|select|include|default|url|right|loaded|Styles|add|activityLeave|activityEnter|toggleInt|event|hideElement|getPositionWithinViewport|eventShow|100|_update|IE|removeVisible|length|getContext|for|replace|borderColor|borderRow|each|li|sizingMethod|stemWrapper|repeat|_build|_isBuilding|find|parseFloat|9500px|activate|setup|fixSafari2|member|_stemTranslation|hideOthers|require|specialEvent|align|fillRect|dom|cumulativeScrollOffset|charAt|create|block|afterHide|fire|Timer|switch|relative|in|absolute|ajaxContentLoaded|ajaxHide|start|buttonEvent|Action|namespaces|On|toggle|eventHide|getWidth|update|input|prototip_Fill|createCorner|hideAll|addVisibile|borderBottom|_highest|prototip_Between|without|_|toUpperCase|stemBox|deactivate|throw|Methods|REQUIRED_|removeAll|WebKit|Version|userAgent|navigator|opacity|undefined|frameBorder|javascript|iframe|9500|exec|typeof|MSIE|RegExp|script|tagName|area|emptyFunction|head|VML|endsWith|styles|js|behavior|addRule|background|Microsoft|closeButtons|progid|filter|scale|createStyleSheet|no|000000|toFixed|arcSize|strokeColor|1px|strokeWeight|fillcolor|roundrect|overflow||fill|PI|arc|fillStyle|cannot|available|canvas|not|Class|LEFTBOTTOM|BOTTOMLEFT|Tip|vml|BOTTOMRIGHT|leftMiddle|abs|bottomMiddle|TOPLEFT|rightBottom|com|bottomRight|leftBottom|clear|bottomLeft|rightMiddle|catch|microsoft|topMiddle|parentNode|rightTop|clearTimeout|topRight|try|schemas|showTimer|Request|Ajax|shown|hideAfterTimer|while|ajaxTimer|marginTop|loaderTimer|responseText|relatedTarget|both|urn|stop|blur|LEFTTOP|findElement|TOPMIDDLE|TOPRIGHT|RIGHTTOP|RIGHTMIDDLE|RIGHTBOTTOM|REQUIRED_Prototype|BOTTOMMIDDLE|hideAction|close_hover|LEFTMIDDLE|textarea|isNumber|_captureTroubleElements|br|cornerCanvas|bl|indexOf|tr|tl|prototip_CornerWrapperBottomRight|Math|cloneNode|prototip_CornerWrapperBottomLeft|prototip_CornerWrapperTopRight|times|prototip_BetweenCorners|prototip_CornerWrapperTopLeft|parseInt|test|ul|addMethods|inline|MIDDLE|prototip_StemImage|prototip_StemBox|requires|prototip_StemWrapper|prototip_Stem|DXImageTransform|gif|AlphaImageLoader|prototipLoader|evaluate|https'.split('|'),0,{}));

if (!window.Modalbox)
	var Modalbox = new Object();

Modalbox.Methods = {
	overrideAlert: false, // Override standard browser alert message with ModalBox
	focusableElements: new Array,
	currFocused: 0,
	initialized: false,
	active: true,
	options: {
		title: "ModalBox Window", // Title of the ModalBox window
		overlayClose: true, // Close modal box by clicking on overlay
		width: 500, // Default width in px
		height: 90, // Default height in px
		overlayOpacity: .65, // Default overlay opacity
		overlayDuration: .25, // Default overlay fade in/out duration in seconds
		slideDownDuration: .5, // Default Modalbox appear slide down effect in seconds
		slideUpDuration: .5, // Default Modalbox hiding slide up effect in seconds
		resizeDuration: .25, // Default resize duration seconds
		inactiveFade: true, // Fades MB window on inactive state
		transitions: true, // Toggles transition effects. Transitions are enabled by default
		loadingString: "Please wait. Loading...", // Default loading string message
		closeString: "Close window", // Default title attribute for close window link
		closeValue: "&times;", // Default string for close link in the header
		params: {},
		method: 'get', // Default Ajax request method
		autoFocusing: true, // Toggles auto-focusing for form elements. Disable for long text pages.
		aspnet: false // Should be use then using with ASP.NET costrols. Then true Modalbox window will be injected into the first form element.
	},
	_options: new Object,	
	
	setOptions: function(options) {
		Object.extend(this.options, options || {});
	},
	
	_init: function(options) {
		// Setting up original options with default options
		Object.extend(this._options, this.options);
		this.setOptions(options);
		
		//Create the overlay
		this.MBoverlay = new Element("div", { id: "MB_overlay", opacity: "0" });
		
		//Create DOm for the window
		this.MBwindow = new Element("div", {id: "MB_window", style: "display: none"}).update(
			this.MBframe = new Element("div", {id: "MB_frame"}).update(
				this.MBheader = new Element("div", {id: "MB_header"}).update(
					this.MBcaption = new Element("div", {id: "MB_caption"})
				)
			)
		);
		this.MBclose = new Element("a", {id: "MB_close", title: this.options.closeString, href: "#"}).update("<span>" + this.options.closeValue + "</span>");
		this.MBheader.insert({'bottom':this.MBclose});
		
		this.MBcontent = new Element("div", {id: "MB_content"}).update(
			this.MBloading = new Element("div", {id: "MB_loading"}).update(this.options.loadingString)
		);
		this.MBframe.insert({'bottom':this.MBcontent});
		
		// Inserting into DOM. If parameter set and form element have been found will inject into it. Otherwise will inject into body as topmost element.
		// Be sure to set padding and marging to null via CSS for both body and (in case of asp.net) form elements. 
		var injectToEl = this.options.aspnet ? $(document.body).down('form') : $(document.body);
		injectToEl.insert({'top':this.MBwindow});
		injectToEl.insert({'top':this.MBoverlay});
		
		// Initial scrolling position of the window. To be used for remove scrolling effect during ModalBox appearing
		this.initScrollX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
		this.initScrollY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
		
		//Adding event observers
		this.hideObserver = this._hide.bindAsEventListener(this);
		this.kbdObserver = this._kbdHandler.bindAsEventListener(this);
		this._initObservers();

		this.initialized = true; // Mark as initialized
	},
	
	show: function(content, options) {
		if(!this.initialized) this._init(options); // Check for is already initialized
		
		this.content = content;
		this.setOptions(options);
		
		if(this.options.title) // Updating title of the MB
			$(this.MBcaption).update(this.options.title);
		else { // If title isn't given, the header will not displayed
			$(this.MBheader).hide();
			$(this.MBcaption).hide();
		}
		
		if(this.MBwindow.style.display == "none") { // First modal box appearing
			this._appear();
			this.event("onShow"); // Passing onShow callback
		}
		else { // If MB already on the screen, update it
			this._update();
			this.event("onUpdate"); // Passing onUpdate callback
		} 
	},
	
	hide: function(options) { // External hide method to use from external HTML and JS
		if(this.initialized) {
			// Reading for options/callbacks except if event given as a pararmeter
			if(options && typeof options.element != 'function') Object.extend(this.options, options); 
			// Passing beforeHide callback
			this.event("beforeHide");
			if(this.options.transitions)
				Effect.SlideUp(this.MBwindow, { duration: this.options.slideUpDuration, transition: Effect.Transitions.sinoidal, afterFinish: this._deinit.bind(this) } );
			else {
				$(this.MBwindow).hide();
				this._deinit();
			}
		} else throw("Modalbox is not initialized.");
	},
	
	_hide: function(event) { // Internal hide method to use with overlay and close link
		event.stop(); // Stop event propaganation for link elements
		/* Then clicked on overlay we'll check the option and in case of overlayClose == false we'll break hiding execution [Fix for #139] */
		if(event.element().id == 'MB_overlay' && !this.options.overlayClose) return false;
		this.hide();
	},
	
	alert: function(message){
		var html = '<div class="MB_alert"><p>' + message + '</p><input type="button" onclick="Modalbox.hide()" value="OK" /></div>';
		Modalbox.show(html, {title: 'Alert: ' + document.title, width: 300});
	},
		
	_appear: function() { // First appearing of MB
		if(Prototype.Browser.IE && !navigator.appVersion.match(/\b7.0\b/)) { // Preparing IE 6 for showing modalbox
			window.scrollTo(0,0);
			this._prepareIE("100%", "hidden"); 
		}
		this._setWidth();
		this._setPosition();
		if(this.options.transitions) {
			$(this.MBoverlay).setStyle({opacity: 0});
			new Effect.Fade(this.MBoverlay, {
					from: 0, 
					to: this.options.overlayOpacity, 
					duration: this.options.overlayDuration, 
					afterFinish: function() {
						new Effect.SlideDown(this.MBwindow, {
							duration: this.options.slideDownDuration, 
							transition: Effect.Transitions.sinoidal, 
							afterFinish: function(){ 
								this._setPosition(); 
								this.loadContent();
							}.bind(this)
						});
					}.bind(this)
			});
		} else {
			$(this.MBoverlay).setStyle({opacity: this.options.overlayOpacity});
			$(this.MBwindow).show();
			this._setPosition(); 
			this.loadContent();
		}
		this._setWidthAndPosition = this._setWidthAndPosition.bindAsEventListener(this);
		Event.observe(window, "resize", this._setWidthAndPosition);
	},
	
	resize: function(byWidth, byHeight, options) { // Change size of MB without loading content
		var wHeight = $(this.MBwindow).getHeight();		
		var wWidth = $(this.MBwindow).getWidth();
		var hHeight = $(this.MBheader).getHeight();
		var cHeight = $(this.MBcontent).getHeight();
		var newHeight = ((wHeight - hHeight + byHeight) < cHeight) ? (cHeight + hHeight - wHeight) : byHeight;
		if(options) this.setOptions(options); // Passing callbacks
		if(this.options.transitions) {
			new Effect.ScaleBy(this.MBwindow, byWidth, newHeight, {
					duration: this.options.resizeDuration, 
				  	afterFinish: function() { 
						this.event("_afterResize"); // Passing internal callback
						this.event("afterResize"); // Passing callback
					}.bind(this)
				});
		} else {
			this.MBwindow.setStyle({width: wWidth + byWidth + "px", height: wHeight + newHeight + "px"});
			setTimeout(function() {
				this.event("_afterResize"); // Passing internal callback
				this.event("afterResize"); // Passing callback
			}.bind(this), 1);
			
		}
		
	},
	
	resizeToContent: function(options){
		
		// Resizes the modalbox window to the actual content height.
		// This might be useful to resize modalbox after some content modifications which were changed ccontent height.
		
		var byHeight = this.options.height - this.MBwindow.offsetHeight;
		if(byHeight != 0) {
			if(options) this.setOptions(options); // Passing callbacks
			Modalbox.resize(0, byHeight);
		}
	},
	
	resizeToInclude: function(element, options){
		
		// Resizes the modalbox window to the camulative height of element. Calculations are using CSS properties for margins and border.
		// This method might be useful to resize modalbox before including or updating content.
		
		var el = $(element);
		var elHeight = el.getHeight() + parseInt(el.getStyle('margin-top')) + parseInt(el.getStyle('margin-bottom')) + parseInt(el.getStyle('border-top-width')) + parseInt(el.getStyle('border-bottom-width'));
		if(elHeight > 0) {
			if(options) this.setOptions(options); // Passing callbacks
			Modalbox.resize(0, elHeight);
		}
	},
	
	_update: function() { // Updating MB in case of wizards
		$(this.MBcontent).update("");
		this.MBcontent.appendChild(this.MBloading);
		$(this.MBloading).update(this.options.loadingString);
		this.currentDims = [this.MBwindow.offsetWidth, this.MBwindow.offsetHeight];		
		Modalbox.resize((this.options.width - this.currentDims[0]), (this.options.height - this.currentDims[1]), {_afterResize: this._loadAfterResize.bind(this) });
	},
	
	loadContent: function () {
		if(this.event("beforeLoad") != false) { // If callback passed false, skip loading of the content
			if(typeof this.content == 'string') {
				var htmlRegExp = new RegExp(/<\/?[^>]+>/gi);
				if(htmlRegExp.test(this.content)) { // Plain HTML given as a parameter
					this._insertContent(this.content.stripScripts());
					this._putContent(function(){
						this.content.extractScripts().map(function(script) { 
							return eval(script.replace("<!--", "").replace("// -->", ""));
						}.bind(window));
					}.bind(this));
				} else // URL given as a parameter. We'll request it via Ajax
					new Ajax.Request( this.content, { method: this.options.method.toLowerCase(), parameters: this.options.params, 
						onSuccess: function(transport) {
							var response = new String(transport.responseText);
							this._insertContent(transport.responseText.stripScripts());
							this._putContent(function(){
								response.extractScripts().map(function(script) { 
									return eval(script.replace("<!--", "").replace("// -->", ""));
								}.bind(window));
							});
						}.bind(this),
						onException: function(instance, exception){
							Modalbox.hide();
							throw('Modalbox Loading Error: ' + exception);
						}
					});
					
			} else if (typeof this.content == 'object') {// HTML Object is given
				this._insertContent(this.content);
				this._putContent();
			} else {
				Modalbox.hide();
				throw('Modalbox Parameters Error: Please specify correct URL or HTML element (plain HTML or object)');
			}
		}
	},
	
	_insertContent: function(content){
		$(this.MBcontent).hide().update("");
		if(typeof content == 'string') {
			setTimeout(function() { // Hack to disable content flickering in Firefox
				this.MBcontent.update(content);
			}.bind(this), 1);
		} else if (typeof content == 'object') { // HTML Object is given
			var _htmlObj = content.cloneNode(true); // If node already a part of DOM we'll clone it
			// If clonable element has ID attribute defined, modifying it to prevent duplicates
			if(content.id) content.id = "MB_" + content.id;
			/* Add prefix for IDs on all elements inside the DOM node */
			$(content).select('*[id]').each(function(el){ el.id = "MB_" + el.id; });
			this.MBcontent.appendChild(_htmlObj);
			this.MBcontent.down().show(); // Toggle visibility for hidden nodes
			if(Prototype.Browser.IE) // Toggling back visibility for hidden selects in IE
				$$("#MB_content select").invoke('setStyle', {'visibility': ''});
		}
	},
	
	_putContent: function(callback){
		// Prepare and resize modal box for content
		if(this.options.height == this._options.height) {
			setTimeout(function() { // MSIE sometimes doesn't display content correctly
				Modalbox.resize(0, $(this.MBcontent).getHeight() - $(this.MBwindow).getHeight() + $(this.MBheader).getHeight(), {
					afterResize: function(){
						this.MBcontent.show().makePositioned();
						this.focusableElements = this._findFocusableElements();
						this._setFocus(); // Setting focus on first 'focusable' element in content (input, select, textarea, link or button)
						setTimeout(function(){ // MSIE fix
							if(callback != undefined)
								callback(); // Executing internal JS from loaded content
							this.event("afterLoad"); // Passing callback
						}.bind(this),1);
					}.bind(this)
				});
			}.bind(this), 1);
		} else { // Height is defined. Creating a scrollable window
			this._setWidth();
			this.MBcontent.setStyle({overflow: 'auto', height: $(this.MBwindow).getHeight() - $(this.MBheader).getHeight() - 13 + 'px'});
			this.MBcontent.show();
			this.focusableElements = this._findFocusableElements();
			this._setFocus(); // Setting focus on first 'focusable' element in content (input, select, textarea, link or button)
			setTimeout(function(){ // MSIE fix
				if(callback != undefined)
					callback(); // Executing internal JS from loaded content
				this.event("afterLoad"); // Passing callback
			}.bind(this),1);
		}
	},
	
	activate: function(options){
		this.setOptions(options);
		this.active = true;
		$(this.MBclose).observe("click", this.hideObserver);
		if(this.options.overlayClose)
			$(this.MBoverlay).observe("click", this.hideObserver);
		$(this.MBclose).show();
		if(this.options.transitions && this.options.inactiveFade)
			new Effect.Appear(this.MBwindow, {duration: this.options.slideUpDuration});
	},
	
	deactivate: function(options) {
		this.setOptions(options);
		this.active = false;
		$(this.MBclose).stopObserving("click", this.hideObserver);
		if(this.options.overlayClose)
			$(this.MBoverlay).stopObserving("click", this.hideObserver);
		$(this.MBclose).hide();
		if(this.options.transitions && this.options.inactiveFade)
			new Effect.Fade(this.MBwindow, {duration: this.options.slideUpDuration, to: .75});
	},
	
	_initObservers: function(){
		$(this.MBclose).observe("click", this.hideObserver);
		if(this.options.overlayClose)
			$(this.MBoverlay).observe("click", this.hideObserver);
		if(Prototype.Browser.IE)
			Event.observe(document, "keydown", this.kbdObserver);
		else
			Event.observe(document, "keypress", this.kbdObserver);
	},
	
	_removeObservers: function(){
		$(this.MBclose).stopObserving("click", this.hideObserver);
		if(this.options.overlayClose)
			$(this.MBoverlay).stopObserving("click", this.hideObserver);
		if(Prototype.Browser.IE)
			Event.stopObserving(document, "keydown", this.kbdObserver);
		else
			Event.stopObserving(document, "keypress", this.kbdObserver);
	},
	
	_loadAfterResize: function() {
		this._setWidth();
		this._setPosition();
		this.loadContent();
	},
	
	_setFocus: function() { 
		/* Setting focus to the first 'focusable' element which is one with tabindex = 1 or the first in the form loaded. */
		if(this.focusableElements.length > 0 && this.options.autoFocusing == true) {
			var firstEl = this.focusableElements.find(function (el){
				return el.tabIndex == 1;
			}) || this.focusableElements.first();
			this.currFocused = this.focusableElements.toArray().indexOf(firstEl);
			firstEl.focus(); // Focus on first focusable element except close button
		} else if($(this.MBclose).visible())
			$(this.MBclose).focus(); // If no focusable elements exist focus on close button
	},
	
	_findFocusableElements: function(){ // Collect form elements or links from MB content
		this.MBcontent.select('input:not([type~=hidden]), select, textarea, button, a[href]').invoke('addClassName', 'MB_focusable');
		return this.MBcontent.select('.MB_focusable');
	},
	
	_kbdHandler: function(event) {
		var node = event.element();
		switch(event.keyCode) {
			case Event.KEY_TAB:
				event.stop();
				
				/* Switching currFocused to the element which was focused by mouse instead of TAB-key. Fix for #134 */ 
				if(node != this.focusableElements[this.currFocused])
					this.currFocused = this.focusableElements.toArray().indexOf(node);
				
				if(!event.shiftKey) { //Focusing in direct order
					if(this.currFocused == this.focusableElements.length - 1) {
						this.focusableElements.first().focus();
						this.currFocused = 0;
					} else {
						this.currFocused++;
						this.focusableElements[this.currFocused].focus();
					}
				} else { // Shift key is pressed. Focusing in reverse order
					if(this.currFocused == 0) {
						this.focusableElements.last().focus();
						this.currFocused = this.focusableElements.length - 1;
					} else {
						this.currFocused--;
						this.focusableElements[this.currFocused].focus();
					}
				}
				break;			
			case Event.KEY_ESC:
				if(this.active) this._hide(event);
				break;
			case 32:
				this._preventScroll(event);
				break;
			case 0: // For Gecko browsers compatibility
				if(event.which == 32) this._preventScroll(event);
				break;
			case Event.KEY_UP:
			case Event.KEY_DOWN:
			case Event.KEY_PAGEDOWN:
			case Event.KEY_PAGEUP:
			case Event.KEY_HOME:
			case Event.KEY_END:
				// Safari operates in slightly different way. This realization is still buggy in Safari.
				if(Prototype.Browser.WebKit && !["textarea", "select"].include(node.tagName.toLowerCase()))
					event.stop();
				else if( (node.tagName.toLowerCase() == "input" && ["submit", "button"].include(node.type)) || (node.tagName.toLowerCase() == "a") )
					event.stop();
				break;
		}
	},
	
	_preventScroll: function(event) { // Disabling scrolling by "space" key
		if(!["input", "textarea", "select", "button"].include(event.element().tagName.toLowerCase())) 
			event.stop();
	},
	
	_deinit: function()
	{	
		this._removeObservers();
		Event.stopObserving(window, "resize", this._setWidthAndPosition );
		if(this.options.transitions) {
			Effect.toggle(this.MBoverlay, 'appear', {duration: this.options.overlayDuration, afterFinish: this._removeElements.bind(this) });
		} else {
			this.MBoverlay.hide();
			this._removeElements();
		}
		$(this.MBcontent).setStyle({overflow: '', height: ''});
	},
	
	_removeElements: function () {
		$(this.MBoverlay).remove();
		$(this.MBwindow).remove();
		if(Prototype.Browser.IE && !navigator.appVersion.match(/\b7.0\b/)) {
			this._prepareIE("", ""); // If set to auto MSIE will show horizontal scrolling
			window.scrollTo(this.initScrollX, this.initScrollY);
		}
		
		/* Replacing prefixes 'MB_' in IDs for the original content */
		if(typeof this.content == 'object') {
			if(this.content.id && this.content.id.match(/MB_/)) {
				this.content.id = this.content.id.replace(/MB_/, "");
			}
			this.content.select('*[id]').each(function(el){ el.id = el.id.replace(/MB_/, ""); });
		}
		/* Initialized will be set to false */
		this.initialized = false;
		this.event("afterHide"); // Passing afterHide callback
		this.setOptions(this._options); //Settings options object into intial state
	},
	
	_setWidth: function () { //Set size
		$(this.MBwindow).setStyle({width: this.options.width + "px", height: this.options.height + "px"});
	},
	
	_setPosition: function () {
		$(this.MBwindow).setStyle({left: Math.round((Element.getWidth(document.body) - Element.getWidth(this.MBwindow)) / 2 ) + "px"});
	},
	
	_setWidthAndPosition: function () {
		$(this.MBwindow).setStyle({width: this.options.width + "px"});
		this._setPosition();
	},
	
	_getScrollTop: function () { //From: http://www.quirksmode.org/js/doctypes.html
		var theTop;
		if (document.documentElement && document.documentElement.scrollTop)
			theTop = document.documentElement.scrollTop;
		else if (document.body)
			theTop = document.body.scrollTop;
		return theTop;
	},
	_prepareIE: function(height, overflow){
		$$('html, body').invoke('setStyle', {width: height, height: height, overflow: overflow}); // IE requires width and height set to 100% and overflow hidden
		$$("select").invoke('setStyle', {'visibility': overflow}); // Toggle visibility for all selects in the common document
	},
	event: function(eventName) {
		if(this.options[eventName]) {
			var returnValue = this.options[eventName](); // Executing callback
			this.options[eventName] = null; // Removing callback after execution
			if(returnValue != undefined) 
				return returnValue;
			else 
				return true;
		}
		return true;
	}
};

Object.extend(Modalbox, Modalbox.Methods);

if(Modalbox.overrideAlert) window.alert = Modalbox.alert;

Effect.ScaleBy = Class.create();
Object.extend(Object.extend(Effect.ScaleBy.prototype, Effect.Base.prototype), {
  initialize: function(element, byWidth, byHeight, options) {
    this.element = $(element)
    var options = Object.extend({
	  scaleFromTop: true,
      scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
      scaleByWidth: byWidth,
	  scaleByHeight: byHeight
    }, arguments[3] || {});
    this.start(options);	
  },
  setup: function() {
    this.elementPositioning = this.element.getStyle('position');
      
    this.originalTop  = this.element.offsetTop;
    this.originalLeft = this.element.offsetLeft;
	
    this.dims = null;
    if(this.options.scaleMode=='box')
      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
	 if(/^content/.test(this.options.scaleMode))
      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
    if(!this.dims)
      this.dims = [this.options.scaleMode.originalHeight,
                   this.options.scaleMode.originalWidth];
	  
	this.deltaY = this.options.scaleByHeight;
	this.deltaX = this.options.scaleByWidth;
  },
  update: function(position) {
    var currentHeight = this.dims[0] + (this.deltaY * position);
	var currentWidth = this.dims[1] + (this.deltaX * position);
	
	currentHeight = (currentHeight > 0) ? currentHeight : 0;
	currentWidth = (currentWidth > 0) ? currentWidth : 0;
	
    this.setDimensions(currentHeight, currentWidth);
  },

  setDimensions: function(height, width) {
    var d = {};
    d.width = width + 'px';
    d.height = height + 'px';	
    
	var topd  = Math.round((height - this.dims[0])/2);
	var leftd = Math.round((width  - this.dims[1])/2);
	if(this.elementPositioning == 'absolute' || this.elementPositioning == 'fixed') {
		if(!this.options.scaleFromTop) d.top = this.originalTop-topd + 'px';
		d.left = this.originalLeft-leftd + 'px';
	} else {
		if(!this.options.scaleFromTop) d.top = -topd + 'px';
		d.left = -leftd + 'px';
	}
    this.element.setStyle(d);
  }
});







var Menu = Class.create();
Menu.prototype = {

	initialize: function(idOrElement, name, customConfigFunction) {

		this.name = name;
		this.type = "comm_menu";
		this.closeDelayTimer = null;
		this.closingMenuItem = null;

		this.config();
		if (typeof customConfigFunction == "function") {
			this.customConfig = customConfigFunction;
			this.customConfig();
		}
		this.rootContainer = new MenuContainer(idOrElement, this);
	},

	config: function() {
	  this.collapseBorders = true;
	  this.quickCollapse = true;
	  this.closeDelayTime = 500;
	}

}

var MenuContainer = Class.create();
MenuContainer.prototype = {
	initialize: function(idOrElement, parent) {
		this.type = "menuContainer";
  		this.menuItems = [];
		this.init(idOrElement, parent);
	},

	init: function(idOrElement, parent) {
	  this.element = $(idOrElement);
	  this.parent = parent;
	  this.parentMenu = (this.type == "menuContainer") ? ((parent) ? parent.parent : null) : parent;
	  this.root = parent instanceof Menu ? parent : parent.root;
	  this.id = this.element.id;

	  if (this.type == "menuContainer") {
	  	if (this.element.hasClassName("level1")) this.menuType = "horizontal";
		else if (this.element.hasClassName("level2")) this.menuType = "dropdown";
		else this.menuType = "flyout";

	    if (this.menuType == "flyout" || this.menuType == "dropdown") {
	      this.isOpen = false;
		  Element.setStyle(this.element,{
	      	position: "absolute",
	      	top: "0px",
	      	left: "0px",
	      	visibility: "hidden"});
	    } else {
	      this.isOpen = true;
	    }
	  } else {
	    this.isOpen = this.parentMenu.isOpen;
	  }

	  var childNodes = this.element.childNodes;
	  if (childNodes == null) return;

	  for (var i = 0; i < childNodes.length; i++) {
	    var node = childNodes[i];
	    if (node.nodeType == 1) {
	      if (this.type == "menuContainer") {
	        if (node.tagName.toLowerCase() == "li") {
	          this.menuItems.push(new MenuItem(node, this));
	        }
	      } else {
	        if (node.tagName.toLowerCase() == "ul") {
	          this.subMenu = new MenuContainer(node, this);
	        }
	      }
	    }
	  }
	},

	getBorders: function(element) {
	  var ltrb = ["Left","Top","Right","Bottom"];
	  var result = {};
	  for (var i = 0; i < ltrb.length; ++i) {
	    if (this.element.currentStyle)
	      var value = parseInt(this.element.currentStyle["border"+ltrb[i]+"Width"]);
	    else if (window.getComputedStyle)
	      var value = parseInt(window.getComputedStyle(this.element, "").getPropertyValue("border-"+ltrb[i].toLowerCase()+"-width"));
	    else
	      var value = parseInt(this.element.style["border"+ltrb[i]]);
	    result[ltrb[i].toLowerCase()] = isNaN(value) ? 0 : value;
	  }
	  return result;
	},

	open: function() {
	  if (this.root.closeDelayTimer) window.clearTimeout(this.root.closeDelayTimer);
	  this.parentMenu.closeAll(this);
	  this.isOpen = true;
	  if (this.menuType == "dropdown") {
		Element.setStyle(this.element,{
			left: (Position.positionedOffset(this.parent.element)[0]) + "px",
			top: (Position.positionedOffset(this.parent.element)[1] + Element.getHeight(this.parent.element)) + "px"
		});

	  } else if (this.menuType == "flyout") {
	    var parentMenuBorders = this.parentMenu ? this.parentMenu.getBorders() : new Object();
	    var thisBorders = this.getBorders();
	    if (
	      (Position.positionedOffset(this.parentMenu.element)[0] + this.parentMenu.element.offsetWidth + this.element.offsetWidth + 20) >
	      (window.innerWidth ? window.innerWidth : document.body.offsetWidth)
	    ) {
			Element.setStyle(this.element,{
	      		left: (- this.element.offsetWidth - (this.root.collapseBorders ?  0 : parentMenuBorders["left"])) + "px"
			});
	    } else {
			Element.setStyle(this.element,{
	    		left: (this.parentMenu.element.offsetWidth - parentMenuBorders["left"] - (this.root.collapseBorders ?  Math.min(parentMenuBorders["right"], thisBorders["left"]) : 0)) + "px"
			});
	    }
		Element.setStyle(this.element,{
	    	top: (this.parent.element.offsetTop - parentMenuBorders["top"] - this.menuItems[0].element.offsetTop) + "px"
		});
	  }
	  Element.setStyle(this.element,{visibility: "visible"});
	},

	close: function() {
		Element.setStyle(this.element,{visibility: "hidden"});
		this.isOpen = false;
		this.closeAll();
	},

	closeAll: function(trigger) {
		for (var i = 0; i < this.menuItems.length; ++i) {
			this.menuItems[i].closeItem(trigger);
		}
	}

}


var MenuItem = Class.create();

Object.extend(Object.extend(MenuItem.prototype, MenuContainer.prototype), {
	initialize: function(idOrElement, parent) {
		var menuItem = this;
		this.type = "menuItem";
		this.subMenu;
		this.init(idOrElement, parent);
		if (this.subMenu) {
			this.element.onmouseover = function() {
				menuItem.subMenu.open();
			}
		} else {
		if (this.root.quickCollapse) {
		  this.element.onmouseover = function() {
			menuItem.parentMenu.closeAll();
		  }
		}
		  }
		  var linkTag = this.element.getElementsByTagName("A")[0];
		  if (linkTag) {
		 linkTag.onfocus = this.element.onmouseover;
		 this.link = linkTag;
		 this.text = linkTag.text;
		  }
		  if (this.subMenu) {
		this.element.onmouseout = function() {
		  if (menuItem.root.openDelayTimer) window.clearTimeout(menuItem.root.openDelayTimer);
		  if (menuItem.root.closeDelayTimer) window.clearTimeout(menuItem.root.closeDelayTimer);
		  eval(menuItem.root.name + ".closingMenuItem = menuItem");
		  menuItem.root.closeDelayTimer = window.setTimeout(menuItem.root.name + ".closingMenuItem.subMenu.close()", menuItem.root.closeDelayTime);
		}
		  }
	},

	openItem: function() {
	  this.isOpen = true;
	  if (this.subMenu) { this.subMenu.open(); }
	},

	closeItem: function(trigger) {
	  this.isOpen = false;
	  if (this.subMenu) {
	    if (this.subMenu != trigger) this.subMenu.close();
	  }
	}
});


var menu;


function configMenu() {
  this.closeDelayTime = 300;
}

function initMenu() {
  menu = new Menu('root', 'menu', configMenu);
}


Event.observe(window, 'load', initMenu, false);





var Lightview = {
  Version: '2.2.9.1',

  // Configuration
  options: {
    backgroundColor: '#ffffff',                            // Background color of the view
    border: 12,                                            // Size of the border
    buttons: {
      opacity: {                                           // Opacity of inner buttons
        disabled: 0.4,
        normal: 0.75,
        hover: 1
      },
      side: { display: true },                             // show side buttons
      innerPreviousNext: { display: true },                // show the inner previous and next button
      slideshow: { display: true }                         // show slideshow button
    },
    cyclic: false,                                         // Makes galleries cyclic, no end/begin.
    images: '../scripts/lightbox/images/',                        // The directory of the images, relative to this file or an absolute url
    imgNumberTemplate: 'Image #{position} of #{total}',    // Want a different language? change it here
    keyboard: { enabled: true },                           // Enabled the keyboard buttons
    overlay: {                                             // Overlay
      background: '#000',                                  // Background color, Mac Firefox & Safari use overlay.png
      close: true,                                         // Overlay click closes the view
      opacity: 0.80,
      display: true
    },
    preloadHover: true,                                    // Preload images on mouseover
    radius: 12,                                            // Corner radius of the border
    removeTitles: true,                                    // Set to false if you want to keep title attributes intact
    resizeDuration: 0.9,                                   // When effects are used, the duration of resizing in seconds
    slideshowDelay: 4,                                     // Seconds to wait before showing the next slide in slideshow
    titleSplit: '::',                                      // The characters you want to split title with
    transition: function(pos) {                            // Or your own transition
      return ((pos/=0.5) < 1 ? 0.5 * Math.pow(pos, 4) :
        -0.5 * ((pos-=2) * Math.pow(pos,3) - 2));
    },
    viewport: true,                                        // Stay within the viewport, true is recommended
    zIndex: 5000,                                          // zIndex of #lightview, #overlay is this -1

    // Optional
    closeDimensions: {                                     // If you've changed the close button you can change these
      large: { width: 85, height: 22 },                    // not required but it speeds things up.
      small: { width: 32, height: 22 },
      innertop: { width: 22, height: 22 },
      topclose: { width: 22, height: 18 }                  // when topclose option is used
    },
    defaultOptions : {                                     // Default open dimensions for each type
      ajax:   { width: 400, height: 300 },
      iframe: { width: 400, height: 300, scrolling: true },
      inline: { width: 400, height: 300 },
      flash:  { width: 400, height: 300 },
      quicktime: { width: 480, height: 220, autoplay: true, controls: true, topclose: true }
    },
    sideDimensions: { width: 16, height: 22 }              // see closeDimensions
  },

  classids: {
    quicktime: 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
    flash: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
  },
  codebases: {
    quicktime: 'http://www.apple.com/qtactivex/qtplugin.cab#version=7,3,0,0',
    flash: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0'
  },
  errors: {
    requiresPlugin: "<div class='message'>The content your are attempting to view requires the <span class='type'>#{type}</span> plugin.</div><div class='pluginspage'><p>Please download and install the required plugin from:</p><a href='#{pluginspage}' target='_blank'>#{pluginspage}</a></div>"
  },
  mimetypes: {
    quicktime: 'video/quicktime',
    flash: 'application/x-shockwave-flash'
  },
  pluginspages: {
    quicktime: 'http://www.apple.com/quicktime/download',
    flash: 'http://www.adobe.com/go/getflashplayer'
  },
  // used with auto detection
  typeExtensions: {
    flash: 'swf',
    image: 'bmp gif jpeg jpg png',
    iframe: 'asp aspx cgi cfm htm html jsp php pl php3 php4 php5 phtml rb rhtml shtml txt',
    quicktime: 'avi mov mpg mpeg movie'
  }
};

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}('1d.4o=(h(B){q A=m 4X("8L ([\\\\d.]+)").81(B);S A?7B(A[1]):-1})(2X.4L);10.1h(W.13,{2u:W.13.2s&&(1d.4o>=6&&1d.4o<7),2x:(W.13.3r&&!1g.4c)});10.1h(1d,{7h:"1.6.0.2",9Y:"1.8.1",X:{1j:"4O",3f:"12"},6f:!!2X.4L.3M(/6d/i),4A:!!2X.4L.3M(/6d/i)&&(W.13.3r||W.13.2q),4x:h(A){f((80 2f[A]=="7Q")||(9.4j(2f[A].7H)<9.4j(9["5C"+A]))){7C("1d 7A "+A+" >= "+9["5C"+A]);}},4j:h(A){q B=A.2D(/5s.*|\\./g,"");B=49(B+"0".7c(4-B.1X));S A.1Z("5s")>-1?B-1:B},6W:h(){9.4x("W");f(!!2f.11&&!2f.6Q){9.4x("6Q")}f(9.k.1f.6D("://")){9.1f=9.k.1f}Z{q A=/12(?:-[\\w\\d.]+)?\\.9j(.*)/;9.1f=(($$("9d 96[1x]").6m(h(B){S B.1x.3M(A)})||{}).1x||"").2D(A,"")+9.k.1f}f(W.13.2s&&!1g.6k.v){1g.6k.6g("v","8H:8F-8C-8B:8x");1g.19("4C:4z",h(){1g.8n().8k("v\\\\:*","8i: 38(#63#8a);")})}},4u:h(){9.2K=9.k.2K;9.1c=(9.2K>9.k.1c)?9.2K:9.k.1c;9.1z=9.k.1z;9.1D=9.k.1D;9.5R();9.5Q();9.5O()},5R:h(){q B,I,D=9.1V(9.1D);$(1g.40).z(9.1F=m y("Y",{2A:"1F"}).r({3q:9.k.3q-1,1j:(!(W.13.2q||W.13.2u))?"4d":"3p",2C:9.4A?"38("+9.1f+"1F.1G) 1k 1o 2V":9.k.1F.2C}).1w((W.13.2q)?1:9.k.1F.1C).15()).z(9.12=m y("Y",{2A:"12"}).r({3q:9.k.3q,1k:"-3n",1o:"-3n"}).1w(0).z(9.5m=m y("Y",{V:"75"}).z(9.44=m y("3m",{V:"a3"}).z(9.6U=m y("1M",{V:"9V"}).r(I=10.1h({1v:-1*9.1D.o+"u"},D)).z(9.3W=m y("Y",{V:"58"}).r(10.1h({1v:9.1D.o+"u"},D)).z(m y("Y",{V:"24"})))).z(9.6E=m y("1M",{V:"9v"}).r(10.1h({6A:-1*9.1D.o+"u"},D)).z(9.3U=m y("Y",{V:"58"}).r(I).z(m y("Y",{V:"24"}))))).z(9.4V=m y("Y",{V:"9n"}).z(9.4W=m y("Y",{V:"58 9g"}).z(9.4S=m y("Y",{V:"24"})))).z(m y("3m",{V:"99"}).z(m y("1M",{V:"6O 92"}).z(B=m y("Y",{V:"8Z"}).r({n:9.1c+"u"}).z(m y("3m",{V:"6n 8Q"}).z(m y("1M",{V:"6l"}).z(m y("Y",{V:"3R"})).z(m y("Y",{V:"30"}).r({1o:9.1c+"u"})))).z(m y("Y",{V:"6i"})).z(m y("3m",{V:"6n 8K"}).z(m y("1M",{V:"6l"}).r("3d-1k: "+(-1*9.1c)+"u").z(m y("Y",{V:"3R"})).z(m y("Y",{V:"30"}).r("1o: "+(-1*9.1c)+"u")))))).z(9.3P=m y("1M",{V:"8G"}).r("n: "+(8E-9.1c)+"u").z(m y("Y",{V:"8D"}).z(m y("Y",{V:"6e"}).r("3d-1k: "+9.1c+"u").z(9.2r=m y("Y",{V:"8A"}).1w(0).r("3H: 0 "+9.1c+"u").z(9.29=m y("Y",{V:"8v 30"})).z(9.1U=m y("Y",{V:"8s"}).z(9.2H=m y("Y",{V:"24 8p"}).r(9.1V(9.k.1z.3F)).r({2C:9.k.17}).1w(9.k.1H.1C.2t)).z(9.3D=m y("3m",{V:"8j"}).z(9.4y=m y("1M",{V:"8h"}).z(9.1u=m y("Y",{V:"8f"})).z(9.1Q=m y("Y",{V:"8d"}))).z(9.3z=m y("1M",{V:"87"}).z(m y("Y"))).z(9.4v=m y("1M",{V:"84"}).z(9.7Z=m y("Y",{V:"24"}).1w(9.k.1H.1C.2t).r({17:9.k.17}).2c(9.1f+"7X.1G",{17:9.k.17})).z(9.7W=m y("Y",{V:"24"}).1w(9.k.1H.1C.2t).r({17:9.k.17}).2c(9.1f+"7V.1G",{17:9.k.17}))).z(9.2m=m y("1M",{V:"7T"}).z(9.2w=m y("Y",{V:"24"}).1w(9.k.1H.1C.2t).r({17:9.k.17}).2c(9.1f+"53.1G",{17:9.k.17}))))).z(9.1L=m y("Y",{V:"7N"}))))).z(9.2S=m y("Y",{V:"7L"}).z(9.5L=m y("Y",{V:"24"}).r("2C: 38("+9.1f+"2S.4k) 1k 1o 3Z-2V")))).z(m y("1M",{V:"6O 7J"}).z(B.7I(1T))).z(9.1J=m y("1M",{V:"7G"}).15().r("3d-1k: "+9.1c+"u; 2C: 38("+9.1f+"7F.4k) 1k 1o 2V"))))).z(m y("Y",{2A:"34"}).15());q H=m 2h();H.1r=h(){H.1r=W.26;9.1D={o:H.o,n:H.n};q K=9.1V(9.1D),C;9.44.r({1O:0-(H.n/2).2j()+"u",n:H.n+"u"});9.6U.r(C=10.1h({1v:-1*9.1D.o+"u"},K));9.3W.r(10.1h({1v:K.o},K));9.6E.r(10.1h({6A:-1*9.1D.o+"u"},K));9.3U.r(C)}.U(9);H.1x=9.1f+"2e.1G";$w("2r 1u 1Q 3z").1b(h(C){9[C].r({17:9.k.17})}.U(9));q G=9.5m.32(".3R");$w("7u 7s 7q 5u").1b(h(K,C){f(9.2K>0){9.5t(G[C],K)}Z{G[C].z(m y("Y",{V:"30"}))}G[C].r({o:9.1c+"u",n:9.1c+"u"}).7m("3R"+K.21())}.U(9));9.12.32(".6i",".30",".6e").3o("r",{17:9.k.17});q E={};$w("2e 1e 2k").1b(h(K){9[K+"2T"].3i=K;q C=9.1f+K+".1G";f(K=="2k"){E[K]=m 2h();E[K].1r=h(){E[K].1r=W.26;9.1z[K]={o:E[K].o,n:E[K].n};q L=9.6f?"1o":"7f",M=10.1h({"7b":L,1O:9.1z[K].n+"u"},9.1V(9.1z[K]));M["3H"+L.21()]=9.1c+"u";9[K+"2T"].r(M);9.4V.r({n:E[K].n+"u",1k:-1*9.1z[K].n+"u"});9[K+"2T"].5W().2c(C).r(9.1V(9.1z[K]))}.U(9);E[K].1x=9.1f+K+".1G"}Z{9[K+"2T"].2c(C)}}.U(9));q A={};$w("3F 48 4F").1b(h(C){A[C]=m 2h();A[C].1r=h(){A[C].1r=W.26;9.1z[C]={o:A[C].o,n:A[C].n}}.U(9);A[C].1x=9.1f+"5n"+C+".1G"}.U(9));q J=m 2h();J.1r=h(){J.1r=W.26;9.2S.r({o:J.o+"u",n:J.n+"u",1O:-0.5*J.n+0.5*9.1c+"u",1v:-0.5*J.o+"u"})}.U(9);J.1x=9.1f+"2S.4k";q F=m 2h();F.1r=h(){F.1r=W.26;q C={o:F.o+"u",n:F.n+"u"};9.2m.r(C);9.2w.r(C)}.U(9);F.1x=9.1f+"53.1G";$w("2e 1e").1b(h(L){q K=L.21(),C=m 2h();C.1r=h(){C.1r=W.26;9["2y"+K+"2P"].r({o:C.o+"u",n:C.n+"u"})}.U(9);C.1x=9.1f+"74"+L+".1G";9["2y"+K+"2P"].1J=L}.U(9))},68:h(){11.2R.2W("12").1b(h(A){A.6Z()});9.1t=1p;9.5f();9.1i=1p},5f:h(){f(!9.3c||!9.3k){S}9.3k.z({9W:9.3c.r({1N:9.3c.6T})});9.3k.23();9.3k=1p},18:h(B){9.1q=1p;f(10.6P(B)||10.6N(B)){9.1q=$(B);f(!9.1q){S}9.1q.9F();9.j=9.1q.1S}Z{f(B.1a){9.1q=$(1g.40);9.j=m 1d.4N(B)}Z{f(10.6H(B)){9.1q=9.4P(9.j.1n).54[B];9.j=9.1q.1S}}}f(!9.j.1a){S}9.68();9.4Q();9.6B();9.6y();9.3g();9.6v();f(9.j.1a!="#34"&&10.6u(1d.4Z).6s(" ").1Z(9.j.14)>=0){f(!1d.4Z[9.j.14]){$("34").1B(m 6r(9.9i.9f).4c({14:9.j.14.21(),52:9.4T[9.j.14]}));q C=$("34").2U();9.18({1a:"#34",1u:9.j.14.21()+" 98 97",k:C});S 2n}}f(9.j.1y()){9.1i=9.j.1y()?9.59(9.j.1n):[9.j]}q A=10.1h({1U:1T,2k:2n,5a:"8Y",5c:9.j.1y()&&9.k.1H.5c.1N,2m:9.j.1y()&&9.k.1H.2m.1N},9.k.8V[9.j.14]||{});9.j.k=10.1h(A,9.j.k);f(!(9.j.1u||9.j.1Q||(9.1i&&9.1i.1X>1))&&9.j.k.2k){9.j.k.1U=2n}f(9.j.2L()){f(9.j.1y()){9.1j=9.1i.1Z(9.j);9.6R()}9.1A=9.j.3X;f(9.1A){9.3Y()}Z{9.4K();q D=m 2h();D.1r=h(){D.1r=W.26;9.43();9.1A={o:D.o,n:D.n};9.3Y()}.U(9);D.1x=9.j.1a}}Z{9.1A=9.j.k.4J?1g.2J.2U():{o:9.j.k.o,n:9.j.k.n};9.3Y()}},4I:h(){q D=9.6j(9.j.1a),A=9.1t||9.1A;f(9.j.2L()){q B=9.1V(A);9.29.r(B).1B(m y("6h",{2A:"2b",1x:9.j.1a,8J:"",8I:"3Z"}).r(B))}Z{f(9.j.3Q()){f(9.1t&&9.j.k.4J){A.n-=9.2Y.n}3O(9.j.14){2i"31":q F=10.3N(9.j.k.31)||{};q E=h(){9.43();f(9.j.k.4E){9.1L.r({o:"3L",n:"3L"});9.1A=9.3K(9.1L)}m 11.1m({X:9.X,1s:9.3J.U(9)})}.U(9);f(F.3I){F.3I=F.3I.1P(h(N,M){E();N(M)})}Z{F.3I=E}9.4K();m 8z.8y(9.1L,9.j.1a,F);2a;2i"22":9.1L.1B(9.22=m y("22",{8w:0,8u:0,1x:9.j.1a,2A:"2b",1R:"8t"+(6b.8r()*8q).2j(),6a:(9.j.k&&9.j.k.6a)?"3L":"3Z"}).r(10.1h({1c:0,3d:0,3H:0},9.1V(A))));2a;2i"3G":q C=9.j.1a,H=$(C.69(C.1Z("#")+1));f(!H||!H.4B){S}q L=m y(9.j.k.8o||"Y"),G=H.1K("1I"),J=H.1K("1N");H.1P(L);H.r({1I:"3E"}).18();q I=9.3K(L);H.r({1I:G,1N:J});L.z({67:H}).23();H.z({67:9.3k=m y(H.4B)});H.6T=H.1K("1N");9.3c=H.18();9.1L.1B(9.3c);8m.8l(9.j.k);9.1L.32("32, 3a, 66").1b(h(M){9.3C.1b(h(N){f(N.1q==M){M.r({1I:N.1I})}})}.U(9));f(9.j.k.4E){9.1A=I;m 11.1m({X:9.X,1s:9.3J.U(9)})}2a}}Z{q K={1E:"3a",2A:"2b",o:A.o,n:A.n};3O(9.j.14){2i"2N":10.1h(K,{52:9.4T[9.j.14],2M:[{1E:"1Y",1R:"65",28:9.j.k.65},{1E:"1Y",1R:"64",28:"8g"},{1E:"1Y",1R:"4w",28:9.j.k.4H},{1E:"1Y",1R:"8e",28:1T},{1E:"1Y",1R:"1x",28:9.j.1a},{1E:"1Y",1R:"62",28:9.j.k.62||2n}]});10.1h(K,W.13.2s?{8c:9.8b[9.j.14],89:9.88[9.j.14]}:{3D:9.j.1a,14:9.60[9.j.14]});2a;2i"36":10.1h(K,{3D:9.j.1a,14:9.60[9.j.14],86:"85",5a:9.j.k.5a,52:9.4T[9.j.14],2M:[{1E:"1Y",1R:"83",28:9.j.1a},{1E:"1Y",1R:"82",28:"1T"}]});f(9.j.k.5Z){K.2M.2Q({1E:"1Y",1R:"7Y",28:9.j.k.5Z})}2a}9.29.r(9.1V(A)).18();9.29.1B(9.4r(K));f(9.j.4p()&&$("2b")){(h(){3T{f("5Y"5X $("2b")){$("2b").5Y(9.j.k.4H)}}3y(M){}}.U(9)).2I(0.4)}}}},3K:h(B){B=$(B);q A=B.7U(),C=[],E=[];A.2Q(B);A.1b(h(F){f(F!=B&&F.3x()){S}C.2Q(F);E.2Q({1N:F.1K("1N"),1j:F.1K("1j"),1I:F.1K("1I")});F.r({1N:"5U",1j:"3p",1I:"3x"})});q D={o:B.7S,n:B.7R};C.1b(h(G,F){G.r(E[F])});S D},55:h(){q A=$("2b");f(A){3O(A.4B.4m()){2i"3a":f(W.13.3r&&9.j.4p()){3T{A.5S()}3y(B){}A.7P=""}f(A.7O){A.23()}Z{A=W.26}2a;2i"22":A.23();f(W.13.2q){4l 2f.7M.2b}2a;63:A.23();2a}}},5P:h(){q A=9.1t||9.1A;f(9.j.k.4H){3O(9.j.14){2i"2N":A.n+=16;2a}}9[(9.1t?"5N":"i")+"5M"]=A},3Y:h(){m 11.1m({X:9.X,1s:h(){9.3V()}.U(9)})},3V:h(){9.3j();f(!9.j.5K()){9.43()}f(!((9.j.k.4E&&9.j.7K())||9.j.5K())){9.3J()}f(!9.j.42()){m 11.1m({X:9.X,1s:9.4I.U(9)})}},5J:h(){m 11.1m({X:9.X,1s:9.5I.U(9)});f(9.j.42()){m 11.1m({2I:0.2,X:9.X,1s:9.4I.U(9)})}f(9.2G){m 11.1m({X:9.X,1s:9.5H.U(9)})}},2p:h(){9.18(9.2l().2p)},1e:h(){9.18(9.2l().1e)},3J:h(){9.5P();q B=9.4i(),D=9.5G();f(9.k.2J&&(B.o>D.o||B.n>D.n)){f(!9.j.k.4J){q E=10.3N(9.5F()),A=D,C=10.3N(E);f(C.o>A.o){C.n*=A.o/C.o;C.o=A.o;f(C.n>A.n){C.o*=A.n/C.n;C.n=A.n}}Z{f(C.n>A.n){C.o*=A.n/C.n;C.n=A.n;f(C.o>A.o){C.n*=A.o/C.o;C.o=A.o}}}q F=(C.o%1>0?C.n/E.n:C.n%1>0?C.o/E.o:1);9.1t={o:(9.1A.o*F).2j(),n:(9.1A.n*F).2j()};9.3j();B={o:9.1t.o,n:9.1t.n+9.2Y.n}}Z{9.1t=D;9.3j();B=D}}Z{9.3j();9.1t=1p}9.3w(B)},3w:h(B){q F=9.12.2U(),I=2*9.1c,D=B.o+I,M=B.n+I;9.4h();q L=h(){9.3g();9.4g=1p;9.5J()};f(F.o==D&&F.n==M){L.U(9)();S}q C={o:D+"u",n:M+"u"};f(!W.13.2u){10.1h(C,{1v:0-D/2+"u",1O:0-M/2+"u"})}q G=D-F.o,K=M-F.n,J=49(9.12.1K("1v").2D("u","")),E=49(9.12.1K("1O").2D("u",""));f(!W.13.2u){q A=(0-D/2)-J,H=(0-M/2)-E}9.4g=m 11.7E(9.12,0,1,{1W:9.k.7D,X:9.X,5E:9.k.5E,1s:L.U(9)},h(Q){q N=(F.o+Q*G).33(0),P=(F.n+Q*K).33(0);f(W.13.2u){9.12.r({o:(F.o+Q*G).33(0)+"u",n:(F.n+Q*K).33(0)+"u"});9.3P.r({n:P-1*9.1c+"u"})}Z{f(W.13.2s){9.12.r({1j:"4d",o:N+"u",n:P+"u",1v:((0-N)/2).2j()+"u",1O:((0-P)/2).2j()+"u"});9.3P.r({n:P-1*9.1c+"u"})}Z{q O=9.3v(),R=1g.2J.5B();9.12.r({1j:"3p",1v:0,1O:0,o:N+"u",n:P+"u",1o:(R[0]+(O.o/2)-(N/2)).2Z()+"u",1k:(R[1]+(O.n/2)-(P/2)).2Z()+"u"});9.3P.r({n:P-1*9.1c+"u"})}}}.U(9))},5I:h(){m 11.1m({X:9.X,1s:y.18.U(9,9[9.j.3u()?"29":"1L"])});m 11.1m({X:9.X,1s:9.4h.U(9)});m 11.5A([m 11.3t(9.2r,{3s:1T,2B:0,2z:1}),m 11.4f(9.44,{3s:1T})],{X:9.X,1W:0.45,1s:h(){f(9.1q){9.1q.5z("12:7z")}}.U(9)});f(9.j.1y()){m 11.1m({X:9.X,1s:9.5x.U(9)})}},6y:h(){f(!9.12.3x()){S}m 11.5A([m 11.3t(9.44,{3s:1T,2B:1,2z:0}),m 11.3t(9.2r,{3s:1T,2B:1,2z:0})],{X:9.X,1W:0.35});m 11.1m({X:9.X,1s:h(){9.55();9.29.1B("").15();9.1L.1B("").15();9.4W.r({1O:9.1z.2k.n+"u"})}.U(9)})},5w:h(){9.4y.15();9.1u.15();9.1Q.15();9.3z.15();9.4v.15();9.2m.15()},3j:h(){9.5w();f(!9.j.k.1U){9.2Y={o:0,n:0};9.4e=0;9.1U.15();S 2n}Z{9.1U.18()}9.1U[(9.j.3Q()?"6g":"23")+"7y"]("7w");f(9.j.1u||9.j.1Q){9.4y.18()}f(9.j.1u){9.1u.1B(9.j.1u).18()}f(9.j.1Q){9.1Q.1B(9.j.1Q).18()}f(9.1i&&9.1i.1X>1){9.3z.18().5W().1B(m 6r(9.k.7v).4c({1j:9.1j+1,7t:9.1i.1X}));f(9.j.k.2m){9.2w.18();9.2m.18()}}f(9.j.k.5c&&9.1i.1X>1){q A={2e:(9.k.2o||9.1j!=0),1e:(9.k.2o||(9.j.1y()&&9.2l().1e!=0))};$w("2e 1e").1b(h(B){9["2y"+B.21()+"2P"].r({7r:(A[B]?"7x":"3L")}).1w(A[B]?9.k.1H.1C.2t:9.k.1H.1C.7p)}.U(9));9.4v.18()}9.5y();9.5v()},5y:h(){q E=9.1z.48.o,D=9.1z.3F.o,G=9.1z.4F.o,A=9.1t?9.1t.o:9.1A.o,F=7o,C=0,B=9.k.7n;f(9.j.k.2k){B=1p}Z{f(!9.j.3u()){B="4F";C=G}Z{f(A>=F+E&&A<F+D){B="48";C=E}Z{f(A>=F+D){B="3F";C=D}}}}f(C>0){9.2H.r({o:C+"u"}).18()}Z{9.2H.15()}f(B){9.2H.2c(9.1f+"5n"+B+".1G",{17:9.k.17})}9.4e=C},4K:h(){9.4q=m 11.4f(9.2S,{1W:0.3,2B:0,2z:1,X:9.X})},43:h(){f(9.4q){11.2R.2W("12").23(9.4q)}m 11.5D(9.2S,{1W:1,X:9.X})},5r:h(){f(!9.j.2L()){S}q D=(9.k.2o||9.1j!=0),B=(9.k.2o||(9.j.1y()&&9.2l().1e!=0));9.3W[D?"18":"15"]();9.3U[B?"18":"15"]();q C=9.1t||9.1A;9.1J.r({n:C.n+"u"});q A=((C.o/2-1)+9.1c).2Z();f(D){9.1J.z(9.2F=m y("Y",{V:"24 7l"}).r({o:A+"u"}));9.2F.3i="2e"}f(B){9.1J.z(9.2E=m y("Y",{V:"24 7k"}).r({o:A+"u"}));9.2E.3i="1e"}f(D||B){9.1J.18()}},5x:h(){f(!9.k.1H.3i.1N||!9.j.2L()){S}9.5r();9.1J.18()},4h:h(){9.1J.1B("").15();9.3W.15().r({1v:9.1D.o+"u"});9.3U.15().r({1v:-1*9.1D.o+"u"})},6v:h(){f(9.12.1K("1C")!=0){S}q A=h(){f(!W.13.2x){9.12.18()}9.12.1w(1)}.U(9);f(9.k.1F.1N){m 11.4f(9.1F,{1W:0.4,2B:0,2z:9.4A?1:9.k.1F.1C,X:9.X,7j:9.4b.U(9),1s:A})}Z{A()}},15:h(){f(W.13.2s&&9.22&&9.j.42()){9.22.23()}f(W.13.2x&&9.j.4p()){q A=$$("3a#2b")[0];f(A){3T{A.5S()}3y(B){}}}f(9.12.1K("1C")==0){S}9.2v();9.1J.15();f(!W.13.2s||!9.j.42()){9.2r.15()}f(11.2R.2W("4a").7i.1X>0){S}11.2R.2W("12").1b(h(C){C.6Z()});m 11.1m({X:9.X,1s:9.5f.U(9)});m 11.3t(9.12,{1W:0.1,2B:1,2z:0,X:{1j:"4O",3f:"4a"}});m 11.5D(9.1F,{1W:0.4,X:{1j:"4O",3f:"4a"},1s:9.5q.U(9)})},5q:h(){f(!W.13.2x){9.12.15()}Z{9.12.r({1v:"-3n",1O:"-3n"})}9.2r.1w(0).18();9.1J.1B("").15();9.55();9.29.1B("").15();9.1L.1B("").15();9.4Q();9.5T();f(9.1q){9.1q.5z("12:3E")}9.1q=1p;9.1i=1p;9.j=1p;9.1t=1p},5v:h(){q B={},A=9[(9.1t?"5N":"i")+"5M"].o;9.1U.r({o:A+"u"});9.3D.r({o:A-9.4e-1+"u"});B=9.3K(9.1U);9.1U.r({o:"7g%"});9.2Y=9.j.k.1U?B:{o:B.o,n:0}},3g:h(){q B=9.12.2U();f(W.13.2u){9.12.r({1k:"50%",1o:"50%"})}Z{f(W.13.2x||W.13.2q){q A=9.3v(),C=1g.2J.5B();9.12.r({1v:0,1O:0,1o:(C[0]+(A.o/2)-(B.o/2)).2Z()+"u",1k:(C[1]+(A.n/2)-(B.n/2)).2Z()+"u"})}Z{9.12.r({1j:"4d",1o:"50%",1k:"50%",1v:(0-B.o/2).2j()+"u",1O:(0-B.n/2).2j()+"u"})}}},5p:h(){9.2v();9.2G=1T;9.1e.U(9).2I(0.25);9.2w.2c(9.1f+"7e.1G",{17:9.k.17}).15()},2v:h(){f(9.2G){9.2G=2n}f(9.4t){7d(9.4t)}9.2w.2c(9.1f+"53.1G",{17:9.k.17})},5V:h(){9[(9.2G?"4n":"4u")+"7a"]()},5H:h(){f(9.2G){9.4t=9.1e.U(9).2I(9.k.79)}},5Q:h(){9.4s=[];q A=$$("a[78~=12]");A.1b(h(B){B.5o();m 1d.4N(B);B.19("2O",9.18.47(B).1P(h(E,D){D.4n();E(D)}).1l(9));f(B.1S.2L()){f(9.k.77){B.19("27",9.5l.U(9,B.1S))}q C=A.76(h(D){S D.1n==B.1n});f(C[0].1X){9.4s.2Q({1n:B.1S.1n,54:C[0]});A=C[1]}}}.U(9))},4P:h(A){S 9.4s.6m(h(B){S B.1n==A})},59:h(A){S 9.4P(A).54.5k("1S")},5O:h(){$(1g.40).19("2O",9.61.1l(9));$w("27 2g").1b(h(C){9.1J.19(C,h(D){q E=D.5j("Y");f(!E){S}f(9.2F&&9.2F==E||9.2E&&9.2E==E){9.3B(D)}}.1l(9))}.U(9));9.1J.19("2O",h(D){q E=D.5j("Y");f(!E){S}q C=(9.2F&&9.2F==E)?"2p":(9.2E&&9.2E==E)?"1e":1p;f(C){9[C].1P(h(G,F){9.2v();G(F)}).U(9)()}}.1l(9));$w("2e 1e").1b(h(F){q E=F.21(),C=h(H,G){9.2v();H(G)},D=h(I,H){q G=H.1q().1J;f((G=="2e"&&(9.k.2o||9.1j!=0))||(G=="1e"&&(9.k.2o||(9.j.1y()&&9.2l().1e!=0)))){I(H)}};9[F+"2T"].19("27",9.3B.1l(9)).19("2g",9.3B.1l(9)).19("2O",9[F=="1e"?F:"2p"].1P(C).1l(9));9["2y"+E+"2P"].19("2O",9[F=="1e"?F:"2p"].1P(D).1l(9)).19("27",y.1w.47(9["2y"+E+"2P"],9.k.1H.1C.5i).1P(D).1l(9)).19("2g",y.1w.47(9["2y"+E+"2P"],9.k.1H.1C.2t).1P(D).1l(9))}.U(9));q B=[9.2H,9.2w];f(!W.13.2x){B.1b(h(C){C.19("27",y.1w.U(9,C,9.k.1H.1C.5i)).19("2g",y.1w.U(9,C,9.k.1H.1C.2t))}.U(9))}Z{B.3o("1w",1)}9.2w.19("2O",9.5V.1l(9));f(W.13.2x||W.13.2q){q A=h(D,C){f(9.12.1K("1k").46(0)=="-"){S}D(C)};1m.19(2f,"3A",9.3g.1P(A).1l(9));1m.19(2f,"3w",9.3g.1P(A).1l(9))}f(W.13.2q){1m.19(2f,"3w",9.4b.1l(9))}9.12.19("27",9.3b.1l(9)).19("2g",9.3b.1l(9));9.4S.19("27",9.3b.1l(9)).19("2g",9.3b.1l(9))},3b:h(C){q B=C.14;f(!9.j){B="2g"}Z{f(!(9.j&&9.j.k&&9.j.k.2k&&(9.2r.73()==1))){S}}f(9.5h){11.2R.2W("72").23(9.5h)}q A={1O:((B=="27")?0:9.1z.2k.n)+"u"};9.5h=m 11.71(9.4W,{70:A,1W:0.2,X:{3f:"72",6Y:1},2I:(B=="2g"?0.3:0)})},6X:h(){q A={};$w("o n").1b(h(E){q C=E.21();q B=1g.a5;A[E]=W.13.2s?[B["a4"+C],B["3A"+C]].a2():W.13.3r?1g.40["3A"+C]:B["3A"+C]});S A},4b:h(){f(!W.13.2q){S}9.1F.r(9.1V(1g.2J.2U()));9.1F.r(9.1V(9.6X()))},61:h(A){f(!9.41){9.41=[9.2H,9.4V,9.5L,9.4S];f(9.k.1F.a1){9.41.2Q(9.1F)}}f(A.4D&&(9.41.6D(A.4D))){9.15()}},3B:h(E){q C=E.4D,B=C.3i,A=9.1D.o,F=(E.14=="27")?0:B=="2e"?A:-1*A,D={1v:F+"u"};f(!9.3l){9.3l={}}f(9.3l[B]){11.2R.2W("6V"+B).23(9.3l[B])}9.3l[B]=m 11.71(9[B+"2T"],{70:D,1W:0.2,X:{3f:"6V"+B,6Y:1},2I:(E.14=="2g"?0.1:0)})},2l:h(){f(!9.1i){S}q D=9.1j,C=9.1i.1X;q B=(D<=0)?C-1:D-1,A=(D>=C-1)?0:D+1;S{2p:B,1e:A}},5t:h(G,H){q F=6c[2]||9.k,B=F.2K,E=F.1c,D=m y("9Z",{V:"9X"+H.21(),o:E+"u",n:E+"u"}),A={1k:(H.46(0)=="t"),1o:(H.46(1)=="l")};f(D&&D.5e&&D.5e("2d")){G.z(D);q C=D.5e("2d");C.9U=F.17;C.9T((A.1o?B:E-B),(A.1k?B:E-B),B,0,6b.9S*2,1T);C.9Q();C.6S((A.1o?B:0),0,E-B,E);C.6S(0,(A.1k?B:0),E,E-B)}Z{G.z(m y("Y").r({o:E+"u",n:E+"u",3d:0,3H:0,1N:"5U",1j:"9P",9O:"3E"}).z(m y("v:9N",{9M:F.17,9L:"9K",9H:F.17,9G:(B/E*0.5).33(2)}).r({o:2*E-1+"u",n:2*E-1+"u",1j:"3p",1o:(A.1o?0:(-1*E))+"u",1k:(A.1k?0:(-1*E))+"u"})))}},6B:h(){f(9.4M){S}q A=$$("32","66","3a");9.3C=A.9A(h(B){S{1q:B,1I:B.1K("1I")}});A.3o("r","1I:3E");9.4M=1T},5T:h(){9.3C.1b(h(B,A){B.1q.r("1I: "+B.1I)});4l 9.3C;9.4M=2n},1V:h(A){q B={};10.6u(A).1b(h(C){B[C]=A[C]+"u"});S B},4i:h(){S{o:9.1A.o,n:9.1A.n+9.2Y.n}},5F:h(){q B=9.4i(),A=2*9.1c;S{o:B.o+A,n:B.n+A}},5G:h(){q C=20,A=2*9.1D.n+C,B=9.3v();S{o:B.o-A,n:B.n-A}},3v:h(){q A=1g.2J.2U();f(9.4w&&9.4w.3x()){A.n-=9.9z}S A}});10.1h(1d,{6M:h(){f(!9.k.6L.6K){S}9.3S=9.6J.1l(9);1g.19("6I",9.3S)},4Q:h(){f(!9.k.6L.6K){S}f(9.3S){1g.5o("6I",9.3S)}},6J:h(C){q B=9y.9w(C.6G).4m(),E=C.6G,F=9.j.1y()&&!9.4g,A=9.j.k.2m,D;f(9.j.3u()){C.4n();D=(E==1m.6p||["x","c"].4R(B))?"15":(E==37&&F&&(9.k.2o||9.1j!=0))?"2p":(E==39&&F&&(9.k.2o||9.2l().1e!=0))?"1e":(B=="p"&&A&&9.j.1y())?"5p":(B=="s"&&A&&9.j.1y())?"2v":1p;f(B!="s"){9.2v()}}Z{D=(E==1m.6p)?"15":1p}f(D){9[D]()}f(F){f(E==1m.9u&&9.1i.6z()!=9.j){9.18(9.1i.6z())}f(E==1m.9s&&9.1i.6x()!=9.j){9.18(9.1i.6x())}}}});1d.3V=1d.3V.1P(h(B,A){9.6M();B(A)});10.1h(1d,{6R:h(){f(9.1i.1X==0){S}q A=9.2l();9.51([A.1e,A.2p])},51:h(C){q A=(9.1i&&9.1i.4R(C)||10.9r(C))?9.1i:C.1n?9.59(C.1n):1p;f(!A){S}q B=$A(10.6H(C)?[C]:C.14?[A.1Z(C)]:C).9q();B.1b(h(F){q D=A[F],E=D.1a;f(D.3X||D.4U||!E){S}q G=m 2h();G.1r=h(){G.1r=W.26;D.4U=1p;9.6q(D,G)}.U(9);G.1x=E}.U(9))},6q:h(A,B){A.3X={o:B.o,n:B.n}},5l:h(A){f(A.3X||A.4U){S}9.51(A)}});y.9p({2c:h(C,B){C=$(C);q A=10.1h({6t:"1k 1o",2V:"3Z-2V",4Y:"64",17:""},6c[2]||{});C.r(W.13.2u?{9o:"9m:9l.9k.9t(1x=\'"+B+"\'\', 4Y=\'"+A.4Y+"\')"}:{2C:A.17+" 38("+B+") "+A.6t+" "+A.2V});S C}});10.1h(1d,{6F:h(A){q B;$w("36 3h 22 2N").1b(h(C){f(m 4X("\\\\.("+9.9h[C].2D(/\\s+/g,"|")+")(\\\\?.*)?","i").6w(A)){B=C}}.U(9));f(B){S B}f(A.57("#")){S"3G"}f(1g.6C&&1g.6C!=(A).2D(/(^.*\\/\\/)|(:.*)|(\\/.*)/g,"")){S"22"}S"3h"},6j:h(A){q B=A.9e(/\\?.*/,"").3M(/\\.([^.]{3,4})$/);S B?B[1]:1p},4r:h(B){q C="<"+B.1E;9x(q A 5X B){f(!["2M","56","1E"].4R(A)){C+=" "+A+\'="\'+B[A]+\'"\'}}f(m 4X("^(?:9c|9b|9a|5u|9B|9C|9D|6h|9E|95|94|93|1Y|9I|91|9J)$","i").6w(B.1E)){C+="/>"}Z{C+=">";f(B.2M){B.2M.1b(h(D){C+=9.4r(D)}.U(9))}f(B.56){C+=B.56}C+="</"+B.1E+">"}S C}});(h(){1g.19("4C:4z",h(){q B=(2X.5b&&2X.5b.1X),A=h(D){q C=2n;f(B){C=($A(2X.5b).5k("1R").6s(",").1Z(D)>=0)}Z{3T{C=m 90(D)}3y(E){}}S!!C};2f.1d.4Z=(B)?{36:A("8X 8W"),2N:A("4G")}:{36:A("6o.6o"),2N:A("4G.4G")}})})();1d.4N=8U.9R({8T:h(b){q c=10.6P(b);f(c&&!b.1S){b.1S=9;f(b.1u){b.1S.5d=b.1u;f(1d.k.8S){b.1u=""}}}9.1a=c?b.8R("1a"):b.1a;f(9.1a.1Z("#")>=0){9.1a=9.1a.69(9.1a.1Z("#"))}f(b.1n&&b.1n.57("3e")){9.14="3e";9.1n=b.1n}Z{f(b.1n){9.14=b.1n;9.1n=b.1n}Z{9.14=1d.6F(9.1a);9.1n=9.14}}$w("31 36 3e 22 3h 3G 2N 1L 29").1b(h(a){q T=a.21(),t=a.4m();f("3h 3e 29 1L".1Z(a)<0){9["8P"+T]=h(){S 9.14==t}.U(9)}}.U(9));f(c&&b.1S.5d){q d=b.1S.5d.8O(1d.k.a0).3o("8N");f(d[0]){9.1u=d[0]}f(d[1]){9.1Q=d[1]}q e=d[2];9.k=(e&&10.6N(e))?8M("({"+e+"})"):{}}Z{9.1u=b.1u;9.1Q=b.1Q;9.k=b.k||{}}f(9.k.5g){9.k.31=10.3N(9.k.5g);4l 9.k.5g}},1y:h(){S 9.14.57("3e")},2L:h(){S(9.1y()||9.14=="3h")},3Q:h(){S"22 3G 31".1Z(9.14)>=0},3u:h(){S!9.3Q()}});1d.6W();1g.19("4C:4z",1d.4u.U(1d));',62,626,'|||||||||this||||||if||function||view|options||new|height|width||var|setStyle|||px||||Element|insert|||||||||||||||||||return||bind|className|Prototype|queue|div|else|Object|Effect|lightview|Browser|type|hide||backgroundColor|show|observe|href|each|border|Lightview|next|images|document|extend|views|position|top|bindAsEventListener|Event|rel|left|null|element|onload|afterFinish|scaledInnerDimensions|title|marginLeft|setOpacity|src|isGallery|closeDimensions|innerDimensions|update|opacity|sideDimensions|tag|overlay|png|buttons|visibility|prevnext|getStyle|external|li|display|marginTop|wrap|caption|name|_view|true|menubar|pixelClone|duration|length|param|indexOf||capitalize|iframe|remove|lv_Button||emptyFunction|mouseover|value|media|break|lightviewContent|setPngBackground||prev|window|mouseout|Image|case|round|topclose|getSurroundingIndexes|slideshow|false|cyclic|previous|Gecko|center|IE|normal|IE6|stopSlideshow|slideshowButton|WebKit419|inner|to|id|from|background|replace|nextButton|prevButton|sliding|closeButton|delay|viewport|radius|isImage|children|quicktime|click|Button|push|Queues|loading|ButtonImage|getDimensions|repeat|get|navigator|menuBarDimensions|floor|lv_Fill|ajax|select|toFixed|lightviewError||flash||url||object|toggleTopClose|inlineContent|margin|gallery|scope|restoreCenter|image|side|fillMenuBar|inlineMarker|sideEffect|ul|10000px|invoke|absolute|zIndex|WebKit|sync|Opacity|isMedia|getViewportDimensions|resize|visible|catch|imgNumber|scroll|toggleSideButton|overlappingRestore|data|hidden|large|inline|padding|onComplete|resizeWithinViewport|getHiddenDimensions|auto|match|clone|switch|resizeCenter|isExternal|lv_Corner|keyboardEvent|try|nextButtonImage|afterShow|prevButtonImage|preloadedDimensions|afterEffect|no|body|delegateCloseElements|isIframe|stopLoading|sideButtons||charAt|curry|small|parseInt|lightview_hide|maxOverlay|evaluate|fixed|closeButtonWidth|Appear|resizing|hidePrevNext|getInnerDimensions|convertVersionString|gif|delete|toLowerCase|stop|IEVersion|isQuicktime|loadingEffect|createHTML|sets|slideTimer|start|innerPrevNext|controller|require|dataText|loaded|pngOverlay|tagName|dom|target|autosize|innertop|QuickTime|controls|insertContent|fullscreen|startLoading|userAgent|preventingOverlap|View|end|getSet|disableKeyboardNavigation|member|topcloseButton|pluginspages|isPreloading|topButtons|topcloseButtonImage|RegExp|sizingMethod|Plugin||preloadFromSet|pluginspage|inner_slideshow_play|elements|clearContent|html|startsWith|lv_Wrapper|getViews|wmode|plugins|innerPreviousNext|_title|getContext|restoreInlineContent|ajaxOptions|topCloseEffect|hover|findElement|pluck|preloadImageHover|container|close_|stopObserving|startSlideshow|afterHide|setPrevNext|_|createCorner|br|setMenuBarDimensions|hideData|showPrevNext|setCloseButtons|fire|Parallel|getScrollOffsets|REQUIRED_|Fade|transition|getOuterDimensions|getBounds|nextSlide|showContent|finishShow|isAjax|loadingButton|nnerDimensions|scaledI|addObservers|adjustDimensionsToView|updateViews|build|Stop|showOverlapping|block|toggleSlideshow|down|in|SetControllerVisible|flashvars|mimetypes|delegateClose|loop|default|scale|autoplay|embed|before|prepare|substr|scrolling|Math|arguments|mac|lv_WrapDown|isMac|add|img|lv_Filler|detectExtension|namespaces|lv_CornerWrapper|find|lv_Half|ShockwaveFlash|KEY_ESC|setPreloadedDimensions|Template|join|align|keys|appear|test|last|hideContent|first|marginRight|hideOverlapping|domain|include|nextSide|detectType|keyCode|isNumber|keydown|keyboardDown|enabled|keyboard|enableKeyboardNavigation|isString|lv_Frame|isElement|Scriptaculous|preloadSurroundingImages|fillRect|_inlineDisplayRestore|prevSide|lightview_side|load|getScrollDimensions|limit|cancel|style|Morph|lightview_topCloseEffect|getOpacity|inner_|lv_Container|partition|preloadHover|class|slideshowDelay|Slideshow|float|times|clearTimeout|inner_slideshow_stop|right|100|REQUIRED_Prototype|effects|beforeStart|lv_NextButton|lv_PrevButton|addClassName|borderColor|180|disabled|bl|cursor|tr|total|tl|imgNumberTemplate|lv_MenuTop|pointer|ClassName|opened|requires|parseFloat|throw|resizeDuration|Tween|blank|lv_PrevNext|Version|cloneNode|lv_FrameBottom|isInline|lv_Loading|frames|lv_External|parentNode|innerHTML|undefined|clientHeight|clientWidth|lv_Slideshow|ancestors|inner_next|innerNextButton|inner_prev|FlashVars|innerPrevButton|typeof|exec|allowFullScreen|movie|lv_innerPrevNext|high|quality|lv_ImgNumber|classids|classid|VML|codebases|codebase|lv_Caption|enablejavascript|lv_Title|tofit|lv_DataText|behavior|lv_Data|addRule|log|console|createStyleSheet|wrapperTag|lv_Close|99999|random|lv_MenuBar|lightviewContent_|hspace|lv_Media|frameBorder|vml|Updater|Ajax|lv_WrapCenter|com|microsoft|lv_WrapUp|150|schemas|lv_Center|urn|galleryimg|alt|lv_HalfRight|MSIE|eval|strip|split|is|lv_HalfLeft|getAttribute|removeTitles|initialize|Class|defaultOptions|Flash|Shockwave|transparent|lv_Liquid|ActiveXObject|spacer|lv_FrameTop|meta|isindex|link|script|required|plugin|lv_Frames|basefont|base|area|head|gsub|requiresPlugin|lv_topcloseButtonImage|typeExtensions|errors|js|Microsoft|DXImageTransform|progid|lv_topButtons|filter|addMethods|uniq|isArray|KEY_END|AlphaImageLoader|KEY_HOME|lv_NextSide|fromCharCode|for|String|controllerOffset|map|col|frame|hr|input|blur|arcSize|strokeColor|range|wbr|1px|strokeWeight|fillcolor|roundrect|overflow|relative|fill|create|PI|arc|fillStyle|lv_PrevSide|after|cornerCanvas|REQUIRED_Scriptaculous|canvas|titleSplit|close|max|lv_Sides|offset|documentElement'.split('|'),0,{}));





if(!Control) var Control = {};
Control.colorPickers = [];
Control.ColorPicker = Class.create();
Control.ColorPicker.activeColorPicker;
Control.ColorPicker.CONTROL;

Control.ColorPicker.prototype = {
  initialize : function(field, type, options) {
    var colorPicker = this;
    Control.colorPickers.push(colorPicker);
	this.type = type;
    this.field = $(field);
    this.fieldName = this.field.name || this.field.id;
    this.options = Object.extend({
       IMAGE_BASE : "../images/"
    }, options || {});
    this.swatch = $(this.options.swatch) || this.field;
    this.rgb = {};
    this.hsv = {};
    this.isOpen = false;

    if (!Control.ColorPicker.CONTROL) {
      Control.ColorPicker.CONTROL = {};
      if (!$("colorpicker")) {
        var control = Builder.node('div', {id: 'colorpicker'});
        control.innerHTML = 
          '<div id="colorpicker-div">' + (
            // apply png fix for ie 5.5 and 6.0
            (/MSIE ((6)|(5\.5))/gi.test(navigator.userAgent) && /windows/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) ?
              '<img id="colorpicker-bg" src="' + this.options.IMAGE_BASE + 'blank.gif" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.options.IMAGE_BASE + 'pickerbg.png\', sizingMethod=\'scale\')" alt="">' :
              '<img id="colorpicker-bg" src="' + this.options.IMAGE_BASE + 'pickerbg.png" alt="">'
             ) +
          '<div id="colorpicker-bg-overlay" style="z-index: 1002;"></div>' +
          '<div id="colorpicker-selector"><img src="' + this.options.IMAGE_BASE + 'select.gif" width="11" height="11" alt="" /></div></div>' +
          '<div id="colorpicker-hue-container"><img src="' + this.options.IMAGE_BASE + 'hue.png" id="colorpicker-hue-bg-img"><div id="colorpicker-hue-slider"><div id="colorpicker-hue-thumb"><img src="' + this.options.IMAGE_BASE + 'hline.png"></div></div></div>' + 
          '<div id="colorpicker-footer"><span id="colorpicker-value">#<input type="text" onclick="this.select()" id="colorpicker-value-input" name="colorpicker-value" value=""></input></span><button id="colorpicker-okbutton">OK</button></div>'
        document.body.appendChild(control);
      }
      Control.ColorPicker.CONTROL = {
        popUp : $("colorpicker"),
        pickerArea : $('colorpicker-div'),
        selector : $('colorpicker-selector'),
        okButton : $("colorpicker-okbutton"),
        value : $("colorpicker-value"),
        input : $("colorpicker-value-input"),
        picker : new Draggable($('colorpicker-selector'), {
          snap: function(x, y) {
            return [
              Math.min(Math.max(x, 0), Control.ColorPicker.activeColorPicker.control.pickerArea.offsetWidth), 
              Math.min(Math.max(y, 0), Control.ColorPicker.activeColorPicker.control.pickerArea.offsetHeight)
            ];
          },
          zindex: 1009,
          change: function(draggable) {
            var pos = draggable.currentDelta();
            Control.ColorPicker.activeColorPicker.update(pos[0], pos[1]);
          }
        }),
        hueSlider: new Control.Slider('colorpicker-hue-thumb', 'colorpicker-hue-slider', {
          axis: 'vertical',
          onChange: function(v) {
            Control.ColorPicker.activeColorPicker.updateHue(v);
          }
        })
      };
      Element.hide($("colorpicker"));
    }
    this.control = Control.ColorPicker.CONTROL;

    // bind event listener to properties, so we can use them savely with Event[observe|stopObserving]
    this.toggleOnClickListener = this.toggle.bindAsEventListener(this);
    this.updateOnChangeListener = this.updateFromFieldValue.bindAsEventListener(this);
    this.closeOnClickOkListener = this.close.bindAsEventListener(this);
    this.updateOnClickPickerListener = this.updateSelector.bindAsEventListener(this);

    Event.observe(this.swatch, "click", this.toggleOnClickListener);
    Event.observe(this.field, "change", this.updateOnChangeListener);
    Event.observe(this.control.input, "change", this.updateOnChangeListener);

    this.updateSwatch();
  },
  toggle : function(event) {
    this[(this.isOpen) ? "close" : "open"](event);
    Event.stop(event);    
  },
  open : function(event) {
    Control.colorPickers.each(function(colorPicker) {
      colorPicker.close();
    });
    Control.ColorPicker.activeColorPicker = this;
    this.isOpen = true;
    Element.show(this.control.popUp);
    if (this.options.getPopUpPosition) {
       var pos = this.options.getPopUpPosition.bind(this)(event);
    } else {
      var pos = Position.cumulativeOffset(this.swatch || this.field);
      pos[0] = (pos[0] + (this.swatch || this.field).offsetWidth + 10);
    }
    this.control.popUp.style.left = (pos[0]) + "px";
    this.control.popUp.style.top = (pos[1]) + "px";
    this.updateFromFieldValue();
    Event.observe(this.control.okButton, "click", this.closeOnClickOkListener);
    Event.observe(this.control.pickerArea, "mousedown", this.updateOnClickPickerListener);
    if (this.options.onOpen) this.options.onOpen.bind(this)(event);
  },
  close : function(event) {
    if (Control.ColorPicker.activeColorPicker == this) Control.ColorPicker.activeColorPicker = null;
    this.isOpen = false;
    Element.hide(this.control.popUp);
    Event.stopObserving(this.control.okButton, "click", this.closeOnClickOkListener);
    Event.stopObserving(this.control.pickerArea, "mousedown", this.updateOnClickPickerListener);
    if (this.options.onClose) this.options.onClose.bind(this)();	
	if (this.field.value!=""){
		if(this.fieldName=="col_bg"){change_bg(this.field.value,999,this.type);}
		if(this.fieldName=="col_nav"){change_nav(this.field.value,999,this.type);}
	}
  },
  updateHue : function(v) {
    var h = (this.control.pickerArea.offsetHeight - v * 100) / this.control.pickerArea.offsetHeight;
    if (h == 1) h = 0;
    var rgb = YAHOO.util.Color.hsv2rgb( h, 1, 1 );
    if (!YAHOO.util.Color.isValidRGB(rgb)) return;
    this.control.pickerArea.style.backgroundColor = "rgb(" + rgb[0] + ", " + rgb[1] + ", " + rgb[2] + ")";	
    this.update();
  },
  updateFromFieldValue : function(event) {
    if (!this.isOpen) return;
    var field = (event && Event.findElement(event, "input")) || this.field;
    var rgb = YAHOO.util.Color.hex2rgb( field.value );
    if (!YAHOO.util.Color.isValidRGB(rgb)) return;
    var hsv = YAHOO.util.Color.rgb2hsv( rgb[0], rgb[1], rgb[2] );
    this.control.selector.style.left = Math.round(hsv[1] * this.control.pickerArea.offsetWidth) + "px";
    this.control.selector.style.top = Math.round((1 - hsv[2]) * this.control.pickerArea.offsetWidth) + "px";
    this.control.hueSlider.setValue((1 - hsv[0]));	
  },
  updateSelector : function(event) {
    var xPos = Event.pointerX(event);
    var yPos = Event.pointerY(event);
    var pos = Position.cumulativeOffset($("colorpicker-bg"));
    this.control.selector.style.left = (xPos - pos[0] - 6) + "px";
    this.control.selector.style.top = (yPos - pos[1] - 6) + "px";
    this.update((xPos - pos[0]), (yPos - pos[1]));
    this.control.picker.initDrag(event);
	if (this.field.value!=""){
		if(this.fieldName=="col_bg"){change_bg(this.field.value,999,this.type);}
		if(this.fieldName=="col_nav"){change_nav(this.field.value,999,this.type);}
		if(this.fieldName=="col_bor"){change_br(this.field.value,999,this.type);}
	}
  },
  updateSwatch : function() {
    var rgb = YAHOO.util.Color.hex2rgb( this.field.value );
    if (!YAHOO.util.Color.isValidRGB(rgb)) return;
    this.swatch.style.backgroundColor = "rgb(" + rgb[0] + ", " + rgb[1] + ", " + rgb[2] + ")";
    var hsv = YAHOO.util.Color.rgb2hsv( rgb[0], rgb[1], rgb[2] );
    this.swatch.style.color = (hsv[2] > 0.65) ? "#000000" : "#FFFFFF";
  },
  update : function(x, y) {
    if (!x) x = this.control.picker.currentDelta()[0];
    if (!y) y = this.control.picker.currentDelta()[1];

    var h = (this.control.pickerArea.offsetHeight - this.control.hueSlider.value * 100) / this.control.pickerArea.offsetHeight;
    if (h == 1) { h = 0; };
    this.hsv = {
      hue: 1 - this.control.hueSlider.value,
      saturation: x / this.control.pickerArea.offsetWidth,
      brightness: (this.control.pickerArea.offsetHeight - y) / this.control.pickerArea.offsetHeight
    };
    var rgb = YAHOO.util.Color.hsv2rgb( this.hsv.hue, this.hsv.saturation, this.hsv.brightness );
    this.rgb = {
      red: rgb[0],
      green: rgb[1],
      blue: rgb[2]
    };
    this.field.value = YAHOO.util.Color.rgb2hex(rgb[0], rgb[1], rgb[2]);
    this.control.input.value = this.field.value;
    this.updateSwatch();
    if (this.options.onUpdate) this.options.onUpdate.bind(this)(this.field.value);
  }
}





/* http://www.victorstanciu.ro/ */
Carousel = Class.create(Abstract, {

	initialize: function (scroller, slides, cons, options) {

		this.scrolling	= false;
		this.scroller	= scroller;
		this.slides		= slides;
		this.cons	= cons;

		this.options    = Object.extend({ duration: 1.0, frequency: 3, conClassName: 'car-con', jumClassName: 'car-jum' }, options || {});

		this.slides.each(function(slide, index) {
			slide._index = index; 
			});

		this.cons.invoke('observe', 'click', this.click.bind(this));

		if (this.options.auto) {
			this.start();
			}

		},
	
	click: function (event) {

		this.stop();
		if (this.scrolling) {
			this.scrolling.cancel();
			}

		var element = event.findElement('a');

		if (element.hasClassName(this.options.conClassName)) {
			eval("this." + element.rel + "()");
			} else if (element.hasClassName(this.options.jumClassName)) {
				this.moveTo(element, element.rel);
				}

		event.stop();

		},

	moveTo: function (trigger, element) {

		if (this.options.beforeMove && (typeof this.options.beforeMove == 'function')) {
			this.options.beforeMove();
			}

		if (this.options.selectedClassName) {
			this.cons.each((function (elm) { elm.removeClassName(this.options.selectedClassName); }).bind(this));
			/*trigger.addClassName(this.options.selectedClassName);*/
			
			}

		this.previous= this.current ? this.current : this.slides[0];
		this.current = $(element);

		var scrollerOffset = this.scroller.cumulativeOffset();
		var elementOffset = this.current.cumulativeOffset();
		this.scrolling = new Effect.SmoothScroll(this.scroller, {duration: this.options.duration, x: (elementOffset[0] - scrollerOffset[0]), y: (elementOffset[1] - scrollerOffset[1])});

		if (this.options.afterMove && (typeof this.options.afterMove == 'function')) {
			this.options.afterMove();
			}

		return false;

		},

	prev: function () {
		if (this.current) {
			var currentIndex = this.current._index;
			var prevIndex = (currentIndex == 0) ? this.slides.length - 1 : currentIndex - 1;
			} else { 
				var prevIndex = this.slides.length - 1;
				}
		
		this.moveTo(this.cons[prevIndex], this.slides[prevIndex]);
		},		

	next: function () {
		if (this.current) {
			var currentIndex = this.current._index;
			var nextIndex = (this.slides.length - 1 == currentIndex) ? 0 : currentIndex + 1;      
			} else {
				var nextIndex = 1;
				}	

		this.moveTo(this.cons[nextIndex], this.slides[nextIndex]);
		},

	first: function () {
		var firstIndex = 0;
		if (this.current) {
			var currentIndex = this.current._index;
			}

		this.moveTo(this.cons[firstIndex], this.slides[firstIndex]);	
		},

	last: function () {
		var lastIndex = (this.slides.length - 1);
		if (this.current) {
			var currentIndex = this.current._index;
			}

		this.moveTo(this.cons[lastIndex], this.slides[lastIndex]);
		},
	
	toggle: function () {
		if (this.previous) {
			this.moveTo(this.cons[this.previous._index], this.slides[this.previous._index]);
			} else {
				return false;
				}
		},

	stop: function () { clearTimeout(this.timer); },
	
	start: function () { this.periodicallyUpdate(); },
		
	periodicallyUpdate: function () {
		if (this.timer != null) {
			clearTimeout(this.timer);
			this.next();
			}
		this.timer = setTimeout(this.periodicallyUpdate.bind(this), this.options.frequency * 1000);
		}

	});

Effect.SmoothScroll = Class.create();

Object.extend(Object.extend(Effect.SmoothScroll.prototype, Effect.Base.prototype), {

	initialize: function (element) {
		this.element = $(element);
		var options = Object.extend({ x: 0, y: 0, mode: 'absolute' } , arguments[1] || {});
		this.start(options);
		},

	setup: function () {
		if (this.options.continuous && !this.element._ext ) {
			this.element.cleanWhitespace();
			this.element._ext = true;
			this.element.appendChild(this.element.firstChild);
			}
   
		this.originalLeft = this.element.scrollLeft;
		this.originalTop = this.element.scrollTop;

		if (this.options.mode == 'absolute') {
			this.options.x -= this.originalLeft;
			this.options.y -= this.originalTop;
			}
		},

	update: function (position) {   
		this.element.scrollLeft = this.options.x * position + this.originalLeft;
		this.element.scrollTop  = this.options.y * position + this.originalTop;
		}

	});



/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */

var YAHOO = function() { return {util: {}} } ();
YAHOO.util.Color = new function() {
  
  // Adapted from http://www.easyrgb.com/math.html
  // hsv values = 0 - 1
  // rgb values 0 - 255
  this.hsv2rgb = function (h, s, v) {
    var r, g, b;
    if ( s == 0 ) {
      r = v * 255;
      g = v * 255;
      b = v * 255;
    } else {

      // h must be < 1
      var var_h = h * 6;
      if ( var_h == 6 ) {
        var_h = 0;
      }

      //Or ... var_i = floor( var_h )
      var var_i = Math.floor( var_h );
      var var_1 = v * ( 1 - s );
      var var_2 = v * ( 1 - s * ( var_h - var_i ) );
      var var_3 = v * ( 1 - s * ( 1 - ( var_h - var_i ) ) );

      if ( var_i == 0 ) { 
        var_r = v; 
        var_g = var_3; 
        var_b = var_1;
      } else if ( var_i == 1 ) { 
        var_r = var_2;
        var_g = v;
        var_b = var_1;
      } else if ( var_i == 2 ) {
        var_r = var_1;
        var_g = v;
        var_b = var_3
      } else if ( var_i == 3 ) {
        var_r = var_1;
        var_g = var_2;
        var_b = v;
      } else if ( var_i == 4 ) {
        var_r = var_3;
        var_g = var_1;
        var_b = v;
      } else { 
        var_r = v;
        var_g = var_1;
        var_b = var_2
      }

      r = var_r * 255          //rgb results = 0 ÷ 255
      g = var_g * 255
      b = var_b * 255

      }
    return [Math.round(r), Math.round(g), Math.round(b)];
  };

  // added by Matthias Platzer AT knallgrau.at 
  this.rgb2hsv = function (r, g, b) {
      var r = ( r / 255 );                   //RGB values = 0 ÷ 255
      var g = ( g / 255 );
      var b = ( b / 255 );

      var min = Math.min( r, g, b );    //Min. value of RGB
      var max = Math.max( r, g, b );    //Max. value of RGB
      deltaMax = max - min;             //Delta RGB value

      var v = max;
      var s, h;
      var deltaRed, deltaGreen, deltaBlue;

      if ( deltaMax == 0 )                     //This is a gray, no chroma...
      {
         h = 0;                               //HSV results = 0 ÷ 1
         s = 0;
      }
      else                                    //Chromatic data...
      {
         s = deltaMax / max;

         deltaRed = ( ( ( max - r ) / 6 ) + ( deltaMax / 2 ) ) / deltaMax;
         deltaGreen = ( ( ( max - g ) / 6 ) + ( deltaMax / 2 ) ) / deltaMax;
         deltaBlue = ( ( ( max - b ) / 6 ) + ( deltaMax / 2 ) ) / deltaMax;

         if      ( r == max ) h = deltaBlue - deltaGreen;
         else if ( g == max ) h = ( 1 / 3 ) + deltaRed - deltaBlue;
         else if ( b == max ) h = ( 2 / 3 ) + deltaGreen - deltaRed;

         if ( h < 0 ) h += 1;
         if ( h > 1 ) h -= 1;
      }

      return [h, s, v];
  }

  this.rgb2hex = function (r,g,b) {
    return this.toHex(r) + this.toHex(g) + this.toHex(b);
  };

  this.hexchars = "0123456789ABCDEF";

  this.toHex = function(n) {
    n = n || 0;
    n = parseInt(n, 10);
    if (isNaN(n)) n = 0;
    n = Math.round(Math.min(Math.max(0, n), 255));

    return this.hexchars.charAt((n - n % 16) / 16) + this.hexchars.charAt(n % 16);
  };

  this.toDec = function(hexchar) {
    return this.hexchars.indexOf(hexchar.toUpperCase());
  };

  this.hex2rgb = function(str) { 
    var rgb = [];
    rgb[0] = (this.toDec(str.substr(0, 1)) * 16) + 
            this.toDec(str.substr(1, 1));
    rgb[1] = (this.toDec(str.substr(2, 1)) * 16) + 
            this.toDec(str.substr(3, 1));
    rgb[2] = (this.toDec(str.substr(4, 1)) * 16) + 
            this.toDec(str.substr(5, 1));
    // gLogger.debug("hex2rgb: " + str + ", " + rgb.toString());
    return rgb;
  };

  this.isValidRGB = function(a) { 
    if ((!a[0] && a[0] !=0) || isNaN(a[0]) || a[0] < 0 || a[0] > 255) return false;
    if ((!a[1] && a[1] !=0) || isNaN(a[1]) || a[1] < 0 || a[1] > 255) return false;
    if ((!a[2] && a[2] !=0) || isNaN(a[2]) || a[2] < 0 || a[2] > 255) return false;

    return true;
  };
}





var SWFUpload = function (settings) {
	this.initSWFUpload(settings);
};

SWFUpload.prototype.initSWFUpload = function (settings) {
	try {
		this.customSettings = {};	// A container where I can place their own settings associated with this instance.
		this.settings = settings;
		this.eventQueue = [];
		this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
		this.movieElement = null;

		// Setup global control tracking
		SWFUpload.instances[this.movieName] = this;

		// Load the settings.  Load the Flash movie.
		this.initSettings();
		this.loadFlash();
		this.displayDebugInfo();
	} catch (ex) {
		delete SWFUpload.instances[this.movieName];
		throw ex;
	}
};

/* *************** */
/* Static Members  */
/* *************** */
SWFUpload.instances = {};
SWFUpload.movieCount = 0;
SWFUpload.version = "2.2.0 Alpha";
SWFUpload.QUEUE_ERROR = {
	QUEUE_LIMIT_EXCEEDED	  		: -100,
	FILE_EXCEEDS_SIZE_LIMIT  		: -110,
	ZERO_BYTE_FILE			  		: -120,
	INVALID_FILETYPE		  		: -130
};
SWFUpload.UPLOAD_ERROR = {
	HTTP_ERROR				  		: -200,
	MISSING_UPLOAD_URL	      		: -210,
	IO_ERROR				  		: -220,
	SECURITY_ERROR			  		: -230,
	UPLOAD_LIMIT_EXCEEDED	  		: -240,
	UPLOAD_FAILED			  		: -250,
	SPECIFIED_FILE_ID_NOT_FOUND		: -260,
	FILE_VALIDATION_FAILED	  		: -270,
	FILE_CANCELLED			  		: -280,
	UPLOAD_STOPPED					: -290
};
SWFUpload.FILE_STATUS = {
	QUEUED		 : -1,
	IN_PROGRESS	 : -2,
	ERROR		 : -3,
	COMPLETE	 : -4,
	CANCELLED	 : -5
};
SWFUpload.BUTTON_ACTION = {
	SELECT_FILE  : -100,
	SELECT_FILES : -110,
	START_UPLOAD : -120
};

/* ******************** */
/* Instance Members  */
/* ******************** */

// Private: initSettings ensures that all the
// settings are set, getting a default value if one was not assigned.
SWFUpload.prototype.initSettings = function () {
	this.ensureDefault = function (settingName, defaultValue) {
		this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
	};
	
	// Upload backend settings
	this.ensureDefault("upload_url", "");
	this.ensureDefault("file_post_name", "Filedata");
	this.ensureDefault("post_params", {});
	this.ensureDefault("use_query_string", false);
	this.ensureDefault("requeue_on_error", false);
	
	// File Settings
	this.ensureDefault("file_types", "*.*");
	this.ensureDefault("file_types_description", "All Files");
	this.ensureDefault("file_size_limit", 0);	// Default zero means "unlimited"
	this.ensureDefault("file_upload_limit", 0);
	this.ensureDefault("file_queue_limit", 0);

	// Flash Settings
	this.ensureDefault("flash_url", "swfupload.swf");
	this.ensureDefault("prevent_swf_caching", true);
	
	// Button Settings
	this.ensureDefault("button_image_url", "");
	this.ensureDefault("button_width", 1);
	this.ensureDefault("button_height", 1);
	this.ensureDefault("button_text", "");
	this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
	this.ensureDefault("button_text_top_padding", 0);
	this.ensureDefault("button_text_left_padding", 0);
	this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
	this.ensureDefault("button_disabled", false);
	this.ensureDefault("button_placeholder_id", null);
	
	// Debug Settings
	this.ensureDefault("debug", false);
	this.settings.debug_enabled = this.settings.debug;	// Here to maintain v2 API
	
	// Event Handlers
	this.settings.return_upload_start_handler = this.returnUploadStart;
	this.ensureDefault("swfupload_loaded_handler", null);
	this.ensureDefault("file_dialog_start_handler", null);
	this.ensureDefault("file_queued_handler", null);
	this.ensureDefault("file_queue_error_handler", null);
	this.ensureDefault("file_dialog_complete_handler", null);
	
	this.ensureDefault("upload_start_handler", null);
	this.ensureDefault("upload_progress_handler", null);
	this.ensureDefault("upload_error_handler", null);
	this.ensureDefault("upload_success_handler", null);
	this.ensureDefault("upload_complete_handler", null);
	
	this.ensureDefault("debug_handler", this.debugMessage);

	this.ensureDefault("custom_settings", {});

	// Other settings
	this.customSettings = this.settings.custom_settings;
	
	// Update the flash url if needed
	if (this.settings.prevent_swf_caching) {
		this.settings.flash_url = this.settings.flash_url + "?swfuploadrnd=" + Math.floor(Math.random() * 999999999);
	}
	
	delete this.ensureDefault;
};

SWFUpload.prototype.loadFlash = function () {
	if (this.settings.button_placeholder_id !== "") {
		this.replaceWithFlash();
	} else {
		this.appendFlash();
	}
};

// Private: appendFlash gets the HTML tag for the Flash
// It then appends the flash to the body
SWFUpload.prototype.appendFlash = function () {
	var targetElement, container;

	// Make sure an element with the ID we are going to use doesn't already exist
	if (document.getElementById(this.movieName) !== null) {
		throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
	}

	// Get the body tag where we will be adding the flash movie
	targetElement = document.getElementsByTagName("body")[0];

	if (targetElement == undefined) {
		throw "Could not find the 'body' element.";
	}

	// Append the container and load the flash
	container = document.createElement("div");
	container.style.width = "1px";
	container.style.height = "1px";
	container.style.overflow = "hidden";

	targetElement.appendChild(container);
	container.innerHTML = this.getFlashHTML();	// Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
};

// Private: replaceWithFlash replaces the button_placeholder element with the flash movie.
SWFUpload.prototype.replaceWithFlash = function () {
	var targetElement, tempParent;

	// Make sure an element with the ID we are going to use doesn't already exist
	if (document.getElementById(this.movieName) !== null) {
		throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
	}

	// Get the element where we will be placing the flash movie
	targetElement = document.getElementById(this.settings.button_placeholder_id);

	if (targetElement == undefined) {
		throw "Could not find the placeholder element.";
	}

	// Append the container and load the flash
	tempParent = document.createElement("div");
	tempParent.innerHTML = this.getFlashHTML();	// Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
	targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);

};

// Private: getFlashHTML generates the object tag needed to embed the flash in to the document
SWFUpload.prototype.getFlashHTML = function () {
	var transparent = this.settings.button_image_url === "" ? true : false;
	
	// Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
	return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
				'<param name="wmode" value="', transparent ? "transparent" : "window", '" />',
				'<param name="movie" value="', this.settings.flash_url, '" />',
				'<param name="quality" value="high" />',
				'<param name="menu" value="false" />',
				'<param name="allowScriptAccess" value="always" />',
				'<param name="flashvars" value="' + this.getFlashVars() + '" />',

				'</object>'].join("");
};

// Private: getFlashVars builds the parameter string that will be passed
// to flash in the flashvars param.
SWFUpload.prototype.getFlashVars = function () {
	// Build a string from the post param object
	var paramString = this.buildParamString();

	// Build the parameter string
	return ["movieName=", encodeURIComponent(this.movieName),
			"&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
			"&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
			"&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
			"&amp;params=", encodeURIComponent(paramString),
			"&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
			"&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
			"&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
			"&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
			"&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
			"&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
			"&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
			"&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
			"&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
			"&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
			"&amp;buttonText=", encodeURIComponent(this.settings.button_text),
			"&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
			"&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
			"&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
			"&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
			"&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled)
		].join("");
};

// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
// The element is cached after the first lookup
SWFUpload.prototype.getMovieElement = function () {
	if (this.movieElement == undefined) {
		this.movieElement = document.getElementById(this.movieName);
	}

	if (this.movieElement === null) {
		throw "Could not find Flash element";
	}
	
	return this.movieElement;
};

// Private: buildParamString takes the name/value pairs in the post_params setting object
// and joins them up in to a string formatted "name=value&amp;name=value"
SWFUpload.prototype.buildParamString = function () {
	var postParams = this.settings.post_params; 
	var paramStringPairs = [];

	if (typeof(postParams) === "object") {
		for (var name in postParams) {
			if (postParams.hasOwnProperty(name)) {
				paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
			}
		}
	}

	return paramStringPairs.join("&amp;");
};

// Public: Used to remove a SWFUpload instance from the page. This method strives to remove
// all references to the SWF, and other objects so memory is properly freed.
// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
SWFUpload.prototype.destroy = function () {
	try {
		// Make sure Flash is done before we try to remove it
		this.stopUpload();
		
		// Remove the SWFUpload DOM nodes
		var movieElement = null;
		try {
			movieElement = this.getMovieElement();
		} catch (ex) {
		}
		
		if (movieElement != undefined && movieElement.parentNode != undefined && typeof movieElement.parentNode.removeChild === "function") {
			var container = movieElement.parentNode;
			if (container != undefined) {
				container.removeChild(movieElement);
				if (container.parentNode != undefined && typeof container.parentNode.removeChild === "function") {
					container.parentNode.removeChild(container);
				}
			}
		}
		
		// Destroy references
		SWFUpload.instances[this.movieName] = null;
		delete SWFUpload.instances[this.movieName];

		delete this.movieElement;
		delete this.settings;
		delete this.customSettings;
		delete this.eventQueue;
		delete this.movieName;
		
		delete window[this.movieName];
		
		return true;
	} catch (ex1) {
		return false;
	}
};

// Public: displayDebugInfo prints out settings and configuration
// information about this SWFUpload instance.
// This function (and any references to it) can be deleted when placing
// SWFUpload in production.
SWFUpload.prototype.displayDebugInfo = function () {
	this.debug(
		[
			"---SWFUpload Instance Info---\n",
			"Version: ", SWFUpload.version, "\n",
			"Movie Name: ", this.movieName, "\n",
			"Settings:\n",
			"\t", "upload_url:               ", this.settings.upload_url, "\n",
			"\t", "flash_url:                ", this.settings.flash_url, "\n",
			"\t", "use_query_string:         ", this.settings.use_query_string.toString(), "\n",
			"\t", "file_post_name:           ", this.settings.file_post_name, "\n",
			"\t", "post_params:              ", this.settings.post_params.toString(), "\n",
			"\t", "file_types:               ", this.settings.file_types, "\n",
			"\t", "file_types_description:   ", this.settings.file_types_description, "\n",
			"\t", "file_size_limit:          ", this.settings.file_size_limit, "\n",
			"\t", "file_upload_limit:        ", this.settings.file_upload_limit, "\n",
			"\t", "file_queue_limit:         ", this.settings.file_queue_limit, "\n",
			"\t", "debug:                    ", this.settings.debug.toString(), "\n",

			"\t", "prevent_swf_caching:      ", this.settings.prevent_swf_caching.toString(), "\n",

			"\t", "button_placeholder_id:    ", this.settings.button_placeholder_id.toString(), "\n",
			"\t", "button_image_url:         ", this.settings.button_image_url.toString(), "\n",
			"\t", "button_width:             ", this.settings.button_width.toString(), "\n",
			"\t", "button_height:            ", this.settings.button_height.toString(), "\n",
			"\t", "button_text:              ", this.settings.button_text.toString(), "\n",
			"\t", "button_text_style:        ", this.settings.button_text_style.toString(), "\n",
			"\t", "button_text_top_padding:  ", this.settings.button_text_top_padding.toString(), "\n",
			"\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
			"\t", "button_action:            ", this.settings.button_action.toString(), "\n",
			"\t", "button_disabled:          ", this.settings.button_disabled.toString(), "\n",

			"\t", "custom_settings:          ", this.settings.custom_settings.toString(), "\n",
			"Event Handlers:\n",
			"\t", "swfupload_loaded_handler assigned:  ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
			"\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
			"\t", "file_queued_handler assigned:       ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
			"\t", "file_queue_error_handler assigned:  ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
			"\t", "upload_start_handler assigned:      ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
			"\t", "upload_progress_handler assigned:   ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
			"\t", "upload_error_handler assigned:      ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
			"\t", "upload_success_handler assigned:    ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
			"\t", "upload_complete_handler assigned:   ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
			"\t", "debug_handler assigned:             ", (typeof this.settings.debug_handler === "function").toString(), "\n"
		].join("")
	);
};

/* Note: addSetting and getSetting are no longer used by SWFUpload but are included
	the maintain v2 API compatibility
*/
// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
SWFUpload.prototype.addSetting = function (name, value, default_value) {
    if (value == undefined) {
        return (this.settings[name] = default_value);
    } else {
        return (this.settings[name] = value);
	}
};

// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
SWFUpload.prototype.getSetting = function (name) {
    if (this.settings[name] != undefined) {
        return this.settings[name];
	}

    return "";
};



// Private: callFlash handles function calls made to the Flash element.
// Calls are made with a setTimeout for some functions to work around
// bugs in the ExternalInterface library.
SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
	argumentArray = argumentArray || [];
	
	var movieElement = this.getMovieElement();
	var returnValue;

	if (typeof movieElement[functionName] === "function") {
		// We have to go through all this if/else stuff because the Flash functions don't have apply() and only accept the exact number of arguments.
		if (argumentArray.length === 0) {
			returnValue = movieElement[functionName]();
		} else if (argumentArray.length === 1) {
			returnValue = movieElement[functionName](argumentArray[0]);
		} else if (argumentArray.length === 2) {
			returnValue = movieElement[functionName](argumentArray[0], argumentArray[1]);
		} else if (argumentArray.length === 3) {
			returnValue = movieElement[functionName](argumentArray[0], argumentArray[1], argumentArray[2]);
		} else {
			throw "Too many arguments";
		}
		
		// Unescape file post param values
		if (returnValue != undefined && typeof returnValue.post === "object") {
			returnValue = this.unescapeFilePostParams(returnValue);
		}
		
		return returnValue;
	} else {
		throw "Invalid function name: " + functionName;
	}
};


/* *****************************
	-- Flash control methods --
	Your UI should use these
	to operate SWFUpload
   ***************************** */

// Public: selectFile causes a File Selection Dialog window to appear.  This
// dialog only allows 1 file to be selected. WARNING: this function does not work in Flash Player 10
SWFUpload.prototype.selectFile = function () {
	this.callFlash("SelectFile");
};

// Public: selectFiles causes a File Selection Dialog window to appear/ This
// dialog allows the user to select any number of files
// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
// If the selection name length is too long the dialog will fail in an unpredictable manner.  There is no work-around
// for this bug.  WARNING: this function does not work in Flash Player 10
SWFUpload.prototype.selectFiles = function () {
	this.callFlash("SelectFiles");
};


// Public: startUpload starts uploading the first file in the queue unless
// the optional parameter 'fileID' specifies the ID 
SWFUpload.prototype.startUpload = function (fileID) {
	this.callFlash("StartUpload", [fileID]);
};

/* Cancels a the file upload.  You must specify a file_id */
// Public: cancelUpload cancels any queued file.  The fileID parameter
// must be specified.
SWFUpload.prototype.cancelUpload = function (fileID) {
	this.callFlash("CancelUpload", [fileID]);
};

// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
// If nothing is currently uploading then nothing happens.
SWFUpload.prototype.stopUpload = function () {
	this.callFlash("StopUpload");
};

/* ************************
 * Settings methods
 *   These methods change the SWFUpload settings.
 *   SWFUpload settings should not be changed directly on the settings object
 *   since many of the settings need to be passed to Flash in order to take
 *   effect.
 * *********************** */

// Public: getStats gets the file statistics object.
SWFUpload.prototype.getStats = function () {
	return this.callFlash("GetStats");
};

// Public: setStats changes the SWFUpload statistics.  You shouldn't need to 
// change the statistics but you can.  Changing the statistics does not
// affect SWFUpload accept for the successful_uploads count which is used
// by the upload_limit setting to determine how many files the user may upload.
SWFUpload.prototype.setStats = function (statsObject) {
	this.callFlash("SetStats", [statsObject]);
};

// Public: getFile retrieves a File object by ID or Index.  If the file is
// not found then 'null' is returned.
SWFUpload.prototype.getFile = function (fileID) {
	if (typeof(fileID) === "number") {
		return this.callFlash("GetFileByIndex", [fileID]);
	} else {
		return this.callFlash("GetFile", [fileID]);
	}
};

// Public: addFileParam sets a name/value pair that will be posted with the
// file specified by the Files ID.  If the name already exists then the
// exiting value will be overwritten.
SWFUpload.prototype.addFileParam = function (fileID, name, value) {
	return this.callFlash("AddFileParam", [fileID, name, value]);
};

// Public: removeFileParam removes a previously set (by addFileParam) name/value
// pair from the specified file.
SWFUpload.prototype.removeFileParam = function (fileID, name) {
	this.callFlash("RemoveFileParam", [fileID, name]);
};

// Public: setUploadUrl changes the upload_url setting.
SWFUpload.prototype.setUploadURL = function (url) {
	this.settings.upload_url = url.toString();
	this.callFlash("SetUploadURL", [url]);
};

// Public: setPostParams changes the post_params setting
SWFUpload.prototype.setPostParams = function (paramsObject) {
	this.settings.post_params = paramsObject;
	this.callFlash("SetPostParams", [paramsObject]);
};

// Public: addPostParam adds post name/value pair.  Each name can have only one value.
SWFUpload.prototype.addPostParam = function (name, value) {
	this.settings.post_params[name] = value;
	this.callFlash("SetPostParams", [this.settings.post_params]);
};

// Public: removePostParam deletes post name/value pair.
SWFUpload.prototype.removePostParam = function (name) {
	delete this.settings.post_params[name];
	this.callFlash("SetPostParams", [this.settings.post_params]);
};

// Public: setFileTypes changes the file_types setting and the file_types_description setting
SWFUpload.prototype.setFileTypes = function (types, description) {
	this.settings.file_types = types;
	this.settings.file_types_description = description;
	this.callFlash("SetFileTypes", [types, description]);
};

// Public: setFileSizeLimit changes the file_size_limit setting
SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
	this.settings.file_size_limit = fileSizeLimit;
	this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
};

// Public: setFileUploadLimit changes the file_upload_limit setting
SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
	this.settings.file_upload_limit = fileUploadLimit;
	this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
};

// Public: setFileQueueLimit changes the file_queue_limit setting
SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
	this.settings.file_queue_limit = fileQueueLimit;
	this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
};

// Public: setFilePostName changes the file_post_name setting
SWFUpload.prototype.setFilePostName = function (filePostName) {
	this.settings.file_post_name = filePostName;
	this.callFlash("SetFilePostName", [filePostName]);
};

// Public: setUseQueryString changes the use_query_string setting
SWFUpload.prototype.setUseQueryString = function (useQueryString) {
	this.settings.use_query_string = useQueryString;
	this.callFlash("SetUseQueryString", [useQueryString]);
};

// Public: setRequeueOnError changes the requeue_on_error setting
SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
	this.settings.requeue_on_error = requeueOnError;
	this.callFlash("SetRequeueOnError", [requeueOnError]);
};

// Public: setDebugEnabled changes the debug_enabled setting
SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
	this.settings.debug_enabled = debugEnabled;
	this.callFlash("SetDebugEnabled", [debugEnabled]);
};

// Public: setButtonImageURL loads a button image sprite
SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
	if (buttonImageURL == undefined) {
		buttonImageURL = "";
	}
	
	this.settings.button_image_url = buttonImageURL;
	this.callFlash("SetButtonImageURL", [buttonImageURL]);
};

// Public: setButtonDimensions resizes the Flash Movie and button
SWFUpload.prototype.setButtonDimensions = function (width, height) {
	this.settings.button_width = width;
	this.settings.button_height = height;
	
	var movie = this.getMovieElement();
	if (movie != undefined) {
		movie.style.width = width + "px";
		movie.style.height = height + "px";
	}
	
	this.callFlash("SetButtonDimensions", [width, height]);
};
// Public: setButtonText Changes the text overlaid on the button
SWFUpload.prototype.setButtonText = function (html) {
	this.settings.button_text = html;
	this.callFlash("SetButtonText", [html]);
};
// Public: setButtonTextPadding changes the top and left padding of the text overlay
SWFUpload.prototype.setButtonTextPadding = function (left, top) {
	this.settings.button_text_top_padding = top;
	this.settings.button_text_left_padding = left;
	this.callFlash("SetButtonTextPadding", [left, top]);
};

// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
SWFUpload.prototype.setButtonTextStyle = function (css) {
	this.settings.button_text_style = css;
	this.callFlash("SetButtonTextStyle", [css]);
};
// Public: setButtonDisabled disables/enables the button
SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
	this.settings.button_disabled = isDisabled;
	this.callFlash("SetButtonDisabled", [isDisabled]);
};
// Public: setButtonAction sets the action that occurs when the button is clicked
SWFUpload.prototype.setButtonAction = function (buttonAction) {
	this.settings.button_action = buttonAction;
	this.callFlash("SetButtonAction", [buttonAction]);
};

/* *******************************
	Flash Event Interfaces
	These functions are used by Flash to trigger the various
	events.
	
	All these functions a Private.
	
	Because the ExternalInterface library is buggy the event calls
	are added to a queue and the queue then executed by a setTimeout.
	This ensures that events are executed in a determinate order and that
	the ExternalInterface bugs are avoided.
******************************* */

SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
	// Warning: Don't call this.debug inside here or you'll create an infinite loop
	
	if (argumentArray == undefined) {
		argumentArray = [];
	} else if (!(argumentArray instanceof Array)) {
		argumentArray = [argumentArray];
	}
	
	var self = this;
	if (typeof this.settings[handlerName] === "function") {
		// Queue the event
		this.eventQueue.push(function () {
			this.settings[handlerName].apply(this, argumentArray);
		});
		
		// Execute the next queued event
		setTimeout(function () {
			self.executeNextEvent();
		}, 0);
		
	} else if (this.settings[handlerName] !== null) {
		throw "Event handler " + handlerName + " is unknown or is not a function";
	}
};

// Private: Causes the next event in the queue to be executed.  Since events are queued using a setTimeout
// we must queue them in order to garentee that they are executed in order.
SWFUpload.prototype.executeNextEvent = function () {
	// Warning: Don't call this.debug inside here or you'll create an infinite loop

	var  f = this.eventQueue ? this.eventQueue.shift() : null;
	if (typeof(f) === "function") {
		f.apply(this);
	}
};

// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
// properties that contain characters that are not valid for JavaScript identifiers. To work around this
// the Flash Component escapes the parameter names and we must unescape again before passing them along.
SWFUpload.prototype.unescapeFilePostParams = function (file) {
	var reg = /[$]([0-9a-f]{4})/i;
	var unescapedPost = {};
	var uk;

	if (file != undefined) {
		for (var k in file.post) {
			if (file.post.hasOwnProperty(k)) {
				uk = k;
				var match;
				while ((match = reg.exec(uk)) !== null) {
					uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
				}
				unescapedPost[uk] = file.post[k];
			}
		}

		file.post = unescapedPost;
	}

	return file;
};

SWFUpload.prototype.flashReady = function () {
	// Check that the movie element is loaded correctly with its ExternalInterface methods defined
	var movieElement = this.getMovieElement();
	if (typeof movieElement.StartUpload !== "function") {
		throw "ExternalInterface methods failed to initialize.";
	}

	// Fix IE Flash/Form bug
	if (window[this.movieName] == undefined) {
		window[this.movieName] = movieElement;
	}
	
	this.queueEvent("swfupload_loaded_handler");
};


/* This is a chance to do something before the browse window opens */
SWFUpload.prototype.fileDialogStart = function () {
	this.queueEvent("file_dialog_start_handler");
};


/* Called when a file is successfully added to the queue. */
SWFUpload.prototype.fileQueued = function (file) {
	file = this.unescapeFilePostParams(file);
	this.queueEvent("file_queued_handler", file);
};




/* Handle errors that occur when an attempt to queue a file fails. */
SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
	file = this.unescapeFilePostParams(file);
	this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
};

/* Called after the file dialog has closed and the selected files have been queued.
	You could call startUpload here if you want the queued files to begin uploading immediately. */
SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued) {
	this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued]);
};

SWFUpload.prototype.uploadStart = function (file) {
	file = this.unescapeFilePostParams(file);
	this.queueEvent("return_upload_start_handler", file);
};

SWFUpload.prototype.returnUploadStart = function (file) {
	var returnValue;
	if (typeof this.settings.upload_start_handler === "function") {
		file = this.unescapeFilePostParams(file);
		returnValue = this.settings.upload_start_handler.call(this, file);
	} else if (this.settings.upload_start_handler != undefined) {
		throw "upload_start_handler must be a function";
	}

	// Convert undefined to true so if nothing is returned from the upload_start_handler it is
	// interpretted as 'true'.
	if (returnValue === undefined) {
		returnValue = true;
	}
	
	returnValue = !!returnValue;
	
	this.callFlash("ReturnUploadStart", [returnValue]);
};



SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
	file = this.unescapeFilePostParams(file);
	this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
};

/*SWFUpload.prototype.uploadError = function (file, errorCode, message) {
	file = this.unescapeFilePostParams(file);
	this.queueEvent("upload_error_handler", [file, errorCode, message]);
};*/

SWFUpload.prototype.uploadSuccess = function (file, serverData) {
	file = this.unescapeFilePostParams(file);
	this.queueEvent("upload_success_handler", [file, serverData]);
};

SWFUpload.prototype.uploadComplete = function (file) {
	file = this.unescapeFilePostParams(file);
	this.queueEvent("upload_complete_handler", file);
};

/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
   internal debug console.  You can override this event and have messages written where you want. */
SWFUpload.prototype.debug = function (message) {
	this.queueEvent("debug_handler", message);
};


/* **********************************
	Debug Console
	The debug console is a self contained, in page location
	for debug message to be sent.  The Debug Console adds
	itself to the body if necessary.

	The console is automatically scrolled as messages appear.
	
	If you are using your own debug handler or when you deploy to production and
	have debug disabled you can remove these functions to reduce the file size
	and complexity.
********************************** */
   
// Private: debugMessage is the default debug_handler.  If you want to print debug messages
// call the debug() function.  When overriding the function your own function should
// check to see if the debug setting is true before outputting debug information.
SWFUpload.prototype.debugMessage = function (message) {
	if (this.settings.debug) {
		var exceptionMessage, exceptionValues = [];

		// Check for an exception object and print it nicely
		if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
			for (var key in message) {
				if (message.hasOwnProperty(key)) {
					exceptionValues.push(key + ": " + message[key]);
				}
			}
			exceptionMessage = exceptionValues.join("\n") || "";
			exceptionValues = exceptionMessage.split("\n");
			exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
			SWFUpload.Console.writeLine(exceptionMessage);
		} else {
			SWFUpload.Console.writeLine(message);
		}
	}
};

SWFUpload.Console = {};
SWFUpload.Console.writeLine = function (message) {
	var console, documentForm;

	try {
		console = document.getElementById("SWFUpload_Console");

		if (!console) {
			documentForm = document.createElement("form");
			document.getElementsByTagName("body")[0].appendChild(documentForm);

			console = document.createElement("textarea");
			console.id = "SWFUpload_Console";
			console.style.fontFamily = "monospace";
			console.setAttribute("wrap", "off");
			console.wrap = "off";
			console.style.overflow = "auto";
			console.style.width = "700px";
			console.style.height = "350px";
			console.style.margin = "5px";
			documentForm.appendChild(console);
		}

		console.value += message + "\n";

		console.scrollTop = console.scrollHeight - console.clientHeight;
	} catch (ex) {
		alert("Exception: " + ex.name + " Message: " + ex.message);
	}
};



/* ************************************************* UPLOAD QUEUE ***************************************************************************************** */

/* ************************************************* UPLOAD QUEUE ***************************************************************************************** */


var SWFUpload;
if (typeof(SWFUpload) === "function") {
	SWFUpload.queue = {};
	
	SWFUpload.prototype.initSettings = (function (oldInitSettings) {
		return function () {
			if (typeof(oldInitSettings) === "function") {
				oldInitSettings.call(this);
			}
			
			this.customSettings.queue_cancelled_flag = false;
			this.customSettings.queue_upload_count = 0;
			
			this.settings.user_upload_complete_handler = this.settings.upload_complete_handler;
			this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
			
			this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
		};
	})(SWFUpload.prototype.initSettings);

	SWFUpload.prototype.startUpload = function (fileID) {
		this.customSettings.queue_cancelled_flag = false;
		this.callFlash("StartUpload", false, [fileID]);
	};

	SWFUpload.prototype.cancelQueue = function () {
		this.customSettings.queue_cancelled_flag = true;
		this.stopUpload();
		
		var stats = this.getStats();
		while (stats.files_queued > 0) {
			this.cancelUpload();
			stats = this.getStats();
		}
	};
	
	SWFUpload.queue.uploadCompleteHandler = function (file) {
		var user_upload_complete_handler = this.settings.user_upload_complete_handler;
		var continueUpload;
		
		if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
			this.customSettings.queue_upload_count++;
		}

		if (typeof(user_upload_complete_handler) === "function") {
			continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
		} else {
			continueUpload = true;
		}
		
		if (continueUpload) {
			var stats = this.getStats();
			if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) {
				this.startUpload();
			} else if (this.customSettings.queue_cancelled_flag === false) {
				this.queueEvent("queue_complete_handler", [this.customSettings.queue_upload_count]);
				this.customSettings.queue_upload_count = 0;
			} else {
				this.customSettings.queue_cancelled_flag = false;
				this.customSettings.queue_upload_count = 0;
			}
		}
	};
}



/* ************************************************* UPLOAD SETTINGS ***************************************************************************************** */

/* ************************************************* UPLOAD SETTINGS ***************************************************************************************** */

function swfUploadPreLoad() {
try{
	document.getElementById("divSWFUploadUI").style.display = "block";
	document.getElementById("divAlternateContent").style.display = "none";
} catch (ex) {this.debug(ex);}
}
   
function swfUploadLoadFailed() {
try{
	document.getElementById("divSWFUploadUI").style.display = "none";
	document.getElementById("spanNeedsFlash").style.display = "";
} catch (ex) {this.debug(ex);}
}   
   
function fileQueued(file) {
	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setStatus("Pending...");
		progress.toggleCancel(true, this);

	} catch (ex) {
		this.debug(ex);
	}

}

function fileQueueError(file, errorCode, message) {
	try {
		if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
			alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
			return;
		}

		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
		case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
			progress.setStatus("File is too big.");
			this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
			progress.setStatus("Cannot upload Zero Byte files.");
			this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
			progress.setStatus("Invalid File Type.");
			this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		default:
			if (file !== null) {
				progress.setStatus("Unhandled Error");
			}
			this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		}
	} catch (ex) {
        this.debug(ex);
    }
}

function fileDialogComplete(numFilesSelected, numFilesQueued) {
try {
	if (numFilesQueued > 0 || numFilesSelected > 0) {
		document.getElementById("startIMGupload").style.display = "";	
		document.getElementById(this.customSettings.cancelButtonId).style.display = "";
		document.getElementById("btnUpload").style.display = "";
	}
	var stats = this.getStats();
	if (stats.files_queued > 3){
		document.getElementById(this.customSettings.progressTarget).style.overflow = "auto";
		document.getElementById(this.customSettings.progressTarget).style.height = "160px";	
	}
} catch (ex) {this.debug(ex);}
}

function startIMGupl(){
	swfu.startUpload();
}

function uploadStart(file) {
try{
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setStatus("Uploading...");
	progress.toggleCancel(true, this);	
	return true;
} catch (ex) {this.debug(ex);}
}

function uploadProgress(file, bytesLoaded, bytesTotal) {	
try{
	var percent = Math.ceil((bytesLoaded / file.size) * 100);
	var progress = new FileProgress(file,  this.customSettings.progressTarget);
	progress.setProgress(percent);
	if (percent === 100) {
		progress.setStatus("Creating thumbnail...");
		progress.toggleCancel(false, this);
	} else {
		progress.setStatus("Uploading...");
		progress.toggleCancel(true, this);
	}	
} catch (ex) {this.debug(ex);}
}

function uploadSuccess(file, serverData) {
try{
	addImage(serverData);	
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setComplete();
	progress.setStatus("Complete.");
	progress.toggleCancel(false);	
	
	document.getElementById("thumbedit").style.visibility = "visible";
	var stats = this.getStats();
	if (stats.files_queued <4){
		document.getElementById(this.customSettings.progressTarget).style.height = "";	
	}	
	
	new Ajax.Request('../ajax/upd_image_act.php');		
	
} catch (ex) {this.debug(ex);}
}

function uploadError(file, errorCode, message) {
	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
		case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
			progress.setStatus("Upload Error: " + message);
			this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
			progress.setStatus("Upload Failed.");
			this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.IO_ERROR:
			progress.setStatus("Server (IO) Error");
			this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
			progress.setStatus("Security Error");
			this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
			progress.setStatus("Upload limit exceeded.");
			this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
			progress.setStatus("Failed Validation.  Upload skipped.");
			this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
			// If there aren't any files left (they were all cancelled) disable the cancel button
			if (this.getStats().files_queued === 0) {
				document.getElementById(this.customSettings.cancelButtonId).style.display = "none";
				document.getElementById("btnUpload").style.display = "none";
			}
			progress.setStatus("Cancelled");
			progress.setCancelled();
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
			progress.setStatus("Stopped");
			break;
		default:
			progress.setStatus("Unhandled Error: " + errorCode);
			this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		}
	} catch (ex) {
        this.debug(ex);
    }
}

function uploadComplete(file) {
try{
	if (this.getStats().files_queued === 0) {
		document.getElementById(this.customSettings.cancelButtonId).style.display = "none";
		document.getElementById("btnUpload").style.display = "none";
		document.getElementById("thumbbtn").style.display = "";
		if ($('aid').innerHTML != $('aid2').innerHTML){
			upl_images('1',$('gid').innerHTML);}
	}
} catch (ex) {this.debug(ex);}
}

// This event comes from the Queue Plugin
function queueComplete(numFilesUploaded) {
try{
	var status = document.getElementById("divStatus");
	status.innerHTML = numFilesUploaded + " file" + (numFilesUploaded === 1 ? "" : "s") + " uploaded.";
} catch (ex) {this.debug(ex);}
}

var upl_bg_color = "";
var cntIMGs = 0;
function addImage(serverData) {
	var theres = serverData.split("|||");
	var imgdomain = theres[0];
	var src = theres[1];	
	cntIMGs++;
	try{
		if (upl_bg_color==""){upl_bg_color = "progressblue"}else{upl_bg_color = ""};			
		var newImg = document.createElement("div");
		var src1 = imgdomain+"scripts/GD/image.php?" + src;
		var src2 = imgdomain+"scripts/GD/imageL.php?" + src;
		
		newImg.style.backgroundPosition="top center";
		newImg.style.backgroundRepeat="no-repeat";
		newImg.style.backgroundImage="url(../images/loading_img.gif)";
		newImg.innerHTML = "<img src='"+src1+"' /><img src='"+src2+"' width='0' height='0' />";
		newImg.style.height = "105px"; newImg.style.padding = "5px";  newImg.style.textAlign = "center";
		newImg.className = upl_bg_color;
		
		/*var formcon = document.getElementById("addform").innerHTML;*/
		var formdiv = document.createElement("div");
		/*formdiv.innerHTML = formcon;*/	
		formdiv.style.height = "105px"; formdiv.style.padding = "5px";
		formdiv.className = upl_bg_color;
		var lastpos1 = src.lastIndexOf("?")+1; var lastpos2 = src.lastIndexOf(".");
		var newsrc = src.slice(lastpos1,lastpos2);	
		formdiv.id = "form_"+newsrc;
		
		var frmselect = document.createElement("select");
		frmselect.id = "albums_"+newsrc; frmselect.display = "inline";  frmselect.float = "left"; frmselect.style.marginTop = "1px"; 
		var selvals = document.getElementById("addform").innerHTML; var selarr = new Array(); selarr = selvals.split(",");	
		for (i=0;i<selarr.length;i++){	
			var optNew = document.createElement('option');
			optNew.text = selarr[i]; optNew.value = i;
			try {frmselect.add(optNew, null);}
			catch(ex) {frmselect.add(optNew);} //for IE
		}	
	
		formdiv.innerHTML = "<div style='float:left;' class='wid_50 pad_3'>Title:</div><div class='indiv'><input type='text' size='25' id='title_"+newsrc+"' /></div>";
		formdiv.innerHTML+= "<div style='clear:left; float:left;' class='wid_50 pad_3'>Desc:</div><div class='indiv'><textarea  style='height:2.4em;'cols='30' id='desc_"+newsrc+"' /></textarea></div>";
		formdiv.innerHTML+= "<div style='clear:left; float:left;' class='wid_50 pad_3'>Tags:</div><div class='indiv txt10'><input type='text' size='25' id='tags_"+newsrc+"' />&nbsp;(use commas)</div>";
		formdiv.innerHTML+= "<div style='clear:left; float:left;' class='wid_50 pad_3'>Albums:</div>";
	
		var IMGvalues = document.getElementById("IMGvalues");
		IMGvalues.innerHTML = IMGvalues.innerHTML+","+newsrc;
		formdiv.appendChild(frmselect);

		if (cntIMGs==4){
			document.getElementById("thumbbox").style.overflow = "scroll";
			document.getElementById("thumbbox").style.height = "360px";								
		}
		document.getElementById("thumbnails").appendChild(newImg);
		document.getElementById("thumbform").appendChild(formdiv);
		newImg = null;
		IMGvalues = null;
		
	} catch (ex) {this.debug(ex);}
}

function upl_images(act,sect){
	var IMGvalues = document.getElementById("IMGvalues").innerHTML; var imgarr = new Array(); imgarr = IMGvalues.split(",");		
	var params = "g=" + sect + "&ids="+escape(IMGvalues);
	for (i=0;i<imgarr.length;i++){if (imgarr[i]!=""){
		params += "&title_"+i+"="+escape(document.getElementById("title_"+imgarr[i]).value);
		params += "&desc_"+i+"="+escape(document.getElementById("desc_"+imgarr[i]).value);
		params += "&tags_"+i+"="+escape(document.getElementById("tags_"+imgarr[i]).value);
		params += "&albums_"+i+"="+escape(document.getElementById("albums_"+imgarr[i]).options[document.getElementById("albums_"+imgarr[i]).selectedIndex].text);
	}}	
	new Ajax.Request('../ajax/upload_images.php', {
		  method: 'post',
		  parameters: params,
		  onSuccess: function (res){
			//input confirmation message!!!		
			if (act==1){ldpg();loadsb();}
		}
	});	
}


/* ******************************************
 *	FileProgress Object
 *	Control object for displaying file info
 * ****************************************** */

function FileProgress(file, targetID) {
	this.fileProgressID = file.id;

	this.opacity = 100;
	this.height = 0;

	this.fileProgressWrapper = document.getElementById(this.fileProgressID);
	if (!this.fileProgressWrapper) {
		this.fileProgressWrapper = document.createElement("div");
		this.fileProgressWrapper.className = "progressWrapper";
		this.fileProgressWrapper.id = this.fileProgressID;
		this.fileProgressElement = document.createElement("div");
		this.fileProgressElement.className = "progressContainer";

		var progressCancel = document.createElement("a");
		progressCancel.className = "progressCancel";
		progressCancel.href = "#";
		progressCancel.style.visibility = "hidden";
		progressCancel.appendChild(document.createTextNode(" "));

		var progressText = document.createElement("div");
		progressText.className = "progressName";
		progressText.appendChild(document.createTextNode(file.name));

		var progressBar = document.createElement("div");
		progressBar.className = "progressBarInProgress";

		var progressStatus = document.createElement("div");
		progressStatus.className = "progressBarStatus";
		progressStatus.innerHTML = "&nbsp;";

		this.fileProgressElement.appendChild(progressCancel);

		this.fileProgressElement.appendChild(progressText);
		this.fileProgressElement.appendChild(progressStatus);
		this.fileProgressElement.appendChild(progressBar);

		this.fileProgressWrapper.appendChild(this.fileProgressElement);

		document.getElementById(targetID).appendChild(this.fileProgressWrapper);
	} else {
		this.fileProgressElement = this.fileProgressWrapper.firstChild;
	}

	this.height = this.fileProgressWrapper.offsetHeight;
}
FileProgress.prototype.setProgress = function (percentage) {
	this.fileProgressElement.className = "progressContainer progressgreen";
	this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
	this.fileProgressElement.childNodes[3].style.width = percentage + "%";
};
FileProgress.prototype.setComplete = function () {
	this.fileProgressElement.className = "progressContainer progressblue";
	this.fileProgressElement.childNodes[3].className = "progressBarComplete";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	setTimeout(function () {oSelf.disappear();}, 1200);
};
FileProgress.prototype.setError = function () {
	this.fileProgressElement.className = "progressContainer progressred";
	this.fileProgressElement.childNodes[3].className = "progressBarError";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	setTimeout(function () {oSelf.disappear();}, 1000);	
};
FileProgress.prototype.setCancelled = function () {
	this.fileProgressElement.className = "progressContainer";
	this.fileProgressElement.childNodes[3].className = "progressBarError";
	this.fileProgressElement.childNodes[3].style.width = "";

	var oSelf = this;
	setTimeout(function () {oSelf.disappear();}, 1000);
};
FileProgress.prototype.setStatus = function (status) {
	this.fileProgressElement.childNodes[2].innerHTML = status;
};

// Show/Hide the cancel button
FileProgress.prototype.toggleCancel = function (show, swfUploadInstance) {
	this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
	if (swfUploadInstance) {
		var fileID = this.fileProgressID;
		this.fileProgressElement.childNodes[0].onclick = function () {
			swfUploadInstance.cancelUpload(fileID);
			return false;
		};
	}
};

// Fades out and clips away the FileProgress box.
FileProgress.prototype.disappear = function () {

	var reduceOpacityBy = 15;
	var reduceHeightBy = 4;
	var rate = 30;	// 15 fps

	if (this.opacity > 0) {
		this.opacity -= reduceOpacityBy;
		if (this.opacity < 0) {
			this.opacity = 0;
		}

		if (this.fileProgressWrapper.filters) {
			try {
				this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = this.opacity;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";
			}
		} else {
			this.fileProgressWrapper.style.opacity = this.opacity / 100;
		}
	}

	if (this.height > 0) {
		this.height -= reduceHeightBy;
		if (this.height < 0) {
			this.height = 0;
		}

		this.fileProgressWrapper.style.height = this.height + "px";
	}

	if (this.height > 0 || this.opacity > 0) {
		var oSelf = this;
		setTimeout(function () {
			oSelf.disappear();
		}, rate);
	} else {
		this.fileProgressWrapper.style.display = "none";
	}
};





/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;





/* Pushup
 * Copyright (c) 2008 Nick Stakenburg (www.nickstakenburg.com)
 *
 * License: MIT-style license.
 * Website: http://www.pushuptheweb.com
 *
 */

var Pushup = {
  Version: '1.0.3',
  options: {
    appearDelay: .5,
    fadeDelay: 6,
    images: '../scripts/pushup/images/',
    message: 'Important browser update available!\nYour browser is outdated and might not work with this site.',
    reminder: {
      hours: 6,
      message: 'Remind me again in #{hours}'
    },
    skip: true
  },
  updateLinks: {
    IE: 'http://www.microsoft.com/windows/downloads/ie/',
    Firefox: 'http://www.getfirefox.com',
    Safari: 'http://www.apple.com/safari/download/',
    Opera: 'http://www.opera.com/download/'
  },
  Browser: {
    IE: !!(window.attachEvent &&
      navigator.userAgent.indexOf('Opera') === -1),
    Firefox: navigator.userAgent.indexOf('Firefox') > -1,
    Safari: navigator.userAgent.indexOf('AppleWebKit/') > -1 &&
      /Apple/.test(navigator.vendor),
    Opera: navigator.userAgent.indexOf('Opera') > -1
  }
};

Pushup.conditions = {
  IE: (function(agent) {
    var version = /MSIE ([\d.]+)/.exec(agent);
    return version && parseFloat(version[1]) < 7;
  })(navigator.userAgent),
  Firefox: Pushup.Browser.Firefox &&
    parseFloat(navigator.userAgent.match(/Firefox[\/\s](\d+)/)[1]) < 3,
  Safari: Pushup.Browser.Safari &&
    parseFloat(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1]) < 500,
  Opera: Pushup.Browser.Opera && (!window.opera.version ||
    parseFloat(window.opera.version()) < 9.5)
};

(function() {
// find current browser and check if it needs an update
for (var browser in Pushup.Browser)
  if (Pushup.Browser[browser]) Pushup._browserUsed = browser;
Pushup._updateBrowser = Pushup.conditions[Pushup._browserUsed] &&
  Pushup._browserUsed;

// stop if no update is required and we want to skip build
if (!Pushup._updateBrowser && Pushup.options.skip) return;

function Extend(destination, source) {
  for (var property in source)
    destination[property] = source[property];
  return destination;
}

Extend(Pushup, {
  start: function() {
    // get the image directory
    if (/^(https?:\/\/|\/)/.test(this.options.images))
      this.images = this.options.images;
    else {
      var srcMatch = /pushup(?:-[\w\d.]+)?\.js(.*)/,
       scripts = document.getElementsByTagName('script');
      for (var i = 0, l = scripts.length; i < l; i++) {
        var s = scripts[i];
        if (s.src && s.src.match(srcMatch))
          this.images = s.src.replace(srcMatch, '') + this.options.images;
      }
    }
    if (Pushup._updateBrowser) this.show();
  },

  build: function() {
    this.pushup = document.createElement('div');
    Opacity.set(this.pushup, 0);
    this.pushup.id = 'pushup';

    this.messageLink = this.pushup.appendChild(document.createElement('a'));
    this.messageLink.className = 'pushup_messageLink';
    this.messageLink.target = '_blank';

    this.messageLink.appendChild(this.icon = document.createElement('div'));
    this.icon.className = 'pushup_icon';

    this.messageLink.appendChild(this.message = document.createElement('span'));
    this.message.className = 'pushup_message';
    this.message.innerHTML = this.options.message;

    // reminder message if cookies are enabled
    var hours = this.options.reminder.hours;
    if (hours && Pushup.cookiesEnabled) {
      this.pushup.appendChild(this.reminder = document.createElement('a'));
      this.reminder.href = '#';
      this.reminder.className = 'pushup_reminder';
      this.pushup.className = 'withReminder';
      var H = hours + ' hour' + (hours > 1 ? 's' : ''),
       message = this.options.reminder.message.replace('#{hours}', H);
      this.reminder.innerHTML = message;
    }

    // Older Opera doesn't handle float correctly
    if (Pushup.Browser.Opera &&
       (!window.opera.version || parseFloat(window.opera.version()) < 9.25)) {
      this.messageLink.style.cssFloat = 'none';
      this.reminder.style.cssFloat = 'none';
    }

    Pushup.setBrowser(Pushup._updateBrowser);
    document.body.appendChild(this.pushup);
    Pushup.addEvents();
  },

  addEvents: function() {
    if (this.reminder) {
      Event.add(this.reminder, 'click', function(event) {
        Event.stop(event);
        Pushup.setReminder(Pushup.options.reminder.hours);
        Pushup.fade();
      });
    }
    Event.add(this.pushup, 'mouseover', Pushup.clearFade);
    Event.add(this.pushup, 'mouseout', function() {
      Pushup.fade({ delay: Pushup.options.fadeDelay })
    });
  },

  setBrowser: function(browser) {
    browser = browser || 'IE';
    setPngBackground(this.icon, this.images + browser.toLowerCase() + '.png');
    this.messageLink.href = this.updateLinks[browser];
  },

  show: function() {
    // default to IE if no browser was detected
    var browser = typeof arguments[0] == 'string' ?
      arguments[0] : Pushup._browserUsed || 'IE',
     options = arguments[browser ? 1 : 0] || {};

    if (options.resetReminder) Pushup.resetReminder();

    // show if not blocked by cookie
    if (!options.ignoreReminder && Pushup.cookiesEnabled &&
      Cookie.get('_pushupBlocked')) return;

    if (!Pushup.pushup) Pushup.build();
    Opacity.set(Pushup.pushup, 0);
    Pushup.pushup.style.display = 'block';
    if (browser) Pushup.setBrowser(browser);
    this.appear({ fadeAfter: true, delay: Pushup.options.appearDelay });
  },

  appear: function(delay) {
    Pushup.clearFade();
    var options = arguments[0] || {};
    return window.setTimeout(function() {
      Appear(Pushup.pushup, { afterFinish: function() {
        if (options.fadeAfter)
          Pushup.fade({ delay: Pushup.options.fadeDelay });
      }});
    }, (options.delay || 0.01) * 1000);
  },

  clearFade: function() {
    if (Pushup._fadeTimer) {
      window.clearTimeout(Pushup._fadeTimer);
      Pushup._fadeTimer = null;
    }
  },

  fade: function() {
    var options = arguments[0] || {};
    Pushup._fadeTimer = window.setTimeout(function() {
      Fade(Pushup.pushup);
    }, (options.delay || 0.01) * 1000);
  },

  setReminder: function(hours) {
    Cookie.set('_pushupBlocked', 'blocked', { duration: 1 / 24 * hours })
  },

  resetReminder: function() { Cookie.remove('_pushupBlocked') }
});

// Opacity adapted from the Prototype JavaScript framework
// http://www.prototypejs.org
var Opacity = {
  set: function(element, value) {
    element.style.opacity = (value == 1 || value === '') ? '' :
      (value < 0.00001) ? 0 : value;
  },

  get:  function(element) {
    var opacity = element.style.opacity;
    return opacity ? parseFloat(opacity) : 1.0;
  }
};

if (Pushup.Browser.IE) {
  Opacity.get = function(element) {
    var opacity = element.style.opacity;
    if (!opacity && element.currentStyle) opacity = element.currentStyle[opacity];

    if (opacity = (element.style.filter || '').match(/alpha\(opacity=(.*)\)/))
      if (opacity[1]) return parseFloat(opacity[1]) / 100;
    return 1.0;
  };

  Opacity.set = function(element, value) {
    function stripAlpha(filter) {
      return filter.replace(/alpha\([^\)]*\)/gi,'')
    }
    var currentStyle = element.currentStyle;
    if ((currentStyle && !currentStyle.hasLayout) ||
      (!currentStyle && element.style.zoom == 'normal'))
        element.style.zoom = 1;
    var filter = element.style.filter,
     style = element.style;
    if (value == 1 || value === '') (filter = stripAlpha(filter)) ?
      style.filter = filter : style.filter = '';
    else style.filter = stripAlpha(filter) +
      'alpha(opacity=' + (value * 100) + ')';
  };
}

function Appear(element) {
  var current = Opacity.get(element),
   options = arguments[1] || {};
  if (element.style.display != 'block')
    element.style.display = 'block';
  if (current < 1) {
    setTimeout(function() {
      Opacity.set(element, current += 0.05);
      Appear(element, options);
    }, 0.01);
  }
  else {
    if (Pushup.Browser.IE && element.style.filter)
      element.style.removeAttribute('filter');
    if (options.afterFinish) options.afterFinish.call();
  }
}

function Fade(element) {
  var current = Opacity.get(element),
   options = arguments[1] || {};
  if (current > 0) {
    setTimeout(function() {
      Opacity.set(element, current -= 0.05);
      Fade(element, options);
    }, 0.01);
  }
  else {
    element.style.display = 'none';
    if (options.afterFinish) options.afterFinish.call();
  }
}

function setPngBackground(element, url) {
  var options = Extend({
    align: 'top left',
    repeat: 'no-repeat',
    sizingMethod: 'crop',
    backgroundColor: ''
  }, arguments[2] || {});

  Extend(element.style, arguments.callee.IEBelow7 ? {
    filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' +
      url + '\'\', sizingMethod=\'' + options.sizingMethod + '\')'
  } : {
    background: options.backgroundColor + ' url(' + url + ') ' +
      options.align + ' ' + options.repeat
  });
}
setPngBackground.IEBelow7 = Pushup.Browser.IE &&
  parseFloat(/MSIE ([\d.]+)/.exec(navigator.userAgent)[1]) < 7;

// Based on the work of Peter-Paul Koch - http://www.quirksmode.org
var Cookie = {
  set: function(name, value) {
    var expires = '', options = arguments[2] || {};
    if (options.duration) {
      var date = new Date();
      date.setTime(date.getTime() + options.duration * 1000 * 60 * 60 * 24);
      value += '; expires=' + date.toGMTString();
    }
    document.cookie = name + "=" + value + expires + "; path=/";
  },

  remove: function(name) { this.set(name, '', -1) },

  get: function(name) {
    var cookies = document.cookie.split(';'), nameEQ = name + "=";
    for (var i = 0, l = cookies.length; i < l; i++) {
      var c = cookies[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;
  }
};

// check if cookies are enabled
Pushup.cookiesEnabled = (function(test) {
  if (Cookie.get(test)) return true;
  Cookie.set(test, 'test', { duration: 15 });
  return Cookie.get(test);
})('_pushupCookiesEnabled');

var Event = {
  add: function(obj, type, fn) {
    if (obj.attachEvent) {
      obj['e' + type + fn] = fn;
      obj[type + fn] = function(){ obj['e' + type +fn](window.event) };
      obj.attachEvent('on' + type, obj[type + fn]);
    }
    else obj.addEventListener(type, fn, false);
  },

  stop: function(event) {
    if (Pushup.Browser.IE) {
      event.cancelBubble = true;
      event.returnValue = false;
    }
    else {
      event.preventDefault();
      event.stopPropagation();
    }
  }
};

Event.add(window, 'load', function() { Pushup.start() });
})();