var Prototype={Version:"1.5.1.1",Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:(document.createElement("div").__proto__!==document.createElement("form").__proto__)},ScriptFragment:"<script[^>]*>([\\S\\s]*?)</script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){
},K:function(x){
return x;
}};
var Class={create:function(){
return function(){
this.initialize.apply(this,arguments);
};
}};
var Abstract=new Object();
Object.extend=function(_2,_3){
for(var _4 in _3){
_2[_4]=_3[_4];
}
return _2;
};
Object.extend(Object,{inspect:function(_5){
try{
if(_5===undefined){
return "undefined";
}
if(_5===null){
return "null";
}
return _5.inspect?_5.inspect():_5.toString();
}
catch(e){
if(e instanceof RangeError){
return "...";
}
throw e;
}
},toJSON:function(_6){
var _7=typeof _6;
switch(_7){
case "undefined":
case "function":
case "unknown":
return;
case "boolean":
return _6.toString();
}
if(_6===null){
return "null";
}
if(_6.toJSON){
return _6.toJSON();
}
if(_6.ownerDocument===document){
return;
}
var _8=[];
for(var _9 in _6){
var _a=Object.toJSON(_6[_9]);
if(_a!==undefined){
_8.push(_9.toJSON()+": "+_a);
}
}
return "{"+_8.join(", ")+"}";
},keys:function(_b){
var _c=[];
for(var _d in _b){
_c.push(_d);
}
return _c;
},values:function(_e){
var _f=[];
for(var _10 in _e){
_f.push(_e[_10]);
}
return _f;
},clone:function(_11){
return Object.extend({},_11);
}});
Function.prototype.bind=function(){
var _12=this,args=$A(arguments),object=args.shift();
return function(){
return _12.apply(object,args.concat($A(arguments)));
};
};
Function.prototype.bindAsEventListener=function(_13){
var _14=this,args=$A(arguments),_13=args.shift();
return function(_15){
return _14.apply(_13,[_15||window.event].concat(args));
};
};
Object.extend(Number.prototype,{toColorPart:function(){
return this.toPaddedString(2,16);
},succ:function(){
return this+1;
},times:function(_16){
$R(0,this,true).each(_16);
return this;
},toPaddedString:function(_17,_18){
var _19=this.toString(_18||10);
return "0".times(_17-_19.length)+_19;
},toJSON:function(){
return isFinite(this)?this.toString():"null";
}});
Date.prototype.toJSON=function(){
return "\""+this.getFullYear()+"-"+(this.getMonth()+1).toPaddedString(2)+"-"+this.getDate().toPaddedString(2)+"T"+this.getHours().toPaddedString(2)+":"+this.getMinutes().toPaddedString(2)+":"+this.getSeconds().toPaddedString(2)+"\"";
};
var Try={these:function(){
var _1a;
for(var i=0,length=arguments.length;i<length;i++){
var _1c=arguments[i];
try{
_1a=_1c();
break;
}
catch(e){
}
}
return _1a;
}};
var PeriodicalExecuter=Class.create();
PeriodicalExecuter.prototype={initialize:function(_1d,_1e){
this.callback=_1d;
this.frequency=_1e;
this.currentlyExecuting=false;
this.registerCallback();
},registerCallback:function(){
this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},stop:function(){
if(!this.timer){
return;
}
clearInterval(this.timer);
this.timer=null;
},onTimerEvent:function(){
if(!this.currentlyExecuting){
try{
this.currentlyExecuting=true;
this.callback(this);
}
finally{
this.currentlyExecuting=false;
}
}
}};
Object.extend(String,{interpret:function(_1f){
return _1f==null?"":String(_1f);
},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});
Object.extend(String.prototype,{gsub:function(_20,_21){
var _22="",source=this,match;
_21=arguments.callee.prepareReplacement(_21);
while(source.length>0){
if(match=source.match(_20)){
_22+=source.slice(0,match.index);
_22+=String.interpret(_21(match));
source=source.slice(match.index+match[0].length);
}else{
_22+=source,source="";
}
}
return _22;
},sub:function(_23,_24,_25){
_24=this.gsub.prepareReplacement(_24);
_25=_25===undefined?1:_25;
return this.gsub(_23,function(_26){
if(--_25<0){
return _26[0];
}
return _24(_26);
});
},scan:function(_27,_28){
this.gsub(_27,_28);
return this;
},truncate:function(_29,_2a){
_29=_29||30;
_2a=_2a===undefined?"...":_2a;
return this.length>_29?this.slice(0,_29-_2a.length)+_2a: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 _2b=new RegExp(Prototype.ScriptFragment,"img");
var _2c=new RegExp(Prototype.ScriptFragment,"im");
return (this.match(_2b)||[]).map(function(_2d){
return (_2d.match(_2c)||["",""])[1];
});
},evalScripts:function(){
return this.extractScripts().map(function(_2e){
return eval(_2e);
});
},escapeHTML:function(){
var _2f=arguments.callee;
_2f.text.data=this;
return _2f.div.innerHTML;
},unescapeHTML:function(){
var div=document.createElement("div");
div.innerHTML=this.stripTags();
return div.childNodes[0]?(div.childNodes.length>1?$A(div.childNodes).inject("",function(_31,_32){
return _31+_32.nodeValue;
}):div.childNodes[0].nodeValue):"";
},toQueryParams:function(_33){
var _34=this.strip().match(/([^?#]*)(#.*)?$/);
if(!_34){
return {};
}
return _34[1].split(_33||"&").inject({},function(_35,_36){
if((_36=_36.split("="))[0]){
var key=decodeURIComponent(_36.shift());
var _38=_36.length>1?_36.join("="):_36[0];
if(_38!=undefined){
_38=decodeURIComponent(_38);
}
if(key in _35){
if(_35[key].constructor!=Array){
_35[key]=[_35[key]];
}
_35[key].push(_38);
}else{
_35[key]=_38;
}
}
return _35;
});
},toArray:function(){
return this.split("");
},succ:function(){
return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1);
},times:function(_39){
var _3a="";
for(var i=0;i<_39;i++){
_3a+=this;
}
return _3a;
},camelize:function(){
var _3c=this.split("-"),len=_3c.length;
if(len==1){
return _3c[0];
}
var _3d=this.charAt(0)=="-"?_3c[0].charAt(0).toUpperCase()+_3c[0].substring(1):_3c[0];
for(var i=1;i<len;i++){
_3d+=_3c[i].charAt(0).toUpperCase()+_3c[i].substring(1);
}
return _3d;
},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(_3f){
var _40=this.gsub(/[\x00-\x1f\\]/,function(_41){
var _42=String.specialChar[_41[0]];
return _42?_42:"\\u00"+_41[0].charCodeAt().toPaddedString(2,16);
});
if(_3f){
return "\""+_40.replace(/"/g,"\\\"")+"\"";
}
return "'"+_40.replace(/'/g,"\\'")+"'";
},toJSON:function(){
return this.inspect(true);
},unfilterJSON:function(_43){
return this.sub(_43||Prototype.JSONFilter,"#{1}");
},isJSON:function(){
var str=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");
return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
},evalJSON:function(_45){
var _46=this.unfilterJSON();
try{
if(!_45||_46.isJSON()){
return eval("("+_46+")");
}
}
catch(e){
}
throw new SyntaxError("Badly formed JSON string: "+this.inspect());
},include:function(_47){
return this.indexOf(_47)>-1;
},startsWith:function(_48){
return this.indexOf(_48)===0;
},endsWith:function(_49){
var d=this.length-_49.length;
return d>=0&&this.lastIndexOf(_49)===d;
},empty:function(){
return this=="";
},blank:function(){
return /^\s*$/.test(this);
}});
if(Prototype.Browser.WebKit||Prototype.Browser.IE){
Object.extend(String.prototype,{escapeHTML:function(){
return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
},unescapeHTML:function(){
return this.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");
}});
}
String.prototype.gsub.prepareReplacement=function(_4b){
if(typeof _4b=="function"){
return _4b;
}
var _4c=new Template(_4b);
return function(_4d){
return _4c.evaluate(_4d);
};
};
String.prototype.parseQuery=String.prototype.toQueryParams;
Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});
with(String.prototype.escapeHTML){
div.appendChild(text);
}
var Template=Class.create();
Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;
Template.prototype={initialize:function(_4e,_4f){
this.template=_4e.toString();
this.pattern=_4f||Template.Pattern;
},evaluate:function(_50){
return this.template.gsub(this.pattern,function(_51){
var _52=_51[1];
if(_52=="\\"){
return _51[2];
}
return _52+String.interpret(_50[_51[3]]);
});
}};
var $break={},$continue=new Error("\"throw $continue\" is deprecated, use \"return\" instead");
var Enumerable={each:function(_53){
var _54=0;
try{
this._each(function(_55){
_53(_55,_54++);
});
}
catch(e){
if(e!=$break){
throw e;
}
}
return this;
},eachSlice:function(_56,_57){
var _58=-_56,slices=[],array=this.toArray();
while((_58+=_56)<array.length){
slices.push(array.slice(_58,_58+_56));
}
return slices.map(_57);
},all:function(_59){
var _5a=true;
this.each(function(_5b,_5c){
_5a=_5a&&!!(_59||Prototype.K)(_5b,_5c);
if(!_5a){
throw $break;
}
});
return _5a;
},any:function(_5d){
var _5e=false;
this.each(function(_5f,_60){
if(_5e=!!(_5d||Prototype.K)(_5f,_60)){
throw $break;
}
});
return _5e;
},collect:function(_61){
var _62=[];
this.each(function(_63,_64){
_62.push((_61||Prototype.K)(_63,_64));
});
return _62;
},detect:function(_65){
var _66;
this.each(function(_67,_68){
if(_65(_67,_68)){
_66=_67;
throw $break;
}
});
return _66;
},findAll:function(_69){
var _6a=[];
this.each(function(_6b,_6c){
if(_69(_6b,_6c)){
_6a.push(_6b);
}
});
return _6a;
},grep:function(_6d,_6e){
var _6f=[];
this.each(function(_70,_71){
var _72=_70.toString();
if(_72.match(_6d)){
_6f.push((_6e||Prototype.K)(_70,_71));
}
});
return _6f;
},include:function(_73){
var _74=false;
this.each(function(_75){
if(_75==_73){
_74=true;
throw $break;
}
});
return _74;
},inGroupsOf:function(_76,_77){
_77=_77===undefined?null:_77;
return this.eachSlice(_76,function(_78){
while(_78.length<_76){
_78.push(_77);
}
return _78;
});
},inject:function(_79,_7a){
this.each(function(_7b,_7c){
_79=_7a(_79,_7b,_7c);
});
return _79;
},invoke:function(_7d){
var _7e=$A(arguments).slice(1);
return this.map(function(_7f){
return _7f[_7d].apply(_7f,_7e);
});
},max:function(_80){
var _81;
this.each(function(_82,_83){
_82=(_80||Prototype.K)(_82,_83);
if(_81==undefined||_82>=_81){
_81=_82;
}
});
return _81;
},min:function(_84){
var _85;
this.each(function(_86,_87){
_86=(_84||Prototype.K)(_86,_87);
if(_85==undefined||_86<_85){
_85=_86;
}
});
return _85;
},partition:function(_88){
var _89=[],falses=[];
this.each(function(_8a,_8b){
((_88||Prototype.K)(_8a,_8b)?_89:falses).push(_8a);
});
return [_89,falses];
},pluck:function(_8c){
var _8d=[];
this.each(function(_8e,_8f){
_8d.push(_8e[_8c]);
});
return _8d;
},reject:function(_90){
var _91=[];
this.each(function(_92,_93){
if(!_90(_92,_93)){
_91.push(_92);
}
});
return _91;
},sortBy:function(_94){
return this.map(function(_95,_96){
return {value:_95,criteria:_94(_95,_96)};
}).sort(function(_97,_98){
var a=_97.criteria,b=_98.criteria;
return a<b?-1:a>b?1:0;
}).pluck("value");
},toArray:function(){
return this.map();
},zip:function(){
var _9a=Prototype.K,args=$A(arguments);
if(typeof args.last()=="function"){
_9a=args.pop();
}
var _9b=[this].concat(args).map($A);
return this.map(function(_9c,_9d){
return _9a(_9b.pluck(_9d));
});
},size:function(){
return this.toArray().length;
},inspect:function(){
return "#<Enumerable:"+this.toArray().inspect()+">";
}};
Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray});
var $A=Array.from=function(_9e){
if(!_9e){
return [];
}
if(_9e.toArray){
return _9e.toArray();
}else{
var _9f=[];
for(var i=0,length=_9e.length;i<length;i++){
_9f.push(_9e[i]);
}
return _9f;
}
};
if(Prototype.Browser.WebKit){
$A=Array.from=function(_a1){
if(!_a1){
return [];
}
if(!(typeof _a1=="function"&&_a1=="[object NodeList]")&&_a1.toArray){
return _a1.toArray();
}else{
var _a2=[];
for(var i=0,length=_a1.length;i<length;i++){
_a2.push(_a1[i]);
}
return _a2;
}
};
}
Object.extend(Array.prototype,Enumerable);
if(!Array.prototype._reverse){
Array.prototype._reverse=Array.prototype.reverse;
}
Object.extend(Array.prototype,{_each:function(_a4){
for(var i=0,length=this.length;i<length;i++){
_a4(this[i]);
}
},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(_a6){
return _a6!=null;
});
},flatten:function(){
return this.inject([],function(_a7,_a8){
return _a7.concat(_a8&&_a8.constructor==Array?_a8.flatten():[_a8]);
});
},without:function(){
var _a9=$A(arguments);
return this.select(function(_aa){
return !_a9.include(_aa);
});
},indexOf:function(_ab){
for(var i=0,length=this.length;i<length;i++){
if(this[i]==_ab){
return i;
}
}
return -1;
},reverse:function(_ad){
return (_ad!==false?this:this.toArray())._reverse();
},reduce:function(){
return this.length>1?this:this[0];
},uniq:function(_ae){
return this.inject([],function(_af,_b0,_b1){
if(0==_b1||(_ae?_af.last()!=_b0:!_af.include(_b0))){
_af.push(_b0);
}
return _af;
});
},clone:function(){
return [].concat(this);
},size:function(){
return this.length;
},inspect:function(){
return "["+this.map(Object.inspect).join(", ")+"]";
},toJSON:function(){
var _b2=[];
this.each(function(_b3){
var _b4=Object.toJSON(_b3);
if(_b4!==undefined){
_b2.push(_b4);
}
});
return "["+_b2.join(", ")+"]";
}});
Array.prototype.toArray=Array.prototype.clone;
function $w(_b5){
_b5=_b5.strip();
return _b5?_b5.split(/\s+/):[];
}
if(Prototype.Browser.Opera){
Array.prototype.concat=function(){
var _b6=[];
for(var i=0,length=this.length;i<length;i++){
_b6.push(this[i]);
}
for(var i=0,length=arguments.length;i<length;i++){
if(arguments[i].constructor==Array){
for(var j=0,arrayLength=arguments[i].length;j<arrayLength;j++){
_b6.push(arguments[i][j]);
}
}else{
_b6.push(arguments[i]);
}
}
return _b6;
};
}
var Hash=function(_ba){
if(_ba instanceof Hash){
this.merge(_ba);
}else{
Object.extend(this,_ba||{});
}
};
Object.extend(Hash,{toQueryString:function(obj){
var _bc=[];
_bc.add=arguments.callee.addPair;
this.prototype._each.call(obj,function(_bd){
if(!_bd.key){
return;
}
var _be=_bd.value;
if(_be&&typeof _be=="object"){
if(_be.constructor==Array){
_be.each(function(_bf){
_bc.add(_bd.key,_bf);
});
}
return;
}
_bc.add(_bd.key,_be);
});
return _bc.join("&");
},toJSON:function(_c0){
var _c1=[];
this.prototype._each.call(_c0,function(_c2){
var _c3=Object.toJSON(_c2.value);
if(_c3!==undefined){
_c1.push(_c2.key.toJSON()+": "+_c3);
}
});
return "{"+_c1.join(", ")+"}";
}});
Hash.toQueryString.addPair=function(key,_c5,_c6){
key=encodeURIComponent(key);
if(_c5===undefined){
this.push(key);
}else{
this.push(key+"="+(_c5==null?"":encodeURIComponent(_c5)));
}
};
Object.extend(Hash.prototype,Enumerable);
Object.extend(Hash.prototype,{_each:function(_c7){
for(var key in this){
var _c9=this[key];
if(_c9&&_c9==Hash.prototype[key]){
continue;
}
var _ca=[key,_c9];
_ca.key=key;
_ca.value=_c9;
_c7(_ca);
}
},keys:function(){
return this.pluck("key");
},values:function(){
return this.pluck("value");
},merge:function(_cb){
return $H(_cb).inject(this,function(_cc,_cd){
_cc[_cd.key]=_cd.value;
return _cc;
});
},remove:function(){
var _ce;
for(var i=0,length=arguments.length;i<length;i++){
var _d0=this[arguments[i]];
if(_d0!==undefined){
if(_ce===undefined){
_ce=_d0;
}else{
if(_ce.constructor!=Array){
_ce=[_ce];
}
_ce.push(_d0);
}
}
delete this[arguments[i]];
}
return _ce;
},toQueryString:function(){
return Hash.toQueryString(this);
},inspect:function(){
return "#<Hash:{"+this.map(function(_d1){
return _d1.map(Object.inspect).join(": ");
}).join(", ")+"}>";
},toJSON:function(){
return Hash.toJSON(this);
}});
function $H(_d2){
if(_d2 instanceof Hash){
return _d2;
}
return new Hash(_d2);
}
if(function(){
var i=0,Test=function(_d4){
this.key=_d4;
};
Test.prototype.key="foo";
for(var _d5 in new Test("bar")){
i++;
}
return i>1;
}()){
Hash.prototype._each=function(_d6){
var _d7=[];
for(var key in this){
var _d9=this[key];
if((_d9&&_d9==Hash.prototype[key])||_d7.include(key)){
continue;
}
_d7.push(key);
var _da=[key,_d9];
_da.key=key;
_da.value=_d9;
_d6(_da);
}
};
}
ObjectRange=Class.create();
Object.extend(ObjectRange.prototype,Enumerable);
Object.extend(ObjectRange.prototype,{initialize:function(_db,end,_dd){
this.start=_db;
this.end=end;
this.exclusive=_dd;
},_each:function(_de){
var _df=this.start;
while(this.include(_df)){
_de(_df);
_df=_df.succ();
}
},include:function(_e0){
if(_e0<this.start){
return false;
}
if(this.exclusive){
return _e0<this.end;
}
return _e0<=this.end;
}});
var $R=function(_e1,end,_e3){
return new ObjectRange(_e1,end,_e3);
};
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(_e4){
this.responders._each(_e4);
},register:function(_e5){
if(!this.include(_e5)){
this.responders.push(_e5);
}
},unregister:function(_e6){
this.responders=this.responders.without(_e6);
},dispatch:function(_e7,_e8,_e9,_ea){
this.each(function(_eb){
if(typeof _eb[_e7]=="function"){
try{
_eb[_e7].apply(_eb,[_e8,_e9,_ea]);
}
catch(e){
}
}
});
}};
Object.extend(Ajax.Responders,Enumerable);
Ajax.Responders.register({onCreate:function(){
Ajax.activeRequestCount++;
},onComplete:function(){
Ajax.activeRequestCount--;
}});
Ajax.Base=function(){
};
Ajax.Base.prototype={setOptions:function(_ec){
this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:""};
Object.extend(this.options,_ec||{});
this.options.method=this.options.method.toLowerCase();
if(typeof this.options.parameters=="string"){
this.options.parameters=this.options.parameters.toQueryParams();
}
}};
Ajax.Request=Class.create();
Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];
Ajax.Request.prototype=Object.extend(new Ajax.Base(),{_complete:false,initialize:function(url,_ee){
this.transport=Ajax.getTransport();
this.setOptions(_ee);
this.request(url);
},request:function(url){
this.url=url;
this.method=this.options.method;
var _f0=Object.clone(this.options.parameters);
if(!["get","post"].include(this.method)){
_f0["_method"]=this.method;
this.method="post";
}
this.parameters=_f0;
if(_f0=Hash.toQueryString(_f0)){
if(this.method=="get"){
this.url+=(this.url.include("?")?"&":"?")+_f0;
}else{
if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
_f0+="&_=";
}
}
}
try{
if(this.options.onCreate){
this.options.onCreate(this.transport);
}
Ajax.Responders.dispatch("onCreate",this,this.transport);
this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);
if(this.options.asynchronous){
setTimeout(function(){
this.respondToReadyState(1);
}.bind(this),10);
}
this.transport.onreadystatechange=this.onStateChange.bind(this);
this.setRequestHeaders();
this.body=this.method=="post"?(this.options.postBody||_f0):null;
this.transport.send(this.body);
if(!this.options.asynchronous&&this.transport.overrideMimeType){
this.onStateChange();
}
}
catch(e){
this.dispatchException(e);
}
},onStateChange:function(){
var _f1=this.transport.readyState;
if(_f1>1&&!((_f1==4)&&this._complete)){
this.respondToReadyState(this.transport.readyState);
}
},setRequestHeaders:function(){
var _f2={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,"Accept":"text/javascript, text/html, application/xml, text/xml, */*"};
if(this.method=="post"){
_f2["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){
_f2["Connection"]="close";
}
}
if(typeof this.options.requestHeaders=="object"){
var _f3=this.options.requestHeaders;
if(typeof _f3.push=="function"){
for(var i=0,length=_f3.length;i<length;i+=2){
_f2[_f3[i]]=_f3[i+1];
}
}else{
$H(_f3).each(function(_f5){
_f2[_f5.key]=_f5.value;
});
}
}
for(var _f6 in _f2){
this.transport.setRequestHeader(_f6,_f2[_f6]);
}
},success:function(){
return !this.transport.status||(this.transport.status>=200&&this.transport.status<300);
},respondToReadyState:function(_f7){
var _f8=Ajax.Request.Events[_f7];
var _f9=this.transport,json=this.evalJSON();
if(_f8=="Complete"){
try{
this._complete=true;
(this.options["on"+this.transport.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(_f9,json);
}
catch(e){
this.dispatchException(e);
}
var _fa=this.getHeader("Content-type");
if(_fa&&_fa.strip().match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)){
this.evalResponse();
}
}
try{
(this.options["on"+_f8]||Prototype.emptyFunction)(_f9,json);
Ajax.Responders.dispatch("on"+_f8,this,_f9,json);
}
catch(e){
this.dispatchException(e);
}
if(_f8=="Complete"){
this.transport.onreadystatechange=Prototype.emptyFunction;
}
},getHeader:function(_fb){
try{
return this.transport.getResponseHeader(_fb);
}
catch(e){
return null;
}
},evalJSON:function(){
try{
var _fc=this.getHeader("X-JSON");
return _fc?_fc.evalJSON():null;
}
catch(e){
return null;
}
},evalResponse:function(){
try{
return eval((this.transport.responseText||"").unfilterJSON());
}
catch(e){
this.dispatchException(e);
}
},dispatchException:function(_fd){
(this.options.onException||Prototype.emptyFunction)(this,_fd);
Ajax.Responders.dispatch("onException",this,_fd);
}});
Ajax.Updater=Class.create();
Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(_fe,url,_100){
this.container={success:(_fe.success||_fe),failure:(_fe.failure||(_fe.success?null:_fe))};
this.transport=Ajax.getTransport();
this.setOptions(_100);
var _101=this.options.onComplete||Prototype.emptyFunction;
this.options.onComplete=(function(_102,_103){
this.updateContent();
_101(_102,_103);
}).bind(this);
this.request(url);
},updateContent:function(){
var _104=this.container[this.success()?"success":"failure"];
var _105=this.transport.responseText;
if(!this.options.evalScripts){
_105=_105.stripScripts();
}
if(_104=$(_104)){
if(this.options.insertion){
new this.options.insertion(_104,_105);
}else{
_104.update(_105);
}
}
if(this.success()){
if(this.onComplete){
setTimeout(this.onComplete.bind(this),10);
}
}
}});
Ajax.PeriodicalUpdater=Class.create();
Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(_106,url,_108){
this.setOptions(_108);
this.onComplete=this.options.onComplete;
this.frequency=(this.options.frequency||2);
this.decay=(this.options.decay||1);
this.updater={};
this.container=_106;
this.url=url;
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(_109){
if(this.options.decay){
this.decay=(_109.responseText==this.lastText?this.decay*this.options.decay:1);
this.lastText=_109.responseText;
}
this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);
},onTimerEvent:function(){
this.updater=new Ajax.Updater(this.container,this.url,this.options);
}});
function $(_10a){
if(arguments.length>1){
for(var i=0,elements=[],length=arguments.length;i<length;i++){
elements.push($(arguments[i]));
}
return elements;
}
if(typeof _10a=="string"){
_10a=document.getElementById(_10a);
}
return Element.extend(_10a);
}
if(Prototype.BrowserFeatures.XPath){
document._getElementsByXPath=function(_10c,_10d){
var _10e=[];
var _10f=document.evaluate(_10c,$(_10d)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
for(var i=0,length=_10f.snapshotLength;i<length;i++){
_10e.push(_10f.snapshotItem(i));
}
return _10e;
};
document.getElementsByClassName=function(_111,_112){
var q=".//*[contains(concat(' ', @class, ' '), ' "+_111+" ')]";
return document._getElementsByXPath(q,_112);
};
}else{
document.getElementsByClassName=function(_114,_115){
var _116=($(_115)||document.body).getElementsByTagName("*");
var _117=[],child,pattern=new RegExp("(^|\\s)"+_114+"(\\s|$)");
for(var i=0,length=_116.length;i<length;i++){
child=_116[i];
var _119=child.className;
if(_119.length==0){
continue;
}
if(_119==_114||_119.match(pattern)){
_117.push(Element.extend(child));
}
}
return _117;
};
}
if(!window.Element){
var Element={};
}
Element.extend=function(_11a){
var F=Prototype.BrowserFeatures;
if(!_11a||!_11a.tagName||_11a.nodeType==3||_11a._extended||F.SpecificElementExtensions||_11a==window){
return _11a;
}
var _11c={},tagName=_11a.tagName,cache=Element.extend.cache,T=Element.Methods.ByTag;
if(!F.ElementExtensions){
Object.extend(_11c,Element.Methods),Object.extend(_11c,Element.Methods.Simulated);
}
if(T[tagName]){
Object.extend(_11c,T[tagName]);
}
for(var _11d in _11c){
var _11e=_11c[_11d];
if(typeof _11e=="function"&&!(_11d in _11a)){
_11a[_11d]=cache.findOrStore(_11e);
}
}
_11a._extended=Prototype.emptyFunction;
return _11a;
};
Element.extend.cache={findOrStore:function(_11f){
return this[_11f]=this[_11f]||function(){
return _11f.apply(null,[this].concat($A(arguments)));
};
}};
Element.Methods={visible:function(_120){
return $(_120).style.display!="none";
},toggle:function(_121){
_121=$(_121);
Element[Element.visible(_121)?"hide":"show"](_121);
return _121;
},hide:function(_122){
$(_122).style.display="none";
return _122;
},show:function(_123){
$(_123).style.display="";
return _123;
},remove:function(_124){
_124=$(_124);
_124.parentNode.removeChild(_124);
return _124;
},update:function(_125,html){
html=typeof html=="undefined"?"":html.toString();
$(_125).innerHTML=html.stripScripts();
setTimeout(function(){
html.evalScripts();
},10);
return _125;
},replace:function(_127,html){
_127=$(_127);
html=typeof html=="undefined"?"":html.toString();
if(_127.outerHTML){
_127.outerHTML=html.stripScripts();
}else{
var _129=_127.ownerDocument.createRange();
_129.selectNodeContents(_127);
_127.parentNode.replaceChild(_129.createContextualFragment(html.stripScripts()),_127);
}
setTimeout(function(){
html.evalScripts();
},10);
return _127;
},inspect:function(_12a){
_12a=$(_12a);
var _12b="<"+_12a.tagName.toLowerCase();
$H({"id":"id","className":"class"}).each(function(pair){
var _12d=pair.first(),attribute=pair.last();
var _12e=(_12a[_12d]||"").toString();
if(_12e){
_12b+=" "+attribute+"="+_12e.inspect(true);
}
});
return _12b+">";
},recursivelyCollect:function(_12f,_130){
_12f=$(_12f);
var _131=[];
while(_12f=_12f[_130]){
if(_12f.nodeType==1){
_131.push(Element.extend(_12f));
}
}
return _131;
},ancestors:function(_132){
return $(_132).recursivelyCollect("parentNode");
},descendants:function(_133){
return $A($(_133).getElementsByTagName("*")).each(Element.extend);
},firstDescendant:function(_134){
_134=$(_134).firstChild;
while(_134&&_134.nodeType!=1){
_134=_134.nextSibling;
}
return $(_134);
},immediateDescendants:function(_135){
if(!(_135=$(_135).firstChild)){
return [];
}
while(_135&&_135.nodeType!=1){
_135=_135.nextSibling;
}
if(_135){
return [_135].concat($(_135).nextSiblings());
}
return [];
},previousSiblings:function(_136){
return $(_136).recursivelyCollect("previousSibling");
},nextSiblings:function(_137){
return $(_137).recursivelyCollect("nextSibling");
},siblings:function(_138){
_138=$(_138);
return _138.previousSiblings().reverse().concat(_138.nextSiblings());
},match:function(_139,_13a){
if(typeof _13a=="string"){
_13a=new Selector(_13a);
}
return _13a.match($(_139));
},up:function(_13b,_13c,_13d){
_13b=$(_13b);
if(arguments.length==1){
return $(_13b.parentNode);
}
var _13e=_13b.ancestors();
return _13c?Selector.findElement(_13e,_13c,_13d):_13e[_13d||0];
},down:function(_13f,_140,_141){
_13f=$(_13f);
if(arguments.length==1){
return _13f.firstDescendant();
}
var _142=_13f.descendants();
return _140?Selector.findElement(_142,_140,_141):_142[_141||0];
},previous:function(_143,_144,_145){
_143=$(_143);
if(arguments.length==1){
return $(Selector.handlers.previousElementSibling(_143));
}
var _146=_143.previousSiblings();
return _144?Selector.findElement(_146,_144,_145):_146[_145||0];
},next:function(_147,_148,_149){
_147=$(_147);
if(arguments.length==1){
return $(Selector.handlers.nextElementSibling(_147));
}
var _14a=_147.nextSiblings();
return _148?Selector.findElement(_14a,_148,_149):_14a[_149||0];
},getElementsBySelector:function(){
var args=$A(arguments),element=$(args.shift());
return Selector.findChildElements(element,args);
},getElementsByClassName:function(_14c,_14d){
return document.getElementsByClassName(_14d,_14c);
},readAttribute:function(_14e,name){
_14e=$(_14e);
if(Prototype.Browser.IE){
if(!_14e.attributes){
return null;
}
var t=Element._attributeTranslations;
if(t.values[name]){
return t.values[name](_14e,name);
}
if(t.names[name]){
name=t.names[name];
}
var _151=_14e.attributes[name];
return _151?_151.nodeValue:null;
}
return _14e.getAttribute(name);
},getHeight:function(_152){
return $(_152).getDimensions().height;
},getWidth:function(_153){
return $(_153).getDimensions().width;
},classNames:function(_154){
return new Element.ClassNames(_154);
},hasClassName:function(_155,_156){
if(!(_155=$(_155))){
return;
}
var _157=_155.className;
if(_157.length==0){
return false;
}
if(_157==_156||_157.match(new RegExp("(^|\\s)"+_156+"(\\s|$)"))){
return true;
}
return false;
},addClassName:function(_158,_159){
if(!(_158=$(_158))){
return;
}
Element.classNames(_158).add(_159);
return _158;
},removeClassName:function(_15a,_15b){
if(!(_15a=$(_15a))){
return;
}
Element.classNames(_15a).remove(_15b);
return _15a;
},toggleClassName:function(_15c,_15d){
if(!(_15c=$(_15c))){
return;
}
Element.classNames(_15c)[_15c.hasClassName(_15d)?"remove":"add"](_15d);
return _15c;
},observe:function(){
Event.observe.apply(Event,arguments);
return $A(arguments).first();
},stopObserving:function(){
Event.stopObserving.apply(Event,arguments);
return $A(arguments).first();
},cleanWhitespace:function(_15e){
_15e=$(_15e);
var node=_15e.firstChild;
while(node){
var _160=node.nextSibling;
if(node.nodeType==3&&!/\S/.test(node.nodeValue)){
_15e.removeChild(node);
}
node=_160;
}
return _15e;
},empty:function(_161){
return $(_161).innerHTML.blank();
},descendantOf:function(_162,_163){
_162=$(_162),_163=$(_163);
while(_162=_162.parentNode){
if(_162==_163){
return true;
}
}
return false;
},scrollTo:function(_164){
_164=$(_164);
var pos=Position.cumulativeOffset(_164);
window.scrollTo(pos[0],pos[1]);
return _164;
},getStyle:function(_166,_167){
_166=$(_166);
_167=_167=="float"?"cssFloat":_167.camelize();
var _168=_166.style[_167];
if(!_168){
var css=document.defaultView.getComputedStyle(_166,null);
_168=css?css[_167]:null;
}
if(_167=="opacity"){
return _168?parseFloat(_168):1;
}
return _168=="auto"?null:_168;
},getOpacity:function(_16a){
return $(_16a).getStyle("opacity");
},setStyle:function(_16b,_16c,_16d){
_16b=$(_16b);
var _16e=_16b.style;
for(var _16f in _16c){
if(_16f=="opacity"){
_16b.setOpacity(_16c[_16f]);
}else{
_16e[(_16f=="float"||_16f=="cssFloat")?(_16e.styleFloat===undefined?"cssFloat":"styleFloat"):(_16d?_16f:_16f.camelize())]=_16c[_16f];
}
}
return _16b;
},setOpacity:function(_170,_171){
_170=$(_170);
_170.style.opacity=(_171==1||_171==="")?"":(_171<0.00001)?0:_171;
return _170;
},getDimensions:function(_172){
_172=$(_172);
var _173=$(_172).getStyle("display");
if(_173!="none"&&_173!=null){
return {width:_172.offsetWidth,height:_172.offsetHeight};
}
var els=_172.style;
var _175=els.visibility;
var _176=els.position;
var _177=els.display;
els.visibility="hidden";
els.position="absolute";
els.display="block";
var _178=_172.clientWidth;
var _179=_172.clientHeight;
els.display=_177;
els.position=_176;
els.visibility=_175;
return {width:_178,height:_179};
},makePositioned:function(_17a){
_17a=$(_17a);
var pos=Element.getStyle(_17a,"position");
if(pos=="static"||!pos){
_17a._madePositioned=true;
_17a.style.position="relative";
if(window.opera){
_17a.style.top=0;
_17a.style.left=0;
}
}
return _17a;
},undoPositioned:function(_17c){
_17c=$(_17c);
if(_17c._madePositioned){
_17c._madePositioned=undefined;
_17c.style.position=_17c.style.top=_17c.style.left=_17c.style.bottom=_17c.style.right="";
}
return _17c;
},makeClipping:function(_17d){
_17d=$(_17d);
if(_17d._overflow){
return _17d;
}
_17d._overflow=_17d.style.overflow||"auto";
if((Element.getStyle(_17d,"overflow")||"visible")!="hidden"){
_17d.style.overflow="hidden";
}
return _17d;
},undoClipping:function(_17e){
_17e=$(_17e);
if(!_17e._overflow){
return _17e;
}
_17e.style.overflow=_17e._overflow=="auto"?"":_17e._overflow;
_17e._overflow=null;
return _17e;
}};
Object.extend(Element.Methods,{childOf:Element.Methods.descendantOf,childElements:Element.Methods.immediateDescendants});
if(Prototype.Browser.Opera){
Element.Methods._getStyle=Element.Methods.getStyle;
Element.Methods.getStyle=function(_17f,_180){
switch(_180){
case "left":
case "top":
case "right":
case "bottom":
if(Element._getStyle(_17f,"position")=="static"){
return null;
}
default:
return Element._getStyle(_17f,_180);
}
};
}else{
if(Prototype.Browser.IE){
Element.Methods.getStyle=function(_181,_182){
_181=$(_181);
_182=(_182=="float"||_182=="cssFloat")?"styleFloat":_182.camelize();
var _183=_181.style[_182];
if(!_183&&_181.currentStyle){
_183=_181.currentStyle[_182];
}
if(_182=="opacity"){
if(_183=(_181.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){
if(_183[1]){
return parseFloat(_183[1])/100;
}
}
return 1;
}
if(_183=="auto"){
if((_182=="width"||_182=="height")&&(_181.getStyle("display")!="none")){
return _181["offset"+_182.capitalize()]+"px";
}
return null;
}
return _183;
};
Element.Methods.setOpacity=function(_184,_185){
_184=$(_184);
var _186=_184.getStyle("filter"),style=_184.style;
if(_185==1||_185===""){
style.filter=_186.replace(/alpha\([^\)]*\)/gi,"");
return _184;
}else{
if(_185<0.00001){
_185=0;
}
}
style.filter=_186.replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+(_185*100)+")";
return _184;
};
Element.Methods.update=function(_187,html){
_187=$(_187);
html=typeof html=="undefined"?"":html.toString();
var _189=_187.tagName.toUpperCase();
if(["THEAD","TBODY","TR","TD"].include(_189)){
var div=document.createElement("div");
switch(_189){
case "THEAD":
case "TBODY":
div.innerHTML="<table><tbody>"+html.stripScripts()+"</tbody></table>";
depth=2;
break;
case "TR":
div.innerHTML="<table><tbody><tr>"+html.stripScripts()+"</tr></tbody></table>";
depth=3;
break;
case "TD":
div.innerHTML="<table><tbody><tr><td>"+html.stripScripts()+"</td></tr></tbody></table>";
depth=4;
}
$A(_187.childNodes).each(function(node){
_187.removeChild(node);
});
depth.times(function(){
div=div.firstChild;
});
$A(div.childNodes).each(function(node){
_187.appendChild(node);
});
}else{
_187.innerHTML=html.stripScripts();
}
setTimeout(function(){
html.evalScripts();
},10);
return _187;
};
}else{
if(Prototype.Browser.Gecko){
Element.Methods.setOpacity=function(_18d,_18e){
_18d=$(_18d);
_18d.style.opacity=(_18e==1)?0.999999:(_18e==="")?"":(_18e<0.00001)?0:_18e;
return _18d;
};
}
}
}
Element._attributeTranslations={names:{colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",datetime:"dateTime",accesskey:"accessKey",tabindex:"tabIndex",enctype:"encType",maxlength:"maxLength",readonly:"readOnly",longdesc:"longDesc"},values:{_getAttr:function(_18f,_190){
return _18f.getAttribute(_190,2);
},_flag:function(_191,_192){
return $(_191).hasAttribute(_192)?_192:null;
},style:function(_193){
return _193.style.cssText.toLowerCase();
},title:function(_194){
var node=_194.getAttributeNode("title");
return node.specified?node.nodeValue:null;
}}};
(function(){
Object.extend(this,{href:this._getAttr,src:this._getAttr,type:this._getAttr,disabled:this._flag,checked:this._flag,readonly:this._flag,multiple:this._flag});
}).call(Element._attributeTranslations.values);
Element.Methods.Simulated={hasAttribute:function(_196,_197){
var t=Element._attributeTranslations,node;
_197=t.names[_197]||_197;
node=$(_196).getAttributeNode(_197);
return node&&node.specified;
}};
Element.Methods.ByTag={};
Object.extend(Element,Element.Methods);
if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div").__proto__){
window.HTMLElement={};
window.HTMLElement.prototype=document.createElement("div").__proto__;
Prototype.BrowserFeatures.ElementExtensions=true;
}
Element.hasAttribute=function(_199,_19a){
if(_199.hasAttribute){
return _199.hasAttribute(_19a);
}
return Element.Methods.Simulated.hasAttribute(_199,_19a);
};
Element.addMethods=function(_19b){
var F=Prototype.BrowserFeatures,T=Element.Methods.ByTag;
if(!_19b){
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 _19d=_19b;
_19b=arguments[1];
}
if(!_19d){
Object.extend(Element.Methods,_19b||{});
}else{
if(_19d.constructor==Array){
_19d.each(extend);
}else{
extend(_19d);
}
}
function extend(_19e){
_19e=_19e.toUpperCase();
if(!Element.Methods.ByTag[_19e]){
Element.Methods.ByTag[_19e]={};
}
Object.extend(Element.Methods.ByTag[_19e],_19b);
}
function copy(_19f,_1a0,_1a1){
_1a1=_1a1||false;
var _1a2=Element.extend.cache;
for(var _1a3 in _19f){
var _1a4=_19f[_1a3];
if(!_1a1||!(_1a3 in _1a0)){
_1a0[_1a3]=_1a2.findOrStore(_1a4);
}
}
}
function findDOMClass(_1a5){
var _1a6;
var _1a7={"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(_1a7[_1a5]){
_1a6="HTML"+_1a7[_1a5]+"Element";
}
if(window[_1a6]){
return window[_1a6];
}
_1a6="HTML"+_1a5+"Element";
if(window[_1a6]){
return window[_1a6];
}
_1a6="HTML"+_1a5.capitalize()+"Element";
if(window[_1a6]){
return window[_1a6];
}
window[_1a6]={};
window[_1a6].prototype=document.createElement(_1a5).__proto__;
return window[_1a6];
}
if(F.ElementExtensions){
copy(Element.Methods,HTMLElement.prototype);
copy(Element.Methods.Simulated,HTMLElement.prototype,true);
}
if(F.SpecificElementExtensions){
for(var tag in Element.Methods.ByTag){
var _1a9=findDOMClass(tag);
if(typeof _1a9=="undefined"){
continue;
}
copy(T[tag],_1a9.prototype);
}
}
Object.extend(Element,Element.Methods);
delete Element.ByTag;
};
var Toggle={display:Element.toggle};
Abstract.Insertion=function(_1aa){
this.adjacency=_1aa;
};
Abstract.Insertion.prototype={initialize:function(_1ab,_1ac){
this.element=$(_1ab);
this.content=_1ac.stripScripts();
if(this.adjacency&&this.element.insertAdjacentHTML){
try{
this.element.insertAdjacentHTML(this.adjacency,this.content);
}
catch(e){
var _1ad=this.element.tagName.toUpperCase();
if(["TBODY","TR"].include(_1ad)){
this.insertContent(this.contentFromAnonymousTable());
}else{
throw e;
}
}
}else{
this.range=this.element.ownerDocument.createRange();
if(this.initializeRange){
this.initializeRange();
}
this.insertContent([this.range.createContextualFragment(this.content)]);
}
setTimeout(function(){
_1ac.evalScripts();
},10);
},contentFromAnonymousTable:function(){
var div=document.createElement("div");
div.innerHTML="<table><tbody>"+this.content+"</tbody></table>";
return $A(div.childNodes[0].childNodes[0].childNodes);
}};
var Insertion=new Object();
Insertion.Before=Class.create();
Insertion.Before.prototype=Object.extend(new Abstract.Insertion("beforeBegin"),{initializeRange:function(){
this.range.setStartBefore(this.element);
},insertContent:function(_1af){
_1af.each((function(_1b0){
this.element.parentNode.insertBefore(_1b0,this.element);
}).bind(this));
}});
Insertion.Top=Class.create();
Insertion.Top.prototype=Object.extend(new Abstract.Insertion("afterBegin"),{initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(true);
},insertContent:function(_1b1){
_1b1.reverse(false).each((function(_1b2){
this.element.insertBefore(_1b2,this.element.firstChild);
}).bind(this));
}});
Insertion.Bottom=Class.create();
Insertion.Bottom.prototype=Object.extend(new Abstract.Insertion("beforeEnd"),{initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(this.element);
},insertContent:function(_1b3){
_1b3.each((function(_1b4){
this.element.appendChild(_1b4);
}).bind(this));
}});
Insertion.After=Class.create();
Insertion.After.prototype=Object.extend(new Abstract.Insertion("afterEnd"),{initializeRange:function(){
this.range.setStartAfter(this.element);
},insertContent:function(_1b5){
_1b5.each((function(_1b6){
this.element.parentNode.insertBefore(_1b6,this.element.nextSibling);
}).bind(this));
}});
Element.ClassNames=Class.create();
Element.ClassNames.prototype={initialize:function(_1b7){
this.element=$(_1b7);
},_each:function(_1b8){
this.element.className.split(/\s+/).select(function(name){
return name.length>0;
})._each(_1b8);
},set:function(_1ba){
this.element.className=_1ba;
},add:function(_1bb){
if(this.include(_1bb)){
return;
}
this.set($A(this).concat(_1bb).join(" "));
},remove:function(_1bc){
if(!this.include(_1bc)){
return;
}
this.set($A(this).without(_1bc).join(" "));
},toString:function(){
return $A(this).join(" ");
}};
Object.extend(Element.ClassNames.prototype,Enumerable);
var Selector=Class.create();
Selector.prototype={initialize:function(_1bd){
this.expression=_1bd.strip();
this.compileMatcher();
},compileMatcher:function(){
if(Prototype.BrowserFeatures.XPath&&!(/\[[\w-]*?:/).test(this.expression)){
return this.compileXPathMatcher();
}
var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;
if(Selector._cache[e]){
this.matcher=Selector._cache[e];
return;
}
this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in ps){
p=ps[i];
if(m=e.match(p)){
this.matcher.push(typeof c[i]=="function"?c[i](m):new Template(c[i]).evaluate(m));
e=e.replace(m[0],"");
break;
}
}
}
this.matcher.push("return h.unique(n);\n}");
eval(this.matcher.join("\n"));
Selector._cache[this.expression]=this.matcher;
},compileXPathMatcher:function(){
var e=this.expression,ps=Selector.patterns,x=Selector.xpath,le,m;
if(Selector._cache[e]){
this.xpath=Selector._cache[e];
return;
}
this.matcher=[".//*"];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in ps){
if(m=e.match(ps[i])){
this.matcher.push(typeof x[i]=="function"?x[i](m):new Template(x[i]).evaluate(m));
e=e.replace(m[0],"");
break;
}
}
}
this.xpath=this.matcher.join("");
Selector._cache[this.expression]=this.xpath;
},findElements:function(root){
root=root||document;
if(this.xpath){
return document._getElementsByXPath(this.xpath,root);
}
return this.matcher(root);
},match:function(_1c3){
return this.findElements(document).include(_1c3);
},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(m){
if(m[1]=="*"){
return "";
}
return "[local-name()='"+m[1].toLowerCase()+"' or local-name()='"+m[1].toUpperCase()+"']";
},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:"[@#{1}]",attr:function(m){
m[3]=m[5]||m[6];
return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
},pseudo:function(m){
var h=Selector.xpath.pseudos[m[1]];
if(!h){
return "";
}
if(typeof h==="function"){
return h(m);
}
return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]","empty":"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]","checked":"[@checked]","disabled":"[@disabled]","enabled":"[not(@disabled)]","not":function(m){
var e=m[6],p=Selector.patterns,x=Selector.xpath,le,m,v;
var _1ca=[];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in p){
if(m=e.match(p[i])){
v=typeof x[i]=="function"?x[i](m):new Template(x[i]).evaluate(m);
_1ca.push("("+v.substring(1,v.length-1)+")");
e=e.replace(m[0],"");
break;
}
}
}
return "[not("+_1ca.join(" and ")+")]";
},"nth-child":function(m){
return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",m);
},"nth-last-child":function(m){
return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",m);
},"nth-of-type":function(m){
return Selector.xpath.pseudos.nth("position() ",m);
},"nth-last-of-type":function(m){
return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",m);
},"first-of-type":function(m){
m[6]="1";
return Selector.xpath.pseudos["nth-of-type"](m);
},"last-of-type":function(m){
m[6]="1";
return Selector.xpath.pseudos["nth-last-of-type"](m);
},"only-of-type":function(m){
var p=Selector.xpath.pseudos;
return p["first-of-type"](m)+p["last-of-type"](m);
},nth:function(_1d4,m){
var mm,formula=m[6],predicate;
if(formula=="even"){
formula="2n+0";
}
if(formula=="odd"){
formula="2n+1";
}
if(mm=formula.match(/^(\d+)$/)){
return "["+_1d4+"= "+mm[1]+"]";
}
if(mm=formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){
if(mm[1]=="-"){
mm[1]=-1;
}
var a=mm[1]?Number(mm[1]):1;
var b=mm[2]?Number(mm[2]):0;
predicate="[((#{fragment} - #{b}) mod #{a} = 0) and "+"((#{fragment} - #{b}) div #{a} >= 0)]";
return new Template(predicate).evaluate({fragment:_1d4,a:a,b:b});
}
}}},criteria:{tagName:"n = h.tagName(n, r, \"#{1}\", c);   c = false;",className:"n = h.className(n, r, \"#{1}\", c); c = false;",id:"n = h.id(n, r, \"#{1}\", c);        c = false;",attrPresence:"n = h.attrPresence(n, r, \"#{1}\"); c = false;",attr:function(m){
m[3]=(m[5]||m[6]);
return new Template("n = h.attr(n, r, \"#{1}\", \"#{3}\", \"#{2}\"); c = false;").evaluate(m);
},pseudo:function(m){
if(m[6]){
m[6]=m[6].replace(/"/g,"\\\"");
}
return new Template("n = h.pseudo(n, \"#{1}\", \"#{6}\", r, c); c = false;").evaluate(m);
// LORACO
//},descendant:"c = \"descendant\";",child:"c = \"child\";",adjacent:"c = \"adjacent\";",laterSibling:"c = \"laterSibling\";"},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/},handlers:{concat:function(a,b){
},descendant:"c = \"descendant\";",child:"c = \"child\";",adjacent:"c = \"adjacent\";",laterSibling:"c = \"laterSibling\";"},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((["])([^\]]*?)\4|([^"][^\]]*?)))?\]/},handlers:{concat:function(a,b){

for(var i=0,node;node=b[i];i++){
a.push(node);
}
return a;
},mark:function(_1de){
for(var i=0,node;node=_1de[i];i++){
node._counted=true;
}
return _1de;
},unmark:function(_1e0){
for(var i=0,node;node=_1e0[i];i++){
node._counted=undefined;
}
return _1e0;
},index:function(_1e2,_1e3,_1e4){
_1e2._counted=true;
if(_1e3){
for(var _1e5=_1e2.childNodes,i=_1e5.length-1,j=1;i>=0;i--){
node=_1e5[i];
if(node.nodeType==1&&(!_1e4||node._counted)){
node.nodeIndex=j++;
}
}
}else{
for(var i=0,j=1,_1e5=_1e2.childNodes;node=_1e5[i];i++){
if(node.nodeType==1&&(!_1e4||node._counted)){
node.nodeIndex=j++;
}
}
}
},unique:function(_1e7){
if(_1e7.length==0){
return _1e7;
}
var _1e8=[],n;
for(var i=0,l=_1e7.length;i<l;i++){
if(!(n=_1e7[i])._counted){
n._counted=true;
_1e8.push(Element.extend(n));
}
}
return Selector.handlers.unmark(_1e8);
},descendant:function(_1ea){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1ea[i];i++){
h.concat(results,node.getElementsByTagName("*"));
}
return results;
},child:function(_1ed){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1ed[i];i++){
for(var j=0,children=[],child;child=node.childNodes[j];j++){
if(child.nodeType==1&&child.tagName!="!"){
results.push(child);
}
}
}
return results;
},adjacent:function(_1f1){
for(var i=0,results=[],node;node=_1f1[i];i++){
var next=this.nextElementSibling(node);
if(next){
results.push(next);
}
}
return results;
},laterSibling:function(_1f4){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1f4[i];i++){
h.concat(results,Element.nextSiblings(node));
}
return results;
},nextElementSibling:function(node){
while(node=node.nextSibling){
if(node.nodeType==1){
return node;
}
}
return null;
},previousElementSibling:function(node){
while(node=node.previousSibling){
if(node.nodeType==1){
return node;
}
}
return null;
},tagName:function(_1f9,root,_1fb,_1fc){
_1fb=_1fb.toUpperCase();
var _1fd=[],h=Selector.handlers;
if(_1f9){
if(_1fc){
if(_1fc=="descendant"){
for(var i=0,node;node=_1f9[i];i++){
h.concat(_1fd,node.getElementsByTagName(_1fb));
}
return _1fd;
}else{
_1f9=this[_1fc](_1f9);
}
if(_1fb=="*"){
return _1f9;
}
}
for(var i=0,node;node=_1f9[i];i++){
if(node.tagName.toUpperCase()==_1fb){
_1fd.push(node);
}
}
return _1fd;
}else{
return root.getElementsByTagName(_1fb);
}
},id:function(_200,root,id,_203){
var _204=$(id),h=Selector.handlers;
if(!_200&&root==document){
return _204?[_204]:[];
}
if(_200){
if(_203){
if(_203=="child"){
for(var i=0,node;node=_200[i];i++){
if(_204.parentNode==node){
return [_204];
}
}
}else{
if(_203=="descendant"){
for(var i=0,node;node=_200[i];i++){
if(Element.descendantOf(_204,node)){
return [_204];
}
}
}else{
if(_203=="adjacent"){
for(var i=0,node;node=_200[i];i++){
if(Selector.handlers.previousElementSibling(_204)==node){
return [_204];
}
}
}else{
_200=h[_203](_200);
}
}
}
}
for(var i=0,node;node=_200[i];i++){
if(node==_204){
return [_204];
}
}
return [];
}
return (_204&&Element.descendantOf(_204,root))?[_204]:[];
},className:function(_209,root,_20b,_20c){
if(_209&&_20c){
_209=this[_20c](_209);
}
return Selector.handlers.byClassName(_209,root,_20b);
},byClassName:function(_20d,root,_20f){
if(!_20d){
_20d=Selector.handlers.descendant([root]);
}
var _210=" "+_20f+" ";
for(var i=0,results=[],node,nodeClassName;node=_20d[i];i++){
nodeClassName=node.className;
if(nodeClassName.length==0){
continue;
}
if(nodeClassName==_20f||(" "+nodeClassName+" ").include(_210)){
results.push(node);
}
}
return results;
},attrPresence:function(_212,root,attr){
var _215=[];
for(var i=0,node;node=_212[i];i++){
if(Element.hasAttribute(node,attr)){
_215.push(node);
}
}
return _215;
},attr:function(_217,root,attr,_21a,_21b){
if(!_217){
_217=root.getElementsByTagName("*");
}
var _21c=Selector.operators[_21b],results=[];
for(var i=0,node;node=_217[i];i++){
var _21e=Element.readAttribute(node,attr);
if(_21e===null){
continue;
}
if(_21c(_21e,_21a)){
results.push(node);
}
}
return results;
},pseudo:function(_21f,name,_221,root,_223){
if(_21f&&_223){
_21f=this[_223](_21f);
}
if(!_21f){
_21f=root.getElementsByTagName("*");
}
return Selector.pseudos[name](_21f,_221,root);
}},pseudos:{"first-child":function(_224,_225,root){
for(var i=0,results=[],node;node=_224[i];i++){
if(Selector.handlers.previousElementSibling(node)){
continue;
}
results.push(node);
}
return results;
},"last-child":function(_228,_229,root){
for(var i=0,results=[],node;node=_228[i];i++){
if(Selector.handlers.nextElementSibling(node)){
continue;
}
results.push(node);
}
return results;
},"only-child":function(_22c,_22d,root){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_22c[i];i++){
if(!h.previousElementSibling(node)&&!h.nextElementSibling(node)){
results.push(node);
}
}
return results;
},"nth-child":function(_231,_232,root){
return Selector.pseudos.nth(_231,_232,root);
},"nth-last-child":function(_234,_235,root){
return Selector.pseudos.nth(_234,_235,root,true);
},"nth-of-type":function(_237,_238,root){
return Selector.pseudos.nth(_237,_238,root,false,true);
},"nth-last-of-type":function(_23a,_23b,root){
return Selector.pseudos.nth(_23a,_23b,root,true,true);
},"first-of-type":function(_23d,_23e,root){
return Selector.pseudos.nth(_23d,"1",root,false,true);
},"last-of-type":function(_240,_241,root){
return Selector.pseudos.nth(_240,"1",root,true,true);
},"only-of-type":function(_243,_244,root){
var p=Selector.pseudos;
return p["last-of-type"](p["first-of-type"](_243,_244,root),_244,root);
},getIndices:function(a,b,_249){
if(a==0){
return b>0?[b]:[];
}
return $R(1,_249).inject([],function(memo,i){
if(0==(i-b)%a&&(i-b)/a>=0){
memo.push(i);
}
return memo;
});
},nth:function(_24c,_24d,root,_24f,_250){
if(_24c.length==0){
return [];
}
if(_24d=="even"){
_24d="2n+0";
}
if(_24d=="odd"){
_24d="2n+1";
}
var h=Selector.handlers,results=[],indexed=[],m;
h.mark(_24c);
for(var i=0,node;node=_24c[i];i++){
if(!node.parentNode._counted){
h.index(node.parentNode,_24f,_250);
indexed.push(node.parentNode);
}
}
if(_24d.match(/^\d+$/)){
_24d=Number(_24d);
for(var i=0,node;node=_24c[i];i++){
if(node.nodeIndex==_24d){
results.push(node);
}
}
}else{
if(m=_24d.match(/^(-?\d*)?n(([+-])(\d+))?/)){
if(m[1]=="-"){
m[1]=-1;
}
var a=m[1]?Number(m[1]):1;
var b=m[2]?Number(m[2]):0;
var _256=Selector.pseudos.getIndices(a,b,_24c.length);
for(var i=0,node,l=_256.length;node=_24c[i];i++){
for(var j=0;j<l;j++){
if(node.nodeIndex==_256[j]){
results.push(node);
}
}
}
}
}
h.unmark(_24c);
h.unmark(indexed);
return results;
},"empty":function(_259,_25a,root){
for(var i=0,results=[],node;node=_259[i];i++){
if(node.tagName=="!"||(node.firstChild&&!node.innerHTML.match(/^\s*$/))){
continue;
}
results.push(node);
}
return results;
},"not":function(_25d,_25e,root){
var h=Selector.handlers,selectorType,m;
var _261=new Selector(_25e).findElements(root);
h.mark(_261);
for(var i=0,results=[],node;node=_25d[i];i++){
if(!node._counted){
results.push(node);
}
}
h.unmark(_261);
return results;
},"enabled":function(_263,_264,root){
for(var i=0,results=[],node;node=_263[i];i++){
if(!node.disabled){
results.push(node);
}
}
return results;
},"disabled":function(_267,_268,root){
for(var i=0,results=[],node;node=_267[i];i++){
if(node.disabled){
results.push(node);
}
}
return results;
},"checked":function(_26b,_26c,root){
for(var i=0,results=[],node;node=_26b[i];i++){
if(node.checked){
results.push(node);
}
}
return results;
}},operators:{"=":function(nv,v){
return nv==v;
},"!=":function(nv,v){
return nv!=v;
},"^=":function(nv,v){
return nv.startsWith(v);
},"$=":function(nv,v){
return nv.endsWith(v);
},"*=":function(nv,v){
return nv.include(v);
},"~=":function(nv,v){
return (" "+nv+" ").include(" "+v+" ");
},"|=":function(nv,v){
return ("-"+nv.toUpperCase()+"-").include("-"+v.toUpperCase()+"-");
}},matchElements:function(_27d,_27e){
var _27f=new Selector(_27e).findElements(),h=Selector.handlers;
h.mark(_27f);
for(var i=0,results=[],element;element=_27d[i];i++){
if(element._counted){
results.push(element);
}
}
h.unmark(_27f);
return results;
},findElement:function(_281,_282,_283){
if(typeof _282=="number"){
_283=_282;
_282=false;
}
return Selector.matchElements(_281,_282||"*")[_283||0];
},findChildElements:function(_284,_285){
var _286=_285.join(","),_285=[];
_286.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(m){
_285.push(m[1].strip());
});
var _288=[],h=Selector.handlers;
for(var i=0,l=_285.length,selector;i<l;i++){
selector=new Selector(_285[i].strip());
h.concat(_288,selector.findElements(_284));
}
return (l>1)?h.unique(_288):_288;
}});
function $$(){
return Selector.findChildElements(document,$A(arguments));
}
var Form={reset:function(form){
$(form).reset();
return form;
},serializeElements:function(_28b,_28c){
var data=_28b.inject({},function(_28e,_28f){
if(!_28f.disabled&&_28f.name){
var key=_28f.name,value=$(_28f).getValue();
if(value!=null){
if(key in _28e){
if(_28e[key].constructor!=Array){
_28e[key]=[_28e[key]];
}
_28e[key].push(value);
}else{
_28e[key]=value;
}
}
}
return _28e;
});
return _28c?data:Hash.toQueryString(data);
}};
Form.Methods={serialize:function(form,_292){
return Form.serializeElements(Form.getElements(form),_292);
},getElements:function(form){
return $A($(form).getElementsByTagName("*")).inject([],function(_294,_295){
if(Form.Element.Serializers[_295.tagName.toLowerCase()]){
_294.push(Element.extend(_295));
}
return _294;
});
},getInputs:function(form,_297,name){
form=$(form);
var _299=form.getElementsByTagName("input");
if(!_297&&!name){
return $A(_299).map(Element.extend);
}
for(var i=0,matchingInputs=[],length=_299.length;i<length;i++){
var _29b=_299[i];
if((_297&&_29b.type!=_297)||(name&&_29b.name!=name)){
continue;
}
matchingInputs.push(Element.extend(_29b));
}
return matchingInputs;
},disable:function(form){
form=$(form);
Form.getElements(form).invoke("disable");
return form;
},enable:function(form){
form=$(form);
Form.getElements(form).invoke("enable");
return form;
},findFirstElement:function(form){
return $(form).getElements().find(function(_29f){
return _29f.type!="hidden"&&!_29f.disabled&&["input","select","textarea"].include(_29f.tagName.toLowerCase());
});
},focusFirstElement:function(form){
form=$(form);
form.findFirstElement().activate();
return form;
},request:function(form,_2a2){
form=$(form),_2a2=Object.clone(_2a2||{});
var _2a3=_2a2.parameters;
_2a2.parameters=form.serialize(true);
if(_2a3){
if(typeof _2a3=="string"){
_2a3=_2a3.toQueryParams();
}
Object.extend(_2a2.parameters,_2a3);
}
if(form.hasAttribute("method")&&!_2a2.method){
_2a2.method=form.method;
}
return new Ajax.Request(form.readAttribute("action"),_2a2);
}};
Form.Element={focus:function(_2a4){
$(_2a4).focus();
return _2a4;
},select:function(_2a5){
$(_2a5).select();
return _2a5;
}};
Form.Element.Methods={serialize:function(_2a6){
_2a6=$(_2a6);
if(!_2a6.disabled&&_2a6.name){
var _2a7=_2a6.getValue();
if(_2a7!=undefined){
var pair={};
pair[_2a6.name]=_2a7;
return Hash.toQueryString(pair);
}
}
return "";
},getValue:function(_2a9){
_2a9=$(_2a9);
var _2aa=_2a9.tagName.toLowerCase();
return Form.Element.Serializers[_2aa](_2a9);
},clear:function(_2ab){
$(_2ab).value="";
return _2ab;
},present:function(_2ac){
return $(_2ac).value!="";
},activate:function(_2ad){
_2ad=$(_2ad);
try{
_2ad.focus();
if(_2ad.select&&(_2ad.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(_2ad.type))){
_2ad.select();
}
}
catch(e){
}
return _2ad;
},disable:function(_2ae){
_2ae=$(_2ae);
_2ae.blur();
_2ae.disabled=true;
return _2ae;
},enable:function(_2af){
_2af=$(_2af);
_2af.disabled=false;
return _2af;
}};
var Field=Form.Element;
var $F=Form.Element.Methods.getValue;
Form.Element.Serializers={input:function(_2b0){
switch(_2b0.type.toLowerCase()){
case "checkbox":
case "radio":
return Form.Element.Serializers.inputSelector(_2b0);
default:
return Form.Element.Serializers.textarea(_2b0);
}
},inputSelector:function(_2b1){
return _2b1.checked?_2b1.value:null;
},textarea:function(_2b2){
return _2b2.value;
},select:function(_2b3){
return this[_2b3.type=="select-one"?"selectOne":"selectMany"](_2b3);
},selectOne:function(_2b4){
var _2b5=_2b4.selectedIndex;
return _2b5>=0?this.optionValue(_2b4.options[_2b5]):null;
},selectMany:function(_2b6){
var _2b7,length=_2b6.length;
if(!length){
return null;
}
for(var i=0,_2b7=[];i<length;i++){
var opt=_2b6.options[i];
if(opt.selected){
_2b7.push(this.optionValue(opt));
}
}
return _2b7;
},optionValue:function(opt){
return Element.extend(opt).hasAttribute("value")?opt.value:opt.text;
}};
Abstract.TimedObserver=function(){
};
Abstract.TimedObserver.prototype={initialize:function(_2bb,_2bc,_2bd){
this.frequency=_2bc;
this.element=$(_2bb);
this.callback=_2bd;
this.lastValue=this.getValue();
this.registerCallback();
},registerCallback:function(){
setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},onTimerEvent:function(){
var _2be=this.getValue();
var _2bf=("string"==typeof this.lastValue&&"string"==typeof _2be?this.lastValue!=_2be:String(this.lastValue)!=String(_2be));
if(_2bf){
this.callback(this.element,_2be);
this.lastValue=_2be;
}
}};
Form.Element.Observer=Class.create();
Form.Element.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){
return Form.Element.getValue(this.element);
}});
Form.Observer=Class.create();
Form.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){
return Form.serialize(this.element);
}});
Abstract.EventObserver=function(){
};
Abstract.EventObserver.prototype={initialize:function(_2c0,_2c1){
this.element=$(_2c0);
this.callback=_2c1;
this.lastValue=this.getValue();
if(this.element.tagName.toLowerCase()=="form"){
this.registerFormCallbacks();
}else{
this.registerCallback(this.element);
}
},onElementEvent:function(){
var _2c2=this.getValue();
if(this.lastValue!=_2c2){
this.callback(this.element,_2c2);
this.lastValue=_2c2;
}
},registerFormCallbacks:function(){
Form.getElements(this.element).each(this.registerCallback.bind(this));
},registerCallback:function(_2c3){
if(_2c3.type){
switch(_2c3.type.toLowerCase()){
case "checkbox":
case "radio":
Event.observe(_2c3,"click",this.onElementEvent.bind(this));
break;
default:
Event.observe(_2c3,"change",this.onElementEvent.bind(this));
break;
}
}
}};
Form.Element.EventObserver=Class.create();
Form.Element.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){
return Form.Element.getValue(this.element);
}});
Form.EventObserver=Class.create();
Form.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){
return Form.serialize(this.element);
}});
if(!window.Event){
var Event=new Object();
}
Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,element:function(_2c4){
return $(_2c4.target||_2c4.srcElement);
},isLeftClick:function(_2c5){
return (((_2c5.which)&&(_2c5.which==1))||((_2c5.button)&&(_2c5.button==1)));
},pointerX:function(_2c6){
return _2c6.pageX||(_2c6.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));
},pointerY:function(_2c7){
return _2c7.pageY||(_2c7.clientY+(document.documentElement.scrollTop||document.body.scrollTop));
},stop:function(_2c8){
if(_2c8.preventDefault){
_2c8.preventDefault();
_2c8.stopPropagation();
}else{
_2c8.returnValue=false;
_2c8.cancelBubble=true;
}
},findElement:function(_2c9,_2ca){
var _2cb=Event.element(_2c9);
while(_2cb.parentNode&&(!_2cb.tagName||(_2cb.tagName.toUpperCase()!=_2ca.toUpperCase()))){
_2cb=_2cb.parentNode;
}
return _2cb;
},observers:false,_observeAndCache:function(_2cc,name,_2ce,_2cf){
if(!this.observers){
this.observers=[];
}
if(_2cc.addEventListener){
this.observers.push([_2cc,name,_2ce,_2cf]);
_2cc.addEventListener(name,_2ce,_2cf);
}else{
if(_2cc.attachEvent){
this.observers.push([_2cc,name,_2ce,_2cf]);
_2cc.attachEvent("on"+name,_2ce);
}
}
},unloadCache:function(){
if(!Event.observers){
return;
}
for(var i=0,length=Event.observers.length;i<length;i++){
Event.stopObserving.apply(this,Event.observers[i]);
Event.observers[i][0]=null;
}
Event.observers=false;
},observe:function(_2d1,name,_2d3,_2d4){
_2d1=$(_2d1);
_2d4=_2d4||false;
if(name=="keypress"&&(Prototype.Browser.WebKit||_2d1.attachEvent)){
name="keydown";
}
Event._observeAndCache(_2d1,name,_2d3,_2d4);
},stopObserving:function(_2d5,name,_2d7,_2d8){
_2d5=$(_2d5);
_2d8=_2d8||false;
if(name=="keypress"&&(Prototype.Browser.WebKit||_2d5.attachEvent)){
name="keydown";
}
if(_2d5.removeEventListener){
_2d5.removeEventListener(name,_2d7,_2d8);
}else{
if(_2d5.detachEvent){
try{
_2d5.detachEvent("on"+name,_2d7);
}
catch(e){
}
}
}
}});
if(Prototype.Browser.IE){
Event.observe(window,"unload",Event.unloadCache,false);
}
var Position={includeScrollOffsets:false,prepare:function(){
this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;
this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;
},realOffset:function(_2d9){
var _2da=0,valueL=0;
do{
_2da+=_2d9.scrollTop||0;
valueL+=_2d9.scrollLeft||0;
_2d9=_2d9.parentNode;
}while(_2d9);
return [valueL,_2da];
},cumulativeOffset:function(_2db){
var _2dc=0,valueL=0;
do{
_2dc+=_2db.offsetTop||0;
valueL+=_2db.offsetLeft||0;
_2db=_2db.offsetParent;
}while(_2db);
return [valueL,_2dc];
},positionedOffset:function(_2dd){
var _2de=0,valueL=0;
do{
_2de+=_2dd.offsetTop||0;
valueL+=_2dd.offsetLeft||0;
_2dd=_2dd.offsetParent;
if(_2dd){
if(_2dd.tagName=="BODY"){
break;
}
var p=Element.getStyle(_2dd,"position");
if(p=="relative"||p=="absolute"){
break;
}
}
}while(_2dd);
return [valueL,_2de];
},offsetParent:function(_2e0){
if(_2e0.offsetParent){
return _2e0.offsetParent;
}
if(_2e0==document.body){
return _2e0;
}
while((_2e0=_2e0.parentNode)&&_2e0!=document.body){
if(Element.getStyle(_2e0,"position")!="static"){
return _2e0;
}
}
return document.body;
},within:function(_2e1,x,y){
if(this.includeScrollOffsets){
return this.withinIncludingScrolloffsets(_2e1,x,y);
}
this.xcomp=x;
this.ycomp=y;
this.offset=this.cumulativeOffset(_2e1);
return (y>=this.offset[1]&&y<this.offset[1]+_2e1.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+_2e1.offsetWidth);
},withinIncludingScrolloffsets:function(_2e4,x,y){
var _2e7=this.realOffset(_2e4);
this.xcomp=x+_2e7[0]-this.deltaX;
this.ycomp=y+_2e7[1]-this.deltaY;
this.offset=this.cumulativeOffset(_2e4);
return (this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+_2e4.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+_2e4.offsetWidth);
},overlap:function(mode,_2e9){
if(!mode){
return 0;
}
if(mode=="vertical"){
return ((this.offset[1]+_2e9.offsetHeight)-this.ycomp)/_2e9.offsetHeight;
}
if(mode=="horizontal"){
return ((this.offset[0]+_2e9.offsetWidth)-this.xcomp)/_2e9.offsetWidth;
}
},page:function(_2ea){
var _2eb=0,valueL=0;
var _2ec=_2ea;
do{
_2eb+=_2ec.offsetTop||0;
valueL+=_2ec.offsetLeft||0;
if(_2ec.offsetParent==document.body){
if(Element.getStyle(_2ec,"position")=="absolute"){
break;
}
}
}while(_2ec=_2ec.offsetParent);
_2ec=_2ea;
do{
if(!window.opera||_2ec.tagName=="BODY"){
_2eb-=_2ec.scrollTop||0;
valueL-=_2ec.scrollLeft||0;
}
}while(_2ec=_2ec.parentNode);
return [valueL,_2eb];
},clone:function(_2ed,_2ee){
var _2ef=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});
_2ed=$(_2ed);
var p=Position.page(_2ed);
_2ee=$(_2ee);
var _2f1=[0,0];
var _2f2=null;
if(Element.getStyle(_2ee,"position")=="absolute"){
_2f2=Position.offsetParent(_2ee);
_2f1=Position.page(_2f2);
}
if(_2f2==document.body){
_2f1[0]-=document.body.offsetLeft;
_2f1[1]-=document.body.offsetTop;
}
if(_2ef.setLeft){
_2ee.style.left=(p[0]-_2f1[0]+_2ef.offsetLeft)+"px";
}
if(_2ef.setTop){
_2ee.style.top=(p[1]-_2f1[1]+_2ef.offsetTop)+"px";
}
if(_2ef.setWidth){
_2ee.style.width=_2ed.offsetWidth+"px";
}
if(_2ef.setHeight){
_2ee.style.height=_2ed.offsetHeight+"px";
}
},absolutize:function(_2f3){
_2f3=$(_2f3);
if(_2f3.style.position=="absolute"){
return;
}
Position.prepare();
var _2f4=Position.positionedOffset(_2f3);
var top=_2f4[1];
var left=_2f4[0];
var _2f7=_2f3.clientWidth;
var _2f8=_2f3.clientHeight;
_2f3._originalLeft=left-parseFloat(_2f3.style.left||0);
_2f3._originalTop=top-parseFloat(_2f3.style.top||0);
_2f3._originalWidth=_2f3.style.width;
_2f3._originalHeight=_2f3.style.height;
_2f3.style.position="absolute";
_2f3.style.top=top+"px";
_2f3.style.left=left+"px";
_2f3.style.width=_2f7+"px";
_2f3.style.height=_2f8+"px";
},relativize:function(_2f9){
_2f9=$(_2f9);
if(_2f9.style.position=="relative"){
return;
}
Position.prepare();
_2f9.style.position="relative";
var top=parseFloat(_2f9.style.top||0)-(_2f9._originalTop||0);
var left=parseFloat(_2f9.style.left||0)-(_2f9._originalLeft||0);
_2f9.style.top=top+"px";
_2f9.style.left=left+"px";
_2f9.style.height=_2f9._originalHeight;
_2f9.style.width=_2f9._originalWidth;
}};
if(Prototype.Browser.WebKit){
Position.cumulativeOffset=function(_2fc){
var _2fd=0,valueL=0;
do{
_2fd+=_2fc.offsetTop||0;
valueL+=_2fc.offsetLeft||0;
if(_2fc.offsetParent==document.body){
if(Element.getStyle(_2fc,"position")=="absolute"){
break;
}
}
_2fc=_2fc.offsetParent;
}while(_2fc);
return [valueL,_2fd];
};
}
Element.addMethods();



//..........................................................................................
// script.aculo.us effects.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
String.prototype.parseColor = function() {  
  var color = '#';
  if(this.slice(0,4) == 'rgb(') {  
    var cols = this.slice(4,this.length-1).split(',');  
    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);  
  } else {  
    if(this.slice(0,1) == '#') {  
      if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();  
      if(this.length==7) color = this.toLowerCase();  
    }  
  }  
  return(color.length==7 ? color : (arguments[0] || this));  
}

/*--------------------------------------------------------------------------*/

Element.collectTextNodes = function(element) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
  }).flatten().join('');
}

Element.collectTextNodesIgnoreClass = function(element, className) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? 
        Element.collectTextNodesIgnoreClass(node, className) : ''));
  }).flatten().join('');
}

Element.setContentZoom = function(element, percent) {
  element = $(element);  
  element.setStyle({fontSize: (percent/100) + 'em'});   
  if(Prototype.Browser.WebKit) window.scrollBy(0,0);
  return element;
}

Element.getInlineOpacity = function(element){
  return $(element).style.opacity || '';
}

Element.forceRerendering = function(element) {
  try {
    element = $(element);
    var n = document.createTextNode(' ');
    element.appendChild(n);
    element.removeChild(n);
  } catch(e) { }
};

/*--------------------------------------------------------------------------*/

Array.prototype.call = function() {
  var args = arguments;
  this.each(function(f){ f.apply(this, args) });
}

/*--------------------------------------------------------------------------*/

var Effect = {
  _elementDoesNotExistError: {
    name: 'ElementDoesNotExistError',
    message: 'The specified DOM element does not exist, but is required for this effect to operate'
  },
  tagifyText: function(element) {
    if(typeof Builder == 'undefined')
      throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
      
    var tagifyStyle = 'position:relative';
    if(Prototype.Browser.IE) tagifyStyle += ';zoom:1';
    
    element = $(element);
    $A(element.childNodes).each( function(child) {
      if(child.nodeType==3) {
        child.nodeValue.toArray().each( function(character) {
          element.insertBefore(
            Builder.node('span',{style: tagifyStyle},
              character == ' ' ? String.fromCharCode(160) : character), 
              child);
        });
        Element.remove(child);
      }
    });
  },
  multiple: function(element, effect) {
    var elements;
    if(((typeof element == 'object') || 
        (typeof element == 'function')) && 
       (element.length))
      elements = element;
    else
      elements = $(element).childNodes;
      
    var options = Object.extend({
      speed: 0.1,
      delay: 0.0
    }, arguments[2] || {});
    var masterDelay = options.delay;

    $A(elements).each( function(element, index) {
      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
    });
  },
  PAIRS: {
    'slide':  ['SlideDown','SlideUp'],
    'blind':  ['BlindDown','BlindUp'],
    'appear': ['Appear','Fade']
  },
  toggle: function(element, effect) {
    element = $(element);
    effect = (effect || 'appear').toLowerCase();
    var options = Object.extend({
      queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
    }, arguments[2] || {});
    Effect[element.visible() ? 
      Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
  }
};

var Effect2 = Effect; // deprecated

/* ------------- transitions ------------- */

Effect.Transitions = {
  linear: Prototype.K,
  sinoidal: function(pos) {
    return (-Math.cos(pos*Math.PI)/2) + 0.5;
  },
  reverse: function(pos) {
    return 1-pos;
  },
  flicker: function(pos) {
    var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
    return (pos > 1 ? 1 : pos);
  },
  wobble: function(pos) {
    return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
  },
  pulse: function(pos, pulses) { 
    pulses = pulses || 5; 
    return (
      Math.round((pos % (1/pulses)) * pulses) == 0 ? 
            ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) : 
        1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))
      );
  },
  none: function(pos) {
    return 0;
  },
  full: function(pos) {
    return 1;
  }
};

/* ------------- core effects ------------- */

Effect.ScopedQueue = Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
  initialize: function() {
    this.effects  = [];
    this.interval = null;    
  },
  _each: function(iterator) {
    this.effects._each(iterator);
  },
  add: function(effect) {
    var timestamp = new Date().getTime();
    
    var position = (typeof effect.options.queue == 'string') ? 
      effect.options.queue : effect.options.queue.position;
    
    switch(position) {
      case 'front':
        // move unstarted effects after this effect  
        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
            e.startOn  += effect.finishOn;
            e.finishOn += effect.finishOn;
          });
        break;
      case 'with-last':
        timestamp = this.effects.pluck('startOn').max() || timestamp;
        break;
      case 'end':
        // start effect after last queued effect has finished
        timestamp = this.effects.pluck('finishOn').max() || timestamp;
        break;
    }
    
    effect.startOn  += timestamp;
    effect.finishOn += timestamp;

    if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
      this.effects.push(effect);
    
    if(!this.interval)
      this.interval = setInterval(this.loop.bind(this), 15);
  },
  remove: function(effect) {
    this.effects = this.effects.reject(function(e) { return e==effect });
    if(this.effects.length == 0) {
      clearInterval(this.interval);
      this.interval = null;
    }
  },
  loop: function() {
    var timePos = new Date().getTime();
    for(var i=0, len=this.effects.length;i<len;i++) 
      this.effects[i] && this.effects[i].loop(timePos);
  }
});

Effect.Queues = {
  instances: $H(),
  get: function(queueName) {
    if(typeof queueName != 'string') return queueName;
    
    if(!this.instances[queueName])
      this.instances[queueName] = new Effect.ScopedQueue();
      
    return this.instances[queueName];
  }
}
Effect.Queue = Effect.Queues.get('global');

Effect.DefaultOptions = {
  transition: Effect.Transitions.sinoidal,
  duration:   1.0,   // seconds
  fps:        100,   // 100= assume 66fps max.
  sync:       false, // true for combining
  from:       0.0,
  to:         1.0,
  delay:      0.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(timePos) {
    if(timePos >= this.startOn) {
      if(timePos >= this.finishOn) {
        this.render(1.0);
        this.cancel();
        this.event('beforeFinish');
        if(this.finish) this.finish(); 
        this.event('afterFinish');
        return;  
      }
      var pos   = (timePos - this.startOn) / this.totalTime,
          frame = Math.round(pos * this.totalFrames);
      if(frame > this.currentFrame) {
        this.render(pos);
        this.currentFrame = frame;
      }
    }
  },
  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(eventName) {
    if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
    if(this.options[eventName]) this.options[eventName](this);
  },
  inspect: function() {
    var data = $H();
    for(property in this)
      if(typeof this[property] != 'function') data[property] = this[property];
    return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
  }
}

Effect.Parallel = Class.create();
Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
  initialize: function(effects) {
    this.effects = effects || [];
    this.start(arguments[1]);
  },
  update: function(position) {
    this.effects.invoke('render', position);
  },
  finish: function(position) {
    this.effects.each( function(effect) {
      effect.render(1.0);
      effect.cancel();
      effect.event('beforeFinish');
      if(effect.finish) effect.finish(position);
      effect.event('afterFinish');
    });
  }
});

Effect.Event = Class.create();
Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), {
  initialize: function() {
    var options = Object.extend({
      duration: 0
    }, arguments[0] || {});
    this.start(options);
  },
  update: Prototype.emptyFunction
});

Effect.Opacity = Class.create();
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    // make this work on IE on elements without 'layout'
    if(Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
      this.element.setStyle({zoom: 1});
    var options = Object.extend({
      from: this.element.getOpacity() || 0.0,
      to:   1.0
    }, arguments[1] || {});
    this.start(options);
  },
  update: function(position) {
    this.element.setOpacity(position);
  }
});

Effect.Move = Class.create();
Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      x:    0,
      y:    0,
      mode: 'relative'
    }, arguments[1] || {});
    this.start(options);
  },
  setup: function() {
    // Bug in Opera: Opera returns the "real" position of a static element or
    // relative element that does not have top/left explicitly set.
    // ==> Always set top and left for position relative elements in your stylesheets 
    // (to 0 if you do not need them) 
    this.element.makePositioned();
    this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
    this.originalTop  = parseFloat(this.element.getStyle('top')  || '0');
    if(this.options.mode == 'absolute') {
      // absolute movement, so we need to calc deltaX and deltaY
      this.options.x = this.options.x - this.originalLeft;
      this.options.y = this.options.y - this.originalTop;
    }
  },
  update: function(position) {
    this.element.setStyle({
      left: Math.round(this.options.x  * position + this.originalLeft) + 'px',
      top:  Math.round(this.options.y  * position + this.originalTop)  + 'px'
    });
  }
});

// for backwards compatibility
Effect.MoveBy = function(element, toTop, toLeft) {
  return new Effect.Move(element, 
    Object.extend({ x: toLeft, y: toTop }, arguments[3] || {}));
};

Effect.Scale = Class.create();
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
  initialize: function(element, percent) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      scaleX: true,
      scaleY: true,
      scaleContent: true,
      scaleFromCenter: false,
      scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
      scaleFrom: 100.0,
      scaleTo:   percent
    }, arguments[2] || {});
    this.start(options);
  },
  setup: function() {
    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
    this.elementPositioning = this.element.getStyle('position');
    
    this.originalStyle = {};
    ['top','left','width','height','fontSize'].each( function(k) {
      this.originalStyle[k] = this.element.style[k];
    }.bind(this));
      
    this.originalTop  = this.element.offsetTop;
    this.originalLeft = this.element.offsetLeft;
    
    var fontSize = this.element.getStyle('font-size') || '100%';
    ['em','px','%','pt'].each( function(fontSizeType) {
      if(fontSize.indexOf(fontSizeType)>0) {
        this.fontSize     = parseFloat(fontSize);
        this.fontSizeType = fontSizeType;
      }
    }.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(position) {
    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
    if(this.options.scaleContent && this.fontSize)
      this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
  },
  finish: function(position) {
    if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
  },
  setDimensions: function(height, width) {
    var d = {};
    if(this.options.scaleX) d.width = Math.round(width) + 'px';
    if(this.options.scaleY) d.height = Math.round(height) + 'px';
    if(this.options.scaleFromCenter) {
      var topd  = (height - this.dims[0])/2;
      var leftd = (width  - this.dims[1])/2;
      if(this.elementPositioning == 'absolute') {
        if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
        if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
      } else {
        if(this.options.scaleY) d.top = -topd + 'px';
        if(this.options.scaleX) d.left = -leftd + 'px';
      }
    }
    this.element.setStyle(d);
  }
});

Effect.Highlight = Class.create();
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
    this.start(options);
  },
  setup: function() {
    // Prevent executing on elements not in the layout flow
    if(this.element.getStyle('display')=='none') { this.cancel(); return; }
    // Disable background image during the effect
    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');
    // init color calculations
    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
  },
  update: function(position) {
    this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
      return m+(Math.round(this._base[i]+(this._delta[i]*position)).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(element) {
    this.element = $(element);
    this.start(arguments[1] || {});
  },
  setup: function() {
    Position.prepare();
    var offsets = Position.cumulativeOffset(this.element);
    if(this.options.offset) offsets[1] += this.options.offset;
    var max = window.innerHeight ? 
      window.height - window.innerHeight :
      document.body.scrollHeight - 
        (document.documentElement.clientHeight ? 
          document.documentElement.clientHeight : document.body.clientHeight);
    this.scrollStart = Position.deltaY;
    this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
  },
  update: function(position) {
    Position.prepare();
    window.scrollTo(Position.deltaX, 
      this.scrollStart + (position*this.delta));
  }
});

/* ------------- combination effects ------------- */

Effect.Fade = function(element) {
  element = $(element);
  var oldOpacity = element.getInlineOpacity();
  var options = Object.extend({
  from: element.getOpacity() || 1.0,
  to:   0.0,
  afterFinishInternal: function(effect) { 
    if(effect.options.to!=0) return;
    effect.element.hide().setStyle({opacity: oldOpacity}); 
  }}, arguments[1] || {});
  return new Effect.Opacity(element,options);
}

Effect.Appear = function(element) {
  element = $(element);
  var options = Object.extend({
  from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
  to:   1.0,
  // force Safari to render floated elements properly
  afterFinishInternal: function(effect) {
    effect.element.forceRerendering();
  },
  beforeSetup: function(effect) {
    effect.element.setOpacity(effect.options.from).show(); 
  }}, arguments[1] || {});
  return new Effect.Opacity(element,options);
}

Effect.Puff = function(element) {
  element = $(element);
  var oldStyle = { 
    opacity: element.getInlineOpacity(), 
    position: element.getStyle('position'),
    top:  element.style.top,
    left: element.style.left,
    width: element.style.width,
    height: element.style.height
  };
  return new Effect.Parallel(
   [ new Effect.Scale(element, 200, 
      { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), 
     new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], 
     Object.extend({ duration: 1.0, 
      beforeSetupInternal: function(effect) {
        Position.absolutize(effect.effects[0].element)
      },
      afterFinishInternal: function(effect) {
         effect.effects[0].element.hide().setStyle(oldStyle); }
     }, arguments[1] || {})
   );
}

Effect.BlindUp = function(element) {
  element = $(element);
  element.makeClipping();
  return new Effect.Scale(element, 0,
    Object.extend({ scaleContent: false, 
      scaleX: false, 
      restoreAfterFinish: true,
      afterFinishInternal: function(effect) {
        effect.element.hide().undoClipping();
      } 
    }, arguments[1] || {})
  );
}

Effect.BlindDown = function(element) {
  element = $(element);
  var elementDimensions = element.getDimensions();
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false,
    scaleFrom: 0,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: true,
    afterSetup: function(effect) {
      effect.element.makeClipping().setStyle({height: '0px'}).show(); 
    },  
    afterFinishInternal: function(effect) {
      effect.element.undoClipping();
    }
  }, arguments[1] || {}));
}

Effect.SwitchOff = function(element) {
  element = $(element);
  var oldOpacity = element.getInlineOpacity();
  return new Effect.Appear(element, Object.extend({
    duration: 0.4,
    from: 0,
    transition: Effect.Transitions.flicker,
    afterFinishInternal: function(effect) {
      new Effect.Scale(effect.element, 1, { 
        duration: 0.3, scaleFromCenter: true,
        scaleX: false, scaleContent: false, restoreAfterFinish: true,
        beforeSetup: function(effect) { 
          effect.element.makePositioned().makeClipping();
        },
        afterFinishInternal: function(effect) {
          effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
        }
      })
    }
  }, arguments[1] || {}));
}

Effect.DropOut = function(element) {
  element = $(element);
  var oldStyle = {
    top: element.getStyle('top'),
    left: element.getStyle('left'),
    opacity: element.getInlineOpacity() };
  return new Effect.Parallel(
    [ new Effect.Move(element, {x: 0, y: 100, sync: true }), 
      new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
    Object.extend(
      { duration: 0.5,
        beforeSetup: function(effect) {
          effect.effects[0].element.makePositioned(); 
        },
        afterFinishInternal: function(effect) {
          effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
        } 
      }, arguments[1] || {}));
}

Effect.Shake = function(element) {
  element = $(element);
  var oldStyle = {
    top: element.getStyle('top'),
    left: element.getStyle('left') };
    return new Effect.Move(element, 
      { x:  20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: -40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x:  40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: -40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x:  40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
        effect.element.undoPositioned().setStyle(oldStyle);
  }}) }}) }}) }}) }}) }});
}

Effect.SlideDown = function(element) {
  element = $(element).cleanWhitespace();
  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
  var oldInnerBottom = element.down().getStyle('bottom');
  var elementDimensions = element.getDimensions();
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false, 
    scaleFrom: window.opera ? 0 : 1,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: true,
    afterSetup: function(effect) {
      effect.element.makePositioned();
      effect.element.down().makePositioned();
      if(window.opera) effect.element.setStyle({top: ''});
      effect.element.makeClipping().setStyle({height: '0px'}).show(); 
    },
    afterUpdateInternal: function(effect) {
      effect.element.down().setStyle({bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' }); 
    },
    afterFinishInternal: function(effect) {
      effect.element.undoClipping().undoPositioned();
      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
    }, arguments[1] || {})
  );
}

Effect.SlideUp = function(element) {
  element = $(element).cleanWhitespace();
  var oldInnerBottom = element.down().getStyle('bottom');
  return new Effect.Scale(element, window.opera ? 0 : 1,
   Object.extend({ scaleContent: false, 
    scaleX: false, 
    scaleMode: 'box',
    scaleFrom: 100,
    restoreAfterFinish: true,
    beforeStartInternal: function(effect) {
      effect.element.makePositioned();
      effect.element.down().makePositioned();
      if(window.opera) effect.element.setStyle({top: ''});
      effect.element.makeClipping().show();
    },  
    afterUpdateInternal: function(effect) {
      effect.element.down().setStyle({bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' });
    },
    afterFinishInternal: function(effect) {
      effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
      effect.element.down().undoPositioned();
    }
   }, arguments[1] || {})
  );
}

// Bug in opera makes the TD containing this element expand for a instance after finish 
Effect.Squish = function(element) {
  return new Effect.Scale(element, window.opera ? 1 : 0, { 
    restoreAfterFinish: true,
    beforeSetup: function(effect) {
      effect.element.makeClipping(); 
    },  
    afterFinishInternal: function(effect) {
      effect.element.hide().undoClipping(); 
    }
  });
}

Effect.Grow = function(element) {
  element = $(element);
  var options = Object.extend({
    direction: 'center',
    moveTransition: Effect.Transitions.sinoidal,
    scaleTransition: Effect.Transitions.sinoidal,
    opacityTransition: Effect.Transitions.full
  }, arguments[1] || {});
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    height: element.style.height,
    width: element.style.width,
    opacity: element.getInlineOpacity() };

  var dims = element.getDimensions();    
  var initialMoveX, initialMoveY;
  var moveX, moveY;
  
  switch (options.direction) {
    case 'top-left':
      initialMoveX = initialMoveY = moveX = moveY = 0; 
      break;
    case 'top-right':
      initialMoveX = dims.width;
      initialMoveY = moveY = 0;
      moveX = -dims.width;
      break;
    case 'bottom-left':
      initialMoveX = moveX = 0;
      initialMoveY = dims.height;
      moveY = -dims.height;
      break;
    case 'bottom-right':
      initialMoveX = dims.width;
      initialMoveY = dims.height;
      moveX = -dims.width;
      moveY = -dims.height;
      break;
    case 'center':
      initialMoveX = dims.width / 2;
      initialMoveY = dims.height / 2;
      moveX = -dims.width / 2;
      moveY = -dims.height / 2;
      break;
  }
  
  return new Effect.Move(element, {
    x: initialMoveX,
    y: initialMoveY,
    duration: 0.01, 
    beforeSetup: function(effect) {
      effect.element.hide().makeClipping().makePositioned();
    },
    afterFinishInternal: function(effect) {
      new Effect.Parallel(
        [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
          new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
          new Effect.Scale(effect.element, 100, {
            scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, 
            sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
        ], Object.extend({
             beforeSetup: function(effect) {
               effect.effects[0].element.setStyle({height: '0px'}).show(); 
             },
             afterFinishInternal: function(effect) {
               effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); 
             }
           }, options)
      )
    }
  });
}

Effect.Shrink = function(element) {
  element = $(element);
  var options = Object.extend({
    direction: 'center',
    moveTransition: Effect.Transitions.sinoidal,
    scaleTransition: Effect.Transitions.sinoidal,
    opacityTransition: Effect.Transitions.none
  }, arguments[1] || {});
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    height: element.style.height,
    width: element.style.width,
    opacity: element.getInlineOpacity() };

  var dims = element.getDimensions();
  var moveX, moveY;
  
  switch (options.direction) {
    case 'top-left':
      moveX = moveY = 0;
      break;
    case 'top-right':
      moveX = dims.width;
      moveY = 0;
      break;
    case 'bottom-left':
      moveX = 0;
      moveY = dims.height;
      break;
    case 'bottom-right':
      moveX = dims.width;
      moveY = dims.height;
      break;
    case 'center':  
      moveX = dims.width / 2;
      moveY = dims.height / 2;
      break;
  }
  
  return new Effect.Parallel(
    [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
      new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
      new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
    ], Object.extend({            
         beforeStartInternal: function(effect) {
           effect.effects[0].element.makePositioned().makeClipping(); 
         },
         afterFinishInternal: function(effect) {
           effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
       }, options)
  );
}

Effect.Pulsate = function(element) {
  element = $(element);
  var options    = arguments[1] || {};
  var oldOpacity = element.getInlineOpacity();
  var transition = options.transition || Effect.Transitions.sinoidal;
  var reverser   = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) };
  reverser.bind(transition);
  return new Effect.Opacity(element, 
    Object.extend(Object.extend({  duration: 2.0, from: 0,
      afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
    }, options), {transition: reverser}));
}

Effect.Fold = function(element) {
  element = $(element);
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    width: element.style.width,
    height: element.style.height };
  element.makeClipping();
  return new Effect.Scale(element, 5, Object.extend({   
    scaleContent: false,
    scaleX: false,
    afterFinishInternal: function(effect) {
    new Effect.Scale(element, 1, { 
      scaleContent: false, 
      scaleY: false,
      afterFinishInternal: function(effect) {
        effect.element.hide().undoClipping().setStyle(oldStyle);
      } });
  }}, arguments[1] || {}));
};

Effect.Morph = Class.create();
Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      style: {}
    }, arguments[1] || {});
    if (typeof options.style == 'string') {
      if(options.style.indexOf(':') == -1) {
        var cssText = '', selector = '.' + options.style;
        $A(document.styleSheets).reverse().each(function(styleSheet) {
          if (styleSheet.cssRules) cssRules = styleSheet.cssRules;
          else if (styleSheet.rules) cssRules = styleSheet.rules;
          $A(cssRules).reverse().each(function(rule) {
            if (selector == rule.selectorText) {
              cssText = rule.style.cssText;
              throw $break;
            }
          });
          if (cssText) throw $break;
        });
        this.style = cssText.parseStyle();
        options.afterFinishInternal = function(effect){
          effect.element.addClassName(effect.options.style);
          effect.transforms.each(function(transform) {
            if(transform.style != 'opacity')
              effect.element.style[transform.style] = '';
          });
        }
      } else this.style = options.style.parseStyle();
    } else this.style = $H(options.style)
    this.start(options);
  },
  setup: function(){
    function parseColor(color){
      if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
      color = color.parseColor();
      return $R(0,2).map(function(i){
        return parseInt( color.slice(i*2+1,i*2+3), 16 ) 
      });
    }
    this.transforms = this.style.map(function(pair){
      var property = pair[0], value = pair[1], unit = null;

      if(value.parseColor('#zzzzzz') != '#zzzzzz') {
        value = value.parseColor();
        unit  = 'color';
      } else if(property == 'opacity') {
        value = parseFloat(value);
        if(Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
          this.element.setStyle({zoom: 1});
      } else if(Element.CSS_LENGTH.test(value)) {
          var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
          value = parseFloat(components[1]);
          unit = (components.length == 3) ? components[2] : null;
      }

      var originalValue = this.element.getStyle(property);
      return { 
        style: property.camelize(), 
        originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), 
        targetValue: unit=='color' ? parseColor(value) : value,
        unit: unit
      };
    }.bind(this)).reject(function(transform){
      return (
        (transform.originalValue == transform.targetValue) ||
        (
          transform.unit != 'color' &&
          (isNaN(transform.originalValue) || isNaN(transform.targetValue))
        )
      )
    });
  },
  update: function(position) {
    var style = {}, transform, i = this.transforms.length;
    while(i--)
      style[(transform = this.transforms[i]).style] = 
        transform.unit=='color' ? '#'+
          (Math.round(transform.originalValue[0]+
            (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() +
          (Math.round(transform.originalValue[1]+
            (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +
          (Math.round(transform.originalValue[2]+
            (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :
        transform.originalValue + Math.round(
          ((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit;
    this.element.setStyle(style, true);
  }
});

Effect.Transform = Class.create();
Object.extend(Effect.Transform.prototype, {
  initialize: function(tracks){
    this.tracks  = [];
    this.options = arguments[1] || {};
    this.addTracks(tracks);
  },
  addTracks: function(tracks){
    tracks.each(function(track){
      var data = $H(track).values().first();
      this.tracks.push($H({
        ids:     $H(track).keys().first(),
        effect:  Effect.Morph,
        options: { style: data }
      }));
    }.bind(this));
    return this;
  },
  play: function(){
    return new Effect.Parallel(
      this.tracks.map(function(track){
        var elements = [$(track.ids) || $$(track.ids)].flatten();
        return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.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 element = document.createElement('div');
  element.innerHTML = '<div style="' + this + '"></div>';
  var style = element.childNodes[0].style, styleRules = $H();
  
  Element.CSS_PROPERTIES.each(function(property){
    if(style[property]) styleRules[property] = style[property]; 
  });
  if(Prototype.Browser.IE && this.indexOf('opacity') > -1) {
    styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
  }
  return styleRules;
};

Element.morph = function(element, style) {
  new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {}));
  return element;
};

['getInlineOpacity','forceRerendering','setContentZoom',
 'collectTextNodes','collectTextNodesIgnoreClass','morph'].each( 
  function(f) { Element.Methods[f] = Element[f]; }
);

Element.Methods.visualEffect = function(element, effect, options) {
  s = effect.dasherize().camelize();
  effect_class = s.charAt(0).toUpperCase() + s.substring(1);
  new Effect[effect_class](element, options);
  return $(element);
};

Element.addMethods();