/*vendor/fastinit*/
var FastInit = {
  onload : function() {
    if (FastInit.done) { return; }
    FastInit.done = true;
    for(var x = 0, al = FastInit.f.length; x < al; x++) {
      FastInit.f[x]();
    }
  },
  addOnLoad : function() {
    var a = arguments;
    for(var x = 0, al = a.length; x < al; x++) {
      if(typeof a[x] === 'function') {
        if (FastInit.done ) {
          a[x]();
        } else {
          FastInit.f.push(a[x]);
        }
      }
    }
  },
  listen : function() {
    if (/WebKit|khtml/i.test(navigator.userAgent)) {
      FastInit.timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
          clearInterval(FastInit.timer);
          delete FastInit.timer;
          FastInit.onload();
        }}, 10);
    } else if (document.addEventListener) {
      document.addEventListener('DOMContentLoaded', FastInit.onload, false);
    } else if(!FastInit.iew32) {
      if(window.addEventListener) {
        window.addEventListener('load', FastInit.onload, false);
      } else if (window.attachEvent) {
        return window.attachEvent('onload', FastInit.onload);
      }
    }
  },
  f:[],done:false,timer:null,iew32:false
};
/*@cc_on @*/
/*@if (@_win32)
FastInit.iew32 = true;
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
/*@end @*/
FastInit.listen();
/*vendor/prototype/prototype*/
var Prototype={Version:"1.6.0.2",Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement("div").__proto__&&document.createElement("div").__proto__!==document.createElement("form").__proto__},ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(A){return A}};if(Prototype.Browser.MobileSafari){Prototype.BrowserFeatures.SpecificElementExtensions=false}var Class={create:function(){var D=null,C=$A(arguments);if(Object.isFunction(C[0])){D=C.shift()}function E(){this.initialize.apply(this,arguments)}Object.extend(E,Class.Methods);E.superclass=D;E.subclasses=[];if(D){var A=function(){};A.prototype=D.prototype;E.prototype=new A;D.subclasses.push(E)}for(var B=0;B<C.length;B++){E.addMethods(C[B])}if(!E.prototype.initialize){E.prototype.initialize=Prototype.emptyFunction}E.prototype.constructor=E;return E}};Class.Methods={addMethods:function(B){var F=this.superclass&&this.superclass.prototype;var E=Object.keys(B);if(!Object.keys({toString:true}).length){E.push("toString","valueOf")}for(var D=0,G=E.length;D<G;D++){var A=E[D],H=B[A];if(F&&Object.isFunction(H)&&H.argumentNames().first()=="$super"){var C=H,H=Object.extend((function(I){return function(){return F[I].apply(this,arguments)}})(A).wrap(C),{valueOf:function(){return C},toString:function(){return C.toString()}})}this.prototype[A]=H}return this}};var Abstract={};Object.extend=function(C,B){for(var A in B){C[A]=B[A]}return C};Object.extend(Object,{inspect:function(B){try{if(Object.isUndefined(B)){return"undefined"}if(B===null){return"null"}return B.inspect?B.inspect():String(B)}catch(A){if(A instanceof RangeError){return"..."}throw A}},toJSON:function(E){var B=typeof E;switch(B){case"undefined":case"function":case"unknown":return ;case"boolean":return E.toString()}if(E===null){return"null"}if(E.toJSON){return E.toJSON()}if(Object.isElement(E)){return }var A=[];for(var D in E){var C=Object.toJSON(E[D]);if(!Object.isUndefined(C)){A.push(D.toJSON()+": "+C)}}return"{"+A.join(", ")+"}"},toQueryString:function(A){return $H(A).toQueryString()},toHTML:function(A){return A&&A.toHTML?A.toHTML():String.interpret(A)},keys:function(C){var A=[];for(var B in C){A.push(B)}return A},values:function(A){var C=[];for(var B in A){C.push(A[B])}return C},clone:function(A){return Object.extend({},A)},isElement:function(A){return A&&A.nodeType==1},isArray:function(A){return A!=null&&typeof A=="object"&&"splice" in A&&"join" in A},isHash:function(A){return A instanceof Hash},isFunction:function(A){return typeof A=="function"},isString:function(A){return typeof A=="string"},isNumber:function(A){return typeof A=="number"},isUndefined:function(A){return typeof A=="undefined"}});Object.extend(Function.prototype,{argumentNames:function(){var A=this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");return A.length==1&&!A[0]?[]:A},bind:function(){if(arguments.length<2&&Object.isUndefined(arguments[0])){return this}var C=this,B=$A(arguments),A=B.shift();return function(){return C.apply(A,B.concat($A(arguments)))}},bindAsEventListener:function(){var C=this,B=$A(arguments),A=B.shift();return function(D){return C.apply(A,[D||window.event].concat(B))}},curry:function(){if(!arguments.length){return this}var B=this,A=$A(arguments);return function(){return B.apply(this,A.concat($A(arguments)))}},delay:function(){var C=this,A=$A(arguments),B=A.shift()*1000;return window.setTimeout(function(){return C.apply(C,A)},B)},wrap:function(A){var B=this;return function(){return A.apply(this,[B.bind(this)].concat($A(arguments)))}},methodize:function(){if(this._methodized){return this._methodized}var A=this;return this._methodized=function(){return A.apply(null,[this].concat($A(arguments)))}}});Function.prototype.defer=Function.prototype.delay.curry(0.01);Date.prototype.toJSON=function(){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"'};var Try={these:function(){var B;for(var A=0,C=arguments.length;A<C;A++){var E=arguments[A];try{B=E();break}catch(D){}}return B}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(A){return String(A).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(A,B){this.callback=A;this.frequency=B;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},execute:function(){this.callback(this)},stop:function(){if(!this.timer){return }clearInterval(this.timer);this.timer=null},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.execute()}finally{this.currentlyExecuting=false}}}});Object.extend(String,{interpret:function(A){return A==null?"":String(A)},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});Object.extend(String.prototype,{gsub:function(D,B){var E="",C=this,A;B=arguments.callee.prepareReplacement(B);while(C.length>0){if(A=C.match(D)){E+=C.slice(0,A.index);E+=String.interpret(B(A));C=C.slice(A.index+A[0].length)}else{E+=C,C=""}}return E},sub:function(B,C,A){C=this.gsub.prepareReplacement(C);A=Object.isUndefined(A)?1:A;return this.gsub(B,function(D){if(--A<0){return D[0]}return C(D)})},scan:function(A,B){this.gsub(A,B);return String(this)},truncate:function(A,B){A=A||30;B=Object.isUndefined(B)?"...":B;return this.length>A?this.slice(0,A-B.length)+B:String(this)},strip:function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"")},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"")},extractScripts:function(){var A=new RegExp(Prototype.ScriptFragment,"img");var B=new RegExp(Prototype.ScriptFragment,"im");return(this.match(A)||[]).map(function(C){return(C.match(B)||["",""])[1]})},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script)})},escapeHTML:function(){var A=arguments.callee;A.text.data=this;return A.div.innerHTML},unescapeHTML:function(){var A=new Element("div");A.innerHTML=this.stripTags();return A.childNodes[0]?(A.childNodes.length>1?$A(A.childNodes).inject("",function(C,B){return C+B.nodeValue}):A.childNodes[0].nodeValue):""},toQueryParams:function(A){var B=this.strip().match(/([^?#]*)(#.*)?$/);if(!B){return{}}return B[1].split(A||"&").inject({},function(F,C){if((C=C.split("="))[0]){var D=decodeURIComponent(C.shift());var E=C.length>1?C.join("="):C[0];if(E!=undefined){E=decodeURIComponent(E)}if(D in F){if(!Object.isArray(F[D])){F[D]=[F[D]]}F[D].push(E)}else{F[D]=E}}return F})},toArray:function(){return this.split("")},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(A){return A<1?"":new Array(A+1).join(this)},camelize:function(){var C=this.split("-"),D=C.length;if(D==1){return C[0]}var B=this.charAt(0)=="-"?C[0].charAt(0).toUpperCase()+C[0].substring(1):C[0];for(var A=1;A<D;A++){B+=C[A].charAt(0).toUpperCase()+C[A].substring(1)}return B},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase()},dasherize:function(){return this.gsub(/_/,"-")},inspect:function(A){var B=this.gsub(/[\x00-\x1f\\]/,function(D){var C=String.specialChar[D[0]];return C?C:"\\u00"+D[0].charCodeAt().toPaddedString(2,16)});if(A){return'"'+B.replace(/"/g,'\\"')+'"'}return"'"+B.replace(/'/g,"\\'")+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(A){return this.sub(A||Prototype.JSONFilter,"#{1}")},isJSON:function(){var A=this;if(A.blank()){return false}A=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(A)},evalJSON:function(sanitize){var json=this.unfilterJSON();try{if(!sanitize||json.isJSON()){return eval("("+json+")")}}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())},include:function(A){return this.indexOf(A)>-1},startsWith:function(A){return this.indexOf(A)===0},endsWith:function(B){var A=this.length-B.length;return A>=0&&this.lastIndexOf(B)===A},empty:function(){return this==""},blank:function(){return/^\s*$/.test(this)},interpolate:function(B,A){return new Template(this,A).evaluate(B)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE){Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},unescapeHTML:function(){return this.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}})}String.prototype.gsub.prepareReplacement=function(A){if(Object.isFunction(A)){return A}var B=new Template(A);return function(C){return B.evaluate(C)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});with(String.prototype.escapeHTML){div.appendChild(text)}var Template=Class.create({initialize:function(B,A){this.template=B.toString();this.pattern=A||Template.Pattern},evaluate:function(A){if(Object.isFunction(A.toTemplateReplacements)){A=A.toTemplateReplacements()}return this.template.gsub(this.pattern,function(E){if(A==null){return""}var G=E[1]||"";if(G=="\\"){return E[2]}var C=A,B=E[3];var F=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;E=F.exec(B);if(E==null){return G}while(E!=null){var D=E[1].startsWith("[")?E[2].gsub("\\\\]","]"):E[1];C=C[D];if(null==C||""==E[3]){break}B=B.substring("["==E[3]?E[1].length:E[0].length);E=F.exec(B)}return G+String.interpret(C)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(B,A){var D=0;B=B.bind(A);try{this._each(function(E){B(E,D++)})}catch(C){if(C!=$break){throw C}}return this},eachSlice:function(C,B,A){B=B?B.bind(A):Prototype.K;var F=-C,D=[],E=this.toArray();while((F+=C)<E.length){D.push(E.slice(F,F+C))}return D.collect(B,A)},all:function(B,A){B=B?B.bind(A):Prototype.K;var C=true;this.each(function(D,E){C=C&&!!B(D,E);if(!C){throw $break}});return C},any:function(B,A){B=B?B.bind(A):Prototype.K;var C=false;this.each(function(D,E){if(C=!!B(D,E)){throw $break}});return C},collect:function(B,A){B=B?B.bind(A):Prototype.K;var C=[];this.each(function(D,E){C.push(B(D,E))});return C},detect:function(B,A){B=B.bind(A);var C;this.each(function(D,E){if(B(D,E)){C=D;throw $break}});return C},findAll:function(B,A){B=B.bind(A);var C=[];this.each(function(D,E){if(B(D,E)){C.push(D)}});return C},grep:function(C,B,A){B=B?B.bind(A):Prototype.K;var D=[];if(Object.isString(C)){C=new RegExp(C)}this.each(function(E,F){if(C.match(E)){D.push(B(E,F))}});return D},include:function(B){if(Object.isFunction(this.indexOf)){if(this.indexOf(B)!=-1){return true}}var A=false;this.each(function(C){if(C==B){A=true;throw $break}});return A},inGroupsOf:function(A,B){B=Object.isUndefined(B)?null:B;return this.eachSlice(A,function(C){while(C.length<A){C.push(B)}return C})},inject:function(C,B,A){B=B.bind(A);this.each(function(D,E){C=B(C,D,E)});return C},invoke:function(A){var B=$A(arguments).slice(1);return this.map(function(C){return C[A].apply(C,B)})},max:function(B,A){B=B?B.bind(A):Prototype.K;var C;this.each(function(D,E){D=B(D,E);if(C==null||D>=C){C=D}});return C},min:function(B,A){B=B?B.bind(A):Prototype.K;var C;this.each(function(D,E){D=B(D,E);if(C==null||D<C){C=D}});return C},partition:function(C,A){C=C?C.bind(A):Prototype.K;var B=[],D=[];this.each(function(E,F){(C(E,F)?B:D).push(E)});return[B,D]},pluck:function(A){var B=[];this.each(function(C){B.push(C[A])});return B},reject:function(B,A){B=B.bind(A);var C=[];this.each(function(D,E){if(!B(D,E)){C.push(D)}});return C},sortBy:function(A,B){A=A.bind(B);return this.map(function(C,D){return{value:C,criteria:A(C,D)}}).sort(function(C,F){var E=C.criteria,D=F.criteria;return E<D?-1:E>D?1:0}).pluck("value")},toArray:function(){return this.map()},zip:function(){var A=Prototype.K,C=$A(arguments);if(Object.isFunction(C.last())){A=C.pop()}var B=[this].concat(C).map($A);return this.map(function(D,E){return A(B.pluck(E))})},size:function(){return this.toArray().length},inspect:function(){return"#<Enumerable:"+this.toArray().inspect()+">"}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(B){if(!B){return[]}if(B.toArray){return B.toArray()}var A=B.length||0,C=new Array(A);while(A--){C[A]=B[A]}return C}if(Prototype.Browser.WebKit){$A=function(B){if(!B){return[]}if(!(Object.isFunction(B)&&B=="[object NodeList]")&&B.toArray){return B.toArray()}var A=B.length||0,C=new Array(A);while(A--){C[A]=B[A]}return C}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse}Object.extend(Array.prototype,{_each:function(A){for(var C=0,B=this.length;C<B;C++){A(this[C])}},clear:function(){this.length=0;return this},first:function(){return this[0]},last:function(){return this[this.length-1]},compact:function(){return this.select(function(A){return A!=null})},flatten:function(){return this.inject([],function(A,B){return A.concat(Object.isArray(B)?B.flatten():[B])})},without:function(){var A=$A(arguments);return this.select(function(B){return !A.include(B)})},reverse:function(A){return(A!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(A){return this.inject([],function(B,D,C){if(0==C||(A?B.last()!=D:!B.include(D))){B.push(D)}return B})},intersect:function(A){return this.uniq().findAll(function(B){return A.detect(function(C){return B===C})})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return"["+this.map(Object.inspect).join(", ")+"]"},toJSON:function(){var A=[];this.each(function(C){var B=Object.toJSON(C);if(!Object.isUndefined(B)){A.push(B)}});return"["+A.join(", ")+"]"}});if(Object.isFunction(Array.prototype.forEach)){Array.prototype._each=Array.prototype.forEach}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(B,C){C||(C=0);var A=this.length;if(C<0){C=A+C}for(;C<A;C++){if(this[C]===B){return C}}return -1}}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(A,C){C=isNaN(C)?this.length:(C<0?this.length+C:C)+1;var B=this.slice(0,C).reverse().indexOf(A);return(B<0)?B:C-B-1}}Array.prototype.toArray=Array.prototype.clone;function $w(A){if(!Object.isString(A)){return[]}A=A.strip();return A?A.split(/\s+/):[]}if(Prototype.Browser.Opera){Array.prototype.concat=function(){var D=[];for(var A=0,B=this.length;A<B;A++){D.push(this[A])}for(var A=0,B=arguments.length;A<B;A++){if(Object.isArray(arguments[A])){for(var E=0,C=arguments[A].length;E<C;E++){D.push(arguments[A][E])}}else{D.push(arguments[A])}}return D}}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(A){$R(0,this,true).each(A);return this},toPaddedString:function(B,A){var C=this.toString(A||10);return"0".times(B-C.length)+C},toJSON:function(){return isFinite(this)?this.toString():"null"}});$w("abs round ceil floor").each(function(A){Number.prototype[A]=Math[A].methodize()});function $H(A){return new Hash(A)}var Hash=Class.create(Enumerable,(function(){function A(C,B){if(Object.isUndefined(B)){return C}return C+"="+encodeURIComponent(String.interpret(B))}return{initialize:function(B){this._object=Object.isHash(B)?B.toObject():Object.clone(B)},_each:function(D){for(var C in this._object){var E=this._object[C],B=[C,E];B.key=C;B.value=E;D(B)}},set:function(C,B){return this._object[C]=B},get:function(B){return this._object[B]},unset:function(C){var B=this._object[C];delete this._object[C];return B},toObject:function(){return Object.clone(this._object)},keys:function(){return this.pluck("key")},values:function(){return this.pluck("value")},index:function(B){var C=this.detect(function(D){return D.value===B});return C&&C.key},merge:function(B){return this.clone().update(B)},update:function(B){return new Hash(B).inject(this,function(C,D){C.set(D.key,D.value);return C})},toQueryString:function(){return this.map(function(B){var D=encodeURIComponent(B.key),C=B.value;if(C&&typeof C=="object"){if(Object.isArray(C)){return C.map(A.curry(D)).join("&")}}return A(D,C)}).join("&")},inspect:function(){return"#<Hash:{"+this.map(function(B){return B.map(Object.inspect).join(": ")}).join(", ")+"}>"},toJSON:function(){return Object.toJSON(this.toObject())},clone:function(){return new Hash(this)}}})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(B,C,A){this.start=B;this.end=C;this.exclusive=A},_each:function(B){var A=this.start;while(this.include(A)){B(A);A=A.succ()}},include:function(A){if(A<this.start){return false}if(this.exclusive){return A<this.end}return A<=this.end}});var $R=function(B,C,A){return new ObjectRange(B,C,A)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(A){this.responders._each(A)},register:function(A){if(!this.include(A)){this.responders.push(A)}},unregister:function(A){this.responders=this.responders.without(A)},dispatch:function(C,A,B,D){this.each(function(F){if(Object.isFunction(F[C])){try{F[C].apply(F,[A,B,D])}catch(E){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=Class.create({initialize:function(A){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:"",evalJSON:true,evalJS:true};Object.extend(this.options,A||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters)){this.options.parameters=this.options.parameters.toQueryParams()}else{if(Object.isHash(this.options.parameters)){this.options.parameters=this.options.parameters.toObject()}}}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,A,B){$super(B);this.transport=Ajax.getTransport();this.request(A)},request:function(A){this.url=A;this.method=this.options.method;var C=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){C._method=this.method;this.method="post"}this.parameters=C;if(C=Object.toQueryString(C)){if(this.method=="get"){this.url+=(this.url.include("?")?"&":"?")+C}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){C+="&_="}}}try{var D=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(D)}Ajax.Responders.dispatch("onCreate",this,D);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){this.respondToReadyState.bind(this).defer(1)}this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=="post"?(this.options.postBody||C):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}}catch(B){this.dispatchException(B)}},onStateChange:function(){var A=this.transport.readyState;if(A>1&&!((A==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var D={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){D["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){D.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var B=this.options.requestHeaders;if(Object.isFunction(B.push)){for(var A=0,C=B.length;A<C;A+=2){D[B[A]]=B[A+1]}}else{$H(B).each(function(F){D[F.key]=F.value})}}for(var E in D){this.transport.setRequestHeader(E,D[E])}},success:function(){var A=this.getStatus();return !A||(A>=200&&A<300)},getStatus:function(){try{return this.transport.status||0}catch(A){return 0}},respondToReadyState:function(E){var B=Ajax.Request.Events[E],A=new Ajax.Response(this);if(B=="Complete"){try{this._complete=true;(this.options["on"+A.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(A,A.headerJSON)}catch(C){this.dispatchException(C)}var D=A.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&D&&D.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){this.evalResponse()}}try{(this.options["on"+B]||Prototype.emptyFunction)(A,A.headerJSON);Ajax.Responders.dispatch("on"+B,this,A,A.headerJSON)}catch(C){this.dispatchException(C)}if(B=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction}},isSameOrigin:function(){var A=this.url.match(/^\s*https?:\/\/[^\/]*/);return !A||(A[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:document.domain,port:location.port?":"+location.port:""}))},getHeader:function(B){try{return this.transport.getResponseHeader(B)||null}catch(A){return null}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(A){(this.options.onException||Prototype.emptyFunction)(this,A);Ajax.Responders.dispatch("onException",this,A)}});Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Response=Class.create({initialize:function(B){this.request=B;var C=this.transport=B.transport,D=this.readyState=C.readyState;if((D>2&&!Prototype.Browser.IE)||D==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(C.responseText);this.headerJSON=this._getHeaderJSON()}if(D==4){var A=C.responseXML;this.responseXML=Object.isUndefined(A)?null:A;this.responseJSON=this._getResponseJSON()}},status:0,statusText:"",getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||""}catch(A){return""}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(A){return null}},getResponseHeader:function(A){return this.transport.getResponseHeader(A)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var B=this.getHeader("X-JSON");if(!B){return null}B=decodeURIComponent(escape(B));try{return B.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(A){this.request.dispatchException(A)}},_getResponseJSON:function(){var B=this.request.options;if(!B.evalJSON||(B.evalJSON!="force"&&!(this.getHeader("Content-type")||"").include("application/json"))||this.responseText.blank()){return null}try{return this.responseText.evalJSON(B.sanitizeJSON||!this.request.isSameOrigin())}catch(A){this.request.dispatchException(A)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,D,B,A){this.container={success:(D.success||D),failure:(D.failure||(D.success?null:D))};A=Object.clone(A);var C=A.onComplete;A.onComplete=(function(F,E){this.updateContent(F.responseText);if(Object.isFunction(C)){C(F,E)}}).bind(this);$super(B,A)},updateContent:function(C){var B=this.container[this.success()?"success":"failure"],D=this.options;if(!D.evalScripts){C=C.stripScripts()}if(B=$(B)){if(D.insertion){if(Object.isString(D.insertion)){var A={};A[D.insertion]=C;B.insert(A)}else{D.insertion(B,C)}}else{B.update(C)}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,C,B,A){$super(A);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=C;this.url=B;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(A){if(this.options.decay){this.decay=(A.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=A.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(A){if(arguments.length>1){for(var D=0,C=[],B=arguments.length;D<B;D++){C.push($(arguments[D]))}return C}if(Object.isString(A)){A=document.getElementById(A)}return Element.extend(A)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(E,F){var B=[];var D=document.evaluate(E,$(F)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var A=0,C=D.snapshotLength;A<C;A++){B.push(Element.extend(D.snapshotItem(A)))}return B}}if(!window.Node){var Node={}}if(!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(){var A=this.Element;this.Element=function(B,D){D=D||{};B=B.toLowerCase();var C=Element.cache;if(Prototype.Browser.IE&&D.name){B="<"+B+' name="'+D.name+'">';delete D.name;return Element.writeAttribute(document.createElement(B),D)}if(!C[B]){C[B]=Element.extend(document.createElement(B))}return Element.writeAttribute(C[B].cloneNode(false),D)};Object.extend(this.Element,A||{})}).call(window);Element.cache={};Element.Methods={visible:function(A){return $(A).style.display!="none"},toggle:function(A){A=$(A);Element[Element.visible(A)?"hide":"show"](A);return A},hide:function(A){$(A).style.display="none";return A},show:function(A){$(A).style.display="";return A},remove:function(A){A=$(A);A.parentNode.removeChild(A);return A},update:function(B,A){B=$(B);if(A&&A.toElement){A=A.toElement()}if(Object.isElement(A)){return B.update().insert(A)}A=Object.toHTML(A);B.innerHTML=A.stripScripts();A.evalScripts.bind(A).defer();return B},replace:function(A,B){A=$(A);if(B&&B.toElement){B=B.toElement()}else{if(!Object.isElement(B)){B=Object.toHTML(B);var C=A.ownerDocument.createRange();C.selectNode(A);B.evalScripts.bind(B).defer();B=C.createContextualFragment(B.stripScripts())}}A.parentNode.replaceChild(B,A);return A},insert:function(G,B){G=$(G);if(Object.isString(B)||Object.isNumber(B)||Object.isElement(B)||(B&&(B.toElement||B.toHTML))){B={bottom:B}}var A,C,F,D;for(var E in B){A=B[E];E=E.toLowerCase();C=Element._insertionTranslations[E];if(A&&A.toElement){A=A.toElement()}if(Object.isElement(A)){C(G,A);continue}A=Object.toHTML(A);F=((E=="before"||E=="after")?G.parentNode:G).tagName.toUpperCase();D=Element._getContentFromAnonymousElement(F,A.stripScripts());if(E=="top"||E=="after"){D.reverse()}D.each(C.curry(G));A.evalScripts.bind(A).defer()}return G},wrap:function(A,B,C){A=$(A);if(Object.isElement(B)){$(B).writeAttribute(C||{})}else{if(Object.isString(B)){B=new Element(B,C)}else{B=new Element("div",B)}}if(A.parentNode){A.parentNode.replaceChild(B,A)}B.appendChild(A);return B},inspect:function(A){A=$(A);var B="<"+A.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(C){var F=C.first(),D=C.last();var E=(A[F]||"").toString();if(E){B+=" "+D+"="+E.inspect(true)}});return B+">"},recursivelyCollect:function(C,B){C=$(C);var A=[];while(C=C[B]){if(C.nodeType==1){A.push(Element.extend(C))}}return A},ancestors:function(A){return $(A).recursivelyCollect("parentNode")},descendants:function(A){return $(A).select("*")},firstDescendant:function(A){A=$(A).firstChild;while(A&&A.nodeType!=1){A=A.nextSibling}return $(A)},immediateDescendants:function(A){if(!(A=$(A).firstChild)){return[]}while(A&&A.nodeType!=1){A=A.nextSibling}if(A){return[A].concat($(A).nextSiblings())}return[]},previousSiblings:function(A){return $(A).recursivelyCollect("previousSibling")},nextSiblings:function(A){return $(A).recursivelyCollect("nextSibling")},siblings:function(A){A=$(A);return A.previousSiblings().reverse().concat(A.nextSiblings())},match:function(A,B){if(Object.isString(B)){B=new Selector(B)}return B.match($(A))},up:function(A,C,D){A=$(A);if(arguments.length==1){return $(A.parentNode)}var B=A.ancestors();return Object.isNumber(C)?B[C]:Selector.findElement(B,C,D)},down:function(A,B,C){A=$(A);if(arguments.length==1){return A.firstDescendant()}return Object.isNumber(B)?A.descendants()[B]:A.select(B)[C||0]},previous:function(A,C,D){A=$(A);if(arguments.length==1){return $(Selector.handlers.previousElementSibling(A))}var B=A.previousSiblings();return Object.isNumber(C)?B[C]:Selector.findElement(B,C,D)},next:function(B,C,A){B=$(B);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(B))}var D=B.nextSiblings();return Object.isNumber(C)?D[C]:Selector.findElement(D,C,A)},select:function(){var B=$A(arguments),A=$(B.shift());return Selector.findChildElements(A,B)},adjacent:function(){var B=$A(arguments),A=$(B.shift());return Selector.findChildElements(A.parentNode,B).without(A)},identify:function(A){A=$(A);var B=A.readAttribute("id"),C=arguments.callee;if(B){return B}do{B="anonymous_element_"+C.counter++}while($(B));A.writeAttribute("id",B);return B},readAttribute:function(B,C){B=$(B);if(Prototype.Browser.IE){var A=Element._attributeTranslations.read;if(A.values[C]){return A.values[C](B,C)}if(A.names[C]){C=A.names[C]}if(C.include(":")){return(!B.attributes||!B.attributes[C])?null:B.attributes[C].value}}return B.getAttribute(C)},writeAttribute:function(D,B,E){D=$(D);var A={},C=Element._attributeTranslations.write;if(typeof B=="object"){A=B}else{A[B]=Object.isUndefined(E)?true:E}for(var F in A){B=C.names[F]||F;E=A[F];if(C.values[F]){B=C.values[F](D,E)}if(E===false||E===null){D.removeAttribute(B)}else{if(E===true){D.setAttribute(B,B)}else{D.setAttribute(B,E)}}}return D},getHeight:function(A){return $(A).getDimensions().height},getWidth:function(A){return $(A).getDimensions().width},classNames:function(A){return new Element.ClassNames(A)},hasClassName:function(C,A){if(!(C=$(C))){return }var B=C.className;return(B.length>0&&(B==A||new RegExp("(^|\\s)"+A+"(\\s|$)").test(B)))},addClassName:function(B,A){if(!(B=$(B))){return }if(!B.hasClassName(A)){B.className+=(B.className?" ":"")+A}return B},removeClassName:function(B,A){if(!(B=$(B))){return }B.className=B.className.replace(new RegExp("(^|\\s+)"+A+"(\\s+|$)")," ").strip();return B},toggleClassName:function(B,A){if(!(B=$(B))){return }return B[B.hasClassName(A)?"removeClassName":"addClassName"](A)},cleanWhitespace:function(A){A=$(A);var B=A.firstChild;while(B){var C=B.nextSibling;if(B.nodeType==3&&!/\S/.test(B.nodeValue)){A.removeChild(B)}B=C}return A},empty:function(A){return $(A).innerHTML.blank()},descendantOf:function(C,B){C=$(C),B=$(B);var E=B;if(C.compareDocumentPosition){return(C.compareDocumentPosition(B)&8)===8}if(C.sourceIndex&&!Prototype.Browser.Opera){var D=C.sourceIndex,A=B.sourceIndex,F=B.nextSibling;if(!F){do{B=B.parentNode}while(!(F=B.nextSibling)&&B.parentNode)}if(F&&F.sourceIndex){return(D>A&&D<F.sourceIndex)}}while(C=C.parentNode){if(C==E){return true}}return false},scrollTo:function(B){B=$(B);var A=B.cumulativeOffset();window.scrollTo(A[0],A[1]);return B},getStyle:function(A,B){A=$(A);B=B=="float"?"cssFloat":B.camelize();var C=A.style[B];if(!C){var D=document.defaultView.getComputedStyle(A,null);C=D?D[B]:null}if(B=="opacity"){return C?parseFloat(C):1}return C=="auto"?null:C},getOpacity:function(A){return $(A).getStyle("opacity")},setStyle:function(A,B){A=$(A);var D=A.style,E;if(Object.isString(B)){A.style.cssText+=";"+B;return B.include("opacity")?A.setOpacity(B.match(/opacity:\s*(\d?\.?\d*)/)[1]):A}for(var C in B){if(C=="opacity"){A.setOpacity(B[C])}else{D[(C=="float"||C=="cssFloat")?(Object.isUndefined(D.styleFloat)?"cssFloat":"styleFloat"):C]=B[C]}}return A},setOpacity:function(B,A){B=$(B);B.style.opacity=(A==1||A==="")?"":(A<0.00001)?0:A;return B},getDimensions:function(F){F=$(F);var B=$(F).getStyle("display");if(B!="none"&&B!=null){return{width:F.offsetWidth,height:F.offsetHeight}}var E=F.style;var A=E.visibility;var G=E.position;var D=E.display;E.visibility="hidden";E.position="absolute";E.display="block";var C=F.clientWidth;var H=F.clientHeight;E.display=D;E.position=G;E.visibility=A;return{width:C,height:H}},makePositioned:function(B){B=$(B);var A=Element.getStyle(B,"position");if(A=="static"||!A){B._madePositioned=true;B.style.position="relative";if(window.opera){B.style.top=0;B.style.left=0}}return B},undoPositioned:function(A){A=$(A);if(A._madePositioned){A._madePositioned=undefined;A.style.position=A.style.top=A.style.left=A.style.bottom=A.style.right=""}return A},makeClipping:function(A){A=$(A);if(A._overflow){return A}A._overflow=Element.getStyle(A,"overflow")||"auto";if(A._overflow!=="hidden"){A.style.overflow="hidden"}return A},undoClipping:function(A){A=$(A);if(!A._overflow){return A}A.style.overflow=A._overflow=="auto"?"":A._overflow;A._overflow=null;return A},cumulativeOffset:function(A){var C=0,B=0;do{C+=A.offsetTop||0;B+=A.offsetLeft||0;A=A.offsetParent}while(A);return Element._returnOffset(B,C)},positionedOffset:function(A){var D=0,C=0;do{D+=A.offsetTop||0;C+=A.offsetLeft||0;A=A.offsetParent;if(A){if(A.tagName=="BODY"){break}var B=Element.getStyle(A,"position");if(B!=="static"){break}}}while(A);return Element._returnOffset(C,D)},absolutize:function(A){A=$(A);if(A.getStyle("position")=="absolute"){return }var C=A.positionedOffset();var E=C[1];var D=C[0];var B=A.clientWidth;var F=A.clientHeight;A._originalLeft=D-parseFloat(A.style.left||0);A._originalTop=E-parseFloat(A.style.top||0);A._originalWidth=A.style.width;A._originalHeight=A.style.height;A.style.position="absolute";A.style.top=E+"px";A.style.left=D+"px";A.style.width=B+"px";A.style.height=F+"px";return A},relativize:function(C){C=$(C);if(C.getStyle("position")=="relative"){return }C.style.position="relative";var B=parseFloat(C.style.top||0)-(C._originalTop||0);var A=parseFloat(C.style.left||0)-(C._originalLeft||0);C.style.top=B+"px";C.style.left=A+"px";C.style.height=C._originalHeight;C.style.width=C._originalWidth;return C},cumulativeScrollOffset:function(A){var C=0,B=0;do{C+=A.scrollTop||0;B+=A.scrollLeft||0;A=A.parentNode}while(A);return Element._returnOffset(B,C)},getOffsetParent:function(A){if(A.offsetParent){return $(A.offsetParent)}if(A==document.body){return $(A)}while((A=A.parentNode)&&A!=document.body){if(Element.getStyle(A,"position")!="static"){return $(A)}}return $(document.body)},viewportOffset:function(C){var D=0,B=0;var A=C;do{D+=A.offsetTop||0;B+=A.offsetLeft||0;if(A.offsetParent==document.body&&Element.getStyle(A,"position")=="absolute"){break}}while(A=A.offsetParent);A=C;do{if(!Prototype.Browser.Opera||A.tagName=="BODY"){D-=A.scrollTop||0;B-=A.scrollLeft||0}}while(A=A.parentNode);return Element._returnOffset(B,D)},clonePosition:function(A,C){var F=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});C=$(C);var D=C.viewportOffset();A=$(A);var E=[0,0];var B=null;if(Element.getStyle(A,"position")=="absolute"){B=A.getOffsetParent();E=B.viewportOffset()}if(B==document.body){E[0]-=document.body.offsetLeft;E[1]-=document.body.offsetTop}if(F.setLeft){A.style.left=(D[0]-E[0]+F.offsetLeft)+"px"}if(F.setTop){A.style.top=(D[1]-E[1]+F.offsetTop)+"px"}if(F.setWidth){A.style.width=C.offsetWidth+"px"}if(F.setHeight){A.style.height=C.offsetHeight+"px"}return A}};Element.Methods.identify.counter=1;Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}};if(Prototype.Browser.Opera){Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(C,A,B){switch(B){case"left":case"top":case"right":case"bottom":if(C(A,"position")==="static"){return null}case"height":case"width":if(!Element.visible(A)){return null}var D=parseInt(C(A,B),10);if(D!==A["offset"+B.capitalize()]){return D+"px"}var E;if(B==="height"){E=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{E=["border-left-width","padding-left","padding-right","border-right-width"]}return E.inject(D,function(G,H){var F=C(A,H);return F===null?G:G-parseInt(F,10)})+"px";default:return C(A,B)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(B,C,A){if(A==="title"){return C.title}return B(C,A)})}else{if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(B,A){A=$(A);var D=A.getStyle("position");if(D!=="static"){return B(A)}A.setStyle({position:"relative"});var C=B(A);A.setStyle({position:D});return C});$w("positionedOffset viewportOffset").each(function(A){Element.Methods[A]=Element.Methods[A].wrap(function(F,D){D=$(D);var C=D.getStyle("position");if(C!=="static"){return F(D)}var E=D.getOffsetParent();if(E&&E.getStyle("position")==="fixed"){E.setStyle({zoom:1})}D.setStyle({position:"relative"});var B=F(D);D.setStyle({position:C});return B})});Element.Methods.getStyle=function(C,A){C=$(C);A=(A=="float"||A=="cssFloat")?"styleFloat":A.camelize();var B=C.style[A];if(!B&&C.currentStyle){B=C.currentStyle[A]}if(A=="opacity"){if(B=(C.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(B[1]){return parseFloat(B[1])/100}}return 1}if(B=="auto"){if((A=="width"||A=="height")&&(C.getStyle("display")!="none")){return C["offset"+A.capitalize()]+"px"}return null}return B};Element.Methods.setOpacity=function(A,D){function E(G){return G.replace(/alpha\([^\)]*\)/gi,"")}A=$(A);var F=A.currentStyle;if((F&&!F.hasLayout)||(!F&&A.style.zoom=="normal")){A.style.zoom=1}var C=A.getStyle("filter"),B=A.style;if(D==1||D===""){(C=E(C))?B.filter=C:B.removeAttribute("filter");return A}else{if(D<0.00001){D=0}}B.filter=E(C)+"alpha(opacity="+(D*100)+")";return A};Element._attributeTranslations={read:{names:{"class":"className","for":"htmlFor"},values:{_getAttr:function(B,A){return B.getAttribute(A,2)},_getAttrNode:function(C,B){var A=C.getAttributeNode(B);return A?A.value:""},_getEv:function(B,A){A=B.getAttribute(A);return A?A.toString().slice(23,-2):null},_flag:function(B,A){return $(B).hasAttribute(A)?A:null},style:function(A){return A.style.cssText.toLowerCase()},title:function(A){return A.title}}}};Element._attributeTranslations.write={names:Object.extend({cellpadding:"cellPadding",cellspacing:"cellSpacing"},Element._attributeTranslations.read.names),values:{checked:function(B,A){B.checked=!!A},style:function(B,A){B.style.cssText=A?A:""}}};Element._attributeTranslations.has={};$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc").each(function(A){Element._attributeTranslations.write.names[A.toLowerCase()]=A;Element._attributeTranslations.has[A.toLowerCase()]=A});(function(A){Object.extend(A,{href:A._getAttr,src:A._getAttr,type:A._getAttr,action:A._getAttrNode,disabled:A._flag,checked:A._flag,readonly:A._flag,multiple:A._flag,onload:A._getEv,onunload:A._getEv,onclick:A._getEv,ondblclick:A._getEv,onmousedown:A._getEv,onmouseup:A._getEv,onmouseover:A._getEv,onmousemove:A._getEv,onmouseout:A._getEv,onfocus:A._getEv,onblur:A._getEv,onkeypress:A._getEv,onkeydown:A._getEv,onkeyup:A._getEv,onsubmit:A._getEv,onreset:A._getEv,onselect:A._getEv,onchange:A._getEv})})(Element._attributeTranslations.read.values)}else{if(Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){Element.Methods.setOpacity=function(B,A){B=$(B);B.style.opacity=(A==1)?0.999999:(A==="")?"":(A<0.00001)?0:A;return B}}else{if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(D,A){D=$(D);D.style.opacity=(A==1||A==="")?"":(A<0.00001)?0:A;if(A==1){if(D.tagName=="IMG"&&D.width){D.width++;D.width--}else{try{var C=document.createTextNode(" ");D.appendChild(C);D.removeChild(C)}catch(B){}}}return D};Element.Methods.cumulativeOffset=function(A){var C=0,B=0;do{C+=A.offsetTop||0;B+=A.offsetLeft||0;if(A.offsetParent==document.body){if(Element.getStyle(A,"position")=="absolute"){break}}A=A.offsetParent}while(A);return Element._returnOffset(B,C)}}}}}if(Prototype.Browser.IE||Prototype.Browser.Opera){Element.Methods.update=function(A,B){A=$(A);if(B&&B.toElement){B=B.toElement()}if(Object.isElement(B)){return A.update().insert(B)}B=Object.toHTML(B);var C=A.tagName.toUpperCase();if(C in Element._insertionTranslations.tags){$A(A.childNodes).each(function(D){A.removeChild(D)});Element._getContentFromAnonymousElement(C,B.stripScripts()).each(function(D){A.appendChild(D)})}else{A.innerHTML=B.stripScripts()}B.evalScripts.bind(B).defer();return A}}if("outerHTML" in document.createElement("div")){Element.Methods.replace=function(B,D){B=$(B);if(D&&D.toElement){D=D.toElement()}if(Object.isElement(D)){B.parentNode.replaceChild(D,B);return B}D=Object.toHTML(D);var C=B.parentNode,A=C.tagName.toUpperCase();if(Element._insertionTranslations.tags[A]){var E=B.next();var F=Element._getContentFromAnonymousElement(A,D.stripScripts());C.removeChild(B);if(E){F.each(function(G){C.insertBefore(G,E)})}else{F.each(function(G){C.appendChild(G)})}}else{B.outerHTML=D.stripScripts()}D.evalScripts.bind(D).defer();return B}}Element._returnOffset=function(A,B){var C=[A,B];C.left=A;C.top=B;return C};Element._getContentFromAnonymousElement=function(B,A){var C=new Element("div"),D=Element._insertionTranslations.tags[B];if(D){C.innerHTML=D[0]+A+D[1];D[2].times(function(){C=C.firstChild})}else{C.innerHTML=A}return $A(C.childNodes)};Element._insertionTranslations={before:function(B,A){B.parentNode.insertBefore(A,B)},top:function(B,A){B.insertBefore(A,B.firstChild)},bottom:function(B,A){B.appendChild(A)},after:function(B,A){B.parentNode.insertBefore(A,B.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(){Object.extend(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD})}).call(Element._insertionTranslations);Element.Methods.Simulated={hasAttribute:function(C,B){B=Element._attributeTranslations.has[B]||B;var A=$(C).getAttributeNode(B);return A&&A.specified}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div").__proto__){window.HTMLElement={};window.HTMLElement.prototype=document.createElement("div").__proto__;Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions){return Prototype.K}var C={},A=Element.Methods.ByTag;var B=Object.extend(function(G){if(!G||G._extendedByPrototype||G.nodeType!=1||G==window){return G}var E=Object.clone(C),F=G.tagName,D,H;if(A[F]){Object.extend(E,A[F])}for(D in E){H=E[D];if(Object.isFunction(H)&&!(D in G)){G[D]=H.methodize()}}G._extendedByPrototype=Prototype.emptyFunction;return G},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(C,Element.Methods);Object.extend(C,Element.Methods.Simulated)}}});B.refresh();return B})();Element.hasAttribute=function(B,A){if(B.hasAttribute){return B.hasAttribute(A)}return Element.Methods.Simulated.hasAttribute(B,A)};Element.addMethods=function(I){var D=Prototype.BrowserFeatures,J=Element.Methods.ByTag;if(!I){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{FORM:Object.clone(Form.Methods),INPUT:Object.clone(Form.Element.Methods),SELECT:Object.clone(Form.Element.Methods),TEXTAREA:Object.clone(Form.Element.Methods)})}if(arguments.length==2){var H=I;I=arguments[1]}if(!H){Object.extend(Element.Methods,I||{})}else{if(Object.isArray(H)){H.each(C)}else{C(H)}}function C(F){F=F.toUpperCase();if(!Element.Methods.ByTag[F]){Element.Methods.ByTag[F]={}}Object.extend(Element.Methods.ByTag[F],I)}function G(F,N,M){M=M||false;for(var L in F){var K=F[L];if(!Object.isFunction(K)){continue}if(!M||!(L in N)){N[L]=K.methodize()}}}function A(F){var K;var L={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(L[F]){K="HTML"+L[F]+"Element"}if(window[K]){return window[K]}K="HTML"+F+"Element";if(window[K]){return window[K]}K="HTML"+F.capitalize()+"Element";if(window[K]){return window[K]}window[K]={};window[K].prototype=document.createElement(F).__proto__;return window[K]}if(D.ElementExtensions){G(Element.Methods,HTMLElement.prototype);G(Element.Methods.Simulated,HTMLElement.prototype,true)}if(D.SpecificElementExtensions){for(var E in Element.Methods.ByTag){var B=A(E);if(Object.isUndefined(B)){continue}G(J[E],B.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh()}Element.cache={}};document.viewport={getDimensions:function(){var C={};var A=Prototype.Browser;$w("width height").each(function(B){var D=B.capitalize();C[B]=(A.WebKit&&!document.evaluate)?self["inner"+D]:(A.Opera)?document.body["client"+D]:document.documentElement["client"+D]});return C},getWidth:function(){return this.getDimensions().width},getHeight:function(){return this.getDimensions().height},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};var Selector=Class.create({initialize:function(A){this.expression=A.strip();this.compileMatcher()},shouldUseXPath:function(){if(!Prototype.BrowserFeatures.XPath){return false}var A=this.expression;if(Prototype.Browser.WebKit&&(A.include("-of-type")||A.include(":empty"))){return false}if((/(\[[\w-]*?:|:checked)/).test(this.expression)){return false}return true},compileMatcher:function(){if(this.shouldUseXPath()){return this.compileXPathMatcher()}var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return }this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(Object.isFunction(c[i])?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],"");break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join("\n"));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var D=this.expression,E=Selector.patterns,A=Selector.xpath,C,F;if(Selector._cache[D]){this.xpath=Selector._cache[D];return }this.matcher=[".//*"];while(D&&C!=D&&(/\S/).test(D)){C=D;for(var B in E){if(F=D.match(E[B])){this.matcher.push(Object.isFunction(A[B])?A[B](F):new Template(A[B]).evaluate(F));D=D.replace(F[0],"");break}}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath},findElements:function(A){A=A||document;if(this.xpath){return document._getElementsByXPath(this.xpath,A)}return this.matcher(A)},match:function(D){this.tokens=[];var H=this.expression,I=Selector.patterns,A=Selector.assertions;var J,L,B;while(H&&J!==H&&(/\S/).test(H)){J=H;for(var E in I){L=I[E];if(B=H.match(L)){if(A[E]){this.tokens.push([E,Object.clone(B)]);H=H.replace(B[0],"")}else{return this.findElements(document).include(D)}}}}var G=true,K,F;for(var E=0,C;C=this.tokens[E];E++){K=C[0],F=C[1];if(!Selector.assertions[K](D,F)){G=false;break}}return G},toString:function(){return this.expression},inspect:function(){return"#<Selector:"+this.expression.inspect()+">"}});Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(A){if(A[1]=="*"){return""}return"[local-name()='"+A[1].toLowerCase()+"' or local-name()='"+A[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:function(A){A[1]=A[1].toLowerCase();return new Template("[@#{1}]").evaluate(A)},attr:function(A){A[1]=A[1].toLowerCase();A[3]=A[5]||A[6];return new Template(Selector.xpath.operators[A[2]]).evaluate(A)},pseudo:function(B){var A=Selector.xpath.pseudos[B[1]];if(!A){return""}if(Object.isFunction(A)){return A(B)}return new Template(Selector.xpath.pseudos[B[1]]).evaluate(B)},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]",empty:"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",checked:"[@checked]",disabled:"[@disabled]",enabled:"[not(@disabled)]",not:function(E){var C=E[6],B=Selector.patterns,D=Selector.xpath,H,F;var A=[];while(C&&H!=C&&(/\S/).test(C)){H=C;for(var G in B){if(E=C.match(B[G])){F=Object.isFunction(D[G])?D[G](E):new Template(D[G]).evaluate(E);A.push("("+F.substring(1,F.length-1)+")");C=C.replace(E[0],"");break}}}return"[not("+A.join(" and ")+")]"},"nth-child":function(A){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",A)},"nth-last-child":function(A){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",A)},"nth-of-type":function(A){return Selector.xpath.pseudos.nth("position() ",A)},"nth-last-of-type":function(A){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",A)},"first-of-type":function(A){A[6]="1";return Selector.xpath.pseudos["nth-of-type"](A)},"last-of-type":function(A){A[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](A)},"only-of-type":function(B){var A=Selector.xpath.pseudos;return A["first-of-type"](B)+A["last-of-type"](B)},nth:function(B,G){var C,D=G[6],F;if(D=="even"){D="2n+0"}if(D=="odd"){D="2n+1"}if(C=D.match(/^(\d+)$/)){return"["+B+"= "+C[1]+"]"}if(C=D.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(C[1]=="-"){C[1]=-1}var A=C[1]?Number(C[1]):1;var E=C[2]?Number(C[2]):0;F="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(F).evaluate({fragment:B,a:A,b:E})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);      c = false;',className:'n = h.className(n, r, "#{1}", c);    c = false;',id:'n = h.id(n, r, "#{1}", c);           c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}", c); c = false;',attr:function(A){A[3]=(A[5]||A[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(A)},pseudo:function(A){if(A[6]){A[6]=A[6].replace(/"/g,'\\"')}return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(A)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(B,A){return A[1].toUpperCase()==B.tagName.toUpperCase()},className:function(B,A){return Element.hasClassName(B,A[1])},id:function(B,A){return B.id===A[1]},attrPresence:function(B,A){return Element.hasAttribute(B,A[1])},attr:function(A,B){var C=Element.readAttribute(A,B[1]);return C&&Selector.operators[B[2]](C,B[5]||B[6])}},handlers:{concat:function(A,D){for(var B=0,C;C=D[B];B++){A.push(C)}return A},mark:function(D){var C=Prototype.emptyFunction;for(var A=0,B;B=D[A];A++){B._countedByPrototype=C}return D},unmark:function(C){for(var A=0,B;B=C[A];A++){B._countedByPrototype=undefined}return C},index:function(E,A,D){E._countedByPrototype=Prototype.emptyFunction;if(A){for(var F=E.childNodes,B=F.length-1,G=1;B>=0;B--){var C=F[B];if(C.nodeType==1&&(!D||C._countedByPrototype)){C.nodeIndex=G++}}}else{for(var B=0,G=1,F=E.childNodes;C=F[B];B++){if(C.nodeType==1&&(!D||C._countedByPrototype)){C.nodeIndex=G++}}}},unique:function(A){if(A.length==0){return A}var C=[],D;for(var B=0,E=A.length;B<E;B++){if(!(D=A[B])._countedByPrototype){D._countedByPrototype=Prototype.emptyFunction;C.push(Element.extend(D))}}return Selector.handlers.unmark(C)},descendant:function(E){var C=Selector.handlers;for(var B=0,A=[],D;D=E[B];B++){C.concat(A,D.getElementsByTagName("*"))}return A},child:function(E){var B=Selector.handlers;for(var A=0,G=[],C;C=E[A];A++){for(var F=0,D;D=C.childNodes[F];F++){if(D.nodeType==1&&D.tagName!="!"){G.push(D)}}}return G},adjacent:function(E){for(var B=0,A=[],D;D=E[B];B++){var C=this.nextElementSibling(D);if(C){A.push(C)}}return A},laterSibling:function(E){var C=Selector.handlers;for(var B=0,A=[],D;D=E[B];B++){C.concat(A,Element.nextSiblings(D))}return A},nextElementSibling:function(A){while(A=A.nextSibling){if(A.nodeType==1){return A}}return null},previousElementSibling:function(A){while(A=A.previousSibling){if(A.nodeType==1){return A}}return null},tagName:function(F,D,H,G){var E=H.toUpperCase();var A=[],C=Selector.handlers;if(F){if(G){if(G=="descendant"){for(var B=0,I;I=F[B];B++){C.concat(A,I.getElementsByTagName(H))}return A}else{F=this[G](F)}if(H=="*"){return F}}for(var B=0,I;I=F[B];B++){if(I.tagName.toUpperCase()===E){A.push(I)}}return A}else{return D.getElementsByTagName(H)}},id:function(E,D,C,A){var B=$(C),G=Selector.handlers;if(!B){return[]}if(!E&&D==document){return[B]}if(E){if(A){if(A=="child"){for(var F=0,H;H=E[F];F++){if(B.parentNode==H){return[B]}}}else{if(A=="descendant"){for(var F=0,H;H=E[F];F++){if(Element.descendantOf(B,H)){return[B]}}}else{if(A=="adjacent"){for(var F=0,H;H=E[F];F++){if(Selector.handlers.previousElementSibling(B)==H){return[B]}}}else{E=G[A](E)}}}}for(var F=0,H;H=E[F];F++){if(H==B){return[B]}}return[]}return(B&&Element.descendantOf(B,D))?[B]:[]},className:function(A,D,B,C){if(A&&C){A=this[C](A)}return Selector.handlers.byClassName(A,D,B)},byClassName:function(F,E,A){if(!F){F=Selector.handlers.descendant([E])}var C=" "+A+" ";for(var H=0,G=[],B,D;B=F[H];H++){D=B.className;if(D.length==0){continue}if(D==A||(" "+D+" ").include(C)){G.push(B)}}return G},attrPresence:function(G,F,E,D){if(!G){G=F.getElementsByTagName("*")}if(G&&D){G=this[D](G)}var B=[];for(var A=0,C;C=G[A];A++){if(Element.hasAttribute(C,E)){B.push(C)}}return B},attr:function(H,E,D,F,J,I){if(!H){H=E.getElementsByTagName("*")}if(H&&I){H=this[I](H)}var G=Selector.operators[J],B=[];for(var A=0,K;K=H[A];A++){var C=Element.readAttribute(K,D);if(C===null){continue}if(G(C,F)){B.push(K)}}return B},pseudo:function(A,B,D,E,C){if(A&&C){A=this[C](A)}if(!A){A=E.getElementsByTagName("*")}return Selector.pseudos[B](A,D,E)}},pseudos:{"first-child":function(A,E,F){for(var C=0,B=[],D;D=A[C];C++){if(Selector.handlers.previousElementSibling(D)){continue}B.push(D)}return B},"last-child":function(A,E,F){for(var C=0,B=[],D;D=A[C];C++){if(Selector.handlers.nextElementSibling(D)){continue}B.push(D)}return B},"only-child":function(F,D,E){var B=Selector.handlers;for(var A=0,G=[],C;C=F[A];A++){if(!B.previousElementSibling(C)&&!B.nextElementSibling(C)){G.push(C)}}return G},"nth-child":function(A,B,C){return Selector.pseudos.nth(A,B,C)},"nth-last-child":function(A,B,C){return Selector.pseudos.nth(A,B,C,true)},"nth-of-type":function(A,B,C){return Selector.pseudos.nth(A,B,C,false,true)},"nth-last-of-type":function(A,B,C){return Selector.pseudos.nth(A,B,C,true,true)},"first-of-type":function(A,B,C){return Selector.pseudos.nth(A,"1",C,false,true)},"last-of-type":function(A,B,C){return Selector.pseudos.nth(A,"1",C,true,true)},"only-of-type":function(A,C,D){var B=Selector.pseudos;return B["last-of-type"](B["first-of-type"](A,C,D),C,D)},getIndices:function(A,C,B){if(A==0){return C>0?[C]:[]}return $R(1,B).inject([],function(E,D){if(0==(D-C)%A&&(D-C)/A>=0){E.push(D)}return E})},nth:function(G,B,D,A,I){if(G.length==0){return[]}if(B=="even"){B="2n+0"}if(B=="odd"){B="2n+1"}var P=Selector.handlers,O=[],H=[],K;P.mark(G);for(var N=0,J;J=G[N];N++){if(!J.parentNode._countedByPrototype){P.index(J.parentNode,A,I);H.push(J.parentNode)}}if(B.match(/^\d+$/)){B=Number(B);for(var N=0,J;J=G[N];N++){if(J.nodeIndex==B){O.push(J)}}}else{if(K=B.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(K[1]=="-"){K[1]=-1}var E=K[1]?Number(K[1]):1;var C=K[2]?Number(K[2]):0;var F=Selector.pseudos.getIndices(E,C,G.length);for(var N=0,J,L=F.length;J=G[N];N++){for(var M=0;M<L;M++){if(J.nodeIndex==F[M]){O.push(J)}}}}}P.unmark(G);P.unmark(H);return O},empty:function(A,E,F){for(var C=0,B=[],D;D=A[C];C++){if(D.tagName=="!"||(D.firstChild&&!D.innerHTML.match(/^\s*$/))){continue}B.push(D)}return B},not:function(G,J,E){var C=Selector.handlers,F,I;var D=new Selector(J).findElements(E);C.mark(D);for(var B=0,A=[],H;H=G[B];B++){if(!H._countedByPrototype){A.push(H)}}C.unmark(D);return A},enabled:function(A,E,F){for(var C=0,B=[],D;D=A[C];C++){if(!D.disabled){B.push(D)}}return B},disabled:function(A,E,F){for(var C=0,B=[],D;D=A[C];C++){if(D.disabled){B.push(D)}}return B},checked:function(A,E,F){for(var C=0,B=[],D;D=A[C];C++){if(D.checked){B.push(D)}}return B}},operators:{"=":function(A,B){return A==B},"!=":function(A,B){return A!=B},"^=":function(A,B){return A.startsWith(B)},"$=":function(A,B){return A.endsWith(B)},"*=":function(A,B){return A.include(B)},"~=":function(A,B){return(" "+A+" ").include(" "+B+" ")},"|=":function(A,B){return("-"+A.toUpperCase()+"-").include("-"+B.toUpperCase()+"-")}},split:function(A){var B=[];A.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(C){B.push(C[1].strip())});return B},matchElements:function(C,D){var B=$$(D),A=Selector.handlers;A.mark(B);for(var G=0,F=[],E;E=C[G];G++){if(E._countedByPrototype){F.push(E)}}A.unmark(B);return F},findElement:function(A,B,C){if(Object.isNumber(B)){C=B;B=false}return Selector.matchElements(A,B||"*")[C||0]},findChildElements:function(B,D){D=Selector.split(D.join(","));var A=[],C=Selector.handlers;for(var G=0,F=D.length,E;G<F;G++){E=new Selector(D[G].strip());C.concat(A,E.findElements(B))}return(F>1)?C.unique(A):A}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(A,D){for(var B=0,C;C=D[B];B++){if(C.tagName!=="!"){A.push(C)}}return A},unmark:function(C){for(var A=0,B;B=C[A];A++){B.removeAttribute("_countedByPrototype")}return C}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(A){$(A).reset();return A},serializeElements:function(D,F){if(typeof F!="object"){F={hash:!!F}}else{if(Object.isUndefined(F.hash)){F.hash=true}}var G,C,E=false,B=F.submit;var A=D.inject({},function(I,H){if(!H.disabled&&H.name){G=H.name;C=$(H).getValue();if(C!=null&&(H.type!="submit"||(!E&&B!==false&&(!B||G==B)&&(E=true)))){if(G in I){if(!Object.isArray(I[G])){I[G]=[I[G]]}I[G].push(C)}else{I[G]=C}}}return I});return F.hash?A:Object.toQueryString(A)}};Form.Methods={serialize:function(A,B){return Form.serializeElements(Form.getElements(A),B)},getElements:function(A){return $A($(A).getElementsByTagName("*")).inject([],function(C,B){if(Form.Element.Serializers[B.tagName.toLowerCase()]){C.push(Element.extend(B))}return C})},getInputs:function(B,F,G){B=$(B);var D=B.getElementsByTagName("input");if(!F&&!G){return $A(D).map(Element.extend)}for(var H=0,C=[],A=D.length;H<A;H++){var E=D[H];if((F&&E.type!=F)||(G&&E.name!=G)){continue}C.push(Element.extend(E))}return C},disable:function(A){A=$(A);Form.getElements(A).invoke("disable");return A},enable:function(A){A=$(A);Form.getElements(A).invoke("enable");return A},findFirstElement:function(A){var B=$(A).getElements().findAll(function(D){return"hidden"!=D.type&&!D.disabled});var C=B.findAll(function(D){return D.hasAttribute("tabIndex")&&D.tabIndex>=0}).sortBy(function(D){return D.tabIndex}).first();return C?C:B.find(function(D){return["input","select","textarea"].include(D.tagName.toLowerCase())})},focusFirstElement:function(A){A=$(A);A.findFirstElement().activate();return A},request:function(A,D){A=$(A),D=Object.clone(D||{});var C=D.parameters,B=A.readAttribute("action")||"";if(B.blank()){B=window.location.href}D.parameters=A.serialize(true);if(C){if(Object.isString(C)){C=C.toQueryParams()}Object.extend(D.parameters,C)}if(A.hasAttribute("method")&&!D.method){D.method=A.method}return new Ajax.Request(B,D)}};Form.Element={focus:function(A){$(A).focus();return A},select:function(A){$(A).select();return A}};Form.Element.Methods={serialize:function(C){C=$(C);if(!C.disabled&&C.name){var A=C.getValue();if(A!=undefined){var B={};B[C.name]=A;return Object.toQueryString(B)}}return""},getValue:function(B){B=$(B);var A=B.tagName.toLowerCase();return Form.Element.Serializers[A](B)},setValue:function(C,A){C=$(C);var B=C.tagName.toLowerCase();Form.Element.Serializers[B](C,A);return C},clear:function(A){$(A).value="";return A},present:function(A){return $(A).value!=""},activate:function(B){B=$(B);try{B.focus();if(B.select&&(B.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(B.type))){B.select()}}catch(A){}return B},disable:function(A){A=$(A);A.blur();A.disabled=true;return A},enable:function(A){A=$(A);A.disabled=false;return A}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(B,A){switch(B.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(B,A);default:return Form.Element.Serializers.textarea(B,A)}},inputSelector:function(B,A){if(Object.isUndefined(A)){return B.checked?B.value:null}else{B.checked=!!A}},textarea:function(B,A){if(Object.isUndefined(A)){return B.value}else{B.value=A}},select:function(A,E){if(Object.isUndefined(E)){return this[A.type=="select-one"?"selectOne":"selectMany"](A)}else{var G,C,D=!Object.isArray(E);for(var F=0,B=A.length;F<B;F++){G=A.options[F];C=this.optionValue(G);if(D){if(C==E){G.selected=true;return }}else{G.selected=E.include(C)}}}},selectOne:function(A){var B=A.selectedIndex;return B>=0?this.optionValue(A.options[B]):null},selectMany:function(C){var E,D=C.length;if(!D){return null}for(var B=0,E=[];B<D;B++){var A=C.options[B];if(A.selected){E.push(this.optionValue(A))}}return E},optionValue:function(A){return Element.extend(A).hasAttribute("value")?A.value:A.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,C,A,B){$super(B,A);this.element=$(C);this.lastValue=this.getValue()},execute:function(){var A=this.getValue();if(Object.isString(this.lastValue)&&Object.isString(A)?this.lastValue!=A:String(this.lastValue)!=String(A)){this.callback(this.element,A);this.lastValue=A}}});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(B,A){this.element=$(B);this.callback=A;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks()}else{this.registerCallback(this.element)}},onElementEvent:function(){var A=this.getValue();if(this.lastValue!=A){this.callback(this.element,A);this.lastValue=A}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this)},registerCallback:function(A){if(A.type){switch(A.type.toLowerCase()){case"checkbox":case"radio":Event.observe(A,"click",this.onElementEvent.bind(this));break;default:Event.observe(A,"change",this.onElementEvent.bind(this));break}}}});Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element)}});if(!window.Event){var Event={}}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{},relatedTarget:function(A){var B;switch(A.type){case"mouseover":B=A.fromElement;break;case"mouseout":B=A.toElement;break;default:return null}return Element.extend(B)}});Event.Methods=(function(){var B;if(Prototype.Browser.IE){var A={0:1,1:4,2:2};B=function(C,D){return C.button==A[D]}}else{if(Prototype.Browser.WebKit){B=function(C,D){switch(D){case 0:return C.which==1&&!C.metaKey;case 1:return C.which==1&&C.metaKey;default:return false}}}else{B=function(C,D){return C.which?(C.which===D+1):(C.button===D)}}}return{isLeftClick:function(C){return B(C,0)},isMiddleClick:function(C){return B(C,1)},isRightClick:function(C){return B(C,2)},element:function(C){var D=Event.extend(C).target;return Element.extend(D.nodeType==Node.TEXT_NODE?D.parentNode:D)},findElement:function(E,C){var D=Event.element(E);if(!C){return D}var F=[D].concat(D.ancestors());return Selector.findElement(F,C,0)},pointer:function(C){return{x:C.pageX||(C.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)),y:C.pageY||(C.clientY+(document.documentElement.scrollTop||document.body.scrollTop))}},pointerX:function(C){return Event.pointer(C).x},pointerY:function(C){return Event.pointer(C).y},stop:function(C){Event.extend(C);C.preventDefault();C.stopPropagation();C.stopped=true}}})();Event.extend=(function(){var A=Object.keys(Event.Methods).inject({},function(C,B){C[B]=Event.Methods[B].methodize();return C});if(Prototype.Browser.IE){Object.extend(A,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});return function(C){if(!C){return false}if(C._extendedByPrototype){return C}C._extendedByPrototype=Prototype.emptyFunction;var B=Event.pointer(C);Object.extend(C,{target:C.srcElement,relatedTarget:Event.relatedTarget(C),pageX:B.x,pageY:B.y});return Object.extend(C,A)}}else{Event.prototype=Event.prototype||document.createEvent("HTMLEvents").__proto__;Object.extend(Event.prototype,A);return Prototype.K}})();Object.extend(Event,(function(){var G=Event.cache;function H(J){if(J._prototypeEventID){return J._prototypeEventID[0]}arguments.callee.id=arguments.callee.id||1;return J._prototypeEventID=[++arguments.callee.id]}function C(J){if(J&&J.include(":")){return"dataavailable"}return J}function F(J){return G[J]=G[J]||{}}function B(J,K){var L=F(J);return L[K]=L[K]||[]}function D(O,N,J){var M=H(O);var L=B(M,N);if(L.pluck("handler").include(J)){return false}var K=function(P){if(!Event||!Event.extend||(P.eventName&&P.eventName!=N)){return false}Event.extend(P);J.call(O,P)};K.handler=J;L.push(K);return K}function E(K,L,M){var J=B(K,L);return J.find(function(N){return N.handler==M})}function I(K,L,M){var J=F(K);if(!J[L]){return false}J[L]=J[L].without(E(K,L,M))}function A(){for(var J in G){for(var K in G[J]){G[J][K]=null}}}if(window.attachEvent){window.attachEvent("onunload",A)}return{observe:function(J,M,K){J=$(J);var N=C(M);var L=D(J,M,K);if(!L){return J}if(J.addEventListener){J.addEventListener(N,L,false)}else{J.attachEvent("on"+N,L)}return J},stopObserving:function(J,N,K){J=$(J);var M=H(J),O=C(N);if(!K&&N){B(M,N).each(function(P){J.stopObserving(N,P.handler)});return J}else{if(!N){Object.keys(F(M)).each(function(P){J.stopObserving(P)});return J}}var L=E(M,N,K);if(!L){return J}if(J.removeEventListener){J.removeEventListener(O,L,false)}else{J.detachEvent("on"+O,L)}I(M,N,K);return J},fire:function(J,M,L){J=$(J);if(J==document&&document.createEvent&&!J.dispatchEvent){J=document.documentElement}var K;if(document.createEvent){K=document.createEvent("HTMLEvents");K.initEvent("dataavailable",true,true)}else{K=document.createEventObject();K.eventType="ondataavailable"}K.eventName=M;K.memo=L||{};if(document.createEvent){J.dispatchEvent(K)}else{J.fireEvent(K.eventType,K)}return Event.extend(K)}}})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize(),loaded:false});(function(){var A;function B(){if(document.loaded){return }if(A){window.clearInterval(A)}document.fire("dom:loaded");document.loaded=true}if(document.addEventListener){if(Prototype.Browser.WebKit){A=window.setInterval(function(){if(/loaded|complete/.test(document.readyState)){B()}},0);Event.observe(window,"load",B)}else{document.addEventListener("DOMContentLoaded",B,false)}}else{document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;B()}}}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(B,A){return Element.insert(B,{before:A})},Top:function(B,A){return Element.insert(B,{top:A})},Bottom:function(B,A){return Element.insert(B,{bottom:A})},After:function(B,A){return Element.insert(B,{after:A})}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(A,C,B){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(A,C,B)}this.xcomp=C;this.ycomp=B;this.offset=Element.cumulativeOffset(A);return(B>=this.offset[1]&&B<this.offset[1]+A.offsetHeight&&C>=this.offset[0]&&C<this.offset[0]+A.offsetWidth)},withinIncludingScrolloffsets:function(A,D,C){var B=Element.cumulativeScrollOffset(A);this.xcomp=D+B[0]-this.deltaX;this.ycomp=C+B[1]-this.deltaY;this.offset=Element.cumulativeOffset(A);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+A.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+A.offsetWidth)},overlap:function(A,B){if(!A){return 0}if(A=="vertical"){return((this.offset[1]+B.offsetHeight)-this.ycomp)/B.offsetHeight}if(A=="horizontal"){return((this.offset[0]+B.offsetWidth)-this.xcomp)/B.offsetWidth}},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(A){Position.prepare();return Element.absolutize(A)},relativize:function(A){Position.prepare();return Element.relativize(A)},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(A,B,C){C=C||{};return Element.clonePosition(B,A,C)}};if(!document.getElementsByClassName){document.getElementsByClassName=function(A){function B(C){return C.blank()?null:"[contains(concat(' ', @class, ' '), ' "+C+" ')]"}A.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(D,C){C=C.toString().strip();var E=/\s/.test(C)?$w(C).map(B).join(""):B(C);return E?document._getElementsByXPath(".//*"+E,D):[]}:function(H,J){J=J.toString().strip();var D=[],E=(/\s/.test(J)?$w(J):null);if(!E&&!J){return D}var F=$(H).getElementsByTagName("*");J=" "+J+" ";for(var G=0,C,I;C=F[G];G++){if(C.className&&(I=" "+C.className+" ")&&(I.include(J)||(E&&E.all(function(K){return !K.toString().blank()&&I.include(" "+K+" ")})))){D.push(Element.extend(C))}}return D};return function(C,D){return $(D||document.body).getElementsByClassName(C)}}(Element.Methods)}Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(A){this.element=$(A)},_each:function(A){this.element.className.split(/\s+/).select(function(B){return B.length>0})._each(A)},set:function(A){this.element.className=A},add:function(A){if(this.include(A)){return }this.set($A(this).concat(A).join(" "))},remove:function(A){if(!this.include(A)){return }this.set($A(this).without(A).join(" "))},toString:function(){return $A(this).join(" ")}};Object.extend(Element.ClassNames.prototype,Enumerable);Element.addMethods();
/*vendor/prototype/effects*/
String.prototype.parseColor=function(){var C="#";if(this.slice(0,4)=="rgb("){var B=this.slice(4,this.length-1).split(",");var A=0;do{C+=parseInt(B[A]).toColorPart()}while(++A<3)}else{if(this.slice(0,1)=="#"){if(this.length==4){for(var A=1;A<4;A++){C+=(this.charAt(A)+this.charAt(A)).toLowerCase()}}if(this.length==7){C=this.toLowerCase()}}}return(C.length==7?C:(arguments[0]||this))};Element.collectTextNodes=function(A){return $A($(A).childNodes).collect(function(B){return(B.nodeType==3?B.nodeValue:(B.hasChildNodes()?Element.collectTextNodes(B):""))}).flatten().join("")};Element.collectTextNodesIgnoreClass=function(B,A){return $A($(B).childNodes).collect(function(C){return(C.nodeType==3?C.nodeValue:((C.hasChildNodes()&&!Element.hasClassName(C,A))?Element.collectTextNodesIgnoreClass(C,A):""))}).flatten().join("")};Element.setContentZoom=function(B,A){B=$(B);B.setStyle({fontSize:(A/100)+"em"});if(Prototype.Browser.WebKit){window.scrollBy(0,0)}return B};Element.getInlineOpacity=function(A){return $(A).style.opacity||""};Element.forceRerendering=function(C){try{C=$(C);var B=document.createTextNode(" ");C.appendChild(B);C.removeChild(B)}catch(A){}};var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},Transitions:{linear:Prototype.K,sinoidal:function(A){return(-Math.cos(A*Math.PI)/2)+0.5},reverse:function(A){return 1-A},flicker:function(A){var A=((-Math.cos(A*Math.PI)/4)+0.75)+Math.random()/4;return A>1?1:A},wobble:function(A){return(-Math.cos(A*Math.PI*(9*A))/2)+0.5},pulse:function(A,B){B=B||5;return(((A%(1/B))*B).round()==0?((A*B*2)-(A*B*2).floor()):1-((A*B*2)-(A*B*2).floor()))},spring:function(A){return 1-(Math.cos(A*4.5*Math.PI)*Math.exp(-A*6))},none:function(A){return 0},full:function(A){return 1}},DefaultOptions:{duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"},tagifyText:function(B){var A="position:relative";if(Prototype.Browser.IE){A+=";zoom:1"}B=$(B);$A(B.childNodes).each(function(C){if(C.nodeType==3){C.nodeValue.toArray().each(function(D){B.insertBefore(new Element("span",{style:A}).update(D==" "?String.fromCharCode(160):D),C)});Element.remove(C)}})},multiple:function(A,B){var D;if(((typeof A=="object")||Object.isFunction(A))&&(A.length)){D=A}else{D=$(A).childNodes}var E=Object.extend({speed:0.1,delay:0},arguments[2]||{});var C=E.delay;$A(D).each(function(F,G){new B(F,Object.extend(E,{delay:G*E.speed+C}))})},PAIRS:{slide:["SlideDown","SlideUp"],blind:["BlindDown","BlindUp"],appear:["Appear","Fade"]},toggle:function(A,B){A=$(A);B=(B||"appear").toLowerCase();var C=Object.extend({queue:{position:"end",scope:(A.id||"global"),limit:1}},arguments[2]||{});Effect[A.visible()?Effect.PAIRS[B][1]:Effect.PAIRS[B][0]](A,C)}};Effect.DefaultOptions.transition=Effect.Transitions.sinoidal;Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){this.effects=[];this.interval=null},_each:function(A){this.effects._each(A)},add:function(A){var B=new Date().getTime();var C=Object.isString(A.options.queue)?A.options.queue:A.options.queue.position;switch(C){case"front":this.effects.findAll(function(D){return D.state=="idle"}).each(function(D){D.startOn+=A.finishOn;D.finishOn+=A.finishOn});break;case"with-last":B=this.effects.pluck("startOn").max()||B;break;case"end":B=this.effects.pluck("finishOn").max()||B;break}A.startOn+=B;A.finishOn+=B;if(!A.options.queue.limit||(this.effects.length<A.options.queue.limit)){this.effects.push(A)}if(!this.interval){this.interval=setInterval(this.loop.bind(this),15)}},remove:function(A){this.effects=this.effects.reject(function(B){return B==A});if(this.effects.length==0){clearInterval(this.interval);this.interval=null}},loop:function(){var B=new Date().getTime();for(var A=0,C=this.effects.length;A<C;A++){this.effects[A]&&this.effects[A].loop(B)}}});Effect.Queues={instances:$H(),get:function(A){if(!Object.isString(A)){return A}return this.instances.get(A)||this.instances.set(A,new Effect.ScopedQueue())}};Effect.Queue=Effect.Queues.get("global");Effect.Base=Class.create({position:null,start:function(options){function codeForEvent(options,eventName){return((options[eventName+"Internal"]?"this.options."+eventName+"Internal(this);":"")+(options[eventName]?"this.options."+eventName+"(this);":""))}if(options&&options.transition===false){options.transition=Effect.Transitions.linear}this.options=Object.extend(Object.extend({},Effect.DefaultOptions),options||{});this.currentFrame=0;this.state="idle";this.startOn=this.options.delay*1000;this.finishOn=this.startOn+(this.options.duration*1000);this.fromToDelta=this.options.to-this.options.from;this.totalTime=this.finishOn-this.startOn;this.totalFrames=this.options.fps*this.options.duration;eval('this.render = function(pos){ if (this.state=="idle"){this.state="running";'+codeForEvent(this.options,"beforeSetup")+(this.setup?"this.setup();":"")+codeForEvent(this.options,"afterSetup")+'};if (this.state=="running"){pos=this.options.transition(pos)*'+this.fromToDelta+"+"+this.options.from+";this.position=pos;"+codeForEvent(this.options,"beforeUpdate")+(this.update?"this.update(pos);":"")+codeForEvent(this.options,"afterUpdate")+"}}");this.event("beforeStart");if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).add(this)}},loop:function(B){if(B>=this.startOn){if(B>=this.finishOn){this.render(1);this.cancel();this.event("beforeFinish");if(this.finish){this.finish()}this.event("afterFinish");return }var A=(B-this.startOn)/this.totalTime,C=(A*this.totalFrames).round();if(C>this.currentFrame){this.render(A);this.currentFrame=C}}},cancel:function(){if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).remove(this)}this.state="finished"},event:function(A){if(this.options[A+"Internal"]){this.options[A+"Internal"](this)}if(this.options[A]){this.options[A](this)}},inspect:function(){var A=$H();for(property in this){if(!Object.isFunction(this[property])){A.set(property,this[property])}}return"#<Effect:"+A.inspect()+",options:"+$H(this.options).inspect()+">"}});Effect.Parallel=Class.create(Effect.Base,{initialize:function(A){this.effects=A||[];this.start(arguments[1])},update:function(A){this.effects.invoke("render",A)},finish:function(A){this.effects.each(function(B){B.render(1);B.cancel();B.event("beforeFinish");if(B.finish){B.finish(A)}B.event("afterFinish")})}});Effect.Tween=Class.create(Effect.Base,{initialize:function(B,E,D){B=Object.isString(B)?$(B):B;var A=$A(arguments),C=A.last(),F=A.length==5?A[3]:null;this.method=Object.isFunction(C)?C.bind(B):Object.isFunction(B[C])?B[C].bind(B):function(G){B[C]=G};this.start(Object.extend({from:E,to:D},F||{}))},update:function(A){this.method(A)}});Effect.Event=Class.create(Effect.Base,{initialize:function(){this.start(Object.extend({duration:0},arguments[0]||{}))},update:Prototype.emptyFunction});Effect.Opacity=Class.create(Effect.Base,{initialize:function(A){this.element=$(A);if(!this.element){throw (Effect._elementDoesNotExistError)}if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}var B=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});this.start(B)},update:function(A){this.element.setOpacity(A)}});Effect.Move=Class.create(Effect.Base,{initialize:function(A){this.element=$(A);if(!this.element){throw (Effect._elementDoesNotExistError)}var B=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});this.start(B)},setup:function(){this.element.makePositioned();this.originalLeft=parseFloat(this.element.getStyle("left")||"0");this.originalTop=parseFloat(this.element.getStyle("top")||"0");if(this.options.mode=="absolute"){this.options.x=this.options.x-this.originalLeft;this.options.y=this.options.y-this.originalTop}},update:function(A){this.element.setStyle({left:(this.options.x*A+this.originalLeft).round()+"px",top:(this.options.y*A+this.originalTop).round()+"px"})}});Effect.MoveBy=function(A,C,B){return new Effect.Move(A,Object.extend({x:B,y:C},arguments[3]||{}))};Effect.Scale=Class.create(Effect.Base,{initialize:function(A,B){this.element=$(A);if(!this.element){throw (Effect._elementDoesNotExistError)}var C=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:B},arguments[2]||{});this.start(C)},setup:function(){this.restoreAfterFinish=this.options.restoreAfterFinish||false;this.elementPositioning=this.element.getStyle("position");this.originalStyle={};["top","left","width","height","fontSize"].each(function(B){this.originalStyle[B]=this.element.style[B]}.bind(this));this.originalTop=this.element.offsetTop;this.originalLeft=this.element.offsetLeft;var A=this.element.getStyle("font-size")||"100%";["em","px","%","pt"].each(function(B){if(A.indexOf(B)>0){this.fontSize=parseFloat(A);this.fontSizeType=B}}.bind(this));this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;this.dims=null;if(this.options.scaleMode=="box"){this.dims=[this.element.offsetHeight,this.element.offsetWidth]}if(/^content/.test(this.options.scaleMode)){this.dims=[this.element.scrollHeight,this.element.scrollWidth]}if(!this.dims){this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]}},update:function(B){var A=(this.options.scaleFrom/100)+(this.factor*B);if(this.options.scaleContent&&this.fontSize){this.element.setStyle({fontSize:this.fontSize*A+this.fontSizeType})}this.setDimensions(this.dims[0]*A,this.dims[1]*A)},finish:function(A){if(this.restoreAfterFinish){this.element.setStyle(this.originalStyle)}},setDimensions:function(E,C){var D={};if(this.options.scaleX){D.width=C.round()+"px"}if(this.options.scaleY){D.height=E.round()+"px"}if(this.options.scaleFromCenter){var B=(E-this.dims[0])/2;var A=(C-this.dims[1])/2;if(this.elementPositioning=="absolute"){if(this.options.scaleY){D.top=this.originalTop-B+"px"}if(this.options.scaleX){D.left=this.originalLeft-A+"px"}}else{if(this.options.scaleY){D.top=-B+"px"}if(this.options.scaleX){D.left=-A+"px"}}}this.element.setStyle(D)}});Effect.Highlight=Class.create(Effect.Base,{initialize:function(A){this.element=$(A);if(!this.element){throw (Effect._elementDoesNotExistError)}var B=Object.extend({startcolor:"#ffff99"},arguments[1]||{});this.start(B)},setup:function(){if(this.element.getStyle("display")=="none"){this.cancel();return }this.oldStyle={};if(!this.options.keepBackgroundImage){this.oldStyle.backgroundImage=this.element.getStyle("background-image");this.element.setStyle({backgroundImage:"none"})}if(!this.options.endcolor){this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff")}if(!this.options.restorecolor){this.options.restorecolor=this.element.getStyle("background-color")}this._base=$R(0,2).map(function(A){return parseInt(this.options.startcolor.slice(A*2+1,A*2+3),16)}.bind(this));this._delta=$R(0,2).map(function(A){return parseInt(this.options.endcolor.slice(A*2+1,A*2+3),16)-this._base[A]}.bind(this))},update:function(A){this.element.setStyle({backgroundColor:$R(0,2).inject("#",function(C,D,B){return C+((this._base[B]+(this._delta[B]*A)).round().toColorPart())}.bind(this))})},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}))}});Effect.ScrollTo=function(C){var B=arguments[1]||{},A=document.viewport.getScrollOffsets(),D=$(C).cumulativeOffset(),E=(window.height||document.body.scrollHeight)-document.viewport.getHeight();if(B.offset){D[1]+=B.offset}return new Effect.Tween(null,A.top,D[1]>E?E:D[1],B,function(F){scrollTo(A.left,F.round())})};Effect.Fade=function(B){B=$(B);var C=B.getInlineOpacity();var A=Object.extend({from:B.getOpacity()||1,to:0,afterFinishInternal:function(D){if(D.options.to!=0){return }D.element.hide().setStyle({opacity:C})}},arguments[1]||{});return new Effect.Opacity(B,A)};Effect.Appear=function(A){A=$(A);var B=Object.extend({from:(A.getStyle("display")=="none"?0:A.getOpacity()||0),to:1,afterFinishInternal:function(C){C.element.forceRerendering()},beforeSetup:function(C){C.element.setOpacity(C.options.from).show()}},arguments[1]||{});return new Effect.Opacity(A,B)};Effect.Puff=function(A){A=$(A);var B={opacity:A.getInlineOpacity(),position:A.getStyle("position"),top:A.style.top,left:A.style.left,width:A.style.width,height:A.style.height};return new Effect.Parallel([new Effect.Scale(A,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(A,{sync:true,to:0})],Object.extend({duration:1,beforeSetupInternal:function(C){Position.absolutize(C.effects[0].element)},afterFinishInternal:function(C){C.effects[0].element.hide().setStyle(B)}},arguments[1]||{}))};Effect.BlindUp=function(A){A=$(A);A.makeClipping();return new Effect.Scale(A,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(B){B.element.hide().undoClipping()}},arguments[1]||{}))};Effect.BlindDown=function(A){A=$(A);var B=A.getDimensions();return new Effect.Scale(A,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:B.height,originalWidth:B.width},restoreAfterFinish:true,afterSetup:function(C){C.element.makeClipping().setStyle({height:"0px"}).show()},afterFinishInternal:function(C){C.element.undoClipping()}},arguments[1]||{}))};Effect.SwitchOff=function(A){A=$(A);var B=A.getInlineOpacity();return new Effect.Appear(A,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(C){new Effect.Scale(C.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(D){D.element.makePositioned().makeClipping()},afterFinishInternal:function(D){D.element.hide().undoClipping().undoPositioned().setStyle({opacity:B})}})}},arguments[1]||{}))};Effect.DropOut=function(A){A=$(A);var B={top:A.getStyle("top"),left:A.getStyle("left"),opacity:A.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(A,{x:0,y:100,sync:true}),new Effect.Opacity(A,{sync:true,to:0})],Object.extend({duration:0.5,beforeSetup:function(C){C.effects[0].element.makePositioned()},afterFinishInternal:function(C){C.effects[0].element.hide().undoPositioned().setStyle(B)}},arguments[1]||{}))};Effect.Shake=function(C){C=$(C);var A=Object.extend({distance:20,duration:0.5},arguments[1]||{});var D=parseFloat(A.distance);var B=parseFloat(A.duration)/10;var E={top:C.getStyle("top"),left:C.getStyle("left")};return new Effect.Move(C,{x:D,y:0,duration:B,afterFinishInternal:function(F){new Effect.Move(F.element,{x:-D*2,y:0,duration:B*2,afterFinishInternal:function(G){new Effect.Move(G.element,{x:D*2,y:0,duration:B*2,afterFinishInternal:function(H){new Effect.Move(H.element,{x:-D*2,y:0,duration:B*2,afterFinishInternal:function(I){new Effect.Move(I.element,{x:D*2,y:0,duration:B*2,afterFinishInternal:function(J){new Effect.Move(J.element,{x:-D,y:0,duration:B,afterFinishInternal:function(K){K.element.undoPositioned().setStyle(E)}})}})}})}})}})}})};Effect.SlideDown=function(B){B=$(B).cleanWhitespace();var C=B.down().getStyle("bottom");var A=B.getDimensions();return new Effect.Scale(B,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:A.height,originalWidth:A.width},restoreAfterFinish:true,afterSetup:function(D){D.element.makePositioned();D.element.down().makePositioned();if(window.opera){D.element.setStyle({top:""})}D.element.makeClipping().setStyle({height:"0px"}).show()},afterUpdateInternal:function(D){D.element.down().setStyle({bottom:(D.dims[0]-D.element.clientHeight)+"px"})},afterFinishInternal:function(D){D.element.undoClipping().undoPositioned();D.element.down().undoPositioned().setStyle({bottom:C})}},arguments[1]||{}))};Effect.SlideUp=function(B){B=$(B).cleanWhitespace();var C=B.down().getStyle("bottom");var A=B.getDimensions();return new Effect.Scale(B,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,scaleMode:{originalHeight:A.height,originalWidth:A.width},restoreAfterFinish:true,afterSetup:function(D){D.element.makePositioned();D.element.down().makePositioned();if(window.opera){D.element.setStyle({top:""})}D.element.makeClipping().show()},afterUpdateInternal:function(D){D.element.down().setStyle({bottom:(D.dims[0]-D.element.clientHeight)+"px"})},afterFinishInternal:function(D){D.element.hide().undoClipping().undoPositioned();D.element.down().undoPositioned().setStyle({bottom:C})}},arguments[1]||{}))};Effect.Squish=function(A){return new Effect.Scale(A,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(B){B.element.makeClipping()},afterFinishInternal:function(B){B.element.hide().undoClipping()}})};Effect.Grow=function(F){F=$(F);var E=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});var D={top:F.style.top,left:F.style.left,height:F.style.height,width:F.style.width,opacity:F.getInlineOpacity()};var B=F.getDimensions();var C,A;var H,G;switch(E.direction){case"top-left":C=A=H=G=0;break;case"top-right":C=B.width;A=G=0;H=-B.width;break;case"bottom-left":C=H=0;A=B.height;G=-B.height;break;case"bottom-right":C=B.width;A=B.height;H=-B.width;G=-B.height;break;case"center":C=B.width/2;A=B.height/2;H=-B.width/2;G=-B.height/2;break}return new Effect.Move(F,{x:C,y:A,duration:0.01,beforeSetup:function(I){I.element.hide().makeClipping().makePositioned()},afterFinishInternal:function(I){new Effect.Parallel([new Effect.Opacity(I.element,{sync:true,to:1,from:0,transition:E.opacityTransition}),new Effect.Move(I.element,{x:H,y:G,sync:true,transition:E.moveTransition}),new Effect.Scale(I.element,100,{scaleMode:{originalHeight:B.height,originalWidth:B.width},sync:true,scaleFrom:window.opera?1:0,transition:E.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(J){J.effects[0].element.setStyle({height:"0px"}).show()},afterFinishInternal:function(J){J.effects[0].element.undoClipping().undoPositioned().setStyle(D)}},E))}})};Effect.Shrink=function(B){B=$(B);var A=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});var F={top:B.style.top,left:B.style.left,height:B.style.height,width:B.style.width,opacity:B.getInlineOpacity()};var E=B.getDimensions();var D,C;switch(A.direction){case"top-left":D=C=0;break;case"top-right":D=E.width;C=0;break;case"bottom-left":D=0;C=E.height;break;case"bottom-right":D=E.width;C=E.height;break;case"center":D=E.width/2;C=E.height/2;break}return new Effect.Parallel([new Effect.Opacity(B,{sync:true,to:0,from:1,transition:A.opacityTransition}),new Effect.Scale(B,window.opera?1:0,{sync:true,transition:A.scaleTransition,restoreAfterFinish:true}),new Effect.Move(B,{x:D,y:C,sync:true,transition:A.moveTransition})],Object.extend({beforeStartInternal:function(G){G.effects[0].element.makePositioned().makeClipping()},afterFinishInternal:function(G){G.effects[0].element.hide().undoClipping().undoPositioned().setStyle(F)}},A))};Effect.Pulsate=function(B){B=$(B);var A=arguments[1]||{};var E=B.getInlineOpacity();var D=A.transition||Effect.Transitions.sinoidal;var C=function(F){return D(1-Effect.Transitions.pulse(F,A.pulses))};C.bind(D);return new Effect.Opacity(B,Object.extend(Object.extend({duration:2,from:0,afterFinishInternal:function(F){F.element.setStyle({opacity:E})}},A),{transition:C}))};Effect.Fold=function(A){A=$(A);var B={top:A.style.top,left:A.style.left,width:A.style.width,height:A.style.height};A.makeClipping();return new Effect.Scale(A,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(C){new Effect.Scale(A,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(D){D.element.hide().undoClipping().setStyle(B)}})}},arguments[1]||{}))};Effect.Morph=Class.create(Effect.Base,{initialize:function(B){this.element=$(B);if(!this.element){throw (Effect._elementDoesNotExistError)}var C=Object.extend({style:{}},arguments[1]||{});if(!Object.isString(C.style)){this.style=$H(C.style)}else{if(C.style.include(":")){this.style=C.style.parseStyle()}else{this.element.addClassName(C.style);this.style=$H(this.element.getStyles());this.element.removeClassName(C.style);var A=this.element.getStyles();this.style=this.style.reject(function(D){return D.value==A[D.key]});C.afterFinishInternal=function(D){D.element.addClassName(D.options.style);D.transforms.each(function(E){D.element.style[E.style]=""})}}}this.start(C)},setup:function(){function A(B){if(!B||["rgba(0, 0, 0, 0)","transparent"].include(B)){B="#ffffff"}B=B.parseColor();return $R(0,2).map(function(C){return parseInt(B.slice(C*2+1,C*2+3),16)})}this.transforms=this.style.map(function(C){var G=C[0],F=C[1],E=null;if(F.parseColor("#zzzzzz")!="#zzzzzz"){F=F.parseColor();E="color"}else{if(G=="opacity"){F=parseFloat(F);if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}}else{if(Element.CSS_LENGTH.test(F)){var D=F.match(/^([\+\-]?[0-9\.]+)(.*)$/);F=parseFloat(D[1]);E=(D.length==3)?D[2]:null}}}var B=this.element.getStyle(G);return{style:G.camelize(),originalValue:E=="color"?A(B):parseFloat(B||0),targetValue:E=="color"?A(F):F,unit:E}}.bind(this)).reject(function(B){return((B.originalValue==B.targetValue)||(B.unit!="color"&&(isNaN(B.originalValue)||isNaN(B.targetValue))))})},update:function(D){var C={},A,B=this.transforms.length;while(B--){C[(A=this.transforms[B]).style]=A.unit=="color"?"#"+(Math.round(A.originalValue[0]+(A.targetValue[0]-A.originalValue[0])*D)).toColorPart()+(Math.round(A.originalValue[1]+(A.targetValue[1]-A.originalValue[1])*D)).toColorPart()+(Math.round(A.originalValue[2]+(A.targetValue[2]-A.originalValue[2])*D)).toColorPart():(A.originalValue+(A.targetValue-A.originalValue)*D).toFixed(3)+(A.unit===null?"":A.unit)}this.element.setStyle(C,true)}});Effect.Transform=Class.create({initialize:function(A){this.tracks=[];this.options=arguments[1]||{};this.addTracks(A)},addTracks:function(A){A.each(function(C){C=$H(C);var B=C.values().first();this.tracks.push($H({ids:C.keys().first(),effect:Effect.Morph,options:{style:B}}))}.bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(E){var C=E.get("ids"),B=E.get("effect"),A=E.get("options");var D=[$(C)||$$(C)].flatten();return D.map(function(F){return new B(F,Object.extend({sync:true},A))})}).flatten(),this.options)}});Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.__parseStyleElement=document.createElement("div");String.prototype.parseStyle=function(){var A,B=$H();if(Prototype.Browser.WebKit){A=new Element("div",{style:this}).style}else{String.__parseStyleElement.innerHTML='<div style="'+this+'"></div>';A=String.__parseStyleElement.childNodes[0].style}Element.CSS_PROPERTIES.each(function(C){if(A[C]){B.set(C,A[C])}});if(Prototype.Browser.IE&&this.include("opacity")){B.set("opacity",this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1])}return B};if(document.defaultView&&document.defaultView.getComputedStyle){Element.getStyles=function(A){var B=document.defaultView.getComputedStyle($(A),null);return Element.CSS_PROPERTIES.inject({},function(D,C){D[C]=B[C];return D})}}else{Element.getStyles=function(A){A=$(A);var C=A.currentStyle,B;B=Element.CSS_PROPERTIES.inject({},function(E,D){E[D]=C[D];return E});if(!B.opacity){B.opacity=A.getOpacity()}return B}}Effect.Methods={morph:function(B,A){B=$(B);new Effect.Morph(B,Object.extend({style:A},arguments[2]||{}));return B},visualEffect:function(B,D,A){B=$(B);var C=D.dasherize().camelize(),E=C.charAt(0).toUpperCase()+C.substring(1);new Effect[E](B,A);return B},highlight:function(A,B){A=$(A);new Effect.Highlight(A,B);return A}};$w("fade appear grow shrink fold blindUp blindDown slideUp slideDown pulsate shake puff squish switchOff dropOut").each(function(A){Effect.Methods[A]=function(B,C){B=$(B);Effect[A.charAt(0).toUpperCase()+A.substring(1)](B,C);return B}});$w("getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles").each(function(A){Effect.Methods[A]=Element[A]});Element.addMethods(Effect.Methods);
/*vendor/prototype/controls*/
if(typeof Effect=="undefined"){throw ("controls.js requires including script.aculo.us' effects.js library")}var Autocompleter={};Autocompleter.Base=Class.create({baseInitialize:function(A,B,C){A=$(A);this.element=A;this.update=$(B);this.hasFocus=false;this.changed=false;this.active=false;this.index=0;this.entryCount=0;this.oldElementValue=this.element.value;if(this.setOptions){this.setOptions(C)}else{this.options=C||{}}this.options.paramName=this.options.paramName||this.element.name;this.options.tokens=this.options.tokens||[];this.options.frequency=this.options.frequency||0.4;this.options.minChars=this.options.minChars||1;this.options.onShow=this.options.onShow||function(E,D){if(!D.style.position||D.style.position=="absolute"){D.style.position="absolute";Position.clone(E,D,{setHeight:false,offsetTop:E.offsetHeight})}Effect.Appear(D,{duration:0.15})};this.options.onHide=this.options.onHide||function(E,D){new Effect.Fade(D,{duration:0.15})};if(typeof (this.options.tokens)=="string"){this.options.tokens=new Array(this.options.tokens)}if(!this.options.tokens.include("\n")){this.options.tokens.push("\n")}this.observer=null;this.element.setAttribute("autocomplete","off");Element.hide(this.update);Event.observe(this.element,"blur",this.onBlur.bindAsEventListener(this));Event.observe(this.element,"keydown",this.onKeyPress.bindAsEventListener(this))},show:function(){if(Element.getStyle(this.update,"display")=="none"){this.options.onShow(this.element,this.update)}if(!this.iefix&&(Prototype.Browser.IE)&&(Element.getStyle(this.update,"position")=="absolute")){new Insertion.After(this.update,'<iframe id="'+this.update.id+'_iefix" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.update.id+"_iefix")}if(this.iefix){setTimeout(this.fixIEOverlapping.bind(this),50)}},fixIEOverlapping:function(){Position.clone(this.update,this.iefix,{setTop:(!this.update.style.height)});this.iefix.style.zIndex=1;this.update.style.zIndex=2;Element.show(this.iefix)},hide:function(){this.stopIndicator();if(Element.getStyle(this.update,"display")!="none"){this.options.onHide(this.element,this.update)}if(this.iefix){Element.hide(this.iefix)}},startIndicator:function(){if(this.options.indicator){Element.show(this.options.indicator)}},stopIndicator:function(){if(this.options.indicator){Element.hide(this.options.indicator)}},onKeyPress:function(A){if(this.active){switch(A.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();Event.stop(A);case Event.KEY_ESC:this.hide();this.active=false;Event.stop(A);return ;case Event.KEY_LEFT:case Event.KEY_RIGHT:return ;case Event.KEY_UP:this.markPrevious();this.render();Event.stop(A);return ;case Event.KEY_DOWN:this.markNext();this.render();Event.stop(A);return }}else{if(A.keyCode==Event.KEY_TAB||A.keyCode==Event.KEY_RETURN||(Prototype.Browser.WebKit>0&&A.keyCode==0)){return }}this.changed=true;this.hasFocus=true;if(this.observer){clearTimeout(this.observer)}this.observer=setTimeout(this.onObserverEvent.bind(this),this.options.frequency*1000)},activate:function(){this.changed=false;this.hasFocus=true;this.getUpdatedChoices()},onHover:function(A){var B=Event.findElement(A,"LI");if(this.index!=B.autocompleteIndex){this.index=B.autocompleteIndex;this.render()}Event.stop(A)},onClick:function(A){var B=Event.findElement(A,"LI");this.index=B.autocompleteIndex;this.selectEntry();this.hide()},onBlur:function(A){setTimeout(this.hide.bind(this),250);this.hasFocus=false;this.active=false},render:function(){if(this.entryCount>0){for(var A=0;A<this.entryCount;A++){this.index==A?Element.addClassName(this.getEntry(A),"selected"):Element.removeClassName(this.getEntry(A),"selected")}if(this.hasFocus){this.show();this.active=true}}else{this.active=false;this.hide()}},markPrevious:function(){if(this.index>0){this.index--}else{this.index=this.entryCount-1}this.getEntry(this.index).scrollIntoView(true)},markNext:function(){if(this.index<this.entryCount-1){this.index++}else{this.index=0}this.getEntry(this.index).scrollIntoView(false)},getEntry:function(A){return this.update.firstChild.childNodes[A]},getCurrentEntry:function(){return this.getEntry(this.index)},selectEntry:function(){this.active=false;this.updateElement(this.getCurrentEntry())},updateElement:function(E){if(this.options.updateElement){this.options.updateElement(E);return }var C="";if(this.options.select){var F=$(E).select("."+this.options.select)||[];if(F.length>0){C=Element.collectTextNodes(F[0],this.options.select)}}else{C=Element.collectTextNodesIgnoreClass(E,"informal")}var B=this.getTokenBounds();if(B[0]!=-1){var D=this.element.value.substr(0,B[0]);var A=this.element.value.substr(B[0]).match(/^\s+/);if(A){D+=A[0]}this.element.value=D+C+this.element.value.substr(B[1])}else{this.element.value=C}this.oldElementValue=this.element.value;this.element.focus();if(this.options.afterUpdateElement){this.options.afterUpdateElement(this.element,E)}},updateChoices:function(B){if(!this.changed&&this.hasFocus){this.update.innerHTML=B;Element.cleanWhitespace(this.update);Element.cleanWhitespace(this.update.down());if(this.update.firstChild&&this.update.down().childNodes){this.entryCount=this.update.down().childNodes.length;for(var C=0;C<this.entryCount;C++){var A=this.getEntry(C);A.autocompleteIndex=C;this.addObservers(A)}}else{this.entryCount=0}this.stopIndicator();this.index=0;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry();this.hide()}else{this.render()}}},addObservers:function(A){Event.observe(A,"mouseover",this.onHover.bindAsEventListener(this));Event.observe(A,"click",this.onClick.bindAsEventListener(this))},onObserverEvent:function(){this.changed=false;this.tokenBounds=null;if(this.getToken().length>=this.options.minChars){this.getUpdatedChoices()}else{this.active=false;this.hide()}this.oldElementValue=this.element.value},getToken:function(){var A=this.getTokenBounds();return this.element.value.substring(A[0],A[1]).strip()},getTokenBounds:function(){if(null!=this.tokenBounds){return this.tokenBounds}var H=this.element.value;if(H.strip().empty()){return[-1,0]}var A=arguments.callee.getFirstDifferencePos(H,this.oldElementValue);var C=(A==this.oldElementValue.length?1:0);var G=-1,F=H.length;var B;for(var E=0,D=this.options.tokens.length;E<D;++E){B=H.lastIndexOf(this.options.tokens[E],A+C-1);if(B>G){G=B}B=H.indexOf(this.options.tokens[E],A+C);if(-1!=B&&B<F){F=B}}return(this.tokenBounds=[G+1,F])}});Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos=function(B,D){var C=Math.min(B.length,D.length);for(var A=0;A<C;++A){if(B[A]!=D[A]){return A}}return C};Ajax.Autocompleter=Class.create(Autocompleter.Base,{initialize:function(B,C,A,D){this.baseInitialize(B,C,D);this.options.asynchronous=true;this.options.onComplete=this.onComplete.bind(this);this.options.defaultParams=this.options.parameters||null;this.url=A},getUpdatedChoices:function(){this.startIndicator();var A=encodeURIComponent(this.options.paramName)+"="+encodeURIComponent(this.getToken());this.options.parameters=this.options.callback?this.options.callback(this.element,A):A;if(this.options.defaultParams){this.options.parameters+="&"+this.options.defaultParams}new Ajax.Request(this.url,this.options)},onComplete:function(A){this.updateChoices(A.responseText)}});Autocompleter.Local=Class.create(Autocompleter.Base,{initialize:function(A,C,B,D){this.baseInitialize(A,C,D);this.options.array=B},getUpdatedChoices:function(){this.updateChoices(this.options.selector(this))},setOptions:function(A){this.options=Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false,selector:function(F){var H=[];var G=[];var E=F.getToken();var D=0;for(var I=0;I<F.options.array.length&&H.length<F.options.choices;I++){var C=F.options.array[I];var B=F.options.ignoreCase?C.toLowerCase().indexOf(E.toLowerCase()):C.indexOf(E);while(B!=-1){if(B==0&&C.length!=E.length){H.push("<li><strong>"+C.substr(0,E.length)+"</strong>"+C.substr(E.length)+"</li>");break}else{if(E.length>=F.options.partialChars&&F.options.partialSearch&&B!=-1){if(F.options.fullSearch||/\s/.test(C.substr(B-1,1))){G.push("<li>"+C.substr(0,B)+"<strong>"+C.substr(B,E.length)+"</strong>"+C.substr(B+E.length)+"</li>");break}}}B=F.options.ignoreCase?C.toLowerCase().indexOf(E.toLowerCase(),B+1):C.indexOf(E,B+1)}}if(G.length){H=H.concat(G.slice(0,F.options.choices-H.length))}return"<ul>"+H.join("")+"</ul>"}},A||{})}});Field.scrollFreeActivate=function(A){setTimeout(function(){Field.activate(A)},1)};Ajax.InPlaceEditor=Class.create({initialize:function(B,A,C){this.url=A;this.element=B=$(B);this.prepareOptions();this._controls={};arguments.callee.dealWithDeprecatedOptions(C);Object.extend(this.options,C||{});if(!this.options.formId&&this.element.id){this.options.formId=this.element.id+"-inplaceeditor";if($(this.options.formId)){this.options.formId=""}}if(this.options.externalControl){this.options.externalControl=$(this.options.externalControl)}if(!this.options.externalControl){this.options.externalControlOnly=false}this._originalBackground=this.element.getStyle("background-color")||"transparent";this.element.title=this.options.clickToEditText;this._boundCancelHandler=this.handleFormCancellation.bind(this);this._boundComplete=(this.options.onComplete||Prototype.emptyFunction).bind(this);this._boundFailureHandler=this.handleAJAXFailure.bind(this);this._boundSubmitHandler=this.handleFormSubmission.bind(this);this._boundWrapperHandler=this.wrapUp.bind(this);this.registerListeners()},checkForEscapeOrReturn:function(A){if(!this._editing||A.ctrlKey||A.altKey||A.shiftKey){return }if(Event.KEY_ESC==A.keyCode){this.handleFormCancellation(A)}else{if(Event.KEY_RETURN==A.keyCode){this.handleFormSubmission(A)}}},createControl:function(D,G,F){var B=this.options[D+"Control"];var C=this.options[D+"Text"];if("button"==B){var E=document.createElement("input");E.type="submit";E.value=C;E.className="editor_"+D+"_button";if("cancel"==D){E.onclick=this._boundCancelHandler}this._form.appendChild(E);this._controls[D]=E}else{if("link"==B){var A=document.createElement("a");A.href="#";A.appendChild(document.createTextNode(C));A.onclick="cancel"==D?this._boundCancelHandler:this._boundSubmitHandler;A.className="editor_"+D+"_link";if(F){A.className+=" "+F}this._form.appendChild(A);this._controls[D]=A}}},createEditField:function(){var B=(this.options.loadTextURL?this.options.loadingText:this.getText());var A;if(1>=this.options.rows&&!/\r|\n/.test(this.getText())){A=document.createElement("input");A.type="text";var C=this.options.size||this.options.cols||0;if(0<C){A.size=C}}else{A=document.createElement("textarea");A.rows=(1>=this.options.rows?this.options.autoRows:this.options.rows);A.cols=this.options.cols||40}A.name=this.options.paramName;A.value=B;A.className="editor_field";if(this.options.submitOnBlur){A.onblur=this._boundSubmitHandler}this._controls.editor=A;if(this.options.loadTextURL){this.loadExternalText()}this._form.appendChild(this._controls.editor)},createForm:function(){var A=this;function B(E,C){var D=A.options["text"+E+"Controls"];if(!D||C===false){return }A._form.appendChild(document.createTextNode(D))}this._form=$(document.createElement("form"));this._form.id=this.options.formId;this._form.addClassName(this.options.formClassName);this._form.onsubmit=this._boundSubmitHandler;this.createEditField();if("textarea"==this._controls.editor.tagName.toLowerCase()){this._form.appendChild(document.createElement("br"))}if(this.options.onFormCustomization){this.options.onFormCustomization(this,this._form)}B("Before",this.options.okControl||this.options.cancelControl);this.createControl("ok",this._boundSubmitHandler);B("Between",this.options.okControl&&this.options.cancelControl);this.createControl("cancel",this._boundCancelHandler,"editor_cancel");B("After",this.options.okControl||this.options.cancelControl)},destroy:function(){if(this._oldInnerHTML){this.element.innerHTML=this._oldInnerHTML}this.leaveEditMode();this.unregisterListeners()},enterEditMode:function(A){if(this._saving||this._editing){return }this._editing=true;this.triggerCallback("onEnterEditMode");if(this.options.externalControl){this.options.externalControl.hide()}this.element.hide();this.createForm();this.element.parentNode.insertBefore(this._form,this.element);if(!this.options.loadTextURL){this.postProcessEditField()}if(A){Event.stop(A)}},enterHover:function(A){if(this.options.hoverClassName){this.element.addClassName(this.options.hoverClassName)}if(this._saving){return }this.triggerCallback("onEnterHover")},getText:function(){return this.element.innerHTML},handleAJAXFailure:function(A){this.triggerCallback("onFailure",A);if(this._oldInnerHTML){this.element.innerHTML=this._oldInnerHTML;this._oldInnerHTML=null}},handleFormCancellation:function(A){this.wrapUp();if(A){Event.stop(A)}},handleFormSubmission:function(C){var A=this._form;var B=$F(this._controls.editor);this.prepareSubmission();var D=this.options.callback(A,B)||"";if(Object.isString(D)){D=D.toQueryParams()}D.editorId=this.element.id;if(this.options.htmlResponse){var E=Object.extend({evalScripts:true},this.options.ajaxOptions);Object.extend(E,{parameters:D,onComplete:this._boundWrapperHandler,onFailure:this._boundFailureHandler});new Ajax.Updater({success:this.element},this.url,E)}else{var E=Object.extend({method:"get"},this.options.ajaxOptions);Object.extend(E,{parameters:D,onComplete:this._boundWrapperHandler,onFailure:this._boundFailureHandler});new Ajax.Request(this.url,E)}if(C){Event.stop(C)}},leaveEditMode:function(){this.element.removeClassName(this.options.savingClassName);this.removeForm();this.leaveHover();this.element.style.backgroundColor=this._originalBackground;this.element.show();if(this.options.externalControl){this.options.externalControl.show()}this._saving=false;this._editing=false;this._oldInnerHTML=null;this.triggerCallback("onLeaveEditMode")},leaveHover:function(A){if(this.options.hoverClassName){this.element.removeClassName(this.options.hoverClassName)}if(this._saving){return }this.triggerCallback("onLeaveHover")},loadExternalText:function(){this._form.addClassName(this.options.loadingClassName);this._controls.editor.disabled=true;var A=Object.extend({method:"get"},this.options.ajaxOptions);Object.extend(A,{parameters:"editorId="+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(B){this._form.removeClassName(this.options.loadingClassName);var C=B.responseText;if(this.options.stripLoadedTextTags){C=C.stripTags()}this._controls.editor.value=C;this._controls.editor.disabled=false;this.postProcessEditField()}.bind(this),onFailure:this._boundFailureHandler});new Ajax.Request(this.options.loadTextURL,A)},postProcessEditField:function(){var A=this.options.fieldPostCreation;if(A){$(this._controls.editor)["focus"==A?"focus":"activate"]()}},prepareOptions:function(){this.options=Object.clone(Ajax.InPlaceEditor.DefaultOptions);Object.extend(this.options,Ajax.InPlaceEditor.DefaultCallbacks);[this._extraDefaultOptions].flatten().compact().each(function(A){Object.extend(this.options,A)}.bind(this))},prepareSubmission:function(){this._saving=true;this.removeForm();this.leaveHover();this.showSaving()},registerListeners:function(){this._listeners={};var A;$H(Ajax.InPlaceEditor.Listeners).each(function(B){A=this[B.value].bind(this);this._listeners[B.key]=A;if(!this.options.externalControlOnly){this.element.observe(B.key,A)}if(this.options.externalControl){this.options.externalControl.observe(B.key,A)}}.bind(this))},removeForm:function(){if(!this._form){return }this._form.remove();this._form=null;this._controls={}},showSaving:function(){this._oldInnerHTML=this.element.innerHTML;this.element.innerHTML=this.options.savingText;this.element.addClassName(this.options.savingClassName);this.element.style.backgroundColor=this._originalBackground;this.element.show()},triggerCallback:function(A,B){if("function"==typeof this.options[A]){this.options[A](this,B)}},unregisterListeners:function(){$H(this._listeners).each(function(A){if(!this.options.externalControlOnly){this.element.stopObserving(A.key,A.value)}if(this.options.externalControl){this.options.externalControl.stopObserving(A.key,A.value)}}.bind(this))},wrapUp:function(A){this.leaveEditMode();this._boundComplete(A,this.element)}});Object.extend(Ajax.InPlaceEditor.prototype,{dispose:Ajax.InPlaceEditor.prototype.destroy});Ajax.InPlaceCollectionEditor=Class.create(Ajax.InPlaceEditor,{initialize:function($super,B,A,C){this._extraDefaultOptions=Ajax.InPlaceCollectionEditor.DefaultOptions;$super(B,A,C)},createEditField:function(){var A=document.createElement("select");A.name=this.options.paramName;A.size=1;this._controls.editor=A;this._collection=this.options.collection||[];if(this.options.loadCollectionURL){this.loadCollection()}else{this.checkForExternalText()}this._form.appendChild(this._controls.editor)},loadCollection:function(){this._form.addClassName(this.options.loadingClassName);this.showLoadingText(this.options.loadingCollectionText);var options=Object.extend({method:"get"},this.options.ajaxOptions);Object.extend(options,{parameters:"editorId="+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(transport){var js=transport.responseText.strip();if(!/^\[.*\]$/.test(js)){throw"Server returned an invalid collection representation."}this._collection=eval(js);this.checkForExternalText()}.bind(this),onFailure:this.onFailure});new Ajax.Request(this.options.loadCollectionURL,options)},showLoadingText:function(A){this._controls.editor.disabled=true;var B=this._controls.editor.firstChild;if(!B){B=document.createElement("option");B.value="";this._controls.editor.appendChild(B);B.selected=true}B.update((A||"").stripScripts().stripTags())},checkForExternalText:function(){this._text=this.getText();if(this.options.loadTextURL){this.loadExternalText()}else{this.buildOptionList()}},loadExternalText:function(){this.showLoadingText(this.options.loadingText);var A=Object.extend({method:"get"},this.options.ajaxOptions);Object.extend(A,{parameters:"editorId="+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(B){this._text=B.responseText.strip();this.buildOptionList()}.bind(this),onFailure:this.onFailure});new Ajax.Request(this.options.loadTextURL,A)},buildOptionList:function(){this._form.removeClassName(this.options.loadingClassName);this._collection=this._collection.map(function(D){return 2===D.length?D:[D,D].flatten()});var A=("value" in this.options)?this.options.value:this._text;var C=this._collection.any(function(D){return D[0]==A}.bind(this));this._controls.editor.update("");var B;this._collection.each(function(D,E){B=document.createElement("option");B.value=D[0];B.selected=C?D[0]==A:0==E;B.appendChild(document.createTextNode(D[1]));this._controls.editor.appendChild(B)}.bind(this));this._controls.editor.disabled=false;Field.scrollFreeActivate(this._controls.editor)}});Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions=function(B){if(!B){return }function A(D,C){if(D in B||C===undefined){return }B[D]=C}A("cancelControl",(B.cancelLink?"link":(B.cancelButton?"button":B.cancelLink==B.cancelButton==false?false:undefined)));A("okControl",(B.okLink?"link":(B.okButton?"button":B.okLink==B.okButton==false?false:undefined)));A("highlightColor",B.highlightcolor);A("highlightEndColor",B.highlightendcolor)};Object.extend(Ajax.InPlaceEditor,{DefaultOptions:{ajaxOptions:{},autoRows:3,cancelControl:"link",cancelText:"cancel",clickToEditText:"Click to edit",externalControl:null,externalControlOnly:false,fieldPostCreation:"activate",formClassName:"inplaceeditor-form",formId:null,highlightColor:"#ffff99",highlightEndColor:"#ffffff",hoverClassName:"",htmlResponse:true,loadingClassName:"inplaceeditor-loading",loadingText:"Loading...",okControl:"button",okText:"ok",paramName:"value",rows:1,savingClassName:"inplaceeditor-saving",savingText:"Saving...",size:0,stripLoadedTextTags:false,submitOnBlur:false,textAfterControls:"",textBeforeControls:"",textBetweenControls:""},DefaultCallbacks:{callback:function(A){return Form.serialize(A)},onComplete:function(A,B){new Effect.Highlight(B,{startcolor:this.options.highlightColor,keepBackgroundImage:true})},onEnterEditMode:null,onEnterHover:function(A){A.element.style.backgroundColor=A.options.highlightColor;if(A._effect){A._effect.cancel()}},onFailure:function(A,B){alert("Error communication with the server: "+A.responseText.stripTags())},onFormCustomization:null,onLeaveEditMode:null,onLeaveHover:function(A){A._effect=new Effect.Highlight(A.element,{startcolor:A.options.highlightColor,endcolor:A.options.highlightEndColor,restorecolor:A._originalBackground,keepBackgroundImage:true})}},Listeners:{click:"enterEditMode",keydown:"checkForEscapeOrReturn",mouseover:"enterHover",mouseout:"leaveHover"}});Ajax.InPlaceCollectionEditor.DefaultOptions={loadingCollectionText:"Loading options..."};Form.Element.DelayedObserver=Class.create({initialize:function(A,C,B){this.delay=C||0.5;this.element=$(A);this.callback=B;this.timer=null;this.lastValue=$F(this.element);Event.observe(this.element,"keyup",this.delayedListener.bindAsEventListener(this))},delayedListener:function(A){if(this.lastValue==$F(this.element)){return }if(this.timer){clearTimeout(this.timer)}this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);this.lastValue=$F(this.element)},onTimerEvent:function(){this.timer=null;this.callback(this.element,$F(this.element))}});
/*vendor/prototype/builder*/
var Builder={NODEMAP:{AREA:"map",CAPTION:"table",COL:"table",COLGROUP:"table",LEGEND:"fieldset",OPTGROUP:"select",OPTION:"select",PARAM:"object",TBODY:"table",TD:"table",TFOOT:"table",TH:"table",THEAD:"table",TR:"table"},node:function(F){F=F.toUpperCase();var E=this.NODEMAP[F]||"div";var A=document.createElement(E);try{A.innerHTML="<"+F+"></"+F+">"}catch(D){}var C=A.firstChild||null;if(C&&(C.tagName.toUpperCase()!=F)){C=C.getElementsByTagName(F)[0]}if(!C){C=document.createElement(F)}if(!C){return }if(arguments[1]){if(this._isStringOrNumber(arguments[1])||(arguments[1] instanceof Array)||arguments[1].tagName){this._children(C,arguments[1])}else{var B=this._attributes(arguments[1]);if(B.length){try{A.innerHTML="<"+F+" "+B+"></"+F+">"}catch(D){}C=A.firstChild||null;if(!C){C=document.createElement(F);for(attr in arguments[1]){C[attr=="class"?"className":attr]=arguments[1][attr]}}if(C.tagName.toUpperCase()!=F){C=A.getElementsByTagName(F)[0]}}}}if(arguments[2]){this._children(C,arguments[2])}return C},_text:function(A){return document.createTextNode(A)},ATTR_MAP:{className:"class",htmlFor:"for"},_attributes:function(B){var A=[];for(attribute in B){A.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+'="'+B[attribute].toString().escapeHTML().gsub(/"/,"&quot;")+'"')}return A.join(" ")},_children:function(A,B){if(B.tagName){A.appendChild(B);return }if(typeof B=="object"){B.flatten().each(function(C){if(typeof C=="object"){A.appendChild(C)}else{if(Builder._isStringOrNumber(C)){A.appendChild(Builder._text(C))}}})}else{if(Builder._isStringOrNumber(B)){A.appendChild(Builder._text(B))}}},_isStringOrNumber:function(A){return(typeof A=="string"||typeof A=="number")},build:function(A){var B=this.node("div");$(B).update(A.strip());return B.down()},dump:function(A){if(typeof A!="object"&&typeof A!="function"){A=window}var B=("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);B.each(function(C){A[C]=function(){return Builder.node.apply(Builder,[C].concat($A(arguments)))}})}};
/*layout*/
var showLogin = true;

function toggleLoginBock()
{
  var fullScreen    =  $('login-fullscreen'),
      formContainer = $('login-form-container');

  if (!fullScreen || !formContainer){
    return;
  }
  if (showLogin){
      new Effect.Opacity(fullScreen, {to: 0.5, duration: 0.0});
      fullScreen.show();
      formContainer.show();
  } else{
    formContainer.hide();
    fullScreen.hide();
  }
  showLogin = !showLogin;
}


function fbLogin(fbVerifyUrl)
{
  FB.Connect.requireSession();
  FB.Facebook.get_sessionState().waitUntilReady(function(data){
    window.location = fbVerifyUrl;
  });
}


function fbInvateFrieds()
{
	FB_RequireFeatures(["Connect"], function(){
    FB.Connect.ifUserConnected(
      function(uid){
        FB.Connect.inviteConnectUsers();
      },
      function(arg){});
  });
}

var isLnavVisible = false;

function toggleGlobLocationNav()
{
  var openBtnBox = $('glob-lnav-open-btn-box'),
      container = $('glob-lnav-container');

  if (!isLnavVisible){
    Effect.SlideDown('globlocation-navigator', { duration: 1.0 });
    openBtnBox.hide();
    container.setStyle({borderTop: '1px solid #FFFFFF'});
  } else{
    Effect.SlideUp('globlocation-navigator', { duration: 1.0 });
    openBtnBox.show();
    container.setStyle({borderTop: '1px solid #93AFCB'});
  }

  isLnavVisible = !isLnavVisible;
}


function fireMessage(messageBoxId, message, type)
{
  messageBox = $(messageBoxId);
  messageBox.hide();
  if (!type){
    chunks = message.split('::');
    message = chunks.pop();
    type = chunks.pop();
  }
  messageBox.update(message);
  messageBox.className = 'content-level-message-'+type;
  messageBox.show();
}


function fireFatalErrorMessage()
{
  fireMessage('content-level-message', 'Error: Ooops, somthing is broken!', 'error');
}


function clearMessage(messageBoxId)
{
  messageBox = $(messageBoxId);
  messageBox.hide();
  messageBox.update('');
}

function clearMessages(type)
{
  $A(document.getElementsByClassName('content-level-message-'+type)).each(function(messageBox){
    messageBox = $(messageBox);
    messageBox.hide();
    messageBox.update('');
  });
}


function onSearchFocus(el, def)
{
  el = $(el);
  el.removeClassName('empty-search-field');
  if(el.value == def){
    el.value='';
  };
}

function onSearchBlur(el, def)
{
  el = $(el);
  if(el.value == ''){
    el.value = def;
    el.addClassName('empty-search-field');
  };
}

function onSearchFormSubmit()
{
  el = $('header_search_string');
  if (el.hasClassName('empty-search-field')){
    el.value = '';
  }
  return true;
}


function showFormErrors(prefix, errors)
{
  clearMessages('error');
  var errorBox;
  $A(errors).each(function(error){
    fireMessage(prefix+error.fieldName, error.errorMessage, 'error');
  });
}


function toggleButtonCode(buttonId)
{
  var buttonCode = $('button-code-'+buttonId),
      buttonCodeTrigger = $('button-code-trigger-'+buttonId);
  if (buttonCode.getStyle('display') == 'none'){
    buttonCode.show();
    buttonCodeTrigger.update('Hide code');
  } else{
    buttonCode.hide();
    buttonCodeTrigger.update('Get code');
  }
}


function charactersLimit(inputId, conunerId, maxLength)
{
  var input = $(inputId),
      value = input.value;

  value = value.truncate(maxLength, '');
  input.value = value;
  $(conunerId).update(maxLength - value.length);
}

function fbShare(u)
{
  u = typeof(u) != 'undefined' && u ? u : location.href;
  var link = 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u);
  window.open(link, 'sharer','toolbar=0,status=0,width=626,height=436');
  return false;
}

/*mod/mod*/
var indexModules = [];

function imInit(params)
{
  var module = {
        topCategoryId:   params.topCategoryId,
        minPostCount:    params.minPostCount,
        postCount:       params.postCount,
        totalPostCount:  params.totalPostCount,
        isStackLocked:   false,
        pushPost:        function imPushPost(event)
                         {
                           if (this.isStackLocked) return;
                           this.isStackLocked = true;
                           var topCategoryId = this.topCategoryId;
                           new Ajax.Request(
                             retrievePostAjaxUrl,
                             {
                               onCreate: function() {imOnAfterRetrievePost(topCategoryId);},
                               onSuccess: function(request) {imOnSuccessRetrievePost(request, topCategoryId);},
                               onComplete: function() {imOnCompleteRetrievePost(topCategoryId);},
                               parameters: {
                                 topCategoryId:   this.topCategoryId,
                                 offset:          this.postCount,
                                 votePeriod:      votePeriod
                               }
                             }
                           );
                         },
        popPost:         function imPushPost(event)
                         {
                           var postSnippetsContainer = $('mod-post-snippets-'+this.topCategoryId),
                               postSnippets = $A(postSnippetsContainer.getElementsByClassName('mod-post-snippet')),
                               lastPostSnippet = postSnippets.last();

                           lastPostSnippet.remove();
                           imUpdatePostStackState(this.topCategoryId, 'pop');
                         }
      };

  module.pushPost = module.pushPost.bindAsEventListener(module);
  module.popPost = module.popPost.bindAsEventListener(module);

  indexModules[params.topCategoryId] = module;

  imUpdatePostStackState(params.topCategoryId);
}


function imUpdatePostStackState(topCategoryId, action)
{
  var module = indexModules[topCategoryId],
      pushBtn = $('mod-push-post-button-'+topCategoryId),
      popBtn = $('mod-pop-post-button-'+topCategoryId);

  switch (action){
    case 'push':
      ++module.postCount;
      break;
    case 'pop':
      --module.postCount;
      break;
  }

  pushBtn.stopObserving('click', module.pushPost);
  if (module.postCount < module.totalPostCount){
    pushBtn.observe('click', module.pushPost);
    pushBtn.className = 'im_button_plus';
  } else{
    pushBtn.className = 'im_button_plus_disabled';
  }

  popBtn.stopObserving('click', module.popPost);
  if (module.postCount > module.minPostCount){
    popBtn.observe('click', module.popPost);
    popBtn.className = 'im_button_minus';
  } else{
    popBtn.className = 'im_button_minus_disabled';
  }

}


function imOnAfterRetrievePost(topCategoryId)
{
  $('mod-post-preloader-'+topCategoryId).show();
}


function imOnSuccessRetrievePost(request, topCategoryId)
{
  imUpdatePostStackState(topCategoryId, 'push');
  $('mod-post-preloader-'+topCategoryId).insert({'before': request.responseText});
}


function imOnCompleteRetrievePost(topCategoryId)
{
  $('mod-post-preloader-'+topCategoryId).hide();
  var module = indexModules[topCategoryId];
  module.isStackLocked = false;
}


function imChangePostImage(topCategoryId, imageUrl, postUrl)
{
  var img = $('mod-post-image-'+topCategoryId);
  if (img){
    $('mod-post-image-'+topCategoryId).src = imageUrl;
    $('mod-post-image-link-'+topCategoryId).href = postUrl;
  }
}

/*post/vote*/
function fbToggle(event, fboxId, show)
{
  var fBox = $(fboxId),
      fBoxBtm = $A(fBox.getElementsByClassName('fb-btm')).first();

  if (show){
    if (fBox.hasClassName('fb-unflagged')){
      fBox.addClassName('fb-over');
      fBoxBtm.update('');
    } else{
      fBox.addClassName('fb-flagged-over');
    }
  } else{
    if(!fBox.hasClassName('no-mouse-out')) {
		if (fBox.hasClassName('fb-unflagged')){
	      fBox.removeClassName('fb-over');
	      fBoxBtm.update('votes');
	    } else{
	      fBox.removeClassName('fb-flagged-over');
	    }
  	}
  }

}
isSendVote = false;
function vote(event, url,votePeriod)
{
	if(!isSendVote) {
	  isSendVote = true;
	  new Ajax.Request(url, {
		parameters:   'votePeriod='+votePeriod,
		asynchronous: true,
		evalScripts:  false,
		on401:        function(request, json){vote401Handler(request)},
		on403:        function(request, json){vote403Handler(request)},
		on404:        function(request, json){vote404Handler(request)},
		onFailure:    function(request, json){voteFailureHandler(request)},
		onSuccess:    function(request, json){voteSuccessHandler(request)}
	  });
	}
}

function vote401Handler(request)
{
  window.location.assign(loginUrl);
}

function vote403Handler(request)
{
  fireMessage(
    'content-level-message',
    'Ooops! You are not allowed to do that.',
    'error'
  );
  isSendVote = false;
}

function vote404Handler(request)
{
  fireMessage(
    'content-level-message',
    'Ooops! Something is missing.',
    'error'
  );
  isSendVote = false;
}

function voteFailureHandler(request)
{
  fireMessage(
    'content-level-message',
    'Ooops! There is a problem with our server.',
    'error'
  );
  isSendVote = false;
}

function voteSuccessHandler(request)
{
  var post = request.responseJSON.post,
      fBoxes = $A(document.getElementsByClassName('fb'));

  fBoxes.each(function(fBox){
    if (fBox.id.endsWith('-'+this.id)){
      var fBoxTop = $A(fBox.getElementsByClassName('fb-top')).first(),
          fBoxBtm = $A(fBox.getElementsByClassName('fb-btm')).first();

      fBox.stopObserving('click');
      fBox.removeClassName('fb-unflagged');
      fBox.removeClassName('fb-over');
      fBoxTop.update(this.votes);
      fBoxBtm.update('votes');
      fireMessage('content-level-message', 'Thanks for your vote.', 'ok');
    }
  }, post);
  isSendVote = false;
  fbPublishPost(post.url);
  
}


function fbPublishPost(url)
{
  FB_RequireFeatures(['Connect'], function(){
    FB.Connect.ifUserConnected(
      function(uid){fbShare(url);},
      function(arg){}
    );
  });
}

/*lib/menu/ns-menu*/
var nsMenu = Class.create({

  _CLASS_MENU:                      'nsmenu',
  _CLASS_ITEM:                      'nsmenuitem',
  _CLASS_ITEM_SELECTED:             'nsmenuitem-selected',
  _CLASS_ITEM_HAS_SUBMENU:          'nsmenuitem-hassubmenu',
  _CLASS_ITEM_HAS_SUBMENU_SELECTED: 'nsmenuitem-hassubmenu-selected',
  _CLASS_ITEM_LABEL:                'nsmenuitemlabel',
  _CLASS_ITEM_LABEL_SELECTED:       'nsmenuitemlabel-selected',

  initialize: function(menuId, config){
    this.menuId = menuId;
    this.idPrefix = config.idPrefix || menuId;
    this.nodes = config.nodes;
    this.parentMenu = config.parentMenu || null;
    this.isSubmenu = config.parentMenu ? true : false;
    this.isActive = !this.isSubmenu;
    this.submenues = [];
    this.currentSubmenu = null;
    this.isRendered = false;
    this.selectedItemIndex = null;
    this.menuIndex = config.menuIndex == 'undefined' ? null : config.menuIndex;
    this.alignConner = config.alignConner || 'trtl';

    if (!this.isSubmenu){
      nsMenuManager.registerMenu(this);
      this.level = 0;
    } else{
      this.level = this.parentMenu.level+1;
    }
  },

  render: function(container){
    this.container = $(container);

    if (this.isRendered) return;

    var menuDiv = $(Builder.node('div', {id: this.menuId, className: this._CLASS_MENU})),
        bdDiv = $(Builder.node('div', {className: 'bd'})),
        itemsList = $(Builder.node('ul')),
        item, label, submenu;

    this.nodes.each(function(node,index){

      item = $(Builder.node(
        'li',
        {
          id: this.idPrefix+'_nsmenuitem_'+node.id,
          className: this._CLASS_ITEM+(node.isLeaf ? '' : ' '+this._CLASS_ITEM_HAS_SUBMENU)
        }
      ));

      label = $(Builder.node(
        'a',
        {
          id: this.idPrefix+'_nsmenuitemlabel_'+node.id,
          className: this._CLASS_ITEM_LABEL,
          href: typeof node.href == 'undefined' ? 'javascript:void(0)' : node.href
        },
        [node.label]
      ));

      label.observe('mouseover', this.onMenuItemMouseOver.bindAsEventListener(this, index));
      label.observe('click', this.onMenuItemClick.bindAsEventListener(this, index));

      item.insert(label);

      if (node.isLeaf){
        this.submenues[index] = null;
      } else{
        this.submenues[index] = new nsMenu(
          this.idPrefix+'_submenu_'+node.id,
          {
            nodes: node.children,
            idPrefix: this.idPrefix,
            parentMenu: this,
            menuIndex: this.menuIndex
          }
        );
      }

      itemsList.insert(item);
    }, this);

    bdDiv.insert(itemsList);
    menuDiv.insert(bdDiv);

    if (!this.isSubmenu){
      this.container.setStyle({position: 'absolute'});
    }

    this.container.insert(menuDiv);

    this.isRendered = true;

    if (!this.isSubmenu){
      document.observe('mouseover', this.checkMouseAction.bindAsEventListener(this));
    }
  },

  checkMouseAction: function(event){
    if (!event.element().id.match(new RegExp('^'+this.idPrefix))){
      this.unselectMenuItem();
    }
  },

  onMenuItemMouseOver: function(event, index){
    this.selectMenuItem(index);
  },

  onMenuItemClick: function(event, index){
    if (this.isSubmenu){
      this.hide();
    }

    nsMenuManager.processEvent(this.menuIndex, index, 'click', event);
  },

  selectMenuItem: function(index){
    var node = this.nodes[index],
        submenu = this.submenues[index],
        item = $(this.idPrefix+'_nsmenuitem_'+node.id),
        label = $(this.idPrefix+'_nsmenuitemlabel_'+node.id);

    this.unselectMenuItem();

    this.selectedItemIndex = index;

    item.addClassName(this._CLASS_ITEM_SELECTED);
    label.addClassName(this._CLASS_ITEM_LABEL_SELECTED);
    if (submenu){
      item.addClassName(this._CLASS_ITEM_HAS_SUBMENU_SELECTED);
    }

    this.openSubmenu(index);
  },

  unselectMenuItem: function(index){
    if (typeof index == 'undefined'){
      index = this.selectedItemIndex;
    }
    if (index == null) return;

    this.selectedItemIndex = null;

    var node = this.nodes[index],
        submenu = this.submenues[index],
        item = $(this.idPrefix+'_nsmenuitem_'+node.id),
        label = $(this.idPrefix+'_nsmenuitemlabel_'+node.id);

    item.removeClassName(this._CLASS_ITEM_SELECTED);
    label.removeClassName(this._CLASS_ITEM_LABEL_SELECTED);
    if (submenu){
      item.removeClassName(this._CLASS_ITEM_HAS_SUBMENU_SELECTED);
    }

    this.closeSubmenu(index);
  },

  openSubmenu: function(index){
    var submenu = this.submenues[index],
        node = this.nodes[index],
        item = $(this.idPrefix+'_nsmenuitem_'+node.id);

    if (!submenu || submenu.isActive) return;

    submenu.render(item);
    submenu.show();
  },

  closeSubmenu: function(index){
    var submenu = this.submenues[index];

    if (!submenu || !submenu.isActive) return;

    submenu.hide();
  },

  show: function(){
    if(!this.isRendered) return;

    var menuDiv = $(this.menuId),
        containerXY = this.container.positionedOffset();

    if (this.isSubmenu){
      var parentMenuDiv = $(this.parentMenu.menuId),
          parentMenuXY = parentMenuDiv.positionedOffset(),
          menuTop, menuLeft;

      switch (this.alignConner){
        case 'bltl':
          if (menuDiv.offsetWidth < this.container.offsetWidth){
            menuDiv.setStyle({width: this.container.offsetWidth+'px'});
          }
          menuTop = (containerXY[1]+this.container.offsetHeight-1)+'px';
          menuLeft = containerXY[0]+'px';
          break;
        case 'trtl':
          menuTop = (containerXY[1]-2)+'px';
          menuLeft = parentMenuXY[0]+parentMenuDiv.offsetWidth+menuDiv.offsetWidth > document.body.clientWidth ?
                     (containerXY[0]-menuDiv.offsetWidth-1)+'px' :
                     (containerXY[0]+parentMenuDiv.offsetWidth-3)+'px';
          break;
      }
    } else{
      menuTop = containerXY[1]+'px';
      menuLeft = containerXY[0]+'px';
    }

    menuDiv.setStyle({visibility: 'visible', top: menuTop, left: menuLeft});
    this.isActive = true;
  },

  hide: function(){
    if(!this.isRendered) return;

    var menuDiv = $(this.menuId),
        submenu = this.submenues[this.selectedItemIndex];

    if (submenu){
      submenu.hide();
    }

    menuDiv.setStyle({visibility: 'hidden'});
    this.unselectMenuItem();

    this.isActive = false;
  },

  subscribe: function(eventName, handler, extraParams){
    nsMenuManager.subscribe(this.menuIndex, eventName, handler, extraParams);
  }

});


var nsMenuBar = Class.create(nsMenu, {

  _CLASS_MENU:                      'nsmenubar',
  _CLASS_ITEM:                      'nsmenubaritem',
  _CLASS_ITEM_SELECTED:             'nsmenubaritem-selected',
  _CLASS_ITEM_HAS_SUBMENU:          'nsmenubaritem-hassubmenu',
  _CLASS_ITEM_HAS_SUBMENU_SELECTED: 'nsmenubaritem-hassubmenu-selected',
  _CLASS_ITEM_LABEL:                'nsmenubaritemlabel',
  _CLASS_ITEM_LABEL_HASSUBMENU:     'nsmenubaritemlabel-hassubmenu',
  _CLASS_ITEM_LABEL_SELECTED:       'nsmenubaritemlabel-selected',
  _CLASS_ITEM_CHEVRONE:             'nsmenubaritemchevrone',
  _CLASS_ITEM_CHEVRONE_SELECTED:    'nsmenubaritemchevrone-selected'
});

nsMenuBar.addMethods({

  render: function($super, container){
    if (this.isRendered) return;

    this.container = $(container);

    var menuDiv = $(Builder.node('div', {id: this.menuId, className: this._CLASS_MENU})),
        bdDiv = $(Builder.node('div', {className: 'bd'})),
        itemsList = $(Builder.node('ul')),
        item, label, submenu;

    this.nodes.each(function(node,index){

      item = $(Builder.node(
        'li',
        {
          id: this.idPrefix+'_nsmenuitem_'+node.id,
          className: this._CLASS_ITEM+(node.isLeaf ? '' : ' '+this._CLASS_ITEM_HAS_SUBMENU)+(node.className ? ' '+node.className : '')
        }
      ));

      label = $(Builder.node(
        'a',
        {
          id: this.idPrefix+'_nsmenuitemlabel_'+node.id,
          className: node.isLeaf ? this._CLASS_ITEM_LABEL : this._CLASS_ITEM_LABEL_HASSUBMENU,
          href: typeof node.href == 'undefined' ? 'javascript:void(0)' : node.href
        },
        [node.label]
      ));

      label.observe('mouseover', this.onMenuItemMouseOver.bindAsEventListener(this, index));
      label.observe('click', this.onMenuItemClick.bindAsEventListener(this, index));

      item.insert(label);

      if (node.isLeaf){
        this.submenues[index] = null;
      } else{
        chevrone = $(Builder.node(
          'span',
          {
            id: this.idPrefix+'_nsmenuitemchevrone_'+node.id,
            className: this._CLASS_ITEM_CHEVRONE,
            href: typeof node.href == 'undefined' ? 'javascript:void(0)' : node.href
          },
          ['']
        ));
        chevrone.observe('mouseover', this.onMenuItemMouseOver.bindAsEventListener(this, index));
        chevrone.observe('click', this.onChevroneClick.bindAsEventListener(this, index));
        label.insert(chevrone);

        this.submenues[index] = new nsMenu(
          this.idPrefix+'_submenu_'+node.id,
          {
            nodes: node.children,
            idPrefix: this.idPrefix,
            parentMenu: this,
            menuIndex: this.menuIndex,
            alignConner: 'bltl'
          }
        );
      }

      itemsList.insert(item);
    }, this);

    bdDiv.insert(itemsList);
    menuDiv.insert(bdDiv);

    this.container.insert(menuDiv);

    document.observe('mouseover', this.checkMouseAction.bindAsEventListener(this));

    this.isRendered = true;
  },

  selectMenuItem: function($super, index){
    var node = this.nodes[index],
        submenu = this.submenues[index],
        item = $(this.idPrefix+'_nsmenuitem_'+node.id),
        label = $(this.idPrefix+'_nsmenuitemlabel_'+node.id);

    if (this.selectedItemIndex == index) return;

    this.unselectMenuItem();

    this.selectedItemIndex = index;

    item.addClassName(this._CLASS_ITEM_SELECTED);
    label.addClassName(this._CLASS_ITEM_LABEL_SELECTED);
  },

  unselectMenuItem: function($super, index){
    if (typeof index == 'undefined'){
      index = this.selectedItemIndex;
    }
    if (index == null) return;

    this.selectedItemIndex = null;

    var node = this.nodes[index],
        submenu = this.submenues[index],
        item = $(this.idPrefix+'_nsmenuitem_'+node.id),
        label = $(this.idPrefix+'_nsmenuitemlabel_'+node.id);

    item.removeClassName(this._CLASS_ITEM_SELECTED);
    label.removeClassName(this._CLASS_ITEM_LABEL_SELECTED);

    this.closeSubmenu(index);
  },

  onChevroneClick: function(event, index){
    if (this.submenues[index].isActive){
      this.closeSubmenu(index);
    } else{
      this.openSubmenu(index);
    }
  },

  onMenuItemClick: function(event, index){
    if (event.element().id.match(/_nsmenuitemchevrone_/)){
      event.stop();
    }
  }

});

var nsMenuManager = {
  menues: [],

  registerMenu: function(menu){
    menu.menuIndex = this.menues.length;
    this.menues.push({
      menu: menu,
      handlers: {}
    });
  },

  subscribe: function(menuIndex, eventName, handler, extraParams){
    this.menues[menuIndex].handlers[eventName] = {
      handler: handler,
      extraParams: extraParams
    };
  },

  processEvent: function(menuIndex, itemIndex, eventName, event){
    var menuData = this.menues[menuIndex];
    if (typeof menuData == 'undefined') return;

    var handlerData = menuData.handlers[eventName];
    if (typeof handlerData == 'undefined') return;

    var handler = handlerData.handler;
    if (typeof handler != 'function') return;

    handler(event, menuData.menu.nodes[itemIndex], handlerData.extraParams);
  }
}

/*category/categorynav*/
var catnavMenu;

function catnavInit(categories)
{
  categories.each(function(category){
    category.className = 'catnavtopitem-'+category.slug;
  });
  catNavMenu = new nsMenuBar('catnav-menu', {nodes: categories});
  catNavMenu.render('catnav-menu-container');
  catNavMenu.show();
}
/*location/globlocationnav*/
function glInit(params)
{
  new Ajax.Autocompleter(
    'address',
    'address_auto_complete',
    params.autocompleteUrl,
    {
      afterUpdateElement: glAutocompleteHandler,
      callback: function(element, value){return 'terminal=0&'+value},
      minChars: 2,
      paramName: 'location'
    }
  );
}

function glAutocompleteHandler(e, l)
{
  var chunks = l.id.split(/_/);
  $('glob-lnav-location-id').value = chunks.pop();
}


Event.observe(document, 'click', glHideMenu);

var glCurrentMenu,
    glMenuShowLock = false;

function glShowMenu(locationId, withTopOffset)
{
  if (glMenuShowLock) return false;

  var linkAnchor = $('gllinkanchor_'+locationId),
      menu   = $('glmenu_'+locationId),
      offsetLeft = 10,
      offsetTop = withTopOffset ? 42 : 12;

  menu.setStyle({
    left: (linkAnchor.offsetLeft-offsetLeft)+'px',
    top:  (linkAnchor.offsetTop-offsetTop)+'px'
  });

  glHideMenu();

  glCurrentMenu = menu;

  menu.show();

  menu.setStyle({width: menu.offsetWidth+'px'});
  menu.hide();
  menu.show();

  return false;
}

function glHideMenu()
{
  if (!glCurrentMenu) return;
  glCurrentMenu.hide();
  glCurrentMenu = null;
  return false;
}

function glZoomOut(params)
{
  glMenuShowLock = true;
  new Ajax.Updater('globlocationnav-right-spiffyfg', params.treeLoadUrl, {
    asynchronous: false,
    onComplete: function (request){
      $('globlocationnav-right-spiffyfg').setStyle({
        height: 'auto'
      });
      glMenuShowLock = false;
    }
  });
}

function glZoomIn(params)
{
  glMenuShowLock = true;
  new Ajax.Updater('glNewChildrenLocationsContainer', params.childrenLoadUrl, {
    asynchronous: false,
    onComplete: function (request){
      var siblingsContainer = $('glSiblingLocationsContainer'),
          siblings = $('glSiblingLocations_'+params.currentLocationId),
          siblingsMarginTop = Number(siblings.getStyle('margin-top').match(/^\d+/)),
          childrenContainer = $('glChildLocationsContainer'),
          children = $('glChildrenLocations_'+params.currentLocationId),
          childrenHeight = Number(children.offsetHeight),
          childrenMarginTop = Number(children.getStyle('margin-top').match(/^\d+/)),
          childrenMarginBottom = Number(children.getStyle('margin-bottom').match(/^\d+/)),
          newChildrenContainer = $('glNewChildrenLocationsContainer'),
          newChildren = $('glChildrenLocations_'+params.childLocationId);


      new Effect.Morph('globlocationnav-right-spiffyfg', {
        style: { height: '300px'},
        duration: 1.0
      });

      new Effect.Parallel(
        [
          new Effect.Move(siblingsContainer, {sync: true, y: -siblingsMarginTop, mode: 'absolute'}),
          new Effect.Opacity(siblingsContainer, {sync: true, from: 1, to: 0 }),
          new Effect.Move(childrenContainer, {sync: true, y: (siblings.offsetTop-children.offsetTop), mode: 'absolute'}),
          new Effect.Move(newChildrenContainer, {sync: true, y: (siblings.offsetTop-children.offsetTop-childrenMarginTop), mode: 'absolute'}),
          new Effect.Appear(newChildrenContainer, {sync: true})
        ],
        {
          duration: 1.5,
          delay: 1.1
        }
      );

      setTimeout("new Effect.Morph('globlocationnav-right-spiffyfg',{style:{height:($('glChildrenLocations_'+"+params.childLocationId+").offsetHeight+"+(childrenHeight+siblingsMarginTop+childrenMarginTop+childrenMarginBottom)+")+'px'},duration:1.0});",2700);

      setTimeout("new Ajax.Updater('globlocationnav-right-spiffyfg', '"+params.treeLoadUrl+"', {asynchronous: false, onComplete: function (request){glMenuShowLock = false;}});", 3800);

    }
  });

  return false;
}

function glHighlightMenuEdge(edgeId)
{
  $(edgeId).addClassName('highlighted');
}

function glUnhighlightMenuEdge(edgeId)
{
  $(edgeId).removeClassName('highlighted');
}

function glSearchLocationSuccessHandler(request)
{
  window.location = request.responseText;
}

function glSearchLocationFilureHandler()
{
  var errBox = $('gl-search-err'),
      input = $('address');

  errBox.update("Sorry, we can't find that place");
  input.addClassName('input-err');
}

function glClearSearchErrors()
{
  var errBox = $('gl-search-err'),
      input = $('address');

  errBox.update('');
  input.removeClassName('input-err');
}

