Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prototype 1.7 + fix for conflict with Angular (minified)
function $A(iterable){if(!iterable)return[];if("toArray"in Object(iterable))return iterable.toArray();for(var length=iterable.length||0,results=new Array(length);length--;)results[length]=iterable[length];return results}function $w(string){return Object.isString(string)?(string=string.strip(),string?string.split(/\s+/):[]):[]}function $H(object){return new Hash(object)}function $R(start,end,exclusive){return new ObjectRange(start,end,exclusive)}function $(element){if(arguments.length>1){for(var i=0,elements=[],length=arguments.length;i<length;i++)elements.push($(arguments[i]));return elements}return Object.isString(element)&&(element=document.getElementById(element)),Element.extend(element)}var bindTemp=Function.prototype.bind;Function.prototype.bind=function(oThis){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var aArgs=Array.prototype.slice.call(arguments,1),fToBind=this,fNOP=function(){},fBound=function(){return fToBind.apply(this instanceof fNOP?this:oThis,aArgs.concat(Array.prototype.slice.call(arguments)))};return this.prototype&&(fNOP.prototype=this.prototype),fBound.prototype=new fNOP,fBound};var Prototype={Version:"1.7",Browser:function(){var ua=navigator.userAgent,isOpera="[object Opera]"==Object.prototype.toString.call(window.opera);return{IE:!!window.attachEvent&&!isOpera,Opera:isOpera,WebKit:ua.indexOf("AppleWebKit/")>-1,Gecko:ua.indexOf("Gecko")>-1&&-1===ua.indexOf("KHTML"),MobileSafari:/Apple.*Mobile/.test(ua)}}(),BrowserFeatures:{XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:function(){var constructor=window.Element||window.HTMLElement;return!(!constructor||!constructor.prototype)}(),SpecificElementExtensions:function(){if(void 0!==window.HTMLDivElement)return!0;var div=document.createElement("div"),form=document.createElement("form"),isSupported=!1;return div.__proto__&&div.__proto__!==form.__proto__&&(isSupported=!0),div=form=null,isSupported}()},ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(x){return x}};Prototype.Browser.MobileSafari&&(Prototype.BrowserFeatures.SpecificElementExtensions=!1);var Abstract={},Try={these:function(){for(var returnValue,i=0,length=arguments.length;i<length;i++){var lambda=arguments[i];try{returnValue=lambda();break}catch(e){}}return returnValue}},Class=function(){function subclass(){}function create(){function klass(){this.initialize.apply(this,arguments)}var parent=null,properties=$A(arguments);Object.isFunction(properties[0])&&(parent=properties.shift()),Object.extend(klass,Class.Methods),klass.superclass=parent,klass.subclasses=[],parent&&(subclass.prototype=parent.prototype,klass.prototype=new subclass,parent.subclasses.push(klass));for(var i=0,length=properties.length;i<length;i++)klass.addMethods(properties[i]);return klass.prototype.initialize||(klass.prototype.initialize=Prototype.emptyFunction),klass.prototype.constructor=klass,klass}function addMethods(source){var ancestor=this.superclass&&this.superclass.prototype,properties=Object.keys(source);IS_DONTENUM_BUGGY&&(source.toString!=Object.prototype.toString&&properties.push("toString"),source.valueOf!=Object.prototype.valueOf&&properties.push("valueOf"));for(var i=0,length=properties.length;i<length;i++){var property=properties[i],value=source[property];if(ancestor&&Object.isFunction(value)&&"$super"==value.argumentNames()[0]){var method=value;value=function(m){return function(){return ancestor[m].apply(this,arguments)}}(property).wrap(method),value.valueOf=method.valueOf.bind(method),value.toString=method.toString.bind(method)}this.prototype[property]=value}return this}var IS_DONTENUM_BUGGY=function(){for(var p in{toString:1})if("toString"===p)return!1;return!0}();return{create:create,Methods:{addMethods:addMethods}}}();!function(){function Type(o){switch(o){case null:return NULL_TYPE;case void 0:return UNDEFINED_TYPE}switch(typeof o){case"boolean":return BOOLEAN_TYPE;case"number":return NUMBER_TYPE;case"string":return STRING_TYPE}return OBJECT_TYPE}function extend(destination,source){for(var property in source)destination[property]=source[property];return destination}function inspect(object){try{return isUndefined(object)?"undefined":null===object?"null":object.inspect?object.inspect():String(object)}catch(e){if(e instanceof RangeError)return"...";throw e}}function toJSON(value){return Str("",{"":value},[])}function Str(key,holder,stack){var value=holder[key];Type(value)===OBJECT_TYPE&&"function"==typeof value.toJSON&&(value=value.toJSON(key));var _class=_toString.call(value);switch(_class){case NUMBER_CLASS:case BOOLEAN_CLASS:case STRING_CLASS:value=value.valueOf()}switch(value){case null:return"null";case!0:return"true";case!1:return"false"}switch(typeof value){case"string":return value.inspect(!0);case"number":return isFinite(value)?String(value):"null";case"object":for(var i=0,length=stack.length;i<length;i++)if(stack[i]===value)throw new TypeError;stack.push(value);var partial=[];if(_class===ARRAY_CLASS){for(var i=0,length=value.length;i<length;i++){var str=Str(i,value,stack);partial.push(void 0===str?"null":str)}partial="["+partial.join(",")+"]"}else{for(var keys=Object.keys(value),i=0,length=keys.length;i<length;i++){var key=keys[i],str=Str(key,value,stack);void 0!==str&&partial.push(key.inspect(!0)+":"+str)}partial="{"+partial.join(",")+"}"}return stack.pop(),partial}}function stringify(object){return JSON.stringify(object)}function toQueryString(object){return $H(object).toQueryString()}function toHTML(object){return object&&object.toHTML?object.toHTML():String.interpret(object)}function keys(object){if(Type(object)!==OBJECT_TYPE)throw new TypeError;var results=[];for(var property in object)object.hasOwnProperty(property)&&results.push(property);return results}function values(object){var results=[];for(var property in object)results.push(object[property]);return results}function clone(object){return extend({},object)}function isElement(object){return!(!object||1!=object.nodeType)}function isArray(object){return _toString.call(object)===ARRAY_CLASS}function isHash(object){return object instanceof Hash}function isFunction(object){return _toString.call(object)===FUNCTION_CLASS}function isString(object){return _toString.call(object)===STRING_CLASS}function isNumber(object){return _toString.call(object)===NUMBER_CLASS}function isDate(object){return _toString.call(object)===DATE_CLASS}function isUndefined(object){return void 0===object}var _toString=Object.prototype.toString,NULL_TYPE="Null",UNDEFINED_TYPE="Undefined",BOOLEAN_TYPE="Boolean",NUMBER_TYPE="Number",STRING_TYPE="String",OBJECT_TYPE="Object",FUNCTION_CLASS="[object Function]",BOOLEAN_CLASS="[object Boolean]",NUMBER_CLASS="[object Number]",STRING_CLASS="[object String]",ARRAY_CLASS="[object Array]",DATE_CLASS="[object Date]",NATIVE_JSON_STRINGIFY_SUPPORT=window.JSON&&"function"==typeof JSON.stringify&&"0"===JSON.stringify(0)&&void 0===JSON.stringify(Prototype.K);"function"==typeof Array.isArray&&Array.isArray([])&&!Array.isArray({})&&(isArray=Array.isArray),extend(Object,{extend:extend,inspect:inspect,toJSON:NATIVE_JSON_STRINGIFY_SUPPORT?stringify:toJSON,toQueryString:toQueryString,toHTML:toHTML,keys:Object.keys||keys,values:values,clone:clone,isElement:isElement,isArray:isArray,isHash:isHash,isFunction:isFunction,isString:isString,isNumber:isNumber,isDate:isDate,isUndefined:isUndefined})}(),Object.extend(Function.prototype,function(){function update(array,args){for(var arrayLength=array.length,length=args.length;length--;)array[arrayLength+length]=args[length];return array}function merge(array,args){return array=slice.call(array,0),update(array,args)}function argumentNames(){var names=this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g,"").replace(/\s+/g,"").split(",");return 1!=names.length||names[0]?names:[]}function bind(context){if(arguments.length<2&&Object.isUndefined(arguments[0]))return this;var __method=this,args=slice.call(arguments,1);return function(){var a=merge(args,arguments);return __method.apply(context,a)}}function bindAsEventListener(context){var __method=this,args=slice.call(arguments,1);return function(event){var a=update([event||window.event],args);return __method.apply(context,a)}}function curry(){if(!arguments.length)return this;var __method=this,args=slice.call(arguments,0);return function(){var a=merge(args,arguments);return __method.apply(this,a)}}function delay(timeout){var __method=this,args=slice.call(arguments,1);return timeout*=1e3,window.setTimeout(function(){return __method.apply(__method,args)},timeout)}function defer(){var args=update([.01],arguments);return this.delay.apply(this,args)}function wrap(wrapper){var __method=this;return function(){var a=update([__method.bind(this)],arguments);return wrapper.apply(this,a)}}function methodize(){if(this._methodized)return this._methodized;var __method=this;return this._methodized=function(){var a=update([this],arguments);return __method.apply(null,a)}}var slice=Array.prototype.slice;return{argumentNames:argumentNames,bind:bind,bindAsEventListener:bindAsEventListener,curry:curry,delay:delay,defer:defer,wrap:wrap,methodize:methodize}}()),function(proto){function toISOString(){return this.getUTCFullYear()+"-"+(this.getUTCMonth()+1).toPaddedString(2)+"-"+this.getUTCDate().toPaddedString(2)+"T"+this.getUTCHours().toPaddedString(2)+":"+this.getUTCMinutes().toPaddedString(2)+":"+this.getUTCSeconds().toPaddedString(2)+"Z"}function toJSON(){return this.toISOString()}proto.toISOString||(proto.toISOString=toISOString),proto.toJSON||(proto.toJSON=toJSON)}(Date.prototype),RegExp.prototype.match=RegExp.prototype.test,RegExp.escape=function(str){return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(callback,frequency){this.callback=callback,this.frequency=frequency,this.currentlyExecuting=!1,this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),1e3*this.frequency)},execute:function(){this.callback(this)},stop:function(){this.timer&&(clearInterval(this.timer),this.timer=null)},onTimerEvent:function(){if(!this.currentlyExecuting)try{this.currentlyExecuting=!0,this.execute(),this.currentlyExecuting=!1}catch(e){throw this.currentlyExecuting=!1,e}}});Object.extend(String,{interpret:function(value){return null==value?"":String(value)},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}}),Object.extend(String.prototype,function(){function prepareReplacement(replacement){if(Object.isFunction(replacement))return replacement;var template=new Template(replacement);return function(match){return template.evaluate(match)}}function gsub(pattern,replacement){var match,result="",source=this;if(replacement=prepareReplacement(replacement),Object.isString(pattern)&&(pattern=RegExp.escape(pattern)),!pattern.length&&!pattern.source)return(replacement=replacement(""))+source.split("").join(replacement)+replacement;for(;source.length>0;)(match=source.match(pattern))?(result+=source.slice(0,match.index),result+=String.interpret(replacement(match)),source=source.slice(match.index+match[0].length)):(result+=source,source="");return result}function sub(pattern,replacement,count){return replacement=prepareReplacement(replacement),count=Object.isUndefined(count)?1:count,this.gsub(pattern,function(match){return--count<0?match[0]:replacement(match)})}function scan(pattern,iterator){return this.gsub(pattern,iterator),String(this)}function truncate(length,truncation){return length=length||30,truncation=Object.isUndefined(truncation)?"...":truncation,this.length>length?this.slice(0,length-truncation.length)+truncation:String(this)}function strip(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}function stripTags(){return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi,"")}function stripScripts(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"")}function extractScripts(){var matchAll=new RegExp(Prototype.ScriptFragment,"img"),matchOne=new RegExp(Prototype.ScriptFragment,"im");return(this.match(matchAll)||[]).map(function(scriptTag){return(scriptTag.match(matchOne)||["",""])[1]})}function evalScripts(){return this.extractScripts().map(function(script){return eval(script)})}function escapeHTML(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function unescapeHTML(){return this.stripTags().replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function toQueryParams(separator){var match=this.strip().match(/([^?#]*)(#.*)?$/);return match?match[1].split(separator||"&").inject({},function(hash,pair){if((pair=pair.split("="))[0]){var key=decodeURIComponent(pair.shift()),value=pair.length>1?pair.join("="):pair[0];void 0!=value&&(value=decodeURIComponent(value)),key in hash?(Object.isArray(hash[key])||(hash[key]=[hash[key]]),hash[key].push(value)):hash[key]=value}return hash}):{}}function toArray(){return this.split("")}function succ(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)}function times(count){return count<1?"":new Array(count+1).join(this)}function camelize(){return this.replace(/-+(.)?/g,function(match,chr){return chr?chr.toUpperCase():""})}function capitalize(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()}function underscore(){return this.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/-/g,"_").toLowerCase()}function dasherize(){return this.replace(/_/g,"-")}function inspect(useDoubleQuotes){var escapedString=this.replace(/[\x00-\x1f\\]/g,function(character){return character in String.specialChar?String.specialChar[character]:"\\u00"+character.charCodeAt().toPaddedString(2,16)});return useDoubleQuotes?'"'+escapedString.replace(/"/g,'\\"')+'"':"'"+escapedString.replace(/'/g,"\\'")+"'"}function unfilterJSON(filter){return this.replace(filter||Prototype.JSONFilter,"$1")}function isJSON(){var str=this;return!str.blank()&&(str=str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@"),str=str.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]"),str=str.replace(/(?:^|:|,)(?:\s*\[)+/g,""),/^[\],:{}\s]*$/.test(str))}function evalJSON(sanitize){var json=this.unfilterJSON(),cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;cx.test(json)&&(json=json.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));try{if(!sanitize||json.isJSON())return eval("("+json+")")}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())}function parseJSON(){var json=this.unfilterJSON();return JSON.parse(json)}function include(pattern){return this.indexOf(pattern)>-1}function startsWith(pattern){return 0===this.lastIndexOf(pattern,0)}function endsWith(pattern){var d=this.length-pattern.length;return d>=0&&this.indexOf(pattern,d)===d}function empty(){return""==this}function blank(){return/^\s*$/.test(this)}function interpolate(object,pattern){return new Template(this,pattern).evaluate(object)}var NATIVE_JSON_PARSE_SUPPORT=window.JSON&&"function"==typeof JSON.parse&&JSON.parse('{"test": true}').test;return{gsub:gsub,sub:sub,scan:scan,truncate:truncate,strip:String.prototype.trim||strip,stripTags:stripTags,stripScripts:stripScripts,extractScripts:extractScripts,evalScripts:evalScripts,escapeHTML:escapeHTML,unescapeHTML:unescapeHTML,toQueryParams:toQueryParams,parseQuery:toQueryParams,toArray:toArray,succ:succ,times:times,camelize:camelize,capitalize:capitalize,underscore:underscore,dasherize:dasherize,inspect:inspect,unfilterJSON:unfilterJSON,isJSON:isJSON,evalJSON:NATIVE_JSON_PARSE_SUPPORT?parseJSON:evalJSON,include:include,startsWith:startsWith,endsWith:endsWith,empty:empty,blank:blank,interpolate:interpolate}}());var Template=Class.create({initialize:function(template,pattern){this.template=template.toString(),this.pattern=pattern||Template.Pattern},evaluate:function(object){return object&&Object.isFunction(object.toTemplateReplacements)&&(object=object.toTemplateReplacements()),this.template.gsub(this.pattern,function(match){if(null==object)return match[1]+"";var before=match[1]||"";if("\\"==before)return match[2];var ctx=object,expr=match[3],pattern=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;if(null==(match=pattern.exec(expr)))return before;for(;null!=match;){if(null==(ctx=ctx[match[1].startsWith("[")?match[2].replace(/\\\\]/g,"]"):match[1]])||""==match[3])break;expr=expr.substring("["==match[3]?match[1].length:match[0].length),match=pattern.exec(expr)}return before+String.interpret(ctx)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={},Enumerable=function(){function each(iterator,context){var index=0;try{this._each(function(value){iterator.call(context,value,index++)})}catch(e){if(e!=$break)throw e}return this}function eachSlice(number,iterator,context){var index=-number,slices=[],array=this.toArray();if(number<1)return array;for(;(index+=number)<array.length;)slices.push(array.slice(index,index+number));return slices.collect(iterator,context)}function all(iterator,context){iterator=iterator||Prototype.K;var result=!0;return this.each(function(value,index){if(!(result=result&&!!iterator.call(context,value,index)))throw $break}),result}function any(iterator,context){iterator=iterator||Prototype.K;var result=!1;return this.each(function(value,index){if(result=!!iterator.call(context,value,index))throw $break}),result}function collect(iterator,context){iterator=iterator||Prototype.K;var results=[];return this.each(function(value,index){results.push(iterator.call(context,value,index))}),results}function detect(iterator,context){var result;return this.each(function(value,index){if(iterator.call(context,value,index))throw result=value,$break}),result}function findAll(iterator,context){var results=[];return this.each(function(value,index){iterator.call(context,value,index)&&results.push(value)}),results}function grep(filter,iterator,context){iterator=iterator||Prototype.K;var results=[];return Object.isString(filter)&&(filter=new RegExp(RegExp.escape(filter))),this.each(function(value,index){filter.match(value)&&results.push(iterator.call(context,value,index))}),results}function include(object){if(Object.isFunction(this.indexOf)&&-1!=this.indexOf(object))return!0;var found=!1;return this.each(function(value){if(value==object)throw found=!0,$break}),found}function inGroupsOf(number,fillWith){return fillWith=Object.isUndefined(fillWith)?null:fillWith,this.eachSlice(number,function(slice){for(;slice.length<number;)slice.push(fillWith);return slice})}function inject(memo,iterator,context){return this.each(function(value,index){memo=iterator.call(context,memo,value,index)}),memo}function invoke(method){var args=$A(arguments).slice(1);return this.map(function(value){return value[method].apply(value,args)})}function max(iterator,context){iterator=iterator||Prototype.K;var result;return this.each(function(value,index){value=iterator.call(context,value,index),(null==result||value>=result)&&(result=value)}),result}function min(iterator,context){iterator=iterator||Prototype.K;var result;return this.each(function(value,index){value=iterator.call(context,value,index),(null==result||value<result)&&(result=value)}),result}function partition(iterator,context){iterator=iterator||Prototype.K;var trues=[],falses=[];return this.each(function(value,index){(iterator.call(context,value,index)?trues:falses).push(value)}),[trues,falses]}function pluck(property){var results=[];return this.each(function(value){results.push(value[property])}),results}function reject(iterator,context){var results=[];return this.each(function(value,index){iterator.call(context,value,index)||results.push(value)}),results}function sortBy(iterator,context){return this.map(function(value,index){return{value:value,criteria:iterator.call(context,value,index)}}).sort(function(left,right){var a=left.criteria,b=right.criteria;return a<b?-1:a>b?1:0}).pluck("value")}function toArray(){return this.map()}function zip(){var iterator=Prototype.K,args=$A(arguments);Object.isFunction(args.last())&&(iterator=args.pop());var collections=[this].concat(args).map($A);return this.map(function(value,index){return iterator(collections.pluck(index))})}function size(){return this.toArray().length}function inspect(){return"#<Enumerable:"+this.toArray().inspect()+">"}return{each:each,eachSlice:eachSlice,all:all,every:all,any:any,some:any,collect:collect,map:collect,detect:detect,findAll:findAll,select:findAll,filter:findAll,grep:grep,include:include,member:include,inGroupsOf:inGroupsOf,inject:inject,invoke:invoke,max:max,min:min,partition:partition,pluck:pluck,reject:reject,sortBy:sortBy,toArray:toArray,entries:toArray,zip:zip,size:size,inspect:inspect,find:detect}}();Array.from=$A,function(){function each(iterator,context){for(var i=0,length=this.length>>>0;i<length;i++)i in this&&iterator.call(context,this[i],i,this)}function clear(){return this.length=0,this}function first(){return this[0]}function last(){return this[this.length-1]}function compact(){return this.select(function(value){return null!=value})}function flatten(){return this.inject([],function(array,value){return Object.isArray(value)?array.concat(value.flatten()):(array.push(value),array)})}function without(){var values=slice.call(arguments,0);return this.select(function(value){return!values.include(value)})}function reverse(inline){return(!1===inline?this.toArray():this)._reverse()}function uniq(sorted){return this.inject([],function(array,value,index){return 0!=index&&(sorted?array.last()==value:array.include(value))||array.push(value),array})}function intersect(array){return this.uniq().findAll(function(item){return array.detect(function(value){return item===value})})}function clone(){return slice.call(this,0)}function size(){return this.length}function inspect(){return"["+this.map(Object.inspect).join(", ")+"]"}function indexOf(item,i){i||(i=0);var length=this.length;for(i<0&&(i=length+i);i<length;i++)if(this[i]===item)return i;return-1}function lastIndexOf(item,i){i=isNaN(i)?this.length:(i<0?this.length+i:i)+1;var n=this.slice(0,i).reverse().indexOf(item);return n<0?n:i-n-1}function concat(){for(var item,array=slice.call(this,0),i=0,length=arguments.length;i<length;i++)if(item=arguments[i],!Object.isArray(item)||"callee"in item)array.push(item);else for(var j=0,arrayLength=item.length;j<arrayLength;j++)array.push(item[j]);return array}var arrayProto=Array.prototype,slice=arrayProto.slice,_each=arrayProto.forEach;_each||(_each=each),Object.extend(arrayProto,Enumerable),arrayProto._reverse||(arrayProto._reverse=arrayProto.reverse),Object.extend(arrayProto,{_each:_each,clear:clear,first:first,last:last,compact:compact,flatten:flatten,without:without,reverse:reverse,uniq:uniq,intersect:intersect,clone:clone,toArray:clone,size:size,inspect:inspect}),function(){return 1!==[].concat(arguments)[0][0]}(1,2)&&(arrayProto.concat=concat),arrayProto.indexOf||(arrayProto.indexOf=indexOf),arrayProto.lastIndexOf||(arrayProto.lastIndexOf=lastIndexOf)}();var Hash=Class.create(Enumerable,function(){function initialize(object){this._object=Object.isHash(object)?object.toObject():Object.clone(object)}function _each(iterator){for(var key in this._object){var value=this._object[key],pair=[key,value];pair.key=key,pair.value=value,iterator(pair)}}function set(key,value){return this._object[key]=value}function get(key){if(this._object[key]!==Object.prototype[key])return this._object[key]}function unset(key){var value=this._object[key];return delete this._object[key],value}function toObject(){return Object.clone(this._object)}function keys(){return this.pluck("key")}function values(){return this.pluck("value")}function index(value){var match=this.detect(function(pair){return pair.value===value});return match&&match.key}function merge(object){return this.clone().update(object)}function update(object){return new Hash(object).inject(this,function(result,pair){return result.set(pair.key,pair.value),result})}function toQueryPair(key,value){return Object.isUndefined(value)?key:key+"="+encodeURIComponent(String.interpret(value))}function toQueryString(){return this.inject([],function(results,pair){var key=encodeURIComponent(pair.key),values=pair.value;if(values&&"object"==typeof values){if(Object.isArray(values)){for(var value,queryValues=[],i=0,len=values.length;i<len;i++)value=values[i],queryValues.push(toQueryPair(key,value));return results.concat(queryValues)}}else results.push(toQueryPair(key,values));return results}).join("&")}function inspect(){return"#<Hash:{"+this.map(function(pair){return pair.map(Object.inspect).join(": ")}).join(", ")+"}>"}function clone(){return new Hash(this)}return{initialize:initialize,_each:_each,set:set,get:get,unset:unset,toObject:toObject,toTemplateReplacements:toObject,keys:keys,values:values,index:index,merge:merge,update:update,toQueryString:toQueryString,inspect:inspect,toJSON:toObject,clone:clone}}());Hash.from=$H,Object.extend(Number.prototype,function(){function toColorPart(){return this.toPaddedString(2,16)}function succ(){return this+1}function times(iterator,context){return $R(0,this,!0).each(iterator,context),this}function toPaddedString(length,radix){var string=this.toString(radix||10);return"0".times(length-string.length)+string}function abs(){return Math.abs(this)}function round(){return Math.round(this)}function ceil(){return Math.ceil(this)}function floor(){return Math.floor(this)}return{toColorPart:toColorPart,succ:succ,times:times,toPaddedString:toPaddedString,abs:abs,round:round,ceil:ceil,floor:floor}}());var ObjectRange=Class.create(Enumerable,function(){function initialize(start,end,exclusive){this.start=start,this.end=end,this.exclusive=exclusive}function _each(iterator){for(var value=this.start;this.include(value);)iterator(value),value=value.succ()}function include(value){return!(value<this.start)&&(this.exclusive?value<this.end:value<=this.end)}return{initialize:initialize,_each:_each,include:include}}()),Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||!1},activeRequestCount:0};if(Ajax.Responders={responders:[],_each:function(iterator){this.responders._each(iterator)},register:function(responder){this.include(responder)||this.responders.push(responder)},unregister:function(responder){this.responders=this.responders.without(responder)},dispatch:function(callback,request,transport,json){this.each(function(responder){if(Object.isFunction(responder[callback]))try{responder[callback].apply(responder,[request,transport,json])}catch(e){}})}},Object.extend(Ajax.Responders,Enumerable),Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}}),Ajax.Base=Class.create({initialize:function(options){this.options={method:"post",asynchronous:!0,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:"",evalJSON:!0,evalJS:!0},Object.extend(this.options,options||{}),this.options.method=this.options.method.toLowerCase(),Object.isHash(this.options.parameters)&&(this.options.parameters=this.options.parameters.toObject())}}),Ajax.Request=Class.create(Ajax.Base,{_complete:!1,initialize:function($super,url,options){$super(options),this.transport=Ajax.getTransport(),this.request(url)},request:function(url){this.url=url,this.method=this.options.method;var params=Object.isString(this.options.parameters)?this.options.parameters:Object.toQueryString(this.options.parameters);["get","post"].include(this.method)||(params+=(params?"&":"")+"_method="+this.method,this.method="post"),params&&"get"===this.method&&(this.url+=(this.url.include("?")?"&":"?")+params),this.parameters=params.toQueryParams();try{var response=new Ajax.Response(this);this.options.onCreate&&this.options.onCreate(response),Ajax.Responders.dispatch("onCreate",this,response),this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous),this.options.asynchronous&&this.respondToReadyState.bind(this).defer(1),this.transport.onreadystatechange=this.onStateChange.bind(this),this.setRequestHeaders(),this.body="post"==this.method?this.options.postBody||params:null,this.transport.send(this.body),!this.options.asynchronous&&this.transport.overrideMimeType&&this.onStateChange()}catch(e){this.dispatchException(e)}},onStateChange:function(){var readyState=this.transport.readyState;readyState>1&&(4!=readyState||!this._complete)&&this.respondToReadyState(this.transport.readyState)},setRequestHeaders:function(){var headers={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if("post"==this.method&&(headers["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:""),this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005&&(headers.Connection="close")),"object"==typeof this.options.requestHeaders){var extras=this.options.requestHeaders;if(Object.isFunction(extras.push))for(var i=0,length=extras.length;i<length;i+=2)headers[extras[i]]=extras[i+1];else $H(extras).each(function(pair){headers[pair.key]=pair.value})}for(var name in headers)this.transport.setRequestHeader(name,headers[name])},success:function(){var status=this.getStatus();return!status||status>=200&&status<300||304==status},getStatus:function(){try{return 1223===this.transport.status?204:this.transport.status||0}catch(e){return 0}},respondToReadyState:function(readyState){var state=Ajax.Request.Events[readyState],response=new Ajax.Response(this);if("Complete"==state){try{this._complete=!0,(this.options["on"+response.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(response,response.headerJSON)}catch(e){this.dispatchException(e)}var contentType=response.getHeader("Content-type");("force"==this.options.evalJS||this.options.evalJS&&this.isSameOrigin()&&contentType&&contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))&&this.evalResponse()}try{(this.options["on"+state]||Prototype.emptyFunction)(response,response.headerJSON),Ajax.Responders.dispatch("on"+state,this,response,response.headerJSON)}catch(e){this.dispatchException(e)}"Complete"==state&&(this.transport.onreadystatechange=Prototype.emptyFunction)},isSameOrigin:function(){var m=this.url.match(/^\s*https?:\/\/[^\/]*/);return!m||m[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:document.domain,port:location.port?":"+location.port:""})},getHeader:function(name){try{return this.transport.getResponseHeader(name)||null}catch(e){return null}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(exception){(this.options.onException||Prototype.emptyFunction)(this,exception),Ajax.Responders.dispatch("onException",this,exception)}}),Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"],Ajax.Response=Class.create({initialize:function(request){this.request=request;var transport=this.transport=request.transport,readyState=this.readyState=transport.readyState;if((readyState>2&&!Prototype.Browser.IE||4==readyState)&&(this.status=this.getStatus(),this.statusText=this.getStatusText(),this.responseText=String.interpret(transport.responseText),this.headerJSON=this._getHeaderJSON()),4==readyState){var xml=transport.responseXML;this.responseXML=Object.isUndefined(xml)?null:xml,this.responseJSON=this._getResponseJSON()}},status:0,statusText:"",getStatus:Ajax.Request.prototype.getStatus,
getStatusText:function(){try{return this.transport.statusText||""}catch(e){return""}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(e){return null}},getResponseHeader:function(name){return this.transport.getResponseHeader(name)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var json=this.getHeader("X-JSON");if(!json)return null;json=decodeURIComponent(escape(json));try{return json.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(e){this.request.dispatchException(e)}},_getResponseJSON:function(){var options=this.request.options;if(!options.evalJSON||"force"!=options.evalJSON&&!(this.getHeader("Content-type")||"").include("application/json")||this.responseText.blank())return null;try{return this.responseText.evalJSON(options.sanitizeJSON||!this.request.isSameOrigin())}catch(e){this.request.dispatchException(e)}}}),Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,container,url,options){this.container={success:container.success||container,failure:container.failure||(container.success?null:container)},options=Object.clone(options);var onComplete=options.onComplete;options.onComplete=function(response,json){this.updateContent(response.responseText),Object.isFunction(onComplete)&&onComplete(response,json)}.bind(this),$super(url,options)},updateContent:function(responseText){var receiver=this.container[this.success()?"success":"failure"],options=this.options;if(options.evalScripts||(responseText=responseText.stripScripts()),receiver=$(receiver))if(options.insertion)if(Object.isString(options.insertion)){var insertion={};insertion[options.insertion]=responseText,receiver.insert(insertion)}else options.insertion(receiver,responseText);else receiver.update(responseText)}}),Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,container,url,options){$super(options),this.onComplete=this.options.onComplete,this.frequency=this.options.frequency||2,this.decay=this.options.decay||1,this.updater={},this.container=container,this.url=url,this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this),this.onTimerEvent()},stop:function(){this.updater.options.onComplete=void 0,clearTimeout(this.timer),(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(response){this.options.decay&&(this.decay=response.responseText==this.lastText?this.decay*this.options.decay:1,this.lastText=response.responseText),this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}}),Prototype.BrowserFeatures.XPath&&(document._getElementsByXPath=function(expression,parentElement){for(var results=[],query=document.evaluate(expression,$(parentElement)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),i=0,length=query.snapshotLength;i<length;i++)results.push(Element.extend(query.snapshotItem(i)));return results}),!Node)var Node={};Node.ELEMENT_NODE||Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12}),function(global){function shouldUseCache(tagName,attributes){return"select"!==tagName&&!("type"in attributes)}var HAS_EXTENDED_CREATE_ELEMENT_SYNTAX=function(){try{var el=document.createElement('<input name="x">');return"input"===el.tagName.toLowerCase()&&"x"===el.name}catch(err){return!1}}(),element=global.Element;global.Element=function(tagName,attributes){attributes=attributes||{},tagName=tagName.toLowerCase();var cache=Element.cache;if(HAS_EXTENDED_CREATE_ELEMENT_SYNTAX&&attributes.name)return tagName="<"+tagName+' name="'+attributes.name+'">',delete attributes.name,Element.writeAttribute(document.createElement(tagName),attributes);cache[tagName]||(cache[tagName]=Element.extend(document.createElement(tagName)));var node=shouldUseCache(tagName,attributes)?cache[tagName].cloneNode(!1):document.createElement(tagName);return Element.writeAttribute(node,attributes)},Object.extend(global.Element,element||{}),element&&(global.Element.prototype=element.prototype)}(this),Element.idCounter=1,Element.cache={},Element._purgeElement=function(element){var uid=element._prototypeUID;uid&&(Element.stopObserving(element),element._prototypeUID=void 0,delete Element.Storage[uid])},Element.Methods={visible:function(element){return"none"!=$(element).style.display},toggle:function(element){return element=$(element),Element[Element.visible(element)?"hide":"show"](element),element},hide:function(element){return element=$(element),element.style.display="none",element},show:function(element){return element=$(element),element.style.display="",element},remove:function(element){return element=$(element),element.parentNode.removeChild(element),element},update:function(){function update(element,content){element=$(element);for(var purgeElement=Element._purgeElement,descendants=element.getElementsByTagName("*"),i=descendants.length;i--;)purgeElement(descendants[i]);if(content&&content.toElement&&(content=content.toElement()),Object.isElement(content))return element.update().insert(content);content=Object.toHTML(content);var tagName=element.tagName.toUpperCase();if("SCRIPT"===tagName&&SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING)return element.text=content,element;if(ANY_INNERHTML_BUGGY)if(tagName in Element._insertionTranslations.tags){for(;element.firstChild;)element.removeChild(element.firstChild);Element._getContentFromAnonymousElement(tagName,content.stripScripts()).each(function(node){element.appendChild(node)})}else if(LINK_ELEMENT_INNERHTML_BUGGY&&Object.isString(content)&&content.indexOf("<link")>-1){for(;element.firstChild;)element.removeChild(element.firstChild);var nodes=Element._getContentFromAnonymousElement(tagName,content.stripScripts(),!0);nodes.each(function(node){element.appendChild(node)})}else element.innerHTML=content.stripScripts();else element.innerHTML=content.stripScripts();return content.evalScripts.bind(content).defer(),element}var SELECT_ELEMENT_INNERHTML_BUGGY=function(){var el=document.createElement("select"),isBuggy=!0;return el.innerHTML='<option value="test">test</option>',el.options&&el.options[0]&&(isBuggy="OPTION"!==el.options[0].nodeName.toUpperCase()),el=null,isBuggy}(),TABLE_ELEMENT_INNERHTML_BUGGY=function(){try{var el=document.createElement("table");if(el&&el.tBodies){el.innerHTML="<tbody><tr><td>test</td></tr></tbody>";var isBuggy=void 0===el.tBodies[0];return el=null,isBuggy}}catch(e){return!0}}(),LINK_ELEMENT_INNERHTML_BUGGY=function(){try{var el=document.createElement("div");el.innerHTML="<link>";var isBuggy=0===el.childNodes.length;return el=null,isBuggy}catch(e){return!0}}(),ANY_INNERHTML_BUGGY=SELECT_ELEMENT_INNERHTML_BUGGY||TABLE_ELEMENT_INNERHTML_BUGGY||LINK_ELEMENT_INNERHTML_BUGGY,SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING=function(){var s=document.createElement("script"),isBuggy=!1;try{s.appendChild(document.createTextNode("")),isBuggy=!s.firstChild||s.firstChild&&3!==s.firstChild.nodeType}catch(e){isBuggy=!0}return s=null,isBuggy}();return update}(),replace:function(element,content){if(element=$(element),content&&content.toElement)content=content.toElement();else if(!Object.isElement(content)){content=Object.toHTML(content);var range=element.ownerDocument.createRange();range.selectNode(element),content.evalScripts.bind(content).defer(),content=range.createContextualFragment(content.stripScripts())}return element.parentNode.replaceChild(content,element),element},insert:function(element,insertions){element=$(element),(Object.isString(insertions)||Object.isNumber(insertions)||Object.isElement(insertions)||insertions&&(insertions.toElement||insertions.toHTML))&&(insertions={bottom:insertions});var content,insert,tagName,childNodes;for(var position in insertions)content=insertions[position],position=position.toLowerCase(),insert=Element._insertionTranslations[position],content&&content.toElement&&(content=content.toElement()),Object.isElement(content)?insert(element,content):(content=Object.toHTML(content),tagName=("before"==position||"after"==position?element.parentNode:element).tagName.toUpperCase(),childNodes=Element._getContentFromAnonymousElement(tagName,content.stripScripts()),"top"!=position&&"after"!=position||childNodes.reverse(),childNodes.each(insert.curry(element)),content.evalScripts.bind(content).defer());return element},wrap:function(element,wrapper,attributes){return element=$(element),Object.isElement(wrapper)?$(wrapper).writeAttribute(attributes||{}):wrapper=Object.isString(wrapper)?new Element(wrapper,attributes):new Element("div",wrapper),element.parentNode&&element.parentNode.replaceChild(wrapper,element),wrapper.appendChild(element),wrapper},inspect:function(element){element=$(element);var result="<"+element.tagName.toLowerCase();return $H({id:"id",className:"class"}).each(function(pair){var property=pair.first(),attribute=pair.last(),value=(element[property]||"").toString();value&&(result+=" "+attribute+"="+value.inspect(!0))}),result+">"},recursivelyCollect:function(element,property,maximumLength){element=$(element),maximumLength=maximumLength||-1;for(var elements=[];(element=element[property])&&(1==element.nodeType&&elements.push(Element.extend(element)),elements.length!=maximumLength););return elements},ancestors:function(element){return Element.recursivelyCollect(element,"parentNode")},descendants:function(element){return Element.select(element,"*")},firstDescendant:function(element){for(element=$(element).firstChild;element&&1!=element.nodeType;)element=element.nextSibling;return $(element)},immediateDescendants:function(element){for(var results=[],child=$(element).firstChild;child;)1===child.nodeType&&results.push(Element.extend(child)),child=child.nextSibling;return results},previousSiblings:function(element,maximumLength){return Element.recursivelyCollect(element,"previousSibling")},nextSiblings:function(element){return Element.recursivelyCollect(element,"nextSibling")},siblings:function(element){return element=$(element),Element.previousSiblings(element).reverse().concat(Element.nextSiblings(element))},match:function(element,selector){return element=$(element),Object.isString(selector)?Prototype.Selector.match(element,selector):selector.match(element)},up:function(element,expression,index){if(element=$(element),1==arguments.length)return $(element.parentNode);var ancestors=Element.ancestors(element);return Object.isNumber(expression)?ancestors[expression]:Prototype.Selector.find(ancestors,expression,index)},down:function(element,expression,index){return element=$(element),1==arguments.length?Element.firstDescendant(element):Object.isNumber(expression)?Element.descendants(element)[expression]:Element.select(element,expression)[index||0]},previous:function(element,expression,index){return element=$(element),Object.isNumber(expression)&&(index=expression,expression=!1),Object.isNumber(index)||(index=0),expression?Prototype.Selector.find(element.previousSiblings(),expression,index):element.recursivelyCollect("previousSibling",index+1)[index]},next:function(element,expression,index){if(element=$(element),Object.isNumber(expression)&&(index=expression,expression=!1),Object.isNumber(index)||(index=0),expression)return Prototype.Selector.find(element.nextSiblings(),expression,index);Object.isNumber(index);return element.recursivelyCollect("nextSibling",index+1)[index]},select:function(element){element=$(element);var expressions=Array.prototype.slice.call(arguments,1).join(", ");return Prototype.Selector.select(expressions,element)},adjacent:function(element){element=$(element);var expressions=Array.prototype.slice.call(arguments,1).join(", ");return Prototype.Selector.select(expressions,element.parentNode).without(element)},identify:function(element){element=$(element);var id=Element.readAttribute(element,"id");if(id)return id;do{id="anonymous_element_"+Element.idCounter++}while($(id));return Element.writeAttribute(element,"id",id),id},readAttribute:function(element,name){if(element=$(element),Prototype.Browser.IE){var t=Element._attributeTranslations.read;if(t.values[name])return t.values[name](element,name);if(t.names[name]&&(name=t.names[name]),name.include(":"))return element.attributes&&element.attributes[name]?element.attributes[name].value:null}return element.getAttribute(name)},writeAttribute:function(element,name,value){element=$(element);var attributes={},t=Element._attributeTranslations.write;"object"==typeof name?attributes=name:attributes[name]=!!Object.isUndefined(value)||value;for(var attr in attributes)name=t.names[attr]||attr,value=attributes[attr],t.values[attr]&&(name=t.values[attr](element,value)),!1===value||null===value?element.removeAttribute(name):!0===value?element.setAttribute(name,name):element.setAttribute(name,value);return element},getHeight:function(element){return Element.getDimensions(element).height},getWidth:function(element){return Element.getDimensions(element).width},classNames:function(element){return new Element.ClassNames(element)},hasClassName:function(element,className){if(element=$(element)){var elementClassName=element.className;return elementClassName.length>0&&(elementClassName==className||new RegExp("(^|\\s)"+className+"(\\s|$)").test(elementClassName))}},addClassName:function(element,className){if(element=$(element))return Element.hasClassName(element,className)||(element.className+=(element.className?" ":"")+className),element},removeClassName:function(element,className){if(element=$(element))return element.className=element.className.replace(new RegExp("(^|\\s+)"+className+"(\\s+|$)")," ").strip(),element},toggleClassName:function(element,className){if(element=$(element))return Element[Element.hasClassName(element,className)?"removeClassName":"addClassName"](element,className)},cleanWhitespace:function(element){element=$(element);for(var node=element.firstChild;node;){var nextNode=node.nextSibling;3!=node.nodeType||/\S/.test(node.nodeValue)||element.removeChild(node),node=nextNode}return element},empty:function(element){return $(element).innerHTML.blank()},descendantOf:function(element,ancestor){if(element=$(element),ancestor=$(ancestor),element.compareDocumentPosition)return 8==(8&element.compareDocumentPosition(ancestor));if(ancestor.contains)return ancestor.contains(element)&&ancestor!==element;for(;element=element.parentNode;)if(element==ancestor)return!0;return!1},scrollTo:function(element){element=$(element);var pos=Element.cumulativeOffset(element);return window.scrollTo(pos[0],pos[1]),element},getStyle:function(element,style){element=$(element),style="float"==style?"cssFloat":style.camelize();var value=element.style[style];if(!value||"auto"==value){var css=document.defaultView.getComputedStyle(element,null);value=css?css[style]:null}return"opacity"==style?value?parseFloat(value):1:"auto"==value?null:value},getOpacity:function(element){return $(element).getStyle("opacity")},setStyle:function(element,styles){element=$(element);var elementStyle=element.style;if(Object.isString(styles))return element.style.cssText+=";"+styles,styles.include("opacity")?element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]):element;for(var property in styles)"opacity"==property?element.setOpacity(styles[property]):elementStyle["float"==property||"cssFloat"==property?Object.isUndefined(elementStyle.styleFloat)?"cssFloat":"styleFloat":property]=styles[property];return element},setOpacity:function(element,value){return element=$(element),element.style.opacity=1==value||""===value?"":value<1e-5?0:value,element},makePositioned:function(element){element=$(element);var pos=Element.getStyle(element,"position");return"static"!=pos&&pos||(element._madePositioned=!0,element.style.position="relative",Prototype.Browser.Opera&&(element.style.top=0,element.style.left=0)),element},undoPositioned:function(element){return element=$(element),element._madePositioned&&(element._madePositioned=void 0,element.style.position=element.style.top=element.style.left=element.style.bottom=element.style.right=""),element},makeClipping:function(element){return element=$(element),element._overflow?element:(element._overflow=Element.getStyle(element,"overflow")||"auto","hidden"!==element._overflow&&(element.style.overflow="hidden"),element)},undoClipping:function(element){return element=$(element),element._overflow?(element.style.overflow="auto"==element._overflow?"":element._overflow,element._overflow=null,element):element},clonePosition:function(element,source){var options=Object.extend({setLeft:!0,setTop:!0,setWidth:!0,setHeight:!0,offsetTop:0,offsetLeft:0},arguments[2]||{});source=$(source);var p=Element.viewportOffset(source),delta=[0,0],parent=null;return element=$(element),"absolute"==Element.getStyle(element,"position")&&(parent=Element.getOffsetParent(element),delta=Element.viewportOffset(parent)),parent==document.body&&(delta[0]-=document.body.offsetLeft,delta[1]-=document.body.offsetTop),options.setLeft&&(element.style.left=p[0]-delta[0]+options.offsetLeft+"px"),options.setTop&&(element.style.top=p[1]-delta[1]+options.offsetTop+"px"),options.setWidth&&(element.style.width=source.offsetWidth+"px"),options.setHeight&&(element.style.height=source.offsetHeight+"px"),element}},Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants}),Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}},Prototype.Browser.Opera?(Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(proceed,element,style){switch(style){case"height":case"width":if(!Element.visible(element))return null;var dim=parseInt(proceed(element,style),10);if(dim!==element["offset"+style.capitalize()])return dim+"px";var properties;return properties="height"===style?["border-top-width","padding-top","padding-bottom","border-bottom-width"]:["border-left-width","padding-left","padding-right","border-right-width"],properties.inject(dim,function(memo,property){var val=proceed(element,property);return null===val?memo:memo-parseInt(val,10)})+"px";default:return proceed(element,style)}}),Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(proceed,element,attribute){return"title"===attribute?element.title:proceed(element,attribute)})):Prototype.Browser.IE?(Element.Methods.getStyle=function(element,style){element=$(element),style="float"==style||"cssFloat"==style?"styleFloat":style.camelize();var value=element.style[style];return!value&&element.currentStyle&&(value=element.currentStyle[style]),"opacity"==style?(value=(element.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/))&&value[1]?parseFloat(value[1])/100:1:"auto"==value?"width"!=style&&"height"!=style||"none"==element.getStyle("display")?null:element["offset"+style.capitalize()]+"px":value},Element.Methods.setOpacity=function(element,value){function stripAlpha(filter){return filter.replace(/alpha\([^\)]*\)/gi,"")}element=$(element);var currentStyle=element.currentStyle;(currentStyle&&!currentStyle.hasLayout||!currentStyle&&"normal"==element.style.zoom)&&(element.style.zoom=1);var filter=element.getStyle("filter"),style=element.style;return 1==value||""===value?((filter=stripAlpha(filter))?style.filter=filter:style.removeAttribute("filter"),element):(value<1e-5&&(value=0),style.filter=stripAlpha(filter)+"alpha(opacity="+100*value+")",element)},Element._attributeTranslations=function(){var classProp="className",forProp="for",el=document.createElement("div");return el.setAttribute(classProp,"x"),"x"!==el.className&&(el.setAttribute("class","x"),"x"===el.className&&(classProp="class")),el=null,el=document.createElement("label"),el.setAttribute(forProp,"x"),"x"!==el.htmlFor&&(el.setAttribute("htmlFor","x"),"x"===el.htmlFor&&(forProp="htmlFor")),el=null,{read:{names:{class:classProp,className:classProp,for:forProp,htmlFor:forProp},values:{_getAttr:function(element,attribute){return element.getAttribute(attribute)},_getAttr2:function(element,attribute){return element.getAttribute(attribute,2)},_getAttrNode:function(element,attribute){var node=element.getAttributeNode(attribute);return node?node.value:""},_getEv:function(){var f,el=document.createElement("div");el.onclick=Prototype.emptyFunction;var value=el.getAttribute("onclick");return String(value).indexOf("{")>-1?f=function(element,attribute){return(attribute=element.getAttribute(attribute))?(attribute=attribute.toString(),attribute=attribute.split("{")[1],attribute=attribute.split("}")[0],attribute.strip()):null}:""===value&&(f=function(element,attribute){return attribute=element.getAttribute(attribute),attribute?attribute.strip():null}),el=null,f}(),_flag:function(element,attribute){return $(element).hasAttribute(attribute)?attribute:null},style:function(element){return element.style.cssText.toLowerCase()},title:function(element){return element.title}}}}}(),Element._attributeTranslations.write={names:Object.extend({cellpadding:"cellPadding",cellspacing:"cellSpacing"},Element._attributeTranslations.read.names),values:{checked:function(element,value){element.checked=!!value},style:function(element,value){element.style.cssText=value||""}}},Element._attributeTranslations.has={},$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc frameBorder").each(function(attr){Element._attributeTranslations.write.names[attr.toLowerCase()]=attr,Element._attributeTranslations.has[attr.toLowerCase()]=attr}),function(v){Object.extend(v,{href:v._getAttr2,src:v._getAttr2,type:v._getAttr,action:v._getAttrNode,disabled:v._flag,checked:v._flag,readonly:v._flag,multiple:v._flag,onload:v._getEv,onunload:v._getEv,onclick:v._getEv,ondblclick:v._getEv,onmousedown:v._getEv,onmouseup:v._getEv,onmouseover:v._getEv,onmousemove:v._getEv,onmouseout:v._getEv,onfocus:v._getEv,onblur:v._getEv,onkeypress:v._getEv,onkeydown:v._getEv,onkeyup:v._getEv,onsubmit:v._getEv,onreset:v._getEv,onselect:v._getEv,onchange:v._getEv})}(Element._attributeTranslations.read.values),Prototype.BrowserFeatures.ElementExtensions&&function(){function _descendants(element){for(var node,nodes=element.getElementsByTagName("*"),results=[],i=0;node=nodes[i];i++)"!"!==node.tagName&&results.push(node);return results}Element.Methods.down=function(element,expression,index){return element=$(element),1==arguments.length?element.firstDescendant():Object.isNumber(expression)?_descendants(element)[expression]:Element.select(element,expression)[index||0]}}()):Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)?Element.Methods.setOpacity=function(element,value){return element=$(element),element.style.opacity=1==value?.999999:""===value?"":value<1e-5?0:value,element}:Prototype.Browser.WebKit&&(Element.Methods.setOpacity=function(element,value){if(element=$(element),element.style.opacity=1==value||""===value?"":value<1e-5?0:value,1==value)if("IMG"==element.tagName.toUpperCase()&&element.width)element.width++,element.width--;else try{var n=document.createTextNode(" ");element.appendChild(n),element.removeChild(n)}catch(e){}return element}),"outerHTML"in document.documentElement&&(Element.Methods.replace=function(element,content){if(element=$(element),content&&content.toElement&&(content=content.toElement()),Object.isElement(content))return element.parentNode.replaceChild(content,element),element;content=Object.toHTML(content);var parent=element.parentNode,tagName=parent.tagName.toUpperCase();if(Element._insertionTranslations.tags[tagName]){var nextSibling=element.next(),fragments=Element._getContentFromAnonymousElement(tagName,content.stripScripts());parent.removeChild(element),nextSibling?fragments.each(function(node){parent.insertBefore(node,nextSibling)}):fragments.each(function(node){parent.appendChild(node)})}else element.outerHTML=content.stripScripts();return content.evalScripts.bind(content).defer(),element}),Element._returnOffset=function(l,t){var result=[l,t];return result.left=l,result.top=t,result},Element._getContentFromAnonymousElement=function(tagName,html,force){var div=new Element("div"),t=Element._insertionTranslations.tags[tagName],workaround=!1;if(t?workaround=!0:force&&(workaround=!0,t=["","",0]),workaround){div.innerHTML="&nbsp;"+t[0]+html+t[1],div.removeChild(div.firstChild);for(var i=t[2];i--;)div=div.firstChild}else div.innerHTML=html;return $A(div.childNodes)},Element._insertionTranslations={before:function(element,node){element.parentNode.insertBefore(node,element)},top:function(element,node){element.insertBefore(node,element.firstChild)},bottom:function(element,node){element.appendChild(node)},after:function(element,node){element.parentNode.insertBefore(node,element.nextSibling)},tags:{TABLE:["<table>","</table>",1],TBODY:["<table><tbody>","</tbody></table>",2],TR:["<table><tbody><tr>","</tr></tbody></table>",3],TD:["<table><tbody><tr><td>","</td></tr></tbody></table>",4],SELECT:["<select>","</select>",1]}},function(){var tags=Element._insertionTranslations.tags;Object.extend(tags,{THEAD:tags.TBODY,TFOOT:tags.TBODY,TH:tags.TD})}(),Element.Methods.Simulated={hasAttribute:function(element,attribute){attribute=Element._attributeTranslations.has[attribute]||attribute;var node=$(element).getAttributeNode(attribute);return!(!node||!node.specified)}},Element.Methods.ByTag={},Object.extend(Element,Element.Methods),function(div){!Prototype.BrowserFeatures.ElementExtensions&&div.__proto__&&(window.HTMLElement={},window.HTMLElement.prototype=div.__proto__,Prototype.BrowserFeatures.ElementExtensions=!0),div=null}(document.createElement("div")),Element.extend=function(){function extendElementWith(element,methods){for(var property in methods){var value=methods[property];!Object.isFunction(value)||property in element||(element[property]=value.methodize())}}var HTMLOBJECTELEMENT_PROTOTYPE_BUGGY=function(tagName){if(void 0!==window.Element){var proto=window.Element.prototype;if(proto){var id="_"+(Math.random()+"").slice(2),el=document.createElement(tagName);proto[id]="x";var isBuggy="x"!==el[id];return delete proto[id],el=null,isBuggy}}return!1}("object");if(Prototype.BrowserFeatures.SpecificElementExtensions)return HTMLOBJECTELEMENT_PROTOTYPE_BUGGY?function(element){if(element&&void 0===element._extendedByPrototype){var t=element.tagName;t&&/^(?:object|applet|embed)$/i.test(t)&&(extendElementWith(element,Element.Methods),extendElementWith(element,Element.Methods.Simulated),extendElementWith(element,Element.Methods.ByTag[t.toUpperCase()]))}return element}:Prototype.K;var Methods={},ByTag=Element.Methods.ByTag,extend=Object.extend(function(element){if(!element||void 0!==element._extendedByPrototype||1!=element.nodeType||element==window)return element;var methods=Object.clone(Methods),tagName=element.tagName.toUpperCase();return ByTag[tagName]&&Object.extend(methods,ByTag[tagName]),extendElementWith(element,methods),element._extendedByPrototype=Prototype.emptyFunction,element},{refresh:function(){Prototype.BrowserFeatures.ElementExtensions||(Object.extend(Methods,Element.Methods),Object.extend(Methods,Element.Methods.Simulated))}});return extend.refresh(),extend}(),document.documentElement.hasAttribute?Element.hasAttribute=function(element,attribute){return element.hasAttribute(attribute)}:Element.hasAttribute=Element.Methods.Simulated.hasAttribute,Element.addMethods=function(methods){function extend(tagName){tagName=tagName.toUpperCase(),Element.Methods.ByTag[tagName]||(Element.Methods.ByTag[tagName]={}),Object.extend(Element.Methods.ByTag[tagName],methods)}function copy(methods,destination,onlyIfAbsent){onlyIfAbsent=onlyIfAbsent||!1;for(var property in methods){var value=methods[property];Object.isFunction(value)&&(onlyIfAbsent&&property in destination||(destination[property]=value.methodize()))}}var F=Prototype.BrowserFeatures,T=Element.Methods.ByTag;if(methods||(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),BUTTON:Object.clone(Form.Element.Methods)})),2==arguments.length){var tagName=methods;methods=arguments[1]}tagName?Object.isArray(tagName)?tagName.each(extend):extend(tagName):Object.extend(Element.Methods,methods||{});var elementPrototype=window.HTMLElement?HTMLElement.prototype:Element.prototype;if(F.ElementExtensions&&(copy(Element.Methods,elementPrototype),copy(Element.Methods.Simulated,elementPrototype,!0)),F.SpecificElementExtensions)for(var tag in Element.Methods.ByTag){var klass=function(tagName){var klass,trans={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(trans[tagName]&&(klass="HTML"+trans[tagName]+"Element"),window[klass])return window[klass];if(klass="HTML"+tagName+"Element",window[klass])return window[klass];if(klass="HTML"+tagName.capitalize()+"Element",window[klass])return window[klass];var element=document.createElement(tagName),proto=element.__proto__||element.constructor.prototype;return element=null,proto}(tag);Object.isUndefined(klass)||copy(T[tag],klass.prototype)}Object.extend(Element,Element.Methods),delete Element.ByTag,Element.extend.refresh&&Element.extend.refresh(),Element.cache={}},document.viewport={getDimensions:function(){return{width:this.getWidth(),height:this.getHeight()}},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}},function(viewport){function getRootElement(){return B.WebKit&&!doc.evaluate?document:B.Opera&&window.parseFloat(window.opera.version())<9.5?document.body:document.documentElement}function define(D){return element||(element=getRootElement()),property[D]="client"+D,viewport["get"+D]=function(){return element[property[D]]},viewport["get"+D]()}var element,B=Prototype.Browser,doc=document,property={};viewport.getWidth=define.curry("Width"),viewport.getHeight=define.curry("Height")}(document.viewport),Element.Storage={UID:1},Element.addMethods({getStorage:function(element){if(element=$(element)){var uid;return element===window?uid=0:(void 0===element._prototypeUID&&(element._prototypeUID=Element.Storage.UID++),uid=element._prototypeUID),Element.Storage[uid]||(Element.Storage[uid]=$H()),Element.Storage[uid]}},store:function(element,key,value){if(element=$(element))return 2===arguments.length?Element.getStorage(element).update(key):Element.getStorage(element).set(key,value),element},retrieve:function(element,key,defaultValue){if(element=$(element)){var hash=Element.getStorage(element),value=hash.get(key);return Object.isUndefined(value)&&(hash.set(key,defaultValue),value=defaultValue),value}},clone:function(element,deep){if(element=$(element)){var clone=element.cloneNode(deep);if(clone._prototypeUID=void 0,deep)for(var descendants=Element.select(clone,"*"),i=descendants.length;i--;)descendants[i]._prototypeUID=void 0;return Element.extend(clone)}},purge:function(element){if(element=$(element)){var purgeElement=Element._purgeElement;purgeElement(element);for(var descendants=element.getElementsByTagName("*"),i=descendants.length;i--;)purgeElement(descendants[i]);return null}}}),function(){function toDecimal(pctString){var match=pctString.match(/^(\d+)%?$/i);return match?Number(match[1])/100:null}
function getPixelValue(value,property,context){var element=null;if(Object.isElement(value)&&(element=value,value=element.getStyle(property)),null===value)return null;if(/^(?:-)?\d+(\.\d+)?(px)?$/i.test(value))return window.parseFloat(value);var isPercentage=value.include("%"),isViewport=context===document.viewport;if(/\d/.test(value)&&element&&element.runtimeStyle&&(!isPercentage||!isViewport)){var style=element.style.left,rStyle=element.runtimeStyle.left;return element.runtimeStyle.left=element.currentStyle.left,element.style.left=value||0,value=element.style.pixelLeft,element.style.left=style,element.runtimeStyle.left=rStyle,value}if(element&&isPercentage){context=context||element.parentNode;var decimal=toDecimal(value),whole=null,isHorizontal=(element.getStyle("position"),property.include("left")||property.include("right")||property.include("width")),isVertical=property.include("top")||property.include("bottom")||property.include("height");return context===document.viewport?isHorizontal?whole=document.viewport.getWidth():isVertical&&(whole=document.viewport.getHeight()):isHorizontal?whole=$(context).measure("width"):isVertical&&(whole=$(context).measure("height")),null===whole?0:whole*decimal}return 0}function isDisplayed(element){for(;element&&element.parentNode;){if("none"===element.getStyle("display"))return!1;element=$(element.parentNode)}return!0}function cssNameFor(key){return key.include("border")&&(key+="-width"),key.camelize()}function getLayout(element,preCompute){return new Element.Layout(element,preCompute)}function measure(element,property){return $(element).getLayout().get(property)}function getDimensions(element){element=$(element);var display=Element.getStyle(element,"display");if(display&&"none"!==display)return{width:element.offsetWidth,height:element.offsetHeight};var style=element.style,originalStyles={visibility:style.visibility,position:style.position,display:style.display},newStyles={visibility:"hidden",display:"block"};"fixed"!==originalStyles.position&&(newStyles.position="absolute"),Element.setStyle(element,newStyles);var dimensions={width:element.offsetWidth,height:element.offsetHeight};return Element.setStyle(element,originalStyles),dimensions}function getOffsetParent(element){if(element=$(element),isDocument(element)||isDetached(element)||isBody(element)||isHtml(element))return $(document.body);if("inline"!==Element.getStyle(element,"display")&&element.offsetParent)return $(element.offsetParent);for(;(element=element.parentNode)&&element!==document.body;)if("static"!==Element.getStyle(element,"position"))return $(isHtml(element)?document.body:element);return $(document.body)}function cumulativeOffset(element){element=$(element);var valueT=0,valueL=0;if(element.parentNode)do{valueT+=element.offsetTop||0,valueL+=element.offsetLeft||0,element=element.offsetParent}while(element);return new Element.Offset(valueL,valueT)}function positionedOffset(element){element=$(element);var layout=element.getLayout(),valueT=0,valueL=0;do{if(valueT+=element.offsetTop||0,valueL+=element.offsetLeft||0,element=element.offsetParent){if(isBody(element))break;var p=Element.getStyle(element,"position");if("static"!==p)break}}while(element);return valueL-=layout.get("margin-top"),valueT-=layout.get("margin-left"),new Element.Offset(valueL,valueT)}function cumulativeScrollOffset(element){var valueT=0,valueL=0;do{valueT+=element.scrollTop||0,valueL+=element.scrollLeft||0,element=element.parentNode}while(element);return new Element.Offset(valueL,valueT)}function viewportOffset(forElement){element=$(element);var valueT=0,valueL=0,docBody=document.body,element=forElement;do{if(valueT+=element.offsetTop||0,valueL+=element.offsetLeft||0,element.offsetParent==docBody&&"absolute"==Element.getStyle(element,"position"))break}while(element=element.offsetParent);element=forElement;do{element!=docBody&&(valueT-=element.scrollTop||0,valueL-=element.scrollLeft||0)}while(element=element.parentNode);return new Element.Offset(valueL,valueT)}function absolutize(element){if(element=$(element),"absolute"===Element.getStyle(element,"position"))return element;var offsetParent=getOffsetParent(element),eOffset=element.viewportOffset(),pOffset=offsetParent.viewportOffset(),offset=eOffset.relativeTo(pOffset),layout=element.getLayout();return element.store("prototype_absolutize_original_styles",{left:element.getStyle("left"),top:element.getStyle("top"),width:element.getStyle("width"),height:element.getStyle("height")}),element.setStyle({position:"absolute",top:offset.top+"px",left:offset.left+"px",width:layout.get("width")+"px",height:layout.get("height")+"px"}),element}function relativize(element){if(element=$(element),"relative"===Element.getStyle(element,"position"))return element;var originalStyles=element.retrieve("prototype_absolutize_original_styles");return originalStyles&&element.setStyle(originalStyles),element}function isBody(element){return"BODY"===element.nodeName.toUpperCase()}function isHtml(element){return"HTML"===element.nodeName.toUpperCase()}function isDocument(element){return element.nodeType===Node.DOCUMENT_NODE}function isDetached(element){return element!==document.body&&!Element.descendantOf(element,document.body)}var hasLayout=Prototype.K;"currentStyle"in document.documentElement&&(hasLayout=function(element){return element.currentStyle.hasLayout||(element.style.zoom=1),element}),Element.Layout=Class.create(Hash,{initialize:function($super,element,preCompute){$super(),this.element=$(element),Element.Layout.PROPERTIES.each(function(property){this._set(property,null)},this),preCompute&&(this._preComputing=!0,this._begin(),Element.Layout.PROPERTIES.each(this._compute,this),this._end(),this._preComputing=!1)},_set:function(property,value){return Hash.prototype.set.call(this,property,value)},set:function(property,value){throw"Properties of Element.Layout are read-only."},get:function($super,property){var value=$super(property);return null===value?this._compute(property):value},_begin:function(){if(!this._prepared){var element=this.element;if(isDisplayed(element))return void(this._prepared=!0);var originalStyles={position:element.style.position||"",width:element.style.width||"",visibility:element.style.visibility||"",display:element.style.display||""};element.store("prototype_original_styles",originalStyles);var position=element.getStyle("position"),width=element.getStyle("width");"0px"!==width&&null!==width||(element.style.display="block",width=element.getStyle("width"));var context="fixed"===position?document.viewport:element.parentNode;element.setStyle({position:"absolute",visibility:"hidden",display:"block"});var newWidth,positionedWidth=element.getStyle("width");if(width&&positionedWidth===width)newWidth=getPixelValue(element,"width",context);else if("absolute"===position||"fixed"===position)newWidth=getPixelValue(element,"width",context);else{var parent=element.parentNode,pLayout=$(parent).getLayout();newWidth=pLayout.get("width")-this.get("margin-left")-this.get("border-left")-this.get("padding-left")-this.get("padding-right")-this.get("border-right")-this.get("margin-right")}element.setStyle({width:newWidth+"px"}),this._prepared=!0}},_end:function(){var element=this.element,originalStyles=element.retrieve("prototype_original_styles");element.store("prototype_original_styles",null),element.setStyle(originalStyles),this._prepared=!1},_compute:function(property){var COMPUTATIONS=Element.Layout.COMPUTATIONS;if(!(property in COMPUTATIONS))throw"Property not found.";return this._set(property,COMPUTATIONS[property].call(this,this.element))},toObject:function(){var args=$A(arguments),keys=0===args.length?Element.Layout.PROPERTIES:args.join(" ").split(" "),obj={};return keys.each(function(key){if(Element.Layout.PROPERTIES.include(key)){var value=this.get(key);null!=value&&(obj[key]=value)}},this),obj},toHash:function(){var obj=this.toObject.apply(this,arguments);return new Hash(obj)},toCSS:function(){var args=$A(arguments),keys=0===args.length?Element.Layout.PROPERTIES:args.join(" ").split(" "),css={};return keys.each(function(key){if(Element.Layout.PROPERTIES.include(key)&&!Element.Layout.COMPOSITE_PROPERTIES.include(key)){var value=this.get(key);null!=value&&(css[cssNameFor(key)]=value+"px")}},this),css},inspect:function(){return"#<Element.Layout>"}}),Object.extend(Element.Layout,{PROPERTIES:$w("height width top left right bottom border-left border-right border-top border-bottom padding-left padding-right padding-top padding-bottom margin-top margin-bottom margin-left margin-right padding-box-width padding-box-height border-box-width border-box-height margin-box-width margin-box-height"),COMPOSITE_PROPERTIES:$w("padding-box-width padding-box-height margin-box-width margin-box-height border-box-width border-box-height"),COMPUTATIONS:{height:function(element){this._preComputing||this._begin();var bHeight=this.get("border-box-height");if(bHeight<=0)return this._preComputing||this._end(),0;var bTop=this.get("border-top"),bBottom=this.get("border-bottom"),pTop=this.get("padding-top"),pBottom=this.get("padding-bottom");return this._preComputing||this._end(),bHeight-bTop-bBottom-pTop-pBottom},width:function(element){this._preComputing||this._begin();var bWidth=this.get("border-box-width");if(bWidth<=0)return this._preComputing||this._end(),0;var bLeft=this.get("border-left"),bRight=this.get("border-right"),pLeft=this.get("padding-left"),pRight=this.get("padding-right");return this._preComputing||this._end(),bWidth-bLeft-bRight-pLeft-pRight},"padding-box-height":function(element){return this.get("height")+this.get("padding-top")+this.get("padding-bottom")},"padding-box-width":function(element){return this.get("width")+this.get("padding-left")+this.get("padding-right")},"border-box-height":function(element){this._preComputing||this._begin();var height=element.offsetHeight;return this._preComputing||this._end(),height},"border-box-width":function(element){this._preComputing||this._begin();var width=element.offsetWidth;return this._preComputing||this._end(),width},"margin-box-height":function(element){var bHeight=this.get("border-box-height"),mTop=this.get("margin-top"),mBottom=this.get("margin-bottom");return bHeight<=0?0:bHeight+mTop+mBottom},"margin-box-width":function(element){var bWidth=this.get("border-box-width"),mLeft=this.get("margin-left"),mRight=this.get("margin-right");return bWidth<=0?0:bWidth+mLeft+mRight},top:function(element){return element.positionedOffset().top},bottom:function(element){var offset=element.positionedOffset();return element.getOffsetParent().measure("height")-this.get("border-box-height")-offset.top},left:function(element){return element.positionedOffset().left},right:function(element){var offset=element.positionedOffset();return element.getOffsetParent().measure("width")-this.get("border-box-width")-offset.left},"padding-top":function(element){return getPixelValue(element,"paddingTop")},"padding-bottom":function(element){return getPixelValue(element,"paddingBottom")},"padding-left":function(element){return getPixelValue(element,"paddingLeft")},"padding-right":function(element){return getPixelValue(element,"paddingRight")},"border-top":function(element){return getPixelValue(element,"borderTopWidth")},"border-bottom":function(element){return getPixelValue(element,"borderBottomWidth")},"border-left":function(element){return getPixelValue(element,"borderLeftWidth")},"border-right":function(element){return getPixelValue(element,"borderRightWidth")},"margin-top":function(element){return getPixelValue(element,"marginTop")},"margin-bottom":function(element){return getPixelValue(element,"marginBottom")},"margin-left":function(element){return getPixelValue(element,"marginLeft")},"margin-right":function(element){return getPixelValue(element,"marginRight")}}}),"getBoundingClientRect"in document.documentElement&&Object.extend(Element.Layout.COMPUTATIONS,{right:function(element){var parent=hasLayout(element.getOffsetParent()),rect=element.getBoundingClientRect();return(parent.getBoundingClientRect().right-rect.right).round()},bottom:function(element){var parent=hasLayout(element.getOffsetParent()),rect=element.getBoundingClientRect();return(parent.getBoundingClientRect().bottom-rect.bottom).round()}}),Element.Offset=Class.create({initialize:function(left,top){this.left=left.round(),this.top=top.round(),this[0]=this.left,this[1]=this.top},relativeTo:function(offset){return new Element.Offset(this.left-offset.left,this.top-offset.top)},inspect:function(){return"#<Element.Offset left: #{left} top: #{top}>".interpolate(this)},toString:function(){return"[#{left}, #{top}]".interpolate(this)},toArray:function(){return[this.left,this.top]}}),Prototype.Browser.IE?(getOffsetParent=getOffsetParent.wrap(function(proceed,element){if(element=$(element),isDocument(element)||isDetached(element)||isBody(element)||isHtml(element))return $(document.body);var position=element.getStyle("position");if("static"!==position)return proceed(element);element.setStyle({position:"relative"});var value=proceed(element);return element.setStyle({position:position}),value}),positionedOffset=positionedOffset.wrap(function(proceed,element){if(element=$(element),!element.parentNode)return new Element.Offset(0,0);var position=element.getStyle("position");if("static"!==position)return proceed(element);var offsetParent=element.getOffsetParent();offsetParent&&"fixed"===offsetParent.getStyle("position")&&hasLayout(offsetParent),element.setStyle({position:"relative"});var value=proceed(element);return element.setStyle({position:position}),value})):Prototype.Browser.Webkit&&(cumulativeOffset=function(element){element=$(element);var valueT=0,valueL=0;do{if(valueT+=element.offsetTop||0,valueL+=element.offsetLeft||0,element.offsetParent==document.body&&"absolute"==Element.getStyle(element,"position"))break;element=element.offsetParent}while(element);return new Element.Offset(valueL,valueT)}),Element.addMethods({getLayout:getLayout,measure:measure,getDimensions:getDimensions,getOffsetParent:getOffsetParent,cumulativeOffset:cumulativeOffset,positionedOffset:positionedOffset,cumulativeScrollOffset:cumulativeScrollOffset,viewportOffset:viewportOffset,absolutize:absolutize,relativize:relativize}),"getBoundingClientRect"in document.documentElement&&Element.addMethods({viewportOffset:function(element){if(element=$(element),isDetached(element))return new Element.Offset(0,0);var rect=element.getBoundingClientRect(),docEl=document.documentElement;return new Element.Offset(rect.left-docEl.clientLeft,rect.top-docEl.clientTop)}})}(),window.$$=function(){var expression=$A(arguments).join(", ");return Prototype.Selector.select(expression,document)},Prototype.Selector=function(){function select(){throw new Error('Method "Prototype.Selector.select" must be defined.')}function match(){throw new Error('Method "Prototype.Selector.match" must be defined.')}function find(elements,expression,index){index=index||0;var i,match=Prototype.Selector.match,length=elements.length,matchIndex=0;for(i=0;i<length;i++)if(match(elements[i],expression)&&index==matchIndex++)return Element.extend(elements[i])}function extendElements(elements){for(var i=0,length=elements.length;i<length;i++)Element.extend(elements[i]);return elements}var K=Prototype.K;return{select:select,match:match,find:find,extendElements:Element.extend===K?K:extendElements,extendElement:Element.extend}}(),Prototype._original_property=window.Sizzle,function(){function dirNodeCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){for(var sibDir="previousSibling"==dir&&!isXML,i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){sibDir&&1===elem.nodeType&&(elem.sizcache=doneName,elem.sizset=i),elem=elem[dir];for(var match=!1;elem;){if(elem.sizcache===doneName){match=checkSet[elem.sizset];break}if(1!==elem.nodeType||isXML||(elem.sizcache=doneName,elem.sizset=i),elem.nodeName===cur){match=elem;break}elem=elem[dir]}checkSet[i]=match}}}function dirCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){for(var sibDir="previousSibling"==dir&&!isXML,i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){sibDir&&1===elem.nodeType&&(elem.sizcache=doneName,elem.sizset=i),elem=elem[dir];for(var match=!1;elem;){if(elem.sizcache===doneName){match=checkSet[elem.sizset];break}if(1===elem.nodeType)if(isXML||(elem.sizcache=doneName,elem.sizset=i),"string"!=typeof cur){if(elem===cur){match=!0;break}}else if(Sizzle.filter(cur,[elem]).length>0){match=elem;break}elem=elem[dir]}checkSet[i]=match}}}var chunker=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,done=0,toString=Object.prototype.toString,hasDuplicate=!1,baseHasDuplicate=!0;[0,0].sort(function(){return baseHasDuplicate=!1,0});var Sizzle=function(selector,context,results,seed){results=results||[];var origContext=context=context||document;if(1!==context.nodeType&&9!==context.nodeType)return[];if(!selector||"string"!=typeof selector)return results;for(var m,set,checkSet,extra,parts=[],prune=!0,contextXML=isXML(context),soFar=selector;null!==(chunker.exec(""),m=chunker.exec(soFar));)if(soFar=m[3],parts.push(m[1]),m[2]){extra=m[3];break}if(parts.length>1&&origPOS.exec(selector))if(2===parts.length&&Expr.relative[parts[0]])set=posProcess(parts[0]+parts[1],context);else for(set=Expr.relative[parts[0]]?[context]:Sizzle(parts.shift(),context);parts.length;)selector=parts.shift(),Expr.relative[selector]&&(selector+=parts.shift()),set=posProcess(selector,set);else{if(!seed&&parts.length>1&&9===context.nodeType&&!contextXML&&Expr.match.ID.test(parts[0])&&!Expr.match.ID.test(parts[parts.length-1])){var ret=Sizzle.find(parts.shift(),context,contextXML);context=ret.expr?Sizzle.filter(ret.expr,ret.set)[0]:ret.set[0]}if(context){var ret=seed?{expr:parts.pop(),set:makeArray(seed)}:Sizzle.find(parts.pop(),1!==parts.length||"~"!==parts[0]&&"+"!==parts[0]||!context.parentNode?context:context.parentNode,contextXML);for(set=ret.expr?Sizzle.filter(ret.expr,ret.set):ret.set,parts.length>0?checkSet=makeArray(set):prune=!1;parts.length;){var cur=parts.pop(),pop=cur;Expr.relative[cur]?pop=parts.pop():cur="",null==pop&&(pop=context),Expr.relative[cur](checkSet,pop,contextXML)}}else checkSet=parts=[]}if(checkSet||(checkSet=set),!checkSet)throw"Syntax error, unrecognized expression: "+(cur||selector);if("[object Array]"===toString.call(checkSet))if(prune)if(context&&1===context.nodeType)for(var i=0;null!=checkSet[i];i++)checkSet[i]&&(!0===checkSet[i]||1===checkSet[i].nodeType&&contains(context,checkSet[i]))&&results.push(set[i]);else for(var i=0;null!=checkSet[i];i++)checkSet[i]&&1===checkSet[i].nodeType&&results.push(set[i]);else results.push.apply(results,checkSet);else makeArray(checkSet,results);return extra&&(Sizzle(extra,origContext,results,seed),Sizzle.uniqueSort(results)),results};Sizzle.uniqueSort=function(results){if(sortOrder&&(hasDuplicate=baseHasDuplicate,results.sort(sortOrder),hasDuplicate))for(var i=1;i<results.length;i++)results[i]===results[i-1]&&results.splice(i--,1);return results},Sizzle.matches=function(expr,set){return Sizzle(expr,null,null,set)},Sizzle.find=function(expr,context,isXML){var set,match;if(!expr)return[];for(var i=0,l=Expr.order.length;i<l;i++){var match,type=Expr.order[i];if(match=Expr.leftMatch[type].exec(expr)){var left=match[1];if(match.splice(1,1),"\\"!==left.substr(left.length-1)&&(match[1]=(match[1]||"").replace(/\\/g,""),null!=(set=Expr.find[type](match,context,isXML)))){expr=expr.replace(Expr.match[type],"");break}}}return set||(set=context.getElementsByTagName("*")),{set:set,expr:expr}},Sizzle.filter=function(expr,set,inplace,not){for(var match,anyFound,old=expr,result=[],curLoop=set,isXMLFilter=set&&set[0]&&isXML(set[0]);expr&&set.length;){for(var type in Expr.filter)if(null!=(match=Expr.match[type].exec(expr))){var found,item,filter=Expr.filter[type];if(anyFound=!1,curLoop==result&&(result=[]),Expr.preFilter[type])if(match=Expr.preFilter[type](match,curLoop,inplace,result,not,isXMLFilter)){if(!0===match)continue}else anyFound=found=!0;if(match)for(var i=0;null!=(item=curLoop[i]);i++)if(item){found=filter(item,match,i,curLoop);var pass=not^!!found;inplace&&null!=found?pass?anyFound=!0:curLoop[i]=!1:pass&&(result.push(item),anyFound=!0)}if(void 0!==found){if(inplace||(curLoop=result),expr=expr.replace(Expr.match[type],""),!anyFound)return[];break}}if(expr==old){if(null==anyFound)throw"Syntax error, unrecognized expression: "+expr;break}old=expr}return curLoop};var Expr=Sizzle.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{class:"className",for:"htmlFor"},attrHandle:{href:function(elem){return elem.getAttribute("href")}},relative:{"+":function(checkSet,part,isXML){var isPartStr="string"==typeof part,isTag=isPartStr&&!/\W/.test(part),isPartStrNotTag=isPartStr&&!isTag;isTag&&!isXML&&(part=part.toUpperCase());for(var elem,i=0,l=checkSet.length;i<l;i++)if(elem=checkSet[i]){for(;(elem=elem.previousSibling)&&1!==elem.nodeType;);checkSet[i]=isPartStrNotTag||elem&&elem.nodeName===part?elem||!1:elem===part}isPartStrNotTag&&Sizzle.filter(part,checkSet,!0)},">":function(checkSet,part,isXML){var isPartStr="string"==typeof part;if(isPartStr&&!/\W/.test(part)){part=isXML?part:part.toUpperCase();for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){var parent=elem.parentNode;checkSet[i]=parent.nodeName===part&&parent}}}else{for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];elem&&(checkSet[i]=isPartStr?elem.parentNode:elem.parentNode===part)}isPartStr&&Sizzle.filter(part,checkSet,!0)}},"":function(checkSet,part,isXML){var doneName=done++,checkFn=dirCheck;if(!/\W/.test(part)){var nodeCheck=part=isXML?part:part.toUpperCase();checkFn=dirNodeCheck}checkFn("parentNode",part,doneName,checkSet,nodeCheck,isXML)},"~":function(checkSet,part,isXML){var doneName=done++,checkFn=dirCheck;if("string"==typeof part&&!/\W/.test(part)){var nodeCheck=part=isXML?part:part.toUpperCase();checkFn=dirNodeCheck}checkFn("previousSibling",part,doneName,checkSet,nodeCheck,isXML)}},find:{ID:function(match,context,isXML){if(void 0!==context.getElementById&&!isXML){var m=context.getElementById(match[1]);return m?[m]:[]}},NAME:function(match,context,isXML){if(void 0!==context.getElementsByName){for(var ret=[],results=context.getElementsByName(match[1]),i=0,l=results.length;i<l;i++)results[i].getAttribute("name")===match[1]&&ret.push(results[i]);return 0===ret.length?null:ret}},TAG:function(match,context){return context.getElementsByTagName(match[1])}},preFilter:{CLASS:function(match,curLoop,inplace,result,not,isXML){if(match=" "+match[1].replace(/\\/g,"")+" ",isXML)return match;for(var elem,i=0;null!=(elem=curLoop[i]);i++)elem&&(not^(elem.className&&(" "+elem.className+" ").indexOf(match)>=0)?inplace||result.push(elem):inplace&&(curLoop[i]=!1));return!1},ID:function(match){return match[1].replace(/\\/g,"")},TAG:function(match,curLoop){for(var i=0;!1===curLoop[i];i++);return curLoop[i]&&isXML(curLoop[i])?match[1]:match[1].toUpperCase()},CHILD:function(match){if("nth"==match[1]){var test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec("even"==match[2]&&"2n"||"odd"==match[2]&&"2n+1"||!/\D/.test(match[2])&&"0n+"+match[2]||match[2]);match[2]=test[1]+(test[2]||1)-0,match[3]=test[3]-0}return match[0]=done++,match},ATTR:function(match,curLoop,inplace,result,not,isXML){var name=match[1].replace(/\\/g,"");return!isXML&&Expr.attrMap[name]&&(match[1]=Expr.attrMap[name]),"~="===match[2]&&(match[4]=" "+match[4]+" "),match},PSEUDO:function(match,curLoop,inplace,result,not){if("not"===match[1]){if(!((chunker.exec(match[3])||"").length>1||/^\w/.test(match[3]))){var ret=Sizzle.filter(match[3],curLoop,inplace,!0^not);return inplace||result.push.apply(result,ret),!1}match[3]=Sizzle(match[3],null,null,curLoop)}else if(Expr.match.POS.test(match[0])||Expr.match.CHILD.test(match[0]))return!0;return match},POS:function(match){return match.unshift(!0),match}},filters:{enabled:function(elem){return!1===elem.disabled&&"hidden"!==elem.type},disabled:function(elem){return!0===elem.disabled},checked:function(elem){return!0===elem.checked},selected:function(elem){return elem.parentNode.selectedIndex,!0===elem.selected},parent:function(elem){return!!elem.firstChild},empty:function(elem){return!elem.firstChild},has:function(elem,i,match){return!!Sizzle(match[3],elem).length},header:function(elem){return/h\d/i.test(elem.nodeName)},text:function(elem){return"text"===elem.type},radio:function(elem){return"radio"===elem.type},checkbox:function(elem){return"checkbox"===elem.type},file:function(elem){return"file"===elem.type},password:function(elem){return"password"===elem.type},submit:function(elem){return"submit"===elem.type},image:function(elem){return"image"===elem.type},reset:function(elem){return"reset"===elem.type},button:function(elem){return"button"===elem.type||"BUTTON"===elem.nodeName.toUpperCase()},input:function(elem){return/input|select|textarea|button/i.test(elem.nodeName)}},setFilters:{first:function(elem,i){return 0===i},last:function(elem,i,match,array){return i===array.length-1},even:function(elem,i){return i%2==0},odd:function(elem,i){return i%2==1},lt:function(elem,i,match){return i<match[3]-0},gt:function(elem,i,match){return i>match[3]-0},nth:function(elem,i,match){return match[3]-0==i},eq:function(elem,i,match){return match[3]-0==i}},filter:{PSEUDO:function(elem,match,i,array){var name=match[1],filter=Expr.filters[name];if(filter)return filter(elem,i,match,array);if("contains"===name)return(elem.textContent||elem.innerText||"").indexOf(match[3])>=0;if("not"===name){for(var not=match[3],i=0,l=not.length;i<l;i++)if(not[i]===elem)return!1;return!0}},CHILD:function(elem,match){var type=match[1],node=elem;switch(type){case"only":case"first":for(;node=node.previousSibling;)if(1===node.nodeType)return!1;if("first"==type)return!0;node=elem;case"last":for(;node=node.nextSibling;)if(1===node.nodeType)return!1;return!0;case"nth":var first=match[2],last=match[3];if(1==first&&0==last)return!0;var doneName=match[0],parent=elem.parentNode;if(parent&&(parent.sizcache!==doneName||!elem.nodeIndex)){var count=0;for(node=parent.firstChild;node;node=node.nextSibling)1===node.nodeType&&(node.nodeIndex=++count);parent.sizcache=doneName}var diff=elem.nodeIndex-last;return 0==first?0==diff:diff%first==0&&diff/first>=0}},ID:function(elem,match){return 1===elem.nodeType&&elem.getAttribute("id")===match},TAG:function(elem,match){return"*"===match&&1===elem.nodeType||elem.nodeName===match},CLASS:function(elem,match){return(" "+(elem.className||elem.getAttribute("class"))+" ").indexOf(match)>-1},ATTR:function(elem,match){var name=match[1],result=Expr.attrHandle[name]?Expr.attrHandle[name](elem):null!=elem[name]?elem[name]:elem.getAttribute(name),value=result+"",type=match[2],check=match[4];return null==result?"!="===type:"="===type?value===check:"*="===type?value.indexOf(check)>=0:"~="===type?(" "+value+" ").indexOf(check)>=0:check?"!="===type?value!=check:"^="===type?0===value.indexOf(check):"$="===type?value.substr(value.length-check.length)===check:"|="===type&&(value===check||value.substr(0,check.length+1)===check+"-"):value&&!1!==result},POS:function(elem,match,i,array){var name=match[2],filter=Expr.setFilters[name];if(filter)return filter(elem,i,match,array)}}},origPOS=Expr.match.POS;for(var type in Expr.match)Expr.match[type]=new RegExp(Expr.match[type].source+/(?![^\[]*\])(?![^\(]*\))/.source),Expr.leftMatch[type]=new RegExp(/(^(?:.|\r|\n)*?)/.source+Expr.match[type].source);var makeArray=function(array,results){return array=Array.prototype.slice.call(array,0),results?(results.push.apply(results,array),results):array};try{Array.prototype.slice.call(document.documentElement.childNodes,0)}catch(e){makeArray=function(array,results){var ret=results||[];if("[object Array]"===toString.call(array))Array.prototype.push.apply(ret,array);else if("number"==typeof array.length)for(var i=0,l=array.length;i<l;i++)ret.push(array[i]);else for(var i=0;array[i];i++)ret.push(array[i]);return ret}}var sortOrder;document.documentElement.compareDocumentPosition?sortOrder=function(a,b){if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a==b&&(hasDuplicate=!0),0;var ret=4&a.compareDocumentPosition(b)?-1:a===b?0:1;return 0===ret&&(hasDuplicate=!0),ret}:"sourceIndex"in document.documentElement?sortOrder=function(a,b){if(!a.sourceIndex||!b.sourceIndex)return a==b&&(hasDuplicate=!0),0;var ret=a.sourceIndex-b.sourceIndex;return 0===ret&&(hasDuplicate=!0),ret}:document.createRange&&(sortOrder=function(a,b){if(!a.ownerDocument||!b.ownerDocument)return a==b&&(hasDuplicate=!0),0;var aRange=a.ownerDocument.createRange(),bRange=b.ownerDocument.createRange();aRange.setStart(a,0),aRange.setEnd(a,0),bRange.setStart(b,0),bRange.setEnd(b,0);var ret=aRange.compareBoundaryPoints(Range.START_TO_END,bRange);return 0===ret&&(hasDuplicate=!0),ret}),function(){var form=document.createElement("div"),id="script"+(new Date).getTime();form.innerHTML="<a name='"+id+"'/>";var root=document.documentElement;root.insertBefore(form,root.firstChild),document.getElementById(id)&&(Expr.find.ID=function(match,context,isXML){if(void 0!==context.getElementById&&!isXML){var m=context.getElementById(match[1]);return m?m.id===match[1]||void 0!==m.getAttributeNode&&m.getAttributeNode("id").nodeValue===match[1]?[m]:void 0:[]}},Expr.filter.ID=function(elem,match){var node=void 0!==elem.getAttributeNode&&elem.getAttributeNode("id");return 1===elem.nodeType&&node&&node.nodeValue===match}),root.removeChild(form),root=form=null}(),function(){var div=document.createElement("div");div.appendChild(document.createComment("")),div.getElementsByTagName("*").length>0&&(Expr.find.TAG=function(match,context){var results=context.getElementsByTagName(match[1]);if("*"===match[1]){for(var tmp=[],i=0;results[i];i++)1===results[i].nodeType&&tmp.push(results[i]);results=tmp}return results}),div.innerHTML="<a href='#'></a>",div.firstChild&&void 0!==div.firstChild.getAttribute&&"#"!==div.firstChild.getAttribute("href")&&(Expr.attrHandle.href=function(elem){return elem.getAttribute("href",2)}),div=null}(),document.querySelectorAll&&function(){var oldSizzle=Sizzle,div=document.createElement("div");if(div.innerHTML="<p class='TEST'></p>",!div.querySelectorAll||0!==div.querySelectorAll(".TEST").length){Sizzle=function(query,context,extra,seed){if(context=context||document,!seed&&9===context.nodeType&&!isXML(context))try{return makeArray(context.querySelectorAll(query),extra)}catch(e){}return oldSizzle(query,context,extra,seed)};for(var prop in oldSizzle)Sizzle[prop]=oldSizzle[prop];div=null}}(),document.getElementsByClassName&&document.documentElement.getElementsByClassName&&function(){var div=document.createElement("div");div.innerHTML="<div class='test e'></div><div class='test'></div>",0!==div.getElementsByClassName("e").length&&(div.lastChild.className="e",1!==div.getElementsByClassName("e").length&&(Expr.order.splice(1,0,"CLASS"),Expr.find.CLASS=function(match,context,isXML){if(void 0!==context.getElementsByClassName&&!isXML)return context.getElementsByClassName(match[1])},div=null))}();var contains=document.compareDocumentPosition?function(a,b){return 16&a.compareDocumentPosition(b)}:function(a,b){return a!==b&&(!a.contains||a.contains(b))},isXML=function(elem){return 9===elem.nodeType&&"HTML"!==elem.documentElement.nodeName||!!elem.ownerDocument&&"HTML"!==elem.ownerDocument.documentElement.nodeName},posProcess=function(selector,context){
for(var match,tmpSet=[],later="",root=context.nodeType?[context]:context;match=Expr.match.PSEUDO.exec(selector);)later+=match[0],selector=selector.replace(Expr.match.PSEUDO,"");selector=Expr.relative[selector]?selector+"*":selector;for(var i=0,l=root.length;i<l;i++)Sizzle(selector,root[i],tmpSet);return Sizzle.filter(later,tmpSet)};window.Sizzle=Sizzle}(),function(engine){function select(selector,scope){return extendElements(engine(selector,scope||document))}function match(element,selector){return 1==engine.matches(selector,[element]).length}var extendElements=Prototype.Selector.extendElements;Prototype.Selector.engine=engine,Prototype.Selector.select=select,Prototype.Selector.match=match}(Sizzle),window.Sizzle=Prototype._original_property,delete Prototype._original_property;var Form={reset:function(form){return form=$(form),form.reset(),form},serializeElements:function(elements,options){"object"!=typeof options?options={hash:!!options}:Object.isUndefined(options.hash)&&(options.hash=!0);var key,value,accumulator,initial,submitted=!1,submit=options.submit;return options.hash?(initial={},accumulator=function(result,key,value){return key in result?(Object.isArray(result[key])||(result[key]=[result[key]]),result[key].push(value)):result[key]=value,result}):(initial="",accumulator=function(result,key,value){return result+(result?"&":"")+encodeURIComponent(key)+"="+encodeURIComponent(value)}),elements.inject(initial,function(result,element){return!element.disabled&&element.name&&(key=element.name,null==(value=$(element).getValue())||"file"==element.type||"submit"==element.type&&(submitted||!1===submit||submit&&key!=submit||!(submitted=!0))||(result=accumulator(result,key,value))),result})}};Form.Methods={serialize:function(form,options){return Form.serializeElements(Form.getElements(form),options)},getElements:function(form){for(var element,elements=$(form).getElementsByTagName("*"),arr=[],serializers=Form.Element.Serializers,i=0;element=elements[i];i++)arr.push(element);return arr.inject([],function(elements,child){return serializers[child.tagName.toLowerCase()]&&elements.push(Element.extend(child)),elements})},getInputs:function(form,typeName,name){form=$(form);var inputs=form.getElementsByTagName("input");if(!typeName&&!name)return $A(inputs).map(Element.extend);for(var i=0,matchingInputs=[],length=inputs.length;i<length;i++){var input=inputs[i];typeName&&input.type!=typeName||name&&input.name!=name||matchingInputs.push(Element.extend(input))}return matchingInputs},disable:function(form){return form=$(form),Form.getElements(form).invoke("disable"),form},enable:function(form){return form=$(form),Form.getElements(form).invoke("enable"),form},findFirstElement:function(form){var elements=$(form).getElements().findAll(function(element){return"hidden"!=element.type&&!element.disabled}),firstByIndex=elements.findAll(function(element){return element.hasAttribute("tabIndex")&&element.tabIndex>=0}).sortBy(function(element){return element.tabIndex}).first();return firstByIndex||elements.find(function(element){return/^(?:input|select|textarea)$/i.test(element.tagName)})},focusFirstElement:function(form){form=$(form);var element=form.findFirstElement();return element&&element.activate(),form},request:function(form,options){form=$(form),options=Object.clone(options||{});var params=options.parameters,action=form.readAttribute("action")||"";return action.blank()&&(action=window.location.href),options.parameters=form.serialize(!0),params&&(Object.isString(params)&&(params=params.toQueryParams()),Object.extend(options.parameters,params)),form.hasAttribute("method")&&!options.method&&(options.method=form.method),new Ajax.Request(action,options)}},Form.Element={focus:function(element){return $(element).focus(),element},select:function(element){return $(element).select(),element}},Form.Element.Methods={serialize:function(element){if(element=$(element),!element.disabled&&element.name){var value=element.getValue();if(void 0!=value){var pair={};return pair[element.name]=value,Object.toQueryString(pair)}}return""},getValue:function(element){element=$(element);var method=element.tagName.toLowerCase();return Form.Element.Serializers[method](element)},setValue:function(element,value){element=$(element);var method=element.tagName.toLowerCase();return Form.Element.Serializers[method](element,value),element},clear:function(element){return $(element).value="",element},present:function(element){return""!=$(element).value},activate:function(element){element=$(element);try{element.focus(),!element.select||"input"==element.tagName.toLowerCase()&&/^(?:button|reset|submit)$/i.test(element.type)||element.select()}catch(e){}return element},disable:function(element){return element=$(element),element.disabled=!0,element},enable:function(element){return element=$(element),element.disabled=!1,element}};var Field=Form.Element,$F=Form.Element.Methods.getValue;Form.Element.Serializers=function(){function input(element,value){switch(element.type.toLowerCase()){case"checkbox":case"radio":return inputSelector(element,value);default:return valueSelector(element,value)}}function inputSelector(element,value){if(Object.isUndefined(value))return element.checked?element.value:null;element.checked=!!value}function valueSelector(element,value){if(Object.isUndefined(value))return element.value;element.value=value}function select(element,value){if(Object.isUndefined(value))return("select-one"===element.type?selectOne:selectMany)(element);for(var opt,currentValue,single=!Object.isArray(value),i=0,length=element.length;i<length;i++)if(opt=element.options[i],currentValue=this.optionValue(opt),single){if(currentValue==value)return void(opt.selected=!0)}else opt.selected=value.include(currentValue)}function selectOne(element){var index=element.selectedIndex;return index>=0?optionValue(element.options[index]):null}function selectMany(element){var values,length=element.length;if(!length)return null;for(var i=0,values=[];i<length;i++){var opt=element.options[i];opt.selected&&values.push(optionValue(opt))}return values}function optionValue(opt){return Element.hasAttribute(opt,"value")?opt.value:opt.text}return{input:input,inputSelector:inputSelector,textarea:valueSelector,select:select,selectOne:selectOne,selectMany:selectMany,optionValue:optionValue,button:valueSelector}}(),Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,element,frequency,callback){$super(callback,frequency),this.element=$(element),this.lastValue=this.getValue()},execute:function(){var value=this.getValue();(Object.isString(this.lastValue)&&Object.isString(value)?this.lastValue!=value:String(this.lastValue)!=String(value))&&(this.callback(this.element,value),this.lastValue=value)}}),Form.Element.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.Element.getValue(this.element)}}),Form.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.serialize(this.element)}}),Abstract.EventObserver=Class.create({initialize:function(element,callback){this.element=$(element),this.callback=callback,this.lastValue=this.getValue(),"form"==this.element.tagName.toLowerCase()?this.registerFormCallbacks():this.registerCallback(this.element)},onElementEvent:function(){var value=this.getValue();this.lastValue!=value&&(this.callback(this.element,value),this.lastValue=value)},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this)},registerCallback:function(element){if(element.type)switch(element.type.toLowerCase()){case"checkbox":case"radio":Event.observe(element,"click",this.onElementEvent.bind(this));break;default:Event.observe(element,"change",this.onElementEvent.bind(this))}}}),Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element)}}),Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element)}}),function(){function _isButtonForDOMEvents(event,code){return event.which?event.which===code+1:event.button===code}function _isButtonForLegacyEvents(event,code){return event.button===legacyButtonMap[code]}function _isButtonForWebKit(event,code){switch(code){case 0:return 1==event.which&&!event.metaKey;case 1:return 2==event.which||1==event.which&&event.metaKey;case 2:return 3==event.which;default:return!1}}function isLeftClick(event){return _isButton(event,0)}function isMiddleClick(event){return _isButton(event,1)}function isRightClick(event){return _isButton(event,2)}function element(event){event=Event.extend(event);var node=event.target,type=event.type,currentTarget=event.currentTarget;return currentTarget&&currentTarget.tagName&&("load"===type||"error"===type||"click"===type&&"input"===currentTarget.tagName.toLowerCase()&&"radio"===currentTarget.type)&&(node=currentTarget),node.nodeType==Node.TEXT_NODE&&(node=node.parentNode),Element.extend(node)}function findElement(event,expression){var element=Event.element(event);if(!expression)return element;for(;element;){if(Object.isElement(element)&&Prototype.Selector.match(element,expression))return Element.extend(element);element=element.parentNode}}function pointer(event){return{x:pointerX(event),y:pointerY(event)}}function pointerX(event){var docElement=document.documentElement,body=document.body||{scrollLeft:0};return event.pageX||event.clientX+(docElement.scrollLeft||body.scrollLeft)-(docElement.clientLeft||0)}function pointerY(event){var docElement=document.documentElement,body=document.body||{scrollTop:0};return event.pageY||event.clientY+(docElement.scrollTop||body.scrollTop)-(docElement.clientTop||0)}function stop(event){Event.extend(event),event.preventDefault(),event.stopPropagation(),event.stopped=!0}function _relatedTarget(event){var element;switch(event.type){case"mouseover":case"mouseenter":element=event.fromElement;break;case"mouseout":case"mouseleave":element=event.toElement;break;default:return null}return Element.extend(element)}function _createResponder(element,eventName,handler){var registry=Element.retrieve(element,"prototype_event_registry");Object.isUndefined(registry)&&(CACHE.push(element),registry=Element.retrieve(element,"prototype_event_registry",$H()));var respondersForEvent=registry.get(eventName);if(Object.isUndefined(respondersForEvent)&&(respondersForEvent=[],registry.set(eventName,respondersForEvent)),respondersForEvent.pluck("handler").include(handler))return!1;var responder;return eventName.include(":")?responder=function(event){return!Object.isUndefined(event.eventName)&&(event.eventName===eventName&&(Event.extend(event,element),void handler.call(element,event)))}:MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED||"mouseenter"!==eventName&&"mouseleave"!==eventName?responder=function(event){Event.extend(event,element),handler.call(element,event)}:"mouseenter"!==eventName&&"mouseleave"!==eventName||(responder=function(event){Event.extend(event,element);for(var parent=event.relatedTarget;parent&&parent!==element;)try{parent=parent.parentNode}catch(e){parent=element}parent!==element&&handler.call(element,event)}),responder.handler=handler,respondersForEvent.push(responder),responder}function _destroyCache(){for(var i=0,length=CACHE.length;i<length;i++)Event.stopObserving(CACHE[i]),CACHE[i]=null}function observe(element,eventName,handler){element=$(element);var responder=_createResponder(element,eventName,handler);if(!responder)return element;if(eventName.include(":"))element.addEventListener?element.addEventListener("dataavailable",responder,!1):(element.attachEvent("ondataavailable",responder),element.attachEvent("onlosecapture",responder));else{var actualEventName=_getDOMEventName(eventName);element.addEventListener?element.addEventListener(actualEventName,responder,!1):element.attachEvent("on"+actualEventName,responder)}return element}function stopObserving(element,eventName,handler){element=$(element);var registry=Element.retrieve(element,"prototype_event_registry");if(!registry)return element;if(!eventName)return registry.each(function(pair){var eventName=pair.key;stopObserving(element,eventName)}),element;var responders=registry.get(eventName);if(!responders)return element;if(!handler)return responders.each(function(r){stopObserving(element,eventName,r.handler)}),element;for(var responder,i=responders.length;i--;)if(responders[i].handler===handler){responder=responders[i];break}if(!responder)return element;if(eventName.include(":"))element.removeEventListener?element.removeEventListener("dataavailable",responder,!1):(element.detachEvent("ondataavailable",responder),element.detachEvent("onlosecapture",responder));else{var actualEventName=_getDOMEventName(eventName);element.removeEventListener?element.removeEventListener(actualEventName,responder,!1):element.detachEvent("on"+actualEventName,responder)}return registry.set(eventName,responders.without(responder)),element}function fire(element,eventName,memo,bubble){element=$(element),Object.isUndefined(bubble)&&(bubble=!0),element==document&&document.createEvent&&!element.dispatchEvent&&(element=document.documentElement);var event;return document.createEvent?(event=document.createEvent("HTMLEvents"),event.initEvent("dataavailable",bubble,!0)):(event=document.createEventObject(),event.eventType=bubble?"ondataavailable":"onlosecapture"),event.eventName=eventName,event.memo=memo||{},document.createEvent?element.dispatchEvent(event):element.fireEvent(event.eventType,event),Event.extend(event)}function on(element,eventName,selector,callback){return element=$(element),Object.isFunction(selector)&&Object.isUndefined(callback)&&(callback=selector,selector=null),new Event.Handler(element,eventName,selector,callback).start()}var 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,KEY_INSERT:45,cache:{}},docEl=document.documentElement,MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED="onmouseenter"in docEl&&"onmouseleave"in docEl,isIELegacyEvent=function(event){return!1};window.attachEvent&&(isIELegacyEvent=window.addEventListener?function(event){return!(event instanceof window.Event)}:function(event){return!0});var _isButton,legacyButtonMap={0:1,1:4,2:2};_isButton=window.attachEvent?window.addEventListener?function(event,code){return isIELegacyEvent(event)?_isButtonForLegacyEvents(event,code):_isButtonForDOMEvents(event,code)}:_isButtonForLegacyEvents:Prototype.Browser.WebKit?_isButtonForWebKit:_isButtonForDOMEvents,Event.Methods={isLeftClick:isLeftClick,isMiddleClick:isMiddleClick,isRightClick:isRightClick,element:element,findElement:findElement,pointer:pointer,pointerX:pointerX,pointerY:pointerY,stop:stop};var methods=Object.keys(Event.Methods).inject({},function(m,name){return m[name]=Event.Methods[name].methodize(),m});if(window.attachEvent){var additionalMethods={stopPropagation:function(){this.cancelBubble=!0},preventDefault:function(){this.returnValue=!1},inspect:function(){return"[object Event]"}};Event.extend=function(event,element){if(!event)return!1;if(!isIELegacyEvent(event))return event;if(event._extendedByPrototype)return event;event._extendedByPrototype=Prototype.emptyFunction;var pointer=Event.pointer(event);return Object.extend(event,{target:event.srcElement||element,relatedTarget:_relatedTarget(event),pageX:pointer.x,pageY:pointer.y}),Object.extend(event,methods),Object.extend(event,additionalMethods),event}}else Event.extend=Prototype.K;window.addEventListener&&(Event.prototype=window.Event.prototype||document.createEvent("HTMLEvents").__proto__,Object.extend(Event.prototype,methods));var CACHE=[];Prototype.Browser.IE&&window.attachEvent("onunload",_destroyCache),Prototype.Browser.WebKit&&window.addEventListener("unload",Prototype.emptyFunction,!1);var _getDOMEventName=Prototype.K,translations={mouseenter:"mouseover",mouseleave:"mouseout"};MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED||(_getDOMEventName=function(eventName){return translations[eventName]||eventName}),Event.Handler=Class.create({initialize:function(element,eventName,selector,callback){this.element=$(element),this.eventName=eventName,this.selector=selector,this.callback=callback,this.handler=this.handleEvent.bind(this)},start:function(){return Event.observe(this.element,this.eventName,this.handler),this},stop:function(){return Event.stopObserving(this.element,this.eventName,this.handler),this},handleEvent:function(event){var element=Event.findElement(event,this.selector);element&&this.callback.call(this.element,event,element)}}),Object.extend(Event,Event.Methods),Object.extend(Event,{fire:fire,observe:observe,stopObserving:stopObserving,on:on}),Element.addMethods({fire:fire,observe:observe,stopObserving:stopObserving,on:on}),Object.extend(document,{fire:fire.methodize(),observe:observe.methodize(),stopObserving:stopObserving.methodize(),on:on.methodize(),loaded:!1}),window.Event?Object.extend(window.Event,Event):window.Event=Event}(),function(){function fireContentLoadedEvent(){document.loaded||(timer&&window.clearTimeout(timer),document.loaded=!0,document.fire("dom:loaded"))}function checkReadyState(){"complete"===document.readyState&&(document.stopObserving("readystatechange",checkReadyState),fireContentLoadedEvent())}function pollDoScroll(){try{document.documentElement.doScroll("left")}catch(e){return void(timer=pollDoScroll.defer())}fireContentLoadedEvent()}var timer;document.addEventListener?document.addEventListener("DOMContentLoaded",fireContentLoadedEvent,!1):(document.observe("readystatechange",checkReadyState),window==top&&(timer=pollDoScroll.defer())),Event.observe(window,"load",fireContentLoadedEvent)}(),Element.addMethods(),Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(element,content){return Element.insert(element,{before:content})},Top:function(element,content){return Element.insert(element,{top:content})},Bottom:function(element,content){return Element.insert(element,{bottom:content})},After:function(element,content){return Element.insert(element,{after:content})}},$continue=new Error('"throw $continue" is deprecated, use "return" instead'),Position={includeScrollOffsets:!1,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0,this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(element,x,y){return this.includeScrollOffsets?this.withinIncludingScrolloffsets(element,x,y):(this.xcomp=x,this.ycomp=y,this.offset=Element.cumulativeOffset(element),y>=this.offset[1]&&y<this.offset[1]+element.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+element.offsetWidth)},withinIncludingScrolloffsets:function(element,x,y){var offsetcache=Element.cumulativeScrollOffset(element);return this.xcomp=x+offsetcache[0]-this.deltaX,this.ycomp=y+offsetcache[1]-this.deltaY,this.offset=Element.cumulativeOffset(element),this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+element.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+element.offsetWidth},overlap:function(mode,element){return mode?"vertical"==mode?(this.offset[1]+element.offsetHeight-this.ycomp)/element.offsetHeight:"horizontal"==mode?(this.offset[0]+element.offsetWidth-this.xcomp)/element.offsetWidth:void 0:0},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(element){return Position.prepare(),Element.absolutize(element)},relativize:function(element){return Position.prepare(),Element.relativize(element)},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(source,target,options){return options=options||{},Element.clonePosition(target,source,options)}};document.getElementsByClassName||(document.getElementsByClassName=function(instanceMethods){function iter(name){return name.blank()?null:"[contains(concat(' ', @class, ' '), ' "+name+" ')]"}return instanceMethods.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(element,className){className=className.toString().strip();var cond=/\s/.test(className)?$w(className).map(iter).join(""):iter(className);return cond?document._getElementsByXPath(".//*"+cond,element):[]}:function(element,className){className=className.toString().strip();var elements=[],classNames=/\s/.test(className)?$w(className):null;if(!classNames&&!className)return elements;var nodes=$(element).getElementsByTagName("*");className=" "+className+" ";for(var child,cn,i=0;child=nodes[i];i++)child.className&&(cn=" "+child.className+" ")&&(cn.include(className)||classNames&&classNames.all(function(name){return!name.toString().blank()&&cn.include(" "+name+" ")}))&&elements.push(Element.extend(child));return elements},function(className,parentElement){return $(parentElement||document.body).getElementsByClassName(className)}}(Element.Methods)),Element.ClassNames=Class.create(),Element.ClassNames.prototype={initialize:function(element){this.element=$(element)},_each:function(iterator){this.element.className.split(/\s+/).select(function(name){return name.length>0})._each(iterator)},set:function(className){this.element.className=className},add:function(classNameToAdd){this.include(classNameToAdd)||this.set($A(this).concat(classNameToAdd).join(" "))},remove:function(classNameToRemove){this.include(classNameToRemove)&&this.set($A(this).without(classNameToRemove).join(" "))},toString:function(){return $A(this).join(" ")}},Object.extend(Element.ClassNames.prototype,Enumerable),function(){window.Selector=Class.create({initialize:function(expression){this.expression=expression.strip()},findElements:function(rootElement){return Prototype.Selector.select(this.expression,rootElement)},match:function(element){return Prototype.Selector.match(element,this.expression)},toString:function(){return this.expression},inspect:function(){return"#<Selector: "+this.expression+">"}}),Object.extend(Selector,{matchElements:function(elements,expression){for(var match=Prototype.Selector.match,results=[],i=0,length=elements.length;i<length;i++){var element=elements[i];match(element,expression)&&results.push(Element.extend(element))}return results},findElement:function(elements,expression,index){index=index||0;for(var element,matchIndex=0,i=0,length=elements.length;i<length;i++)if(element=elements[i],Prototype.Selector.match(element,expression)&&index===matchIndex++)return Element.extend(element)},findChildElements:function(element,expressions){var selector=expressions.toArray().join(", ");return Prototype.Selector.select(selector,element||document)}})}(),Function.prototype.bind=bindTemp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment