We're using the pristine version, thus no need to keep the minimal one
authorJoey Schulze <joey@infodrom.org>
Sat, 27 Feb 2010 18:36:12 +0000 (19:36 +0100)
committerJoey Schulze <joey@infodrom.org>
Sat, 27 Feb 2010 18:36:12 +0000 (19:36 +0100)
lib/rico/min.rico.js [deleted file]

diff --git a/lib/rico/min.rico.js b/lib/rico/min.rico.js
deleted file mode 100644 (file)
index f51ca6a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-var Prototype={Version:"1.6.0.3",Browser:{IE:!!(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1),Opera:navigator.userAgent.indexOf("Opera")>-1,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")===-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},BrowserFeatures:{XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement("div")["__proto__"]&&document.createElement("div")["__proto__"]!==document.createElement("form")["__proto__"]},ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(a){return a}};if(Prototype.Browser.MobileSafari){Prototype.BrowserFeatures.SpecificElementExtensions=false}var Class={create:function(){var e=null,d=$A(arguments);if(Object.isFunction(d[0])){e=d.shift()}function a(){this.initialize.apply(this,arguments)}Object.extend(a,Class.Methods);a.superclass=e;a.subclasses=[];if(e){var b=function(){};b.prototype=e.prototype;a.prototype=new b;e.subclasses.push(a)}for(var c=0;c<d.length;c++){a.addMethods(d[c])}if(!a.prototype.initialize){a.prototype.initialize=Prototype.emptyFunction}a.prototype.constructor=a;return a}};Class.Methods={addMethods:function(g){var c=this.superclass&&this.superclass.prototype;var b=Object.keys(g);if(!Object.keys({toString:true}).length){b.push("toString","valueOf")}for(var a=0,d=b.length;a<d;a++){var f=b[a],e=g[f];if(c&&Object.isFunction(e)&&e.argumentNames().first()=="$super"){var h=e;e=(function(i){return function(){return c[i].apply(this,arguments)}})(f).wrap(h);e.valueOf=h.valueOf.bind(h);e.toString=h.toString.bind(h)}this.prototype[f]=e}return this}};var Abstract={};Object.extend=function(a,c){for(var b in c){a[b]=c[b]}return a};Object.extend(Object,{inspect:function(a){try{if(Object.isUndefined(a)){return"undefined"}if(a===null){return"null"}return a.inspect?a.inspect():String(a)}catch(b){if(b instanceof RangeError){return"..."}throw b}},toJSON:function(a){var c=typeof a;switch(c){case"undefined":case"function":case"unknown":return;case"boolean":return a.toString()}if(a===null){return"null"}if(a.toJSON){return a.toJSON()}if(Object.isElement(a)){return}var b=[];for(var e in a){var d=Object.toJSON(a[e]);if(!Object.isUndefined(d)){b.push(e.toJSON()+": "+d)}}return"{"+b.join(", ")+"}"},toQueryString:function(a){return $H(a).toQueryString()},toHTML:function(a){return a&&a.toHTML?a.toHTML():String.interpret(a)},keys:function(a){var b=[];for(var c in a){b.push(c)}return b},values:function(b){var a=[];for(var c in b){a.push(b[c])}return a},clone:function(a){return Object.extend({},a)},isElement:function(a){return !!(a&&a.nodeType==1)},isArray:function(a){return a!=null&&typeof a=="object"&&"splice" in a&&"join" in a},isHash:function(a){return a instanceof Hash},isFunction:function(a){return typeof a=="function"},isString:function(a){return typeof a=="string"},isNumber:function(a){return typeof a=="number"},isUndefined:function(a){return typeof a=="undefined"}});Object.extend(Function.prototype,{argumentNames:function(){var a=this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1].replace(/\s+/g,"").split(",");return a.length==1&&!a[0]?[]:a},bind:function(){if(arguments.length<2&&Object.isUndefined(arguments[0])){return this}var a=this,c=$A(arguments),b=c.shift();return function(){return a.apply(b,c.concat($A(arguments)))}},bindAsEventListener:function(){var a=this,c=$A(arguments),b=c.shift();return function(d){return a.apply(b,[d||window.event].concat(c))}},curry:function(){if(!arguments.length){return this}var a=this,b=$A(arguments);return function(){return a.apply(this,b.concat($A(arguments)))}},delay:function(){var a=this,b=$A(arguments),c=b.shift()*1000;return window.setTimeout(function(){return a.apply(a,b)},c)},defer:function(){var a=[0.01].concat($A(arguments));return this.delay.apply(this,a)},wrap:function(b){var a=this;return function(){return b.apply(this,[a.bind(this)].concat($A(arguments)))}},methodize:function(){if(this._methodized){return this._methodized}var a=this;return this._methodized=function(){return a.apply(null,[this].concat($A(arguments)))}}});Date.prototype.toJSON=function(){return'"'+this.getUTCFullYear()+"-"+(this.getUTCMonth()+1).toPaddedString(2)+"-"+this.getUTCDate().toPaddedString(2)+"T"+this.getUTCHours().toPaddedString(2)+":"+this.getUTCMinutes().toPaddedString(2)+":"+this.getUTCSeconds().toPaddedString(2)+'Z"'};var Try={these:function(){var c;for(var b=0,d=arguments.length;b<d;b++){var a=arguments[b];try{c=a();break}catch(f){}}return c}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(b,a){this.callback=b;this.frequency=a;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},execute:function(){this.callback(this)},stop:function(){if(!this.timer){return}clearInterval(this.timer);this.timer=null},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.execute()}finally{this.currentlyExecuting=false}}}});Object.extend(String,{interpret:function(a){return a==null?"":String(a)},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});Object.extend(String.prototype,{gsub:function(e,c){var a="",d=this,b;c=arguments.callee.prepareReplacement(c);while(d.length>0){if(b=d.match(e)){a+=d.slice(0,b.index);a+=String.interpret(c(b));d=d.slice(b.index+b[0].length)}else{a+=d,d=""}}return a},sub:function(c,a,b){a=this.gsub.prepareReplacement(a);b=Object.isUndefined(b)?1:b;return this.gsub(c,function(d){if(--b<0){return d[0]}return a(d)})},scan:function(b,a){this.gsub(b,a);return String(this)},truncate:function(b,a){b=b||30;a=Object.isUndefined(a)?"...":a;return this.length>b?this.slice(0,b-a.length)+a:String(this)},strip:function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"")},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"")},extractScripts:function(){var b=new RegExp(Prototype.ScriptFragment,"img");var a=new RegExp(Prototype.ScriptFragment,"im");return(this.match(b)||[]).map(function(c){return(c.match(a)||["",""])[1]})},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script)})},escapeHTML:function(){var a=arguments.callee;a.text.data=this;return a.div.innerHTML},unescapeHTML:function(){var a=new Element("div");a.innerHTML=this.stripTags();return a.childNodes[0]?(a.childNodes.length>1?$A(a.childNodes).inject("",function(b,c){return b+c.nodeValue}):a.childNodes[0].nodeValue):""},toQueryParams:function(b){var a=this.strip().match(/([^?#]*)(#.*)?$/);if(!a){return{}}return a[1].split(b||"&").inject({},function(e,f){if((f=f.split("="))[0]){var c=decodeURIComponent(f.shift());var d=f.length>1?f.join("="):f[0];if(d!=undefined){d=decodeURIComponent(d)}if(c in e){if(!Object.isArray(e[c])){e[c]=[e[c]]}e[c].push(d)}else{e[c]=d}}return e})},toArray:function(){return this.split("")},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(a){return a<1?"":new Array(a+1).join(this)},camelize:function(){var d=this.split("-"),a=d.length;if(a==1){return d[0]}var c=this.charAt(0)=="-"?d[0].charAt(0).toUpperCase()+d[0].substring(1):d[0];for(var b=1;b<a;b++){c+=d[b].charAt(0).toUpperCase()+d[b].substring(1)}return c},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase()},dasherize:function(){return this.gsub(/_/,"-")},inspect:function(b){var a=this.gsub(/[\x00-\x1f\\]/,function(c){var d=String.specialChar[c[0]];return d?d:"\\u00"+c[0].charCodeAt().toPaddedString(2,16)});if(b){return'"'+a.replace(/"/g,'\\"')+'"'}return"'"+a.replace(/'/g,"\\'")+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(a){return this.sub(a||Prototype.JSONFilter,"#{1}")},isJSON:function(){var a=this;if(a.blank()){return false}a=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(a)},evalJSON:function(sanitize){var json=this.unfilterJSON();try{if(!sanitize||json.isJSON()){return eval("("+json+")")}}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())},include:function(a){return this.indexOf(a)>-1},startsWith:function(a){return this.indexOf(a)===0},endsWith:function(a){var b=this.length-a.length;return b>=0&&this.lastIndexOf(a)===b},empty:function(){return this==""},blank:function(){return/^\s*$/.test(this)},interpolate:function(a,b){return new Template(this,b).evaluate(a)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE){Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},unescapeHTML:function(){return this.stripTags().replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}})}String.prototype.gsub.prepareReplacement=function(b){if(Object.isFunction(b)){return b}var a=new Template(b);return function(c){return a.evaluate(c)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);var Template=Class.create({initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(a){if(Object.isFunction(a.toTemplateReplacements)){a=a.toTemplateReplacements()}return this.template.gsub(this.pattern,function(d){if(a==null){return""}var f=d[1]||"";if(f=="\\"){return d[2]}var b=a,g=d[3];var e=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;d=e.exec(g);if(d==null){return f}while(d!=null){var c=d[1].startsWith("[")?d[2].gsub("\\\\]","]"):d[1];b=b[c];if(null==b||""==d[3]){break}g=g.substring("["==d[3]?d[1].length:d[0].length);d=e.exec(g)}return f+String.interpret(b)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(c,b){var a=0;try{this._each(function(e){c.call(b,e,a++)})}catch(d){if(d!=$break){throw d}}return this},eachSlice:function(d,c,b){var a=-d,e=[],f=this.toArray();if(d<1){return f}while((a+=d)<f.length){e.push(f.slice(a,a+d))}return e.collect(c,b)},all:function(c,b){c=c||Prototype.K;var a=true;this.each(function(e,d){a=a&&!!c.call(b,e,d);if(!a){throw $break}});return a},any:function(c,b){c=c||Prototype.K;var a=false;this.each(function(e,d){if(a=!!c.call(b,e,d)){throw $break}});return a},collect:function(c,b){c=c||Prototype.K;var a=[];this.each(function(e,d){a.push(c.call(b,e,d))});return a},detect:function(c,b){var a;this.each(function(e,d){if(c.call(b,e,d)){a=e;throw $break}});return a},findAll:function(c,b){var a=[];this.each(function(e,d){if(c.call(b,e,d)){a.push(e)}});return a},grep:function(d,c,b){c=c||Prototype.K;var a=[];if(Object.isString(d)){d=new RegExp(d)}this.each(function(f,e){if(d.match(f)){a.push(c.call(b,f,e))}});return a},include:function(a){if(Object.isFunction(this.indexOf)){if(this.indexOf(a)!=-1){return true}}var b=false;this.each(function(c){if(c==a){b=true;throw $break}});return b},inGroupsOf:function(b,a){a=Object.isUndefined(a)?null:a;return this.eachSlice(b,function(c){while(c.length<b){c.push(a)}return c})},inject:function(a,c,b){this.each(function(e,d){a=c.call(b,a,e,d)});return a},invoke:function(b){var a=$A(arguments).slice(1);return this.map(function(c){return c[b].apply(c,a)})},max:function(c,b){c=c||Prototype.K;var a;this.each(function(e,d){e=c.call(b,e,d);if(a==null||e>=a){a=e}});return a},min:function(c,b){c=c||Prototype.K;var a;this.each(function(e,d){e=c.call(b,e,d);if(a==null||e<a){a=e}});return a},partition:function(d,b){d=d||Prototype.K;var c=[],a=[];this.each(function(f,e){(d.call(b,f,e)?c:a).push(f)});return[c,a]},pluck:function(b){var a=[];this.each(function(c){a.push(c[b])});return a},reject:function(c,b){var a=[];this.each(function(e,d){if(!c.call(b,e,d)){a.push(e)}});return a},sortBy:function(b,a){return this.map(function(d,c){return{value:d,criteria:b.call(a,d,c)}}).sort(function(f,e){var d=f.criteria,c=e.criteria;return d<c?-1:d>c?1:0}).pluck("value")},toArray:function(){return this.map()},zip:function(){var b=Prototype.K,a=$A(arguments);if(Object.isFunction(a.last())){b=a.pop()}var c=[this].concat(a).map($A);return this.map(function(e,d){return b(c.pluck(d))})},size:function(){return this.toArray().length},inspect:function(){return"#<Enumerable:"+this.toArray().inspect()+">"}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(c){if(!c){return[]}if(c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}if(Prototype.Browser.WebKit){$A=function(c){if(!c){return[]}if(!(typeof c==="function"&&typeof c.length==="number"&&typeof c.item==="function")&&c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse}Object.extend(Array.prototype,{_each:function(b){for(var a=0,c=this.length;a<c;a++){b(this[a])}},clear:function(){this.length=0;return this},first:function(){return this[0]},last:function(){return this[this.length-1]},compact:function(){return this.select(function(a){return a!=null})},flatten:function(){return this.inject([],function(b,a){return b.concat(Object.isArray(a)?a.flatten():[a])})},without:function(){var a=$A(arguments);return this.select(function(b){return !a.include(b)})},reverse:function(a){return(a!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(a){return this.inject([],function(d,c,b){if(0==b||(a?d.last()!=c:!d.include(c))){d.push(c)}return d})},intersect:function(a){return this.uniq().findAll(function(b){return a.detect(function(c){return b===c})})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return"["+this.map(Object.inspect).join(", ")+"]"},toJSON:function(){var a=[];this.each(function(b){var c=Object.toJSON(b);if(!Object.isUndefined(c)){a.push(c)}});return"["+a.join(", ")+"]"}});if(Object.isFunction(Array.prototype.forEach)){Array.prototype._each=Array.prototype.forEach}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c,a){a||(a=0);var b=this.length;if(a<0){a=b+a}for(;a<b;a++){if(this[a]===c){return a}}return -1}}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(b,a){a=isNaN(a)?this.length:(a<0?this.length+a:a)+1;var c=this.slice(0,a).reverse().indexOf(b);return(c<0)?c:a-c-1}}Array.prototype.toArray=Array.prototype.clone;function $w(a){if(!Object.isString(a)){return[]}a=a.strip();return a?a.split(/\s+/):[]}if(Prototype.Browser.Opera){Array.prototype.concat=function(){var e=[];for(var b=0,c=this.length;b<c;b++){e.push(this[b])}for(var b=0,c=arguments.length;b<c;b++){if(Object.isArray(arguments[b])){for(var a=0,d=arguments[b].length;a<d;a++){e.push(arguments[b][a])}}else{e.push(arguments[b])}}return e}}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(b,a){$R(0,this,true).each(b,a);return this},toPaddedString:function(c,b){var a=this.toString(b||10);return"0".times(c-a.length)+a},toJSON:function(){return isFinite(this)?this.toString():"null"}});$w("abs round ceil floor").each(function(a){Number.prototype[a]=Math[a].methodize()});function $H(a){return new Hash(a)}var Hash=Class.create(Enumerable,(function(){function a(b,c){if(Object.isUndefined(c)){return b}return b+"="+encodeURIComponent(String.interpret(c))}return{initialize:function(b){this._object=Object.isHash(b)?b.toObject():Object.clone(b)},_each:function(c){for(var b in this._object){var d=this._object[b],e=[b,d];e.key=b;e.value=d;c(e)}},set:function(b,c){return this._object[b]=c},get:function(b){if(this._object[b]!==Object.prototype[b]){return this._object[b]}},unset:function(b){var c=this._object[b];delete this._object[b];return c},toObject:function(){return Object.clone(this._object)},keys:function(){return this.pluck("key")},values:function(){return this.pluck("value")},index:function(c){var b=this.detect(function(d){return d.value===c});return b&&b.key},merge:function(b){return this.clone().update(b)},update:function(b){return new Hash(b).inject(this,function(c,d){c.set(d.key,d.value);return c})},toQueryString:function(){return this.inject([],function(d,e){var c=encodeURIComponent(e.key),b=e.value;if(b&&typeof b=="object"){if(Object.isArray(b)){return d.concat(b.map(a.curry(c)))}}else{d.push(a(c,b))}return d}).join("&")},inspect:function(){return"#<Hash:{"+this.map(function(b){return b.map(Object.inspect).join(": ")}).join(", ")+"}>"},toJSON:function(){return Object.toJSON(this.toObject())},clone:function(){return new Hash(this)}}})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(c,a,b){this.start=c;this.end=a;this.exclusive=b},_each:function(a){var b=this.start;while(this.include(b)){a(b);b=b.succ()}},include:function(a){if(a<this.start){return false}if(this.exclusive){return a<this.end}return a<=this.end}});var $R=function(c,a,b){return new ObjectRange(c,a,b)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(a){this.responders._each(a)},register:function(a){if(!this.include(a)){this.responders.push(a)}},unregister:function(a){this.responders=this.responders.without(a)},dispatch:function(d,b,c,a){this.each(function(f){if(Object.isFunction(f[d])){try{f[d].apply(f,[b,c,a])}catch(g){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=Class.create({initialize:function(a){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:"",evalJSON:true,evalJS:true};Object.extend(this.options,a||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters)){this.options.parameters=this.options.parameters.toQueryParams()}else{if(Object.isHash(this.options.parameters)){this.options.parameters=this.options.parameters.toObject()}}}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,b,a){$super(a);this.transport=Ajax.getTransport();this.request(b)},request:function(b){this.url=b;this.method=this.options.method;var d=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){d._method=this.method;this.method="post"}this.parameters=d;if(d=Object.toQueryString(d)){if(this.method=="get"){this.url+=(this.url.include("?")?"&":"?")+d}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){d+="&_="}}}try{var a=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(a)}Ajax.Responders.dispatch("onCreate",this,a);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){this.respondToReadyState.bind(this).defer(1)}this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=="post"?(this.options.postBody||d):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}}catch(c){this.dispatchException(c)}},onStateChange:function(){var a=this.transport.readyState;if(a>1&&!((a==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var e={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){e["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){e.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var c=this.options.requestHeaders;if(Object.isFunction(c.push)){for(var b=0,d=c.length;b<d;b+=2){e[c[b]]=c[b+1]}}else{$H(c).each(function(f){e[f.key]=f.value})}}for(var a in e){this.transport.setRequestHeader(a,e[a])}},success:function(){var a=this.getStatus();return !a||(a>=200&&a<300)},getStatus:function(){try{return this.transport.status||0}catch(a){return 0}},respondToReadyState:function(a){var c=Ajax.Request.Events[a],b=new Ajax.Response(this);if(c=="Complete"){try{this._complete=true;(this.options["on"+b.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(b,b.headerJSON)}catch(d){this.dispatchException(d)}var f=b.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&f&&f.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){this.evalResponse()}}try{(this.options["on"+c]||Prototype.emptyFunction)(b,b.headerJSON);Ajax.Responders.dispatch("on"+c,this,b,b.headerJSON)}catch(d){this.dispatchException(d)}if(c=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction}},isSameOrigin:function(){var a=this.url.match(/^\s*https?:\/\/[^\/]*/);return !a||(a[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:document.domain,port:location.port?":"+location.port:""}))},getHeader:function(a){try{return this.transport.getResponseHeader(a)||null}catch(b){return null}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(a){(this.options.onException||Prototype.emptyFunction)(this,a);Ajax.Responders.dispatch("onException",this,a)}});Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Response=Class.create({initialize:function(c){this.request=c;var d=this.transport=c.transport,a=this.readyState=d.readyState;if((a>2&&!Prototype.Browser.IE)||a==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(d.responseText);this.headerJSON=this._getHeaderJSON()}if(a==4){var b=d.responseXML;this.responseXML=Object.isUndefined(b)?null:b;this.responseJSON=this._getResponseJSON()}},status:0,statusText:"",getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||""}catch(a){return""}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(a){return null}},getResponseHeader:function(a){return this.transport.getResponseHeader(a)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var a=this.getHeader("X-JSON");if(!a){return null}a=decodeURIComponent(escape(a));try{return a.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(b){this.request.dispatchException(b)}},_getResponseJSON:function(){var a=this.request.options;if(!a.evalJSON||(a.evalJSON!="force"&&!(this.getHeader("Content-type")||"").include("application/json"))||this.responseText.blank()){return null}try{return this.responseText.evalJSON(a.sanitizeJSON||!this.request.isSameOrigin())}catch(b){this.request.dispatchException(b)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,a,c,b){this.container={success:(a.success||a),failure:(a.failure||(a.success?null:a))};b=Object.clone(b);var d=b.onComplete;b.onComplete=(function(e,f){this.updateContent(e.responseText);if(Object.isFunction(d)){d(e,f)}}).bind(this);$super(c,b)},updateContent:function(d){var c=this.container[this.success()?"success":"failure"],a=this.options;if(!a.evalScripts){d=d.stripScripts()}if(c=$(c)){if(a.insertion){if(Object.isString(a.insertion)){var b={};b[a.insertion]=d;c.insert(b)}else{a.insertion(c,d)}}else{c.update(d)}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,a,c,b){$super(b);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=a;this.url=c;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(a){if(this.options.decay){this.decay=(a.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=a.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(b){if(arguments.length>1){for(var a=0,d=[],c=arguments.length;a<c;a++){d.push($(arguments[a]))}return d}if(Object.isString(b)){b=document.getElementById(b)}return Element.extend(b)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(f,a){var c=[];var e=document.evaluate(f,$(a)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var b=0,d=e.snapshotLength;b<d;b++){c.push(Element.extend(e.snapshotItem(b)))}return c}}if(!window.Node){var Node={}}if(!Node.ELEMENT_NODE){Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12})}(function(){var a=this.Element;this.Element=function(d,c){c=c||{};d=d.toLowerCase();var b=Element.cache;if(Prototype.Browser.IE&&c.name){d="<"+d+' name="'+c.name+'">';delete c.name;return Element.writeAttribute(document.createElement(d),c)}if(!b[d]){b[d]=Element.extend(document.createElement(d))}return Element.writeAttribute(b[d].cloneNode(false),c)};Object.extend(this.Element,a||{});if(a){this.Element.prototype=a.prototype}}).call(window);Element.cache={};Element.Methods={visible:function(a){return $(a).style.display!="none"},toggle:function(a){a=$(a);Element[Element.visible(a)?"hide":"show"](a);return a},hide:function(a){a=$(a);a.style.display="none";return a},show:function(a){a=$(a);a.style.display="";return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},update:function(a,b){a=$(a);if(b&&b.toElement){b=b.toElement()}if(Object.isElement(b)){return a.update().insert(b)}b=Object.toHTML(b);a.innerHTML=b.stripScripts();b.evalScripts.bind(b).defer();return a},replace:function(b,c){b=$(b);if(c&&c.toElement){c=c.toElement()}else{if(!Object.isElement(c)){c=Object.toHTML(c);var a=b.ownerDocument.createRange();a.selectNode(b);c.evalScripts.bind(c).defer();c=a.createContextualFragment(c.stripScripts())}}b.parentNode.replaceChild(c,b);return b},insert:function(c,e){c=$(c);if(Object.isString(e)||Object.isNumber(e)||Object.isElement(e)||(e&&(e.toElement||e.toHTML))){e={bottom:e}}var d,f,b,g;for(var a in e){d=e[a];a=a.toLowerCase();f=Element._insertionTranslations[a];if(d&&d.toElement){d=d.toElement()}if(Object.isElement(d)){f(c,d);continue}d=Object.toHTML(d);b=((a=="before"||a=="after")?c.parentNode:c).tagName.toUpperCase();g=Element._getContentFromAnonymousElement(b,d.stripScripts());if(a=="top"||a=="after"){g.reverse()}g.each(f.curry(c));d.evalScripts.bind(d).defer()}return c},wrap:function(b,c,a){b=$(b);if(Object.isElement(c)){$(c).writeAttribute(a||{})}else{if(Object.isString(c)){c=new Element(c,a)}else{c=new Element("div",c)}}if(b.parentNode){b.parentNode.replaceChild(c,b)}c.appendChild(b);return c},inspect:function(b){b=$(b);var a="<"+b.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(f){var e=f.first(),c=f.last();var d=(b[e]||"").toString();if(d){a+=" "+c+"="+d.inspect(true)}});return a+">"},recursivelyCollect:function(a,c){a=$(a);var b=[];while(a=a[c]){if(a.nodeType==1){b.push(Element.extend(a))}}return b},ancestors:function(a){return $(a).recursivelyCollect("parentNode")},descendants:function(a){return $(a).select("*")},firstDescendant:function(a){a=$(a).firstChild;while(a&&a.nodeType!=1){a=a.nextSibling}return $(a)},immediateDescendants:function(a){if(!(a=$(a).firstChild)){return[]}while(a&&a.nodeType!=1){a=a.nextSibling}if(a){return[a].concat($(a).nextSiblings())}return[]},previousSiblings:function(a){return $(a).recursivelyCollect("previousSibling")},nextSiblings:function(a){return $(a).recursivelyCollect("nextSibling")},siblings:function(a){a=$(a);return a.previousSiblings().reverse().concat(a.nextSiblings())},match:function(b,a){if(Object.isString(a)){a=new Selector(a)}return a.match($(b))},up:function(b,d,a){b=$(b);if(arguments.length==1){return $(b.parentNode)}var c=b.ancestors();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},down:function(b,c,a){b=$(b);if(arguments.length==1){return b.firstDescendant()}return Object.isNumber(c)?b.descendants()[c]:Element.select(b,c)[a||0]},previous:function(b,d,a){b=$(b);if(arguments.length==1){return $(Selector.handlers.previousElementSibling(b))}var c=b.previousSiblings();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},next:function(c,d,b){c=$(c);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(c))}var a=c.nextSiblings();return Object.isNumber(d)?a[d]:Selector.findElement(a,d,b)},select:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b,a)},adjacent:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b.parentNode,a).without(b)},identify:function(b){b=$(b);var c=b.readAttribute("id"),a=arguments.callee;if(c){return c}do{c="anonymous_element_"+a.counter++}while($(c));b.writeAttribute("id",c);return c},readAttribute:function(c,a){c=$(c);if(Prototype.Browser.IE){var b=Element._attributeTranslations.read;if(b.values[a]){return b.values[a](c,a)}if(b.names[a]){a=b.names[a]}if(a.include(":")){return(!c.attributes||!c.attributes[a])?null:c.attributes[a].value}}return c.getAttribute(a)},writeAttribute:function(e,c,f){e=$(e);var b={},d=Element._attributeTranslations.write;if(typeof c=="object"){b=c}else{b[c]=Object.isUndefined(f)?true:f}for(var a in b){c=d.names[a]||a;f=b[a];if(d.values[a]){c=d.values[a](e,f)}if(f===false||f===null){e.removeAttribute(c)}else{if(f===true){e.setAttribute(c,c)}else{e.setAttribute(c,f)}}}return e},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(a,b){if(!(a=$(a))){return}var c=a.className;return(c.length>0&&(c==b||new RegExp("(^|\\s)"+b+"(\\s|$)").test(c)))},addClassName:function(a,b){if(!(a=$(a))){return}if(!a.hasClassName(b)){a.className+=(a.className?" ":"")+b}return a},removeClassName:function(a,b){if(!(a=$(a))){return}a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)")," ").strip();return a},toggleClassName:function(a,b){if(!(a=$(a))){return}return a[a.hasClassName(b)?"removeClassName":"addClassName"](b)},cleanWhitespace:function(b){b=$(b);var c=b.firstChild;while(c){var a=c.nextSibling;if(c.nodeType==3&&!/\S/.test(c.nodeValue)){b.removeChild(c)}c=a}return b},empty:function(a){return $(a).innerHTML.blank()},descendantOf:function(b,a){b=$(b),a=$(a);if(b.compareDocumentPosition){return(b.compareDocumentPosition(a)&8)===8}if(a.contains){return a.contains(b)&&a!==b}while(b=b.parentNode){if(b==a){return true}}return false},scrollTo:function(a){a=$(a);var b=a.cumulativeOffset();window.scrollTo(b[0],b[1]);return a},getStyle:function(b,c){b=$(b);c=c=="float"?"cssFloat":c.camelize();var d=b.style[c];if(!d||d=="auto"){var a=document.defaultView.getComputedStyle(b,null);d=a?a[c]:null}if(c=="opacity"){return d?parseFloat(d):1}return d=="auto"?null:d},getOpacity:function(a){return $(a).getStyle("opacity")},setStyle:function(b,c){b=$(b);var e=b.style,a;if(Object.isString(c)){b.style.cssText+=";"+c;return c.include("opacity")?b.setOpacity(c.match(/opacity:\s*(\d?\.?\d*)/)[1]):b}for(var d in c){if(d=="opacity"){b.setOpacity(c[d])}else{e[(d=="float"||d=="cssFloat")?(Object.isUndefined(e.styleFloat)?"cssFloat":"styleFloat"):d]=c[d]}}return b},setOpacity:function(a,b){a=$(a);a.style.opacity=(b==1||b==="")?"":(b<0.00001)?0:b;return a},getDimensions:function(c){c=$(c);var g=c.getStyle("display");if(g!="none"&&g!=null){return{width:c.offsetWidth,height:c.offsetHeight}}var b=c.style;var f=b.visibility;var d=b.position;var a=b.display;b.visibility="hidden";b.position="absolute";b.display="block";var h=c.clientWidth;var e=c.clientHeight;b.display=a;b.position=d;b.visibility=f;return{width:h,height:e}},makePositioned:function(a){a=$(a);var b=Element.getStyle(a,"position");if(b=="static"||!b){a._madePositioned=true;a.style.position="relative";if(Prototype.Browser.Opera){a.style.top=0;a.style.left=0}}return a},undoPositioned:function(a){a=$(a);if(a._madePositioned){a._madePositioned=undefined;a.style.position=a.style.top=a.style.left=a.style.bottom=a.style.right=""}return a},makeClipping:function(a){a=$(a);if(a._overflow){return a}a._overflow=Element.getStyle(a,"overflow")||"auto";if(a._overflow!=="hidden"){a.style.overflow="hidden"}return a},undoClipping:function(a){a=$(a);if(!a._overflow){return a}a.style.overflow=a._overflow=="auto"?"":a._overflow;a._overflow=null;return a},cumulativeOffset:function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;b=b.offsetParent}while(b);return Element._returnOffset(c,a)},positionedOffset:function(b){var a=0,d=0;do{a+=b.offsetTop||0;d+=b.offsetLeft||0;b=b.offsetParent;if(b){if(b.tagName.toUpperCase()=="BODY"){break}var c=Element.getStyle(b,"position");if(c!=="static"){break}}}while(b);return Element._returnOffset(d,a)},absolutize:function(b){b=$(b);if(b.getStyle("position")=="absolute"){return b}var d=b.positionedOffset();var f=d[1];var e=d[0];var c=b.clientWidth;var a=b.clientHeight;b._originalLeft=e-parseFloat(b.style.left||0);b._originalTop=f-parseFloat(b.style.top||0);b._originalWidth=b.style.width;b._originalHeight=b.style.height;b.style.position="absolute";b.style.top=f+"px";b.style.left=e+"px";b.style.width=c+"px";b.style.height=a+"px";return b},relativize:function(a){a=$(a);if(a.getStyle("position")=="relative"){return a}a.style.position="relative";var c=parseFloat(a.style.top||0)-(a._originalTop||0);var b=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=c+"px";a.style.left=b+"px";a.style.height=a._originalHeight;a.style.width=a._originalWidth;return a},cumulativeScrollOffset:function(b){var a=0,c=0;do{a+=b.scrollTop||0;c+=b.scrollLeft||0;b=b.parentNode}while(b);return Element._returnOffset(c,a)},getOffsetParent:function(a){if(a.offsetParent){return $(a.offsetParent)}if(a==document.body){return $(a)}while((a=a.parentNode)&&a!=document.body){if(Element.getStyle(a,"position")!="static"){return $(a)}}return $(document.body)},viewportOffset:function(d){var a=0,c=0;var b=d;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;if(b.offsetParent==document.body&&Element.getStyle(b,"position")=="absolute"){break}}while(b=b.offsetParent);b=d;do{if(!Prototype.Browser.Opera||(b.tagName&&(b.tagName.toUpperCase()=="BODY"))){a-=b.scrollTop||0;c-=b.scrollLeft||0}}while(b=b.parentNode);return Element._returnOffset(c,a)},clonePosition:function(b,d){var a=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});d=$(d);var e=d.viewportOffset();b=$(b);var f=[0,0];var c=null;if(Element.getStyle(b,"position")=="absolute"){c=b.getOffsetParent();f=c.viewportOffset()}if(c==document.body){f[0]-=document.body.offsetLeft;f[1]-=document.body.offsetTop}if(a.setLeft){b.style.left=(e[0]-f[0]+a.offsetLeft)+"px"}if(a.setTop){b.style.top=(e[1]-f[1]+a.offsetTop)+"px"}if(a.setWidth){b.style.width=d.offsetWidth+"px"}if(a.setHeight){b.style.height=d.offsetHeight+"px"}return b}};Element.Methods.identify.counter=1;Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}};if(Prototype.Browser.Opera){Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(d,b,c){switch(c){case"left":case"top":case"right":case"bottom":if(d(b,"position")==="static"){return null}case"height":case"width":if(!Element.visible(b)){return null}var e=parseInt(d(b,c),10);if(e!==b["offset"+c.capitalize()]){return e+"px"}var a;if(c==="height"){a=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{a=["border-left-width","padding-left","padding-right","border-right-width"]}return a.inject(e,function(f,g){var h=d(b,g);return h===null?f:f-parseInt(h,10)})+"px";default:return d(b,c)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(c,a,b){if(b==="title"){return a.title}return c(a,b)})}else{if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(c,b){b=$(b);try{b.offsetParent}catch(f){return $(document.body)}var a=b.getStyle("position");if(a!=="static"){return c(b)}b.setStyle({position:"relative"});var d=c(b);b.setStyle({position:a});return d});$w("positionedOffset viewportOffset").each(function(a){Element.Methods[a]=Element.Methods[a].wrap(function(f,c){c=$(c);try{c.offsetParent}catch(h){return Element._returnOffset(0,0)}var b=c.getStyle("position");if(b!=="static"){return f(c)}var d=c.getOffsetParent();if(d&&d.getStyle("position")==="fixed"){d.setStyle({zoom:1})}c.setStyle({position:"relative"});var g=f(c);c.setStyle({position:b});return g})});Element.Methods.cumulativeOffset=Element.Methods.cumulativeOffset.wrap(function(b,a){try{a.offsetParent}catch(c){return Element._returnOffset(0,0)}return b(a)});Element.Methods.getStyle=function(a,b){a=$(a);b=(b=="float"||b=="cssFloat")?"styleFloat":b.camelize();var c=a.style[b];if(!c&&a.currentStyle){c=a.currentStyle[b]}if(b=="opacity"){if(c=(a.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(c[1]){return parseFloat(c[1])/100}}return 1}if(c=="auto"){if((b=="width"||b=="height")&&(a.getStyle("display")!="none")){return a["offset"+b.capitalize()]+"px"}return null}return c};Element.Methods.setOpacity=function(b,e){function f(g){return g.replace(/alpha\([^\)]*\)/gi,"")}b=$(b);var a=b.currentStyle;if((a&&!a.hasLayout)||(!a&&b.style.zoom=="normal")){b.style.zoom=1}var d=b.getStyle("filter"),c=b.style;if(e==1||e===""){(d=f(d))?c.filter=d:c.removeAttribute("filter");return b}else{if(e<0.00001){e=0}}c.filter=f(d)+"alpha(opacity="+(e*100)+")";return b};Element._attributeTranslations={read:{names:{"class":"className","for":"htmlFor"},values:{_getAttr:function(a,b){return a.getAttribute(b,2)},_getAttrNode:function(a,c){var b=a.getAttributeNode(c);return b?b.value:""},_getEv:function(a,b){b=a.getAttribute(b);return b?b.toString().slice(23,-2):null},_flag:function(a,b){return $(a).hasAttribute(b)?b:null},style:function(a){return a.style.cssText.toLowerCase()},title:function(a){return a.title}}}};Element._attributeTranslations.write={names:Object.extend({cellpadding:"cellPadding",cellspacing:"cellSpacing"},Element._attributeTranslations.read.names),values:{checked:function(a,b){a.checked=!!b},style:function(a,b){a.style.cssText=b?b:""}}};Element._attributeTranslations.has={};$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc frameBorder").each(function(a){Element._attributeTranslations.write.names[a.toLowerCase()]=a;Element._attributeTranslations.has[a.toLowerCase()]=a});(function(a){Object.extend(a,{href:a._getAttr,src:a._getAttr,type:a._getAttr,action:a._getAttrNode,disabled:a._flag,checked:a._flag,readonly:a._flag,multiple:a._flag,onload:a._getEv,onunload:a._getEv,onclick:a._getEv,ondblclick:a._getEv,onmousedown:a._getEv,onmouseup:a._getEv,onmouseover:a._getEv,onmousemove:a._getEv,onmouseout:a._getEv,onfocus:a._getEv,onblur:a._getEv,onkeypress:a._getEv,onkeydown:a._getEv,onkeyup:a._getEv,onsubmit:a._getEv,onreset:a._getEv,onselect:a._getEv,onchange:a._getEv})})(Element._attributeTranslations.read.values)}else{if(Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1)?0.999999:(b==="")?"":(b<0.00001)?0:b;return a}}else{if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1||b==="")?"":(b<0.00001)?0:b;if(b==1){if(a.tagName.toUpperCase()=="IMG"&&a.width){a.width++;a.width--}else{try{var d=document.createTextNode(" ");a.appendChild(d);a.removeChild(d)}catch(c){}}}return a};Element.Methods.cumulativeOffset=function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;if(b.offsetParent==document.body){if(Element.getStyle(b,"position")=="absolute"){break}}b=b.offsetParent}while(b);return Element._returnOffset(c,a)}}}}}if(Prototype.Browser.IE||Prototype.Browser.Opera){Element.Methods.update=function(b,c){b=$(b);if(c&&c.toElement){c=c.toElement()}if(Object.isElement(c)){return b.update().insert(c)}c=Object.toHTML(c);var a=b.tagName.toUpperCase();if(a in Element._insertionTranslations.tags){$A(b.childNodes).each(function(d){b.removeChild(d)});Element._getContentFromAnonymousElement(a,c.stripScripts()).each(function(d){b.appendChild(d)})}else{b.innerHTML=c.stripScripts()}c.evalScripts.bind(c).defer();return b}}if("outerHTML" in document.createElement("div")){Element.Methods.replace=function(c,e){c=$(c);if(e&&e.toElement){e=e.toElement()}if(Object.isElement(e)){c.parentNode.replaceChild(e,c);return c}e=Object.toHTML(e);var d=c.parentNode,b=d.tagName.toUpperCase();if(Element._insertionTranslations.tags[b]){var f=c.next();var a=Element._getContentFromAnonymousElement(b,e.stripScripts());d.removeChild(c);if(f){a.each(function(g){d.insertBefore(g,f)})}else{a.each(function(g){d.appendChild(g)})}}else{c.outerHTML=e.stripScripts()}e.evalScripts.bind(e).defer();return c}}Element._returnOffset=function(b,c){var a=[b,c];a.left=b;a.top=c;return a};Element._getContentFromAnonymousElement=function(c,b){var d=new Element("div"),a=Element._insertionTranslations.tags[c];if(a){d.innerHTML=a[0]+b+a[1];a[2].times(function(){d=d.firstChild})}else{d.innerHTML=b}return $A(d.childNodes)};Element._insertionTranslations={before:function(a,b){a.parentNode.insertBefore(b,a)},top:function(a,b){a.insertBefore(b,a.firstChild)},bottom:function(a,b){a.appendChild(b)},after:function(a,b){a.parentNode.insertBefore(b,a.nextSibling)},tags:{TABLE:["<table>","</table>",1],TBODY:["<table><tbody>","</tbody></table>",2],TR:["<table><tbody><tr>","</tr></tbody></table>",3],TD:["<table><tbody><tr><td>","</td></tr></tbody></table>",4],SELECT:["<select>","</select>",1]}};(function(){Object.extend(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD})}).call(Element._insertionTranslations);Element.Methods.Simulated={hasAttribute:function(a,c){c=Element._attributeTranslations.has[c]||c;var b=$(a).getAttributeNode(c);return !!(b&&b.specified)}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div")["__proto__"]){window.HTMLElement={};window.HTMLElement.prototype=document.createElement("div")["__proto__"];Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions){return Prototype.K}var a={},b=Element.Methods.ByTag;var c=Object.extend(function(f){if(!f||f._extendedByPrototype||f.nodeType!=1||f==window){return f}var d=Object.clone(a),e=f.tagName.toUpperCase(),h,g;if(b[e]){Object.extend(d,b[e])}for(h in d){g=d[h];if(Object.isFunction(g)&&!(h in f)){f[h]=g.methodize()}}f._extendedByPrototype=Prototype.emptyFunction;return f},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(a,Element.Methods);Object.extend(a,Element.Methods.Simulated)}}});c.refresh();return c})();Element.hasAttribute=function(a,b){if(a.hasAttribute){return a.hasAttribute(b)}return Element.Methods.Simulated.hasAttribute(a,b)};Element.addMethods=function(c){var h=Prototype.BrowserFeatures,d=Element.Methods.ByTag;if(!c){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{FORM:Object.clone(Form.Methods),INPUT:Object.clone(Form.Element.Methods),SELECT:Object.clone(Form.Element.Methods),TEXTAREA:Object.clone(Form.Element.Methods)})}if(arguments.length==2){var b=c;c=arguments[1]}if(!b){Object.extend(Element.Methods,c||{})}else{if(Object.isArray(b)){b.each(g)}else{g(b)}}function g(j){j=j.toUpperCase();if(!Element.Methods.ByTag[j]){Element.Methods.ByTag[j]={}}Object.extend(Element.Methods.ByTag[j],c)}function a(l,k,j){j=j||false;for(var n in l){var m=l[n];if(!Object.isFunction(m)){continue}if(!j||!(n in k)){k[n]=m.methodize()}}}function e(l){var j;var k={OPTGROUP:"OptGroup",TEXTAREA:"TextArea",P:"Paragraph",FIELDSET:"FieldSet",UL:"UList",OL:"OList",DL:"DList",DIR:"Directory",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading",Q:"Quote",INS:"Mod",DEL:"Mod",A:"Anchor",IMG:"Image",CAPTION:"TableCaption",COL:"TableCol",COLGROUP:"TableCol",THEAD:"TableSection",TFOOT:"TableSection",TBODY:"TableSection",TR:"TableRow",TH:"TableCell",TD:"TableCell",FRAMESET:"FrameSet",IFRAME:"IFrame"};if(k[l]){j="HTML"+k[l]+"Element"}if(window[j]){return window[j]}j="HTML"+l+"Element";if(window[j]){return window[j]}j="HTML"+l.capitalize()+"Element";if(window[j]){return window[j]}window[j]={};window[j].prototype=document.createElement(l)["__proto__"];return window[j]}if(h.ElementExtensions){a(Element.Methods,HTMLElement.prototype);a(Element.Methods.Simulated,HTMLElement.prototype,true)}if(h.SpecificElementExtensions){for(var i in Element.Methods.ByTag){var f=e(i);if(Object.isUndefined(f)){continue}a(d[i],f.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh()}Element.cache={}};document.viewport={getDimensions:function(){var a={},b=Prototype.Browser;$w("width height").each(function(e){var c=e.capitalize();if(b.WebKit&&!document.evaluate){a[e]=self["inner"+c]}else{if(b.Opera&&parseFloat(window.opera.version())<9.5){a[e]=document.body["client"+c]}else{a[e]=document.documentElement["client"+c]}}});return a},getWidth:function(){return this.getDimensions().width},getHeight:function(){return this.getDimensions().height},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};var Selector=Class.create({initialize:function(a){this.expression=a.strip();if(this.shouldUseSelectorsAPI()){this.mode="selectorsAPI"}else{if(this.shouldUseXPath()){this.mode="xpath";this.compileXPathMatcher()}else{this.mode="normal";this.compileMatcher()}}},shouldUseXPath:function(){if(!Prototype.BrowserFeatures.XPath){return false}var a=this.expression;if(Prototype.Browser.WebKit&&(a.include("-of-type")||a.include(":empty"))){return false}if((/(\[[\w-]*?:|:checked)/).test(a)){return false}return true},shouldUseSelectorsAPI:function(){if(!Prototype.BrowserFeatures.SelectorsAPI){return false}if(!Selector._div){Selector._div=new Element("div")}try{Selector._div.querySelector(this.expression)}catch(a){return false}return true},compileMatcher:function(){var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return}this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(Object.isFunction(c[i])?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],"");break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join("\n"));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var f=this.expression,g=Selector.patterns,b=Selector.xpath,d,a;if(Selector._cache[f]){this.xpath=Selector._cache[f];return}this.matcher=[".//*"];while(f&&d!=f&&(/\S/).test(f)){d=f;for(var c in g){if(a=f.match(g[c])){this.matcher.push(Object.isFunction(b[c])?b[c](a):new Template(b[c]).evaluate(a));f=f.replace(a[0],"");break}}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath},findElements:function(a){a=a||document;var c=this.expression,b;switch(this.mode){case"selectorsAPI":if(a!==document){var d=a.id,f=$(a).identify();c="#"+f+" "+c}b=$A(a.querySelectorAll(c)).map(Element.extend);a.id=d;return b;case"xpath":return document._getElementsByXPath(this.xpath,a);default:return this.matcher(a)}},match:function(j){this.tokens=[];var o=this.expression,a=Selector.patterns,f=Selector.assertions;var b,d,g;while(o&&b!==o&&(/\S/).test(o)){b=o;for(var k in a){d=a[k];if(g=o.match(d)){if(f[k]){this.tokens.push([k,Object.clone(g)]);o=o.replace(g[0],"")}else{return this.findElements(document).include(j)}}}}var n=true,c,l;for(var k=0,h;h=this.tokens[k];k++){c=h[0],l=h[1];if(!Selector.assertions[c](j,l)){n=false;break}}return n},toString:function(){return this.expression},inspect:function(){return"#<Selector:"+this.expression.inspect()+">"}});Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(a){if(a[1]=="*"){return""}return"[local-name()='"+a[1].toLowerCase()+"' or local-name()='"+a[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:function(a){a[1]=a[1].toLowerCase();return new Template("[@#{1}]").evaluate(a)},attr:function(a){a[1]=a[1].toLowerCase();a[3]=a[5]||a[6];return new Template(Selector.xpath.operators[a[2]]).evaluate(a)},pseudo:function(a){var b=Selector.xpath.pseudos[a[1]];if(!b){return""}if(Object.isFunction(b)){return b(a)}return new Template(Selector.xpath.pseudos[a[1]]).evaluate(a)},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]",empty:"[count(*) = 0 and (count(text()) = 0)]",checked:"[@checked]",disabled:"[(@disabled) and (@type!='hidden')]",enabled:"[not(@disabled) and (@type!='hidden')]",not:function(b){var j=b[6],h=Selector.patterns,a=Selector.xpath,f,c;var g=[];while(j&&f!=j&&(/\S/).test(j)){f=j;for(var d in h){if(b=j.match(h[d])){c=Object.isFunction(a[d])?a[d](b):new Template(a[d]).evaluate(b);g.push("("+c.substring(1,c.length-1)+")");j=j.replace(b[0],"");break}}}return"[not("+g.join(" and ")+")]"},"nth-child":function(a){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",a)},"nth-last-child":function(a){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",a)},"nth-of-type":function(a){return Selector.xpath.pseudos.nth("position() ",a)},"nth-last-of-type":function(a){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",a)},"first-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-of-type"](a)},"last-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](a)},"only-of-type":function(a){var b=Selector.xpath.pseudos;return b["first-of-type"](a)+b["last-of-type"](a)},nth:function(g,e){var h,i=e[6],d;if(i=="even"){i="2n+0"}if(i=="odd"){i="2n+1"}if(h=i.match(/^(\d+)$/)){return"["+g+"= "+h[1]+"]"}if(h=i.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(h[1]=="-"){h[1]=-1}var f=h[1]?Number(h[1]):1;var c=h[2]?Number(h[2]):0;d="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(d).evaluate({fragment:g,a:f,b:c})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);      c = false;',className:'n = h.className(n, r, "#{1}", c);    c = false;',id:'n = h.id(n, r, "#{1}", c);           c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}", c); c = false;',attr:function(a){a[3]=(a[5]||a[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(a)},pseudo:function(a){if(a[6]){a[6]=a[6].replace(/"/g,'\\"')}return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(a)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,attrPresence:/^\[((?:[\w]+:)?[\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(a,b){return b[1].toUpperCase()==a.tagName.toUpperCase()},className:function(a,b){return Element.hasClassName(a,b[1])},id:function(a,b){return a.id===b[1]},attrPresence:function(a,b){return Element.hasAttribute(a,b[1])},attr:function(b,c){var a=Element.readAttribute(b,c[1]);return a&&Selector.operators[c[2]](a,c[5]||c[6])}},handlers:{concat:function(d,c){for(var e=0,f;f=c[e];e++){d.push(f)}return d},mark:function(a){var d=Prototype.emptyFunction;for(var b=0,c;c=a[b];b++){c._countedByPrototype=d}return a},unmark:function(a){for(var b=0,c;c=a[b];b++){c._countedByPrototype=undefined}return a},index:function(a,d,g){a._countedByPrototype=Prototype.emptyFunction;if(d){for(var b=a.childNodes,e=b.length-1,c=1;e>=0;e--){var f=b[e];if(f.nodeType==1&&(!g||f._countedByPrototype)){f.nodeIndex=c++}}}else{for(var e=0,c=1,b=a.childNodes;f=b[e];e++){if(f.nodeType==1&&(!g||f._countedByPrototype)){f.nodeIndex=c++}}}},unique:function(b){if(b.length==0){return b}var d=[],e;for(var c=0,a=b.length;c<a;c++){if(!(e=b[c])._countedByPrototype){e._countedByPrototype=Prototype.emptyFunction;d.push(Element.extend(e))}}return Selector.handlers.unmark(d)},descendant:function(a){var d=Selector.handlers;for(var c=0,b=[],e;e=a[c];c++){d.concat(b,e.getElementsByTagName("*"))}return b},child:function(a){var e=Selector.handlers;for(var d=0,c=[],f;f=a[d];d++){for(var b=0,g;g=f.childNodes[b];b++){if(g.nodeType==1&&g.tagName!="!"){c.push(g)}}}return c},adjacent:function(a){for(var c=0,b=[],e;e=a[c];c++){var d=this.nextElementSibling(e);if(d){b.push(d)}}return b},laterSibling:function(a){var d=Selector.handlers;for(var c=0,b=[],e;e=a[c];c++){d.concat(b,Element.nextSiblings(e))}return b},nextElementSibling:function(a){while(a=a.nextSibling){if(a.nodeType==1){return a}}return null},previousElementSibling:function(a){while(a=a.previousSibling){if(a.nodeType==1){return a}}return null},tagName:function(a,j,c,b){var k=c.toUpperCase();var e=[],g=Selector.handlers;if(a){if(b){if(b=="descendant"){for(var f=0,d;d=a[f];f++){g.concat(e,d.getElementsByTagName(c))}return e}else{a=this[b](a)}if(c=="*"){return a}}for(var f=0,d;d=a[f];f++){if(d.tagName.toUpperCase()===k){e.push(d)}}return e}else{return j.getElementsByTagName(c)}},id:function(b,a,j,f){var g=$(j),d=Selector.handlers;if(!g){return[]}if(!b&&a==document){return[g]}if(b){if(f){if(f=="child"){for(var c=0,e;e=b[c];c++){if(g.parentNode==e){return[g]}}}else{if(f=="descendant"){for(var c=0,e;e=b[c];c++){if(Element.descendantOf(g,e)){return[g]}}}else{if(f=="adjacent"){for(var c=0,e;e=b[c];c++){if(Selector.handlers.previousElementSibling(g)==e){return[g]}}}else{b=d[f](b)}}}}for(var c=0,e;e=b[c];c++){if(e==g){return[g]}}return[]}return(g&&Element.descendantOf(g,a))?[g]:[]},className:function(b,a,c,d){if(b&&d){b=this[d](b)}return Selector.handlers.byClassName(b,a,c)},byClassName:function(c,b,f){if(!c){c=Selector.handlers.descendant([b])}var h=" "+f+" ";for(var e=0,d=[],g,a;g=c[e];e++){a=g.className;if(a.length==0){continue}if(a==f||(" "+a+" ").include(h)){d.push(g)}}return d},attrPresence:function(c,b,a,g){if(!c){c=b.getElementsByTagName("*")}if(c&&g){c=this[g](c)}var e=[];for(var d=0,f;f=c[d];d++){if(Element.hasAttribute(f,a)){e.push(f)}}return e},attr:function(a,j,h,k,c,b){if(!a){a=j.getElementsByTagName("*")}if(a&&b){a=this[b](a)}var l=Selector.operators[c],f=[];for(var e=0,d;d=a[e];e++){var g=Element.readAttribute(d,h);if(g===null){continue}if(l(g,k)){f.push(d)}}return f},pseudo:function(b,c,e,a,d){if(b&&d){b=this[d](b)}if(!b){b=a.getElementsByTagName("*")}return Selector.pseudos[c](b,e,a)}},pseudos:{"first-child":function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(Selector.handlers.previousElementSibling(e)){continue}c.push(e)}return c},"last-child":function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(Selector.handlers.nextElementSibling(e)){continue}c.push(e)}return c},"only-child":function(b,g,a){var e=Selector.handlers;for(var d=0,c=[],f;f=b[d];d++){if(!e.previousElementSibling(f)&&!e.nextElementSibling(f)){c.push(f)}}return c},"nth-child":function(b,c,a){return Selector.pseudos.nth(b,c,a)},"nth-last-child":function(b,c,a){return Selector.pseudos.nth(b,c,a,true)},"nth-of-type":function(b,c,a){return Selector.pseudos.nth(b,c,a,false,true)},"nth-last-of-type":function(b,c,a){return Selector.pseudos.nth(b,c,a,true,true)},"first-of-type":function(b,c,a){return Selector.pseudos.nth(b,"1",a,false,true)},"last-of-type":function(b,c,a){return Selector.pseudos.nth(b,"1",a,true,true)},"only-of-type":function(b,d,a){var c=Selector.pseudos;return c["last-of-type"](c["first-of-type"](b,d,a),d,a)},getIndices:function(d,c,e){if(d==0){return c>0?[c]:[]}return $R(1,e).inject([],function(a,b){if(0==(b-c)%d&&(b-c)/d>=0){a.push(b)}return a})},nth:function(c,s,u,r,e){if(c.length==0){return[]}if(s=="even"){s="2n+0"}if(s=="odd"){s="2n+1"}var q=Selector.handlers,p=[],d=[],g;q.mark(c);for(var o=0,f;f=c[o];o++){if(!f.parentNode._countedByPrototype){q.index(f.parentNode,r,e);d.push(f.parentNode)}}if(s.match(/^\d+$/)){s=Number(s);for(var o=0,f;f=c[o];o++){if(f.nodeIndex==s){p.push(f)}}}else{if(g=s.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(g[1]=="-"){g[1]=-1}var v=g[1]?Number(g[1]):1;var t=g[2]?Number(g[2]):0;var w=Selector.pseudos.getIndices(v,t,c.length);for(var o=0,f,k=w.length;f=c[o];o++){for(var n=0;n<k;n++){if(f.nodeIndex==w[n]){p.push(f)}}}}}q.unmark(c);q.unmark(d);return p},empty:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.tagName=="!"||e.firstChild){continue}c.push(e)}return c},not:function(a,d,k){var g=Selector.handlers,l,c;var j=new Selector(d).findElements(k);g.mark(j);for(var f=0,e=[],b;b=a[f];f++){if(!b._countedByPrototype){e.push(b)}}g.unmark(j);return e},enabled:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(!e.disabled&&(!e.type||e.type!=="hidden")){c.push(e)}}return c},disabled:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.disabled){c.push(e)}}return c},checked:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.checked){c.push(e)}}return c}},operators:{"=":function(b,a){return b==a},"!=":function(b,a){return b!=a},"^=":function(b,a){return b==a||b&&b.startsWith(a)},"$=":function(b,a){return b==a||b&&b.endsWith(a)},"*=":function(b,a){return b==a||b&&b.include(a)},"$=":function(b,a){return b.endsWith(a)},"*=":function(b,a){return b.include(a)},"~=":function(b,a){return(" "+b+" ").include(" "+a+" ")},"|=":function(b,a){return("-"+(b||"").toUpperCase()+"-").include("-"+(a||"").toUpperCase()+"-")}},split:function(b){var a=[];b.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(c){a.push(c[1].strip())});return a},matchElements:function(f,g){var e=$$(g),d=Selector.handlers;d.mark(e);for(var c=0,b=[],a;a=f[c];c++){if(a._countedByPrototype){b.push(a)}}d.unmark(e);return b},findElement:function(b,c,a){if(Object.isNumber(c)){a=c;c=false}return Selector.matchElements(b,c||"*")[a||0]},findChildElements:function(e,g){g=Selector.split(g.join(","));var d=[],f=Selector.handlers;for(var c=0,b=g.length,a;c<b;c++){a=new Selector(g[c].strip());f.concat(d,a.findElements(e))}return(b>1)?f.unique(d):d}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(d,c){for(var e=0,f;f=c[e];e++){if(f.tagName!=="!"){d.push(f)}}return d},unmark:function(a){for(var b=0,c;c=a[b];b++){c.removeAttribute("_countedByPrototype")}return a}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(g,b){if(typeof b!="object"){b={hash:!!b}}else{if(Object.isUndefined(b.hash)){b.hash=true}}var c,f,a=false,e=b.submit;var d=g.inject({},function(h,i){if(!i.disabled&&i.name){c=i.name;f=$(i).getValue();if(f!=null&&i.type!="file"&&(i.type!="submit"||(!a&&e!==false&&(!e||c==e)&&(a=true)))){if(c in h){if(!Object.isArray(h[c])){h[c]=[h[c]]}h[c].push(f)}else{h[c]=f}}}return h});return b.hash?d:Object.toQueryString(d)}};Form.Methods={serialize:function(b,a){return Form.serializeElements(Form.getElements(b),a)},getElements:function(a){return $A($(a).getElementsByTagName("*")).inject([],function(b,c){if(Form.Element.Serializers[c.tagName.toLowerCase()]){b.push(Element.extend(c))}return b})},getInputs:function(g,c,d){g=$(g);var a=g.getElementsByTagName("input");if(!c&&!d){return $A(a).map(Element.extend)}for(var e=0,h=[],f=a.length;e<f;e++){var b=a[e];if((c&&b.type!=c)||(d&&b.name!=d)){continue}h.push(Element.extend(b))}return h},disable:function(a){a=$(a);Form.getElements(a).invoke("disable");return a},enable:function(a){a=$(a);Form.getElements(a).invoke("enable");return a},findFirstElement:function(b){var c=$(b).getElements().findAll(function(d){return"hidden"!=d.type&&!d.disabled});var a=c.findAll(function(d){return d.hasAttribute("tabIndex")&&d.tabIndex>=0}).sortBy(function(d){return d.tabIndex}).first();return a?a:c.find(function(d){return["input","select","textarea"].include(d.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(b,a){b=$(b),a=Object.clone(a||{});var d=a.parameters,c=b.readAttribute("action")||"";if(c.blank()){c=window.location.href}a.parameters=b.serialize(true);if(d){if(Object.isString(d)){d=d.toQueryParams()}Object.extend(a.parameters,d)}if(b.hasAttribute("method")&&!a.method){a.method=b.method}return new Ajax.Request(c,a)}};Form.Element={focus:function(a){$(a).focus();return a},select:function(a){$(a).select();return a}};Form.Element.Methods={serialize:function(a){a=$(a);if(!a.disabled&&a.name){var b=a.getValue();if(b!=undefined){var c={};c[a.name]=b;return Object.toQueryString(c)}}return""},getValue:function(a){a=$(a);var b=a.tagName.toLowerCase();return Form.Element.Serializers[b](a)},setValue:function(a,b){a=$(a);var c=a.tagName.toLowerCase();Form.Element.Serializers[c](a,b);return a},clear:function(a){$(a).value="";return a},present:function(a){return $(a).value!=""},activate:function(a){a=$(a);try{a.focus();if(a.select&&(a.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(a.type))){a.select()}}catch(b){}return a},disable:function(a){a=$(a);a.disabled=true;return a},enable:function(a){a=$(a);a.disabled=false;return a}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(a,b){switch(a.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(a,b);default:return Form.Element.Serializers.textarea(a,b)}},inputSelector:function(a,b){if(Object.isUndefined(b)){return a.checked?a.value:null}else{a.checked=!!b}},textarea:function(a,b){if(Object.isUndefined(b)){return a.value}else{a.value=b}},select:function(c,f){if(Object.isUndefined(f)){return this[c.type=="select-one"?"selectOne":"selectMany"](c)}else{var b,d,g=!Object.isArray(f);for(var a=0,e=c.length;a<e;a++){b=c.options[a];d=this.optionValue(b);if(g){if(d==f){b.selected=true;return}}else{b.selected=f.include(d)}}}},selectOne:function(b){var a=b.selectedIndex;return a>=0?this.optionValue(b.options[a]):null},selectMany:function(d){var a,e=d.length;if(!e){return null}for(var c=0,a=[];c<e;c++){var b=d.options[c];if(b.selected){a.push(this.optionValue(b))}}return a},optionValue:function(a){return Element.extend(a).hasAttribute("value")?a.value:a.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,a,b,c){$super(c,b);this.element=$(a);this.lastValue=this.getValue()},execute:function(){var a=this.getValue();if(Object.isString(this.lastValue)&&Object.isString(a)?this.lastValue!=a:String(this.lastValue)!=String(a)){this.callback(this.element,a);this.lastValue=a}}});Form.Element.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.serialize(this.element)}});Abstract.EventObserver=Class.create({initialize:function(a,b){this.element=$(a);this.callback=b;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks()}else{this.registerCallback(this.element)}},onElementEvent:function(){var a=this.getValue();if(this.lastValue!=a){this.callback(this.element,a);this.lastValue=a}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this)},registerCallback:function(a){if(a.type){switch(a.type.toLowerCase()){case"checkbox":case"radio":Event.observe(a,"click",this.onElementEvent.bind(this));break;default:Event.observe(a,"change",this.onElementEvent.bind(this));break}}}});Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element)}});if(!window.Event){var Event={}}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{},relatedTarget:function(b){var a;switch(b.type){case"mouseover":a=b.fromElement;break;case"mouseout":a=b.toElement;break;default:return null}return Element.extend(a)}});Event.Methods=(function(){var a;if(Prototype.Browser.IE){var b={0:1,1:4,2:2};a=function(d,c){return d.button==b[c]}}else{if(Prototype.Browser.WebKit){a=function(d,c){switch(c){case 0:return d.which==1&&!d.metaKey;case 1:return d.which==1&&d.metaKey;default:return false}}}else{a=function(d,c){return d.which?(d.which===c+1):(d.button===c)}}}return{isLeftClick:function(c){return a(c,0)},isMiddleClick:function(c){return a(c,1)},isRightClick:function(c){return a(c,2)},element:function(e){e=Event.extend(e);var d=e.target,c=e.type,f=e.currentTarget;if(f&&f.tagName){if(c==="load"||c==="error"||(c==="click"&&f.tagName.toLowerCase()==="input"&&f.type==="radio")){d=f}}if(d.nodeType==Node.TEXT_NODE){d=d.parentNode}return Element.extend(d)},findElement:function(d,f){var c=Event.element(d);if(!f){return c}var e=[c].concat(c.ancestors());return Selector.findElement(e,f,0)},pointer:function(e){var d=document.documentElement,c=document.body||{scrollLeft:0,scrollTop:0};return{x:e.pageX||(e.clientX+(d.scrollLeft||c.scrollLeft)-(d.clientLeft||0)),y:e.pageY||(e.clientY+(d.scrollTop||c.scrollTop)-(d.clientTop||0))}},pointerX:function(c){return Event.pointer(c).x},pointerY:function(c){return Event.pointer(c).y},stop:function(c){Event.extend(c);c.preventDefault();c.stopPropagation();c.stopped=true}}})();Event.extend=(function(){var a=Object.keys(Event.Methods).inject({},function(b,c){b[c]=Event.Methods[c].methodize();return b});if(Prototype.Browser.IE){Object.extend(a,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});return function(b){if(!b){return false}if(b._extendedByPrototype){return b}b._extendedByPrototype=Prototype.emptyFunction;var c=Event.pointer(b);Object.extend(b,{target:b.srcElement,relatedTarget:Event.relatedTarget(b),pageX:c.x,pageY:c.y});return Object.extend(b,a)}}else{Event.prototype=Event.prototype||document.createEvent("HTMLEvents")["__proto__"];Object.extend(Event.prototype,a);return Prototype.K}})();Object.extend(Event,(function(){var b=Event.cache;function c(j){if(j._prototypeEventID){return j._prototypeEventID[0]}arguments.callee.id=arguments.callee.id||1;return j._prototypeEventID=[++arguments.callee.id]}function g(j){if(j&&j.include(":")){return"dataavailable"}return j}function a(j){return b[j]=b[j]||{}}function f(l,j){var k=a(l);return k[j]=k[j]||[]}function h(k,j,l){var o=c(k);var n=f(o,j);if(n.pluck("handler").include(l)){return false}var m=function(p){if(!Event||!Event.extend||(p.eventName&&p.eventName!=j)){return false}Event.extend(p);l.call(k,p)};m.handler=l;n.push(m);return m}function i(m,j,k){var l=f(m,j);return l.find(function(n){return n.handler==k})}function d(m,j,k){var l=a(m);if(!l[j]){return false}l[j]=l[j].without(i(m,j,k))}function e(){for(var k in b){for(var j in b[k]){b[k][j]=null}}}if(window.attachEvent){window.attachEvent("onunload",e)}if(Prototype.Browser.WebKit){window.addEventListener("unload",Prototype.emptyFunction,false)}return{observe:function(l,j,m){l=$(l);var k=g(j);var n=h(l,j,m);if(!n){return l}if(l.addEventListener){l.addEventListener(k,n,false)}else{l.attachEvent("on"+k,n)}return l},stopObserving:function(l,j,m){l=$(l);var o=c(l),k=g(j);if(!m&&j){f(o,j).each(function(p){l.stopObserving(j,p.handler)});return l}else{if(!j){Object.keys(a(o)).each(function(p){l.stopObserving(p)});return l}}var n=i(o,j,m);if(!n){return l}if(l.removeEventListener){l.removeEventListener(k,n,false)}else{l.detachEvent("on"+k,n)}d(o,j,m);return l},fire:function(l,k,j){l=$(l);if(l==document&&document.createEvent&&!l.dispatchEvent){l=document.documentElement}var m;if(document.createEvent){m=document.createEvent("HTMLEvents");m.initEvent("dataavailable",true,true)}else{m=document.createEventObject();m.eventType="ondataavailable"}m.eventName=k;m.memo=j||{};if(document.createEvent){l.dispatchEvent(m)}else{l.fireEvent(m.eventType,m)}return Event.extend(m)}}})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize(),loaded:false});(function(){var b;function a(){if(document.loaded){return}if(b){window.clearInterval(b)}document.fire("dom:loaded");document.loaded=true}if(document.addEventListener){if(Prototype.Browser.WebKit){b=window.setInterval(function(){if(/loaded|complete/.test(document.readyState)){a()}},0);Event.observe(window,"load",a)}else{document.addEventListener("DOMContentLoaded",a,false)}}else{document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;a()}}}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(a,b){return Element.insert(a,{before:b})},Top:function(a,b){return Element.insert(a,{top:b})},Bottom:function(a,b){return Element.insert(a,{bottom:b})},After:function(a,b){return Element.insert(a,{after:b})}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(b,a,c){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(b,a,c)}this.xcomp=a;this.ycomp=c;this.offset=Element.cumulativeOffset(b);return(c>=this.offset[1]&&c<this.offset[1]+b.offsetHeight&&a>=this.offset[0]&&a<this.offset[0]+b.offsetWidth)},withinIncludingScrolloffsets:function(b,a,d){var c=Element.cumulativeScrollOffset(b);this.xcomp=a+c[0]-this.deltaX;this.ycomp=d+c[1]-this.deltaY;this.offset=Element.cumulativeOffset(b);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+b.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+b.offsetWidth)},overlap:function(b,a){if(!b){return 0}if(b=="vertical"){return((this.offset[1]+a.offsetHeight)-this.ycomp)/a.offsetHeight}if(b=="horizontal"){return((this.offset[0]+a.offsetWidth)-this.xcomp)/a.offsetWidth}},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(a){Position.prepare();return Element.absolutize(a)},relativize:function(a){Position.prepare();return Element.relativize(a)},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(b,c,a){a=a||{};return Element.clonePosition(c,b,a)}};if(!document.getElementsByClassName){document.getElementsByClassName=function(b){function a(c){return c.blank()?null:"[contains(concat(' ', @class, ' '), ' "+c+" ')]"}b.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(c,e){e=e.toString().strip();var d=/\s/.test(e)?$w(e).map(a).join(""):a(e);return d?document._getElementsByXPath(".//*"+d,c):[]}:function(e,f){f=f.toString().strip();var g=[],h=(/\s/.test(f)?$w(f):null);if(!h&&!f){return g}var c=$(e).getElementsByTagName("*");f=" "+f+" ";for(var d=0,k,j;k=c[d];d++){if(k.className&&(j=" "+k.className+" ")&&(j.include(f)||(h&&h.all(function(i){return !i.toString().blank()&&j.include(" "+i+" ")})))){g.push(Element.extend(k))}}return g};return function(d,c){return $(c||document.body).getElementsByClassName(d)}}(Element.Methods)}Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(a){this.element=$(a)},_each:function(a){this.element.className.split(/\s+/).select(function(b){return b.length>0})._each(a)},set:function(a){this.element.className=a},add:function(a){if(this.include(a)){return}this.set($A(this).concat(a).join(" "))},remove:function(a){if(!this.include(a)){return}this.set($A(this).without(a).join(" "))},toString:function(){return $A(this).join(" ")}};Object.extend(Element.ClassNames.prototype,Enumerable);Element.addMethods();var Rico={Version:"2.1",loadRequested:1,loadComplete:2,init:function(){try{document.execCommand("BackgroundImageCache",false,true)}catch(g){}this.preloadMsgs="";var b=document.getElementsByTagName("script");this.baseHref=location.protocol+"//"+location.host;this.loadedFiles={};this.windowIsLoaded=false;this.onLoadCallbacks=[];var d,c;for(var h=0;h<b.length;h++){if(!b[h].src){continue}var a=b[h].src;var j=a.lastIndexOf("/");var l=a.substring(0,j+1);d=a.substring(j+1);var k=d.indexOf("?");if(k>0){d=d.substring(0,k)}this.loadedFiles[d]=this.loadComplete;if(d=="rico.js"||d=="min.rico.js"){c=d;var f=(l.indexOf("/javascripts")>=0);if(f){this.jsDir="/javascripts/";this.cssDir="/stylesheets/";this.imgDir="/images/";this.htmDir="/";this.xslDir="/"}else{this.jsDir=l;this.cssDir=l+"css/";this.imgDir=l+"images/";this.htmDir=l;this.xslDir=l}}}if(!c){throw ("unable to locate rico.js or min.rico.js script element")}if(typeof Prototype=="undefined"){if(typeof(google)=="object"&&google.load){google.load("prototype","1.6")}else{this.include("prototype.js")}}if(c=="rico.js"){this.include("ricoCommon.js");this.languageInclude("en")}var e=function(){Rico.windowLoaded()};if(window.addEventListener){window.addEventListener("load",e,false)}else{if(window.attachEvent){window.attachEvent("onload",e)}}this.onLoad(function(){Rico.writeDebugMsg("Pre-load messages:\n"+Rico.preloadMsgs)})},moduleDependencies:{Accordion:["ricoBehaviors.js","ricoEffects.js","ricoComponents.js"],Color:["ricoStyles.js"],Corner:["ricoStyles.js"],DragAndDrop:["ricoStyles.js","ricoEffects.js","ricoDragDrop.js"],Effect:["ricoEffects.js"],Calendar:["ricoCalendar.js","ricoCalendar.css"],Tree:["ricoTree.js","ricoTree.css"],ColorPicker:["ricoColorPicker.js","ricoStyles.js","ricoColorPicker.css"],CustomMenu:["ricoMenu.js","ricoMenu.css"],SimpleGrid:["+Effect","ricoGridCommon.js","ricoGrid.css","ricoSimpleGrid.js"],LiveGridBasic:["ricoGridCommon.js","ricoGrid.css","ricoBehaviors.js","ricoLiveGrid.js"],LiveGrid:["+Effect","+LiveGridBasic","ricoLiveGridControls.js"],LiveGridMenu:["+CustomMenu","ricoLiveGridMenu.js"],LiveGridAjax:["+LiveGrid","ricoLiveGridAjax.js"],LiveGridJSON:["+LiveGridAjax","ricoLiveGridJSON.js"],LiveGridForms:["+LiveGridAjax","+LiveGridMenu","+Accordion","+Corner","ricoLiveGridForms.js","ricoLiveGridForms.css"],SpreadSheet:["+SimpleGrid","ricoSheet.js","ricoSheet.css"]},languages:{de:"translations/ricoLocale_de.js",en:"translations/ricoLocale_en.js",es:"translations/ricoLocale_es.js",fr:"translations/ricoLocale_fr.js",it:"translations/ricoLocale_it.js",ja:"translations/ricoLocale_ja.js",ko:"translations/ricoLocale_ko.js",pt:"translations/ricoLocale_pt.js",zh:"translations/ricoLocale_zh.js"},languageInclude:function(b){var a=this.languages[b];if(a){this.include(a)}return !!a},acceptLanguage:function(c){var a=c.toLowerCase().split(",");for(var b=0;b<a.length;b++){var d=a[b].match(/\w\w/);if(!d){continue}if(this.languageInclude(d)){return true}}return false},loadModule:function(){for(var b=0,e=arguments.length;b<e;b++){var c=arguments[b];var f=this.moduleDependencies[c];if(f){for(var d=0;d<f.length;d++){if(f[d].substring(0,1)=="+"){this.loadModule(f[d].slice(1))}else{this.include(f[d])}}}else{this.include(c)}}},include:function(a){if(this.loadedFiles[a]){return}this.addPreloadMsg("include: "+a);var c=a.substr(a.lastIndexOf(".")+1);switch(c.toLowerCase()){case"js":this.loadedFiles[a]=a.substring(0,4)=="rico"?this.loadRequested:this.loadComplete;document.write("<script type='text/javascript' src='"+this.jsDir+a+"'><\/script>");return;case"css":var b=document.createElement("link");b.type="text/css";b.rel="stylesheet";b.href=this.cssDir+a;this.loadedFiles[a]=this.loadComplete;document.getElementsByTagName("head")[0].appendChild(b);return}},includeLoaded:function(a){this.loadedFiles[a]=this.loadComplete;this.checkIfComplete()},windowLoaded:function(){this.windowIsLoaded=true;this.checkIfComplete()},checkIfComplete:function(){var c=this.windowIsLoaded?"":"window";for(var a in this.loadedFiles){if(this.loadedFiles[a]==this.loadRequested){c+=" "+a}}this.addPreloadMsg("waitingFor: "+c);if(c.length==0){this.addPreloadMsg("Processing callbacks");while(this.onLoadCallbacks.length>0){var b=this.onLoadCallbacks.shift();if(b){b()}}}},onLoad:function(b,a){if(a){this.onLoadCallbacks.unshift(b)}else{this.onLoadCallbacks.push(b)}this.checkIfComplete()},isKonqueror:navigator.userAgent.toLowerCase().indexOf("konqueror")>=0,startTime:new Date(),timeStamp:function(){var a=new Date();return(a.getTime()-this.startTime.getTime())+": "},setDebugArea:function(c,a){if(!this.debugArea||a){var b=document.getElementById(c);if(!b){return}this.debugArea=b;b.value=""}},addPreloadMsg:function(a){this.preloadMsgs+=Rico.timeStamp()+a+"\n"},writeDebugMsg:function(b,a){if(this.debugArea){if(a){this.debugArea.value=""}this.debugArea.value+=this.timeStamp()+b+"\n"}else{if(window.console){if(window.console.firebug){window.console.log(this.timeStamp(),b)}else{window.console.log(this.timeStamp()+b)}}else{if(window.opera){window.opera.postError(this.timeStamp()+b)}}}}};Rico.init();if(typeof Rico=="undefined"){throw ("Cannot find the Rico object")}if(typeof Prototype=="undefined"){throw ("Rico requires the Prototype JavaScript framework")}Rico.prototypeVersion=parseFloat(Prototype.Version.split(".")[0]+"."+Prototype.Version.split(".")[1]);if(Rico.prototypeVersion<1.3){throw ("Rico requires Prototype JavaScript framework version 1.3 or greater")}var RicoUtil={getDirectChildrenByTag:function(b,a){a=a.toLowerCase();return $(b).childElements().inject([],function(c,d){if(d.tagName&&d.tagName.toLowerCase()==a){c.push(d)}return c})},createXmlDocument:function(){if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);if(a.readyState==null){a.readyState=1;a.addEventListener("load",function(){a.readyState=4;if(typeof a.onreadystatechange=="function"){a.onreadystatechange()}},false)}return a}if(window.ActiveXObject){return Try.these(function(){return new ActiveXObject("MSXML2.DomDocument")},function(){return new ActiveXObject("Microsoft.DomDocument")},function(){return new ActiveXObject("MSXML.DomDocument")},function(){return new ActiveXObject("MSXML3.DomDocument")})||false}return null},getInnerText:function(f,b,g,e){switch(typeof f){case"string":return f;case"undefined":return f;case"number":return f.toString()}var d=f.childNodes;var a=d.length;var h="";for(var c=0;c<a;c++){switch(d[c].nodeType){case 1:if(Element.getStyle(d[c],"display")=="none"){continue}if(e&&Element.hasClassName(d[c],e)){continue}switch(d[c].tagName.toLowerCase()){case"img":if(!b){h+=d[c].alt||d[c].title||d[c].src}break;case"input":if(d[c].type=="hidden"){continue}case"select":case"textarea":if(!g){h+=$F(d[c])||""}break;default:h+=this.getInnerText(d[c],b,g,e);break}break;case 3:h+=d[c].nodeValue;break}}return h},getContentAsString:function(a,b){if(b){return this._getEncodedContent(a)}if(typeof a.xml!="undefined"){return this._getContentAsStringIE(a)}return this._getContentAsStringMozilla(a)},_getEncodedContent:function(a){if(a.innerHTML){return a.innerHTML}switch(a.childNodes.length){case 0:return"";case 1:return a.firstChild.nodeValue;default:return a.childNodes[1].nodeValue}},_getContentAsStringIE:function(a){var c="";for(var b=0;b<a.childNodes.length;b++){var d=a.childNodes[b];c+=(d.nodeType==4)?d.nodeValue:d.xml}return c},_getContentAsStringMozilla:function(b){var a=new XMLSerializer();var d="";for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==4){d+=e.nodeValue}else{d+=a.serializeToString(e)}}return d},docElement:function(){return(document.compatMode&&document.compatMode.indexOf("CSS")!=-1)?document.documentElement:document.getElementsByTagName("body")[0]},windowHeight:function(){if(document.viewport){return document.viewport.getHeight()}else{return window.innerHeight?window.innerHeight:this.docElement().clientHeight}},windowWidth:function(){if(document.viewport){return document.viewport.getWidth()}else{return this.docElement().clientWidth}},docScrollLeft:function(){if(window.pageXOffset){return window.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollLeft){return document.documentElement.scrollLeft}else{if(document.body){return document.body.scrollLeft}else{return 0}}}},docScrollTop:function(){if(window.pageYOffset){return window.pageYOffset}else{if(document.documentElement&&document.documentElement.scrollTop){return document.documentElement.scrollTop}else{if(document.body){return document.body.scrollTop}else{return 0}}}},nan2zero:function(a){if(typeof(a)=="string"){a=parseInt(a,10)}return isNaN(a)||typeof(a)=="undefined"?0:a},eventKey:function(a){if(typeof(a.keyCode)=="number"){return a.keyCode}else{if(typeof(a.which)=="number"){return a.which}else{if(typeof(a.charCode)=="number"){return a.charCode}}}return -1},getPreviosSiblingByTagName:function(c,b){var a=c.previousSibling;while(a){if((a.tagName==b)&&(a.style.display!="none")){return a}a=a.previousSibling}return null},getParentByTagName:function(d,a,c){var b=d;a=a.toLowerCase();while(b){if(b.tagName&&b.tagName.toLowerCase()==a){if(!c||b.className.indexOf(c)>=0){return b}}b=b.parentNode}return null},wrapChildren:function(b,a,e,c){var d=document.createElement(c||"div");if(e){d.id=e}if(a){d.className=a}while(b.firstChild){d.appendChild(b.firstChild)}b.appendChild(d);return d},formatPosNumber:function(f,g,c,e){var b=f.toFixed(g).split(/\./);if(c){var d=/(\d+)(\d{3})/;while(d.test(b[0])){b[0]=b[0].replace(d,"$1"+c+"$2")}}return b.join(e)},DOMNode_insertAfter:function(a,b){var c=b.parentNode;if(c.lastChild==b){return c.appendChild(a)}else{return c.insertBefore(a,b.nextSibling)}},positionCtlOverIcon:function(g,k){var c=Position.page(k);var j=this.docScrollTop();var a=this.windowHeight();if(g.style.display=="none"){g.style.display="block"}var h=Prototype.Browser.IE?1:2;var b=this.nan2zero(Element.getStyle(k,"padding-left"));g.style.left=(c[0]+b+h)+"px";var i=c[1]+h+j;var f=g.offsetHeight;var e=k.offsetHeight;var d=10;if(i+e+f+d<a+j){i+=e}else{i=Math.max(i-f,j)}g.style.top=i+"px"},createFormField:function(d,b,f,g,a){var e;if(typeof a!="string"){a=g}if(Prototype.Browser.IE){var c=b+' id="'+g+'"';if(f){c+=' type="'+f+'"'}if(b.match(/^(form|input|select|textarea|object|button|img)$/)){c+=' name="'+a+'"'}e=document.createElement("<"+c+" />")}else{e=document.createElement(b);if(f){e.type=f}e.id=g;if(typeof e.name=="string"){e.name=a}}d.appendChild(e);return e},addSelectOption:function(b,c,d){var a=document.createElement("option");if(typeof c=="string"){a.value=c}a.text=d;if(Prototype.Browser.IE){b.add(a)}else{b.add(a,null)}return a},getCookie:function(g){var b=g+"=";var f=b.length;var a=document.cookie.length;var d=0;while(d<a){var c=d+f;if(document.cookie.substring(d,c)==b){var e=document.cookie.indexOf(";",c);if(e==-1){e=document.cookie.length}return unescape(document.cookie.substring(c,e))}d=document.cookie.indexOf(" ",d)+1;if(d==0){break}}return null},setCookie:function(e,g,f,d,a){var h=e+"="+escape(g);if(typeof(f)=="number"){var b=new Date();b.setTime(b.getTime()+(f*24*60*60*1000));h+="; expires="+b.toGMTString()}if(typeof(d)=="string"){h+="; path="+d}if(typeof(a)=="string"){h+="; domain="+a}document.cookie=h}};if(!RicoTranslate){var RicoTranslate={phrases:{},phrasesById:{},thouSep:",",decPoint:".",langCode:"en",re:/^(\W*)\b(.*)\b(\W*)$/,dateFmt:"mm/dd/yyyy",timeFmt:"hh:nn:ss a/pm",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthAbbr:function(a){return this.monthNames[a].substr(0,3)},dayAbbr:function(a){return this.dayNames[a].substr(0,3)},addPhrase:function(b,a){this.phrases[b]=a},getPhrase:function(c){var e=c.split(/\t/);var a,d="";for(var b=0;b<e.length;b++){if(this.re.exec(e[b])){a=this.phrases[RegExp.$2];d+=(typeof a=="string")?RegExp.$1+a+RegExp.$3:e[b]}else{d+=e[b]}}return d},addPhraseId:function(b,a){this.phrasesById[b]=a},getPhraseById:function(d){var b=this.phrasesById[d];if(!b){alert("Error: missing phrase for "+d);return""}if(arguments.length<=1){return b}var c=arguments;return b.replace(/(\$\d)/g,function(e){var a=parseInt(e.charAt(1),10);return(a<c.length)?c[a]:""})}}}if(!Date.prototype.formatDate){Date.prototype.formatDate=function(a){var c=this;var b=(typeof a=="string")?a:"translateDate";switch(b){case"locale":case"localeDateTime":return c.toLocaleString();case"localeDate":return c.toLocaleDateString();case"translate":case"translateDateTime":b=RicoTranslate.dateFmt+" "+RicoTranslate.timeFmt;break;case"translateDate":b=RicoTranslate.dateFmt;break}return b.replace(/(yyyy|yy|mmmm|mmm|mm|dddd|ddd|dd|hh|nn|ss|a\/p)/gi,function(d){var e;switch(d){case"yyyy":return c.getFullYear();case"yy":return c.getFullYear().toString().substr(2);case"mmmm":return RicoTranslate.monthNames[c.getMonth()];case"mmm":return RicoTranslate.monthAbbr(c.getMonth());case"mm":return(c.getMonth()+1).toPaddedString(2);case"m":return(c.getMonth()+1);case"dddd":return RicoTranslate.dayNames[c.getDay()];case"ddd":return RicoTranslate.dayAbbr(c.getDay());case"dd":return c.getDate().toPaddedString(2);case"d":return c.getDate();case"hh":return((e=c.getHours()%12)?e:12).toPaddedString(2);case"h":return((e=c.getHours()%12)?e:12);case"HH":return c.getHours().toPaddedString(2);case"H":return c.getHours();case"nn":return c.getMinutes().toPaddedString(2);case"ss":return c.getSeconds().toPaddedString(2);case"a/p":return c.getHours()<12?"a":"p"}})}}if(!Date.prototype.setISO8601){Date.prototype.setISO8601=function(b,f){if(!b){return false}var e=b.match(/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|(?:([-+])(\d\d)(?::?(\d\d))?)?)?)?)?)?/);if(!e){return false}if(!f){f=0}var a=new Date(e[1],0,1);if(e[2]){a.setMonth(e[2]-1)}if(e[3]){a.setDate(e[3])}if(e[4]){a.setHours(e[4])}if(e[5]){a.setMinutes(e[5])}if(e[6]){a.setSeconds(e[6])}if(e[7]){a.setMilliseconds(Number("0."+e[7])*1000)}if(e[8]){if(e[10]&&e[11]){f=(Number(e[10])*60)+Number(e[11])}f*=((e[9]=="-")?1:-1);f-=a.getTimezoneOffset()}var c=(Number(a)+(f*60*1000));this.setTime(Number(c));return true}}if(!Date.prototype.toISO8601String){Date.prototype.toISO8601String=function(e,h){if(!e){e=6}var a;if(!h){h="Z";a=this}else{var g=h.match(/([-+])([0-9]{2}):([0-9]{2})/);var c=(Number(g[2])*60)+Number(g[3]);c*=((g[1]=="-")?-1:1);a=new Date(Number(Number(this)+(c*60000)))}var i=function(d){return((d<10)?"0":"")+d};var f=a.getUTCFullYear();if(e>1){f+="-"+i(a.getUTCMonth()+1)}if(e>2){f+="-"+i(a.getUTCDate())}if(e>3){f+="T"+i(a.getUTCHours())+":"+i(a.getUTCMinutes())}if(e>5){var b=Number(a.getUTCSeconds()+"."+((a.getUTCMilliseconds()<100)?"0":"")+i(a.getUTCMilliseconds()));f+=":"+i(b)}else{if(e>4){f+=":"+i(a.getUTCSeconds())}}if(e>3){f+=h}return f}}if(!String.prototype.toISO8601Date){String.prototype.toISO8601Date=function(){var a=new Date();return a.setISO8601(this)?a:null}}if(!String.prototype.formatDate){String.prototype.formatDate=function(a){var b=this.replace(/-/g,"/");var c=new Date(b);return isNaN(c)?this:c.formatDate(a)}}if(!Number.prototype.formatNumber){Number.prototype.formatNumber=function(c){if(isNaN(this)){return"NaN"}var b=this;if(typeof c.multiplier=="number"){b*=c.multiplier}var i=typeof c.decPlaces=="number"?c.decPlaces:0;var e=typeof c.thouSep=="string"?c.thouSep:RicoTranslate.thouSep;var f=typeof c.decPoint=="string"?c.decPoint:RicoTranslate.decPoint;var d=c.prefix||"";var g=c.suffix||"";var a=typeof c.negSign=="string"?c.negSign:"L";a=a.toUpperCase();var j,h;if(b<0){j=RicoUtil.formatPosNumber(-b,i,e,f);if(a=="P"){j="("+j+")"}j=d+j;if(a=="L"){j="-"+j}if(a=="T"){j+="-"}h="negNumber"}else{h=b==0?"zeroNumber":"posNumber";j=d+RicoUtil.formatPosNumber(b,i,e,f)}return"<span class='"+h+"'>"+j+g+"</span>"}}if(!String.prototype.formatNumber){String.prototype.formatNumber=function(a){var b=parseFloat(this.replace(/,/,"."));return isNaN(b)?this:b.formatNumber(a)}}Rico.Shim=Class.create();if(Prototype.Browser.IE){Rico.Shim.prototype={initialize:function(a){this.ifr=document.createElement("iframe");this.ifr.style.position="absolute";this.ifr.style.display="none";this.ifr.style.top="0px";this.ifr.style.left="0px";this.ifr.src="javascript:false;";a.parentNode.appendChild(this.ifr);this.DivRef=a},hide:function(){this.ifr.style.display="none"},move:function(){this.ifr.style.top=this.DivRef.style.top;this.ifr.style.left=this.DivRef.style.left},show:function(){this.ifr.style.width=this.DivRef.offsetWidth;this.ifr.style.height=this.DivRef.offsetHeight;this.move();this.ifr.style.zIndex=this.DivRef.currentStyle.zIndex-1;this.ifr.style.display="block"}}}else{Rico.Shim.prototype={initialize:function(){},hide:function(){},move:function(){},show:function(){}}}Rico.Shadow=Class.create({initialize:function(a){this.div=document.createElement("div");this.div.style.position="absolute";this.div.style.top="0px";this.div.style.left="0px";if(typeof this.div.style.filter=="undefined"){new Image().src=Rico.imgDir+"shadow.png";new Image().src=Rico.imgDir+"shadow_ur.png";new Image().src=Rico.imgDir+"shadow_ll.png";this.createShadow();this.offset=5}else{this.div.style.backgroundColor="#888";this.div.style.filter="progid:DXImageTransform.Microsoft.Blur(makeShadow=1, shadowOpacity=0.3, pixelRadius=3)";this.offset=0}this.div.style.display="none";a.parentNode.appendChild(this.div);this.DivRef=a},createShadow:function(){var e=document.createElement("table");e.style.height="100%";e.style.width="100%";e.cellSpacing=0;e.dir="ltr";var a=e.insertRow(-1);a.style.height="8px";var c=a.insertCell(-1);c.style.width="8px";var b=a.insertCell(-1);b.style.background="transparent url("+Rico.imgDir+"shadow_ur.png) no-repeat right bottom";var g=e.insertRow(-1);var f=g.insertCell(-1);f.style.background="transparent url("+Rico.imgDir+"shadow_ll.png) no-repeat right bottom";var d=g.insertCell(-1);d.style.background="transparent url("+Rico.imgDir+"shadow.png) no-repeat right bottom";this.div.appendChild(e)},hide:function(){this.div.style.display="none"},move:function(){this.div.style.top=(parseInt(this.DivRef.style.top||"0",10)+this.offset)+"px";this.div.style.left=(parseInt(this.DivRef.style.left||"0",10)+this.offset)+"px"},show:function(){this.div.style.width=this.DivRef.offsetWidth+"px";this.div.style.height=this.DivRef.offsetHeight+"px";this.move();this.div.style.zIndex=parseInt(Element.getStyle(this.DivRef,"z-index"),10)-1;this.div.style.display="block"}});Rico.Popup=Class.create({initialize:function(b,a,c){this.options={hideOnEscape:true,hideOnClick:true,ignoreClicks:false,position:"absolute",shadow:true,margin:6,zIndex:1,overflow:"auto",canDragFunc:false};Object.extend(this.options,b||{});if(a){this.setDiv(a,c)}},setDiv:function(b,c){this.divPopup=$(b);var a=this.options.position=="auto"?Element.getStyle(this.divPopup,"position").toLowerCase():this.options.position;if(!this.divPopup||a!="absolute"){return}this.closeFunc=c||this.closePopup.bindAsEventListener(this);this.shim=new Rico.Shim(this.divPopup);if(this.options.shadow){this.shadow=new Rico.Shadow(this.divPopup)}if(this.options.hideOnClick){Event.observe(document,"click",this.closeFunc)}if(this.options.hideOnEscape){Event.observe(document,"keyup",this._checkKey.bindAsEventListener(this))}if(this.options.canDragFunc){Event.observe(this.titleDiv||this.divPopup,"mousedown",this.startDrag.bind(this))}if(this.options.ignoreClicks||this.options.canDragFunc){this.ignoreClicks()}},createPopup:function(b,e,c,a,d,f){var g=document.createElement("div");g.style.position=this.options.position;g.style.zIndex=this.options.zIndex;g.style.overflow=this.options.overflow;g.style.top="0px";g.style.left="0px";g.style.height=c;g.style.width=a;g.className=d||"ricoPopup";if(e){g.innerHTML=e}b.appendChild(g);this.setDiv(g,f);this.contentDiv=g;if(this.options.canDragFunc===true){this.options.canDragFunc=this.safeDragTest.bind(this)}},safeDragTest:function(b,a){return(b.componentFromPoint&&b.componentFromPoint(a.clientX,a.clientY)!="")?false:b==this.divPopup},createWindow:function(f,e,c,a,d){var g=document.createElement("div");this.titleDiv=document.createElement("div");this.contentDiv=document.createElement("div");this.titleDiv.className="ricoTitle";this.titleDiv.innerHTML=f;this.titleDiv.style.position="relative";var b=document.createElement("img");b.src=Rico.imgDir+"close.gif";b.title=RicoTranslate.getPhraseById("close");b.style.cursor="pointer";b.style.position="absolute";b.style.right="0px";this.titleDiv.appendChild(b);this.contentDiv.className="ricoContent";this.contentDiv.innerHTML=e;this.contentDiv.style.height=c;this.contentDiv.style.width=a;this.contentDiv.style.overflow=this.options.overflow;g.style.position=this.options.position;g.style.zIndex=this.options.zIndex;g.style.top="0px";g.style.left="0px";g.style.display="none";g.className=d||"ricoWindow";g.appendChild(this.titleDiv);g.appendChild(this.contentDiv);document.body.appendChild(g);this.setDiv(g);Event.observe(b,"click",this.closePopup.bindAsEventListener(this))},ignoreClicks:function(){Event.observe(this.divPopup,"click",this._ignoreClick.bindAsEventListener(this))},_ignoreClick:function(a){if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}return true},_checkKey:function(a){if(RicoUtil.eventKey(a)==27){this.closeFunc()}return true},move:function(b,a){if(typeof b=="number"){this.divPopup.style.left=b+"px"}if(typeof a=="number"){this.divPopup.style.top=a+"px"}if(this.shim){this.shim.move()}if(this.shadow){this.shadow.move()}},startDrag:function(c){var b=Event.element(c);var a=typeof(this.options.canDragFunc)=="function"?this.options.canDragFunc(b,c):this.options.canDragFunc;if(!a){return}this.divPopup.style.cursor="move";this.lastMouseX=c.clientX;this.lastMouseY=c.clientY;this.dragHandler=this.drag.bindAsEventListener(this);this.dropHandler=this.endDrag.bindAsEventListener(this);Event.observe(document,"mousemove",this.dragHandler);Event.observe(document,"mouseup",this.dropHandler);Event.stop(c)},drag:function(c){var b=parseInt(this.divPopup.style.left,10)+c.clientX-this.lastMouseX;var a=parseInt(this.divPopup.style.top,10)+c.clientY-this.lastMouseY;this.move(b,a);this.lastMouseX=c.clientX;this.lastMouseY=c.clientY;Event.stop(c)},endDrag:function(){this.divPopup.style.cursor="";Event.stopObserving(document,"mousemove",this.dragHandler);Event.stopObserving(document,"mouseup",this.dropHandler);this.dragHandler=null;this.dropHandler=null},openPopup:function(b,a){this.divPopup.style.display="block";if(typeof b=="number"){this.divPopup.style.left=b+"px"}if(typeof a=="number"){this.divPopup.style.top=a+"px"}if(this.shim){this.shim.show()}if(this.shadow){this.shadow.show()}},closePopup:function(){if(this.dragHandler){this.endDrag()}if(this.shim){this.shim.hide()}if(this.shadow){this.shadow.hide()}this.divPopup.style.display="none"}});Rico.includeLoaded("ricoCommon.js");Rico.Color=Class.create({initialize:function(c,b,a){this.rgb={r:c,g:b,b:a}},setRed:function(a){this.rgb.r=a},setGreen:function(a){this.rgb.g=a},setBlue:function(a){this.rgb.b=a},setHue:function(b){var a=this.asHSB();a.h=b;this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)},setSaturation:function(b){var a=this.asHSB();a.s=b;this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)},setBrightness:function(a){var c=this.asHSB();c.b=a;this.rgb=Rico.Color.HSBtoRGB(c.h,c.s,c.b)},darken:function(b){var a=this.asHSB();this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.max(a.b-b,0))},brighten:function(b){var a=this.asHSB();this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.min(a.b+b,1))},blend:function(a){this.rgb.r=Math.floor((this.rgb.r+a.rgb.r)/2);this.rgb.g=Math.floor((this.rgb.g+a.rgb.g)/2);this.rgb.b=Math.floor((this.rgb.b+a.rgb.b)/2)},isBright:function(){var a=this.asHSB();return this.asHSB().b>0.5},isDark:function(){return !this.isBright()},asRGB:function(){return"rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")"},asHex:function(){return"#"+this.rgb.r.toColorPart()+this.rgb.g.toColorPart()+this.rgb.b.toColorPart()},asHSB:function(){return Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b)},toString:function(){return this.asHex()}});Rico.Color.createFromHex=function(d){if(d.length==4){var b=d;d="#";for(var c=1;c<4;c++){d+=(b.charAt(c)+b.charAt(c))}}if(d.indexOf("#")==0){d=d.substring(1)}if(!d.match(/^[0-9A-Fa-f]{6}$/)){return null}var f=d.substring(0,2);var e=d.substring(2,4);var a=d.substring(4,6);return new Rico.Color(parseInt(f,16),parseInt(e,16),parseInt(a,16))};Rico.Color.createColorFromBackground=function(d){if(!d.style){return new Rico.Color(255,255,255)}var b=Element.getStyle(d,"background-color");if(b.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&d.parentNode){return Rico.Color.createColorFromBackground(d.parentNode)}if(b==null){return new Rico.Color(255,255,255)}if(b.indexOf("rgb(")==0){var a=b.substring(4,b.length-1);var c=a.split(",");return new Rico.Color(parseInt(c[0],10),parseInt(c[1],10),parseInt(c[2],10))}else{if(b.indexOf("#")==0){return Rico.Color.createFromHex(b)}else{return new Rico.Color(255,255,255)}}};Rico.Color.HSBtoRGB=function(i,e,k){var c=0;var d=0;var l=0;if(e==0){c=parseInt(k*255+0.5,10);d=c;l=c}else{var g=(i-Math.floor(i))*6;var j=g-Math.floor(g);var b=k*(1-e);var a=k*(1-e*j);var m=k*(1-(e*(1-j)));switch(parseInt(g,10)){case 0:c=(k*255+0.5);d=(m*255+0.5);l=(b*255+0.5);break;case 1:c=(a*255+0.5);d=(k*255+0.5);l=(b*255+0.5);break;case 2:c=(b*255+0.5);d=(k*255+0.5);l=(m*255+0.5);break;case 3:c=(b*255+0.5);d=(a*255+0.5);l=(k*255+0.5);break;case 4:c=(m*255+0.5);d=(b*255+0.5);l=(k*255+0.5);break;case 5:c=(k*255+0.5);d=(b*255+0.5);l=(a*255+0.5);break}}return{r:parseInt(c,10),g:parseInt(d,10),b:parseInt(l,10)}};Rico.Color.RGBtoHSB=function(a,f,l){var h;var e;var k;var m=(a>f)?a:f;if(l>m){m=l}var i=(a<f)?a:f;if(l<i){i=l}k=m/255;if(m!=0){e=(m-i)/m}else{e=0}if(e==0){h=0}else{var c=(m-a)/(m-i);var j=(m-f)/(m-i);var d=(m-l)/(m-i);if(a==m){h=d-j}else{if(f==m){h=2+c-d}else{h=4+j-c}}h=h/6;if(h<0){h=h+1}}return{h:h,s:e,b:k}};Rico.Color.createGradientV=function(m,n,c){var i=typeof(n)=="string"?Rico.Color.createFromHex(n):n;var f=typeof(c)=="string"?Rico.Color.createFromHex(c):c;if(Prototype.Browser.IE){m.style.filter='progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr="'+i.asHex()+'",EndColorStr="'+f.asHex()+'")'}else{var r=Rico.Color.createColorPath(i,f,Math.min(m.offsetHeight,50));var o=m.offsetHeight,d=r.length;var a=Rico.Color.createGradientContainer();var q=document.createDocumentFragment();for(var k,j,b=0;b<r.length;b++){j=Math.round(o/d)||1;k=document.createElement("div");k.setAttribute("style","height:"+j+"px;width:100%;background-color:"+r[b].asRGB()+";");q.appendChild(k);d--;o-=j}a.appendChild(q);m.appendChild(a);q=null}};Rico.Color.createGradientH=function(k,m,d){var i=typeof(m)=="string"?Rico.Color.createFromHex(m):m;var h=typeof(d)=="string"?Rico.Color.createFromHex(d):d;if(Prototype.Browser.IE){k.style.filter='progid:DXImageTransform.Microsoft.Gradient(GradientType=1,StartColorStr="'+i.asHex()+'",EndColorStr="'+h.asHex()+'")'}else{var r=Rico.Color.createColorPath(i,h,Math.min(k.offsetWidth,50));var n=0,c=k.offsetWidth,f=r.length;var a=Rico.Color.createGradientContainer();var q=document.createDocumentFragment();for(var b=0;b<r.length;b++){var o=Math.round(c/f)||1;var j=document.createElement("div");j.setAttribute("style","position:absolute;top:0px;left:"+n+"px;height:100%;width:"+o+"px;background-color:"+r[b].asRGB()+";");q.appendChild(j);n+=o;f--;c-=o}a.appendChild(q);k.appendChild(a);q=null}};Rico.Color.createGradientContainer=function(){var a=document.createElement("div");a.style.height="100%";a.style.width="100%";a.style.position="absolute";a.style.top="0px";a.style.left="0px";a.style.zIndex=-1;return a};Rico.Color.createColorPath=function(b,a,e){var d=[];var c=1;var f=1/e;do{d[d.length]=Rico.Color.setColorHue(b,c,a);c-=f}while(c>0);return d};Rico.Color.setColorHue=function(b,a,c){return new Rico.Color(Math.round(b.rgb.r*a+c.rgb.r*(1-a)),Math.round(b.rgb.g*a+c.rgb.g*(1-a)),Math.round(b.rgb.b*a+c.rgb.b*(1-a)))};Rico.Corner={round:function(d,b){d=$(d);this._setOptions(b);var a=this.options.color=="fromElement"?this._background(d):this.options.color;var c=this.options.bgColor=="fromParent"?this._background(d.parentNode):this.options.bgColor;if(Prototype.Browser.Gecko&&this.options.useMoz&&!this.options.border&&Element.getStyle(d,"background-image")=="none"){this._roundCornersGecko(d,a)}else{if(typeof(Element.getStyle(d,"-webkit-border-radius"))=="string"&&!this.options.border){this._roundCornersWebKit(d,a)}else{this._roundCornersImpl(d,a,c)}}},_roundCornersImpl:function(c,a,b){this.options.numSlices=this.options.compact?2:4;this.borderColor=this._borderColor(a,b);if(this.options.border){this._renderBorder(c,b)}if(this._isTopRounded()){this._roundTopCorners(c,a,b)}if(this._isBottomRounded()){this._roundBottomCorners(c,a,b)}},_roundCornersGecko:function(c,b){var a=this.options.compact?"4px":"8px";if(this._hasString(this.options.corners,"all")){Element.setStyle(c,{MozBorderRadius:a},true)}else{if(this._hasString(this.options.corners,"top","tl")){Element.setStyle(c,{MozBorderRadiusTopleft:a},true)}if(this._hasString(this.options.corners,"top","tr")){Element.setStyle(c,{MozBorderRadiusTopright:a},true)}if(this._hasString(this.options.corners,"bottom","bl")){Element.setStyle(c,{MozBorderRadiusBottomleft:a},true)}if(this._hasString(this.options.corners,"bottom","br")){Element.setStyle(c,{MozBorderRadiusBottomright:a},true)}}},_roundCornersWebKit:function(c,b){var a=this.options.compact?"4px":"8px";if(this._hasString(this.options.corners,"all")){Element.setStyle(c,{WebkitBorderRadius:a},true)}else{if(this._hasString(this.options.corners,"top","tl")){Element.setStyle(c,{WebkitBorderTopLeftRadius:a},true)}if(this._hasString(this.options.corners,"top","tr")){Element.setStyle(c,{WebkitBorderTopRightRadius:a},true)}if(this._hasString(this.options.corners,"bottom","bl")){Element.setStyle(c,{WebkitBorderBottomLeftRadius:a},true)}if(this._hasString(this.options.corners,"bottom","br")){Element.setStyle(c,{WebkitBorderBottomRightRadius:a},true)}}},_renderBorder:function(b,c){var d=RicoUtil.wrapChildren(b);var a="1px solid "+this._borderColor(c);Element.setStyle(d,{borderLeft:a,borderRight:a,marginTop:"0px",marginBottom:"0px",padding:"1px",height:"100%"})},_roundTopCorners:function(c,a,e){var d=this._createCorner(e);for(var b=0;b<this.options.numSlices;b++){d.appendChild(this._createCornerSlice(a,e,b,"top"))}c.style.paddingTop="0px";c.insertBefore(d,c.firstChild)},_roundBottomCorners:function(c,a,e){var d=this._createCorner(e);for(var b=(this.options.numSlices-1);b>=0;b--){d.appendChild(this._createCornerSlice(a,e,b,"bottom"))}c.style.paddingBottom=0;c.appendChild(d)},_createCorner:function(b){var a=document.createElement("div");a.style.backgroundColor=(this._isTransparent()?"transparent":b);return a},_createCornerSlice:function(c,d,f,a){var e=document.createElement("span");var b=e.style;b.backgroundColor=c;b.display="block";b.height="1px";b.overflow="hidden";b.fontSize="1px";if(this.options.border&&f==0){b.borderTopStyle="solid";b.borderTopWidth="1px";b.borderLeftWidth="0px";b.borderRightWidth="0px";b.borderBottomWidth="0px";b.height="0px";b.borderColor=this.borderColor}else{if(this.borderColor){b.borderColor=this.borderColor;b.borderStyle="solid";b.borderWidth="0px 1px"}}if(!this.options.compact&&(f==(this.options.numSlices-1))){b.height="2px"}this._setMargin(e,f,a);this._setBorder(e,f,a);return e},_setOptions:function(a){this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false,useMoz:true};Object.extend(this.options,a||{});if(this._isTransparent()){this.options.blend=false}},_whichSideTop:function(){if(this._hasString(this.options.corners,"all","top")){return""}if(this.options.corners.indexOf("tl")>=0&&this.options.corners.indexOf("tr")>=0){return""}if(this.options.corners.indexOf("tl")>=0){return"left"}else{if(this.options.corners.indexOf("tr")>=0){return"right"}}return""},_whichSideBottom:function(){if(this._hasString(this.options.corners,"all","bottom")){return""}if(this.options.corners.indexOf("bl")>=0&&this.options.corners.indexOf("br")>=0){return""}if(this.options.corners.indexOf("bl")>=0){return"left"}else{if(this.options.corners.indexOf("br")>=0){return"right"}}return""},_borderColor:function(a,d){if(a=="transparent"){return d}if(this.options.border){return this.options.border}if(!this.options.blend){return""}var c=Rico.Color.createFromHex(d);var b=Rico.Color.createFromHex(a);if(c==null||b==null){this.options.blend=false;return""}c.blend(b);return c},_setMargin:function(d,e,b){var c=this._marginSize(e);var a=b=="top"?this._whichSideTop():this._whichSideBottom();if(a=="left"){d.style.marginLeft=c+"px";d.style.marginRight="0px"}else{if(a=="right"){d.style.marginRight=c+"px";d.style.marginLeft="0px"}else{d.style.marginLeft=c+"px";d.style.marginRight=c+"px"}}},_setBorder:function(d,e,b){var c=this._borderSize(e);var a=b=="top"?this._whichSideTop():this._whichSideBottom();if(a=="left"){d.style.borderLeftWidth=c+"px";d.style.borderRightWidth="0px"}else{if(a=="right"){d.style.borderRightWidth=c+"px";d.style.borderLeftWidth="0px"}else{d.style.borderLeftWidth=c+"px";d.style.borderRightWidth=c+"px"}}if(this.options.border){d.style.borderLeftWidth=c+"px";d.style.borderRightWidth=c+"px"}},_marginSize:function(e){if(this._isTransparent()){return 0}var d=[5,3,2,1];var a=[3,2,1,0];var c=[2,1];var b=[1,0];if(this.options.compact&&this.options.blend){return b[e]}else{if(this.options.compact){return c[e]}else{if(this.options.blend){return a[e]}else{return d[e]}}}},_borderSize:function(e){var d=[5,3,2,1];var b=[2,1,1,1];var a=[1,0];var c=[0,2,0,0];if(this.options.compact&&(this.options.blend||this._isTransparent())){return 1}else{if(this.options.compact){return a[e]}else{if(this.options.blend){return b[e]}else{if(this.options.border){return c[e]}else{if(this._isTransparent()){return d[e]}}}}}return 0},_background:function(c){try{var a=Element.getStyle(c,"background-color");if(a.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&c.parentNode){return this._background(c.parentNode)}return a==null?"#ffffff":a}catch(b){return"#ffffff"}},_hasString:function(b){for(var a=1;a<arguments.length;a++){if(b.indexOf(arguments[a])>=0){return true}}return false},_isTransparent:function(){return this.options.color=="transparent"},_isTopRounded:function(){return this._hasString(this.options.corners,"all","top","tl","tr")},_isBottomRounded:function(){return this._hasString(this.options.corners,"all","bottom","bl","br")},_hasSingleTextChild:function(a){return a.childNodes.length==1&&a.childNodes[0].nodeType==3}};Rico.includeLoaded("ricoStyles.js");Rico.selectionSet=function(b,a){new Rico.SelectionSet(b,a)};Rico.SelectionSet=Class.create({initialize:function(c,a){this.options=a||{};if(typeof c=="string"){c=$$(c)}this.previouslySelected=[];this.selectionSet=c;this.selectedClassName=this.options.selectedClass||"selected";this.selectNode=this.options.selectNode||function(d){return d};this.onSelect=this.options.onSelect;this.onFirstSelect=this.options.onFirstSelect;this.clickHandler=this.click.bind(this);c.each(function(d){Event.observe(d,"click",new Rico.EventWrapper(this.clickHandler,d).wrapper)}.bind(this));if(!this.options.noDefault){var b=this.options.cookieName?this.getCookie():0;this.selectIndex(b||this.options.selectedIndex||0)}},getCookie:function(){var b=RicoUtil.getCookie(this.options.cookieName);if(!b){return 0}var a=parseInt(b);return a<this.selectionSet.length?a:0},reset:function(){this.previouslySelected=[];this.notifySelected(this.selected)},select:function(a){if(this.selected==a){return}if(this.selected){Element.removeClassName(this.selectNode(this.selected),this.selectedClassName)}this.notifySelected(a);this.selected=a;Element.addClassName(this.selectNode(this.selected),this.selectedClassName)},notifySelected:function(b){var a=this.selectionSet.indexOf(b);if(this.options.cookieName){RicoUtil.setCookie(this.options.cookieName,a,this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)}if(this.onFirstSelect&&!this.previouslySelected[a]){this.onFirstSelect(b,a);this.previouslySelected[a]=true}if(this.onSelect){try{this.onSelect(b,a)}catch(c){}}},selectIndex:function(a){this.select(this.selectionSet[a])},nextSelectItem:function(){var a=this.selectionSet.indexOf(this.selected);if(a+1>=this.selectionSet.length){return this.selectionSet[a-1]}else{return this.selectionSet[a+1]}},selectNext:function(){var a=this.selectionSet.indexOf(this.selected);if(a>=this.selectionSet.length){this.selectIndex(a-1)}else{this.selectIndex(a+1)}},click:function(a,b){this.select(b)},add:function(a){if(a.constructur==Array){a.each(function(b){Event.observe(b,"click",new Rico.EventWrapper(this.clickHandler,a).wrapper)}.bind(this))}else{Event.observe(a,"click",new Rico.EventWrapper(this.clickHandler,a).wrapper)}},remove:function(a){this.selectionSet=this.selectionSet.without(a)},removeAll:function(){}});Rico.HoverSet=Class.create({initialize:function(c,a){a=a||[];this.hoverSet=c;this.hoverClassName=a.hoverClass||"hover";this.hoverNodes=a.hoverNodes||function(d){return[d]};this.listenerHover=this._onHover.bind(this);this.listenerEndHover=this._onUnHover.bind(this);for(var b=0;b<this.hoverSet.length;b++){this.add(this.hoverSet[b])}},_onHover:function(a,b){this.hover(b)},_onUnHover:function(a,b){this.unHover(b)},hover:function(a){this.hoverNodes(a).each((function(b){Element.addClassName(b,this.hoverClassName)}).bind(this))},unHover:function(a){this.hoverNodes(a).each((function(b){Element.removeClassName(b,this.hoverClassName)}).bind(this))},add:function(a){Event.observe(a,"mousemove",new Rico.EventWrapper(this.listenerHover,a).wrapper);Event.observe(a,"mouseout",new Rico.EventWrapper(this.listenerEndHover,a).wrapper)}});Rico.Hover={groups:{},clearCurrent:function(a){var b=Rico.Hover.groups[a];if(!b){return}clearTimeout(b[0]);b[1].end();Rico.Hover.groups[a]=null},end:function(a){Rico.Hover.groups[a][1].end()},endWith:function(a,b){var c=setTimeout('Rico.Hover.end("'+b+'")',a.exitDelay);Rico.Hover.groups[b]=[c,a]}};Rico.HoverDisplay=Class.create({initialize:function(b,a){this.element=b;this.options=a||{};this.group=this.options.group;this.exitDelay=this.options.delay||1000},begin:function(){Rico.Hover.clearCurrent(this.group);Element.show(this.element)},end:function(a){if(a){Rico.Hover.endWith(this,this.group)}else{Element.hide(this.element)}}});Rico.EventWrapper=Class.create({initialize:function(a,b){this.handler=a;this.target=b;this.wrapper=this.wrapperCall.bindAsEventListener(this)},wrapperCall:function(a){this.handler(a,this.target)}});Rico.includeLoaded("ricoBehaviors.js");Rico.animate=function(a){new Rico.Effect.Animator().play(a,arguments[1])};Rico.Effect={};Rico.Effect.easeIn=function(a){return Math.sqrt(a)};Rico.Effect.easeOut=function(a){return a*a};Rico.Stepping={};Rico.Stepping.easeIn=Rico.Effect.easeIn;Rico.Stepping.easeOut=Rico.Effect.easeOut;Rico.Effect.Animator=Class.create({initialize:function(a){this.animateMethod=this.animate.bind(this);this.options=arguments[1]||{};this.stepsLeft=0;if(!a){return}this.reset(a,arguments[1])},reset:function(a){this.effect=a;if(arguments[1]){this.setOptions(arguments[1])}this.stepsLeft=this.options.steps;this.duration=this.options.duration},setOptions:function(a){this.options=Object.extend({steps:10,duration:200,rate:function(b){return b}},a||{})},play:function(a){this.setOptions(arguments[1]);if(a){if(a.step){this.reset(a,arguments[1])}else{$H(a).keys().each((function(c){var b={fadeOut:Rico.Effect.FadeOut}[c];this.reset(new b(a[c]))}).bind(this))}}this.animate()},stop:function(){if(this.timer){clearTimeout(this.timer)}this.stepsLeft=0;if(this.effect&&this.effect.finish){this.effect.finish()}if(this.options.onFinish){this.options.onFinish()}},pause:function(){this.interupt=true},resume:function(){this.interupt=false;if(this.stepsLeft>0){this.animate()}},animate:function(){if(this.interupt){return}if(this.stepsLeft<=0){this.stop();return}if(this.timer){clearTimeout(this.timer)}this.effect.step(this.options.rate(this.stepsLeft));this.startNextStep()},startNextStep:function(){var a=Math.round(this.duration/this.stepsLeft);this.duration-=a;this.stepsLeft--;this.timer=setTimeout(this.animateMethod,a)},isPlaying:function(){return this.stepsLeft!=0&&!this.interupt}});Rico.Effect.Group=Class.create({initialize:function(a){this.effects=a},step:function(a){this.effects.each(function(b){b.step(a)})},finish:function(){this.effects.each(function(a){if(a.finish){a.finish()}})}});Rico.Effect.SizeAndPosition=Class.create({initialize:function(c,a,e,b,d){Object.extend(this,new Rico.Effect.SizeAndPositionFade(c,a,e,b,d))}});Rico.Effect.SizeAndPositionFade=Class.create({initialize:function(c,a,f,b,d,e){this.element=$(c);this.x=typeof(a)=="number"?a:this.element.offsetLeft;this.y=typeof(f)=="number"?f:this.element.offsetTop;if(!Prototype.Browser.IE||(document.compatMode&&document.compatMode.indexOf("CSS")!=-1)){this.pw=RicoUtil.nan2zero(Element.getStyle(this.element,"padding-left"))+RicoUtil.nan2zero(Element.getStyle(this.element,"padding-right"));this.pw+=RicoUtil.nan2zero(Element.getStyle(this.element,"border-left-width"))+RicoUtil.nan2zero(Element.getStyle(this.element,"border-right-width"));this.ph=RicoUtil.nan2zero(Element.getStyle(this.element,"padding-top"))+RicoUtil.nan2zero(Element.getStyle(this.element,"padding-bottom"));this.ph+=RicoUtil.nan2zero(Element.getStyle(this.element,"border-top-width"))+RicoUtil.nan2zero(Element.getStyle(this.element,"border-bottom-width"))}else{this.pw=0;this.ph=0}this.w=typeof(b)=="number"?b:this.element.offsetWidth;this.h=typeof(d)=="number"?d:this.element.offsetHeight;this.opacity=Element.getStyle(this.element,"opacity")||1;this.target=arguments.length>5?Math.min(e,1):this.opacity},step:function(b){var g=this.element.offsetLeft+((this.x-this.element.offsetLeft)/b);var f=this.element.offsetTop+((this.y-this.element.offsetTop)/b);var e=this.element.offsetWidth+((this.w-this.element.offsetWidth)/b)-this.pw;var a=this.element.offsetHeight+((this.h-this.element.offsetHeight)/b)-this.ph;var d=this.element.style;var c=Element.getStyle(this.element,"opacity");var h=c+(this.target-c)/b;Rico.Effect.setOpacity(this.element,Math.min(Math.max(0,h),1));d.left=g+"px";d.top=f+"px";d.width=e+"px";d.height=a+"px"}});Rico.AccordionEffect=Class.create({initialize:function(c,b,a){this.toClose=c;this.toOpen=b;b.style.height="0px";Element.show(b);Element.makeClipping(b);Element.makeClipping(c);Rico.Controls.disableNativeControls(c);this.endHeight=a},step:function(c){var b=Math.max(1,this.toClose.offsetHeight-parseInt((parseInt(this.toClose.offsetHeight,10))/c,10));var d=b+"px";var a=(this.endHeight-b)+"px";this.toClose.style.height=d;this.toOpen.style.height=a},finish:function(){Element.hide(this.toClose);this.toOpen.style.height=this.endHeight+"px";this.toClose.style.height="0px";Element.undoClipping(this.toOpen);Element.undoClipping(this.toClose);Rico.Controls.enableNativeControls(this.toOpen)}});Rico.Effect.SizeFromBottom=Class.create({initialize:function(a,c,b){this.element=$(a);this.y=typeof(c)=="number"?c:this.element.offsetTop;this.h=typeof(b)=="number"?b:this.element.offsetHeight;this.options=arguments[3]||{}},step:function(b){var d=this.element.offsetTop+((this.y-this.element.offsetTop)/b)+"px";var a=this.element.offsetHeight+((this.h-this.element.offsetHeight)/b)+"px";var c=this.element.style;c.height=a;c.top=d}});Rico.Effect.Position=Class.create({initialize:function(b,a,c){this.element=$(b);this.x=typeof(a)=="number"?a:this.element.offsetLeft;this.destTop=typeof(c)=="number"?c:this.element.offsetTop},step:function(a){var d=this.element.offsetLeft+((this.x-this.element.offsetLeft)/a)+"px";var c=this.element.offsetTop+((this.destTop-this.element.offsetTop)/a)+"px";var b=this.element.style;b.left=d;b.top=c}});Rico.Effect.FadeTo=Class.create({initialize:function(a,b){this.element=a;this.opacity=Element.getStyle(this.element,"opacity")||1;this.target=Math.min(b,1)},step:function(b){var a=Element.getStyle(this.element,"opacity");var c=a+(this.target-a)/b;Rico.Effect.setOpacity(this.element,Math.min(Math.max(0,c),1))}});Rico.Effect.FadeOut=Class.create({initialize:function(a){this.effect=new Rico.Effect.FadeTo(a,0)},step:function(a){this.effect.step(a)}});Rico.Effect.FadeIn=Class.create({initialize:function(c){var b=arguments[1]||{};var a=b.startValue||0;Rico.Effect.setOpacity(c,a);this.effect=new Rico.Effect.FadeTo(c,1)},step:function(a){this.effect.step(a)}});Rico.Effect.setOpacity=function(a,b){if(a.setOpacity){a.setOpacity(b)}else{a.style.filter="alpha(opacity="+Math.round(b*100)+")";a.style.opacity=b}};Rico.Effect.SizeFromTop=Class.create({initialize:function(a,c,d,b){this.element=$(a);this.h=typeof(b)=="number"?b:this.element.offsetHeight;this.scrollElement=c;this.options=arguments[4]||{};this.baseHeight=this.options.baseHeight||Math.max(this.h,this.element.offsetHeight)},step:function(c){var d=this.element.offsetHeight+((this.h-this.element.offsetHeight)/c);var b=d+"px";var a=(d-this.baseHeight)+"px";this.scrollElement.style.top=a;this.element.style.height=b}});Rico.Effect.Height=Class.create({initialize:function(a,b){this.element=a;this.endHeight=b},step:function(b){var a;if(this.element.constructor!=Array){a=this.element.offsetHeight+((this.endHeight-this.element.offsetHeight)/b)+"px";this.element.style.height=a}else{a=this.element[0].offsetHeight+((this.endHeight-this.element[0].offsetHeight)/b)+"px";this.element.each(function(c){c.style.height=a})}}});Rico.Effect.SizeWidth=Class.create({initialize:function(a,b){this.element=a;this.endWidth=b},step:function(a){var b=Math.abs(this.endWidth-parseInt(this.element.offsetWidth,10))/(a);this.element.style.width=(this.element.offsetWidth-b)+"px"}});Rico.Controls={editors:[],scrollSelectors:[],disableNativeControls:function(a){Rico.Controls.defaultDisabler.disableNative(a)},enableNativeControls:function(a){Rico.Controls.defaultDisabler.enableNative(a)},prepareForSizing:function(a){Element.makeClipping(a);Rico.Controls.disableNativeControls(a)},resetSizing:function(a){Element.undoClipping(a);Rico.Controls.enableNativeControls(a)},registerScrollSelectors:function(a){a.each(function(b){Rico.Controls.scrollSelectors.push(Rico.selector(b))})}};Rico.Controls.Disabler=Class.create({initialize:function(){this.options=Object.extend({excludeSet:[],hidables:Rico.Controls.editors},arguments[0]||{})},disableNative:function(a){if(!(/Konqueror|Safari|KHTML/.test(navigator.userAgent))){if(!navigator.appVersion.match(/\bMSIE\b/)){this.blockControls(a).each(function(b){Element.makeClipping(b)})}else{this.hidableControls(a).each(function(b){b.disable()})}}},enableNative:function(a){if(!(/Konqueror|Safari|KHTML/.test(navigator.userAgent))){if(!navigator.appVersion.match(/\bMSIE\b/)){this.blockControls(a).each(function(b){Element.undoClipping(b)})}else{this.hidableControls(a).each(function(b){b.enable()})}}},blockControls:function(c){try{var b=[];if(this.options.includeSet){b=this.options.includeSet}else{var a=this.options.includeSelectors||Rico.Controls.scrollSelectors;b=a.map(function(e){return e.findAll(c)}).flatten()}return b.select(function(f){return(Element.getStyle(f,"display")!="none")&&!this.options.excludeSet.include(f)}.bind(this))}catch(d){return[]}},hidableControls:function(a){if(a){return this.options.hidables.select(function(b){return Element.childOf(b,a)})}else{return this.options.hidables}}});Rico.Controls.defaultDisabler=new Rico.Controls.Disabler();Rico.Controls.blankDisabler=new Rico.Controls.Disabler({includeSet:[],hidables:[]});Rico.Controls.HidableInput=Class.create({initialize:function(b,a){this.field=b;this.view=a;this.enable();Rico.Controls.editors.push(this)},enable:function(){Element.hide(this.view);Element.show(this.field)},disable:function(){this.view.value=$F(this.field);if(this.field.offsetWidth>1){this.view.style.width=parseInt(this.field.offsetWidth,10)+"px";Element.hide(this.field);Element.show(this.view)}}});Element.forceRefresh=function(a){try{var c=document.createTextNode(" ");a.appendChild(c);a.removeChild(c)}catch(b){}};Rico.includeLoaded("ricoEffects.js");Rico.ContentTransitionBase=function(){};Rico.ContentTransitionBase.prototype={initialize:function(c,b,a){if(typeof c=="string"){c=$$(c)}if(typeof b=="string"){b=$$(b)}this.titles=c;this.contents=b;this.options=Object.extend({duration:200,steps:8,rate:Rico.Effect.easeIn},a||{});this.hoverSet=new Rico.HoverSet(c,a);b.each(function(d){if(d){Element.hide(d)}});this.selectionSet=new Rico.SelectionSet(c,Object.extend(this.options,{onSelect:this.select.bind(this)}));if(this.initContent){this.initContent()}},reset:function(){this.selectionSet.reset()},select:function(c){var a=this.contentOf(c);if(this.selected==a){return}if(this.transition){if(this.selected){var b=this.transition(a);if(b){Rico.animate(b,this.options)}}else{Element.show(a)}}else{if(this.selected){Element.hide(this.selected)}Element.show(a)}this.selected=a},add:function(b,a){this.titles.push(b);this.contents.push(a);this.hoverSet.add(b);this.selectionSet.add(b);this.selectionSet.select(b)},remove:function(a){},removeAll:function(){this.hoverSet.removeAll();this.selectionSet.removeAll()},openByIndex:function(a){this.selectionSet.selectIndex(a)},contentOf:function(a){return this.contents[this.titles.indexOf(a)]}};Rico.ContentTransition=Class.create();Rico.ContentTransition.prototype=Object.extend(new Rico.ContentTransitionBase(),{});Rico.SlidingPanel=Class.create({initialize:function(a){this.panel=a;this.options=arguments[1]||{};this.closed=true;this.showing=false;this.openEffect=this.options.openEffect;this.closeEffect=this.options.closeEffect;this.animator=new Rico.Effect.Animator();Element.makeClipping(this.panel)},toggle:function(){if(!this.showing){this.open()}else{this.close()}},open:function(){if(this.closed){this.showing=true;Element.show(this.panel);this.options.disabler.disableNative()}this.animator.play(this.openEffect,{onFinish:function(){Element.undoClipping($(this.panel))}.bind(this),rate:Rico.Effect.easeIn})},close:function(){Element.makeClipping(this.panel);this.animator.stop();this.showing=false;this.animator.play(this.closeEffect,{onFinish:function(){Element.hide(this.panel);this.options.disabler.enableNative()}.bind(this),rate:Rico.Effect.easeOut})}});Rico.Accordion=Class.create();Rico.Accordion.prototype=Object.extend(new Rico.ContentTransitionBase(),{initContent:function(){this.selected.style.height=this.options.panelHeight+"px"},transition:function(a){if(!this.options.noAnimate){return new Rico.AccordionEffect(this.selected,a,this.options.panelHeight)}else{a.style.height=this.options.panelHeight+"px";if(this.selected){Element.hide(this.selected)}Element.show(a)}}});Rico.TabbedPanel=Class.create();Rico.TabbedPanel.prototype=Object.extend(new Rico.ContentTransitionBase(),{initContent:function(){if(typeof this.options.panelWidth=="number"){this.options.panelWidth+="px"}if(typeof this.options.panelHeight=="number"){this.options.panelHeight+="px"}if(!this.options.corners){this.options.corners="top"}if(Rico.Corner&&this.options.corners!="none"){if(!this.options.border){this.options.color="transparent"}for(var a=0;a<this.titles.length;a++){if(this.titles[a]){if(this.options.panelHdrWidth){this.titles[a].style.width=this.options.panelHdrWidth}Rico.Corner.round(this.titles[a],this.options)}}}this.transition(this.selected)},transition:function(a){if(this.selected){Element.hide(this.selected)}Element.show(a);if(this.options.panelHeight){a.style.height=this.options.panelHeight}if(this.options.panelWidth){a.style.width=this.options.panelWidth}}});Rico.SlidingPanel.top=function(b,d){var c=Object.extend({disabler:Rico.Controls.defaultDisabler},arguments[2]||{});var a=c.height||Element.getDimensions(d)[1]||d.offsetHeight;var e=c.top||Position.positionedOffset(b)[1];c.openEffect=new Rico.Effect.SizeFromTop(b,d,e,a,{baseHeight:a});c.closeEffect=new Rico.Effect.SizeFromTop(b,d,e,1,{baseHeight:a});b.style.height="0px";d.style.top=-a+"px";return new Rico.SlidingPanel(b,c)};Rico.SlidingPanel.bottom=function(b){var c=Object.extend({disabler:Rico.Controls.blankDisabler},arguments[1]||{});var a=c.height||Element.getDimensions(b).height;var d=Position.positionedOffset(b)[1];c.openEffect=new Rico.Effect.SizeFromBottom(b,d-a,a);c.closeEffect=new Rico.Effect.SizeFromBottom(b,d,1);return new Rico.SlidingPanel(b,c)};Rico.includeLoaded("ricoComponents.js");Rico.DragAndDrop=Class.create({initialize:function(){this.dropZones=new Array();this.draggables=new Array();this.currentDragObjects=new Array();this.dragElement=null;this.lastSelectedDraggable=null;this.currentDragObjectVisible=false;this.interestedInMotionEvents=false;this._mouseDown=this._mouseDownHandler.bindAsEventListener(this);this._mouseMove=this._mouseMoveHandler.bindAsEventListener(this);this._mouseUp=this._mouseUpHandler.bindAsEventListener(this)},registerDropZone:function(a){this.dropZones[this.dropZones.length]=a},deregisterDropZone:function(a){var d=new Array();var b=0;for(var c=0;c<this.dropZones.length;c++){if(this.dropZones[c]!=a){d[b++]=this.dropZones[c]}}this.dropZones=d},clearDropZones:function(){this.dropZones=new Array()},registerDraggable:function(a){this.draggables[this.draggables.length]=a;this._addMouseDownHandler(a)},clearSelection:function(){for(var a=0;a<this.currentDragObjects.length;a++){this.currentDragObjects[a].deselect()}this.currentDragObjects=new Array();this.lastSelectedDraggable=null},hasSelection:function(){return this.currentDragObjects.length>0},setStartDragFromElement:function(a,b){this.origPos=RicoUtil.toDocumentPosition(b);this.startx=a.screenX-this.origPos.x;this.starty=a.screenY-this.origPos.y;this.interestedInMotionEvents=this.hasSelection();this._terminateEvent(a)},updateSelection:function(a,b){if(!b){this.clearSelection()}if(a.isSelected()){this.currentDragObjects=this.currentDragObjects.without(a);a.deselect();if(a==this.lastSelectedDraggable){this.lastSelectedDraggable=null}}else{a.select();if(a.isSelected()){this.currentDragObjects.push(a);this.lastSelectedDraggable=a}}},_mouseDownHandler:function(g){if(arguments.length==0){g=event}var b=g.which!=undefined;if((b&&g.which!=1)||(!b&&g.button!=1)){return}var f=g.target?g.target:g.srcElement;var a=f.ricoDraggable;var d=f;while(a==null&&d.parentNode){d=d.parentNode;a=d.ricoDraggable}if(a==null){return}this.updateSelection(a,g.ctrlKey);if(this.hasSelection()){for(var c=0;c<this.dropZones.length;c++){this.dropZones[c].clearPositionCache()}}this.setStartDragFromElement(g,a.getMouseDownHTMLElement())},_mouseMoveHandler:function(b){var a=b.which!=undefined;if(!this.interestedInMotionEvents){return}if(!this.hasSelection()){return}if(!this.currentDragObjectVisible){this._startDrag(b)}if(!this.activatedDropZones){this._activateRegisteredDropZones()}this._updateDraggableLocation(b);this._updateDropZonesHover(b);this._terminateEvent(b)},_makeDraggableObjectVisible:function(b){if(!this.hasSelection()){return}var a;if(this.currentDragObjects.length>1){a=this.currentDragObjects[0].getMultiObjectDragGUI(this.currentDragObjects)}else{a=this.currentDragObjects[0].getSingleObjectDragGUI()}this.dragElemPosition=RicoUtil.getElementsComputedStyle(a,"position");if(this.dragElemPosition!="absolute"){a.style.position="absolute"}if(a.parentNode==null||a.parentNode.nodeType==11){document.body.appendChild(a)}this.dragElement=a;this._updateDraggableLocation(b);this.currentDragObjectVisible=true},_leftOffset:function(a){return a.offsetX?document.body.scrollLeft:0},_topOffset:function(a){return a.offsetY?document.body.scrollTop:0},_updateDraggableLocation:function(b){var a=this.dragElement.style;a.left=(b.screenX+this._leftOffset(b)-this.startx)+"px";a.top=(b.screenY+this._topOffset(b)-this.starty)+"px"},_updateDropZonesHover:function(b){var a,c=this.dropZones.length;for(a=0;a<c;a++){if(!this._mousePointInDropZone(b,this.dropZones[a])){this.dropZones[a].hideHover()}}for(a=0;a<c;a++){if(this._mousePointInDropZone(b,this.dropZones[a])){if(this.dropZones[a].canAccept(this.currentDragObjects)){this.dropZones[a].showHover()}}}},_startDrag:function(b){for(var a=0;a<this.currentDragObjects.length;a++){this.currentDragObjects[a].startDrag()}this._makeDraggableObjectVisible(b)},_mouseUpHandler:function(b){if(!this.hasSelection()){return}var a=b.which!=undefined;if((a&&b.which!=1)||(!a&&b.button!=1)){return}this.interestedInMotionEvents=false;if(this._placeDraggableInDropZone(b)){this._completeDropOperation(b)}else{if(this.dragElement!=null){this._terminateEvent(b);Rico.animate(new Rico.Effect.Position(this.dragElement,this.origPos.x,this.origPos.y),{duration:200,steps:20,onFinish:this._doCancelDragProcessing.bind(this)})}}Event.stopObserving(document.body,"mousemove",this._mouseMove);Event.stopObserving(document.body,"mouseup",this._mouseUp)},_retTrue:function(){return true},_completeDropOperation:function(a){if(this.dragElement!=this.currentDragObjects[0].getMouseDownHTMLElement()){if(this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)}}this._deactivateRegisteredDropZones();this._endDrag();this.clearSelection();this.dragElement=null;this.currentDragObjectVisible=false;this._terminateEvent(a)},_doCancelDragProcessing:function(){this._cancelDrag();if(this.dragElement==this.currentDragObjects[0].getMouseDownHTMLElement()){this.dragElement.style.position=this.dragElemPosition}else{if(this.dragElement&&this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)}}this._deactivateRegisteredDropZones();this.dragElement=null;this.currentDragObjectVisible=false},_placeDraggableInDropZone:function(c){var a=false;var d=this.dropZones.length;for(var b=0;b<d;b++){if(this._mousePointInDropZone(c,this.dropZones[b])){if(this.dropZones[b].canAccept(this.currentDragObjects)){this.dropZones[b].hideHover();this.dropZones[b].accept(this.currentDragObjects);a=true;break}}}return a},_cancelDrag:function(){for(var a=0;a<this.currentDragObjects.length;a++){this.currentDragObjects[a].cancelDrag()}},_endDrag:function(){for(var a=0;a<this.currentDragObjects.length;a++){this.currentDragObjects[a].endDrag()}},_mousePointInDropZone:function(b,c){var a=c.getAbsoluteRect();return b.clientX>a.left+this._leftOffset(b)&&b.clientX<a.right+this._leftOffset(b)&&b.clientY>a.top+this._topOffset(b)&&b.clientY<a.bottom+this._topOffset(b)},_addMouseDownHandler:function(a){var b=a.getMouseDownHTMLElement();if(b!=null){b.ricoDraggable=a;Event.observe(b,"mousedown",this._onmousedown.bindAsEventListener(this));Event.observe(b,"mousedown",this._mouseDown)}},_activateRegisteredDropZones:function(){var c=this.dropZones.length;for(var a=0;a<c;a++){var b=this.dropZones[a];if(b.canAccept(this.currentDragObjects)){b.activate()}}this.activatedDropZones=true},_deactivateRegisteredDropZones:function(){var b=this.dropZones.length;for(var a=0;a<b;a++){this.dropZones[a].deactivate()}this.activatedDropZones=false},_onmousedown:function(){Event.observe(document.body,"mousemove",this._mouseMove);Event.observe(document.body,"mouseup",this._mouseUp)},_terminateEvent:function(a){Event.stop(a)},initializeEventHandlers:function(){if(typeof document.implementation!="undefined"&&document.implementation.hasFeature("HTML","1.0")&&document.implementation.hasFeature("Events","2.0")&&document.implementation.hasFeature("CSS","2.0")){document.addEventListener("mouseup",this._mouseUpHandler.bindAsEventListener(this),false);document.addEventListener("mousemove",this._mouseMoveHandler.bindAsEventListener(this),false)}else{document.attachEvent("onmouseup",this._mouseUpHandler.bindAsEventListener(this));document.attachEvent("onmousemove",this._mouseMoveHandler.bindAsEventListener(this))}}});var dndMgr=new Rico.DragAndDrop();Rico.Draggable=Class.create({initialize:function(a,b){this.type=a;this.htmlElement=$(b);this.selected=false},getMouseDownHTMLElement:function(){return this.htmlElement},select:function(){this._select()},_select:function(){this.selected=true;if(this.showingSelected){return}this.showingSelected=true;var b=this.getMouseDownHTMLElement();var a=Rico.Color.createColorFromBackground(b);a.isBright()?a.darken(0.033):a.brighten(0.033);this.saveBackground=RicoUtil.getElementsComputedStyle(b,"backgroundColor","background-color");b.style.backgroundColor=a.asHex()},deselect:function(){this.selected=false;if(!this.showingSelected){return}var a=this.getMouseDownHTMLElement();a.style.backgroundColor=this.saveBackground;this.showingSelected=false},isSelected:function(){return this.selected},startDrag:function(){},cancelDrag:function(){},endDrag:function(){},getSingleObjectDragGUI:function(){return this.htmlElement},getMultiObjectDragGUI:function(a){return this.htmlElement},getDroppedGUI:function(){return this.htmlElement},toString:function(){return this.type+":"+this.htmlElement+":"}});Rico.LiveGridDraggable=Class.create();Rico.LiveGridDraggable.prototype=Object.extend(new Rico.Draggable(),{initialize:function(b,a,c){this.type="RicoCell";this.htmlElement=b.cell(a,c);this.liveGrid=b;this.dragRow=a;this.dragCol=c},select:function(){if(this.dragRow>=this.liveGrid.buffer.totalRows){return}this.selected=true;this.showingSelected=true},deselect:function(){this.selected=false;this.showingSelected=false},getSingleObjectDragGUI:function(){var a=document.createElement("div");a.className="LiveGridDraggable";a.style.width=(this.htmlElement.offsetWidth-10)+"px";Element.insert(a,this.htmlElement.innerHTML);return a}});Rico.Dropzone=Class.create({initialize:function(a){this.htmlElement=$(a);this.absoluteRect=null},getHTMLElement:function(){return this.htmlElement},clearPositionCache:function(){this.absoluteRect=null},getAbsoluteRect:function(){if(this.absoluteRect==null){var a=this.getHTMLElement();var b=RicoUtil.toViewportPosition(a);this.absoluteRect={top:b.y,left:b.x,bottom:b.y+a.offsetHeight,right:b.x+a.offsetWidth}}return this.absoluteRect},activate:function(){var c=this.getHTMLElement();if(c==null||this.showingActive){return}this.showingActive=true;this.saveBackgroundColor=c.style.backgroundColor;var b="#ffea84";var a=Rico.Color.createColorFromBackground(c);if(a==null){c.style.backgroundColor=b}else{a.isBright()?a.darken(0.2):a.brighten(0.2);c.style.backgroundColor=a.asHex()}},deactivate:function(){var a=this.getHTMLElement();if(a==null||!this.showingActive){return}a.style.backgroundColor=this.saveBackgroundColor;this.showingActive=false;this.saveBackgroundColor=null},showHover:function(){var a=this.getHTMLElement();if(a==null||this.showingHover){return}this.saveBorderWidth=a.style.borderWidth;this.saveBorderStyle=a.style.borderStyle;this.saveBorderColor=a.style.borderColor;this.showingHover=true;a.style.borderWidth="1px";a.style.borderStyle="solid";a.style.borderColor="#ffff00"},hideHover:function(){var a=this.getHTMLElement();if(a==null||!this.showingHover){return}a.style.borderWidth=this.saveBorderWidth;a.style.borderStyle=this.saveBorderStyle;a.style.borderColor=this.saveBorderColor;this.showingHover=false},canAccept:function(a){return true},accept:function(b){var d=this.getHTMLElement();if(d==null){return}var e=b.length;for(var a=0;a<e;a++){var c=b[a].getDroppedGUI();if(RicoUtil.getElementsComputedStyle(c,"position")=="absolute"){c.style.position="static";c.style.top="";c.style.top=""}d.appendChild(c)}}});RicoUtil=Object.extend(RicoUtil,{getElementsComputedStyle:function(d,a,b){if(arguments.length==2){b=a}var c=$(d);if(c.currentStyle){return c.currentStyle[a]}else{return document.defaultView.getComputedStyle(c,null).getPropertyValue(b)}},toViewportPosition:function(a){return this._toAbsolute(a,true)},toDocumentPosition:function(a){return this._toAbsolute(a,false)},_toAbsolute:function(b,e){if(!Prototype.Browser.IE&&!Prototype.Browser.Opera){return this._toAbsoluteMozilla(b,e)}var a=0;var g=0;var d=b;while(d){var c=0;var f=0;if(d!=b){c=parseInt(this.getElementsComputedStyle(d,"borderLeftWidth"),10);f=parseInt(this.getElementsComputedStyle(d,"borderTopWidth"),10);c=isNaN(c)?0:c;f=isNaN(f)?0:f}a+=d.offsetLeft-d.scrollLeft+c;g+=d.offsetTop-d.scrollTop+f;d=d.offsetParent}if(e){a-=this.docScrollLeft();g-=this.docScrollTop()}return{x:a,y:g}},_toAbsoluteMozilla:function(b,d){var a=0;var e=0;var c=b;while(c){a+=c.offsetLeft;e+=c.offsetTop;c=c.offsetParent}c=b;while(c&&c!=document.body&&c!=document.documentElement){if(c.scrollLeft){a-=c.scrollLeft}if(c.scrollTop){e-=c.scrollTop}c=c.parentNode}if(d){a-=this.docScrollLeft();e-=this.docScrollTop()}return{x:a,y:e}}});Rico.includeLoaded("ricoDragDrop.js");Rico.CalendarControl=Class.create({initialize:function(c,b){this.id=c;var a=new Date();Object.extend(this,new Rico.Popup({ignoreClicks:true}));Object.extend(this.options,{startAt:0,showWeekNumber:0,showToday:1,cursorColor:"#FDD",repeatInterval:100,dateFmt:"ISO8601",selectedDateBorder:"#666666",minDate:new Date(a.getFullYear()-50,0,1),maxDate:new Date(a.getFullYear()+50,11,31)});Object.extend(this.options,b||{});this.close=this.closePopup;this.bPageLoaded=false;this.img=[];this.Holidays={};this.weekString=RicoTranslate.getPhraseById("calWeekHdg");this.re=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;this.setDateFmt(this.options.dateFmt)},setDateFmt:function(a){this.dateFmt=(a=="rico")?RicoTranslate.dateFmt:a;this.dateParts=[];if(this.re.exec(this.dateFmt)){this.dateParts[RegExp.$1]=0;this.dateParts[RegExp.$3]=1;this.dateParts[RegExp.$5]=2}},addHoliday:function(f,a,g,e,c,b){this.Holidays[this.holidayKey(g,a-1,f)]={desc:e,txtColor:b,bgColor:c||"#DDF"}},holidayKey:function(c,a,b){return"h"+c.toPaddedString(4)+a.toPaddedString(2)+b.toPaddedString(2)},atLoad:function(){this.container=document.createElement("div");this.container.style.display="none";this.container.id=this.id;this.container.className="ricoCalContainer";this.maintab=document.createElement("table");this.maintab.cellSpacing=0;this.maintab.cellPadding=0;this.maintab.border=0;this.maintab.className="ricoCalTab";var h,l,f,e,d,k,b,g;for(f=0;f<7;f++){h=this.maintab.insertRow(-1);h.className="row"+f;for(l=0;l<8;l++){h.insertCell(-1)}}this.tbody=this.maintab.tBodies[0];h=this.tbody.rows[0];h.className="ricoCalDayNames";if(this.options.showWeekNumber){h.cells[0].innerHTML=this.weekString;for(f=0;f<7;f++){this.tbody.rows[f].cells[0].className="ricoCalWeekNum"}}this.styles=[];for(f=0;f<7;f++){k=(f+this.options.startAt)%7;h.cells[f+1].innerHTML=RicoTranslate.dayAbbr(k);this.styles[f+1]="ricoCal"+k}this.thead=this.maintab.createTHead();h=this.thead.insertRow(-1);l=h.insertCell(-1);l.colSpan=8;d=this.createNavArrow("decMonth","left");l.appendChild(document.createElement("a")).appendChild(d);this.titleMonth=document.createElement("a");l.appendChild(this.titleMonth);Event.observe(this.titleMonth,"click",this.popUpMonth.bindAsEventListener(this),false);d=this.createNavArrow("incMonth","right");l.appendChild(document.createElement("a")).appendChild(d);g=document.createElement("span");g.innerHTML="&nbsp;";g.style.paddingLeft="3em";l.appendChild(g);d=this.createNavArrow("decYear","left");l.appendChild(document.createElement("a")).appendChild(d);this.titleYear=document.createElement("a");Event.observe(this.titleYear,"click",this.popUpYear.bindAsEventListener(this),false);l.appendChild(this.titleYear);d=this.createNavArrow("incYear","right");l.appendChild(document.createElement("a")).appendChild(d);if(this.options.showToday){this.tfoot=this.maintab.createTFoot();h=this.tfoot.insertRow(-1);this.todayCell=h.insertCell(-1);this.todayCell.colSpan=8;Event.observe(this.todayCell,"click",this.selectNow.bindAsEventListener(this),false)}this.container.appendChild(this.maintab);d=document.createElement("img");d.src=Rico.imgDir+"close.gif";d.onclick=this.close.bind(this);d.style.cursor="pointer";d.style.position="absolute";d.style.top="1px";d.style.right="1px";d.title=RicoTranslate.getPhraseById("close");this.container.appendChild(d);this.monthSelect=document.createElement("table");this.monthSelect.className="ricoCalMenu";this.monthSelect.cellPadding=2;this.monthSelect.cellSpacing=0;this.monthSelect.border=0;for(f=0;f<4;f++){h=this.monthSelect.insertRow(-1);for(e=0;e<3;e++){l=h.insertCell(-1);b=document.createElement("a");b.innerHTML=RicoTranslate.monthAbbr(f*3+e);b.name=f*3+e;l.appendChild(b);Event.observe(b,"click",this.selectMonth.bindAsEventListener(this),false)}}this.monthSelect.style.display="none";this.container.appendChild(this.monthSelect);this.yearPopup=document.createElement("div");this.yearPopup.style.display="block";this.yearPopup.className="ricoCalYearPrompt";this.container.appendChild(this.yearPopup);this.yearPopupSpan=this.yearPopup.appendChild(document.createElement("span"));this.yearPopupYear=this.yearPopup.appendChild(document.createElement("input"));this.yearPopupYear.maxlength=4;this.yearPopupYear.size=4;Event.observe(this.yearPopupYear,"keypress",this.yearKey.bindAsEventListener(this),false);d=document.createElement("img");d.src=Rico.imgDir+"checkmark.gif";Event.observe(d,"click",this.processPopUpYear.bindAsEventListener(this),false);this.yearPopup.appendChild(d);d=document.createElement("img");d.src=Rico.imgDir+"delete.gif";Event.observe(d,"click",this.popDownYear.bindAsEventListener(this),false);this.yearPopup.appendChild(d);b=this.container.getElementsByTagName("a");for(f=0;f<b.length;f++){b[f].href="javascript:void(0)"}Event.observe(this.tbody,"click",this.saveAndClose.bindAsEventListener(this));Event.observe(this.tbody,"mouseover",this.mouseOver.bindAsEventListener(this));Event.observe(this.tbody,"mouseout",this.mouseOut.bindAsEventListener(this));document.getElementsByTagName("body")[0].appendChild(this.container);this.setDiv(this.container);this.close();this.bPageLoaded=true},selectNow:function(){this.monthSelected=this.monthNow;this.yearSelected=this.yearNow;this.constructCalendar()},createNavArrow:function(a,b){var c=document.createElement("img");c.src=Rico.imgDir+b+".gif";c.name=a;Event.observe(c,"click",this[a].bindAsEventListener(this),false);Event.observe(c,"mousedown",this.mouseDown.bindAsEventListener(this),false);Event.observe(c,"mouseup",this.mouseUp.bindAsEventListener(this),false);Event.observe(c,"mouseout",this.mouseUp.bindAsEventListener(this),false);return c},mouseOver:function(d){var c=Event.element(d);if(this.lastHighlight==c){return}this.unhighlight();var b=c.innerHTML.replace(/&nbsp;/g,"");if(b==""||c.className=="ricoCalWeekNum"){return}var a=parseInt(b,10);if(isNaN(a)){return}this.lastHighlight=c;this.tmpColor=c.style.backgroundColor;c.style.backgroundColor=this.options.cursorColor},unhighlight:function(){if(!this.lastHighlight){return}this.lastHighlight.style.backgroundColor=this.tmpColor;this.lastHighlight=null},mouseOut:function(b){var a=Event.element(b);if(a==this.lastHighlight){this.unhighlight()}},mouseDown:function(b){var a=Event.element(b);this.repeatFunc=this[a.name].bind(this);this.timeoutID=setTimeout(this.repeatStart.bind(this),500)},mouseUp:function(a){clearTimeout(this.timeoutID);clearInterval(this.intervalID)},repeatStart:function(){clearInterval(this.intervalID);this.intervalID=setInterval(this.repeatFunc,this.options.repeatInterval)},isValidMonth:function(a,b){if(a<this.options.minDate.getFullYear()){return false}if(a==this.options.minDate.getFullYear()&&b<this.options.minDate.getMonth()){return false}if(a>this.options.maxDate.getFullYear()){return false}if(a==this.options.maxDate.getFullYear()&&b>this.options.maxDate.getMonth()){return false}return true},incMonth:function(){var b=this.monthSelected+1;var a=this.yearSelected;if(b>11){b=0;a++}if(!this.isValidMonth(a,b)){return}this.monthSelected=b;this.yearSelected=a;this.constructCalendar()},decMonth:function(){var b=this.monthSelected-1;var a=this.yearSelected;if(b<0){b=11;a--}if(!this.isValidMonth(a,b)){return}this.monthSelected=b;this.yearSelected=a;this.constructCalendar()},selectMonth:function(b){var a=Event.element(b);this.monthSelected=parseInt(a.name,10);this.constructCalendar();Event.stop(b)},popUpMonth:function(){Element.toggle(this.monthSelect);this.monthSelect.style.top=(this.thead.offsetHeight+2)+"px";this.monthSelect.style.left=this.titleMonth.offsetLeft+"px"},popDownMonth:function(){Element.hide(this.monthSelect)},popDownYear:function(){Element.hide(this.yearPopup);this.yearPopup.disabled=true},popUpYear:function(){Element.toggle(this.yearPopup);if(!Element.visible(this.yearPopup)){return}this.yearPopup.disabled=false;this.yearPopup.style.left="120px";this.yearPopup.style.top=(this.thead.offsetHeight+2)+"px";this.yearPopupSpan.innerHTML="&nbsp;"+RicoTranslate.getPhraseById("calYearRange",this.options.minDate.getFullYear(),this.options.maxDate.getFullYear())+"<br>";this.yearPopupYear.value="";this.yearPopupYear.focus()},yearKey:function(a){switch(RicoUtil.eventKey(a)){case 27:this.popDownYear();Event.stop(a);return false;case 13:this.processPopUpYear();Event.stop(a);return false}return true},processPopUpYear:function(){var a=this.yearPopupYear.value;a=parseInt(a,10);if(isNaN(a)||a<this.options.minDate.getFullYear()||a>this.options.maxDate.getFullYear()){alert(RicoTranslate.getPhraseById("calInvalidYear"))}else{this.yearSelected=a;this.popDownYear();this.constructCalendar()}},incYear:function(){if(this.yearSelected>=this.options.maxDate.getFullYear()){return}this.yearSelected++;this.constructCalendar()},decYear:function(){if(this.yearSelected<=this.options.minDate.getFullYear()){return}this.yearSelected--;this.constructCalendar()},WeekNbr:function(h,f,j){var g=new Date(h,f,j);var c=new Date(h,0,1);var e=7+1-c.getDay();if(e==8){e=1}var b=((Date.UTC(h,g.getMonth(),g.getDate(),0,0,0)-Date.UTC(h,0,1,0,0,0))/1000/60/60/24)+1;var d=Math.floor((b-e+7)/7);if(d==0){h--;var a=new Date(h,0,1);var i=7+1-a.getDay();d=(i==2||i==8)?53:52}return d},constructCalendar:function(){var m=[31,0,31,30,31,30,31,31,30,31,30,31];var d=new Date(this.yearSelected,this.monthSelected,1);var k,e,f,b;if(typeof this.monthSelected!="number"||this.monthSelected>=12||this.monthSelected<0){alert("ERROR in calendar: monthSelected="+this.monthSelected);return}if(this.monthSelected==1){k=new Date(this.yearSelected,this.monthSelected+1,1);k=new Date(k-(24*60*60*1000));e=k.getDate()}else{e=m[this.monthSelected]}var p=d.getDay()-this.options.startAt;if(p<0){p+=7}this.popDownMonth();this.popDownYear();this.bgcolor=Element.getStyle(this.tbody,"background-color");this.bgcolor=this.bgcolor.replace(/\"/g,"");if(this.options.showWeekNumber){for(f=1;f<7;f++){this.tbody.rows[f].cells[0].innerHTML="&nbsp;"}}for(f=1;f<=p;f++){this.resetCell(this.tbody.rows[1].cells[f])}for(var l=1,a=1;l<=e;l++,p++){b=p%7+1;if(this.options.showWeekNumber==1&&b==1){this.tbody.rows[a].cells[0].innerHTML=this.WeekNbr(this.yearSelected,this.monthSelected,l)}var o=this.styles[b];if((l==this.dateNow)&&(this.monthSelected==this.monthNow)&&(this.yearSelected==this.yearNow)){o="ricoCalToday"}var n=this.tbody.rows[a].cells[b];n.innerHTML="&nbsp;"+l+"&nbsp;";n.className=o;var j=(l==this.odateSelected)&&(this.monthSelected==this.omonthSelected)&&(this.yearSelected==this.oyearSelected)?this.options.selectedDateBorder:this.bgcolor;n.style.border="1px solid "+j;var g=this.Holidays[this.holidayKey(this.yearSelected,this.monthSelected,l)];if(!g){g=this.Holidays[this.holidayKey(0,this.monthSelected,l)]}n.style.color=g?g.txtColor:"";n.style.backgroundColor=g?g.bgColor:"";n.title=g?g.desc:"";if(b==7){a++}}while(p<42){b=p%7+1;this.resetCell(this.tbody.rows[a].cells[b]);p++;if(b==7){a++}}this.titleMonth.innerHTML=RicoTranslate.monthAbbr(this.monthSelected);this.titleYear.innerHTML=this.yearSelected;if(this.todayCell){this.todayCell.innerHTML=RicoTranslate.getPhraseById("calToday",this.dateNow,RicoTranslate.monthAbbr(this.monthNow),this.yearNow,this.monthNow+1)}},resetCell:function(a){a.innerHTML="&nbsp;";a.className="ricoCalEmpty";a.style.border="1px solid "+this.bgcolor;a.style.color="";a.style.backgroundColor="";a.title=""},saveAndClose:function(g){Event.stop(g);var f=Event.element(g);var c=f.innerHTML.replace(/&nbsp;/g,"");if(c==""||f.className=="ricoCalWeekNum"){return}var b=parseInt(c,10);if(isNaN(b)){return}var h=new Date(this.yearSelected,this.monthSelected,b);var a=h.formatDate(this.dateFmt=="ISO8601"?"yyyy-mm-dd":this.dateFmt);if(this.returnValue){this.returnValue(a)}this.close()},open:function(b){if(!this.bPageLoaded){return}var a=new Date();this.dateNow=a.getDate();this.monthNow=a.getMonth();this.yearNow=a.getFullYear();if(typeof b=="object"){this.dateSelected=b.getDate();this.monthSelected=b.getMonth();this.yearSelected=b.getFullYear()}else{if(this.dateFmt=="ISO8601"){var c=new Date();c.setISO8601(b);this.dateSelected=c.getDate();this.monthSelected=c.getMonth();this.yearSelected=c.getFullYear()}else{if(this.re.exec(b)){var f=[RegExp.$1,RegExp.$3,RegExp.$5];this.dateSelected=parseInt(f[this.dateParts.dd],10);this.monthSelected=parseInt(f[this.dateParts.mm],10)-1;this.yearSelected=parseInt(f[this.dateParts.yyyy],10);if(this.yearSelected<100){this.yearSelected+=this.yearNow-(this.yearNow%100);var e=this.options.maxDate.getFullYear();while(this.yearSelected>e){this.yearSelected-=100}}}else{if(b){alert("ERROR: invalid date passed to calendar ("+b+")")}this.dateSelected=this.dateNow;this.monthSelected=this.monthNow;this.yearSelected=this.yearNow}}}this.odateSelected=this.dateSelected;this.omonthSelected=this.monthSelected;this.oyearSelected=this.yearSelected;this.constructCalendar();this.openPopup()}});Rico.includeLoaded("ricoCalendar.js");Rico.TreeControl=Class.create({initialize:function(c,b,a){Object.extend(this,new Rico.Popup({ignoreClicks:true}));Object.extend(this.options,{nodeIdDisplay:"none",showCheckBox:false,showFolders:false,showPlusMinus:true,showLines:true,defaultAction:this.nodeClick.bindAsEventListener(this),height:"300px",width:"300px",leafIcon:Rico.imgDir+"doc.gif"});Object.extend(this.options,a||{});this.id=c;this.dataSource=b;this.close=this.closePopup},atLoad:function(){var d=["node.gif","nodelast.gif","folderopen.gif","folderclosed.gif"];for(var b=0;b<d.length;b++){var a=new Image();a.src=Rico.imgDir+d[b]}this.treeDiv=document.createElement("div");this.treeDiv.id=this.id;this.treeDiv.className="ricoTree";this.treeDiv.style.height=this.options.height;this.treeDiv.style.width=this.options.width;this.container=document.createElement("div");this.container.style.display="none";this.container.className="ricoTreeContainer";this.container.appendChild(this.treeDiv);document.body.appendChild(this.container);if(this.options.showCheckBox){this.buttonDiv=document.createElement("div");this.buttonDiv.style.width=this.options.width;this.buttonDiv.className="ricoTreeButtons";if(Element.getStyle(this.container,"position")=="absolute"){var c=document.createElement("span");c.innerHTML=RicoTranslate.getPhraseById("treeSave");Element.setStyle(c,{"float":"left",cursor:"pointer"});this.buttonDiv.appendChild(c);Event.observe(c,"click",this.saveSelection.bindAsEventListener(this))}var c=document.createElement("span");c.innerHTML=RicoTranslate.getPhraseById("treeClear");Element.setStyle(c,{"float":"right",cursor:"pointer"});this.buttonDiv.appendChild(c);this.container.appendChild(this.buttonDiv);Event.observe(c,"click",this.clrCheckBoxEvent.bindAsEventListener(this))}this.setDiv(this.container);this.close()},setTreeDiv:function(a){this.treeDiv=$(a);this.openPopup=function(){}},open:function(){this.openPopup();if(this.treeDiv.childNodes.length==0&&this.dataSource){this.loadXMLDoc()}},loadXMLDoc:function(c){var a="id="+this.id;if(c){a+="&Parent="+c}Rico.writeDebugMsg("Tree loadXMLDoc:\n"+a+"\n"+this.dataSource);var b=new Ajax.Request(this.dataSource,{parameters:a,method:"get",onComplete:this.processResponse.bind(this)})},domID:function(b,a){return"RicoTree_"+a+"_"+this.id+"_"+b},processResponse:function(d){var b=d.responseXML.getElementsByTagName("ajax-response");if(b==null||b.length!=1){return}var f=b[0].getElementsByTagName("rows")[0];var g=f.getElementsByTagName("tr");var k=[];for(var e=0;e<g.length;e++){var l=g[e].getElementsByTagName("td");if(l.length<5){continue}var h=[];h[5]=this.options.leafIcon;for(var c=0;c<l.length;c++){h[c]=RicoUtil.getContentAsString(l[c],true)}h[3]=h[3].match(/^0|L$/i)?0:1;h[4]=parseInt(h[4]);k.push(h)}for(var e=0;e<k.length;e++){var a=(e<k.length-1)&&(k[e][0]==k[e+1][0]);this.addNode(k[e][0],k[e][1],k[e][2],k[e][3],k[e][4],k[e][5],!a)}},DisplayImages:function(d,a){var c,b,e;for(c=0;c<a.length;c++){b=document.createElement("img");b.src=Rico.imgDir+a[c]+".gif";e=d.insertCell(-1);e.appendChild(b)}},addNode:function(q,l,t,f,u,s,k){var h=$(this.domID(q,"Parent"));var v=$(this.domID(q,"Children"));var a=h?h.TreeLevel+1:0;var b=document.createElement("table");var m=document.createElement("div");m.id=this.domID(l,"Children");m.className="ricoTreeBranch";m.style.display=h?"none":"";b.border=0;b.cellSpacing=0;b.cellPadding=0;b.id=this.domID(l,"Parent");b.TreeLevel=a;b.TreeContainer=f;b.TreeFetchedChildren=this.dataSource?false:true;var d=b.insertRow(0);var g=[];for(var r=0;r<a-1;r++){g[r]=d.insertCell(-1)}if(a>1){var e=h.getElementsByTagName("td");for(var r=0;r<a-2;r++){g[r].innerHTML=e[r].innerHTML}var w=document.createElement("img");w.src=Rico.imgDir+(v.nextSibling&&this.options.showLines?"nodeline":"nodeblank")+".gif";g[a-2].appendChild(w)}if(a>0){var c=k&&this.options.showLines?"last":"";var o=this.options.showLines?"node":"";if(this.options.showPlusMinus&&f){var w=document.createElement("img");w.name=l;w.style.cursor="pointer";w.onclick=this.clickBranch.bindAsEventListener(this);w.src=Rico.imgDir+o+"p"+c+".gif";d.insertCell(-1).appendChild(w)}else{if(this.options.showLines){var w=document.createElement("img");w.src=Rico.imgDir+"node"+c+".gif";d.insertCell(-1).appendChild(w)}}if(this.options.showFolders&&(f||(s&&s!="none"))){var w=document.createElement("img");if(!f){w.src=s}else{w.name=l;w.style.cursor="pointer";w.onclick=this.clickBranch.bindAsEventListener(this);w.src=Rico.imgDir+"folderclosed.gif"}d.insertCell(-1).appendChild(w)}}if(u&&this.options.showCheckBox){var n=document.createElement("input");n.type="checkbox";n.value=l;d.insertCell(-1).appendChild(n)}if(u&&!this.options.showCheckBox){var p=document.createElement("a");if(typeof u=="string"){p.href=u}else{p.href="javascript:void(0)";p.onclick=this.options.defaultAction}}else{var p=document.createElement("p")}p.id=this.domID(l,"Desc");p.className="ricoTreeLevel"+a;switch(this.options.nodeIdDisplay){case"last":t+=" ("+l+")";break;case"first":t=l+" - "+t;break;case"tooltip":p.title=l;break}p.appendChild(document.createTextNode(t));d.insertCell(-1).appendChild(p);var j=v||this.treeDiv;j.appendChild(b);j.appendChild(m)},nodeClick:function(c){var b=Event.element(c);if(this.returnValue){var a=this.domID("","Desc");this.returnValue(b.id.substr(a.length),b.innerHTML)}this.close()},saveSelection:function(a){if(this.returnValue){this.returnValue(this.getCheckedItems())}this.close()},getCheckedItems:function(){var b=this.treeDiv.getElementsByTagName("input");var c=[];for(var a=0;a<b.length;a++){if(b[a].type=="checkbox"&&b[a].checked){c.push(b[a].value)}}return c},setCheckBoxes:function(c){var b=this.treeDiv.getElementsByTagName("input");for(var a=0;a<b.length;a++){if(b[a].type=="checkbox"){b[a].checked=c}}},clrCheckBoxEvent:function(a){Event.stop(a);this.setCheckBoxes(false)},clickBranch:function(h){var g=Event.element(h);var f=RicoUtil.getParentByTagName(g,"table");if(!f||!f.TreeContainer){return}var c=f.id.split("_");c[1]="Children";var b=$(c.join("_"));Element.toggle(b);if(g.tagName=="IMG"){var d=Element.visible(b);if(g.src.match(/node(p|m)(last)?\.gif$/)){g.src=g.src.replace(/nodep|nodem/,"node"+(d?"m":"p"))}else{if(g.src.match(/folder(open|closed)\.gif$/)){g.src=g.src.replace(/folder(open|closed)/,"folder"+(d?"open":"closed"))}else{if(g.src.match(/\b(m|p)\.gif$/)){g.src=g.src.replace(/(p|m)\.gif/,d?"m.gif":"p.gif")}}}}if(!f.TreeFetchedChildren){f.TreeFetchedChildren=1;this.loadXMLDoc(g.name)}}});Rico.includeLoaded("ricoTree.js");Rico.ColorPicker=Class.create({initialize:function(h,c){this.id=h;this.currentValue="#FFFFFF";Object.extend(this,new Rico.Popup());Object.extend(this.options,{showColorCode:false,cellsPerRow:18,palette:[]});var f=["00","33","66","99","CC","FF"];for(var e=0;e<f.length;e++){for(var d=0;d<f.length;d++){for(var a=0;a<f.length;a++){this.options.palette.push(f[d]+f[e]+f[a])}}}Object.extend(this.options,c||{})},atLoad:function(){this.container=document.createElement("div");this.container.style.display="none";this.container.className="ricoColorPicker";var c=this.options.cellsPerRow;var d="<TABLE BORDER='1' CELLSPACING='1' CELLPADDING='0'>";for(var b=0;b<this.options.palette.length;b++){if((b%c)==0){d+="<TR>"}d+='<TD BGCOLOR="#'+this.options.palette[b]+'">&nbsp;</TD>';if(((b+1)>=this.options.palette.length)||(((b+1)%c)==0)){d+="</TR>"}}var a=Math.floor(c/2);if(this.options.showColorCode){d+="<TR><TD COLSPAN='"+a+"' ID='colorPickerSelectedColor'>&nbsp;</TD><TD COLSPAN='"+(c-a)+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue'>#FFFFFF</TD></TR>"}else{d+="<TR><TD COLSPAN='"+c+"' ID='colorPickerSelectedColor'>&nbsp;</TD></TR>"}d+="</TABLE>";this.container.innerHTML=d;document.body.appendChild(this.container);this.setDiv(this.container);this.open=this.openPopup;this.close=this.closePopup;Event.observe(this.container,"mouseover",this.highlightColor.bindAsEventListener(this),false);Event.observe(this.container,"click",this.selectColor.bindAsEventListener(this),false);this.close()},selectColor:function(a){Event.stop(a);if(this.returnValue){this.returnValue(this.currentValue)}this.close()},highlightColor:function(b){var a=Event.element(b);if(!a.tagName||a.tagName.toLowerCase()!="td"){return}var g=Rico.Color.createColorFromBackground(a).toString();this.currentValue=g;Element.setStyle("colorPickerSelectedColor",{backgroundColor:g},true);var f=$("colorPickerSelectedColorValue");if(f){f.innerHTML=g}}});Rico.includeLoaded("ricoColorPicker.js");Rico.Menu=Class.create({initialize:function(a){Object.extend(this,new Rico.Popup());Object.extend(this.options,{width:"15em"});if(typeof a=="string"){this.options.width=a}else{Object.extend(this.options,a||{})}this.hideFunc=null;this.highlightElem=null;new Image().src=Rico.imgDir+"left.gif";new Image().src=Rico.imgDir+"right.gif"},createDiv:function(a){if(this.div){return}this.div=document.createElement("div");this.div.className=Prototype.Browser.WebKit?"ricoMenuSafari":"ricoMenu";this.div.style.position="absolute";this.div.style.top="0px";this.div.style.left="0px";this.div.style.width=this.options.width;if(!a){a=document.getElementsByTagName("body")[0]}a.appendChild(this.div);this.width=this.div.offsetWidth;this.setDiv(this.div,this.cancelmenu.bindAsEventListener(this));this.direction=Element.getStyle(this.div,"direction")||"ltr";this.direction=this.direction.toLowerCase();this.hidemenu();this.itemCount=0},showmenu:function(a,b){Event.stop(a);this.hideFunc=b;if(this.div.childNodes.length==0){this.cancelmenu();return false}this.openmenu(a.clientX,a.clientY,0,0)},openmenu:function(a,g,d,f){var e=RicoUtil.docScrollLeft()+a;if(this.direction=="rtl"){if(e>this.width+d){e-=this.width+d}}else{if(a+this.width+this.options.margin>RicoUtil.windowWidth()){e-=this.width+d}}var b=RicoUtil.docScrollTop()+g;this.div.style.visibility="hidden";this.div.style.display="block";var c=this.div.offsetHeight;if(g+c+this.options.margin>RicoUtil.windowHeight()){b=Math.max(b-c+f,0)}this.openPopup(e,b);this.div.style.visibility="visible";return false},clearMenu:function(){this.div.innerHTML="";this.defaultAction=null;this.itemCount=0},addMenuHeading:function(b){var a=document.createElement("div");a.innerHTML=b;a.className="ricoMenuHeading";this.div.appendChild(a)},addMenuBreak:function(){var a=document.createElement("div");a.className="ricoMenuBreak";this.div.appendChild(a)},addSubMenuItem:function(b,e,f){var d=this.direction=="rtl"?"left":"right";var c=this.addMenuItem(b,null,true,null,f);c.className="ricoSubMenu";c.style.backgroundImage="url("+Rico.imgDir+d+".gif)";c.style.backgroundRepeat="no-repeat";c.style.backgroundPosition=d;c.onmouseover=this.showSubMenu.bind(this,c,e);c.onmouseout=this.subMenuOut.bindAsEventListener(this)},showSubMenu:function(b,c){if(this.openSubMenu){this.hideSubMenu()}this.openSubMenu=c;this.openMenuAnchor=b;var d=Position.page(b);if(b.className=="ricoSubMenu"){b.className="ricoSubMenuOpen"}c.openmenu(d[0]+b.offsetWidth,d[1],b.offsetWidth-2,b.offsetHeight+2)},subMenuOut:function(d){if(!this.openSubMenu){return}Event.stop(d);var c=Event.element(d);var a=(d.relatedTarget)?d.relatedTarget:d.toElement;try{while(a!=null&&a!=this.openSubMenu.div){a=a.parentNode}}catch(b){}if(a==this.openSubMenu.div){return}this.hideSubMenu()},hideSubMenu:function(){if(this.openMenuAnchor){this.openMenuAnchor.className="ricoSubMenu";this.openMenuAnchor=null}if(this.openSubMenu){this.openSubMenu.hidemenu();this.openSubMenu=null}},addMenuItemId:function(c,b,a,e,d){if(arguments.length<3){a=true}this.addMenuItem(RicoTranslate.getPhraseById(c),b,a,e,false,d)},addMenuItem:function(b,e,d,h,g,f){this.itemCount++;if(g==null){g=true}var c=document.createElement(typeof e=="string"?"a":"div");if(arguments.length<3||d){switch(typeof e){case"function":c.onclick=e;break;case"string":c.href=e;if(f){c.target=f}break}c.className="enabled";if(this.defaultAction==null){this.defaultAction=e}}else{c.disabled=true;c.className="disabled"}c.innerHTML=g?RicoTranslate.getPhrase(b):b;if(typeof h=="string"){c.title=g?RicoTranslate.getPhrase(h):h}c=this.div.appendChild(c);Event.observe(c,"mouseover",this.mouseOver.bindAsEventListener(this));Event.observe(c,"mouseout",this.mouseOut.bindAsEventListener(this));return c},mouseOver:function(b){if(this.highlightElem&&this.highlightElem.className=="enabled-hover"){this.highlightElem.className="enabled";this.highlightElem=null}var a=Event.element(b);if(this.openMenuAnchor&&this.openMenuAnchor!=a){this.hideSubMenu()}if(a.className=="enabled"){a.className="enabled-hover";this.highlightElem=a}},mouseOut:function(b){var a=Event.element(b);if(a.className=="enabled-hover"){a.className="enabled"}if(this.highlightElem==a){this.highlightElem=null}},isVisible:function(){return this.div&&Element.visible(this.div)},cancelmenu:function(){if(!this.isVisible()){return}if(this.hideFunc){this.hideFunc()}this.hideFunc=null;this.hidemenu()},hidemenu:function(){if(!this.div){return}if(this.openSubMenu){this.openSubMenu.hidemenu()}this.closePopup()}});Rico.includeLoaded("ricoMenu.js");if(typeof Rico=="undefined"){throw ("GridCommon requires the Rico JavaScript framework")}if(typeof RicoUtil=="undefined"){throw ("GridCommon requires the RicoUtil Library")}Rico.GridCommon=function(){};Rico.GridCommon.prototype={baseInit:function(){this.options={resizeBackground:"resize.gif",saveColumnInfo:{width:true,filter:false,sort:false},cookiePrefix:"RicoGrid.",allowColResize:true,windowResize:true,click:null,dblclick:null,contextmenu:null,useUnformattedColWidth:true,menuEvent:"dblclick",defaultWidth:100,scrollBarWidth:19,minScrollWidth:100,exportWindow:"height=400,width=500,scrollbars=1,menubar=1,resizable=1",exportStyleList:["background-color","color","text-align","font-weight","font-size","font-family"],exportImgTags:false,exportFormFields:true,FilterLocation:null,FilterAllToken:"___ALL___",columnSpecs:[]};this.colWidths=[];this.hdrCells=[];this.headerColCnt=0;this.headerRowIdx=0;this.tabs=new Array(2);this.thead=new Array(2);this.tbody=new Array(2)},attachMenuEvents:function(){var a;if(!this.options.menuEvent||this.options.menuEvent=="none"){return}this.hideScroll=navigator.userAgent.match(/Macintosh\b.*\b(Firefox|Camino)\b/i)||(Prototype.Browser.Opera&&parseFloat(window.opera.version())<9.5);this.options[this.options.menuEvent]=this.handleMenuClick.bindAsEventListener(this);if(this.highlightDiv){switch(this.options.highlightElem){case"cursorRow":this.attachMenu(this.highlightDiv[0]);break;case"cursorCell":for(a=0;a<2;a++){this.attachMenu(this.highlightDiv[a])}break}}for(a=0;a<2;a++){this.attachMenu(this.tbody[a])}},attachMenu:function(a){if(this.options.click){Event.observe(a,"click",this.options.click,false)}if(this.options.dblclick){if(Prototype.Browser.WebKit||Prototype.Browser.Opera){Event.observe(a,"click",this.handleDblClick.bindAsEventListener(this),false)}else{Event.observe(a,"dblclick",this.options.dblclick,false)}}if(this.options.contextmenu){if(Prototype.Browser.Opera||Rico.isKonqueror){Event.observe(a,"click",this.handleContextMenu.bindAsEventListener(this),false)}else{Event.observe(a,"contextmenu",this.options.contextmenu,false)}}},handleDblClick:function(b){var a=Event.element(b);if(this.dblClickElem==a){this.options.dblclick(b)}else{this.dblClickElem=a;this.safariTimer=setTimeout(this.clearDblClick.bind(this),300)}},clearDblClick:function(){this.dblClickElem=null},handleContextMenu:function(c){var a;if(typeof(c.which)=="number"){a=c.which}else{if(typeof(c.button)=="number"){a=c.button}else{return}}if(a==1&&c.ctrlKey){this.options.contextmenu(c)}},cancelMenu:function(){if(this.menu&&this.menu.isVisible()){this.menu.cancelmenu()}},getColumnInfo:function(f){Rico.writeDebugMsg("getColumnInfo: len="+f.length);if(f.length==0){return 0}this.headerRowCnt=f.length;var d,h,e;for(d=0;d<this.headerRowCnt;d++){var b=f[d];var a=b.cells;if(d>=this.hdrCells.length){this.hdrCells[d]=[]}for(h=0;h<a.length;h++){var g={};g.cell=a[h];g.colSpan=a[h].colSpan||1;if(this.options.useUnformattedColWidth){g.initWidth=a[h].offsetWidth}this.hdrCells[d].push(g)}if(b.id.slice(-5)=="_main"){e=this.hdrCells[d].length;this.headerRowIdx=d}}if(!e){this.headerRowIdx=this.headerRowCnt-1;e=this.hdrCells[this.headerRowIdx].length}Rico.writeDebugMsg("getColumnInfo: colcnt="+e);return e},addHeadingRow:function(){var d=this.headerRowCnt++;this.hdrCells[d]=[];for(var b=0;b<2;b++){var g=this.thead[b].insertRow(-1);g.className="ricoLG_hdg "+this.tableId+"_hdg"+d;var a=b==0?this.options.frozenColumns:this.headerColCnt-this.options.frozenColumns;for(var i=0;i<a;i++){var e=g.insertCell(-1);var f=RicoUtil.wrapChildren(e,"ricoLG_col");RicoUtil.wrapChildren(f,"ricoLG_cell");this.hdrCells[d].push({cell:e,colSpan:1})}}return d},createColumnArray:function(a){this.direction=Element.getStyle(this.outerDiv,"direction").toLowerCase();this.align=this.direction=="rtl"?["right","left"]:["left","right"];Rico.writeDebugMsg("createColumnArray: dir="+this.direction);this.columns=[];for(var d=0;d<this.headerColCnt;d++){Rico.writeDebugMsg("createColumnArray: c="+d);var b=d<this.options.frozenColumns?0:1;this.columns.push(new Rico[a](this,d,this.hdrCells[this.headerRowIdx][d],b))}this.getCookie()},createDivs:function(){Rico.writeDebugMsg("createDivs start");this.outerDiv=this.createDiv("outer");if(Prototype.Browser.Opera){this.outerDiv.style.overflow="hidden"}this.scrollDiv=this.createDiv("scroll",this.outerDiv);this.frozenTabs=this.createDiv("frozenTabs",this.outerDiv);this.innerDiv=this.createDiv("inner",this.outerDiv);this.resizeDiv=this.createDiv("resize",this.outerDiv);this.resizeDiv.style.display="none";this.exportDiv=this.createDiv("export",this.outerDiv);this.exportDiv.style.display="none";this.messageDiv=this.createDiv("message",this.outerDiv);this.messageDiv.style.display="none";this.messageShadow=new Rico.Shadow(this.messageDiv);this.keywordDiv=this.createDiv("keyword",this.outerDiv);this.keywordDiv.style.display="none";this.keywordTitle=this.keywordDiv.appendChild(document.createElement("p"));Element.addClassName(this.keywordTitle,"keywordTitle");var a=this.keywordDiv.appendChild(document.createElement("p"));a.innerHTML=RicoTranslate.getPhraseById("keywordPrompt");this.keywordBox=this.keywordDiv.appendChild(document.createElement("input"));this.keywordBox.size=20;Event.observe(this.keywordBox,"keypress",this.keywordKey.bindAsEventListener(this),false);var b=document.createElement("img");b.src=Rico.imgDir+"checkmark.gif";Event.observe(b,"click",this.processKeyword.bindAsEventListener(this),false);this.keywordDiv.appendChild(b);b=document.createElement("img");b.src=Rico.imgDir+"delete.gif";Event.observe(b,"click",this.closeKeyword.bindAsEventListener(this),false);this.keywordDiv.appendChild(b);Rico.writeDebugMsg("createDivs end")},keywordKey:function(a){switch(RicoUtil.eventKey(a)){case 27:this.closeKeyword();Event.stop(a);return false;case 13:this.processKeyword();Event.stop(a);return false}return true},openKeyword:function(a){this.keywordCol=a;this.keywordBox.value="";this.keywordTitle.innerHTML=this.columns[a].displayName;this.centerMsg(this.keywordDiv);this.keywordBox.focus()},closeKeyword:function(){Element.hide(this.keywordDiv);this.cancelMenu()},processKeyword:function(){var a=this.keywordBox.value;this.closeKeyword();this.columns[this.keywordCol].setFilterKW(a)},createDiv:function(b,a){var d=this.tableId+"_"+b+"Div";c=$(d);if(!c){var c=document.createElement("div");c.id=d;if(a){a.appendChild(c)}}c.className="ricoLG_"+b+"Div";return c},baseSizeDivs:function(){this.setOtherHdrCellWidths();if(this.options.frozenColumns){Element.show(this.tabs[0]);Element.show(this.frozenTabs);this.hdrHt=Math.max(RicoUtil.nan2zero(this.thead[0].offsetHeight),this.thead[1].offsetHeight);this.dataHt=Math.max(RicoUtil.nan2zero(this.tbody[0].offsetHeight),this.tbody[1].offsetHeight);this.frzWi=this.borderWidth(this.tabs[0])}else{Element.hide(this.tabs[0]);Element.hide(this.frozenTabs);this.frzWi=0;this.hdrHt=this.thead[1].offsetHeight;this.dataHt=this.tbody[1].offsetHeight}var d,b;var c=this.borderWidth(this.columns[0].dataCell);Rico.writeDebugMsg("baseSizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);for(b=0;b<this.options.frozenColumns;b++){if(this.columns[b].visible){this.frzWi+=parseInt(this.columns[b].colWidth,10)+c}}this.scrTabWi=this.borderWidth(this.tabs[1]);for(b=this.options.frozenColumns;b<this.columns.length;b++){if(this.columns[b].visible){this.scrTabWi+=parseInt(this.columns[b].colWidth,10)+c}}this.scrWi=this.scrTabWi+this.options.scrollBarWidth;if(this.sizeTo=="parent"){if(Prototype.Browser.IE){Element.hide(this.outerDiv)}d=this.outerDiv.parentNode.offsetWidth;if(Prototype.Browser.IE){Element.show(this.outerDiv)}}else{d=RicoUtil.windowWidth()-this.options.scrollBarWidth-8}if(this.outerDiv.parentNode.clientWidth>0){d=Math.min(this.outerDiv.parentNode.clientWidth,d)}var a=this.frzWi+this.scrWi-d;Rico.writeDebugMsg("baseSizeDivs "+this.tableId+": scrWi="+this.scrWi+" wiLimit="+d+" overage="+a+" clientWidth="+this.outerDiv.parentNode.clientWidth);if(a>0&&this.options.frozenColumns<this.columns.length){this.scrWi=Math.max(this.scrWi-a,this.options.minScrollWidth)}this.scrollDiv.style.width=this.scrWi+"px";this.scrollDiv.style.top=this.hdrHt+"px";this.frozenTabs.style.width=this.scrollDiv.style[this.align[0]]=this.innerDiv.style[this.align[0]]=this.frzWi+"px";this.outerDiv.style.width=(this.frzWi+this.scrWi)+"px"},borderWidth:function(a){return RicoUtil.nan2zero(Element.getStyle(a,"border-left-width"))+RicoUtil.nan2zero(Element.getStyle(a,"border-right-width"))},setOtherHdrCellWidths:function(){var k,g,f,a,l,b,m,d,e,h;for(a=0;a<this.hdrCells.length;a++){if(a==this.headerRowIdx){continue}Rico.writeDebugMsg("setOtherHdrCellWidths: r="+a);k=g=0;while(g<this.headerColCnt&&k<this.hdrCells[a].length){b=this.hdrCells[a][k];m=b.cell;d=e=b.colSpan;for(l=f=0;f<d;f++,g++){if(this.columns[g].hdrCell.style.display=="none"){e--}else{if(this.columns[g].hdrColDiv.style.display!="none"){l+=parseInt(this.columns[g].colWidth,10)}}}if(!b.hdrColDiv||!b.hdrCellDiv){h=m.getElementsByTagName("div");b.hdrColDiv=(h.length<1)?RicoUtil.wrapChildren(m,"ricoLG_col"):h[0];b.hdrCellDiv=(h.length<2)?RicoUtil.wrapChildren(b.hdrColDiv,"ricoLG_cell"):h[1]}if(e==0){m.style.display="none"}else{if(l==0){b.hdrColDiv.style.display="none";m.colSpan=e}else{m.style.display="";b.hdrColDiv.style.display="";m.colSpan=e;b.hdrColDiv.style.width=l+"px"}}k++}}},initFilterImage:function(a){this.filterAnchor=$(this.tableId+"_filterLink");if(!this.filterAnchor){return}this.filterRows=$$("tr."+this.tableId+"_hdg"+a);if(this.filterRows.length!=2){return}for(var c=0,d=[];c<2;c++){d[c]=Element.select(this.filterRows[c],".ricoLG_cell")}this.filterElements=d[0].concat(d[1]);this.saveHeight=this.filterElements[0].offsetHeight;var e=Element.getStyle(this.filterElements[0],"padding-top");var b=Element.getStyle(this.filterElements[0],"padding-bottom");if(e){this.saveHeight-=parseInt(e,10)}if(b){this.saveHeight-=parseInt(b,10)}this.rowNum=a;this.setFilterImage(false);Event.observe(this.filterAnchor,"click",this.toggleFilterRow.bindAsEventListener(this),false)},toggleFilterRow:function(){if(this.filterRows[0].visible()){this.slideFilterUp()}else{this.slideFilterDown()}},slideFilterUp:function(){for(var a=0;a<2;a++){this.filterRows[a].makeClipping()}Rico.animate(new Rico.Effect.Height(this.filterElements,0),{onFinish:function(){for(var b=0;b<2;b++){this.filterRows[b].hide()}this.resizeWindow()}.bind(this)});this.setFilterImage(true)},slideFilterDown:function(){for(var a=0;a<2;a++){this.filterRows[a].show()}Rico.animate(new Rico.Effect.Height(this.filterElements,this.saveHeight),{onFinish:function(){for(var b=0;b<2;b++){this.filterRows[b].undoClipping()}this.resizeWindow()}.bind(this)});this.setFilterImage(false)},setFilterImage:function(b){var a=RicoTranslate.getPhraseById((b?"show":"hide")+"FilterRow");this.filterAnchor.innerHTML='<img src="'+Rico.imgDir+"tableFilter"+(b?"Expand":"Collapse")+'.gif" alt="'+a+'" border="0">'},cell:function(a,b){return(0<=b&&b<this.columns.length&&a>=0)?this.columns[b].cell(a):null},availHt:function(){var a=Position.page(this.outerDiv);return RicoUtil.windowHeight()-a[1]-2*this.options.scrollBarWidth-15},setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";this.hdrTabs[1].style.left=a},pluginScroll:function(){if(this.scrollPluggedIn){return}Event.observe(this.scrollDiv,"scroll",this.scrollEventFunc,false);this.scrollPluggedIn=true},unplugScroll:function(){Event.stopObserving(this.scrollDiv,"scroll",this.scrollEventFunc,false);this.scrollPluggedIn=false},hideMsg:function(){if(this.messageDiv.style.display=="none"){return}this.messageDiv.style.display="none";this.messageShadow.hide()},showMsg:function(a){this.messageDiv.innerHTML=a;this.centerMsg(this.messageDiv);this.messageShadow.show();Rico.writeDebugMsg("showMsg: "+a)},centerMsg:function(e){Element.show(e);var d=e.offsetWidth;var c=e.offsetHeight;var a=this.outerDiv.offsetWidth;var b=this.outerDiv.offsetHeight;e.style.top=parseInt((b-c)/2,10)+"px";e.style.left=parseInt((a-d)/2,10)+"px"},listInvisible:function(){var b=[];for(var a=0;a<this.columns.length;a++){if(this.columns[a].visible==false){b.push(this.columns[a])}}return b},firstVisible:function(){for(var a=0;a<this.columns.length;a++){if(this.columns[a].visible){return a}}return -1},showAll:function(){var b=this.listInvisible();for(var a=0;a<b.length;a++){b[a].showColumn()}},chooseColumns:function(f){Event.stop(f);this.menu.cancelmenu();var i,g,a,b,j,h;if(!this.columnChooser){g=Element.getStyle(this.outerDiv.offsetParent,"z-index");if(typeof g!="number"){g=0}this.columnChooser=new Rico.Popup({canDragFunc:true,zIndex:g+2});this.columnChooser.createWindow(RicoTranslate.getPhraseById("gridChooseCols"),"","150px","200px","ricoLG_chooser");h=this.columnChooser.contentDiv;for(i=0;i<this.columns.length;i++){a=this.columns[i];b=h.appendChild(document.createElement("div"));a.ChooserBox=RicoUtil.createFormField(b,"input","checkbox");j=b.appendChild(document.createElement("span"));j.innerHTML=a.displayName;Event.observe(a.ChooserBox,"click",a.chooseColumn.bindAsEventListener(a),false)}}var d=Position.page(this.outerDiv);var c=d[1]+this.hdrHt+RicoUtil.docScrollTop();this.columnChooser.openPopup(d[0]+1,c);for(i=0;i<this.columns.length;i++){this.columns[i].ChooserBox.checked=this.columns[i].visible;this.columns[i].ChooserBox.disabled=!this.columns[i].canHideShow()}},blankRow:function(a){for(var b=0;b<this.columns.length;b++){this.columns[b].clearCell(a)}},printVisible:function(a){this.showMsg(RicoTranslate.getPhraseById("exportInProgress"));setTimeout(this._printVisible.bind(this,a),10)},exportStart:function(){var h,k,f,e,b,d,g,a;this.exportRows=[];this.exportText="<table border='1' cellspacing='0'>";for(k=0;k<this.columns.length;k++){if(this.columns[k].visible){this.exportText+="<col width='"+parseInt(this.columns[k].colWidth,10)+"'>"}}this.exportText+="<thead style='display: table-header-group;'>";if(this.exportHeader){this.exportText+=this.exportHeader}for(h=0;h<this.hdrCells.length;h++){if(this.hdrCells[h].length==0||Element.getStyle(this.hdrCells[h][0].cell.parentNode,"display")=="none"){continue}this.exportText+="<tr>";for(k=0,f=0;k<this.hdrCells[h].length;k++){b=this.hdrCells[h][k];d=b.colSpan;for(e=0;e<b.colSpan;e++,f++){if(!this.columns[f].visible){d--}}if(d>0){g=Element.select(b.cell,".ricoLG_cell");a=g&&g.length>0?g[0]:b.cell;this.exportText+="<td style='"+this.exportStyle(a)+"'";if(b.colSpan>1){this.exportText+=" colspan='"+d+"'"}this.exportText+=">"+RicoUtil.getInnerText(a,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport")+"</td>"}}this.exportText+="</tr>"}this.exportText+="</thead><tbody>"},exportFinish:function(b){if(this.hideMsg){this.hideMsg()}window.status=RicoTranslate.getPhraseById("exportComplete");if(this.exportRows.length>0){this.exportText+="<tr>"+this.exportRows.join("</tr><tr>")+"</tr>"}if(this.exportFooter){this.exportText+=this.exportFooter}this.exportText+="</tbody></table>";this.exportDiv.innerHTML=this.exportText;this.exportText=undefined;this.exportRows=undefined;if(this.cancelMenu){this.cancelMenu()}var a=window.open(Rico.htmDir+"export-"+(b||"plain")+".html?"+this.exportDiv.id,"",this.options.exportWindow);if(a==null){alert(RicoTranslate.getPhraseById("disableBlocker"))}},exportStyle:function(d){var g=this.options.exportStyleList;for(var b=0,c="";b<g.length;b++){try{var a=Element.getStyle(d,g[b]);if(a){c+=g[b]+":"+a+";"}}catch(f){}}return c},getCookie:function(){var k=RicoUtil.getCookie(this.options.cookiePrefix+this.tableId);if(!k){return}var f=k.split(",");for(var g=0;g<f.length;g++){var a=f[g].split(":");if(a.length!=2){continue}var h=parseInt(a[0].slice(1),10);if(h<0||h>=this.columns.length){continue}var e=this.columns[h];switch(a[0].charAt(0)){case"w":e.setColWidth(a[1]);e.customWidth=true;break;case"h":if(a[1].toLowerCase()=="true"){e.hideshow(true,true)}else{e.hideshow(false,true)}break;case"s":if(!this.options.saveColumnInfo.sort||!e.sortable){break}e.setSorted(a[1]);break;case"f":if(!this.options.saveColumnInfo.filter||!e.filterable){break}var d=a[1].split("~");e.filterOp=d.shift();e.filterValues=[];e.filterType=Rico.TableColumn.USERFILTER;for(var b=0;b<d.length;b++){e.filterValues.push(unescape(d[b]))}break}}},setCookie:function(){var d=[];for(var e=0;e<this.columns.length;e++){var c=this.columns[e];if(this.options.saveColumnInfo.width){if(c.customWidth){d.push("w"+e+":"+c.colWidth)}if(c.customVisible){d.push("h"+e+":"+c.visible)}}if(this.options.saveColumnInfo.sort){if(c.currentSort!=Rico.TableColumn.UNSORTED){d.push("s"+e+":"+c.currentSort)}}if(this.options.saveColumnInfo.filter&&c.filterType==Rico.TableColumn.USERFILTER){var b=[c.filterOp];for(var a=0;a<c.filterValues.length;a++){b.push(escape(c.filterValues[a]))}d.push("f"+e+":"+b.join("~"))}}RicoUtil.setCookie(this.options.cookiePrefix+this.tableId,d.join(","),this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)}};Rico.TableColumn=Class.create();Rico.TableColumn.UNFILTERED=0;Rico.TableColumn.SYSTEMFILTER=1;Rico.TableColumn.USERFILTER=2;Rico.TableColumn.UNSORTED=0;Rico.TableColumn.SORT_ASC="ASC";Rico.TableColumn.SORT_DESC="DESC";Rico.TableColumn.MINWIDTH=10;Rico.TableColumn.DOLLAR={type:"number",prefix:"$",decPlaces:2,ClassName:"alignright"};Rico.TableColumn.EURO={type:"number",prefix:"&euro;",decPlaces:2,ClassName:"alignright"};Rico.TableColumn.PERCENT={type:"number",suffix:"%",decPlaces:2,multiplier:100,ClassName:"alignright"};Rico.TableColumn.QTY={type:"number",decPlaces:0,ClassName:"alignright"};Rico.TableColumn.DEFAULT={type:"raw"};Rico.TableColumnBase=function(){};Rico.TableColumnBase.prototype={baseInit:function(h,g,e,d){Rico.writeDebugMsg("TableColumnBase.init index="+g+" tabIdx="+d);this.liveGrid=h;this.index=g;this.hideWidth=Rico.isKonqueror||Prototype.Browser.WebKit||h.headerRowCnt>1?5:2;this.options=h.options;this.tabIdx=d;this.hdrCell=e.cell;this.body=document.getElementsByTagName("body")[0];this.displayName=this.getDisplayName(this.hdrCell);var c=this.hdrCell.getElementsByTagName("div");this.hdrColDiv=(c.length<1)?RicoUtil.wrapChildren(this.hdrCell,"ricoLG_col"):c[0];this.hdrCellDiv=(c.length<2)?RicoUtil.wrapChildren(this.hdrColDiv,"ricoLG_cell"):c[1];var f=d==0?g:g-h.options.frozenColumns;this.dataCell=h.tbody[d].rows[0].cells[f];c=this.dataCell.getElementsByTagName("div");this.dataColDiv=(c.length<1)?RicoUtil.wrapChildren(this.dataCell,"ricoLG_col"):c[0];this.mouseDownHandler=this.handleMouseDown.bindAsEventListener(this);this.mouseMoveHandler=this.handleMouseMove.bindAsEventListener(this);this.mouseUpHandler=this.handleMouseUp.bindAsEventListener(this);this.mouseOutHandler=this.handleMouseOut.bindAsEventListener(this);this.fieldName="col"+this.index;var b=h.options.columnSpecs[g];this.format=Object.extend({},Rico.TableColumn.DEFAULT);switch(typeof b){case"object":if(typeof b.format=="string"){Object.extend(this.format,Rico.TableColumn[b.format.toUpperCase()])}Object.extend(this.format,b);break;case"string":if(b.slice(0,4)=="spec"){b=b.slice(4).toUpperCase()}this.format=typeof Rico.TableColumn[b]=="object"?Rico.TableColumn[b]:Rico.TableColumn.DEFAULT;break}Element.addClassName(this.dataColDiv,this.colClassName());this.visible=true;if(typeof this.format.visible=="boolean"){this.visible=this.format.visible}Rico.writeDebugMsg("TableColumn.init index="+g+" fieldName="+this.fieldName);this.sortable=typeof this.format.canSort=="boolean"?this.format.canSort:h.options.canSortDefault;this.currentSort=Rico.TableColumn.UNSORTED;this.filterable=typeof this.format.canFilter=="boolean"?this.format.canFilter:h.options.canFilterDefault;this.filterType=Rico.TableColumn.UNFILTERED;this.hideable=typeof this.format.canHide=="boolean"?this.format.canHide:h.options.canHideDefault;var a=(typeof(this.format.width)=="number")?this.format.width:e.initWidth;a=(typeof(a)=="number")?Math.max(a,Rico.TableColumn.MINWIDTH):h.options.defaultWidth;this.setColWidth(a);if(!this.visible){this.setDisplay("none")}if(this.options.allowColResize&&!this.format.noResize){this.insertResizer()}},colClassName:function(){return this.format.ClassName?this.format.ClassName:this.liveGrid.tableId+"_col"+this.index},insertResizer:function(){this.hdrCell.style.width="";var b=this.hdrCellDiv.appendChild(document.createElement("div"));b.className="ricoLG_Resize";b.style[this.liveGrid.align[1]]="0px";if(this.options.resizeBackground){var a=Rico.imgDir+this.options.resizeBackground;if(Prototype.Browser.IE&&typeof(XDomainRequest)=="undefined"){a=location.protocol+a}b.style.backgroundImage="url("+a+")"}Event.observe(b,"mousedown",this.mouseDownHandler,false)},getDisplayName:function(a){var b=a.getElementsByTagName("A");if(b.length>0){return b[0].innerHTML}else{return a.innerHTML.stripTags()}},_clear:function(a){a.innerHTML="&nbsp;"},clearCell:function(d){var c=this.cell(d);this._clear(c,d);if(!this.liveGrid.buffer){return}var b=this.liveGrid.buffer.options.acceptAttr;for(var a=0;a<b.length;a++){switch(b[a]){case"style":c.style.cssText="";break;case"class":c.className="";break;default:c["_"+b[a]]="";break}}},dataTable:function(){return this.liveGrid.tabs[this.tabIdx]},numRows:function(){return this.dataColDiv.childNodes.length},clearColumn:function(){var b=this.numRows();for(var a=0;a<b;a++){this.clearCell(a)}},cell:function(a){return this.dataColDiv.childNodes[a]},getFormattedValue:function(c,a,d,b){return RicoUtil.getInnerText(this.cell(c),a,d,b)},setColWidth:function(a){if(typeof a=="number"){a=parseInt(a,10);if(a<Rico.TableColumn.MINWIDTH){return}a=a+"px"}Rico.writeDebugMsg("setColWidth "+this.index+": "+a);this.colWidth=a;this.hdrColDiv.style.width=a;this.dataColDiv.style.width=a},pluginMouseEvents:function(){if(this.mousePluggedIn==true){return}Event.observe(this.body,"mousemove",this.mouseMoveHandler,false);Event.observe(this.body,"mouseup",this.mouseUpHandler,false);Event.observe(this.body,"mouseout",this.mouseOutHandler,false);this.mousePluggedIn=true},unplugMouseEvents:function(){Event.stopObserving(this.body,"mousemove",this.mouseMoveHandler,false);Event.stopObserving(this.body,"mouseup",this.mouseUpHandler,false);Event.stopObserving(this.body,"mouseout",this.mouseOutHandler,false);this.mousePluggedIn=false},handleMouseDown:function(b){this.resizeStart=b.clientX;this.origWidth=parseInt(this.colWidth,10);var a=Position.positionedOffset(this.hdrCell);if(this.liveGrid.direction=="rtl"){this.edge=a[0]+this.liveGrid.options.scrollBarWidth;switch(this.tabIdx){case 0:this.edge+=this.liveGrid.innerDiv.offsetWidth;break;case 1:this.edge-=this.liveGrid.scrollDiv.scrollLeft;break}}else{this.edge=a[0]+this.hdrCell.offsetWidth;if(this.tabIdx>0){this.edge+=RicoUtil.nan2zero(this.liveGrid.tabs[0].offsetWidth)-this.liveGrid.scrollDiv.scrollLeft}}this.liveGrid.resizeDiv.style.left=this.edge+"px";this.liveGrid.resizeDiv.style.display="";this.liveGrid.outerDiv.style.cursor="e-resize";this.tmpHighlight=this.liveGrid.highlightEnabled;this.liveGrid.highlightEnabled=false;this.pluginMouseEvents();Event.stop(b)},handleMouseMove:function(b){var c=b.clientX-this.resizeStart;var a=(this.liveGrid.direction=="rtl")?this.origWidth-c:this.origWidth+c;if(a<Rico.TableColumn.MINWIDTH){return}this.liveGrid.resizeDiv.style.left=(this.edge+c)+"px";this.colWidth=a;Event.stop(b)},handleMouseUp:function(a){this.unplugMouseEvents();Rico.writeDebugMsg("handleMouseUp "+this.liveGrid.tableId);this.liveGrid.outerDiv.style.cursor="";this.liveGrid.resizeDiv.style.display="none";this.setColWidth(this.colWidth);this.customWidth=true;this.liveGrid.setCookie();this.liveGrid.highlightEnabled=this.tmpHighlight;this.liveGrid.sizeDivs();Event.stop(a)},handleMouseOut:function(b){var a=(b.relatedTarget)?b.relatedTarget:b.toElement;while(a!=null&&a.nodeName.toLowerCase()!="body"){a=a.parentNode}if(a!=null&&a.nodeName.toLowerCase()=="body"){return true}this.handleMouseUp(b);return true},setDisplay:function(a){this.hdrCell.style.display=a;this.hdrColDiv.style.display=a;this.dataCell.style.display=a;this.dataColDiv.style.display=a},hideshow:function(b,a){this.setDisplay(b?"":"none");this.liveGrid.cancelMenu();this.visible=b;this.customVisible=true;if(a){return}this.liveGrid.setCookie();this.liveGrid.sizeDivs()},hideColumn:function(){Rico.writeDebugMsg("hideColumn "+this.liveGrid.tableId);this.hideshow(false,false)},showColumn:function(){Rico.writeDebugMsg("showColumn "+this.liveGrid.tableId);this.hideshow(true,false)},chooseColumn:function(b){var a=Event.element(b);this.hideshow(a.checked,false)},setImage:function(){if(this.currentSort==Rico.TableColumn.SORT_ASC){this.imgSort.style.display="";this.imgSort.src=Rico.imgDir+this.options.sortAscendImg}else{if(this.currentSort==Rico.TableColumn.SORT_DESC){this.imgSort.style.display="";this.imgSort.src=Rico.imgDir+this.options.sortDescendImg}else{this.imgSort.style.display="none"}}if(this.filterType==Rico.TableColumn.USERFILTER){this.imgFilter.style.display="";this.imgFilter.title=this.getFilterText()}else{this.imgFilter.style.display="none"}},canHideShow:function(){return this.hideable}};Rico.includeLoaded("ricoGridCommon.js");if(typeof Rico=="undefined"){throw ("SimpleGrid requires the Rico JavaScript framework")}if(typeof RicoUtil=="undefined"){throw ("SimpleGrid requires the RicoUtil Library")}if(typeof RicoTranslate=="undefined"){throw ("SimpleGrid requires the RicoTranslate Library")}Rico.SimpleGrid=Class.create({initialize:function(b,a){Object.extend(this,new Rico.GridCommon);this.baseInit();Rico.setDebugArea(b+"_debugmsgs");Object.extend(this.options,a||{});this.tableId=b;Rico.writeDebugMsg("SimpleGrid initialize start: "+b);this.createDivs();this.hdrTabs=new Array(2);this.simpleGridInit();Rico.writeDebugMsg("SimpleGrid initialize end: "+b)},simpleGridInit:function(){var a;for(a=0;a<2;a++){Rico.writeDebugMsg("simpleGridInit "+a);this.tabs[a]=$(this.tableId+"_tab"+a);if(!this.tabs[a]){return}this.hdrTabs[a]=$(this.tableId+"_tab"+a+"h");if(!this.hdrTabs[a]){return}if(a==0){this.tabs[a].style.position="absolute"}if(a==0){this.tabs[a].style.left="0px"}this.hdrTabs[a].style.position="absolute";this.hdrTabs[a].style.top="0px";this.hdrTabs[a].style.zIndex=1;this.thead[a]=this.hdrTabs[a];this.tbody[a]=this.tabs[a];this.headerColCnt=this.getColumnInfo(this.hdrTabs[a].rows);if(a==0){this.options.frozenColumns=this.headerColCnt}}if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');return}this.hdrHt=Math.max(RicoUtil.nan2zero(this.hdrTabs[0].offsetHeight),this.hdrTabs[1].offsetHeight);for(a=0;a<2;a++){if(a==0){this.tabs[a].style.top=this.hdrHt+"px"}}this.createColumnArray("SimpleGridColumn");this.pageSize=this.columns[0].dataColDiv.childNodes.length;this.sizeDivs();if(typeof(this.options.FilterLocation)=="number"){this.createFilters(this.options.FilterLocation)}this.attachMenuEvents();this.scrollEventFunc=this.handleScroll.bindAsEventListener(this);this.pluginScroll();if(this.options.windowResize){Event.observe(window,"resize",this.sizeDivs.bindAsEventListener(this),false)}},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a},createFilters:function(a){if(a<0){a=this.addHeadingRow();this.sizeDivs()}for(var g=0;g<this.headerColCnt;g++){var d=this.columns[g];var e=d.format;if(typeof e.filterUI!="string"){continue}var k=this.hdrCells[a][g].cell;var j,b=this.filterId(g);var h=k.getElementsByTagName("div");switch(e.filterUI.charAt(0)){case"t":j=RicoUtil.createFormField(h[1],"input","text",b,b);var m=e.filterUI.match(/\d+/);j.maxLength=e.Length||50;j.size=m?parseInt(m,10):10;Event.observe(j,"keyup",d.filterKeypress.bindAsEventListener(d),false);break;case"s":j=RicoUtil.createFormField(h[1],"select",null,b);RicoUtil.addSelectOption(j,this.options.FilterAllToken,RicoTranslate.getPhraseById("filterAll"));this.getFilterValues(d);var l=d.filterHash.keys();l.sort();for(var f=0;f<l.length;f++){RicoUtil.addSelectOption(j,l[f],l[f]||RicoTranslate.getPhraseById("filterBlank"))}Event.observe(j,"change",d.filterChange.bindAsEventListener(d),false);break}}this.initFilterImage(a)},getFilterValues:function(b){var e=$H();var f=b.numRows();for(var c=0;c<f;c++){var a=RicoUtil.getInnerText(b.cell(c));var d=e.get(a);if(d){d.push(c)}else{e.set(a,[c])}}b.filterHash=e},applyFilters:function(){var b=[];for(var f=0;f<this.columns.length;f++){if(this.columns[f].filterRows){b.push(this.columns[f].filterRows)}}if(b.length==0){this.showAllRows();return}for(var d=0;d<this.pageSize;d++){var e=true;for(var a=0;a<b.length;a++){if(b[a].indexOf(d)==-1){e=false;break}}if(e){this.showRow(d)}else{this.hideRow(d)}}this.sizeDivs()},handleScroll:function(b){var a=(this.hdrHt-this.scrollDiv.scrollTop)+"px";this.tabs[0].style.top=a;this.setHorizontalScroll()},registerScrollMenu:function(a){if(!this.menu){this.menu=a}a.grid=this;a.showmenu=a.showSimpleMenu;a.showSubMenu=a.showSimpleSubMenu;a.createDiv(this.outerDiv)},handleMenuClick:function(a){if(!this.menu){return}this.cancelMenu();this.menuCell=RicoUtil.getParentByTagName(Event.element(a),"div");this.highlightEnabled=false;if(this.hideScroll){this.scrollDiv.style.overflow="hidden"}if(this.menu.buildGridMenu){this.menu.buildGridMenu(this.menuCell)}this.menu.showmenu(a,this.closeMenu.bind(this))},closeMenu:function(){if(this.hideScroll){this.scrollDiv.style.overflow=""}this.highlightEnabled=true},sizeDivs:function(){if(this.outerDiv.offsetParent.style.display=="none"){return}this.baseSizeDivs();var c=Math.max(this.options.maxHt||this.availHt(),50);var b=Math.min(this.hdrHt+this.dataHt,c);Rico.writeDebugMsg("sizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);this.dataHt=b-this.hdrHt;if(this.scrWi>0){this.dataHt+=this.options.scrollBarWidth}this.scrollDiv.style.height=this.dataHt+"px";var a=2;this.innerDiv.style.width=(this.scrWi-this.options.scrollBarWidth+a)+"px";this.innerDiv.style.height=this.hdrHt+"px";b+=a;this.resizeDiv.style.height=this.frozenTabs.style.height=b+"px";this.outerDiv.style.height=(b+this.options.scrollBarWidth)+"px";this.handleScroll()},_printVisible:function(a){this.exportStart();for(var f=0;f<this.pageSize;f++){if(this.columns[0].cell(f).style.display=="none"){continue}var e="";for(var g=0;g<this.columns.length;g++){var d=this.columns[g];if(d.visible){var b=d.getFormattedValue(f,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport");if(d.format.exportPrefix){b=d.format.exportPrefix+b}if(b==""){b="&nbsp;"}e+="<td style='"+this.exportStyle(d.cell(f))+"'>"+b+"</td>"}}this.exportRows.push(e)}this.exportFinish(a)},hideRow:function(a){if(this.columns[0].cell(a).style.display=="none"){return}for(var b=0;b<this.columns.length;b++){this.columns[b].cell(a).style.display="none"}},showRow:function(a){if(this.columns[0].cell(a).style.display==""){return}for(var b=0;b<this.columns.length;b++){this.columns[b].cell(a).style.display=""}},searchRows:function(h,e,c){if(!e){return}var f=new RegExp(e);var d=this.columns[h].numRows();for(var g=0;g<d;g++){var b=this.cell(g,h).innerHTML;var a=(b.match(f)!=null);if(a!=c){this.hideRow(g)}}this.sizeDivs();this.handleScroll()},showAllRows:function(){for(var a=0;a<this.pageSize;a++){this.showRow(a)}this.sizeDivs()},openPopup:function(d,e){while(d&&!Element.hasClassName(d,"ricoLG_cell")){d=d.parentNode}if(!d){return false}var f=RicoUtil.getParentByTagName(d,"td");var c=Math.floor(f.offsetLeft-this.scrollDiv.scrollLeft+f.offsetWidth/2);if(this.direction=="rtl"){if(c>this.width){c-=this.width}}else{if(c+this.width+this.options.margin>this.scrollDiv.clientWidth){c-=this.width}}e.divPopup.style.visibility="hidden";e.divPopup.style.display="block";var b=e.divPopup.offsetHeight;var a=Math.floor(d.offsetTop-this.scrollDiv.scrollTop+d.offsetHeight/2);if(a+b+e.options.margin>this.scrollDiv.clientHeight){a=Math.max(a-b,0)}e.openPopup(this.frzWi+c,this.hdrHt+a);e.divPopup.style.visibility="visible";return d}});if(Rico.Menu){Object.extend(Rico.Menu.prototype,{showSimpleMenu:function(b,c){Event.stop(b);this.hideFunc=c;if(this.div.childNodes.length==0){this.cancelmenu();return false}var a=Event.element(b);this.grid.openPopup(a,this);return a},showSimpleSubMenu:function(b,c){if(this.openSubMenu){this.hideSubMenu()}this.openSubMenu=c;this.openMenuAnchor=b;if(b.className=="ricoSubMenu"){b.className="ricoSubMenuOpen"}var e=parseInt(this.div.style.top,10);var d=parseInt(this.div.style.left,10);c.openPopup(d+b.offsetWidth,e+b.offsetTop);c.div.style.visibility="visible"}})}Rico.SimpleGridColumn=Class.create({initialize:function(a,d,c,b){Object.extend(this,new Rico.TableColumnBase());this.baseInit(a,d,c,b)},setUnfiltered:function(){this.filterRows=null},filterChange:function(a){var b=Event.element(a);if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()}else{this.filterRows=this.filterHash.get(b.value)}this.liveGrid.applyFilters()},filterKeypress:function(f){var a=Event.element(f);if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""}if(this.lastKeyFilter==a.value){return}var b=a.value;Rico.writeDebugMsg("filterKeypress: "+this.index+" "+b);this.lastKeyFilter=b;if(b){b=b.replace("\\","\\\\");b=b.replace("(","\\(").replace(")","\\)");b=b.replace(".","\\.");if(this.format.filterUI.indexOf("^")>0){b="^"+b}var d=new RegExp(b,"i");this.filterRows=[];var h=this.numRows();for(var c=0;c<h;c++){var g=RicoUtil.getInnerText(this.cell(c));if(g.match(d)){this.filterRows.push(c)}}}else{this.setUnfiltered()}this.liveGrid.applyFilters()}});Rico.includeLoaded("ricoSimpleGrid.js");if(typeof Rico=="undefined"){throw ("LiveGrid requires the Rico JavaScript framework")}if(typeof RicoUtil=="undefined"){throw ("LiveGrid requires the RicoUtil Library")}if(typeof RicoTranslate=="undefined"){throw ("LiveGrid requires the RicoTranslate Library")}if(typeof Rico.TableColumn=="undefined"){throw ("LiveGrid requires ricoGridCommon.js")}Rico.Buffer={};Rico.Buffer.Base=Class.create({initialize:function(b,a){this.clear();this.updateInProgress=false;this.lastOffset=0;this.rcvdRowCount=false;this.foundRowCount=false;this.totalRows=0;this.rowcntContent="";this.rcvdOffset=-1;this.options={fixedHdrRows:0,canFilter:true,isEncoded:true,acceptAttr:[]};Object.extend(this.options,a||{});if(b){this.loadRowsFromTable(b,this.options.fixedHdrRows)}else{this.clear()}},registerGrid:function(a){this.liveGrid=a},setTotalRows:function(a){if(typeof(a)!="number"){a=this.size}if(this.totalRows==a){return}this.totalRows=a;if(this.liveGrid){Rico.writeDebugMsg("setTotalRows, newTotalRows="+a);if(this.liveGrid.sizeTo=="data"){this.liveGrid.resizeWindow()}this.liveGrid.updateHeightDiv()}},loadRowsFromTable:function(h,g){var e=new Array();var a=h.getElementsByTagName("tr");for(var d=g||0;d<a.length;d++){var f=new Array();var c=a[d].getElementsByTagName("td");for(var b=0;b<c.length;b++){f[b]=c[b].innerHTML}e.push(f)}this.loadRows(e)},loadRowsFromArray:function(b){for(var c=0;c<b.length;c++){for(var a=0;a<b[c].length;a++){b[c][a]=b[c][a].toString()}}this.loadRows(b)},loadRows:function(a){this.baseRows=a;this.startPos=0;this.size=this.baseRows.length},dom2jstable:function(f){Rico.writeDebugMsg("dom2jstable: encoded="+this.options.isEncoded);var e=new Array();var a=f.getElementsByTagName("tr");for(var d=0;d<a.length;d++){var g=new Array();var c=a[d].getElementsByTagName("td");for(var b=0;b<c.length;b++){g[b]=RicoUtil.getContentAsString(c[b],this.options.isEncoded)}e.push(g)}return e},dom2jstableAttr:function(e,b){var h=this.options.acceptAttr;Rico.writeDebugMsg("dom2jstableAttr start, # attr="+h.length);var f=new Array();var g=e.getElementsByTagName("tr");for(var d=b||0;d<g.length;d++){var m=new Array();var l=g[d].getElementsByTagName("td");for(var c=0;c<l.length;c++){m[c]={};for(var a=0;a<h.length;a++){m[c]["_"+h[a]]=l[c].getAttribute(h[a])}if(Prototype.Browser.IE){m[c]._class=l[c].getAttribute("className")}}f.push(m)}Rico.writeDebugMsg("dom2jstableAttr end");return f},_blankRow:function(){var a=[];for(var b=0;b<this.liveGrid.columns.length;b++){a[b]=""}return a},deleteRows:function(b,a){this.baseRows.splice(b,typeof(a)=="number"?a:1);this.liveGrid.isPartialBlank=true;this.size=this.baseRows.length},insertRow:function(a){var b=this._blankRow();this.baseRows.splice(a,0,b);this.size=this.baseRows.length;this.liveGrid.isPartialBlank=true;if(this.startPos<0){this.startPos=0}return b},appendRows:function(b){var c=[];for(var a=0;a<b;a++){var d=this._blankRow();this.baseRows.push(d);c.push(d)}this.size=this.baseRows.length;this.liveGrid.isPartialBlank=true;if(this.startPos<0){this.startPos=0}return c},sortFunc:function(a){switch(a){case"number":return this._sortNumeric.bind(this);case"control":return this._sortControl.bind(this);default:return this._sortAlpha.bind(this)}},sortBuffer:function(b){if(!this.baseRows){this.delayedSortCol=b;return}this.liveGrid.showMsg(RicoTranslate.getPhraseById("sorting"));this.sortColumn=b;var a=this.liveGrid.columns[b];this.getValFunc=a._sortfunc;this.baseRows.sort(this.sortFunc(a.format.type));if(a.getSortDirection()=="DESC"){this.baseRows.reverse()}},_sortAlpha:function(d,c){var e=this.sortColumn<d.length?RicoUtil.getInnerText(d[this.sortColumn]):"";var f=this.sortColumn<c.length?RicoUtil.getInnerText(c[this.sortColumn]):"";if(e==f){return 0}if(e<f){return -1}return 1},_sortNumeric:function(d,c){var e=this.sortColumn<d.length?this.nan2zero(RicoUtil.getInnerText(d[this.sortColumn])):0;var f=this.sortColumn<c.length?this.nan2zero(RicoUtil.getInnerText(c[this.sortColumn])):0;return e-f},nan2zero:function(a){if(typeof(a)=="string"){a=parseFloat(a)}return isNaN(a)||typeof(a)=="undefined"?0:a},_sortControl:function(d,c){var e=this.sortColumn<d.length?RicoUtil.getInnerText(d[this.sortColumn]):"";var f=this.sortColumn<c.length?RicoUtil.getInnerText(c[this.sortColumn]):"";if(this.getValFunc){e=this.getValFunc(e);f=this.getValFunc(f)}if(e==f){return 0}if(e<f){return -1}return 1},clear:function(){this.baseRows=[];this.rows=[];this.startPos=-1;this.size=0;this.windowPos=0},isInRange:function(a){var b=Math.min(this.totalRows,a+this.liveGrid.pageSize);return(a>=this.startPos)&&(b<=this.endPos())},endPos:function(){return this.startPos+this.rows.length},fetch:function(a){Rico.writeDebugMsg("fetch "+this.liveGrid.tableId+": offset="+a);this.applyFilters();this.setTotalRows();this.rcvdRowCount=true;this.foundRowCount=true;if(a<0){a=0}this.liveGrid.refreshContents(a);return},exportAllRows:function(b,a){b(this.getRows(0,this.totalRows));a()},visibleRows:function(){return this.rows.slice(this.windowStart,this.windowEnd)},setWindow:function(b,a){this.windowStart=b-this.startPos;this.windowEnd=Math.min(this.windowStart+a,this.size);this.windowPos=b},isVisible:function(a){return a<this.rows.length&&a>=this.windowStart&&a<this.windowEnd},bufferRow:function(a){return this.windowStart+a},getWindowCell:function(c,b){var a=this.bufferRow(c);return this.isVisible(a)&&b<this.rows[a].length?this.rows[a][b]:null},getWindowAttr:function(c,b){var a=this.bufferRow(c);return this.attr&&this.isVisible(a)&&b<this.attr[a].length?this.attr[a][b]:null},getWindowValue:function(b,a){return this.getWindowCell(b,a)},setWindowValue:function(d,b,c){var a=this.bufferRow(d);if(a>=this.windowEnd){return false}return this.setValue(a,b,c)},getCell:function(b,a){return b<this.size?this.rows[b][a]:null},getValue:function(b,a){return this.getCell(b,a)},setValue:function(d,b,c,a){if(d>=this.size){return false}if(!this.rows[d][b]){this.rows[d][b]={}}this.rows[d][b]=c;if(typeof a=="string"){this.rows[d][b]._style=a}this.rows[d][b].modified=true;return true},getRows:function(f,d){var e=f-this.startPos;var a=Math.min(e+d,this.size);var c=new Array();for(var b=e;b<a;b++){c.push(this.rows[b])}return c},applyFilters:function(){var g=[],k=[];var a,h,d,e,f,b;var j=this.liveGrid.columns;for(d=0,b=0;d<j.length;d++){h=j[d];if(h.filterType==Rico.TableColumn.UNFILTERED){continue}b++;if(h.filterOp=="LIKE"){k[d]=new RegExp(h.filterValues[0],"i")}}Rico.writeDebugMsg("applyFilters: # of filters="+b);if(b==0){this.rows=this.baseRows}else{for(a=0;a<this.baseRows.length;a++){f=true;for(d=0;d<j.length&&f;d++){h=j[d];if(h.filterType==Rico.TableColumn.UNFILTERED){continue}switch(h.filterOp){case"LIKE":f=k[d].test(this.baseRows[a][d]);break;case"EQ":f=this.baseRows[a][d]==h.filterValues[0];break;case"NE":for(e=0;e<h.filterValues.length&&f;e++){f=this.baseRows[a][d]!=h.filterValues[e]}break;case"LE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])<=this.nan2zero(h.filterValues[0])}else{f=this.baseRows[a][d]<=h.filterValues[0]}break;case"GE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])>=this.nan2zero(h.filterValues[0])}else{f=this.baseRows[a][d]>=h.filterValues[0]}break;case"NULL":f=this.baseRows[a][d]=="";break;case"NOTNULL":f=this.baseRows[a][d]!="";break}}if(f){g.push(this.baseRows[a])}}this.rows=g}this.rowcntContent=this.size=this.rows.length}});Rico.LiveGrid=Class.create({initialize:function(d,b,c){Object.extend(this,new Rico.GridCommon);Object.extend(this,new Rico.LiveGridMethods);this.baseInit();this.tableId=d;this.buffer=b;Rico.setDebugArea(d+"_debugmsgs");Object.extend(this.options,{visibleRows:-1,frozenColumns:0,offset:0,prefetchBuffer:true,minPageRows:2,maxPageRows:50,canSortDefault:true,canFilterDefault:b.options.canFilter,canHideDefault:true,highlightElem:"none",highlightSection:3,highlightMethod:"class",highlightClass:"ricoLG_selection",maxPrint:1000,headingSort:"link",hdrIconsFirst:true,sortAscendImg:"sort_asc.gif",sortDescendImg:"sort_desc.gif",filterImg:"filtercol.gif"});this.options.sortHandler=this.sortHandler.bind(this);this.options.filterHandler=this.filterHandler.bind(this);this.options.onRefreshComplete=this.bookmarkHandler.bind(this);this.options.rowOverHandler=this.rowMouseOver.bindAsEventListener(this);this.options.mouseDownHandler=this.selectMouseDown.bindAsEventListener(this);this.options.mouseOverHandler=this.selectMouseOver.bindAsEventListener(this);this.options.mouseUpHandler=this.selectMouseUp.bindAsEventListener(this);Object.extend(this.options,c||{});switch(typeof this.options.visibleRows){case"string":this.sizeTo=this.options.visibleRows;switch(this.options.visibleRows){case"data":this.options.visibleRows=-2;break;case"body":this.options.visibleRows=-3;break;case"parent":this.options.visibleRows=-4;break;default:this.options.visibleRows=-1;break}break;case"number":switch(this.options.visibleRows){case -1:this.sizeTo="window";break;case -2:this.sizeTo="data";break;case -3:this.sizeTo="body";break;case -4:this.sizeTo="parent";break;default:this.sizeTo="fixed";break}break;default:this.sizeTo="window";this.options.visibleRows=-1;break}this.highlightEnabled=this.options.highlightSection>0;this.pageSize=0;this.createTables();if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');return}this.createColumnArray("TableColumn");if(this.options.headingSort=="hover"){this.createHoverSet()}this.bookmark=$(this.tableId+"_bookmark");this.sizeDivs();var a=this.buffer.options.canFilter?this.options.FilterLocation:false;if(typeof(a)=="number"&&a<0){a=this.addHeadingRow()}this.createDataCells(this.options.visibleRows);if(this.pageSize==0){return}this.buffer.registerGrid(this);if(this.buffer.setBufferSize){this.buffer.setBufferSize(this.pageSize)}this.scrollTimeout=null;this.lastScrollPos=0;this.attachMenuEvents();new Image().src=Rico.imgDir+this.options.filterImg;new Image().src=Rico.imgDir+this.options.sortAscendImg;new Image().src=Rico.imgDir+this.options.sortDescendImg;Rico.writeDebugMsg("images preloaded");this.setSortUI(this.options.sortCol,this.options.sortDir);this.setImages();if(this.listInvisible().length==this.columns.length){this.columns[0].showColumn()}this.sizeDivs();this.scrollDiv.style.display="";if(this.buffer.totalRows>0){this.updateHeightDiv()}if(this.options.prefetchBuffer){if(this.bookmark){this.bookmark.innerHTML=RicoTranslate.getPhraseById("bookmarkLoading")}if(this.options.canFilterDefault&&this.options.getQueryParms){this.checkForFilterParms()}this.buffer.fetch(this.options.offset)}if(typeof(a)=="number"){this.createFilters(a)}this.scrollEventFunc=this.handleScroll.bindAsEventListener(this);this.wheelEventFunc=this.handleWheel.bindAsEventListener(this);this.wheelEvent=(Prototype.Browser.IE||Prototype.Browser.Opera||Prototype.Browser.WebKit)?"mousewheel":"DOMMouseScroll";if(this.options.offset&&this.options.offset<this.buffer.totalRows){setTimeout(this.scrollToRow.bind(this,this.options.offset),50)}this.pluginScroll();this.setHorizontalScroll();if(this.options.windowResize){setTimeout(this.pluginWindowResize.bind(this),100)}}});Rico.LiveGridMethods=function(){};Rico.LiveGridMethods.prototype={createHoverSet:function(){var a=[];for(var b=0;b<this.headerColCnt;b++){if(this.columns[b].sortable){a.push(this.columns[b].hdrCellDiv)}}this.hoverSet=new Rico.HoverSet(a)},checkForFilterParms:function(){var b=window.location.search;if(b.charAt(0)=="?"){b=b.substring(1)}var c=b.split("&");for(var a=0;a<c.length;a++){if(c[a].match(/^f\[\d+\]/)){this.buffer.options.requestParameters.push(c[a])}}},setDetailFilter:function(a,d){var b=this.columns[a];b.format.ColData=d;b.setSystemFilter("EQ",d)},createTables:function(){var f,g,b;var e=$(this.tableId)||$(this.tableId+"_outerDiv");if(!e){return false}if(e.tagName.toLowerCase()=="table"){var a=e.getElementsByTagName("thead");if(a.length==1){Rico.writeDebugMsg("createTables: using thead section, id="+this.tableId);if(this.options.PanelNamesOnTabHdr&&this.options.panels){var d=a[0].insertRow(0);this.insertPanelNames(d,0,this.options.frozenColumns,"ricoFrozen");this.insertPanelNames(d,this.options.frozenColumns,this.options.columnSpecs.length)}g=a[0].rows}else{Rico.writeDebugMsg("createTables: using tbody section, id="+this.tableId);g=new Array(e.rows[0])}f=e}else{if(this.options.columnSpecs.length>0){if(!e.id.match(/_outerDiv$/)){f=e}Rico.writeDebugMsg("createTables: inserting at "+e.tagName+", id="+this.tableId)}else{alert("ERROR!\n\nUnable to initialize '"+this.tableId+"'\n\nLiveGrid terminated");return false}}this.createDivs();this.scrollTabs=this.createDiv("scrollTabs",this.innerDiv);this.shadowDiv=this.createDiv("shadow",this.scrollDiv);this.shadowDiv.style.direction="ltr";this.scrollDiv.style.display="none";this.scrollDiv.scrollTop=0;if(this.options.highlightMethod!="class"){this.highlightDiv=[];switch(this.options.highlightElem){case"menuRow":case"cursorRow":this.highlightDiv[0]=this.createDiv("highlight",this.outerDiv);this.highlightDiv[0].style.display="none";break;case"menuCell":case"cursorCell":for(b=0;b<2;b++){this.highlightDiv[b]=this.createDiv("highlight",b==0?this.frozenTabs:this.scrollTabs);this.highlightDiv[b].style.display="none";this.highlightDiv[b].id+=b}break;case"selection":var h=this.options.highlightSection==1?this.frozenTabs:this.scrollTabs;for(b=0;b<4;b++){this.highlightDiv[b]=this.createDiv("highlight",h);this.highlightDiv[b].style.display="none";this.highlightDiv[b].style.overflow="hidden";this.highlightDiv[b].id+=b;this.highlightDiv[b].style[b%2==0?"height":"width"]="0px"}break}}for(b=0;b<2;b++){this.tabs[b]=document.createElement("table");this.tabs[b].className="ricoLG_table";this.tabs[b].border=0;this.tabs[b].cellPadding=0;this.tabs[b].cellSpacing=0;this.tabs[b].id=this.tableId+"_tab"+b;this.thead[b]=this.tabs[b].createTHead();this.thead[b].className="ricoLG_top";if(this.tabs[b].tBodies.length==0){this.tbody[b]=this.tabs[b].appendChild(document.createElement("tbody"))}else{this.tbody[b]=this.tabs[b].tBodies[0]}this.tbody[b].className="ricoLG_bottom";this.tbody[b].insertRow(-1)}this.frozenTabs.appendChild(this.tabs[0]);this.scrollTabs.appendChild(this.tabs[1]);if(f){f.parentNode.insertBefore(this.outerDiv,f)}if(g){this.headerColCnt=this.getColumnInfo(g);this.loadHdrSrc(g)}else{this.createHdr(0,0,this.options.frozenColumns);this.createHdr(1,this.options.frozenColumns,this.options.columnSpecs.length);if(this.options.PanelNamesOnTabHdr&&this.options.panels){this.insertPanelNames(this.thead[0].insertRow(0),0,this.options.frozenColumns);this.insertPanelNames(this.thead[1].insertRow(0),this.options.frozenColumns,this.options.columnSpecs.length)}for(b=0;b<2;b++){this.headerColCnt=this.getColumnInfo(this.thead[b].rows)}}for(var j=0;j<this.headerColCnt;j++){this.tbody[j<this.options.frozenColumns?0:1].rows[0].insertCell(-1)}if(f){e.parentNode.removeChild(e)}Rico.writeDebugMsg("createTables end");return true},createDataCells:function(d){if(d<0){for(var a=0;a<this.options.minPageRows;a++){this.appendBlankRow()}this.sizeDivs();this.autoAppendRows(this.remainingHt())}else{for(var c=0;c<d;c++){this.appendBlankRow()}}var b=this.options.highlightSection;if(b&1){this.attachHighlightEvents(this.tbody[0])}if(b&2){this.attachHighlightEvents(this.tbody[1])}},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a},createFilters:function(b){for(var i=0;i<this.headerColCnt;i++){var e=this.columns[i];var f=e.format;if(typeof f.filterUI!="string"){continue}var m=this.hdrCells[b][i].cell;var k,d=this.filterId(i);var j=m.getElementsByTagName("div");var g=Element.getStyle(this.cell(0,i),"textAlign");Element.setStyle(j[1],{textAlign:g});switch(f.filterUI.charAt(0)){case"t":k=RicoUtil.createFormField(j[1],"input","text",d,d);var o=f.filterUI.match(/\d+/);k.maxLength=f.Length||50;k.size=o?parseInt(o,10):10;var h=document.createElement("img");h.style.paddingLeft="4px";h.style.cursor="pointer";h.align="top";h.src=Rico.imgDir+"delete.gif";h.alt=RicoTranslate.getPhraseById("clear");j[1].appendChild(h);Event.observe(h,"click",e.filterClear.bindAsEventListener(e,k),false);if(e.filterType==Rico.TableColumn.USERFILTER&&e.filterOp=="LIKE"){var l=e.filterValues[0];if(l.charAt(0)=="*"){l=l.substr(1)}if(l.slice(-1)=="*"){l=l.slice(0,-1)}k.value=l;e.lastKeyFilter=l}Event.observe(k,"keyup",e.filterKeypress.bindAsEventListener(e),false);break;case"s":k=RicoUtil.createFormField(j[1],"select",null,d);RicoUtil.addSelectOption(k,this.options.FilterAllToken,RicoTranslate.getPhraseById("filterAll"));var n={};Object.extend(n,this.buffer.ajaxOptions);var a=typeof(f.filterCol)=="number"?f.filterCol:i;n.parameters="id="+this.tableId+"&distinct="+a;n.onComplete=this.filterValuesUpdate.bind(this,i);new Ajax.Request(this.buffer.dataSource,n);break;case"c":if(typeof e._createFilters=="function"){e._createFilters(j[1],d)}break}}this.initFilterImage(b)},filterValuesUpdate:function(a,e){var d=e.responseXML.getElementsByTagName("ajax-response");Rico.writeDebugMsg("filterValuesUpdate: "+e.status);if(d==null||d.length!=1){return false}d=d[0];var k=d.getElementsByTagName("error");if(k.length>0){Rico.writeDebugMsg("Data provider returned an error:\n"+RicoUtil.getContentAsString(k[0],this.buffer.isEncoded));alert(RicoTranslate.getPhraseById("requestError",RicoUtil.getContentAsString(k[0],this.buffer.isEncoded)));return false}d=d.getElementsByTagName("response")[0];var j=d.getElementsByTagName("rows")[0];var c=this.columns[parseInt(a,10)];var n=this.buffer.dom2jstable(j);var h,g,b,m,l=$(this.filterId(a));if(c.filterType==Rico.TableColumn.USERFILTER&&c.filterOp=="EQ"){m=c.filterValues[0]}Rico.writeDebugMsg("filterValuesUpdate: col="+a+" rows="+n.length);for(var f=0;f<n.length;f++){if(n[f].length>0){h=g=n[f][0];if(h.match(/<span\s+class=(['"]?)ricolookup\1>(.*)<\/span>/i)){g=RegExp.leftContext}b=RicoUtil.addSelectOption(l,h,g||RicoTranslate.getPhraseById("filterBlank"));if(c.filterType==Rico.TableColumn.USERFILTER&&h==m){b.selected=true}}}Event.observe(l,"change",c.filterChange.bindAsEventListener(c),false);return true},unplugHighlightEvents:function(){var a=this.options.highlightSection;if(a&1){this.detachHighlightEvents(this.tbody[0])}if(a&2){this.detachHighlightEvents(this.tbody[1])}},insertPanelNames:function(a,b,d,f){Rico.writeDebugMsg("insertPanelNames: start="+b+" limit="+d);a.className="ricoLG_hdg";var i=-1,j,e=null,g=0;for(var h=b;h<d;h++){if(i==this.options.columnSpecs[h].panelIdx){j++}else{if(e){e.colSpan=j}e=a.insertCell(-1);if(f){e.className=f}j=1;i=this.options.columnSpecs[h].panelIdx;e.innerHTML=this.options.panels[i]}}if(e){e.colSpan=j}},createHdr:function(d,g,b){Rico.writeDebugMsg("createHdr: i="+d+" start="+g+" limit="+b);var a=this.thead[d].insertRow(-1);a.id=this.tableId+"_tab"+d+"h_main";a.className="ricoLG_hdg";for(var f=g;f<b;f++){var e=a.insertCell(-1);e.innerHTML=this.options.columnSpecs[f].Hdg}},loadHdrSrc:function(g){var b,d,j,e,f,a;Rico.writeDebugMsg("loadHdrSrc start");for(b=0;b<2;b++){for(e=0;e<g.length;e++){f=this.thead[b].insertRow(-1);f.className="ricoLG_hdg "+this.tableId+"_hdg"+e}}if(g.length==1){a=g[0].cells;for(j=0;a.length>0;j++){this.thead[j<this.options.frozenColumns?0:1].rows[0].appendChild(a[0])}}else{for(e=0;e<g.length;e++){a=g[e].cells;for(j=0,d=0;a.length>0;j++){if(a[0].className=="ricoFrozen"){if(e==this.headerRowIdx){this.options.frozenColumns=j+1}}else{d=1}this.thead[d].rows[e].appendChild(a[0])}}}Rico.writeDebugMsg("loadHdrSrc end")},sizeDivs:function(){Rico.writeDebugMsg("sizeDivs: "+this.tableId);this.unhighlight();this.baseSizeDivs();var d=this.firstVisible();if(this.pageSize==0||d<0){return}var c=this.columns[d].dataColDiv.offsetHeight;this.rowHeight=Math.round(c/this.pageSize);var b=this.dataHt;if(this.scrWi>0||Prototype.Browser.IE||Prototype.Browser.WebKit){b+=this.options.scrollBarWidth}this.scrollDiv.style.height=b+"px";this.innerDiv.style.width=(this.scrWi-this.options.scrollBarWidth+1)+"px";this.resizeDiv.style.height=this.frozenTabs.style.height=this.innerDiv.style.height=(this.hdrHt+this.dataHt+1)+"px";Rico.writeDebugMsg("sizeDivs scrHt="+b+" innerHt="+this.innerDiv.style.height+" rowHt="+this.rowHeight+" pageSize="+this.pageSize);var a=(this.scrWi-this.scrTabWi<this.options.scrollBarWidth)?2:0;this.shadowDiv.style.width=(this.scrTabWi+a)+"px";this.outerDiv.style.height=(this.hdrHt+b)+"px";this.setHorizontalScroll()},setHorizontalScroll:function(){var a=this.scrollDiv.scrollLeft;this.scrollTabs.style.left=(-a)+"px"},remainingHt:function(){var e;var g=RicoUtil.windowHeight();var d=Prototype.Browser.IE?15:10;if(!Prototype.Browser.IE&&window.frameElement&&window.frameElement.scrolling=="yes"&&this.sizeTo!="parent"){d+=this.options.scrollBarWidth}switch(this.sizeTo){case"window":case"data":var f=Position.page(this.outerDiv);e=Math.max(this.tabs[0].offsetHeight,this.tabs[1].offsetHeight);Rico.writeDebugMsg("remainingHt, winHt="+g+" tabHt="+e+" gridY="+f[1]);return g-f[1]-e-this.options.scrollBarWidth-d;case"parent":var h=this.offsetFromParent(this.outerDiv);e=Math.max(this.tabs[0].offsetHeight,this.tabs[1].offsetHeight);if(Prototype.Browser.IE){Element.hide(this.outerDiv)}var b=this.outerDiv.parentNode.offsetHeight;if(Prototype.Browser.IE){Element.show(this.outerDiv)}Rico.writeDebugMsg("remainingHt, parentHt="+b+" gridY="+h+" winHt="+g+" tabHt="+e);return b-e-h-this.options.scrollBarWidth;case"body":var a=Prototype.Browser.IE?document.body.scrollHeight:document.body.offsetHeight;var c=g-a-d;if(!Prototype.Browser.WebKit){c-=this.options.scrollBarWidth}Rico.writeDebugMsg("remainingHt, winHt="+g+" pageHt="+a+" remHt="+c);return c;default:e=Math.max(this.tabs[0].offsetHeight,this.tabs[1].offsetHeight);Rico.writeDebugMsg("remainingHt, winHt="+g+" tabHt="+e);if(this.sizeTo.slice(-1)=="%"){g*=parseFloat(this.sizeTo)/100}else{if(this.sizeTo.slice(-2)=="px"){g=parseInt(this.sizeTo,10)}}return g-e-this.options.scrollBarWidth-d}},offsetFromParent:function(b){var a=0;var c=b.parentNode;do{a+=b.offsetTop||0;b=b.offsetParent;if(!b||b==null){break}var d=Element.getStyle(b,"position");if(b.tagName=="BODY"||b.tagName=="HTML"||d=="absolute"){return a-c.offsetTop}}while(b!=c);return a},adjustPageSize:function(){var a=this.remainingHt();Rico.writeDebugMsg("adjustPageSize remHt="+a+" lastRow="+this.lastRowPos);if(a>this.rowHeight){this.autoAppendRows(a)}else{if(a<0||this.sizeTo=="data"){this.autoRemoveRows(-a)}}},pluginWindowResize:function(){this.resizeWindowHandler=this.resizeWindow.bindAsEventListener(this);Event.observe(window,"resize",this.resizeWindowHandler,false)},unplugWindowResize:function(){if(!this.resizeWindowHandler){return}Event.stopObserving(window,"resize",this.resizeWindowHandler,false);this.resizeWindowHandler=null},resizeWindow:function(){Rico.writeDebugMsg("resizeWindow "+this.tableId+" lastRow="+this.lastRowPos);if(this.resizeState=="finish"){Rico.writeDebugMsg("resizeWindow postponed");this.resizeState="resize";return}if(!this.sizeTo||this.sizeTo=="fixed"){this.sizeDivs();return}if(this.sizeTo=="parent"&&Element.getStyle(this.outerDiv.parentNode,"display")=="none"){return}var b=this.pageSize;this.adjustPageSize();if(this.pageSize>b&&this.buffer.totalRows>0){this.isPartialBlank=true;var a=this.adjustRow(this.lastRowPos);this.buffer.fetch(a)}else{if(this.pageSize<b){if(this.options.onRefreshComplete){this.options.onRefreshComplete(this.contentStartPos,this.contentStartPos+this.pageSize-1)}}}this.resizeState="finish";setTimeout(this.finishResize.bind(this),20);Rico.writeDebugMsg("resizeWindow "+this.tableId+" complete. old size="+b+" new size="+this.pageSize)},finishResize:function(){this.sizeDivs();this.updateHeightDiv();if(this.resizeState=="resize"){this.resizeWindow()}else{this.resizeState=""}},topOfLastPage:function(){return Math.max(this.buffer.totalRows-this.pageSize,0)},updateHeightDiv:function(){var b=this.topOfLastPage();var a=this.scrollDiv.clientHeight+this.rowHeight*b;Rico.writeDebugMsg("updateHeightDiv, ht="+a+" scrollDiv.clientHeight="+this.scrollDiv.clientHeight+" rowsNotDisplayed="+b);this.shadowDiv.style.height=a+"px"},autoRemoveRows:function(a){if(!this.rowHeight){return}var c=Math.ceil(a/this.rowHeight);if(this.sizeTo=="data"){c=Math.max(c,this.pageSize-this.buffer.totalRows)}Rico.writeDebugMsg("autoRemoveRows overage="+a+" removeCnt="+c);for(var b=0;b<c;b++){this.removeRow()}},removeRow:function(){if(this.pageSize<=this.options.minPageRows){return}this.pageSize--;for(var b=0;b<this.headerColCnt;b++){var a=this.columns[b].cell(this.pageSize);this.columns[b].dataColDiv.removeChild(a)}},autoAppendRows:function(a){if(!this.rowHeight){return}var c=Math.floor(a/this.rowHeight);Rico.writeDebugMsg("autoAppendRows overage="+a+" cnt="+c+" rowHt="+this.rowHeight);for(var b=0;b<c;b++){if(this.sizeTo=="data"&&this.pageSize>=this.buffer.totalRows){break}this.appendBlankRow()}},appendBlankRow:function(){if(this.pageSize>=this.options.maxPageRows){return}Rico.writeDebugMsg("appendBlankRow #"+this.pageSize);var a=this.defaultRowClass(this.pageSize);for(var d=0;d<this.headerColCnt;d++){var b=document.createElement("div");b.className="ricoLG_cell "+a;b.id=this.tableId+"_"+this.pageSize+"_"+d;this.columns[d].dataColDiv.appendChild(b);b.innerHTML="&nbsp;";if(this.columns[d].format.canDrag&&dndMgr){dndMgr.registerDraggable(new Rico.LiveGridDraggable(this,this.pageSize,d))}if(this.columns[d]._create){this.columns[d]._create(b,this.pageSize)}}this.pageSize++},defaultRowClass:function(a){return(a%2==0)?"ricoLG_evenRow":"ricoLG_oddRow"},handleMenuClick:function(d){if(!this.menu){return}this.cancelMenu();this.unhighlight();var b;var a=Event.element(d);if(a.className=="ricoLG_highlightDiv"){b=this.highlightIdx}else{a=RicoUtil.getParentByTagName(a,"div","ricoLG_cell");if(!a){return}b=this.winCellIndex(a);if((this.options.highlightSection&(b.tabIdx+1))==0){return}}this.highlight(b);this.highlightEnabled=false;if(this.hideScroll){this.scrollDiv.style.overflow="hidden"}this.menuIdx=b;if(!this.menu.div){this.menu.createDiv()}this.menu.liveGrid=this;if(this.menu.buildGridMenu){var c=this.menu.buildGridMenu(b.row,b.column,b.tabIdx);if(!c){return}}if(this.options.highlightElem=="selection"&&!this.isSelected(b.cell)){this.selectCell(b.cell)}this.menu.showmenu(d,this.closeMenu.bind(this))},closeMenu:function(){if(!this.menuIdx){return}if(this.hideScroll){this.scrollDiv.style.overflow=""}this.unhighlight();this.highlightEnabled=true;this.menuIdx=null},winCellIndex:function(b){var e=b.id.split(/_/);var d=e.length;var f=parseInt(e[d-2],10);var g=parseInt(e[d-1],10);return{row:f,column:g,tabIdx:this.columns[g].tabIdx,cell:b}},datasetIndex:function(b){var a=this.winCellIndex(b);a.row+=this.buffer.windowPos;a.onBlankRow=(a.row>=this.buffer.endPos());return a},attachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Event.observe(a,"mousedown",this.options.mouseDownHandler,false);a.ondrag=function(){return false};a.onselectstart=function(){return false};break;case"cursorRow":case"cursorCell":Event.observe(a,"mouseover",this.options.rowOverHandler,false);break}},detachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Event.stopObserving(a,"mousedown",this.options.mouseDownHandler,false);a.ondrag=null;a.onselectstart=null;break;case"cursorRow":case"cursorCell":Event.stopObserving(a,"mouseover",this.options.rowOverHandler,false);break}},getVisibleSelection:function(){var d=[];if(this.SelectIdxStart&&this.SelectIdxEnd){var b=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowStart);var a=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowEnd-1);var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);var f=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);for(var h=b;h<=a;h++){for(var j=g;j<=f;j++){d.push({row:h-this.buffer.windowStart,column:j})}}}if(this.SelectCtrl){for(var e=0;e<this.SelectCtrl.length;e++){if(this.SelectCtrl[e].row>=this.buffer.windowStart&&this.SelectCtrl[e].row<this.buffer.windowEnd){d.push({row:this.SelectCtrl[e].row-this.buffer.windowStart,column:this.SelectCtrl[e].column})}}}return d},updateSelectOutline:function(){if(!this.SelectIdxStart||!this.SelectIdxEnd){return}var d=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);var c=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);if(d>c){this.HideSelection();return}var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);var e=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);var h=this.columns[g].cell(d-this.buffer.windowStart).offsetTop;var j=this.columns[g].cell(c-this.buffer.windowStart);var b=j.offsetTop+j.offsetHeight;var l=this.columns[g].dataCell.offsetLeft;var k=this.columns[e].dataCell.offsetLeft;var a=k+this.columns[e].dataCell.offsetWidth;this.highlightDiv[0].style.top=this.highlightDiv[3].style.top=this.highlightDiv[1].style.top=(this.hdrHt+h-1)+"px";this.highlightDiv[2].style.top=(this.hdrHt+b-1)+"px";this.highlightDiv[3].style.left=(l-2)+"px";this.highlightDiv[0].style.left=this.highlightDiv[2].style.left=(l-1)+"px";this.highlightDiv[1].style.left=(a-1)+"px";this.highlightDiv[0].style.width=this.highlightDiv[2].style.width=(a-l-1)+"px";this.highlightDiv[1].style.height=this.highlightDiv[3].style.height=(b-h)+"px";for(var f=0;f<4;f++){this.highlightDiv[f].style.display=""}},HideSelection:function(){var b;if(this.options.highlightMethod!="class"){for(b=0;b<this.highlightDiv.length;b++){this.highlightDiv[b].style.display="none"}}if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();Rico.writeDebugMsg("HideSelection "+a.length);for(b=0;b<a.length;b++){this.unhighlightCell(this.columns[a[b].column].cell(a[b].row))}}},ShowSelection:function(){if(this.options.highlightMethod!="class"){this.updateSelectOutline()}if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();for(var b=0;b<a.length;b++){this.highlightCell(this.columns[a[b].column].cell(a[b].row))}}},ClearSelection:function(){Rico.writeDebugMsg("ClearSelection");this.HideSelection();this.SelectIdxStart=null;this.SelectIdxEnd=null;this.SelectCtrl=[]},selectCell:function(a){this.ClearSelection();this.SelectIdxStart=this.SelectIdxEnd=this.datasetIndex(a);this.ShowSelection()},AdjustSelection:function(a){var b=this.datasetIndex(a);if(this.SelectIdxStart.tabIdx!=b.tabIdx){return}this.HideSelection();this.SelectIdxEnd=b;this.ShowSelection()},RefreshSelection:function(){var a=this.getVisibleSelection();for(var b=0;b<a.length;b++){this.columns[a[b].column].displayValue(a[b].row)}},FillSelection:function(b,f){if(this.SelectIdxStart&&this.SelectIdxEnd){var e=Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row);var d=Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row);var j=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);var g=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);for(var a=e;a<=d;a++){for(var k=j;k<=g;k++){this.buffer.setValue(a,k,b,f)}}}if(this.SelectCtrl){for(var h=0;h<this.SelectCtrl.length;h++){this.buffer.setValue(this.SelectCtrl[h].row,this.SelectCtrl[h].column,b,f)}}this.RefreshSelection()},selectMouseDown:function(d){if(this.highlightEnabled==false){return true}this.cancelMenu();var a=Event.element(d);if(!Event.isLeftClick(d)){return true}a=RicoUtil.getParentByTagName(a,"div","ricoLG_cell");if(!a){return true}Event.stop(d);var c=this.datasetIndex(a);if(c.onBlankRow){return true}Rico.writeDebugMsg("selectMouseDown @"+c.row+","+c.column);if(d.ctrlKey){if(!this.SelectIdxStart||this.options.highlightMethod!="class"){return true}if(!this.isSelected(a)){this.highlightCell(a);this.SelectCtrl.push(this.datasetIndex(a))}else{for(var b=0;b<this.SelectCtrl.length;b++){if(this.SelectCtrl[b].row==c.row&&this.SelectCtrl[b].column==c.column){this.unhighlightCell(a);this.SelectCtrl.splice(b,1);break}}}}else{if(d.shiftKey){if(!this.SelectIdxStart){return true}this.AdjustSelection(a)}else{this.selectCell(a);this.pluginSelect()}}return false},pluginSelect:function(){if(this.selectPluggedIn){return}var a=this.tbody[this.SelectIdxStart.tabIdx];Event.observe(a,"mouseover",this.options.mouseOverHandler,false);Event.observe(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);this.selectPluggedIn=true},unplugSelect:function(){if(!this.selectPluggedIn){return}var a=this.tbody[this.SelectIdxStart.tabIdx];Event.stopObserving(a,"mouseover",this.options.mouseOverHandler,false);Event.stopObserving(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);this.selectPluggedIn=false},selectMouseUp:function(b){this.unplugSelect();var a=Event.element(b);a=RicoUtil.getParentByTagName(a,"div","ricoLG_cell");if(!a){return}if(this.SelectIdxStart&&this.SelectIdxEnd){this.AdjustSelection(a)}else{this.ClearSelection()}},selectMouseOver:function(b){var a=Event.element(b);a=RicoUtil.getParentByTagName(a,"div","ricoLG_cell");if(!a){return}this.AdjustSelection(a);Event.stop(b)},isSelected:function(a){if(this.options.highlightMethod!="outline"){return Element.hasClassName(a,this.options.highlightClass)}if(!this.SelectIdxStart||!this.SelectIdxEnd){return false}var c=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);var b=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);if(c>b){return false}var e=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);var d=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);var f=this.datasetIndex(a);return(c<=f.row&&f.row<=b&&e<=f.column&&f.column<=d)},highlightCell:function(a){Element.addClassName(a,this.options.highlightClass)},unhighlightCell:function(a){if(a==null){return}Element.removeClassName(a,this.options.highlightClass)},selectRow:function(a){for(var b=0;b<this.columns.length;b++){this.highlightCell(this.columns[b].cell(a))}},unselectRow:function(a){for(var b=0;b<this.columns.length;b++){this.unhighlightCell(this.columns[b].cell(a))}},rowMouseOver:function(c){if(!this.highlightEnabled){return}var a=Event.element(c);a=RicoUtil.getParentByTagName(a,"div","ricoLG_cell");if(!a){return}var b=this.winCellIndex(a);if((this.options.highlightSection&(b.tabIdx+1))==0){return}this.highlight(b)},highlight:function(a){if(this.options.highlightMethod!="outline"){this.cursorSetClass(a)}if(this.options.highlightMethod!="class"){this.cursorOutline(a)}this.highlightIdx=a},cursorSetClass:function(e){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)}this.highlightCell(e.cell);break;case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)}var b=this.options.highlightSection&1;var a=this.options.highlightSection&2;var f=b?0:this.options.frozenColumns;var d=a?this.columns.length:this.options.frozenColumns;for(var g=f;g<d;g++){this.highlightCell(this.columns[g].cell(e.row))}break;default:return}},cursorOutline:function(c){var d;switch(this.options.highlightElem){case"menuCell":case"cursorCell":d=this.highlightDiv[c.tabIdx];d.style.left=(this.columns[c.column].dataCell.offsetLeft-1)+"px";d.style.width=this.columns[c.column].colWidth;this.highlightDiv[1-c.tabIdx].style.display="none";break;case"menuRow":case"cursorRow":d=this.highlightDiv[0];var b=this.options.highlightSection&1;var a=this.options.highlightSection&2;d.style.left=b?"0px":this.frozenTabs.style.width;d.style.width=((b?this.frozenTabs.offsetWidth:0)+(a?this.innerDiv.offsetWidth:0)-4)+"px";break;default:return}d.style.top=(this.hdrHt+c.row*this.rowHeight-1)+"px";d.style.height=(this.rowHeight-1)+"px";d.style.display=""},unhighlight:function(){switch(this.options.highlightElem){case"menuCell":this.highlightIdx=this.menuIdx;case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)}if(!this.highlightDiv){return}for(var a=0;a<2;a++){this.highlightDiv[a].style.display="none"}break;case"menuRow":this.highlightIdx=this.menuIdx;case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)}if(this.highlightDiv){this.highlightDiv[0].style.display="none"}break}},resetContents:function(a){Rico.writeDebugMsg("resetContents("+a+")");this.ClearSelection();this.buffer.clear();this.clearRows();if(typeof a=="undefined"||a==true){this.buffer.setTotalRows(0)}else{this.scrollToRow(0)}this.clearBookmark()},setImages:function(){for(var a=0;a<this.columns.length;a++){this.columns[a].setImage()}},findSortedColumn:function(){for(var a=0;a<this.columns.length;a++){if(this.columns[a].isSorted()){return a}}return -1},findColumnName:function(a){for(var b=0;b<this.columns.length;b++){if(this.columns[b].fieldName==a){return b}}return -1},setSortUI:function(b,c){Rico.writeDebugMsg("setSortUI: "+b+" "+c);var a=this.findSortedColumn();if(a>=0){c=this.columns[a].getSortDirection()}else{if(typeof c!="string"){c=Rico.TableColumn.SORT_ASC}else{c=c.toUpperCase();if(c!=Rico.TableColumn.SORT_DESC){c=Rico.TableColumn.SORT_ASC}}switch(typeof b){case"string":a=this.findColumnName(b);break;case"number":a=b;break}}if(typeof(a)!="number"||a<0){return}this.clearSort();this.columns[a].setSorted(c);this.buffer.sortBuffer(a)},clearSort:function(){for(var a=0;a<this.columns.length;a++){this.columns[a].setUnsorted()}},clearFilters:function(){for(var a=0;a<this.columns.length;a++){this.columns[a].setUnfiltered(true)}if(this.options.filterHandler){this.options.filterHandler()}},filterCount:function(){for(var a=0,b=0;a<this.columns.length;a++){if(this.columns[a].isFiltered()){b++}}return b},sortHandler:function(){this.cancelMenu();this.ClearSelection();this.setImages();var a=this.findSortedColumn();if(a<0){return}Rico.writeDebugMsg("sortHandler: sorting column "+a);this.buffer.sortBuffer(a);this.clearRows();this.scrollDiv.scrollTop=0;this.buffer.fetch(0)},filterHandler:function(){Rico.writeDebugMsg("filterHandler");this.cancelMenu();if(this.buffer.processingRequest){this.queueFilter=true;return}this.unplugScroll();this.ClearSelection();this.setImages();this.clearBookmark();this.clearRows();this.buffer.fetch(-1);setTimeout(this.pluginScroll.bind(this),1)},clearBookmark:function(){if(this.bookmark){this.bookmark.innerHTML="&nbsp;"}},bookmarkHandler:function(a,d){var b;if(isNaN(a)||!this.bookmark){return}var c=this.buffer.totalRows;if(c<d){d=c}if(c<=0){b=RicoTranslate.getPhraseById("bookmarkNoMatch")}else{if(d<0){b=RicoTranslate.getPhraseById("bookmarkNoRec")}else{if(this.buffer.foundRowCount){b=RicoTranslate.getPhraseById("bookmarkExact",a,d,c)}else{b=RicoTranslate.getPhraseById("bookmarkAbout",a,d,c)}}}this.bookmark.innerHTML=b},clearRows:function(){if(this.isBlank==true){return}for(var a=0;a<this.columns.length;a++){this.columns[a].clearColumn()}this.isBlank=true},refreshContents:function(j){Rico.writeDebugMsg("refreshContents: startPos="+j+" lastRow="+this.lastRowPos+" PartBlank="+this.isPartialBlank+" pageSize="+this.pageSize);this.hideMsg();this.cancelMenu();this.unhighlight();if(this.queueFilter){Rico.writeDebugMsg("refreshContents: cancelling refresh because filter has changed");this.queueFilter=false;this.filterHandler();return}this.highlightEnabled=this.options.highlightSection!="none";if(j==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return}this.isBlank=false;var h=this.buffer.startPos>j;var d=h?this.buffer.startPos:j;this.contentStartPos=d+1;var b=Math.min(this.buffer.startPos+this.buffer.size,j+this.pageSize);var m=this.options.onRefreshComplete;if((j+this.pageSize<this.buffer.startPos)||(this.buffer.startPos+this.buffer.size<j)||(this.buffer.size==0)){this.clearRows();if(m){m(this.contentStartPos,b)}return}Rico.writeDebugMsg("refreshContents: contentStartPos="+d+" contentEndPos="+b+" viewPrecedesBuffer="+h);var n=b-d;this.buffer.setWindow(d,n);var f=this.pageSize-n;var k=h?0:n;var e=h?f:0;for(var a=0;a<n;a++){for(var l=0;l<this.columns.length;l++){this.columns[l].displayValue(a+e)}}for(var g=0;g<f;g++){this.blankRow(g+k)}if(this.options.highlightElem=="selection"){this.ShowSelection()}this.isPartialBlank=f>0;this.lastRowPos=j;Rico.writeDebugMsg("refreshContents complete, startPos="+j);if(m){m(this.contentStartPos,b)}},scrollToRow:function(a){var b=this.rowToPixel(a);Rico.writeDebugMsg("scrollToRow, rowOffset="+a+" pixel="+b);this.scrollDiv.scrollTop=b;if(this.options.onscroll){this.options.onscroll(this,a)}},scrollUp:function(){this.moveRelative(-1)},scrollDown:function(){this.moveRelative(1)},pageUp:function(){this.moveRelative(-this.pageSize)},pageDown:function(){this.moveRelative(this.pageSize)},adjustRow:function(a){var b=this.topOfLastPage();if(b==0||!a){return 0}return Math.min(b,a)},rowToPixel:function(a){return this.adjustRow(a)*this.rowHeight},pixeltorow:function(c){var b=this.topOfLastPage();if(b==0){return 0}var a=parseInt(c/this.rowHeight,10);return Math.min(b,a)},moveRelative:function(b){var a=Math.max(this.scrollDiv.scrollTop+b*this.rowHeight,0);a=Math.min(a,this.scrollDiv.scrollHeight);this.scrollDiv.scrollTop=a},pluginScroll:function(){if(this.scrollPluggedIn){return}Rico.writeDebugMsg("pluginScroll: wheelEvent="+this.wheelEvent);Event.observe(this.scrollDiv,"scroll",this.scrollEventFunc,false);for(var a=0;a<2;a++){Event.observe(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)}this.scrollPluggedIn=true},unplugScroll:function(){if(!this.scrollPluggedIn){return}Rico.writeDebugMsg("unplugScroll");Event.stopObserving(this.scrollDiv,"scroll",this.scrollEventFunc,false);for(var a=0;a<2;a++){Event.stopObserving(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)}this.scrollPluggedIn=false},handleWheel:function(a){var b=0;if(a.wheelDelta){if(Prototype.Browser.Opera){b=a.wheelDelta/120}else{if(Prototype.Browser.WebKit){b=-a.wheelDelta/12}else{b=-a.wheelDelta/120}}}else{if(a.detail){b=a.detail/3}}if(b){this.moveRelative(b)}Event.stop(a);return false},handleScroll:function(g){if(this.scrollTimeout){clearTimeout(this.scrollTimeout)}this.setHorizontalScroll();var a=this.scrollDiv.scrollTop;var b=this.lastScrollPos-a;if(b==0){return}var d=this.pixeltorow(a);if(d==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return}var f=new Date();if(this.options.highlightElem=="selection"){this.HideSelection()}this.buffer.fetch(d);if(this.options.onscroll){this.options.onscroll(this,d)}this.scrollTimeout=setTimeout(this.scrollIdle.bind(this),1200);this.lastScrollPos=this.scrollDiv.scrollTop;var c=new Date()},scrollIdle:function(){if(this.options.onscrollidle){this.options.onscrollidle()}},printAll:function(a){this.showMsg(RicoTranslate.getPhraseById("exportInProgress"));setTimeout(this._printAll.bind(this,a),10)},_printAll:function(a){this.exportStart();this.buffer.exportAllRows(this.exportBuffer.bind(this),this.exportFinish.bind(this,a))},_printVisible:function(a){this.exportStart();this.exportBuffer(this.buffer.visibleRows(),0);this.exportFinish(a)},exportBuffer:function(j,e){var a,f,i,b,h;Rico.writeDebugMsg("exportBuffer: "+j.length+" rows");var g=[];var d=e||0;for(f=0;f<this.columns.length;f++){if(this.columns[f].visible){g[f]=this.exportStyle(this.columns[f].cell(0))}}for(a=0;a<j.length;a++){h="";for(f=0;f<this.columns.length;f++){if(!this.columns[f].visible){continue}b=this.columns[f];b.expStyle=g[f];i=b._export(j[a][f],j[a]);if(i.match(/<span\s+class=(['"]?)ricolookup\1>(.*)<\/span>/i)){i=RegExp.leftContext}if(i==""){i="&nbsp;"}h+="<td style='"+b.expStyle+"'>"+i+"</td>"}this.exportRows.push(h);d++;if(d%10==0){window.status=RicoTranslate.getPhraseById("exportStatus",d)}}}};Rico.TableColumn.prototype={initialize:function(liveGrid,colIdx,hdrInfo,tabIdx){Object.extend(this,new Rico.TableColumnBase());this.baseInit(liveGrid,colIdx,hdrInfo,tabIdx);if(typeof this.format.type!="string"){this.format.type="raw"}if(typeof this.isNullable!="boolean"){this.isNullable=/number|date/.test(this.format.type)}this.isText=/raw|text|showTags/.test(this.format.type);Rico.writeDebugMsg(" sortable="+this.sortable+" filterable="+this.filterable+" hideable="+this.hideable+" isNullable="+this.isNullable+" isText="+this.isText);this.fixHeaders(this.liveGrid.tableId,this.options.hdrIconsFirst);if(this.format.control){if(typeof this.format.control=="string"){this.format.control=eval(this.format.control)}for(var property in this.format.control){if(property.charAt(0)=="_"){Rico.writeDebugMsg("Copying control property "+property);this[property]=this.format.control[property]}}}if(this["format_"+this.format.type]){this._format=this["format_"+this.format.type].bind(this)}},sortAsc:function(){this.setColumnSort(Rico.TableColumn.SORT_ASC)},sortDesc:function(){this.setColumnSort(Rico.TableColumn.SORT_DESC)},setColumnSort:function(a){this.liveGrid.clearSort();this.setSorted(a);if(this.liveGrid.options.saveColumnInfo.sort){this.liveGrid.setCookie()}if(this.options.sortHandler){this.options.sortHandler()}},isSortable:function(){return this.sortable},isSorted:function(){return this.currentSort!=Rico.TableColumn.UNSORTED},getSortDirection:function(){return this.currentSort},toggleSort:function(){if(this.liveGrid.buffer&&this.liveGrid.buffer.totalRows==0){return}if(this.currentSort==Rico.TableColumn.SORT_ASC){this.sortDesc()}else{this.sortAsc()}},setUnsorted:function(){this.setSorted(Rico.TableColumn.UNSORTED)},setSorted:function(a){this.currentSort=a},canFilter:function(){return this.filterable},getFilterText:function(){var c=[];for(var b=0;b<this.filterValues.length;b++){var a=this.filterValues[b];if(typeof(a)=="string"&&a.match(/<span\s+class=(['"]?)ricolookup\1>(.*)<\/span>/i)){a=RegExp.leftContext}c.push(a==""?RicoTranslate.getPhraseById("filterBlank"):a)}switch(this.filterOp){case"EQ":return"= "+(c[0]);case"NE":return RicoTranslate.getPhraseById("filterNot",c.join(", "));case"LE":return"<= "+c[0];case"GE":return">= "+c[0];case"LIKE":return RicoTranslate.getPhraseById("filterLike",c[0]);case"NULL":return RicoTranslate.getPhraseById("filterEmpty");case"NOTNULL":return RicoTranslate.getPhraseById("filterNotEmpty")}return"?"},getFilterQueryParm:function(){if(this.filterType==Rico.TableColumn.UNFILTERED){return""}var a="&f["+this.index+"][op]="+this.filterOp;a+="&f["+this.index+"][len]="+this.filterValues.length;for(var b=0;b<this.filterValues.length;b++){a+="&f["+this.index+"]["+b+"]="+escape(this.filterValues[b])}return a},setUnfiltered:function(a){this.filterType=Rico.TableColumn.UNFILTERED;if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()}if(this.removeFilterFunc){this.removeFilterFunc()}if(this.options.filterHandler&&!a){this.options.filterHandler()}},setFilterEQ:function(){this.setUserFilter("EQ")},setFilterNE:function(){this.setUserFilter("NE")},addFilterNE:function(){this.filterValues.push(this.userFilter);if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()}if(this.options.filterHandler){this.options.filterHandler()}},setFilterGE:function(){this.setUserFilter("GE")},setFilterLE:function(){this.setUserFilter("LE")},setFilterKW:function(a){if(a!=""&&a!=null){this.setFilter("LIKE",a,Rico.TableColumn.USERFILTER)}else{this.setUnfiltered(false)}},setUserFilter:function(a){this.setFilter(a,this.userFilter,Rico.TableColumn.USERFILTER)},setSystemFilter:function(a,b){this.setFilter(a,b,Rico.TableColumn.SYSTEMFILTER)},setFilter:function(a,c,b,d){this.filterValues=[c];this.filterType=b;this.filterOp=a;if(b==Rico.TableColumn.USERFILTER&&this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()}this.removeFilterFunc=d;if(this.options.filterHandler){this.options.filterHandler()}},isFiltered:function(){return this.filterType==Rico.TableColumn.USERFILTER},filterChange:function(a){var b=Event.element(a);if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()}else{this.setFilter("EQ",b.value,Rico.TableColumn.USERFILTER,function(){b.selectedIndex=0})}},filterClear:function(b,a){a.value="";this.setUnfiltered()},filterKeypress:function(c){var a=Event.element(c);if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""}if(this.lastKeyFilter==a.value){return}var b=a.value;Rico.writeDebugMsg("filterKeypress: "+this.index+" "+b);this.lastKeyFilter=b;if(b==""||b=="*"){this.setUnfiltered()}else{this.setFilter("LIKE",b,Rico.TableColumn.USERFILTER,function(){a.value=""})}},format_text:function(a){if(typeof a!="string"){return"&nbsp;"}else{return a.stripTags()}},format_showTags:function(a){if(typeof a!="string"){return"&nbsp;"}else{return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}},format_number:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"}else{return a.formatNumber(this.format)}},format_datetime:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"}else{var b=new Date();if(!b.setISO8601(a)){return a}return(this.format.prefix||"")+b.formatDate(this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")}},format_UTCasLocalTime:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"}else{var b=new Date();if(!b.setISO8601(a,-b.getTimezoneOffset())){return a}return(this.format.prefix||"")+b.formatDate(this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")}},format_date:function(a){if(typeof a=="undefined"||a==null||a==""){return"&nbsp;"}else{var b=new Date();if(!b.setISO8601(a)){return a}return(this.format.prefix||"")+b.formatDate(this.format.dateFmt||"translateDate")+(this.format.suffix||"")}},fixHeaders:function(c,d){if(this.sortable){switch(this.options.headingSort){case"link":var b=RicoUtil.wrapChildren(this.hdrCellDiv,"ricoSort",undefined,"a");b.href="javascript:void(0)";b.onclick=this.toggleSort.bindAsEventListener(this);break;case"hover":this.hdrCellDiv.onclick=this.toggleSort.bindAsEventListener(this);break}}this.imgFilter=document.createElement("img");this.imgFilter.style.display="none";this.imgFilter.src=Rico.imgDir+this.options.filterImg;this.imgFilter.className="ricoLG_HdrIcon";this.imgSort=document.createElement("img");this.imgSort.style.display="none";this.imgSort.src=Rico.imgDir+this.options.sortAscendImg;this.imgSort.className="ricoLG_HdrIcon";if(d){this.hdrCellDiv.insertBefore(this.imgSort,this.hdrCellDiv.firstChild);this.hdrCellDiv.insertBefore(this.imgFilter,this.hdrCellDiv.firstChild)}else{this.hdrCellDiv.appendChild(this.imgFilter);this.hdrCellDiv.appendChild(this.imgSort)}if(!this.format.filterUI){Event.observe(this.imgFilter,"click",this.filterClick.bindAsEventListener(this),false)}},filterClick:function(a){if(this.filterType==Rico.TableColumn.USERFILTER&&this.filterOp=="LIKE"){this.liveGrid.openKeyword(this.index)}},getValue:function(a){return this.liveGrid.buffer.getWindowValue(a,this.index)},getBufferCell:function(a){return this.liveGrid.buffer.getWindowCell(a,this.index)},getBufferAttr:function(a){return this.liveGrid.buffer.getWindowAttr(a,this.index)},setValue:function(b,a){this.liveGrid.buffer.setWindowValue(b,this.index,a)},_format:function(a){return a},_display:function(a,b){b.innerHTML=this._format(a)},_export:function(a){return this._format(a)},displayValue:function(f){var c=this.getBufferCell(f);if(c==null){this.clearCell(f);return}var e=this.cell(f);this._display(c,e,f);var d=this.liveGrid.buffer.options.acceptAttr;if(d.length==0){return}var b=this.getBufferAttr(f);if(b==null){return}for(var a=0;a<d.length;a++){b=b["_"+d[a]]||"";switch(d[a]){case"style":e.style.cssText=b;break;case"class":e.className=b;break;default:e["_"+d[a]]=b;break}}}};Rico.includeLoaded("ricoLiveGrid.js");Rico.TableColumn.checkboxKey=Class.create({initialize:function(a){this._checkboxes=[];this._spans=[];this._KeyHash=$H();this._showKey=a},_create:function(a,b){this._checkboxes[b]=RicoUtil.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);this._spans[b]=RicoUtil.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);this._clear(a,b);Event.observe(this._checkboxes[b],"click",this._onclick.bindAsEventListener(this),false)},_onclick:function(c){var b=Event.element(c);var d=parseInt(b.id.split(/_/).pop(),10);var a=this.getValue(d);if(b.checked){this._addChecked(a)}else{this._remChecked(a)}},_clear:function(b,c){var a=this._checkboxes[c];a.checked=false;a.style.display="none";this._spans[c].innerHTML=""},_display:function(a,c,d){var b=this._checkboxes[d];b.style.display="";b.checked=this._KeyHash.get(a);if(this._showKey){this._spans[d].innerHTML=a}},_SelectedKeys:function(){return this._KeyHash.keys()},_addChecked:function(a){this._KeyHash.set(a,1)},_remChecked:function(a){this._KeyHash.unset(a)}});Rico.TableColumn.checkbox=Class.create({initialize:function(b,c,a,d){this._checkedValue=b;this._uncheckedValue=c;this._defaultValue=a||false;this._readOnly=d||false;this._checkboxes=[]},_create:function(a,b){this._checkboxes[b]=RicoUtil.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);this._clear(a,b);if(this._readOnly){this._checkboxes[b].disabled=true}else{Event.observe(this._checkboxes[b],"click",this._onclick.bindAsEventListener(this),false)}},_onclick:function(c){var a=Event.element(c);var d=parseInt(a.id.split(/_/).pop(),10);var b=a.checked?this._checkedValue:this._uncheckedValue;this.setValue(d,b)},_clear:function(b,c){var a=this._checkboxes[c];a.checked=this._defaultValue;a.style.display="none"},_display:function(a,c,d){var b=this._checkboxes[d];b.style.display="";b.checked=(a==this._checkedValue)}});Rico.TableColumn.textbox=Class.create({initialize:function(c,b,a){this._boxSize=c;this._boxMaxLen=b;this._readOnly=a||false;this._textboxes=[]},_create:function(b,c){var a=RicoUtil.createFormField(b,"input","text",this.liveGrid.tableId+"_txtbox_"+this.index+"_"+c);a.size=this._boxSize;a.maxLength=this._boxMaxLen;this._textboxes[c]=a;this._clear(b,c);if(this._readOnly){a.disabled=true}else{Event.observe(a,"change",this._onchange.bindAsEventListener(this),false)}},_onchange:function(b){var a=Event.element(b);var c=parseInt(a.id.split(/_/).pop(),10);this.setValue(c,a.value)},_clear:function(b,c){var a=this._textboxes[c];a.value="";a.style.display="none"},_display:function(a,c,d){var b=this._textboxes[d];b.style.display="";b.value=a}});Rico.TableColumn.HighlightCell=Class.create({initialize:function(a,c,e,b,d){this._chkcol=a;this._chkval=c;this._chkop=d;this._highlightColor=e;this._highlightBackground=b},_clear:function(a,b){a.style.color="";a.style.backgroundColor="";a.innerHTML="&nbsp;"},_display:function(b,d,e){var a=this.liveGrid.buffer.getWindowValue(e,this._chkcol);var c;switch(this._chkop){case"!=":c=(a!=this._chkval);break;case">":c=(a>this._chkval);break;case"<":c=(a<this._chkval);break;case">=":c=(a>=this._chkval);break;case"<=":c=(a<=this._chkval);break;default:c=(a==this._chkval);break}d.style.color=c?this._highlightColor:"";d.style.backgroundColor=c?this._highlightBackground:"";d.innerHTML=this._format(b)}});Rico.TableColumn.bgColor=Class.create({initialize:function(){},_clear:function(a,b){a.style.backgroundColor=""},_display:function(a,b,c){b.style.backgroundColor=a}});Rico.TableColumn.link=Class.create({initialize:function(a,b){this._href=a;this._target=b;this._anchors=[]},_create:function(a,b){this._anchors[b]=RicoUtil.createFormField(a,"a",null,this.liveGrid.tableId+"_a_"+this.index+"_"+b);if(this._target){this._anchors[b].target=this._target}this._clear(a,b)},_clear:function(a,b){this._anchors[b].href="";this._anchors[b].innerHTML=""},_display:function(a,c,d){this._anchors[d].innerHTML=a;var b=this.liveGrid.buffer.getWindowValue.bind(this.liveGrid.buffer);this._anchors[d].href=this._href.replace(/\{\d+\}/g,function(e){var f=parseInt(e.substr(1),10);return b(d,f)})}});Rico.TableColumn.image=Class.create({initialize:function(){this._img=[]},_create:function(a,b){this._img[b]=RicoUtil.createFormField(a,"img",null,this.liveGrid.tableId+"_img_"+this.index+"_"+b);this._clear(a,b)},_clear:function(b,c){var a=this._img[c];a.style.display="none";a.src=""},_display:function(b,c,d){var a=this._img[d];this._img[d].src=b;a.style.display=""}});Rico.TableColumn.lookup=Class.create({initialize:function(c,a,b){this._map=c;this._defaultCode=a||"";this._defaultDesc=b||"&nbsp;";this._sortfunc=this._sortvalue.bind(this);this._codes=[];this._descriptions=[]},_create:function(a,b){this._descriptions[b]=RicoUtil.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);this._codes[b]=RicoUtil.createFormField(a,"input","hidden",this.liveGrid.tableId+"_code_"+this.index+"_"+b);this._clear(a,b)},_clear:function(a,b){this._codes[b].value=this._defaultCode;this._descriptions[b].innerHTML=this._defaultDesc},_sortvalue:function(a){return this._getdesc(a).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ")},_getdesc:function(a){var b=this._map[a];return(typeof b=="string")?b:this._defaultDesc},_export:function(a){return this._getdesc(a)},_display:function(a,b,c){this._codes[c].value=a;this._descriptions[c].innerHTML=this._getdesc(a)}});Rico.TableColumn.MultiLine=Class.create({initialize:function(){},_display:function(a,c,d){var b=document.createElement("div");b.innerHTML=this._format(a);b.style.height="100%";if(c.firstChild){c.replaceChild(b,c.firstChild)}else{c.appendChild(b)}}});Rico.includeLoaded("ricoLiveGridControls.js");if(typeof Rico=="undefined"){throw ("GridMenu requires the Rico JavaScript framework")}Rico.GridMenu=Class.create();Rico.GridMenu.prototype={initialize:function(a){this.options={width:"18em",dataMenuHandler:null};Object.extend(this.options,a||{});Object.extend(this,new Rico.Menu(this.options));this.sortmenu=new Rico.Menu({width:"15em"});this.filtermenu=new Rico.Menu({width:"22em"});this.exportmenu=new Rico.Menu({width:"24em"});this.hideshowmenu=new Rico.Menu({width:"22em"});this.createDiv();this.sortmenu.createDiv();this.filtermenu.createDiv();this.exportmenu.createDiv();this.hideshowmenu.createDiv()},buildGridMenu:function(a,i){this.clearMenu();var l=this.liveGrid.buffer.totalRows;var b=a>=l;var e=this.liveGrid.columns[i];if(this.options.dataMenuHandler){var m=this.options.dataMenuHandler(this.liveGrid,a,i,b);if(!m){return(this.itemCount>0)}}if(e.sortable&&l>0){this.sortmenu.clearMenu();this.addSubMenuItem(RicoTranslate.getPhraseById("gridmenuSortBy",e.displayName),this.sortmenu,false);this.sortmenu.addMenuItemId("gridmenuSortAsc",e.sortAsc.bind(e),true);this.sortmenu.addMenuItemId("gridmenuSortDesc",e.sortDesc.bind(e),true)}this.filtermenu.clearMenu();if(e.canFilter()&&!e.format.filterUI&&(!b||e.filterType==Rico.TableColumn.USERFILTER)){this.addSubMenuItem(RicoTranslate.getPhraseById("gridmenuFilterBy",e.displayName),this.filtermenu,false);e.userFilter=e.getValue(a);if(e.filterType==Rico.TableColumn.USERFILTER){this.filtermenu.addMenuItemId("gridmenuRemoveFilter",e.setUnfiltered.bind(e,false),true);if(e.filterOp=="LIKE"){this.filtermenu.addMenuItemId("gridmenuChgKeyword",this.liveGrid.openKeyword.bind(this.liveGrid,i),true)}if(e.filterOp=="NE"&&!b){this.filtermenu.addMenuItemId("gridmenuExcludeAlso",e.addFilterNE.bind(e),true)}}else{if(!b){this.filtermenu.addMenuItemId("gridmenuInclude",e.setFilterEQ.bind(e),true);this.filtermenu.addMenuItemId("gridmenuGreaterThan",e.setFilterGE.bind(e),e.userFilter!="");this.filtermenu.addMenuItemId("gridmenuLessThan",e.setFilterLE.bind(e),e.userFilter!="");if(e.isText){this.filtermenu.addMenuItemId("gridmenuContains",this.liveGrid.openKeyword.bind(this.liveGrid,i),true)}this.filtermenu.addMenuItemId("gridmenuExclude",e.setFilterNE.bind(e),true)}}if(this.liveGrid.filterCount()>0){this.filtermenu.addMenuItemId("gridmenuRefresh",this.liveGrid.filterHandler.bind(this.liveGrid),true);this.filtermenu.addMenuItemId("gridmenuRemoveAll",this.liveGrid.clearFilters.bind(this.liveGrid),true)}}else{if(this.liveGrid.filterCount()>0){this.addSubMenuItem(RicoTranslate.getPhraseById("gridmenuFilterBy",e.displayName),this.filtermenu,false);this.filtermenu.addMenuItemId("gridmenuRemoveAll",this.liveGrid.clearFilters.bind(this.liveGrid),true)}}if(this.liveGrid.options.maxPrint>0&&l>0){this.exportmenu.clearMenu();this.addSubMenuItem(RicoTranslate.getPhraseById("gridmenuExport"),this.exportmenu,false);this.exportmenu.addMenuItemId("gridmenuExportVis2Web",this.liveGrid.printVisible.bind(this.liveGrid,"plain"));this.exportmenu.addMenuItemId("gridmenuExportAll2Web",this.liveGrid.printAll.bind(this.liveGrid,"plain"),this.liveGrid.buffer.totalRows<=this.liveGrid.options.maxPrint);if(Prototype.Browser.IE){this.exportmenu.addMenuBreak();this.exportmenu.addMenuItemId("gridmenuExportVis2SS",this.liveGrid.printVisible.bind(this.liveGrid,"owc"));this.exportmenu.addMenuItemId("gridmenuExportAll2SS",this.liveGrid.printAll.bind(this.liveGrid,"owc"),this.liveGrid.buffer.totalRows<=this.liveGrid.options.maxPrint)}}var k=this.liveGrid.listInvisible();for(var f=0,j=0;j<k.length;j++){if(k[j].canHideShow()){f++}}if(f>0||e.canHideShow()){this.hideshowmenu.clearMenu();this.addSubMenuItem(RicoTranslate.getPhraseById("gridmenuHideShow"),this.hideshowmenu,false);this.hideshowmenu.addMenuItemId("gridmenuChooseCols",this.liveGrid.chooseColumns.bindAsEventListener(this.liveGrid));var h=this.liveGrid.columns.length-k.length;var g=(h>1&&e.visible&&e.canHideShow());this.hideshowmenu.addMenuItem(RicoTranslate.getPhraseById("gridmenuHide",e.displayName),e.hideColumn.bind(e),g,false);for(var d=0,j=0;j<k.length;j++){if(k[j].canHideShow()){if(d++==0){this.hideshowmenu.addMenuBreak()}this.hideshowmenu.addMenuItem(RicoTranslate.getPhraseById("gridmenuShow",k[j].displayName),k[j].showColumn.bind(k[j]),true,false)}}if(k.length>1){this.hideshowmenu.addMenuItemId("gridmenuShowAll",this.liveGrid.showAll.bind(this.liveGrid))}}return true}};Rico.includeLoaded("ricoLiveGridMenu.js");if(typeof Rico=="undefined"){throw ("LiveGridAjax requires the Rico JavaScript framework")}if(typeof RicoUtil=="undefined"){throw ("LiveGridAjax requires the RicoUtil object")}if(typeof Rico.Buffer=="undefined"){throw ("LiveGridAjax requires the Rico.Buffer object")}Rico.Buffer.AjaxXML=Class.create({initialize:function(c,b,a){Object.extend(this,new Rico.Buffer.Base());Object.extend(this,new Rico.Buffer.AjaxXMLMethods);this.dataSource=c;this.options.bufferTimeout=20000;this.options.requestParameters=[];this.options.waitMsg=RicoTranslate.getPhraseById("waitForData");this.options.canFilter=true;Object.extend(this.options,b||{});this.ajaxOptions={parameters:null,method:"get"};Object.extend(this.ajaxOptions,a||{});this.requestCount=0;this.processingRequest=false;this.pendingRequest=-2;this.fetchData=true;this.sortParm={}}});Rico.Buffer.AjaxXMLMethods=function(){};Rico.Buffer.AjaxXMLMethods.prototype={fetch:function(a){if(this.fetchData){this.foundRowCount=true;this.fetchData=false;this.processingRequest=true;this.liveGrid.showMsg(this.options.waitMsg);this.timeoutHandler=setTimeout(this.handleTimedOut.bind(this),this.options.bufferTimeout);this.ajaxOptions.parameters=this.formQueryHashXML(0,-1);Rico.writeDebugMsg("sending request");if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=this.ajaxUpdate.bind(this,a);new Ajax.Request(this.dataSource,this.ajaxOptions)}else{this.ajaxOptions.onComplete=this.jsUpdate.bind(this,a);this.dataSource(this.ajaxOptions)}}else{if(a<0){this.applyFilters();this.setTotalRows(this.size);a=0}this.liveGrid.refreshContents(a)}},handleTimedOut:function(){Rico.writeDebugMsg("Request Timed Out");this.liveGrid.showMsg(RicoTranslate.getPhraseById("requestTimedOut"))},formQueryHashXML:function(e,c){var d={id:this.liveGrid.tableId,page_size:(typeof c=="number")?c:this.totalRows,offset:e};if(!this.foundRowCount){d.get_total="true"}if(this.options.requestParameters){for(var f=0;f<this.options.requestParameters.length;f++){var g=this.options.requestParameters[f];if(g.name!=undefined&&g.value!=undefined){d[g.name]=g.value}else{var b=g.indexOf("=");var h=g.substring(0,b);var a=g.substring(b+1);d[h]=a}}}return d},clearTimer:function(){if(typeof this.timeoutHandler!="number"){return}window.clearTimeout(this.timeoutHandler);delete this.timeoutHandler},jsUpdate:function(a,c,f,b,d){this.clearTimer();this.processingRequest=false;Rico.writeDebugMsg("jsUpdate: "+arguments.length);if(d){Rico.writeDebugMsg("jsUpdate: received error="+d);this.liveGrid.showMsg(RicoTranslate.getPhraseById("requestError",d));return}this.rcvdRows=c.length;if(typeof b=="number"){this.rowcntContent=b.toString();this.rcvdRowCount=true;this.foundRowCount=true;Rico.writeDebugMsg("jsUpdate: found RowCount="+this.rowcntContent)}this.updateBuffer(a,c,f);if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()}this.updateGrid(a);if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()}if(this.pendingRequest>=-1){var e=this.pendingRequest;Rico.writeDebugMsg("jsUpdate: found pending request for offset="+e);this.pendingRequest=-2;this.fetch(e)}},ajaxUpdate:function(a,b){this.clearTimer();this.processingRequest=false;if(b.status!=200){Rico.writeDebugMsg("ajaxUpdate: received http error="+b.status);this.liveGrid.showMsg(RicoTranslate.getPhraseById("httpError",b.status));return}if(!this.processResponse(a,b)){return}if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()}this.updateGrid(a);if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()}if(this.pendingRequest>=-1){var c=this.pendingRequest;Rico.writeDebugMsg("ajaxUpdate: found pending request for offset="+c);this.pendingRequest=-2;this.fetch(c)}},processResponse:function(k,f){var o=f.responseXML;if(f.responseText.substring(0,4)=="<!--"){var m=f.responseText.indexOf("-->");if(m==-1){this.liveGrid.showMsg("Web server error - client side debugging may be enabled");return false}o=RicoUtil.createXmlDocument();o.loadXML(f.responseText.substring(m+3))}var e=o.getElementsByTagName("ajax-response");if(e==null||e.length!=1){return false}this.rcvdRows=0;this.rcvdRowCount=false;var c=e[0];var a=c.getElementsByTagName("debug");for(var g=0;g<a.length;g++){Rico.writeDebugMsg("ajaxUpdate: debug msg "+g+": "+RicoUtil.getContentAsString(a[g],this.options.isEncoded))}var l=c.getElementsByTagName("error");if(l.length>0){var d=RicoUtil.getContentAsString(l[0],this.options.isEncoded);alert("Data provider returned an error:\n"+d);Rico.writeDebugMsg("Data provider returned an error:\n"+d);return false}var j=c.getElementsByTagName("rows")[0];if(!j){Rico.writeDebugMsg("ajaxUpdate: invalid response");this.liveGrid.showMsg(RicoTranslate.getPhraseById("invalidResponse"));return false}var n=c.getElementsByTagName("rowcount");if(n&&n.length==1){this.rowcntContent=RicoUtil.getContentAsString(n[0],this.options.isEncoded);this.rcvdRowCount=true;this.foundRowCount=true;Rico.writeDebugMsg("ajaxUpdate: found RowCount="+this.rowcntContent)}this.updateUI=j.getAttribute("update_ui")=="true";this.rcvdOffset=j.getAttribute("offset");Rico.writeDebugMsg("ajaxUpdate: rcvdOffset="+this.rcvdOffset);var h=this.dom2jstable(j);var b=(this.options.acceptAttr.length>0)?this.dom2jstableAttr(j):false;this.rcvdRows=h.length;this.updateBuffer(k,h,b);return true},updateBuffer:function(c,a,b){this.baseRows=a;this.attr=b;Rico.writeDebugMsg("updateBuffer: # of rows="+this.rcvdRows);this.rcvdRowCount=true;this.rowcntContent=this.rcvdRows;if(typeof this.delayedSortCol=="number"){this.sortBuffer(this.delayedSortCol)}this.applyFilters();this.startPos=0},updateGrid:function(f){Rico.writeDebugMsg("updateGrid, size="+this.size+" rcv cnt type="+typeof(this.rowcntContent));var e;if(this.rcvdRowCount==true){Rico.writeDebugMsg("found row cnt: "+this.rowcntContent);var d=parseInt(this.rowcntContent,10);var b=this.totalRows;if(!isNaN(d)&&d!=b){this.setTotalRows(d);e=Math.min(this.liveGrid.topOfLastPage(),f);Rico.writeDebugMsg("updateGrid: new rowcnt="+d+" newpos="+e);if(b==0&&this.liveGrid.sizeTo=="data"){this.liveGrid.adjustPageSize()}this.liveGrid.scrollToRow(e);if(this.isInRange(e)){this.liveGrid.refreshContents(e)}else{this.fetch(e)}return}}else{var a=f+this.rcvdRows;if(a>this.totalRows){var c=a;Rico.writeDebugMsg("extending totrows to "+c);this.setTotalRows(c)}}e=this.liveGrid.pixeltorow(this.liveGrid.scrollDiv.scrollTop);Rico.writeDebugMsg("updateGrid: newpos="+e);this.liveGrid.refreshContents(e)}};Rico.Buffer.AjaxSQL=Class.create({initialize:function(c,b,a){Object.extend(this,new Rico.Buffer.AjaxXML());Object.extend(this,new Rico.Buffer.AjaxSQLMethods());this.dataSource=c;this.options.canFilter=true;this.options.largeBufferSize=7;this.options.nearLimitFactor=1;Object.extend(this.options,b||{});Object.extend(this.ajaxOptions,a||{})}});Rico.Buffer.AjaxSQLMethods=function(){};Rico.Buffer.AjaxSQLMethods.prototype={registerGrid:function(a){this.liveGrid=a;this.sessionExpired=false;this.timerMsg=$(a.tableId+"_timer");if(this.options.TimeOut&&this.timerMsg){if(!this.timerMsg.title){this.timerMsg.title=RicoTranslate.getPhraseById("sessionExpireMinutes")}this.restartSessionTimer()}},setBufferSize:function(a){this.maxFetchSize=Math.max(50,parseInt(this.options.largeBufferSize*a,10));this.nearLimit=parseInt(this.options.nearLimitFactor*a,10);this.maxBufferSize=this.maxFetchSize*3},restartSessionTimer:function(){if(this.sessionExpired==true){return}this.sessionEndTime=(new Date()).getTime()+this.options.TimeOut*60000;if(this.sessionTimer){clearTimeout(this.sessionTimer)}this.updateSessionTimer()},updateSessionTimer:function(){var b=(new Date()).getTime();if(b>this.sessionEndTime){this.displaySessionTimer(RicoTranslate.getPhraseById("sessionExpired"));this.timerMsg.style.backgroundColor="red";this.sessionExpired=true}else{var a=Math.ceil((this.sessionEndTime-b)/60000);this.displaySessionTimer(a);this.sessionTimer=setTimeout(this.updateSessionTimer.bind(this),10000)}},displaySessionTimer:function(a){this.timerMsg.innerHTML="&nbsp;"+a+"&nbsp;"},refresh:function(b){var a=this.liveGrid.lastRowPos;this.clear();if(b){this.setTotalRows(0);this.foundRowCount=false}this.liveGrid.clearBookmark();this.liveGrid.clearRows();this.fetch(a)},fetch:function(d){Rico.writeDebugMsg("AjaxSQL fetch: offset="+d+", lastOffset="+this.lastOffset);if(this.processingRequest){Rico.writeDebugMsg("AjaxSQL fetch: queue request");this.pendingRequest=d;return}if(d<0){this.clear();this.setTotalRows(0);this.foundRowCount=false;d=0}var c=this.lastOffset;this.lastOffset=d;if(this.isInRange(d)){Rico.writeDebugMsg("AjaxSQL fetch: in buffer");this.liveGrid.refreshContents(d);if(d>c){if(d+this.liveGrid.pageSize<this.endPos()-this.nearLimit){return}if(this.endPos()==this.totalRows&&this.foundRowCount){return}}else{if(d<c){if(d>this.startPos+this.nearLimit){return}if(this.startPos==0){return}}else{return}}}if(d>=this.totalRows&&this.foundRowCount){return}this.processingRequest=true;Rico.writeDebugMsg("AjaxSQL fetch: processing offset="+d);var b=this.getFetchOffset(d);var a=this.getFetchSize(b);var e=false;this.liveGrid.showMsg(this.options.waitMsg);this.timeoutHandler=setTimeout(this.handleTimedOut.bind(this),this.options.bufferTimeout);this.ajaxOptions.parameters=this.formQueryHashSQL(b,a);this.requestCount++;Rico.writeDebugMsg("sending req #"+this.requestCount);if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=this.ajaxUpdate.bind(this,b);new Ajax.Request(this.dataSource,this.ajaxOptions)}else{this.ajaxOptions.onComplete=this.jsUpdate.bind(this,b);this.dataSource(this.ajaxOptions)}},formQueryHashSQL:function(e,b){var d=this.formQueryHashXML(e,b);Object.extend(d,this.sortParm);for(var j=0;j<this.liveGrid.columns.length;j++){var h=this.liveGrid.columns[j];if(h.filterType==Rico.TableColumn.UNFILTERED){continue}var g=typeof(h.format.filterCol)=="number"?h.format.filterCol:h.index;d["f["+g+"][op]"]=h.filterOp;d["f["+g+"][len]"]=h.filterValues.length;for(var f=0;f<h.filterValues.length;f++){var a=h.filterValues[f];if(h.filterOp=="LIKE"&&a.indexOf("*")==-1){a="*"+a+"*"}d["f["+g+"]["+f+"]"]=a}}return d},getFetchSize:function(a){var b=0;if(a>=this.startPos){var c=this.maxFetchSize+a;b=c-a;if(a==0&&b<this.maxFetchSize){b=this.maxFetchSize}Rico.writeDebugMsg("getFetchSize/append, adjustedSize="+b+" adjustedOffset="+a+" endFetchOffset="+c)}else{b=Math.min(this.startPos-a,this.maxFetchSize)}return b},getFetchOffset:function(b){var a=b;if(b>this.startPos){a=Math.max(b,this.endPos())}else{if(b+this.maxFetchSize>=this.startPos){a=Math.max(this.startPos-this.maxFetchSize,0)}}return a},updateBuffer:function(d,a,b){Rico.writeDebugMsg("updateBuffer: start="+d+", # of rows="+this.rcvdRows);if(this.rows.length==0){this.rows=a;this.attr=b;this.startPos=d}else{if(d>this.startPos){if(this.startPos+this.rows.length<d){this.rows=a;this.attr=b;this.startPos=d}else{this.rows=this.rows.concat(a.slice(0,a.length));if(this.attr){this.attr=this.attr.concat(b.slice(0,b.length))}if(this.rows.length>this.maxBufferSize){var c=this.rows.length;this.rows=this.rows.slice(this.rows.length-this.maxBufferSize,this.rows.length);if(this.attr){this.attr=this.attr.slice(this.attr.length-this.maxBufferSize,this.attr.length)}this.startPos=this.startPos+(c-this.rows.length)}}}else{if(d+a.length<this.startPos){this.rows=a}else{this.rows=a.slice(0,this.startPos).concat(this.rows);if(this.maxBufferSize&&this.rows.length>this.maxBufferSize){this.rows=this.rows.slice(0,this.maxBufferSize)}}this.startPos=d}}this.size=this.rows.length},sortBuffer:function(b){this.sortParm={};var a=this.liveGrid.columns[b];if(this.options.sortParmFmt){this.sortParm.sort_col=a[this.options.sortParmFmt];this.sortParm.sort_dir=a.getSortDirection()}else{this.sortParm["s"+b]=a.getSortDirection()}this.clear()},exportAllRows:function(b,a){this.exportPopulate=b;this.exportFinish=a;this.sendExportRequest(0)},sendExportRequest:function(a){this.timeoutHandler=setTimeout(this.exportTimedOut.bind(this),this.options.bufferTimeout);this.ajaxOptions.parameters=this.formQueryHashSQL(a,200);this.requestCount++;Rico.writeDebugMsg("sending export req #"+this.requestCount);if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=this.ajaxExportAppend.bind(this,a);new Ajax.Request(this.dataSource,this.ajaxOptions)}else{this.ajaxOptions.onComplete=this.jsExportAppend.bind(this,a);this.dataSource(this.ajaxOptions)}},exportTimedOut:function(){Rico.writeDebugMsg("Print Request Timed Out");this.liveGrid.showMsg(RicoTranslate.getPhraseById("requestTimedOut"));this.exportFinish()},jsExportAppend:function(a,c,e,b,d){this.clearTimer();Rico.writeDebugMsg("jsExportAppend: "+arguments.length);if(d){Rico.writeDebugMsg("jsExportAppend: received error="+d);this.liveGrid.showMsg(RicoTranslate.getPhraseById("requestError",d));return}this.exportPopulate(c,a);if(c.length==0){this.exportFinish()}else{this.sendExportRequest(a+c.length)}},ajaxExportAppend:function(b,d){this.clearTimer();Rico.writeDebugMsg("ajaxExportAppend");var a=d.responseXML.getElementsByTagName("ajax-response");if(a==null||a.length!=1){return}var c=a[0].getElementsByTagName("rows")[0];var e=this.dom2jstable(c);this.exportPopulate(e,b);if(e.length==0){this.exportFinish()}else{this.sendExportRequest(b+e.length)}}};Rico.includeLoaded("ricoLiveGridAjax.js");Rico.Buffer.AjaxJSON=Class.create({initialize:function(c,b,a){Object.extend(this,new Rico.Buffer.AjaxSQL());Object.extend(this,new Rico.Buffer.AjaxJSONMethods());this.dataSource=c;Object.extend(this.options,b||{});Object.extend(this.ajaxOptions,a||{})}});Rico.Buffer.AjaxJSONMethods=function(){};Rico.Buffer.AjaxJSONMethods.prototype={processResponse:function(a,e){var c=e.responseText.evalJSON(true);if(!c||c==null){Rico.writeDebugMsg("jsonAjaxUpdate: json conversion failed");return false}if(c.debug){for(var b=0;b<c.debug.length;b++){Rico.writeDebugMsg("debug msg "+b+": "+c.debug[b])}}if(c.error){alert("Data provider returned an error:\n"+c.error);Rico.writeDebugMsg("Data provider returned an error:\n"+c.error);return false}this.rcvdRows=0;var d=this.loadRows(c);if(d==null){return false}this.rcvdRows=d.length;this.updateBuffer(a,d);return true},loadRows:function(b){Rico.writeDebugMsg("loadRows");b=$H(b);this.rcvdRowCount=false;var c=b.get("rows");var a=b.get("rowCount");if(a){this.rowcntContent=a;this.rcvdRowCount=true;this.foundRowCount=true;Rico.writeDebugMsg("loadRows, found RowCount="+this.rowcntContent)}this.updateUI=b.get("update_ui");this.rcvdOffset=b.get("offset");Rico.writeDebugMsg("loadRows, rcvdOffset="+this.rcvdOffset);if(this.options.template){return this.template2jsTable(b,this.options.template)}else{return c}},json2jsTable:function(c,f){var d=new Array();var a=c.get("rows");a=$A(a);var b=0;var e=this.options.acceptAttr;a.each(function(h){var i=new Array();h=$H(h);var g=0;h.each(function(l){i[g]={};i[g].content=l.value;for(var j=0;j<e.length;j++){i[g]["_"+e[j]]=""}g++});d.push(i);b++});return d},template2jsTable:function(d,e){var a=d.get("rows");a=$A(a);var b="<table>";a.each(function(f){b+=e.evaluate(f)});b+="</table>";var c=this.string2DOM(b);return this.dom2jstable(c)},string2DOM:function(a){var c=null;try{c=new ActiveXObject("Microsoft.XMLDOM");c.async="false";c.loadXML(a)}catch(d){try{var f=new DOMParser();c=f.parseFromString(a,"text/xml")}catch(d){alert(d.message)}}var b=document._importNode(c.childNodes[0],true);return b}};Rico.includeLoaded("ricoLiveGridJSON.js");if(typeof Rico=="undefined"){throw ("LiveGridForms requires the Rico JavaScript framework")}if(typeof RicoUtil=="undefined"){throw ("LiveGridForms requires the RicoUtil object")}if(typeof RicoTranslate=="undefined"){throw ("LiveGridForms requires the RicoTranslate object")}Rico.TableEdit=Class.create({initialize:function(a){Rico.writeDebugMsg("Rico.TableEdit initialize: "+a.tableId);this.grid=a;this.options={maxDisplayLen:20,panelHeight:200,panelWidth:500,hoverClass:"tabHover",selectedClass:"tabSelected",compact:false,RecordName:RicoTranslate.getPhraseById("record"),updateURL:window.location.href,readOnlyColor:"#AAA",showSaveMsg:"errors"};Object.extend(this.options,a.options);this.hasWF2=(document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("WebForms","2.0"));this.menu=a.menu;this.menu.options.dataMenuHandler=this.editMenu.bind(this);this.menu.ignoreClicks();RicoEditControls.atLoad();this.createEditDiv();this.createKeyArray();this.saveMsg=$(a.tableId+"_savemsg");Event.observe(document,"click",this.clearSaveMsg.bindAsEventListener(this),false);this.extraMenuItems=new Array();this.responseHandler=this.processResponse.bind(this);Rico.writeDebugMsg("Rico.TableEdit.initialize complete, hasWF2="+this.hasWF2)},canDragFunc:function(b,a){if(b.componentFromPoint){var d=b.componentFromPoint(a.clientX,a.clientY);if(d!=""&&d!="outside"){return false}}return(b==this.editDiv||b.tagName=="FORM")},createKeyArray:function(){this.keys=[];for(var a=0;a<this.grid.columns.length;a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.isKey){this.keys.push(a)}}},createEditDiv:function(){this.requestCount=1;this.editDiv=this.grid.createDiv("edit",document.body);this.editDiv.style.display="none";if(this.options.canEdit||this.options.canAdd){this.startForm();this.createForm(this.form)}else{var a=this.createButton(RicoTranslate.getPhraseById("close"));Event.observe(a,"click",this.cancelEdit.bindAsEventListener(this),false);this.createForm(this.editDiv)}this.editDivCreated=true;this.formPopup=new Rico.Popup({ignoreClicks:true,hideOnClick:false,canDragFunc:this.canDragFunc.bind(this)},this.editDiv);this.responseDialog=this.grid.createDiv("editResponse",document.body);this.responseDialog.style.display="none";var b=document.createElement("button");b.appendChild(document.createTextNode("OK"));b.onclick=this.ackResponse.bindAsEventListener(this);this.responseDialog.appendChild(b);this.responseDiv=this.grid.createDiv("editResponseText",this.responseDialog);if(this.panelGroup){Rico.writeDebugMsg("createEditDiv complete, requestCount="+this.requestCount);setTimeout(this.initPanelGroup.bind(this),50)}},initPanelGroup:function(){this.requestCount--;Rico.writeDebugMsg("initPanelGroup: "+this.requestCount);if(this.requestCount>0){return}var a=parseInt(this.options.panelWidth,10);if(this.form){this.form.style.width=(a+10)+"px";if(Prototype.Browser.WebKit){this.editDiv.style.display="block"}this.options.bgColor=Rico.Color.createColorFromBackground(this.form)}this.editDiv.style.display="none";this.options.panelHdrWidth=(Math.floor(a/this.options.panels.length)-4)+"px";this.Accordion=new Rico.TabbedPanel(this.panelHdr.findAll(this.notEmpty),this.panelContent.findAll(this.notEmpty),this.options)},notEmpty:function(a){return typeof(a)!="undefined"},startForm:function(){this.form=document.createElement("form");this.form.onsubmit=function(){return false};this.editDiv.appendChild(this.form);var e=document.createElement("table");var f=e.insertRow(-1);var b=f.insertCell(-1);var d=b.appendChild(this.createButton(RicoTranslate.getPhraseById("saveRecord",this.options.RecordName)));Event.observe(d,"click",this.TESubmit.bindAsEventListener(this),false);b=f.insertCell(-1);d=b.appendChild(this.createButton(RicoTranslate.getPhraseById("cancel")));Event.observe(d,"click",this.cancelEdit.bindAsEventListener(this),false);this.form.appendChild(e);this.hiddenFields=document.createElement("div");this.hiddenFields.style.display="none";this.action=this.appendHiddenField(this.grid.tableId+"__action","");var c,a;for(c=0;c<this.grid.columns.length;c++){a=this.grid.columns[c].format;if(a&&a.FormView&&a.FormView=="hidden"){this.appendHiddenField(a.FieldName,a.ColData)}}this.form.appendChild(this.hiddenFields)},createButton:function(b){var a=document.createElement("button");a.innerHTML="<span style='text-decoration:underline;'>"+b.charAt(0)+"</span>"+b.substr(1);a.accessKey=b.charAt(0);return a},createPanel:function(c){var e=false;for(var b=0;b<this.grid.columns.length;b++){var a=this.grid.columns[b].format;if(!a){continue}if(!a.EntryType){continue}if(a.EntryType=="H"){continue}var d=a.panelIdx||0;if(d==c){e=true;break}}if(!e){return false}this.panelHdr[c]=document.createElement("div");this.panelHdr[c].className="tabHeader";this.panelHdr[c].innerHTML=this.options.panels[c];this.panelHdrs.appendChild(this.panelHdr[c]);this.panelContent[c]=document.createElement("div");this.panelContent[c].className="tabContent";this.panelContents.appendChild(this.panelContent[c]);return true},createForm:function(e){var c,f,a,d,b=[];this.panelHdr=[];this.panelContent=[];if(this.options.panels){this.panelGroup=document.createElement("div");this.panelGroup.className="tabPanelGroup";this.panelHdrs=document.createElement("div");this.panelGroup.appendChild(this.panelHdrs);this.panelContents=document.createElement("div");this.panelContents.className="tabContentContainer";this.panelGroup.appendChild(this.panelContents);e.appendChild(this.panelGroup);if(this.grid.direction=="rtl"){for(c=this.options.panels.length-1;c>=0;c--){if(this.createPanel(c)){b[c]=this.createFormTable(this.panelContent[c],"tabContent")}}}else{for(c=0;c<this.options.panels.length;c++){if(this.createPanel(c)){b[c]=this.createFormTable(this.panelContent[c],"tabContent")}}}e.appendChild(this.panelGroup)}else{f=document.createElement("div");f.className="noTabContent";b[0]=this.createFormTable(f);e.appendChild(f)}for(c=0;c<this.grid.columns.length;c++){a=this.grid.columns[c].format;if(!a){continue}d=a.panelIdx||0;if(b[d]){this.appendFormField(this.grid.columns[c],b[d])}if(typeof a.pattern=="string"){switch(a.pattern){case"email":a.regexp=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;break;case"float-unsigned":a.regexp=/^\d+(\.\d+)?$/;break;case"float-signed":a.regexp=/^[-+]?\d+(\.\d+)?$/;break;case"int-unsigned":a.regexp=/^\d+$/;break;case"int-signed":a.regexp=/^[-+]?\d+$/;break;default:a.regexp=new RegExp(a.pattern);break}}}},createFormTable:function(b){var a=document.createElement("table");a.border=0;b.appendChild(a);return a},appendHiddenField:function(a,b){var c=RicoUtil.createFormField(this.hiddenFields,"input","hidden",a,a);c.value=b;return c},appendFormField:function(c,e){var a=c.format;if(!a.EntryType){return}if(a.EntryType=="H"){return}if(a.FormView){return}Rico.writeDebugMsg("appendFormField: "+c.displayName+" - "+a.EntryType);var g=e.insertRow(-1);var h=g.insertCell(-1);c.formLabel=h;if(h.noWrap){h.noWrap=true}var d=g.insertCell(-1);if(d.noWrap){d.noWrap=true}h.innerHTML=c.displayName;h.id="lbl_"+a.FieldName;if(a.Help){h.title=a.Help;h.className="ricoEditLabelWithHelp"}else{h.className="ricoEditLabel"}var f,b=a.FieldName;switch(a.EntryType){case"TA":case"tinyMCE":f=RicoUtil.createFormField(d,"textarea",null,b);f.cols=a.TxtAreaCols;f.rows=a.TxtAreaRows;f.innerHTML=a.ColData;h.style.verticalAlign="top";break;case"R":case"RL":f=RicoUtil.createFormField(d,"div",null,b);if(a.isNullable){this.addSelectNone(f)}this.selectValuesRequest(f,a);break;case"N":f=RicoUtil.createFormField(d,"select",null,b);if(a.isNullable){this.addSelectNone(f)}f.onchange=this.checkSelectNew.bindAsEventListener(this);this.selectValuesRequest(f,a);f=document.createElement("span");f.className="ricoEditLabel";f.id="labelnew__"+a.FieldName;f.innerHTML="&nbsp;&nbsp;&nbsp;"+RicoTranslate.getPhraseById("formNewValue").replace(" ","&nbsp;");d.appendChild(f);b="textnew__"+a.FieldName;f=RicoUtil.createFormField(d,"input","text",b,b);break;case"S":case"SL":f=RicoUtil.createFormField(d,"select",null,b);if(a.isNullable){this.addSelectNone(f)}this.selectValuesRequest(f,a);break;case"D":if(!a.isNullable){a.required=true}if(typeof a.min=="string"){a.min=a.min.toISO8601Date()||new Date(a.min)}if(typeof a.max=="string"){a.max=a.max.toISO8601Date()||new Date(a.max)}if(this.hasWF2){f=RicoUtil.createFormField(d,"input","date",b,b);f.required=a.required;if(a.min){f.min=a.min.toISO8601String(3)}if(a.max){f.max=a.max.toISO8601String(3)}f.required=a.required;a.SelectCtl=null}else{f=RicoUtil.createFormField(d,"input","text",b,b)}this.initField(f,a);break;case"I":if(!a.isNullable){a.required=true}if(!a.pattern){a.pattern="int-signed"}if(this.hasWF2){f=RicoUtil.createFormField(d,"input","number",b,b);f.required=a.required;f.min=a.min;f.max=a.max;f.step=1}else{f=RicoUtil.createFormField(d,"input","text",b,b)}if(typeof a.min=="string"){a.min=parseInt(a.min,10)}if(typeof a.max=="string"){a.max=parseInt(a.max,10)}this.initField(f,a);break;case"F":if(!a.isNullable){a.required=true}if(!a.pattern){a.pattern="float-signed"}f=RicoUtil.createFormField(d,"input","text",b,b);this.initField(f,a);if(typeof a.min=="string"){a.min=parseFloat(a.min)}if(typeof a.max=="string"){a.max=parseFloat(a.max)}break;default:f=RicoUtil.createFormField(d,"input","text",b,b);if(!a.isNullable&&a.EntryType!="T"){a.required=true}this.initField(f,a);break}if(f){if(a.SelectCtl){RicoEditControls.applyTo(c,f)}}},addSelectNone:function(a){this.addSelectOption(a,this.options.TableSelectNone,RicoTranslate.getPhraseById("selectNone"))},initField:function(b,a){if(a.Length){b.maxLength=a.Length;b.size=Math.min(a.Length,this.options.maxDisplayLen)}b.value=a.ColData},checkSelectNew:function(a){this.updateSelectNew(Event.element(a))},updateSelectNew:function(b){var a=(b.value==this.options.TableSelectNew)?"":"hidden";$("labelnew__"+b.id).style.visibility=a;$("textnew__"+b.id).style.visibility=a},selectValuesRequest:function(e,a){if(a.SelectValues){var b=a.SelectValues.split(",");for(var d=0;d<b.length;d++){this.addSelectOption(e,b[d],b[d],d)}}else{this.requestCount++;var c={};Object.extend(c,this.grid.buffer.ajaxOptions);c.parameters="id="+a.FieldName+"&offset=0&page_size=-1";c.onComplete=this.selectValuesUpdate.bind(this);new Ajax.Request(this.grid.buffer.dataSource,c);Rico.writeDebugMsg("selectValuesRequest: "+c.parameters)}},selectValuesUpdate:function(d){var c=d.responseXML.getElementsByTagName("ajax-response");Rico.writeDebugMsg("selectValuesUpdate: "+d.status);if(c==null||c.length!=1){return}c=c[0];var k=c.getElementsByTagName("error");if(k.length>0){var h=RicoUtil.getContentAsString(k[0],this.grid.buffer.isEncoded);Rico.writeDebugMsg("Data provider returned an error:\n"+h);alert(RicoTranslate.getPhraseById("requestError",h));return null}c=c.getElementsByTagName("response")[0];var a=c.getAttribute("id").slice(0,-8);var j=c.getElementsByTagName("rows")[0];var l=this.grid.buffer.dom2jstable(j);var b=$(a);Rico.writeDebugMsg("selectValuesUpdate: id="+a+" rows="+l.length);for(var f=0;f<l.length;f++){if(l[f].length>0){var g=l[f][0];var e=(l[f].length>1)?l[f][1]:g;this.addSelectOption(b,g,e,f)}}if($("textnew__"+a)){this.addSelectOption(b,this.options.TableSelectNew,RicoTranslate.getPhraseById("selectNewVal"))}if(this.panelGroup){setTimeout(this.initPanelGroup.bind(this),50)}},addSelectOption:function(c,e,f,a){switch(c.tagName.toLowerCase()){case"div":var b=RicoUtil.createFormField(c,"input","radio",c.id+"_"+a,c.id);b.value=e;var d=document.createElement("label");d.innerHTML=f;d.htmlFor=b.id;c.appendChild(d);break;case"select":RicoUtil.addSelectOption(c,e,f);break}},clearSaveMsg:function(){if(this.saveMsg){this.saveMsg.innerHTML=""}},addMenuItem:function(c,b,a){this.extraMenuItems.push({menuText:c,menuAction:b,enabled:a})},editMenu:function(d,h,j,e){this.clearSaveMsg();if(this.grid.buffer.sessionExpired==true||this.grid.buffer.startPos<0){return false}this.rowIdx=h;var g=$("pageTitle");var f=g?g.innerHTML:document.title;this.menu.addMenuHeading(f);for(var b=0;b<this.extraMenuItems.length;b++){this.menu.addMenuItem(this.extraMenuItems[b].menuText,this.extraMenuItems[b].menuAction,this.extraMenuItems[b].enabled)}var a;if(e==false){a=RicoTranslate.getPhraseById("editRecord",this.options.RecordName);this.menu.addMenuItem(a,this.editRecord.bindAsEventListener(this),this.options.canEdit);a=RicoTranslate.getPhraseById("deleteRecord",this.options.RecordName);this.menu.addMenuItem(a,this.deleteRecord.bindAsEventListener(this),this.options.canDelete);if(this.options.canClone){a=RicoTranslate.getPhraseById("cloneRecord",this.options.RecordName);this.menu.addMenuItem(a,this.cloneRecord.bindAsEventListener(this),this.options.canAdd&&this.options.canEdit)}}a=RicoTranslate.getPhraseById("addRecord",this.options.RecordName);this.menu.addMenuItem(a,this.addRecord.bindAsEventListener(this),this.options.canAdd);return true},cancelEdit:function(b){Event.stop(b);for(var a=0;a<this.grid.columns.length;a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.SelectCtl){RicoEditControls.close(this.grid.columns[a].format.SelectCtl)}}this.makeFormInvisible();this.grid.highlightEnabled=true;this.menu.cancelmenu();return false},setField:function(d,j){var m=this.grid.columns[d].format;var h=$(m.FieldName);var k,g,c,l,b,f;if(!h){return}Rico.writeDebugMsg("setField: "+m.FieldName+"="+j);switch(h.tagName.toUpperCase()){case"DIV":c=h.getElementsByTagName("INPUT");l=this.getLookupValue(j)[0];for(g=0;g<c.length;g++){c[g].checked=(c[g].value==l)}break;case"INPUT":if(m.EntryType.charAt(1)=="L"){j=this.getLookupValue(j)[0]}if(m.EntryType=="D"){k=j.split(/\s|T/);j=k[0]}h.value=j;break;case"SELECT":b=h.options;l=this.getLookupValue(j)[0];for(g=0;g<b.length;g++){if(b[g].value==l){h.selectedIndex=g;break}}if(m.EntryType=="N"){f=$("textnew__"+h.id);if(!f){alert('Warning: unable to find id "textnew__'+h.id+'"')}f.value=j;if(h.selectedIndex!=g){h.selectedIndex=b.length-1}this.updateSelectNew(h)}return;case"TEXTAREA":h.value=j;if(m.EntryType=="tinyMCE"&&typeof(tinyMCE)!="undefined"&&this.initialized){tinyMCE.updateContent(h.id)}return}},getLookupValue:function(a){switch(typeof a){case"number":return[a.toString(),a.toString()];case"string":return a.match(/<span\s+class=(['"]?)ricolookup\1>(.*)<\/span>/i)?[RegExp.$2,RegExp.leftContext]:[a,a];default:return["",""]}},setReadOnly:function(k){for(var f=0;f<this.grid.columns.length;f++){var l=this.grid.columns[f].format;if(!l){continue}var h=$(l.FieldName);if(!h){continue}var g=!l.Writeable||l.ReadOnly||(l.InsertOnly&&!k)||(l.UpdateOnly&&k);var b=g?this.options.readOnlyColor:"";switch(h.tagName.toUpperCase()){case"DIV":var a=h.getElementsByTagName("INPUT");for(var c=0;c<a.length;c++){a[c].disabled=g}break;case"SELECT":if(l.EntryType=="N"){var d=$("textnew__"+h.id);d.disabled=g}h.disabled=g;break;case"TEXTAREA":case"INPUT":h.readOnly=g;h.style.color=b;if(l.selectIcon){l.selectIcon.style.display=g?"none":""}break}}},hideResponse:function(a){this.responseDiv.innerHTML=a;this.responseDialog.style.display="none"},showResponse:function(){var a=Position.page(this.grid.outerDiv);a[1]+=RicoUtil.docScrollTop();this.responseDialog.style.top=a[1]+"px";this.responseDialog.style.left=a[0]+"px";this.responseDialog.style.display=""},processResponse:function(){var d,f=true;var e=Element.select(this.responseDiv,".ricoFormResponse");if(e){var c=$w(e[0].className)[1];d=RicoTranslate.getPhraseById(c,this.options.RecordName)}else{var b=this.responseDiv.childNodes;for(var a=b.length-1;a>=0;a--){if(b[a].nodeType==1&&b[a].nodeName!="P"&&b[a].nodeName!="DIV"&&b[a].nodeName!="BR"){this.responseDiv.removeChild(b[a])}}d=this.responseDiv.innerHTML.stripTags();f=(d.toLowerCase().indexOf("error")==-1)}if(f&&this.options.showSaveMsg!="full"){this.hideResponse("");this.grid.resetContents();this.grid.buffer.foundRowCount=false;this.grid.buffer.fetch(this.grid.lastRowPos||0);if(this.saveMsg){this.saveMsg.innerHTML="&nbsp;"+d+"&nbsp;"}}this.processCallback(this.options.onSubmitResponse)},processCallback:function(callback){switch(typeof callback){case"string":eval(callback);break;case"function":callback();break}},ackResponse:function(){this.hideResponse("");this.grid.highlightEnabled=true},cloneRecord:function(){this.displayEditForm("ins")},editRecord:function(){this.displayEditForm("upd")},displayEditForm:function(d){this.grid.highlightEnabled=false;this.menu.cancelmenu();this.hideResponse(RicoTranslate.getPhraseById("saving"));this.grid.outerDiv.style.cursor="auto";this.action.value=d;for(var b=0;b<this.grid.columns.length;b++){if(this.grid.columns[b].format){var e=this.grid.columns[b];var a=e.getValue(this.rowIdx);this.setField(b,a);if(e.format.selectDesc){e.format.selectDesc.innerHTML=e._format(a)}if(e.format.SelectCtl){RicoEditControls.displayClrImg(e,!e.format.InsertOnly)}}}this.setReadOnly(false);this.key=this.getKey(this.rowIdx);this.makeFormVisible(this.rowIdx)},addPrepare:function(){this.hideResponse(RicoTranslate.getPhraseById("saving"));this.setReadOnly(true);this.form.reset();this.action.value="ins";for(var a=0;a<this.grid.columns.length;a++){if(this.grid.columns[a].format){this.setField(a,this.grid.columns[a].format.ColData);if(this.grid.columns[a].format.SelectCtl){RicoEditControls.resetValue(this.grid.columns[a])}}}this.key=""},addRecord:function(){this.menu.cancelmenu();this.addPrepare();this.makeFormVisible(-1);if(this.Accordion){this.Accordion.selectionSet.selectIndex(0)}},drillDown:function(g,f,h){var b=Event.element(g||window.event);b=RicoUtil.getParentByTagName(b,"div","ricoLG_cell");if(!b){return}this.grid.unhighlight();var a=this.grid.winCellIndex(b);this.grid.menuIdx=a;this.grid.highlight(a);var c=this.grid.columns[f].getValue(a.row);for(var d=3;d<arguments.length;d++){arguments[d].setDetailFilter(h,c)}return a.row},setDetailFilter:function(a,b){this.grid.setDetailFilter(a,b)},makeFormVisible:function(l){var d=8;this.editDiv.style.display="block";var c=this.editDiv.offsetWidth+d;var j=Position.page(this.grid.outerDiv);var e=RicoUtil.windowWidth();if(c+j[0]>e){this.editDiv.style.left=(e-c)+"px"}else{this.editDiv.style.left=(j[0]+1)+"px"}var h=RicoUtil.docScrollTop();var b=this.editDiv.offsetHeight+d;var g=j[1]+this.grid.hdrHt+h;var a=RicoUtil.windowHeight()+h;if(l>=0){g+=(l+1)*this.grid.rowHeight;if(g+b>a){g-=(b+this.grid.rowHeight)}}else{if(g+b>a){g=a-b}}this.processCallback(this.options.formOpen);this.formPopup.openPopup(null,Math.max(g,h));this.editDiv.style.visibility="visible";if(this.initialized){return}var f,k;for(f=0;f<this.grid.columns.length;f++){k=this.grid.columns[f].format;if(!k||!k.EntryType||!k.FieldName){continue}switch(k.EntryType){case"tinyMCE":if(typeof tinyMCE!="undefined"){tinyMCE.execCommand("mceAddControl",true,k.FieldName)}break}}if(!this.panelGroup){this.editDiv.style.width=(this.editDiv.offsetWidth-this.grid.options.scrollBarWidth+2)+"px";this.editDiv.style.height=(this.editDiv.offsetHeight-this.grid.options.scrollBarWidth+2)+"px"}this.formPopup.openPopup();this.initialized=true},makeFormInvisible:function(){this.editDiv.style.visibility="hidden";this.formPopup.closePopup();this.processCallback(this.options.formClose)},getConfirmDesc:function(a){var b=this.grid.columns[this.options.ConfirmDeleteCol].cell(a).innerHTML;b=this.getLookupValue(b)[1];return b.stripTags().unescapeHTML()},deleteRecord:function(){this.menu.cancelmenu();var e;switch(this.options.ConfirmDeleteCol){case -1:e=RicoTranslate.getPhraseById("thisRecord",this.options.RecordName);break;case -2:for(var a=0;a<this.keys.length;a++){var b=this.keys[a];var d=this.grid.columns[b].getValue(this.rowIdx);d=this.getLookupValue(d)[0];if(e){e+=", "}e+=this.grid.columns[b].displayName+" "+d}break;default:e='"'+this.getConfirmDesc(this.rowIdx).truncate(50)+'"';break}if(!this.options.ConfirmDelete.valueOf||confirm(RicoTranslate.getPhraseById("confirmDelete",e))){this.hideResponse(RicoTranslate.getPhraseById("deleting"));this.showResponse();var c=this.action.name+"=del"+this.getKey(this.rowIdx);new Ajax.Updater(this.responseDiv,this.options.updateURL,{parameters:c,onComplete:this.processResponse.bind(this)})}this.menu.cancelmenu()},getKey:function(c){var e=$H();for(var a=0;a<this.keys.length;a++){var b=this.keys[a];var d=this.grid.columns[b].getValue(c);d=this.getLookupValue(d)[0];e.set("_k"+b,d)}return"&"+e.toQueryString()},validationMsg:function(c,b,d){var a=this.grid.columns[b];if(this.Accordion){this.Accordion.openByIndex(a.format.panelIdx)}var e=RicoTranslate.getPhraseById(d,' "'+a.formLabel.innerHTML+'"');Rico.writeDebugMsg(" Validation error: "+e);if(a.format.Help){e+="\n\n"+a.format.Help}alert(e);setTimeout(function(){try{c.focus();c.select()}catch(f){}},10);return false},TESubmit:function(g){var b,f,a,c,j;Event.stop(g||event);Rico.writeDebugMsg("Event: TESubmit called to validate input");for(b=0;b<this.grid.columns.length;b++){a=this.grid.columns[b].format;if(!a||!a.EntryType||!a.FieldName){continue}c=$(a.FieldName);if(!c){continue}if(c.tagName.toLowerCase()!="input"){continue}if(c.type.toLowerCase()!="text"){continue}Rico.writeDebugMsg(" Validating field #"+b+" EntryType="+a.EntryType+" ("+a.FieldName+")");if(c.value.length==0&&a.required){return this.validationMsg(c,b,"formPleaseEnter")}if(c.value.length>0&&a.regexp&&!a.regexp.test(c.value)){return this.validationMsg(c,b,"formInvalidFmt")}switch(a.EntryType.charAt(0)){case"I":j=parseInt(c.value,10);break;case"F":j=parseFloat(c.value);break;case"D":j=new Date();j.setISO8601(c.value);break;default:j=NaN;break}if(typeof a.min!="undefined"&&!isNaN(j)&&j<a.min){return this.validationMsg(c,b,"formOutOfRange")}if(typeof a.max!="undefined"&&!isNaN(j)&&j>a.max){return this.validationMsg(c,b,"formOutOfRange")}}for(b=0;b<this.grid.columns.length;b++){a=this.grid.columns[b].format;if(!a||!a.EntryType||!a.FieldName){continue}if(a.EntryType.charAt(0)!="N"){continue}var d=$(a.FieldName);if(!d||d.value!=this.options.TableSelectNew){continue}var h=$("textnew__"+d.id).value;this.addSelectOption(d,h,h)}if(typeof tinyMCE!="undefined"){tinyMCE.triggerSave()}this.makeFormInvisible();this.sendForm();this.menu.cancelmenu();return false},sendForm:function(){this.showResponse();var a=Form.serialize(this.form)+this.key;Rico.writeDebugMsg("sendForm: "+a);new Ajax.Updater(this.responseDiv,this.options.updateURL,{parameters:a,onComplete:this.responseHandler})}});var RicoEditControls={widgetList:$H(),elemList:$H(),clearImg:Rico.imgDir+"delete.gif",register:function(a,b){this.widgetList.set(a.id,{imgsrc:b,widget:a,currentEl:""});a.returnValue=this.setValue.bind(this,a);Rico.writeDebugMsg("RicoEditControls.register:"+a.id)},atLoad:function(){this.widgetList.each(function(a){if(a.value.widget.atLoad){a.value.widget.atLoad()}})},applyTo:function(e,f){var c=this.widgetList.get(e.format.SelectCtl);if(!c){return}Rico.writeDebugMsg("RicoEditControls.applyTo: "+e.displayName+" : "+e.format.SelectCtl);var d=document.createElement("span");var a=document.createElement("img");a.style.paddingLeft="4px";a.style.cursor="pointer";a.align="top";a.src=c.imgsrc;a.id=this.imgId(e.format.FieldName);a.onclick=this.processClick.bindAsEventListener(this);f.parentNode.appendChild(d);f.parentNode.appendChild(a);f.style.display="none";if(e.format.isNullable){var b=document.createElement("img");b.style.paddingLeft="4px";b.style.cursor="pointer";b.align="top";b.src=this.clearImg;b.id=a.id+"_clear";b.alt=RicoTranslate.getPhraseById("clear");b.onclick=this.processClear.bindAsEventListener(this);f.parentNode.appendChild(b)}this.elemList.set(a.id,{descSpan:d,inputCtl:f,widget:c.widget,listObj:c,column:e,clrimg:b});e.format.selectIcon=a;e.format.selectDesc=d},displayClrImg:function(c,a){var b=this.elemList.get(this.imgId(c.format.FieldName));if(b&&b.clrimg){b.clrimg.style.display=a?"":"none"}},processClear:function(c){var b=Event.element(c);var a=this.elemList.get(b.id.slice(0,-6));if(!a){return}a.inputCtl.value="";a.descSpan.innerHTML=a.column._format("")},processClick:function(c){var b=Event.element(c);var a=this.elemList.get(b.id);if(!a){return}if(a.listObj.currentEl==b.id&&a.widget.container.style.display!="none"){a.widget.close();a.listObj.currentEl=""}else{a.listObj.currentEl=b.id;Rico.writeDebugMsg("RicoEditControls.processClick: "+a.widget.id+" : "+a.inputCtl.value);a.widget.open(a.inputCtl.value);RicoUtil.positionCtlOverIcon(a.widget.container,b);if(a.widget.move){a.widget.move()}}},imgId:function(a){return"icon_"+a},resetValue:function(b){var a=this.elemList.get(this.imgId(b.format.FieldName));if(!a){return}a.inputCtl.value=b.format.ColData;a.descSpan.innerHTML=b._format(b.format.ColData)},setValue:function(e,a,d){var b=this.widgetList.get(e.id);if(!b){return null}var f=b.currentEl;if(!f){return null}var c=this.elemList.get(f);if(!c){return null}c.inputCtl.value=a;if(!d){d=c.column._format(a)}c.descSpan.innerHTML=d},close:function(b){var a=this.widgetList.get(b);if(!a){return}if(a.widget.container.style.display!="none"){a.widget.close()}}};Rico.includeLoaded("ricoLiveGridForms.js");RicoTranslate.langCode="en";RicoTranslate.addPhraseId("bookmarkExact","Listing records $1 - $2 of $3");RicoTranslate.addPhraseId("bookmarkAbout","Listing records $1 - $2 of more than $3");RicoTranslate.addPhraseId("bookmarkNoRec","No records");RicoTranslate.addPhraseId("bookmarkNoMatch","No matching records");RicoTranslate.addPhraseId("bookmarkLoading","Loading...");RicoTranslate.addPhraseId("sorting","Sorting...");RicoTranslate.addPhraseId("exportStatus","Exporting row $1");RicoTranslate.addPhraseId("filterAll","(all)");RicoTranslate.addPhraseId("filterBlank","(blank)");RicoTranslate.addPhraseId("filterEmpty","(empty)");RicoTranslate.addPhraseId("filterNotEmpty","(not empty)");RicoTranslate.addPhraseId("filterLike","like: $1");RicoTranslate.addPhraseId("filterNot","not: $1");RicoTranslate.addPhraseId("requestError","The request for data returned an error:\n$1");RicoTranslate.addPhraseId("keywordPrompt","Enter keyword to search for (use * as a wildcard):");RicoTranslate.addPhraseId("gridmenuSortBy","Sort by: $1");RicoTranslate.addPhraseId("gridmenuSortAsc","Ascending");RicoTranslate.addPhraseId("gridmenuSortDesc","Descending");RicoTranslate.addPhraseId("gridmenuFilterBy","Filter by: $1");RicoTranslate.addPhraseId("gridmenuRefresh","Refresh");RicoTranslate.addPhraseId("gridmenuChgKeyword","Change keyword...");RicoTranslate.addPhraseId("gridmenuExcludeAlso","Exclude this value also");RicoTranslate.addPhraseId("gridmenuInclude","Include only this value");RicoTranslate.addPhraseId("gridmenuGreaterThan","Greater than or equal to this value");RicoTranslate.addPhraseId("gridmenuLessThan","Less than or equal to this value");RicoTranslate.addPhraseId("gridmenuContains","Contains keyword...");RicoTranslate.addPhraseId("gridmenuExclude","Exclude this value");RicoTranslate.addPhraseId("gridmenuRemoveFilter","Remove filter");RicoTranslate.addPhraseId("gridmenuRemoveAll","Remove all filters");RicoTranslate.addPhraseId("gridmenuExport","Print/Export");RicoTranslate.addPhraseId("gridmenuExportVis2Web","Visible rows to web page");RicoTranslate.addPhraseId("gridmenuExportAll2Web","All rows to web page");RicoTranslate.addPhraseId("gridmenuExportVis2SS","Visible rows to spreadsheet");RicoTranslate.addPhraseId("gridmenuExportAll2SS","All rows to spreadsheet");RicoTranslate.addPhraseId("gridmenuHideShow","Hide/Show");RicoTranslate.addPhraseId("gridmenuChooseCols","Choose columns...");RicoTranslate.addPhraseId("gridmenuHide","Hide: $1");RicoTranslate.addPhraseId("gridmenuShow","Show: $1");RicoTranslate.addPhraseId("gridmenuShowAll","Show All");RicoTranslate.addPhraseId("sessionExpireMinutes","minutes before your session expires");RicoTranslate.addPhraseId("sessionExpired","EXPIRED");RicoTranslate.addPhraseId("requestTimedOut","Request for data timed out!");RicoTranslate.addPhraseId("waitForData","Waiting for data...");RicoTranslate.addPhraseId("httpError","Received HTTP error: $1");RicoTranslate.addPhraseId("invalidResponse","Server returned an invalid response");RicoTranslate.addPhraseId("gridChooseCols","Choose columns");RicoTranslate.addPhraseId("exportComplete","Exporting complete");RicoTranslate.addPhraseId("exportInProgress","Export in progress...");RicoTranslate.addPhraseId("disableBlocker","You need to disable your browser's pop-up blocker before exporting.");RicoTranslate.addPhraseId("showFilterRow","Show filter row");RicoTranslate.addPhraseId("hideFilterRow","Hide filter row");RicoTranslate.addPhraseId("selectNone","(none)");RicoTranslate.addPhraseId("selectNewVal","(new value)");RicoTranslate.addPhraseId("record","record");RicoTranslate.addPhraseId("thisRecord","this $1");RicoTranslate.addPhraseId("confirmDelete","Are you sure you want to delete $1?");RicoTranslate.addPhraseId("deleting","Deleting...");RicoTranslate.addPhraseId("formPleaseEnter","Please enter a value for $1");RicoTranslate.addPhraseId("formInvalidFmt","Invalid format for $1");RicoTranslate.addPhraseId("formOutOfRange","Value is out of range for $1");RicoTranslate.addPhraseId("formNewValue","new value:");RicoTranslate.addPhraseId("saving","Saving...");RicoTranslate.addPhraseId("clear","clear");RicoTranslate.addPhraseId("close","Close");RicoTranslate.addPhraseId("saveRecord","Save $1");RicoTranslate.addPhraseId("cancel","Cancel");RicoTranslate.addPhraseId("editRecord","Edit this $1");RicoTranslate.addPhraseId("deleteRecord","Delete this $1");RicoTranslate.addPhraseId("cloneRecord","Clone this $1");RicoTranslate.addPhraseId("addRecord","Add new $1");RicoTranslate.addPhraseId("addedSuccessfully","$1 added successfully");RicoTranslate.addPhraseId("deletedSuccessfully","$1 deleted successfully");RicoTranslate.addPhraseId("updatedSuccessfully","$1 updated successfully");RicoTranslate.addPhraseId("treeSave","Save Selection");RicoTranslate.addPhraseId("treeClear","Clear All");RicoTranslate.addPhraseId("calToday","Today is $1 $2 $3");RicoTranslate.addPhraseId("calWeekHdg","Wk");RicoTranslate.addPhraseId("calYearRange","Year ($1-$2)");RicoTranslate.addPhraseId("calInvalidYear","Invalid year");RicoTranslate.thouSep=",";RicoTranslate.decPoint=".";RicoTranslate.dateFmt="mm/dd/yyyy";RicoTranslate.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];RicoTranslate.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Rico.includeLoaded("translations/ricoLocale_en.js");Rico.acceptLanguage(navigator.language||navigator.userLanguage);
\ No newline at end of file