var Prototype={Version:"1.4.0",ScriptFragment:"(?:<script.*?>)((\n|\r|.)*?)(?:</script>)",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(property in _3){
_2[property]=_3[property];
}
return _2;
};
Object.inspect=function(_4){
try{
if(_4==undefined){
return "undefined";
}
if(_4==null){
return "null";
}
return _4.inspect?_4.inspect():_4.toString();
}
catch(e){
if(e instanceof RangeError){
return "...";
}
throw e;
}
};
Function.prototype.bind=function(){
var _5=this,_6=$A(arguments),_7=_6.shift();
return function(){
return _5.apply(_7,_6.concat($A(arguments)));
};
};
Function.prototype.bindAsEventListener=function(_8){
var _9=this;
return function(_a){
return _9.call(_8,_a||window.event);
};
};
Object.extend(Number.prototype,{toColorPart:function(){
var _b=this.toString(16);
if(this<16){
return "0"+_b;
}
return _b;
},succ:function(){
return this+1;
},times:function(_c){
$R(0,this,true).each(_c);
return this;
}});
var Try={these:function(){
var _d;
for(var i=0;i<arguments.length;i++){
var _f=arguments[i];
try{
_d=_f();
break;
}
catch(e){
}
}
return _d;
}};
function $E(_10,a,b,c){
if(_10.substr(0,1)=="="){
return function(x,y,z){
return eval(_10.substr(1));
};
}else{
return function(x,y,z){
eval(_10);
};
}
}
var PeriodicalExecuter=Class.create();
PeriodicalExecuter.prototype={initialize:function(_1a,_1b){
this.callback=_1a;
this.frequency=_1b;
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;
}
}
}};
function $(){
var _1c=new Array();
for(var i=0;i<arguments.length;i++){
var _1e=arguments[i];
if(typeof _1e=="string"){
_1e=document.getElementById(_1e);
}
if(arguments.length==1){
return _1e;
}
_1c.push(_1e);
}
return _1c;
}
Object.extend(String.prototype,{stripTags:function(){
return this.replace(/<\/?[^>]+>/gi,"");
},stripScripts:function(){
return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"");
},extractScripts:function(){
var _1f=new RegExp(Prototype.ScriptFragment,"img");
var _20=new RegExp(Prototype.ScriptFragment,"im");
return (this.match(_1f)||[]).map(function(_21){
return (_21.match(_20)||["",""])[1];
});
},evalScripts:function(){
return this.extractScripts().map(eval);
},escapeHTML:function(){
var div=document.createElement("div");
var _23=document.createTextNode(this);
div.appendChild(_23);
return div.innerHTML;
},unescapeHTML:function(){
var div=document.createElement("div");
div.innerHTML=this.stripTags();
return div.childNodes[0]?div.childNodes[0].nodeValue:"";
},toQueryParams:function(){
var _25=this.match(/^\??(.*)$/)[1].split("&");
return _25.inject({},function(_26,_27){
var _28=_27.split("=");
_26[_28[0]]=_28[1];
return _26;
});
},toArray:function(){
return this.split("");
},camelize:function(){
var _29=this.split("-");
if(_29.length==1){
return _29[0];
}
var _2a=this.indexOf("-")==0?_29[0].charAt(0).toUpperCase()+_29[0].substring(1):_29[0];
for(var i=1,len=_29.length;i<len;i++){
var s=_29[i];
_2a+=s.charAt(0).toUpperCase()+s.substring(1);
}
return _2a;
},inspect:function(){
return "'"+this.replace("\\","\\\\").replace("'","\\'")+"'";
}});
String.prototype.parseQuery=String.prototype.toQueryParams;
var $break=new Object();
var $continue=new Object();
var Enumerable={each:function(_2e){
var _2f=0;
try{
this._each(function(_30){
try{
if(_30!==undefined){
_2e(_30,_2f);
}
_2f++;
}
catch(e){
if(e!=$continue){
throw e;
}
}
});
}
catch(e){
if(e!=$break){
throw e;
}
}
},all:function(_31){
var _32=true;
this.each(function(_33,_34){
_32=_32&&!!(_31||Prototype.K)(_33,_34);
if(!_32){
throw $break;
}
});
return _32;
},any:function(_35){
var _36=true;
this.each(function(_37,_38){
if(_36=!!(_35||Prototype.K)(_37,_38)){
throw $break;
}
});
return _36;
},collect:function(_39){
var _3a=[];
this.each(function(_3b,_3c){
_3a.push(_39(_3b,_3c));
});
return _3a;
},detect:function(_3d){
var _3e;
this.each(function(_3f,_40){
if(_3d(_3f,_40)){
_3e=_3f;
throw $break;
}
});
return _3e;
},findAll:function(_41){
var _42=[];
this.each(function(_43,_44){
if(_41(_43,_44)){
_42.push(_43);
}
});
return _42;
},grep:function(_45,_46){
var _47=[];
this.each(function(_48,_49){
var _4a=_48.toString();
if(_4a.match(_45)){
_47.push((_46||Prototype.K)(_48,_49));
}
});
return _47;
},include:function(_4b){
var _4c=false;
this.each(function(_4d){
if(_4d==_4b){
_4c=true;
throw $break;
}
});
return _4c;
},inject:function(_4e,_4f){
this.each(function(_50,_51){
_4e=_4f(_4e,_50,_51);
});
return _4e;
},invoke:function(_52){
var _53=$A(arguments).slice(1);
return this.collect(function(_54){
return _54[_52].apply(_54,_53);
});
},max:function(_55){
var _56;
this.each(function(_57,_58){
_57=(_55||Prototype.K)(_57,_58);
if(_57>=(_56||_57)){
_56=_57;
}
});
return _56;
},min:function(_59){
var _5a;
this.each(function(_5b,_5c){
_5b=(_59||Prototype.K)(_5b,_5c);
if(_5b<=(_5a||_5b)){
_5a=_5b;
}
});
return _5a;
},partition:function(_5d){
var _5e=[],_5f=[];
this.each(function(_60,_61){
((_5d||Prototype.K)(_60,_61)?_5e:_5f).push(_60);
});
return [_5e,_5f];
},pluck:function(_62){
var _63=[];
this.each(function(_64,_65){
_63.push(_64[_62]);
});
return _63;
},reject:function(_66){
var _67=[];
this.each(function(_68,_69){
if(!_66(_68,_69)){
_67.push(_68);
}
});
return _67;
},sortBy:function(_6a){
return this.collect(function(_6b,_6c){
return {value:_6b,criteria:_6a(_6b,_6c)};
}).sort(function(_6d,_6e){
var a=_6d.criteria,b=_6e.criteria;
return a<b?-1:a>b?1:0;
}).pluck("value");
},toArray:function(){
return this.collect(Prototype.K);
},zip:function(){
var _71=Prototype.K,_72=$A(arguments);
if(typeof _72.last()=="function"){
_71=_72.pop();
}
var _73=[this].concat(_72).map($A);
return this.map(function(_74,_75){
_71(_74=_73.pluck(_75));
return _74;
});
},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(_76){
if(!_76){
return [];
}
if(_76.toArray){
return _76.toArray();
}else{
var _77=[];
for(var i=0;i<_76.length;i++){
_77.push(_76[i]);
}
return _77;
}
};
Object.extend(Array.prototype,Enumerable);
Array.prototype._reverse=Array.prototype.reverse;
Object.extend(Array.prototype,{_each:function(_79){
for(var i=0;i<this.length;i++){
_79(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(_7b){
return _7b!=undefined||_7b!=null;
});
},flatten:function(){
return this.inject([],function(_7c,_7d){
return _7c.concat(_7d.constructor==Array?_7d.flatten():[_7d]);
});
},without:function(){
var _7e=$A(arguments);
return this.select(function(_7f){
return !_7e.include(_7f);
});
},indexOf:function(_80){
for(var i=0;i<this.length;i++){
if(this[i]==_80){
return i;
}
}
return -1;
},reverse:function(_82){
return (_82!==false?this:this.toArray())._reverse();
},shift:function(){
var _83=this[0];
for(var i=0;i<this.length-1;i++){
this[i]=this[i+1];
}
this.length--;
return _83;
},inspect:function(){
return "["+this.map(Object.inspect).join(", ")+"]";
}});
var Hash={_each:function(_85){
for(key in this){
var _86=this[key];
if(typeof _86=="function"){
continue;
}
var _87=[key,_86];
_87.key=key;
_87.value=_86;
_85(_87);
}
},keys:function(){
return this.pluck("key");
},values:function(){
return this.pluck("value");
},merge:function(_88){
return $H(_88).inject($H(this),function(_89,_8a){
_89[_8a.key]=_8a.value;
return _89;
});
},toQueryString:function(){
return this.map(function(_8b){
return _8b.map(encodeURIComponent).join("=");
}).join("&");
},inspect:function(){
return "#<Hash:{"+this.map(function(_8c){
return _8c.map(Object.inspect).join(": ");
}).join(", ")+"}>";
}};
function $H(_8d){
var _8e=Object.extend({},_8d||{});
Object.extend(_8e,Enumerable);
Object.extend(_8e,Hash);
return _8e;
}
ObjectRange=Class.create();
Object.extend(ObjectRange.prototype,Enumerable);
Object.extend(ObjectRange.prototype,{initialize:function(_8f,end,_91){
this.start=_8f;
this.end=end;
this.exclusive=_91;
},_each:function(_92){
var _93=this.start;
do{
_92(_93);
_93=_93.succ();
}while(this.include(_93));
},include:function(_94){
if(_94<this.start){
return false;
}
if(this.exclusive){
return _94<this.end;
}
return _94<=this.end;
}});
var $R=function(_95,end,_97){
return new ObjectRange(_95,end,_97);
};
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(_98){
this.responders._each(_98);
},register:function(_99){
if(!this.include(_99)){
this.responders.push(_99);
}
},unregister:function(_9a){
this.responders=this.responders.without(_9a);
},dispatch:function(_9b,_9c,_9d,_9e){
this.each(function(_9f){
if(_9f[_9b]&&typeof _9f[_9b]=="function"){
try{
_9f[_9b].apply(_9f,[_9c,_9d,_9e]);
}
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(_a0){
this.options={method:"post",asynchronous:true,parameters:""};
Object.extend(this.options,_a0||{});
},responseIsSuccess:function(){
return this.transport.status==undefined||this.transport.status==0||(this.transport.status>=200&&this.transport.status<300);
},responseIsFailure:function(){
return !this.responseIsSuccess();
}};
Ajax.Request=Class.create();
Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];
Ajax.Request.prototype=Object.extend(new Ajax.Base(),{initialize:function(url,_a2){
this.transport=Ajax.getTransport();
this.setOptions(_a2);
this.request(url);
},request:function(url){
var _a4=this.options.parameters||"";
if(_a4.length>0){
_a4+="&_=";
}
try{
this.url=url;
if(this.options.method=="get"&&_a4.length>0){
this.url+=(this.url.match(/\?/)?"&":"?")+_a4;
}
Ajax.Responders.dispatch("onCreate",this,this.transport);
this.transport.open(this.options.method,this.url,this.options.asynchronous);
if(this.options.asynchronous){
this.transport.onreadystatechange=this.onStateChange.bind(this);
setTimeout((function(){
this.respondToReadyState(1);
}).bind(this),10);
}
this.setRequestHeaders();
var _a5=this.options.postBody?this.options.postBody:_a4;
this.transport.send(this.options.method=="post"?_a5:null);
}
catch(e){
this.dispatchException(e);
}
},setRequestHeaders:function(){
var _a6=["X-Requested-With","XMLHttpRequest","X-Prototype-Version",Prototype.Version];
if(this.options.method=="post"){
_a6.push("Content-type","application/x-www-form-urlencoded");
if(this.transport.overrideMimeType){
_a6.push("Connection","close");
}
}
if(this.options.requestHeaders){
_a6.push.apply(_a6,this.options.requestHeaders);
}
for(var i=0;i<_a6.length;i+=2){
this.transport.setRequestHeader(_a6[i],_a6[i+1]);
}
},onStateChange:function(){
var _a8=this.transport.readyState;
if(_a8!=1){
this.respondToReadyState(this.transport.readyState);
}
},header:function(_a9){
try{
return this.transport.getResponseHeader(_a9);
}
catch(e){
}
},evalJSON:function(){
try{
return eval(this.header("X-JSON"));
}
catch(e){
}
},evalResponse:function(){
try{
return eval(this.transport.responseText);
}
catch(e){
this.dispatchException(e);
}
},respondToReadyState:function(_aa){
var _ab=Ajax.Request.Events[_aa];
var _ac=this.transport,_ad=this.evalJSON();
if(_ab=="Complete"){
try{
(this.options["on"+this.transport.status]||this.options["on"+(this.responseIsSuccess()?"Success":"Failure")]||Prototype.emptyFunction)(_ac,_ad);
}
catch(e){
this.dispatchException(e);
}
if((this.header("Content-type")||"").match(/^text\/javascript/i)){
this.evalResponse();
}
}
try{
(this.options["on"+_ab]||Prototype.emptyFunction)(_ac,_ad);
Ajax.Responders.dispatch("on"+_ab,this,_ac,_ad);
}
catch(e){
this.dispatchException(e);
}
if(_ab=="Complete"){
this.transport.onreadystatechange=Prototype.emptyFunction;
}
},dispatchException:function(_ae){
(this.options.onException||Prototype.emptyFunction)(this,_ae);
Ajax.Responders.dispatch("onException",this,_ae);
}});
Ajax.Updater=Class.create();
Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(_af,url,_b1){
this.containers={success:_af.success?$(_af.success):$(_af),failure:_af.failure?$(_af.failure):(_af.success?null:$(_af))};
this.transport=Ajax.getTransport();
this.setOptions(_b1);
var _b2=this.options.onComplete||Prototype.emptyFunction;
this.options.onComplete=(function(_b3,_b4){
this.updateContent();
_b2(_b3,_b4);
}).bind(this);
this.request(url);
},updateContent:function(){
var _b5=this.responseIsSuccess()?this.containers.success:this.containers.failure;
var _b6=this.transport.responseText;
if(!this.options.evalScripts){
_b6=_b6.stripScripts();
}
if(_b5){
if(this.options.insertion){
new this.options.insertion(_b5,_b6);
}else{
Element.update(_b5,_b6);
}
}
if(this.responseIsSuccess()){
if(this.onComplete){
setTimeout(this.onComplete.bind(this),10);
}
}
}});
Ajax.PeriodicalUpdater=Class.create();
Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(_b7,url,_b9){
this.setOptions(_b9);
this.onComplete=this.options.onComplete;
this.frequency=(this.options.frequency||2);
this.decay=(this.options.decay||1);
this.updater={};
this.container=_b7;
this.url=url;
this.start();
},start:function(){
this.options.onComplete=this.updateComplete.bind(this);
this.onTimerEvent();
},stop:function(){
this.updater.onComplete=undefined;
clearTimeout(this.timer);
(this.onComplete||Prototype.emptyFunction).apply(this,arguments);
},updateComplete:function(_ba){
if(this.options.decay){
this.decay=(_ba.responseText==this.lastText?this.decay*this.options.decay:1);
this.lastText=_ba.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);
}});
document.getElementsByClassName=function(_bb,_bc){
var _bd=($(_bc)||document.body).getElementsByTagName("*");
return $A(_bd).inject([],function(_be,_bf){
if(_bf.className.match(new RegExp("(^|\\s)"+_bb+"(\\s|$)"))){
_be.push(_bf);
}
return _be;
});
};
if(!window.Element){
var Element=new Object();
}
Object.extend(Element,{visible:function(_c0){
return $(_c0).style.display!="none";
},toggle:function(){
for(var i=0;i<arguments.length;i++){
var _c2=$(arguments[i]);
Element[Element.visible(_c2)?"hide":"show"](_c2);
}
},hide:function(){
for(var i=0;i<arguments.length;i++){
var _c4=$(arguments[i]);
_c4.style.display="none";
}
},show:function(){
for(var i=0;i<arguments.length;i++){
var _c6=$(arguments[i]);
_c6.style.display="";
}
},remove:function(_c7){
_c7=$(_c7);
_c7.parentNode.removeChild(_c7);
},update:function(_c8,_c9){
$(_c8).innerHTML=_c9.stripScripts();
setTimeout(function(){
_c9.evalScripts();
},10);
},getHeight:function(_ca){
_ca=$(_ca);
return _ca.offsetHeight;
},classNames:function(_cb){
return new Element.ClassNames(_cb);
},hasClassName:function(_cc,_cd){
if(!(_cc=$(_cc))){
return;
}
return Element.classNames(_cc).include(_cd);
},addClassName:function(_ce,_cf){
if(!(_ce=$(_ce))){
return;
}
return Element.classNames(_ce).add(_cf);
},removeClassName:function(_d0,_d1){
if(!(_d0=$(_d0))){
return;
}
return Element.classNames(_d0).remove(_d1);
},cleanWhitespace:function(_d2){
_d2=$(_d2);
for(var i=0;i<_d2.childNodes.length;i++){
var _d4=_d2.childNodes[i];
if(_d4.nodeType==3&&!/\S/.test(_d4.nodeValue)){
Element.remove(_d4);
}
}
},empty:function(_d5){
return $(_d5).innerHTML.match(/^\s*$/);
},scrollTo:function(_d6){
_d6=$(_d6);
var x=_d6.x?_d6.x:_d6.offsetLeft,y=_d6.y?_d6.y:_d6.offsetTop;
window.scrollTo(x,y);
},getStyle:function(_d9,_da){
_d9=$(_d9);
var _db=_d9.style[_da.camelize()];
if(!_db){
if(document.defaultView&&document.defaultView.getComputedStyle){
var css=document.defaultView.getComputedStyle(_d9,null);
_db=css?css.getPropertyValue(_da):null;
}else{
if(_d9.currentStyle){
_db=_d9.currentStyle[_da.camelize()];
}
}
}
if(window.opera&&["left","top","right","bottom"].include(_da)){
if(Element.getStyle(_d9,"position")=="static"){
_db="auto";
}
}
return _db=="auto"?null:_db;
},setStyle:function(_dd,_de){
_dd=$(_dd);
for(name in _de){
_dd.style[name.camelize()]=_de[name];
}
},getDimensions:function(_df){
_df=$(_df);
if(Element.getStyle(_df,"display")!="none"){
return {width:_df.offsetWidth,height:_df.offsetHeight};
}
var els=_df.style;
var _e1=els.visibility;
var _e2=els.position;
els.visibility="hidden";
els.position="absolute";
els.display="";
var _e3=_df.clientWidth;
var _e4=_df.clientHeight;
els.display="none";
els.position=_e2;
els.visibility=_e1;
return {width:_e3,height:_e4};
},makePositioned:function(_e5){
_e5=$(_e5);
var pos=Element.getStyle(_e5,"position");
if(pos=="static"||!pos){
_e5._madePositioned=true;
_e5.style.position="relative";
if(window.opera){
_e5.style.top=0;
_e5.style.left=0;
}
}
},undoPositioned:function(_e7){
_e7=$(_e7);
if(_e7._madePositioned){
_e7._madePositioned=undefined;
_e7.style.position=_e7.style.top=_e7.style.left=_e7.style.bottom=_e7.style.right="";
}
},makeClipping:function(_e8){
_e8=$(_e8);
if(_e8._overflow){
return;
}
_e8._overflow=_e8.style.overflow;
if((Element.getStyle(_e8,"overflow")||"visible")!="hidden"){
_e8.style.overflow="hidden";
}
},undoClipping:function(_e9){
_e9=$(_e9);
if(_e9._overflow){
return;
}
_e9.style.overflow=_e9._overflow;
_e9._overflow=undefined;
}});
var Toggle=new Object();
Toggle.display=Element.toggle;
Abstract.Insertion=function(_ea){
this.adjacency=_ea;
};
Abstract.Insertion.prototype={initialize:function(_eb,_ec){
this.element=$(_eb);
this.content=_ec.stripScripts();
if(this.adjacency&&this.element.insertAdjacentHTML){
try{
this.element.insertAdjacentHTML(this.adjacency,this.content);
}
catch(e){
if(this.element.tagName.toLowerCase()=="tbody"){
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(){
_ec.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(_ee){
_ee.each((function(_ef){
this.element.parentNode.insertBefore(_ef,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(_f0){
_f0.reverse(false).each((function(_f1){
this.element.insertBefore(_f1,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(_f2){
_f2.each((function(_f3){
this.element.appendChild(_f3);
}).bind(this));
}});
Insertion.After=Class.create();
Insertion.After.prototype=Object.extend(new Abstract.Insertion("afterEnd"),{initializeRange:function(){
this.range.setStartAfter(this.element);
},insertContent:function(_f4){
_f4.each((function(_f5){
this.element.parentNode.insertBefore(_f5,this.element.nextSibling);
}).bind(this));
}});
Element.ClassNames=Class.create();
Element.ClassNames.prototype={initialize:function(_f6){
this.element=$(_f6);
},_each:function(_f7){
this.element.className.split(/\s+/).select(function(_f8){
return _f8.length>0;
})._each(_f7);
},set:function(_f9){
this.element.className=_f9;
},add:function(_fa){
if(this.include(_fa)){
return;
}
this.set(this.toArray().concat(_fa).join(" "));
},remove:function(_fb){
if(!this.include(_fb)){
return;
}
this.set(this.select(function(_fc){
return _fc!=_fb;
}).join(" "));
},toString:function(){
return this.toArray().join(" ");
}};
Object.extend(Element.ClassNames.prototype,Enumerable);
var Field={clear:function(){
for(var i=0;i<arguments.length;i++){
$(arguments[i]).value="";
}
},focus:function(_fe){
$(_fe).focus();
},present:function(){
for(var i=0;i<arguments.length;i++){
if($(arguments[i]).value==""){
return false;
}
}
return true;
},select:function(_100){
$(_100).select();
},activate:function(_101){
_101=$(_101);
_101.focus();
if(_101.select){
_101.select();
}
}};
var Form={serialize:function(form){
var _103=Form.getElements($(form));
var _104=new Array();
for(var i=0;i<_103.length;i++){
var _106=Form.Element.serialize(_103[i]);
if(_106){
_104.push(_106);
}
}
return _104.join("&");
},getElements:function(form){
form=$(form);
var _108=new Array();
for(tagName in Form.Element.Serializers){
var _109=form.getElementsByTagName(tagName);
for(var j=0;j<_109.length;j++){
_108.push(_109[j]);
}
}
return _108;
},getInputs:function(form,_10c,name){
form=$(form);
var _10e=form.getElementsByTagName("input");
if(!_10c&&!name){
return _10e;
}
var _10f=new Array();
for(var i=0;i<_10e.length;i++){
var _111=_10e[i];
if((_10c&&_111.type!=_10c)||(name&&_111.name!=name)){
continue;
}
_10f.push(_111);
}
return _10f;
},disable:function(form){
var _113=Form.getElements(form);
for(var i=0;i<_113.length;i++){
var _115=_113[i];
_115.blur();
_115.disabled="true";
}
},enable:function(form){
var _117=Form.getElements(form);
for(var i=0;i<_117.length;i++){
var _119=_117[i];
_119.disabled="";
}
},findFirstElement:function(form){
return Form.getElements(form).find(function(_11b){
return _11b.type!="hidden"&&!_11b.disabled&&["input","select","textarea"].include(_11b.tagName.toLowerCase());
});
},focusFirstElement:function(form){
Field.activate(Form.findFirstElement(form));
},reset:function(form){
$(form).reset();
}};
Form.Element={serialize:function(_11e){
_11e=$(_11e);
var _11f=_11e.tagName.toLowerCase();
var _120=Form.Element.Serializers[_11f](_11e);
if(_120){
var key=encodeURIComponent(_120[0]);
if(key.length==0){
return;
}
if(_120[1].constructor!=Array){
_120[1]=[_120[1]];
}
return _120[1].map(function(_122){
return key+"="+encodeURIComponent(_122);
}).join("&");
}
},getValue:function(_123){
_123=$(_123);
var _124=_123.tagName.toLowerCase();
var _125=Form.Element.Serializers[_124](_123);
if(_125){
return _125[1];
}
}};
Form.Element.Serializers={input:function(_126){
switch(_126.type.toLowerCase()){
case "submit":
case "hidden":
case "password":
case "text":
return Form.Element.Serializers.textarea(_126);
case "checkbox":
case "radio":
return Form.Element.Serializers.inputSelector(_126);
}
return false;
},inputSelector:function(_127){
if(_127.checked){
return [_127.name,_127.value];
}
},textarea:function(_128){
return [_128.name,_128.value];
},select:function(_129){
return Form.Element.Serializers[_129.type=="select-one"?"selectOne":"selectMany"](_129);
},selectOne:function(_12a){
var _12b="",opt,_12d=_12a.selectedIndex;
if(_12d>=0){
opt=_12a.options[_12d];
_12b=opt.value;
if(!_12b&&!("value" in opt)){
_12b=opt.text;
}
}
return [_12a.name,_12b];
},selectMany:function(_12e){
var _12f=new Array();
for(var i=0;i<_12e.length;i++){
var opt=_12e.options[i];
if(opt.selected){
var _132=opt.value;
if(!_132&&!("value" in opt)){
_132=opt.text;
}
_12f.push(_132);
}
}
return [_12e.name,_12f];
}};
var $F=Form.Element.getValue;
Abstract.TimedObserver=function(){
};
Abstract.TimedObserver.prototype={initialize:function(_133,_134,_135){
this.frequency=_134;
this.element=$(_133);
this.callback=_135;
this.lastValue=this.getValue();
this.registerCallback();
},registerCallback:function(){
setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},onTimerEvent:function(){
var _136=this.getValue();
if(this.lastValue!=_136){
this.callback(this.element,_136);
this.lastValue=_136;
}
}};
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(_137,_138){
this.element=$(_137);
this.callback=_138;
this.lastValue=this.getValue();
if(this.element.tagName.toLowerCase()=="form"){
this.registerFormCallbacks();
}else{
this.registerCallback(this.element);
}
},onElementEvent:function(){
var _139=this.getValue();
if(this.lastValue!=_139){
this.callback(this.element,_139);
this.lastValue=_139;
}
},registerFormCallbacks:function(){
var _13a=Form.getElements(this.element);
for(var i=0;i<_13a.length;i++){
this.registerCallback(_13a[i]);
}
},registerCallback:function(_13c){
if(_13c.type){
switch(_13c.type.toLowerCase()){
case "checkbox":
case "radio":
Event.observe(_13c,"click",this.onElementEvent.bind(this));
break;
case "password":
case "text":
case "textarea":
case "select-one":
case "select-multiple":
Event.observe(_13c,"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,element:function(_13d){
return _13d.target||_13d.srcElement;
},isLeftClick:function(_13e){
return (((_13e.which)&&(_13e.which==1))||((_13e.button)&&(_13e.button==1)));
},pointerX:function(_13f){
return _13f.pageX||(_13f.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));
},pointerY:function(_140){
return _140.pageY||(_140.clientY+(document.documentElement.scrollTop||document.body.scrollTop));
},stop:function(_141){
if(_141.preventDefault){
_141.preventDefault();
_141.stopPropagation();
}else{
_141.returnValue=false;
_141.cancelBubble=true;
}
},findElement:function(_142,_143){
var _144=Event.element(_142);
while(_144.parentNode&&(!_144.tagName||(_144.tagName.toUpperCase()!=_143.toUpperCase()))){
_144=_144.parentNode;
}
return _144;
},observers:false,_observeAndCache:function(_145,name,_147,_148){
if(!this.observers){
this.observers=[];
}
if(_145.addEventListener){
this.observers.push([_145,name,_147,_148]);
_145.addEventListener(name,_147,_148);
}else{
if(_145.attachEvent){
this.observers.push([_145,name,_147,_148]);
_145.attachEvent("on"+name,_147);
}
}
},unloadCache:function(){
if(!Event.observers){
return;
}
for(var i=0;i<Event.observers.length;i++){
Event.stopObserving.apply(this,Event.observers[i]);
Event.observers[i][0]=null;
}
Event.observers=false;
},observe:function(_14a,name,_14c,_14d){
var _14a=$(_14a);
_14d=_14d||false;
if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_14a.attachEvent)){
name="keydown";
}
this._observeAndCache(_14a,name,_14c,_14d);
},stopObserving:function(_14e,name,_150,_151){
var _14e=$(_14e);
_151=_151||false;
if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_14e.detachEvent)){
name="keydown";
}
if(_14e.removeEventListener){
_14e.removeEventListener(name,_150,_151);
}else{
if(_14e.detachEvent){
_14e.detachEvent("on"+name,_150);
}
}
}});
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(_152){
var _153=0,_154=0;
do{
_153+=_152.scrollTop||0;
_154+=_152.scrollLeft||0;
_152=_152.parentNode;
}while(_152);
return [_154,_153];
},cumulativeOffset:function(_155){
var _156=0,_157=0;
do{
_156+=_155.offsetTop||0;
_157+=_155.offsetLeft||0;
_155=_155.offsetParent;
}while(_155);
return [_157,_156];
},positionedOffset:function(_158){
var _159=0,_15a=0;
do{
_159+=_158.offsetTop||0;
_15a+=_158.offsetLeft||0;
_158=_158.offsetParent;
if(_158){
p=Element.getStyle(_158,"position");
if(p=="relative"||p=="absolute"){
break;
}
}
}while(_158);
return [_15a,_159];
},offsetParent:function(_15b){
if(_15b.offsetParent){
return _15b.offsetParent;
}
if(_15b==document.body){
return _15b;
}
while((_15b=_15b.parentNode)&&_15b!=document.body){
if(Element.getStyle(_15b,"position")!="static"){
return _15b;
}
}
return document.body;
},within:function(_15c,x,y){
if(this.includeScrollOffsets){
return this.withinIncludingScrolloffsets(_15c,x,y);
}
this.xcomp=x;
this.ycomp=y;
this.offset=this.cumulativeOffset(_15c);
return (y>=this.offset[1]&&y<this.offset[1]+_15c.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+_15c.offsetWidth);
},withinIncludingScrolloffsets:function(_15f,x,y){
var _162=this.realOffset(_15f);
this.xcomp=x+_162[0]-this.deltaX;
this.ycomp=y+_162[1]-this.deltaY;
this.offset=this.cumulativeOffset(_15f);
return (this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+_15f.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+_15f.offsetWidth);
},overlap:function(mode,_164){
if(!mode){
return 0;
}
if(mode=="vertical"){
return ((this.offset[1]+_164.offsetHeight)-this.ycomp)/_164.offsetHeight;
}
if(mode=="horizontal"){
return ((this.offset[0]+_164.offsetWidth)-this.xcomp)/_164.offsetWidth;
}
},clone:function(_165,_166){
_165=$(_165);
_166=$(_166);
_166.style.position="absolute";
var _167=this.cumulativeOffset(_165);
_166.style.top=_167[1]+"px";
_166.style.left=_167[0]+"px";
_166.style.width=_165.offsetWidth+"px";
_166.style.height=_165.offsetHeight+"px";
},page:function(_168){
var _169=0,_16a=0;
var _16b=_168;
do{
_169+=_16b.offsetTop||0;
_16a+=_16b.offsetLeft||0;
if(_16b.offsetParent==document.body){
if(Element.getStyle(_16b,"position")=="absolute"){
break;
}
}
}while(_16b=_16b.offsetParent);
_16b=_168;
do{
_169-=_16b.scrollTop||0;
_16a-=_16b.scrollLeft||0;
}while(_16b=_16b.parentNode);
return [_16a,_169];
},clone:function(_16c,_16d){
var _16e=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});
_16c=$(_16c);
var p=Position.page(_16c);
_16d=$(_16d);
var _170=[0,0];
var _171=null;
if(Element.getStyle(_16d,"position")=="absolute"){
_171=Position.offsetParent(_16d);
_170=Position.page(_171);
}
if(_171==document.body){
_170[0]-=document.body.offsetLeft;
_170[1]-=document.body.offsetTop;
}
if(_16e.setLeft){
_16d.style.left=(p[0]-_170[0]+_16e.offsetLeft)+"px";
}
if(_16e.setTop){
_16d.style.top=(p[1]-_170[1]+_16e.offsetTop)+"px";
}
if(_16e.setWidth){
_16d.style.width=_16c.offsetWidth+"px";
}
if(_16e.setHeight){
_16d.style.height=_16c.offsetHeight+"px";
}
},absolutize:function(_172){
_172=$(_172);
if(_172.style.position=="absolute"){
return;
}
Position.prepare();
var _173=Position.positionedOffset(_172);
var top=_173[1];
var left=_173[0];
var _176=_172.clientWidth;
var _177=_172.clientHeight;
_172._originalLeft=left-parseFloat(_172.style.left||0);
_172._originalTop=top-parseFloat(_172.style.top||0);
_172._originalWidth=_172.style.width;
_172._originalHeight=_172.style.height;
_172.style.position="absolute";
_172.style.top=top+"px";
_172.style.left=left+"px";
_172.style.width=_176+"px";
_172.style.height=_177+"px";
},relativize:function(_178){
_178=$(_178);
if(_178.style.position=="relative"){
return;
}
Position.prepare();
_178.style.position="relative";
var top=parseFloat(_178.style.top||0)-(_178._originalTop||0);
var left=parseFloat(_178.style.left||0)-(_178._originalLeft||0);
_178.style.top=top+"px";
_178.style.left=left+"px";
_178.style.height=_178._originalHeight;
_178.style.width=_178._originalWidth;
}};
if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
Position.cumulativeOffset=function(_17b){
var _17c=0,_17d=0;
do{
_17c+=_17b.offsetTop||0;
_17d+=_17b.offsetLeft||0;
if(_17b.offsetParent==document.body){
if(Element.getStyle(_17b,"position")=="absolute"){
break;
}
}
_17b=_17b.offsetParent;
}while(_17b);
return [_17d,_17c];
};
}
Class.create=function(_17e){
var base=function(){
this.initialize.apply(this,arguments);
};
if(_17e){
base.prototype=_17e;
}
if(!_17e||!_17e.initialize){
base.prototype.initialize=Prototype.emptyFunction;
}
return base;
};
Class.extend=function(_180,_181){
var _182=function(){
this.__inits=$A(_182.prototype.__inits);
this.initialize.apply(this,arguments);
};
Object.extend(_182.prototype,_180.prototype);
if(!_182.prototype.superInit){
_182.prototype.__inits=[];
_182.prototype.superInit=function(){
var init=this.__inits.pop();
init.apply(this,arguments);
};
}else{
_182.prototype.__inits=$A(_180.prototype.__inits);
}
_182.prototype.__inits.push(_180.prototype.initialize);
if(_181){
Object.extend(_182.prototype,_181);
}
if(!_181||!_181.initialize){
_182.prototype.initialize=function(){
this.superInit.apply(this,arguments);
};
}
return _182;
};
var JSON={regex:/^("(\\["\\\/bfnrtu]|[^"\\\n\r])*?"|[,:{}\[\] \n\r\t]|(true|false|null[,:}\] \n\r\t])|-?(0|[1-9]\d*)(\.\d+)?([eE](\+|\-)?\d+)?[,:}\] \n\r\t])+?$/,convertToObj:function(json){
var out=new Array();
json.arrayData.each(function(row){
var obj=new Object();
json.colNames.each($E("a[x]=b[y]",obj,row));
out.push(obj);
});
return out;
},parse:function(_188){
if(!_188){
return null;
}
var json;
try{
if(!JSON.regex.test(_188)){
throw $break;
}
json=eval("("+_188+")");
}
catch(e){
json=null;
}
return json;
}};
JSON.Request=Class.extend(Ajax.Request,{initialize:function(url,_18b){
_18b=_18b||{};
this.userOptions=Object.extend({},_18b);
for(var _18c in _18b){
if(/^on\d\d\d$/.test(_18c)){
_18b[_18c]=undefined;
}
}
_18b.onFailure=undefined;
_18b.onSuccess=undefined;
if(_18b.forceReload){
_18b.parameters=_18b.parameters+(_18b.parameters.length>0?"&":"")+"_time="+(new Date()).getTime();
}
_18b.onComplete=this.handleComplete.bind(this);
this.superInit(url,_18b);
},userOptions:null,handleComplete:function(_18d,json){
(this.userOptions["on"+_18d.status]||this.userOptions["on"+((this.responseIsSuccess||this.success).bind(this)()?"Success":"Failure")]||Prototype.emptyFunction)(_18d,json);
if(!json){
json=JSON.parse(_18d.responseText);
}
if(!(this.responseIsSuccess||this.success).bind(this)()||!json||!json.error&&((this.options.jsonNeeded&&this.options.jsonNeeded.any($E("=!a[x]",json)))||(this.options.jsonValidate&&this.options.jsonValidate(json)===false))){
(this.options.onJsonFailure||Prototype.emptyFunction)(_18d,json);
(this.userOptions.onComplete||Prototype.emptyFunction)(_18d,json);
return;
}
(this.userOptions.onComplete||Prototype.emptyFunction)(_18d,json);
if(json.error){
(this.options.onJsonError||Prototype.emptyFunction)(json.error);
return;
}
(this.options.onJsonSuccess||Prototype.emptyFunction)(json);
if(this.options.jsonDispatch){
for(var prop in this.options.jsonDispatch){
if(json[prop]){
this.options.jsonDispatch[prop](json[prop]);
}
}
}
(this.options.onJsonFinish||Prototype.emptyFunction)(json);
}});
var Store={Persistant:{store:null,init:function(){
this.store=globalStorage[location.hostname];
},test:function(){
this.store.setItem("_test","1");
var ret=this.store.getItem("_test").value;
this.store.removeItem("_test");
if(ret!=="1"){
throw $break;
}else{
return true;
}
},set:function(name,_192){
this.store.setItem(name,_192);
},get:function(name){
var item=this.store.getItem(name);
return item?item.value:null;
},erase:function(name){
var val=this.get(name)||true;
this.store.removeItem(name);
return val;
}},Cookie:{init:Prototype.emptyFunction,set:function(name,_198,_199){
var _19a="";
if(_199!=undefined){
var d=new Date();
d.setTime(d.getTime()+(86400000*parseFloat(_199)));
_19a="; expires="+d.toGMTString();
}
document.cookie=escape(name)+"="+escape(_198||"")+_19a;
},get:function(name){
var _19d=document.cookie.match(new RegExp("(^|;)\\s*"+escape(name)+"=([^;\\s]*)"));
return (_19d?unescape(_19d[2]):null);
},erase:function(name){
var _19f=Store.Cookie.get(name)||true;
Store.Cookie.set(name,"",-1);
return _19f;
},test:function(){
if(typeof navigator.cookieEnabled=="boolean"){
if(!navigator.cookieEnabled){
throw $break;
}else{
return true;
}
}
Store.Cookie.set("_test","1");
if(Store.Cookie.erase("_test")!=="1"){
throw $break;
}else{
return true;
}
}},Array:{data:null,init:function(){
this.data=[];
},set:function(name,_1a1){
this.data[name]=_1a1;
},get:function(name){
return this.data[name]||null;
},erase:function(name){
var _1a4=this.data[name]||true;
this.data[name]=undefined;
return _1a4;
}},method:null};
Try.these(function(){
Store.Persistant.init();
Store.Persistant.test();
Object.extend(Store,Store.Persistant);
Store.method="persistant";
},function(){
Store.Cookie.init();
Store.Cookie.test();
Object.extend(Store,Store.Cookie);
Store.method="cookie";
},function(){
Store.Array.init();
Object.extend(Store,Store.Array);
Store.method="array";
});
var StringArray=Class.create({initialize:function(){
this.data=[];
},write:function(){
for(var i=0;i<arguments.length;i++){
this.data.push(arguments[i]);
}
},reset:function(){
this.data=[];
},output:function(){
return this.data.join("");
},outputToElement:function(elem){
elem.innerHTML=this.data.join("");
}});
var ComboOption=Class.create({initialize:function(_1a7,name){
this.value=_1a7;
this.name=name;
}});
var ComboData=Class.create({initialize:function(data){
this.notifyOnChange=[];
this.pairs=[];
this.initd=false;
if(data){
this.setData(data);
}
},clear:function(){
this.pairs.clear();
},add:function(_1aa,name){
this.pairs.push(new ComboOption(_1aa,name));
},done:function(){
this.setData(this.pairs);
},setData:function(data){
this.pairs=data;
this.initd=true;
this.notifyOnChange.invoke("notifyHaveData");
}});
var SavedCombo=Class.create({initialize:function(name,data,_1af,_1b0,_1b1,_1b2){
this.id=SavedCombo.id++;
SavedCombo.combosList[this.id]=this;
this.name=name;
this.data=data;
this.data.notifyOnChange.push(this);
this.onChange=_1af;
this.onReload=_1b0;
this.reloadOpt=_1b1;
this.value=null;
this.showAllOption=_1b2;
if(this.data.initd){
this.notifyHaveData();
}
},display:function(){
if(!this.data.initd){
return;
}
var _1b3=$(this.name+"Container");
this.getValue();
if(_1b3){
_1b3.innerHTML=this.displayHTML();
}
this.getValue();
},displayHTML:function(){
var _1b4=this;
return this.data.pairs.inject("<select id=\""+this.name+"\" "+"name =\""+this.name+"\" "+"onChange=\"SavedCombo.combosList["+this.id+"].change(this.value)\">",function(_1b5,cur,_1b7){
if(cur.value=="all"&&!_1b4.showAllOption){
return _1b5;
}
return _1b5+"<option value=\""+cur.value+"\" "+(_1b4.value==cur.value?"selected=\"selected\"":"")+">"+cur.name+"</option>";
})+(this.reloadOpt?"<option value=\"__reload\">Reload...</option>":"")+"</select>";
},getValue:function(){
if(!this.value||this.value=="__reload"||(!this.showAllOption&&this.value=="all")){
if($(this.name)&&this.data.pairs.pluck("value").include($F(this.name))){
this.value=$F(this.name);
}else{
this.value=this.data.pairs[0].value;
}
}
},change:function(_1b8){
if(this.value==_1b8){
return;
}
this.displayChange(_1b8);
this.value=_1b8;
if(this.value=="__reload"){
this.onReload();
}else{
this.onChange(this.value);
Store.set(this.name,this.value,7);
}
},displayChange:function(_1b9){
if($(this.name)){
$(this.name).value=_1b9;
}
},notifyHaveData:function(){
this.value=Store.get(this.name);
if(!this.data.pairs){
alert("Error: combo "+this.name+" does not have data");
}
if(!this.data.pairs.pluck("value").include(this.value)){
this.value=this.data.pairs[0].value;
}
this.display();
this.onChange(this.value);
}});
Object.extend(SavedCombo,{combosList:[],id:0});
var SavedSelector=Class.extend(SavedCombo,{initialize:function(name,data,_1bc,_1bd,_1be,_1bf,_1c0,_1c1,_1c2){
this.defValue=_1c0;
this.linkClass=_1c1;
this.selLinkClass=_1c2;
this.superInit(name,data,_1bc,_1bd,_1be,_1bf);
},displayHTML:function(){
var _1c3=this;
return this.data.pairs.inject("<div id=\""+this.name+"\">",function(_1c4,cur,_1c6){
if(cur.value=="all"&&!_1c3.showAllOption){
return _1c4;
}
return _1c4+"<div id=\""+_1c3.name+"Div"+cur.value+"\" "+"class=\""+(_1c3.value==cur.value?_1c3.selLinkClass:_1c3.linkClass)+"\">"+"<a id =\""+_1c3.name+"Link"+cur.value+"\" "+"onclick=\"SavedCombo.combosList["+_1c3.id+"].changeSelector("+cur.value+");\" "+"class=\""+(_1c3.value==cur.value?_1c3.selLinkClass:_1c3.linkClass)+"\">"+cur.name+"</a></div>";
})+"</div>";
},getValue:function(){
if(!this.value){
this.value=this.defValue;
}
},changeSelector:function(_1c7){
this.change(_1c7);
},displayChange:function(_1c8){
if($(this.name+"Div"+this.value)){
$(this.name+"Div"+this.value).className=this.linkClass;
}
if($(this.name+"Link"+this.value)){
$(this.name+"Link"+this.value).className=this.linkClass;
}
if($(this.name+"Div"+_1c8)){
$(this.name+"Div"+_1c8).className=this.selLinkClass;
}
if($(this.name+"Link"+_1c8)){
$(this.name+"Link"+_1c8).className=this.selLinkClass;
}
}});
Object.extend(Date,{timeString:function(secs){
if(secs<60){
return ""+secs+" secs";
}else{
if(secs<60*60){
var mins=Math.floor(secs/60);
return (mins>1?mins+" mins":"1 min");
}else{
if(secs<60*60*24){
var _1cb=Math.floor(secs/(60*60));
return (_1cb>1?_1cb+" hours":"1 hour");
}else{
var days=Math.floor(secs/(24*60*60));
return (days>1?days+" days":"1 day");
}
}
}
},timeLongString:function(secs){
if(secs===0||secs>=365*24*60*60){
return "N/A";
}
var _1ce=false;
function strRep(num,unit){
if(num==0&&!_1ce){
return "";
}
_1ce=true;
if(num==1){
return "1 "+unit+" ";
}
return num+" "+unit+"s ";
}
var mins=Math.floor(secs/60)%60;
var _1d2=Math.floor(secs/(60*60))%24;
var days=Math.floor(secs/(24*60*60));
secs=Math.floor(secs%60);
return strRep(days,"day")+strRep(_1d2,"hour")+strRep(mins,"min")+strRep(secs,"sec");
}});
Object.extend(Number.prototype,{toFixedPrecision:function(prec){
var _1d5=prec-Math.floor(Math.log(this.valueOf())/Math.LN10+1);
_1d5=Math.max(_1d5,0);
return this.toFixed(_1d5);
},toFixedIfNeeded:function(_1d6){
var _1d7=this.round(_1d6);
for(var _1d8=_1d6-1;_1d8>=0;_1d8--){
if(Math.abs(this.round(_1d8)-_1d7)>Math.pow10(-_1d6-1)){
return this.toFixed(_1d8+1);
}
}
return this.toFixed(0);
},round:function(_1d9){
return Math.round(this.valueOf()*Math.pow10(_1d9))/Math.pow10(_1d9);
}});
Math.pow10=function(pow){
return Math.pow(10,pow);
};
var SortedTable=Class.create({initialize:function(name,_1dc,_1dd){
this.data={};
this.initd=false;
this.name=name;
this.columns=[];
var _1de=this.columns;
var _1df=0;
var _1e0=undefined;
var _1e1=undefined;
var _1e2=this;
_1dc.each(function(col){
var _1e4={display:col.id,heading:col.id.substr(0,1).toUpperCase().concat(col.id.substr(1)),longHeading:(col.heading?col.heading:col.id.substr(0,1).toUpperCase().concat(col.id.substr(1))),sort:col.id,dir:1,visible:true,defaultVisible:(col.visible===false?false:true),location:_1df,defaultLocation:_1df,defaultSort:false};
_1df+=2;
Object.extend(_1e4,col);
var _1e5=Store.get(_1e2.name+_1e4.id+"Visible");
if(_1e5=="show"){
_1e4.visible=true;
}else{
if(_1e5=="hide"){
_1e4.visible=false;
}
}
_1de.push(_1e4);
if(_1e4.defaultSort){
_1e0=_1e4.sort;
_1e1=_1e4.dir;
}
});
var _1e6=Store.get(this.name+"ColOrder");
if(_1e6!==null){
_1e6.split(",").each(function(_1e7,loc){
var col=_1de.find($E("=x.id==a",_1e7));
if(col){
col.location=loc*2;
}
});
}
this.assignLocations();
if(_1e0===undefined){
_1e0=this.columns[0].sort;
_1e1=this.columns[0].dir;
}
this.defaultSortCol=_1e0;
this.defaultSortDir=_1e1;
this.onRowBegin=$E("=y");
this.onRowEnd=$E("=\"</tr>\"");
this.onCellBegin=$E("=\"<td>\"");
this.onCellEnd=$E("=\"</td>\"");
this.onTableHeader=$E("=\"\"");
this.onChangeWidth=Prototype.emptyFunction;
this.width=null;
this.extraCols=0;
this.showTableControls=false;
if(_1dd){
Object.extend(this,_1dd);
}
this.sortCol=Store.get(this.name+"SortCol");
this.sortDir=Store.get(this.name+"SortDir");
if(!this.columns.map(function(col){
return col.sort;
}).include(this.sortCol)||!(this.sortDir==-1||this.sortDir==1)){
this.sortCol=_1e0;
this.sortDir=_1e1;
}
this.id=SortedTable.id++;
SortedTable.tablesList[this.id]=this;
},sort:function(){
if(this.data.length==0){
return;
}
var _1eb=this.sortDir;
var _1ec=this.sortCol;
var _1ed=null;
var _1ee=function(row){
if(_1ed==null){
_1ed=row;
return true;
}
var ret=(_1eb==1?_1ed[_1ec]<=row[_1ec]:_1ed[_1ec]>=row[_1ec]);
_1ed=row;
return ret;
};
if(!this.data.all(_1ee)){
this.data.sort(function(a,b){
return _1eb*(a[_1ec]>=b[_1ec]?(a[_1ec]>b[_1ec]?1:0):-1);
});
}
},setData:function(data){
this.data=data;
this.initd=true;
},invalidate:function(){
this.initd=false;
$(this.name+"Container").innerHTML="";
},isInitd:function(){
return this.initd;
},display:function(){
if(!this.initd){
return;
}
this.sort();
if(!$(this.name+"Container")){
return;
}
var _1f4=this;
var _1f5=new StringArray();
_1f5.write("<table class=\"dataTable\" id=\"",this.name,"\" ",(this.width?"style=\"width:"+this.width+"\"":""),">");
_1f5.write("<tr class=\"titleRow\"><th colspan=\"",this.countCols(),"\">");
_1f5.write("<div class=\"tableControlHandle\"><img class=\"tableControlImage\" src=\"img/");
_1f5.write((this.showTableControls?"hide":"show"),".png\" ","onclick=\"SortedTable.tablesList[",_1f4.id,"].toggleControls()\" /> ","<a onclick=\"SortedTable.tablesList[",_1f4.id,"].reset()\">R</a> </div>",this.onTableHeader(this.countRows()),"</th></tr>");
_1f5.write("<tr class=\"hiddenColsRow\"",(this.showTableControls&&this.haveInvisibleCols()?">":" style=\"display: none\">"),"<td colspan=\"",this.countCols(),"\">");
this.columns.each(function(col){
if(col.heading&&!col.visible){
_1f5.write("<a onclick=\"SortedTable.tablesList[",_1f4.id,"].showCol('",col.id,"')\">",col.longHeading,"</a> ");
}
});
_1f5.write("</td></tr>");
_1f5.write(this.onRowBegin(SortedTable.tableControlRow,"<tr class=\"tableControlsRow\""+(this.showTableControls?">":" style=\"display: none\">")));
this.columns.each(function(col){
if(col.heading&&col.visible){
_1f5.write("<td>");
_1f5.write("<img class=\"tableControlImage\" src=\"img/ascending.png\" ","onclick=\"SortedTable.tablesList[",_1f4.id,"].setSort('",col.sort,"',1)\" />");
_1f5.write("<img class=\"tableControlImage\" src=\"img/descending.png\" ","onclick=\"SortedTable.tablesList[",_1f4.id,"].setSort('",col.sort,"',-1)\" />");
_1f5.write("<img class=\"tableControlImage\" src=\"img/moveleft.png\" ","onclick=\"SortedTable.tablesList[",_1f4.id,"].moveCol('",col.id,"',-1)\" />");
_1f5.write("<img class=\"tableControlImage\" src=\"img/moveright.png\" ","onclick=\"SortedTable.tablesList[",_1f4.id,"].moveCol('",col.id,"',1)\" />");
_1f5.write("<img class=\"tableControlImage\" src=\"img/hide.png\" ","onclick=\"SortedTable.tablesList[",_1f4.id,"].hideCol('",col.id,"')\" /></td>");
}
});
_1f5.write(this.onRowEnd(SortedTable.tableControlRow));
_1f5.write(this.onRowBegin(SortedTable.colHeadingsRow,"<tr>"));
this.columns.each(function(col){
if((col.heading)&&col.visible){
_1f5.write("<th><a onclick=\"SortedTable.tablesList[",_1f4.id,"].setSort('",col.sort,"',",(_1f4.sortCol==col.sort?_1f4.sortDir*-1:col.dir),")\">",col.heading,"</a></th>");
}
});
_1f5.write(this.onRowEnd(SortedTable.colHeadingsRow));
this.data.each(function(row){
_1f5.write(_1f4.onRowBegin(row,"<tr>"));
return _1f4.columns.each(function(col){
if(col.visible){
_1f5.write(_1f4.onCellBegin(row,col),row[col.display],_1f4.onCellEnd(row,col));
}
});
_1f5.write(_1f4.onRowEnd(row));
});
_1f5.write("</table>");
_1f5.outputToElement($(this.name+"Container"));
},getHeader:function(_1fb){
var _1fc=$(this.name);
if(!_1fc){
throw $break;
}
var rows=document.getElementsByClassName(_1fb,_1fc);
if(rows.length!=1){
throw $break;
}
return rows[0];
},toggleControls:function(){
try{
var _1fe=this.getHeader("tableControlsRow");
if(this.showTableControls){
this.showTableControls=false;
this.getHeader("tableControlHandle").childNodes[0].src="img/show.png";
Element.hide(_1fe);
Element.hide(this.getHeader("hiddenColsRow"));
}else{
this.showTableControls=true;
this.getHeader("tableControlHandle").childNodes[0].src="img/hide.png";
Element.show(_1fe);
if(this.haveInvisibleCols()){
Element.show(this.getHeader("hiddenColsRow"));
}
}
this.onChangeWidth();
}
catch(e){
if(e!=$break){
throw e;
}
}
},setSort:function(col,dir){
Store.set(this.name+"SortCol",col,7);
Store.set(this.name+"SortDir",dir,7);
this.sortCol=col;
this.sortDir=dir;
this.display();
},showCol:function(_201){
Store.set(this.name+_201+"Visible","show",7);
var col=this.columns.find($E("=x.id==a",_201));
col.visible=true;
this.display();
this.onChangeWidth();
},hideCol:function(_203){
Store.set(this.name+_203+"Visible","hide",7);
var col=this.columns.find($E("=x.id==a",_203));
col.visible=false;
this.display();
this.onChangeWidth();
},moveCol:function(_205,dir){
var col=this.columns.find($E("=x.id==a",_205));
var _208=col.location;
var _209;
if(dir<0){
_209=this.columns.findAll($E("=x.visible && x.location < a",_208)).max();
}else{
_209=this.columns.findAll($E("=x.visible && x.location > a",_208)).min();
}
if(!_209){
alert("Can't move past edge of visible screen");
return;
}
var _20a=_209.location+dir;
col.location=_20a;
this.assignLocations();
this.display();
},reset:function(){
Store.erase(this.name+"SortCol");
Store.erase(this.name+"SortDir");
Store.erase(this.name+"ColOrder");
this.sortCol=this.defaultSortCol;
this.sortDir=this.defaultSortDir;
var name=this.name;
this.columns.each(function(col){
col.visible=col.defaultVisible;
col.location=col.defaultLocation;
Store.erase(name+col.id+"Visible");
Store.erase(name+col.id+"Location");
});
this.display();
},assignLocations:function(){
this.columns.sort($E("=x.location-y.location"));
var _20d=this;
this.columns.each(function(col,_20f){
col.location=_20f*2;
});
Store.set(_20d.name+"ColOrder",this.columns.pluck("id").join(","),7);
},haveInvisibleCols:function(){
return !!this.columns.find($E("=!x.visible"));
},countRows:function(){
return this.data.length;
},countCols:function(){
var cols=this.extraCols;
this.columns.each(function(col){
if(col.visible){
cols++;
}
});
return cols;
}});
Object.extend(SortedTable,{tablesList:[],id:0,colHeadingsRow:{isColHeadingsRow:true,isHeadingRow:true},tableControlRow:{isTableControlRow:true,isHeadingRow:true}});
var App={server:(/^(.*\/)[^\/]*$/).exec(document.URL)[1],defaultPage:undefined,readyToRender:function(){
return true;
},displayNothing:Prototype.emptyFunction,callError:function(msg){
alert(msg);
},pageListData:new ComboData(),pageListSelector:null,pagePairs:[],addPage:function(page){
var opt=new ComboOption(page.pageOrder,page.name);
opt.render=page.render;
opt.helpPage=page.helpPage;
App.pagePairs.push(opt);
},needsInit:[],addInit:function(page){
App.needsInit.push(page);
},init:function(){
var a=App;
a.pageListSelector=new SavedSelector("page",a.pageListData,a.render,Prototype.emptyFunction,false,true,a.defaultPage,"pageSelector","pageSelected");
a.pageListData.setData(App.pagePairs);
a.pagePairs.sort(function(a,b){
return a.value-b.value;
});
},onLoad:function(){
App.addInit(App);
App.needsInit.invoke("init");
},render:function(){
var _219;
if(App.readyToRender()&&App.pageListSelector&&(_219=App.pagePairs.find($E("=x.value==a",App.pageListSelector.value)))){
_219.render();
}else{
App.displayNothing();
}
}};
var Commods={groupPairs:[{value:"all",name:"All Commodities"},{value:0,name:"Basic Commodities"},{value:1,name:"Ship Supplies"},{value:2,name:"Herbs"},{value:3,name:"Minerals"},{value:4,name:"Cloth"},{value:5,name:"Dye"},{value:6,name:"Paint"},{value:7,name:"Enamel"},{value:8,name:"Fruit"},{value:9,name:"Gems"}],commodPairs:[[{value:1,name:"Sugar cane"},{value:2,name:"Hemp"},{value:3,name:"Iron"},{value:4,name:"Wood"},{value:5,name:"Stone"},{value:6,name:"Hemp oil"},{value:7,name:"Varnish"},{value:8,name:"Lacquer"}],[{value:9,name:"Swill"},{value:10,name:"Grog"},{value:11,name:"Fine rum"},{value:12,name:"Small cannon balls"},{value:13,name:"Medium cannon balls"},{value:14,name:"Large cannon balls"}],[{value:15,name:"Madder"},{value:16,name:"Old man's beard"},{value:17,name:"Yarrow"},{value:18,name:"Sassafras"},{value:19,name:"Iris root"},{value:20,name:"Weld"},{value:21,name:"Broom flower"},{value:22,name:"Lobelia"},{value:23,name:"Pokeweed berries"},{value:24,name:"Indigo"},{value:25,name:"Elderberries"},{value:26,name:"Cowslip"},{value:27,name:"Lily of the valley"},{value:28,name:"Nettle"},{value:29,name:"Butterfly weed"}],[{value:30,name:"Lorandite"},{value:31,name:"Leushite"},{value:32,name:"Tellurium"},{value:33,name:"Thorianite"},{value:34,name:"Chalcocite"},{value:35,name:"Cubanite"},{value:36,name:"Serandite"},{value:37,name:"Papagoite"},{value:38,name:"Sincosite"},{value:39,name:"Masuyite"},{value:40,name:"Gold ore"},{value:154,name:"Gold nuggets"}],[{value:41,name:"Red cloth"},{value:42,name:"Fine red cloth"},{value:43,name:"Tan cloth"},{value:44,name:"Fine tan cloth"},{value:45,name:"White cloth"},{value:46,name:"Fine white cloth"},{value:47,name:"Black cloth"},{value:48,name:"Fine black cloth"},{value:49,name:"Grey cloth"},{value:50,name:"Fine grey cloth"},{value:51,name:"Yellow cloth"},{value:52,name:"Fine yellow cloth"},{value:53,name:"Pink cloth"},{value:54,name:"Fine pink cloth"},{value:55,name:"Violet cloth"},{value:56,name:"Fine violet cloth"},{value:57,name:"Purple cloth"},{value:58,name:"Fine purple cloth"},{value:59,name:"Navy cloth"},{value:60,name:"Fine navy cloth"},{value:61,name:"Blue cloth"},{value:62,name:"Fine blue cloth"},{value:63,name:"Aqua cloth"},{value:64,name:"Fine aqua cloth"},{value:65,name:"Lime cloth"},{value:66,name:"Fine lime cloth"},{value:67,name:"Green cloth"},{value:68,name:"Fine green cloth"},{value:69,name:"Orange cloth"},{value:70,name:"Fine orange cloth"},{value:71,name:"Maroon cloth"},{value:72,name:"Fine maroon cloth"},{value:73,name:"Brown cloth"},{value:74,name:"Fine brown cloth"},{value:75,name:"Gold cloth"},{value:76,name:"Fine gold cloth"},{value:142,name:"Rose cloth"},{value:143,name:"Fine rose cloth"},{value:138,name:"Lavender cloth"},{value:139,name:"Fine lavender cloth"},{value:140,name:"Mint cloth"},{value:141,name:"Fine mint cloth"},{value:77,name:"Sail cloth"},{value:155,name:"Light green cloth"},{value:156,name:"Fine light green cloth"},{value:157,name:"Magenta cloth"},{value:158,name:"Fine magenta cloth"},{value:169,name:"Lemon cloth"},{value:170,name:"Fine lemon cloth"},{value:171,name:"Peach cloth"},{value:172,name:"Fine peach cloth"},{value:173,name:"Light blue cloth"},{value:174,name:"Fine light blue cloth"},{value:181,name:"Persimmon cloth"},{value:182,name:"Fine persimmon cloth"}],[{value:78,name:"Red dye"},{value:79,name:"Kraken's blood"},{value:80,name:"Yellow dye"},{value:81,name:"Blue dye"},{value:82,name:"Lime dye"},{value:83,name:"Green dye"}],[{value:84,name:"Red paint"},{value:85,name:"Tan paint"},{value:86,name:"White paint"},{value:87,name:"Black paint"},{value:88,name:"Grey paint"},{value:89,name:"Yellow paint"},{value:90,name:"Pink paint"},{value:91,name:"Violet paint"},{value:92,name:"Purple paint"},{value:93,name:"Navy paint"},{value:94,name:"Blue paint"},{value:95,name:"Aqua paint"},{value:96,name:"Lime paint"},{value:97,name:"Green paint"},{value:98,name:"Orange paint"},{value:99,name:"Maroon paint"},{value:100,name:"Brown paint"},{value:101,name:"Gold paint"},{value:159,name:"Rose paint"},{value:160,name:"Lavender paint"},{value:161,name:"Mint paint"},{value:162,name:"Light green paint"},{value:163,name:"Magenta paint"},{value:175,name:"Lemon paint"},{value:176,name:"Peach paint"},{value:177,name:"Light blue paint"},{value:184,name:"Persimmon paint"}],[{value:102,name:"Red enamel"},{value:103,name:"Orange enamel"},{value:104,name:"Yellow enamel"},{value:105,name:"Green enamel"},{value:106,name:"Blue enamel"},{value:107,name:"Purple enamel"},{value:108,name:"White enamel"},{value:109,name:"Black enamel"},{value:152,name:"Tan enamel"},{value:147,name:"Grey enamel"},{value:151,name:"Pink enamel"},{value:153,name:"Violet enamel"},{value:150,name:"Navy enamel"},{value:144,name:"Aqua enamel"},{value:148,name:"Lime enamel"},{value:149,name:"Maroon enamel"},{value:145,name:"Brown enamel"},{value:146,name:"Gold enamel"},{value:164,name:"Lavender enamel"},{value:165,name:"Light green enamel"},{value:166,name:"Magenta enamel"},{value:167,name:"Mint enamel"},{value:168,name:"Rose enamel"},{value:178,name:"Lemon enamel"},{value:179,name:"Peach enamel"},{value:180,name:"Light blue enamel"},{value:183,name:"Persimmon enamel"}],[{value:118,name:"Bananas"},{value:119,name:"Carambolas"},{value:120,name:"Coconuts"},{value:121,name:"Durians"},{value:122,name:"Limes"},{value:123,name:"Mangos"},{value:124,name:"Passion fruit"},{value:125,name:"Pineapples"},{value:126,name:"Pomegranates"},{value:127,name:"Rambutan"}],[{value:110,name:"Coral gems"},{value:111,name:"Diamonds"},{value:112,name:"Emeralds"},{value:113,name:"Jet gems"},{value:114,name:"Opals"},{value:115,name:"Pearls"},{value:116,name:"Rubies"},{value:117,name:"Sapphires"},{value:128,name:"Amber gems"},{value:129,name:"Amethyst gems"},{value:130,name:"Beryls"},{value:131,name:"Jade gems"},{value:132,name:"Jasper gems"},{value:133,name:"Lapis lazuli gems"},{value:134,name:"Moonstones"},{value:135,name:"Quartz gems"},{value:136,name:"Tiger eyes"},{value:137,name:"Topazes"}],[{value:1,name:"Sugar cane",mass:50,volume:100},{value:2,name:"Hemp",mass:125,volume:250},{value:3,name:"Iron",mass:7.8,volume:1},{value:4,name:"Wood",mass:175,volume:250},{value:5,name:"Stone",mass:2.6,volume:1},{value:6,name:"Hemp oil",mass:1,volume:1},{value:7,name:"Varnish",mass:1,volume:1},{value:8,name:"Lacquer",mass:1,volume:1},{value:9,name:"Swill",mass:1,volume:1},{value:10,name:"Grog",mass:1,volume:1},{value:11,name:"Fine rum",mass:1,volume:1},{value:12,name:"Small cannon balls",mass:7.1,volume:1},{value:13,name:"Medium cannon balls",mass:14.2,volume:2},{value:14,name:"Large cannon balls",mass:21.3,volume:3},{value:15,name:"Madder",mass:0.4,volume:1},{value:16,name:"Old man's beard",mass:0.8,volume:1},{value:17,name:"Yarrow",mass:0.2,volume:1},{value:18,name:"Sassafras",mass:0.5,volume:1},{value:19,name:"Iris root",mass:0.3,volume:1},{value:20,name:"Weld",mass:0.3,volume:1},{value:21,name:"Broom flower",mass:0.2,volume:1},{value:22,name:"Lobelia",mass:0.2,volume:1},{value:23,name:"Pokeweed berries",mass:0.3,volume:1},{value:24,name:"Indigo",mass:0.7,volume:1},{value:25,name:"Elderberries",mass:0.7,volume:1},{value:26,name:"Cowslip",mass:0.7,volume:1},{value:27,name:"Lily of the valley",mass:0.3,volume:1},{value:28,name:"Nettle",mass:0.3,volume:1},{value:29,name:"Butterfly weed",mass:0.1,volume:1},{value:30,name:"Lorandite",mass:5.5,volume:1},{value:31,name:"Leushite",mass:4.4,volume:1},{value:32,name:"Tellurium",mass:6.2,volume:1},{value:33,name:"Thorianite",mass:0.1,volume:1},{value:34,name:"Chalcocite",mass:5.7,volume:1},{value:35,name:"Cubanite",mass:4.7,volume:1},{value:36,name:"Serandite",mass:3.4,volume:1},{value:37,name:"Papagoite",mass:3.3,volume:1},{value:38,name:"Sincosite",mass:3,volume:1},{value:39,name:"Masuyite",mass:5.1,volume:1},{value:40,name:"Gold ore",mass:4,volume:1},{value:41,name:"Red cloth",mass:0.7,volume:1},{value:42,name:"Fine red cloth",mass:0.7,volume:1},{value:43,name:"Tan cloth",mass:0.7,volume:1},{value:44,name:"Fine tan cloth",mass:0.7,volume:1},{value:45,name:"White cloth",mass:0.7,volume:1},{value:46,name:"Fine white cloth",mass:0.7,volume:1},{value:47,name:"Black cloth",mass:0.7,volume:1},{value:48,name:"Fine black cloth",mass:0.7,volume:1},{value:49,name:"Grey cloth",mass:0.7,volume:1},{value:50,name:"Fine grey cloth",mass:0.7,volume:1},{value:51,name:"Yellow cloth",mass:0.7,volume:1},{value:52,name:"Fine yellow cloth",mass:0.7,volume:1},{value:53,name:"Pink cloth",mass:0.7,volume:1},{value:54,name:"Fine pink cloth",mass:0.7,volume:1},{value:55,name:"Violet cloth",mass:0.7,volume:1},{value:56,name:"Fine violet cloth",mass:0.7,volume:1},{value:57,name:"Purple cloth",mass:0.7,volume:1},{value:58,name:"Fine purple cloth",mass:0.7,volume:1},{value:59,name:"Navy cloth",mass:0.7,volume:1},{value:60,name:"Fine navy cloth",mass:0.7,volume:1},{value:61,name:"Blue cloth",mass:0.7,volume:1},{value:62,name:"Fine blue cloth",mass:0.7,volume:1},{value:63,name:"Aqua cloth",mass:0.7,volume:1},{value:64,name:"Fine aqua cloth",mass:0.7,volume:1},{value:65,name:"Lime cloth",mass:0.7,volume:1},{value:66,name:"Fine lime cloth",mass:0.7,volume:1},{value:67,name:"Green cloth",mass:0.7,volume:1},{value:68,name:"Fine green cloth",mass:0.7,volume:1},{value:69,name:"Orange cloth",mass:0.7,volume:1},{value:70,name:"Fine orange cloth",mass:0.7,volume:1},{value:71,name:"Maroon cloth",mass:0.7,volume:1},{value:72,name:"Fine maroon cloth",mass:0.7,volume:1},{value:73,name:"Brown cloth",mass:0.7,volume:1},{value:74,name:"Fine brown cloth",mass:0.7,volume:1},{value:75,name:"Gold cloth",mass:0.7,volume:1},{value:76,name:"Fine gold cloth",mass:0.7,volume:1},{value:77,name:"Sail cloth",mass:0.7,volume:1},{value:78,name:"Red dye",mass:1,volume:1},{value:79,name:"Kraken's blood",mass:1,volume:1},{value:80,name:"Yellow dye",mass:1,volume:1},{value:81,name:"Blue dye",mass:1,volume:1},{value:82,name:"Lime dye",mass:1,volume:1},{value:83,name:"Green dye",mass:1,volume:1},{value:84,name:"Red paint",mass:1.2,volume:1},{value:85,name:"Tan paint",mass:1.2,volume:1},{value:86,name:"White paint",mass:1.2,volume:1},{value:87,name:"Black paint",mass:1.2,volume:1},{value:88,name:"Grey paint",mass:1.2,volume:1},{value:89,name:"Yellow paint",mass:1.2,volume:1},{value:90,name:"Pink paint",mass:1.2,volume:1},{value:91,name:"Violet paint",mass:1.2,volume:1},{value:92,name:"Purple paint",mass:1.2,volume:1},{value:93,name:"Navy paint",mass:1.2,volume:1},{value:94,name:"Blue paint",mass:1.2,volume:1},{value:95,name:"Aqua paint",mass:1.2,volume:1},{value:96,name:"Lime paint",mass:1.2,volume:1},{value:97,name:"Green paint",mass:1.2,volume:1},{value:98,name:"Orange paint",mass:1.2,volume:1},{value:99,name:"Maroon paint",mass:1.2,volume:1},{value:100,name:"Brown paint",mass:1.2,volume:1},{value:101,name:"Gold paint",mass:1.2,volume:1},{value:102,name:"Red enamel",mass:5,volume:1},{value:103,name:"Orange enamel",mass:5,volume:1},{value:104,name:"Yellow enamel",mass:5,volume:1},{value:105,name:"Green enamel",mass:5,volume:1},{value:106,name:"Blue enamel",mass:5,volume:1},{value:107,name:"Purple enamel",mass:5,volume:1},{value:108,name:"White enamel",mass:5,volume:1},{value:109,name:"Black enamel",mass:5,volume:1},{value:110,name:"Coral gems",mass:10,volume:1},{value:111,name:"Diamonds",mass:10,volume:1},{value:112,name:"Emeralds",mass:10,volume:1},{value:113,name:"Jet gems",mass:10,volume:1},{value:114,name:"Opals",mass:10,volume:1},{value:115,name:"Pearls",mass:10,volume:1},{value:116,name:"Rubies",mass:10,volume:1},{value:117,name:"Sapphires",mass:10,volume:1},{value:118,name:"Bananas",mass:125,volume:100},{value:119,name:"Carambolas",mass:125,volume:100},{value:120,name:"Coconuts",mass:125,volume:100},{value:121,name:"Durians",mass:125,volume:100},{value:122,name:"Limes",mass:125,volume:100},{value:123,name:"Mangos",mass:125,volume:100},{value:124,name:"Passion fruit",mass:125,volume:100},{value:125,name:"Pineapples",mass:125,volume:100},{value:126,name:"Pomegranates",mass:125,volume:100},{value:127,name:"Rambutan",mass:125,volume:100},{value:128,name:"Amber gems",mass:10,volume:1},{value:129,name:"Amethyst gems",mass:10,volume:1},{value:130,name:"Beryl gems",mass:10,volume:1},{value:131,name:"Jade gems",mass:10,volume:1},{value:132,name:"Jasper gems",mass:10,volume:1},{value:133,name:"Lapis gems",mass:10,volume:1},{value:134,name:"Moonstone gems",mass:10,volume:1},{value:135,name:"Moonstone gems",mass:10,volume:1},{value:136,name:"Tiger eye gems",mass:10,volume:1},{value:137,name:"Topaz gems",mass:10,volume:1},{value:138,name:"Lavender cloth",mass:0.7,volume:1},{value:139,name:"Fine lavender cloth",mass:0.7,volume:1},{value:140,name:"Mint cloth",mass:0.7,volume:1},{value:141,name:"Fine mint cloth",mass:0.7,volume:1},{value:142,name:"Rose cloth",mass:0.7,volume:1},{value:143,name:"Fine rose cloth",mass:0.7,volume:1},{value:144,name:"Aqua enamel",mass:5,volume:1},{value:145,name:"Brown enamel",mass:5,volume:1},{value:146,name:"Gold enamel",mass:5,volume:1},{value:147,name:"Grey enamel",mass:5,volume:1},{value:148,name:"Lime enamel",mass:5,volume:1},{value:149,name:"Maroon enamel",mass:5,volume:1},{value:150,name:"Navy enamel",mass:5,volume:1},{value:151,name:"Pink enamel",mass:5,volume:1},{value:152,name:"Tan enamel",mass:5,volume:1},{value:153,name:"Violet enamel",mass:5,volume:1},{value:154,name:"Gold nuggets",mass:0.4,volume:1},{value:155,name:"Light green cloth",mass:0.7,volume:1},{value:156,name:"Fine light green cloth",mass:0.7,volume:1},{value:157,name:"Magenta cloth",mass:0.7,volume:1},{value:158,name:"Fine magenta cloth",mass:0.7,volume:1},{value:159,name:"Rose paint",mass:1.2,volume:1},{value:160,name:"Lavender paint",mass:1.2,volume:1},{value:161,name:"Mint paint",mass:1.2,volume:1},{value:162,name:"Light green paint",mass:1.2,volume:1},{value:163,name:"Magenta paint",mass:1.2,volume:1},{value:164,name:"Lavender enamel",mass:5,volume:1},{value:165,name:"Light green enamel",mass:5,volume:1},{value:166,name:"Magenta enamel",mass:5,volume:1},{value:167,name:"Mint enamel",mass:5,volume:1},{value:168,name:"Rose enamel",mass:5,volume:1},{value:169,name:"Lemon cloth",mass:0.7,volume:1},{value:170,name:"Fine lemon cloth",mass:0.7,volume:1},{value:171,name:"Peach cloth",mass:0.7,volume:1},{value:172,name:"Fine peach cloth",mass:0.7,volume:1},{value:173,name:"Light blue cloth",mass:0.7,volume:1},{value:174,name:"Fine light blue cloth",mass:0.7,volume:1},{value:175,name:"Lemon paint",mass:1.2,volume:1},{value:176,name:"Peach paint",mass:1.2,volume:1},{value:177,name:"Light blue paint",mass:1.2,volume:1},{value:178,name:"Lemon enamel",mass:5,volume:1},{value:179,name:"Peach enamel",mass:5,volume:1},{value:180,name:"Light blue enamel",mass:5,volume:1},{value:181,name:"Persimmon cloth",mass:0.7,volume:1},{value:182,name:"Fine persimmon cloth",mass:0.7,volume:1},{value:183,name:"Persimmon enamel",mass:5,volume:1},{value:184,name:"Persimmon paint",mass:1.2,volume:1}]],harvestGroupPairs:[{value:"all",name:"All Commodities"},{value:0,name:"Basic Commodities"},{value:2,name:"Herbs"},{value:3,name:"Minerals"}],harvestCommodPairs:{"all":[{value:"all",name:"All Commodities"},{value:1,name:"Sugar cane"},{value:2,name:"Hemp"},{value:3,name:"Iron"},{value:4,name:"Wood"},{value:5,name:"Stone"},{value:15,name:"Madder"},{value:16,name:"Old man's beard"},{value:17,name:"Yarrow"},{value:18,name:"Sassafras"},{value:19,name:"Iris root"},{value:20,name:"Weld"},{value:21,name:"Broom flower"},{value:22,name:"Lobelia"},{value:23,name:"Pokeweed berries"},{value:24,name:"Indigo"},{value:25,name:"Elderberries"},{value:26,name:"Cowslip"},{value:27,name:"Lily of the valley"},{value:28,name:"Nettle"},{value:29,name:"Butterfly weed"},{value:30,name:"Lorandite"},{value:31,name:"Leushite"},{value:32,name:"Tellurium"},{value:33,name:"Thorianite"},{value:34,name:"Chalcocite"},{value:35,name:"Cubanite"},{value:36,name:"Serandite"},{value:37,name:"Papagoite"},{value:38,name:"Sincosite"},{value:39,name:"Masuyite"}],0:[{value:"all",name:"All Basic Commodities"},{value:1,name:"Sugar cane"},{value:2,name:"Hemp"},{value:3,name:"Iron"},{value:4,name:"Wood"},{value:5,name:"Stone"}],2:[{value:"all",name:"All Herbs"},{value:15,name:"Madder"},{value:16,name:"Old man's beard"},{value:17,name:"Yarrow"},{value:18,name:"Sassafras"},{value:19,name:"Iris root"},{value:20,name:"Weld"},{value:21,name:"Broom flower"},{value:22,name:"Lobelia"},{value:23,name:"Pokeweed berries"},{value:24,name:"Indigo"},{value:25,name:"Elderberries"},{value:26,name:"Cowslip"},{value:27,name:"Lily of the valley"},{value:28,name:"Nettle"},{value:29,name:"Butterfly weed"}],3:[{value:"all",name:"All Minerals"},{value:30,name:"Lorandite"},{value:31,name:"Leushite"},{value:32,name:"Tellurium"},{value:33,name:"Thorianite"},{value:34,name:"Chalcocite"},{value:35,name:"Cubanite"},{value:36,name:"Serandite"},{value:37,name:"Papagoite"},{value:38,name:"Sincosite"},{value:39,name:"Masuyite"}]},getCommod:function(id){
var _21b=Commods.all[id-1];
if(_21b.value!=id){
alert("Commodity lookup error");
}
return _21b;
},getGroup:function(id){
var _21d;
Commods.commodPairs.find(function(_21e,_21f){
var _220=_21f;
return _21e?_21e.find(function(_221){
if(_221.value==id){
_21d=_220;
return true;
}
}):false;
});
return _21d;
},all:null,getGroupName:function(id){
var _223=Commods.groupPairs.find($E("=x.value==a",id));
if(_223){
return _223.name;
}else{
return "Unknown Group";
}
},groupData:null,harvestGroupData:null};
Commods.all=Commods.commodPairs[10];
Commods.groupData=new ComboData(Commods.groupPairs);
Commods.harvestGroupData=new ComboData(Commods.harvestGroupPairs);
Object.extend(CommodGroupCombo.prototype,SavedCombo.prototype);
CommodGroupCombo.prototype.parentConstruct=SavedCombo;
function CommodGroupCombo(name,_225){
this.parentConstruct(name,Commods.groupData,function(_226){
if(_226!==null||_226!==undefined){
if(_226=="all"){
_226=10;
}
_225.setData(Commods.commodPairs[_226]);
}
},Prototype.emptyFunction,false,true);
}
Object.extend(CommodCombo.prototype,SavedCombo.prototype);
CommodCombo.prototype.parentConstruct=SavedCombo;
function CommodCombo(name,data){
this.parentConstruct(name,data,Prototype.emptyFunction,Prototype.emptyFunction,false,false);
}
var Ocean={oceanAjax:null,islandAjax:null,reloadingIslands:false,initArchData:[new ComboOption("all","Whole Ocean")],islandPairs:{"all":[new ComboOption("all","Whole Ocean")]},oceanData:new ComboData(),archData:null,oceanCombo:null,init:function(){
Ocean.oceanCombo=new SavedCombo("ocean",Ocean.oceanData,Ocean.changeOcean,Ocean.reloadOceans,true);
Ocean.archData=new ComboData(Ocean.initArchData);
Ocean.getOceans(false);
},getOceans:function(_229){
Ocean.oceanAjax=new JSON.Request(App.server+"oceans.php",{method:"get",forceReload:_229,jsonNeeded:["oceans"],onJsonFailure:$E("App.callError(\"Failed to open ocean data\")"),jsonDispatch:{oceans:Ocean.setOceans}});
},changeOcean:function(_22a){
if(_22a){
Ocean.islandAjax=new JSON.Request(App.server+"islands.php",{method:"get",parameters:"oceanName="+_22a,onJsonFailure:$E("App.callError(\"Failed to open ocean data\")"),jsonNeeded:["islands","arches"],jsonDispatch:{islands:Ocean.setIslands,arches:Ocean.setArches}});
}
App.render();
},reloadOceans:function(){
Ocean.getOceans(true);
},reloadIslands:function(){
if(!Ocean.reloadingIslands){
Ocean.reloadingIslands=true;
Ocean.islandAjax=new JSON.Request(App.server+"islands.php",{method:"get",forceReload:true,parameters:"oceanName="+Ocean.oceanCombo.value,onJsonFailure:$E("App.callError(\"Failed to open ocean data\")"),jsonNeeded:["islands","arches"],jsonDispatch:{islands:Ocean.setIslands,arches:Ocean.setArches}});
}
},setOceans:function(json){
Ocean.oceanData.clear();
json.each(function(_22c){
Ocean.oceanData.add(_22c,_22c.substr(0,1).concat(_22c.substr(1).toLowerCase()));
});
Ocean.oceanData.done();
},setArches:function(json){
Ocean.archData.clear();
Ocean.archData.add("all","Whole Ocean");
JSON.convertToObj(json).each(function(arch){
Ocean.archData.add(arch.id,arch.name);
});
Ocean.archData.done();
},setIslands:function(json){
Ocean.islandPairs=[];
Ocean.islandPairs.all=[];
Ocean.islandPairs.all.push(new ComboOption("all","Whole Ocean"));
JSON.convertToObj(json).each(function(_230){
if(!Ocean.islandPairs[_230.arch]){
Ocean.islandPairs[_230.arch]=[];
Ocean.islandPairs[_230.arch].push(new ComboOption("all","Whole Arch"));
}
Ocean.islandPairs[_230.arch].push(new ComboOption(_230.id,_230.name));
Ocean.islandPairs.all.push(new ComboOption(_230.id,_230.name));
});
Ocean.reloadingIslands=false;
},getIslandName:function(id){
var _232=Ocean.islandPairs.all.find(function(_233){
return _233.value==id;
});
if(_232){
return _232.name;
}else{
Ocean.reloadIslands();
return "Unknown Island";
}
},getIslandArch:function(id){
var _235;
Ocean.islandPairs.find(function(_236,arch){
var _238=arch;
return _236?_236.find(function(_239){
if(_239.value==id){
_235=_238;
return true;
}
}):false;
});
return _235;
},getArchName:function(id){
var arch=Ocean.archData.pairs.find($E("=x.value==a",id));
if(arch){
return arch.name;
}else{
return "Unknown";
}
},stallTypes:{"A":"'s Apothecary Stall","D":"'s Distilling Stall","F":"'s Furnishing Stall","I":"'s Ironworking Stall","S":"'s Shipbuilding Stall","T":"'s Tailoring Stall","W":"'s Weaving Stall"},stallNameRegex:/(.*)\^([A-Z])$/,expandStallName:function(name){
if(Ocean.stallNameRegex.test(name)){
var a=Ocean.stallNameRegex.exec(name);
return a[1].concat(Ocean.stallTypes[a[2]]);
}else{
return name;
}
}};
App.addInit(Ocean);
Object.extend(ArchCombo.prototype,SavedCombo.prototype);
ArchCombo.prototype.parentConstruct=SavedCombo;
function ArchCombo(name,_23f){
this.parentConstruct(name,Ocean.archData,$E("if(Ocean.islandPairs[x]) a.setData(Ocean.islandPairs[x])",_23f),Ocean.reloadIslands,true,true);
}
Object.extend(IslandCombo.prototype,SavedCombo.prototype);
IslandCombo.prototype.parentConstruct=SavedCombo;
function IslandCombo(name,data,_242){
this.parentConstruct(name,data,Prototype.emptyFunction,Ocean.reloadIslands,true,_242);
}
var SummaryMode={pageOrder:10,name:"Summary",helpPage:"summary.html",queryAjax:null,fromIslandData:new ComboData(Ocean.islandPairs.all),toIslandData:new ComboData(Ocean.islandPairs.all),fromArchCombo:null,fromIslandCombo:null,toArchCombo:null,toIslandCombo:null,init:function(){
SummaryMode.fromArchCombo=new ArchCombo("fromArch",SummaryMode.fromIslandData);
SummaryMode.fromIslandCombo=new IslandCombo("fromIsland",SummaryMode.fromIslandData,true);
SummaryMode.toArchCombo=new ArchCombo("toArch",SummaryMode.toIslandData);
SummaryMode.toIslandCombo=new IslandCombo("toIsland",SummaryMode.toIslandData,true);
var _243=[{id:"fromIslandName",heading:"From"},{id:"toIslandName",heading:"To"},{id:"profit",dir:-1,defaultSort:true},{id:"roi",heading:"ROI",display:"roiStr",dir:-1},{id:"capital"},{id:"ppMass",heading:"P/M",display:"ppMassStr",dir:-1},{id:"mass",heading:"Mass",display:"massStr"}];
RouteMode.shipTypes.each(function(ship){
if(ship.mass>0){
_243.push({id:"mass"+ship.name,display:"massStr"+ship.name,heading:"Mass",longHeading:"Mass ("+ship.name+")",visible:false});
}
});
_243.push({id:"ppVolumeStr",heading:"P/V",sort:"ppVolume",dir:-1});
_243.push({id:"volume",heading:"Vol",longHeading:"Volume"});
RouteMode.shipTypes.each(function(ship){
if(ship.volume>0){
_243.push({id:"volume"+ship.name,display:"volumeStr"+ship.name,heading:"Vol",longHeading:"Volume ("+ship.name+")",visible:false});
}
});
_243.push({id:"ageStr",heading:"Age",sort:"age"});
_243.push({id:"ageColor",display:"ageStr",heading:"Age",sort:"age",color:"ageColor",longHeading:"Age (Colourful)",visible:false});
RouteMode.shipTypes.each(function(ship){
if(ship.volume>0){
_243.push({id:"trips"+ship.name,heading:"Trips",longHeading:"Trips ("+ship.name+")",display:"tripsStr"+ship.name,visible:false});
_243.push({id:"tripsColor"+ship.name,display:"tripsStr"+ship.name,heading:"Trips",longHeading:"Trips ("+ship.name+", Colourful)",sort:"trips"+ship.name,color:"tripsColor"+ship.name,visible:false});
}
});
SummaryMode.table=new SortedTable("summaryTable",_243,{onRowBegin:function(row,_248){
if(row.isHeadingRow||row.fromIsland!=row.toIsland){
return _248;
}else{
return "<tr class=\"sameIsland\">";
}
},onCellBegin:function(row,col){
return "<td"+(col.color?" style=\"background-color:"+row[col.color]+"\">":">")+"<a onclick=\"SummaryMode.selectRoute("+row.fromIsland+","+row.toIsland+")\">";
},onCellEnd:$E("=\"</a></td>\""),onTableHeader:function(_24b){
return (_24b?"Profitable trade routes ("+_24b+" found)":"No profitable routes found");
}});
},table:null,colors:[{color:"#bfffbf",ageThreshold:169,tripsThreshold:0.25},{color:"#bfffdf",ageThreshold:338,tripsThreshold:0.5},{color:"#bfffff",ageThreshold:675,tripsThreshold:0.75},{color:"#bfdfff",ageThreshold:1350,tripsThreshold:1},{color:"#bfbfff",ageThreshold:2700,tripsThreshold:1.5},{color:"#dfbfff",ageThreshold:5400,tripsThreshold:2},{color:"#ffbfff",ageThreshold:10800,tripsThreshold:4},{color:"#ffbfdf",ageThreshold:21600,tripsThreshold:6},{color:"#ffbfbf",last:true}],get:function(){
SummaryMode.table.invalidate();
var _24c="oceanName="+Ocean.oceanCombo.value+"&"+Form.serialize("summaryOptionsForm");
SummaryMode.queryAjax=new JSON.Request(App.server+"query.php",{method:"get",parameters:_24c,jsonNeeded:["summary"],forceReload:true,onJsonFailure:$E("App.callError(\"Error response from server\\n\"+x.responseText)"),onJsonError:App.callError,jsonDispatch:{summary:SummaryMode.set}});
},reverse:function(){
if($F("fromIsland")==$F("toIsland")&&$F("fromArch")==$F("toArch")){
alert("Dude, they're the same, I can't reverse them.");
return;
}
var arch=$F("fromArch");
var _24e=$F("fromIsland");
SummaryMode.fromArchCombo.change($F("toArch"));
SummaryMode.fromIslandCombo.change($F("toIsland"));
SummaryMode.toArchCombo.change(arch);
SummaryMode.toIslandCombo.change(_24e);
SummaryMode.get();
},selectRoute:function(_24f,_250){
RouteMode.fromArchCombo.change(Ocean.getIslandArch(_24f));
RouteMode.fromIslandCombo.change(_24f);
RouteMode.toArchCombo.change(Ocean.getIslandArch(_250));
RouteMode.toIslandCombo.change(_250);
RouteMode.initd=false;
App.pageListSelector.changeSelector(RouteMode.pageOrder);
RouteMode.get();
},set:function(json){
SummaryMode.table.setData(JSON.convertToObj(json).map(function(_252){
_252.fromIslandName=Ocean.getIslandName(_252.fromIsland);
_252.toIslandName=Ocean.getIslandName(_252.toIsland);
_252.roi=_252.profit/_252.capital*100;
_252.roiStr=_252.roi.toFixedPrecision(3)+"%";
_252.ppMass=_252.profit/_252.mass*100;
_252.ppMassStr=_252.ppMass.toFixedPrecision(3);
_252.massStr=_252.mass.toFixedIfNeeded(1);
_252.ppVolume=_252.profit/_252.volume*100;
_252.ppVolumeStr=_252.ppVolume.toFixedPrecision(3);
_252.ageStr=Date.timeString(_252.age);
SummaryMode.colors.each(function(_253){
if(_252.age<_253.ageThreshold||_253.last==true){
_252.ageColor=_253.color;
throw $break;
}
});
RouteMode.shipTypes.each(function(ship){
if(ship.mass>0){
_252["mass"+ship.name]=_252.mass/ship.mass;
_252["volume"+ship.name]=_252.volume/ship.volume;
_252["trips"+ship.name]=Math.max(_252["mass"+ship.name],_252["volume"+ship.name]);
_252["massStr"+ship.name]=_252["mass"+ship.name].toFixedIfNeeded(2);
_252["volumeStr"+ship.name]=_252["volume"+ship.name].toFixedIfNeeded(2);
_252["tripsStr"+ship.name]=_252["trips"+ship.name].toFixedIfNeeded(2);
var _255=_252["trips"+ship.name];
SummaryMode.colors.each(function(_256){
if(_255<_256.tripsThreshold||_256.last==true){
_252["tripsColor"+ship.name]=_256.color;
throw $break;
}
});
}
});
return _252;
}));
SummaryMode.table.display();
},render:function(){
var _257="<div class=\"options\" id=\"summaryOptions\"><form id=\"summaryOptionsForm\">"+"<table><tr><td>"+"<div class=\"islandSelector\" id=\"from\">"+"From:<div id=\"fromArchContainer\"></div>"+"<div id=\"fromIslandContainer\"></div>"+"</div></td><td>"+"<div class=\"islandSelector\" class=\"optionGroup\" id=\"to\">"+"To:<div id=\"toArchContainer\"></div>"+"<div id=\"toIslandContainer\"></div>"+"</div></td></tr></table></form>"+"<a class=\"queryButton\" onclick=\"SummaryMode.get()\">Search</a>"+"<a class=\"queryButton\" onclick=\"SummaryMode.reverse()\">Reverse</a>"+"<a class=\"queryButton\" onclick=\"HelpMode.help(SummaryMode.pageOrder)\">Help!</a>"+"</div>"+"<div class=\"tableContainer\" id=\"summaryTableContainer\"></div>";
$("query").innerHTML=_257;
SummaryMode.fromArchCombo.display();
SummaryMode.fromIslandCombo.display();
SummaryMode.toArchCombo.display();
SummaryMode.toIslandCombo.display();
if(SummaryMode.table.isInitd()){
SummaryMode.table.display();
}
}};
App.addInit(SummaryMode);
App.addPage(SummaryMode);
var RouteMode={pageOrder:20,name:"Route",helpPage:"route.html",queryAjax:null,fromIslandData:new ComboData(),toIslandData:new ComboData(),fromArchCombo:null,fromIslandCombo:null,toArchCombo:null,toIslandCombo:null,tradesTable:null,registeredWindowListener:false,oldWidth:null,buysTable:new SortedTable("buysTable",[{id:"commodName",heading:"Commodity",sort:"commod"},{id:"shop"},{id:"price"},{id:"selected",heading:"Qty"}],{onTableHeader:function(){
return "To Buy at "+RouteMode.fromIsland;
}}),sellsTable:new SortedTable("sellsTable",[{id:"commodName",heading:"Commodity",sort:"commod"},{id:"shop"},{id:"price",dir:-1},{id:"selected",heading:"Qty"}],{onTableHeader:function(){
return "To Sell at "+RouteMode.toIsland;
}}),tables:null,init:function(){
RouteMode.fromArchCombo=new ArchCombo("routeFromArch",RouteMode.fromIslandData);
RouteMode.fromIslandCombo=new IslandCombo("routeFromIsland",RouteMode.fromIslandData,false);
RouteMode.toArchCombo=new ArchCombo("routeToArch",RouteMode.toIslandData);
RouteMode.toIslandCombo=new IslandCombo("routeToIsland",RouteMode.toIslandData,false);
RouteMode.tradesTable=new SortedTable("tradesTable",[{id:"commodName",heading:"Commodity",sort:"commod"},{id:"qty",dir:-1},{id:"sell",heading:"Buy"},{id:"buy",heading:"Sell",dir:-1},{id:"profit",dir:-1},{id:"roiStr",heading:"ROI",sort:"roi",dir:-1,defaultSort:true},{id:"capital"},{id:"ppMassStr",heading:"P/M",sort:"ppMass",dir:-1},{id:"massStr",heading:"Mass",sort:"mass"},{id:"ppVolumeStr",heading:"P/V",sort:"ppVolume",dir:-1},{id:"volume",heading:"Vol"}],{onRowBegin:RouteMode.tradeSelector,onCellBegin:RouteMode.linkCommodStart,onCellEnd:RouteMode.linkCommodEnd,onTableHeader:function(_258){
return (_258?"Available trades":"Nothing to trade");
},onChangeWidth:RouteMode.setTablesWidth,extraCols:1});
RouteMode.tables=[RouteMode.tradesTable,RouteMode.buysTable,RouteMode.sellsTable];
},tradeSelector:function(_259,_25a){
if(_259.isColHeadingsRow){
return "<tr><th><a onclick=\"RouteMode.selectAll()\">Sel Qty</a></th>";
}else{
if(_259.isTableControlRow){
return _25a+"<td></td>";
}else{
return "<tr id=\"tradeRow"+_259.id+"\"><td class=\"inTableSelect\">"+"<input type=\"checkbox\" id=\"tradeCheck"+_259.id+"\" "+(_259.selected?"checked=\"checked\"":"")+"onChange=\"RouteMode.checkTrade("+_259.id+",this);\" />"+"<input type=\"text\" size=\"4\" id=\"tradeText"+_259.id+"\" "+"onChange=\"RouteMode.selectTrade("+_259.id+",this);\" value=\""+_259.selected+"\" /></td>";
}
}
},linkCommodStart:function(row,col){
var _25d="<td "+(row&&row.overLimit?"class=\"overLimit\">":">");
if(col.sort=="commod"&&row){
return _25d+"<a onclick=\"RouteMode.selectCommod("+row.commod+");\">";
}else{
return _25d;
}
},linkCommodEnd:function(row,col){
if(col.sort=="commod"&&row){
return "</a></td>";
}else{
return "</td>";
}
},get:function(){
if($F("routeFromIsland")=="__reload"||$F("routeToIsland")=="_reload"){
alert("Must select islands first");
return;
}
RouteMode.fromIsland=Ocean.getIslandName(RouteMode.fromIslandCombo.value);
RouteMode.toIsland=Ocean.getIslandName(RouteMode.toIslandCombo.value);
RouteMode.initd=false;
Element.hide($("routeAllData"));
RouteMode.tables.each($E("x.invalidate()"));
var _260="oceanName="+Ocean.oceanCombo.value+"&"+Form.serialize("routeOptionsForm");
RouteMode.queryAjax=new JSON.Request(App.server+"route.php",{method:"get",parameters:_260,forceReload:true,onJsonFailure:$E("App.callError(\"Error response from server\\n\"+x.responseText)"),onJsonError:App.callError,jsonNeeded:["trades","buys","sells","routeAge"],jsonDispatch:{trades:RouteMode.setTrades,buys:RouteMode.setBuys,sells:RouteMode.setSells,routeAge:RouteMode.setRouteAge},onJsonFinish:RouteMode.setAllDataSent});
},reverse:function(){
if($F("routeFromIsland")==$F("routeToIsland")){
alert("This is an intra island trade. Reversing an intra-island trade is the hight of futility.");
return;
}
var arch=$F("routeFromArch");
var _262=$F("routeFromIsland");
RouteMode.fromArchCombo.change($F("routeToArch"));
RouteMode.fromIslandCombo.change($F("routeToIsland"));
RouteMode.toArchCombo.change(arch);
RouteMode.toIslandCombo.change(_262);
RouteMode.get();
    },fromIsland:"",toIsland:"",profit:"",captial:"",mass:"",volume:"",age:"",initd:false,buyOffers:null,sellOffers:null,selectedProfit:0,selectedCapital:0,selectedMass:0,selectedVolume:0,overLimit:false,ship:0,stockMass:0,stockVolume:0,availCapital:0,availMass:0,availVolume:0,remainCapital:0,remainMass:0,remainVolume:0,shipTypes:[{name:"N/A",volume:0,mass:0},{name:"Sloop",volume:20250,mass:13500},{name:"Dhow",volume:20250,mass:13500},{name:"Longship",volume:20250,mass:13500},{name:"Baglah",volume:27000,mass:18000},{name:"Cutter",volume:60750,mass:40500},{name:"MB",volume:135000,mass:90000},{name:"MG",volume:405000,mass:270000},{name:"Xebec",volume:182250,mass:121500},{name:"WF",volume:324000,mass:216000},{name:"GF",volume:810000,mass:540000}],checkTrade:function(id,_264){
var _265=RouteMode.tradesTable.data.find($E("=x.id==a",id));
if(_265){
if(_264.checked){
_265.select(_265.qty);
}else{
_265.select(0);
}
}
RouteMode.updateSelected();
},selectTrade:function(id,_267){
var _268=RouteMode.tradesTable.data.find(function(_269){
return _269.id==id;
});
if(_268){
var text=_267.value;
if(Math.round(text)!=text||text<0||text>_268.qty){
_267.value=_268.selected;
}else{
_268.select(Number(text));
RouteMode.updateSelected();
}
}
},selectAll:function(){
if(RouteMode.tradesTable.data.all(function(_26b){
return _26b.selected==_26b.qty;
})){
RouteMode.tradesTable.data.each(function(_26c){
_26c.select(0);
});
}else{
RouteMode.tradesTable.data.each(function(_26d){
_26d.select(_26d.qty);
});
}
RouteMode.updateSelected();
},selectCommod:function(_26e){
var _26f=function(_270){
return _270.commod!=_26e||_270.selected==_270.qty;
};
if(RouteMode.tradesTable.data.all(_26f)){
RouteMode.tradesTable.data.each(function(_271){
if(_271.commod==_26e){
_271.select(0);
}
});
}else{
RouteMode.tradesTable.data.each(function(_272){
if(_272.commod==_26e){
_272.select(_272.qty);
}
});
}
RouteMode.updateSelected();
},selectShip:function(_273){
with(RouteMode){
if(Math.round(_273)!=_273||_273<0||_273>=shipTypes.length){
ship=Number(Store.get("shipRadio"));
$("shipRadio"+ship).checked=true;
}else{
ship=_273;
Store.set("shipRadio",ship,7);
}
if(ship==0){
stockMass=0;
$("stockMassText").value=0;
$("stockMassText").disabled=true;
stockVolume=0;
$("stockVolumeText").value=0;
$("stockVolumeText").disabled=true;
}else{
$("stockMassText").disabled=false;
$("stockVolumeText").disabled=false;
}
calcAvail();
updateSelected();
}
},changeAvailCapital:function(_274){
with(RouteMode){
var text=_274.value;
if(Math.round(text)!=text||text<0){
_274.value=Number(Store.get("availCapital"));
}else{
availCapital=text;
Store.set("availCapital",availCapital,7);
calcAvail();
updateSelected();
}
}
},changeStockMass:function(_276){
with(RouteMode){
var text=_276.value;
if(Math.round(text)!=text||text<0||text>shipTypes[ship].mass){
_276.value=Number(Store.get("stockMass"));
}else{
stockMass=text;
Store.set("stockMass",stockMass,7);
calcAvail();
updateSelected();
}
}
},changeStockVolume:function(_278){
with(RouteMode){
var text=_278.value;
if(Math.round(text)!=text||text<0||text>shipTypes[ship].volume){
_278.value=Number(Store.get("stockVolume"));
}else{
stockVolume=text;
Store.set("stockVolume",stockVolume,7);
calcAvail();
updateSelected();
}
}
},calcAvail:function(){
with(RouteMode){
var _27a=shipTypes[ship];
availMass=_27a.mass-stockMass;
availVolume=_27a.volume-stockVolume;
var _27b=false;
["Capital","Mass","Volume"].each(function(res){
if(RouteMode["avail"+res]!=0){
RouteMode["remain"+res]=RouteMode["avail"+res]-RouteMode["selected"+res];
}else{
RouteMode["remain"+res]="0";
}
if(RouteMode["remain"+res]<0){
_27b=true;
}
});
if(overLimit&&!_27b){
document.getElementsByClassName("overLimit",$("query")).each($E("x.className=\"\""));
RouteMode.tradesTable.data.each(function(_27d){
_27d.overLimit=false;
});
}
overLimit=_27b;
}
},updateSelected:function(){
["selectedProfit","selectedCapital","selectedMass","selectedVolume"].each(function(_27e){
$(_27e+"Text").innerHTML=RouteMode[_27e].toFixedIfNeeded(1);
});
var _27f=true;
["Capital","Mass","Volume"].each(function(res){
if(RouteMode["avail"+res]!=0){
$("remain"+res+"Text").innerHTML=RouteMode["remain"+res].toFixedIfNeeded(1);
_27f=false;
}else{
RouteMode["remain"+res]="0";
$("remain"+res+"Text").innerHTML="<span class=\"naText\">N/A</span>";
}
if(RouteMode["remain"+res]<0){
$("remain"+res+"Text").className="overLimit";
}else{
$("remain"+res+"Text").className="";
}
});
if(_27f){
document.getElementsByClassName("remainRow",$("selectedTable")).each($E("Element.hide(x)"));
}else{
document.getElementsByClassName("remainRow",$("selectedTable")).each($E("Element.show(x)"));
}
var _281=function(bool){
if(!bool){
alert("Could not select offers, asertion failed");
throw "selectOffers failed";
}
};
var _283=new Array();
var _284=new Array();
var _285=new Array();
var _286=new Array();
RouteMode.tradesTable.data.each(function(_287){
if(!_285[String(_287.commod)+","+String(_287.sell)]){
_285[String(_287.commod)+","+String(_287.sell)]=0;
}
_285[String(_287.commod)+","+String(_287.sell)]+=_287.selected;
});
RouteMode.buyOffers.each(function(_288){
if(_285[String(_288.commod)+","+String(_288.price)]>0){
_288.selected=Math.min(_285[String(_288.commod)+","+String(_288.price)],_288.qty);
_286.push(_288);
_285[String(_288.commod)+","+String(_288.price)]-=_288.selected;
_281(_285[String(_288.commod)+","+String(_288.price)]>=0);
}
});
_281(_285.all(function(um){
return !um;
}));
RouteMode.buysTable.setData(_286);
RouteMode.buysTable.display();
_285=new Array();
_286=new Array();
RouteMode.tradesTable.data.each(function(_28a){
if(!_285[String(_28a.commod)+","+String(_28a.buy)]){
_285[String(_28a.commod)+","+String(_28a.buy)]=0;
}
_285[String(_28a.commod)+","+String(_28a.buy)]+=_28a.selected;
});
RouteMode.sellOffers.each(function(_28b){
if(_285[String(_28b.commod)+","+String(_28b.price)]>0){
_28b.selected=Math.min(_285[String(_28b.commod)+","+String(_28b.price)],_28b.qty);
_286.push(_28b);
_285[String(_28b.commod)+","+String(_28b.price)]-=_28b.selected;
_281(_285[String(_28b.commod)+","+String(_28b.price)]>=0);
}
});
_281(_285.all(function(um){
return !um;
}));
RouteMode.sellsTable.setData(_286);
RouteMode.sellsTable.display();
},setTrades:function(json){
var _28e=0;
var _28f=0;
var _290=0;
var _291=0;
var _292=0;
RouteMode.selectedProfit=0;
RouteMode.selectedCapital=0;
RouteMode.selectedMass=0;
RouteMode.selectedVolume=0;
RouteMode.tradesTable.setData(JSON.convertToObj(json).map(function(_293){
_293.id=_292++;
var _294=Commods.getCommod(_293.commod);
_293.commodName=_294.name;
_293.profit=(_293.buy-_293.sell)*_293.qty;
_293.capital=_293.sell*_293.qty;
_293.roi=_293.profit/_293.capital*100;
_293.roiStr=_293.roi.toFixedPrecision(3);
_293.mass=_294.mass*_293.qty;
_293.massStr=_293.mass.toFixedIfNeeded(1);
_293.ppMass=_293.profit/_293.mass*100;
_293.ppMassStr=_293.ppMass.toFixedPrecision(3);
_293.volume=_294.volume*_293.qty;
_293.ppVolume=_293.profit/_293.volume*100;
_293.ppVolumeStr=_293.ppVolume.toFixedPrecision(3);
_293.selected=0;
_293.select=function(sqty){
if(sqty>_293.qty){
sqty=_293.qty;
alert("selected bad qty");
}
if(sqty<0){
sqty=0;
alert("selected bad qty");
}
var dSel=sqty-_293.selected;
_293.selected=sqty;
var _297=Commods.getCommod(_293.commod);
RouteMode.selectedProfit+=dSel*(_293.buy-_293.sell);
RouteMode.selectedCapital+=dSel*_293.sell;
RouteMode.selectedMass+=dSel*_297.mass;
RouteMode.selectedVolume+=dSel*_297.volume;
var _298=sqty!=0;
$("tradeCheck"+_293.id).checked=_298;
$("tradeText"+_293.id).value=sqty;
RouteMode.calcAvail();
if(RouteMode.overLimit&&sqty>0){
var _299=$("tradeRow"+_293.id).getElementsByTagName("td");
for(var i=0;i<_299.length;i++){
_299[i].className="overLimit";
}
_293.overLimit=true;
}
if(_293.overLimit&&sqty==0){
var _299=$("tradeRow"+_293.id).getElementsByTagName("td");
for(var i=0;i<_299.length;i++){
_299[i].className="";
}
_293.overLimit=false;
}
};
_28e+=_293.profit;
_28f+=_293.capital;
_290+=_293.mass;
_291+=_293.volume;
return _293;
}));
RouteMode.profit=_28e;
RouteMode.capital=_28f;
RouteMode.mass=_290.toFixedIfNeeded(1);
RouteMode.volume=_291;
},setBuys:function(json){
RouteMode.sellOffers=JSON.convertToObj(json).map(function(_29c){
_29c.commodName=Commods.getCommod(_29c.commod).name;
_29c.shop=Ocean.expandStallName(_29c.shop);
return _29c;
});
},setSells:function(json){
RouteMode.buyOffers=JSON.convertToObj(json).map(function(_29e){
_29e.commodName=Commods.getCommod(_29e.commod).name;
_29e.shop=Ocean.expandStallName(_29e.shop);
return _29e;
});
},setRouteAge:function(json){
RouteMode.age=Date.timeString(json);
},setAllDataSent:function(){
with(RouteMode){
initd=true;
renderDataArea();
selectAll();
}
},toggleAvailRows:function(){
var _2a0=document.getElementsByClassName("availRow",$("selectedTable"));
if(_2a0[0].style.display=="none"){
_2a0.each($E("x.style.display = \"\""));
$("showAvailImg").src="img/hide.png";
}else{
_2a0.each($E("x.style.display = \"none\""));
$("showAvailImg").src="img/show.png";
}
},render:function(){
with(RouteMode){
var _2a1="<div class=\"options\" id=\"routeOptions\"><form id=\"routeOptionsForm\">"+"<table><tr><td>"+"<div class=\"islandSelector\" id=\"from\">"+"From:<div id=\"routeFromArchContainer\"></div>"+"<div id=\"routeFromIslandContainer\"></div>"+"</div></td><td>"+"<div class=\"islandSelector\" id=\"to\">"+"To:<div id=\"routeToArchContainer\"></div>"+"<div id=\"routeToIslandContainer\"></div>"+"</div></td></tr></table></form>"+"<div class=\"queryButtons\"><a class=\"queryButton\" onclick=\"RouteMode.get()\">Find profitable trades</a>"+"<a class=\"queryButton\" onclick=\"RouteMode.reverse()\">Reverse route</a>"+"<a class=\"queryButton\" onclick=\"HelpMode.help(RouteMode.pageOrder)\">Help!</a></div>"+"</div>"+"<div id=\"routeAllData\" style=\"display:none\">"+"<div class=\"tableContainer\" id=\"routeDataTableContainer\">"+"<table id=\"routeDataTable\" class=\"dataTable\">"+"<tr><th>From</th><th>To</th><th>Profit</th><th>Capital</th><th>Mass</th>"+"<th>Vol</th><th>Age</th></tr>"+"<tr><td id=\"fromIslandText\"></td><td id=\"toIslandText\"></td>"+"<td id=\"profitText\"></td><td id=\"capitalText\"></td>"+"<td id=\"massText\"></td><td id=\"volumeText\"></td>"+"<td id=\"ageText\"></td></tr></table></div>"+"<div class=\"tableContainer\" id=\"tradesTableContainer\"></div>"+"<div class=\"tableContainer\" id=\"selectedTableContainer\">"+"<table id=\"selectedTable\" class=\"dataTable\">"+"<tr><th colspan=\"4\">"+"<div class=\"tableControlHandle\"><img class=\"tableControlImage\" src=\"img/show.png\" "+"onclick=\"RouteMode.toggleAvailRows()\" id=\"showAvailImg\" /></div>"+"Selected Trades</th></tr>"+"<tr><th style=\"width:19%\">Profit</th><th style=\"width:27%\">Capital</th>"+"<th style=\"width:27%\">Mass</th><th style=\"width:27%\">Volume</th></tr>"+"<tr><td id=\"selectedProfitText\"></td><td id=\"selectedCapitalText\"></td>"+"<td id=\"selectedMassText\"></td><td id=\"selectedVolumeText\"></td></tr>"+"<tr class=\"availRow\" style=\"display:none\"><td colspan=\"4\"><form name=\"shipradios\">"+"Ship: "+shipTypes.inject("",function(_2a2,ship,_2a4){
return _2a2+"<input type=\"radio\" name=\"shipRadio\" value=\""+_2a4+"\" "+"onclick=\"RouteMode.selectShip("+_2a4+")\" id=\"shipRadio"+_2a4+"\"></input>"+"<label class=\"shipRadio\" for=\"shipRadio"+_2a4+"\">"+ship.name+"</label>";
})+"</form></td></tr>"+"<tr class=\"availRow\" style=\"display:none\"><th></th><th>Available Capital</th>"+"<th>Stock Mass</th><th>Stock Vol</th></tr>"+"<tr class=\"availRow\" style=\"display:none\"><td></td><td>"+"<input type=\"text\" id=\"availCapitalText\" size=\"6\" onChange=\"RouteMode.changeAvailCapital(this)\">"+"</input></td><td>"+"<input type=\"text\" id=\"stockMassText\" size=\"6\" onChange=\"RouteMode.changeStockMass(this)\">"+"</input></td><td>"+"<input type=\"text\" id=\"stockVolumeText\" size=\"6\" onChange=\"RouteMode.changeStockVolume(this)\">"+"</input></td></tr>"+"<tr class=\"remainRow\" style=\"display:none\"><th></th><th>Remaining Capital</th><th>Remaining Mass</th>"+"<th>Remaining Volume</th></tr>"+"<tr class=\"remainRow\" style=\"display:none\"><td></td><td id=\"remainCapitalText\"></td><td id=\"remainMassText\"></td>"+"<td id=\"remainVolumeText\"></td></tr>"+"</table></div>"+"<div class=\"tableContainer\" id=\"buysTableContainer\"></div>"+"<div class=\"tableContainer\" id=\"sellsTableContainer\"></div>"+"<div id=\"heightSpacer\">&nbsp;</div>"+"</div>";
$("query").innerHTML=_2a1;
fromArchCombo.display();
fromIslandCombo.display();
toArchCombo.display();
toIslandCombo.display();
if(initd){
renderDataArea();
}
}
},renderDataArea:function(){
with(RouteMode){
["routeDataTable","selectedTable"].each($E("$(x).style.display = \"none\""));
Element.show($("routeAllData"));
["fromIsland","toIsland","profit","capital","mass","volume","age","selectedProfit","selectedCapital","selectedMass","selectedVolume"].each(function(_2a5){
$(_2a5+"Text").innerHTML=RouteMode[_2a5];
});
oldWidth=null;
tradesTable.display();
setTablesWidth();
var _2a6=buyOffers.length+sellOffers.length;
$("heightSpacer").style.height=_2a6*4+"ex";
availCapital=Number(Store.get("availCapital"));
$("availCapitalText").value=availCapital;
stockMass=Number(Store.get("stockMass"));
$("stockMassText").value=stockMass;
stockVolume=Number(Store.get("stockVolume"));
$("stockVolumeText").value=stockVolume;
selectShip(-1);
}
},setTablesWidth:function(){
if(App.pageListSelector.value!=RouteMode.pageOrder){
return;
}
with(RouteMode){
var _2a7=styleWidth($("tradesTable").clientWidth);
if(_2a7!=oldWidth){
Element.hide($("routeAllData"));
oldWidth=_2a7;
tables.each($E("x.width = a",_2a7));
tradesTable.width=null;
["routeDataTable","selectedTable"].each($E("$(x).style.width=a;$(x).style.display=\"\";",_2a7));
tables.each($E("x.display()"));
Element.show($("routeAllData"));
}
if(!registeredWindowListener){
window.onresize=setTablesWidth;
registeredWindowListener=true;
}
}
},styleWidth:function(_2a8){
return _2a8+100-$("findClientWidth").clientWidth+"px";
}};
App.addInit(RouteMode);
App.addPage(RouteMode);
var CommodMode={pageOrder:30,name:"Commodities",helpPage:"commod.html",commodAjax:null,islandAjax:null,commodData:new ComboData(Commods.all),groupCombo:null,commodCombo:null,buysTable:new SortedTable("commodBuys",[{id:"islandName",heading:"Island"},{id:"price",defaultSort:true},{id:"qty",dir:-1}],{onCellBegin:$E("='<td><a onclick=\"CommodMode.getIsland('+x.island+')\">'"),onCellEnd:$E("=\"</a></td>\""),onTableHeader:function(_2a9){
return (_2a9?_2a9+" islands to buy "+CommodMode.curCommodName+" from":"No trading");
}}),sellsTable:new SortedTable("commodSells",[{id:"islandName",heading:"Island"},{id:"price",dir:-1,defaultSort:true},{id:"qty",dir:-1}],{onCellBegin:$E("='<td><a onclick=\"CommodMode.getIsland('+x.island+')\">'"),onCellEnd:$E("=\"</a></td>\""),onTableHeader:function(_2aa){
return (_2aa?_2aa+" islands to sell "+CommodMode.curCommodName+" to":"No trading");
}}),sellProfitsTable:new SortedTable("commodSellProfits",[{id:"islandName",heading:"Island"},{id:"price",dir:-1},{id:"qty",dir:-1},{id:"profit",dir:-1,defaultSort:true}],{onCellBegin:$E("='<td><a onclick=\"CommodMode.getIsland('+x.island+')\">'"),onCellEnd:$E("=\"</a></td>\""),onTableHeader:function(_2ab){
return (_2ab?_2ab+" islands to sell "+CommodMode.curCommodName+" to":"No trading");
}}),buyOffersTable:new SortedTable("commodBuyOffers",[{id:"shop"},{id:"price",defaultSort:true},{id:"qty",dir:-1}],{onTableHeader:function(_2ac){
return (_2ac?_2ac+" shops to buy "+CommodMode.curCommodName+" from on "+CommodMode.curIslandName:"No trading");
}}),sellOffersTable:new SortedTable("commodSellOffers",[{id:"shop"},{id:"price",dir:-1,defaultSort:true},{id:"qty",dir:-1}],{onTableHeader:function(_2ad){
return (_2ad?_2ad+" shops to sell "+CommodMode.curCommodName+" to on "+CommodMode.curIslandName:"No trading");
}}),tables:null,offerTables:null,baughtPrice:0,baughtQty:0,trans:"buy",curCommod:null,curCommodName:null,curIslandName:null,curTrans:null,init:function(){
with(CommodMode){
groupCombo=new CommodGroupCombo("commodGroup",commodData);
commodCombo=new CommodCombo("commod",commodData);
tables=[buysTable,sellsTable,sellProfitsTable,buyOffersTable,sellOffersTable];
offerTables=[buyOffersTable,sellOffersTable];
}
},getCommod:function(){
with(CommodMode){
baughtPrice=$F("baughtPrice");
baughtQty=$F("baughtQty");
trans=$F("trans");
tables.each($E("x.invalidate()"));
tables.each($E("$(x.name+\"Container\").innerHTML=\"\""));
var _2ae="oceanName="+Ocean.oceanCombo.value+"&"+Form.serialize("commodOptionsForm");
commodAjax=new JSON.Request(App.server+"commod.php",{method:"get",parameters:_2ae,forceReload:true,onJsonFailure:$E("App.callError(\"Error response from server\\n\"+x.responseText)"),onJsonError:App.callError,jsonValidate:$E("=!!(x.buy||x.sell||x.buyprofit)"),jsonDispatch:{buy:$E("CommodMode.setCommod(x, CommodMode.sellsTable)"),sell:$E("CommodMode.setCommod(x, CommodMode.buysTable)"),buyprofit:$E("CommodMode.setCommod(x, CommodMode.sellProfitsTable)")}});
curCommod=commodCombo.value;
curCommodName=Commods.getCommod(curCommod).name;
curTrans=trans;
}
},getIsland:function(_2af){
with(CommodMode){
baughtPrice=$F("baughtPrice");
baughtQty=$F("baughtQty");
trans=$F("trans");
offerTables.each($E("x.invalidate()"));
offerTables.each($E("$(x.name+\"Container\").innerHTML=\"\""));
var _2b0="oceanName="+Ocean.oceanCombo.value+"&commod="+curCommod+"&island="+_2af+"&trans="+curTrans;
islandAjax=new JSON.Request(App.server+"commodisland.php",{method:"get",parameters:_2b0,forceReload:true,onJsonFailure:$E("App.callError(\"Error response from server\\n\"+x.responseText)"),onJsonError:App.callError,jsonValidate:$E("=!!(x.buy||x.sell)"),jsonDispatch:{buy:$E("CommodMode.setIsland(x, CommodMode.sellOffersTable)"),sell:$E("CommodMode.setIsland(x, CommodMode.buyOffersTable)")}});
curIslandName=Ocean.getIslandName(_2af);
}
},setCommod:function(json,_2b2){
_2b2.setData(JSON.convertToObj(json).map(function(_2b3){
_2b3.islandName=Ocean.getIslandName(_2b3.island);
return _2b3;
}));
_2b2.display();
},setIsland:function(json,_2b5){
_2b5.setData(JSON.convertToObj(json).map(function(_2b6){
_2b6.shop=Ocean.expandStallName(_2b6.shop);
return _2b6;
}));
_2b5.display();
},render:function(){
var _2b7="<div class=\"options\" id=\"routeoptions\"><form id=\"commodOptionsForm\" name=\"commodOptionsForm\">"+"<table><tr><td>Commodity:"+"<div class=\"islandSelector\">"+"<div id=\"commodGroupContainer\"></div><div id=\"commodContainer\"></div>"+"</div>"+"</td></tr><tr><td>"+"<select id=\"trans\" name=\"trans\" class=\"shortSelect\"><option value=\"buy\">Sell</option>"+"  <option value=\"sell\">Buy</option></select>"+" Price: <input name=\"baughtPrice\" id=\"baughtPrice\" type=\"text\" size=\"5\" />"+" Qty: <input name=\"baughtQty\" id=\"baughtQty\" type=\"text\" size=\"5\" />"+"</td></tr></table></form>"+"<div class=\"queryButtons\">"+"<a class=\"queryButton\" onclick=\"CommodMode.getCommod()\">View commodity prices</a>"+"<a class=\"queryButton\" onclick=\"HelpMode.help(CommodMode.pageOrder)\">Help!</a></div>"+"</div>"+"<div class=\"tableContainer\" id=\"commodBuysContainer\"></div>"+"<div class=\"tableContainer\" id=\"commodSellsContainer\"></div>"+"<div class=\"tableContainer\" id=\"commodSellProfitsContainer\"></div>"+"<div class=\"tableContainer\" id=\"commodBuyOffersContainer\"></div>"+"<div class=\"tableContainer\" id=\"commodSellOffersContainer\"></div>";
$("query").innerHTML=_2b7;
with(CommodMode){
groupCombo.display();
commodCombo.display();
$("trans").value=trans;
$("baughtPrice").value=baughtPrice;
$("baughtQty").value=baughtQty;
tables.each($E("x.isInitd() && x.display()"));
}
}};
App.addInit(CommodMode);
App.addPage(CommodMode);
var BidMode={pageOrder:40,name:"Bid",helpPage:"bid.html",bidAjax:null,commodData:new ComboData(),islandData:new ComboData(),commodGroupCombo:null,commodCombo:null,archCombo:null,islandCombo:null,table:new SortedTable("bidTable",[{id:"commodName",heading:"Commodity",sort:"commod"},{id:"islandName",heading:"Island"},{id:"archName",heading:"Arch"},{id:"price"}],{onCellBegin:function(row){
return "<td><a onclick=\"BidMode.selectBid("+row.commod+","+row.price+","+row.qty+")\">";
},onCellEnd:$E("=\"</a></td>\""),onTableHeader:function(_2b9){
return (_2b9?"Found "+_2b9+" bids":"No bids found");
}}),init:function(){
BidMode.commodData.setData(Commods.harvestCommodPairs.all);
BidMode.commodGroupCombo=new SavedCombo("bidCommodGroup",Commods.harvestGroupData,$E("if(x)BidMode.commodData.setData(Commods.harvestCommodPairs[x])"),Prototype.emptyFunction,false,true);
BidMode.commodCombo=new SavedCombo("bidCommod",BidMode.commodData,Prototype.emptyFunction,Prototype.emptyFunction,false,true);
BidMode.archCombo=new ArchCombo("bidArch",BidMode.islandData);
BidMode.islandCombo=new IslandCombo("bidIsland",BidMode.islandData,true);
},getByCommod:function(){
BidMode.table.invalidate();
var _2ba="oceanName="+Ocean.oceanCombo.value+"&"+Form.serialize("bidCommodOptionsForm");
BidMode.queryAjax=new JSON.Request(App.server+"bid.php",{method:"get",parameters:_2ba,forceReload:true,onJsonFailure:$E("App.callError(\"Error response from server\\n\"+x.responseText)"),onJsonError:App.callError,jsonNeeded:["bids"],jsonDispatch:{bids:BidMode.set}});
},getByIsland:function(){
BidMode.table.invalidate();
var _2bb="oceanName="+Ocean.oceanCombo.value+"&"+Form.serialize("bidIslandOptionsForm");
BidMode.queryAjax=new JSON.Request(App.server+"bid.php",{method:"get",parameters:_2bb,forceReload:true,onJsonFailure:$E("App.callError(\"Error response from server\\n\"+x.responseText)"),onJsonError:App.callError,jsonNeeded:["bids"],jsonDispatch:{bids:BidMode.set}});
},selectBid:function(_2bc,_2bd,qty){
CommodMode.groupCombo.change(Commods.getGroup(_2bc));
CommodMode.commodCombo.change(_2bc);
CommodMode.trans="buy";
CommodMode.baughtPrice=_2bd;
CommodMode.baughtQty=qty;
App.pageListSelector.changeSelector(CommodMode.pageOrder);
CommodMode.getCommod();
},set:function(json){
BidMode.table.setData(JSON.convertToObj(json).map(function(bid){
bid.islandName=Ocean.getIslandName(bid.island);
bid.commodName=Commods.getCommod(bid.commod).name;
bid.archName=Ocean.getArchName(Ocean.getIslandArch(bid.island));
return bid;
}));
BidMode.table.display();
},render:function(){
with(BidMode){
var _2c1="<div class=\"options\" id=\"bidOptions\">"+"<table><tr><td><form id=\"bidCommodOptionsForm\">"+"<div class=\"islandSelector\" id=\"bidCommodSelector\">"+"Commodity:<div id=\"bidCommodGroupContainer\"></div>"+"<div id=\"bidCommodContainer\"></div>"+"</div></form>"+"<div class=\"queryButtons\"><a class=\"queryButton\" onclick=\"BidMode.getByCommod()\">"+"Find commodity bids</a></div>"+"</td><td><form id=\"bidIslandOptionsForm\">"+"<div class=\"islandSelector\" id=\"bidIslandSelector\">"+"Island:<div id=\"bidArchContainer\"></div>"+"<div id=\"bidIslandContainer\"></div>"+"</div></form>"+"<div class=\"queryButtons\">"+"<a class=\"queryButton\" onclick=\"BidMode.getByIsland()\">Find island bids</a>"+"<a class=\"queryButton\" onclick=\"HelpMode.help(BidMode.pageOrder)\">Help!</a>"+"</div>"+"</td></tr></table></div>"+"<div class=\"tableContainer\" id=\"bidTableContainer\"></div>";
$("query").innerHTML=_2c1;
commodGroupCombo.display();
commodCombo.display();
archCombo.display();
islandCombo.display();
if(table.isInitd()){
table.display();
}
}
}};
App.addInit(BidMode);
App.addPage(BidMode);
var AgeMode={name:"Data Age",pageOrder:90,receivedTime:0,timer:null,ageColWidth:"",ageTable:new SortedTable("ageTable",[{id:"islandName",heading:"Island"},{id:"archName",heading:"Arch"},{id:"marketAgeStr",heading:"Market Data Age",sort:"curMarketAge",defaultSort:true},{id:"bidAgeStr",heading:"Bid Data Age",sort:"curBidAge"}],{onCellBegin:function(_2c2,col){
if(["curMarketAge","curBidAge"].include(col.sort)){
return "<td id=\""+_2c2.island+col.sort+"\" style=\"width:"+AgeMode.ageColWidth+"\">";
}else{
return "<td>";
}
},onTableHeader:$E("='Data Age ('+x+ ' islands)'")}),ageAjax:null,get:function(){
AgeMode.ageAjax=new JSON.Request(App.server+"age.php",{method:"get",parameters:"oceanName="+Ocean.oceanCombo.value,forceReload:true,onJsonFailure:$E("App.callError(\"Error response from server\\n\"+x.responseText)"),onJsonError:App.callError,jsonNeeded:["ages"],jsonDispatch:{ages:AgeMode.set}});
},set:function(json){
AgeMode.ageTable.setData(JSON.convertToObj(json).map(function(_2c5){
_2c5.islandName=Ocean.getIslandName(_2c5.island);
_2c5.archName=Ocean.getArchName(Ocean.getIslandArch(_2c5.island));
var _2c6=(new Date()).getTime()/1000;
_2c5.marketTime=_2c6-_2c5.marketAge;
_2c5.curMarketAge=_2c5.marketAge;
_2c5.bidTime=_2c6-_2c5.bidAge;
_2c5.curBidAge=_2c5.bidAge;
_2c5.marketAgeStr=Date.timeLongString(_2c5.marketAge);
_2c5.bidAgeStr=Date.timeLongString(_2c5.bidAge);
return _2c5;
}));
if(AgeMode.timer){
AgeMode.timer.stop();
}
AgeMode.timer=new PeriodicalExecuter(AgeMode.addTime,10);
AgeMode.ageTable.display();
},addTime:function(){
if(App.pageListSelector.value!=AgeMode.pageOrder){
AgeMode.timer.stop();
AgeMode.timer=null;
return;
}
AgeMode.ageTable.data.each(function(_2c7){
var _2c8=(new Date()).getTime()/1000;
_2c7.curMarketAge=_2c8-_2c7.marketTime;
_2c7.curBidAge=_2c8-_2c7.bidTime;
_2c7.marketAgeStr=Date.timeLongString(_2c7.curMarketAge);
$(_2c7.island+"curMarketAge").innerHTML=_2c7.marketAgeStr;
_2c7.bidAgeStr=Date.timeLongString(_2c7.curBidAge);
$(_2c7.island+"curBidAge").innerHTML=_2c7.bidAgeStr;
});
},render:function(){
if(AgeMode.ageColWidth===""){
AgeMode.ageColWidth=$("findAgeWidth").clientWidth+10+"px";
}
var _2c9="<div class=\"options\">"+"<a class=\"queryButton\" onclick=\"AgeMode.get()\">Update</a>"+"</div>"+"<div class=\"tableContainer\" id=\"ageTableContainer\"></div>";
$("query").innerHTML=_2c9;
AgeMode.get();
}};
App.addPage(AgeMode);
var UploadMode;
if(window.OCR){
UploadMode={pageOrder:95,name:"Upload",helpPage:"upload.html",timer:null,uploadReady:false,running:false,updateStart:function(){
$("startMarketBtn").className="queryButtonDisabled";
$("startBidBtn").className="queryButtonDisabled";
$("stopBtn").className="queryButton";
this.updateClearUpload();
this.running=true;
},updateStop:function(){
$("startMarketBtn").className="queryButton";
$("startBidBtn").className="queryButton";
$("stopBtn").className="queryButtonDisabled";
this.running=false;
},updateReadyUpload:function(mode){
$("clearBtn").className="queryButton";
$("uploadBtn").className="queryButton";
var _2cb;
switch(mode){
case OCR.MODE_MARKET:
_2cb="Upload Market Data";
break;
case OCR.MODE_BID:
_2cb="Upload Bid Data";
break;
}
$("uploadBtn").innerHTML=_2cb;
this.uploadReady=true;
},updateClearUpload:function(){
$("clearBtn").className="queryButtonDisabled";
$("uploadBtn").className="queryButtonDisabled";
$("uploadBtn").innerHTML="No data to upload";
$("dataFrame").src="blank.html";
this.uploadReady=false;
},pollOCR:function(){
var msg=OCR.GetMsgBuf();
if(msg!==""){
$("dataFrame").contentDocument.body.innerHTML+=msg;
}
if(!this.uploadReady){
var _2cd=OCR.ReadyMode();
if(_2cd!=OCR.MODE_NONE){
$("uploadForm").action=OCR.GetAction();
OCR.SetFileInput($("inputFile"));
this.updateReadyUpload(_2cd);
}
}
if(!OCR.IsRunning()){
timer.stop();
this.updateStop();
}
$("dataFrame").contentWindow.scrollBy(0,window.innerHeight);
},startMarket:function(){
if(!this.running){
this.updateStart();
OCR.Start(OCR.MODE_MARKET);
timer=new PeriodicalExecuter(this.pollOCR.bind(this),0.5);
}
},startBid:function(){
if(!this.running){
this.updateStart();
OCR.Start(OCR.MODE_BID);
timer=new PeriodicalExecuter(this.pollOCR.bind(this),0.5);
}
},stopCapture:function(){
if(this.running){
OCR.Stop();
}
},clearUpload:function(){
if(this.uploadReady){
this.updateClearUpload();
OCR.Clear();
}
},upload:function(){
if(this.uploadReady){
this.updateClearUpload();
$("dataFrame").contentDocument.body.innerHTML="<p>Uploading data...</p>";
$("uploadForm").submit();
}
},render:function(){
var _2ce="<div class=\"options\"></div><div class=\"options\">"+"<a class=\"queryButton\" onclick=\"UploadMode.startMarket()\" "+"id=\"startMarketBtn\">Start Market Capture</a>"+"<a class=\"queryButton\" onclick=\"UploadMode.startBid()\" "+"id=\"startBidBtn\">Start Bid Capture</a></div>"+"<div class=\"options\">"+"<a class=\"queryButtonDisabled\" onclick=\"UploadMode.stopCapture()\" "+"id=\"stopBtn\">Stop Capture</a>"+"<a class=\"queryButtonDisabled\" onclick=\"UploadMode.clearUpload()\" "+"id=\"clearBtn\">Clear Upload</a>"+"<a class=\"queryButtonDisabled\" onclick=\"UploadMode.upload()\" "+"id=\"uploadBtn\">No Data to Upload</a></div>"+"<form id=\"uploadForm\" method=\"POST\" enctype=\"multipart/form-data\" "+"target=\"dataFrame\" style=\"display:none\">"+"<input id=\"inputFile\" type=\"file\" name=\"marketdata\"/>"+"</form>"+"<iframe src=\"blank.html\" id=\"dataFrame\" name=\"dataFrame\"></iframe>";
$("query").innerHTML=_2ce;
}};
App.addPage(UploadMode);
}else{
UploadMode={upload:{value:95,name:"Upload Client",helpPage:"upload.html"},init:function(){
HelpMode.helpPairs.push(UploadMode.upload);
}};
App.addInit(UploadMode);
}
var HelpMode={pageOrder:100,name:"Help!",helpAjax:null,helpSelect:null,helpPairs:[],helpData:new ComboData(),helpPage:"index.html",helpText:"",about:{value:190,name:"About",helpPage:"about.html"},bodyRegex:/<!--contentbegin-->((?:.|\n|\r)*)<!--contentend-->/,helpLinkRegex:/<a (.*?)href="(\w+\.html)"/g,helpLinkReplaceStr:"<a $1onclick=\"HelpMode.help('$2')\"",extLinkRegex:/<a([^>]*)>/g,extLinkReplaceStr:"<a target=\"_blank\" $1>",linkReplace:function(html){
html=html.replace(HelpMode.helpLinkRegex,HelpMode.helpLinkReplaceStr);
html=html.replace(HelpMode.extLinkRegex,HelpMode.extLinkReplaceStr);
return html;
},init:function(){
with(HelpMode){
helpSelect=new SavedSelector("helpSelect",helpData,selectPage,null,false,false,0,"helpSelect","helpSelected");
helpPairs.push(about);
App.pagePairs.each(function(page){
if(page.helpPage){
var opt=new ComboOption((page.value==HelpMode.pageOrder?0:page.value),page.name);
opt.helpPage=page.helpPage;
helpPairs.push(opt);
}
});
helpPairs.sort($E("= x.value - y.value"));
helpData.setData(HelpMode.helpPairs);
}
},help:function(page){
var _2d3;
if(HelpMode.helpSelect.data.pairs.pluck("value").include(page)){
_2d3=page;
}else{
if(_2d3=HelpMode.helpSelect.data.pairs.find($E("=x.helpPage==a",page))){
_2d3=_2d3.value;
}else{
return;
}
}
App.pageListSelector.changeSelector(HelpMode.pageOrder);
HelpMode.helpSelect.changeSelector(_2d3);
},selectPage:function(){
if(App.pageListSelector&&App.pageListSelector.value==HelpMode.pageOrder){
HelpMode.get();
}
},get:function(){
var _2d4=HelpMode.helpPairs.find($E("=x.value==HelpMode.helpSelect.value"));
if(_2d4){
var _2d5=_2d4.helpPage;
HelpMode.helpAjax=new Ajax.Request(App.server+"help/"+_2d5,{method:"get",onSuccess:$E("HelpMode.set(x.responseText)")});
}
},set:function(html){
with(HelpMode){
helpText=linkReplace(bodyRegex.exec(html)[1]);
helpText=helpText.stripScripts();
$("helpText").innerHTML=HelpMode.helpText;
}
},render:function(){
var _2d7="<table id=\"helpContainer\"><tr><td id=\"helpSelectContainer\"></td>"+"<td id=\"helpBody\"><div id=\"helpText\"></div></td></tr></table>";
$("query").innerHTML=_2d7;
if(HelpMode.helpText===""){
HelpMode.get();
}
HelpMode.helpSelect.display();
$("helpText").innerHTML=HelpMode.helpText;
}};
App.addInit(HelpMode);
App.addPage(HelpMode);
var PCTB=Object.extend(App,{defaultPage:SummaryMode.pageOrder,readyToRender:function(){
return !!Ocean.oceanCombo.value;
},nothingToDisplay:function(){
$("query").innerHTML="";
}});
Ajax.Responders.register({onCreate:$E("Element.show('loadingnotify')"),onComplete:$E("if(Ajax.activeRequestCount == 0) Element.hide('loadingnotify')"),onException:$E("alert('Ajax responder failed with message:\"'+y.message+'\"')")});

