//  Lightview 2.5.2 - 06-10-2009
//  Copyright (c) 2008-2009 Nick Stakenburg (http://www.nickstakenburg.com)
//
//  Licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License
//  http://creativecommons.org/licenses/by-nc-nd/3.0/

//  More information on this project:
//  http://www.nickstakenburg.com/projects/lightview/

var Lightview = {
  Version: '2.5.2',

  // 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 },                             // Toggle side buttons
      innerPreviousNext: { display: true },                // Toggle the inner previous and next button
      slideshow: { display: true },                        // Toggle slideshow button
      topclose: { side: 'right' }                          // 'right' or 'left'                    
    },
    controller: {                                          // The controller is used on sets
      backgroundColor: '#4d4d4d',
      border: 6,
      buttons: {
        innerPreviousNext: true,
        side: false
      },
      margin: 18,
      opacity: 0.7,
      radius: 6,
      setNumberTemplate: '#{position} of #{total}'
    },
    cyclic: false,                                         // Makes galleries cyclic, no end/begin
    images: '/images/lightview/',                          // The directory of the images, from this file
    imgNumberTemplate: 'Image #{position} of #{total}',    // Want a different language? change it here
    keyboard: true,                                        // Toggle keyboard buttons
    menubarPadding: 6,                                     // Space between menubar and content in px
    overlay: {                                             // Overlay
      background: '#000',                                  // Background color, Mac Firefox & Mac Safari use overlay.png
      close: true,
      opacity: 0.85,
      display: true
    },
    preloadHover: false,                                   // 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.45,                                  // The duration of the resize effect in seconds
    slideshowDelay: 5,                                     // Delay in seconds before showing the next slide
    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

    startDimensions: {                                     // Dimensions Lightview starts at
      width: 100,
      height: 100
    },
    closeDimensions: {                                     // Modify if you've changed the close button images
      large: { width: 77, height: 22 },
      small: { width: 25, height: 22 }
    },
    sideDimensions: {                                      // Modify if you've changed the side button images
      width: 16,
      height: 22
    },

    defaultOptions: {                                      // Default options for each type of view
      image: {
        menubar: 'bottom',
        closeButton: 'large'
      },
      gallery: {
        menubar: 'bottom',
        closeButton: 'large'
      },
      ajax:   {
        width: 400,
        height: 300,
        menubar: 'top',
        closeButton: 'small',
        overflow: 'auto'
      },
      iframe: {
        width: 400,
        height: 300,
        menubar: 'top',
        scrolling: true,
        closeButton: 'small'
      },
      inline: {
        width: 400,
        height: 300,
        menubar: 'top',
        closeButton: 'small',
        overflow: 'auto'
      },
      flash: {
        width: 400,
        height: 300,
        menubar: 'bottom',
        closeButton: 'large'
      },
      quicktime: {
        width: 480,
        height: 220,
        autoplay: true,
        controls: true,
        closeButton: 'large'
      }
    }
  },
  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,5,5,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}('(n(){B l=!!19.aq("3y").5T,2G=1m.1Z.2F&&(n(a){B b=u 4A("9b ([\\\\d.]+)").al(a);J b?4J(b[1]):-1})(3b.4T)<7,2C=(1m.1Z.5a&&!19.45),32=3b.4T.24("6r")>-1&&4J(3b.4T.3T(/6r[\\/\\s](\\d+)/)[1])<3,4k=!!3b.4T.3T(/95/i)&&(2C||32);12.1l(Y,{aw:"1.6.1",bn:"1.8.2",R:{1a:"5u",3q:"V"},5x:n(a){m((bo 20[a]=="8M")||(9.5z(20[a].9m)<9.5z(9["8n"+a]))){9O("Y a9 "+a+" >= "+9["8n"+a]);}},5z:n(a){B v=a.2Z(/8w.*|\\./g,"");v=4w(v+"0".bq(4-v.1p));J a.24("8w")>-1?v-1:v},5G:n(){9.5x("1m");m(!!20.11&&!20.6E){9.5x("6E")}m(/^(9L?:\\/\\/|\\/)/.58(9.y.1e)){9.1e=9.y.1e}W{B b=/V(?:-[\\w\\d.]+)?\\.at(.*)/;9.1e=(($$("av[1t]").6N(n(s){J s.1t.3T(b)})||{}).1t||"").2Z(b,"")+9.y.1e}m(!l){m(19.5K>=8&&!19.6Q.3k){19.6Q.bs("3k","bA:bN-bQ-c2:c3","#5R#79")}W{19.1f("5Y:3P",n(){B a=19.9r();a.9B="3k\\\\:*{9I:3Q(#5R#79)}"})}}},60:n(){9.1z=9.y.1z;9.Q=(9.1z>9.y.Q)?9.1z:9.y.Q;9.1I=9.y.1I;9.1R=9.y.1R;9.4E()}});12.1l(Y,{7p:14,2a:n(){B a=3Z.aJ;a.61++;m(a.61==9.7p){$(19.2e).62("V:3P")}}});Y.2a.61=0;12.1l(Y,{4E:n(){9.V=u I("O",{2S:"V"});B d,3G,4N=1P(9.1R);m(2C){9.V.13=n(){9.F("1h:-3C;1b:-3C;1k:1Q;");J 9};9.V.18=n(){9.F("1k:1u");J 9};9.V.1u=n(){J(9.1H("1k")=="1u"&&4J(9.1H("1b").2Z("H",""))>-7K)}}$(19.2e).M(9.2B=u I("O",{2S:"7V"}).F({2Q:9.y.2Q-1,1a:(!(32||2G))?"4r":"35",29:4k?"3Q("+9.1e+"2B.1s) 1b 1h 3A":9.y.2B.29}).1n(4k?1:9.y.2B.1F).13()).M(9.V.F({2Q:9.y.2Q,1b:"-3C",1h:"-3C"}).1n(0).M(9.84=u I("O",{N:"bJ"}).M(9.4b=u I("3z",{N:"c1"}).M(9.8G=u I("1B",{N:"c7"}).F(3G=12.1l({1M:-1*9.1R.E+"H"},4N)).M(9.4Q=u I("O",{N:"6n"}).F(12.1l({1M:9.1R.E+"H"},4N)).M(u I("O",{N:"1D"})))).M(9.8E=u I("1B",{N:"9w"}).F(12.1l({8z:-1*9.1R.E+"H"},4N)).M(9.4O=u I("O",{N:"6n"}).F(3G).M(u I("O",{N:"1D"}))))).M(9.8x=u I("O",{N:"8v"}).M(9.4F=u I("O",{N:"6n 9Q"}).M(9.9S=u I("O",{N:"1D"})))).M(u I("3z",{N:"a8"}).M(u I("1B",{N:"8u ac"}).M(d=u I("O",{N:"ai"}).F({G:9.Q+"H"}).M(u I("3z",{N:"8r ar"}).M(u I("1B",{N:"8i"}).M(u I("O",{N:"2t"})).M(u I("O",{N:"38"}).F({1h:9.Q+"H"})))).M(u I("O",{N:"8h"})).M(u I("3z",{N:"8r az"}).M(u I("1B",{N:"8i"}).F("1N-1b: "+(-1*9.Q)+"H").M(u I("O",{N:"2t"})).M(u I("O",{N:"38"}).F("1h: "+(-1*9.Q)+"H")))))).M(9.4V=u I("1B",{N:"aP"}).F("G: "+(ba-9.Q)+"H").M(u I("O",{N:"bd"}).M(u I("O",{N:"8d"}).F("1N-1b: "+9.Q+"H").M(9.30=u I("O",{N:"bp"}).1n(0).F("3p: 0 "+9.Q+"H").M(9.85=u I("O",{N:"bz 38"})).M(9.1o=u I("O",{N:"bH 80"}).M(9.2c=u I("O",{N:"1D 7X"}).F(1P(9.y.1I.3e)).F({29:9.y.10}).1n(9.y.1A.1F.3f)).M(9.2P=u I("3z",{N:"8L"}).M(9.6b=u I("1B",{N:"94"}).M(9.1C=u I("O",{N:"97"})).M(9.2m=u I("O",{N:"9i"}))).M(9.6a=u I("O",{N:"9n"}).M(9.48=u I("1B",{N:"9u"}).M(u I("O"))).M(9.4Y=u I("1B",{N:"9x"}).M(9.9y=u I("O",{N:"1D"}).1n(9.y.1A.1F.3f).F({10:9.y.10}).1G(9.1e+"9D.1s",{10:9.y.10})).M(9.9E=u I("O",{N:"1D"}).1n(9.y.1A.1F.3f).F({10:9.y.10}).1G(9.1e+"9F.1s",{10:9.y.10}))).M(9.28=u I("1B",{N:"9K"}).M(9.34=u I("O",{N:"1D"}).1n(9.y.1A.1F.3f).F({10:9.y.10}).1G(9.1e+"7I.1s",{10:9.y.10})))))).M(9.7F=u I("O",{N:"9P "}))))).M(9.3v=u I("O",{N:"7E"}).M(9.9Y=u I("O",{N:"1D"}).F("29: 3Q("+9.1e+"3v.64) 1b 1h 4H-3A")))).M(u I("1B",{N:"8u aa"}).M(d.ab(26))).M(9.1V=u I("1B",{N:"aj"}).13().F("1N-1b: "+9.Q+"H; 29: 3Q("+9.1e+"ak.64) 1b 1h 3A"))))).M(u I("O",{2S:"41"}).13());B f=u 2f();f.1w=n(){f.1w=1m.2z;9.1R={E:f.E,G:f.G};B a=1P(9.1R),3G;9.4b.F({1X:0-(f.G/2).2o()+"H",G:f.G+"H"});9.8G.F(3G=12.1l({1M:-1*9.1R.E+"H"},a));9.4Q.F(12.1l({1M:a.E},a));9.8E.F(12.1l({8z:-1*9.1R.E+"H"},a));9.4O.F(3G);9.2a()}.U(9);f.1t=9.1e+"2u.1s";$w("30 1C 2m 48").3W(n(e){9[e].F({10:9.y.10})}.U(9));B g=9.84.2p(".2t");$w("7o 7n bl br").1d(n(a,i){m(9.1z>0){9.5Z(g[i],a)}W{g[i].M(u I("O",{N:"38"}))}g[i].F({E:9.Q+"H",G:9.Q+"H"}).7g("2t"+a.1K());9.2a()}.U(9));9.V.2p(".8h",".38",".8d").3F("F",{10:9.y.10});B S={};$w("2u 1c 2k").1d(n(s){9[s+"3i"].1J=s;B b=9.1e+s+".1s";m(s=="2k"){S[s]=u 2f();S[s].1w=n(){S[s].1w=1m.2z;9.1I[s]={E:S[s].E,G:S[s].G};B a=9.y.1A.2k.1J,27=12.1l({"5Q":a,1X:9.1I[s].G+"H"},1P(9.1I[s]));27["3p"+a.1K()]=9.Q+"H";9[s+"3i"].F(27);9.8x.F({G:S[s].G+"H",1b:-1*9.1I[s].G+"H"});9[s+"3i"].5N().1G(b).F(1P(9.1I[s]));9.2a()}.U(9);S[s].1t=9.1e+s+".1s"}W{9[s+"3i"].1G(b)}},9);B C={};$w("3e 5M").1d(n(a){C[a]=u 2f();C[a].1w=n(){C[a].1w=1m.2z;9.1I[a]={E:C[a].E,G:C[a].G};9.2a()}.U(9);C[a].1t=9.1e+"6T"+a+".1s"},9);B L=u 2f();L.1w=n(){L.1w=1m.2z;9.3v.F({E:L.E+"H",G:L.G+"H",1X:-0.5*L.G+0.5*9.Q+"H",1M:-0.5*L.E+"H"});9.2a()}.U(9);L.1t=9.1e+"3v.64";B h=u 2f();h.1w=n(a){h.1w=1m.2z;B b={E:h.E+"H",G:h.G+"H"};9.28.F(b);9.34.F(b);9.2a()}.U(9);h.1t=9.1e+"6P.1s";$w("2u 1c").1d(n(s){B S=s.1K(),i=u 2f();i.1w=n(){i.1w=1m.2z;9["3r"+S+"3s"].F({E:i.E+"H",G:i.G+"H"});9.2a()}.U(9);i.1t=9.1e+"9o"+s+".1s";9["3r"+S+"3s"].1V=s},9);$w("28 4Y 48").1d(n(c){9[c].13=9[c].13.1v(n(a,b){9.27.1a="35";a(b);J 9});9[c].18=9[c].18.1v(n(a,b){9.27.1a="9v";a(b);J 9})},9);9.V.2p("*").3F("F",{2Q:9.y.2Q+1});9.V.13();9.2a()},6K:n(){11.2J.2I("V").3W(n(e){e.6F()});9.1S=1E;m(9.q.1O()){9.6w=9.6q;m(9.X&&!9.X.1u()){9.X.F("1k:1Q").18();9.3g.1n(0)}}W{9.6w=1E;9.X.13()}m(4w(9.4F.1H("1X"))<9.1I.2k.G){9.5B(2H)}9.8H();9.8y();u 11.1i({R:9.R,1q:n(){$w("1b 3K").1d(n(a){B b=a.1K();9["3E"+b].2n();B c={};9["3E"+b]=u I("O",{N:"ad"+b}).13();c[a]=9["3E"+b];9.30.M(c)}.U(9))}.U(9)});9.5A();9.1j=1E},5y:n(){m(!9.3J||!9.3V){J}9.3V.M({2W:9.3J.F({2q:9.3J.87})});9.3V.2n();9.3V=1E},18:n(b){9.1y=1E;B c=12.7W(b);m(12.7N(b)||c){m(c&&b.3x("#")){9.18({1g:b,y:12.1l({55:26},3Z[1]||{})});J}9.1y=$(b);m(!9.1y){J}9.1y.aW();9.q=9.1y.22||u Y.3N(9.1y)}W{m(b.1g){9.1y=$(19.2e);9.q=u Y.3N(b)}W{m(12.7v(b)){9.1y=9.4j(9.q.1Y)[b];9.q=9.1y.22}}}m(!9.q.1g){J}9.6K();m(9.q.2i()||9.q.1O()){9.7r(9.q.1Y);9.1j=9.5s(9.q.1Y);m(9.q.1O()){9.2s=9.1j.1p>1?9.7e:0;9.2V=9.1j.bK(n(a){J a.2T()})}}9.3R();9.7c();m(9.q.1g!="#41"&&12.70(Y.4u).6W(" ").24(9.q.17)>=0){m(!Y.4u[9.q.17]){$("41").1x(u 4y(9.8U.8V).45({17:9.q.17.1K(),5l:9.5k[9.q.17]}));B d=$("41").2l();9.18({1g:"#41",1C:9.q.17.1K()+" 98 99",y:d});J 2H}}B e=12.1l({1o:"3K",2k:2H,5j:"9h",3X:9.q.2i()&&9.y.1A.3X.2q,5i:9.y.5i,28:(9.q.2i()&&9.y.1A.28.2q)||(9.2V),2A:"1Q",7Z:9.y.2B.9p,33:9.y.33},9.y.9t[9.q.17]||{});9.q.y=12.1l(e,9.q.y);m(9.q.1O()){9.q.y.2k=(9.1j.1p<=1)}m(!(9.q.1C||9.q.2m||(9.1j&&9.1j.1p>1))&&9.q.y.2k){9.q.y.1o=2H}9.1T="3E"+(9.q.y.1o=="1b"?"7M":"7G");m(9.q.2T()){m(!l&&!9.q.7w){9.q.7w=26;B f=u I("3k:2h",{1t:9.q.1g,2q:"9z"}).F("G:5h;E:5h;");$(19.2e).M(f);I.2n.2X(0.1,f)}m(9.q.2i()||9.q.1O()){9.1a=9.1j.24(9.q);9.74()}9.1W=9.q.4P;m(9.1W){9.4G()}W{9.5d();B f=u 2f();f.1w=n(){f.1w=1m.2z;9.4S();9.1W={E:f.E,G:f.G};9.4G()}.U(9);f.1t=9.q.1g}}W{m(9.q.1O()){9.1a=9.1j.24(9.q)}9.1W=9.q.y.6M?19.33.2l():{E:9.q.y.E,G:9.q.y.G};9.4G()}},4U:(n(){n 5c(a,b,c){a=$(a);B d=1P(c);a.1x(u I("82",{2S:"2w",1t:b,a6:"",a7:"4H"}).F(d))}B k=(n(){n 7f(a,b,c){a=$(a);B d=12.1l({"5Q":"1h"},1P(c));B e=u I("3k:2h",{1t:b,2S:"2w"}).F(d);a.1x(e);e.51=e.51}n 6Z(b,c,d){b=$(b);B f=1P(d),2h=u 2f();2h.1w=n(){3y=u I("3y",f);b.1x(3y);4c{B a=3y.5T("2d");a.ah(2h,0,0,d.E,d.G)}4e(e){5c(b,c,d)}}.U(9);2h.1t=c}m(1m.1Z.2F){J 7f}W{J 6Z}})();J n(){B c=9.8a(9.q.1g),2D=9.1S||9.1W;m(9.q.2T()){B d=1P(2D);9[9.1T].F(d);m(9.1S){k(9[9.1T],9.q.1g,2D)}W{5c(9[9.1T],9.q.1g,2D)}}W{m(9.q.5p()){59(9.q.17){2M"4f":B f=12.5f(9.q.y.4f)||{};B g=n(){9.4S();m(9.q.y.55){9[9.1T].F({E:"1L",G:"1L"});9.1W=9.5b(9[9.1T])}u 11.1i({R:9.R,1q:9.52.U(9)})}.U(9);m(f.4Z){f.4Z=f.4Z.1v(n(a,b){g();a(b)})}W{f.4Z=g}9.5d();u aF.aH(9[9.1T],9.q.1g,f);2v;2M"2x":m(9.1S){2D.G-=9.3a.G}9[9.1T].1x(9.2x=u I("2x",{b1:0,b9:0,1t:9.q.1g,2S:"2w",2b:"bc"+(6z.bf()*bg).2o(),6J:(9.q.y&&9.q.y.6J)?"1L":"4H"}).F(12.1l({Q:0,1N:0,3p:0},1P(2D))));2v;2M"4R":B h=9.q.1g,2g=$(h.5e(h.24("#")+1));m(!2g||!2g.47){J}B i=2g.2l();2g.M({by:9.3V=u I(2g.47).13()});2g.87=2g.1H("2q");9.3J=2g.18();9[9.1T].1x(9.3J);9[9.1T].2p("2p, 3t, 5g").1d(n(b){9.44.1d(n(a){m(a.1y==b){b.F({1k:a.1k})}})}.U(9));m(9.q.y.55){9.1W=i;u 11.1i({R:9.R,1q:9.52.U(9)})}2v}}W{B j={1U:"3t",2S:"2w",E:2D.E,G:2D.G};59(9.q.17){2M"40":12.1l(j,{5l:9.5k[9.q.17],3o:[{1U:"2y",2b:"88",2N:9.q.y.88},{1U:"2y",2b:"8k",2N:"8I"},{1U:"2y",2b:"X",2N:9.q.y.6p},{1U:"2y",2b:"9M",2N:26},{1U:"2y",2b:"1t",2N:9.q.1g},{1U:"2y",2b:"6s",2N:9.q.y.6s||2H}]});12.1l(j,1m.1Z.2F?{8N:9.8O[9.q.17],8P:9.8R[9.q.17]}:{2P:9.q.1g,17:9.6t[9.q.17]});2v;2M"3U":12.1l(j,{2P:9.q.1g,17:9.6t[9.q.17],8W:"8X",5j:9.q.y.5j,5l:9.5k[9.q.17],3o:[{1U:"2y",2b:"8Y",2N:9.q.1g},{1U:"2y",2b:"8Z",2N:"26"}]});m(9.q.y.6D){j.3o.3S({1U:"2y",2b:"96",2N:9.q.y.6D})}2v}9[9.1T].F(1P(2D)).1x(9.5m(j)).F("1k:1Q").18();m(9.q.4v()){(n(){4c{m("6O"6S $("2w")){$("2w").6O(9.q.y.6p)}}4e(e){}}.U(9)).9c()}}}}})(),5b:n(b){b=$(b);B d=b.9d(),5n=[],5o=[];d.3S(b);d.1d(n(c){m(c!=b&&c.1u()){J}5n.3S(c);5o.3S({2q:c.1H("2q"),1a:c.1H("1a"),1k:c.1H("1k")});c.F({2q:"9j",1a:"35",1k:"1u"})});B e={E:b.9k,G:b.9l};5n.1d(n(r,a){r.F(5o[a])});J e},4t:n(){B a=$("2w");m(a){59(a.47.4s()){2M"3t":m(1m.1Z.5a&&9.q.4v()){4c{a.71()}4e(e){}a.9q=""}m(a.72){a.2n()}W{a=1m.2z}2v;2M"2x":a.2n();m(1m.1Z.9s&&20.73.2w){5q 20.73.2w}2v;5R:a.2n();2v}}$w("7G 7M").1d(n(S){9["3E"+S].F("E:1L;G:1L;").1x("").13()},9)},77:1m.K,4G:n(){u 11.1i({R:9.R,1q:9.4o.U(9)})},4o:n(){9.3c();m(!9.q.5r()){9.4S()}m(!((9.q.y.55&&9.q.7h())||9.q.5r())){9.52()}m(!9.q.4l()){u 11.1i({R:9.R,1q:9.4U.U(9)})}m(9.q.y.2k){u 11.1i({R:9.R,1q:9.5B.U(9,26)})}},7l:n(){u 11.1i({R:9.R,1q:9.7q.U(9)});m(9.q.4l()){u 11.1i({2X:0.2,R:9.R,1q:9.4U.U(9)})}m(9.3n){u 11.1i({R:9.R,1q:9.7u.U(9)})}m(9.q.4v()||9.q.9J()){u 11.1i({R:9.R,2X:0.1,1q:I.F.U(9,9[9.1T],"1k:1u")})}},2K:n(){m(11.2J.2I(Y.R.3q).5t.1p){J}9.18(9.2O().2K)},1c:n(){m(11.2J.2I(Y.R.3q).5t.1p){J}9.18(9.2O().1c)},52:n(){9.77();B a=9.5v(),2Y=9.7P();m(9.q.y.33&&(a.E>2Y.E||a.G>2Y.G)){m(9.q.y.6M){9.1S=2Y;9.3c();a=2Y}W{B c=9.7S(),b=2Y;m(9.q.4W()){B d=[2Y.G/c.G,2Y.E/c.E,1].a4();9.1S={E:(9.1W.E*d).2o(),G:(9.1W.G*d).2o()}}W{9.1S={E:c.E>b.E?b.E:c.E,G:c.G>b.G?b.G:c.G}}9.3c();a=12.5f(9.1S);m(9.q.4W()){a.G+=9.3a.G}}}W{9.3c();9.1S=1E}9.5w(a)},3I:n(a){9.5w(a,{23:0})},5w:(n(){B e,4L,4K,8c,8e,2s,b;B f=(n(){B w,h;n 4I(p){w=(e.E+p*4L).3L(0);h=(e.G+p*4K).3L(0)}B a;m(2G){a=n(p){9.V.F({E:(e.E+p*4L).3L(0)+"H",G:(e.G+p*4K).3L(0)+"H"});9.4V.F({G:h-1*9.Q+"H"})}}W{m(32){a=n(p){B v=9.4C(),o=19.33.6o();9.V.F({1a:"35",1M:0,1X:0,E:w+"H",G:h+"H",1h:(o[0]+(v.E/2)-(w/2)).3M()+"H",1b:(o[1]+(v.G/2)-(h/2)).3M()+"H"});9.4V.F({G:h-1*9.Q+"H"})}}W{a=n(p){9.V.F({1a:"4r",E:w+"H",G:h+"H",1M:((0-w)/2).2o()+"H",1X:((0-h)/2-2s).2o()+"H"});9.4V.F({G:h-1*9.Q+"H"})}}}J n(p){4I.3w(9,p);a.3w(9,p)}})();J n(a){B c=3Z[1]||{};e=9.V.2l();b=2*9.Q;E=a.E?a.E+b:e.E;G=a.G?a.G+b:e.G;9.5C();m(e.E==E&&e.G==G){u 11.1i({R:9.R,1q:9.5D.U(9,a)});J}B d={E:E+"H",G:G+"H"};4L=E-e.E;4K=G-e.G;8c=4w(9.V.1H("1M").2Z("H",""));8e=4w(9.V.1H("1X").2Z("H",""));2s=9.X.1u()?(9.2s/2):0;m(!2G){12.1l(d,{1M:0-E/2+"H",1X:0-G/2+"H"})}m(c.23==0){f.3w(9,1)}W{9.5E=u 11.6u(9.V,0,1,12.1l({23:9.y.ax,R:9.R,6v:9.y.6v,1q:9.5D.U(9,a)},c),f.U(9))}}})(),5D:n(a){m(!9.3a){J}B b=9[9.1T],4p;m(9.q.y.2A=="1L"){4p=b.2l()}b.F({G:(a.G-9.3a.G)+"H",E:a.E+"H"});m(9.q.y.2A!="1Q"&&(9.q.5r()||9.q.7h())){m(1m.1Z.2F){m(9.q.y.2A=="1L"){B c=b.2l();b.F("2A:1u");B d={6x:"1Q",6y:"1Q"},5F=0,4n=15;m(4p.G>a.G){d.6y="1L";d.E=c.E-4n;d.aX="6A";5F=4n}m(4p.E-5F>a.E){d.6x="1L";d.G=c.G-4n;d.b2="6A"}b.F(d)}W{b.F({2A:9.q.y.2A})}}W{b.F({2A:9.q.y.2A})}}W{b.F("2A:1Q")}9.3R();9.5E=1E;9.7l()},7q:n(){u 11.1i({R:9.R,1q:9.5C.U(9)});u 11.1i({R:9.R,1q:n(){9[9.1T].18();9.3c();m(9.1o.1u()){9.1o.F("1k:1u").1n(1)}}.U(9)});u 11.b6([u 11.6B(9.30,{6C:26,4m:0,57:1}),u 11.53(9.4b,{6C:26})],{R:9.R,23:0.25,1q:n(){m(9.1y){9.1y.62("V:bh")}}.U(9)});m(9.q.2i()||(9.2V&&9.y.X.1A.1J)){u 11.1i({R:9.R,1q:9.6G.U(9)})}},8y:(n(){n 2W(){9.4t();9.4F.F({1X:9.1I.2k.G+"H"});9.5y()}n 6H(p){9.30.1n(p);9.4b.1n(p)}J n(){m(!9.V.1u()){9.30.1n(0);9.4b.1n(0);9.4t();J}u 11.6u(9.V,1,0,{23:0.2,R:9.R,1q:2W.U(9)},6H.U(9))}})(),6I:n(){$w("6a 2P 6b 1C 2m 48 4Y 28 2c").1d(n(a){I.13(9[a])},9);9.1o.F("1k:1Q").1n(0)},3c:n(){9.6I();m(!9.q.y.1o){9.3a={E:0,G:0};9.5H=0;9.1o.13()}W{9.1o.18()}m(9.q.1C||9.q.2m){9.6b.18();9.2P.18()}m(9.q.1C){9.1C.1x(9.q.1C).18()}m(9.q.2m){9.2m.1x(9.q.2m).18()}m(9.1j&&9.1j.1p>1){m(9.q.1O()){9.2r.1x(u 4y(9.y.X.6L).45({1a:9.1a+1,5I:9.1j.1p}));m(9.X.1H("1k")=="1Q"){9.X.F("1k:1u");m(9.5J){11.2J.2I("V").2n(9.5J)}9.5J=u 11.53(9.3g,{R:9.R,23:0.1})}}W{9.2P.18();m(9.q.2T()){9.6a.18();9.48.18().5N().1x(u 4y(9.y.bF).45({1a:9.1a+1,5I:9.1j.1p}));m(9.q.y.28){9.34.18();9.28.18()}}}}B a=9.q.1O();m((9.q.y.3X||a)&&9.1j.1p>1){B b={2u:(9.y.31||9.1a!=0),1c:(9.y.31||((9.q.2i()||a)&&9.2O().1c!=0))};$w("2u 1c").1d(n(z){B Z=z.1K(),3u=b[z]?"6R":"1L";m(a){9["X"+Z].F({3u:3u}).1n(b[z]?1:9.y.1A.1F.5L)}W{9["3r"+Z+"3s"].F({3u:3u}).1n(b[z]?9.y.1A.1F.3f:9.y.1A.1F.5L)}}.U(9));m(9.q.y.3X||9.y.X.3X){9.4Y.18()}}9.3O.1n(9.2V?1:9.y.1A.1F.5L).F({3u:9.2V?"6R":"1L"});9.6U();m(!9.1o.c4().6N(I.1u)){9.1o.13();9.q.y.1o=2H}9.6V()},6U:n(){B a=9.1I.5M.E,3e=9.1I.3e.E,3d=9.1S?9.1S.E:9.1W.E,4D=8J,E=0,2c=9.q.y.2c||"3e",29=9.y.8K;m(9.q.y.2k||9.q.1O()||!9.q.y.2c){29=1E}W{m(3d>=4D+a&&3d<4D+3e){29="5M";E=a}W{m(3d>=4D+3e){29=2c;E=9.1I[2c].E}}}m(E>0){9.2P.18();9.2c.F({E:E+"H"}).18()}W{9.2c.13()}m(29){9.2c.1G(9.1e+"6T"+29+".1s",{10:9.y.10})}9.5H=E},5d:n(){9.5O=u 11.53(9.3v,{23:0.2,4m:0,57:1,R:9.R})},4S:n(){m(9.5O){11.2J.2I("V").2n(9.5O)}u 11.6X(9.3v,{23:0.2,R:9.R,2X:0.2})},6Y:n(){m(!9.q.2T()){J}B a=(9.y.31||9.1a!=0),1c=(9.y.31||((9.q.2i()||9.q.1O())&&9.2O().1c!=0));9.4Q[a?"18":"13"]();9.4O[1c?"18":"13"]();B b=9.1S||9.1W;9.1V.F({G:b.G+"H",1X:9.Q+(9.q.y.1o=="1b"?9.1o.5P():0)+"H"});B c=((b.E/2-1)+9.Q).3M();m(a){9.1V.M(9.3j=u I("O",{N:"1D 8Q"}).F({E:c+"H"}));9.3j.1J="2u"}m(1c){9.1V.M(9.3h=u I("O",{N:"1D 8S"}).F({E:c+"H"}));9.3h.1J="1c"}m(a||1c){9.1V.18()}},6G:n(){m(!9.q||!9.y.1A.1J.2q||!9.q.2T()){J}9.6Y();9.1V.18()},5C:n(){9.1V.1x("").13();9.4Q.13().F({1M:9.1R.E+"H"});9.4O.13().F({1M:-1*9.1R.E+"H"})},7c:(n(){n 2W(){9.V.1n(1)}m(!2C){2W=2W.1v(n(a,b){a(b);9.V.18()})}J n(){m(9.V.1H("1F")!=0){J}m(9.y.2B.2q){u 11.53(9.2B,{23:0.2,4m:0,57:4k?1:9.y.2B.1F,R:9.R,8T:9.5S.U(9),1q:2W.U(9)})}W{2W.3w(9)}}})(),13:n(){m(1m.1Z.2F&&9.2x&&9.q.4l()){9.2x.2n()}m(2C&&9.q.4v()){B a=$$("3t#2w")[0];m(a){4c{a.71()}4e(e){}}}m(9.V.1H("1F")==0){J}9.2j();9.1V.13();m(!1m.1Z.2F||!9.q.4l()){9.30.13()}m(11.2J.2I("5U").5t.1p>0){J}11.2J.2I("V").1d(n(e){e.6F()});u 11.1i({R:9.R,1q:9.5y.U(9)});u 11.6B(9.V,{23:0.1,4m:1,57:0,R:{1a:"5u",3q:"5U"}});u 11.6X(9.2B,{23:0.16,R:{1a:"5u",3q:"5U"},1q:9.75.U(9)})},75:n(){9.4t();9.V.13();9.30.1n(0).18();9.1V.1x("").13();9.85.1x("").13();9.7F.1x("").13();9.5A();9.76();u 11.1i({R:9.R,1q:9.3I.U(9,9.y.90)});u 11.1i({R:9.R,1q:n(){m(9.1y){9.1y.62("V:1Q")}$w("1y 1j q 1S 2V 91 3E").3W(n(a){9[a]=1E}.U(9))}.U(9)})},6V:n(){9.1o.F("3p:0;");B a={},3d=9[(9.1S?"92":"i")+"93"].E;9.1o.F({E:3d+"H"});9.2P.F({E:3d-9.5H-1+"H"});a=9.5b(9.1o);m(9.q.y.1o){a.G+=9.y.5V;59(9.q.y.1o){2M"3K":9.1o.F("3p:"+9.y.5V+"H 0 0 0");2v;2M"1b":9.1o.F("3p: 0 0 "+9.y.5V+"H 0");2v}}9.1o.F({E:"78%"});9.3a=9.q.y.1o?a:{E:a.E,G:0}},3R:(n(){B a,2s;n 4I(){a=9.V.2l();2s=9.X.1u()?(9.2s/2):0}B b;m(2G){b=n(){9.V.F({1b:"50%",1h:"50%"})}}W{m(2C||32){b=n(){B v=9.4C(),o=19.33.6o();9.V.F({1M:0,1X:0,1h:(o[0]+(v.E/2)-(a.E/2)).3M()+"H",1b:(o[1]+(v.G/2)-(a.G/2)).3M()+"H"})}}W{b=n(){9.V.F({1a:"4r",1h:"50%",1b:"50%",1M:(0-a.E/2).2o()+"H",1X:(0-a.G/2-2s).2o()+"H"})}}}J n(){4I.3w(9);b.3w(9)}})(),7a:n(){9.2j();9.3n=26;9.1c.U(9).2X(0.25);9.34.1G(9.1e+"6P.1s",{10:9.y.10}).13();9.3O.1G(9.1e+"7b.1s",{10:9.y.X.10})},2j:n(){m(9.3n){9.3n=2H}m(9.5W){9a(9.5W)}9.34.1G(9.1e+"7I.1s",{10:9.y.10});9.3O.1G(9.1e+"7d.1s",{10:9.y.X.10})},5X:n(){m(9.q.1O()&&!9.2V){J}9[(9.3n?"4X":"60")+"9e"]()},7u:n(){m(9.3n){9.5W=9.1c.U(9).2X(9.y.9f)}},9g:n(){$$("a[2U~=V], 3B[2U~=V]").1d(n(a){B b=a.22;m(!b){J}m(b.3H){a.7i("1C",b.3H)}a.22=1E})},4j:n(a){B b=a.24("][");m(b>-1){a=a.5e(0,b+1)}J $$(\'a[1Y^="\'+a+\'"], 3B[1Y^="\'+a+\'"]\')},5s:n(a){J 9.4j(a).7j("22")},7k:n(){$(19.2e).1f("2L",9.7m.1r(9));$w("2R 3Y").1d(n(e){9.1V.1f(e,n(a){B b=a.3m("O");m(!b){J}m(9.3j&&9.3j==b||9.3h&&9.3h==b){9.54(a)}}.1r(9))}.U(9));9.1V.1f("2L",n(c){B d=c.3m("O");m(!d){J}B e=(9.3j&&9.3j==d)?"2K":(9.3h&&9.3h==d)?"1c":1E;m(e){9[e].1v(n(a,b){9.2j();a(b)}).U(9)()}}.1r(9));$w("2u 1c").1d(n(s){B S=s.1K(),2j=n(a,b){9.2j();a(b)},42=n(a,b){B c=b.1y().1V;m((c=="2u"&&(9.y.31||9.1a!=0))||(c=="1c"&&(9.y.31||((9.q.2i()||9.q.1O())&&9.2O().1c!=0)))){a(b)}};9[s+"3i"].1f("2R",9.54.1r(9)).1f("3Y",9.54.1r(9)).1f("2L",9[s=="1c"?s:"2K"].1v(2j).1r(9));9["3r"+S+"3s"].1f("2L",9[s=="1c"?s:"2K"].1v(42).1v(2j).1r(9)).1f("2R",I.1n.7s(9["3r"+S+"3s"],9.y.1A.1F.7t).1v(42).1r(9)).1f("3Y",I.1n.7s(9["3r"+S+"3s"],9.y.1A.1F.3f).1v(42).1r(9));9["X"+S].1f("2L",9[s=="1c"?s:"2K"].1v(42).1v(2j).1r(9))},9);B f=[9.2c,9.34];m(!2C){f.1d(n(b){b.1f("2R",I.1n.U(9,b,9.y.1A.1F.7t)).1f("3Y",I.1n.U(9,b,9.y.1A.1F.3f))},9)}W{f.3F("1n",1)}9.34.1f("2L",9.5X.1r(9));9.3O.1f("2L",9.5X.1r(9));m(2C||32){B g=n(a,b){m(9.V.1H("1b").63(0)=="-"){J}a(b)};1i.1f(20,"43",9.3R.1v(g).1r(9));1i.1f(20,"3I",9.3R.1v(g).1r(9))}m(32){1i.1f(20,"3I",9.5S.1r(9))}m(2G){n 65(){m(9.X){9.X.F({1h:((19.7x.9A||0)+19.33.7y()/2).2o()+"H"})}}1i.1f(20,"43",65.1r(9));1i.1f(20,"3I",65.1r(9))}m(9.y.9C){9.7z=n(a){B b=a.3m("a[2U~=V], 3B[2U~=V]");m(!b){J}a.4X();m(!b.22){u Y.3N(b)}9.7A(b)}.1r(9);$(19.2e).1f("2R",9.7z)}},5B:n(a){m(9.7B){11.2J.2I("9G").2n(9.9H)}B b={1X:(a?0:9.1I.2k.G)+"H"};9.7B=u 11.7C(9.4F,{27:b,23:0.16,R:9.R,2X:a?0.15:0})},7D:n(){B a={};$w("E G").1d(n(d){B D=d.1K(),4x=19.7x;a[d]=1m.1Z.2F?[4x["66"+D],4x["43"+D]].9N():1m.1Z.5a?19.2e["43"+D]:4x["43"+D]});J a},5S:n(){m(!32){J}9.2B.F(1P(9.7D()))},7m:(n(){B b=".7X, .8v .1D, .7E, .7H";J n(a){m(9.q&&9.q.y&&a.3m(b+(9.q.y.7Z?", #7V":""))){9.13()}}})(),54:n(a){B b=a.2g,1J=b.1J,w=9.1R.E,66=(a.17=="2R")?0:1J=="2u"?w:-1*w,27={1M:66+"H"};m(!9.46){9.46={}}m(9.46[1J]){11.2J.2I("7J"+1J).2n(9.46[1J])}9.46[1J]=u 11.7C(9[1J+"3i"],{27:27,23:0.2,R:{3q:"7J"+1J,9R:1},2X:(a.17=="3Y")?0.1:0})},2O:n(){m(!9.1j){J}B a=9.1a,1p=9.1j.1p;B b=(a<=0)?1p-1:a-1,1c=(a>=1p-1)?0:a+1;J{2K:b,1c:1c}},5Z:n(a,b){B c=3Z[2]||9.y,1z=c.1z,Q=c.Q;1a={1b:(b.63(0)=="t"),1h:(b.63(1)=="l")};m(l){B d=u I("3y",{N:"9T"+b.1K(),E:Q+"H",G:Q+"H"});d.F("5Q:1h");a.M(d);B e=d.5T("2d");e.9U=c.10;e.9V((1a.1h?1z:Q-1z),(1a.1b?1z:Q-1z),1z,0,6z.9W*2,26);e.9X();e.7L((1a.1h?1z:0),0,Q-1z,Q);e.7L(0,(1a.1b?1z:0),Q,Q-1z)}W{B f=u I("3k:9Z",{a0:c.10,a1:"5h",a2:c.10,a3:(1z/Q*0.5).3L(2)}).F({E:2*Q-1+"H",G:2*Q-1+"H",1a:"35",1h:(1a.1h?0:(-1*Q))+"H",1b:(1a.1b?0:(-1*Q))+"H"});a.M(f);f.51=f.51}},8H:(n(){n 67(){J $$("3t, 5g, 2p")}m(1m.1Z.2F&&19.5K>=8){67=n(){J 19.a5("3t, 5g, 2p")}}J n(){m(9.68){J}B a=67();9.44=[];7O(B i=0,1p=a.1p;i<1p;i++){B b=a[i];9.44.3S({1y:b,1k:b.27.1k});b.27.1k="1Q"}9.68=26}})(),76:n(){9.44.1d(n(a,i){a.1y.27.1k=a.1k});5q 9.44;9.68=2H},5v:n(){J{E:9.1W.E,G:9.1W.G+9.3a.G}},7S:n(){B i=9.5v(),b=2*9.Q;J{E:i.E+b,G:i.G+b}},7P:n(){B a=21,69=2*9.1R.G+a,v=9.4C();J{E:v.E-69,G:v.G-69}},4C:n(){B v=19.33.2l();m(9.X&&9.X.1u()&&9.1j&&9.1j.1p>1){v.G-=9.2s}J v}});(n(){n 7Q(a,b){m(!9.q){J}a(b)}$w("3c 4U").1d(n(a){9[a]=9[a].1v(7Q)},Y)})();n 1P(b){B c={};12.70(b).1d(n(a){c[a]=b[a]+"H"});J c}12.1l(Y,{7R:n(){m(!9.q.y.5i){J}9.4M=9.7T.1r(9);19.1f("7U",9.4M)},5A:n(){m(9.4M){19.ae("7U",9.4M)}},7T:n(a){B b=af.ag(a.2E).4s(),2E=a.2E,3D=(9.q.2i()||9.2V)&&!9.5E,28=9.q.y.28,49;m(9.q.4W()){a.4X();49=(2E==1i.7Y||["x","c"].6c(b))?"13":(2E==37&&3D&&(9.y.31||9.1a!=0))?"2K":(2E==39&&3D&&(9.y.31||9.2O().1c!=0))?"1c":(b=="p"&&28&&3D)?"7a":(b=="s"&&28&&3D)?"2j":1E;m(b!="s"){9.2j()}}W{49=(2E==1i.7Y)?"13":1E}m(49){9[49]()}m(3D){m(2E==1i.am&&9.1j.an()!=9.q){9.18(0)}m(2E==1i.ao&&9.1j.ap()!=9.q){9.18(9.1j.1p-1)}}}});Y.4o=Y.4o.1v(n(a,b){9.7R();a(b)});12.1l(Y,{7r:n(a){B b=9.4j(a);m(!b){J}b.3W(Y.4a)},74:n(){m(9.1j.1p==0){J}B a=9.2O();9.81([a.1c,a.2K])},81:n(c){B d=(9.1j&&9.1j.6c(c)||12.as(c))?9.1j:c.1Y?9.5s(c.1Y):1E;m(!d){J}B e=$A(12.7v(c)?[c]:c.17?[d.24(c)]:c).au();e.1d(n(a){B b=d[a];9.6d(b)},9)},83:n(a,b){a.4P={E:b.E,G:b.G}},6d:n(a){m(a.4P||a.4B||!a.1g){J}B P=u 2f();P.1w=n(){P.1w=1m.2z;a.4B=1E;9.83(a,P)}.U(9);a.4B=26;P.1t=a.1g},7A:n(a){B b=a.22;m(b&&b.4P||b.4B||!b.2T()){J}9.6d(b)}});I.ay({1G:n(a,b){a=$(a);B c=12.1l({86:"1b 1h",3A:"4H-3A",6e:"8k",10:""},3Z[2]||{});a.F(2G?{aA:"aB:aC.aD.aE(1t=\'"+b+"\'\', 6e=\'"+c.6e+"\')"}:{29:c.10+" 3Q("+b+") "+c.86+" "+c.3A});J a}});12.1l(Y,{6f:n(a,b){B c;$w("3U 2h 2x 40").1d(n(t){m(u 4A("\\\\.("+9.aG[t].2Z(/\\s+/g,"|")+")(\\\\?.*)?","i").58(a)){c=t}}.U(9));m(c){J c}m(a.3x("#")){J"4R"}m(19.89&&19.89!=(a).2Z(/(^.*\\/\\/)|(:.*)|(\\/.*)/g,"")){J"2x"}J"2h"},8a:n(a){B b=a.aI(/\\?.*/,"").3T(/\\.([^.]{3,4})$/);J b?b[1]:1E},5m:n(b){B c="<"+b.1U;7O(B d 6S b){m(!["3o","6g","1U"].6c(d)){c+=" "+d+\'="\'+b[d]+\'"\'}}m(u 4A("^(?:3B|aK|aL|br|aM|aN|aO|82|8b|aQ|aR|aS|2y|aT|aU|aV)$","i").58(b.1U)){c+="/>"}W{c+=">";m(b.3o){b.3o.1d(n(a){c+=9.5m(a)}.U(9))}m(b.6g){c+=b.6g}c+="</"+b.1U+">"}J c}});(n(){19.1f("5Y:3P",n(){B c=(3b.6h&&3b.6h.1p);n 4d(a){B b=2H;m(c){b=($A(3b.6h).7j("2b").6W(",").24(a)>=0)}W{4c{b=u aY(a)}4e(e){}}J!!b}m(c){20.Y.4u={3U:4d("aZ b0"),40:4d("6i")}}W{20.Y.4u={3U:4d("8f.8f"),40:4d("6i.6i")}}})})();Y.3N=b3.b4({b5:n(b){m(b.22){J}B c=12.7N(b);m(c&&!b.22){b.22=9;m(b.1C){b.22.3H=b.1C;m(Y.y.8g){b.b7("1C","")}}}9.1g=c?b.b8("1g"):b.1g;m(9.1g.24("#")>=0){9.1g=9.1g.5e(9.1g.24("#"))}B d=b.1Y;m(d){9.1Y=d;m(d.3x("4g")){9.17="4g"}W{m(d.3x("56")){m(d.bb("][")){B e=d.8j("]["),6j=e[1].3T(/([a-be-Z]*)/)[1];m(6j){9.17=6j;B f=e[0]+"]";b.7i("1Y",f);9.1Y=f}}W{9.17=Y.6f(9.1g)}}W{9.17=d}}}W{9.17=Y.6f(9.1g);9.1Y=9.17}$w("4f 3U 4g 2x 2h 4R 40 8l 8m 56").3W(n(a){B T=a.1K(),t=a.4s();m("2h 4g 8m 8l 56".24(a)<0){9["bi"+T]=n(){J 9.17==t}.U(9)}}.U(9));m(c&&b.22.3H){B g=b.22.3H.8j(Y.y.bj).3F("bk");m(g[0]){9.1C=g[0]}m(g[1]){9.2m=g[1]}B h=g[2];9.y=(h&&12.7W(h))?bm("({"+h+"})"):{}}W{9.1C=b.1C;9.2m=b.2m;9.y=b.y||{}}m(9.y.6k){9.y.4f=12.5f(9.y.6k);5q 9.y.6k}},2i:n(){J 9.17.3x("4g")},1O:n(){J 9.1Y.3x("56")},2T:n(){J(9.2i()||9.17=="2h")},5p:n(){J"2x 4R 4f".24(9.17)>=0},4W:n(){J!9.5p()}});Y.4a=n(a){B b=$(a);u Y.3N(a);J b};(n(){n 8o(a){B b=a.3m("a[2U~=V], 3B[2U~=V]");m(!b){J}a.4X();9.4a(b);9.18(b)}n 8p(a){B b=a.3m("a[2U~=V], 3B[2U~=V]");m(!b){J}9.4a(b)}n 8q(a){B b=a.2g,17=a.17,36=a.36;m(36&&36.47){m(17==="5G"||17==="bt"||(17==="2L"&&36.47.4s()==="8b"&&36.17==="bu")){b=36}}m(b.bv==bw.bx){b=b.72}J b}n 8s(a,b){m(!a){J}B c=a.N;J(c.1p>0&&(c==b||u 4A("(^|\\\\s)"+b+"(\\\\s|$)").58(c)))}n 8t(a){B b=8q(a);m(b&&8s(b,"V")){9.4a(b)}}19.1f("V:3P",n(){$(19.2e).1f("2L",8o.1r(Y));m(Y.y.8g&&1m.1Z.2F&&19.5K>=8){$(19.2e).1f("2R",8t.1r(Y))}W{$(19.2e).1f("2R",8p.1r(Y))}})})();12.1l(Y,{4z:n(){B b=9.y.X,Q=b.Q;$(19.2e).M(9.X=u I("O",{2S:"bB"}).F({2Q:9.y.2Q+1,bC:b.1N+"H",1a:"35",1k:"1Q"}).M(9.bD=u I("O",{N:"bE"}).M(u I("O",{N:"4q bG"}).F("1N-1h: "+Q+"H").M(u I("O",{N:"2t"}))).M(u I("O",{N:"6l"}).F({1N:"0 "+Q+"H",G:Q+"H"})).M(u I("O",{N:"4q bI"}).F("1N-1h: -"+Q+"H").M(u I("O",{N:"2t"})))).M(9.3l=u I("O",{N:"6m 80"}).M(9.3g=u I("3z",{N:"bL"}).F("1N: 0 "+Q+"H").M(u I("1B",{N:"bM"}).M(9.2r=u I("O"))).M(u I("1B",{N:"4h bO"}).M(9.bP=u I("O",{N:"1D"}).1G(9.1e+"8A.1s",{10:b.10}))).M(u I("1B",{N:"4h bR"}).M(9.bS=u I("O",{N:"1D"}).1G(9.1e+"bT.1s",{10:b.10}))).M(u I("1B",{N:"4h bU"}).M(9.3O=u I("O",{N:"1D"}).1G(9.1e+"7d.1s",{10:b.10}))).M(u I("1B",{N:"4h 7H"}).M(9.bV=u I("O",{N:"1D"}).1G(9.1e+"bW.1s",{10:b.10}))))).M(9.bX=u I("O",{N:"bY"}).M(u I("O",{N:"4q bZ"}).F("1N-1h: "+Q+"H").M(u I("O",{N:"2t"}))).M(u I("O",{N:"6l"}).F({1N:"0 "+Q+"H",G:Q+"H"})).M(u I("O",{N:"4q c0"}).F("1N-1h: -"+Q+"H").M(u I("O",{N:"2t"})))));$w("2u 1c").1d(n(s){B S=s.1K();9["X"+S].1V=s},9);m(2C){9.X.13=n(){9.F("1h:-3C;1b:-3C;1k:1Q;");J 9};9.X.18=n(){9.F("1k:1u");J 9};9.X.1u=n(){J(9.1H("1k")=="1u"&&4J(9.1H("1b").2Z("H",""))>-7K)}}9.X.2p(".4h O").3F("F",1P(9.8B));B c=9.X.2p(".2t");$w("7o 7n bl br").1d(n(a,i){m(b.1z>0){9.5Z(c[i],a,b)}W{c[i].M(u I("O",{N:"38"}))}c[i].F({E:b.Q+"H",G:b.Q+"H"}).7g("2t"+a.1K())},9);9.X.5N(".6m").F("E:78%;");9.X.F(2G?{1a:"35",1b:"1L",1h:""}:{1a:"4r",1b:"1L",1h:"50%"});9.X.2p(".6l",".6m",".1D",".38").3F("F",{10:b.10});9.2r.1x(u 4y(b.6L).45({1a:8C,5I:8C}));9.2r.F({E:9.2r.7y()+"H",G:9.3g.5P()+"H"});9.8D();9.2r.1x("");9.X.13().F("1k:1u");9.7k();9.2a()},8D:n(){B b,4i,X=9.y.X,Q=X.Q;m(2G){b=9.3g.2l(),4i=b.E+2*Q;9.3g.F({E:b.E+"H",1N:0});9.3l.F("E:1L;");9.3g.F({c5:Q+"H"});9.3l.F({E:4i+"H"});$w("1b 3K").1d(n(a){9["X"+a.1K()].F({E:4i+"H"})},9);9.X.F("1N-1h:-"+(4i/2).2o()+"H")}W{9.3l.F("E:1L");b=9.3l.2l();9.2r.c6().F({8F:b.G+"H",E:9.2r.2l().E+"H"});9.X.F({E:b.E+"H",1M:(0-(b.E/2).2o())+"H"});9.3l.F({E:b.E+"H"});$w("1b 3K").1d(n(a){9["X"+a.1K()].F({E:b.E+"H"})},9)}9.7e=X.1N+b.G+2*Q;9.6q=9.X.5P();9.2r.F({8F:b.G+"H"})}});Y.4z=Y.4z.1v(n(a,b){B c=u 2f();c.1w=n(){c.1w=1m.2z;9.8B={E:c.E,G:c.G};a(b)}.U(9);c.1t=9.1e+"8A.1s";B d=(u 2f()).1t=9.1e+"7b.1s"});Y.4E=Y.4E.1v(n(a,b){a(b);9.4z()});Y.13=Y.13.1v(n(a,b){m(9.q&&9.q.1O()){9.X.13();9.2r.1x("")}a(b)})})();Y.5G();19.1f("5Y:3P",Y.60.U(Y));',62,752,'|||||||||this|||||||||||||if|function|||view||||new||||options|||var|||width|setStyle|height|px|Element|return|||insert|className|div||border|queue|||bind|lightview|else|controller|Lightview||backgroundColor|Effect|Object|hide||||type|show|document|position|top|next|each|images|observe|href|left|Event|views|visibility|extend|Prototype|setOpacity|menubar|length|afterFinish|bindAsEventListener|png|src|visible|wrap|onload|update|element|radius|buttons|li|title|lv_Button|null|opacity|setPngBackground|getStyle|closeDimensions|side|capitalize|auto|marginLeft|margin|isSet|pixelClone|hidden|sideDimensions|scaledInnerDimensions|_contentPosition|tag|prevnext|innerDimensions|marginTop|rel|Browser|window||_view|duration|indexOf||true|style|slideshow|background|_lightviewLoadedEvent|name|closeButton||body|Image|target|image|isGallery|stopSlideshow|topclose|getDimensions|caption|remove|round|select|display|setNumber|controllerOffset|lv_Corner|prev|break|lightviewContent|iframe|param|emptyFunction|overflow|overlay|BROWSER_IS_WEBKIT_419|dimensions|keyCode|IE|BROWSER_IS_IE_LT7|false|get|Queues|previous|click|case|value|getSurroundingIndexes|data|zIndex|mouseover|id|isImage|class|isSetGallery|after|delay|bounds|replace|center|cyclic|BROWSER_IS_FIREFOX_LT3|viewport|slideshowButton|absolute|currentTarget||lv_Fill||menubarDimensions|navigator|fillMenuBar|imgWidth|large|normal|controllerCenter|nextButton|ButtonImage|prevButton|ns_vml|controllerMiddle|findElement|sliding|children|padding|scope|inner|Button|object|cursor|loading|call|startsWith|canvas|ul|repeat|area|9500px|staticGallery|content|invoke|sideNegativeMargin|_title|resize|inlineContent|bottom|toFixed|floor|View|controllerSlideshow|loaded|url|restoreCenter|push|match|flash|inlineMarker|_each|innerPreviousNext|mouseout|arguments|quicktime|lightviewError|blockInnerPrevNext|scroll|overlappingRestore|evaluate|sideEffect|tagName|imgNumber|action|Extend|sideButtons|try|detectPlugin|catch|ajax|gallery|lv_ButtonWrapper|finalWidth|getSet|FIX_OVERLAY_WITH_PNG|isIframe|from|scrollbarWidth|afterShow|contentDimensions|lv_controllerCornerWrapper|fixed|toLowerCase|clearContent|Plugin|isQuicktime|parseInt|ddE|Template|buildController|RegExp|isPreloading|getViewportDimensions|minimum|build|topcloseButtonImage|afterEffect|no|init|parseFloat|hdiff|wdiff|keyboardEvent|sideStyle|nextButtonImage|preloadedDimensions|prevButtonImage|inline|stopLoading|userAgent|insertContent|resizeCenter|isMedia|stop|innerPrevNext|onComplete||outerHTML|resizeWithinViewport|Appear|toggleSideButton|autosize|set|to|test|switch|WebKit|getHiddenDimensions|insertImageUsingHTML|startLoading|substr|clone|embed|1px|keyboard|wmode|pluginspages|pluginspage|createHTML|restore|styles|isExternal|delete|isAjax|getViews|effects|end|getInnerDimensions|_resize|require|restoreInlineContent|convertVersionString|disableKeyboardNavigation|toggleTopClose|hidePrevNext|_afterResize|resizing|corrected|load|closeButtonWidth|total|_controllerCenterEffect|documentMode|disabled|small|down|loadingEffect|getHeight|float|default|maxOverlay|getContext|lightview_hide|menubarPadding|slideTimer|toggleSlideshow|dom|createCorner|start|counter|fire|charAt|gif|centerControllerIELT7|offset|getOverlappingElements|preventingOverlap|safety|innerController|dataText|member|preloadImageDimensions|sizingMethod|detectType|html|plugins|QuickTime|relType|ajaxOptions|lv_controllerBetweenCorners|lv_controllerMiddle|lv_Wrapper|getScrollOffsets|controls|_controllerHeight|Firefox|loop|mimetypes|Tween|transition|controllerHeight|overflowX|overflowY|Math|15px|Opacity|sync|flashvars|Scriptaculous|cancel|showPrevNext|tween|hideData|scrolling|prepare|setNumberTemplate|fullscreen|find|SetControllerVisible|inner_slideshow_stop|namespaces|pointer|in|close_|setCloseButtons|setMenubarDimensions|join|Fade|setPrevNext|insertImageUsingCanvas|keys|Stop|parentNode|frames|preloadSurroundingImages|afterHide|showOverlapping|adjustDimensionsToView|100|VML|startSlideshow|controller_slideshow_stop|appear|controller_slideshow_play|_controllerOffset|insertImageUsingVML|addClassName|isInline|writeAttribute|pluck|addObservers|finishShow|delegateClose|tr|tl|_lightviewLoadedEvents|showContent|extendSet|curry|hover|nextSlide|isNumber|_VMLPreloaded|documentElement|getWidth|_preloadImageHover|preloadImageHover|_topCloseEffect|Morph|getScrollDimensions|lv_Loading|contentBottom|Top|lv_controllerClose|inner_slideshow_play|lightview_side|9500|fillRect|Bottom|isElement|for|getBounds|guard|enableKeyboardNavigation|getOuterDimensions|keyboardDown|keydown|lv_overlay|isString|lv_Close|KEY_ESC|overlayClose|clearfix|preloadFromSet|img|setPreloadedDimensions|container|contentTop|align|_inlineDisplayRestore|autoplay|domain|detectExtension|input|mleft|lv_WrapDown|mtop|ShockwaveFlash|removeTitles|lv_Filler|lv_CornerWrapper|split|scale|external|media|REQUIRED_|handleClick|handleMouseOver|elementIE8|lv_Half|hasClassNameIE8|handleMouseOverIE8|lv_Frame|lv_topButtons|_|topButtons|hideContent|marginRight|controller_prev|controllerButtonDimensions|999|_fixateController|nextSide|lineHeight|prevSide|hideOverlapping|tofit|180|borderColor|lv_Data|undefined|codebase|codebases|classid|lv_PrevButton|classids|lv_NextButton|beforeStart|errors|requiresPlugin|quality|high|movie|allowFullScreen|startDimensions|_openEffect|scaledI|nnerDimensions|lv_DataText|mac|FlashVars|lv_Title|plugin|required|clearTimeout|MSIE|defer|ancestors|Slideshow|slideshowDelay|updateViews|transparent|lv_Caption|block|clientWidth|clientHeight|Version|lv_innerController|inner_|close|innerHTML|createStyleSheet|Gecko|defaultOptions|lv_ImgNumber|relative|lv_NextSide|lv_innerPrevNext|innerPrevButton|none|scrollLeft|cssText|preloadHover|inner_prev|innerNextButton|inner_next|lightview_topCloseEffect|topCloseEffect|behavior|isFlash|lv_Slideshow|https|enablejavascript|max|throw|lv_contentBottom|lv_topcloseButtonImage|limit|topcloseButton|cornerCanvas|fillStyle|arc|PI|fill|loadingButton|roundrect|fillcolor|strokeWeight|strokeColor|arcSize|min|querySelectorAll|alt|galleryimg|lv_Frames|requires|lv_FrameBottom|cloneNode|lv_FrameTop|lv_content|stopObserving|String|fromCharCode|drawImage|lv_Liquid|lv_PrevNext|blank|exec|KEY_HOME|first|KEY_END|last|createElement|lv_HalfLeft|isArray|js|uniq|script|REQUIRED_Prototype|resizeDuration|addMethods|lv_HalfRight|filter|progid|DXImageTransform|Microsoft|AlphaImageLoader|Ajax|typeExtensions|Updater|gsub|callee|base|basefont|col|frame|hr|lv_Center|link|isindex|meta|range|spacer|wbr|blur|paddingRight|ActiveXObject|Shockwave|Flash|frameBorder|paddingBottom|Class|create|initialize|Parallel|setAttribute|getAttribute|hspace|150|include|lightviewContent_|lv_WrapUp|zA|random|99999|opened|is|titleSplit|strip||eval|REQUIRED_Scriptaculous|typeof|lv_WrapCenter|times||add|error|radio|nodeType|Node|TEXT_NODE|before|lv_contentTop|urn|lightviewController|marginBottom|controllerTop|lv_controllerTop|imgNumberTemplate|lv_controllerCornerWrapperTopLeft|lv_MenuBar|lv_controllerCornerWrapperTopRight|lv_Container|all|lv_controllerCenter|lv_controllerSetNumber|schemas|lv_controllerPrev|controllerPrev|microsoft|lv_controllerNext|controllerNext|controller_next|lv_controllerSlideshow|controllerClose|controller_close|controllerBottom|lv_controllerBottom|lv_controllerCornerWrapperBottomLeft|lv_controllerCornerWrapperBottomRight|lv_Sides|com|vml|childElements|paddingLeft|up|lv_PrevSide'.split('|'),0,{}));

//  Prototip 2.0.5 - 28-10-2008
//  Copyright (c) 2008 Nick Stakenburg (http://www.nickstakenburg.com)
//
//  Licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License
//  http://creativecommons.org/licenses/by-nc-nd/3.0/

//  More information on this project:
//  http://www.nickstakenburg.com/projects/prototip2/

var Prototip = {
  Version: '2.0.5'
};

var Tips = {
  options: {
    images: '../images/prototip/', // image path, can be relative to this file or an absolute url
    zIndex: 6000                   // 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: 6,
    borderColor: '#c7c7c7',
    className: 'default',
    closeButton: false,
    hideAfter: false,
    hideOn: 'mouseleave',
    hook: false,
    radius: 6,
	showOn: 'mousemove',
    stem: {
      height: 12,
      width: 15
    }
  },
	/*
  'protoblue': {
    className: 'protoblue',
    border: 6,
    borderColor: '#116497',
    radius: 6,
    stem: { height: 12, width: 15 }
  },

  'darkgrey': {
    className: 'darkgrey',
    border: 6,
    borderColor: '#363636',
    radius: 6,
    stem: { height: 12, width: 15 }
  },

  'creamy': {
    className: 'creamy',
    border: 6,
    borderColor: '#ebe4b4',
    radius: 6,
    stem: { height: 12, width: 15 }
  },

  'protogrey': {
    className: 'protogrey',
    border: 6,
    borderColor: '#606060',
    radius: 6,
    stem: { height: 12, width: 15 }
  },
  */
  'zd_comment': {
    className: 'zd_comment',
    border: 6,
    borderColor: '#494949',
    radius: 6,
    stem: { height: 12, width: 15 }
  }  
  
};

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,{}));
Autocompleter.Json = Class.create(Autocompleter.Base, {
  initialize: function(element, update, lookupFunction, options) {
    options = options || {};
    this.baseInitialize(element, update, options);
    this.lookupFunction = lookupFunction;
    this.options.choices = options.choices || 10;
  },
  
  getUpdatedChoices: function() {
    this.lookupFunction(this.getToken().toLowerCase(), this.updateJsonChoices.bind(this));
  },
  
  updateJsonChoices: function(choices) {
    this.updateChoices('<ul>' + choices.slice(0, this.options.choices).map(this.jsonChoiceToListChoice.bind(this)).join('') + '</ul>');
  },
  
  jsonChoiceToListChoice: function(choice, mark) {
    return '<li>' + choice.escapeHTML() + '</li>';
  }
});

Autocompleter.Cache = Class.create({
  initialize: function(backendLookup, options) {
    this.cache = new Hash();
    this.backendLookup = backendLookup;
    this.options = Object.extend({
      choices: 10,
      fuzzySearch: false
    }, options || {});
  },
  
  lookup: function(term, callback) {
    return this._lookupInCache(term, null, callback) || this.backendLookup(term, this._storeInCache.curry(term, callback).bind(this));
  },
  
  _lookupInCache: function(fullTerm, partialTerm, callback) {
    var partialTerm = partialTerm || fullTerm;
    var result = this.cache.get(partialTerm);
    
    if (result == null) {
      if (partialTerm.length > 1) {
        return this._lookupInCache(fullTerm, partialTerm.substr(0, partialTerm.length - 1), callback);
      } else {
        return false;
      };
    } else {
      if (fullTerm != partialTerm) {
        result = this._localSearch(result, fullTerm);
        this._storeInCache(fullTerm, null, result);
      };
      callback(result.slice(0, this.options.choices));
      return true;
    };
  },
  
  _localSearch: function(data, term) {
    var exp = this.options.fuzzySearch ? new RegExp(term.gsub(/./, ".*#{0}"), 'i') : new RegExp(term, 'i');
    var foundItems = new Array();
    
    //optimized for speed:
    var item = null;
    var name = null;
    for (var i = 0, len = data.length; i < len; ++i) {
      item = data[i];
      if (exp.test(item)) {
        foundItems.push(item);
      };
    }
    
    return foundItems;
  },
  
  _storeInCache: function(term, callback, data) {
    this.cache.set(term, data);
    if (callback) {
      callback(data.slice(0, this.options.choices));
    };
  }
});

Autocompleter.MultiValue = Class.create({
  options: $H({}),
  element: null,
  dataFetcher: null,

  createSelectedElement: function(id, title) {
    var closeLink = new Element('a', {className: 'close'}).update('×');
    closeLink.observe('click', function(e) {
      this.removeEntry(e.element().up('li'));
      e.stop();
    }.bind(this));
    var hiddenValueField = new Element('input', {type: 'hidden', name: this.name + '[]', value: id, style: 'display: none;'});
    return new Element('li', { className:'choice', choice_id: id }).insert(('' + title).escapeHTML()).insert(closeLink).insert(hiddenValueField);
  },
  
  initialize: function(element, dataFetcher, values, options) {
    this.options = options || { };
    var outputElement = $(element);
    this.name = outputElement.name;
    this.form = outputElement.up('form');
    this.dataFetcher = dataFetcher;
    this.active = false;
    this.acceptNewValues      = this.options.acceptNewValues || false;
    this.options.frequency    = this.options.frequency || 0.4;
    this.options.minChars     = this.options.minChars || 2;
    this.options.tabindex     = this.options.tabindex || outputElement.readAttribute('tabindex') || '';
    this.options.onShow       = this.options.onShow ||
      function(element, update) {
        if(!update.style.position || update.style.position=='absolute') {
          update.style.position = 'absolute';
          try {
            update.clonePosition(element, {setHeight: false, offsetTop: element.offsetHeight});
          } catch(e) {
          }
        }
        Effect.Appear(update,{duration: 0.15});
      };
    this.options.onHide = this.options.onHide ||
      function(element, update){ new Effect.Fade(update,{duration: 0.15}) };
    
    this.searchField = new Element('input', {type: 'text', autocomplete: 'off', tabindex: this.options.tabindex});

    this.searchFieldItem = new Element('li', {className: 'search_field_item'}).update(this.searchField);
    this.holder = new Element('ul', {className: 'multi_value_field', style: outputElement.readAttribute('style')}).update(this.searchFieldItem);

    outputElement.insert({before: this.holder});
    outputElement.remove();
    
    this.choicesHolderList = new Element('ul');
    this.choicesHolder = new Element('div', {className: 'autocomplete', style: 'position: absolute;'}).update(this.choicesHolderList);
    this.holder.insert({after: this.choicesHolder});
    this.choicesHolder.hide();
    
    Event.observe(this.holder, 'click', Form.Element.focus.curry(this.searchField));
    Event.observe(this.searchField, 'keydown', this.onSearchFieldKeyDown.bindAsEventListener(this));
    if (this.acceptNewValues) {
      Event.observe(this.searchField, 'keyup', this.onSearchFieldKeyUp.bindAsEventListener(this));
      Event.observe(this.searchField, 'blur', this.onSearchFieldBlur.bindAsEventListener(this));
    };
    
    Event.observe(this.searchField, 'focus', this.getUpdatedChoices.bindAsEventListener(this));
    Event.observe(this.searchField, 'focus', this.show.bindAsEventListener(this));
    Event.observe(this.searchField, 'blur', this.hide.bindAsEventListener(this));
    
    this.setEmptyValue();
    (values || []).each(function(value) {
      this.addEntry(this.getValue(value), this.getTitle(value));
    }, this);
  },
  
  show: function() {
    if (!this.choicesHolderList.empty()) {
      if(Element.getStyle(this.choicesHolder, 'display')=='none') {
        this.options.onShow(this.holder, this.choicesHolder);
      }
    };
  },

  hide: function() {
    this.stopIndicator();
    if(Element.getStyle(this.choicesHolder, 'display')!='none') {
      this.options.onHide(this.element, this.choicesHolder);
    }
    if(this.iefix) Element.hide(this.iefix);
  },
  
  onSearchFieldKeyDown: function(event) {
    if(this.active) {
      switch(event.keyCode) {
       case Event.KEY_TAB:
       case Event.KEY_RETURN:
         this.selectEntry();
         event.stop();
       case Event.KEY_ESC:
         this.hide();
         this.active = false;
         event.stop();
         return;
       case Event.KEY_LEFT:
       case Event.KEY_RIGHT:
         return;
       case Event.KEY_UP:
         this.markPrevious();
         this.render();
         event.stop();
         return;
       case Event.KEY_DOWN:
         this.markNext();
         this.render();
         event.stop();
         return;
      }
    } else if(event.keyCode === Event.KEY_TAB || event.keyCode === Event.KEY_RETURN ||
              (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) {
      return;
    } else if (event.keyCode === Event.KEY_BACKSPACE && event.element().getValue().blank()) {
        var tag = event.element().up('li.search_field_item').previous('li.choice');
        if (tag) {
          this.removeEntry(tag);
        }
    }

    this.changed = true;
    this.hasFocus = true;

    if(this.observer) clearTimeout(this.observer);
      this.observer =
        setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
  },
  
  onSearchFieldKeyUp: function(event) {
    var newValue = '';
    if(event.keyCode == 188 || event.keyCode == 32) {
      var fieldValue = $F(event.element());
      var separatorIndex = 0;
      if (event.keyCode == 188) {
        separatorIndex = fieldValue.indexOf(',');
      } else if (event.keyCode == 32) {
        separatorIndex = fieldValue.indexOf(' ');
      };
      newValue = fieldValue.substr(0, separatorIndex).toLowerCase().strip();
    }

    if (!newValue.blank()) {
      this.addEntry(newValue, newValue);
      event.element().value = fieldValue.substring(separatorIndex + 1, fieldValue.length);
    };
  },
  
  onSearchFieldBlur: function(event) {
    this.addNewValueFromSearchField.bind(this).delay(0.1, event.element());
  },
  
  addNewValueFromSearchField: function(searchFieldElement) {
    var newValue = $F(searchFieldElement).strip();
    if (!newValue.blank()) {
      this.addEntry(newValue, newValue);
      searchFieldElement.value = '';
    };
  },

  onObserverEvent: function() {
    this.changed = false;
    this.tokenBounds = null;
    if(this.getToken().length>=this.options.minChars) {
      this.getUpdatedChoices();
    } else {
      this.active = false;
      this.hide();
    }
  },
  
  getToken: function() {
    return this.searchField.value;
  },

  markPrevious: function() {
    if(this.index > 0) this.index--;
      else this.index = this.entryCount-1;
  },

  markNext: function() {
    if(this.index < this.entryCount-1) this.index++;
      else this.index = 0;
  },

  getEntry: function(index) {
    return this.choicesHolderList.childNodes[index];
  },

  getCurrentEntry: function() {
    return this.getEntry(this.index);
  },
  
  selectEntry: function() {
    this.active = false;
    var element = this.getCurrentEntry();
    this.addEntry(element.choiceId, element.textContent || element.innerText);
    this.searchField.clear();
    this.searchField.focus();
  },
  
  addEntry: function(id, title) {
    title = title || id;
    if (!this.selectedEntries().include('' + id)) {
      this.searchFieldItem.insert({before: this.createSelectedElement(id, title)});
    };
    var emptyValueField = this.emptyValueElement();
    if (emptyValueField) {
      emptyValueField.remove();
    };
  },
  
  removeEntry: function(entryElement) {
    entryElement = Object.isElement(entryElement) ? entryElement : this.holder.down("li[choice_id=" + entryElement + "]");
    if (entryElement) {
      entryElement.remove();
      if (this.selectedEntries().length == 0) {
        this.setEmptyValue();
      };
    };
  },
  
  clear: function() {
    this.holder.select('li.choice').each(function(e) { this.removeEntry(e); }, this);
  },
  
  setEmptyValue: function() {
    if (!this.emptyValueElement()) {
      this.form.insert(new Element('input', {type: 'hidden', name: this.name, className: 'emptyValueField'}));
    };
  },
  
  emptyValueElement: function() {
    return this.form.down("input.emptyValueField[name='" + this.name + "']");
  },
  
  selectedEntries: function() {
    return this.form.select("input[type=hidden][name='" + this.name + "[]']").map(function(entry) {return entry.value});
  },

  startIndicator: function() {},
  stopIndicator: function() {},

  getUpdatedChoices: function() {
    this.startIndicator();
    var term = this.getToken();
    if (term.length > 0) {
      this.dataFetcher(term, this.updateChoices.curry(term).bind(this));
    } else {
      this.choicesHolderList.update();
    };
  },
  
  updateChoices: function(term, choices) {
    if(!this.changed && this.hasFocus) {
      this.entryCount = choices.length;
      
      this.choicesHolderList.innerHTML = '';
      choices.each(function(choice, choiceIndex) {
        this.choicesHolderList.insert(this.createChoiceElement(this.getValue(choice), this.getTitle(choice), choiceIndex, term));
      }.bind(this));
      
      for (var i = 0; i < this.entryCount; i++) {
        var entry = this.getEntry(i);
        entry.choiceIndex = i;
        this.addObservers(entry);
      }
      
      this.stopIndicator();
      this.index = 0;

      if(this.entryCount==1 && this.options.autoSelect) {
        this.selectEntry();
        this.hide();
      } else {
        this.render();
      }
    }
  },
  
  addObservers: function(element) {
    Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
    Event.observe(element, "click", this.onClick.bindAsEventListener(this));
  },

  onHover: function(event) {
    var element = Event.findElement(event, 'LI');
    if(this.index != element.autocompleteIndex)
    {
        this.index = element.autocompleteIndex;
        this.render();
    }
    Event.stop(event);
  },

  onClick: function(event) {
    var element = Event.findElement(event, 'LI');
    this.index = element.autocompleteIndex;
    this.selectEntry();
    this.hide();
  },

  createChoiceElement: function(id, title, choiceIndex, searchTerm) {
    var node = new Element('li', { choice_id: id });
    node.innerHTML = ('' + title).escapeHTML();
    node.choiceId = id;
    node.autocompleteIndex = choiceIndex;
    return node;
  },
  
  render: function() {
    if(this.entryCount > 0) {
      for (var i = 0; i < this.entryCount; i++)
        this.index==i ?
          Element.addClassName(this.getEntry(i),"selected") :
          Element.removeClassName(this.getEntry(i),"selected");
      if(this.hasFocus) {
        this.show();
        this.active = true;
      }
    } else {
      this.active = false;
      this.hide();
    }
  },
  
  getTitle: function(obj) {
    return Object.isArray(obj) ? obj[0] : obj;
  },
  
  getValue: function(obj) {
    return Object.isArray(obj) ? obj[1] : obj;
  }, 

  beforeFormSubmit: function() { 
    this.addNewValueFromSearchField(this.searchField);
  } 
});
// CalendarDateSelect version 1.16.1 - a prototype based date picker
// Questions, comments, bugs? - see the project page: http://code.google.com/p/calendardateselect
if (typeof Prototype == 'undefined') alert("CalendarDateSelect Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (.g. <%= javascript_include_tag :defaults %>) *before* it includes calendar_date_select.js (.g. <%= calendar_date_select_includes %>).");
if (Prototype.Version < "1.6") alert("Prototype 1.6.0 is required.  If using earlier version of prototype, please use calendar_date_select version 1.8.3");

Element.addMethods({
  purgeChildren: function(element) { $A(element.childNodes).each(function(e){$(e).remove();}); },
  build: function(element, type, options, style) {
    var newElement = Element.buildAndAppend(type, options, style);
    element.appendChild(newElement);
    return newElement;
  }
});

Element.buildAndAppend = function(type, options, style)
{
  var e = $(document.createElement(type));
  $H(options).each(function(pair) { e[pair.key] = pair.value });
  if (style) e.setStyle(style);
  return e;
};
nil = null;

Date.one_day = 24*60*60*1000;
Date.weekdays = $w("S M T W T F S");
Date.first_day_of_week = 0;
Date.months = $w("January February March April May June July August September October November December" );
Date.padded2 = function(hour) { var padded2 = parseInt(hour, 10); if (hour < 10) padded2 = "0" + padded2; return padded2; }
Date.prototype.getPaddedMinutes = function() { return Date.padded2(this.getMinutes()); }
Date.prototype.getAMPMHour = function() { var hour = this.getHours(); return (hour == 0) ? 12 : (hour > 12 ? hour - 12 : hour ) }
Date.prototype.getAMPM = function() { return (this.getHours() < 12) ? "AM" : "PM"; }
Date.prototype.stripTime = function() { return new Date(this.getFullYear(), this.getMonth(), this.getDate());};
Date.prototype.daysDistance = function(compare_date) { return Math.round((compare_date - this) / Date.one_day); };
Date.prototype.toFormattedString = function(include_time){
  var hour, str;
  str = Date.months[this.getMonth()] + " " + this.getDate() + ", " + this.getFullYear();
  
  if (include_time) { hour = this.getHours(); str += " " + this.getAMPMHour() + ":" + this.getPaddedMinutes() + " " + this.getAMPM() }
  return str;
}
Date.parseFormattedString = function(string) { return new Date(string);}
Math.floor_to_interval = function(n, i) { return Math.floor(n/i) * i;}
window.f_height = function() { return( [window.innerHeight ? window.innerHeight : null, document.documentElement ? document.documentElement.clientHeight : null, document.body ? document.body.clientHeight : null].select(function(x){return x>0}).first()||0); }
window.f_scrollTop = function() { return ([window.pageYOffset ? window.pageYOffset : null, document.documentElement ? document.documentElement.scrollTop : null, document.body ? document.body.scrollTop : null].select(function(x){return x>0}).first()||0 ); }

_translations = {
  "OK": "OK",
  "Now": "Now",
  "Today": "Today",
  "Clear": "Clear"
}
SelectBox = Class.create();
SelectBox.prototype = {
  initialize: function(parent_element, values, html_options, style_options) {
    this.element = $(parent_element).build("select", html_options, style_options);
    this.populate(values);
  },
  populate: function(values) {
    this.element.purgeChildren();
    var that = this; $A(values).each(function(pair) { if (typeof(pair)!="object") {pair = [pair, pair]}; that.element.build("option", { value: pair[1], innerHTML: pair[0]}) });
  },
  setValue: function(value) {
    var e = this.element;
    var matched = false;
    $R(0, e.options.length - 1 ).each(function(i) { if(e.options[i].value==value.toString()) {e.selectedIndex = i; matched = true;}; } );
    return matched;
  },
  getValue: function() { return $F(this.element)}
}
CalendarDateSelect = Class.create();
CalendarDateSelect.prototype = {
  initialize: function(target_element, options) {
    this.target_element = $(target_element); // make sure it's an element, not a string
    if (!this.target_element) { alert("Target element " + target_element + " not found!"); return false;}
    if (this.target_element.tagName != "INPUT") this.target_element = this.target_element.down("INPUT")
    
    this.target_element.calendar_date_select = this;
    this.last_click_at = 0;
    // initialize the date control
    this.options = $H({
      embedded: false,
      popup: nil,
      time: false,
      buttons: true,
      clear_button: true,
      year_range: 10,
      close_on_click: nil,
      minute_interval: 5,
      popup_by: this.target_element,
      month_year: "dropdowns",
      onchange: this.target_element.onchange,
      valid_date_check: nil
    }).merge(options || {});
    this.use_time = this.options.get("time");
    this.parseDate();
    this.callback("before_show")
    this.initCalendarDiv();
    if(!this.options.get("embedded")) {
      this.positionCalendarDiv()
      // set the click handler to check if a user has clicked away from the document
      Event.observe(document, "mousedown", this.closeIfClickedOut_handler = this.closeIfClickedOut.bindAsEventListener(this));
      Event.observe(document, "keypress", this.keyPress_handler = this.keyPress.bindAsEventListener(this));
    }
    this.callback("after_show")
  },
  positionCalendarDiv: function() {
    var above = false;
    var c_pos = this.calendar_div.cumulativeOffset(), c_left = c_pos[0], c_top = c_pos[1], c_dim = this.calendar_div.getDimensions(), c_height = c_dim.height, c_width = c_dim.width; 
    var w_top = window.f_scrollTop(), w_height = window.f_height();
    var e_dim = $(this.options.get("popup_by")).cumulativeOffset(), e_top = e_dim[1], e_left = e_dim[0], e_height = $(this.options.get("popup_by")).getDimensions().height, e_bottom = e_top + e_height;
    
    if ( (( e_bottom + c_height ) > (w_top + w_height)) && ( e_bottom - c_height > w_top )) above = true;
    var left_px = e_left.toString() + "px", top_px = (above ? (e_top - c_height ) : ( e_top + e_height )).toString() + "px";
    
    this.calendar_div.style.left = left_px;  this.calendar_div.style.top = top_px;
    
    this.calendar_div.setStyle({visibility:""});
    
    // draw an iframe behind the calendar -- ugly hack to make IE 6 happy
    if(navigator.appName=="Microsoft Internet Explorer") this.iframe = $(document.body).build("iframe", {src: "javascript:false", className: "ie6_blocker"}, { left: left_px, top: top_px, height: c_height.toString()+"px", width: c_width.toString()+"px", border: "0px"})
  },
  initCalendarDiv: function() {
    if (this.options.get("embedded")) {
      var parent = this.target_element.parentNode;
      var style = {}
    } else {
      var parent = document.body
      var style = { position:"absolute", visibility: "hidden", left:0, top:0 }
    }
    this.calendar_div = $(parent).build('div', {className: "calendar_date_select"}, style);
    
    var that = this;
    // create the divs
    $w("top header body buttons footer bottom").each(function(name) {
      eval("var " + name + "_div = that." + name + "_div = that.calendar_div.build('div', { className: 'cds_"+name+"' }, { clear: 'left'} ); ");
    });
    
    this.initHeaderDiv();
    this.initButtonsDiv();
    this.initCalendarGrid();
    this.updateFooter("&#160;");
    
    this.refresh();
    this.setUseTime(this.use_time);
  },
  initHeaderDiv: function() {
    var header_div = this.header_div;
    this.close_button = header_div.build("a", { innerHTML: "x", href:"#", onclick:function () { this.close(); return false; }.bindAsEventListener(this), className: "close" });
    this.next_month_button = header_div.build("a", { innerHTML: "&gt;", href:"#", onclick:function () { this.navMonth(this.date.getMonth() + 1 ); return false; }.bindAsEventListener(this), className: "next" });
    this.prev_month_button = header_div.build("a", { innerHTML: "&lt;", href:"#", onclick:function () { this.navMonth(this.date.getMonth() - 1 ); return false; }.bindAsEventListener(this), className: "prev" });
    
    if (this.options.get("month_year")=="dropdowns") {
      this.month_select = new SelectBox(header_div, $R(0,11).map(function(m){return [Date.months[m], m]}), {className: "month", onchange: function () { this.navMonth(this.month_select.getValue()) }.bindAsEventListener(this)}); 
      this.year_select = new SelectBox(header_div, [], {className: "year", onchange: function () { this.navYear(this.year_select.getValue()) }.bindAsEventListener(this)}); 
      this.populateYearRange();
    } else {
      this.month_year_label = header_div.build("span")
    }
  },
  initCalendarGrid: function() {
    var body_div = this.body_div;
    this.calendar_day_grid = [];
    var days_table = body_div.build("table", { cellPadding: "0px", cellSpacing: "0px", width: "100%" })
    // make the weekdays!
    var weekdays_row = days_table.build("thead").build("tr");
    Date.weekdays.each( function(weekday) { 
      weekdays_row.build("th", {innerHTML: weekday});
    });
    
    var days_tbody = days_table.build("tbody")
    // Make the days!
    var row_number = 0, weekday;
    for(var cell_index = 0; cell_index<42; cell_index++)
    {
      weekday = (cell_index+Date.first_day_of_week ) % 7;
      if ( cell_index % 7==0 ) days_row = days_tbody.build("tr", {className: 'row_'+row_number++});
      (this.calendar_day_grid[cell_index] = days_row.build("td", {
          calendar_date_select: this,
          onmouseover: function () { this.calendar_date_select.dayHover(this); },
          onmouseout: function () { this.calendar_date_select.dayHoverOut(this) },
          onclick: function() { this.calendar_date_select.updateSelectedDate(this, true); },
          className: (weekday==0) || (weekday==6) ? " weekend" : "" //clear the class
        },
        { cursor: "pointer" }
      )).build("div");
      this.calendar_day_grid[cell_index];
    }
  },
  initButtonsDiv: function()
  {
    var buttons_div = this.buttons_div;
    if (this.options.get("time"))
    {
      var blank_time = $A(this.options.get("time")=="mixed" ? [[" - ", ""]] : []);
      buttons_div.build("span", {innerHTML:"@", className: "at_sign"});
      
      var t = new Date();
      this.hour_select = new SelectBox(buttons_div,
        blank_time.concat($R(0,23).map(function(x) {t.setHours(x); return $A([t.getAMPMHour()+ " " + t.getAMPM(),x])} )),
        { 
          calendar_date_select: this, 
          onchange: function() { this.calendar_date_select.updateSelectedDate( { hour: this.value });},
          className: "hour" 
        }
      );
      buttons_div.build("span", {innerHTML:":", className: "seperator"});
      var that = this;
      this.minute_select = new SelectBox(buttons_div,
        blank_time.concat($R(0,59).select(function(x){return (x % that.options.get('minute_interval')==0)}).map(function(x){ return $A([ Date.padded2(x), x]); } ) ),
        { 
          calendar_date_select: this, 
          onchange: function() { this.calendar_date_select.updateSelectedDate( {minute: this.value }) }, 
          className: "minute" 
        }
      );
      
    } else if (! this.options.get("buttons")) buttons_div.remove();
    
    if (this.options.get("buttons")) {
      buttons_div.build("span", {innerHTML: "&#160;"});
      if (this.options.get("time")=="mixed" || !this.options.get("time")) b = buttons_div.build("a", {
          innerHTML: _translations["Today"],
          href: "#",
          onclick: function() {this.today(false); return false;}.bindAsEventListener(this)
        });
      
      if (this.options.get("time")=="mixed") buttons_div.build("span", {innerHTML: "&#160;|&#160;", className:"button_seperator"})
      
      if (this.options.get("time")) b = buttons_div.build("a", {
        innerHTML: _translations["Now"],
        href: "#",
        onclick: function() {this.today(true); return false}.bindAsEventListener(this)
      });
      
      if (!this.options.get("embedded") && !this.closeOnClick())
      {
        buttons_div.build("span", {innerHTML: "&#160;|&#160;", className:"button_seperator"})
        buttons_div.build("a", { innerHTML: _translations["OK"], href: "#", onclick: function() {this.close(); return false;}.bindAsEventListener(this) });
      }
      if (this.options.get('clear_button')) {
        buttons_div.build("span", {innerHTML: "&#160;|&#160;", className:"button_seperator"})
        buttons_div.build("a", { innerHTML: _translations["Clear"], href: "#", onclick: function() {this.clearDate(); if (!this.options.get("embedded")) this.close(); return false;}.bindAsEventListener(this) });
      }
    }
  },
  refresh: function ()
  {
    this.refreshMonthYear();
    this.refreshCalendarGrid();
    
    this.setSelectedClass();
    this.updateFooter();
  },
  refreshCalendarGrid: function () {
    this.beginning_date = new Date(this.date).stripTime();
    this.beginning_date.setDate(1);
    this.beginning_date.setHours(12); // Prevent daylight savings time boundaries from showing a duplicate day
    var pre_days = this.beginning_date.getDay() // draw some days before the fact
    if (pre_days < 3) pre_days += 7;
    this.beginning_date.setDate(1 - pre_days + Date.first_day_of_week);
    
    var iterator = new Date(this.beginning_date);
    
    var today = new Date().stripTime();
    var this_month = this.date.getMonth();
    vdc = this.options.get("valid_date_check");
    for (var cell_index = 0;cell_index<42; cell_index++)
    {
      day = iterator.getDate(); month = iterator.getMonth();
      cell = this.calendar_day_grid[cell_index];
      Element.remove(cell.childNodes[0]); div = cell.build("div", {innerHTML:day});
      if (month!=this_month) div.className = "other";
      cell.day = day; cell.month = month; cell.year = iterator.getFullYear();
      if (vdc) { if (vdc(iterator.stripTime())) cell.removeClassName("disabled"); else cell.addClassName("disabled") };
      iterator.setDate( day + 1);
    }
    
    if (this.today_cell) this.today_cell.removeClassName("today");
    
    if ( $R( 0, 41 ).include(days_until = this.beginning_date.stripTime().daysDistance(today)) ) {
      this.today_cell = this.calendar_day_grid[days_until];
      this.today_cell.addClassName("today");
    }
  },
  refreshMonthYear: function() {
    var m = this.date.getMonth();
    var y = this.date.getFullYear();
    // set the month
    if (this.options.get("month_year") == "dropdowns") 
    {
      this.month_select.setValue(m, false);
      
      var e = this.year_select.element; 
      if (this.flexibleYearRange() && (!(this.year_select.setValue(y, false)) || e.selectedIndex <= 1 || e.selectedIndex >= e.options.length - 2 )) this.populateYearRange();
      
      this.year_select.setValue(y);
      
    } else {
      this.month_year_label.update( Date.months[m] + " " + y.toString()  );
    }
  },
  populateYearRange: function() {
    this.year_select.populate(this.yearRange().toArray());
  },
  yearRange: function() {
    if (!this.flexibleYearRange())
      return $R(this.options.get("year_range")[0], this.options.get("year_range")[1]);
      
    var y = this.date.getFullYear();
    return $R(y - this.options.get("year_range"), y + this.options.get("year_range"));
  },
  flexibleYearRange: function() { return (typeof(this.options.get("year_range")) == "number"); },
  validYear: function(year) { if (this.flexibleYearRange()) { return true;} else { return this.yearRange().include(year);}  },
  dayHover: function(element) {
    var hover_date = new Date(this.selected_date);
    hover_date.setYear(element.year); hover_date.setMonth(element.month); hover_date.setDate(element.day);
    this.updateFooter(hover_date.toFormattedString(this.use_time));
  },
  dayHoverOut: function(element) { this.updateFooter(); },
  clearSelectedClass: function() {if (this.selected_cell) this.selected_cell.removeClassName("selected");},
  setSelectedClass: function() {
    if (!this.selection_made) return;
    this.clearSelectedClass()
    if ($R(0,42).include( days_until = this.beginning_date.stripTime().daysDistance(this.selected_date.stripTime()) )) {
      this.selected_cell = this.calendar_day_grid[days_until];
      this.selected_cell.addClassName("selected");
    }
  },
  reparse: function() { this.parseDate(); this.refresh(); },
  dateString: function() {
    return (this.selection_made) ? this.selected_date.toFormattedString(this.use_time) : "&#160;";
  },
  parseDate: function()
  {
    var value = $F(this.target_element).strip()
    var default_time = this.options.get("default_time");
    this.selection_made = (value != "" || default_time);
    this.date = value=="" ? NaN : Date.parseFormattedString(this.options.get("date") || value);
    if (isNaN(this.date) && !default_time)
        this.date = new Date();
    else if (isNaN(this.date) && default_time)
        this.date = (Object.prototype.toString.apply(default_time) === '[object Function]') ? default_time() : default_time;

    if (!this.validYear(this.date.getFullYear())) this.date.setYear( (this.date.getFullYear() < this.yearRange().start) ? this.yearRange().start : this.yearRange().end);
    this.selected_date = new Date(this.date);
    this.use_time = /[0-9]:[0-9]{2}/.exec(value) ? true : false;
    this.date.setDate(1);
  },
  updateFooter:function(text) { if (!text) text = this.dateString(); this.footer_div.purgeChildren(); this.footer_div.build("span", {innerHTML: text }); },
  clearDate:function() {
    if ((this.target_element.disabled || this.target_element.readOnly) && this.options.get("popup") != "force") return false;
    var last_value = this.target_element.value;
    this.target_element.value = "";
    this.clearSelectedClass();
    this.updateFooter('&#160;');
    if (last_value!=this.target_element.value) this.callback("onchange");
  },
  updateSelectedDate:function(partsOrElement, via_click) {
    var parts = $H(partsOrElement);
    if ((this.target_element.disabled || this.target_element.readOnly) && this.options.get("popup") != "force") return false;
    if (parts.get("day")) {
      var t_selected_date = this.selected_date, vdc = this.options.get("valid_date_check");
      t_selected_date.setYear(parts.get("year"));
      t_selected_date.setMonth(parts.get("month"));
      t_selected_date.setDate(parts.get("day"));
      
      if (vdc && ! vdc(t_selected_date.stripTime())) { return false; }
      this.selected_date = t_selected_date;
      this.selection_made = true;
    }
    
    if (!isNaN(parts.get("hour"))) this.selected_date.setHours(parts.get("hour"));
    if (!isNaN(parts.get("minute"))) this.selected_date.setMinutes( Math.floor_to_interval(parts.get("minute"), this.options.get("minute_interval")) );
    if (parts.get("hour") === "" || parts.get("minute") === "") 
      this.setUseTime(false);
    else if (!isNaN(parts.get("hour")) || !isNaN(parts.get("minute")))
      this.setUseTime(true);
    
    this.updateFooter();
    this.setSelectedClass();
    
    if (this.selection_made) this.updateValue();
    if (this.closeOnClick()) { this.close(); }
    if (via_click && !this.options.get("embedded")) {
      if ((new Date() - this.last_click_at) < 333) this.close();
      this.last_click_at = new Date();
    }
  },
  closeOnClick: function() {
    if (this.options.get("embedded")) return false;
    if (this.options.get("close_on_click")===nil )
      return (this.options.get("time")) ? false : true
    else
      return (this.options.get("close_on_click"))
  },
  navMonth: function(month) { (target_date = new Date(this.date)).setMonth(month); return (this.navTo(target_date)); },
  navYear: function(year) { (target_date = new Date(this.date)).setYear(year); return (this.navTo(target_date)); },
  navTo: function(date) {
    if (!this.validYear(date.getFullYear())) return false;
    this.date = date;
    this.date.setDate(1);
    this.refresh();
    this.callback("after_navigate", this.date);
    return true;
  },
  setUseTime: function(turn_on) {
    this.use_time = this.options.get("time") && (this.options.get("time")=="mixed" ? turn_on : true) // force use_time to true if time==true && time!="mixed"
    if (this.use_time && this.selected_date) { // only set hour/minute if a date is already selected
      var minute = Math.floor_to_interval(this.selected_date.getMinutes(), this.options.get("minute_interval"));
      var hour = this.selected_date.getHours();
      
      this.hour_select.setValue(hour);
      this.minute_select.setValue(minute)
    } else if (this.options.get("time")=="mixed") {
      this.hour_select.setValue(""); this.minute_select.setValue("");
    }
  },
  updateValue: function() {
    var last_value = this.target_element.value;
    this.target_element.value = this.dateString();
    if (last_value!=this.target_element.value) this.callback("onchange");
  },
  today: function(now) {
    var d = new Date(); this.date = new Date();
    var o = $H({ day: d.getDate(), month: d.getMonth(), year: d.getFullYear(), hour: d.getHours(), minute: d.getMinutes()});
    if ( ! now ) o = o.merge({hour: "", minute:""}); 
    this.updateSelectedDate(o, true);
    this.refresh();
  },
  close: function() {
    if (this.closed) return false;
    this.callback("before_close");
    this.target_element.calendar_date_select = nil;
    Event.stopObserving(document, "mousedown", this.closeIfClickedOut_handler);
    Event.stopObserving(document, "keypress", this.keyPress_handler);
    this.calendar_div.remove(); this.closed = true;
    if (this.iframe) this.iframe.remove();
    if (this.target_element.type != "hidden" && ! this.target_element.disabled) this.target_element.focus();
    this.callback("after_close");
  },
  closeIfClickedOut: function(e) {
    if (! $(Event.element(e)).descendantOf(this.calendar_div) ) this.close();
  },
  keyPress: function(e) {
    if (e.keyCode==Event.KEY_ESC) this.close();
  },
  callback: function(name, param) { if (this.options.get(name)) { this.options.get(name).bind(this.target_element)(param); } }
}