var Prototype={Version:"1.5.0",BrowserFeatures:{XPath:!!document.evaluate},ScriptFragment:"(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)",emptyFunction:function(){},K:function(a){return a}};var Class={create:function(){return function(){this.initialize.apply(this,arguments)}}};var Abstract=new Object();Object.extend=function(c,b){for(var a in b){c[a]=b[a]}return c};Object.extend(Object,{inspect:function(a){try{if(a===undefined){return"undefined"}if(a===null){return"null"}return a.inspect?a.inspect():a.toString()}catch(b){if(b instanceof RangeError){return"..."}throw b}},keys:function(b){var c=[];for(var a in b){c.push(a)}return c},values:function(b){var c=[];for(var a in b){c.push(b[a])}return c},clone:function(a){return Object.extend({},a)}});Function.prototype.bind=function(){var c=this,a=$A(arguments),b=a.shift();return function(){return c.apply(b,a.concat($A(arguments)))}};Function.prototype.bindAsEventListener=function(b){var c=this,a=$A(arguments),b=a.shift();return function(d){return c.apply(b,[(d||window.event)].concat(a).concat($A(arguments)))}};Object.extend(Number.prototype,{toColorPart:function(){var a=this.toString(16);if(this<16){return"0"+a}return a},succ:function(){return this+1},times:function(a){$R(0,this,true).each(a);return this}});var Try={these:function(){var b;for(var c=0,a=arguments.length;c<a;c++){var d=arguments[c];try{b=d();break}catch(f){}}return b}};var PeriodicalExecuter=Class.create();PeriodicalExecuter.prototype={initialize:function(a,b){this.callback=a;this.frequency=b;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(a){return a==null?"":String(a)};Object.extend(String.prototype,{gsub:function(b,d){var e="",a=this,c;d=arguments.callee.prepareReplacement(d);while(a.length>0){if(c=a.match(b)){e+=a.slice(0,c.index);e+=String.interpret(d(c));a=a.slice(c.index+c[0].length)}else{e+=a,a=""}}return e},sub:function(a,b,c){b=this.gsub.prepareReplacement(b);c=c===undefined?1:c;return this.gsub(a,function(d){if(--c<0){return d[0]}return b(d)})},scan:function(a,b){this.gsub(a,b);return this},truncate:function(a,b){a=a||30;b=b===undefined?"...":b;return this.length>a?this.slice(0,a-b.length)+b: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 b=new RegExp(Prototype.ScriptFragment,"img");var a=new RegExp(Prototype.ScriptFragment,"im");return(this.match(b)||[]).map(function(c){return(c.match(a)||["",""])[1]})},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script)})},escapeHTML:function(){var b=document.createElement("div");var a=document.createTextNode(this);b.appendChild(a);return b.innerHTML},unescapeHTML:function(){var a=document.createElement("div");a.innerHTML=this.stripTags();return a.childNodes[0]?(a.childNodes.length>1?$A(a.childNodes).inject("",function(b,c){return b+c.nodeValue}):a.childNodes[0].nodeValue):""},toQueryParams:function(b){var a=this.strip().match(/([^?#]*)(#.*)?$/);if(!a){return{}}return a[1].split(b||"&").inject({},function(e,f){if((f=f.split("="))[0]){var c=decodeURIComponent(f[0]);var d=f[1]?decodeURIComponent(f[1]):undefined;if(e[c]!==undefined){if(e[c].constructor!=Array){e[c]=[e[c]]}if(d){e[c].push(d)}}else{e[c]=d}}return e})},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 d=this.split("-"),a=d.length;if(a==1){return d[0]}var b=this.charAt(0)=="-"?d[0].charAt(0).toUpperCase()+d[0].substring(1):d[0];for(var c=1;c<a;c++){b+=d[c].charAt(0).toUpperCase()+d[c].substring(1)}return b},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(b){var a=this.replace(/\\/g,"\\\\");if(b){return'"'+a.replace(/"/g,'\\"')+'"'}else{return"'"+a.replace(/'/g,"\\'")+"'"}}});String.prototype.gsub.prepareReplacement=function(b){if(typeof b=="function"){return b}var a=new Template(b);return function(c){return a.evaluate(c)}};String.prototype.parseQuery=String.prototype.toQueryParams;var Template=Class.create();Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;Template.prototype={initialize:function(b,a){this.template=b.toString();this.pattern=a||Template.Pattern},evaluate:function(a){return this.template.gsub(this.pattern,function(c){var b=c[1];if(b=="\\"){return c[2]}return b+String.interpret(a[c[3]])})}};var $break=new Object();var $continue=new Object();var Enumerable={each:function(b){var a=0;try{this._each(function(d){try{b(d,a++)}catch(f){if(f!=$continue){throw f}}})}catch(c){if(c!=$break){throw c}}return this},eachSlice:function(a,c){var b=-a,d=[],e=this.toArray();while((b+=a)<e.length){d.push(e.slice(b,b+a))}return d.map(c)},all:function(a){var b=true;this.each(function(d,c){b=b&&!!(a||Prototype.K)(d,c);if(!b){throw $break}});return b},any:function(a){var b=false;this.each(function(d,c){if(b=!!(a||Prototype.K)(d,c)){throw $break}});return b},collect:function(b){var a=[];this.each(function(d,c){a.push((b||Prototype.K)(d,c))});return a},detect:function(a){var b;this.each(function(d,c){if(a(d,c)){b=d;throw $break}});return b},findAll:function(b){var a=[];this.each(function(d,c){if(b(d,c)){a.push(d)}});return a},grep:function(a,c){var b=[];this.each(function(f,d){var e=f.toString();if(e.match(a)){b.push((c||Prototype.K)(f,d))}});return b},include:function(a){var b=false;this.each(function(c){if(c==a){b=true;throw $break}});return b},inGroupsOf:function(a,b){b=b===undefined?null:b;return this.eachSlice(a,function(c){while(c.length<a){c.push(b)}return c})},inject:function(a,b){this.each(function(d,c){a=b(a,d,c)});return a},invoke:function(b){var a=$A(arguments).slice(1);return this.map(function(c){return c[b].apply(c,a)})},max:function(a){var b;this.each(function(d,c){d=(a||Prototype.K)(d,c);if(b==undefined||d>=b){b=d}});return b},min:function(a){var b;this.each(function(d,c){d=(a||Prototype.K)(d,c);if(b==undefined||d<b){b=d}});return b},partition:function(c){var b=[],a=[];this.each(function(e,d){((c||Prototype.K)(e,d)?b:a).push(e)});return[b,a]},pluck:function(a){var b=[];this.each(function(d,c){b.push(d[a])});return b},reject:function(b){var a=[];this.each(function(d,c){if(!b(d,c)){a.push(d)}});return a},sortBy:function(a){return this.map(function(c,b){return{value:c,criteria:a(c,b)}}).sort(function(f,e){var d=f.criteria,c=e.criteria;return d<c?-1:d>c?1:0}).pluck("value")},toArray:function(){return this.map()},zip:function(){var b=Prototype.K,a=$A(arguments);if(typeof a.last()=="function"){b=a.pop()}var c=[this].concat(a).map($A);return this.map(function(e,d){return b(c.pluck(d))})},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(d){if(!d){return[]}if(d.toArray){return d.toArray()}else{var c=[];for(var b=0,a=d.length;b<a;b++){c.push(d[b])}return c}};Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse}Object.extend(Array.prototype,{_each:function(c){for(var b=0,a=this.length;b<a;b++){c(this[b])}},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(a){return a!=null})},flatten:function(){return this.inject([],function(b,a){return b.concat(a&&a.constructor==Array?a.flatten():[a])})},without:function(){var a=$A(arguments);return this.select(function(b){return !a.include(b)})},indexOf:function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1},reverse:function(a){return(a!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(){return this.inject([],function(b,a){return b.include(a)?b:b.concat([a])})},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(a){a=a.strip();return a?a.split(/\s+/):[]}if(window.opera){Array.prototype.concat=function(){var e=[];for(var c=0,a=this.length;c<a;c++){e.push(this[c])}for(var c=0,a=arguments.length;c<a;c++){if(arguments[c].constructor==Array){for(var b=0,d=arguments[c].length;b<d;b++){e.push(arguments[c][b])}}else{e.push(arguments[c])}}return e}}var Hash=function(a){Object.extend(this,a||{})};Object.extend(Hash,{toQueryString:function(b){var a=[];this.prototype._each.call(b,function(d){if(!d.key){return}if(d.value&&d.value.constructor==Array){var c=d.value.compact();if(c.length<2){d.value=c.reduce()}else{key=encodeURIComponent(d.key);c.each(function(e){e=e!=undefined?encodeURIComponent(e):"";a.push(key+"="+encodeURIComponent(e))});return}}if(d.value==undefined){d[1]=""}a.push(d.map(encodeURIComponent).join("="))});return a.join("&")}});Object.extend(Hash.prototype,Enumerable);Object.extend(Hash.prototype,{_each:function(b){for(var a in this){var c=this[a];if(c&&c==Hash.prototype[a]){continue}var d=[a,c];d.key=a;d.value=c;b(d)}},keys:function(){return this.pluck("key")},values:function(){return this.pluck("value")},merge:function(a){return $H(a).inject(this,function(b,c){b[c.key]=c.value;return b})},remove:function(){var d;for(var b=0,a=arguments.length;b<a;b++){var c=this[arguments[b]];if(c!==undefined){if(d===undefined){d=c}else{if(d.constructor!=Array){d=[d]}d.push(c)}}delete this[arguments[b]]}return d},toQueryString:function(){return Hash.toQueryString(this)},inspect:function(){return"#<Hash:{"+this.map(function(a){return a.map(Object.inspect).join(": ")}).join(", ")+"}>"}});function $H(a){if(a&&a.constructor==Hash){return a}return new Hash(a)}ObjectRange=Class.create();Object.extend(ObjectRange.prototype,Enumerable);Object.extend(ObjectRange.prototype,{initialize:function(c,a,b){this.start=c;this.end=a;this.exclusive=b},_each:function(a){var b=this.start;while(this.include(b)){a(b);b=b.succ()}},include:function(a){if(a<this.start){return false}if(this.exclusive){return a<this.end}return a<=this.end}});var $R=function(c,a,b){return new ObjectRange(c,a,b)};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(a){this.responders._each(a)},register:function(a){if(!this.include(a)){this.responders.push(a)}},unregister:function(a){this.responders=this.responders.without(a)},dispatch:function(c,b,d,a){this.each(function(f){if(typeof f[c]=="function"){try{f[c].apply(f,[b,d,a])}catch(g){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=function(){};Ajax.Base.prototype={setOptions:function(a){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:""};Object.extend(this.options,a||{});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(a,b){this.transport=Ajax.getTransport();this.setOptions(b);this.request(a)},request:function(b){this.url=b;this.method=this.options.method;var d=this.options.parameters;if(!["get","post"].include(this.method)){d._method=this.method;this.method="post"}d=Hash.toQueryString(d);if(d&&/Konqueror|Safari|KHTML/.test(navigator.userAgent)){d+="&_="}if(this.method=="get"&&d){this.url+=(this.url.indexOf("?")>-1?"&":"?")+d}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 a=this.method=="post"?(this.options.postBody||d):null;this.transport.send(a);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}}catch(c){this.dispatchException(c)}},onStateChange:function(){var a=this.transport.readyState;if(a>1&&!((a==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var e={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){e["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){e.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var b=this.options.requestHeaders;if(typeof b.push=="function"){for(var d=0,a=b.length;d<a;d+=2){e[b[d]]=b[d+1]}}else{$H(b).each(function(f){e[f.key]=f.value})}}for(var c in e){this.transport.setRequestHeader(c,e[c])}},success:function(){return !this.transport.status||(this.transport.status>=200&&this.transport.status<300)},respondToReadyState:function(a){var c=Ajax.Request.Events[a];var f=this.transport,b=this.evalJSON();if(c=="Complete"){try{this._complete=true;(this.options["on"+this.transport.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(f,b)}catch(d){this.dispatchException(d)}if((this.getHeader("Content-type")||"text/javascript").strip().match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)){this.evalResponse()}}try{(this.options["on"+c]||Prototype.emptyFunction)(f,b);Ajax.Responders.dispatch("on"+c,this,f,b)}catch(d){this.dispatchException(d)}if(c=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction}},getHeader:function(a){try{return this.transport.getResponseHeader(a)}catch(b){return null}},evalJSON:function(){try{var json=this.getHeader("X-JSON");return json?eval("("+json+")"):null}catch(e){return null}},evalResponse:function(){try{return eval(this.transport.responseText)}catch(e){this.dispatchException(e)}},dispatchException:function(a){(this.options.onException||Prototype.emptyFunction)(this,a);Ajax.Responders.dispatch("onException",this,a)}});Ajax.Updater=Class.create();Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(c,a,b){this.container={success:(c.success||c),failure:(c.failure||(c.success?null:c))};this.transport=Ajax.getTransport();this.setOptions(b);var d=this.options.onComplete||Prototype.emptyFunction;this.options.onComplete=(function(f,e){this.updateContent();d(f,e)}).bind(this);this.request(a)},updateContent:function(){var a=this.container[this.success()?"success":"failure"];var b=this.transport.responseText;if(!this.options.evalScripts){b=b.stripScripts()}if(a=$(a)){if(this.options.insertion){new this.options.insertion(a,b)}else{a.update(b)}}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(c,a,b){this.setOptions(b);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=c;this.url=a;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(a){if(this.options.decay){this.decay=(a.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=a.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 $(c){if(arguments.length>1){for(var d=0,a=[],b=arguments.length;d<b;d++){a.push($(arguments[d]))}return a}if(typeof c=="string"){c=document.getElementById(c)}return Element.extend(c)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(f,d){var c=[];var e=document.evaluate(f,$(d)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var b=0,a=e.snapshotLength;b<a;b++){c.push(e.snapshotItem(b))}return c}}document.getElementsByClassName=function(c,f){if(Prototype.BrowserFeatures.XPath){var g=".//*[contains(concat(' ', @class, ' '), ' "+c+" ')]";return document._getElementsByXPath(g,f)}else{var e=($(f)||document.body).getElementsByTagName("*");var a=[],h;for(var d=0,b=e.length;d<b;d++){h=e[d];if(Element.hasClassName(h,c)){a.push(Element.extend(h))}}return a}};if(!window.Element){var Element=new Object()}Element.extend=function(d){if(!d||_nativeExtensions||d.nodeType==3){return d}if(!d._extended&&d.tagName&&d!=window){var c=Object.clone(Element.Methods),b=Element.extend.cache;if(d.tagName=="FORM"){Object.extend(c,Form.Methods)}if(["INPUT","TEXTAREA","SELECT"].include(d.tagName)){Object.extend(c,Form.Element.Methods)}Object.extend(c,Element.Methods.Simulated);for(var a in c){var e=c[a];if(typeof e=="function"&&!(a in d)){d[a]=b.findOrStore(e)}}}d._extended=true;return d};Element.extend.cache={findOrStore:function(a){return this[a]=this[a]||function(){return a.apply(null,[this].concat($A(arguments)))}}};Element.Methods={visible:function(a){return $(a).style.display!="none"},toggle:function(a){a=$(a);Element[Element.visible(a)?"hide":"show"](a);return a},hide:function(a){$(a).style.display="none";return a},show:function(a){$(a).style.display="";return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},update:function(a,b){b=typeof b=="undefined"?"":b.toString();$(a).innerHTML=b.stripScripts();setTimeout(function(){b.evalScripts()},10);return a},replace:function(b,c){b=$(b);c=typeof c=="undefined"?"":c.toString();if(b.outerHTML){b.outerHTML=c.stripScripts()}else{var a=b.ownerDocument.createRange();a.selectNodeContents(b);b.parentNode.replaceChild(a.createContextualFragment(c.stripScripts()),b)}setTimeout(function(){c.evalScripts()},10);return b},inspect:function(a){a=$(a);var b="<"+a.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(f){var c=f.first(),d=f.last();var e=(a[c]||"").toString();if(e){b+=" "+d+"="+e.inspect(true)}});return b+">"},recursivelyCollect:function(c,b){c=$(c);var a=[];while(c=c[b]){if(c.nodeType==1){a.push(Element.extend(c))}}return a},ancestors:function(a){return $(a).recursivelyCollect("parentNode")},descendants:function(a){return $A($(a).getElementsByTagName("*"))},immediateDescendants:function(a){if(!(a=$(a).firstChild)){return[]}while(a&&a.nodeType!=1){a=a.nextSibling}if(a){return[a].concat($(a).nextSiblings())}return[]},previousSiblings:function(a){return $(a).recursivelyCollect("previousSibling")},nextSiblings:function(a){return $(a).recursivelyCollect("nextSibling")},siblings:function(a){a=$(a);return a.previousSiblings().reverse().concat(a.nextSiblings())},match:function(b,a){if(typeof a=="string"){a=new Selector(a)}return a.match($(b))},up:function(b,c,a){return Selector.findElement($(b).ancestors(),c,a)},down:function(b,c,a){return Selector.findElement($(b).descendants(),c,a)},previous:function(b,c,a){return Selector.findElement($(b).previousSiblings(),c,a)},next:function(b,c,a){return Selector.findElement($(b).nextSiblings(),c,a)},getElementsBySelector:function(){var b=$A(arguments),a=$(b.shift());return Selector.findChildElements(a,b)},getElementsByClassName:function(b,a){return document.getElementsByClassName(a,b)},readAttribute:function(b,a){b=$(b);if(document.all&&!window.opera){var c=Element._attributeTranslations;if(c.values[a]){return c.values[a](b,a)}if(c.names[a]){a=c.names[a]}var d=b.attributes[a];if(d){return d.nodeValue}}return b.getAttribute(a)},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(b,a){if(!(b=$(b))){return}var c=b.className;if(c.length==0){return false}if(c==a||c.match(new RegExp("(^|\\s)"+a+"(\\s|$)"))){return true}return false},addClassName:function(b,a){if(!(b=$(b))){return}Element.classNames(b).add(a);return b},removeClassName:function(b,a){if(!(b=$(b))){return}Element.classNames(b).remove(a);return b},toggleClassName:function(b,a){if(!(b=$(b))){return}Element.classNames(b)[b.hasClassName(a)?"remove":"add"](a);return b},observe:function(){Event.observe.apply(Event,arguments);return $A(arguments).first()},stopObserving:function(){Event.stopObserving.apply(Event,arguments);return $A(arguments).first()},cleanWhitespace:function(b){b=$(b);var c=b.firstChild;while(c){var a=c.nextSibling;if(c.nodeType==3&&!/\S/.test(c.nodeValue)){b.removeChild(c)}c=a}return b},empty:function(a){return $(a).innerHTML.match(/^\s*$/)},descendantOf:function(b,a){b=$(b),a=$(a);while(b=b.parentNode){if(b==a){return true}}return false},scrollTo:function(a){a=$(a);var b=Position.cumulativeOffset(a);window.scrollTo(b[0],b[1]);return a},getStyle:function(a,c){a=$(a);if(["float","cssFloat"].include(c)){c=(typeof a.style.styleFloat!="undefined"?"styleFloat":"cssFloat")}c=c.camelize();var d=a.style[c];if(!d){if(document.defaultView&&document.defaultView.getComputedStyle){var b=document.defaultView.getComputedStyle(a,null);d=b?b[c]:null}else{if(a.currentStyle){d=a.currentStyle[c]}}}if((d=="auto")&&["width","height"].include(c)&&(a.getStyle("display")!="none")){d=a["offset"+c.capitalize()]+"px"}if(window.opera&&["left","top","right","bottom"].include(c)){if(Element.getStyle(a,"position")=="static"){d="auto"}}if(c=="opacity"){if(d){return parseFloat(d)}if(d=(a.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(d[1]){return parseFloat(d[1])/100}}return 1}return d=="auto"?null:d},setStyle:function(b,c){b=$(b);for(var a in c){var d=c[a];if(a=="opacity"){if(d==1){d=(/Gecko/.test(navigator.userAgent)&&!/Konqueror|Safari|KHTML/.test(navigator.userAgent))?0.999999:1;if(/MSIE/.test(navigator.userAgent)&&!window.opera){b.style.filter=b.getStyle("filter").replace(/alpha\([^\)]*\)/gi,"")}}else{if(d==""){if(/MSIE/.test(navigator.userAgent)&&!window.opera){b.style.filter=b.getStyle("filter").replace(/alpha\([^\)]*\)/gi,"")}}else{if(d<0.00001){d=0}if(/MSIE/.test(navigator.userAgent)&&!window.opera){b.style.filter=b.getStyle("filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+d*100+")"}}}}else{if(["float","cssFloat"].include(a)){a=(typeof b.style.styleFloat!="undefined")?"styleFloat":"cssFloat"}}b.style[a.camelize()]=d}return b},getDimensions:function(c){c=$(c);var g=$(c).getStyle("display");if(g!="none"&&g!=null){return{width:c.offsetWidth,height:c.offsetHeight}}var e=c.style;var a=e.visibility;var b=e.position;var d=e.display;e.visibility="hidden";e.position="absolute";e.display="block";var h=c.clientWidth;var f=c.clientHeight;e.display=d;e.position=b;e.visibility=a;return{width:h,height:f}},makePositioned:function(a){a=$(a);var b=Element.getStyle(a,"position");if(b=="static"||!b){a._madePositioned=true;a.style.position="relative";if(window.opera){a.style.top=0;a.style.left=0}}return a},undoPositioned:function(a){a=$(a);if(a._madePositioned){a._madePositioned=undefined;a.style.position=a.style.top=a.style.left=a.style.bottom=a.style.right=""}return a},makeClipping:function(a){a=$(a);if(a._overflow){return a}a._overflow=a.style.overflow||"auto";if((Element.getStyle(a,"overflow")||"visible")!="hidden"){a.style.overflow="hidden"}return a},undoClipping:function(a){a=$(a);if(!a._overflow){return a}a.style.overflow=a._overflow=="auto"?"":a._overflow;a._overflow=null;return a}};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(a,b){return a.getAttribute(b,2)},_flag:function(a,b){return $(a).hasAttribute(b)?b:null},style:function(a){return a.style.cssText.toLowerCase()},title:function(a){var b=a.getAttributeNode("title");return b.specified?b.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(a,c){var b=Element._attributeTranslations;c=b.names[c]||c;return $(a).getAttributeNode(c).specified}};if(document.all&&!window.opera){Element.Methods.update=function(b,c){b=$(b);c=typeof c=="undefined"?"":c.toString();var a=b.tagName.toUpperCase();if(["THEAD","TBODY","TR","TD"].include(a)){var d=document.createElement("div");switch(a){case"THEAD":case"TBODY":d.innerHTML="<table><tbody>"+c.stripScripts()+"</tbody></table>";depth=2;break;case"TR":d.innerHTML="<table><tbody><tr>"+c.stripScripts()+"</tr></tbody></table>";depth=3;break;case"TD":d.innerHTML="<table><tbody><tr><td>"+c.stripScripts()+"</td></tr></tbody></table>";depth=4}$A(b.childNodes).each(function(e){b.removeChild(e)});depth.times(function(){d=d.firstChild});$A(d.childNodes).each(function(e){b.appendChild(e)})}else{b.innerHTML=c.stripScripts()}setTimeout(function(){c.evalScripts()},10);return b}}Object.extend(Element,Element.Methods);var _nativeExtensions=false;if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){["","Form","Input","TextArea","Select"].each(function(b){var c="HTML"+b+"Element";if(window[c]){return}var a=window[c]={};a.prototype=document.createElement(b?b.toLowerCase():"div").__proto__})}Element.addMethods=function(a){Object.extend(Element.Methods,a||{});function b(e,h,g){g=g||false;var d=Element.extend.cache;for(var c in e){var f=e[c];if(!g||!(c in h)){h[c]=d.findOrStore(f)}}}if(typeof HTMLElement!="undefined"){b(Element.Methods,HTMLElement.prototype);b(Element.Methods.Simulated,HTMLElement.prototype,true);b(Form.Methods,HTMLFormElement.prototype);[HTMLInputElement,HTMLTextAreaElement,HTMLSelectElement].each(function(c){b(Form.Element.Methods,c.prototype)});_nativeExtensions=true}};var Toggle=new Object();Toggle.display=Element.toggle;Abstract.Insertion=function(a){this.adjacency=a};Abstract.Insertion.prototype={initialize:function(b,c){this.element=$(b);this.content=c.stripScripts();if(this.adjacency&&this.element.insertAdjacentHTML){try{this.element.insertAdjacentHTML(this.adjacency,this.content)}catch(d){var a=this.element.tagName.toUpperCase();if(["TBODY","TR"].include(a)){this.insertContent(this.contentFromAnonymousTable())}else{throw d}}}else{this.range=this.element.ownerDocument.createRange();if(this.initializeRange){this.initializeRange()}this.insertContent([this.range.createContextualFragment(this.content)])}setTimeout(function(){c.evalScripts()},10)},contentFromAnonymousTable:function(){var a=document.createElement("div");a.innerHTML="<table><tbody>"+this.content+"</tbody></table>";return $A(a.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(a){a.each((function(b){this.element.parentNode.insertBefore(b,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(a){a.reverse(false).each((function(b){this.element.insertBefore(b,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(a){a.each((function(b){this.element.appendChild(b)}).bind(this))}});Insertion.After=Class.create();Insertion.After.prototype=Object.extend(new Abstract.Insertion("afterEnd"),{initializeRange:function(){this.range.setStartAfter(this.element)},insertContent:function(a){a.each((function(b){this.element.parentNode.insertBefore(b,this.element.nextSibling)}).bind(this))}});Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(a){this.element=$(a)},_each:function(a){this.element.className.split(/\s+/).select(function(b){return b.length>0})._each(a)},set:function(a){this.element.className=a},add:function(a){if(this.include(a)){return}this.set($A(this).concat(a).join(" "))},remove:function(a){if(!this.include(a)){return}this.set($A(this).without(a).join(" "))},toString:function(){return $A(this).join(" ")}};Object.extend(Element.ClassNames.prototype,Enumerable);var Selector=Class.create();Selector.prototype={initialize:function(a){this.params={classNames:[]};this.expression=a.toString().strip();this.parseExpression();this.compileMatcher()},parseExpression:function(){function g(h){throw"Parse error in selector: "+h}if(this.expression==""){g("empty expression")}var e=this.params,d=this.expression,a,c,f,b;while(a=d.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)){e.attributes=e.attributes||[];e.attributes.push({name:a[2],operator:a[3],value:a[4]||a[5]||""});d=a[1]}if(d=="*"){return this.params.wildcard=true}while(a=d.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)){c=a[1],f=a[2],b=a[3];switch(c){case"#":e.id=f;break;case".":e.classNames.push(f);break;case"":case undefined:e.tagName=f.toUpperCase();break;default:g(d.inspect())}d=b}if(d.length>0){g(d.inspect())}},buildMatchExpression:function(){var c=this.params,e=[],d;if(c.wildcard){e.push("true")}if(d=c.id){e.push('element.readAttribute("id") == '+d.inspect())}if(d=c.tagName){e.push("element.tagName.toUpperCase() == "+d.inspect())}if((d=c.classNames).length>0){for(var b=0,a=d.length;b<a;b++){e.push("element.hasClassName("+d[b].inspect()+")")}}if(d=c.attributes){d.each(function(f){var h="element.readAttribute("+f.name.inspect()+")";var g=function(i){return h+" && "+h+".split("+i.inspect()+")"};switch(f.operator){case"=":e.push(h+" == "+f.value.inspect());break;case"~=":e.push(g(" ")+".include("+f.value.inspect()+")");break;case"|=":e.push(g("-")+".first().toUpperCase() == "+f.value.toUpperCase().inspect());break;case"!=":e.push(h+" != "+f.value.inspect());break;case"":case undefined:e.push("element.hasAttribute("+f.name.inspect()+")");break;default:throw"Unknown operator "+f.operator+" in selector"}})}return e.join(" && ")},compileMatcher:function(){this.match=new Function("element","if (!element.tagName) return false;       element = $(element);       return "+this.buildMatchExpression())},findElements:function(e){var b;if(b=$(this.params.id)){if(this.match(b)){if(!e||Element.childOf(b,e)){return[b]}}}e=(e||document).getElementsByTagName(this.params.tagName||"*");var d=[];for(var c=0,a=e.length;c<a;c++){if(this.match(b=e[c])){d.push(Element.extend(b))}}return d},toString:function(){return this.expression}};Object.extend(Selector,{matchElements:function(b,c){var a=new Selector(c);return b.select(a.match.bind(a)).map(Element.extend)},findElement:function(a,c,b){if(typeof c=="number"){b=c,c=false}return Selector.matchElements(a,c||"*")[b||0]},findChildElements:function(a,b){return b.map(function(c){return c.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null],function(e,f){var d=new Selector(f);return e.inject([],function(g,h){return g.concat(d.findElements(h||a))})})}).flatten()}});function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(a,b){var c=a.inject({},function(g,d){if(!d.disabled&&d.name){var e=d.name,f=$(d).getValue();if(f!=undefined){if(g[e]){if(g[e].constructor!=Array){g[e]=[g[e]]}g[e].push(f)}else{g[e]=f}}}return g});return b?c:Hash.toQueryString(c)}};Form.Methods={serialize:function(b,a){return Form.serializeElements(Form.getElements(b),a)},getElements:function(a){return $A($(a).getElementsByTagName("*")).inject([],function(b,c){if(Form.Element.Serializers[c.tagName.toLowerCase()]){b.push(Element.extend(c))}return b})},getInputs:function(g,e,c){g=$(g);var f=g.getElementsByTagName("input");if(!e&&!c){return $A(f).map(Element.extend)}for(var d=0,h=[],a=f.length;d<a;d++){var b=f[d];if((e&&b.type!=e)||(c&&b.name!=c)){continue}h.push(Element.extend(b))}return h},disable:function(a){a=$(a);a.getElements().each(function(b){b.blur();b.disabled="true"});return a},enable:function(a){a=$(a);a.getElements().each(function(b){b.disabled=""});return a},findFirstElement:function(a){return $(a).getElements().find(function(b){return b.type!="hidden"&&!b.disabled&&["input","select","textarea"].include(b.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a}};Object.extend(Form,Form.Methods);Form.Element={focus:function(a){$(a).focus();return a},select:function(a){$(a).select();return a}};Form.Element.Methods={serialize:function(a){a=$(a);if(!a.disabled&&a.name){var b=a.getValue();if(b!=undefined){var c={};c[a.name]=b;return Hash.toQueryString(c)}}return""},getValue:function(a){a=$(a);var b=a.tagName.toLowerCase();return Form.Element.Serializers[b](a)},clear:function(a){$(a).value="";return a},present:function(a){return $(a).value!=""},activate:function(a){a=$(a);a.focus();if(a.select&&(a.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(a.type))){a.select()}return a},disable:function(a){a=$(a);a.disabled=true;return a},enable:function(a){a=$(a);a.blur();a.disabled=false;return a}};Object.extend(Form.Element,Form.Element.Methods);var Field=Form.Element;var $F=Form.Element.getValue;Form.Element.Serializers={input:function(a){switch(a.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(a);default:return Form.Element.Serializers.textarea(a)}},inputSelector:function(a){return a.checked?a.value:null},textarea:function(a){return a.value},select:function(a){return this[a.type=="select-one"?"selectOne":"selectMany"](a)},selectOne:function(b){var a=b.selectedIndex;return a>=0?this.optionValue(b.options[a]):null},selectMany:function(b){var e,a=b.length;if(!a){return null}for(var d=0,e=[];d<a;d++){var c=b.options[d];if(c.selected){e.push(this.optionValue(c))}}return e},optionValue:function(a){return Element.extend(a).hasAttribute("value")?a.value:a.text}};Abstract.TimedObserver=function(){};Abstract.TimedObserver.prototype={initialize:function(a,c,b){this.frequency=c;this.element=$(a);this.callback=b;this.lastValue=this.getValue();this.registerCallback()},registerCallback:function(){setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},onTimerEvent:function(){var a=this.getValue();var b=("string"==typeof this.lastValue&&"string"==typeof a?this.lastValue!=a:String(this.lastValue)!=String(a));if(b){this.callback(this.element,a);this.lastValue=a}}};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(a,b){this.element=$(a);this.callback=b;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks()}else{this.registerCallback(this.element)}},onElementEvent:function(){var a=this.getValue();if(this.lastValue!=a){this.callback(this.element,a);this.lastValue=a}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback.bind(this))},registerCallback:function(a){if(a.type){switch(a.type.toLowerCase()){case"checkbox":case"radio":Event.observe(a,"click",this.onElementEvent.bind(this));break;default:Event.observe(a,"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(a){return a.target||a.srcElement},isLeftClick:function(a){return(((a.which)&&(a.which==1))||((a.button)&&(a.button==1)))},pointerX:function(a){return a.pageX||(a.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft))},pointerY:function(a){return a.pageY||(a.clientY+(document.documentElement.scrollTop||document.body.scrollTop))},stop:function(a){if(a.preventDefault){a.preventDefault();a.stopPropagation()}else{a.returnValue=false;a.cancelBubble=true}},findElement:function(c,b){var a=Event.element(c);while(a.parentNode&&(!a.tagName||(a.tagName.toUpperCase()!=b.toUpperCase()))){a=a.parentNode}return a},observers:false,_observeAndCache:function(c,b,a,d){if(!this.observers){this.observers=[]}if(c.addEventListener){this.observers.push([c,b,a,d]);c.addEventListener(b,a,d)}else{if(c.attachEvent){this.observers.push([c,b,a,d]);c.attachEvent("on"+b,a)}}},unloadCache:function(){if(!Event.observers){return}for(var b=0,a=Event.observers.length;b<a;b++){Event.stopObserving.apply(this,Event.observers[b]);Event.observers[b][0]=null}Event.observers=false},observe:function(c,b,a,d){c=$(c);d=d||false;if(b=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||c.attachEvent)){b="keydown"}Event._observeAndCache(c,b,a,d)},stopObserving:function(c,b,a,d){c=$(c);d=d||false;if(b=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||c.detachEvent)){b="keydown"}if(c.removeEventListener){c.removeEventListener(b,a,d)}else{if(c.detachEvent){try{c.detachEvent("on"+b,a)}catch(f){}}}}});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(a){var b=0,c=0;do{b+=a.scrollTop||0;c+=a.scrollLeft||0;a=a.parentNode}while(a);return[c,b]},cumulativeOffset:function(a){var b=0,c=0;do{b+=a.offsetTop||0;c+=a.offsetLeft||0;a=a.offsetParent}while(a);return[c,b]},positionedOffset:function(a){var b=0,d=0;do{b+=a.offsetTop||0;d+=a.offsetLeft||0;a=a.offsetParent;if(a){if(a.tagName=="BODY"){break}var c=Element.getStyle(a,"position");if(c=="relative"||c=="absolute"){break}}}while(a);return[d,b]},offsetParent:function(a){if(a.offsetParent){return a.offsetParent}if(a==document.body){return a}while((a=a.parentNode)&&a!=document.body){if(Element.getStyle(a,"position")!="static"){return a}}return document.body},within:function(b,a,c){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(b,a,c)}this.xcomp=a;this.ycomp=c;this.offset=this.cumulativeOffset(b);return(c>=this.offset[1]&&c<this.offset[1]+b.offsetHeight&&a>=this.offset[0]&&a<this.offset[0]+b.offsetWidth)},withinIncludingScrolloffsets:function(b,a,d){var c=this.realOffset(b);this.xcomp=a+c[0]-this.deltaX;this.ycomp=d+c[1]-this.deltaY;this.offset=this.cumulativeOffset(b);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+b.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+b.offsetWidth)},overlap:function(b,a){if(!b){return 0}if(b=="vertical"){return((this.offset[1]+a.offsetHeight)-this.ycomp)/a.offsetHeight}if(b=="horizontal"){return((this.offset[0]+a.offsetWidth)-this.xcomp)/a.offsetWidth}},page:function(c){var b=0,d=0;var a=c;do{b+=a.offsetTop||0;d+=a.offsetLeft||0;if(a.offsetParent==document.body){if(Element.getStyle(a,"position")=="absolute"){break}}}while(a=a.offsetParent);a=c;do{if(!window.opera||a.tagName=="BODY"){b-=a.scrollTop||0;d-=a.scrollLeft||0}}while(a=a.parentNode);return[d,b]},clone:function(a,f){var c=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});a=$(a);var d=Position.page(a);f=$(f);var e=[0,0];var b=null;if(Element.getStyle(f,"position")=="absolute"){b=Position.offsetParent(f);e=Position.page(b)}if(b==document.body){e[0]-=document.body.offsetLeft;e[1]-=document.body.offsetTop}if(c.setLeft){f.style.left=(d[0]-e[0]+c.offsetLeft)+"px"}if(c.setTop){f.style.top=(d[1]-e[1]+c.offsetTop)+"px"}if(c.setWidth){f.style.width=a.offsetWidth+"px"}if(c.setHeight){f.style.height=a.offsetHeight+"px"}},absolutize:function(b){b=$(b);if(b.style.position=="absolute"){return}Position.prepare();var a=Position.positionedOffset(b);var f=a[1];var e=a[0];var c=b.clientWidth;var d=b.clientHeight;b._originalLeft=e-parseFloat(b.style.left||0);b._originalTop=f-parseFloat(b.style.top||0);b._originalWidth=b.style.width;b._originalHeight=b.style.height;b.style.position="absolute";b.style.top=f+"px";b.style.left=e+"px";b.style.width=c+"px";b.style.height=d+"px"},relativize:function(a){a=$(a);if(a.style.position=="relative"){return}Position.prepare();a.style.position="relative";var c=parseFloat(a.style.top||0)-(a._originalTop||0);var b=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=c+"px";a.style.left=b+"px";a.style.height=a._originalHeight;a.style.width=a._originalWidth}};if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){Position.cumulativeOffset=function(a){var b=0,c=0;do{b+=a.offsetTop||0;c+=a.offsetLeft||0;if(a.offsetParent==document.body){if(Element.getStyle(a,"position")=="absolute"){break}}a=a.offsetParent}while(a);return[c,b]}}Element.addMethods();
