// script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008

// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/

var Builder = {
  NODEMAP: {
    AREA: 'map',
    CAPTION: 'table',
    COL: 'table',
    COLGROUP: 'table',
    LEGEND: 'fieldset',
    OPTGROUP: 'select',
    OPTION: 'select',
    PARAM: 'object',
    TBODY: 'table',
    TD: 'table',
    TFOOT: 'table',
    TH: 'table',
    THEAD: 'table',
    TR: 'table'
  },
  // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
  //       due to a Firefox bug
  node: function(elementName) {
    elementName = elementName.toUpperCase();
    
    // try innerHTML approach
    var parentTag = this.NODEMAP[elementName] || 'div';
    var parentElement = document.createElement(parentTag);
    try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
      parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
    } catch(e) {}
    var element = parentElement.firstChild || null;
      
    // see if browser added wrapping tags
    if(element && (element.tagName.toUpperCase() != elementName))
      element = element.getElementsByTagName(elementName)[0];
    
    // fallback to createElement approach
    if(!element) element = document.createElement(elementName);
    
    // abort if nothing could be created
    if(!element) return;

    // attributes (or text)
    if(arguments[1])
      if(this._isStringOrNumber(arguments[1]) ||
        (arguments[1] instanceof Array) ||
        arguments[1].tagName) {
          this._children(element, arguments[1]);
        } else {
          var attrs = this._attributes(arguments[1]);
          if(attrs.length) {
            try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
              parentElement.innerHTML = "<" +elementName + " " +
                attrs + "></" + elementName + ">";
            } catch(e) {}
            element = parentElement.firstChild || null;
            // workaround firefox 1.0.X bug
            if(!element) {
              element = document.createElement(elementName);
              for(attr in arguments[1]) 
                element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
            }
            if(element.tagName.toUpperCase() != elementName)
              element = parentElement.getElementsByTagName(elementName)[0];
          }
        } 

    // text, or array of children
    if(arguments[2])
      this._children(element, arguments[2]);

     return element;
  },
  _text: function(text) {
     return document.createTextNode(text);
  },

  ATTR_MAP: {
    'className': 'class',
    'htmlFor': 'for'
  },

  _attributes: function(attributes) {
    var attrs = [];
    for(attribute in attributes)
      attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
          '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
    return attrs.join(" ");
  },
  _children: function(element, children) {
    if(children.tagName) {
      element.appendChild(children);
      return;
    }
    if(typeof children=='object') { // array can hold nodes and text
      children.flatten().each( function(e) {
        if(typeof e=='object')
          element.appendChild(e)
        else
          if(Builder._isStringOrNumber(e))
            element.appendChild(Builder._text(e));
      });
    } else
      if(Builder._isStringOrNumber(children))
        element.appendChild(Builder._text(children));
  },
  _isStringOrNumber: function(param) {
    return(typeof param=='string' || typeof param=='number');
  },
  build: function(html) {
    var element = this.node('div');
    $(element).update(html.strip());
    return element.down();
  },
  dump: function(scope) { 
    if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope 
  
    var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
      "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
      "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
      "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
      "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
      "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
  
    tags.each( function(tag){ 
      scope[tag] = function() { 
        return Builder.node.apply(Builder, [tag].concat($A(arguments)));  
      } 
    });
  }
}


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

/** 
 * Copyright (c) 2006, David Spurr (http://www.defusion.org.uk/)
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 * 
 *     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 *     * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * http://www.opensource.org/licenses/bsd-license.php
 * 
 * See scriptaculous.js for full scriptaculous licence
 */

var CropDraggable=Class.create();
Object.extend(Object.extend(CropDraggable.prototype,Draggable.prototype),{initialize:function(_1){
this.options=Object.extend({drawMethod:function(){
}},arguments[1]||{});
this.element=$(_1);
this.handle=this.element;
this.delta=this.currentDelta();
this.dragging=false;
this.eventMouseDown=this.initDrag.bindAsEventListener(this);
Event.observe(this.handle,"mousedown",this.eventMouseDown);
Draggables.register(this);
},draw:function(_2){
var _3=Position.cumulativeOffset(this.element);
var d=this.currentDelta();
_3[0]-=d[0];
_3[1]-=d[1];
var p=[0,1].map(function(i){
return (_2[i]-_3[i]-this.offset[i]);
}.bind(this));
this.options.drawMethod(p);
}});
var Cropper={};
Cropper.Img=Class.create();
Cropper.Img.prototype={initialize:function(_7,_8){
this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true,onloadCoords:null,maxWidth:0,maxHeight:0},_8||{});
this.img=$(_7);
this.clickCoords={x:0,y:0};
this.dragging=false;
this.resizing=false;
this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent);
this.isIE=/MSIE/.test(navigator.userAgent);
this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent);
this.ratioX=0;
this.ratioY=0;
this.attached=false;
this.fixedWidth=(this.options.maxWidth>0&&(this.options.minWidth>=this.options.maxWidth));
this.fixedHeight=(this.options.maxHeight>0&&(this.options.minHeight>=this.options.maxHeight));
if(typeof this.img=="undefined"){
return;
}
$A(document.getElementsByTagName("script")).each(function(s){
if(s.src.match(/cropper\.js/)){
var _a=s.src.replace(/cropper\.js(.*)?/,"");
var _b=document.createElement("link");
_b.rel="stylesheet";
_b.type="text/css";
_b.href=_a+"cropper.css";
_b.media="screen";
document.getElementsByTagName("head")[0].appendChild(_b);
}
});
if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){
var _c=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y);
this.ratioX=this.options.ratioDim.x/_c;
this.ratioY=this.options.ratioDim.y/_c;
}
this.subInitialize();
if(this.img.complete||this.isWebKit){
this.onLoad();
}else{
Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this));
}
},getGCD:function(a,b){
if(b==0){
return a;
}
return this.getGCD(b,a%b);
},onLoad:function(){
var _f="imgCrop_";
var _10=this.img.parentNode;
var _11="";
if(this.isOpera8){
_11=" opera8";
}
this.imgWrap=Builder.node("div",{"class":_f+"wrap"+_11});
this.north=Builder.node("div",{"class":_f+"overlay "+_f+"north"},[Builder.node("span")]);
this.east=Builder.node("div",{"class":_f+"overlay "+_f+"east"},[Builder.node("span")]);
this.south=Builder.node("div",{"class":_f+"overlay "+_f+"south"},[Builder.node("span")]);
this.west=Builder.node("div",{"class":_f+"overlay "+_f+"west"},[Builder.node("span")]);
var _12=[this.north,this.east,this.south,this.west];
this.dragArea=Builder.node("div",{"class":_f+"dragArea"},_12);
this.handleN=Builder.node("div",{"class":_f+"handle "+_f+"handleN"});
this.handleNE=Builder.node("div",{"class":_f+"handle "+_f+"handleNE"});
this.handleE=Builder.node("div",{"class":_f+"handle "+_f+"handleE"});
this.handleSE=Builder.node("div",{"class":_f+"handle "+_f+"handleSE"});
this.handleS=Builder.node("div",{"class":_f+"handle "+_f+"handleS"});
this.handleSW=Builder.node("div",{"class":_f+"handle "+_f+"handleSW"});
this.handleW=Builder.node("div",{"class":_f+"handle "+_f+"handleW"});
this.handleNW=Builder.node("div",{"class":_f+"handle "+_f+"handleNW"});
this.selArea=Builder.node("div",{"class":_f+"selArea"},[Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeNorth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeEast"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeSouth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeWest"},[Builder.node("span")]),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,Builder.node("div",{"class":_f+"clickArea"})]);
this.imgWrap.appendChild(this.img);
this.imgWrap.appendChild(this.dragArea);
this.dragArea.appendChild(this.selArea);
this.dragArea.appendChild(Builder.node("div",{"class":_f+"clickArea"}));
_10.appendChild(this.imgWrap);
this.startDragBind=this.startDrag.bindAsEventListener(this);
Event.observe(this.dragArea,"mousedown",this.startDragBind);
this.onDragBind=this.onDrag.bindAsEventListener(this);
Event.observe(document,"mousemove",this.onDragBind);
this.endCropBind=this.endCrop.bindAsEventListener(this);
Event.observe(document,"mouseup",this.endCropBind);
this.resizeBind=this.startResize.bindAsEventListener(this);
this.handles=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];
this.registerHandles(true);
if(this.options.captureKeys){
this.keysBind=this.handleKeys.bindAsEventListener(this);
Event.observe(document,"keypress",this.keysBind);
}
new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)});
this.setParams();
},registerHandles:function(_13){
for(var i=0;i<this.handles.length;i++){
var _15=$(this.handles[i]);
if(_13){
var _16=false;
if(this.fixedWidth&&this.fixedHeight){
_16=true;
}else{
if(this.fixedWidth||this.fixedHeight){
var _17=_15.className.match(/([S|N][E|W])$/);
var _18=_15.className.match(/(E|W)$/);
var _19=_15.className.match(/(N|S)$/);
if(_17){
_16=true;
}else{
if(this.fixedWidth&&_18){
_16=true;
}else{
if(this.fixedHeight&&_19){
_16=true;
}
}
}
}
}
if(_16){
_15.hide();
}else{
Event.observe(_15,"mousedown",this.resizeBind);
}
}else{
_15.show();
Event.stopObserving(_15,"mousedown",this.resizeBind);
}
}
},setParams:function(){
this.imgW=this.img.width;
this.imgH=this.img.height;
$(this.north).setStyle({height:0});
$(this.east).setStyle({width:0,height:0});
$(this.south).setStyle({height:0});
$(this.west).setStyle({width:0,height:0});
$(this.imgWrap).setStyle({"width":this.imgW+"px","height":this.imgH+"px"});
$(this.selArea).hide();
var _1a={x1:0,y1:0,x2:0,y2:0};
var _1b=false;
if(this.options.onloadCoords!=null){
_1a=this.cloneCoords(this.options.onloadCoords);
_1b=true;
}else{
if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){
_1a.x1=Math.ceil((this.imgW-this.options.ratioDim.x)/2);
_1a.y1=Math.ceil((this.imgH-this.options.ratioDim.y)/2);
_1a.x2=_1a.x1+this.options.ratioDim.x;
_1a.y2=_1a.y1+this.options.ratioDim.y;
_1b=true;
}
}
this.setAreaCoords(_1a,false,false,1);
if(this.options.displayOnInit&&_1b){
this.selArea.show();
this.drawArea();
this.endCrop();
}
this.attached=true;
},remove:function(){
if(this.attached){
this.attached=false;
this.imgWrap.parentNode.insertBefore(this.img,this.imgWrap);
this.imgWrap.parentNode.removeChild(this.imgWrap);
Event.stopObserving(this.dragArea,"mousedown",this.startDragBind);
Event.stopObserving(document,"mousemove",this.onDragBind);
Event.stopObserving(document,"mouseup",this.endCropBind);
this.registerHandles(false);
if(this.options.captureKeys){
Event.stopObserving(document,"keypress",this.keysBind);
}
}
},reset:function(){
if(!this.attached){
this.onLoad();
}else{
this.setParams();
}
this.endCrop();
},handleKeys:function(e){
var dir={x:0,y:0};
if(!this.dragging){
switch(e.keyCode){
case (37):
dir.x=-1;
break;
case (38):
dir.y=-1;
break;
case (39):
dir.x=1;
break;
case (40):
dir.y=1;
break;
}
if(dir.x!=0||dir.y!=0){
if(e.shiftKey){
dir.x*=10;
dir.y*=10;
}
this.moveArea([this.areaCoords.x1+dir.x,this.areaCoords.y1+dir.y]);
Event.stop(e);
}
}
},calcW:function(){
return (this.areaCoords.x2-this.areaCoords.x1);
},calcH:function(){
return (this.areaCoords.y2-this.areaCoords.y1);
},moveArea:function(_1e){
this.setAreaCoords({x1:_1e[0],y1:_1e[1],x2:_1e[0]+this.calcW(),y2:_1e[1]+this.calcH()},true,false);
this.drawArea();
},cloneCoords:function(_1f){
return {x1:_1f.x1,y1:_1f.y1,x2:_1f.x2,y2:_1f.y2};
},setAreaCoords:function(_20,_21,_22,_23,_24){
if(_21){
var _25=_20.x2-_20.x1;
var _26=_20.y2-_20.y1;
if(_20.x1<0){
_20.x1=0;
_20.x2=_25;
}
if(_20.y1<0){
_20.y1=0;
_20.y2=_26;
}
if(_20.x2>this.imgW){
_20.x2=this.imgW;
_20.x1=this.imgW-_25;
}
if(_20.y2>this.imgH){
_20.y2=this.imgH;
_20.y1=this.imgH-_26;
}
}else{
if(_20.x1<0){
_20.x1=0;
}
if(_20.y1<0){
_20.y1=0;
}
if(_20.x2>this.imgW){
_20.x2=this.imgW;
}
if(_20.y2>this.imgH){
_20.y2=this.imgH;
}
if(_23!=null){
if(this.ratioX>0){
this.applyRatio(_20,{x:this.ratioX,y:this.ratioY},_23,_24);
}else{
if(_22){
this.applyRatio(_20,{x:1,y:1},_23,_24);
}
}
var _27=[this.options.minWidth,this.options.minHeight];
var _28=[this.options.maxWidth,this.options.maxHeight];
if(_27[0]>0||_27[1]>0||_28[0]>0||_28[1]>0){
var _29={a1:_20.x1,a2:_20.x2};
var _2a={a1:_20.y1,a2:_20.y2};
var _2b={min:0,max:this.imgW};
var _2c={min:0,max:this.imgH};
if((_27[0]!=0||_27[1]!=0)&&_22){
if(_27[0]>0){
_27[1]=_27[0];
}else{
if(_27[1]>0){
_27[0]=_27[1];
}
}
}
if((_28[0]!=0||_28[0]!=0)&&_22){
if(_28[0]>0&&_28[0]<=_28[1]){
_28[1]=_28[0];
}else{
if(_28[1]>0&&_28[1]<=_28[0]){
_28[0]=_28[1];
}
}
}
if(_27[0]>0){
this.applyDimRestriction(_29,_27[0],_23.x,_2b,"min");
}
if(_27[1]>1){
this.applyDimRestriction(_2a,_27[1],_23.y,_2c,"min");
}
if(_28[0]>0){
this.applyDimRestriction(_29,_28[0],_23.x,_2b,"max");
}
if(_28[1]>1){
this.applyDimRestriction(_2a,_28[1],_23.y,_2c,"max");
}
_20={x1:_29.a1,y1:_2a.a1,x2:_29.a2,y2:_2a.a2};
}
}
}
this.areaCoords=_20;
},applyDimRestriction:function(_2d,val,_2f,_30,_31){
var _32;
if(_31=="min"){
_32=((_2d.a2-_2d.a1)<val);
}else{
_32=((_2d.a2-_2d.a1)>val);
}
if(_32){
if(_2f==1){
_2d.a2=_2d.a1+val;
}else{
_2d.a1=_2d.a2-val;
}
if(_2d.a1<_30.min){
_2d.a1=_30.min;
_2d.a2=val;
}else{
if(_2d.a2>_30.max){
_2d.a1=_30.max-val;
_2d.a2=_30.max;
}
}
}
},applyRatio:function(_33,_34,_35,_36){
var _37;
if(_36=="N"||_36=="S"){
_37=this.applyRatioToAxis({a1:_33.y1,b1:_33.x1,a2:_33.y2,b2:_33.x2},{a:_34.y,b:_34.x},{a:_35.y,b:_35.x},{min:0,max:this.imgW});
_33.x1=_37.b1;
_33.y1=_37.a1;
_33.x2=_37.b2;
_33.y2=_37.a2;
}else{
_37=this.applyRatioToAxis({a1:_33.x1,b1:_33.y1,a2:_33.x2,b2:_33.y2},{a:_34.x,b:_34.y},{a:_35.x,b:_35.y},{min:0,max:this.imgH});
_33.x1=_37.a1;
_33.y1=_37.b1;
_33.x2=_37.a2;
_33.y2=_37.b2;
}
},applyRatioToAxis:function(_38,_39,_3a,_3b){
var _3c=Object.extend(_38,{});
var _3d=_3c.a2-_3c.a1;
var _3e=Math.floor(_3d*_39.b/_39.a);
var _3f;
var _40;
var _41=null;
if(_3a.b==1){
_3f=_3c.b1+_3e;
if(_3f>_3b.max){
_3f=_3b.max;
_41=_3f-_3c.b1;
}
_3c.b2=_3f;
}else{
_3f=_3c.b2-_3e;
if(_3f<_3b.min){
_3f=_3b.min;
_41=_3f+_3c.b2;
}
_3c.b1=_3f;
}
if(_41!=null){
_40=Math.floor(_41*_39.a/_39.b);
if(_3a.a==1){
_3c.a2=_3c.a1+_40;
}else{
_3c.a1=_3c.a1=_3c.a2-_40;
}
}
return _3c;
},drawArea:function(){
var _42=this.calcW();
var _43=this.calcH();
var px="px";
var _45=[this.areaCoords.x1+px,this.areaCoords.y1+px,_42+px,_43+px,this.areaCoords.x2+px,this.areaCoords.y2+px,(this.img.width-this.areaCoords.x2)+px,(this.img.height-this.areaCoords.y2)+px];
var _46=this.selArea.style;
_46.left=_45[0];
_46.top=_45[1];
_46.width=_45[2];
_46.height=_45[3];
var _47=Math.ceil((_42-6)/2)+px;
var _48=Math.ceil((_43-6)/2)+px;
this.handleN.style.left=_47;
this.handleE.style.top=_48;
this.handleS.style.left=_47;
this.handleW.style.top=_48;
this.north.style.height=_45[1];
var _49=this.east.style;
_49.top=_45[1];
_49.height=_45[3];
_49.left=_45[4];
_49.width=_45[6];
var _4a=this.south.style;
_4a.top=_45[5];
_4a.height=_45[7];
var _4b=this.west.style;
_4b.top=_45[1];
_4b.height=_45[3];
_4b.width=_45[0];
this.subDrawArea();
this.forceReRender();
},forceReRender:function(){
if(this.isIE||this.isWebKit){
var n=document.createTextNode(" ");
var d,el,fixEL,i;
if(this.isIE){
fixEl=this.selArea;
}else{
if(this.isWebKit){
fixEl=document.getElementsByClassName("imgCrop_marqueeSouth",this.imgWrap)[0];
d=Builder.node("div","");
d.style.visibility="hidden";
var _4e=["SE","S","SW"];
for(i=0;i<_4e.length;i++){
el=document.getElementsByClassName("imgCrop_handle"+_4e[i],this.selArea)[0];
if(el.childNodes.length){
el.removeChild(el.childNodes[0]);
}
el.appendChild(d);
}
}
}
fixEl.appendChild(n);
fixEl.removeChild(n);
}
},startResize:function(e){
this.startCoords=this.cloneCoords(this.areaCoords);
this.resizing=true;
this.resizeHandle=Event.element(e).classNames().toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,"");
Event.stop(e);
},startDrag:function(e){
this.selArea.show();
this.clickCoords=this.getCurPos(e);
this.setAreaCoords({x1:this.clickCoords.x,y1:this.clickCoords.y,x2:this.clickCoords.x,y2:this.clickCoords.y},false,false,null);
this.dragging=true;
this.onDrag(e);
Event.stop(e);
},getCurPos:function(e){
var el=this.imgWrap,wrapOffsets=Position.cumulativeOffset(el);
while(el.nodeName!="BODY"){
wrapOffsets[1]-=el.scrollTop||0;
wrapOffsets[0]-=el.scrollLeft||0;
el=el.parentNode;
}
return curPos={x:Event.pointerX(e)-wrapOffsets[0],y:Event.pointerY(e)-wrapOffsets[1]};
},onDrag:function(e){
if(this.dragging||this.resizing){
var _54=null;
var _55=this.getCurPos(e);
var _56=this.cloneCoords(this.areaCoords);
var _57={x:1,y:1};
if(this.dragging){
if(_55.x<this.clickCoords.x){
_57.x=-1;
}
if(_55.y<this.clickCoords.y){
_57.y=-1;
}
this.transformCoords(_55.x,this.clickCoords.x,_56,"x");
this.transformCoords(_55.y,this.clickCoords.y,_56,"y");
}else{
if(this.resizing){
_54=this.resizeHandle;
if(_54.match(/E/)){
this.transformCoords(_55.x,this.startCoords.x1,_56,"x");
if(_55.x<this.startCoords.x1){
_57.x=-1;
}
}else{
if(_54.match(/W/)){
this.transformCoords(_55.x,this.startCoords.x2,_56,"x");
if(_55.x<this.startCoords.x2){
_57.x=-1;
}
}
}
if(_54.match(/N/)){
this.transformCoords(_55.y,this.startCoords.y2,_56,"y");
if(_55.y<this.startCoords.y2){
_57.y=-1;
}
}else{
if(_54.match(/S/)){
this.transformCoords(_55.y,this.startCoords.y1,_56,"y");
if(_55.y<this.startCoords.y1){
_57.y=-1;
}
}
}
}
}
this.setAreaCoords(_56,false,e.shiftKey,_57,_54);
this.drawArea();
Event.stop(e);
}
},transformCoords:function(_58,_59,_5a,_5b){
var _5c=[_58,_59];
if(_58>_59){
_5c.reverse();
}
_5a[_5b+"1"]=_5c[0];
_5a[_5b+"2"]=_5c[1];
},endCrop:function(){
this.dragging=false;
this.resizing=false;
this.options.onEndCrop(this.areaCoords,{width:this.calcW(),height:this.calcH()});
},subInitialize:function(){
},subDrawArea:function(){
}};
Cropper.ImgWithPreview=Class.create();
Object.extend(Object.extend(Cropper.ImgWithPreview.prototype,Cropper.Img.prototype),{subInitialize:function(){
this.hasPreviewImg=false;
if(typeof (this.options.previewWrap)!="undefined"&&this.options.minWidth>0&&this.options.minHeight>0){
this.previewWrap=$(this.options.previewWrap);
this.previewImg=this.img.cloneNode(false);
this.previewImg.id="imgCrop_"+this.previewImg.id;
this.options.displayOnInit=true;
this.hasPreviewImg=true;
this.previewWrap.addClassName("imgCrop_previewWrap");
this.previewWrap.setStyle({width:this.options.minWidth+"px",height:this.options.minHeight+"px"});
this.previewWrap.appendChild(this.previewImg);
}
},subDrawArea:function(){
if(this.hasPreviewImg){
var _5d=this.calcW();
var _5e=this.calcH();
var _5f={x:this.imgW/_5d,y:this.imgH/_5e};
var _60={x:_5d/this.options.minWidth,y:_5e/this.options.minHeight};
var _61={w:Math.ceil(this.options.minWidth*_5f.x)+"px",h:Math.ceil(this.options.minHeight*_5f.y)+"px",x:"-"+Math.ceil(this.areaCoords.x1/_60.x)+"px",y:"-"+Math.ceil(this.areaCoords.y1/_60.y)+"px"};
var _62=this.previewImg.style;
_62.width=_61.w;
_62.height=_61.h;
_62.left=_61.x;
_62.top=_61.y;
}
}});



// This file was derived from: AC_OETags.js
// The file AC_OETags.js was emitting invalid HTML for the <object> tag in function AC_Generateobj().

// Flash Player Version Detection - Rev 1.5
// Detect Client Browser type
// Copyright 2006 Adobe Systems, Inc. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
		str += '>';
  		for (var i in params)
  			str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '</object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }
    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}




/*
 * QTObject embed
 * http://blog.deconcept.com/2005/01/26/web-standards-compliant-javascript-quicktime-detect-and-embed/
 *
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.0.2 - 02-16-2005
 *
 * Embeds a quicktime movie to the page, includes plugin detection
 *
 * Usage:
 *
 *	myQTObject = new QTObject("path/to/mov.mov", "movid", "width", "height");
 *	myQTObject.altTxt = "Upgrade your Quicktime Player!";    // optional
 
 *  myQTObject.addParam("controller", "false");              // optional
 *	myQTObject.write();
 *
 */

QTObject = function(mov, id, w, h) {
	this.mov = mov;
	this.id = id;
	this.width = w;
	this.height = h;
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "This content requires the QuickTime Plugin. <a href='http://www.apple.com/quicktime/download/'>Download QuickTime Player</a>.";
	this.bypassTxt = "<p>Already have QuickTime Player? <a href='?detectqt=false&"+ this.sq +"'>Click here.</a></p>";
	this.params = new Object();
	this.doDetect = getQueryParamValue('detectqt');
}

QTObject.prototype.addParam = function(name, value) {
	this.params[name] = value;
}

QTObject.prototype.getParams = function() {
    return this.params;
}

QTObject.prototype.getParam = function(name) {
    return this.params[name];
}

QTObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

QTObject.prototype.getHTML = function() {
    var qtHTML = "";
	if (navigator.plugins && navigator.plugins.length) { // not ie
        qtHTML += '<embed type="video/quicktime" src="' + this.mov + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '"';
        for (var param in this.getParams()) {
            qtHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        qtHTML += '></embed>';
    }
    else { // pc ie
        qtHTML += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '">';
        this.addParam("src", this.mov);
        if (this.getParamTags() != null) {
            qtHTML += this.getParamTags();
        }
        qtHTML += '</object>';
    }
    return qtHTML;
}


QTObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}

QTObject.prototype.write = function(elementId) {
	if(isQTInstalled() || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}

function isQTInstalled() {
	var qtInstalled = false;
	qtObj = false;
	if (navigator.plugins && navigator.plugins.length) {
		for (var i=0; i < navigator.plugins.length; i++ ) {
         var plugin = navigator.plugins[i];
         if (plugin.name.indexOf("QuickTime") > -1) {
			qtInstalled = true;
         }
      }
	} else {
		execScript('on error resume next: qtObj = IsObject(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))','VBScript');
		qtInstalled = qtObj;
	}
	return qtInstalled;
}

/* get value of querystring param */
function getQueryParamValue(param) {
	var q = document.location.search;
	var detectIndex = q.indexOf(param);
	var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length;
	if(q.length > 1 && detectIndex != -1) {
		return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
	} else {
		return "";
	}
}


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

// Dialog functionality for modal and non-modal dialog boxes

Veer.Dialog = {

	// the ID of the autoFade timeout, so that new alerts reset the close timer
	closeTimeout: null,
	// the url to redirect to if a user proceeds through a confirmation
	proceedUrl: null,
	// determines whether confirms proceed via xhr or normal posts
	proceedViaXhr: false,

  // Our custom showInline method.
  // Shows a dialog inline. The given element identified by id is re-parented into position.
  // Effectively the element is removed from the DOM and becomes a child of dialog_window.
  // Effects take place on dialog_window, so the re-parented DOM is made visible so that
  // you can actually see it. Subsequently calling showInline with a different element
  // does not pose a problem. All re-parented dialogs will collect under RB-window.
  //
  // Parameter formId is optional. If the dialog being shown has a form, pass in the id of the
  // form to have the first field receive focus automatically. 
  showInline: function(id, /* optional */ formId)
  {
		Veer.Dialog.prepareDialog(id, null, true);
		var focusFirstElement = formId ? function() { Form.focusFirstElement(formId); } : Prototype.emptyFunction;
    new Effect.Appear('dialog_window', {duration: 0.1, queue: 'end', afterFinish: focusFirstElement });
  },

	// populates the alert message and launches a non-modal dialog box which fades after the designated time (minimum 3 seconds)
	alert: function(message)
	{
		Veer.Dialog.prepareDialog('alert_dialog', message, false);
		new Effect.Appear('dialog_window', {duration: 0.1, afterFinish: function() {
			Veer.Dialog.closeTimeout = setTimeout('Veer.Dialog.close()',  Math.max(message.length * 50, 3000));
			}
		});
	},
	
	// populates the confirm message, prepares the proceed link, and launches a modal dialog
	confirm: function(message, url, xhr)
	{
		Veer.Dialog.proceedUrl = url;
		Veer.Dialog.proceedViaXhr = xhr;
		Veer.Dialog.prepareDialog('confirm_dialog', message, true);
    new Effect.Appear('dialog_window', {duration: 0.1, queue: 'end' });
	},
  
	// hides residual dialogs, updates the requested dialog with the submitted message,
	// and positions the required containers and overlays
	prepareDialog: function(id, message, isModal)
	{
		clearTimeout(Veer.Dialog.closeTimeout);
		$$('#dialog_window div').each(function (child) {if (child.id.indexOf('_dialog') != -1 && child.id != id) child.hide();});
		dialog = $(id);
		if (message) dialog.down('p').update(message);
		Veer.Dialog.showOverlay(isModal);
		$('dialog_window').insert(dialog.remove().show());
		Veer.Dialog.center('dialog_window');
	},

	// inserts necessary dialog containers and optionaly brings up the gray screen for modal interaction
  showOverlay: function(isModal)
  {
    if (!$('dialog_container'))
    {
      new Insertion.Top(document.body, '<div id="dialog_container" align="center"><div id="dialog_window" style="display: none;"></div><div id="dialog_overlay" style="display: none;"></div></div>');      
    }
    
		if (Veer.Dialog.isIE6()) {
			// The stylesheet says dialog_window is position: fixed. That causes IE6 grief, so we revert it to absolute.
			$('dialog_window').setStyle({position: 'absolute'});	
		   Veer.Dialog.hideSelectBoxes();
		}

		if (isModal)
    {
			Veer.Dialog.setOverlaySize();
    	new Effect.Appear('dialog_overlay', {duration: 0.2, to: 0.4, queue: 'end'});
		}
  },

  setOverlaySize: function()
  {
    if (window.innerHeight && window.scrollMaxY)
    {  
      yScroll = window.innerHeight + window.scrollMaxY;
    } 
    else if (document.body.scrollHeight > document.body.offsetHeight)
    { // all but Explorer Mac
      yScroll = document.body.scrollHeight;
    }
    else
    { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
      yScroll = document.body.offsetHeight;
    }
    $("dialog_overlay").style['height'] = yScroll +"px";
    $("dialog_overlay").style['left'] = "0px";
  },

  // centers the element (dialog_window) on the page
	center: function(element) {
		//get the dialog dimensions
		var d = Element.getDimensions(element);
		var w = d.width;
		var h = d.height;
		
		Position.prepare(); 
		
		//get page size for calculating position, adding delta if IE6 since it doesn't respect fixed positioning
    var ps = Veer.Dialog.getPageSize();
		var hPos = ps[1]/2 - h/2;
		if (Veer.Dialog.isIE6())	hPos += Position.deltaY;
		
		//reset positions
		$(element).style.top = hPos + "px";
		$(element).style.left = ps[0]/2 - w/2 + "px";
	},
	
  getPageSize: function() {
    var width = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
    var height = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
    return [width, height];
  },
  
	// hides select boxes so IE6 doesn't look like ass if the dialog appears over top of any
  hideSelectBoxes: function()
  {
  	selects = document.getElementsByTagName("select");
  	for (i = 0; i != selects.length; i++) {
  		selects[i].style.visibility = "hidden";
  	}
  },

	// restore select boxes for IE6
  showSelectBoxes: function()
  {
  	selects = document.getElementsByTagName("select");
  	for (i = 0; i != selects.length; i++) {
  		selects[i].style.visibility = "visible";
  	}
  },
  
	// proceeds from a confirm window, via xhr or standard redirect
	proceed: function()
	{
		if (Veer.Dialog.proceedViaXhr)
		{
			Veer.Dialog.close(function() {
				new Ajax.Request(Veer.Dialog.proceedUrl,
					{asynchronous:true, evalScripts:true, parameters:'authenticity_token=' + encodeURIComponent(window._auth_token)});
			});
		}
		else
		{
			Veer.Dialog.close(function() {location = Veer.Dialog.proceedUrl;});
		}
	},
	
  // Closes the dialog box. After the box is closed, the optional callback will be called.
	// Note: callbacks can only be specified for modal dialogs
  close: function(/* optional */ callback)
  {
		clearTimeout(Veer.Dialog.closeTimeout); //cancel any other pending closes
    new Effect.Fade('dialog_window', {duration: 0.2});
		if (Element.visible('dialog_overlay')) new Effect.Fade('dialog_overlay', {duration: 0.2, afterFinish: callback});
    if (Veer.Dialog.isIE6()) Veer.Dialog.showSelectBoxes();
  },
  
	isIE6: function() {
		return (navigator.appVersion.indexOf('MSIE 6') != -1);
	}
}

// Veer.Feature 
// Singleton object used to communicate with Flash-based applications on the site.

Veer.Feature = {
     
	// Status keeps track of Javascript and Flash 'ready-ness'. As soon as the
	// Flash app is instatiated, it starts calling Veer.feature.isReady(). When
	// the 'dom:loaded' event happens, JavaScript is ready and isReady() returns
	// true. The Flash app now initializes itself, and registers callbacks. The
	// Flash app then calls Veer.Feature.setSwfReady(). Both sides are ready
	// and two-way communication between JavaScript and ActionScript can begin.
	status: { jsReady: false, swfReady: false, saveDialogClosedMessage: "<p>You will be able to continue editing your world momentarily.</p>" },

	// ------- ActionScript callbacks -------
  
	// Called to check if the page has initialized and JavaScript is available
	isReady: function() { 
		return Veer.Feature.status.jsReady; 
	},

	// Called to notify the page that the SWF has set it's callbacks
	setSwfIsReady: function() { 
		Veer.Feature.status.swfReady = true;
		Veer.Feature.swf.setup(Veer.Feature.status.mode, Veer.Feature.status.name, Veer.Feature.status.symbolSet, window._auth_token, Veer.Feature.status.dataUrl);
	},
    
	// Called by Flash Player when the artwork has been saved. with an optional url
	// indicating whether to redirect to another page. A save typically remains on
	// the current page, a save_as will typically redirect to a new page.
	saved: function(dataUrl, /* optional */ redirectUrl) {
		var callback;
		Veer.Feature.status.dataUrl = dataUrl;
		$('saving_failed_message').hide();
		$('saving_indicator').hide();
		if (redirectUrl && redirectUrl.length > 0) callback = Veer.Feature.saveDialogClosed.delay(0.5, redirectUrl);
		Veer.Dialog.close(callback);
	},
	
	// Called by the new improved Flash Player 10 to cause a fast redirect to another place.
	savedFastRedirect: function(dataUrl, redirectUrl) {
		window.location = redirectUrl;
	},
	
	// Called by Flash Player when the artwork was not saved.
	notSaved: function(message) {
		$('saving_indicator').hide(); 
		var el = $('saving_failed_message');
		if (el) {
			el.update('Oops. Veer\'s server said: ' + message);
			el.show();
		}
	},
	
	// Called when the save as dialog closes after a saved() call and a callback was registered.
	saveDialogClosed: function(url) {
		if (url && url.length > 0) { 
			Veer.Feature.restoreScreen();
            
			var title = $F('feature_title').escapeHTML();
		
			// Make it painfully obvious that we have to redirect after a save_as operation.
			// Our preference for supplementary messaging is to use a string set by the caller. A message for Worlds is the default.
			$(document.body).update("<div style='display: none; position: absolute;' id='loading'><h1>Please stand by.</h1><span id='saving_indicator' class='pale'><img src='/images/spinny_loader.gif' alt='You are getting sleepy&#8230;' width='16' height='16' /> Loading &#8230; &#8220;" + title + "&#8221;</span>" + Veer.Feature.status.saveDialogClosedMessage + "</div>");
		
			// Center the div
			var d = $('loading').getDimensions();
			var v = document.viewport.getDimensions();
			var x = Math.floor((v.width - d.width) / 2);
			var y = Math.floor((v.height - d.height) / 2);
			var el = $('loading');
			el.style['left'] = x + "px";
			el.style['top'] = y + "px";
			el.show();
		
			// Wait a bit seconds so they can read the message
			Veer.Feature.changeLocation.delay(2, url);
		}
	},
	
	changeLocation: function(url) {
		location = url;
	},
	
	// ------- JavaScript callbacks -------

	// Called on dom:loaded event to indicate that JavaScript is ready to go.
	setJavaScriptIsReady: function() { 
		Veer.Feature.status.jsReady = true; 
		Veer.Feature.setFeatureSize();
		Veer.Feature.swf = Veer.Feature.getSwf("featureApp");
	},

	// Gets a reference to the specified SWF file by checking which browser is
	// being used and using the appropriate JavaScript.
	// Unfortunately, newer approaches such as using getElementByID() don't
	// work well with Flash Player/ExternalInterface.
	getSwf: function(movieName) {
		return ((navigator.appName.indexOf("Microsoft") != -1) ? window[movieName] : document[movieName]);
	},
	
	// Returns true if the flash app says it has been modified.
	isModified: function() {
		return (Veer.Feature.status.swfReady) ? Veer.Feature.swf.isModified() : false;
	},
	
	// ------- Page functions -------
  
	// Handles a click on the Finished link, showing a confirm prompt if changes have been made.
	finishedClick: function(message, url) {
		Veer.Feature.isModified() ? Veer.Dialog.confirm(message, url, false) : Veer.Feature.finished(url);
	},
	
	// Callback from the confirm dialog Finished button.
	// Redirects to the given url.
	finished: function(url) {
		location = url;
	},       
    
	// Handles button clicks when the canvas is blank.
	blank: function() {
		$('blank_message').show().visualEffect('Highlight', { afterFinish: Veer.Feature.blankComplete });
	},
	
	blankComplete: function() {
		$('blank_message').visualEffect('Fade', { delay: 4 });
	},
	
	// Handles a click on a Save link. Causes a save for existing artworks, save_as for new artworks.
	saveClick: function(title, method, checkDefaultText) {
		if (Veer.Feature.status.isNew) {
			$('save_status_draft').up().show();
			Veer.Feature.save('Save World', 'save_as', true);
		} else {
			Veer.Feature.save('Save World', 'save', false);
		}
	},

	// Saves the artwork as a new artwork with a new id.
	saveAsClick: function(title) {
		// Default title text is checked if feature is new, otherwise we don't bother.
		Veer.Feature.save(title || 'Save World As', 'save_as', Veer.Feature.status.isNew);
	},
    
	save: function(title, method, checkDefaultText) {
		$('save_dialog_title').update(title);
		if ($('save_status_draft')) {
			(Veer.Feature.getSaveStatus() == 'draft' || method == 'save_as') ? $('save_status_draft').up().show() : $('save_status_draft').up().hide();
		}
		Veer.Feature.status.saveMethod = method;
		Veer.Feature.showDialog(checkDefaultText);
	},
	
	// Shows the dialog, optionally capturing the feature title text.
	showDialog: function(checkDefaultText) {
		Veer.Feature.status.defaultTitleText = (checkDefaultText) ? $F('feature_title') : null;
		Veer.Dialog.showInline('save_dialog', 'save_form');
	},
	
	// Callback from the save dialog Save button. Handles saving the feature. 
	// The dialog stays open while the Flash app talks to the server. We expect 
	// a callback to saved() or notSaved().
	saveFeature: function() {
		$('saving_failed_message').hide();
		$('saving_indicator').show();
		Veer.Feature.flashSaveAsFeature.defer();
		return false;
	},
	
	// Callback from saveFeature() method. Handles talking to Flash Player to save the feature. 
	// This method is deferred since some browsers can't multitask Javascript and Flash ActionScript. 
	// Deferral allows the HTML DOM to update before Flash starts to encode a JPEG.
	// Flash Player will callback to either the saved() or notSaved() methods.
	flashSaveAsFeature: function() {
		// Default text in the title field will translate to empty string.
		var title = ($F('feature_title') == Veer.Feature.status.defaultTitleText) ? "" : $F('feature_title');
		Veer.Feature.getSwf("featureApp").save(title, $F('feature_description'), Veer.Feature.getSaveStatus(), Veer.Feature.status.saveMethod);

		//only update on-page elements when editing (new saves are considered a save as)
		if (Veer.Feature.status.saveMethod == 'save')
		{
			// Update the feature title on the page if there is one.
			var el = $("title");
			if (el) el.update(title);
		
			// Update the draft message if there is one.
			el = $('feature_is_draft');
			if (el) (Veer.Feature.getSaveStatus() == 'draft') ? el.show() : el.hide();
		}
	},

	// Callback from the Save as Profile Picture button. Handles talking to Flash Player
	// to save the image as the current user's avatar.
	saveAvatar: function() {
		$('avatar_saving_indicator').show();
	},

	// Called by Flash Player on completion of a saveAvatar invocation.
	avatarSaved: function(status) {
		$('avatar_saving_indicator').hide();
		$('avatar_failed_message').hide().setOpacity(1);
		$('avatar_success_message').hide().setOpacity(1);
		$('avatar_' + status + '_message').show().highlight().visualEffect('Fade', { delay: 8 });
	},
	
	// Toggles the screen size between full screen and restored size.
	fullScreenClick: function() {
		(Veer.Feature.status.originalBrowserSize) ? Veer.Feature.restoreScreen() : Veer.Feature.fullscreen();
	},
	
	// Sets the browser to full screen. You must call restoreScreen() before you can call fullscreen() again.
	// If there is a link on the page with the id='fullscreen_toggle', the text and title are altered.
	fullscreen: function() {
		var d = Veer.Feature.status.originalBrowserSize;
		if (!d) {
			var original = document.viewport.getDimensions();
		 
			//new Effect.Move(self, 0, 0);
			self.moveTo(0, 0);
			window.resizeTo(screen.availWidth, screen.availHeight);
		
			// Calculations to determine the browser's physical size. Based on:
			// 1. Save the current inner dimensions.
			// 2. Resize the window using fixed values.
			// 3. Subtract the new inner dimensions from those fixed values. This
			//    difference is the amount of "chrome" horizontally and vertically.
			//    Save these values in global variables.
			// 4. Restore the window to its original size by adding the "chrome"

			var current = document.viewport.getDimensions();
			var chrome = { width: screen.availWidth - current.width, height: screen.availHeight - current.height };
			Veer.Feature.status.originalBrowserSize = { width: original.width + chrome.width, height: original.height + chrome.height };
        
			var el = $('fullscreen_toggle');
			if (el) {
				Veer.Feature.status.originalLinkText = { text: el.innerHTML, title: el.readAttribute('title') };
				el.update('Restore');
				el.writeAttribute('title', 'Restore the browser window to normal size');
			}
		}
	},
	
	// Restores the browser to it's prior size. You must call fullscreen() before you can call restoreScreen().
	// If there is a link on the page with the id='fullscreen_toggle', the text and title are altered.
	restoreScreen: function() {
		var d = Veer.Feature.status.originalBrowserSize;
		
		if (d) {
			self.moveTo(Math.floor((screen.availWidth - d.width) / 2), Math.floor((screen.availHeight - d.height) / 2));
			window.resizeTo(d.width, d.height);

			Veer.Feature.status.originalBrowserSize = null;
        
			t = Veer.Feature.status.originalLinkText;
			var el = $('fullscreen_toggle');
			if (el) {
				el.update(t.text);
				el.writeAttribute('title', t.title);
			}
		}
	},
	
	// -------- Helpers ---------

	// Creates the requested Flash application on the page.
	// The file adobe_flash.js must also be included into the document.
	//
	// The following arguments rules exist:
	// - Two arguments means we are creating a brand new feature.
	// - Three arguments means we are editing an existing feature owned by the current user.
	// - Four arguments with the last being true, indicates we are creating a brand new feature, derived from another feature.
	//
	// appPath - the partial path to the SWF file for this feature
	// mode - either 'edit' or 'view' 
	// width - the desired width of the swf as a string, or '100%'
	// height - the desired height of the swf as a string, or '100%'
	// modelName - the name of the model (Example: modelName of Features::World is 'World')
	// symbolSet - a string describing the set of symbols to load
	// dataUrl - optional - the url from which data for a feature can be loaded
	// isDerived - optional - when true, indicates a new feature is being derived from dataUrl
	instantiate: function(appPath, mode, width, height, modelName, symbolSet, /* optional */ dataUrl, /* optional */ isDerived) {

		Veer.Feature.status.mode = mode;
		Veer.Feature.status.dataUrl = dataUrl;
		Veer.Feature.status.isNew = (arguments.length == 6) || (arguments.length == 8 && isDerived);
		Veer.Feature.status.name = modelName.toLowerCase() || 'unknown';
		Veer.Feature.status.symbolSet = symbolSet

		if (window.AC_FL_RunContent) {
			AC_FL_RunContent(
				'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
				'width', width || '100%',
				'height', height || '100%',
				'src', appPath,
				'quality', 'high',
				'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'false',
				'loop', 'false',
				'scale', 'showall',
				'wmode', 'opaque',
				'devicefont', 'false',
				'id', 'featureApp',
				'bgcolor', '#ffffff',
				'name', 'featureApp',
				'menu', 'false',
				'allowScriptAccess','always',
				'movie', appPath,
				'salign', ''
				);
		} else {
			alert("This page requires adobe_flash.js.");
		}
				
		Event.observe(window, 'resize', Veer.Feature.setFeatureSize);
	},

	// Turns off the scrollbar in the browser window.
	turnOffScrollbars: function() {
		var element = $(document.documentElement) || $(document.body);
		element.setStyle({overflow: 'hidden'});
	},
	
	// Sets the size of the feature so it occupies the entire viewport.
	// Does no work if the movie and the box can't be found.
	setFeatureSize: function() {
		var d = document.viewport.getDimensions();
		var swf = Veer.Feature.getSwf("featureApp");  // The movie object
		var box = $('feature_box');                   // The outermost containing DIV of the movie object
		if (swf && box) {
			var p = box.cumulativeOffset();
			var w = Math.max(0, (d.width - p.left * 2)) + "px";
			var h = Math.max(0, d.height - p.top - 66);   // The number 66 is a fudge factor, we must revisit this.

			// Now for the weirdness. We have to set the width of 
			// the containing box, but the height of the swf.
			box.setStyle({width: w});
			swf.height = h;
		}
	},
	
	// Returns the save status from the save_status_dialog which may have one or more
	// missing radio buttons.
	getSaveStatus: function() {
		var draft = $('save_status_draft');
		var post = $('save_status_post');
		 
		return (draft && $F(draft)) || (post && $F(post)) || 'draft';
	}
}

document.observe('dom:loaded', Veer.Feature.setJavaScriptIsReady);


/**
 * This is the Cookie() constructor function.
 *
 * This constructor looks for a cookie with the specified name for the
 * current document.  If one exists, it parses its value into a set of
 * name/value pairs and stores those values as properties of the newly created
 * object.
 *
 * To store new data in the cookie, simply set properties of the Cookie
 * object.  Avoid properties named "store" and "remove" since these are 
 * reserved as method names.
 * 
 * To save cookie data in the web browser's local store, call store().
 * To remove cookie data from the browser's store, call remove().
 *
 * The static method Cookie.enabled() returns true if cookies are
 * enabled and returns false otherwise.
 */
// function Cookie(name) {
//     this.$name = name;  // Remember the name of this cookie
// 
//     // First, get a list of all cookies that pertain to this document
//     // We do this by reading the magic Document.cookie property
//     // If there are no cookies, we don't have anything to do 
//     var allcookies = document.cookie;
//     if (allcookies == "") return;
// 
//     // Break the string of all cookies into individual cookie strings
//     // Then loop through the cookie strings, looking for our name
//     var cookies = allcookies.split(';');
//     var cookie = null;
//     for(var i = 0; i < cookies.length; i++) {
//         // Does this cookie string begin with the name we want?
//         if (cookies[i].substring(0, name.length+1) == (name + "=")) {
//             cookie = cookies[i];
//             break;
//         }
//     }
// 
//     // If we didn't find a matching cookie, quit now
//     if (cookie == null) return;
// 
//     // The cookie value is the part after the equals sign
//     var cookieval = cookie.substring(name.length+1);
// 
//     // Now that we've extracted the value of the named cookie, we
//     // must break that value down into individual state variable 
//     // names and values. The name/value pairs are separated from each
//     // other by ampersands, and the individual names and values are
//     // separated from each other by colons. We use the split() method
//     // to parse everything.
//     var a = cookieval.split('&'); // Break it into an array of name/value pairs
//     for(var i=0; i < a.length; i++)  // Break each pair into an array
//         a[i] = a[i].split(':');
// 
//     // Now that we've parsed the cookie value, set all the names and values
//     // as properties of this Cookie object. Note that we decode
//     // the property value because the store() method encodes it
//     for(var i = 0; i < a.length; i++) {
//         this[a[i][0]] = decodeURIComponent(a[i][1]);
//     }
// }

/**
 * This function is the store() method of the Cookie object.
 *
 * Arguments:
 *
 *   daysToLive: the lifetime of the cookie, in days. If you set this
 *     to zero, the cookie will be deleted.  If you set it to null, or 
 *     omit this argument, the cookie will be a session cookie and will
 *     not be retained when the browser exits.  This argument is used to
 *     set the max-age attribute of the cookie.
 *   path: the value of the path attribute of the cookie
 *   domain: the value of the domain attribute of the cookie
 *   secure: if true, the secure attribute of the cookie will be set
 */
// Cookie.prototype.store = function(daysToLive, path, domain, secure) {
//     // First, loop through the properties of the Cookie object and
//     // put together the value of the cookie. Since cookies use the
//     // equals sign and semicolons as separators, we'll use colons
//     // and ampersands for the individual state variables we store 
//     // within a single cookie value. Note that we encode the value
//     // of each property in case it contains punctuation or other
//     // illegal characters.
//     var cookieval = "";
//     for(var prop in this) {
//         // Ignore properties with names that begin with '$' and also methods
//         if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
//             continue;
//         if (cookieval != "") cookieval += '&';
//         cookieval += prop + ':' + encodeURIComponent(this[prop]);
//     }
// 
//     // Now that we have the value of the cookie, put together the 
//     // complete cookie string, which includes the name and the various
//     // attributes specified when the Cookie object was created
//     var cookie = this.$name + '=' + cookieval;
//     if (daysToLive || daysToLive == 0) { 
//         cookie += "; max-age=" + (daysToLive*24*60*60);
//     }
// 
//     if (path) cookie += "; path=" + path;
//     if (domain) cookie += "; domain=" + domain;
//     if (secure) cookie += "; secure";
// 
//     // Now store the cookie by setting the magic Document.cookie property
//     document.cookie = cookie;
// }

/**
 * This function is the remove() method of the Cookie object; it deletes the
 * properties of the object and removes the cookie from the browser's 
 * local store.
 * 
 * The arguments to this function are all optional, but to remove a cookie
 * you must pass the same values you passed to store().
 */
// Cookie.prototype.remove = function(path, domain, secure) {
//     // Delete the properties of the cookie
//     for(var prop in this) {
//         if (prop.charAt(0) != '$' && typeof this[prop] != 'function') 
//             delete this[prop];
//     }
// 
//     // Then, store the cookie with a lifetime of 0
//     this.store(0, path, domain, secure);
// }

/**
 * This static method attempts to determine whether cookies are enabled.
 * It returns true if they appear to be enabled and false otherwise.
 * A return value of true does not guarantee that cookies actually persist.
 * Nonpersistent session cookies may still work even if this method 
 * returns false.
 */
// Cookie.enabled = function() {
//     // Use navigator.cookieEnabled if this browser defines it
//     if (navigator.cookieEnabled != undefined) return navigator.cookieEnabled;
// 
//     // If we've already cached a value, use that value
//     if (Cookie.enabled.cache != undefined) return Cookie.enabled.cache;
// 
//     // Otherwise, create a test cookie with a lifetime
//     document.cookie = "testcookie=test; max-age=10000";  // Set cookie
// 
//     // Now see if that cookie was saved
//     var cookies = document.cookie;
//     if (cookies.indexOf("testcookie=test") == -1) {
//         // The cookie was not saved
//         return Cookie.enabled.cache = false;
//     }
//     else {
//         // Cookie was saved, so we've got to delete it before returning
//         document.cookie = "testcookie=test; max-age=0";  // Delete cookie
//         return Cookie.enabled.cache = true;
//     }
// }



function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/"+"; domain=.veer.com";
}

function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function eraseCookie(name)
{
  createCookie(name, "", -1);
}


// script by Josh Fraser (http://www.onlineaspect.com)

function calculate_time_zone() {
   var rightNow = new Date();
   var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);  // jan 1st
   var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0); // june 1st
   var temp = jan1.toGMTString();
   var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
   temp = june1.toGMTString();
   var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
   var std_time_offset = (jan1 - jan2) / (1000 * 60);
   var daylight_time_offset = (june1 - june2) / (1000 * 60);
   var dst;
   if (std_time_offset == daylight_time_offset) {
		dst = "0"; // daylight savings time is NOT observed
   } else {
   		// positive is southern, negative is northern hemisphere
		var hemisphere = std_time_offset - daylight_time_offset;
		if (hemisphere >= 0)
			std_time_offset = daylight_time_offset;
		dst = "1"; // daylight savings time is observed
   }
return daylight_time_offset;
}


// Functionality for the filters on the /jobs page.

Veer.Jobs = {
    Controls: {
		FULLTIME_CHECKBOX: 'fulltime',
		FREELANCE_CHECKBOX: 'freelance',
		DESIGN_CHECKBOX: 'design',
		DEVELOPMENT_CHECKBOX: 'development',
		FILTER_BUTTON: 'filter',
		JOBS_PATH: '/jobs',
		JOBS_SLASH_PATH: '/jobs/'
	},

	initializeFilterControls: function() {
		([Veer.Jobs.Controls.JOBS_PATH, Veer.Jobs.Controls.JOBS_SLASH_PATH].indexOf(location.pathname) == -1) ? Veer.Jobs.initializeFiltersFromLocation() : Veer.Jobs.allCategoriesFilter()
		Veer.Jobs.setConversationalTitle();
		$(Veer.Jobs.Controls.FILTER_BUTTON).observe('click', Veer.Jobs.filterClick);
	},

	setConversationalTitle: function() {
		// The start of the title.
		var heading = "Showing ";
	
		// Tack on the filters as links.
		var filterLink = new Template('<a href="#{path}/#{filterName}">#{humanName}</a>');
		var titles = [];
	
		if ($F(Veer.Jobs.Controls.FULLTIME_CHECKBOX))    titles.push(filterLink.evaluate({filterName: Veer.Jobs.Controls.FULLTIME_CHECKBOX,    humanName: 'full-time',   path: Veer.Jobs.Controls.JOBS_PATH}));
		if ($F(Veer.Jobs.Controls.FREELANCE_CHECKBOX))   titles.push(filterLink.evaluate({filterName: Veer.Jobs.Controls.FREELANCE_CHECKBOX,   humanName: 'freelance',   path: Veer.Jobs.Controls.JOBS_PATH}));
		if ($F(Veer.Jobs.Controls.DESIGN_CHECKBOX))      titles.push(filterLink.evaluate({filterName: Veer.Jobs.Controls.DESIGN_CHECKBOX,      humanName: 'design',      path: Veer.Jobs.Controls.JOBS_PATH}));
		if ($F(Veer.Jobs.Controls.DEVELOPMENT_CHECKBOX)) titles.push(filterLink.evaluate({filterName: Veer.Jobs.Controls.DEVELOPMENT_CHECKBOX, humanName: 'development', path: Veer.Jobs.Controls.JOBS_PATH}));
           
		if (titles.length == 4) {
			heading += "everything";
		} else {
			var title;
			var andComma = (titles.length >= 3) ? ',' : ''; // Our style-guide requires a comma before the and for a list of three or more items
			while (title = titles.shift()) {
				heading += title;
				if (titles.length > 1) heading += ', '
				if (titles.length == 1) heading += andComma + ' and ';
			}
		}
	
		// Tack on the region as a link.
		regionsElem = $('regions');
		optionsElem = regionsElem.options;
		selectedIndex = regionsElem.selectedIndex;
		var regionLink = new Template(' in <a href="#{path}/#{regionCode}">#{regionName}</a>');

		if (selectedIndex == 0) {
			heading += ', everywhere';
		} else {
			var show = {regionCode: optionsElem[selectedIndex].value, regionName: optionsElem[selectedIndex].text, path: Veer.Jobs.Controls.JOBS_PATH};
			heading += regionLink.evaluate(show);
		}
		
		// Now set from the server.
		// $('now_showing').update(heading);
	},

	filterClick: function(event) {
		var filter = "";
		filter = Veer.Jobs.appendFilter(filter, $F(Veer.Jobs.Controls.FULLTIME_CHECKBOX));
		filter = Veer.Jobs.appendFilter(filter, $F(Veer.Jobs.Controls.FREELANCE_CHECKBOX));
		filter = Veer.Jobs.appendFilter(filter, $F(Veer.Jobs.Controls.DESIGN_CHECKBOX));
		filter = Veer.Jobs.appendFilter(filter, $F(Veer.Jobs.Controls.DEVELOPMENT_CHECKBOX));
		// If all the filters are on, then really it's just an all filter.
		if (Veer.Jobs.appendFilter.counter == 4) filter = "";

		filter = Veer.Jobs.appendFilter(filter, $F('regions').toLowerCase());
		if (filter) filter = "/" + filter;
		location = Veer.Jobs.Controls.JOBS_PATH + filter
	},

	appendFilter: function(filter, filterValue) {
		if (!arguments.callee.counter) arguments.callee.counter = 0;
		if (filterValue) {
			if (filter) filter += '+';
			filter += filterValue;
			arguments.callee.counter += 1;
		}
		return filter;
	},

	allCategoriesFilter: function() {
		$(Veer.Jobs.Controls.FULLTIME_CHECKBOX).enable().checked = true;
		$(Veer.Jobs.Controls.FREELANCE_CHECKBOX).enable().checked = true;
		$(Veer.Jobs.Controls.DESIGN_CHECKBOX).enable().checked = true;
		$(Veer.Jobs.Controls.DEVELOPMENT_CHECKBOX).enable().checked = true;
	},

	chooseCategoriesFilter: function() {
		$(Veer.Jobs.Controls.FULLTIME_CHECKBOX).enable();
		$(Veer.Jobs.Controls.FREELANCE_CHECKBOX).enable();
		$(Veer.Jobs.Controls.DESIGN_CHECKBOX).enable();
		$(Veer.Jobs.Controls.DEVELOPMENT_CHECKBOX).enable();
	},

	initializeFiltersFromLocation: function() {
		if (location.pathname.startsWith(Veer.Jobs.Controls.JOBS_SLASH_PATH)) {
			filters = location.pathname.slice(6).split(/ |\+/);
			if (filters.length == 0) {
				Veer.Jobs.allCategoriesFilter();
			} else {
				var categoryFilter = false;
				var filter;
				while (filter = filters.pop()) {
					var element = $(filter);
					if (element) element.checked = categoryFilter = true;
					else $('regions').setValue(filter.toUpperCase());
				}
				if (!categoryFilter) Veer.Jobs.allCategoriesFilter();
			}
		}
	}
}
