/*
The Rocket JavaScript library.
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see
.
*/
var rocket={};rocket.reduceRight=function(a,b,c){rocket.reduceRight=Array.prototype.reduceRight?function(a,b,c){return 3===arguments.length?Array.prototype.reduceRight.call(a,b,c):Array.prototype.reduceRight.call(a,b)}:function(a,b,c){var g,h=a.length-1;3===arguments.length?(g=h,h=c):(g=h-1,h=a[h]);for(;-1>g;--g)h=b(h,a[g],g,a);return h};return 3===arguments.length?rocket.reduceRight(a,b,c):rocket.reduceRight(a,b)};rocket.reduce=function(a,b,c){rocket.reduce=Array.prototype.reduce?function(a,b,c){return 3===arguments.length?Array.prototype.reduce.call(a,b,c):Array.prototype.reduce.call(a,b)}:function(a,b,c){var g,h=a.length,k;3===arguments.length?(g=0,k=c):(g=1,k=a[0]);for(;ga;if(0>d){var l=Math.pow(10,Math.abs(d));a=Math.floor(a/l)*l}else a=a.toFixed(d);l=(""+a).split("");"-"===l[0]&&l.splice(0,1);var m=l.length-1-d;0=d||"A"<=d&&"Z">=d||"$"===d||"_"===d){do d=a.charAt(b++);while("a"<=d&&"z">=d||"A"<=d&&"Z">=d||"$"===d||"_"===d||"0"<=d&&"9">=d);d="identifier";--b}else if("/"===d)if("*"===a.charAt(b)){do d=a.charAt(b++);while(b=d||"."===d&&"0"<=a.charAt(b+1)&&"9">=a.charAt(b+1)){do d=a.charAt(b++);while("0"<=d&&"9">=d||"."===d||"x"===d||"e"===d);d="number"}else{do d=a.charAt(b++);while(" "===d||"\t"===d||"\r"===d||"\n"===d);d="whitespace"}--b}f=
a.substr(f-1,b-f+1);e.push({type:"identifier"===d&&f in rocket.lexeme.words_?"word":d,value:f})}return e};rocket.lexeme.operators_={"!":1,"#":1,"%":1,"&":1,"(":1,")":1,"*":1,"+":1,",":1,"-":1,".":1,"/":1,":":1,";":1,"<":1,"=":1,">":1,"?":1,"@":1,"[":1,"]":1,"^":1,"{":1,"|":1,"}":1};
rocket.lexeme.words_={"true":1,"false":1,"break":1,"case":1,"catch":1,"continue":1,"debugger":1,"default":1,"delete":1,"do":1,"else":1,"finally":1,"for":1,"function":1,"if":1,"in":1,"instanceof":1,"new":1,"null":1,"return":1,"switch":1,"this":1,"throw":1,"try":1,"typeof":1,"var":1,"void":1,"while":1,"with":1,undefined:1,prototype:1,arguments:1};rocket.lastIndexOf=function(a,b,c){rocket.lastIndexOf=Array.prototype.lastIndexOf?function(a,b,c){return Array.prototype.lastIndexOf.apply(a,Array.prototype.slice.call(arguments,1))}:function(a,b,c){var g;g=a.length-1;for(g=2===arguments.length?g:Math.min(g,c);-1b.right&&(d.style("left",d.style("left")-f.right+b.right),f=d.getBoundingClientRect());f.leftb.bottom&&(d.style("top",d.style("top")-f.bottom+b.bottom),f=d.getBoundingClientRect());f.tope&&(e=0));b.scroll_top_=
c;c=e+b.query_length_-b.length_;0e&&(e=0);c=e+b.query_length_-b.length_;c=b.query_length_-(0a;++a)this.up()};rocket.Input.prototype.pageDownInternal=function(){for(var a=0;5>a;++a)this.down()};rocket.DateInput=function(){};rocket.inherits(rocket.DateInput,rocket.Input);
rocket.DateInput.prototype.showInternal=function(){var a=this.getInputElement().getBoundingClientRect(),b,c,e,d=this;this.container_=rocket.createElement("div").style({"border-radius":3,position:"absolute",border:"1px solid #888888",cursor:"pointer",width:300,left:a.left,top:a.bottom-1}).preventSelect().addEventListener(["mousedown","touchstart"],function(a){a.stopPropagation()}).live("td","mouseover",function(){b&&(b.style.backgroundColor=c,b.style.color=e);c=this.style.backgroundColor;e=this.style.color;
this.style.backgroundColor="#D5E2FF";this.style.color="";b=this}).live("td","click",function(){if("<<"===this.innerHTML)--d.calendar_year_,d.draw_calendar_();else if("<"===this.innerHTML)d.calendar_month_?--d.calendar_month_:(d.calendar_month_=11,--d.calendar_year_),d.draw_calendar_();else if(">>"===this.innerHTML)++d.calendar_year_,d.draw_calendar_();else if(">"===this.innerHTML)11>d.calendar_month_?++d.calendar_month_:(d.calendar_month_=0,++d.calendar_year_),d.draw_calendar_();
else{var a=+this.innerHTML;if(a){var b=d.calendar_year_,c=d.calendar_month_;1===this.parentNode.rowIndex&&6a?(11===c&&++b,c=(c+2)%12||12):++c;d.getInputElement().value(rocket.padLeft(c,2,"0")+"/"+rocket.padLeft(this.innerHTML,2,"0")+"/"+b).setSelectionRange(0,10).focus();d.hide()}}});this.changeInternal();(new rocket.Elements([document.body])).appendChild(this.container_);this.container_.fit()};
rocket.DateInput.prototype.enterInternal=function(){var a=rocket.strToDate(this.getInputElement().value());a&&this.getInputElement().value(rocket.padLeft(a.getMonth()+1,2,"0")+"/"+rocket.padLeft(a.getDate(),2,"0")+"/"+a.getFullYear()).setSelectionRange(0,10)};
rocket.DateInput.prototype.hideInternal=function(){var a=rocket.strToDate(this.getInputElement().value());a&&this.getInputElement().value(rocket.padLeft(a.getMonth()+1,2,"0")+"/"+rocket.padLeft(a.getDate(),2,"0")+"/"+a.getFullYear());this.container_.removeEventListener();(new rocket.Elements([document.body])).removeChild(this.container_);delete this.container_};
rocket.DateInput.prototype.changeInternal=function(){var a=(this.entered_date_=rocket.strToDate(this.getInputElement().value()))||new Date;this.calendar_year_=a.getFullYear();this.calendar_month_=a.getMonth();this.draw_calendar_()};
rocket.DateInput.prototype.draw_calendar_=function(){var a=rocket.createElement("table"),b=rocket.createElement("tbody");a.setAttribute({width:"100%",cellpadding:"5",cellspacing:"1",border:"0"}).style({"table-layout":"fixed","background-color":"#CCCCCC"});b.style({"background-color":"#FFFFFF"});var c=rocket.createElement("tr");this.draw_calendar_header_(c);b.appendChild(c);this.draw_calendar_contents_(b);a.appendChild(b);this.container_.innerHTML("").appendChild(a)};
rocket.DateInput.prototype.draw_calendar_header_=function(a){var b;b=rocket.createElement("td");b.innerHTML("<<").setAttribute({align:"center"});a.appendChild(b);b=rocket.createElement("td");b.innerHTML("<").setAttribute({align:"center"});a.appendChild(b);b=rocket.createElement("td");b.innerHTML("January February March April May June July August September October November December".split(" ")[this.calendar_month_]+" "+this.calendar_year_).setAttribute({colspan:3,align:"center"});a.appendChild(b);
b=rocket.createElement("td");b.innerHTML(">").setAttribute({align:"center"});a.appendChild(b);b=rocket.createElement("td");b.innerHTML(">>").setAttribute({align:"center"});a.appendChild(b)};
rocket.DateInput.prototype.draw_calendar_contents_=function(a){for(var b=32-(new Date(this.calendar_year_,this.calendar_month_,32)).getDate(),c=32-(new Date(this.calendar_year_,this.calendar_month_-1,32)).getDate(),e=(new Date(this.calendar_year_,this.calendar_month_)).getDay(),d=new Date,f=d.getFullYear(),g=d.getMonth(),d=d.getDate(),e=c-(e||7),h=0,k=0,l=0;6>l;++l){for(var m=rocket.createElement("tr"),n=0;7>n;++n){var p=rocket.createElement("td");p.setAttribute({align:"center"});ec?c:a};rocket.chunk=function(a,b){for(var c=[],e=0,d=a.length;eb[d])return 1}return 0});var b=this;this.query_=function(c){var e=[];c=c.toLowerCase();for(var d=0;a[d];++d)for(var f=0;a[d][f];++f)if(-1!==a[d][f].toLowerCase().replace(/<[^>]+>/g,"").indexOf(c)){e.push(a[d]);break}b.setResults(e)}};
rocket.AutoSuggest.prototype.highlight_=function(a,b){this.highlighted_.style({backgroundColor:""});this.highlighted_=a;this.highlighted_.style({backgroundColor:"#D5E2FF"});if(b){var c=this.highlighted_.getBoundingClientRect(),e=this.scroller_.getBoundingClientRect();c.bottom>e.bottom?this.scroller_.setAttribute({scrollTop:this.scroller_.getAttribute("scrollTop")+c.bottom-e.bottom}):c.top]+>/g,""))};rocket.AutoSuggest.prototype.getResult=function(){return this.result_};
rocket.AutoSuggest.prototype.enterInternal=function(){var a;this.highlighted_.length?a=this.results_[this.highlighted_.getAttribute("rowIndex")]:1===this.results_.length&&(a=this.results_[0]);a&&(this.setResult(a),(new rocket.Elements([document.body])).contains(this.getInputElement())&&this.getInputElement().setSelectionRange(0,a[0].length).focus(),this.dispatchEvent("select"))};
rocket.AutoSuggest.prototype.hideInternal=function(){this.container_.removeEventListener();(new rocket.Elements([document.body])).removeChild(this.container_);delete this.container_};rocket.AutoSuggest.prototype.upInternal=function(){var a=this.tbody_.children(),b=this.highlighted_.getAttribute("rowIndex");b?this.highlight_(a.i(b-1),!0):this.highlight_(a.i(a.length-1),!0)};
rocket.AutoSuggest.prototype.downInternal=function(){var a=this.tbody_.children(),b=this.highlighted_.getAttribute("rowIndex");a[b+1]?this.highlight_(a.i(b+1),!0):this.highlight_(a.i(0),!0)};rocket.AutoSelect=function(){this.addEventListener("show",function(){if(this.getResult()){this.place_holder_=rocket.createElement("div");this.getInputElement().value("");var a=this.getInputElement().getBoundingClientRect();this.place_holder_.style({"border-radius":3,position:"absolute","background-color":"#FFFFFF",border:"1px solid #888888",top:0,width:a.width-2,left:a.left}).innerHTML(this.getResult()[0]);(new rocket.Elements([document.body])).appendChild(this.place_holder_);var b=this.place_holder_.getBoundingClientRect();
this.place_holder_.style({top:a.top-b.height+1})}});this.addEventListener("hide",function(){this.place_holder_&&(this.getInputElement().value(this.getResult()[0]),(new rocket.Elements([document.body])).removeChild(this.place_holder_),delete this.place_holder_)})};rocket.inherits(rocket.AutoSelect,rocket.AutoSuggest);rocket.AutoSelect.prototype.getPlaceHolder=function(){return this.place_holder_};rocket.arrayify=function(a){if("string"!==typeof a)return a||[];a=rocket.trim(a);return""===a?[]:-1===a.indexOf(",")?-1===a.indexOf(" ")&&-1===a.indexOf("\r")&&-1===a.indexOf("\n")&&-1===a.indexOf("\t")?a.split(" "):a.split(/\s+/):a.split(/[\s,]+/)};rocket.$=function(a,b){var c;if("string"===typeof a)c=1===arguments.length?"#"===a.charAt(0)&&a.match(/^#[\w\d]+$/)?(c=document.getElementById(a.substr(1)))?[c]:[]:rocket.querySelectorAll(a,document):"string"===typeof b?rocket.querySelectorAll(a,rocket.querySelectorAll(b)[0]):b.nodeType?rocket.querySelectorAll(a,b):rocket.querySelectorAll(a,b[0]);else if(a)if(a.nodeType||a===window)c=[a];else if(rocket.isArray(a[0])){c=[];for(var e=0;a[e];++e)for(var d=0;a[e][d];++d)c.push(a[e][d])}else c=a;else c=
[];return new rocket.Elements(c)};rocket.round=function(a,b){if(0>b){var c=Math.pow(10,Math.abs(b));return Math.floor(a/c)*c}return parseFloat((+a).toFixed(b))};rocket.setInterval=function(a,b,c){rocket.setInterval=function(a,b,c){if(3>arguments.length)return setInterval(a,b);var g=Array.prototype.slice.call(arguments,2);return setInterval(function(){a.apply(window,g)},b)};window.setTimeout(function(a){!0===a&&(rocket.setInterval=setInterval)},0,!0);return rocket.setInterval.apply(window,arguments)};rocket.setTimeout=function(a,b,c){rocket.setTimeout=function(a,b,c){if(3>arguments.length)return setTimeout(a,b);var g=Array.prototype.slice.call(arguments,2);return setTimeout(function(){a.apply(window,g)},b)};window.setTimeout(function(a){!0===a&&(rocket.setTimeout=setTimeout)},0,!0);return rocket.setTimeout.apply(window,arguments)};rocket.some=function(a,b,c){rocket.some=Array.prototype.some?function(a,b,c){return Array.prototype.some.call(a,b,c)}:function(a,b,c){for(var g=0,h=a.length;gn)return d.desc?-1:1;if(mf?e=a:3===f||5===f||7===f?(c=a.substr(0,1),e=a.substr(1,2),b=a.substr(3,4)):9>f&&(c=a.substr(0,2),e=a.substr(2,2),b=a.substr(4,4)):(f=a.replace(/^\D+|\D+$/g,"").split(/\D+/),4>f.length&&(-1===a.indexOf("-")?(c=f[0],e=f[1],b=f[2]):(b=f[0],c=f[1],e=f[2])));if(!e)return null;b?100>b&&(b=bb?"pm":"am"),b=rocket.padLeft(""+(b%12||12),2,"0"),c=rocket.padLeft(""+c,2,"0"),b+":"+c+" "+e):null};rocket.sum=function(a){for(var b=arguments.length,c=0;b--;)c+=arguments[b];return c};rocket.table=function(a,b){var c,e;2===arguments.length?(c=a,e=b):(e=1,c=1===arguments.length?a:1);var d=rocket.createElement("table"),f=rocket.createElement("tbody");d.setAttribute({width:"100%",cellpadding:"0",cellspacing:"0",border:"0"});d.style({"table-layout":"fixed"});d.trs=[];d.tds=[];for(var g=0;gd;++d)e=rocket.createElement("td"),e.setAttribute({align:"center"}),e.innerHTML(""+(d||12)),c.appendChild(e);b.appendChild(c);c=rocket.createElement("tr");for(d=
0;4>d;++d)e=rocket.createElement("td"),e.setAttribute({align:"center",colspan:3}),e.innerHTML(""+(15*d||"00")),c.appendChild(e);b.appendChild(c);c=rocket.createElement("tr");e=rocket.createElement("td");e.setAttribute({align:"center",colspan:6});e.innerHTML("am");c.appendChild(e);e=rocket.createElement("td");e.setAttribute({align:"center",colspan:6});e.innerHTML("pm");c.appendChild(e);b.appendChild(c);a.appendChild(b);this.container_.appendChild(a)};
rocket.TimeInput.prototype.enterInternal=function(){var a=rocket.strToTime(this.getInputElement().value());a&&this.getInputElement().value(a)};rocket.TimeInput.prototype.hideInternal=function(){var a=rocket.strToTime(this.getInputElement().value());a&&this.getInputElement().value(a);this.container_.removeEventListener();(new rocket.Elements([document.body])).removeChild(this.container_);delete this.container_};rocket.trim=function(a){rocket.trim=String.trim?String.trim:function(a){return a&&a.replace(/^\s+|\s+$/g,"")};return rocket.trim(a)};rocket.trimLeft=function(a){rocket.trimLeft=String.trimLeft?String.trimLeft:function(a){return a&&a.replace(/^\s+/,"")};return rocket.trimLeft(a)};rocket.trimRight=function(a){rocket.trimRight=String.trimRight?String.trimRight:function(a){return a&&a.replace(/\s+$/,"")};return rocket.trimRight(a)};rocket.unique=function(a){for(var b=[],c=0,e=a.length;c