//  Lightview 1.0.2 - 15-01-2007

//  Copyright (c) 2007 Nick Stakenburg (http://www.nickstakenburg.com)
//
//  Permission is hereby granted, free of charge, to any person obtaining
//  a copy of this software and associated documentation files (the
//  "Software"), to deal in the Software without restriction, including
//  without limitation the rights to use, copy, modify, merge, publish,
//  distribute, sublicense, and/or sell copies of the Software, and to
//  permit persons to whom the Software is furnished to do so, subject to
//  the following conditions:
//
//  The above copyright notice and this permission notice shall be
//  included in all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
//  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
//  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
//  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

//  More information on this project:
//  http://www.nickstakenburg.com/projects/lightview/

var Lightview = {
  Version: '1.0.2',

  // Configuration
  options: {
    backgroundColor: '#ffffff',                            // Background color of the lightview
    border: 12,                                            // Size of the border
    buttons: { opacity: { normal: 0.65, hover: 1 } },      // Opacity of inner buttons
    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 }
    },
    effects: !!window.Effect,                              // Use effects when available, or true/false
    images: '../images/lightview/',                        // the directory of the images, from this file
    imgNumberTemplate: 'Image #{position} of #{total}',    // Want a different language? change it here
    overlay: { display: true, opacity: 0.8 },              // overlay display and opacity
    radius: 12,                                            // Corner radius of the border
    resizeDuration: 1.0,                                   // When effects are used, the duration of resizing in seconds
    sideDimensions: { width: 16, height: 22 },             // see closeDimensions
    slideshow: { delay: 5 },                               // seconds each image is visible in slideshow
    titleCaptionSplit: '::',                               // The characters you want to split title and caption 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,                                        // Resize large images to screen when they open
    zIndex: 5000                                           // zIndex of #lightview, #overlay is this -1
  }
};

//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}('Q.1i(1V,{5D:"1.6.0",5Y:"1.8.0",2K:[],55:[],y:{19:"4z",4p:"q"},44:7(){3.2N("1a");e(3.k.V){3.2N("4M")}j A=/q(?:-[\\w\\d.]+)?\\.4w/;3.M=(($$("6h 6b[X]").35(7(B){n B.X.5J(A)})||{}).X||"").5C(A,"")+3.k.M;e(1a.2R.3M&&!16.3G.v){16.5j().5c("v\\\\:*","54: 1d(#4T#4O);");16.3G.4L("v","4K:4I-4G-4F:4E")}},2N:7(A){e((4D 3m[A]=="4y")||(3.38(3m[A].4v)<3.38(3["3h"+A]))){6j("1V 6i "+A+" >= "+3["3h"+A])}},38:7(A){j B=A.6f(".");n 3c(B[0])*6a+3c(B[1])*67+3c(B[2])},23:(7(B){j A=9 5S("5Q ([\\\\d.]+)").5O(B);n A?(5N(A[1])<=6.2):2X})(5I.5H),2S:7(){3.1y=3.k.1y;3.L=(3.1y>3.k.L)?3.1y:3.k.L;3.1n=3.k.1n;3.U=3.k.U;3.3J();3.3H();3.3Q()},3J:7(){j G,E,D=3.31(3.U);$(16.2c).i(3.1b=9 f("o",{4g:"1b"}).g({2a:3.k.2a-1}).1f(3.k.1b.1t).u()).i(3.q=9 f("o",{4g:"q"}).g({2a:3.k.2a}).u().i(3.28=9 f("o",{m:"28"}).i(9 f("1K",{m:"4J"}).i(3.3w=9 f("12",{m:"27 1A"}).g(E=Q.1i({1j:-1*3.U.4+"h"},D)).i(3.2g=9 f("o",{m:"3r"}).g(Q.1i({1j:3.U.4+"h"},D)).i(9 f("o",{m:"1h"})))).i(3.3n=9 f("12",{m:"27 S"}).g(Q.1i({30:-1*3.U.4+"h"},D)).i(3.1Z=9 f("o",{m:"3r"}).g(E).i(9 f("o",{m:"1h"}))))).i(9 f("1K",{m:"4x"}).i(9 f("12",{m:"3k W"}).i(G=9 f("o",{m:"4u"}).g({b:3.L+"h"}).i(9 f("1K",{m:"3g T"}).i(9 f("12",{m:"2s"}).i(9 f("o",{m:"3f"})).i(9 f("o",{m:"1W"}).g({T:3.L+"h"})))).i(9 f("o",{m:"4n"})).i(9 f("1K",{m:"3g 3d"}).i(9 f("12",{m:"2s"}).g({1U:-1*3.L+"h"}).i(9 f("o",{m:"3f"})).i(9 f("o",{m:"1W"}).g({T:-1*3.L+"h"})))))).i(9 f("12",{m:"1c"}).i(9 f("o",{m:"6c"}).g({4i:3.L+"h"}).i(9 f("o",{m:"4f"}).g({1U:2*3.L+"h"}).i(3.1c=9 f("o",{m:"66"}).1f(0).g({4c:"0 "+3.L+"h"}).i(3.3b=9 f("o",{m:"3b"}).i(3.3a=9 f("62",{X:3.M+"2F.1T",5V:""}))).i(3.1M=9 f("o",{m:"1M"}).i(3.33=9 f("o",{m:"29"}).g({b:3.k.1n.2o.b+"h",4:3.k.1n.2o.4+"h"}).i(3.3Y=9 f("a",{m:"1h"}).g({1m:"1d("+3.M+"29.1e) W 3d 1R-1w"}).1f(3.k.2b.1t.2U))).i(3.2I=9 f("1K",{m:"2I"}).i(3.2j=9 f("12",{m:"2j"}).i(3.1I=9 f("o",{m:"1I"})).i(3.1P=9 f("o",{m:"1P"}))).i(3.1N=9 f("12",{m:"1N"}).i(9 f("o"))).i(3.1Q=9 f("12",{m:"1Q"}).i(3.1D=9 f("a",{m:"1h"}).1f(3.k.2b.1t.2U).g({1m:"1d("+3.M+"2Q.1e) W T 1R-1w"})))))))).i(3.15=9 f("12",{m:"15"}).i(9 f("o",{m:"1h"}).g({1m:"1d("+3.M+"15.1T) W T 1R-1w"})))).i(3.2P=9 f("12",{m:"2P"}).g({1U:3.L+"h",1m:"1d("+3.M+"2F.1T) W T 1w"}).i(3.2l=9 f("o",{m:"1A 1h"})).i(3.2m=9 f("o",{m:"S 1h"}))).i(9 f("12",{m:"3k 4i"}).i(G.5x(1O))))));j H=9 1B();H.Z=7(){H.Z=1a.1x;j J={4:H.4+"h",b:H.b+"h"},C;3.U={4:H.4,b:H.b};3.3w.g(C=Q.1i({1j:-1*3.U.4+"h"},J));3.2g.g(Q.1i({1j:3.U.4+"h"},J));3.3n.g(Q.1i({30:-1*3.U.4+"h"},J));3.1Z.g(C)}.r(3);H.X=3.M+"1A.3C";e(3.23){$$("5o, 2c").1E("g",{4:"36%",b:"36%"});3.1b.g({19:"3Z"})}3.q.1v(".1I",".1P",".1N").1E("g",{1l:3.k.1l});j F=3.28.1v(".3f");$w("5d 5b 59 58").10(7(K,C){j J=(3.k.1y>0)?3.3A(K):9 f("o",{m:"1W"});F[C].g({4:3.L+"h",b:3.L+"h"}).50(K).i(J)}.r(3));3.q.1v(".4n",".1W",".4f").1E("g",{1l:3.k.1l});$w("1A S").10(7(J){j C=3.M+J+".3C";3[J+"4t"].27=J;3[J+"2H"].g(!3.23?{1m:"1d("+C+")"}:{4W:"4V:4U.4S.4R(X=\'"+C+"\'\', 4Q=\'4P\')"})}.r(3));j I={};$w("2o 2G").10(7(C){I[C]=9 1B();I[C].Z=7(){I[C].Z=1a.1x;3.1n[C]={4:I[C].4,b:I[C].b}}.r(3);I[C].X=3.M+"29"+((C=="2G")?"4N.1e":".1e")}.r(3));j B=9 1B();B.Z=7(){B.Z=1a.1x;3.15.g({4:B.4+"h",b:B.b+"h",1U:-0.5*B.b+"h",1j:-0.5*B.4+"h"})}.r(3);B.X=3.M+"15.1T";j A=9 1B();A.Z=7(){A.Z=1a.1x;3.1D.g({4:A.4+"h",b:A.b+"h"})}.r(3);A.X=3.M+"2Q.1e"},z:7(A){3.N=Q.3x(A)?3.O[A]:$(A);e(!3.N.18){n}3.1k=(3.N.11.3v()=="q");3.N.4H();3.14=Y;e(3.k.V){P.26.2i("q").10(7(D){D.3u()})}3.O=(3.1k)?[3.N]:3.2E(3.N.11).O;3.19=3.O.22(3.N);3.3t();3.17=3.21(3.N.18);3.2D();3.3s();3.2C();3.3q();3.3o();j C="4C"+(3.k.V?"P":"4B");e(!3.17){3.3V();j B=9 1B();B.Z=7(){B.Z=1a.1x;3.2B();3.17={4:B.4,b:B.b};3[C]()}.r(3);B.X=3.N.18}R{3[C]()}},4A:7(){9 P.1S({y:3.y,1F:7(){3.3l()}.r(3)})},3l:7(){3.2B();3.2n(3.17);3.2y(3.k.V?3.N.18:3.M+"2F.1T");3.32();3.3j();3.3i();3.47();e(3.k.V){9 P.1S({y:3.y,1F:7(){3.2w()}.r(3)});e(3.1o){9 P.1S({y:3.y,1F:7(){3.2v()}.r(3)})}}R{3.2w();e(3.1o){3.2v()}}},1H:7(){3.z(3.1G().1H)},S:7(){3.z(3.1G().S)},3i:7(){j B=3.2u(),D=3.2t();e(3.k.2p&&(B.4>D.4||B.b>D.b)){j E=Q.4s(3.4r()),A=D,C=Q.4s(E);e(C.4>A.4){C.b*=A.4/C.4;C.4=A.4;e(C.b>A.b){C.4*=A.b/C.b;C.b=A.b}}R{e(C.b>A.b){C.4*=A.b/C.b;C.b=A.b;e(C.4>A.4){C.b*=A.4/C.4;C.4=A.4}}}j F=(C.4%1>0?C.b/E.b:C.b%1>0?C.4/E.4:1);3.14={4:(3.17.4*F).4q(),b:(3.17.b*F).4q()};3.2n(3.14);3.32();B={4:3.14.4,b:3.14.b+3.3e.b}}R{3.2n(3.17);3.14=Y}3.4o(B)},4o:7(F){j C=3.q.1Y(),B=2*3.L,E=F.4+B,A=F.b+B;e(C.4==F.4&&C.b==F.b){n}j D={4:E+"h",b:A+"h"};e(!3.23){Q.1i(D,{1j:0-E/2+"h",1U:0-A/2+"h"})}e(3.k.V){3.2r=9 P.4m(3.q,{4l:D,1q:3.k.6d,y:3.y,4k:3.k.4k,1F:7(){3.2r=Y}.r(3)})}R{3.q.g(D)}},47:7(){e(3.k.V){9 P.4j(3.1c,{1q:0.5,2q:0,2e:1,y:3.y,1F:1S.2z.r(3,3.N,"q:4h")})}R{3.2y(3.N.18);3.1c.1f(1);$(3.N).2z("q:4h")}},3q:7(){3.2C();e(3.k.V&&3.q.1p()){9 P.4j(3.1c,{1q:0.24,2q:1,2e:0,y:3.y})}R{3.1c.1f(0)}},2n:7(D){j C=3.31(D);3.2P.g({b:D.b+"h"});3.3b.g(C);3.3a.g(C);j B=3.U.4;j A=(D.4/2-1)+B+3.L;3.2l.g({4:A+"h",1j:-1*B+"h"});3.2m.g({4:A+"h",30:-1*B+"h"})},2y:7(A){3.3a.X=A},32:7(){3.2j.u();3.1I.u();3.1P.u();3.1N.u();3.1Q.u();j C=3.N.68("1I"),A=Y,B=C&&C.22(3.k.4e)?C.22(3.k.4e):Y;e(C&&B>-1){A=C.4d(B+2).3p();C=C.4d(0,B).3p()}e(C||A){3.2j.z()}e(C){3.1I.2A(C).z()}e(A){3.1P.2A(A).z()}e(3.O.1J>1){3.1N.z().4a().2A(9 65(3.k.64).48({19:3.19+1,5Z:3.O.1J}));3.1Q.z();3.1D.z()}3.46=3.3y();3.3e=3.45()},3y:7(){j E=3.1n.2G.4,D=3.1n.2o.4,A=3.14?3.14.4:3.17.4,F=5W,C=0,B=3.k.5U;e(A>=F+E&&A<F+D){B="1d("+3.M+"5T.1e)";C=E}R{e(A>=F+D){B="1d("+3.M+"29.1e)";C=D}}e(C>0){3.33.g({4:C+"h"}).z()}R{3.33.u()}n C},3V:7(){e(3.k.V){3.34=9 P.43(3.15,{1q:0.2,2q:0,2e:1,y:3.y})}R{3.15.z()}},2B:7(){e(!3.15.1p()){n}e(3.k.V){e(3.34){P.26.2i("q").42(3.34)}9 P.5R(3.15,{1q:1,y:3.y})}R{3.15.u()}},2w:7(){j B=(3.19!=0?"z":"u"),A=(!3.1k&&3.1G().S!=0?"z":"u");3.2l[B]();3.2m[A]();3.2g[B]();3.1Z[A]()},2C:7(){3.2l.u();3.2m.u();3.2g.u();3.1Z.u()},3o:7(){e(3.q.1p()){n}e(3.k.V){9 P.43(3.1b,{1q:0.6,2q:0,2e:3.k.1b.1t,y:3.y,1F:f.z.r(3,3.q)})}R{3.q.z();3.1b.z()}},u:7(){e(!3.1b.1p()){n}e(3.k.V){P.26.2i("q").10(7(A){A.3u()})}3.1s();3.q.u();3.1c.1f(0);3.1b.u();3.2D();3.40();$(3.N).2z("q:1u");3.N=Y;3.O=Y;3.5P=Y;3.14=Y},45:7(){j C={},B=3.14?3.14.4:3.17.4,D=3.q.3z("1L"),A=3.1c.3z("1L");3.1M.g({4:B+"h"});3.2I.g({4:B-3.46-1+"h"});3.1c.g({1r:"1u"}).z();3.q.g({1r:"1u"}).z();C=3.1M.1Y();3.q.g({1r:"1p",1L:D});3.1c.g({1r:"1p",1L:A});3.1M.g({4:"36%"});n C},3X:7(){3.1s();3.1o=1O;3.S.r(3).2Z(0.25);3.1D.g({1m:"1d("+3.M+"5M.1e) W T 1R-1w"}).u()},1s:7(){e(3.1o){3.1o=2X}e(3.2Y){5L(3.2Y)}3.1D.g({1m:"1d("+3.M+"2Q.1e) W T 1R-1w"})},3U:7(){3[(3.1o?"2W":"2S")+"5K"]()},2v:7(){e(3.1o){3.2Y=3.S.r(3).2Z(3.k.1Q.2Z)}},3j:7(){3.2k=3.3T.1g(3);16.13("3S",3.2k)},2D:7(){e(3.2k){16.3R("3S",3.2k)}},3T:7(B){B.2W();j A=5G.5F(B.2h).3v(),C=(B.2h==1S.5B||["x","c"].3P(A))?"u":(B.2h==37&&!3.1k&&!3.2r&&3.19!=0)?"1H":(B.2h==39&&!3.1k&&!3.2r&&3.1G().S!=0)?"S":(A=="p"&&!3.1k)?"3X":(A=="s"&&!3.1k)?"1s":Y;e(A!="s"){3.1s()}e(C){3[C]()}},3H:7(){3.2J=[];j A=$$("a[11^=q]");A.1E("3R","1z");A.10(7(B){B.13("1z",3.z.5A(B).2s(7(E,D){D.2W();E(D)}).1g(3)).13("2f",3.3N.r(3,B));j C=A.5z(7(D){n D.11==B.11});e(C[0].1J){3.2J.2L({11:B.11,O:C[0]});A=C[1]}}.r(3))},2E:7(A){n 3.2J.35(7(B){n B.11==A})},3Q:7(){$(16.2c).13("1z",3.3L.1g(3));$w("1A S").10(7(A){3[A+"4t"].13("2f",3.2O.1g(3)).13("3K",3.2O.1g(3)).13("1z",3[A=="S"?A:"1H"].2s(7(C,B){3.1s();C(B)}).1g(3))}.r(3));3.28.1v("a.1h").10(7(A){A.13("2f",f.1f.r(3,A,3.k.2b.1t.5y)).13("3K",f.1f.r(3,A,3.k.2b.1t.2U))}.r(3));3.3Y.13("1z",3.u.1g(3));3.1D.13("1z",3.3U.1g(3))},3L:7(B){j A=[3.1b,3.T,3.3d,3.15.4a()];e(1a.2R.3M){A.2L(3.5w)}e(B.3I&&A.5v(B.3I)){3.u()}},3N:7(A){e(A.3O||!A.11||3.21(A.11)){n}3.2M(A)},3t:7(){e(3.O.1J==0){n}2T=3.1G();3.2M([2T.S,2T.1H])},2M:7(C){j B=(3.O&&3.O.3P(C)||Q.5u(C))?3.O:C.11?3.2E(C.11).O:Y;e(!B){n}j A=$A(Q.3x(C)?[C]:Q.5t($(C))?[B.22(C)]:C).5s();A.10(7(F){j G=B[F],E=G.18;e(G.5r||!E||3.21(E)){n}j D=9 1B();D.Z=7(){D.Z=1a.1x;3.2K.2L({18:E,4:D.4,b:D.b});$$("a[18]").5q(7(H){n H.18==E}).10(7(H){H.3O=1O})}.r(3);D.X=E}.r(3))},21:7(A){j B=3.2K.35(7(C){n C.18==A});n B?{4:B.4,b:B.b}:Y},2O:7(E){j C=E.N(),B=C.27,A=3.U.4,F=(E.5E=="2f")?0:B=="1A"?A:-1*A,D={1j:F+"h"};e(3.k.V){e(!3.1X){3.1X={}}e(3.1X[B]){P.26.2i("3F"+B).42(3.1X[B])}3.1X[B]=9 P.4m(3[B+"2H"],{4l:D,1q:0.2,y:{4p:"3F"+B,5p:1}})}R{3[B+"2H"].g(D)}},1G:7(){e(!3.O){n}j D=3.19,C=3.O.1J;j B=(D<=0)?C-1:D-1,A=(D>=C-1)?0:D+1;n{1H:B,S:A}},3A:7(C){j D,A=3.1y,B=3.L,F=9 f("3E"),E={W:(C.3D(0)=="t"),T:(C.3D(1)=="l")};e(F&&F.2V&&F.2V("2d")){D=9 f("3E",{4:B+"h",b:B+"h",3W:"1u"}),1C=D.2V("2d");1C.5n=3.k.1l;1C.5m((E.T?A:B-A),(E.W?A:B-A),A,0,5l.5k*2,1O);1C.1W();1C.41((E.T?A:0),0,B-A,B);1C.41(0,(E.W?A:0),B,B-A)}R{D=9 f("o").g({4:B+"h",b:B+"h",5i:0,4c:0,1L:"5h",19:"5g",3W:"1u"});D.i(9 f("v:5X",{5f:3.k.1l,5e:"60",61:3.k.1l,5a:(A/B*0.5).63(2)}).g({4:2*B-1+"h",b:2*B-1+"h",19:"3Z",T:(E.T?0:(-1*B))+"h",W:(E.W?0:(-1*B))+"h"}))}n D},3s:7(){e(3.2x){n}$$("1v","4b","49").1E("g",{1r:"1u"});3.2x=1O},40:7(){$$("1v","4b","49").1E("g",{1r:"1p"});3.2x=2X},2p:{1Y:7(){j A={};j C=1a.2R;$w("4 b").10(7(E){j B=E.57();A[E]=(C.56&&!16.48)?69["53"+B]:(C.52)?16.2c["3B"+B]:16.51["3B"+B]});n A}},31:7(A){j B={};Q.4Z(A).10(7(C){B[C]=A[C]+"h"});n B},6e:7(){j E=3.k.4Y,D=2*3.L+3.U.4,A=D+E,C=3.2p.1Y();j B=3.6g(),F=3.2t(),G={4:B.4+E,b:B.b+E};n(G.4<=F.4||G.b<=F.b)},2u:7(){n{4:3.17.4,b:3.17.b+3.3e.b}},4r:7(){j B=3.2u(),A=2*3.L;n{4:B.4+A,b:B.b+A}},2t:7(){j C=20,A=2*3.U.b+C,B=3.2p.1Y();n{4:B.4-A,b:B.b-A}}});1V.44();16.13("4X:6k",1V.2S.r(1V));',62,393,'|||this|width|||function||new||height|||if|Element|setStyle|px|insert|var|options||className|return|div||lightview|bind|||hide||||queue|show||||||||||||border|images|element|elements|Effect|Object|else|next|left|sideDimensions|effects|top|src|null|onload|each|rel|li|observe|scaledImageDimensions|loading|document|imageDimensions|href|position|Prototype|overlay|center|url|jpg|setOpacity|bindAsEventListener|button|extend|marginLeft|noset|backgroundColor|background|closeDimensions|sliding|visible|duration|visibility|stopSlideshow|opacity|hidden|select|repeat|emptyFunction|radius|click|prev|Image|ctx|slideshowButton|invoke|afterFinish|getSurroundingIndexes|previous|title|length|ul|display|dataContainer|imgNumber|true|caption|slideshow|no|Event|gif|marginTop|Lightview|fill|sideEffect|getDimensions|nextButtonImage||getPreloadedImageDimensions|indexOf|fixIE|||Queues|side|container|close|zIndex|buttons|body||to|mouseover|prevButtonImage|keyCode|get|imgText|keyboardEvent|prevButton|nextButton|resizeImage|large|viewport|from|resizing|wrap|getBounds|getInnerDimensions|nextSlide|showButtons|preventingOverlap|setImage|fire|update|stopLoading|hideButtons|disableKeyboardNavigation|getSet|blank|small|ButtonImage|data|sets|preloadedImages|push|preloadFromSet|require|toggleSideButton|prevnext|slideshow_play|Browser|start|surrounding|normal|getContext|stop|false|slideTimer|delay|marginRight|pixelClone|fillData|closeWrapper|loadingEffect|find|100||convertVersionString||image|imageWrapper|parseInt|right|dataDimensions|corner|half|REQUIRED_|resizeWithinViewport|enableKeyboardNavigation|frame|afterShow|window|nextSide|appear|strip|hideContent|wrapper|hideOverlapping|preloadSurroundingImages|cancel|toLowerCase|prevSide|isNumber|setCloseButton|getStyle|createCorner|client|png|charAt|canvas|lightview_side|namespaces|updateViews|target|build|mouseout|bodyClick|IE|preloadImageHover|_lightviewPreloaded|member|addObservers|stopObserving|keydown|keyboardDown|toggleSlideshow|startLoading|overflow|startSlideshow|closeButton|absolute|showOverlapping|fillRect|remove|Appear|load|setDataDimensions|closeButtonWidth|showContent|evaluate|object|down|embed|padding|substr|titleCaptionSplit|wrapdown|id|opened|bottom|Opacity|transition|style|Morph|filler|resize|scope|round|getOuterDimensions|clone|Button|liquid|Version|js|frames|undefined|end|afterEffect|Show|after|typeof|vml|com|microsoft|blur|schemas|sideButtons|urn|add|Scriptaculous|_small|VML|scale|sizingMethod|AlphaImageLoader|Microsoft|default|DXImageTransform|progid|filter|dom|viewportPadding|keys|addClassName|documentElement|Opera|inner|behavior|preloadedData|WebKit|capitalize|br|bl|arcSize|tr|addRule|tl|strokeWeight|fillcolor|relative|block|margin|createStyleSheet|PI|Math|arc|fillStyle|html|limit|findAll|_lightboxPreloaded|uniq|isElement|isArray|include|closeable|cloneNode|hover|partition|curry|KEY_ESC|replace|REQUIRED_Prototype|type|fromCharCode|String|userAgent|navigator|match|Slideshow|clearTimeout|slideshow_stop|parseFloat|exec|set|MSIE|Fade|RegExp|close_small|borderColor|alt|180|roundrect|REQUIRED_Scriptaculous|total|1px|strokeColor|img|toFixed|imgNumberTemplate|Template|wrapcenter|1000|getAttribute|self|100000|script|wrapup|resizeDuration|fitsWithinViewport|split|getInnerSize|head|requires|throw|loaded'.split('|'),0,{}));

Object.extend(Lightview, {
    REQUIRED_Prototype: "1.6.0",
    REQUIRED_Scriptaculous: "1.8.0",
    preloadedImages: [],
    preloadedData: [],
    queue: {
        position: "end",
        scope: "lightview"
    },
    load: function () {
        this.require("Prototype");
        if (this.options.effects) {
            this.require("Scriptaculous")
        }
        var A = /lightview(?:-[\w\d.]+)?\.js/;
        this.images = (($$("head script[src]").find(function (B) {
            return B.src.match(A)
        }) || {}).src || "").replace(A, "") + this.options.images;
        if (Prototype.Browser.IE && !document.namespaces.v) {
            document.createStyleSheet().addRule("v\\:*", "behavior: url(#default#VML);");
            document.namespaces.add("v", "urn:schemas-microsoft-com:vml")
        }
    },
    require: function (A) {
        if ((typeof window[A] == "undefined") || (this.convertVersionString(window[A].Version) < this.convertVersionString(this["REQUIRED_" + A]))) {
            throw ("Lightview requires " + A + " >= " + this["REQUIRED_" + A])
        }
    },
    convertVersionString: function (A) {
        var B = A.split(".");
        return parseInt(B[0]) * 100000 + parseInt(B[1]) * 1000 + parseInt(B[2])
    },
    fixIE: (function (B) {
        var A = new RegExp("MSIE ([\\d.]+)").exec(B);
        return A ? (parseFloat(A[1]) <= 6.2) : false
    })(navigator.userAgent),
    start: function () {
        this.radius = this.options.radius;
        this.border = (this.radius > this.options.border) ? this.radius : this.options.border;
        this.closeDimensions = this.options.closeDimensions;
        this.sideDimensions = this.options.sideDimensions;
        this.build();
        this.updateViews();
        this.addObservers()
    },
    build: function () {
        var G, E, D = this.pixelClone(this.sideDimensions);
        $(document.body).insert(this.overlay = new Element("div", {
            id: "overlay"
        }).setStyle({
            zIndex: this.options.zIndex - 1
        }).setOpacity(this.options.overlay.opacity).hide()).insert(this.lightview = new Element("div", {
            id: "lightview"
        }).setStyle({
            zIndex: this.options.zIndex
        }).hide().insert(this.container = new Element("div", {
            className: "container"
        }).insert(new Element("ul", {
            className: "sideButtons"
        }).insert(this.prevSide = new Element("li", {
            className: "side prev"
        }).setStyle(E = Object.extend({
            marginLeft: -1 * this.sideDimensions.width + "px"
        }, D)).insert(this.prevButtonImage = new Element("div", {
            className: "wrapper"
        }).setStyle(Object.extend({
            marginLeft: this.sideDimensions.width + "px"
        }, D)).insert(new Element("div", {
            className: "button"
        })))).insert(this.nextSide = new Element("li", {
            className: "side next"
        }).setStyle(Object.extend({
            marginRight: -1 * this.sideDimensions.width + "px"
        }, D)).insert(this.nextButtonImage = new Element("div", {
            className: "wrapper"
        }).setStyle(E).insert(new Element("div", {
            className: "button"
        }))))).insert(new Element("ul", {
            className: "frames"
        }).insert(new Element("li", {
            className: "frame top"
        }).insert(G = new Element("div", {
            className: "liquid"
        }).setStyle({
            height: this.border + "px"
        }).insert(new Element("ul", {
            className: "half left"
        }).insert(new Element("li", {
            className: "wrap"
        }).insert(new Element("div", {
            className: "corner"
        })).insert(new Element("div", {
            className: "fill"
        }).setStyle({
            left: this.border + "px"
        })))).insert(new Element("div", {
            className: "filler"
        })).insert(new Element("ul", {
            className: "half right"
        }).insert(new Element("li", {
            className: "wrap"
        }).setStyle({
            marginTop: -1 * this.border + "px"
        }).insert(new Element("div", {
            className: "corner"
        })).insert(new Element("div", {
            className: "fill"
        }).setStyle({
            left: -1 * this.border + "px"
        })))))).insert(new Element("li", {
            className: "center"
        }).insert(new Element("div", {
            className: "wrapup"
        }).setStyle({
            bottom: this.border + "px"
        }).insert(new Element("div", {
            className: "wrapdown"
        }).setStyle({
            marginTop: 2 * this.border + "px"
        }).insert(this.center = new Element("div", {
            className: "wrapcenter"
        }).setOpacity(0).setStyle({
            padding: "0 " + this.border + "px"
        }).insert(this.imageWrapper = new Element("div", {
            className: "imageWrapper"
        }).insert(this.image = new Element("img", {
            src: this.images + "blank.gif",
            alt: ""
        }))).insert(this.dataContainer = new Element("div", {
            className: "dataContainer"
        }).insert(this.closeWrapper = new Element("div", {
            className: "close"
        }).setStyle({
            height: this.options.closeDimensions.large.height + "px",
            width: this.options.closeDimensions.large.width + "px"
        }).insert(this.closeButton = new Element("a", {
            className: "button"
        }).setStyle({
            background: "url(" + this.images + "close.jpg) top right no-repeat"
        }).setOpacity(this.options.buttons.opacity.normal))).insert(this.data = new Element("ul", {
            className: "data"
        }).insert(this.imgText = new Element("li", {
            className: "imgText"
        }).insert(this.title = new Element("div", {
            className: "title"
        })).insert(this.caption = new Element("div", {
            className: "caption"
        }))).insert(this.imgNumber = new Element("li", {
            className: "imgNumber"
        }).insert(new Element("div"))).insert(this.slideshow = new Element("li", {
            className: "slideshow"
        }).insert(this.slideshowButton = new Element("a", {
            className: "button"
        }).setOpacity(this.options.buttons.opacity.normal).setStyle({
            background: "url(" + this.images + "slideshow_play.jpg) top left no-repeat"
        })))))))).insert(this.loading = new Element("li", {
            className: "loading"
        }).insert(new Element("div", {
            className: "button"
        }).setStyle({
            background: "url(" + this.images + "loading.gif) top left no-repeat"
        })))).insert(this.prevnext = new Element("li", {
            className: "prevnext"
        }).setStyle({
            marginTop: this.border + "px",
            background: "url(" + this.images + "blank.gif) top left repeat"
        }).insert(this.prevButton = new Element("div", {
            className: "prev button"
        })).insert(this.nextButton = new Element("div", {
            className: "next button"
        }))).insert(new Element("li", {
            className: "frame bottom"
        }).insert(G.cloneNode(true))))));
        var H = new Image();
        H.onload = function () {
            H.onload = Prototype.emptyFunction;
            var J = {
                width: H.width + "px",
                height: H.height + "px"
            },
                C;
            this.sideDimensions = {
                width: H.width,
                height: H.height
            };
            this.prevSide.setStyle(C = Object.extend({
                marginLeft: -1 * this.sideDimensions.width + "px"
            }, J));
            this.prevButtonImage.setStyle(Object.extend({
                marginLeft: this.sideDimensions.width + "px"
            }, J));
            this.nextSide.setStyle(Object.extend({
                marginRight: -1 * this.sideDimensions.width + "px"
            }, J));
            this.nextButtonImage.setStyle(C)
        }.bind(this);
        H.src = this.images + "prev.png";
        if (this.fixIE) {
            $$("html, body").invoke("setStyle", {
                width: "100%",
                height: "100%"
            });
            this.overlay.setStyle({
                position: "absolute"
            })
        }
        this.lightview.select(".title", ".caption", ".imgNumber").invoke("setStyle", {
            backgroundColor: this.options.backgroundColor
        });
        var F = this.container.select(".corner");
        $w("tl tr bl br").each(function (K, C) {
            var J = (this.options.radius > 0) ? this.createCorner(K) : new Element("div", {
                className: "fill"
            });
            F[C].setStyle({
                width: this.border + "px",
                height: this.border + "px"
            }).addClassName(K).insert(J)
        }.bind(this));
        this.lightview.select(".filler", ".fill", ".wrapdown").invoke("setStyle", {
            backgroundColor: this.options.backgroundColor
        });
        $w("prev next").each(function (J) {
            var C = this.images + J + ".png";
            this[J + "Button"].side = J;
            this[J + "ButtonImage"].setStyle(!this.fixIE ? {
                background: "url(" + C + ")"
            } : {
                filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + C + "'', sizingMethod='scale')"
            })
        }.bind(this));
        var I = {};
        $w("large small").each(function (C) {
            I[C] = new Image();
            I[C].onload = function () {
                I[C].onload = Prototype.emptyFunction;
                this.closeDimensions[C] = {
                    width: I[C].width,
                    height: I[C].height
                }
            }.bind(this);
            I[C].src = this.images + "close" + ((C == "small") ? "_small.jpg" : ".jpg")
        }.bind(this));
        var B = new Image();
        B.onload = function () {
            B.onload = Prototype.emptyFunction;
            this.loading.setStyle({
                width: B.width + "px",
                height: B.height + "px",
                marginTop: -0.5 * B.height + "px",
                marginLeft: -0.5 * B.width + "px"
            })
        }.bind(this);
        B.src = this.images + "loading.gif";
        var A = new Image();
        A.onload = function () {
            A.onload = Prototype.emptyFunction;
            this.slideshowButton.setStyle({
                width: A.width + "px",
                height: A.height + "px"
            })
        }.bind(this);
        A.src = this.images + "slideshow_play.jpg"
    },
    show: function (A) {
        this.element = Object.isNumber(A) ? this.elements[A] : $(A);
        if (!this.element.href) {
            return
        }
        this.noset = (this.element.rel.toLowerCase() == "lightview");
        this.element.blur();
        this.scaledImageDimensions = null;
        if (this.options.effects) {
            Effect.Queues.get("lightview").each(function (D) {
                D.cancel()
            })
        }
        this.elements = (this.noset) ? [this.element] : this.getSet(this.element.rel).elements;
        this.position = this.elements.indexOf(this.element);
        this.preloadSurroundingImages();
        this.imageDimensions = this.getPreloadedImageDimensions(this.element.href);
        this.disableKeyboardNavigation();
        this.hideOverlapping();
        this.hideButtons();
        this.hideContent();
        this.appear();
        var C = "after" + (this.options.effects ? "Effect" : "Show");
        if (!this.imageDimensions) {
            this.startLoading();
            var B = new Image();
            B.onload = function () {
                B.onload = Prototype.emptyFunction;
                this.stopLoading();
                this.imageDimensions = {
                    width: B.width,
                    height: B.height
                };
                this[C]()
            }.bind(this);
            B.src = this.element.href
        } else {
            this[C]()
        }
    },
    afterEffect: function () {
        new Effect.Event({
            queue: this.queue,
            afterFinish: function () {
                this.afterShow()
            }.bind(this)
        })
    },
    afterShow: function () {
        this.stopLoading();
        this.resizeImage(this.imageDimensions);
        this.setImage(this.options.effects ? this.element.href : this.images + "blank.gif");
        this.fillData();
        this.enableKeyboardNavigation();
        this.resizeWithinViewport();
        this.showContent();
        if (this.options.effects) {
            new Effect.Event({
                queue: this.queue,
                afterFinish: function () {
                    this.showButtons()
                }.bind(this)
            });
            if (this.sliding) {
                new Effect.Event({
                    queue: this.queue,
                    afterFinish: function () {
                        this.nextSlide()
                    }.bind(this)
                })
            }
        } else {
            this.showButtons();
            if (this.sliding) {
                this.nextSlide()
            }
        }
    },
    previous: function () {
        this.show(this.getSurroundingIndexes().previous)
    },
    next: function () {
        this.show(this.getSurroundingIndexes().next)
    },
    resizeWithinViewport: function () {
        var B = this.getInnerDimensions(),
            D = this.getBounds();
        if (this.options.viewport && (B.width > D.width || B.height > D.height)) {
            var E = Object.clone(this.getOuterDimensions()),
                A = D,
                C = Object.clone(E);
            if (C.width > A.width) {
                C.height *= A.width / C.width;
                C.width = A.width;
                if (C.height > A.height) {
                    C.width *= A.height / C.height;
                    C.height = A.height
                }
            } else {
                if (C.height > A.height) {
                    C.width *= A.height / C.height;
                    C.height = A.height;
                    if (C.width > A.width) {
                        C.height *= A.width / C.width;
                        C.width = A.width
                    }
                }
            }
            var F = (C.width % 1 > 0 ? C.height / E.height : C.height % 1 > 0 ? C.width / E.width : 1);
            this.scaledImageDimensions = {
                width: (this.imageDimensions.width * F).round(),
                height: (this.imageDimensions.height * F).round()
            };
            this.resizeImage(this.scaledImageDimensions);
            this.fillData();
            B = {
                width: this.scaledImageDimensions.width,
                height: this.scaledImageDimensions.height + this.dataDimensions.height
            }
        } else {
            this.resizeImage(this.imageDimensions);
            this.scaledImageDimensions = null
        }
        this.resize(B)
    },
    resize: function (F) {
        var C = this.lightview.getDimensions(),
            B = 2 * this.border,
            E = F.width + B,
            A = F.height + B;
        if (C.width == F.width && C.height == F.height) {
            return
        }
        var D = {
            width: E + "px",
            height: A + "px"
        };
        if (!this.fixIE) {
            Object.extend(D, {
                marginLeft: 0 - E / 2 + "px",
                marginTop: 0 - A / 2 + "px"
            })
        }
        if (this.options.effects) {
            this.resizing = new Effect.Morph(this.lightview, {
                style: D,
                duration: this.options.resizeDuration,
                queue: this.queue,
                transition: this.options.transition,
                afterFinish: function () {
                    this.resizing = null
                }.bind(this)
            })
        } else {
            this.lightview.setStyle(D)
        }
    },
    showContent: function () {
        if (this.options.effects) {
            new Effect.Opacity(this.center, {
                duration: 0.5,
                from: 0,
                to: 1,
                queue: this.queue,
                afterFinish: Event.fire.bind(this, this.element, "lightview:opened")
            })
        } else {
            this.setImage(this.element.href);
            this.center.setOpacity(1);
            $(this.element).fire("lightview:opened")
        }
    },
    hideContent: function () {
        this.hideButtons();
        if (this.options.effects && this.lightview.visible()) {
            new Effect.Opacity(this.center, {
                duration: 0.24,
                from: 1,
                to: 0,
                queue: this.queue
            })
        } else {
            this.center.setOpacity(0)
        }
    },
    resizeImage: function (D) {
        var C = this.pixelClone(D);
        this.prevnext.setStyle({
            height: D.height + "px"
        });
        this.imageWrapper.setStyle(C);
        this.image.setStyle(C);
        var B = this.sideDimensions.width;
        var A = (D.width / 2 - 1) + B + this.border;
        this.prevButton.setStyle({
            width: A + "px",
            marginLeft: -1 * B + "px"
        });
        this.nextButton.setStyle({
            width: A + "px",
            marginRight: -1 * B + "px"
        })
    },
    setImage: function (A) {
        this.image.src = A
    },
    fillData: function () {
        this.imgText.hide();
        this.title.hide();
        this.caption.hide();
        this.imgNumber.hide();
        this.slideshow.hide();
        var C = this.element.getAttribute("title"),
            A = null,
            B = C && C.indexOf(this.options.titleCaptionSplit) ? C.indexOf(this.options.titleCaptionSplit) : null;
        if (C && B > -1) {
            A = C.substr(B + 2).strip();
            C = C.substr(0, B).strip()
        }
        if (C || A) {
            this.imgText.show()
        }
        if (C) {
            this.title.update(C).show()
        }
        if (A) {
            this.caption.update(A).show()
        }
        if (this.elements.length > 1) {
            this.imgNumber.show().down().update(new Template(this.options.imgNumberTemplate).evaluate({
                position: this.position + 1,
                total: this.elements.length
            }));
            this.slideshow.show();
            this.slideshowButton.show()
        }
        this.closeButtonWidth = this.setCloseButton();
        this.dataDimensions = this.setDataDimensions()
    },
    setCloseButton: function () {
        var E = this.closeDimensions.small.width,
            D = this.closeDimensions.large.width,
            A = this.scaledImageDimensions ? this.scaledImageDimensions.width : this.imageDimensions.width,
            F = 180,
            C = 0,
            B = this.options.borderColor;
        if (A >= F + E && A < F + D) {
            B = "url(" + this.images + "close_small.jpg)";
            C = E
        } else {
            if (A >= F + D) {
                B = "url(" + this.images + "close.jpg)";
                C = D
            }
        }
        if (C > 0) {
            this.closeWrapper.setStyle({
                width: C + "px"
            }).show()
        } else {
            this.closeWrapper.hide()
        }
        return C
    },
    startLoading: function () {
        if (this.options.effects) {
            this.loadingEffect = new Effect.Appear(this.loading, {
                duration: 0.2,
                from: 0,
                to: 1,
                queue: this.queue
            })
        } else {
            this.loading.show()
        }
    },
    stopLoading: function () {
        if (!this.loading.visible()) {
            return
        }
        if (this.options.effects) {
            if (this.loadingEffect) {
                Effect.Queues.get("lightview").remove(this.loadingEffect)
            }
            new Effect.Fade(this.loading, {
                duration: 1,
                queue: this.queue
            })
        } else {
            this.loading.hide()
        }
    },
    showButtons: function () {
        var B = (this.position != 0 ? "show" : "hide"),
            A = (!this.noset && this.getSurroundingIndexes().next != 0 ? "show" : "hide");
        this.prevButton[B]();
        this.nextButton[A]();
        this.prevButtonImage[B]();
        this.nextButtonImage[A]()
    },
    hideButtons: function () {
        this.prevButton.hide();
        this.nextButton.hide();
        this.prevButtonImage.hide();
        this.nextButtonImage.hide()
    },
    appear: function () {
        if (this.lightview.visible()) {
            return
        }
        if (this.options.effects) {
            new Effect.Appear(this.overlay, {
                duration: 0.6,
                from: 0,
                to: this.options.overlay.opacity,
                queue: this.queue,
                afterFinish: Element.show.bind(this, this.lightview)
            })
        } else {
            this.lightview.show();
            this.overlay.show()
        }
    },
    hide: function () {
        if (!this.overlay.visible()) {
            return
        }
        if (this.options.effects) {
            Effect.Queues.get("lightview").each(function (A) {
                A.cancel()
            })
        }
        this.stopSlideshow();
        this.lightview.hide();
        this.center.setOpacity(0);
        this.overlay.hide();
        this.disableKeyboardNavigation();
        this.showOverlapping();
        $(this.element).fire("lightview:hidden");
        this.element = null;
        this.elements = null;
        this.set = null;
        this.scaledImageDimensions = null
    },
    setDataDimensions: function () {
        var C = {},
            B = this.scaledImageDimensions ? this.scaledImageDimensions.width : this.imageDimensions.width,
            D = this.lightview.getStyle("display"),
            A = this.center.getStyle("display");
        this.dataContainer.setStyle({
            width: B + "px"
        });
        this.data.setStyle({
            width: B - this.closeButtonWidth - 1 + "px"
        });
        this.center.setStyle({
            visibility: "hidden"
        }).show();
        this.lightview.setStyle({
            visibility: "hidden"
        }).show();
        C = this.dataContainer.getDimensions();
        this.lightview.setStyle({
            visibility: "visible",
            display: D
        });
        this.center.setStyle({
            visibility: "visible",
            display: A
        });
        this.dataContainer.setStyle({
            width: "100%"
        });
        return C
    },
    startSlideshow: function () {
        this.stopSlideshow();
        this.sliding = true;
        this.next.bind(this).delay(0.25);
        this.slideshowButton.setStyle({
            background: "url(" + this.images + "slideshow_stop.jpg) top left no-repeat"
        }).hide()
    },
    stopSlideshow: function () {
        if (this.sliding) {
            this.sliding = false
        }
        if (this.slideTimer) {
            clearTimeout(this.slideTimer)
        }
        this.slideshowButton.setStyle({
            background: "url(" + this.images + "slideshow_play.jpg) top left no-repeat"
        })
    },
    toggleSlideshow: function () {
        this[(this.sliding ? "stop" : "start") + "Slideshow"]()
    },
    nextSlide: function () {
        if (this.sliding) {
            this.slideTimer = this.next.bind(this).delay(this.options.slideshow.delay)
        }
    },
    enableKeyboardNavigation: function () {
        this.keyboardEvent = this.keyboardDown.bindAsEventListener(this);
        document.observe("keydown", this.keyboardEvent)
    },
    disableKeyboardNavigation: function () {
        if (this.keyboardEvent) {
            document.stopObserving("keydown", this.keyboardEvent)
        }
    },
    keyboardDown: function (B) {
        B.stop();
        var A = String.fromCharCode(B.keyCode).toLowerCase(),
            C = (B.keyCode == Event.KEY_ESC || ["x", "c"].member(A)) ? "hide" : (B.keyCode == 37 && !this.noset && !this.resizing && this.position != 0) ? "previous" : (B.keyCode == 39 && !this.noset && !this.resizing && this.getSurroundingIndexes().next != 0) ? "next" : (A == "p" && !this.noset) ? "startSlideshow" : (A == "s" && !this.noset) ? "stopSlideshow" : null;
        if (A != "s") {
            this.stopSlideshow()
        }
        if (C) {
            this[C]()
        }
    },
    updateViews: function () {
        this.sets = [];
        var A = $$("a[rel^=lightview]");
        A.invoke("stopObserving", "click");
        A.each(function (B) {
            B.observe("click", this.show.curry(B).wrap(function (E, D) {
                D.stop();
                E(D)
            }).bindAsEventListener(this)).observe("mouseover", this.preloadImageHover.bind(this, B));
            var C = A.partition(function (D) {
                return D.rel == B.rel
            });
            if (C[0].length) {
                this.sets.push({
                    rel: B.rel,
                    elements: C[0]
                });
                A = C[1]
            }
        }.bind(this))
    },
    getSet: function (A) {
        return this.sets.find(function (B) {
            return B.rel == A
        })
    },
    addObservers: function () {
        $(document.body).observe("click", this.bodyClick.bindAsEventListener(this));
        $w("prev next").each(function (A) {
            this[A + "Button"].observe("mouseover", this.toggleSideButton.bindAsEventListener(this)).observe("mouseout", this.toggleSideButton.bindAsEventListener(this)).observe("click", this[A == "next" ? A : "previous"].wrap(function (C, B) {
                this.stopSlideshow();
                C(B)
            }).bindAsEventListener(this))
        }.bind(this));
        this.container.select("a.button").each(function (A) {
            A.observe("mouseover", Element.setOpacity.bind(this, A, this.options.buttons.opacity.hover)).observe("mouseout", Element.setOpacity.bind(this, A, this.options.buttons.opacity.normal))
        }.bind(this));
        this.closeButton.observe("click", this.hide.bindAsEventListener(this));
        this.slideshowButton.observe("click", this.toggleSlideshow.bindAsEventListener(this))
    },
    bodyClick: function (B) {
        var A = [this.overlay, this.left, this.right, this.loading.down()];
        if (Prototype.Browser.IE) {
            A.push(this.closeable)
        }
        if (B.target && A.include(B.target)) {
            this.hide()
        }
    },
    preloadImageHover: function (A) {
        if (A._lightviewPreloaded || !A.rel || this.getPreloadedImageDimensions(A.rel)) {
            return
        }
        this.preloadFromSet(A)
    },
    preloadSurroundingImages: function () {
        if (this.elements.length == 0) {
            return
        }
        surrounding = this.getSurroundingIndexes();
        this.preloadFromSet([surrounding.next, surrounding.previous])
    },
    preloadFromSet: function (C) {
        var B = (this.elements && this.elements.member(C) || Object.isArray(C)) ? this.elements : C.rel ? this.getSet(C.rel).elements : null;
        if (!B) {
            return
        }
        var A = $A(Object.isNumber(C) ? [C] : Object.isElement($(C)) ? [B.indexOf(C)] : C).uniq();
        A.each(function (F) {
            var G = B[F],
                E = G.href;
            if (G._lightboxPreloaded || !E || this.getPreloadedImageDimensions(E)) {
                return
            }
            var D = new Image();
            D.onload = function () {
                D.onload = Prototype.emptyFunction;
                this.preloadedImages.push({
                    href: E,
                    width: D.width,
                    height: D.height
                });
                $$("a[href]").findAll(function (H) {
                    return H.href == E
                }).each(function (H) {
                    H._lightviewPreloaded = true
                })
            }.bind(this);
            D.src = E
        }.bind(this))
    },
    getPreloadedImageDimensions: function (A) {
        var B = this.preloadedImages.find(function (C) {
            return C.href == A
        });
        return B ? {
            width: B.width,
            height: B.height
        } : null
    },
    toggleSideButton: function (E) {
        var C = E.element(),
            B = C.side,
            A = this.sideDimensions.width,
            F = (E.type == "mouseover") ? 0 : B == "prev" ? A : -1 * A,
            D = {
                marginLeft: F + "px"
            };
        if (this.options.effects) {
            if (!this.sideEffect) {
                this.sideEffect = {}
            }
            if (this.sideEffect[B]) {
                Effect.Queues.get("lightview_side" + B).remove(this.sideEffect[B])
            }
            this.sideEffect[B] = new Effect.Morph(this[B + "ButtonImage"], {
                style: D,
                duration: 0.2,
                queue: {
                    scope: "lightview_side" + B,
                    limit: 1
                }
            })
        } else {
            this[B + "ButtonImage"].setStyle(D)
        }
    },
    getSurroundingIndexes: function () {
        if (!this.elements) {
            return
        }
        var D = this.position,
            C = this.elements.length;
        var B = (D <= 0) ? C - 1 : D - 1,
            A = (D >= C - 1) ? 0 : D + 1;
        return {
            previous: B,
            next: A
        }
    },
    createCorner: function (C) {
        var D, A = this.radius,
            B = this.border,
            F = new Element("canvas"),
            E = {
                top: (C.charAt(0) == "t"),
                left: (C.charAt(1) == "l")
            };
        if (F && F.getContext && F.getContext("2d")) {
            D = new Element("canvas", {
                width: B + "px",
                height: B + "px",
                overflow: "hidden"
            }), ctx = D.getContext("2d");
            ctx.fillStyle = this.options.backgroundColor;
            ctx.arc((E.left ? A : B - A), (E.top ? A : B - A), A, 0, Math.PI * 2, true);
            ctx.fill();
            ctx.fillRect((E.left ? A : 0), 0, B - A, B);
            ctx.fillRect(0, (E.top ? A : 0), B, B - A)
        } else {
            D = new Element("div").setStyle({
                width: B + "px",
                height: B + "px",
                margin: 0,
                padding: 0,
                display: "block",
                position: "relative",
                overflow: "hidden"
            });
            D.insert(new Element("v:roundrect", {
                fillcolor: this.options.backgroundColor,
                strokeWeight: "1px",
                strokeColor: this.options.backgroundColor,
                arcSize: (A / B * 0.5).toFixed(2)
            }).setStyle({
                width: 2 * B - 1 + "px",
                height: 2 * B - 1 + "px",
                position: "absolute",
                left: (E.left ? 0 : (-1 * B)) + "px",
                top: (E.top ? 0 : (-1 * B)) + "px"
            }))
        }
        return D
    },
    hideOverlapping: function () {
        if (this.preventingOverlap) {
            return
        }
        $$("select", "embed", "object").invoke("setStyle", {
            visibility: "hidden"
        });
        this.preventingOverlap = true
    },
    showOverlapping: function () {
        $$("select", "embed", "object").invoke("setStyle", {
            visibility: "visible"
        });
        this.preventingOverlap = false
    },
    viewport: {
        getDimensions: function () {
            var A = {};
            var C = Prototype.Browser;
            $w("width height").each(function (E) {
                var B = E.capitalize();
                A[E] = (C.WebKit && !document.evaluate) ? self["inner" + B] : (C.Opera) ? document.body["client" + B] : document.documentElement["client" + B]
            });
            return A
        }
    },
    pixelClone: function (A) {
        var B = {};
        Object.keys(A).each(function (C) {
            B[C] = A[C] + "px"
        });
        return B
    },
    fitsWithinViewport: function () {
        var E = this.options.viewportPadding,
            D = 2 * this.border + this.sideDimensions.width,
            A = D + E,
            C = this.viewport.getDimensions();
        var B = this.getInnerSize(),
            F = this.getBounds(),
            G = {
                width: B.width + E,
                height: B.height + E
            };
        return (G.width <= F.width || G.height <= F.height)
    },
    getInnerDimensions: function () {
        return {
            width: this.imageDimensions.width,
            height: this.imageDimensions.height + this.dataDimensions.height
        }
    },
    getOuterDimensions: function () {
        var B = this.getInnerDimensions(),
            A = 2 * this.border;
        return {
            width: B.width + A,
            height: B.height + A
        }
    },
    getBounds: function () {
        var C = 20,
            A = 2 * this.sideDimensions.height + C,
            B = this.viewport.getDimensions();
        return {
            width: B.width - A,
            height: B.height - A
        }
    }
});
Lightview.load();
document.observe("dom:loaded", Lightview.start.bind(Lightview));
