var Prototype={Version:"1.6.0.3",Browser:{IE:!!(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1),Opera:navigator.userAgent.indexOf("Opera")>-1,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,SelectorsAPI:!!document.querySelector,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 e=null,d=$A(arguments);if(Object.isFunction(d[0])){e=d.shift()}function a(){this.initialize.apply(this,arguments)}Object.extend(a,Class.Methods);a.superclass=e;a.subclasses=[];if(e){var b=function(){};b.prototype=e.prototype;a.prototype=new b;e.subclasses.push(a)}for(var c=0;c<d.length;c++){a.addMethods(d[c])}if(!a.prototype.initialize){a.prototype.initialize=Prototype.emptyFunction}a.prototype.constructor=a;return a}};Class.Methods={addMethods:function(g){var c=this.superclass&&this.superclass.prototype;var b=Object.keys(g);if(!Object.keys({toString:true}).length){b.push("toString","valueOf")}for(var a=0,d=b.length;a<d;a++){var f=b[a],e=g[f];if(c&&Object.isFunction(e)&&e.argumentNames().first()=="$super"){var h=e;e=(function(j){return function(){return c[j].apply(this,arguments)}})(f).wrap(h);e.valueOf=h.valueOf.bind(h);e.toString=h.toString.bind(h)}this.prototype[f]=e}return this}};var Abstract={};Object.extend=function(a,c){for(var b in c){a[b]=c[b]}return a};Object.extend(Object,{inspect:function(a){try{if(Object.isUndefined(a)){return"undefined"}if(a===null){return"null"}return a.inspect?a.inspect():String(a)}catch(b){if(b instanceof RangeError){return"..."}throw b}},toJSON:function(a){var c=typeof a;switch(c){case"undefined":case"function":case"unknown":return;case"boolean":return a.toString()}if(a===null){return"null"}if(a.toJSON){return a.toJSON()}if(Object.isElement(a)){return}var b=[];for(var e in a){var d=Object.toJSON(a[e]);if(!Object.isUndefined(d)){b.push(e.toJSON()+": "+d)}}return"{"+b.join(", ")+"}"},toQueryString:function(a){return $H(a).toQueryString()},toHTML:function(a){return a&&a.toHTML?a.toHTML():String.interpret(a)},keys:function(a){var b=[];for(var c in a){b.push(c)}return b},values:function(b){var a=[];for(var c in b){a.push(b[c])}return a},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].replace(/\s+/g,"").split(",");return a.length==1&&!a[0]?[]:a},bind:function(){if(arguments.length<2&&Object.isUndefined(arguments[0])){return this}var a=this,c=$A(arguments),b=c.shift();return function(){return a.apply(b,c.concat($A(arguments)))}},bindAsEventListener:function(){var a=this,c=$A(arguments),b=c.shift();return function(d){return a.apply(b,[d||window.event].concat(c))}},curry:function(){if(!arguments.length){return this}var a=this,b=$A(arguments);return function(){return a.apply(this,b.concat($A(arguments)))}},delay:function(){var a=this,b=$A(arguments),c=b.shift()*1000;return window.setTimeout(function(){return a.apply(a,b)},c)},defer:function(){var a=[0.01].concat($A(arguments));return this.delay.apply(this,a)},wrap:function(b){var a=this;return function(){return b.apply(this,[a.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)))}}});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 c;for(var b=0,d=arguments.length;b<d;b++){var a=arguments[b];try{c=a();break}catch(f){}}return c}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(b,a){this.callback=b;this.frequency=a;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*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(e,c){var a="",d=this,b;c=arguments.callee.prepareReplacement(c);while(d.length>0){if(b=d.match(e)){a+=d.slice(0,b.index);a+=String.interpret(c(b));d=d.slice(b.index+b[0].length)}else{a+=d,d=""}}return a},sub:function(c,a,b){a=this.gsub.prepareReplacement(a);b=Object.isUndefined(b)?1:b;return this.gsub(c,function(d){if(--b<0){return d[0]}return a(d)})},scan:function(b,a){this.gsub(b,a);return String(this)},truncate:function(b,a){b=b||30;a=Object.isUndefined(a)?"...":a;return this.length>b?this.slice(0,b-a.length)+a: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 b=new RegExp(Prototype.ScriptFragment,"img");var a=new RegExp(Prototype.ScriptFragment,"im");return(this.match(b)||[]).map(function(c){return(c.match(a)||["",""])[1]})},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script)})},escapeHTML:function(){var 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(b,c){return b+c.nodeValue}):a.childNodes[0].nodeValue):""},toQueryParams:function(b){var a=this.strip().match(/([^?#]*)(#.*)?$/);if(!a){return{}}return a[1].split(b||"&").inject({},function(e,f){if((f=f.split("="))[0]){var c=decodeURIComponent(f.shift());var d=f.length>1?f.join("="):f[0];if(d!=undefined){d=decodeURIComponent(d)}if(c in e){if(!Object.isArray(e[c])){e[c]=[e[c]]}e[c].push(d)}else{e[c]=d}}return e})},toArray:function(){return this.split("")},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(a){return a<1?"":new Array(a+1).join(this)},camelize:function(){var d=this.split("-"),a=d.length;if(a==1){return d[0]}var c=this.charAt(0)=="-"?d[0].charAt(0).toUpperCase()+d[0].substring(1):d[0];for(var b=1;b<a;b++){c+=d[b].charAt(0).toUpperCase()+d[b].substring(1)}return c},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase()},dasherize:function(){return this.gsub(/_/,"-")},inspect:function(b){var a=this.gsub(/[\x00-\x1f\\]/,function(c){var d=String.specialChar[c[0]];return d?d:"\\u00"+c[0].charCodeAt().toPaddedString(2,16)});if(b){return'"'+a.replace(/"/g,'\\"')+'"'}return"'"+a.replace(/'/g,"\\'")+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(a){return this.sub(a||Prototype.JSONFilter,"#{1}")},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(a){var b=this.length-a.length;return b>=0&&this.lastIndexOf(a)===b},empty:function(){return this==""},blank:function(){return/^\s*$/.test(this)},interpolate:function(a,b){return new Template(this,b).evaluate(a)}});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.stripTags().replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}})}String.prototype.gsub.prepareReplacement=function(b){if(Object.isFunction(b)){return b}var a=new Template(b);return function(c){return a.evaluate(c)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);var Template=Class.create({initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(a){if(Object.isFunction(a.toTemplateReplacements)){a=a.toTemplateReplacements()}return this.template.gsub(this.pattern,function(d){if(a==null){return""}var f=d[1]||"";if(f=="\\"){return d[2]}var b=a,g=d[3];var e=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;d=e.exec(g);if(d==null){return f}while(d!=null){var c=d[1].startsWith("[")?d[2].gsub("\\\\]","]"):d[1];b=b[c];if(null==b||""==d[3]){break}g=g.substring("["==d[3]?d[1].length:d[0].length);d=e.exec(g)}return f+String.interpret(b)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(c,b){var a=0;try{this._each(function(e){c.call(b,e,a++)})}catch(d){if(d!=$break){throw d}}return this},eachSlice:function(d,c,b){var a=-d,e=[],f=this.toArray();if(d<1){return f}while((a+=d)<f.length){e.push(f.slice(a,a+d))}return e.collect(c,b)},all:function(c,b){c=c||Prototype.K;var a=true;this.each(function(e,d){a=a&&!!c.call(b,e,d);if(!a){throw $break}});return a},any:function(c,b){c=c||Prototype.K;var a=false;this.each(function(e,d){if(a=!!c.call(b,e,d)){throw $break}});return a},collect:function(c,b){c=c||Prototype.K;var a=[];this.each(function(e,d){a.push(c.call(b,e,d))});return a},detect:function(c,b){var a;this.each(function(e,d){if(c.call(b,e,d)){a=e;throw $break}});return a},findAll:function(c,b){var a=[];this.each(function(e,d){if(c.call(b,e,d)){a.push(e)}});return a},grep:function(d,c,b){c=c||Prototype.K;var a=[];if(Object.isString(d)){d=new RegExp(d)}this.each(function(f,e){if(d.match(f)){a.push(c.call(b,f,e))}});return a},include:function(a){if(Object.isFunction(this.indexOf)){if(this.indexOf(a)!=-1){return true}}var b=false;this.each(function(c){if(c==a){b=true;throw $break}});return b},inGroupsOf:function(b,a){a=Object.isUndefined(a)?null:a;return this.eachSlice(b,function(c){while(c.length<b){c.push(a)}return c})},inject:function(a,c,b){this.each(function(e,d){a=c.call(b,a,e,d)});return a},invoke:function(b){var a=$A(arguments).slice(1);return this.map(function(c){return c[b].apply(c,a)})},max:function(c,b){c=c||Prototype.K;var a;this.each(function(e,d){e=c.call(b,e,d);if(a==null||e>=a){a=e}});return a},min:function(c,b){c=c||Prototype.K;var a;this.each(function(e,d){e=c.call(b,e,d);if(a==null||e<a){a=e}});return a},partition:function(d,b){d=d||Prototype.K;var c=[],a=[];this.each(function(f,e){(d.call(b,f,e)?c:a).push(f)});return[c,a]},pluck:function(b){var a=[];this.each(function(c){a.push(c[b])});return a},reject:function(c,b){var a=[];this.each(function(e,d){if(!c.call(b,e,d)){a.push(e)}});return a},sortBy:function(b,a){return this.map(function(d,c){return{value:d,criteria:b.call(a,d,c)}}).sort(function(f,e){var d=f.criteria,c=e.criteria;return d<c?-1:d>c?1:0}).pluck("value")},toArray:function(){return this.map()},zip:function(){var b=Prototype.K,a=$A(arguments);if(Object.isFunction(a.last())){b=a.pop()}var c=[this].concat(a).map($A);return this.map(function(e,d){return b(c.pluck(d))})},size:function(){return this.toArray().length},inspect:function(){return"#<Enumerable:"+this.toArray().inspect()+">"}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(c){if(!c){return[]}if(c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}if(Prototype.Browser.WebKit){$A=function(c){if(!c){return[]}if(!(typeof c==="function"&&typeof c.length==="number"&&typeof c.item==="function")&&c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse}Object.extend(Array.prototype,{_each:function(b){for(var a=0,c=this.length;a<c;a++){b(this[a])}},clear:function(){this.length=0;return this},first:function(){return this[0]},last:function(){return this[this.length-1]},compact:function(){return this.select(function(a){return a!=null})},flatten:function(){return this.inject([],function(b,a){return b.concat(Object.isArray(a)?a.flatten():[a])})},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(d,c,b){if(0==b||(a?d.last()!=c:!d.include(c))){d.push(c)}return d})},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(b){var c=Object.toJSON(b);if(!Object.isUndefined(c)){a.push(c)}});return"["+a.join(", ")+"]"}});if(Object.isFunction(Array.prototype.forEach)){Array.prototype._each=Array.prototype.forEach}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c,a){a||(a=0);var b=this.length;if(a<0){a=b+a}for(;a<b;a++){if(this[a]===c){return a}}return -1}}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(b,a){a=isNaN(a)?this.length:(a<0?this.length+a:a)+1;var c=this.slice(0,a).reverse().indexOf(b);return(c<0)?c:a-c-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 e=[];for(var b=0,c=this.length;b<c;b++){e.push(this[b])}for(var b=0,c=arguments.length;b<c;b++){if(Object.isArray(arguments[b])){for(var a=0,d=arguments[b].length;a<d;a++){e.push(arguments[b][a])}}else{e.push(arguments[b])}}return e}}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(b,a){$R(0,this,true).each(b,a);return this},toPaddedString:function(c,b){var a=this.toString(b||10);return"0".times(c-a.length)+a},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(b,c){if(Object.isUndefined(c)){return b}return b+"="+encodeURIComponent(String.interpret(c))}return{initialize:function(b){this._object=Object.isHash(b)?b.toObject():Object.clone(b)},_each:function(c){for(var b in this._object){var d=this._object[b],e=[b,d];e.key=b;e.value=d;c(e)}},set:function(b,c){return this._object[b]=c},get:function(b){if(this._object[b]!==Object.prototype[b]){return this._object[b]}},unset:function(b){var c=this._object[b];delete this._object[b];return c},toObject:function(){return Object.clone(this._object)},keys:function(){return this.pluck("key")},values:function(){return this.pluck("value")},index:function(c){var b=this.detect(function(d){return d.value===c});return b&&b.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.inject([],function(d,e){var c=encodeURIComponent(e.key),b=e.value;if(b&&typeof b=="object"){if(Object.isArray(b)){return d.concat(b.map(a.curry(c)))}}else{d.push(a(c,b))}return d}).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(c,a,b){this.start=c;this.end=a;this.exclusive=b},_each:function(a){var b=this.start;while(this.include(b)){a(b);b=b.succ()}},include:function(a){if(a<this.start){return false}if(this.exclusive){return a<this.end}return a<=this.end}});var $R=function(c,a,b){return new ObjectRange(c,a,b)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(a){this.responders._each(a)},register:function(a){if(!this.include(a)){this.responders.push(a)}},unregister:function(a){this.responders=this.responders.without(a)},dispatch:function(d,b,c,a){this.each(function(f){if(Object.isFunction(f[d])){try{f[d].apply(f,[b,c,a])}catch(g){}}})}};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,b,a){$super(a);this.transport=Ajax.getTransport();this.request(b)},request:function(b){this.url=b;this.method=this.options.method;var d=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){d._method=this.method;this.method="post"}this.parameters=d;if(d=Object.toQueryString(d)){if(this.method=="get"){this.url+=(this.url.include("?")?"&":"?")+d}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){d+="&_="}}}try{var a=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(a)}Ajax.Responders.dispatch("onCreate",this,a);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||d):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}}catch(c){this.dispatchException(c)}},onStateChange:function(){var a=this.transport.readyState;if(a>1&&!((a==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var e={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){e["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){e.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var c=this.options.requestHeaders;if(Object.isFunction(c.push)){for(var b=0,d=c.length;b<d;b+=2){e[c[b]]=c[b+1]}}else{$H(c).each(function(f){e[f.key]=f.value})}}for(var a in e){this.transport.setRequestHeader(a,e[a])}},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(a){var c=Ajax.Request.Events[a],b=new Ajax.Response(this);if(c=="Complete"){try{this._complete=true;(this.options["on"+b.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(b,b.headerJSON)}catch(d){this.dispatchException(d)}var f=b.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&f&&f.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){this.evalResponse()}}try{(this.options["on"+c]||Prototype.emptyFunction)(b,b.headerJSON);Ajax.Responders.dispatch("on"+c,this,b,b.headerJSON)}catch(d){this.dispatchException(d)}if(c=="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(a){try{return this.transport.getResponseHeader(a)||null}catch(b){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(c){this.request=c;var d=this.transport=c.transport,a=this.readyState=d.readyState;if((a>2&&!Prototype.Browser.IE)||a==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(d.responseText);this.headerJSON=this._getHeaderJSON()}if(a==4){var b=d.responseXML;this.responseXML=Object.isUndefined(b)?null:b;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 a=this.getHeader("X-JSON");if(!a){return null}a=decodeURIComponent(escape(a));try{return a.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(b){this.request.dispatchException(b)}},_getResponseJSON:function(){var a=this.request.options;if(!a.evalJSON||(a.evalJSON!="force"&&!(this.getHeader("Content-type")||"").include("application/json"))||this.responseText.blank()){return null}try{return this.responseText.evalJSON(a.sanitizeJSON||!this.request.isSameOrigin())}catch(b){this.request.dispatchException(b)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,a,c,b){this.container={success:(a.success||a),failure:(a.failure||(a.success?null:a))};b=Object.clone(b);var d=b.onComplete;b.onComplete=(function(e,f){this.updateContent(e.responseText);if(Object.isFunction(d)){d(e,f)}}).bind(this);$super(c,b)},updateContent:function(d){var c=this.container[this.success()?"success":"failure"],a=this.options;if(!a.evalScripts){d=d.stripScripts()}if(c=$(c)){if(a.insertion){if(Object.isString(a.insertion)){var b={};b[a.insertion]=d;c.insert(b)}else{a.insertion(c,d)}}else{c.update(d)}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,a,c,b){$super(b);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=a;this.url=c;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(a){if(this.options.decay){this.decay=(a.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=a.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(b){if(arguments.length>1){for(var a=0,d=[],c=arguments.length;a<c;a++){d.push($(arguments[a]))}return d}if(Object.isString(b)){b=document.getElementById(b)}return Element.extend(b)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(f,a){var c=[];var e=document.evaluate(f,$(a)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var b=0,d=e.snapshotLength;b<d;b++){c.push(Element.extend(e.snapshotItem(b)))}return c}}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(d,c){c=c||{};d=d.toLowerCase();var b=Element.cache;if(Prototype.Browser.IE&&c.name){d="<"+d+' name="'+c.name+'">';delete c.name;return Element.writeAttribute(document.createElement(d),c)}if(!b[d]){b[d]=Element.extend(document.createElement(d))}return Element.writeAttribute(b[d].cloneNode(false),c)};Object.extend(this.Element,a||{});if(a){this.Element.prototype=a.prototype}}).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=$(a);a.style.display="none";return a},show:function(a){a=$(a);a.style.display="";return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},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);a.innerHTML=b.stripScripts();b.evalScripts.bind(b).defer();return a},replace:function(b,c){b=$(b);if(c&&c.toElement){c=c.toElement()}else{if(!Object.isElement(c)){c=Object.toHTML(c);var a=b.ownerDocument.createRange();a.selectNode(b);c.evalScripts.bind(c).defer();c=a.createContextualFragment(c.stripScripts())}}b.parentNode.replaceChild(c,b);return b},insert:function(c,e){c=$(c);if(Object.isString(e)||Object.isNumber(e)||Object.isElement(e)||(e&&(e.toElement||e.toHTML))){e={bottom:e}}var d,f,b,g;for(var a in e){d=e[a];a=a.toLowerCase();f=Element._insertionTranslations[a];if(d&&d.toElement){d=d.toElement()}if(Object.isElement(d)){f(c,d);continue}d=Object.toHTML(d);b=((a=="before"||a=="after")?c.parentNode:c).tagName.toUpperCase();g=Element._getContentFromAnonymousElement(b,d.stripScripts());if(a=="top"||a=="after"){g.reverse()}g.each(f.curry(c));d.evalScripts.bind(d).defer()}return c},wrap:function(b,c,a){b=$(b);if(Object.isElement(c)){$(c).writeAttribute(a||{})}else{if(Object.isString(c)){c=new Element(c,a)}else{c=new Element("div",c)}}if(b.parentNode){b.parentNode.replaceChild(c,b)}c.appendChild(b);return c},inspect:function(b){b=$(b);var a="<"+b.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(f){var e=f.first(),c=f.last();var d=(b[e]||"").toString();if(d){a+=" "+c+"="+d.inspect(true)}});return a+">"},recursivelyCollect:function(a,c){a=$(a);var b=[];while(a=a[c]){if(a.nodeType==1){b.push(Element.extend(a))}}return b},ancestors:function(a){return $(a).recursivelyCollect("parentNode")},descendants:function(a){return $(a).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(b,a){if(Object.isString(a)){a=new Selector(a)}return a.match($(b))},up:function(b,d,a){b=$(b);if(arguments.length==1){return $(b.parentNode)}var c=b.ancestors();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},down:function(b,c,a){b=$(b);if(arguments.length==1){return b.firstDescendant()}return Object.isNumber(c)?b.descendants()[c]:Element.select(b,c)[a||0]},previous:function(b,d,a){b=$(b);if(arguments.length==1){return $(Selector.handlers.previousElementSibling(b))}var c=b.previousSiblings();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},next:function(c,d,b){c=$(c);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(c))}var a=c.nextSiblings();return Object.isNumber(d)?a[d]:Selector.findElement(a,d,b)},select:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b,a)},adjacent:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b.parentNode,a).without(b)},identify:function(b){b=$(b);var c=b.readAttribute("id"),a=arguments.callee;if(c){return c}do{c="anonymous_element_"+a.counter++}while($(c));b.writeAttribute("id",c);return c},readAttribute:function(c,a){c=$(c);if(Prototype.Browser.IE){var b=Element._attributeTranslations.read;if(b.values[a]){return b.values[a](c,a)}if(b.names[a]){a=b.names[a]}if(a.include(":")){return(!c.attributes||!c.attributes[a])?null:c.attributes[a].value}}return c.getAttribute(a)},writeAttribute:function(e,c,f){e=$(e);var b={},d=Element._attributeTranslations.write;if(typeof c=="object"){b=c}else{b[c]=Object.isUndefined(f)?true:f}for(var a in b){c=d.names[a]||a;f=b[a];if(d.values[a]){c=d.values[a](e,f)}if(f===false||f===null){e.removeAttribute(c)}else{if(f===true){e.setAttribute(c,c)}else{e.setAttribute(c,f)}}}return e},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(a,b){if(!(a=$(a))){return}var c=a.className;return(c.length>0&&(c==b||new RegExp("(^|\\s)"+b+"(\\s|$)").test(c)))},addClassName:function(a,b){if(!(a=$(a))){return}if(!a.hasClassName(b)){a.className+=(a.className?" ":"")+b}return a},removeClassName:function(a,b){if(!(a=$(a))){return}a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)")," ").strip();return a},toggleClassName:function(a,b){if(!(a=$(a))){return}return a[a.hasClassName(b)?"removeClassName":"addClassName"](b)},cleanWhitespace:function(b){b=$(b);var c=b.firstChild;while(c){var a=c.nextSibling;if(c.nodeType==3&&!/\S/.test(c.nodeValue)){b.removeChild(c)}c=a}return b},empty:function(a){return $(a).innerHTML.blank()},descendantOf:function(b,a){b=$(b),a=$(a);if(b.compareDocumentPosition){return(b.compareDocumentPosition(a)&8)===8}if(a.contains){return a.contains(b)&&a!==b}while(b=b.parentNode){if(b==a){return true}}return false},scrollTo:function(a){a=$(a);var b=a.cumulativeOffset();window.scrollTo(b[0],b[1]);return a},getStyle:function(b,c){b=$(b);c=c=="float"?"cssFloat":c.camelize();var d=b.style[c];if(!d||d=="auto"){var a=document.defaultView.getComputedStyle(b,null);d=a?a[c]:null}if(c=="opacity"){return d?parseFloat(d):1}return d=="auto"?null:d},getOpacity:function(a){return $(a).getStyle("opacity")},setStyle:function(b,c){b=$(b);var e=b.style,a;if(Object.isString(c)){b.style.cssText+=";"+c;return c.include("opacity")?b.setOpacity(c.match(/opacity:\s*(\d?\.?\d*)/)[1]):b}for(var d in c){if(d=="opacity"){b.setOpacity(c[d])}else{e[(d=="float"||d=="cssFloat")?(Object.isUndefined(e.styleFloat)?"cssFloat":"styleFloat"):d]=c[d]}}return b},setOpacity:function(a,b){a=$(a);a.style.opacity=(b==1||b==="")?"":(b<0.00001)?0:b;return a},getDimensions:function(c){c=$(c);var g=c.getStyle("display");if(g!="none"&&g!=null){return{width:c.offsetWidth,height:c.offsetHeight}}var b=c.style;var f=b.visibility;var d=b.position;var a=b.display;b.visibility="hidden";b.position="absolute";b.display="block";var h=c.clientWidth;var e=c.clientHeight;b.display=a;b.position=d;b.visibility=f;return{width:h,height:e}},makePositioned:function(a){a=$(a);var b=Element.getStyle(a,"position");if(b=="static"||!b){a._madePositioned=true;a.style.position="relative";if(Prototype.Browser.Opera){a.style.top=0;a.style.left=0}}return a},undoPositioned:function(a){a=$(a);if(a._madePositioned){a._madePositioned=undefined;a.style.position=a.style.top=a.style.left=a.style.bottom=a.style.right=""}return a},makeClipping:function(a){a=$(a);if(a._overflow){return a}a._overflow=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(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;b=b.offsetParent}while(b);return Element._returnOffset(c,a)},positionedOffset:function(b){var a=0,d=0;do{a+=b.offsetTop||0;d+=b.offsetLeft||0;b=b.offsetParent;if(b){if(b.tagName.toUpperCase()=="BODY"){break}var c=Element.getStyle(b,"position");if(c!=="static"){break}}}while(b);return Element._returnOffset(d,a)},absolutize:function(b){b=$(b);if(b.getStyle("position")=="absolute"){return b}var d=b.positionedOffset();var f=d[1];var e=d[0];var c=b.clientWidth;var a=b.clientHeight;b._originalLeft=e-parseFloat(b.style.left||0);b._originalTop=f-parseFloat(b.style.top||0);b._originalWidth=b.style.width;b._originalHeight=b.style.height;b.style.position="absolute";b.style.top=f+"px";b.style.left=e+"px";b.style.width=c+"px";b.style.height=a+"px";return b},relativize:function(a){a=$(a);if(a.getStyle("position")=="relative"){return a}a.style.position="relative";var c=parseFloat(a.style.top||0)-(a._originalTop||0);var b=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=c+"px";a.style.left=b+"px";a.style.height=a._originalHeight;a.style.width=a._originalWidth;return a},cumulativeScrollOffset:function(b){var a=0,c=0;do{a+=b.scrollTop||0;c+=b.scrollLeft||0;b=b.parentNode}while(b);return Element._returnOffset(c,a)},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(d){var a=0,c=0;var b=d;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;if(b.offsetParent==document.body&&Element.getStyle(b,"position")=="absolute"){break}}while(b=b.offsetParent);b=d;do{if(!Prototype.Browser.Opera||(b.tagName&&(b.tagName.toUpperCase()=="BODY"))){a-=b.scrollTop||0;c-=b.scrollLeft||0}}while(b=b.parentNode);return Element._returnOffset(c,a)},clonePosition:function(b,d){var a=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});d=$(d);var e=d.viewportOffset();b=$(b);var f=[0,0];var c=null;if(Element.getStyle(b,"position")=="absolute"){c=b.getOffsetParent();f=c.viewportOffset()}if(c==document.body){f[0]-=document.body.offsetLeft;f[1]-=document.body.offsetTop}if(a.setLeft){b.style.left=(e[0]-f[0]+a.offsetLeft)+"px"}if(a.setTop){b.style.top=(e[1]-f[1]+a.offsetTop)+"px"}if(a.setWidth){b.style.width=d.offsetWidth+"px"}if(a.setHeight){b.style.height=d.offsetHeight+"px"}return b}};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(d,b,c){switch(c){case"left":case"top":case"right":case"bottom":if(d(b,"position")==="static"){return null}case"height":case"width":if(!Element.visible(b)){return null}var e=parseInt(d(b,c),10);if(e!==b["offset"+c.capitalize()]){return e+"px"}var a;if(c==="height"){a=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{a=["border-left-width","padding-left","padding-right","border-right-width"]}return a.inject(e,function(f,g){var h=d(b,g);return h===null?f:f-parseInt(h,10)})+"px";default:return d(b,c)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(c,a,b){if(b==="title"){return a.title}return c(a,b)})}else{if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(c,b){b=$(b);try{b.offsetParent}catch(f){return $(document.body)}var a=b.getStyle("position");if(a!=="static"){return c(b)}b.setStyle({position:"relative"});var d=c(b);b.setStyle({position:a});return d});$w("positionedOffset viewportOffset").each(function(a){Element.Methods[a]=Element.Methods[a].wrap(function(f,c){c=$(c);try{c.offsetParent}catch(h){return Element._returnOffset(0,0)}var b=c.getStyle("position");if(b!=="static"){return f(c)}var d=c.getOffsetParent();if(d&&d.getStyle("position")==="fixed"){d.setStyle({zoom:1})}c.setStyle({position:"relative"});var g=f(c);c.setStyle({position:b});return g})});Element.Methods.cumulativeOffset=Element.Methods.cumulativeOffset.wrap(function(b,a){try{a.offsetParent}catch(c){return Element._returnOffset(0,0)}return b(a)});Element.Methods.getStyle=function(a,b){a=$(a);b=(b=="float"||b=="cssFloat")?"styleFloat":b.camelize();var c=a.style[b];if(!c&&a.currentStyle){c=a.currentStyle[b]}if(b=="opacity"){if(c=(a.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(c[1]){return parseFloat(c[1])/100}}return 1}if(c=="auto"){if((b=="width"||b=="height")&&(a.getStyle("display")!="none")){return a["offset"+b.capitalize()]+"px"}return null}return c};Element.Methods.setOpacity=function(b,e){function f(g){return g.replace(/alpha\([^\)]*\)/gi,"")}b=$(b);var a=b.currentStyle;if((a&&!a.hasLayout)||(!a&&b.style.zoom=="normal")){b.style.zoom=1}var d=b.getStyle("filter"),c=b.style;if(e==1||e===""){(d=f(d))?c.filter=d:c.removeAttribute("filter");return b}else{if(e<0.00001){e=0}}c.filter=f(d)+"alpha(opacity="+(e*100)+")";return b};Element._attributeTranslations={read:{names:{"class":"className","for":"htmlFor"},values:{_getAttr:function(a,b){return a.getAttribute(b,2)},_getAttrNode:function(a,c){var b=a.getAttributeNode(c);return b?b.value:""},_getEv:function(a,b){b=a.getAttribute(b);return b?b.toString().slice(23,-2):null},_flag:function(a,b){return $(a).hasAttribute(b)?b: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(a,b){a.checked=!!b},style:function(a,b){a.style.cssText=b?b:""}}};Element._attributeTranslations.has={};$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc frameBorder").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(a,b){a=$(a);a.style.opacity=(b==1)?0.999999:(b==="")?"":(b<0.00001)?0:b;return a}}else{if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1||b==="")?"":(b<0.00001)?0:b;if(b==1){if(a.tagName.toUpperCase()=="IMG"&&a.width){a.width++;a.width--}else{try{var d=document.createTextNode(" ");a.appendChild(d);a.removeChild(d)}catch(c){}}}return a};Element.Methods.cumulativeOffset=function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;if(b.offsetParent==document.body){if(Element.getStyle(b,"position")=="absolute"){break}}b=b.offsetParent}while(b);return Element._returnOffset(c,a)}}}}}if(Prototype.Browser.IE||Prototype.Browser.Opera){Element.Methods.update=function(b,c){b=$(b);if(c&&c.toElement){c=c.toElement()}if(Object.isElement(c)){return b.update().insert(c)}c=Object.toHTML(c);var a=b.tagName.toUpperCase();if(a in Element._insertionTranslations.tags){$A(b.childNodes).each(function(d){b.removeChild(d)});Element._getContentFromAnonymousElement(a,c.stripScripts()).each(function(d){b.appendChild(d)})}else{b.innerHTML=c.stripScripts()}c.evalScripts.bind(c).defer();return b}}if("outerHTML" in document.createElement("div")){Element.Methods.replace=function(c,e){c=$(c);if(e&&e.toElement){e=e.toElement()}if(Object.isElement(e)){c.parentNode.replaceChild(e,c);return c}e=Object.toHTML(e);var d=c.parentNode,b=d.tagName.toUpperCase();if(Element._insertionTranslations.tags[b]){var f=c.next();var a=Element._getContentFromAnonymousElement(b,e.stripScripts());d.removeChild(c);if(f){a.each(function(g){d.insertBefore(g,f)})}else{a.each(function(g){d.appendChild(g)})}}else{c.outerHTML=e.stripScripts()}e.evalScripts.bind(e).defer();return c}}Element._returnOffset=function(b,c){var a=[b,c];a.left=b;a.top=c;return a};Element._getContentFromAnonymousElement=function(c,b){var d=new Element("div"),a=Element._insertionTranslations.tags[c];if(a){d.innerHTML=a[0]+b+a[1];a[2].times(function(){d=d.firstChild})}else{d.innerHTML=b}return $A(d.childNodes)};Element._insertionTranslations={before:function(a,b){a.parentNode.insertBefore(b,a)},top:function(a,b){a.insertBefore(b,a.firstChild)},bottom:function(a,b){a.appendChild(b)},after:function(a,b){a.parentNode.insertBefore(b,a.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(a,c){c=Element._attributeTranslations.has[c]||c;var b=$(a).getAttributeNode(c);return !!(b&&b.specified)}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div")["__proto__"]){window.HTMLElement={};window.HTMLElement.prototype=document.createElement("div")["__proto__"];Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions){return Prototype.K}var a={},b=Element.Methods.ByTag;var c=Object.extend(function(f){if(!f||f._extendedByPrototype||f.nodeType!=1||f==window){return f}var d=Object.clone(a),e=f.tagName.toUpperCase(),h,g;if(b[e]){Object.extend(d,b[e])}for(h in d){g=d[h];if(Object.isFunction(g)&&!(h in f)){f[h]=g.methodize()}}f._extendedByPrototype=Prototype.emptyFunction;return f},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(a,Element.Methods);Object.extend(a,Element.Methods.Simulated)}}});c.refresh();return c})();Element.hasAttribute=function(a,b){if(a.hasAttribute){return a.hasAttribute(b)}return Element.Methods.Simulated.hasAttribute(a,b)};Element.addMethods=function(c){var h=Prototype.BrowserFeatures,d=Element.Methods.ByTag;if(!c){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{FORM:Object.clone(Form.Methods),INPUT:Object.clone(Form.Element.Methods),SELECT:Object.clone(Form.Element.Methods),TEXTAREA:Object.clone(Form.Element.Methods)})}if(arguments.length==2){var b=c;c=arguments[1]}if(!b){Object.extend(Element.Methods,c||{})}else{if(Object.isArray(b)){b.each(g)}else{g(b)}}function g(k){k=k.toUpperCase();if(!Element.Methods.ByTag[k]){Element.Methods.ByTag[k]={}}Object.extend(Element.Methods.ByTag[k],c)}function a(m,l,k){k=k||false;for(var o in m){var n=m[o];if(!Object.isFunction(n)){continue}if(!k||!(o in l)){l[o]=n.methodize()}}}function e(m){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[m]){k="HTML"+l[m]+"Element"}if(window[k]){return window[k]}k="HTML"+m+"Element";if(window[k]){return window[k]}k="HTML"+m.capitalize()+"Element";if(window[k]){return window[k]}window[k]={};window[k].prototype=document.createElement(m)["__proto__"];return window[k]}if(h.ElementExtensions){a(Element.Methods,HTMLElement.prototype);a(Element.Methods.Simulated,HTMLElement.prototype,true)}if(h.SpecificElementExtensions){for(var j in Element.Methods.ByTag){var f=e(j);if(Object.isUndefined(f)){continue}a(d[j],f.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh()}Element.cache={}};document.viewport={getDimensions:function(){var a={},b=Prototype.Browser;$w("width height").each(function(e){var c=e.capitalize();if(b.WebKit&&!document.evaluate){a[e]=self["inner"+c]}else{if(b.Opera&&parseFloat(window.opera.version())<9.5){a[e]=document.body["client"+c]}else{a[e]=document.documentElement["client"+c]}}});return a},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();if(this.shouldUseSelectorsAPI()){this.mode="selectorsAPI"}else{if(this.shouldUseXPath()){this.mode="xpath";this.compileXPathMatcher()}else{this.mode="normal";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(a)){return false}return true},shouldUseSelectorsAPI:function(){if(!Prototype.BrowserFeatures.SelectorsAPI){return false}if(!Selector._div){Selector._div=new Element("div")}try{Selector._div.querySelector(this.expression)}catch(a){return false}return true},compileMatcher:function(){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 f=this.expression,g=Selector.patterns,b=Selector.xpath,d,a;if(Selector._cache[f]){this.xpath=Selector._cache[f];return}this.matcher=[".//*"];while(f&&d!=f&&(/\S/).test(f)){d=f;for(var c in g){if(a=f.match(g[c])){this.matcher.push(Object.isFunction(b[c])?b[c](a):new Template(b[c]).evaluate(a));f=f.replace(a[0],"");break}}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath},findElements:function(a){a=a||document;var c=this.expression,b;switch(this.mode){case"selectorsAPI":if(a!==document){var d=a.id,f=$(a).identify();c="#"+f+" "+c}b=$A(a.querySelectorAll(c)).map(Element.extend);a.id=d;return b;case"xpath":return document._getElementsByXPath(this.xpath,a);default:return this.matcher(a)}},match:function(j){this.tokens=[];var o=this.expression,a=Selector.patterns,f=Selector.assertions;var b,d,g;while(o&&b!==o&&(/\S/).test(o)){b=o;for(var k in a){d=a[k];if(g=o.match(d)){if(f[k]){this.tokens.push([k,Object.clone(g)]);o=o.replace(g[0],"")}else{return this.findElements(document).include(j)}}}}var n=true,c,l;for(var k=0,h;h=this.tokens[k];k++){c=h[0],l=h[1];if(!Selector.assertions[c](j,l)){n=false;break}}return n},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(a){var b=Selector.xpath.pseudos[a[1]];if(!b){return""}if(Object.isFunction(b)){return b(a)}return new Template(Selector.xpath.pseudos[a[1]]).evaluate(a)},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]",empty:"[count(*) = 0 and (count(text()) = 0)]",checked:"[@checked]",disabled:"[(@disabled) and (@type!='hidden')]",enabled:"[not(@disabled) and (@type!='hidden')]",not:function(b){var j=b[6],h=Selector.patterns,a=Selector.xpath,f,c;var g=[];while(j&&f!=j&&(/\S/).test(j)){f=j;for(var d in h){if(b=j.match(h[d])){c=Object.isFunction(a[d])?a[d](b):new Template(a[d]).evaluate(b);g.push("("+c.substring(1,c.length-1)+")");j=j.replace(b[0],"");break}}}return"[not("+g.join(" and ")+")]"},"nth-child":function(a){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",a)},"nth-last-child":function(a){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",a)},"nth-of-type":function(a){return Selector.xpath.pseudos.nth("position() ",a)},"nth-last-of-type":function(a){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",a)},"first-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-of-type"](a)},"last-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](a)},"only-of-type":function(a){var b=Selector.xpath.pseudos;return b["first-of-type"](a)+b["last-of-type"](a)},nth:function(g,e){var h,j=e[6],d;if(j=="even"){j="2n+0"}if(j=="odd"){j="2n+1"}if(h=j.match(/^(\d+)$/)){return"["+g+"= "+h[1]+"]"}if(h=j.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(h[1]=="-"){h[1]=-1}var f=h[1]?Number(h[1]):1;var c=h[2]?Number(h[2]):0;d="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(d).evaluate({fragment:g,a:f,b:c})}}}},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]+:)?[\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(a,b){return b[1].toUpperCase()==a.tagName.toUpperCase()},className:function(a,b){return Element.hasClassName(a,b[1])},id:function(a,b){return a.id===b[1]},attrPresence:function(a,b){return Element.hasAttribute(a,b[1])},attr:function(b,c){var a=Element.readAttribute(b,c[1]);return a&&Selector.operators[c[2]](a,c[5]||c[6])}},handlers:{concat:function(d,c){for(var e=0,f;f=c[e];e++){d.push(f)}return d},mark:function(a){var d=Prototype.emptyFunction;for(var b=0,c;c=a[b];b++){c._countedByPrototype=d}return a},unmark:function(a){for(var b=0,c;c=a[b];b++){c._countedByPrototype=undefined}return a},index:function(a,d,g){a._countedByPrototype=Prototype.emptyFunction;if(d){for(var b=a.childNodes,e=b.length-1,c=1;e>=0;e--){var f=b[e];if(f.nodeType==1&&(!g||f._countedByPrototype)){f.nodeIndex=c++}}}else{for(var e=0,c=1,b=a.childNodes;f=b[e];e++){if(f.nodeType==1&&(!g||f._countedByPrototype)){f.nodeIndex=c++}}}},unique:function(b){if(b.length==0){return b}var d=[],e;for(var c=0,a=b.length;c<a;c++){if(!(e=b[c])._countedByPrototype){e._countedByPrototype=Prototype.emptyFunction;d.push(Element.extend(e))}}return Selector.handlers.unmark(d)},descendant:function(a){var d=Selector.handlers;for(var c=0,b=[],e;e=a[c];c++){d.concat(b,e.getElementsByTagName("*"))}return b},child:function(a){var e=Selector.handlers;for(var d=0,c=[],f;f=a[d];d++){for(var b=0,g;g=f.childNodes[b];b++){if(g.nodeType==1&&g.tagName!="!"){c.push(g)}}}return c},adjacent:function(a){for(var c=0,b=[],e;e=a[c];c++){var d=this.nextElementSibling(e);if(d){b.push(d)}}return b},laterSibling:function(a){var d=Selector.handlers;for(var c=0,b=[],e;e=a[c];c++){d.concat(b,Element.nextSiblings(e))}return b},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(a,j,c,b){var k=c.toUpperCase();var e=[],g=Selector.handlers;if(a){if(b){if(b=="descendant"){for(var f=0,d;d=a[f];f++){g.concat(e,d.getElementsByTagName(c))}return e}else{a=this[b](a)}if(c=="*"){return a}}for(var f=0,d;d=a[f];f++){if(d.tagName.toUpperCase()===k){e.push(d)}}return e}else{return j.getElementsByTagName(c)}},id:function(b,a,j,f){var g=$(j),d=Selector.handlers;if(!g){return[]}if(!b&&a==document){return[g]}if(b){if(f){if(f=="child"){for(var c=0,e;e=b[c];c++){if(g.parentNode==e){return[g]}}}else{if(f=="descendant"){for(var c=0,e;e=b[c];c++){if(Element.descendantOf(g,e)){return[g]}}}else{if(f=="adjacent"){for(var c=0,e;e=b[c];c++){if(Selector.handlers.previousElementSibling(g)==e){return[g]}}}else{b=d[f](b)}}}}for(var c=0,e;e=b[c];c++){if(e==g){return[g]}}return[]}return(g&&Element.descendantOf(g,a))?[g]:[]},className:function(b,a,c,d){if(b&&d){b=this[d](b)}return Selector.handlers.byClassName(b,a,c)},byClassName:function(c,b,f){if(!c){c=Selector.handlers.descendant([b])}var h=" "+f+" ";for(var e=0,d=[],g,a;g=c[e];e++){a=g.className;if(a.length==0){continue}if(a==f||(" "+a+" ").include(h)){d.push(g)}}return d},attrPresence:function(c,b,a,g){if(!c){c=b.getElementsByTagName("*")}if(c&&g){c=this[g](c)}var e=[];for(var d=0,f;f=c[d];d++){if(Element.hasAttribute(f,a)){e.push(f)}}return e},attr:function(a,j,h,k,c,b){if(!a){a=j.getElementsByTagName("*")}if(a&&b){a=this[b](a)}var l=Selector.operators[c],f=[];for(var e=0,d;d=a[e];e++){var g=Element.readAttribute(d,h);if(g===null){continue}if(l(g,k)){f.push(d)}}return f},pseudo:function(b,c,e,a,d){if(b&&d){b=this[d](b)}if(!b){b=a.getElementsByTagName("*")}return Selector.pseudos[c](b,e,a)}},pseudos:{"first-child":function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(Selector.handlers.previousElementSibling(e)){continue}c.push(e)}return c},"last-child":function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(Selector.handlers.nextElementSibling(e)){continue}c.push(e)}return c},"only-child":function(b,g,a){var e=Selector.handlers;for(var d=0,c=[],f;f=b[d];d++){if(!e.previousElementSibling(f)&&!e.nextElementSibling(f)){c.push(f)}}return c},"nth-child":function(b,c,a){return Selector.pseudos.nth(b,c,a)},"nth-last-child":function(b,c,a){return Selector.pseudos.nth(b,c,a,true)},"nth-of-type":function(b,c,a){return Selector.pseudos.nth(b,c,a,false,true)},"nth-last-of-type":function(b,c,a){return Selector.pseudos.nth(b,c,a,true,true)},"first-of-type":function(b,c,a){return Selector.pseudos.nth(b,"1",a,false,true)},"last-of-type":function(b,c,a){return Selector.pseudos.nth(b,"1",a,true,true)},"only-of-type":function(b,d,a){var c=Selector.pseudos;return c["last-of-type"](c["first-of-type"](b,d,a),d,a)},getIndices:function(d,c,e){if(d==0){return c>0?[c]:[]}return $R(1,e).inject([],function(a,b){if(0==(b-c)%d&&(b-c)/d>=0){a.push(b)}return a})},nth:function(c,t,v,r,e){if(c.length==0){return[]}if(t=="even"){t="2n+0"}if(t=="odd"){t="2n+1"}var q=Selector.handlers,p=[],d=[],g;q.mark(c);for(var o=0,f;f=c[o];o++){if(!f.parentNode._countedByPrototype){q.index(f.parentNode,r,e);d.push(f.parentNode)}}if(t.match(/^\d+$/)){t=Number(t);for(var o=0,f;f=c[o];o++){if(f.nodeIndex==t){p.push(f)}}}else{if(g=t.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(g[1]=="-"){g[1]=-1}var w=g[1]?Number(g[1]):1;var u=g[2]?Number(g[2]):0;var x=Selector.pseudos.getIndices(w,u,c.length);for(var o=0,f,k=x.length;f=c[o];o++){for(var n=0;n<k;n++){if(f.nodeIndex==x[n]){p.push(f)}}}}}q.unmark(c);q.unmark(d);return p},empty:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.tagName=="!"||e.firstChild){continue}c.push(e)}return c},not:function(a,d,k){var g=Selector.handlers,l,c;var j=new Selector(d).findElements(k);g.mark(j);for(var f=0,e=[],b;b=a[f];f++){if(!b._countedByPrototype){e.push(b)}}g.unmark(j);return e},enabled:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(!e.disabled&&(!e.type||e.type!=="hidden")){c.push(e)}}return c},disabled:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.disabled){c.push(e)}}return c},checked:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.checked){c.push(e)}}return c}},operators:{"=":function(b,a){return b==a},"!=":function(b,a){return b!=a},"^=":function(b,a){return b==a||b&&b.startsWith(a)},"$=":function(b,a){return b==a||b&&b.endsWith(a)},"*=":function(b,a){return b==a||b&&b.include(a)},"$=":function(b,a){return b.endsWith(a)},"*=":function(b,a){return b.include(a)},"~=":function(b,a){return(" "+b+" ").include(" "+a+" ")},"|=":function(b,a){return("-"+(b||"").toUpperCase()+"-").include("-"+(a||"").toUpperCase()+"-")}},split:function(b){var a=[];b.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(c){a.push(c[1].strip())});return a},matchElements:function(f,g){var e=$$(g),d=Selector.handlers;d.mark(e);for(var c=0,b=[],a;a=f[c];c++){if(a._countedByPrototype){b.push(a)}}d.unmark(e);return b},findElement:function(b,c,a){if(Object.isNumber(c)){a=c;c=false}return Selector.matchElements(b,c||"*")[a||0]},findChildElements:function(e,g){g=Selector.split(g.join(","));var d=[],f=Selector.handlers;for(var c=0,b=g.length,a;c<b;c++){a=new Selector(g[c].strip());f.concat(d,a.findElements(e))}return(b>1)?f.unique(d):d}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(d,c){for(var e=0,f;f=c[e];e++){if(f.tagName!=="!"){d.push(f)}}return d},unmark:function(a){for(var b=0,c;c=a[b];b++){c.removeAttribute("_countedByPrototype")}return a}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(g,b){if(typeof b!="object"){b={hash:!!b}}else{if(Object.isUndefined(b.hash)){b.hash=true}}var c,f,a=false,e=b.submit;var d=g.inject({},function(h,j){if(!j.disabled&&j.name){c=j.name;f=$(j).getValue();if(f!=null&&j.type!="file"&&(j.type!="submit"||(!a&&e!==false&&(!e||c==e)&&(a=true)))){if(c in h){if(!Object.isArray(h[c])){h[c]=[h[c]]}h[c].push(f)}else{h[c]=f}}}return h});return b.hash?d:Object.toQueryString(d)}};Form.Methods={serialize:function(b,a){return Form.serializeElements(Form.getElements(b),a)},getElements:function(a){return $A($(a).getElementsByTagName("*")).inject([],function(b,c){if(Form.Element.Serializers[c.tagName.toLowerCase()]){b.push(Element.extend(c))}return b})},getInputs:function(g,c,d){g=$(g);var a=g.getElementsByTagName("input");if(!c&&!d){return $A(a).map(Element.extend)}for(var e=0,h=[],f=a.length;e<f;e++){var b=a[e];if((c&&b.type!=c)||(d&&b.name!=d)){continue}h.push(Element.extend(b))}return h},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(b){var c=$(b).getElements().findAll(function(d){return"hidden"!=d.type&&!d.disabled});var a=c.findAll(function(d){return d.hasAttribute("tabIndex")&&d.tabIndex>=0}).sortBy(function(d){return d.tabIndex}).first();return a?a:c.find(function(d){return["input","select","textarea"].include(d.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(b,a){b=$(b),a=Object.clone(a||{});var d=a.parameters,c=b.readAttribute("action")||"";if(c.blank()){c=window.location.href}a.parameters=b.serialize(true);if(d){if(Object.isString(d)){d=d.toQueryParams()}Object.extend(a.parameters,d)}if(b.hasAttribute("method")&&!a.method){a.method=b.method}return new Ajax.Request(c,a)}};Form.Element={focus:function(a){$(a).focus();return a},select:function(a){$(a).select();return a}};Form.Element.Methods={serialize:function(a){a=$(a);if(!a.disabled&&a.name){var b=a.getValue();if(b!=undefined){var c={};c[a.name]=b;return Object.toQueryString(c)}}return""},getValue:function(a){a=$(a);var b=a.tagName.toLowerCase();return Form.Element.Serializers[b](a)},setValue:function(a,b){a=$(a);var c=a.tagName.toLowerCase();Form.Element.Serializers[c](a,b);return a},clear:function(a){$(a).value="";return a},present:function(a){return $(a).value!=""},activate:function(a){a=$(a);try{a.focus();if(a.select&&(a.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(a.type))){a.select()}}catch(b){}return a},disable:function(a){a=$(a);a.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(a,b){switch(a.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(a,b);default:return Form.Element.Serializers.textarea(a,b)}},inputSelector:function(a,b){if(Object.isUndefined(b)){return a.checked?a.value:null}else{a.checked=!!b}},textarea:function(a,b){if(Object.isUndefined(b)){return a.value}else{a.value=b}},select:function(c,f){if(Object.isUndefined(f)){return this[c.type=="select-one"?"selectOne":"selectMany"](c)}else{var b,d,g=!Object.isArray(f);for(var a=0,e=c.length;a<e;a++){b=c.options[a];d=this.optionValue(b);if(g){if(d==f){b.selected=true;return}}else{b.selected=f.include(d)}}}},selectOne:function(b){var a=b.selectedIndex;return a>=0?this.optionValue(b.options[a]):null},selectMany:function(d){var a,e=d.length;if(!e){return null}for(var c=0,a=[];c<e;c++){var b=d.options[c];if(b.selected){a.push(this.optionValue(b))}}return a},optionValue:function(a){return Element.extend(a).hasAttribute("value")?a.value:a.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,a,b,c){$super(c,b);this.element=$(a);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(a,b){this.element=$(a);this.callback=b;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks()}else{this.registerCallback(this.element)}},onElementEvent:function(){var a=this.getValue();if(this.lastValue!=a){this.callback(this.element,a);this.lastValue=a}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,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(b){var a;switch(b.type){case"mouseover":a=b.fromElement;break;case"mouseout":a=b.toElement;break;default:return null}return Element.extend(a)}});Event.Methods=(function(){var a;if(Prototype.Browser.IE){var b={0:1,1:4,2:2};a=function(d,c){return d.button==b[c]}}else{if(Prototype.Browser.WebKit){a=function(d,c){switch(c){case 0:return d.which==1&&!d.metaKey;case 1:return d.which==1&&d.metaKey;default:return false}}}else{a=function(d,c){return d.which?(d.which===c+1):(d.button===c)}}}return{isLeftClick:function(c){return a(c,0)},isMiddleClick:function(c){return a(c,1)},isRightClick:function(c){return a(c,2)},element:function(e){e=Event.extend(e);var d=e.target,c=e.type,f=e.currentTarget;if(f&&f.tagName){if(c==="load"||c==="error"||(c==="click"&&f.tagName.toLowerCase()==="input"&&f.type==="radio")){d=f}}if(d.nodeType==Node.TEXT_NODE){d=d.parentNode}return Element.extend(d)},findElement:function(d,f){var c=Event.element(d);if(!f){return c}var e=[c].concat(c.ancestors());return Selector.findElement(e,f,0)},pointer:function(e){var d=document.documentElement,c=document.body||{scrollLeft:0,scrollTop:0};return{x:e.pageX||(e.clientX+(d.scrollLeft||c.scrollLeft)-(d.clientLeft||0)),y:e.pageY||(e.clientY+(d.scrollTop||c.scrollTop)-(d.clientTop||0))}},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(b,c){b[c]=Event.Methods[c].methodize();return b});if(Prototype.Browser.IE){Object.extend(a,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});return function(b){if(!b){return false}if(b._extendedByPrototype){return b}b._extendedByPrototype=Prototype.emptyFunction;var c=Event.pointer(b);Object.extend(b,{target:b.srcElement,relatedTarget:Event.relatedTarget(b),pageX:c.x,pageY:c.y});return Object.extend(b,a)}}else{Event.prototype=Event.prototype||document.createEvent("HTMLEvents")["__proto__"];Object.extend(Event.prototype,a);return Prototype.K}})();Object.extend(Event,(function(){var b=Event.cache;function c(k){if(k._prototypeEventID){return k._prototypeEventID[0]}arguments.callee.id=arguments.callee.id||1;return k._prototypeEventID=[++arguments.callee.id]}function g(k){if(k&&k.include(":")){return"dataavailable"}return k}function a(k){return b[k]=b[k]||{}}function f(m,k){var l=a(m);return l[k]=l[k]||[]}function h(l,k,m){var p=c(l);var o=f(p,k);if(o.pluck("handler").include(m)){return false}var n=function(q){if(!Event||!Event.extend||(q.eventName&&q.eventName!=k)){return false}Event.extend(q);m.call(l,q)};n.handler=m;o.push(n);return n}function j(n,k,l){var m=f(n,k);return m.find(function(o){return o.handler==l})}function d(n,k,l){var m=a(n);if(!m[k]){return false}m[k]=m[k].without(j(n,k,l))}function e(){for(var l in b){for(var k in b[l]){b[l][k]=null}}}if(window.attachEvent){window.attachEvent("onunload",e)}if(Prototype.Browser.WebKit){window.addEventListener("unload",Prototype.emptyFunction,false)}return{observe:function(m,k,n){m=$(m);var l=g(k);var o=h(m,k,n);if(!o){return m}if(m.addEventListener){m.addEventListener(l,o,false)}else{m.attachEvent("on"+l,o)}return m},stopObserving:function(m,k,n){m=$(m);var p=c(m),l=g(k);if(!n&&k){f(p,k).each(function(q){m.stopObserving(k,q.handler)});return m}else{if(!k){Object.keys(a(p)).each(function(q){m.stopObserving(q)});return m}}var o=j(p,k,n);if(!o){return m}if(m.removeEventListener){m.removeEventListener(l,o,false)}else{m.detachEvent("on"+l,o)}d(p,k,n);return m},fire:function(m,l,k){m=$(m);if(m==document&&document.createEvent&&!m.dispatchEvent){m=document.documentElement}var n;if(document.createEvent){n=document.createEvent("HTMLEvents");n.initEvent("dataavailable",true,true)}else{n=document.createEventObject();n.eventType="ondataavailable"}n.eventName=l;n.memo=k||{};if(document.createEvent){m.dispatchEvent(n)}else{m.fireEvent(n.eventType,n)}return Event.extend(n)}}})());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 b;function a(){if(document.loaded){return}if(b){window.clearInterval(b)}document.fire("dom:loaded");document.loaded=true}if(document.addEventListener){if(Prototype.Browser.WebKit){b=window.setInterval(function(){if(/loaded|complete/.test(document.readyState)){a()}},0);Event.observe(window,"load",a)}else{document.addEventListener("DOMContentLoaded",a,false)}}else{document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;a()}}}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(a,b){return Element.insert(a,{before:b})},Top:function(a,b){return Element.insert(a,{top:b})},Bottom:function(a,b){return Element.insert(a,{bottom:b})},After:function(a,b){return Element.insert(a,{after:b})}};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(b,a,c){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(b,a,c)}this.xcomp=a;this.ycomp=c;this.offset=Element.cumulativeOffset(b);return(c>=this.offset[1]&&c<this.offset[1]+b.offsetHeight&&a>=this.offset[0]&&a<this.offset[0]+b.offsetWidth)},withinIncludingScrolloffsets:function(b,a,d){var c=Element.cumulativeScrollOffset(b);this.xcomp=a+c[0]-this.deltaX;this.ycomp=d+c[1]-this.deltaY;this.offset=Element.cumulativeOffset(b);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+b.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+b.offsetWidth)},overlap:function(b,a){if(!b){return 0}if(b=="vertical"){return((this.offset[1]+a.offsetHeight)-this.ycomp)/a.offsetHeight}if(b=="horizontal"){return((this.offset[0]+a.offsetWidth)-this.xcomp)/a.offsetWidth}},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(b,c,a){a=a||{};return Element.clonePosition(c,b,a)}};if(!document.getElementsByClassName){document.getElementsByClassName=function(b){function a(c){return c.blank()?null:"[contains(concat(' ', @class, ' '), ' "+c+" ')]"}b.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(c,e){e=e.toString().strip();var d=/\s/.test(e)?$w(e).map(a).join(""):a(e);return d?document._getElementsByXPath(".//*"+d,c):[]}:function(e,f){f=f.toString().strip();var g=[],h=(/\s/.test(f)?$w(f):null);if(!h&&!f){return g}var c=$(e).getElementsByTagName("*");f=" "+f+" ";for(var d=0,k,j;k=c[d];d++){if(k.className&&(j=" "+k.className+" ")&&(j.include(f)||(h&&h.all(function(l){return !l.toString().blank()&&j.include(" "+l+" ")})))){g.push(Element.extend(k))}}return g};return function(d,c){return $(c||document.body).getElementsByClassName(d)}}(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();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(a){a=a.toUpperCase();var g=this.NODEMAP[a]||"div";var b=document.createElement(g);try{b.innerHTML="<"+a+"></"+a+">"}catch(f){}var d=b.firstChild||null;if(d&&(d.tagName.toUpperCase()!=a)){d=d.getElementsByTagName(a)[0]}if(!d){d=document.createElement(a)}if(!d){return}if(arguments[1]){if(this._isStringOrNumber(arguments[1])||(arguments[1] instanceof Array)||arguments[1].tagName){this._children(d,arguments[1])}else{var c=this._attributes(arguments[1]);if(c.length){try{b.innerHTML="<"+a+" "+c+"></"+a+">"}catch(f){}d=b.firstChild||null;if(!d){d=document.createElement(a);for(attr in arguments[1]){d[attr=="class"?"className":attr]=arguments[1][attr]}}if(d.tagName.toUpperCase()!=a){d=b.getElementsByTagName(a)[0]}}}}if(arguments[2]){this._children(d,arguments[2])}return d},_text:function(a){return document.createTextNode(a)},ATTR_MAP:{className:"class",htmlFor:"for"},_attributes:function(a){var b=[];for(attribute in a){b.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+'="'+a[attribute].toString().escapeHTML().gsub(/"/,"&quot;")+'"')}return b.join(" ")},_children:function(b,a){if(a.tagName){b.appendChild(a);return}if(typeof a=="object"){a.flatten().each(function(c){if(typeof c=="object"){b.appendChild(c)}else{if(Builder._isStringOrNumber(c)){b.appendChild(Builder._text(c))}}})}else{if(Builder._isStringOrNumber(a)){b.appendChild(Builder._text(a))}}},_isStringOrNumber:function(a){return(typeof a=="string"||typeof a=="number")},build:function(b){var a=this.node("div");$(a).update(b.strip());return a.down()},dump:function(b){if(typeof b!="object"&&typeof b!="function"){b=window}var a=("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+/);a.each(function(c){b[c]=function(){return Builder.node.apply(Builder,[c].concat($A(arguments)))}})}};String.prototype.parseColor=function(){var a="#";if(this.slice(0,4)=="rgb("){var c=this.slice(4,this.length-1).split(",");var b=0;do{a+=parseInt(c[b]).toColorPart()}while(++b<3)}else{if(this.slice(0,1)=="#"){if(this.length==4){for(var b=1;b<4;b++){a+=(this.charAt(b)+this.charAt(b)).toLowerCase()}}if(this.length==7){a=this.toLowerCase()}}}return(a.length==7?a:(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(a,b){return $A($(a).childNodes).collect(function(c){return(c.nodeType==3?c.nodeValue:((c.hasChildNodes()&&!Element.hasClassName(c,b))?Element.collectTextNodesIgnoreClass(c,b):""))}).flatten().join("")};Element.setContentZoom=function(a,b){a=$(a);a.setStyle({fontSize:(b/100)+"em"});if(Prototype.Browser.WebKit){window.scrollBy(0,0)}return a};Element.getInlineOpacity=function(a){return $(a).style.opacity||""};Element.forceRerendering=function(a){try{a=$(a);var c=document.createTextNode(" ");a.appendChild(c);a.removeChild(c)}catch(b){}};Array.prototype.call=function(){var a=arguments;this.each(function(b){b.apply(this,a)})};var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},tagifyText:function(a){if(typeof Builder=="undefined"){throw ("Effect.tagifyText requires including script.aculo.us' builder.js library")}var b="position:relative";if(Prototype.Browser.IE){b+=";zoom:1"}a=$(a);$A(a.childNodes).each(function(c){if(c.nodeType==3){c.nodeValue.toArray().each(function(d){a.insertBefore(Builder.node("span",{style:b},d==" "?String.fromCharCode(160):d),c)});Element.remove(c)}})},multiple:function(b,c){var e;if(((typeof b=="object")||(typeof b=="function"))&&(b.length)){e=b}else{e=$(b).childNodes}var a=Object.extend({speed:0.1,delay:0},arguments[2]||{});var d=a.delay;$A(e).each(function(g,f){new c(g,Object.extend(a,{delay:f*a.speed+d}))})},PAIRS:{slide:["SlideDown","SlideUp"],blind:["BlindDown","BlindUp"],appear:["Appear","Fade"]},toggle:function(b,c){b=$(b);c=(c||"appear").toLowerCase();var a=Object.extend({queue:{position:"end",scope:(b.id||"global"),limit:1}},arguments[2]||{});Effect[b.visible()?Effect.PAIRS[c][1]:Effect.PAIRS[c][0]](b,a)}};var Effect2=Effect;Effect.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(b,a){a=a||5;return(Math.round((b%(1/a))*a)==0?((b*a*2)-Math.floor(b*a*2)):1-((b*a*2)-Math.floor(b*a*2)))},none:function(a){return 0},full:function(a){return 1}};Effect.ScopedQueue=Class.create();Object.extend(Object.extend(Effect.ScopedQueue.prototype,Enumerable),{initialize:function(){this.effects=[];this.interval=null},_each:function(a){this.effects._each(a)},add:function(b){var c=new Date().getTime();var a=(typeof b.options.queue=="string")?b.options.queue:b.options.queue.position;switch(a){case"front":this.effects.findAll(function(d){return d.state=="idle"}).each(function(d){d.startOn+=b.finishOn;d.finishOn+=b.finishOn});break;case"with-last":c=this.effects.pluck("startOn").max()||c;break;case"end":c=this.effects.pluck("finishOn").max()||c;break}b.startOn+=c;b.finishOn+=c;if(!b.options.queue.limit||(this.effects.length<b.options.queue.limit)){this.effects.push(b)}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 c=new Date().getTime();for(var b=0,a=this.effects.length;b<a;b++){this.effects[b]&&this.effects[b].loop(c)}}});Effect.Queues={instances:$H(),get:function(a){if(typeof a!="string"){return a}if(!this.instances[a]){this.instances[a]=new Effect.ScopedQueue()}return this.instances[a]}};Effect.Queue=Effect.Queues.get("global");Effect.DefaultOptions={transition:Effect.Transitions.sinoidal,duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"};Effect.Base=function(){};Effect.Base.prototype={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.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(options,"beforeSetup")+(this.setup?"this.setup();":"")+codeForEvent(options,"afterSetup")+'};if(this.state=="running"){pos=this.options.transition(pos)*'+this.fromToDelta+"+"+this.options.from+";this.position=pos;"+codeForEvent(options,"beforeUpdate")+(this.update?"this.update(pos);":"")+codeForEvent(options,"afterUpdate")+"}}");this.event("beforeStart");if(!this.options.sync){Effect.Queues.get(typeof this.options.queue=="string"?"global":this.options.queue.scope).add(this)}},loop:function(c){if(c>=this.startOn){if(c>=this.finishOn){this.render(1);this.cancel();this.event("beforeFinish");if(this.finish){this.finish()}this.event("afterFinish");return}var b=(c-this.startOn)/this.totalTime,a=Math.round(b*this.totalFrames);if(a>this.currentFrame){this.render(b);this.currentFrame=a}}},cancel:function(){if(!this.options.sync){Effect.Queues.get(typeof this.options.queue=="string"?"global":this.options.queue.scope).remove(this)}this.state="finished"},event:function(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(typeof this[property]!="function"){a[property]=this[property]}}return"#<Effect:"+a.inspect()+",options:"+$H(this.options).inspect()+">"}};Effect.Parallel=Class.create();Object.extend(Object.extend(Effect.Parallel.prototype,Effect.Base.prototype),{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.Event=Class.create();Object.extend(Object.extend(Effect.Event.prototype,Effect.Base.prototype),{initialize:function(){var a=Object.extend({duration:0},arguments[0]||{});this.start(a)},update:Prototype.emptyFunction});Effect.Opacity=Class.create();Object.extend(Object.extend(Effect.Opacity.prototype,Effect.Base.prototype),{initialize:function(b){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}var a=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});this.start(a)},update:function(a){this.element.setOpacity(a)}});Effect.Move=Class.create();Object.extend(Object.extend(Effect.Move.prototype,Effect.Base.prototype),{initialize:function(b){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});this.start(a)},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:Math.round(this.options.x*a+this.originalLeft)+"px",top:Math.round(this.options.y*a+this.originalTop)+"px"})}});Effect.MoveBy=function(b,a,c){return new Effect.Move(b,Object.extend({x:c,y:a},arguments[3]||{}))};Effect.Scale=Class.create();Object.extend(Object.extend(Effect.Scale.prototype,Effect.Base.prototype),{initialize:function(b,c){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:c},arguments[2]||{});this.start(a)},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(a){var b=(this.options.scaleFrom/100)+(this.factor*a);if(this.options.scaleContent&&this.fontSize){this.element.setStyle({fontSize:this.fontSize*b+this.fontSizeType})}this.setDimensions(this.dims[0]*b,this.dims[1]*b)},finish:function(a){if(this.restoreAfterFinish){this.element.setStyle(this.originalStyle)}},setDimensions:function(a,e){var f={};if(this.options.scaleX){f.width=Math.round(e)+"px"}if(this.options.scaleY){f.height=Math.round(a)+"px"}if(this.options.scaleFromCenter){var c=(a-this.dims[0])/2;var b=(e-this.dims[1])/2;if(this.elementPositioning=="absolute"){if(this.options.scaleY){f.top=this.originalTop-c+"px"}if(this.options.scaleX){f.left=this.originalLeft-b+"px"}}else{if(this.options.scaleY){f.top=-c+"px"}if(this.options.scaleX){f.left=-b+"px"}}}this.element.setStyle(f)}});Effect.Highlight=Class.create();Object.extend(Object.extend(Effect.Highlight.prototype,Effect.Base.prototype),{initialize:function(b){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({startcolor:"#ffff99"},arguments[1]||{});this.start(a)},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(b,c,d){return b+(Math.round(this._base[d]+(this._delta[d]*a)).toColorPart())}.bind(this))})},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}))}});Effect.ScrollTo=Class.create();Object.extend(Object.extend(Effect.ScrollTo.prototype,Effect.Base.prototype),{initialize:function(a){this.element=$(a);this.start(arguments[1]||{})},setup:function(){Position.prepare();var b=Position.cumulativeOffset(this.element);if(this.options.offset){b[1]+=this.options.offset}var a=window.innerHeight?window.height-window.innerHeight:document.body.scrollHeight-(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight);this.scrollStart=Position.deltaY;this.delta=(b[1]>a?a:b[1])-this.scrollStart},update:function(a){Position.prepare();window.scrollTo(Position.deltaX,this.scrollStart+(a*this.delta))}});Effect.Fade=function(c){c=$(c);var a=c.getInlineOpacity();var b=Object.extend({from:c.getOpacity()||1,to:0,afterFinishInternal:function(d){if(d.options.to!=0){return}d.element.hide().setStyle({opacity:a})}},arguments[1]||{});return new Effect.Opacity(c,b)};Effect.Appear=function(b){b=$(b);var a=Object.extend({from:(b.getStyle("display")=="none"?0:b.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(b,a)};Effect.Puff=function(b){b=$(b);var a={opacity:b.getInlineOpacity(),position:b.getStyle("position"),top:b.style.top,left:b.style.left,width:b.style.width,height:b.style.height};return new Effect.Parallel([new Effect.Scale(b,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(b,{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(a)}},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(b){b=$(b);var a=b.getDimensions();return new Effect.Scale(b,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:a.height,originalWidth:a.width},restoreAfterFinish:true,afterSetup:function(c){c.element.makeClipping().setStyle({height:"0px"}).show()},afterFinishInternal:function(c){c.element.undoClipping()}},arguments[1]||{}))};Effect.SwitchOff=function(b){b=$(b);var a=b.getInlineOpacity();return new Effect.Appear(b,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:a})}})}},arguments[1]||{}))};Effect.DropOut=function(b){b=$(b);var a={top:b.getStyle("top"),left:b.getStyle("left"),opacity:b.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(b,{x:0,y:100,sync:true}),new Effect.Opacity(b,{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(a)}},arguments[1]||{}))};Effect.Shake=function(b){b=$(b);var a={top:b.getStyle("top"),left:b.getStyle("left")};return new Effect.Move(b,{x:20,y:0,duration:0.05,afterFinishInternal:function(c){new Effect.Move(c.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(d){new Effect.Move(d.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(e){new Effect.Move(e.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(f){new Effect.Move(f.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(g){new Effect.Move(g.element,{x:-20,y:0,duration:0.05,afterFinishInternal:function(h){h.element.undoPositioned().setStyle(a)}})}})}})}})}})}})};Effect.SlideDown=function(c){c=$(c).cleanWhitespace();var a=c.down().getStyle("bottom");var b=c.getDimensions();return new Effect.Scale(c,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:b.height,originalWidth:b.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:a})}},arguments[1]||{}))};Effect.SlideUp=function(b){b=$(b).cleanWhitespace();var a=b.down().getStyle("bottom");return new Effect.Scale(b,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,beforeStartInternal:function(c){c.element.makePositioned();c.element.down().makePositioned();if(window.opera){c.element.setStyle({top:""})}c.element.makeClipping().show()},afterUpdateInternal:function(c){c.element.down().setStyle({bottom:(c.dims[0]-c.element.clientHeight)+"px"})},afterFinishInternal:function(c){c.element.hide().undoClipping().undoPositioned().setStyle({bottom:a});c.element.down().undoPositioned()}},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(c){c=$(c);var b=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});var a={top:c.style.top,left:c.style.left,height:c.style.height,width:c.style.width,opacity:c.getInlineOpacity()};var g=c.getDimensions();var h,f;var e,d;switch(b.direction){case"top-left":h=f=e=d=0;break;case"top-right":h=g.width;f=d=0;e=-g.width;break;case"bottom-left":h=e=0;f=g.height;d=-g.height;break;case"bottom-right":h=g.width;f=g.height;e=-g.width;d=-g.height;break;case"center":h=g.width/2;f=g.height/2;e=-g.width/2;d=-g.height/2;break}return new Effect.Move(c,{x:h,y:f,duration:0.01,beforeSetup:function(j){j.element.hide().makeClipping().makePositioned()},afterFinishInternal:function(j){new Effect.Parallel([new Effect.Opacity(j.element,{sync:true,to:1,from:0,transition:b.opacityTransition}),new Effect.Move(j.element,{x:e,y:d,sync:true,transition:b.moveTransition}),new Effect.Scale(j.element,100,{scaleMode:{originalHeight:g.height,originalWidth:g.width},sync:true,scaleFrom:window.opera?1:0,transition:b.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(k){k.effects[0].element.setStyle({height:"0px"}).show()},afterFinishInternal:function(k){k.effects[0].element.undoClipping().undoPositioned().setStyle(a)}},b))}})};Effect.Shrink=function(c){c=$(c);var b=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});var a={top:c.style.top,left:c.style.left,height:c.style.height,width:c.style.width,opacity:c.getInlineOpacity()};var f=c.getDimensions();var e,d;switch(b.direction){case"top-left":e=d=0;break;case"top-right":e=f.width;d=0;break;case"bottom-left":e=0;d=f.height;break;case"bottom-right":e=f.width;d=f.height;break;case"center":e=f.width/2;d=f.height/2;break}return new Effect.Parallel([new Effect.Opacity(c,{sync:true,to:0,from:1,transition:b.opacityTransition}),new Effect.Scale(c,window.opera?1:0,{sync:true,transition:b.scaleTransition,restoreAfterFinish:true}),new Effect.Move(c,{x:e,y:d,sync:true,transition:b.moveTransition})],Object.extend({beforeStartInternal:function(g){g.effects[0].element.makePositioned().makeClipping()},afterFinishInternal:function(g){g.effects[0].element.hide().undoClipping().undoPositioned().setStyle(a)}},b))};Effect.Pulsate=function(c){c=$(c);var b=arguments[1]||{};var a=c.getInlineOpacity();var e=b.transition||Effect.Transitions.sinoidal;var d=function(f){return e(1-Effect.Transitions.pulse(f,b.pulses))};d.bind(e);return new Effect.Opacity(c,Object.extend(Object.extend({duration:2,from:0,afterFinishInternal:function(f){f.element.setStyle({opacity:a})}},b),{transition:d}))};Effect.Fold=function(b){b=$(b);var a={top:b.style.top,left:b.style.left,width:b.style.width,height:b.style.height};b.makeClipping();return new Effect.Scale(b,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(c){new Effect.Scale(b,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(d){d.element.hide().undoClipping().setStyle(a)}})}},arguments[1]||{}))};Effect.Morph=Class.create();Object.extend(Object.extend(Effect.Morph.prototype,Effect.Base.prototype),{initialize:function(c){this.element=$(c);if(!this.element){throw (Effect._elementDoesNotExistError)}var b=Object.extend({style:{}},arguments[1]||{});if(typeof b.style=="string"){if(b.style.indexOf(":")==-1){var d="",a="."+b.style;$A(document.styleSheets).reverse().each(function(e){if(e.cssRules){cssRules=e.cssRules}else{if(e.rules){cssRules=e.rules}}$A(cssRules).reverse().each(function(f){if(a==f.selectorText){d=f.style.cssText;throw $break}});if(d){throw $break}});this.style=d.parseStyle();b.afterFinishInternal=function(e){e.element.addClassName(e.options.style);e.transforms.each(function(f){if(f.style!="opacity"){e.element.style[f.style]=""}})}}else{this.style=b.style.parseStyle()}}else{this.style=$H(b.style)}this.start(b)},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(g){var f=g[0],e=g[1],d=null;if(e.parseColor("#zzzzzz")!="#zzzzzz"){e=e.parseColor();d="color"}else{if(f=="opacity"){e=parseFloat(e);if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}}else{if(Element.CSS_LENGTH.test(e)){var c=e.match(/^([\+\-]?[0-9\.]+)(.*)$/);e=parseFloat(c[1]);d=(c.length==3)?c[2]:null}}}var b=this.element.getStyle(f);return{style:f.camelize(),originalValue:d=="color"?a(b):parseFloat(b||0),targetValue:d=="color"?a(e):e,unit:d}}.bind(this)).reject(function(b){return((b.originalValue==b.targetValue)||(b.unit!="color"&&(isNaN(b.originalValue)||isNaN(b.targetValue))))})},update:function(a){var d={},b,c=this.transforms.length;while(c--){d[(b=this.transforms[c]).style]=b.unit=="color"?"#"+(Math.round(b.originalValue[0]+(b.targetValue[0]-b.originalValue[0])*a)).toColorPart()+(Math.round(b.originalValue[1]+(b.targetValue[1]-b.originalValue[1])*a)).toColorPart()+(Math.round(b.originalValue[2]+(b.targetValue[2]-b.originalValue[2])*a)).toColorPart():b.originalValue+Math.round(((b.targetValue-b.originalValue)*a)*1000)/1000+b.unit}this.element.setStyle(d,true)}});Effect.Transform=Class.create();Object.extend(Effect.Transform.prototype,{initialize:function(a){this.tracks=[];this.options=arguments[1]||{};this.addTracks(a)},addTracks:function(a){a.each(function(b){var c=$H(b).values().first();this.tracks.push($H({ids:$H(b).keys().first(),effect:Effect.Morph,options:{style:c}}))}.bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(a){var b=[$(a.ids)||$$(a.ids)].flatten();return b.map(function(c){return new a.effect(c,Object.extend({sync:true},a.options))})}).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.prototype.parseStyle=function(){var b=document.createElement("div");b.innerHTML='<div style="'+this+'"></div>';var c=b.childNodes[0].style,a=$H();Element.CSS_PROPERTIES.each(function(d){if(c[d]){a[d]=c[d]}});if(Prototype.Browser.IE&&this.indexOf("opacity")>-1){a.opacity=this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]}return a};Element.morph=function(a,b){new Effect.Morph(a,Object.extend({style:b},arguments[2]||{}));return a};["getInlineOpacity","forceRerendering","setContentZoom","collectTextNodes","collectTextNodesIgnoreClass","morph"].each(function(a){Element.Methods[a]=Element[a]});Element.Methods.visualEffect=function(b,c,a){s=c.dasherize().camelize();effect_class=s.charAt(0).toUpperCase()+s.substring(1);new Effect[effect_class](b,a);return $(b)};Element.addMethods();if(typeof Effect=="undefined"){throw ("controls.js requires including script.aculo.us' effects.js library")}var Autocompleter={};Autocompleter.Base=function(){};Autocompleter.Base.prototype={baseInitialize:function(b,c,a){b=$(b);this.element=b;this.update=$(c);this.hasFocus=false;this.changed=false;this.active=false;this.index=0;this.entryCount=0;if(this.setOptions){this.setOptions(a)}else{this.options=a||{}}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(d,e){if(!e.style.position||e.style.position=="absolute"){e.style.position="absolute";Position.clone(d,e,{setHeight:false,offsetTop:d.offsetHeight})}Effect.Appear(e,{duration:0.15})};this.options.onHide=this.options.onHide||function(d,e){new Effect.Fade(e,{duration:0.15})};if(typeof(this.options.tokens)=="string"){this.options.tokens=new Array(this.options.tokens)}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,"keypress",this.onKeyPress.bindAsEventListener(this));Event.observe(window,"beforeunload",function(){b.setAttribute("autocomplete","on")})},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();if(Prototype.Browser.WebKit){Event.stop(a)}return;case Event.KEY_DOWN:this.markNext();this.render();if(Prototype.Browser.WebKit){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(b){var a=Event.findElement(b,"LI");if(this.index!=a.autocompleteIndex){this.index=a.autocompleteIndex;this.render()}Event.stop(b)},onClick:function(b){var a=Event.findElement(b,"LI");this.index=a.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(f){if(this.options.updateElement){this.options.updateElement(f);return}var c="";if(this.options.select){var a=document.getElementsByClassName(this.options.select,f)||[];if(a.length>0){c=Element.collectTextNodes(a[0],this.options.select)}}else{c=Element.collectTextNodesIgnoreClass(f,"informal")}var e=this.findLastToken();if(e!=-1){var d=this.element.value.substr(0,e+1);var b=this.element.value.substr(e+1).match(/^\s+/);if(b){d+=b[0]}this.element.value=d+c}else{this.element.value=c}this.element.focus();if(this.options.afterUpdateElement){this.options.afterUpdateElement(this.element,f)}},updateChoices:function(c){if(!this.changed&&this.hasFocus){this.update.innerHTML=c;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 a=0;a<this.entryCount;a++){var b=this.getEntry(a);b.autocompleteIndex=a;this.addObservers(b)}}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;if(this.getToken().length>=this.options.minChars){this.getUpdatedChoices()}else{this.active=false;this.hide()}},getToken:function(){var b=this.findLastToken();if(b!=-1){var a=this.element.value.substr(b+1).replace(/^\s+/,"").replace(/\s+$/,"")}else{var a=this.element.value}return/\n/.test(a)?"":a},findLastToken:function(){var c=-1;for(var b=0;b<this.options.tokens.length;b++){var a=this.element.value.lastIndexOf(this.options.tokens[b]);if(a>c){c=a}}return c}};Ajax.Autocompleter=Class.create();Object.extend(Object.extend(Ajax.Autocompleter.prototype,Autocompleter.Base.prototype),{initialize:function(c,d,b,a){this.baseInitialize(c,d,a);this.options.asynchronous=true;this.options.onComplete=this.onComplete.bind(this);this.options.defaultParams=this.options.parameters||null;this.url=b},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.Local.prototype=Object.extend(new Autocompleter.Base(),{initialize:function(b,d,c,a){this.baseInitialize(b,d,a);this.options.array=c},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(b){var d=[];var c=[];var h=b.getToken();var g=0;for(var e=0;e<b.options.array.length&&d.length<b.options.choices;e++){var f=b.options.array[e];var j=b.options.ignoreCase?f.toLowerCase().indexOf(h.toLowerCase()):f.indexOf(h);while(j!=-1){if(j==0&&f.length!=h.length){d.push("<li><strong>"+f.substr(0,h.length)+"</strong>"+f.substr(h.length)+"</li>");break}else{if(h.length>=b.options.partialChars&&b.options.partialSearch&&j!=-1){if(b.options.fullSearch||/\s/.test(f.substr(j-1,1))){c.push("<li>"+f.substr(0,j)+"<strong>"+f.substr(j,h.length)+"</strong>"+f.substr(j+h.length)+"</li>");break}}}j=b.options.ignoreCase?f.toLowerCase().indexOf(h.toLowerCase(),j+1):f.indexOf(h,j+1)}}if(c.length){d=d.concat(c.slice(0,b.options.choices-d.length))}return"<ul>"+d.join("")+"</ul>"}},a||{})}});Field.scrollFreeActivate=function(a){setTimeout(function(){Field.activate(a)},1)};Ajax.InPlaceEditor=Class.create();Ajax.InPlaceEditor.defaultHighlightColor="#FFFF99";Ajax.InPlaceEditor.prototype={initialize:function(c,b,a){this.url=b;this.element=$(c);this.options=Object.extend({paramName:"value",okButton:true,okLink:false,okText:"ok",cancelButton:false,cancelLink:true,cancelText:"cancel",textBeforeControls:"",textBetweenControls:"",textAfterControls:"",savingText:"Saving...",clickToEditText:"Click to edit",okText:"ok",rows:1,onComplete:function(e,d){new Effect.Highlight(d,{startcolor:this.options.highlightcolor})},onFailure:function(d){alert("Error communicating with the server: "+d.responseText.stripTags())},callback:function(d){return Form.serialize(d)},handleLineBreaks:true,loadingText:"Loading...",savingClassName:"inplaceeditor-saving",loadingClassName:"inplaceeditor-loading",formClassName:"inplaceeditor-form",highlightcolor:Ajax.InPlaceEditor.defaultHighlightColor,highlightendcolor:"#FFFFFF",externalControl:null,submitOnBlur:false,ajaxOptions:{},evalScripts:false},a||{});if(!this.options.formId&&this.element.id){this.options.formId=this.element.id+"-inplaceeditor";if($(this.options.formId)){this.options.formId=null}}if(this.options.externalControl){this.options.externalControl=$(this.options.externalControl)}this.originalBackground=Element.getStyle(this.element,"background-color");if(!this.originalBackground){this.originalBackground="transparent"}this.element.title=this.options.clickToEditText;this.onclickListener=this.enterEditMode.bindAsEventListener(this);this.mouseoverListener=this.enterHover.bindAsEventListener(this);this.mouseoutListener=this.leaveHover.bindAsEventListener(this);Event.observe(this.element,"click",this.onclickListener);Event.observe(this.element,"mouseover",this.mouseoverListener);Event.observe(this.element,"mouseout",this.mouseoutListener);if(this.options.externalControl){Event.observe(this.options.externalControl,"click",this.onclickListener);Event.observe(this.options.externalControl,"mouseover",this.mouseoverListener);Event.observe(this.options.externalControl,"mouseout",this.mouseoutListener)}},enterEditMode:function(a){if(this.saving){return}if(this.editing){return}this.editing=true;this.onEnterEditMode();if(this.options.externalControl){Element.hide(this.options.externalControl)}Element.hide(this.element);this.createForm();this.element.parentNode.insertBefore(this.form,this.element);if(!this.options.loadTextURL){Field.scrollFreeActivate(this.editField)}if(a){Event.stop(a)}return false},createForm:function(){this.form=document.createElement("form");this.form.id=this.options.formId;Element.addClassName(this.form,this.options.formClassName);this.form.onsubmit=this.onSubmit.bind(this);this.createEditField();if(this.options.textarea){var b=document.createElement("br");this.form.appendChild(b)}if(this.options.textBeforeControls){this.form.appendChild(document.createTextNode(this.options.textBeforeControls))}if(this.options.okButton){var e=document.createElement("input");e.type="submit";e.value=this.options.okText;e.className="editor_ok_button";this.form.appendChild(e)}if(this.options.okLink){var c=document.createElement("a");c.href="#";c.appendChild(document.createTextNode(this.options.okText));c.onclick=this.onSubmit.bind(this);c.className="editor_ok_link";this.form.appendChild(c)}if(this.options.textBetweenControls&&(this.options.okLink||this.options.okButton)&&(this.options.cancelLink||this.options.cancelButton)){this.form.appendChild(document.createTextNode(this.options.textBetweenControls))}if(this.options.cancelButton){var d=document.createElement("input");d.type="submit";d.value=this.options.cancelText;d.onclick=this.onclickCancel.bind(this);d.className="editor_cancel_button";this.form.appendChild(d)}if(this.options.cancelLink){var a=document.createElement("a");a.href="#";a.appendChild(document.createTextNode(this.options.cancelText));a.onclick=this.onclickCancel.bind(this);a.className="editor_cancel editor_cancel_link";this.form.appendChild(a)}if(this.options.textAfterControls){this.form.appendChild(document.createTextNode(this.options.textAfterControls))}},hasHTMLLineBreaks:function(a){if(!this.options.handleLineBreaks){return false}return a.match(/<br/i)||a.match(/<p>/i)},convertHTMLLineBreaks:function(a){return a.replace(/<br>/gi,"\n").replace(/<br\/>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<p>/gi,"")},createEditField:function(){var e;if(this.options.loadTextURL){e=this.options.loadingText}else{e=this.getText()}var c=this;if(this.options.rows==1&&!this.hasHTMLLineBreaks(e)){this.options.textarea=false;var a=document.createElement("input");a.obj=this;a.type="text";a.name=this.options.paramName;a.value=e;a.style.backgroundColor=this.options.highlightcolor;a.className="editor_field";var b=this.options.size||this.options.cols||0;if(b!=0){a.size=b}if(this.options.submitOnBlur){a.onblur=this.onSubmit.bind(this)}this.editField=a}else{this.options.textarea=true;var d=document.createElement("textarea");d.obj=this;d.name=this.options.paramName;d.value=this.convertHTMLLineBreaks(e);d.rows=this.options.rows;d.cols=this.options.cols||40;d.className="editor_field";if(this.options.submitOnBlur){d.onblur=this.onSubmit.bind(this)}this.editField=d}if(this.options.loadTextURL){this.loadExternalText()}this.form.appendChild(this.editField)},getText:function(){return this.element.innerHTML},loadExternalText:function(){Element.addClassName(this.form,this.options.loadingClassName);this.editField.disabled=true;new Ajax.Request(this.options.loadTextURL,Object.extend({asynchronous:true,onComplete:this.onLoadedExternalText.bind(this)},this.options.ajaxOptions))},onLoadedExternalText:function(a){Element.removeClassName(this.form,this.options.loadingClassName);this.editField.disabled=false;this.editField.value=a.responseText.stripTags();Field.scrollFreeActivate(this.editField)},onclickCancel:function(){this.onComplete();this.leaveEditMode();return false},onFailure:function(a){this.options.onFailure(a);if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML;this.oldInnerHTML=null}return false},onSubmit:function(){var a=this.form;var b=this.editField.value;this.onLoading();if(this.options.evalScripts){new Ajax.Request(this.url,Object.extend({parameters:this.options.callback(a,b),onComplete:this.onComplete.bind(this),onFailure:this.onFailure.bind(this),asynchronous:true,evalScripts:true},this.options.ajaxOptions))}else{new Ajax.Updater({success:this.element,failure:null},this.url,Object.extend({parameters:this.options.callback(a,b),onComplete:this.onComplete.bind(this),onFailure:this.onFailure.bind(this)},this.options.ajaxOptions))}if(arguments.length>1){Event.stop(arguments[0])}return false},onLoading:function(){this.saving=true;this.removeForm();this.leaveHover();this.showSaving()},showSaving:function(){this.oldInnerHTML=this.element.innerHTML;this.element.innerHTML=this.options.savingText;Element.addClassName(this.element,this.options.savingClassName);this.element.style.backgroundColor=this.originalBackground;Element.show(this.element)},removeForm:function(){if(this.form){if(this.form.parentNode){Element.remove(this.form)}this.form=null}},enterHover:function(){if(this.saving){return}this.element.style.backgroundColor=this.options.highlightcolor;if(this.effect){this.effect.cancel()}Element.addClassName(this.element,this.options.hoverClassName)},leaveHover:function(){if(this.options.backgroundColor){this.element.style.backgroundColor=this.oldBackground}Element.removeClassName(this.element,this.options.hoverClassName);if(this.saving){return}this.effect=new Effect.Highlight(this.element,{startcolor:this.options.highlightcolor,endcolor:this.options.highlightendcolor,restorecolor:this.originalBackground})},leaveEditMode:function(){Element.removeClassName(this.element,this.options.savingClassName);this.removeForm();this.leaveHover();this.element.style.backgroundColor=this.originalBackground;Element.show(this.element);if(this.options.externalControl){Element.show(this.options.externalControl)}this.editing=false;this.saving=false;this.oldInnerHTML=null;this.onLeaveEditMode()},onComplete:function(a){this.leaveEditMode();this.options.onComplete.bind(this)(a,this.element)},onEnterEditMode:function(){},onLeaveEditMode:function(){},dispose:function(){if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML}this.leaveEditMode();Event.stopObserving(this.element,"click",this.onclickListener);Event.stopObserving(this.element,"mouseover",this.mouseoverListener);Event.stopObserving(this.element,"mouseout",this.mouseoutListener);if(this.options.externalControl){Event.stopObserving(this.options.externalControl,"click",this.onclickListener);Event.stopObserving(this.options.externalControl,"mouseover",this.mouseoverListener);Event.stopObserving(this.options.externalControl,"mouseout",this.mouseoutListener)}}};Ajax.InPlaceCollectionEditor=Class.create();Object.extend(Ajax.InPlaceCollectionEditor.prototype,Ajax.InPlaceEditor.prototype);Object.extend(Ajax.InPlaceCollectionEditor.prototype,{createEditField:function(){if(!this.cached_selectTag){var a=document.createElement("select");var c=this.options.collection||[];var b;c.each(function(f,d){b=document.createElement("option");b.value=(f instanceof Array)?f[0]:f;if((typeof this.options.value=="undefined")&&((f instanceof Array)?this.element.innerHTML==f[1]:f==b.value)){b.selected=true}if(this.options.value==b.value){b.selected=true}b.appendChild(document.createTextNode((f instanceof Array)?f[1]:f));a.appendChild(b)}.bind(this));this.cached_selectTag=a}this.editField=this.cached_selectTag;if(this.options.loadTextURL){this.loadExternalText()}this.form.appendChild(this.editField);this.options.callback=function(d,e){return"value="+encodeURIComponent(e)}}});Form.Element.DelayedObserver=Class.create();Form.Element.DelayedObserver.prototype={initialize:function(b,a,c){this.delay=a||0.5;this.element=$(b);this.callback=c;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))}};if(typeof(Control)=="undefined"){Control={}}var $proc=function(a){return typeof(a)=="function"?a:function(){return a}};var $value=function(a){return typeof(a)=="function"?a():a};Object.Event={extend:function(a){a._objectEventSetup=function(b){this._observers=this._observers||{};this._observers[b]=this._observers[b]||[]};a.observe=function(d,b){if(typeof(d)=="string"&&typeof(b)!="undefined"){this._objectEventSetup(d);if(!this._observers[d].include(b)){this._observers[d].push(b)}}else{for(var c in d){this.observe(c,d[c])}}};a.stopObserving=function(c,b){this._objectEventSetup(c);if(c&&b){this._observers[c]=this._observers[c].without(b)}else{if(c){this._observers[c]=[]}else{this._observers={}}}};a.observeOnce=function(d,c){var b=function(){c.apply(this,arguments);this.stopObserving(d,b)}.bind(this);this._objectEventSetup(d);this._observers[d].push(b)};a.notify=function(g){this._objectEventSetup(g);var d=[];var b=$A(arguments).slice(1);try{for(var c=0;c<this._observers[g].length;++c){d.push(this._observers[g][c].apply(this._observers[g][c],b)||null)}}catch(f){if(f==$break){return false}else{throw f}}return d};if(a.prototype){a.prototype._objectEventSetup=a._objectEventSetup;a.prototype.observe=a.observe;a.prototype.stopObserving=a.stopObserving;a.prototype.observeOnce=a.observeOnce;a.prototype.notify=function(g){if(a.notify){var b=$A(arguments).slice(1);b.unshift(this);b.unshift(g);a.notify.apply(a,b)}this._objectEventSetup(g);var b=$A(arguments).slice(1);var d=[];try{if(this.options&&this.options[g]&&typeof(this.options[g])=="function"){d.push(this.options[g].apply(this,b)||null)}for(var c=0;c<this._observers[g].length;++c){d.push(this._observers[g][c].apply(this._observers[g][c],b)||null)}}catch(f){if(f==$break){return false}else{throw f}}return d}}}};Element.addMethods({observeOnce:function(c,d,b){var a=function(){b.apply(this,arguments);Element.stopObserving(c,d,a)};Element.observe(c,d,a)}});Object.extend(Event,(function(){var b=Event.cache;function c(k){if(k._prototypeEventID){return k._prototypeEventID[0]}arguments.callee.id=arguments.callee.id||1;return k._prototypeEventID=[++arguments.callee.id]}function g(k){if(k&&k.include(":")){return"dataavailable"}if(!Prototype.Browser.IE){k={mouseenter:"mouseover",mouseleave:"mouseout"}[k]||k}return k}function a(k){return b[k]=b[k]||{}}function f(m,k){var l=a(m);return l[k]=l[k]||[]}function h(l,k,m){var p=c(l);var o=f(p,k);if(o.pluck("handler").include(m)){return false}var n=function(q){if(!Event||!Event.extend||(q.eventName&&q.eventName!=k)){return false}Event.extend(q);m.call(l,q)};if(!(Prototype.Browser.IE)&&["mouseenter","mouseleave"].include(k)){n=n.wrap(function(t,r){var q=r.relatedTarget;var u=r.currentTarget;if(q&&q.nodeType==Node.TEXT_NODE){q=q.parentNode}if(q&&q!=u&&!q.descendantOf(u)){return t(r)}})}n.handler=m;o.push(n);return n}function j(n,k,l){var m=f(n,k);return m.find(function(o){return o.handler==l})}function d(n,k,l){var m=a(n);if(!m[k]){return false}m[k]=m[k].without(j(n,k,l))}function e(){for(var l in b){for(var k in b[l]){b[l][k]=null}}}if(window.attachEvent){window.attachEvent("onunload",e)}return{observe:function(m,k,n){m=$(m);var l=g(k);var o=h(m,k,n);if(!o){return m}if(m.addEventListener){m.addEventListener(l,o,false)}else{m.attachEvent("on"+l,o)}return m},stopObserving:function(m,k,n){m=$(m);var p=c(m),l=g(k);if(!n&&k){f(p,k).each(function(q){m.stopObserving(k,q.handler)});return m}else{if(!k){Object.keys(a(p)).each(function(q){m.stopObserving(q)});return m}}var o=j(p,k,n);if(!o){return m}if(m.removeEventListener){m.removeEventListener(l,o,false)}else{m.detachEvent("on"+l,o)}d(p,k,n);return m},fire:function(m,l,k){m=$(m);if(m==document&&document.createEvent&&!m.dispatchEvent){m=document.documentElement}var n;if(document.createEvent){n=document.createEvent("HTMLEvents");n.initEvent("dataavailable",true,true)}else{n=document.createEventObject();n.eventType="ondataavailable"}n.eventName=l;n.memo=k||{};if(document.createEvent){m.dispatchEvent(n)}else{m.fireEvent(n.eventType,n)}return Event.extend(n)}}})());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()});(function(){function a(c){var d;if(c.wheelDelta){d=c.wheelDelta/120}else{if(c.detail){d=-c.detail/3}}if(!d){return}var b=c.element().fire("mouse:wheel",{delta:d});if(b.stopped){c.stop();return false}}document.observe("mousewheel",a);document.observe("DOMMouseScroll",a)})();var IframeShim=Class.create({initialize:function(){this.element=new Element("iframe",{style:"position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none",src:"javascript:void(0);",frameborder:0});$(document.body).insert(this.element)},hide:function(){this.element.hide();return this},show:function(){this.element.show();return this},positionUnder:function(a){var a=$(a);var c=a.cumulativeOffset();var b=a.getDimensions();this.element.setStyle({left:c[0]+"px",top:c[1]+"px",width:b.width+"px",height:b.height+"px",zIndex:a.getStyle("zIndex")-1}).show();return this},setBounds:function(a){for(prop in a){a[prop]+="px"}this.element.setStyle(a);return this},destroy:function(){if(this.element){this.element.remove()}return this}});if(typeof(Prototype)=="undefined"){throw"Control.Tabs requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.Tabs requires Object.Event to be loaded."}Control.Tabs=Class.create({initialize:function(c,b){if(!$(c)){throw"Control.Tabs could not find the element: "+c}this.activeContainer=false;this.activeLink=false;this.containers=$H({});this.links=[];Control.Tabs.instances.push(this);this.options={beforeChange:Prototype.emptyFunction,afterChange:Prototype.emptyFunction,hover:false,linkSelector:"li a",setClassOnContainer:false,activeClassName:"active",defaultTab:"first",autoLinkExternal:true,targetRegExp:/#(.+)$/,showFunction:Element.show,hideFunction:Element.hide};Object.extend(this.options,b||{});(typeof(this.options.linkSelector=="string")?$(c).select(this.options.linkSelector):this.options.linkSelector($(c))).findAll(function(d){return(/^#/).exec((Prototype.Browser.WebKit?decodeURIComponent(d.href):d.href).replace(window.location.href.split("#")[0],""))}).each(function(d){this.addTab(d)}.bind(this));this.containers.values().each(Element.hide);if(this.options.defaultTab=="first"){this.setActiveTab(this.links.first())}else{if(this.options.defaultTab=="last"){this.setActiveTab(this.links.last())}else{this.setActiveTab(this.options.defaultTab)}}var a=this.options.targetRegExp.exec(window.location);if(a&&a[1]){a[1].split(",").each(function(d){this.setActiveTab(this.links.find(function(e){return e.key==d}))}.bind(this))}if(this.options.autoLinkExternal){$A(document.getElementsByTagName("a")).each(function(d){if(!this.links.include(d)){var e=d.href.replace(window.location.href.split("#")[0],"");if(e.substring(0,1)=="#"){if(this.containers.keys().include(e.substring(1))){$(d).observe("click",function(g,f){this.setActiveTab(f.substring(1))}.bindAsEventListener(this,e))}}}}.bind(this))}},addTab:function(b){this.links.push(b);b.key=b.getAttribute("href").replace(window.location.href.split("#")[0],"").split("/").last().replace(/#/,"");var a=$(b.key);if(!a){throw"Control.Tabs: #"+b.key+" was not found on the page."}this.containers.set(b.key,a);b[this.options.hover?"onmouseover":"onclick"]=function(c){if(window.event){Event.stop(window.event)}this.setActiveTab(c);return false}.bind(this,b)},setActiveTab:function(a){if(!a&&typeof(a)=="undefined"){return}if(typeof(a)=="string"){this.setActiveTab(this.links.find(function(b){return b.key==a}))}else{if(typeof(a)=="number"){this.setActiveTab(this.links[a])}else{if(this.notify("beforeChange",this.activeContainer,this.containers.get(a.key))===false){return}if(this.activeContainer){this.options.hideFunction(this.activeContainer)}this.links.each(function(b){(this.options.setClassOnContainer?$(b.parentNode):b).removeClassName(this.options.activeClassName)}.bind(this));(this.options.setClassOnContainer?$(a.parentNode):a).addClassName(this.options.activeClassName);this.activeContainer=this.containers.get(a.key);this.activeLink=a;this.options.showFunction(this.containers.get(a.key));this.notify("afterChange",this.containers.get(a.key))}}},next:function(){this.links.each(function(b,a){if(this.activeLink==b&&this.links[a+1]){this.setActiveTab(this.links[a+1]);throw $break}}.bind(this))},previous:function(){this.links.each(function(b,a){if(this.activeLink==b&&this.links[a-1]){this.setActiveTab(this.links[a-1]);throw $break}}.bind(this))},first:function(){this.setActiveTab(this.links.first())},last:function(){this.setActiveTab(this.links.last())}});Object.extend(Control.Tabs,{instances:[],findByTabId:function(a){return Control.Tabs.instances.find(function(b){return b.links.find(function(c){return c.key==a})})}});Object.Event.extend(Control.Tabs);var north_pole;function getAngle(e,d,h){var g=Math.atan2(e.lat()-d.lat(),e.lng()-d.lng());var f=Math.atan2(h.lat()-d.lat(),h.lng()-d.lng());if(g<0){g=2*Math.PI+g}if(f<0){f=2*Math.PI+f}return(g-f)/Math.PI*180}function get_static_map_for_route(e,d,c,b,f,g){var h=g.waypoints;var a="http://maps.google.com/staticmap?size="+e+"&sensor=false&key="+d;a+="&markers=";if(c[0].round()!=0||c[1].round()!=0){a+=c[0]+","+c[1]+",midyellow|"}a+=b[0]+","+b[1]+",midreds|";a+=f[0]+","+f[1]+",midgreene|";a+=h.map(function(j){return""+j[0]+","+j[1]+",tinyred"}).join("|");a+="&path=rgb:0x0000ff,weight:4|";a+=h.map(function(j){return""+j[0]+","+j[1]}).join("|");return a}function get_static_map_for_moving_car(d,c,b){var a="http://maps.google.com/staticmap?size="+d+"&sensor=false&key="+c;a+="&markers=";a+=b.lat()+","+b.lng()+",midyellow";return a}function load_cached_polyline(b){var a=b.map(function(c){var d=new GLatLng(c[0],c[1]);d.vt_distance=c[2];d.vt_angle=c[3];d.vt_speed=c[4];return d});return a}function _getNextRandom(){if(this.index==this.data.length-1){this.index=0}else{this.index++}return this.data[this.index]}function _resetRandom(){this.index=0}var gmaps_key,carmap,angle_comp,carlocation,cardata,routedata,routerandoms,timeelapsed,carstart_time,cached_polyline,streetview,streetviewclient,car_yaw=0;var last_location=null;function interpolate_car_location(w,c){if(c.route.cached_polyline){var d=c.route.cached_polyline;var h=c.route.routerandoms;h.reset();var f=c.speed_multiplier;var g=c.left_turn_penalty;var v=c.right_turn_penalty;var l=0;for(var m=0;m<d.length-1;m++){var u=d[m];var q=d[m+1];var o=q.distanceFrom(u);if(!u.vt_speed){u.vt_speed=10}if((l+o/(u.vt_speed*f))>w){var n=(w-l)/(o/(u.vt_speed*f));var r=new GLatLng(u.lat()+(q.lat()-u.lat())*n,u.lng()+(q.lng()-u.lng())*n);var j=getAngle(north_pole,r,q)+45;return{location:r,angle:j}}l+=o/(u.vt_speed*f);var k=u.vt_angle;if((k<angle_comp&&k>0)||(k>(360-angle_comp))){var e=g*h.next()/100;l+=e}else{if((k>-angle_comp&&k<0)||(k<(-360+angle_comp))){var e=v*h.next()/100;l+=e}}if(l>=w){var j=0;if(m<d.length-2){j=getAngle(north_pole,q,d[m+2])+45}return{location:q,angle:j}}}return{location:d[d.length-1],angle:0}}return{location:c.location,angle:c.angle}}function update_car_location(){var a=interpolate_car_location(timeelapsed+((new Date()).getTime()/1000-carstart_time),cardata);if(a){carlocation=a.location;car_yaw=a.angle}}function street_view_refresh(){north_pole=new GLatLng(90,0);$("facility-maps-control").update("Loading...");update_car_location();if(last_location&&last_location.distanceFrom(carlocation)<10){$("facility-maps-control").update('<span class="red">Car didn&#39;t move enough. Wait a few seconds and try again. <a href="#" onclick="street_view_refresh(); return false;">Refresh</a>');return}streetviewclient=new GStreetviewClient();streetviewclient.getNearestPanorama(carlocation,function(a){last_location=carlocation;$("facility-maps-control").update("Please wait...");(function(){$("facility-maps-control").update('<a href="#" onclick="street_view_refresh(); return false;">Refresh</a>')}).delay(5);if(a&&a.code==600){if(streetview){streetview.remove();streetview=null}var b=get_static_map_for_moving_car("260x260",gmaps_key,carlocation);$("facility-maps").update("There is no Street View data for the car&#39;s current location. We have shown a static map instead.<br /><img src='"+b+"' />");new Effect.Highlight("facility-maps");return null}else{if((!a)||(!a.location)){if(streetview){streetview.remove();streetview=null}$("facility-maps").update("<div class='error'>Error fetching Google StreetView data. "+(a?"Error code: "+a.code:"")+"</div>");new Effect.Highlight("facility-maps");return null}}if(streetview){streetview.remove()}a.location.pov.yaw=car_yaw;streetview=new GStreetviewPanorama($("facility-maps"),a.location)})}var live_map_carmarkers=[],live_map_window_car;var live_map_route_poly,live_map_route_customer,live_map_route_dest,live_map_last_streetview_update=(new Date()).getTime()/1000;function reset_streetview(a,b){live_map_last_streetview_update=(new Date()).getTime()/1000;if(streetview){streetview.remove();GEvent.removeListener(streetview.tm_error_listener);streetview.tm_error_listener=null}streetview=new GStreetviewPanorama($("streetview-frame"),{latlng:a,pov:{yaw:b}});streetview.tm_error_listener=GEvent.addListener(streetview,"error",function(c){streetview.remove();GEvent.removeListener(streetview.tm_error_listener);streetview.tm_error_listener=null;if(c==600){$("streetview-frame").update("There is no Street View available for the car&#39;s current location.")}else{$("streetview-frame").update("Error happened: "+c)}streetview=null})}function update_streetview(a,b){live_map_last_streetview_update=(new Date()).getTime()/1000;if(!streetview){streetview=new GStreetviewPanorama($("streetview-frame"),{latlng:a,pov:{yaw:b}});streetview.tm_error_listener=GEvent.addListener(streetview,"error",function(c){streetview.remove();GEvent.removeListener(streetview.tm_error_listener);streetview.tm_error_listener=null;if(c==600){$("streetview-frame").update("There is no Street View available for the car&#39;s current location.")}else{$("streetview-frame").update("Error happened: "+c)}streetview=null})}else{streetview.setLocationAndPOV(a,{yaw:b})}}function live_map_on_marker_click(a){if(live_map_route_poly){map.removeOverlay(live_map_route_poly)}live_map_route_poly=new GPolyline(a.cardata.route.cached_polyline);map.addOverlay(live_map_route_poly);if(live_map_route_customer){map.removeOverlay(live_map_route_customer)}live_map_route_customer=new GMarker(a.cardata.customer_location,{title:"Pick up point",icon:icons.route_start});map.addOverlay(live_map_route_customer);if(live_map_route_dest){map.removeOverlay(live_map_route_dest)}live_map_route_dest=new GMarker(a.cardata.route.cached_polyline.last(),{title:"Destination",icon:icons.route_end});map.addOverlay(live_map_route_dest);live_map_window_car=a.cardata;reset_streetview(a.cardata.location,a.cardata.angle);a.openInfoWindowHtml(a.cardata.info_html)}function show_cars(){var a=((new Date()).getTime()/1000-carstart_time);live_car_carmarkers=cardata.map(function(b){var c=interpolate_car_location(b.elapsed_time+a,b);var d=new GMarker(c.location,{title:b.name,icon:icons.car_idle_with_driver});d.cardata=b;d.cardata.angle=c.angle;d.cardata.location=c.location;GEvent.addListener(d,"click",function(){live_map_on_marker_click(d)});map.addOverlay(d);return d});zoomToBounds(live_car_carmarkers.map(function(b){return b.getLatLng()}),1)}function update_cars(){var a=((new Date()).getTime()/1000-carstart_time);live_car_carmarkers.each(function(b){var c=interpolate_car_location(b.cardata.elapsed_time+a,b.cardata);b.cardata.location=c.location;b.cardata.angle=c.angle;if(c.location.distanceFrom(b.getLatLng())>10){b.setLatLng(c.location);if(live_map_window_car==b.cardata&&((new Date()).getTime()/1000-live_map_last_streetview_update)>4&&!map.getInfoWindow().isHidden()){update_streetview(c.location,c.angle);map.getInfoWindow().reset(b.cardata.location,map.getInfoWindow().getTabs(),map.getInfoWindow().getPixelOffset())}}});update_cars.delay(1)}function live_map_load(){north_pole=new GLatLng(90,0);if(!GBrowserIsCompatible()){$("map-frame").update('<div class="eroror">Your web browser is not supported by Taxi Mogul.</div>');return}map=new GMap2(document.getElementById("map-frame"));map.setUIToDefault();map.enableScrollWheelZoom();map.setCenter(new GLatLng(40.793188,-73.940563),13);setup_icons();show_cars();if(cardata.length>0){var a=((Math.random())*live_car_carmarkers.length).floor();a=live_car_carmarkers[a];map.panTo(a.cardata.location);live_map_on_marker_click(a)}update_cars()}var facs_markers;var facs_circle;function facilities_rollover_circle(d,j){if(facs_circle){map.removeOverlay(facs_circle);facs_circle=null}var c=map.getCurrentMapType();var e=c.getMinimumResolution();var h=c.getMaximumResolution();var f=c.getProjection();var a=new GBounds([panPoint(d,j*2,90),panPoint(d,j*2,0)]);var l;var g,k;for(l=h;l>=e;l--){g=f.fromLatLngToPixel(new GLatLng(a.min().y,a.min().x),l);k=f.fromLatLngToPixel(new GLatLng(a.max().y,a.max().x),l);if((Math.abs(g.x-k.x)<=maxNavCircleSize)&&(Math.abs(g.y-k.y)<=maxNavCircleSize)){break}}var b="/static/draw_circle?width="+Math.abs(g.x-k.x)+"&height="+Math.abs(g.y-k.y);facs_circle=new EInsert(d,b,new GSize(Math.abs(g.x-k.x)+10,Math.abs(g.y-k.y)+10),l,1);map.addOverlay(facs_circle)}function facilities_map_load(){if(!GBrowserIsCompatible()){$("map-frame").update('<div class="eroror">Your web browser is not supported by Taxi Mogul.</div>');return}map=new GMap2(document.getElementById("map-frame"));map.setUIToDefault();map.enableScrollWheelZoom();setup_icons();map.setCenter(new GLatLng(40.793188,-73.940563),13);facs_markers=new MarkerManager(map);var a=new GLatLngBounds();cm_facdata.each(function(c){var b=new GMarker(new GLatLng(c.lat,c.lng),{icon:icons[c.facility_type+(c.fleet_id==cm_curfleet?"_own":"")],title:c.facility_type_name+(c.fleet_id==cm_curfleet?" (yours)":"("+c.fleet_name.replace(/&#39;/g,"'")+")")});if(c.facility_type=="dispatch"){GEvent.addListener(b,"mouseover",function(){facilities_rollover_circle(b.getLatLng(),c.catchment_radius)});GEvent.addListener(b,"mouseout",function(){if(facs_circle){map.removeOverlay(facs_circle);facs_circle=null}})}GEvent.addListener(b,"click",function(){var f="<div><h5 style='margin-top: 0; margin-bottom: 0;'>";if(c.fleet_id==cm_curfleet){f+="<a href='/facility/show/"+c.facility_id+"'>"+c.facility_name+"</a>"}else{f+=c.facility_name}f+="</h5>";f+="<p style='margin-bottom: 0; padding-bottom: 10px;'>"+c.facility_type_name+"</p><p style='margin-bottom: 0; padding-bottom: 10px;'><b>Owner:</b> "+c.fleet_url+"<br />";if(c.facility_type=="dispatch"){f+="<b>Dispatch coverage:</b> "+c.catchment_radius_txt+" miles<br />"}if(cm_contract_data[c.fleet_id]){var d=cm_contract_data[c.fleet_id][c.facility_type+"_access_fee"];var e=cm_contract_data[c.fleet_id][c.facility_type+"_access_percent"];if((d!=null)||(e!=null)){f+="</p><p style='margin-bottom: 0; padding-bottom: 10px;'>";if(d!=null){f+="<b>"+cm_contract_text[c.facility_type+"_access_fee"]+":</b> "+d+"<br />"}if(e!=null){f+="<b>"+cm_contract_text[c.facility_type+"_access_percent"]+":</b> "+e+"<br />"}}}f+="</p><p style='margin-bottom: 0; padding-bottom: 10px;'>";if(c.fleet_id==cm_curfleet){f+="You own this facility"}else{f+="Message owners <a href='/fleet/"+c.fleet_id+"'>here</a><br />";f+="</p></div>"}b.openInfoWindowHtml(f)});facs_markers.addMarker(b,3);a.extend(b.getLatLng())});facs_markers.refresh()}Element.addMethods({scrollTo:function(a,c,b){var a=$(a);if(arguments.length==1){var d=a.cumulativeOffset();window.scrollTo(d[0],d[1])}else{a.scrollLeft=c;a.scrollTop=b}return a}});Effect.Scroll=Class.create();Object.extend(Object.extend(Effect.Scroll.prototype,Effect.Base.prototype),{initialize:function(a){this.element=$(a);if(!this.element){throw (Effect._elementDoesNotExistError)}this.start(Object.extend({x:0,y:0},arguments[1]||{}))},setup:function(){var a=(this.element==window)?document.viewport.getScrollOffsets():Element._returnOffset(this.element.scrollLeft,this.element.scrollTop);this.originalScrollLeft=a.left;this.originalScrollTop=a.top},update:function(a){this.element.scrollTo(Math.round(this.options.x*a+this.originalScrollLeft),Math.round(this.options.y*a+this.originalScrollTop))}});function parse_iso8601(a){var b="([0-9]{4})-([0-9]{2})-([0-9]{2})";var c=a.match(new RegExp(b));if(c){return new Date(c[1],c[2]-1,c[3])}else{return null}}var map;var markerdir;var icons={};var car_markers,car_data={},dblclick_listener,route_markers;var car_info_window,dispatch_selected,do_dispatch;var route_start,route_end,car_selected,route_car_marker,route_hint_poly,randomNumbers;var gdirections,gdirectionsSecond,gdirectionsListener={},error_count;var directions_optimal,directions_user,pending_query,customer_entry_id;var user_waypoints=[],user_waypoint_markers=[],waypoint_listener,navRad,gotToStart,gotToEnd,max_waypoints=20;var user_result_poly,is_challenge=false,dumb_routing;var dispatch_entries_markers=[],dispatch_entry_line=null;var map_loaded=false;var doing_free_bet=false;var directions_optimal_moved=[];var user_waypoints_put=false;var vt_bad_waypoint_offset=0.00255;var facility_request={reset:function(){this.is_rank=false;this.is_gas=false;this.is_mechanic=false}};var rank_panel={};function panToNavLoc(){var a=user_waypoints.last();if(a){map.panTo(a.getLatLng())}return false}function panToCustStart(){if(route_start){map.panTo(route_start)}return false}function panToCustEnd(){if(route_end){map.panTo(route_end)}return false}function wrapInfoWindowHtml(a){return"<div style='width:220px;margin:0;padding:0;padding-bottom: 30px;font-size:1em;line-height:1em'>"+a+"<br /><br /></div>"}function showInfoWindow(a,b){return a.openInfoWindowHtml(wrapInfoWindowHtml(b))}function mapInfoWindow(b,c,a){return b.openInfoWindowHtml(c,wrapInfoWindowHtml(a))}function clear_dispatch_entries_markers(){dispatch_entries_markers.each(function(a){if(a.tm_marker_listener){GEvent.removeListener(a.tm_marker_listener)}map.removeOverlay(a)});dispatch_entries_markers=[];if(dispatch_entry_line){map.removeOverlay(dispatch_entry_line)}dispatch_entry_line=null}function reset_side_panel_scroll(){var a=Effect.Queues.get("addr_marker_scope");if(a){a.each(function(b){b.cancel()})}new Effect.Scroll("side_panel_contents",{y:-$("side_panel_contents").scrollTop,queue:{scope:"addr_marker_scope"}})}function add_dispatch_entry(j,b,a,f){j=new GLatLng(j[0],j[1]);b=new GLatLng(b[0],b[1]);var d=new GMarker(j,{icon:icons.dispatch_route_start,title:"Customer location",zIndexProcss:function(){return 150}});d.tm_marker_listener=GEvent.addListener(d,"click",f);map.addOverlay(d);var h=function(){if(dispatch_entry_line){map.removeOverlay(dispatch_entry_line)}dispatch_entry_line=new GPolyline([j,b],"#AA0000",5,0.5);map.addOverlay(dispatch_entry_line);if($("dentry_"+a)){var k=Effect.Queues.get("addr_marker_scope");k.each(function(e){e.cancel()});$$(".dentry").each(function(e){e.setStyle({backgroundColor:"#ffffff"})});var l=$("dentry_"+a);var m=l.offsetTop-$("side_panel_contents").scrollTop;new Effect.Scroll("side_panel_contents",{y:m,queue:{scope:"addr_marker_scope"}});new Effect.Highlight("dentry_"+a,{restorecolor:"#ffffff",queue:{scope:"addr_marker_scope",position:"end"}})}};var c=function(){if(dispatch_entry_line){map.removeOverlay(dispatch_entry_line)}dispatch_entry_line=null};d.tm_mouseover=GEvent.addListener(d,"mouseover",h);d.tm_mouseout=GEvent.addListener(d,"mouseout",c);dispatch_entries_markers.push(d);var g=new GMarker(b,{icon:icons.dispatch_route_end,title:"Customer's destination",zIndexProcess:function(){return -150}});g.tm_marker_listener=GEvent.addListener(g,"click",f);map.addOverlay(g);g.tm_mouseover=GEvent.addListener(g,"mouseover",h);g.tm_mouseout=GEvent.addListener(g,"mouseout",c);dispatch_entries_markers.push(g)}function zoom_to_dispatch_entries(){zoomToBounds(dispatch_entries_markers.map(function(a){return a.getLatLng()}))}function setup_icons(){["dispatch","dispatch_own","mechanic","mechanic_own","gas_station","gas_station_own","rank","rank_own","rest_stop","rest_stop_own","car_idle","car_transit_delivery","car_repairing","car_waiting_driver","car_en_route","car_broken","waypoint","car_idle_with_driver","car_assigned_customer","cross","dispatch_route_start","dispatch_route_end"].each(function(b){var c=new GIcon();c.image=markerdir+"/"+b+".png";c.iconSize=new GSize(32,32);c.iconAnchor=new GPoint(16,16);c.infoWindowAnchor=new GPoint(2,20);icons[b]=c});var a=new GIcon();a.image=markerdir+"/route_start.png";a.iconSize=new GSize(20,34);a.iconAnchor=new GPoint(10,34);icons.route_start=a;a=new GIcon();a.image=markerdir+"/route_end.png";a.iconSize=new GSize(20,34);a.iconAnchor=new GPoint(10,34);icons.route_end=a}function panPoint(a,g,c){var f=a.distanceFrom(new GLatLng(a.lat()+0.1,a.lng()))*10;var e=a.distanceFrom(new GLatLng(a.lat(),a.lng()+0.1))*10;var d=g*Math.cos(c*Math.PI/180)/f;var b=g*Math.sin(c*Math.PI/180)/e;return new GLatLng(a.lat()+d,a.lng()+b)}function m2m(a){return a*0.621371192/1000}var maxNavCircleSize=470;var navCircleOverlay,navCircleCentreOverlay;var navCircleZoom;function showNavCircle(d,j){var c=map.getCurrentMapType();var e=c.getMinimumResolution();var h=c.getMaximumResolution();var f=c.getProjection();var a=new GBounds([panPoint(d,j*2,90),panPoint(d,j*2,0)]);var l;var g,k;for(l=h;l>=e;l--){g=f.fromLatLngToPixel(new GLatLng(a.min().y,a.min().x),l);k=f.fromLatLngToPixel(new GLatLng(a.max().y,a.max().x),l);if((Math.abs(g.x-k.x)<=maxNavCircleSize)&&(Math.abs(g.y-k.y)<=maxNavCircleSize)){break}}var b="/static/draw_circle?width="+Math.abs(g.x-k.x)+"&height="+Math.abs(g.y-k.y);if(navCircleOverlay){map.removeOverlay(navCircleOverlay)}navCircleOverlay=new EInsert(d,b,new GSize(Math.abs(g.x-k.x)+10,Math.abs(g.y-k.y)+10),l,1);map.addOverlay(navCircleOverlay);if(navCircleCentreOverlay){map.removeOverlay(navCircleCentreOverlay)}navCircleCentreOverlay=new GMarker(d,{icon:icons.cross,title:"Current waypoint",zIndexProcess:function(){return 200},draggable:true});navCircleCentreOverlay.drag_listener=GEvent.addListener(navCircleCentreOverlay,"dragend",onNavMarkerMove);map.addOverlay(navCircleCentreOverlay);navCircleCentreOverlay.radius=j;navCircleZoom=l}function show_facilities(){clear_dispatch_entries_markers();var a=new GLatLngBounds();facilities.each(function(c){var d=icons[c.type+(c.is_own?"_own":"")];var b=new GMarker(c.latlng,{icon:d,title:c.name});c.info_window_extra="";c.marker_listener=GEvent.addListener(b,"click",function(){showInfoWindow(b,"<span class='small'>"+c.name+" ("+c.type+")<br />"+(c.is_own?"Belongs to your company<br />":"Belongs to "+c.owner+"<br />Contract: "+c.contract+" ("+(c.contract_summary)+")<br />")+c.info_window_extra+"</span>")});c.marker=b;map.addOverlay(b);a.extend(c.latlng)});map.setCenter(a.getCenter());map.setZoom(map.getBoundsZoomLevel(a)-1)}function zoomToBounds(a,c){var b=new GLatLngBounds();a.each(function(d){b.extend(d)});map.setCenter(b.getCenter());if(!c){c=-1}map.setZoom(map.getBoundsZoomLevel(b)+c)}function hide_cars_but(a){car_data.data.each(function(b){if(b!=a){car_markers.removeMarker(b.marker)}})}function useGas(a,b){map.closeInfoWindow();$("side_panel_contents").update("Loading...");new Ajax.Updater("side_panel_contents","/mapping/use_gas/"+b+"?carid="+a,{asynchronous:true,evalScripts:true})}function useMechanic(a,b){map.closeInfoWindow();$("side_panel_contents").update("Loading...");new Ajax.Updater("side_panel_contents","/mapping/use_mechanic/"+b+"?carid="+a,{asynchronous:true,evalScripts:true})}function hideFacilities(){facilities.each(function(a){a.marker.hide()})}function startFacility(b){map.closeInfoWindow();facilities.each(function(c){if(c.type!="mechanic"&&c.type!="gas_station"){c.marker.hide()}else{c.marker.show()}});var a=car_data.data.find(function(c){return c.car_id==b});if(a){hide_cars_but(a)}else{return null}var f="<p>Select the gas station or repair shop you would like to use for <a href='#' onclick='map.panTo(new GLatLng("+a.latlng.lat()+","+a.latlng.lng()+"))'>"+a.name+"</a>.</p>";var e="",d="";facilities.each(function(c){if(c.type=="mechanic"){d+="<li><a href='#' onclick='useMechanic("+b+","+c.facility_id+")'>"+c.name+"</a> ";if(!c.is_own){d+="("+c.contract_summary+")"}d+="</li>";c.info_window_extra="<a href='#' onclick='useMechanic("+b+","+c.facility_id+")'>Use this shop</a>"}else{if(c.type=="gas_station"){e+="<li><a href='#' onclick='useGas("+b+","+c.facility_id+")'>"+c.name+"</a> ";if(!c.is_own){e+="("+c.contract_summary+")"}e+="</li>";c.info_window_extra="<a href='#' onclick='useGas("+b+","+c.facility_id+")'>Refuel here</a>"}}});f+="<h6>Gas stations</h6><ul>";f+=e+"</ul><h6>Repair shops</h6><ul>"+d+"</ul>";$("side_panel_contents").update(f)}function startRank(b){new Ajax.Updater("side_panel_contents","/mapping/show_rank_panel/"+b,{asynchronous:true,evalScripts:true});map.closeInfoWindow();facilities.each(function(c){if(c.type!="rank"){c.marker.hide()}else{c.marker.show()}});var a=car_data.data.find(function(c){return c.car_id==b});if(a){hide_cars_but(a)}}function startDispatch(b){new Ajax.Updater("side_panel_contents","/mapping/show_dispatch_panel/"+b,{asynchronous:true,evalScripts:true});map.closeInfoWindow();facilities.each(function(c){if(c.type!="dispatch"){c.marker.hide()}else{c.marker.show()}});var a=car_data.data.find(function(c){return c.car_id==b});if(a){hide_cars_but(a)}}var default_draggable_cursor="url(http://maps.google.com/intl/en_ALL/mapfiles/openhand_8_8.cur), default";var default_dragging_cursor="url(http://maps.google.com/intl/en_ALL/mapfiles/closedhand_8_8.cur), move";function tm_onMouseMove(b){if(!map_loaded){return}if(waypoint_listener){if(navCircleCentreOverlay){var a=navCircleCentreOverlay.getLatLng().distanceFrom(b);if(a<navCircleCentreOverlay.radius){map.getDragObject().setDraggableCursor("crosshair");map.getDragObject().setDraggingCursor("crosshair");return}}}map.getDragObject().setDraggableCursor(default_draggable_cursor);map.getDragObject().setDraggingCursor(default_dragging_cursor)}function load(a){GLatLng.prototype.toJSON=function(){return[this.lat(),this.lng(),this.vt_distance,this.vt_angle,this.vt_speed].toJSON()};if(!GBrowserIsCompatible()){$("map_frame").update("<div class='error'>Your web browser is not supported by Taxi Mogul.TODO</div>");return}map=new GMap2(document.getElementById("map_frame"));map.setUIToDefault();GEvent.addListener(map,"load",function(){$("show-buttons-loading").hide();$("show-buttons").show();map_loaded=true});map.disableDoubleClickZoom();map.enableScrollWheelZoom();map.setCenter(new GLatLng(40.793188,-73.940563),13);GEvent.clearListeners(map,"dblclick");facilities=facilities.map(function(d){d.latlng=new GLatLng(d.lat,d.lng);return d});car_markers=new MarkerManager(map);route_markers=new MarkerManager(map);setup_icons();show_facilities();gdirections=new GDirections();gdirectionsSecond=new GDirections();GEvent.addListener(map,"mousemove",tm_onMouseMove);if(on_load_ui()){}else{if(window.location.hash&&window.location.hash.length>1){var c=window.location.hash;if(c.toLowerCase().startsWith("#car-")){var b=c.toLowerCase().substr("#car-".length);if(b&&parseInt(b)){startWithCarSelected(b)}}}else{if(!a){$("side_panel_contents").update("<div class='notice'>Loading car data...</div>");new Ajax.Updater("side_panel_contents","/mapping/show_car_panel",{asynchronous:true,evalScripts:true})}}}}function startDriveCustomer(a){new Ajax.Updater("side_panel_contents","/mapping/drive_car/"+a,{evalScripts:true});$("side_panel_contents").update("Loading...");return false}function switchNavTutStep(a){$$(".in-map-tut").each(Element.hide);a="in-map-tut-"+a;if($(a)){$(a).show();new Effect.Highlight("in-map-tutorial-id")}}function car_info_window(b){if((b.state=="idle_with_driver"||b.state=="assigned_customer")&&$("in-map-tut-select-car")){$("in-map-tut-select-car").hide();$$(".in-map-tut-dispatch").each(Element.hide);var a;if(b.state=="idle_with_driver"){a="in-map-tut-dispatch-"+b.car_id}else{a="in-map-tut-customer-"+b.car_id}if($(a)){$(a).show();new Effect.Highlight("in-map-tutorial-id")}}var d="<span class='small'><a href='/vehicle/show/"+b.car_id+"'>"+b.plate_name+"</a> ("+b.name+") "+b.user_state+"<br />";if(b.state=="en_route"||b.state=="repairing"){d+="Showing final position. <br />ETA: "+b.eta+"<br />"}d+="Gas: "+b.fuel_distance+" miles; Next service: "+b.next_service+" miles.<br />";if(b.driver_energy&&b.driver_navigation_miles){d+="Driver: "+b.driver+" ("+(b.driver_energy).round()+"H energy, "+b.driver_navigation_miles.toFixed(2)+" miles navigation)<br />"}else{d+="Driver: "+b.driver+"<br />"}if(b.state=="idle_with_driver"){d+="<a href='#' onclick='startDispatch("+b.car_id+"); return false;'>Dispatch</a> | <a href='#' onclick='startRank("+b.car_id+"); return false;'>Pick up at rank</a> | <a href='#' onclick='startFacility("+b.car_id+"); return false;'>Refuel / repair</a><br />"}else{if(b.state=="assigned_customer"){d+='<a href="#" onclick="startDriveCustomer('+b.car_id+'); return false">Drive customer</a><br />'}}d+="</span>";mapInfoWindow(map,(b.cached_inter_location?i.latlng:b.latlng),d);car_selected=b}function startWithCarSelected(a){$("side_panel_contents").update("<div class='notice'>Please wait...</div>");new Ajax.Updater("side_panel_contents","/mapping/show_car_panel",{asynchronous:true,evalScripts:true,onComplete:function(c){var b=function(){var d=car_data.data.find(function(e){return e.car_id==a});if(d){car_info_window(d);map.panTo(d.latlng)}else{$("side_panel_error_box").update("Something strange happened. Did you come to this page from an obsolete URL?");$("side_panel_error_box").show()}};b.defer()}})}function get_eta(r,m){randomNumbers.reset();var f=r.speed_multiplier;var g=r.left_turn_penalty;var t=r.right_turn_penalty;var j=0;var c=m.cached_polyline;var l=0;for(var k=0;k<c.length-1;k++){var q=c[k];var o=c[k+1];var n=o.distanceFrom(q);j+=n/(q.vt_speed*f);var h=q.vt_angle;if((h<angle_comp&&h>0)||(h>(360-angle_comp))){var e=g*randomNumbers.next()/100;j+=e;l+=e}else{if((h>-angle_comp&&h<0)||(h<(-360+angle_comp))){var e=t*randomNumbers.next()/100;j+=e;l+=e}}}return j}function clean_gdirections_listeners(){if(gdirectionsListener.load){GEvent.removeListener(gdirectionsListener.load)}if(gdirectionsListener.error){GEvent.removeListener(gdirectionsListener.error)}}function extract_challenge_distance(g){var a=g.getPolyline();var l=$R(0,g.getNumRoutes()-1).map(function(d){return g.getRoute(d)});var b=false;var h=0;var m=0;for(var f=0;f<l.length;f++){var k=l[f];for(var e=0;e<k.getNumSteps();e++){var c=k.getStep(e);if((!b)&&(c.getLatLng().distanceFrom(route_start)<100)){b=true}if(b){h+=c.getDistance().meters;m+=c.getDuration().seconds}}}return{distance:h}}function extract_steps(f){var g=[];var a=f.getPolyline();var k=$R(0,f.getNumRoutes()-1).map(function(d){return f.getRoute(d)});for(var e=0;e<k.length;e++){var h=k[e];for(var c=0;c<h.getNumSteps();c++){var b=h.getStep(c);var l=b.getPolylineIndex();if(l<(a.getVertexCount()-1)){g.push({polyindex:l,start:a.getVertex(l),end:a.getVertex(l+1),distance:b.getDistance().meters,duration:b.getDuration().seconds})}}}return g}function extract_poly(k){var h=k.getPolyline();var c=$R(0,h.getVertexCount()-1).map(function(e){var d=h.getVertex(e);if(e>0&&e<(h.getVertexCount()-1)){d.vt_angle=getAngle(h.getVertex(e-1),h.getVertex(e),h.getVertex(e+1))}return d});c.first().vt_angle=180;c.last().vt_angle=180;$R(0,c.length-2).each(function(d){c[d].vt_distance=c[d+1].distanceFrom(c[d])});var a=$R(0,k.getNumRoutes()-1).map(function(d){return $R(0,k.getRoute(d).getNumSteps()-1).map(function(e){return k.getRoute(d).getStep(e)})}).flatten();for(var b=0;b<a.length;b++){var g=a[b];var f=g.getPolylineIndex();var j=c.length-1;if(b<a.length-1){j=a[b+1].getPolylineIndex()}$R(f,j).each(function(d){c[d].vt_speed=g.getDistance().meters/g.getDuration().seconds})}c=$R(0,c.length-1).map(function(l){if(l==c.length-1){return c[l]}var e=c[l],d=c[l+1];if(e.lat()==d.lat()&&e.lng()==d.lng()){return null}else{return e}}).compact();return c}function reset_route(){user_waypoint_markers.each(function(a){map.removeOverlay(a)});user_waypoints=[];user_waypoint_markers=[];if(navCircleOverlay){map.removeOverlay(navCircleOverlay)}if(navCircleCentreOverlay){map.removeOverlay(navCircleCentreOverlay)}if(user_result_poly){map.removeOverlay(user_result_poly)}$("side_panel_contents").show();$("route_result_contents").update("");$("route_result_contents").hide();$("side_panel_error_box").hide();start_routing(route_start,route_end,customer_entry_id,null,true,is_challenge)}function start_driving(){user_waypoint_markers.each(function(b){map.removeOverlay(b)});$("side_panel_contents").update("Loading...");$("side_panel_contents").show();$("side_panel_error_box").hide();$("route_result_contents").hide();if(facility_request.is_gas){var a={directions_optimal:directions_optimal,directions_user:directions_user,car_id:facility_request.car.car_id,gas_id:facility_request.gas.facility_id,gallons:facility_request.gallons};new Ajax.Updater("side_panel_contents","/mapping/finish_gas/"+facility_request.car.car_id,{evalScripts:true,method:"post",parameters:{json_data:Object.toJSON(a)}})}else{if(facility_request.is_mechanic){var a={directions_optimal:directions_optimal,directions_user:directions_user,car_id:facility_request.car.car_id,mechanic_id:facility_request.mechanic.facility_id,points:facility_request.points};new Ajax.Updater("side_panel_contents","/mapping/finish_mechanic/"+facility_request.car.car_id,{evalScripts:true,method:"post",parameters:{json_data:Object.toJSON(a)}})}else{var a={directions_optimal:directions_optimal,directions_user:directions_user,customer_entry_id:customer_entry_id};new Ajax.Updater("side_panel_contents","/mapping/finish_navigation",{evalScripts:true,method:"post",parameters:{json_data:Object.toJSON(a)}})}}}function user_directions(d,g,a){if(car_selected!=d||g!=route_start||a!=route_end){return}directions_user={distance:gdirections.getDistance().meters,time:null,real_time:gdirections.getDuration().seconds,cached_steps:extract_steps(gdirections),waypoints:user_waypoints,dumb_routing:dumb_routing,navigation_radius:navRad,dchallengeDistance:extract_challenge_distance(gdirections).distance,cached_polyline:extract_poly(gdirections)};if(!is_challenge){directions_user.time=get_eta(car_selected,directions_user)}user_result_poly=gdirections.getPolyline();map.addOverlay(user_result_poly);map.setZoom(map.getBoundsZoomLevel(user_result_poly.getBounds()));map.setCenter(user_result_poly.getBounds().getCenter());if(directions_optimal.moved&&directions_optimal.moved.length>0){var b=directions_optimal.moved;b.each(function(h){if(route_car_marker&&route_car_marker.getLatLng()==h[0]){route_car_marker.setLatLng(h[1])}});if(route_markers.vt_markers){route_markers.vt_markers.each(function(h){b.each(function(k){if(h.getLatLng()==k[0]){h.setLatLng(k[1])}})});route_markers.refresh()}}$("side_panel_error_box").hide();$("side_panel_contents").hide();$("route_result_contents").update("Loading details...");$("route_result_contents").setStyle({overflow:"auto"});$("route_result_contents").show();if(!is_challenge){if(!(facility_request.is_gas||facility_request.is_mechanic)){new Ajax.Updater("route_result_contents","/mapping/route_result/"+customer_entry_id,{evalScripts:true,method:"get",parameters:{route_distance:directions_user.distance,route_duration:directions_user.time,optimal_distance:directions_optimal.distance,optimal_duration:directions_optimal.time,dchallengeDistance:directions_user.dchallengeDistance,dumb_routing:(dumb_routing?"1":"0"),user_waypoints:(user_waypoints_put?"1":"0")}})}else{var e="";e+="<p class='key-line'><a href='#' onclick='start_driving(); return false;'><img src='/icons/arrow.png' width='16' height='16' /> Start driving</img></a>";if(user_waypoints_put){e+="<a href='#' onclick='reset_route(); return false;'><img src='/icons/arrow_circle.png' width='16' height='16' /> Try again</a></p>"}e+="<p>We have shown the route on the map. If you're satisfied with it, you may <a href='#' onclick='start_driving(); return false'>start driving</a>.</p>";$("route_result_contents").update(e)}}else{var e;var c=gdirections.getDuration().seconds/bet_data.route_real_duration;if(!doing_free_bet){if(c<0.98){e="<p class='success'>Congratulations! The route you have placed (now shown on the map) is shorter than the one in the original dispatch (yours is "+((c*100).round())+"% of it).</p><p id='bet-successful-result'>Please wait while we upload your results.</p>";var f={directions_user:directions_user};$("route_result_contents").update(e);new Ajax.Updater("bet-successful-result","/mapping/bet_success/"+bet_data.entry_id,{evalScripts:true,method:"post",parameters:{json_data:Object.toJSON(f)}})}else{e="<p class='notice'>Sorry, but the route you have placed isn't sufficiently shorter than the one in the original dispatch (yours is "+((c*100).round())+"% of it).</p>";$("route_result_contents").update(e)}}else{$("route_result_contents").update("Loading results...");if(c<0.98){new Ajax.Updater("route_result_contents","/mapping/free_bet_success/"+bet_data.entry_id,{evalScripts:true,method:"get"})}else{new Ajax.Updater("route_result_contents","/mapping/free_bet_failed/"+bet_data.entry_id,{evalScripts:true,method:"get"})}}$("side_panel_error_box").hide()}}function optimal_directions(b,c,a){if(car_selected!=b||c!=route_start||a!=route_end){return}directions_optimal={distance:gdirections.getDistance().meters,moved:directions_optimal_moved,time:null,real_time:gdirections.getDuration().seconds,cached_steps:extract_steps(gdirections),waypoints:[car_selected.latlng,route_start,route_end],cached_polyline:extract_poly(gdirections)};directions_optimal.time=get_eta(car_selected,directions_optimal);clean_gdirections_listeners();if(pending_query){if(pending_query.do_query){gdirections.clear();gdirections.vt_waypoints=pending_query.waypoints;gdirections.vt_params=pending_query.params;error_count=0;gdirectionsListener.load=GEvent.addListener(gdirections,"load",pending_query.OnLoad);gdirectionsListener.error=GEvent.addListener(gdirections,"error",pending_query.OnError);gdirections.loadFromWaypoints(gdirections.vt_waypoints,gdirections.vt_params);pending_query=null}else{pending_query.OnLoad()}}}function optimal_directions_error(b,c,a){if(car_selected!=b||c!=route_start||a!=route_end){return}if(error_count<2){error_count++;if(gdirections.getStatus().code==G_GEO_UNKNOWN_DIRECTIONS){if(directions_optimal){$("side_panel_error_box").update("We couldn't find a route through waypoints you provided. Please <a href='#' onclick='reset_route();return false'>try again</a>. Try placing waypoints on real roads, maybe?")}else{if(error_count<2){new Ajax.Request("/mapping/report_broken_customer",{parameters:Object.toJSON({waypoints:Object.toJSON(gdirections.vt_waypoints)})});directions_optimal_moved=[];gdirections.vt_waypoints=gdirections.vt_waypoints.map(function(d){var e=new GLatLng(d.lat()+vt_bad_waypoint_offset,d.lng()+vt_bad_waypoint_offset);directions_optimal_moved.push([d,e]);return e});setTimeout(function(){gdirections.clear();gdirections.loadFromWaypoints(gdirections.vt_waypoints,gdirections.vt_params)},1000);return null}else{$("side_panel_error_box").update("Looks like something went wrong. We cannot find an optimal route. Please wait while we remove this customer from the car and give you a refund.");new Ajax.Updater("side_panel_error_box","/mapping/remove_broken_customer/"+car_selected.car_id,{evalScripts:true})}}}else{$("side_panel_error_box").update("We're experiencing problems processing this request. Please wait a little. Error code: "+gdirections.getStatus().code);setTimeout(function(){gdirections.clear();gdirections.loadFromWaypoints(gdirections.vt_waypoints,gdirections.vt_params)},1000)}$("side_panel_error_box").show()}else{$("side_panel_error_box").update("We're experiencing problems processing your request. This may be due to a temporary problem on some server somewhere, or because your internet connection is unreliable. Please refresh the page and try again. Error code: "+gdirections.getStatus().code);$("side_panel_error_box").show()}}function processUserNav(){var e=car_selected,b=route_start,a=route_end;var g=user_waypoints;var f={getSteps:true,getPolyline:true};var d=function(){user_directions(e,b,a)};var c=function(){optimal_directions_error(e,b,a)};if(user_waypoints_put){if(directions_optimal.moved&&directions_optimal.moved.length>0){g=g.map(function(j){var h=directions_optimal.moved.find(function(k){return k[0]==j});if(h){return h[1]}else{return j}})}}if(directions_optimal){pending_query=null;if(user_waypoints_put){gdirections.clear();gdirections.vt_waypoints=g;gdirections.vt_params=f;error_count=0;if(gdirectionsListener.load){GEvent.removeListener(gdirectionsListener.load)}if(gdirectionsListener.error){GEvent.removeListener(gdirectionsListener.error)}gdirectionsListener.load=GEvent.addListener(gdirections,"load",d);gdirectionsListener.error=GEvent.addListener(gdirections,"error",c);gdirections.loadFromWaypoints(gdirections.vt_waypoints,gdirections.vt_params)}else{d()}}else{pending_query={waypoints:g,params:f,OnLoad:d,OnError:c,do_query:true};if(!user_waypoints_put){pending_query.do_query=false}}}function finishUserNav(){user_waypoint_markers=user_waypoints.map(function(a){return a});user_waypoints=user_waypoints.map(function(a){return a.getLatLng()});if(route_markers&&route_markers.vt_markers){route_markers.clearMarkers();route_markers.vt_markers.each(function(a){route_markers.addMarker(a,3)});route_markers.refresh()}$("side_panel_error_box").update("We're processing your request. Please sit tight.");$("side_panel_error_box").show();$("side_panel_contents").hide();processUserNav();if(waypoint_listener){GEvent.removeListener(waypoint_listener);waypoint_listener=null}map.removeOverlay(route_hint_poly)}function showFacilities(){clear_dispatch_entries_markers();var a=new GLatLngBounds();facilities.each(function(b){if(b.marker.isHidden()){b.marker.show()}a.extend(b.marker.getLatLng());b.info_window_extra=""});map.setZoom(map.getBoundsZoomLevel(a)-1);map.setCenter(a.getCenter());$("side_panel_contents").update("You should see all your accessible facilities the map now.")}function clear_navstuff(){clear_dispatch_entries_markers();if(navCircleOverlay){map.removeOverlay(navCircleOverlay)}if(navCircleCentreOverlay){map.removeOverlay(navCircleCentreOverlay)}if(user_waypoint_markers){user_waypoint_markers.each(function(a){map.removeOverlay(a);a.info_window_extra=""})}if(waypoint_listener){GEvent.removeListener(waypoint_listener);waypoint_listener=null}if(route_markers){route_markers.clearMarkers()}if(route_car_marker){map.removeOverlay(route_car_marker)}if(route_hint_poly){map.removeOverlay(route_hint_poly)}}function onNavMarkerMove(c){$("side_panel_error_box").hide();if((user_waypoints.size()<2)||(!(user_waypoints.last()&&user_waypoints.last().vt_draggable))){if(user_waypoints.last()){navCircleCentreOverlay.setPoint(user_waypoints.last().getLatLng())}return}var b=user_waypoints[user_waypoints.size()-2];if(c.distanceFrom(b.getLatLng())>navRad){if(user_waypoints.last()){navCircleCentreOverlay.setPoint(user_waypoints.last().getLatLng())}$("side_panel_error_box").update("You've dragged the waypoint too far.");$("side_panel_error_box").show();new Effect.Highlight("side_panel_error_box");return}if(navCircleOverlay){navCircleOverlay.setPoint(c)}if(navCircleCentreOverlay){navCircleCentreOverlay.setLatLng(c)}if(user_waypoints.last().vt_draggable){var a=user_waypoints.last();a.setPoint(c);if(route_hint_poly){map.removeOverlay(route_hint_poly);route_hint_poly=newRouteHintPoly([c,(gotToStart?route_end:route_start)]);map.addOverlay(route_hint_poly)}}}function put_waypoint(c,g,f){if(!g){return null}user_waypoints_put=user_waypoints_put||(!f);if(user_waypoints.length>=max_waypoints){$("side_panel_error_box").update("You have tried to put too many waypoints. Please <a href='#' onclick='reset_route();return false;'>try again</a> with fewer steps.<br /><br />Perhaps your driver isn't experienced enough? More experienced drivers require fewer waypoints to get anywhere.");$("side_panel_error_box").show();new Effect.Highlight("side_panel_error_box");clear_navstuff();user_waypoints=[];user_waypoint_markers=[];if(waypoint_listener){GEvent.removeListener(waypoint_listener);waypoint_listener=null}return}if(g.distanceFrom(user_waypoints.last().getLatLng())<=navRad){$("side_panel_error_box").hide();var b;if(!f){b=new GMarker(g,{draggable:false,icon:icons.waypoint,zIndexProcess:function(){return -201}});b.vt_draggable=true;var d=g;map.addOverlay(b)}else{b=new GMarker(g,{draggable:false,icon:icons.waypoint,zIndexProcess:function(){return -201}});b.vt_draggable=false;map.addOverlay(b)}user_waypoints.push(b);user_waypoint_markers.push(b);var a=false;if(!gotToStart&&route_start.distanceFrom(g)<=navRad){if(route_markers&&route_markers.vt_markers){route_markers.clearMarkers();route_markers.vt_markers.each(function(h){if(h.getLatLng()!=route_start){route_markers.addMarker(h,3)}});route_markers.refresh()}if(route_start!=g){var e=new GMarker(route_start,{draggable:false,icon:icons.waypoint,zIndexProcess:function(){return -201}});e.vt_draggable=false;map.addOverlay(e);user_waypoints.push(e);user_waypoint_markers.push(e);g=route_start}gotToStart=true;if(!route_end){if(navCircleOverlay){map.removeOverlay(navCircleOverlay)}if(navCircleCentreOverlay){map.removeOverlay(navCircleCentreOverlay)}if(waypoint_listener){GEvent.removeListener(waypoint_listener);waypoint_listener=null}switchNavTutStep("reached-end");gotToEnd=true;return finishUserNav()}if(route_end.distanceFrom(g)<=navRad){switchNavTutStep("reached-end");a=true}else{switchNavTutStep("reached-customer");a=true;if(route_hint_poly){map.removeOverlay(route_hint_poly);route_hint_poly=newRouteHintPoly([route_start,route_end]);map.addOverlay(route_hint_poly)}}}if(gotToStart&&route_end.distanceFrom(g)<=navRad){var e=new GMarker(route_end,{draggable:false,icon:icons.waypoint,zIndexProcess:function(){return -201}});e.vt_draggable=false;map.addOverlay(e);user_waypoints.push(e);user_waypoint_markers.push(e);if(navCircleOverlay){map.removeOverlay(navCircleOverlay)}if(navCircleCentreOverlay){map.removeOverlay(navCircleCentreOverlay)}if(waypoint_listener){GEvent.removeListener(waypoint_listener);waypoint_listener=null}switchNavTutStep("reached-end");gotToEnd=true;return finishUserNav()}if(!a){if(gotToStart){switchNavTutStep("to-end-cont")}else{switchNavTutStep("to-customer-cont")}}map.panTo(g);showNavCircle(g,navRad);if(route_hint_poly){map.removeOverlay(route_hint_poly);route_hint_poly=newRouteHintPoly([g,(gotToStart?route_end:route_start)]);map.addOverlay(route_hint_poly)}}else{$("side_panel_error_box").update("Point you clicked on is too far away from the last one. Make sure you double-click inside the blue circle.");$("side_panel_error_box").show();new Effect.Highlight("side_panel_error_box")}}function start_routing(b,e,h,c,l,m){clear_dispatch_entries_markers();is_challenge=m;if($("before_nav")&&$("after_nav")){$("before_nav").hide();new Effect.Appear("after_nav")}customer_entry_id=h;map.closeInfoWindow();car_markers.clearMarkers();var d=new GLatLngBounds();d.extend(car_selected.latlng);d.extend(b);if(e){d.extend(e)}route_markers.clearMarkers();var o=new GMarker(b,{icon:icons.route_start});route_markers.addMarker(o,3);route_markers.vt_markers=[o];if(e){o=new GMarker(e,{icon:icons.route_end});route_markers.addMarker(o,3);route_markers.vt_markers.push(o)}route_markers.refresh();map.setZoom(map.getBoundsZoomLevel(d));map.setCenter(d.getCenter());route_start=b;route_end=e;if(!l){randomNumbers={data:c,index:0,next:_getNextRandom,reset:_resetRandom}}if(route_car_marker){map.removeOverlay(route_car_marker)}route_car_marker=new GMarker(car_selected.latlng,{icon:icons.car_idle_with_driver,title:car_selected.plate_name,zIndexProcess:function(p){return 100}});map.addOverlay(route_car_marker);if(route_hint_poly){map.removeOverlay(route_hint_poly)}var f=[car_selected.latlng,b];route_hint_poly=newRouteHintPoly(f);map.addOverlay(route_hint_poly);showNavCircle(car_selected.latlng,car_selected.driver_radius);var g=car_selected,n=b,a=e;if(!l){pending_query=null;gdirections.clear();var k=[car_selected.latlng,b];if(e){k.push(e)}gdirections.vt_waypoints=k;gdirections.vt_params={getSteps:true,getPolyline:true};if(gdirectionsListener.load){GEvent.removeListener(gdirectionsListener.load)}if(gdirectionsListener.error){GEvent.removeListener(gdirectionsListener.error)}error_count=0;directions_optimal=null;directions_optimal_moved=[];gdirectionsListener.load=GEvent.addListener(gdirections,"load",function(){optimal_directions(g,n,a)});gdirectionsListener.error=GEvent.addListener(gdirections,"error",function(){optimal_directions_error(g,n,a)});gdirections.loadFromWaypoints(gdirections.vt_waypoints,gdirections.vt_params)}else{pending_query=null}user_waypoint_markers.each(function(p){map.removeOverlay(p)});var j=new GMarker(car_selected.latlng,{draggable:false,icon:icons.waypoint,zIndexProcess:function(){return -201}});j.vt_draggable=false;map.addOverlay(j);user_waypoints=[j];user_waypoint_markers=[j];navRad=car_selected.driver_radius;gotToStart=false;gotToEnd=false;dumb_routing=false;if(waypoint_listener){GEvent.removeListener(waypoint_listener);waypoint_listener=null}user_waypoints_put=false;waypoint_listener=GEvent.addListener(map,"dblclick",put_waypoint);if(route_start.distanceFrom(car_selected.latlng)<=navRad){put_waypoint(null,route_start,true)}else{switchNavTutStep("to-customer")}}function startPurchaseGas(c,d,b,a){clear_dispatch_entries_markers();$("side_panel_contents").update("Loading...");facility_request.reset();facility_request.is_gas=true;facility_request.gas=facilities.find(function(e){return e.facility_id==d});if(car_selected.car_id!=c){$("side_panel_contents").update("");$("side_panel_error_box").update("Internal error happened. Please refresh the page and try again.");$("side_panel_error_box").show();return}new Ajax.Updater("side_panel_contents","/mapping/do_facility_navigation?facid="+d+"&carid="+c,{asynchronous:true,evalScripts:true});facility_request.car=car_selected;facility_request.gallons=b;start_routing(facility_request.gas.latlng,null,null,a,false,false)}function startRepair(b,d,c,a){clear_dispatch_entries_markers();$("side_panel_contents").update("Loading...");facility_request.reset();facility_request.is_mechanic=true;facility_request.mechanic=facilities.find(function(e){return e.facility_id==d});if(car_selected.car_id!=b){$("side_panel_contents").update("");$("side_panel_error_box").update("Internal error happened. Please refresh the page and try again.");$("side_panel_error_box").show();return}new Ajax.Updater("side_panel_contents","/mapping/do_facility_navigation?facid="+d+"&carid="+b,{asynchronous:true,evalScripts:true});facility_request.car=car_selected;facility_request.points=c;start_routing(facility_request.mechanic.latlng,null,null,a,false,false)}function show_point(a){map.panTo(a)}function do_bet(b){if(!map_loaded){do_bet.delay(0.5,b);return}clear_dispatch_entries_markers();if(!bet_data){return}doing_free_bet=b;car_selected={latlng:new GLatLng(bet_data.carpos[0],bet_data.carpos[1]),plate_name:bet_data.player_name+"'s vehicle",driver_radius:bet_data.route_data.navigation_radius};directions_optimal=[];directions_optimal_moved=[];start_routing(new GLatLng(bet_data.startpos[0],bet_data.startpos[1]),new GLatLng(bet_data.endpos[0],bet_data.endpos[1]),null,[],true,true);$("side_panel_contents").update("Loading details...");var a;if(b){a="/mapping/doing_free_bet"}else{a="/mapping/doing_bet"}new Ajax.Updater("side_panel_contents",a,{asynchronous:true,evalScripts:true})}function disableInMapTutorial(b){if(confirm("Do you want to disable in-map tips?")){var a;if(b){a="/mapping/disable_in_map_rank_tut"}else{a="/mapping/disable_in_map_tut"}new Ajax.Request(a,{method:"post"});$("in-map-tutorial-id").hide()}}function newRouteHintPoly(a){return new GPolyline(a,"#499200",4,0.6)}function do_dumb_routing(){var a=0;dumb_routing=true;do{a+=1;if(a>27){$("side_panel_error_box").update("Auto-routing failed. The customer or her destination is probably too  far for your driver to reach them.");$("side_panel_error_box").show();return}var e=user_waypoints.last().getLatLng();var c=(gotToStart?route_end:route_start);if(!c){break}if(e.distanceFrom(c)<navRad){put_waypoint(null,c,true)}else{var b=navRad/(e.distanceFrom(c))-0.01;var d=new GLatLng(e.lat()+(c.lat()-e.lat())*b,e.lng()+(c.lng()-e.lng())*b);put_waypoint(null,d,false)}}while(!gotToEnd)}if(typeof deconcept=="undefined"){var deconcept=new Object()}if(typeof deconcept.util=="undefined"){deconcept.util=new Object()}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object()}deconcept.SWFObject=function(n,b,o,e,k,l,g,f,d,m){if(!document.getElementById){return}this.DETECT_KEY=m?m:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(n){this.setAttribute("swf",n)}if(b){this.setAttribute("id",b)}if(o){this.setAttribute("width",o)}if(e){this.setAttribute("height",e)}if(k){this.setAttribute("version",new deconcept.PlayerVersion(k.toString().split(".")))}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true}if(l){this.addParam("bgcolor",l)}var a=g?g:"high";this.addParam("quality",a);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var j=(f)?f:window.location;this.setAttribute("xiRedirectUrl",j);this.setAttribute("redirectUrl","");if(d){this.setAttribute("redirectUrl",d)}};deconcept.SWFObject.prototype={useExpressInstall:function(a){this.xiSWFPath=!a?"expressinstall.swf":a;this.setAttribute("useExpressInstall",true)},setAttribute:function(a,b){this.attributes[a]=b},getAttribute:function(a){return this.attributes[a]},addParam:function(b,a){this.params[b]=a},getParams:function(){return this.params},addVariable:function(b,a){this.variables[b]=a},getVariable:function(a){return this.variables[a]},getVariables:function(){return this.variables},getVariablePairs:function(){var c=new Array();var b;var a=this.getVariables();for(b in a){c[c.length]=b+"="+a[b]}return c},getSWFHTML:function(){var b="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath)}b='<embed type="application/x-shockwave-flash" src="'+this.getAttribute("swf")+'" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'" style="'+this.getAttribute("style")+'"';b+=' id="'+this.getAttribute("id")+'" name="'+this.getAttribute("id")+'" ';var f=this.getParams();for(var e in f){b+=[e]+'="'+f[e]+'" '}var d=this.getVariablePairs().join("&");if(d.length>0){b+='flashvars="'+d+'"'}b+="/>"}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath)}b='<object id="'+this.getAttribute("id")+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'" style="'+this.getAttribute("style")+'">';b+='<param name="movie" value="'+this.getAttribute("swf")+'" />';var c=this.getParams();for(var e in c){b+='<param name="'+e+'" value="'+c[e]+'" />'}var a=this.getVariablePairs().join("&");if(a.length>0){b+='<param name="flashvars" value="'+a+'" />'}b+="</object>"}return b},write:function(b){if(this.getAttribute("useExpressInstall")){var a=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(a)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",encodeURIComponent(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title)}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var c=(typeof b=="string")?document.getElementById(b):b;c.innerHTML=this.getSWFHTML();if(!(navigator.plugins&&navigator.mimeTypes.length)){window[this.getAttribute("id")]=document.getElementById(this.getAttribute("id"))}return true}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"))}}return false}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var f=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var a=navigator.plugins["Shockwave Flash"];if(a&&a.description){f=new deconcept.PlayerVersion(a.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."))}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var b=1;var c=3;while(b){try{c++;b=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+c);f=new deconcept.PlayerVersion([c,0,0])}catch(d){b=null}}}else{try{var b=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(d){try{var b=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");f=new deconcept.PlayerVersion([6,0,21]);b.AllowScriptAccess="always"}catch(d){if(f.major==6){return f}}try{b=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(d){}}if(b!=null){f=new deconcept.PlayerVersion(b.GetVariable("$version").split(" ")[1].split(","))}}}return f};deconcept.PlayerVersion=function(a){this.major=a[0]!=null?parseInt(a[0]):0;this.minor=a[1]!=null?parseInt(a[1]):0;this.rev=a[2]!=null?parseInt(a[2]):0};deconcept.PlayerVersion.prototype.versionIsValid=function(a){if(this.major<a.major){return false}if(this.major>a.major){return true}if(this.minor<a.minor){return false}if(this.minor>a.minor){return true}if(this.rev<a.rev){return false}return true};deconcept.util={getRequestParameter:function(c){var d=document.location.search||document.location.hash;if(c==null){return d}if(d){var b=d.substring(1).split("&");for(var a=0;a<b.length;a++){if(b[a].substring(0,b[a].indexOf("="))==c){return b[a].substring((b[a].indexOf("=")+1))}}}return""}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var b=document.getElementsByTagName("OBJECT");for(var c=b.length-1;c>=0;c--){b[c].style.display="none";for(var a in b[c]){if(typeof b[c][a]=="function"){b[c][a]=function(){}}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs)};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true}}if(!document.getElementById&&document.all){document.getElementById=function(a){return document.all[a]}}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;var TableKit=Class.create();TableKit.prototype={initialize:function(d,a){var b=$(d);if(b.tagName!=="TABLE"){return}TableKit.register(b,Object.extend(TableKit.options,a||{}));this.id=b.id;var c=TableKit.option("sortable resizable editable",this.id);if(c.sortable){TableKit.Sortable.init(b)}if(c.resizable){TableKit.Resizable.init(b)}if(c.editable){TableKit.Editable.init(b)}},sort:function(b,a){TableKit.Sortable.sort(this.id,b,a)},resizeColumn:function(b,a){TableKit.Resizable.resize(this.id,b,a)},editCell:function(b,a){TableKit.Editable.editCell(this.id,b,a)}};Object.extend(TableKit,{getBodyRows:function(a){a=$(a);var b=a.id;if(!TableKit.tables[b].dom.rows){TableKit.tables[b].dom.rows=(a.tHead&&a.tHead.rows.length>0)?$A(a.tBodies[0].rows):$A(a.rows).without(a.rows[0])}return TableKit.tables[b].dom.rows},getHeaderCells:function(b,a){if(!b){b=$(a).up("table")}var c=b.id;if(!TableKit.tables[c].dom.head){TableKit.tables[c].dom.head=$A((b.tHead&&b.tHead.rows.length>0)?b.tHead.rows[b.tHead.rows.length-1].cells:b.rows[0].cells)}return TableKit.tables[c].dom.head},getCellIndex:function(a){return $A(a.parentNode.cells).indexOf(a)},getRowIndex:function(a){return $A(a.parentNode.rows).indexOf(a)},getCellText:function(a,b){if(!a){return""}var c=TableKit.getCellData(a);if(b||c.refresh||!c.textContent){c.textContent=a.textContent?a.textContent:a.innerText;c.refresh=false}return c.textContent},getCellData:function(a){var c=null;if(!a.id){c=$(a).up("table");a.id=c.id+"-cell-"+TableKit._getc()}var b=c?c.id:a.id.match(/(.*)-cell.*/)[1];if(!TableKit.tables[b].dom.cells[a.id]){TableKit.tables[b].dom.cells[a.id]={textContent:"",htmlContent:"",active:false}}return TableKit.tables[b].dom.cells[a.id]},register:function(b,a){if(!b.id){b.id="tablekit-table-"+TableKit._getc()}var c=b.id;TableKit.tables[c]=TableKit.tables[c]?Object.extend(TableKit.tables[c],a||{}):Object.extend({dom:{head:null,rows:null,cells:{}},sortable:false,resizable:false,editable:false},a||{})},notify:function(a,c,b){if(TableKit.tables[c.id]&&TableKit.tables[c.id].observers&&TableKit.tables[c.id].observers[a]){TableKit.tables[c.id].observers[a](c,b)}TableKit.options.observers[a](c,b)()},isSortable:function(a){return TableKit.tables[a.id]?TableKit.tables[a.id].sortable:false},isResizable:function(a){return TableKit.tables[a.id]?TableKit.tables[a.id].resizable:false},isEditable:function(a){return TableKit.tables[a.id]?TableKit.tables[a.id].editable:false},setup:function(a){Object.extend(TableKit.options,a||{})},option:function(b,e,d,c){d=d||TableKit.options;c=c||(e?(TableKit.tables[e]?TableKit.tables[e]:{}):{});var a=e+b;if(!TableKit._opcache[a]){TableKit._opcache[a]=$A($w(b)).inject([],function(f,g){f.push(f[g]=c[g]||d[g]);return f})}return TableKit._opcache[a]},e:function(a){return a||window.event},tables:{},_opcache:{},options:{autoLoad:true,stripe:true,sortable:true,resizable:true,editable:true,rowEvenClass:"roweven",rowOddClass:"rowodd",sortableSelector:["table.sortable"],columnClass:"sortcol",descendingClass:"sortdesc",ascendingClass:"sortasc",defaultSortDirection:1,noSortClass:"nosort",sortFirstAscendingClass:"sortfirstasc",sortFirstDecendingClass:"sortfirstdesc",resizableSelector:["table.resizable"],minWidth:10,showHandle:true,resizeOnHandleClass:"resize-handle-active",editableSelector:["table.editable"],formClassName:"editable-cell-form",noEditClass:"noedit",editAjaxURI:"/",editAjaxOptions:{},observers:{onSortStart:function(){},onSort:function(){},onSortEnd:function(){},onResizeStart:function(){},onResize:function(){},onResizeEnd:function(){},onEditStart:function(){},onEdit:function(){},onEditEnd:function(){}}},_c:0,_getc:function(){return TableKit._c+=1},unloadTable:function(e){e=$(e);if(!TableKit.tables[e.id]){return}var b=TableKit.getHeaderCells(e);var g=TableKit.option("sortable resizable editable noSortClass descendingClass ascendingClass columnClass sortFirstAscendingClass sortFirstDecendingClass",e.id);b.each(function(h){h=$(h);if(g.sortable){if(!h.hasClassName(g.noSortClass)){Event.stopObserving(h,"mousedown",TableKit.Sortable._sort);h.removeClassName(g.columnClass);h.removeClassName(g.sortFirstAscendingClass);h.removeClassName(g.sortFirstDecendingClass);if(h.hasClassName(g.ascendingClass)){h.removeClassName(g.ascendingClass);h.addClassName(g.sortFirstAscendingClass)}else{if(h.hasClassName(g.descendingClass)){h.removeClassName(g.descendingClass);h.addClassName(g.sortFirstDecendingClass)}}}}if(g.resizable){Event.stopObserving(h,"mouseover",TableKit.Resizable.initDetect);Event.stopObserving(h,"mouseout",TableKit.Resizable.killDetect)}});if(g.editable){Event.stopObserving(e.tBodies[0],"click",TableKit.Editable._editCell);for(var f in TableKit.tables[e.id].dom.cells){if(TableKit.tables[e.id].dom.cells[f].active){var a=$(f);var d=TableKit.Editable.getCellEditor(a);d.cancel(a)}}}TableKit.tables[e.id].dom={head:null,rows:null,cells:{}}},reloadTable:function(a){a=$(a);TableKit.unloadTable(a);var b=TableKit.option("sortable resizable editable",a.id);if(b.sortable){TableKit.Sortable.init(a)}if(b.resizable){TableKit.Resizable.init(a)}if(b.editable){TableKit.Editable.init(a)}},reload:function(){for(var a in TableKit.tables){TableKit.reloadTable(a)}},load:function(){if(TableKit.options.autoLoad){if(TableKit.options.sortable){$A(TableKit.options.sortableSelector).each(function(a){$$(a).each(function(b){TableKit.Sortable.init(b)})})}if(TableKit.options.resizable){$A(TableKit.options.resizableSelector).each(function(a){$$(a).each(function(b){TableKit.Resizable.init(b)})})}if(TableKit.options.editable){$A(TableKit.options.editableSelector).each(function(a){$$(a).each(function(b){TableKit.Editable.init(b)})})}}}});TableKit.Rows={stripe:function(a){var b=TableKit.getBodyRows(a);b.each(function(d,c){TableKit.Rows.addStripeClass(a,d,c)})},addStripeClass:function(j,a,c){j=j||a.up("table");var d=TableKit.option("rowEvenClass rowOddClass",j.id);var e=((c+1)%2===0?d[0]:d[1]);var f=a.className.split(/\s+/);var h=[];for(var g=0,b=f.length;g<b;g+=1){if(f[g]!==d[0]&&f[g]!==d[1]){h.push(f[g])}}h.push(e);a.className=h.join(" ")}};TableKit.Sortable={init:function(f,c){var d=$(f);if(d.tagName!=="TABLE"){return}TableKit.register(d,Object.extend(c||{},{sortable:true}));var b;var a=TableKit.getHeaderCells(d);var e=TableKit.option("noSortClass columnClass sortFirstAscendingClass sortFirstDecendingClass",d.id);a.each(function(g){g=$(g);if(!g.hasClassName(e.noSortClass)){Event.observe(g,"mousedown",TableKit.Sortable._sort);g.addClassName(e.columnClass);if(g.hasClassName(e.sortFirstAscendingClass)||g.hasClassName(e.sortFirstDecendingClass)){b=g}}});if(b){if(b.hasClassName(e.sortFirstAscendingClass)){TableKit.Sortable.sort(d,b,1)}else{TableKit.Sortable.sort(d,b,-1)}}else{TableKit.Rows.stripe(d)}},reload:function(b){b=$(b);var a=TableKit.getHeaderCells(b);var c=TableKit.option("noSortClass columnClass",b.id);a.each(function(d){d=$(d);if(!d.hasClassName(c.noSortClass)){Event.stopObserving(d,"mousedown",TableKit.Sortable._sort);d.removeClassName(c.columnClass)}});TableKit.Sortable.init(b)},_sort:function(b){if(TableKit.Resizable._onHandle){return}b=TableKit.e(b);Event.stop(b);var a=Event.element(b);while(!(a.tagName&&a.tagName.match(/td|th/gi))){a=a.parentNode}TableKit.Sortable.sort(null,a)},sort:function(k,f,b){var h;if(typeof f==="number"){if(!k||(k.tagName&&k.tagName!=="TABLE")){return}k=$(k);f=Math.min(k.rows[0].cells.length,f);f=Math.max(1,f);f-=1;h=(k.tHead&&k.tHead.rows.length>0)?$(k.tHead.rows[k.tHead.rows.length-1].cells[f]):$(k.rows[0].cells[f])}else{h=$(f);k=k?$(k):h.up("table");f=TableKit.getCellIndex(h)}var e=TableKit.option("noSortClass descendingClass ascendingClass defaultSortDirection",k.id);if(h.hasClassName(e.noSortClass)){return}b=b?b:e.defaultSortDirection;var l=TableKit.getBodyRows(k);if(h.hasClassName(e.ascendingClass)||h.hasClassName(e.descendingClass)){l.reverse();b=h.hasClassName(e.descendingClass)?1:-1}else{var d=TableKit.Sortable.getDataType(h,f,k);var j=TableKit.Sortable.types;l.sort(function(n,m){return b*j[d].compare(TableKit.getCellText(n.cells[f]),TableKit.getCellText(m.cells[f]))})}var c=k.tBodies[0];var a=TableKit.Rows;l.each(function(n,m){c.appendChild(n);a.addStripeClass(k,n,m)});var g=TableKit.getHeaderCells(null,h);$A(g).each(function(n,m){n=$(n);n.removeClassName(e.ascendingClass);n.removeClassName(e.descendingClass);if(f===m){if(b===1){n.addClassName(e.ascendingClass)}else{n.addClassName(e.descendingClass)}}})},types:{},detectors:[],addSortType:function(){$A(arguments).each(function(a){TableKit.Sortable.types[a.name]=a})},getDataType:function(a,c,e){a=$(a);c=(c||c===0)?c:TableKit.getCellIndex(a);var g=TableKit.Sortable._coltypecache;var b=g[e.id]?g[e.id]:(g[e.id]={});if(!b[c]){var d=false;if(a.id&&TableKit.Sortable.types[a.id]){d=a.id}if(!d){d=$w(a.className).detect(function(h){return(TableKit.Sortable.types[h])?true:false})}if(!d){var f=TableKit.getBodyRows(e);a=f[0].cells[c];d=TableKit.Sortable.detectors.detect(function(h){return TableKit.Sortable.types[h].detect(TableKit.getCellText(a))})}b[c]=d}return b[c]},_coltypecache:{}};TableKit.Sortable.detectors=$A($w("date-iso date date-eu date-au time currency datasize number casesensitivetext text"));TableKit.Sortable.Type=Class.create();TableKit.Sortable.Type.prototype={initialize:function(b,a){this.name=b;a=Object.extend({normal:function(c){return c},pattern:/.*/},a||{});this.normal=a.normal;this.pattern=a.pattern;if(a.compare){this.compare=a.compare}if(a.detect){this.detect=a.detect}},compare:function(d,c){return TableKit.Sortable.Type.compare(this.normal(d),this.normal(c))},detect:function(a){return this.pattern.test(a)}};TableKit.Sortable.Type.compare=function(d,c){return d<c?-1:d===c?0:1};TableKit.Sortable.addSortType(new TableKit.Sortable.Type("number",{pattern:/^[-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?/,normal:function(a){a=parseFloat(a.replace(/^.*?([-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?).*$/,"$1"));return isNaN(a)?0:a}}),new TableKit.Sortable.Type("text",{normal:function(a){return a?a.toLowerCase():""}}),new TableKit.Sortable.Type("casesensitivetext",{pattern:/^[A-Z]+$/}),new TableKit.Sortable.Type("datasize",{pattern:/^[-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?\s?[k|m|g|t]b$/i,normal:function(e){var f=e.match(/^([-+]?[\d]*\.?[\d]+([eE][-+]?[\d]+)?)\s?([k|m|g|t]?b)?/i);var d=f[1]?Number(f[1]).valueOf():0;var c=f[3]?f[3].substr(0,1).toLowerCase():"";var a=d;switch(c){case"k":a=d*1024;break;case"m":a=d*1024*1024;break;case"g":a=d*1024*1024*1024;break;case"t":a=d*1024*1024*1024*1024;break}return a}}),new TableKit.Sortable.Type("date-au",{pattern:/^\d{2}\/\d{2}\/\d{4}\s?(?:\d{1,2}\:\d{2}(?:\:\d{2})?\s?[a|p]?m?)?/i,normal:function(j){if(!this.pattern.test(j)){return 0}var a=j.match(/^(\d{2})\/(\d{2})\/(\d{4})\s?(?:(\d{1,2})\:(\d{2})(?:\:(\d{2}))?\s?([a|p]?m?))?/i);var h=a[3];var e=parseInt(a[2],10)-1;var b=a[1];var g=a[4]?a[4]:0;if(a[7]){var d=parseInt(a[4],10);if(a[7].toLowerCase().indexOf("p")!==-1){g=d<12?d+12:d}else{if(a[7].toLowerCase().indexOf("a")!==-1){g=d<12?d:0}}}var f=a[5]?a[5]:0;var c=a[6]?a[6]:0;return new Date(h,e,b,g,f,c,0).valueOf()}}),new TableKit.Sortable.Type("date-us",{pattern:/^\d{2}\/\d{2}\/\d{4}\s?(?:\d{1,2}\:\d{2}(?:\:\d{2})?\s?[a|p]?m?)?/i,normal:function(j){if(!this.pattern.test(j)){return 0}var a=j.match(/^(\d{2})\/(\d{2})\/(\d{4})\s?(?:(\d{1,2})\:(\d{2})(?:\:(\d{2}))?\s?([a|p]?m?))?/i);var h=a[3];var e=parseInt(a[1],10)-1;var b=a[2];var g=a[4]?a[4]:0;if(a[7]){var d=parseInt(a[4],10);if(a[7].toLowerCase().indexOf("p")!==-1){g=d<12?d+12:d}else{if(a[7].toLowerCase().indexOf("a")!==-1){g=d<12?d:0}}}var f=a[5]?a[5]:0;var c=a[6]?a[6]:0;return new Date(h,e,b,g,f,c,0).valueOf()}}),new TableKit.Sortable.Type("date-eu",{pattern:/^\d{2}-\d{2}-\d{4}/i,normal:function(b){if(!this.pattern.test(b)){return 0}var d=b.match(/^(\d{2})-(\d{2})-(\d{4})/);var e=d[3];var a=parseInt(d[2],10)-1;var c=d[1];return new Date(e,a,c).valueOf()}}),new TableKit.Sortable.Type("date-iso",{pattern:/[\d]{4}-[\d]{2}-[\d]{2}(?:T[\d]{2}\:[\d]{2}(?:\:[\d]{2}(?:\.[\d]+)?)?(Z|([-+][\d]{2}:[\d]{2})?)?)?/,normal:function(a){if(!this.pattern.test(a)){return 0}var f=a.match(/([\d]{4})(-([\d]{2})(-([\d]{2})(T([\d]{2}):([\d]{2})(:([\d]{2})(\.([\d]+))?)?(Z|(([-+])([\d]{2}):([\d]{2})))?)?)?)?/);var e=0;var b=new Date(f[1],0,1);if(f[3]){b.setMonth(f[3]-1)}if(f[5]){b.setDate(f[5])}if(f[7]){b.setHours(f[7])}if(f[8]){b.setMinutes(f[8])}if(f[10]){b.setSeconds(f[10])}if(f[12]){b.setMilliseconds(Number("0."+f[12])*1000)}if(f[14]){e=(Number(f[16])*60)+Number(f[17]);e*=((f[15]==="-")?1:-1)}e-=b.getTimezoneOffset();if(e!==0){var c=(Number(b)+(e*60*1000));b.setTime(Number(c))}return b.valueOf()}}),new TableKit.Sortable.Type("date",{pattern:/^(?:sun|mon|tue|wed|thu|fri|sat)\,\s\d{1,2}\s(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s\d{4}(?:\s\d{2}\:\d{2}(?:\:\d{2})?(?:\sGMT(?:[+-]\d{4})?)?)?/i,compare:function(d,c){if(d&&c){return TableKit.Sortable.Type.compare(new Date(d),new Date(c))}else{return TableKit.Sortable.Type.compare(d?1:0,c?1:0)}}}),new TableKit.Sortable.Type("time",{pattern:/^\d{1,2}\:\d{2}(?:\:\d{2})?(?:\s[a|p]m)?$/i,compare:function(e,c){var g=new Date();var f=g.getMonth()+"/"+g.getDate()+"/"+g.getFullYear()+" ";return TableKit.Sortable.Type.compare(new Date(f+e),new Date(f+c))}}),new TableKit.Sortable.Type("currency",{pattern:/^[$����]/,normal:function(a){return a?parseFloat(a.replace(/[^-\d\.]/g,"")):0}}));TableKit.Resizable={init:function(d,b){var c=$(d);if(c.tagName!=="TABLE"){return}TableKit.register(c,Object.extend(b||{},{resizable:true}));var a=TableKit.getHeaderCells(c);a.each(function(e){e=$(e);Event.observe(e,"mouseover",TableKit.Resizable.initDetect);Event.observe(e,"mouseout",TableKit.Resizable.killDetect)})},resize:function(d,c,b){var a;if(typeof c==="number"){if(!d||(d.tagName&&d.tagName!=="TABLE")){return}d=$(d);c=Math.min(d.rows[0].cells.length,c);c=Math.max(1,c);c-=1;a=(d.tHead&&d.tHead.rows.length>0)?$(d.tHead.rows[d.tHead.rows.length-1].cells[c]):$(d.rows[0].cells[c])}else{a=$(c);d=d?$(d):a.up("table");c=TableKit.getCellIndex(a)}var e=parseInt(a.getStyle("paddingLeft"),10)+parseInt(a.getStyle("paddingRight"),10);b=Math.max(b-e,TableKit.option("minWidth",d.id)[0]);a.setStyle({width:b+"px"})},initDetect:function(b){b=TableKit.e(b);var a=Event.element(b);Event.observe(a,"mousemove",TableKit.Resizable.detectHandle);Event.observe(a,"mousedown",TableKit.Resizable.startResize)},detectHandle:function(b){b=TableKit.e(b);var a=Event.element(b);if(TableKit.Resizable.pointerPos(a,Event.pointerX(b),Event.pointerY(b))){a.addClassName(TableKit.option("resizeOnHandleClass",a.up("table").id)[0]);TableKit.Resizable._onHandle=true}else{a.removeClassName(TableKit.option("resizeOnHandleClass",a.up("table").id)[0]);TableKit.Resizable._onHandle=false}},killDetect:function(b){b=TableKit.e(b);TableKit.Resizable._onHandle=false;var a=Event.element(b);Event.stopObserving(a,"mousemove",TableKit.Resizable.detectHandle);Event.stopObserving(a,"mousedown",TableKit.Resizable.startResize);a.removeClassName(TableKit.option("resizeOnHandleClass",a.up("table").id)[0])},startResize:function(c){c=TableKit.e(c);if(!TableKit.Resizable._onHandle){return}var a=Event.element(c);Event.stopObserving(a,"mousemove",TableKit.Resizable.detectHandle);Event.stopObserving(a,"mousedown",TableKit.Resizable.startResize);Event.stopObserving(a,"mouseout",TableKit.Resizable.killDetect);TableKit.Resizable._cell=a;var b=a.up("table");TableKit.Resizable._tbl=b;if(TableKit.option("showHandle",b.id)[0]){TableKit.Resizable._handle=$(document.createElement("div")).addClassName("resize-handle").setStyle({top:a.cumulativeOffset()[1]+"px",left:Event.pointerX(c)+"px",height:b.getDimensions().height+"px"});document.body.appendChild(TableKit.Resizable._handle)}Event.observe(document,"mousemove",TableKit.Resizable.drag);Event.observe(document,"mouseup",TableKit.Resizable.endResize);Event.stop(c)},endResize:function(b){b=TableKit.e(b);var a=TableKit.Resizable._cell;TableKit.Resizable.resize(null,a,(Event.pointerX(b)-a.cumulativeOffset()[0]));Event.stopObserving(document,"mousemove",TableKit.Resizable.drag);Event.stopObserving(document,"mouseup",TableKit.Resizable.endResize);if(TableKit.option("showHandle",TableKit.Resizable._tbl.id)[0]){$$("div.resize-handle").each(function(c){document.body.removeChild(c)})}Event.observe(a,"mouseout",TableKit.Resizable.killDetect);TableKit.Resizable._tbl=TableKit.Resizable._handle=TableKit.Resizable._cell=null;Event.stop(b)},drag:function(a){a=TableKit.e(a);if(TableKit.Resizable._handle===null){try{TableKit.Resizable.resize(TableKit.Resizable._tbl,TableKit.Resizable._cell,(Event.pointerX(a)-TableKit.Resizable._cell.cumulativeOffset()[0]))}catch(a){}}else{TableKit.Resizable._handle.setStyle({left:Event.pointerX(a)+"px"})}return false},pointerPos:function(b,a,d){var c=$(b).cumulativeOffset();return(d>=c[1]&&d<c[1]+b.offsetHeight&&a>=c[0]+b.offsetWidth-5&&a<c[0]+b.offsetWidth)},_onHandle:false,_cell:null,_tbl:null,_handle:null};TableKit.Editable={init:function(c,a){var b=$(c);if(b.tagName!=="TABLE"){return}TableKit.register(b,Object.extend(a||{},{editable:true}));Event.observe(b.tBodies[0],"click",TableKit.Editable._editCell)},_editCell:function(b){b=TableKit.e(b);var a=Event.findElement(b,"td");if(a){TableKit.Editable.editCell(null,a,null,b)}else{return false}},editCell:function(h,d,j,a){var g,k;if(typeof d==="number"){if(!h||(h.tagName&&h.tagName!=="TABLE")){return}h=$(h);d=Math.min(h.tBodies[0].rows.length,d);d=Math.max(1,d);d-=1;j=Math.min(h.rows[0].cells.length,j);j=Math.max(1,j);j-=1;k=$(h.tBodies[0].rows[d]);g=$(k.cells[j])}else{g=$(a?Event.findElement(a,"td"):d);h=(h&&h.tagName&&h.tagName!=="TABLE")?$(h):g.up("table");k=g.up("tr")}var c=TableKit.option("noEditClass",h.id);if(g.hasClassName(c.noEditClass)){return}var e=$(TableKit.getHeaderCells(h,g)[TableKit.getCellIndex(g)]);if(e.hasClassName(c.noEditClass)){return}var b=TableKit.getCellData(g);if(b.active){return}b.htmlContent=g.innerHTML;var f=TableKit.Editable.getCellEditor(null,null,e);f.edit(g,a);b.active=true},getCellEditor:function(a,d,c){var c=c?c:$(TableKit.getHeaderCells(d,a)[TableKit.getCellIndex(a)]);var b=TableKit.Editable.types["text-input"];if(c.id&&TableKit.Editable.types[c.id]){b=TableKit.Editable.types[c.id]}else{var e=$w(c.className).detect(function(f){return(TableKit.Editable.types[f])?true:false});b=e?TableKit.Editable.types[e]:b}return b},types:{},addCellEditor:function(a){if(a&&a.name){TableKit.Editable.types[a.name]=a}}};TableKit.Editable.CellEditor=Class.create();TableKit.Editable.CellEditor.prototype={initialize:function(b,a){this.name=b;this.options=Object.extend({element:"input",attributes:{name:"value",type:"text"},selectOptions:[],showSubmit:true,submitText:"OK",showCancel:true,cancelText:"Cancel",ajaxURI:null,ajaxOptions:null},a||{})},edit:function(b){b=$(b);var h=this.options;var e=b.up("table");var d=$(document.createElement("form"));d.id=b.id+"-form";d.addClassName(TableKit.option("formClassName",e.id)[0]);d.onsubmit=this._submit.bindAsEventListener(this);var f=document.createElement(h.element);$H(h.attributes).each(function(j){f[j.key]=j.value});switch(h.element){case"input":case"textarea":f.value=TableKit.getCellText(b);break;case"select":var a=TableKit.getCellText(b);$A(h.selectOptions).each(function(j){f.options[f.options.length]=new Option(j[0],j[1]);if(a===j[1]){f.options[f.options.length-1].selected="selected"}});break}d.appendChild(f);if(h.element==="textarea"){d.appendChild(document.createElement("br"))}if(h.showSubmit){var g=document.createElement("input");g.type="submit";g.value=h.submitText;g.className="editor_ok_button";d.appendChild(g)}if(h.showCancel){var c=document.createElement("a");c.href="#";c.appendChild(document.createTextNode(h.cancelText));c.onclick=this._cancel.bindAsEventListener(this);c.className="editor_cancel";d.appendChild(c)}b.innerHTML="";b.appendChild(d)},_submit:function(c){var a=Event.findElement(c,"td");var b=Event.findElement(c,"form");Event.stop(c);this.submit(a,b)},submit:function(a,e){var g=this.options;e=e?e:a.down("form");var b=$(TableKit.getHeaderCells(null,a)[TableKit.getCellIndex(a)]);var f=a.up("tr");var d=a.up("table");var c="&row="+(TableKit.getRowIndex(f)+1)+"&cell="+(TableKit.getCellIndex(a)+1)+"&id="+f.id+"&field="+b.id+"&"+Form.serialize(e);this.ajax=new Ajax.Updater(a,g.ajaxURI||TableKit.option("editAjaxURI",d.id)[0],Object.extend(g.ajaxOptions||TableKit.option("editAjaxOptions",d.id)[0],{postBody:c,onComplete:function(){var h=TableKit.getCellData(a);h.active=false;h.refresh=true}}))},_cancel:function(b){var a=Event.findElement(b,"td");Event.stop(b);this.cancel(a)},cancel:function(a){this.ajax=null;var b=TableKit.getCellData(a);a.innerHTML=b.htmlContent;b.htmlContent="";b.active=false},ajax:null};TableKit.Editable.textInput=function(b,a){TableKit.Editable.addCellEditor(new TableKit.Editable.CellEditor(b,{element:"input",attributes:Object.extend({name:"value",type:"text"},a||{})}))};TableKit.Editable.textInput("text-input");TableKit.Editable.multiLineInput=function(b,a){TableKit.Editable.addCellEditor(new TableKit.Editable.CellEditor(b,{element:"textarea",attributes:Object.extend({name:"value",rows:"5",cols:"20"},a||{})}))};TableKit.Editable.multiLineInput("multi-line-input");TableKit.Editable.selectInput=function(c,b,a){TableKit.Editable.addCellEditor(new TableKit.Editable.CellEditor(c,{element:"select",attributes:Object.extend({name:"value"},b||{}),selectOptions:a}))};document.observe("dom:loaded",TableKit.load);LightboxOptions=Object.extend({fileLoadingImage:"images/loading.gif",fileBottomNavCloseImage:"images/closelabel.gif",overlayOpacity:0.8,animate:true,resizeSpeed:7,borderSize:10,labelImage:"Image",labelOf:"of"},window.LightboxOptions||{});var Lightbox=Class.create();Lightbox.prototype={imageArray:[],activeImage:undefined,initialize:function(){this.updateImageList();this.keyboardAction=this.keyboardAction.bindAsEventListener(this);if(LightboxOptions.resizeSpeed>10){LightboxOptions.resizeSpeed=10}if(LightboxOptions.resizeSpeed<1){LightboxOptions.resizeSpeed=1}this.resizeDuration=LightboxOptions.animate?((11-LightboxOptions.resizeSpeed)*0.15):0;this.overlayDuration=LightboxOptions.animate?0.2:0;var b=(LightboxOptions.animate?250:1)+"px";var a=$$("body")[0];a.appendChild(Builder.node("div",{id:"overlay"}));a.appendChild(Builder.node("div",{id:"lightbox"},[Builder.node("div",{id:"outerImageContainer"},Builder.node("div",{id:"imageContainer"},[Builder.node("img",{id:"lightboxImage"}),Builder.node("div",{id:"hoverNav"},[Builder.node("a",{id:"prevLink",href:"#"}),Builder.node("a",{id:"nextLink",href:"#"})]),Builder.node("div",{id:"loading"},Builder.node("a",{id:"loadingLink",href:"#"},Builder.node("img",{src:LightboxOptions.fileLoadingImage})))])),Builder.node("div",{id:"imageDataContainer"},Builder.node("div",{id:"imageData"},[Builder.node("div",{id:"imageDetails"},[Builder.node("span",{id:"caption"}),Builder.node("span",{id:"numberDisplay"})]),Builder.node("div",{id:"bottomNav"},Builder.node("a",{id:"bottomNavClose",href:"#"},Builder.node("img",{src:LightboxOptions.fileBottomNavCloseImage})))]))]));$("overlay").hide().observe("click",(function(){this.end()}).bind(this));$("lightbox").hide().observe("click",(function(d){if(d.element().id=="lightbox"){this.end()}}).bind(this));$("outerImageContainer").setStyle({width:b,height:b});$("prevLink").observe("click",(function(d){d.stop();this.changeImage(this.activeImage-1)}).bindAsEventListener(this));$("nextLink").observe("click",(function(d){d.stop();this.changeImage(this.activeImage+1)}).bindAsEventListener(this));$("loadingLink").observe("click",(function(d){d.stop();this.end()}).bind(this));$("bottomNavClose").observe("click",(function(d){d.stop();this.end()}).bind(this));var c=this;(function(){var d="overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose";$w(d).each(function(e){c[e]=$(e)})}).defer()},updateImageList:function(){this.updateImageList=Prototype.emptyFunction;document.observe("click",(function(a){var b=a.findElement("a[rel^=lightbox]")||a.findElement("area[rel^=lightbox]");if(b){a.stop();this.start(b)}}).bind(this))},start:function(f){$$("select","object","embed").each(function(g){g.style.visibility="hidden"});var c=this.getPageSize();$("overlay").setStyle({width:c[0]+"px",height:c[1]+"px"});new Effect.Appear(this.overlay,{duration:this.overlayDuration,from:0,to:LightboxOptions.overlayOpacity});this.imageArray=[];var b=0;if((f.rel=="lightbox")){this.imageArray.push([f.href,f.title])}else{this.imageArray=$$(f.tagName+'[href][rel="'+f.rel+'"]').collect(function(g){return[g.href,g.title]}).uniq();while(this.imageArray[b][0]!=f.href){b++}}var a=document.viewport.getScrollOffsets();var e=a[1]+(document.viewport.getHeight()/10);var d=a[0];this.lightbox.setStyle({top:e+"px",left:d+"px"}).show();this.changeImage(b)},changeImage:function(b){this.activeImage=b;if(LightboxOptions.animate){this.loading.show()}this.lightboxImage.hide();this.hoverNav.hide();this.prevLink.hide();this.nextLink.hide();this.imageDataContainer.setStyle({opacity:0.0001});this.numberDisplay.hide();var a=new Image();a.onload=(function(){this.lightboxImage.src=this.imageArray[this.activeImage][0];this.resizeImageContainer(a.width,a.height)}).bind(this);a.src=this.imageArray[this.activeImage][0]},resizeImageContainer:function(e,f){var h=this.outerImageContainer.getWidth();var c=this.outerImageContainer.getHeight();var g=(e+LightboxOptions.borderSize*2);var k=(f+LightboxOptions.borderSize*2);var l=(g/h)*100;var b=(k/c)*100;var j=h-g;var a=c-k;if(a!=0){new Effect.Scale(this.outerImageContainer,b,{scaleX:false,duration:this.resizeDuration,queue:"front"})}if(j!=0){new Effect.Scale(this.outerImageContainer,l,{scaleY:false,duration:this.resizeDuration,delay:this.resizeDuration})}var d=0;if((a==0)&&(j==0)){d=100;if(Prototype.Browser.IE){d=250}}(function(){this.prevLink.setStyle({height:f+"px"});this.nextLink.setStyle({height:f+"px"});this.imageDataContainer.setStyle({width:g+"px"});this.showImage()}).bind(this).delay(d/1000)},showImage:function(){this.loading.hide();new Effect.Appear(this.lightboxImage,{duration:this.resizeDuration,queue:"end",afterFinish:(function(){this.updateDetails()}).bind(this)});this.preloadNeighborImages()},updateDetails:function(){if(this.imageArray[this.activeImage][1]!=""){this.caption.update(this.imageArray[this.activeImage][1]).show()}if(this.imageArray.length>1){this.numberDisplay.update(LightboxOptions.labelImage+" "+(this.activeImage+1)+" "+LightboxOptions.labelOf+"  "+this.imageArray.length).show()}new Effect.Parallel([new Effect.SlideDown(this.imageDataContainer,{sync:true,duration:this.resizeDuration,from:0,to:1}),new Effect.Appear(this.imageDataContainer,{sync:true,duration:this.resizeDuration})],{duration:this.resizeDuration,afterFinish:(function(){var a=this.getPageSize();this.overlay.setStyle({height:a[1]+"px"});this.updateNav()}).bind(this)})},updateNav:function(){this.hoverNav.show();if(this.activeImage>0){this.prevLink.show()}if(this.activeImage<(this.imageArray.length-1)){this.nextLink.show()}this.enableKeyboardNav()},enableKeyboardNav:function(){document.observe("keydown",this.keyboardAction)},disableKeyboardNav:function(){document.stopObserving("keydown",this.keyboardAction)},keyboardAction:function(d){var a=d.keyCode;var b;if(d.DOM_VK_ESCAPE){b=d.DOM_VK_ESCAPE}else{b=27}var c=String.fromCharCode(a).toLowerCase();if(c.match(/x|o|c/)||(a==b)){this.end()}else{if((c=="p")||(a==37)){if(this.activeImage!=0){this.disableKeyboardNav();this.changeImage(this.activeImage-1)}}else{if((c=="n")||(a==39)){if(this.activeImage!=(this.imageArray.length-1)){this.disableKeyboardNav();this.changeImage(this.activeImage+1)}}}}},preloadNeighborImages:function(){var a,b;if(this.imageArray.length>this.activeImage+1){a=new Image();a.src=this.imageArray[this.activeImage+1][0]}if(this.activeImage>0){b=new Image();b.src=this.imageArray[this.activeImage-1][0]}},end:function(){this.disableKeyboardNav();this.lightbox.hide();new Effect.Fade(this.overlay,{duration:this.overlayDuration});$$("select","object","embed").each(function(a){a.style.visibility="visible"})},getPageSize:function(){var c,a;if(window.innerHeight&&window.scrollMaxY){c=window.innerWidth+window.scrollMaxX;a=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){c=document.body.scrollWidth;a=document.body.scrollHeight}else{c=document.body.offsetWidth;a=document.body.offsetHeight}}var b,d;if(self.innerHeight){if(document.documentElement.clientWidth){b=document.documentElement.clientWidth}else{b=self.innerWidth}d=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){b=document.documentElement.clientWidth;d=document.documentElement.clientHeight}else{if(document.body){b=document.body.clientWidth;d=document.body.clientHeight}}}if(a<d){pageHeight=d}else{pageHeight=a}if(c<b){pageWidth=c}else{pageWidth=b}return[pageWidth,pageHeight]}};