﻿var Prototype={Version:"1.5.1",Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement("div").__proto__!==document.createElement("form").__proto__},ScriptFragment:"<script[^>]*>([\1-￿]*?)</sc"+"ript>",JSONFilter:/^\/\*-secure-\s*(.*)\s*\*\/\s*$/,emptyFunction:function(){},K:function(a){return a}},Class={create:function(){return function(){this.initialize.apply(this,arguments)}}},Abstract={};Object.extend=function(a,c){for(var b in c)a[b]=c[b];return a};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}},toJSON:function(a){var e=typeof a;switch(e){case "undefined":case "function":case "unknown":return;case "boolean":return a.toString()}if(a===null)return "null";if(a.toJSON)return a.toJSON();if(a.ownerDocument===document)return;var c=[];for(var b in a){var d=Object.toJSON(a[b]);if(d!==undefined)c.push(b.toJSON()+": "+d)}return "{"+c.join(", ")+"}"},keys:function(c){var a=[];for(var b in c)a.push(b);return a},values:function(a){var b=[];for(var c in a)b.push(a[c]);return b},clone:function(a){return Object.extend({},a)}});Function.prototype.bind=function(){var b=this,a=$A(arguments),c=a.shift();return function(){return b.apply(c,a.concat($A(arguments)))}};Function.prototype.bindAsEventListener=function(c){var b=this,a=$A(arguments),c=a.shift();return function(d){return b.apply(c,[d||window.event].concat(a))}};Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(a){$R(0,this,true).each(a);return this},toPaddedString:function(b,c){var a=this.toString(c||10);return "0".times(b-a.length)+a},toJSON:function(){return isFinite(this)?this.toString():"null"}});Date.prototype.toJSON=function(){return '"'+this.getFullYear()+"-"+(this.getMonth()+1).toPaddedString(2)+"-"+this.getDate().toPaddedString(2)+"T"+this.getHours().toPaddedString(2)+":"+this.getMinutes().toPaddedString(2)+":"+this.getSeconds().toPaddedString(2)+'"'};var Try={these:function(){var b;for(var a=0,d=arguments.length;a<d;a++){var c=arguments[a];try{b=c();break}catch(e){}}return b}},PeriodicalExecuter=Class.create();PeriodicalExecuter.prototype={initialize:function(b,a){this.callback=b;this.frequency=a;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1e3)},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}}};Object.extend(String,{interpret:function(a){return a==null?"":String(a)},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});Object.extend(String.prototype,{gsub:function(e,d){var c="",a=this,b;d=arguments.callee.prepareReplacement(d);while(a.length>0)if(b=a.match(e)){c+=a.slice(0,b.index);c+=String.interpret(d(b));a=a.slice(b.index+b[0].length)}else c+=a,a="";return c},sub:function(c,b,a){b=this.gsub.prepareReplacement(b);a=a===undefined?1:a;return this.gsub(c,function(c){if(--a<0)return c[0];return b(c)})},scan:function(b,a){this.gsub(b,a);return this},truncate:function(b,a){b=b||30;a=a===undefined?"...":a;return this.length>b?this.slice(0,b-a.length)+a: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 a=new RegExp(Prototype.ScriptFragment,"img"),b=new RegExp(Prototype.ScriptFragment,"im");return (this.match(a)||[]).map(function(a){return (a.match(b)||["",""])[1]})},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script)})},escapeHTML:function(){var a=arguments.callee;a.text.data=this;return a.div.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(a,b){return a+b.nodeValue}):a.childNodes[0].nodeValue:""},toQueryParams:function(b){var a=this.strip().match(/([^?#]*)(#.*)?$/);if(!a)return {};return a[1].split(b||"&").inject({},function(a,b){if((b=b.split("="))[0]){var c=decodeURIComponent(b.shift()),d=b.length>1?b.join("="):b[0];if(d!=undefined)d=decodeURIComponent(d);if(c in a){if(a[c].constructor!=Array)a[c]=[a[c]];a[c].push(d)}else a[c]=d}return a})},toArray:function(){return this.split("")},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(c){var a="";for(var b=0;b<c;b++)a+=this;return a},camelize:function(){var a=this.split("-"),d=a.length;if(d==1)return a[0];var c=this.charAt(0)=="-"?a[0].charAt(0).toUpperCase()+a[0].substring(1):a[0];for(var b=1;b<d;b++)c+=a[b].charAt(0).toUpperCase()+a[b].substring(1);return c},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.gsub(/[\x00-\x1f\\]/,function(b){var a=String.specialChar[b[0]];return a?a:"\\u00"+b[0].charCodeAt().toPaddedString(2,16)});if(b)return '"'+a.replace(/"/g,'\\"')+'"';return "'"+a.replace(/'/g,"\\'")+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(a){return this.sub(a||Prototype.JSONFilter,"#{1}")},evalJSON:function(sanitize){var json=this.unfilterJSON();try{if(!sanitize||/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json))return eval("("+json+")")}catch(a){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())},include:function(a){return this.indexOf(a)>-1},startsWith:function(a){return this.indexOf(a)===0},endsWith:function(a){var b=this.length-a.length;return b>=0&&this.lastIndexOf(a)===b},empty:function(){return this==""},blank:function(){return /^\s*$/.test(this)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE)Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},unescapeHTML:function(){return this.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}});String.prototype.gsub.prepareReplacement=function(a){if(typeof a=="function")return a;var b=new Template(a);return function(a){return b.evaluate(a)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});with(String.prototype.escapeHTML)div.appendChild(text);var Template=Class.create();Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;Template.prototype={initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(a){return this.template.gsub(this.pattern,function(b){var c=b[1];if(c=="\\")return b[2];return c+String.interpret(a[b[3]])})}};var $break={},$continue=new Error('"throw $continue" is deprecated, use "return" instead'),Enumerable={each:function(a){var b=0;try{this._each(function(c){a(c,b++)})}catch(c){if(c!=$break)throw c}return this},eachSlice:function(a,e){var b=-a,c=[],d=this.toArray();while((b+=a)<d.length)c.push(d.slice(b,b+a));return c.map(e)},all:function(b){var a=true;this.each(function(d,c){a=a&&!!(b||Prototype.K)(d,c);if(!a)throw $break});return a},any:function(b){var a=false;this.each(function(d,c){if(a=!!(b||Prototype.K)(d,c))throw $break});return a},collect:function(b){var a=[];this.each(function(d,c){a.push((b||Prototype.K)(d,c))});return a},detect:function(b){var a;this.each(function(c,d){if(b(c,d)){a=c;throw $break}});return a},findAll:function(b){var a=[];this.each(function(c,d){if(b(c,d))a.push(c)});return a},grep:function(c,b){var a=[];this.each(function(d,f){var e=d.toString();if(e.match(c))a.push((b||Prototype.K)(d,f))});return a},include:function(b){var a=false;this.each(function(c){if(c==b){a=true;throw $break}});return a},inGroupsOf:function(b,a){a=a===undefined?null:a;return this.eachSlice(b,function(c){while(c.length<b)c.push(a);return c})},inject:function(a,b){this.each(function(d,c){a=b(a,d,c)});return a},invoke:function(a){var b=$A(arguments).slice(1);return this.map(function(c){return c[a].apply(c,b)})},max:function(b){var a;this.each(function(c,d){c=(b||Prototype.K)(c,d);if(a==undefined||c>=a)a=c});return a},min:function(b){var a;this.each(function(c,d){c=(b||Prototype.K)(c,d);if(a==undefined||c<a)a=c});return a},partition:function(c){var b=[],a=[];this.each(function(d,e){((c||Prototype.K)(d,e)?b:a).push(d)});return [b,a]},pluck:function(b){var a=[];this.each(function(c){a.push(c[b])});return a},reject:function(b){var a=[];this.each(function(c,d){if(!b(c,d))a.push(c)});return a},sortBy:function(a){return this.map(function(b,c){return {value:b,criteria:a(b,c)}}).sort(function(d,c){var a=d.criteria,b=c.criteria;return a<b?-1:a>b?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(d,a){return b(c.pluck(a))})},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(a){if(!a)return [];if(a.toArray)return a.toArray();else{var c=[];for(var b=0,d=a.length;b<d;b++)c.push(a[b]);return c}};if(Prototype.Browser.WebKit)$A=Array.from=function(a){if(!a)return [];if(!(typeof a=="function"&&a=="[object NodeList]")&&a.toArray)return a.toArray();else{var c=[];for(var b=0,d=a.length;b<d;b++)c.push(a[b]);return c}};Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse)Array.prototype._reverse=Array.prototype.reverse;Object.extend(Array.prototype,{_each:function(b){for(var a=0,c=this.length;a<c;a++)b(this[a])},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 a=0,b=this.length;a<b;a++)if(this[a]==c)return a;return -1},reverse:function(a){return (a!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(a){return this.inject([],function(b,c,d){if(0==d||(a?b.last()!=c:!b.include(c)))b.push(c);return b})},clone:function(){return [].concat(this)},size:function(){return this.length},inspect:function(){return "["+this.map(Object.inspect).join(", ")+"]"},toJSON:function(){var a=[];this.each(function(c){var b=Object.toJSON(c);if(b!==undefined)a.push(b)});return "["+a.join(", ")+"]"}});Array.prototype.toArray=Array.prototype.clone;function $w(a){a=a.strip();return a?a.split(/\s+/):[]}if(Prototype.Browser.Opera)Array.prototype.concat=function(){var b=[];for(var a=0,d=this.length;a<d;a++)b.push(this[a]);for(var a=0,d=arguments.length;a<d;a++)if(arguments[a].constructor==Array)for(var c=0,e=arguments[a].length;c<e;c++)b.push(arguments[a][c]);else b.push(arguments[a]);return b};var Hash=function(a){if(a instanceof Hash)this.merge(a);else Object.extend(this,a||{})};Object.extend(Hash,{toQueryString:function(b){var a=[];a.add=arguments.callee.addPair;this.prototype._each.call(b,function(c){if(!c.key)return;var b=c.value;if(b&&typeof b=="object"){if(b.constructor==Array)b.each(function(b){a.add(c.key,b)});return}a.add(c.key,b)});return a.join("&")},toJSON:function(b){var a=[];this.prototype._each.call(b,function(c){var b=Object.toJSON(c.value);if(b!==undefined)a.push(c.key.toJSON()+": "+b)});return "{"+a.join(", ")+"}"}});Hash.toQueryString.addPair=function(a,b){a=encodeURIComponent(a);if(b===undefined)this.push(a);else this.push(a+"="+(b==null?"":encodeURIComponent(b)))};Object.extend(Hash.prototype,Enumerable);Object.extend(Hash.prototype,{_each:function(d){for(var b in this){var a=this[b];if(a&&a==Hash.prototype[b])continue;var c=[b,a];c.key=b;c.value=a;d(c)}},keys:function(){return this.pluck("key")},values:function(){return this.pluck("value")},merge:function(a){return $H(a).inject(this,function(a,b){a[b.key]=b.value;return a})},remove:function(){var a;for(var b=0,d=arguments.length;b<d;b++){var c=this[arguments[b]];if(c!==undefined)if(a===undefined)a=c;else{if(a.constructor!=Array)a=[a];a.push(c)}delete this[arguments[b]]}return a},toQueryString:function(){return Hash.toQueryString(this)},inspect:function(){return "#<Hash:{"+this.map(function(a){return a.map(Object.inspect).join(": ")}).join(", ")+"}>"},toJSON:function(){return Hash.toJSON(this)}});function $H(a){if(a instanceof Hash)return a;return new Hash(a)}if(function(){var b=0,a=function(a){this.key=a};a.prototype.key="foo";for(var c in new a("bar"))b++;return b>1}())Hash.prototype._each=function(e){var d=[];for(var a in this){var b=this[a];if(b&&b==Hash.prototype[a]||d.include(a))continue;d.push(a);var c=[a,b];c.key=a;c.value=b;e(c)}};ObjectRange=Class.create();Object.extend(ObjectRange.prototype,Enumerable);Object.extend(ObjectRange.prototype,{initialize:function(b,c,a){this.start=b;this.end=c;this.exclusive=a},_each:function(b){var a=this.start;while(this.include(a)){b(a);a=a.succ()}},include:function(a){if(a<this.start)return false;if(this.exclusive)return a<this.end;return a<=this.end}});var $R=function(b,c,a){return new ObjectRange(b,c,a)},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(a,c,b,d){this.each(function(e){if(typeof e[a]=="function")try{e[a].apply(e,[c,b,d])}catch(f){}})}};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(b,a){this.transport=Ajax.getTransport();this.setOptions(a);this.request(b)},request:function(b){this.url=b;this.method=this.options.method;var a=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){a["_method"]=this.method;this.method="post"}this.parameters=a;if(a=Hash.toQueryString(a))if(this.method=="get")this.url+=(this.url.include("?")?"&":"?")+a;else if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))a+="&_=";try{if(this.options.onCreate)this.options.onCreate(this.transport);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();this.body=this.method=="post"?this.options.postBody||a:null;this.transport.send(this.body);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 a={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){a["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)a["Connection"]="close"}if(typeof this.options.requestHeaders=="object"){var b=this.options.requestHeaders;if(typeof b.push=="function")for(var c=0,e=b.length;c<e;c+=2)a[b[c]]=b[c+1];else $H(b).each(function(b){a[b.key]=b.value})}for(var d in a)this.transport.setRequestHeader(d,a[d])},success:function(){return !this.transport.status||this.transport.status>=200&&this.transport.status<300},respondToReadyState:function(e){var a=Ajax.Request.Events[e],b=this.transport,c=this.evalJSON();if(a=="Complete"){try{this._complete=true;(this.options["on"+this.transport.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(b,c)}catch(f){this.dispatchException(f)}var d=this.getHeader("Content-type");if(d&&d.strip().match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))this.evalResponse()}try{(this.options["on"+a]||Prototype.emptyFunction)(b,c);Ajax.Responders.dispatch("on"+a,this,b,c)}catch(f){this.dispatchException(f)}if(a=="Complete")this.transport.onreadystatechange=Prototype.emptyFunction},getHeader:function(a){try{return this.transport.getResponseHeader(a)}catch(b){return null}},evalJSON:function(){try{var a=this.getHeader("X-JSON");return a?a.evalJSON():null}catch(b){return null}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON())}catch(a){this.dispatchException(a)}},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(a,d,c){this.container={success:a.success||a,failure:a.failure||(a.success?null:a)};this.transport=Ajax.getTransport();this.setOptions(c);var b=this.options.onComplete||Prototype.emptyFunction;this.options.onComplete=function(a,c){this.updateContent();b(a,c)}.bind(this);this.request(d)},updateContent:function(){var a=this.container[this.success()?"success":"failure"],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(a,c,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=a;this.url=c;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*1e3)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(a){if(arguments.length>1){for(var b=0,c=[],d=arguments.length;b<d;b++)c.push($(arguments[b]));return c}if(typeof a=="string")a=document.getElementById(a);return Element.extend(a)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(e,d){var b=[],c=document.evaluate(e,$(d)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var a=0,f=c.snapshotLength;a<f;a++)b.push(c.snapshotItem(a));return b};document.getElementsByClassName=function(b,a){var c=".//*[contains(concat(' ', @class, ' '), ' "+b+" ')]";return document._getElementsByXPath(c,a)}}else document.getElementsByClassName=function(f,e){var c=($(e)||document.body).getElementsByTagName("*"),d=[],a;for(var b=0,g=c.length;b<g;b++){a=c[b];if(Element.hasClassName(a,f))d.push(Element.extend(a))}return d};if(!window.Element)var Element={};Element.extend=function(a){var f=Prototype.BrowserFeatures;if(!a||!a.tagName||a.nodeType==3||a._extended||f.SpecificElementExtensions||a==window)return a;var b={},d=a.tagName,h=Element.extend.cache,g=Element.Methods.ByTag;if(!f.ElementExtensions)Object.extend(b,Element.Methods),Object.extend(b,Element.Methods.Simulated);if(g[d])Object.extend(b,g[d]);for(var c in b){var e=b[c];if(typeof e=="function"&&!(c in a))a[c]=h.findOrStore(e)}a._extended=Prototype.emptyFunction;return a};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(b,a){a=typeof a=="undefined"?"":a.toString();$(b).innerHTML=a.stripScripts();setTimeout(function(){a.evalScripts()},10);return b},replace:function(a,b){a=$(a);b=typeof b=="undefined"?"":b.toString();if(a.outerHTML)a.outerHTML=b.stripScripts();else{var c=a.ownerDocument.createRange();c.selectNodeContents(a);a.parentNode.replaceChild(c.createContextualFragment(b.stripScripts()),a)}setTimeout(function(){b.evalScripts()},10);return a},inspect:function(a){a=$(a);var b="<"+a.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(d){var f=d.first(),e=d.last(),c=(a[f]||"").toString();if(c)b+=" "+e+"="+c.inspect(true)});return b+">"},recursivelyCollect:function(a,c){a=$(a);var b=[];while(a=a[c])if(a.nodeType==1)b.push(Element.extend(a));return b},ancestors:function(a){return $(a).recursivelyCollect("parentNode")},descendants:function(a){return $A($(a).getElementsByTagName("*")).each(Element.extend)},firstDescendant:function(a){a=$(a).firstChild;while(a&&a.nodeType!=1)a=a.nextSibling;return $(a)},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(a,b,d){a=$(a);if(arguments.length==1)return $(a.parentNode);var c=a.ancestors();return b?Selector.findElement(c,b,d):c[d||0]},down:function(a,c,d){a=$(a);if(arguments.length==1)return a.firstDescendant();var b=a.descendants();return c?Selector.findElement(b,c,d):b[d||0]},previous:function(a,c,d){a=$(a);if(arguments.length==1)return $(Selector.handlers.previousElementSibling(a));var b=a.previousSiblings();return c?Selector.findElement(b,c,d):b[d||0]},next:function(a,c,d){a=$(a);if(arguments.length==1)return $(Selector.handlers.nextElementSibling(a));var b=a.nextSiblings();return c?Selector.findElement(b,c,d):b[d||0]},getElementsBySelector:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b,a)},getElementsByClassName:function(b,a){return document.getElementsByClassName(a,b)},readAttribute:function(b,a){b=$(b);if(Prototype.Browser.IE){if(!b.attributes)return null;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];return d?d.nodeValue:null}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,c){if(!(b=$(b)))return;var a=b.className;if(a.length==0)return false;if(a==c||a.match(new RegExp("(^|\\s)"+c+"(\\s|$)")))return true;return false},addClassName:function(a,b){if(!(a=$(a)))return;Element.classNames(a).add(b);return a},removeClassName:function(a,b){if(!(a=$(a)))return;Element.classNames(a).remove(b);return a},toggleClassName:function(a,b){if(!(a=$(a)))return;Element.classNames(a)[a.hasClassName(b)?"remove":"add"](b);return a},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 a=b.firstChild;while(a){var c=a.nextSibling;if(a.nodeType==3&&!/\S/.test(a.nodeValue))b.removeChild(a);a=c}return b},empty:function(a){return $(a).innerHTML.blank()},descendantOf:function(a,b){a=$(a),b=$(b);while(a=a.parentNode)if(a==b)return true;return false},scrollTo:function(a){a=$(a);var b=Position.cumulativeOffset(a);window.scrollTo(b[0],b[1]);return a},getStyle:function(c,a){c=$(c);a=a=="float"?"cssFloat":a.camelize();var b=c.style[a];if(!b){var d=document.defaultView.getComputedStyle(c,null);b=d?d[a]:null}if(a=="opacity")return b?parseFloat(b):1;return b=="auto"?null:b},getOpacity:function(a){return $(a).getStyle("opacity")},setStyle:function(b,c,e){b=$(b);var d=b.style;for(var a in c)if(a=="opacity")b.setOpacity(c[a]);else d[a=="float"||a=="cssFloat"?d.styleFloat===undefined?"cssFloat":"styleFloat":e?a:a.camelize()]=c[a];return b},setOpacity:function(a,b){a=$(a);a.style.opacity=b==1||b===""?"":b<1e-5?0:b;return a},getDimensions:function(b){b=$(b);var c=$(b).getStyle("display");if(c!="none"&&c!=null)return {width:b.offsetWidth,height:b.offsetHeight};var a=b.style,d=a.visibility,e=a.position,f=a.display;a.visibility="hidden";a.position="absolute";a.display="block";var h=b.clientWidth,g=b.clientHeight;a.display=f;a.position=e;a.visibility=d;return {width:h,height:g}},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,childElements:Element.Methods.immediateDescendants});if(Prototype.Browser.Opera){Element.Methods._getStyle=Element.Methods.getStyle;Element.Methods.getStyle=function(a,b){switch(b){case "left":case "top":case "right":case "bottom":if(Element._getStyle(a,"position")=="static")return null;default:return Element._getStyle(a,b)}}}else if(Prototype.Browser.IE){Element.Methods.getStyle=function(b,a){b=$(b);a=a=="float"||a=="cssFloat"?"styleFloat":a.camelize();var c=b.style[a];if(!c&&b.currentStyle)c=b.currentStyle[a];if(a=="opacity"){if(c=(b.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/))if(c[1])return parseFloat(c[1])/100;return 1}if(c=="auto"){if((a=="width"||a=="height")&&b.getStyle("display")!="none")return b["offset"+a.capitalize()]+"px";return null}return c};Element.Methods.setOpacity=function(a,b){a=$(a);var c=a.getStyle("filter"),d=a.style;if(b==1||b===""){d.filter=c.replace(/alpha\([^\)]*\)/gi,"");return a}else if(b<1e-5)b=0;d.filter=c.replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+b*100+")";return a};Element.Methods.update=function(a,b){a=$(a);b=typeof b=="undefined"?"":b.toString();var d=a.tagName.toUpperCase();if(["THEAD","TBODY","TR","TD"].include(d)){var c=document.createElement("div");switch(d){case "THEAD":case "TBODY":c.innerHTML="<table><tbody>"+b.stripScripts()+"</tbody></table>";depth=2;break;case "TR":c.innerHTML="<table><tbody><tr>"+b.stripScripts()+"</tr></tbody></table>";depth=3;break;case "TD":c.innerHTML="<table><tbody><tr><td>"+b.stripScripts()+"</td></tr></tbody></table>";depth=4}$A(a.childNodes).each(function(b){a.removeChild(b)});depth.times(function(){c=c.firstChild});$A(c.childNodes).each(function(b){a.appendChild(b)})}else a.innerHTML=b.stripScripts();setTimeout(function(){b.evalScripts()},10);return a}}else if(Prototype.Browser.Gecko)Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=b==1?.999999:b===""?"":b<1e-5?0:b;return a};Element._attributeTranslations={names:{colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",datetime:"dateTime",accesskey:"accessKey",tabindex:"tabIndex",enctype:"encType",maxlength:"maxLength",readonly:"readOnly",longdesc:"longDesc"},values:{_getAttr:function(b,a){return b.getAttribute(a,2)},_flag:function(b,a){return $(b).hasAttribute(a)?a:null},style:function(a){return a.style.cssText.toLowerCase()},title:function(b){var a=b.getAttributeNode("title");return a.specified?a.nodeValue:null}}};(function(){Object.extend(this,{href:this._getAttr,src:this._getAttr,type:this._getAttr,disabled:this._flag,checked:this._flag,readonly:this._flag,multiple:this._flag})}).call(Element._attributeTranslations.values);Element.Methods.Simulated={hasAttribute:function(c,a){var d=Element._attributeTranslations,b;a=d.names[a]||a;b=$(c).getAttributeNode(a);return b&&b.specified}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div").__proto__){window.HTMLElement={};window.HTMLElement.prototype=document.createElement("div").__proto__;Prototype.BrowserFeatures.ElementExtensions=true}Element.hasAttribute=function(a,b){if(a.hasAttribute)return a.hasAttribute(b);return Element.Methods.Simulated.hasAttribute(a,b)};Element.addMethods=function(a){var g=Prototype.BrowserFeatures,i=Element.Methods.ByTag;if(!a){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{FORM:Object.clone(Form.Methods),INPUT:Object.clone(Form.Element.Methods),SELECT:Object.clone(Form.Element.Methods),TEXTAREA:Object.clone(Form.Element.Methods)})}if(arguments.length==2){var b=a;a=arguments[1]}if(!b)Object.extend(Element.Methods,a||{});else if(b.constructor==Array)b.each(d);else d(b);function d(b){b=b.toUpperCase();if(!Element.Methods.ByTag[b])Element.Methods.ByTag[b]={};Object.extend(Element.Methods.ByTag[b],a)}function c(d,c,a){a=a||false;var e=Element.extend.cache;for(var b in d){var f=d[b];if(!a||!(b in c))c[b]=e.findOrStore(f)}}function h(b){var a,c={OPTGROUP:"OptGroup",TEXTAREA:"TextArea",P:"Paragraph",FIELDSET:"FieldSet",UL:"UList",OL:"OList",DL:"DList",DIR:"Directory",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading",Q:"Quote",INS:"Mod",DEL:"Mod",A:"Anchor",IMG:"Image",CAPTION:"TableCaption",COL:"TableCol",COLGROUP:"TableCol",THEAD:"TableSection",TFOOT:"TableSection",TBODY:"TableSection",TR:"TableRow",TH:"TableCell",TD:"TableCell",FRAMESET:"FrameSet",IFRAME:"IFrame"};if(c[b])a="HTML"+c[b]+"Element";if(window[a])return window[a];a="HTML"+b+"Element";if(window[a])return window[a];a="HTML"+b.capitalize()+"Element";if(window[a])return window[a];window[a]={};window[a].prototype=document.createElement(b).__proto__;return window[a]}if(g.ElementExtensions){c(Element.Methods,HTMLElement.prototype);c(Element.Methods.Simulated,HTMLElement.prototype,true)}if(g.SpecificElementExtensions)for(var f in Element.Methods.ByTag){var e=h(f);if(typeof e=="undefined")continue;c(i[f],e.prototype)}Object.extend(Element,Element.Methods);delete Element.ByTag};var Toggle={display:Element.toggle};Abstract.Insertion=function(a){this.adjacency=a};Abstract.Insertion.prototype={initialize:function(b,a){this.element=$(b);this.content=a.stripScripts();if(this.adjacency&&this.element.insertAdjacentHTML)try{this.element.insertAdjacentHTML(this.adjacency,this.content)}catch(d){var c=this.element.tagName.toUpperCase();if(["TBODY","TR"].include(c))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(){a.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={};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(a){this.element.parentNode.insertBefore(a,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(a){this.element.insertBefore(a,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(a){this.element.appendChild(a)}.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(a){this.element.parentNode.insertBefore(a,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(a){return a.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.expression=a.strip();this.compileMatcher()},compileMatcher:function(){if(Prototype.BrowserFeatures.XPath&&!/\[[\w-]*?:/.test(this.expression))return this.compileXPathMatcher();var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return}this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&/\S/.test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(typeof c[i]=="function"?c[i](m):(new Template(c[i])).evaluate(m));e=e.replace(m[0],"");break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join("\n"));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var a=this.expression,f=Selector.patterns,d=Selector.xpath,e,c;if(Selector._cache[a]){this.xpath=Selector._cache[a];return}this.matcher=[".//*"];while(a&&e!=a&&/\S/.test(a)){e=a;for(var b in f)if(c=a.match(f[b])){this.matcher.push(typeof d[b]=="function"?d[b](c):(new Template(d[b])).evaluate(c));a=a.replace(c[0],"");break}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath},findElements:function(a){a=a||document;if(this.xpath)return document._getElementsByXPath(this.xpath,a);return this.matcher(a)},match:function(a){return this.findElements(document).include(a)},toString:function(){return this.expression},inspect:function(){return "#<Selector:"+this.expression.inspect()+">"}};Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(a){if(a[1]=="*")return "";return "[local-name()='"+a[1].toLowerCase()+"' or local-name()='"+a[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:"[@#{1}]",attr:function(a){a[3]=a[5]||a[6];return (new Template(Selector.xpath.operators[a[2]])).evaluate(a)},pseudo:function(a){var b=Selector.xpath.pseudos[a[1]];if(!b)return "";if(typeof b==="function")return b(a);return (new Template(Selector.xpath.pseudos[a[1]])).evaluate(a)},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]",empty:"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",checked:"[@checked]",disabled:"[@disabled]",enabled:"[not(@disabled)]",not:function(b){var a=b[6],h=Selector.patterns,e=Selector.xpath,g,b,d,f=[];while(a&&g!=a&&/\S/.test(a)){g=a;for(var c in h)if(b=a.match(h[c])){d=typeof e[c]=="function"?e[c](b):(new Template(e[c])).evaluate(b);f.push("("+d.substring(1,d.length-1)+")");a=a.replace(b[0],"");break}}return "[not("+f.join(" and ")+")]"},"nth-child":function(a){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",a)},"nth-last-child":function(a){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",a)},"nth-of-type":function(a){return Selector.xpath.pseudos.nth("position() ",a)},"nth-last-of-type":function(a){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",a)},"first-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-of-type"](a)},"last-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](a)},"only-of-type":function(a){var b=Selector.xpath.pseudos;return b["first-of-type"](a)+b["last-of-type"](a)},nth:function(d,g){var a,b=g[6],c;if(b=="even")b="2n+0";if(b=="odd")b="2n+1";if(a=b.match(/^(\d+)$/))return "["+d+"= "+a[1]+"]";if(a=b.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(a[1]=="-")a[1]=-1;var e=a[1]?Number(a[1]):1,f=a[2]?Number(a[2]):0;c="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return (new Template(c)).evaluate({fragment:d,a:e,b:f})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);   c = false;',className:'n = h.className(n, r, "#{1}", c); c = false;',id:'n = h.id(n, r, "#{1}", c);        c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}"); c = false;',attr:function(a){a[3]=a[5]||a[6];return (new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;')).evaluate(a)},pseudo:function(a){if(a[6])a[6]=a[6].replace(/"/g,'\\"');return (new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;')).evaluate(a)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/},handlers:{concat:function(b,d){for(var c=0,a;a=d[c];c++)b.push(a);return b},mark:function(a){for(var c=0,b;b=a[c];c++)b._counted=true;return a},unmark:function(a){for(var c=0,b;b=a[c];c++)b._counted=undefined;return a},index:function(b,f,d){b._counted=true;if(f)for(var c=b.childNodes,a=c.length-1,e=1;a>=0;a--){node=c[a];if(node.nodeType==1&&(!d||node._counted))node.nodeIndex=e++}else for(var a=0,e=1,c=b.childNodes;node=c[a];a++)if(node.nodeType==1&&(!d||node._counted))node.nodeIndex=e++},unique:function(a){if(a.length==0)return a;var d=[],c;for(var b=0,e=a.length;b<e;b++)if(!(c=a[b])._counted){c._counted=true;d.push(Element.extend(c))}return Selector.handlers.unmark(d)},descendant:function(d){var e=Selector.handlers;for(var c=0,a=[],b;b=d[c];c++)e.concat(a,b.getElementsByTagName("*"));return a},child:function(f){var h=Selector.handlers;for(var d=0,b=[],c;c=f[d];d++)for(var e=0,g=[],a;a=c.childNodes[e];e++)if(a.nodeType==1&&a.tagName!="!")b.push(a);return b},adjacent:function(e){for(var d=0,a=[],c;c=e[d];d++){var b=this.nextElementSibling(c);if(b)a.push(b)}return a},laterSibling:function(d){var e=Selector.handlers;for(var c=0,a=[],b;b=d[c];c++)e.concat(a,Element.nextSiblings(b));return a},nextElementSibling:function(a){while(a=a.nextSibling)if(a.nodeType==1)return a;return null},previousElementSibling:function(a){while(a=a.previousSibling)if(a.nodeType==1)return a;return null},tagName:function(b,g,a,f){a=a.toUpperCase();var d=[],h=Selector.handlers;if(b){if(f){if(f=="descendant"){for(var e=0,c;c=b[e];e++)h.concat(d,c.getElementsByTagName(a));return d}else b=this[f](b);if(a=="*")return b}for(var e=0,c;c=b[e];e++)if(c.tagName.toUpperCase()==a)d.push(c);return d}else return g.getElementsByTagName(a)},id:function(b,f,g,e){var a=$(g),h=Selector.handlers;if(!b&&f==document)return a?[a]:[];if(b){if(e)if(e=="child"){for(var d=0,c;c=b[d];d++)if(a.parentNode==c)return [a]}else if(e=="descendant"){for(var d=0,c;c=b[d];d++)if(Element.descendantOf(a,c))return [a]}else if(e=="adjacent"){for(var d=0,c;c=b[d];d++)if(Selector.handlers.previousElementSibling(a)==c)return [a]}else b=h[e](b);for(var d=0,c;c=b[d];d++)if(c==a)return [a];return []}return a&&Element.descendantOf(a,f)?[a]:[]},className:function(a,d,c,b){if(a&&b)a=this[b](a);return Selector.handlers.byClassName(a,d,c)},byClassName:function(b,h,d){if(!b)b=Selector.handlers.descendant([h]);var g=" "+d+" ";for(var f=0,e=[],c,a;c=b[f];f++){a=c.className;if(a.length==0)continue;if(a==d||(" "+a+" ").include(g))e.push(c)}return e},attrPresence:function(d,f,e){var b=[];for(var c=0,a;a=d[c];c++)if(Element.hasAttribute(a,e))b.push(a);return b},attr:function(a,j,i,h,f){if(!a)a=j.getElementsByTagName("*");var g=Selector.operators[f],d=[];for(var e=0,b;b=a[e];e++){var c=Element.readAttribute(b,i);if(c===null)continue;if(g(c,h))d.push(b)}return d},pseudo:function(a,e,d,c,b){if(a&&b)a=this[b](a);if(!a)a=c.getElementsByTagName("*");return Selector.pseudos[e](a,d,c)}},pseudos:{"first-child":function(d){for(var c=0,b=[],a;a=d[c];c++){if(Selector.handlers.previousElementSibling(a))continue;b.push(a)}return b},"last-child":function(d){for(var c=0,b=[],a;a=d[c];c++){if(Selector.handlers.nextElementSibling(a))continue;b.push(a)}return b},"only-child":function(e){var c=Selector.handlers;for(var d=0,b=[],a;a=e[d];d++)if(!c.previousElementSibling(a)&&!c.nextElementSibling(a))b.push(a);return b},"nth-child":function(b,a,c){return Selector.pseudos.nth(b,a,c)},"nth-last-child":function(b,a,c){return Selector.pseudos.nth(b,a,c,true)},"nth-of-type":function(b,a,c){return Selector.pseudos.nth(b,a,c,false,true)},"nth-last-of-type":function(b,a,c){return Selector.pseudos.nth(b,a,c,true,true)},"first-of-type":function(a,c,b){return Selector.pseudos.nth(a,"1",b,false,true)},"last-of-type":function(a,c,b){return Selector.pseudos.nth(a,"1",b,true,true)},"only-of-type":function(d,a,b){var c=Selector.pseudos;return c["last-of-type"](c["first-of-type"](d,a,b),a,b)},getIndices:function(b,a,c){if(b==0)return a>0?[a]:[];return $R(1,c).inject([],function(d,c){if(0==(c-a)%b&&(c-a)/b>=0)d.push(c);return d})},nth:function(c,b,p,k,l){if(c.length==0)return [];if(b=="even")b="2n+0";if(b=="odd")b="2n+1";var f=Selector.handlers,g=[],i=[],d;f.mark(c);for(var e=0,a;a=c[e];e++)if(!a.parentNode._counted){f.index(a.parentNode,k,l);i.push(a.parentNode)}if(b.match(/^\d+$/)){b=Number(b);for(var e=0,a;a=c[e];e++)if(a.nodeIndex==b)g.push(a)}else if(d=b.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(d[1]=="-")d[1]=-1;var m=d[1]?Number(d[1]):1,n=d[2]?Number(d[2]):0,j=Selector.pseudos.getIndices(m,n,c.length);for(var e=0,a,o=j.length;a=c[e];e++)for(var h=0;h<o;h++)if(a.nodeIndex==j[h])g.push(a)}f.unmark(c);f.unmark(i);return g},empty:function(d){for(var c=0,b=[],a;a=d[c];c++){if(a.tagName=="!"||a.firstChild&&!a.innerHTML.match(/^\s*$/))continue;b.push(a)}return b},not:function(g,f,h){var d=Selector.handlers,i,j,b=(new Selector(f)).findElements(h);d.mark(b);for(var e=0,c=[],a;a=g[e];e++)if(!a._counted)c.push(a);d.unmark(b);return c},enabled:function(d){for(var c=0,b=[],a;a=d[c];c++)if(!a.disabled)b.push(a);return b},disabled:function(d){for(var c=0,b=[],a;a=d[c];c++)if(a.disabled)b.push(a);return b},checked:function(d){for(var c=0,b=[],a;a=d[c];c++)if(a.checked)b.push(a);return b}},operators:{"=":function(a,b){return a==b},"!=":function(a,b){return a!=b},"^=":function(a,b){return a.startsWith(b)},"$=":function(a,b){return a.endsWith(b)},"*=":function(a,b){return a.include(b)},"~=":function(a,b){return (" "+a+" ").include(" "+b+" ")},"|=":function(a,b){return ("-"+a.toUpperCase()+"-").include("-"+b.toUpperCase()+"-")}},matchElements:function(g,f){var b=(new Selector(f)).findElements(),d=Selector.handlers;d.mark(b);for(var e=0,c=[],a;a=g[e];e++)if(a._counted)c.push(a);d.unmark(b);return c},findElement:function(c,a,b){if(typeof a=="number"){b=a;a=false}return Selector.matchElements(c,a||"*")[b||0]},findChildElements:function(g,a){var h=a.join(","),a=[];h.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(b){a.push(b[1].strip())});var b=[],e=Selector.handlers;for(var c=0,f=a.length,d;c<f;c++){d=new Selector(a[c].strip());e.concat(b,d.findElements(g))}return f>1?e.unique(b):b}});function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(b,c){var a=b.inject({},function(a,c){if(!c.disabled&&c.name){var b=c.name,d=$(c).getValue();if(d!=null)if(b in a){if(a[b].constructor!=Array)a[b]=[a[b]];a[b].push(d)}else a[b]=d}return a});return c?a:Hash.toQueryString(a)}};Form.Methods={serialize:function(b,a){return Form.serializeElements(Form.getElements(b),a)},getElements:function(a){return $A($(a).getElementsByTagName("*")).inject([],function(a,b){if(Form.Element.Serializers[b.tagName.toLowerCase()])a.push(Element.extend(b));return a})},getInputs:function(d,a,e){d=$(d);var b=d.getElementsByTagName("input");if(!a&&!e)return $A(b).map(Element.extend);for(var f=0,g=[],h=b.length;f<h;f++){var c=b[f];if(a&&c.type!=a||e&&c.name!=e)continue;g.push(Element.extend(c))}return g},disable:function(a){a=$(a);Form.getElements(a).invoke("disable");return a},enable:function(a){a=$(a);Form.getElements(a).invoke("enable");return a},findFirstElement:function(a){return $(a).getElements().find(function(a){return a.type!="hidden"&&!a.disabled&&["input","select","textarea"].include(a.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(b,a){b=$(b),a=Object.clone(a||{});var c=a.parameters;a.parameters=b.serialize(true);if(c){if(typeof c=="string")c=c.toQueryParams();Object.extend(a.parameters,c)}if(b.hasAttribute("method")&&!a.method)a.method=b.method;return new Ajax.Request(b.readAttribute("action"),a)}};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);try{a.focus();if(a.select&&(a.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(a.type)))a.select()}catch(b){}return a},disable:function(a){a=$(a);a.blur();a.disabled=true;return a},enable:function(a){a=$(a);a.disabled=false;return a}};var Field=Form.Element,$F=Form.Element.Methods.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(a){var b=a.selectedIndex;return b>=0?this.optionValue(a.options[b]):null},selectMany:function(b){var d,c=b.length;if(!c)return null;for(var a=0,d=[];a<c;a++){var e=b.options[a];if(e.selected)d.push(this.optionValue(e))}return d},optionValue:function(a){return Element.extend(a).hasAttribute("value")?a.value:a.text}};Abstract.TimedObserver=function(){};Abstract.TimedObserver.prototype={initialize:function(c,a,b){this.frequency=a;this.element=$(c);this.callback=b;this.lastValue=this.getValue();this.registerCallback()},registerCallback:function(){setInterval(this.onTimerEvent.bind(this),this.frequency*1e3)},onTimerEvent:function(){var a=this.getValue(),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(b,a){this.element=$(b);this.callback=a;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))}}};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={};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(a,c,b,d){if(!this.observers)this.observers=[];if(a.addEventListener){this.observers.push([a,c,b,d]);a.addEventListener(c,b,d)}else if(a.attachEvent){this.observers.push([a,c,b,d]);a.attachEvent("on"+c,b)}},unloadCache:function(){if(!Event.observers)return;for(var a=0,b=Event.observers.length;a<b;a++){Event.stopObserving.apply(this,Event.observers[a]);Event.observers[a][0]=null}Event.observers=false},observe:function(a,c,d,b){a=$(a);b=b||false;if(c=="keypress"&&(Prototype.Browser.WebKit||a.attachEvent))c="keydown";Event._observeAndCache(a,c,d,b)},stopObserving:function(a,b,d,c){a=$(a);c=c||false;if(b=="keypress"&&(Prototype.Browser.WebKit||a.attachEvent))b="keydown";if(a.removeEventListener)a.removeEventListener(b,d,c);else if(a.detachEvent)try{a.detachEvent("on"+b,d)}catch(e){}}});if(Prototype.Browser.IE)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 c=0,b=0;do{c+=a.scrollTop||0;b+=a.scrollLeft||0;a=a.parentNode}while(a);return [b,c]},cumulativeOffset:function(a){var c=0,b=0;do{c+=a.offsetTop||0;b+=a.offsetLeft||0;a=a.offsetParent}while(a);return [b,c]},positionedOffset:function(a){var c=0,b=0;do{c+=a.offsetTop||0;b+=a.offsetLeft||0;a=a.offsetParent;if(a){if(a.tagName=="BODY")break;var d=Element.getStyle(a,"position");if(d=="relative"||d=="absolute")break}}while(a);return [b,c]},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(a,b,c){if(this.includeScrollOffsets)return this.withinIncludingScrolloffsets(a,b,c);this.xcomp=b;this.ycomp=c;this.offset=this.cumulativeOffset(a);return c>=this.offset[1]&&c<this.offset[1]+a.offsetHeight&&b>=this.offset[0]&&b<this.offset[0]+a.offsetWidth},withinIncludingScrolloffsets:function(a,c,d){var b=this.realOffset(a);this.xcomp=c+b[0]-this.deltaX;this.ycomp=d+b[1]-this.deltaY;this.offset=this.cumulativeOffset(a);return this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+a.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+a.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(d){var c=0,b=0,a=d;do{c+=a.offsetTop||0;b+=a.offsetLeft||0;if(a.offsetParent==document.body)if(Element.getStyle(a,"position")=="absolute")break}while(a=a.offsetParent);a=d;do if(!window.opera||a.tagName=="BODY"){c-=a.scrollTop||0;b-=a.scrollLeft||0}while(a=a.parentNode);return [b,c]},clone:function(c,a){var b=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});c=$(c);var f=Position.page(c);a=$(a);var d=[0,0],e=null;if(Element.getStyle(a,"position")=="absolute"){e=Position.offsetParent(a);d=Position.page(e)}if(e==document.body){d[0]-=document.body.offsetLeft;d[1]-=document.body.offsetTop}if(b.setLeft)a.style.left=f[0]-d[0]+b.offsetLeft+"px";if(b.setTop)a.style.top=f[1]-d[1]+b.offsetTop+"px";if(b.setWidth)a.style.width=c.offsetWidth+"px";if(b.setHeight)a.style.height=c.offsetHeight+"px"},absolutize:function(a){a=$(a);if(a.style.position=="absolute")return;Position.prepare();var b=Position.positionedOffset(a),d=b[1],c=b[0],f=a.clientWidth,e=a.clientHeight;a._originalLeft=c-parseFloat(a.style.left||0);a._originalTop=d-parseFloat(a.style.top||0);a._originalWidth=a.style.width;a._originalHeight=a.style.height;a.style.position="absolute";a.style.top=d+"px";a.style.left=c+"px";a.style.width=f+"px";a.style.height=e+"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),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(Prototype.Browser.WebKit)Position.cumulativeOffset=function(a){var c=0,b=0;do{c+=a.offsetTop||0;b+=a.offsetLeft||0;if(a.offsetParent==document.body)if(Element.getStyle(a,"position")=="absolute")break;a=a.offsetParent}while(a);return [b,c]};Element.addMethods()