
var Prototype={Version:"1.5.0",BrowserFeatures:{XPath:!!document.evaluate},ScriptFragment:"(?:<script.*?>)((\n|\r|.)*?)(?:</script>)",emptyFunction:function(){},K:function(x){return x;}};var Class={create:function(){return function(){this.initialize.apply(this,arguments);};}};var Abstract=new Object();Object.extend=function(_2,_3){for(var _4 in _3){_2[_4]=_3[_4];}return _2;};Object.extend(Object,{inspect:function(_5){try{if(_5===undefined){return "undefined";}if(_5===null){return "null";}return _5.inspect?_5.inspect():_5.toString();}catch(e){if(e instanceof RangeError){return "...";}throw e;}},keys:function(_6){var _7=[];for(var _8 in _6){_7.push(_8);}return _7;},values:function(_9){var _a=[];for(var _b in _9){_a.push(_9[_b]);}return _a;},clone:function(_c){return Object.extend({},_c);}});Function.prototype.bind=function(){var _d=this,args=$A(arguments),object=args.shift();return function(){return _d.apply(object,args.concat($A(arguments)));};};Function.prototype.bindAsEventListener=function(_e){var _f=this,args=$A(arguments),_e=args.shift();return function(_10){return _f.apply(_e,[(_10||window.event)].concat(args).concat($A(arguments)));};};Object.extend(Number.prototype,{toColorPart:function(){var _11=this.toString(16);if(this<16){return "0"+_11;}return _11;},succ:function(){return this+1;},times:function(_12){$R(0,this,true).each(_12);return this;}});var Try={these:function(){var _13;for(var i=0,length=arguments.length;i<length;i++){var _15=arguments[i];try{_13=_15();break;}catch(e){}}return _13;}};var PeriodicalExecuter=Class.create();PeriodicalExecuter.prototype={initialize:function(_16,_17){this.callback=_16;this.frequency=_17;this.currentlyExecuting=false;this.registerCallback();},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000);},stop:function(){if(!this.timer){return;}clearInterval(this.timer);this.timer=null;},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.callback(this);}finally{this.currentlyExecuting=false;}}}};String.interpret=function(_18){return _18==null?"":String(_18);};Object.extend(String.prototype,{gsub:function(_19,_1a){var _1b="",source=this,match;_1a=arguments.callee.prepareReplacement(_1a);while(source.length>0){if(match=source.match(_19)){_1b+=source.slice(0,match.index);_1b+=String.interpret(_1a(match));source=source.slice(match.index+match[0].length);}else{_1b+=source,source="";}}return _1b;},sub:function(_1c,_1d,_1e){_1d=this.gsub.prepareReplacement(_1d);_1e=_1e===undefined?1:_1e;return this.gsub(_1c,function(_1f){if(--_1e<0){return _1f[0];}return _1d(_1f);});},scan:function(_20,_21){this.gsub(_20,_21);return this;},truncate:function(_22,_23){_22=_22||30;_23=_23===undefined?"...":_23;return this.length>_22?this.slice(0,_22-_23.length)+_23:this;},strip:function(){return this.replace(/^\s+/,"").replace(/\s+$/,"");},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"");},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"");},extractScripts:function(){var _24=new RegExp(Prototype.ScriptFragment,"img");var _25=new RegExp(Prototype.ScriptFragment,"im");return (this.match(_24)||[]).map(function(_26){return (_26.match(_25)||["",""])[1];});},evalScripts:function(){return this.extractScripts().map(function(_27){return eval(_27);});},escapeHTML:function(){var div=document.createElement("div");var _29=document.createTextNode(this);div.appendChild(_29);return div.innerHTML;},unescapeHTML:function(){var div=document.createElement("div");div.innerHTML=this.stripTags();return div.childNodes[0]?(div.childNodes.length>1?$A(div.childNodes).inject("",function(_2b,_2c){return _2b+_2c.nodeValue;}):div.childNodes[0].nodeValue):"";},toQueryParams:function(_2d){var _2e=this.strip().match(/([^?#]*)(#.*)?$/);if(!_2e){return {};}return _2e[1].split(_2d||"&").inject({},function(_2f,_30){if((_30=_30.split("="))[0]){var _31=decodeURIComponent(_30[0]);var _32=_30[1]?decodeURIComponent(_30[1]):undefined;if(_2f[_31]!==undefined){if(_2f[_31].constructor!=Array){_2f[_31]=[_2f[_31]];}if(_32){_2f[_31].push(_32);}}else{_2f[_31]=_32;}}return _2f;});},toArray:function(){return this.split("");},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1);},camelize:function(){var _33=this.split("-"),len=_33.length;if(len==1){return _33[0];}var _34=this.charAt(0)=="-"?_33[0].charAt(0).toUpperCase()+_33[0].substring(1):_33[0];for(var i=1;i<len;i++){_34+=_33[i].charAt(0).toUpperCase()+_33[i].substring(1);}return _34;},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase();},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase();},dasherize:function(){return this.gsub(/_/,"-");},inspect:function(_36){var _37=this.replace(/\\/g,"\\\\");if(_36){return "\""+_37.replace(/"/g,"\\\"")+"\"";}else{return "'"+_37.replace(/'/g,"\\'")+"'";}}});String.prototype.gsub.prepareReplacement=function(_38){if(typeof _38=="function"){return _38;}var _39=new Template(_38);return function(_3a){return _39.evaluate(_3a);};};String.prototype.parseQuery=String.prototype.toQueryParams;var Template=Class.create();Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;Template.prototype={initialize:function(_3b,_3c){this.template=_3b.toString();this.pattern=_3c||Template.Pattern;},evaluate:function(_3d){return this.template.gsub(this.pattern,function(_3e){var _3f=_3e[1];if(_3f=="\\"){return _3e[2];}return _3f+String.interpret(_3d[_3e[3]]);});}};var $break=new Object();var $continue=new Object();var Enumerable={each:function(_40){var _41=0;try{this._each(function(_42){try{_40(_42,_41++);}catch(e){if(e!=$continue){throw e;}}});}catch(e){if(e!=$break){throw e;}}return this;},eachSlice:function(_43,_44){var _45=-_43,slices=[],array=this.toArray();while((_45+=_43)<array.length){slices.push(array.slice(_45,_45+_43));}return slices.map(_44);},all:function(_46){var _47=true;this.each(function(_48,_49){_47=_47&&!!(_46||Prototype.K)(_48,_49);if(!_47){throw $break;}});return _47;},any:function(_4a){var _4b=false;this.each(function(_4c,_4d){if(_4b=!!(_4a||Prototype.K)(_4c,_4d)){throw $break;}});return _4b;},collect:function(_4e){var _4f=[];this.each(function(_50,_51){_4f.push((_4e||Prototype.K)(_50,_51));});return _4f;},detect:function(_52){var _53;this.each(function(_54,_55){if(_52(_54,_55)){_53=_54;throw $break;}});return _53;},findAll:function(_56){var _57=[];this.each(function(_58,_59){if(_56(_58,_59)){_57.push(_58);}});return _57;},grep:function(_5a,_5b){var _5c=[];this.each(function(_5d,_5e){var _5f=_5d.toString();if(_5f.match(_5a)){_5c.push((_5b||Prototype.K)(_5d,_5e));}});return _5c;},include:function(_60){var _61=false;this.each(function(_62){if(_62==_60){_61=true;throw $break;}});return _61;},inGroupsOf:function(_63,_64){_64=_64===undefined?null:_64;return this.eachSlice(_63,function(_65){while(_65.length<_63){_65.push(_64);}return _65;});},inject:function(_66,_67){this.each(function(_68,_69){_66=_67(_66,_68,_69);});return _66;},invoke:function(_6a){var _6b=$A(arguments).slice(1);return this.map(function(_6c){return _6c[_6a].apply(_6c,_6b);});},max:function(_6d){var _6e;this.each(function(_6f,_70){_6f=(_6d||Prototype.K)(_6f,_70);if(_6e==undefined||_6f>=_6e){_6e=_6f;}});return _6e;},min:function(_71){var _72;this.each(function(_73,_74){_73=(_71||Prototype.K)(_73,_74);if(_72==undefined||_73<_72){_72=_73;}});return _72;},partition:function(_75){var _76=[],falses=[];this.each(function(_77,_78){((_75||Prototype.K)(_77,_78)?_76:falses).push(_77);});return [_76,falses];},pluck:function(_79){var _7a=[];this.each(function(_7b,_7c){_7a.push(_7b[_79]);});return _7a;},reject:function(_7d){var _7e=[];this.each(function(_7f,_80){if(!_7d(_7f,_80)){_7e.push(_7f);}});return _7e;},sortBy:function(_81){return this.map(function(_82,_83){return {value:_82,criteria:_81(_82,_83)};}).sort(function(_84,_85){var a=_84.criteria,b=_85.criteria;return a<b?-1:a>b?1:0;}).pluck("value");},toArray:function(){return this.map();},zip:function(){var _87=Prototype.K,args=$A(arguments);if(typeof args.last()=="function"){_87=args.pop();}var _88=[this].concat(args).map($A);return this.map(function(_89,_8a){return _87(_88.pluck(_8a));});},size:function(){return this.toArray().length;},inspect:function(){return "#<Enumerable:"+this.toArray().inspect()+">";}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray});var $A=Array.from=function(_8b){if(!_8b){return [];}if(_8b.toArray){return _8b.toArray();}else{var _8c=[];for(var i=0,length=_8b.length;i<length;i++){_8c.push(_8b[i]);}return _8c;}};Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse;}Object.extend(Array.prototype,{_each:function(_8e){for(var i=0,length=this.length;i<length;i++){_8e(this[i]);}},clear:function(){this.length=0;return this;},first:function(){return this[0];},last:function(){return this[this.length-1];},compact:function(){return this.select(function(_90){return _90!=null;});},flatten:function(){return this.inject([],function(_91,_92){return _91.concat(_92&&_92.constructor==Array?_92.flatten():[_92]);});},without:function(){var _93=$A(arguments);return this.select(function(_94){return !_93.include(_94);});},indexOf:function(_95){for(var i=0,length=this.length;i<length;i++){if(this[i]==_95){return i;}}return -1;},reverse:function(_97){return (_97!==false?this:this.toArray())._reverse();},reduce:function(){return this.length>1?this:this[0];},uniq:function(){return this.inject([],function(_98,_99){return _98.include(_99)?_98:_98.concat([_99]);});},clone:function(){return [].concat(this);},size:function(){return this.length;},inspect:function(){return "["+this.map(Object.inspect).join(", ")+"]";}});Array.prototype.toArray=Array.prototype.clone;function $w(_9a){_9a=_9a.strip();return _9a?_9a.split(/\s+/):[];}if(window.opera){Array.prototype.concat=function(){var _9b=[];for(var i=0,length=this.length;i<length;i++){_9b.push(this[i]);}for(var i=0,length=arguments.length;i<length;i++){if(arguments[i].constructor==Array){for(var j=0,arrayLength=arguments[i].length;j<arrayLength;j++){_9b.push(arguments[i][j]);}}else{_9b.push(arguments[i]);}}return _9b;};}var Hash=function(obj){Object.extend(this,obj||{});};Object.extend(Hash,{toQueryString:function(obj){var _a1=[];this.prototype._each.call(obj,function(_a2){if(!_a2.key){return;}if(_a2.value&&_a2.value.constructor==Array){var _a3=_a2.value.compact();if(_a3.length<2){_a2.value=_a3.reduce();}else{key=encodeURIComponent(_a2.key);_a3.each(function(_a4){_a4=_a4!=undefined?encodeURIComponent(_a4):"";_a1.push(key+"="+encodeURIComponent(_a4));});return;}}if(_a2.value==undefined){_a2[1]="";}_a1.push(_a2.map(encodeURIComponent).join("="));});return _a1.join("&");}});Object.extend(Hash.prototype,Enumerable);Object.extend(Hash.prototype,{_each:function(_a5){for(var key in this){var _a7=this[key];if(_a7&&_a7==Hash.prototype[key]){continue;}var _a8=[key,_a7];_a8.key=key;_a8.value=_a7;_a5(_a8);}},keys:function(){return this.pluck("key");},values:function(){return this.pluck("value");},merge:function(_a9){return $H(_a9).inject(this,function(_aa,_ab){_aa[_ab.key]=_ab.value;return _aa;});},remove:function(){var _ac;for(var i=0,length=arguments.length;i<length;i++){var _ae=this[arguments[i]];if(_ae!==undefined){if(_ac===undefined){_ac=_ae;}else{if(_ac.constructor!=Array){_ac=[_ac];}_ac.push(_ae);}}delete this[arguments[i]];}return _ac;},toQueryString:function(){return Hash.toQueryString(this);},inspect:function(){return "#<Hash:{"+this.map(function(_af){return _af.map(Object.inspect).join(": ");}).join(", ")+"}>";}});function $H(_b0){if(_b0&&_b0.constructor==Hash){return _b0;}return new Hash(_b0);}ObjectRange=Class.create();Object.extend(ObjectRange.prototype,Enumerable);Object.extend(ObjectRange.prototype,{initialize:function(_b1,end,_b3){this.start=_b1;this.end=end;this.exclusive=_b3;},_each:function(_b4){var _b5=this.start;while(this.include(_b5)){_b4(_b5);_b5=_b5.succ();}},include:function(_b6){if(_b6<this.start){return false;}if(this.exclusive){return _b6<this.end;}return _b6<=this.end;}});var $R=function(_b7,end,_b9){return new ObjectRange(_b7,end,_b9);};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest();},function(){return new ActiveXObject("Msxml2.XMLHTTP");},function(){return new ActiveXObject("Microsoft.XMLHTTP");})||false;},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(_ba){this.responders._each(_ba);},register:function(_bb){if(!this.include(_bb)){this.responders.push(_bb);}},unregister:function(_bc){this.responders=this.responders.without(_bc);},dispatch:function(_bd,_be,_bf,_c0){this.each(function(_c1){if(typeof _c1[_bd]=="function"){try{_c1[_bd].apply(_c1,[_be,_bf,_c0]);}catch(e){}}});}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++;},onComplete:function(){Ajax.activeRequestCount--;}});Ajax.Base=function(){};Ajax.Base.prototype={setOptions:function(_c2){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:""};Object.extend(this.options,_c2||{});this.options.method=this.options.method.toLowerCase();if(typeof this.options.parameters=="string"){this.options.parameters=this.options.parameters.toQueryParams();}}};Ajax.Request=Class.create();Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Request.prototype=Object.extend(new Ajax.Base(),{_complete:false,initialize:function(url,_c4){this.transport=Ajax.getTransport();this.setOptions(_c4);this.request(url);},request:function(url){this.url=url;this.method=this.options.method;var _c6=this.options.parameters;if(!["get","post"].include(this.method)){_c6["_method"]=this.method;this.method="post";}_c6=Hash.toQueryString(_c6);if(_c6&&/Konqueror|Safari|KHTML/.test(navigator.userAgent)){_c6+="&_=";}if(this.method=="get"&&_c6){this.url+=(this.url.indexOf("?")>-1?"&":"?")+_c6;}try{Ajax.Responders.dispatch("onCreate",this,this.transport);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){setTimeout(function(){this.respondToReadyState(1);}.bind(this),10);}this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();var _c7=this.method=="post"?(this.options.postBody||_c6):null;this.transport.send(_c7);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange();}}catch(e){this.dispatchException(e);}},onStateChange:function(){var _c8=this.transport.readyState;if(_c8>1&&!((_c8==4)&&this._complete)){this.respondToReadyState(this.transport.readyState);}},setRequestHeaders:function(){var _c9={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,"Accept":"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){_c9["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){_c9["Connection"]="close";}}if(typeof this.options.requestHeaders=="object"){var _ca=this.options.requestHeaders;if(typeof _ca.push=="function"){for(var i=0,length=_ca.length;i<length;i+=2){_c9[_ca[i]]=_ca[i+1];}}else{$H(_ca).each(function(_cc){_c9[_cc.key]=_cc.value;});}}for(var _cd in _c9){this.transport.setRequestHeader(_cd,_c9[_cd]);}},success:function(){return !this.transport.status||(this.transport.status>=200&&this.transport.status<300);},respondToReadyState:function(_ce){var _cf=Ajax.Request.Events[_ce];var _d0=this.transport,json=this.evalJSON();if(_cf=="Complete"){try{this._complete=true;(this.options["on"+this.transport.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(_d0,json);}catch(e){this.dispatchException(e);}if((this.getHeader("Content-type")||"text/javascript").strip().match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)){this.evalResponse();}}try{(this.options["on"+_cf]||Prototype.emptyFunction)(_d0,json);Ajax.Responders.dispatch("on"+_cf,this,_d0,json);}catch(e){this.dispatchException(e);}if(_cf=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction;}},getHeader:function(_d1){try{return this.transport.getResponseHeader(_d1);}catch(e){return null;}},evalJSON:function(){try{var _d2=this.getHeader("X-JSON");return _d2?eval("("+_d2+")"):null;}catch(e){return null;}},evalResponse:function(){try{return eval(this.transport.responseText);}catch(e){this.dispatchException(e);}},dispatchException:function(_d3){(this.options.onException||Prototype.emptyFunction)(this,_d3);Ajax.Responders.dispatch("onException",this,_d3);}});Ajax.Updater=Class.create();Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(_d4,url,_d6){this.container={success:(_d4.success||_d4),failure:(_d4.failure||(_d4.success?null:_d4))};this.transport=Ajax.getTransport();this.setOptions(_d6);var _d7=this.options.onComplete||Prototype.emptyFunction;this.options.onComplete=(function(_d8,_d9){this.updateContent();_d7(_d8,_d9);}).bind(this);this.request(url);},updateContent:function(){var _da=this.container[this.success()?"success":"failure"];var _db=this.transport.responseText;if(!this.options.evalScripts){_db=_db.stripScripts();}if(_da=$(_da)){if(this.options.insertion){new this.options.insertion(_da,_db);}else{_da.update(_db);}}if(this.success()){if(this.onComplete){setTimeout(this.onComplete.bind(this),10);}}}});Ajax.PeriodicalUpdater=Class.create();Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(_dc,url,_de){this.setOptions(_de);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=_dc;this.url=url;this.start();},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent();},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments);},updateComplete:function(_df){if(this.options.decay){this.decay=(_df.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=_df.responseText;}this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});function $(_e0){if(arguments.length>1){for(var i=0,elements=[],length=arguments.length;i<length;i++){elements.push($(arguments[i]));}return elements;}if(typeof _e0=="string"){_e0=document.getElementById(_e0);}return Element.extend(_e0);}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(_e2,_e3){var _e4=[];var _e5=document.evaluate(_e2,$(_e3)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var i=0,length=_e5.snapshotLength;i<length;i++){_e4.push(_e5.snapshotItem(i));}return _e4;};}document.getElementsByClassName=function(_e7,_e8){if(Prototype.BrowserFeatures.XPath){var q=".//*[contains(concat(' ', @class, ' '), ' "+_e7+" ')]";return document._getElementsByXPath(q,_e8);}else{var _ea=($(_e8)||document.body).getElementsByTagName("*");var _eb=[],child;for(var i=0,length=_ea.length;i<length;i++){child=_ea[i];if(Element.hasClassName(child,_e7)){_eb.push(Element.extend(child));}}return _eb;}};if(!window.Element){var Element=new Object();}Element.extend=function(_ed){if(!_ed||_nativeExtensions||_ed.nodeType==3){return _ed;}if(!_ed._extended&&_ed.tagName&&_ed!=window){var _ee=Object.clone(Element.Methods),cache=Element.extend.cache;if(_ed.tagName=="FORM"){Object.extend(_ee,Form.Methods);}if(["INPUT","TEXTAREA","SELECT"].include(_ed.tagName)){Object.extend(_ee,Form.Element.Methods);}Object.extend(_ee,Element.Methods.Simulated);for(var _ef in _ee){var _f0=_ee[_ef];if(typeof _f0=="function"&&!(_ef in _ed)){_ed[_ef]=cache.findOrStore(_f0);}}}_ed._extended=true;return _ed;};Element.extend.cache={findOrStore:function(_f1){return this[_f1]=this[_f1]||function(){return _f1.apply(null,[this].concat($A(arguments)));};}};Element.Methods={visible:function(_f2){return $(_f2).style.display!="none";},toggle:function(_f3){_f3=$(_f3);Element[Element.visible(_f3)?"hide":"show"](_f3);return _f3;},hide:function(_f4){$(_f4).style.display="none";return _f4;},show:function(_f5){$(_f5).style.display="";return _f5;},remove:function(_f6){_f6=$(_f6);_f6.parentNode.removeChild(_f6);return _f6;},update:function(_f7,_f8){_f8=typeof _f8=="undefined"?"":_f8.toString();$(_f7).innerHTML=_f8.stripScripts();setTimeout(function(){_f8.evalScripts();},10);return _f7;},replace:function(_f9,_fa){_f9=$(_f9);_fa=typeof _fa=="undefined"?"":_fa.toString();if(_f9.outerHTML){_f9.outerHTML=_fa.stripScripts();}else{var _fb=_f9.ownerDocument.createRange();_fb.selectNodeContents(_f9);_f9.parentNode.replaceChild(_fb.createContextualFragment(_fa.stripScripts()),_f9);}setTimeout(function(){_fa.evalScripts();},10);return _f9;},inspect:function(_fc){_fc=$(_fc);var _fd="<"+_fc.tagName.toLowerCase();$H({"id":"id","className":"class"}).each(function(_fe){var _ff=_fe.first(),attribute=_fe.last();var _100=(_fc[_ff]||"").toString();if(_100){_fd+=" "+attribute+"="+_100.inspect(true);}});return _fd+">";},recursivelyCollect:function(_101,_102){_101=$(_101);var _103=[];while(_101=_101[_102]){if(_101.nodeType==1){_103.push(Element.extend(_101));}}return _103;},ancestors:function(_104){return $(_104).recursivelyCollect("parentNode");},descendants:function(_105){return $A($(_105).getElementsByTagName("*"));},immediateDescendants:function(_106){if(!(_106=$(_106).firstChild)){return [];}while(_106&&_106.nodeType!=1){_106=_106.nextSibling;}if(_106){return [_106].concat($(_106).nextSiblings());}return [];},previousSiblings:function(_107){return $(_107).recursivelyCollect("previousSibling");},nextSiblings:function(_108){return $(_108).recursivelyCollect("nextSibling");},siblings:function(_109){_109=$(_109);return _109.previousSiblings().reverse().concat(_109.nextSiblings());},match:function(_10a,_10b){if(typeof _10b=="string"){_10b=new Selector(_10b);}return _10b.match($(_10a));},up:function(_10c,_10d,_10e){return Selector.findElement($(_10c).ancestors(),_10d,_10e);},down:function(_10f,_110,_111){return Selector.findElement($(_10f).descendants(),_110,_111);},previous:function(_112,_113,_114){return Selector.findElement($(_112).previousSiblings(),_113,_114);},next:function(_115,_116,_117){return Selector.findElement($(_115).nextSiblings(),_116,_117);},getElementsBySelector:function(){var args=$A(arguments),element=$(args.shift());return Selector.findChildElements(element,args);},getElementsByClassName:function(_119,_11a){return document.getElementsByClassName(_11a,_119);},readAttribute:function(_11b,name){_11b=$(_11b);if(document.all&&!window.opera){var t=Element._attributeTranslations;if(t.values[name]){return t.values[name](_11b,name);}if(t.names[name]){name=t.names[name];}var _11e=_11b.attributes[name];if(_11e){return _11e.nodeValue;}}return _11b.getAttribute(name);},getHeight:function(_11f){return $(_11f).getDimensions().height;},getWidth:function(_120){return $(_120).getDimensions().width;},classNames:function(_121){return new Element.ClassNames(_121);},hasClassName:function(_122,_123){if(!(_122=$(_122))){return;}var _124=_122.className;if(_124.length==0){return false;}if(_124==_123||_124.match(new RegExp("(^|\\s)"+_123+"(\\s|$)"))){return true;}return false;},addClassName:function(_125,_126){if(!(_125=$(_125))){return;}Element.classNames(_125).add(_126);return _125;},removeClassName:function(_127,_128){if(!(_127=$(_127))){return;}Element.classNames(_127).remove(_128);return _127;},toggleClassName:function(_129,_12a){if(!(_129=$(_129))){return;}Element.classNames(_129)[_129.hasClassName(_12a)?"remove":"add"](_12a);return _129;},observe:function(){Event.observe.apply(Event,arguments);return $A(arguments).first();},stopObserving:function(){Event.stopObserving.apply(Event,arguments);return $A(arguments).first();},cleanWhitespace:function(_12b){_12b=$(_12b);var node=_12b.firstChild;while(node){var _12d=node.nextSibling;if(node.nodeType==3&&!/\S/.test(node.nodeValue)){_12b.removeChild(node);}node=_12d;}return _12b;},empty:function(_12e){return $(_12e).innerHTML.match(/^\s*$/);},descendantOf:function(_12f,_130){_12f=$(_12f),_130=$(_130);while(_12f=_12f.parentNode){if(_12f==_130){return true;}}return false;},scrollTo:function(_131){_131=$(_131);var pos=Position.cumulativeOffset(_131);window.scrollTo(pos[0],pos[1]);return _131;},getStyle:function(_133,_134){_133=$(_133);if(["float","cssFloat"].include(_134)){_134=(typeof _133.style.styleFloat!="undefined"?"styleFloat":"cssFloat");}_134=_134.camelize();var _135=_133.style[_134];if(!_135){if(document.defaultView&&document.defaultView.getComputedStyle){var css=document.defaultView.getComputedStyle(_133,null);_135=css?css[_134]:null;}else{if(_133.currentStyle){_135=_133.currentStyle[_134];}}}if((_135=="auto")&&["width","height"].include(_134)&&(_133.getStyle("display")!="none")){_135=_133["offset"+_134.capitalize()]+"px";}if(window.opera&&["left","top","right","bottom"].include(_134)){if(Element.getStyle(_133,"position")=="static"){_135="auto";}}if(_134=="opacity"){if(_135){return parseFloat(_135);}if(_135=(_133.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(_135[1]){return parseFloat(_135[1])/100;}}return 1;}return _135=="auto"?null:_135;},setStyle:function(_137,_138){_137=$(_137);for(var name in _138){var _13a=_138[name];if(name=="opacity"){if(_13a==1){_13a=(/Gecko/.test(navigator.userAgent)&&!/Konqueror|Safari|KHTML/.test(navigator.userAgent))?0.999999:1;if(/MSIE/.test(navigator.userAgent)&&!window.opera){_137.style.filter=_137.getStyle("filter").replace(/alpha\([^\)]*\)/gi,"");}}else{if(_13a==""){if(/MSIE/.test(navigator.userAgent)&&!window.opera){_137.style.filter=_137.getStyle("filter").replace(/alpha\([^\)]*\)/gi,"");}}else{if(_13a<0.00001){_13a=0;}if(/MSIE/.test(navigator.userAgent)&&!window.opera){_137.style.filter=_137.getStyle("filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+_13a*100+")";}}}}else{if(["float","cssFloat"].include(name)){name=(typeof _137.style.styleFloat!="undefined")?"styleFloat":"cssFloat";}}_137.style[name.camelize()]=_13a;}return _137;},getDimensions:function(_13b){_13b=$(_13b);var _13c=$(_13b).getStyle("display");if(_13c!="none"&&_13c!=null){return {width:_13b.offsetWidth,height:_13b.offsetHeight};}var els=_13b.style;var _13e=els.visibility;var _13f=els.position;var _140=els.display;els.visibility="hidden";els.position="absolute";els.display="block";var _141=_13b.clientWidth;var _142=_13b.clientHeight;els.display=_140;els.position=_13f;els.visibility=_13e;return {width:_141,height:_142};},makePositioned:function(_143){_143=$(_143);var pos=Element.getStyle(_143,"position");if(pos=="static"||!pos){_143._madePositioned=true;_143.style.position="relative";if(window.opera){_143.style.top=0;_143.style.left=0;}}return _143;},undoPositioned:function(_145){_145=$(_145);if(_145._madePositioned){_145._madePositioned=undefined;_145.style.position=_145.style.top=_145.style.left=_145.style.bottom=_145.style.right="";}return _145;},makeClipping:function(_146){_146=$(_146);if(_146._overflow){return _146;}_146._overflow=_146.style.overflow||"auto";if((Element.getStyle(_146,"overflow")||"visible")!="hidden"){_146.style.overflow="hidden";}return _146;},undoClipping:function(_147){_147=$(_147);if(!_147._overflow){return _147;}_147.style.overflow=_147._overflow=="auto"?"":_147._overflow;_147._overflow=null;return _147;}};Object.extend(Element.Methods,{childOf:Element.Methods.descendantOf});Element._attributeTranslations={};Element._attributeTranslations.names={colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",datetime:"dateTime",accesskey:"accessKey",tabindex:"tabIndex",enctype:"encType",maxlength:"maxLength",readonly:"readOnly",longdesc:"longDesc"};Element._attributeTranslations.values={_getAttr:function(_148,_149){return _148.getAttribute(_149,2);},_flag:function(_14a,_14b){return $(_14a).hasAttribute(_14b)?_14b:null;},style:function(_14c){return _14c.style.cssText.toLowerCase();},title:function(_14d){var node=_14d.getAttributeNode("title");return node.specified?node.nodeValue:null;}};Object.extend(Element._attributeTranslations.values,{href:Element._attributeTranslations.values._getAttr,src:Element._attributeTranslations.values._getAttr,disabled:Element._attributeTranslations.values._flag,checked:Element._attributeTranslations.values._flag,readonly:Element._attributeTranslations.values._flag,multiple:Element._attributeTranslations.values._flag});Element.Methods.Simulated={hasAttribute:function(_14f,_150){var t=Element._attributeTranslations;_150=t.names[_150]||_150;return $(_14f).getAttributeNode(_150).specified;}};if(document.all&&!window.opera){Element.Methods.update=function(_152,html){_152=$(_152);html=typeof html=="undefined"?"":html.toString();var _154=_152.tagName.toUpperCase();if(["THEAD","TBODY","TR","TD"].include(_154)){var div=document.createElement("div");switch(_154){case "THEAD":case "TBODY":div.innerHTML="<table><tbody>"+html.stripScripts()+"</tbody></table>";depth=2;break;case "TR":div.innerHTML="<table><tbody><tr>"+html.stripScripts()+"</tr></tbody></table>";depth=3;break;case "TD":div.innerHTML="<table><tbody><tr><td>"+html.stripScripts()+"</td></tr></tbody></table>";depth=4;}$A(_152.childNodes).each(function(node){_152.removeChild(node);});depth.times(function(){div=div.firstChild;});$A(div.childNodes).each(function(node){_152.appendChild(node);});}else{_152.innerHTML=html.stripScripts();}setTimeout(function(){html.evalScripts();},10);return _152;};}Object.extend(Element,Element.Methods);var _nativeExtensions=false;if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){["","Form","Input","TextArea","Select"].each(function(tag){var _159="HTML"+tag+"Element";if(window[_159]){return;}var _15a=window[_159]={};_15a.prototype=document.createElement(tag?tag.toLowerCase():"div").__proto__;});}Element.addMethods=function(_15b){Object.extend(Element.Methods,_15b||{});function copy(_15c,_15d,_15e){_15e=_15e||false;var _15f=Element.extend.cache;for(var _160 in _15c){var _161=_15c[_160];if(!_15e||!(_160 in _15d)){_15d[_160]=_15f.findOrStore(_161);}}}if(typeof HTMLElement!="undefined"){copy(Element.Methods,HTMLElement.prototype);copy(Element.Methods.Simulated,HTMLElement.prototype,true);copy(Form.Methods,HTMLFormElement.prototype);[HTMLInputElement,HTMLTextAreaElement,HTMLSelectElement].each(function(_162){copy(Form.Element.Methods,_162.prototype);});_nativeExtensions=true;}};var Toggle=new Object();Toggle.display=Element.toggle;Abstract.Insertion=function(_163){this.adjacency=_163;};Abstract.Insertion.prototype={initialize:function(_164,_165){this.element=$(_164);this.content=_165.stripScripts();if(this.adjacency&&this.element.insertAdjacentHTML){try{this.element.insertAdjacentHTML(this.adjacency,this.content);}catch(e){var _166=this.element.tagName.toUpperCase();if(["TBODY","TR"].include(_166)){this.insertContent(this.contentFromAnonymousTable());}else{throw e;}}}else{this.range=this.element.ownerDocument.createRange();if(this.initializeRange){this.initializeRange();}this.insertContent([this.range.createContextualFragment(this.content)]);}setTimeout(function(){_165.evalScripts();},10);},contentFromAnonymousTable:function(){var div=document.createElement("div");div.innerHTML="<table><tbody>"+this.content+"</tbody></table>";return $A(div.childNodes[0].childNodes[0].childNodes);}};var Insertion=new Object();Insertion.Before=Class.create();Insertion.Before.prototype=Object.extend(new Abstract.Insertion("beforeBegin"),{initializeRange:function(){this.range.setStartBefore(this.element);},insertContent:function(_168){_168.each((function(_169){this.element.parentNode.insertBefore(_169,this.element);}).bind(this));}});Insertion.Top=Class.create();Insertion.Top.prototype=Object.extend(new Abstract.Insertion("afterBegin"),{initializeRange:function(){this.range.selectNodeContents(this.element);this.range.collapse(true);},insertContent:function(_16a){_16a.reverse(false).each((function(_16b){this.element.insertBefore(_16b,this.element.firstChild);}).bind(this));}});Insertion.Bottom=Class.create();Insertion.Bottom.prototype=Object.extend(new Abstract.Insertion("beforeEnd"),{initializeRange:function(){this.range.selectNodeContents(this.element);this.range.collapse(this.element);},insertContent:function(_16c){_16c.each((function(_16d){this.element.appendChild(_16d);}).bind(this));}});Insertion.After=Class.create();Insertion.After.prototype=Object.extend(new Abstract.Insertion("afterEnd"),{initializeRange:function(){this.range.setStartAfter(this.element);},insertContent:function(_16e){_16e.each((function(_16f){this.element.parentNode.insertBefore(_16f,this.element.nextSibling);}).bind(this));}});Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(_170){this.element=$(_170);},_each:function(_171){this.element.className.split(/\s+/).select(function(name){return name.length>0;})._each(_171);},set:function(_173){this.element.className=_173;},add:function(_174){if(this.include(_174)){return;}this.set($A(this).concat(_174).join(" "));},remove:function(_175){if(!this.include(_175)){return;}this.set($A(this).without(_175).join(" "));},toString:function(){return $A(this).join(" ");}};Object.extend(Element.ClassNames.prototype,Enumerable);var Selector=Class.create();Selector.prototype={initialize:function(_176){this.params={classNames:[]};this.expression=_176.toString().strip();this.parseExpression();this.compileMatcher();},parseExpression:function(){function abort(_177){throw "Parse error in selector: "+_177;}if(this.expression==""){abort("empty expression");}var _178=this.params,expr=this.expression,match,modifier,clause,rest;while(match=expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)){_178.attributes=_178.attributes||[];_178.attributes.push({name:match[2],operator:match[3],value:match[4]||match[5]||""});expr=match[1];}if(expr=="*"){return this.params.wildcard=true;}while(match=expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)){modifier=match[1],clause=match[2],rest=match[3];switch(modifier){case "#":_178.id=clause;break;case ".":_178.classNames.push(clause);break;case "":case undefined:_178.tagName=clause.toUpperCase();break;default:abort(expr.inspect());}expr=rest;}if(expr.length>0){abort(expr.inspect());}},buildMatchExpression:function(){var _179=this.params,conditions=[],clause;if(_179.wildcard){conditions.push("true");}if(clause=_179.id){conditions.push("element.readAttribute(\"id\") == "+clause.inspect());}if(clause=_179.tagName){conditions.push("element.tagName.toUpperCase() == "+clause.inspect());}if((clause=_179.classNames).length>0){for(var i=0,length=clause.length;i<length;i++){conditions.push("element.hasClassName("+clause[i].inspect()+")");}}if(clause=_179.attributes){clause.each(function(_17b){var _17c="element.readAttribute("+_17b.name.inspect()+")";var _17d=function(_17e){return _17c+" && "+_17c+".split("+_17e.inspect()+")";};switch(_17b.operator){case "=":conditions.push(_17c+" == "+_17b.value.inspect());break;case "~=":conditions.push(_17d(" ")+".include("+_17b.value.inspect()+")");break;case "|=":conditions.push(_17d("-")+".first().toUpperCase() == "+_17b.value.toUpperCase().inspect());break;case "!=":conditions.push(_17c+" != "+_17b.value.inspect());break;case "":case undefined:conditions.push("element.hasAttribute("+_17b.name.inspect()+")");break;default:throw "Unknown operator "+_17b.operator+" in selector";}});}return conditions.join(" && ");},compileMatcher:function(){this.match=new Function("element","if (!element.tagName) return false;       element = $(element);       return "+this.buildMatchExpression());},findElements:function(_17f){var _180;if(_180=$(this.params.id)){if(this.match(_180)){if(!_17f||Element.childOf(_180,_17f)){return [_180];}}}_17f=(_17f||document).getElementsByTagName(this.params.tagName||"*");var _181=[];for(var i=0,length=_17f.length;i<length;i++){if(this.match(_180=_17f[i])){_181.push(Element.extend(_180));}}return _181;},toString:function(){return this.expression;}};Object.extend(Selector,{matchElements:function(_183,_184){var _185=new Selector(_184);return _183.select(_185.match.bind(_185)).map(Element.extend);},findElement:function(_186,_187,_188){if(typeof _187=="number"){_188=_187,_187=false;}return Selector.matchElements(_186,_187||"*")[_188||0];},findChildElements:function(_189,_18a){return _18a.map(function(_18b){return _18b.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null],function(_18c,expr){var _18e=new Selector(expr);return _18c.inject([],function(_18f,_190){return _18f.concat(_18e.findElements(_190||_189));});});}).flatten();}});function $$(){return Selector.findChildElements(document,$A(arguments));}var Form={reset:function(form){$(form).reset();return form;},serializeElements:function(_192,_193){var data=_192.inject({},function(_195,_196){if(!_196.disabled&&_196.name){var key=_196.name,value=$(_196).getValue();if(value!=undefined){if(_195[key]){if(_195[key].constructor!=Array){_195[key]=[_195[key]];}_195[key].push(value);}else{_195[key]=value;}}}return _195;});return _193?data:Hash.toQueryString(data);}};Form.Methods={serialize:function(form,_199){return Form.serializeElements(Form.getElements(form),_199);},getElements:function(form){return $A($(form).getElementsByTagName("*")).inject([],function(_19b,_19c){if(Form.Element.Serializers[_19c.tagName.toLowerCase()]){_19b.push(Element.extend(_19c));}return _19b;});},getInputs:function(form,_19e,name){form=$(form);var _1a0=form.getElementsByTagName("input");if(!_19e&&!name){return $A(_1a0).map(Element.extend);}for(var i=0,matchingInputs=[],length=_1a0.length;i<length;i++){var _1a2=_1a0[i];if((_19e&&_1a2.type!=_19e)||(name&&_1a2.name!=name)){continue;}matchingInputs.push(Element.extend(_1a2));}return matchingInputs;},disable:function(form){form=$(form);form.getElements().each(function(_1a4){_1a4.blur();_1a4.disabled="true";});return form;},enable:function(form){form=$(form);form.getElements().each(function(_1a6){_1a6.disabled="";});return form;},findFirstElement:function(form){return $(form).getElements().find(function(_1a8){return _1a8.type!="hidden"&&!_1a8.disabled&&["input","select","textarea"].include(_1a8.tagName.toLowerCase());});},focusFirstElement:function(form){form=$(form);form.findFirstElement().activate();return form;}};Object.extend(Form,Form.Methods);Form.Element={focus:function(_1aa){$(_1aa).focus();return _1aa;},select:function(_1ab){$(_1ab).select();return _1ab;}};Form.Element.Methods={serialize:function(_1ac){_1ac=$(_1ac);if(!_1ac.disabled&&_1ac.name){var _1ad=_1ac.getValue();if(_1ad!=undefined){var pair={};pair[_1ac.name]=_1ad;return Hash.toQueryString(pair);}}return "";},getValue:function(_1af){_1af=$(_1af);var _1b0=_1af.tagName.toLowerCase();return Form.Element.Serializers[_1b0](_1af);},clear:function(_1b1){$(_1b1).value="";return _1b1;},present:function(_1b2){return $(_1b2).value!="";},activate:function(_1b3){_1b3=$(_1b3);_1b3.focus();if(_1b3.select&&(_1b3.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(_1b3.type))){_1b3.select();}return _1b3;},disable:function(_1b4){_1b4=$(_1b4);_1b4.disabled=true;return _1b4;},enable:function(_1b5){_1b5=$(_1b5);_1b5.blur();_1b5.disabled=false;return _1b5;}};Object.extend(Form.Element,Form.Element.Methods);var Field=Form.Element;var $F=Form.Element.getValue;Form.Element.Serializers={input:function(_1b6){switch(_1b6.type.toLowerCase()){case "checkbox":case "radio":return Form.Element.Serializers.inputSelector(_1b6);default:return Form.Element.Serializers.textarea(_1b6);}},inputSelector:function(_1b7){return _1b7.checked?_1b7.value:null;},textarea:function(_1b8){return _1b8.value;},select:function(_1b9){return this[_1b9.type=="select-one"?"selectOne":"selectMany"](_1b9);},selectOne:function(_1ba){var _1bb=_1ba.selectedIndex;return _1bb>=0?this.optionValue(_1ba.options[_1bb]):null;},selectMany:function(_1bc){var _1bd,length=_1bc.length;if(!length){return null;}for(var i=0,_1bd=[];i<length;i++){var opt=_1bc.options[i];if(opt.selected){_1bd.push(this.optionValue(opt));}}return _1bd;},optionValue:function(opt){return Element.extend(opt).hasAttribute("value")?opt.value:opt.text;}};Abstract.TimedObserver=function(){};Abstract.TimedObserver.prototype={initialize:function(_1c1,_1c2,_1c3){this.frequency=_1c2;this.element=$(_1c1);this.callback=_1c3;this.lastValue=this.getValue();this.registerCallback();},registerCallback:function(){setInterval(this.onTimerEvent.bind(this),this.frequency*1000);},onTimerEvent:function(){var _1c4=this.getValue();var _1c5=("string"==typeof this.lastValue&&"string"==typeof _1c4?this.lastValue!=_1c4:String(this.lastValue)!=String(_1c4));if(_1c5){this.callback(this.element,_1c4);this.lastValue=_1c4;}}};Form.Element.Observer=Class.create();Form.Element.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){return Form.Element.getValue(this.element);}});Form.Observer=Class.create();Form.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){return Form.serialize(this.element);}});Abstract.EventObserver=function(){};Abstract.EventObserver.prototype={initialize:function(_1c6,_1c7){this.element=$(_1c6);this.callback=_1c7;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks();}else{this.registerCallback(this.element);}},onElementEvent:function(){var _1c8=this.getValue();if(this.lastValue!=_1c8){this.callback(this.element,_1c8);this.lastValue=_1c8;}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback.bind(this));},registerCallback:function(_1c9){if(_1c9.type){switch(_1c9.type.toLowerCase()){case "checkbox":case "radio":Event.observe(_1c9,"click",this.onElementEvent.bind(this));break;default:Event.observe(_1c9,"change",this.onElementEvent.bind(this));break;}}}};Form.Element.EventObserver=Class.create();Form.Element.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){return Form.Element.getValue(this.element);}});Form.EventObserver=Class.create();Form.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){return Form.serialize(this.element);}});if(!window.Event){var Event=new Object();}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,element:function(_1ca){return _1ca.target||_1ca.srcElement;},isLeftClick:function(_1cb){return (((_1cb.which)&&(_1cb.which==1))||((_1cb.button)&&(_1cb.button==1)));},pointerX:function(_1cc){return _1cc.pageX||(_1cc.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));},pointerY:function(_1cd){return _1cd.pageY||(_1cd.clientY+(document.documentElement.scrollTop||document.body.scrollTop));},stop:function(_1ce){if(_1ce.preventDefault){_1ce.preventDefault();_1ce.stopPropagation();}else{_1ce.returnValue=false;_1ce.cancelBubble=true;}},findElement:function(_1cf,_1d0){var _1d1=Event.element(_1cf);while(_1d1.parentNode&&(!_1d1.tagName||(_1d1.tagName.toUpperCase()!=_1d0.toUpperCase()))){_1d1=_1d1.parentNode;}return _1d1;},observers:false,_observeAndCache:function(_1d2,name,_1d4,_1d5){if(!this.observers){this.observers=[];}if(_1d2.addEventListener){this.observers.push([_1d2,name,_1d4,_1d5]);_1d2.addEventListener(name,_1d4,_1d5);}else{if(_1d2.attachEvent){this.observers.push([_1d2,name,_1d4,_1d5]);_1d2.attachEvent("on"+name,_1d4);}}},unloadCache:function(){if(!Event.observers){return;}for(var i=0,length=Event.observers.length;i<length;i++){Event.stopObserving.apply(this,Event.observers[i]);Event.observers[i][0]=null;}Event.observers=false;},observe:function(_1d7,name,_1d9,_1da){_1d7=$(_1d7);_1da=_1da||false;if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_1d7.attachEvent)){name="keydown";}Event._observeAndCache(_1d7,name,_1d9,_1da);},stopObserving:function(_1db,name,_1dd,_1de){_1db=$(_1db);_1de=_1de||false;if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_1db.detachEvent)){name="keydown";}if(_1db.removeEventListener){_1db.removeEventListener(name,_1dd,_1de);}else{if(_1db.detachEvent){try{_1db.detachEvent("on"+name,_1dd);}catch(e){}}}}});if(navigator.appVersion.match(/\bMSIE\b/)){Event.observe(window,"unload",Event.unloadCache,false);}var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;},realOffset:function(_1df){var _1e0=0,valueL=0;do{_1e0+=_1df.scrollTop||0;valueL+=_1df.scrollLeft||0;_1df=_1df.parentNode;}while(_1df);return [valueL,_1e0];},cumulativeOffset:function(_1e1){var _1e2=0,valueL=0;do{_1e2+=_1e1.offsetTop||0;valueL+=_1e1.offsetLeft||0;_1e1=_1e1.offsetParent;}while(_1e1);return [valueL,_1e2];},positionedOffset:function(_1e3){var _1e4=0,valueL=0;do{_1e4+=_1e3.offsetTop||0;valueL+=_1e3.offsetLeft||0;_1e3=_1e3.offsetParent;if(_1e3){if(_1e3.tagName=="BODY"){break;}var p=Element.getStyle(_1e3,"position");if(p=="relative"||p=="absolute"){break;}}}while(_1e3);return [valueL,_1e4];},offsetParent:function(_1e6){if(_1e6.offsetParent){return _1e6.offsetParent;}if(_1e6==document.body){return _1e6;}while((_1e6=_1e6.parentNode)&&_1e6!=document.body){if(Element.getStyle(_1e6,"position")!="static"){return _1e6;}}return document.body;},within:function(_1e7,x,y){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(_1e7,x,y);}this.xcomp=x;this.ycomp=y;this.offset=this.cumulativeOffset(_1e7);return (y>=this.offset[1]&&y<this.offset[1]+_1e7.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+_1e7.offsetWidth);},withinIncludingScrolloffsets:function(_1ea,x,y){var _1ed=this.realOffset(_1ea);this.xcomp=x+_1ed[0]-this.deltaX;this.ycomp=y+_1ed[1]-this.deltaY;this.offset=this.cumulativeOffset(_1ea);return (this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+_1ea.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+_1ea.offsetWidth);},overlap:function(mode,_1ef){if(!mode){return 0;}if(mode=="vertical"){return ((this.offset[1]+_1ef.offsetHeight)-this.ycomp)/_1ef.offsetHeight;}if(mode=="horizontal"){return ((this.offset[0]+_1ef.offsetWidth)-this.xcomp)/_1ef.offsetWidth;}},page:function(_1f0){var _1f1=0,valueL=0;var _1f2=_1f0;do{_1f1+=_1f2.offsetTop||0;valueL+=_1f2.offsetLeft||0;if(_1f2.offsetParent==document.body){if(Element.getStyle(_1f2,"position")=="absolute"){break;}}}while(_1f2=_1f2.offsetParent);_1f2=_1f0;do{if(!window.opera||_1f2.tagName=="BODY"){_1f1-=_1f2.scrollTop||0;valueL-=_1f2.scrollLeft||0;}}while(_1f2=_1f2.parentNode);return [valueL,_1f1];},clone:function(_1f3,_1f4){var _1f5=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});_1f3=$(_1f3);var p=Position.page(_1f3);_1f4=$(_1f4);var _1f7=[0,0];var _1f8=null;if(Element.getStyle(_1f4,"position")=="absolute"){_1f8=Position.offsetParent(_1f4);_1f7=Position.page(_1f8);}if(_1f8==document.body){_1f7[0]-=document.body.offsetLeft;_1f7[1]-=document.body.offsetTop;}if(_1f5.setLeft){_1f4.style.left=(p[0]-_1f7[0]+_1f5.offsetLeft)+"px";}if(_1f5.setTop){_1f4.style.top=(p[1]-_1f7[1]+_1f5.offsetTop)+"px";}if(_1f5.setWidth){_1f4.style.width=_1f3.offsetWidth+"px";}if(_1f5.setHeight){_1f4.style.height=_1f3.offsetHeight+"px";}},absolutize:function(_1f9){_1f9=$(_1f9);if(_1f9.style.position=="absolute"){return;}Position.prepare();var _1fa=Position.positionedOffset(_1f9);var top=_1fa[1];var left=_1fa[0];var _1fd=_1f9.clientWidth;var _1fe=_1f9.clientHeight;_1f9._originalLeft=left-parseFloat(_1f9.style.left||0);_1f9._originalTop=top-parseFloat(_1f9.style.top||0);_1f9._originalWidth=_1f9.style.width;_1f9._originalHeight=_1f9.style.height;_1f9.style.position="absolute";_1f9.style.top=top+"px";_1f9.style.left=left+"px";_1f9.style.width=_1fd+"px";_1f9.style.height=_1fe+"px";},relativize:function(_1ff){_1ff=$(_1ff);if(_1ff.style.position=="relative"){return;}Position.prepare();_1ff.style.position="relative";var top=parseFloat(_1ff.style.top||0)-(_1ff._originalTop||0);var left=parseFloat(_1ff.style.left||0)-(_1ff._originalLeft||0);_1ff.style.top=top+"px";_1ff.style.left=left+"px";_1ff.style.height=_1ff._originalHeight;_1ff.style.width=_1ff._originalWidth;}};if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){Position.cumulativeOffset=function(_202){var _203=0,valueL=0;do{_203+=_202.offsetTop||0;valueL+=_202.offsetLeft||0;if(_202.offsetParent==document.body){if(Element.getStyle(_202,"position")=="absolute"){break;}}_202=_202.offsetParent;}while(_202);return [valueL,_203];};}Element.addMethods();
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// 
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

var Scriptaculous = {
  Version: '1.5.1',
  require: function(libraryName) {
    // inserting via DOM fails in Safari 2.0, so brute force approach
    document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
  },
  load: function() {
    if((typeof Prototype=='undefined') ||
      parseFloat(Prototype.Version.split(".")[0] + "." +
                 Prototype.Version.split(".")[1]) < 1.4)
      throw("script.aculo.us requires the Prototype JavaScript framework >= 1.4.0");
    
    $A(document.getElementsByTagName("script")).findAll( function(s) {
      return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
    }).each( function(s) {
      var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
      var includes = s.src.match(/\?.*load=([a-z,]*)/);
      (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider').split(',').each(
       function(include) { Scriptaculous.require(path+include+'.js') });
    });
  }
}

Scriptaculous.load();
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
//  Justin Palmer (http://encytemedia.com/)
//  Mark Pilgrim (http://diveintomark.org/)
//  Martin Bialasinki
// 
// See scriptaculous.js for full license.  

/* ------------- element ext -------------- */  
 
// converts rgb() and #xxx to #xxxxxx format,  
// returns self (or first argument) if not convertable  
String.prototype.parseColor = function() {  
  var color = '#';  
  if(this.slice(0,4) == 'rgb(') {  
    var cols = this.slice(4,this.length-1).split(',');  
    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);  
  } else {  
    if(this.slice(0,1) == '#') {  
      if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();  
      if(this.length==7) color = this.toLowerCase();  
    }  
  }  
  return(color.length==7 ? color : (arguments[0] || this));  
}

Element.collectTextNodes = function(element) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
  }).flatten().join('');
}

Element.collectTextNodesIgnoreClass = function(element, className) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? 
        Element.collectTextNodes(node) : ''));
  }).flatten().join('');
}

Element.setStyle = function(element, style) {
  element = $(element);
  for(k in style) element.style[k.camelize()] = style[k];
}

Element.setContentZoom = function(element, percent) {  
  Element.setStyle(element, {fontSize: (percent/100) + 'em'});   
  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);  
}

Element.getOpacity = function(element){  
  var opacity;
  if (opacity = Element.getStyle(element, 'opacity'))  
    return parseFloat(opacity);  
  if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))  
    if(opacity[1]) return parseFloat(opacity[1]) / 100;  
  return 1.0;  
}

Element.setOpacity = function(element, value){  
  element= $(element);  
  if (value == 1){
    Element.setStyle(element, { opacity: 
      (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 
      0.999999 : null });
    if(/MSIE/.test(navigator.userAgent))  
      Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});  
  } else {  
    if(value < 0.00001) value = 0;  
    Element.setStyle(element, {opacity: value});
    if(/MSIE/.test(navigator.userAgent))  
     Element.setStyle(element, 
       { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
                 'alpha(opacity='+value*100+')' });  
  }   
}  
 
Element.getInlineOpacity = function(element){  
  return $(element).style.opacity || '';
}  

Element.childrenWithClassName = function(element, className) {  
  return $A($(element).getElementsByTagName('*')).select(
    function(c) { return Element.hasClassName(c, className) });
}

Array.prototype.call = function() {
  var args = arguments;
  this.each(function(f){ f.apply(this, args) });
}

/*--------------------------------------------------------------------------*/

var Effect = {
  tagifyText: function(element) {
    var tagifyStyle = 'position:relative';
    if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
    element = $(element);
    $A(element.childNodes).each( function(child) {
      if(child.nodeType==3) {
        child.nodeValue.toArray().each( function(character) {
          element.insertBefore(
            Builder.node('span',{style: tagifyStyle},
              character == ' ' ? String.fromCharCode(160) : character), 
              child);
        });
        Element.remove(child);
      }
    });
  },
  multiple: function(element, effect) {
    var elements;
    if(((typeof element == 'object') || 
        (typeof element == 'function')) && 
       (element.length))
      elements = element;
    else
      elements = $(element).childNodes;
      
    var options = Object.extend({
      speed: 0.1,
      delay: 0.0
    }, arguments[2] || {});
    var masterDelay = options.delay;

    $A(elements).each( function(element, index) {
      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
    });
  },
  PAIRS: {
    'slide':  ['SlideDown','SlideUp'],
    'blind':  ['BlindDown','BlindUp'],
    'appear': ['Appear','Fade']
  },
  toggle: function(element, effect) {
    element = $(element);
    effect = (effect || 'appear').toLowerCase();
    var options = Object.extend({
      queue: { position:'end', scope:(element.id || 'global') }
    }, arguments[2] || {});
    Effect[Element.visible(element) ? 
      Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
  }
};

var Effect2 = Effect; // deprecated

/* ------------- transitions ------------- */

Effect.Transitions = {}

Effect.Transitions.linear = function(pos) {
  return pos;
}
Effect.Transitions.sinoidal = function(pos) {
  return (-Math.cos(pos*Math.PI)/2) + 0.5;
}
Effect.Transitions.reverse  = function(pos) {
  return 1-pos;
}
Effect.Transitions.flicker = function(pos) {
  return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
}
Effect.Transitions.wobble = function(pos) {
  return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
}
Effect.Transitions.pulse = function(pos) {
  return (Math.floor(pos*10) % 2 == 0 ? 
    (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)));
}
Effect.Transitions.none = function(pos) {
  return 0;
}
Effect.Transitions.full = function(pos) {
  return 1;
}

/* ------------- core effects ------------- */

Effect.ScopedQueue = Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
  initialize: function() {
    this.effects  = [];
    this.interval = null;
  },
  _each: function(iterator) {
    this.effects._each(iterator);
  },
  add: function(effect) {
    var timestamp = new Date().getTime();
    
    var position = (typeof effect.options.queue == 'string') ? 
      effect.options.queue : effect.options.queue.position;
    
    switch(position) {
      case 'front':
        // move unstarted effects after this effect  
        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
            e.startOn  += effect.finishOn;
            e.finishOn += effect.finishOn;
          });
        break;
      case 'end':
        // start effect after last queued effect has finished
        timestamp = this.effects.pluck('finishOn').max() || timestamp;
        break;
    }
    
    effect.startOn  += timestamp;
    effect.finishOn += timestamp;
    this.effects.push(effect);
    if(!this.interval) 
      this.interval = setInterval(this.loop.bind(this), 40);
  },
  remove: function(effect) {
    this.effects = this.effects.reject(function(e) { return e==effect });
    if(this.effects.length == 0) {
      clearInterval(this.interval);
      this.interval = null;
    }
  },
  loop: function() {
    var timePos = new Date().getTime();
    this.effects.invoke('loop', timePos);
  }
});

Effect.Queues = {
  instances: $H(),
  get: function(queueName) {
    if(typeof queueName != 'string') return queueName;
    
    if(!this.instances[queueName])
      this.instances[queueName] = new Effect.ScopedQueue();
      
    return this.instances[queueName];
  }
}
Effect.Queue = Effect.Queues.get('global');

Effect.DefaultOptions = {
  transition: Effect.Transitions.sinoidal,
  duration:   1.0,   // seconds
  fps:        25.0,  // max. 25fps due to Effect.Queue implementation
  sync:       false, // true for combining
  from:       0.0,
  to:         1.0,
  delay:      0.0,
  queue:      'parallel'
}

Effect.Base = function() {};
Effect.Base.prototype = {
  position: null,
  start: function(options) {
    this.options      = Object.extend(Object.extend({},Effect.DefaultOptions), options || {});
    this.currentFrame = 0;
    this.state        = 'idle';
    this.startOn      = this.options.delay*1000;
    this.finishOn     = this.startOn + (this.options.duration*1000);
    this.event('beforeStart');
    if(!this.options.sync)
      Effect.Queues.get(typeof this.options.queue == 'string' ? 
        'global' : this.options.queue.scope).add(this);
  },
  loop: function(timePos) {
    if(timePos >= this.startOn) {
      if(timePos >= this.finishOn) {
        this.render(1.0);
        this.cancel();
        this.event('beforeFinish');
        if(this.finish) this.finish(); 
        this.event('afterFinish');
        return;  
      }
      var pos   = (timePos - this.startOn) / (this.finishOn - this.startOn);
      var frame = Math.round(pos * this.options.fps * this.options.duration);
      if(frame > this.currentFrame) {
        this.render(pos);
        this.currentFrame = frame;
      }
    }
  },
  render: function(pos) {
    if(this.state == 'idle') {
      this.state = 'running';
      this.event('beforeSetup');
      if(this.setup) this.setup();
      this.event('afterSetup');
    }
    if(this.state == 'running') {
      if(this.options.transition) pos = this.options.transition(pos);
      pos *= (this.options.to-this.options.from);
      pos += this.options.from;
      this.position = pos;
      this.event('beforeUpdate');
      if(this.update) this.update(pos);
      this.event('afterUpdate');
    }
  },
  cancel: function() {
    if(!this.options.sync)
      Effect.Queues.get(typeof this.options.queue == 'string' ? 
        'global' : this.options.queue.scope).remove(this);
    this.state = 'finished';
  },
  event: function(eventName) {
    if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
    if(this.options[eventName]) this.options[eventName](this);
  },
  inspect: function() {
    return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>';
  }
}

Effect.Parallel = Class.create();
Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
  initialize: function(effects) {
    this.effects = effects || [];
    this.start(arguments[1]);
  },
  update: function(position) {
    this.effects.invoke('render', position);
  },
  finish: function(position) {
    this.effects.each( function(effect) {
      effect.render(1.0);
      effect.cancel();
      effect.event('beforeFinish');
      if(effect.finish) effect.finish(position);
      effect.event('afterFinish');
    });
  }
});

Effect.Opacity = Class.create();
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    // make this work on IE on elements without 'layout'
    if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
      Element.setStyle(this.element, {zoom: 1});
    var options = Object.extend({
      from: Element.getOpacity(this.element) || 0.0,
      to:   1.0
    }, arguments[1] || {});
    this.start(options);
  },
  update: function(position) {
    Element.setOpacity(this.element, position);
  }
});

Effect.Move = Class.create();
Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    var options = Object.extend({
      x:    0,
      y:    0,
      mode: 'relative'
    }, arguments[1] || {});
    this.start(options);
  },
  setup: function() {
    // Bug in Opera: Opera returns the "real" position of a static element or
    // relative element that does not have top/left explicitly set.
    // ==> Always set top and left for position relative elements in your stylesheets 
    // (to 0 if you do not need them) 
    Element.makePositioned(this.element);
    this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0');
    this.originalTop  = parseFloat(Element.getStyle(this.element,'top')  || '0');
    if(this.options.mode == 'absolute') {
      // absolute movement, so we need to calc deltaX and deltaY
      this.options.x = this.options.x - this.originalLeft;
      this.options.y = this.options.y - this.originalTop;
    }
  },
  update: function(position) {
    Element.setStyle(this.element, {
      left: this.options.x  * position + this.originalLeft + 'px',
      top:  this.options.y  * position + this.originalTop  + 'px'
    });
  }
});

// for backwards compatibility
Effect.MoveBy = function(element, toTop, toLeft) {
  return new Effect.Move(element, 
    Object.extend({ x: toLeft, y: toTop }, arguments[3] || {}));
};

Effect.Scale = Class.create();
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
  initialize: function(element, percent) {
    this.element = $(element)
    var options = Object.extend({
      scaleX: true,
      scaleY: true,
      scaleContent: true,
      scaleFromCenter: false,
      scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
      scaleFrom: 100.0,
      scaleTo:   percent
    }, arguments[2] || {});
    this.start(options);
  },
  setup: function() {
    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
    this.elementPositioning = Element.getStyle(this.element,'position');
    
    this.originalStyle = {};
    ['top','left','width','height','fontSize'].each( function(k) {
      this.originalStyle[k] = this.element.style[k];
    }.bind(this));
      
    this.originalTop  = this.element.offsetTop;
    this.originalLeft = this.element.offsetLeft;
    
    var fontSize = Element.getStyle(this.element,'font-size') || '100%';
    ['em','px','%'].each( function(fontSizeType) {
      if(fontSize.indexOf(fontSizeType)>0) {
        this.fontSize     = parseFloat(fontSize);
        this.fontSizeType = fontSizeType;
      }
    }.bind(this));
    
    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
    
    this.dims = null;
    if(this.options.scaleMode=='box')
      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
    if(/^content/.test(this.options.scaleMode))
      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
    if(!this.dims)
      this.dims = [this.options.scaleMode.originalHeight,
                   this.options.scaleMode.originalWidth];
  },
  update: function(position) {
    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
    if(this.options.scaleContent && this.fontSize)
      Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType });
    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
  },
  finish: function(position) {
    if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle);
  },
  setDimensions: function(height, width) {
    var d = {};
    if(this.options.scaleX) d.width = width + 'px';
    if(this.options.scaleY) d.height = height + 'px';
    if(this.options.scaleFromCenter) {
      var topd  = (height - this.dims[0])/2;
      var leftd = (width  - this.dims[1])/2;
      if(this.elementPositioning == 'absolute') {
        if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
        if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
      } else {
        if(this.options.scaleY) d.top = -topd + 'px';
        if(this.options.scaleX) d.left = -leftd + 'px';
      }
    }
    Element.setStyle(this.element, d);
  }
});

Effect.Highlight = Class.create();
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
    this.start(options);
  },
  setup: function() {
    // Prevent executing on elements not in the layout flow
    if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; }
    // Disable background image during the effect
    this.oldStyle = {
      backgroundImage: Element.getStyle(this.element, 'background-image') };
    Element.setStyle(this.element, {backgroundImage: 'none'});
    if(!this.options.endcolor)
      this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff');
    if(!this.options.restorecolor)
      this.options.restorecolor = Element.getStyle(this.element, 'background-color');
    // init color calculations
    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
  },
  update: function(position) {
    Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){
      return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
  },
  finish: function() {
    Element.setStyle(this.element, Object.extend(this.oldStyle, {
      backgroundColor: this.options.restorecolor
    }));
  }
});

Effect.ScrollTo = Class.create();
Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    this.start(arguments[1] || {});
  },
  setup: function() {
    Position.prepare();
    var offsets = Position.cumulativeOffset(this.element);
    if(this.options.offset) offsets[1] += this.options.offset;
    var max = window.innerHeight ? 
      window.height - window.innerHeight :
      document.body.scrollHeight - 
        (document.documentElement.clientHeight ? 
          document.documentElement.clientHeight : document.body.clientHeight);
    this.scrollStart = Position.deltaY;
    this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
  },
  update: function(position) {
    Position.prepare();
    window.scrollTo(Position.deltaX, 
      this.scrollStart + (position*this.delta));
  }
});

/* ------------- combination effects ------------- */

Effect.Fade = function(element) {
  var oldOpacity = Element.getInlineOpacity(element);
  var options = Object.extend({
  from: Element.getOpacity(element) || 1.0,
  to:   0.0,
  afterFinishInternal: function(effect) { with(Element) { 
    if(effect.options.to!=0) return;
    hide(effect.element);
    setStyle(effect.element, {opacity: oldOpacity}); }}
  }, arguments[1] || {});
  return new Effect.Opacity(element,options);
}

Effect.Appear = function(element) {
  var options = Object.extend({
  from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
  to:   1.0,
  beforeSetup: function(effect) { with(Element) {
    setOpacity(effect.element, effect.options.from);
    show(effect.element); }}
  }, arguments[1] || {});
  return new Effect.Opacity(element,options);
}

Effect.Puff = function(element) {
  element = $(element);
  var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') };
  return new Effect.Parallel(
   [ new Effect.Scale(element, 200, 
      { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), 
     new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], 
     Object.extend({ duration: 1.0, 
      beforeSetupInternal: function(effect) { with(Element) {
        setStyle(effect.effects[0].element, {position: 'absolute'}); }},
      afterFinishInternal: function(effect) { with(Element) {
         hide(effect.effects[0].element);
         setStyle(effect.effects[0].element, oldStyle); }}
     }, arguments[1] || {})
   );
}

Effect.BlindUp = function(element) {
  element = $(element);
  Element.makeClipping(element);
  return new Effect.Scale(element, 0, 
    Object.extend({ scaleContent: false, 
      scaleX: false, 
      restoreAfterFinish: true,
      afterFinishInternal: function(effect) { with(Element) {
        [hide, undoClipping].call(effect.element); }} 
    }, arguments[1] || {})
  );
}

Effect.BlindDown = function(element) {
  element = $(element);
  var oldHeight = Element.getStyle(element, 'height');
  var elementDimensions = Element.getDimensions(element);
  return new Effect.Scale(element, 100, 
    Object.extend({ scaleContent: false, 
      scaleX: false,
      scaleFrom: 0,
      scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
      restoreAfterFinish: true,
      afterSetup: function(effect) { with(Element) {
        makeClipping(effect.element);
        setStyle(effect.element, {height: '0px'});
        show(effect.element); 
      }},  
      afterFinishInternal: function(effect) { with(Element) {
        undoClipping(effect.element);
        setStyle(effect.element, {height: oldHeight});
      }}
    }, arguments[1] || {})
  );
}

Effect.SwitchOff = function(element) {
  element = $(element);
  var oldOpacity = Element.getInlineOpacity(element);
  return new Effect.Appear(element, { 
    duration: 0.4,
    from: 0,
    transition: Effect.Transitions.flicker,
    afterFinishInternal: function(effect) {
      new Effect.Scale(effect.element, 1, { 
        duration: 0.3, scaleFromCenter: true,
        scaleX: false, scaleContent: false, restoreAfterFinish: true,
        beforeSetup: function(effect) { with(Element) {
          [makePositioned,makeClipping].call(effect.element);
        }},
        afterFinishInternal: function(effect) { with(Element) {
          [hide,undoClipping,undoPositioned].call(effect.element);
          setStyle(effect.element, {opacity: oldOpacity});
        }}
      })
    }
  });
}

Effect.DropOut = function(element) {
  element = $(element);
  var oldStyle = {
    top: Element.getStyle(element, 'top'),
    left: Element.getStyle(element, 'left'),
    opacity: Element.getInlineOpacity(element) };
  return new Effect.Parallel(
    [ new Effect.Move(element, {x: 0, y: 100, sync: true }), 
      new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
    Object.extend(
      { duration: 0.5,
        beforeSetup: function(effect) { with(Element) {
          makePositioned(effect.effects[0].element); }},
        afterFinishInternal: function(effect) { with(Element) {
          [hide, undoPositioned].call(effect.effects[0].element);
          setStyle(effect.effects[0].element, oldStyle); }} 
      }, arguments[1] || {}));
}

Effect.Shake = function(element) {
  element = $(element);
  var oldStyle = {
    top: Element.getStyle(element, 'top'),
    left: Element.getStyle(element, 'left') };
	  return new Effect.Move(element, 
	    { x:  20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
	  new Effect.Move(effect.element,
	    { x: -40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
	  new Effect.Move(effect.element,
	    { x:  40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
	  new Effect.Move(effect.element,
	    { x: -40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
	  new Effect.Move(effect.element,
	    { x:  40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
	  new Effect.Move(effect.element,
	    { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { with(Element) {
        undoPositioned(effect.element);
        setStyle(effect.element, oldStyle);
  }}}) }}) }}) }}) }}) }});
}

Effect.SlideDown = function(element) {
  element = $(element);
  Element.cleanWhitespace(element);
  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
  var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
  var elementDimensions = Element.getDimensions(element);
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false, 
    scaleFrom: 0,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: true,
    afterSetup: function(effect) { with(Element) {
      makePositioned(effect.element);
      makePositioned(effect.element.firstChild);
      if(window.opera) setStyle(effect.element, {top: ''});
      makeClipping(effect.element);
      setStyle(effect.element, {height: '0px'});
      show(element); }},
    afterUpdateInternal: function(effect) { with(Element) {
      setStyle(effect.element.firstChild, {bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
    afterFinishInternal: function(effect) { with(Element) {
      undoClipping(effect.element); 
      undoPositioned(effect.element.firstChild);
      undoPositioned(effect.element);
      setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
    }, arguments[1] || {})
  );
}
  
Effect.SlideUp = function(element) {
  element = $(element);
  Element.cleanWhitespace(element);
  var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
  return new Effect.Scale(element, 0, 
   Object.extend({ scaleContent: false, 
    scaleX: false, 
    scaleMode: 'box',
    scaleFrom: 100,
    restoreAfterFinish: true,
    beforeStartInternal: function(effect) { with(Element) {
      makePositioned(effect.element);
      makePositioned(effect.element.firstChild);
      if(window.opera) setStyle(effect.element, {top: ''});
      makeClipping(effect.element);
      show(element); }},  
    afterUpdateInternal: function(effect) { with(Element) {
      setStyle(effect.element.firstChild, {bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
    afterFinishInternal: function(effect) { with(Element) {
        [hide, undoClipping].call(effect.element); 
        undoPositioned(effect.element.firstChild);
        undoPositioned(effect.element);
        setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
   }, arguments[1] || {})
  );
}

// Bug in opera makes the TD containing this element expand for a instance after finish 
Effect.Squish = function(element) {
  return new Effect.Scale(element, window.opera ? 1 : 0, 
    { restoreAfterFinish: true,
      beforeSetup: function(effect) { with(Element) {
        makeClipping(effect.element); }},  
      afterFinishInternal: function(effect) { with(Element) {
        hide(effect.element); 
        undoClipping(effect.element); }}
  });
}

Effect.Grow = function(element) {
  element = $(element);
  var options = Object.extend({
    direction: 'center',
    moveTransistion: Effect.Transitions.sinoidal,
    scaleTransition: Effect.Transitions.sinoidal,
    opacityTransition: Effect.Transitions.full
  }, arguments[1] || {});
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    height: element.style.height,
    width: element.style.width,
    opacity: Element.getInlineOpacity(element) };

  var dims = Element.getDimensions(element);    
  var initialMoveX, initialMoveY;
  var moveX, moveY;
  
  switch (options.direction) {
    case 'top-left':
      initialMoveX = initialMoveY = moveX = moveY = 0; 
      break;
    case 'top-right':
      initialMoveX = dims.width;
      initialMoveY = moveY = 0;
      moveX = -dims.width;
      break;
    case 'bottom-left':
      initialMoveX = moveX = 0;
      initialMoveY = dims.height;
      moveY = -dims.height;
      break;
    case 'bottom-right':
      initialMoveX = dims.width;
      initialMoveY = dims.height;
      moveX = -dims.width;
      moveY = -dims.height;
      break;
    case 'center':
      initialMoveX = dims.width / 2;
      initialMoveY = dims.height / 2;
      moveX = -dims.width / 2;
      moveY = -dims.height / 2;
      break;
  }
  
  return new Effect.Move(element, {
    x: initialMoveX,
    y: initialMoveY,
    duration: 0.01, 
    beforeSetup: function(effect) { with(Element) {
      hide(effect.element);
      makeClipping(effect.element);
      makePositioned(effect.element);
    }},
    afterFinishInternal: function(effect) {
      new Effect.Parallel(
        [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
          new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
          new Effect.Scale(effect.element, 100, {
            scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, 
            sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
        ], Object.extend({
             beforeSetup: function(effect) { with(Element) {
               setStyle(effect.effects[0].element, {height: '0px'});
               show(effect.effects[0].element); }},
             afterFinishInternal: function(effect) { with(Element) {
               [undoClipping, undoPositioned].call(effect.effects[0].element); 
               setStyle(effect.effects[0].element, oldStyle); }}
           }, options)
      )
    }
  });
}

Effect.Shrink = function(element) {
  element = $(element);
  var options = Object.extend({
    direction: 'center',
    moveTransistion: Effect.Transitions.sinoidal,
    scaleTransition: Effect.Transitions.sinoidal,
    opacityTransition: Effect.Transitions.none
  }, arguments[1] || {});
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    height: element.style.height,
    width: element.style.width,
    opacity: Element.getInlineOpacity(element) };

  var dims = Element.getDimensions(element);
  var moveX, moveY;
  
  switch (options.direction) {
    case 'top-left':
      moveX = moveY = 0;
      break;
    case 'top-right':
      moveX = dims.width;
      moveY = 0;
      break;
    case 'bottom-left':
      moveX = 0;
      moveY = dims.height;
      break;
    case 'bottom-right':
      moveX = dims.width;
      moveY = dims.height;
      break;
    case 'center':  
      moveX = dims.width / 2;
      moveY = dims.height / 2;
      break;
  }
  
  return new Effect.Parallel(
    [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
      new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
      new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
    ], Object.extend({            
         beforeStartInternal: function(effect) { with(Element) {
           [makePositioned, makeClipping].call(effect.effects[0].element) }},
         afterFinishInternal: function(effect) { with(Element) {
           [hide, undoClipping, undoPositioned].call(effect.effects[0].element);
           setStyle(effect.effects[0].element, oldStyle); }}
       }, options)
  );
}

Effect.Pulsate = function(element) {
  element = $(element);
  var options    = arguments[1] || {};
  var oldOpacity = Element.getInlineOpacity(element);
  var transition = options.transition || Effect.Transitions.sinoidal;
  var reverser   = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
  reverser.bind(transition);
  return new Effect.Opacity(element, 
    Object.extend(Object.extend({  duration: 3.0, from: 0,
      afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); }
    }, options), {transition: reverser}));
}

Effect.Fold = function(element) {
  element = $(element);
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    width: element.style.width,
    height: element.style.height };
  Element.makeClipping(element);
  return new Effect.Scale(element, 5, Object.extend({   
    scaleContent: false,
    scaleX: false,
    afterFinishInternal: function(effect) {
    new Effect.Scale(element, 1, { 
      scaleContent: false, 
      scaleY: false,
      afterFinishInternal: function(effect) { with(Element) {
        [hide, undoClipping].call(effect.element); 
        setStyle(effect.element, oldStyle);
      }} });
  }}, arguments[1] || {}));
}

// -----------------------------------------------------------------------------------
//
//	Lightbox v2.03.3
//	by Lokesh Dhakar - http://www.huddletogether.com
//	5/21/06
//
//	For more information on this script, visit:
//	http://huddletogether.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//	
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), Thomas Fuchs(mir.aculo.us), and others.
//
//
// -----------------------------------------------------------------------------------
/*

	Table of Contents
	-----------------
	Configuration
	Global Variables

	Extending Built-in Objects	
	- Object.extend(Element)
	- Array.prototype.removeDuplicates()
	- Array.prototype.empty()

	Lightbox Class Declaration
	- initialize()
	- updateImageList()
	- start()
	- changeImage()
	- resizeImageContainer()
	- showImage()
	- updateDetails()
	- updateNav()
	- enableKeyboardNav()
	- disableKeyboardNav()
	- keyboardAction()
	- preloadNeighborImages()
	- end()
	
	Miscellaneous Functions
	- getPageScroll()
	- getPageSize()
	- getKey()
	- listenKey()
	- showSelectBoxes()
	- hideSelectBoxes()
	- showFlash()
	- hideFlash()
	- pause()
	- initLightbox()
	
	Function Calls
	- addLoadEvent(initLightbox)
	
*/
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "http://www.carrozzeriaangiari.it/images/lightbox/loading.gif";		
var fileBottomNavCloseImage = "http://www.carrozzeriaangiari.it/images/lightbox/closelabel.gif";

var overlayOpacity = 0.8;	// controls transparency of shadow overlay

var animate = true;			// toggles resizing animations
var resizeSpeed = 7;		// controls the speed of the image resizing animations (1=slowest and 10=fastest)

var borderSize = 10;		//if you adjust the padding in the CSS, you will need to update this variable

// -----------------------------------------------------------------------------------

//
//	Global Variables
//
var imageArray = new Array;
var activeImage;

if(animate == true){
	overlayDuration = 0.2;	// shadow fade in/out duration
	if(resizeSpeed > 10){ resizeSpeed = 10;}
	if(resizeSpeed < 1){ resizeSpeed = 1;}
	resizeDuration = (11 - resizeSpeed) * 0.15;
} else { 
	overlayDuration = 0;
	resizeDuration = 0;
}

// -----------------------------------------------------------------------------------

//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setLeft: function(element,l) {
	   	element = $(element);
    	element.style.left = l +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------

//
//	Extending built-in Array object
//	- array.removeDuplicates()
//	- array.empty()
//
Array.prototype.removeDuplicates = function () {
    for(i = 0; i < this.length; i++){
        for(j = this.length-1; j>i; j--){        
            if(this[i][0] == this[j][0]){
                this.splice(j,1);
            }
        }
    }
}

// -----------------------------------------------------------------------------------

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}

// -----------------------------------------------------------------------------------

//
//	Lightbox Class Declaration
//	- initialize()
//	- start()
//	- changeImage()
//	- resizeImageContainer()
//	- showImage()
//	- updateDetails()
//	- updateNav()
//	- enableKeyboardNav()
//	- disableKeyboardNav()
//	- keyboardNavAction()
//	- preloadNeighborImages()
//	- end()
//
//	Structuring of code inspired by Scott Upton (http://www.uptonic.com/)
//
var Lightbox = Class.create();

Lightbox.prototype = {
	
	// initialize()
	// Constructor runs on completion of the DOM loading. Calls updateImageList and then
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {	
		
		this.updateImageList();

		// Code inserts html at the bottom of the page that looks similar to this:
		//
		//	<div id="overlay"></div>
		//	<div id="lightbox">
		//		<div id="outerImageContainer">
		//			<div id="imageContainer">
		//				<img id="lightboxImage">
		//				<div style="" id="hoverNav">
		//					<a href="#" id="prevLink"></a>
		//					<a href="#" id="nextLink"></a>
		//				</div>
		//				<div id="loading">
		//					<a href="#" id="loadingLink">
		//						<img src="images/loading.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//		<div id="imageDataContainer">
		//			<div id="imageData">
		//				<div id="imageDetails">
		//					<span id="caption"></span>
		//					<span id="numberDisplay"></span>
		//				</div>
		//				<div id="bottomNav">
		//					<a href="#" id="bottomNavClose">
		//						<img src="images/close.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//	</div>


		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objOverlay.onclick = function() { myLightbox.end(); }
		objBody.appendChild(objOverlay);
		
		var objLightbox = document.createElement("div");
		objLightbox.setAttribute('id','lightbox');
		objLightbox.style.display = 'none';
		objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
			if (!e) var e = window.event;
			var clickObj = Event.element(e).id;
			if ( clickObj == 'lightbox') {
				myLightbox.end();
			}
		};
		objBody.appendChild(objLightbox);
			
		var objOuterImageContainer = document.createElement("div");
		objOuterImageContainer.setAttribute('id','outerImageContainer');
		objLightbox.appendChild(objOuterImageContainer);

		// When Lightbox starts it will resize itself from 250 by 250 to the current image dimension.
		// If animations are turned off, it will be hidden as to prevent a flicker of a
		// white 250 by 250 box.
		if(animate){
			Element.setWidth('outerImageContainer', 250);
			Element.setHeight('outerImageContainer', 250);			
		} else {
			Element.setWidth('outerImageContainer', 1);
			Element.setHeight('outerImageContainer', 1);			
		}

		var objImageContainer = document.createElement("div");
		objImageContainer.setAttribute('id','imageContainer');
		objOuterImageContainer.appendChild(objImageContainer);
	
		var objLightboxImage = document.createElement("img");
		objLightboxImage.setAttribute('id','lightboxImage');
		objImageContainer.appendChild(objLightboxImage);
	
		var objHoverNav = document.createElement("div");
		objHoverNav.setAttribute('id','hoverNav');
		objImageContainer.appendChild(objHoverNav);
	
		var objPrevLink = document.createElement("a");
		objPrevLink.setAttribute('id','prevLink');
		objPrevLink.setAttribute('href','#');
		objHoverNav.appendChild(objPrevLink);
		
		var objNextLink = document.createElement("a");
		objNextLink.setAttribute('id','nextLink');
		objNextLink.setAttribute('href','#');
		objHoverNav.appendChild(objNextLink);
	
		var objLoading = document.createElement("div");
		objLoading.setAttribute('id','loading');
		objImageContainer.appendChild(objLoading);
	
		var objLoadingLink = document.createElement("a");
		objLoadingLink.setAttribute('id','loadingLink');
		objLoadingLink.setAttribute('href','#');
		objLoadingLink.onclick = function() { myLightbox.end(); return false; }
		objLoading.appendChild(objLoadingLink);
	
		var objLoadingImage = document.createElement("img");
		objLoadingImage.setAttribute('src', fileLoadingImage);
		objLoadingLink.appendChild(objLoadingImage);

		var objImageDataContainer = document.createElement("div");
		objImageDataContainer.setAttribute('id','imageDataContainer');
		objLightbox.appendChild(objImageDataContainer);

		var objImageData = document.createElement("div");
		objImageData.setAttribute('id','imageData');
		objImageDataContainer.appendChild(objImageData);
	
		var objImageDetails = document.createElement("div");
		objImageDetails.setAttribute('id','imageDetails');
		objImageData.appendChild(objImageDetails);
	
		var objCaption = document.createElement("span");
		objCaption.setAttribute('id','caption');
		objImageDetails.appendChild(objCaption);
	
		var objNumberDisplay = document.createElement("span");
		objNumberDisplay.setAttribute('id','numberDisplay');
		objImageDetails.appendChild(objNumberDisplay);
		
		var objBottomNav = document.createElement("div");
		objBottomNav.setAttribute('id','bottomNav');
		objImageData.appendChild(objBottomNav);
	
		var objBottomNavCloseLink = document.createElement("a");
		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
		objBottomNavCloseLink.setAttribute('href','#');
		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
		objBottomNav.appendChild(objBottomNavCloseLink);
	
		var objBottomNavCloseImage = document.createElement("img");
		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
	},


	//
	// updateImageList()
	// Loops through anchor tags looking for 'lightbox' references and applies onclick
	// events to appropriate links. You can rerun after dynamically adding images w/ajax.
	//
	updateImageList: function() {	
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');
		var areas = document.getElementsByTagName('area');

		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			
			var relAttribute = String(anchor.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				anchor.onclick = function () {myLightbox.start(this); return false;}
			}
		}

		// loop through all area tags
		// todo: combine anchor & area tag loops
		for (var i=0; i< areas.length; i++){
			var area = areas[i];
			
			var relAttribute = String(area.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				area.onclick = function () {myLightbox.start(this); return false;}
			}
		}
	},
	
	
	//
	//	start()
	//	Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
	//
	start: function(imageLink) {	

		hideSelectBoxes();
		hideFlash();

		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[0]);
		Element.setHeight('overlay', arrayPageSize[1]);

		new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });

		imageArray = [];
		imageNum = 0;		

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName( imageLink.tagName);

		// if image is NOT part of a set..
		if((imageLink.getAttribute('rel') == 'lightbox')){
			// add single image to imageArray
			imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));			
		} else {
		// if image is part of a set..

			// loop through anchors, find other images in set, and add them to imageArray
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
					imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
				}
			}
			imageArray.removeDuplicates();
			while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
		}

		// calculate top and left offset for the lightbox 
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxLeft = arrayPageScroll[0];
		Element.setTop('lightbox', lightboxTop);
		Element.setLeft('lightbox', lightboxLeft);
		
		Element.show('lightbox');
		
		this.changeImage(imageNum);
	},

	//
	//	changeImage()
	//	Hide most elements and preload image in preparation for resizing image container.
	//
	changeImage: function(imageNum) {	
		
		activeImage = imageNum;	// update global var

		// hide elements during transition
		if(animate){ Element.show('loading');}
		Element.hide('lightboxImage');
		Element.hide('hoverNav');
		Element.hide('prevLink');
		Element.hide('nextLink');
		Element.hide('imageDataContainer');
		Element.hide('numberDisplay');		
		
		imgPreloader = new Image();
		
		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
			Element.setSrc('lightboxImage', imageArray[activeImage][0]);
			myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
			
			imgPreloader.onload=function(){};	//	clear onLoad, IE behaves irratically with animated gifs otherwise 
		}
		imgPreloader.src = imageArray[activeImage][0];
	},

	//
	//	resizeImageContainer()
	//
	resizeImageContainer: function( imgWidth, imgHeight) {

		// get curren width and height
		this.widthCurrent = Element.getWidth('outerImageContainer');
		this.heightCurrent = Element.getHeight('outerImageContainer');

		// get new width and height
		var widthNew = (imgWidth  + (borderSize * 2));
		var heightNew = (imgHeight  + (borderSize * 2));

		// scalars based on change from old to new
		this.xScale = ( widthNew / this.widthCurrent) * 100;
		this.yScale = ( heightNew / this.heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = this.widthCurrent - widthNew;
		hDiff = this.heightCurrent - heightNew;

		if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
		if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }

		// if new and old image are same size and no scaling transition is necessary, 
		// do a quick pause to prevent image flicker.
		if((hDiff == 0) && (wDiff == 0)){
			if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} 
		}

		Element.setHeight('prevLink', imgHeight);
		Element.setHeight('nextLink', imgHeight);
		Element.setWidth( 'imageDataContainer', widthNew);

		this.showImage();
	},
	
	//
	//	showImage()
	//	Display image and begin preloading neighbors.
	//
	showImage: function(){
		Element.hide('loading');
		new Effect.Appear('lightboxImage', { duration: resizeDuration, queue: 'end', afterFinish: function(){	myLightbox.updateDetails(); } });
		this.preloadNeighborImages();
	},

	//
	//	updateDetails()
	//	Display caption, image number, and bottom nav.
	//
	updateDetails: function() {
	
		// if caption is not null
		if(imageArray[activeImage][1]){
			Element.show('caption');
			Element.setInnerHTML( 'caption', imageArray[activeImage][1]);
		}
		
		// if image is part of set display 'Image x of x' 
		if(imageArray.length > 1){
			Element.show('numberDisplay');
			Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length);
		}

		new Effect.Parallel(
			[ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
			  new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], 
			{ duration: resizeDuration, afterFinish: function() {
				// update overlay size and update nav
				var arrayPageSize = getPageSize();
				Element.setHeight('overlay', arrayPageSize[1]);
				myLightbox.updateNav();
				}
			} 
		);
	},

	//
	//	updateNav()
	//	Display appropriate previous and next hover navigation.
	//
	updateNav: function() {

		Element.show('hoverNav');				

		// if not first image in set, display prev image button
		if(activeImage != 0){
			Element.show('prevLink');
			document.getElementById('prevLink').onclick = function() {
				myLightbox.changeImage(activeImage - 1); return false;
			}
		}

		// if not last image in set, display next image button
		if(activeImage != (imageArray.length - 1)){
			Element.show('nextLink');
			document.getElementById('nextLink').onclick = function() {
				myLightbox.changeImage(activeImage + 1); return false;
			}
		}
		
		this.enableKeyboardNav();
	},

	//
	//	enableKeyboardNav()
	//
	enableKeyboardNav: function() {
		document.onkeydown = this.keyboardAction; 
	},

	//
	//	disableKeyboardNav()
	//
	disableKeyboardNav: function() {
		document.onkeydown = '';
	},

	//
	//	keyboardAction()
	//
	keyboardAction: function(e) {
		if (e == null) { // ie
			keycode = event.keyCode;
			escapeKey = 27;
		} else { // mozilla
			keycode = e.keyCode;
			escapeKey = e.DOM_VK_ESCAPE;
		}

		key = String.fromCharCode(keycode).toLowerCase();
		
		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){	// close lightbox
			myLightbox.end();
		} else if((key == 'p') || (keycode == 37)){	// display previous image
			if(activeImage != 0){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage - 1);
			}
		} else if((key == 'n') || (keycode == 39)){	// display next image
			if(activeImage != (imageArray.length - 1)){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage + 1);
			}
		}

	},

	//
	//	preloadNeighborImages()
	//	Preload previous and next images.
	//
	preloadNeighborImages: function(){

		if((imageArray.length - 1) > activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = imageArray[activeImage + 1][0];
		}
		if(activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = imageArray[activeImage - 1][0];
		}
	
	},

	//
	//	end()
	//
	end: function() {
		this.disableKeyboardNav();
		Element.hide('lightbox');
		new Effect.Fade('overlay', { duration: overlayDuration});
		showSelectBoxes();
		showFlash();
	}
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){
	}
}

// -----------------------------------------------------------------------------------

//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }
	
// ---------------------------------------------------

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

// ---------------------------------------------------

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}


// ---------------------------------------------------

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Help from Ran Bar-On [ran2103@gmail.com]
//

function pause(ms){
	var date = new Date();
	curDate = null;
	do{var curDate = new Date();}
	while( curDate - date < ms);
}
/*
function pause(numberMillis) {
	var curently = new Date().getTime() + sender;
	while (new Date().getTime();	
}
*/
// ---------------------------------------------------



function initLightbox() { myLightbox = new Lightbox(); }
Event.observe(window, 'load', initLightbox, false);
function popupc(URL,w,h,scrolls){var scrolls=scrolls?'yes':'no';var l = Math.floor((screen.width-w)/2);var t = Math.floor((screen.height-h)/2);window.open(URL,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l+ 'toolbar=0,scrollbars='+scrolls+',location=no,statusbar=no,menubar=no,resizable=no');}
