Updated Rico 2 and Rico 3 with all patches submitted on Sourceforge.
[infodrom/rico3] / ricoClient / js / rico_min.js
1 Rico.Version="3.0b2";
2 Rico.theme={};
3 Rico.onLoadCallbacks=[];
4 Rico.windowIsLoaded=false;
5 Rico.inputtypes={search:0,number:0,range:0,color:0,tel:0,url:0,email:0,date:0,month:0,week:0,time:0,datetime:0,"datetime-local":0};
6 Rico.windowLoaded=function(){this.windowIsLoaded=true;
7 if(typeof Rico_CONFIG=="object"){var b=document.createElement("style");
8 document.getElementsByTagName("head")[0].appendChild(b);
9 if(!window.createPopup){b.appendChild(document.createTextNode(""))
10 }var a=document.styleSheets[document.styleSheets.length-1];
11 this.addCssBackgroundRule(a,".rico-icon",Rico_CONFIG.imgIcons,"no-repeat");
12 this.addCssBackgroundRule(a,".ricoLG_Resize",Rico_CONFIG.imgResize,"repeat");
13 if(Rico_CONFIG.imgHeading){var c="repeat-x";
14 var e="left center";
15 this.addCssBackgroundRule(a,"tr.ricoLG_hdg th",Rico_CONFIG.imgHeading,c,e);
16 this.addCssBackgroundRule(a,"tr.ricoLG_hdg td",Rico_CONFIG.imgHeading,c,e);
17 this.addCssBackgroundRule(a,"table.ricoLiveGrid thead td",Rico_CONFIG.imgHeading,c,e);
18 this.addCssBackgroundRule(a,"table.ricoLiveGrid thead th",Rico_CONFIG.imgHeading,c,e);
19 this.addCssBackgroundRule(a,".ricoTitle",Rico_CONFIG.imgHeading,c,e);
20 this.addCssBackgroundRule(a,".Rico_accTitle",Rico_CONFIG.imgHeading,c,e)
21 }if(Rico_CONFIG.enableLogging){this.enableLogging()
22 }if(Rico_CONFIG.enableHTML5){this._CheckInputTypes()
23 }}Rico.writeDebugMsg=Rico.log;
24 Rico.log("Processing callbacks");
25 while(this.onLoadCallbacks.length>0){var d=this.onLoadCallbacks.shift();
26 if(d){d()
27 }}};
28 Rico.addCssBackgroundRule=function(d,b,c,e,a){if(!c){return
29 }this.addCssRule(d,b,"background-image:url('"+c+"')");
30 this.addCssRule(d,b,"background-repeat:"+e);
31 if(a){this.addCssRule(d,b,"background-position:"+a)
32 }};
33 Rico.addCssRule=function(b,a,c){if(b.addRule){b.addRule(a,c)
34 }else{if(b.insertRule){b.insertRule(a+" { "+c+" }",0)
35 }else{alert("unable to add rule: "+c)
36 }}};
37 Rico._CheckInputTypes=function(){var a=document.createElement("input");
38 for(var b in this.inputtypes){a.setAttribute("type","text");
39 a.setAttribute("type",b);
40 this.inputtypes[b]=(a.type!=="text")
41 }};
42 Rico.onLoad=function(b,a){if(this.windowIsLoaded){b()
43 }else{if(a){this.onLoadCallbacks.unshift(b)
44 }else{this.onLoadCallbacks.push(b)
45 }}};
46 Rico.isKonqueror=navigator.userAgent.toLowerCase().indexOf("konqueror")>-1;
47 Rico.isIE=!!(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1);
48 Rico.isOpera=navigator.userAgent.indexOf("Opera")>-1;
49 Rico.isWebKit=navigator.userAgent.indexOf("AppleWebKit/")>-1;
50 Rico.isGecko=navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")===-1;
51 Rico.ieVersion=/MSIE (\d+\.\d+);/.test(navigator.userAgent)?new Number(RegExp.$1):null;
52 Rico.startTime=new Date();
53 Rico.timeStamp=function(){var a=new Date();
54 return(a.getTime()-this.startTime.getTime())+": "
55 };
56 Rico.setDebugArea=function(c,a){if(!this.debugArea||a){var b=document.getElementById(c);
57 if(!b){return
58 }this.debugArea=b;
59 b.value=""
60 }};
61 Rico.log=function(){};
62 Rico.enableLogging=function(){if(this.debugArea){this.log=function(b,a){if(a){this.debugArea.value=""
63 }this.debugArea.value+=this.timeStamp()+b+"\n"
64 }
65 }else{if(window.console){if(window.console.firebug){this.log=function(a){window.console.log(this.timeStamp(),a)
66 }
67 }else{this.log=function(a){window.console.log(this.timeStamp()+a)
68 }
69 }}else{if(window.opera){this.log=function(a){window.opera.postError(this.timeStamp()+a)
70 }
71 }}}};
72 Rico.$=function(a){return typeof a=="string"?document.getElementById(a):a
73 };
74 Rico.runLater=function(){var b=Array.prototype.slice.call(arguments);
75 var c=b.shift();
76 var a=b.shift();
77 var d=b.shift();
78 return setTimeout(function(){a[d].apply(a,b)
79 },c)
80 };
81 Rico.visible=function(a){return Rico.getStyle(a,"display")!="none"
82 };
83 Rico.show=function(a){a.style.display=""
84 };
85 Rico.hide=function(a){a.style.display="none"
86 };
87 Rico.toggle=function(a){a.style.display=a.style.display=="none"?"":"none"
88 };
89 Rico.direction=function(a){return(Rico.getStyle(a,"direction")||"ltr").toLowerCase()
90 };
91 Rico.viewportOffset=function(a){var b=Rico.cumulativeOffset(a);
92 b.left-=this.docScrollLeft();
93 b.top-=this.docScrollTop();
94 return b
95 };
96 Rico.getInnerText=function(f,b,g,e){switch(typeof f){case"string":return f;
97 case"undefined":return f;
98 case"number":return f.toString()
99 }var d=f.childNodes;
100 var a=d.length;
101 var h="";
102 for(var c=0;
103 c<a;
104 c++){switch(d[c].nodeType){case 1:if(this.getStyle(d[c],"display")=="none"){continue
105 }if(e&&this.hasClass(d[c],e)){continue
106 }switch(d[c].tagName.toLowerCase()){case"img":if(!b){h+=d[c].alt||d[c].title||d[c].src
107 }break;
108 case"input":if(!g&&!d[c].disabled&&d[c].type.toLowerCase()=="text"){h+=d[c].value
109 }break;
110 case"select":if(!g&&d[c].selectedIndex>=0){h+=d[c].options[d[c].selectedIndex].text
111 }break;
112 case"textarea":if(!g&&!d[c].disabled){h+=d[c].value
113 }break;
114 default:h+=this.getInnerText(d[c],b,g,e);
115 break
116 }break;
117 case 3:h+=d[c].nodeValue;
118 break
119 }}return h
120 };
121 Rico.getContentAsString=function(a,b){if(b){return this._getEncodedContent(a)
122 }if(typeof a.xml!="undefined"){return this._getContentAsStringIE(a)
123 }return this._getContentAsStringMozilla(a)
124 };
125 Rico._getEncodedContent=function(a){if(a.innerHTML){return a.innerHTML
126 }switch(a.childNodes.length){case 0:return"";
127 case 1:return a.firstChild.nodeValue;
128 default:return a.childNodes[1].nodeValue
129 }};
130 Rico._getContentAsStringIE=function(a){var c="";
131 for(var b=0;
132 b<a.childNodes.length;
133 b++){var d=a.childNodes[b];
134 c+=(d.nodeType==4)?d.nodeValue:d.xml
135 }return c
136 };
137 Rico._getContentAsStringMozilla=function(b){var a=new XMLSerializer();
138 var d="";
139 for(var c=0;
140 c<b.childNodes.length;
141 c++){var e=b.childNodes[c];
142 if(e.nodeType==4){d+=e.nodeValue
143 }else{d+=a.serializeToString(e)
144 }}return d
145 };
146 Rico.nan2zero=function(a){if(typeof(a)=="string"){a=parseInt(a,10)
147 }return isNaN(a)||typeof(a)=="undefined"?0:a
148 };
149 Rico.stripTags=function(a){return a.replace(/<\/?[^>]+>/gi,"")
150 };
151 Rico.truncate=function(a,b){return a.length>b?a.substr(0,b-3)+"...":a
152 };
153 Rico.zFill=function(d,c,b){var a=d.toString(b||10);
154 while(a.length<c){a="0"+a
155 }return a
156 };
157 Rico.keys=function(c){var b=[];
158 for(var a in c){b.push[a]
159 }return b
160 };
161 Rico.eventKey=function(a){if(typeof(a.keyCode)=="number"){return a.keyCode
162 }else{if(typeof(a.which)=="number"){return a.which
163 }else{if(typeof(a.charCode)=="number"){return a.charCode
164 }}}return -1
165 };
166 Rico.eventLeftClick=function(a){return(((a.which)&&(a.which==1))||((a.button)&&(a.button==1)))
167 };
168 Rico.eventRelatedTarget=function(a){return a.relatedTarget
169 };
170 Rico.getPreviosSiblingByTagName=function(c,b){var a=c.previousSibling;
171 while(a){if((a.tagName==b)&&(a.style.display!="none")){return a
172 }a=a.previousSibling
173 }return null
174 };
175 Rico.getParentByTagName=function(d,a,c){var b=d;
176 a=a.toLowerCase();
177 while(b){if(b.tagName&&b.tagName.toLowerCase()==a){if(!c||b.className.indexOf(c)>=0){return b
178 }}b=b.parentNode
179 }return null
180 };
181 Rico.wrapChildren=function(b,a,e,c){var d=document.createElement(c||"div");
182 if(e){d.id=e
183 }if(a){d.className=a
184 }while(b.firstChild){d.appendChild(b.firstChild)
185 }b.appendChild(d);
186 return d
187 };
188 Rico.positionCtlOverIcon=function(g,k){k=this.$(k);
189 var c=this.cumulativeOffset(k);
190 var j=this.docScrollTop();
191 var a=this.windowHeight();
192 if(g.style.display=="none"){g.style.display="block"
193 }var h=2;
194 var b=this.nan2zero(this.getStyle(k,"paddingLeft"));
195 g.style.left=(c.left+b+h)+"px";
196 var i=c.top+h;
197 var f=g.offsetHeight;
198 var e=k.offsetHeight;
199 var d=10;
200 if(i+e+f+d<a+j){i+=e
201 }else{i=Math.max(i-f,j)
202 }g.style.top=i+"px"
203 };
204 Rico.createFormField=function(d,b,f,g,a){var e;
205 if(typeof a!="string"){a=g
206 }if(this.isIE&&this.ieVersion<8){var c=b+' id="'+g+'"';
207 if(f){c+=' type="'+f+'"'
208 }if(b.match(/^(form|input|select|textarea|object|button|img)$/)){c+=' name="'+a+'"'
209 }e=document.createElement("<"+c+" />")
210 }else{e=document.createElement(b);
211 if(f){e.type=f
212 }e.id=g;
213 if(typeof e.name=="string"){e.name=a
214 }}d.appendChild(e);
215 return e
216 };
217 Rico.addSelectOption=function(b,c,d){var a=document.createElement("option");
218 if(typeof c=="string"){a.value=c
219 }a.text=d;
220 if(this.isIE){b.add(a)
221 }else{b.add(a,null)
222 }return a
223 };
224 Rico.getCookie=function(g){var b=g+"=";
225 var f=b.length;
226 var a=document.cookie.length;
227 var d=0;
228 while(d<a){var c=d+f;
229 if(document.cookie.substring(d,c)==b){var e=document.cookie.indexOf(";",c);
230 if(e==-1){e=document.cookie.length
231 }return unescape(document.cookie.substring(c,e))
232 }d=document.cookie.indexOf(" ",d)+1;
233 if(d==0){break
234 }}return null
235 };
236 Rico.getTBody=function(a){return a.tBodies.length==0?a.appendChild(document.createElement("tbody")):a.tBodies[0]
237 };
238 Rico.setCookie=function(e,g,f,d,a){var h=e+"="+escape(g);
239 if(typeof(f)=="number"){var b=new Date();
240 b.setTime(b.getTime()+(f*24*60*60*1000));
241 h+="; expires="+b.toGMTString()
242 }if(typeof(d)=="string"){h+="; path="+d
243 }if(typeof(a)=="string"){h+="; domain="+a
244 }document.cookie=h
245 };
246 Rico.phrasesById={};
247 Rico.thouSep=",";
248 Rico.decPoint=".";
249 Rico.langCode="en";
250 Rico.dateFmt="mm/dd/yyyy";
251 Rico.timeFmt="hh:nn:ss a/pm";
252 Rico.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];
253 Rico.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
254 Rico.monthAbbr=function(a){return this.monthNamesShort?this.monthNamesShort[a]:this.monthNames[a].substr(0,3)
255 };
256 Rico.dayAbbr=function(a){return this.dayNamesShort?this.dayNamesShort[a]:this.dayNames[a].substr(0,3)
257 };
258 Rico.addPhraseId=function(b,a){this.phrasesById[b]=a
259 };
260 Rico.getPhraseById=function(d){var b=this.phrasesById[d];
261 if(!b){alert("Error: missing phrase for "+d);
262 return""
263 }if(arguments.length<=1){return b
264 }var c=arguments;
265 return b.replace(/(\$\d)/g,function(e){var a=parseInt(e.charAt(1),10);
266 return(a<c.length)?c[a]:""
267 })
268 };
269 Rico.formatPosNumber=function(e,f,c){var b=e.toFixed(f).split(/\./);
270 if(c){var d=/(\d+)(\d{3})/;
271 while(d.test(b[0])){b[0]=b[0].replace(d,"$1"+Rico.thouSep+"$2")
272 }}return b.join(Rico.decPoint)
273 };
274 Rico.formatNumber=function(b,c){if(typeof b=="string"){b=parseFloat(b.replace(/,/,"."),10)
275 }if(isNaN(b)){return"NaN"
276 }if(typeof c.multiplier=="number"){b*=c.multiplier
277 }var h=typeof c.decPlaces=="number"?c.decPlaces:0;
278 var e=typeof c.thouSep=="undefined"?true:this.thouSep;
279 var d=c.prefix||"";
280 var f=c.suffix||"";
281 var a=typeof c.negSign=="string"?c.negSign:"L";
282 a=a.toUpperCase();
283 var i,g;
284 if(b<0){i=this.formatPosNumber(-b,h,e);
285 if(a=="P"){i="("+i+")"
286 }i=d+i;
287 if(a=="L"){i="-"+i
288 }if(a=="T"){i+="-"
289 }g="negNumber"
290 }else{g=b==0?"zeroNumber":"posNumber";
291 i=d+this.formatPosNumber(b,h,e)
292 }return"<span class='"+g+"'>"+i+f+"</span>"
293 };
294 Rico.formatDate=function(c,a){var b=(typeof a=="string")?a:"translateDate";
295 switch(b){case"locale":case"localeDateTime":return c.toLocaleString();
296 case"localeDate":return c.toLocaleDateString();
297 case"translate":case"translateDateTime":b=this.dateFmt+" "+this.timeFmt;
298 break;
299 case"translateDate":b=this.dateFmt;
300 break
301 }return b.replace(/(yyyy|yy|mmmm|mmm|mm|dddd|ddd|dd|d|hh|nn|ss|a\/p)/gi,function(d){var e;
302 switch(d){case"yyyy":return c.getFullYear();
303 case"yy":return c.getFullYear().toString().substr(2);
304 case"mmmm":return Rico.monthNames[c.getMonth()];
305 case"mmm":return Rico.monthAbbr(c.getMonth());
306 case"mm":return Rico.zFill(c.getMonth()+1,2);
307 case"m":return(c.getMonth()+1);
308 case"dddd":return Rico.dayNames[c.getDay()];
309 case"ddd":return Rico.dayAbbr(c.getDay());
310 case"dd":return Rico.zFill(c.getDate(),2);
311 case"d":return c.getDate();
312 case"hh":return Rico.zFill((e=c.getHours()%12)?e:12,2);
313 case"h":return((e=c.getHours()%12)?e:12);
314 case"HH":return Rico.zFill(c.getHours(),2);
315 case"H":return c.getHours();
316 case"nn":return Rico.zFill(c.getMinutes(),2);
317 case"ss":return Rico.zFill(c.getSeconds(),2);
318 case"a/p":return c.getHours()<12?"a":"p"
319 }})
320 };
321 Rico.setISO8601=function(b,f){if(!b){return false
322 }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))?)?)?)?)?)?/);
323 if(!e){return false
324 }if(!f){f=0
325 }var a=new Date(e[1],0,1);
326 if(e[2]){a.setMonth(e[2]-1)
327 }if(e[3]){a.setDate(e[3])
328 }if(e[4]){a.setHours(e[4])
329 }if(e[5]){a.setMinutes(e[5])
330 }if(e[6]){a.setSeconds(e[6])
331 }if(e[7]){a.setMilliseconds(Number("0."+e[7])*1000)
332 }if(e[8]){if(e[10]&&e[11]){f=(Number(e[10])*60)+Number(e[11])
333 }f*=((e[9]=="-")?1:-1);
334 f-=a.getTimezoneOffset()
335 }var c=(Number(a)+(f*60*1000));
336 a.setTime(Number(c));
337 return a
338 };
339 Rico.toISO8601String=function(a,e,h){if(!e){e=6
340 }if(!h){h="Z"
341 }else{var g=h.match(/([-+])([0-9]{2}):([0-9]{2})/);
342 var c=(Number(g[2])*60)+Number(g[3]);
343 c*=((g[1]=="-")?-1:1);
344 a=new Date(Number(Number(a)+(c*60000)))
345 }var i=function(d){return((d<10)?"0":"")+d
346 };
347 var f=a.getUTCFullYear();
348 if(e>1){f+="-"+i(a.getUTCMonth()+1)
349 }if(e>2){f+="-"+i(a.getUTCDate())
350 }if(e>3){f+="T"+i(a.getUTCHours())+":"+i(a.getUTCMinutes())
351 }if(e>5){var b=Number(a.getUTCSeconds()+"."+((a.getUTCMilliseconds()<100)?"0":"")+i(a.getUTCMilliseconds()));
352 f+=":"+i(b)
353 }else{if(e>4){f+=":"+i(a.getUTCSeconds())
354 }}if(e>3){f+=h
355 }return f
356 };
357 Rico.createXmlDocument=function(){if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);
358 if(a.readyState==null){a.readyState=1;
359 a.addEventListener("load",function(){a.readyState=4;
360 if(typeof a.onreadystatechange=="function"){a.onreadystatechange()
361 }},false)
362 }return a
363 }if(window.ActiveXObject){return Rico.tryFunctions(function(){return new ActiveXObject("MSXML2.DomDocument")
364 },function(){return new ActiveXObject("Microsoft.DomDocument")
365 },function(){return new ActiveXObject("MSXML.DomDocument")
366 },function(){return new ActiveXObject("MSXML3.DomDocument")
367 })||false
368 }return null
369 };
370 Rico.ajaxUpdater=function(c,b,a){this.updateSend(c,b,a)
371 };
372 Rico.ajaxUpdater.prototype={updateSend:function(d,c,b){this.element=d;
373 this.onComplete=b.onComplete;
374 var a=this;
375 b.onComplete=function(e){a.updateComplete(e)
376 };
377 new Rico.ajaxRequest(c,b)
378 },updateComplete:function(a){this.element.innerHTML=a.responseText;
379 if(this.onComplete){this.onComplete(a)
380 }}};
381 try{document.execCommand("BackgroundImageCache",false,true)
382 }catch(err){}Rico.eventBind(window,"load",Rico.eventHandle(Rico,"windowLoaded"));
383 Rico.applyShadow=function(b,a){if(typeof a=="undefined"){a=true
384 }if(a){Rico.addClass(b,"ricoShadow")
385 }return b
386 };
387 Rico._OpenPopupList=[];
388 Rico._RemoveOpenPopup=function(a){if(a.openIndex>=0&&a.openIndex<Rico._OpenPopupList.length){Rico._OpenPopupList.splice(a.openIndex,1)
389 }a.openIndex=-1
390 };
391 Rico._AddOpenPopup=function(a){a.openIndex=Rico._OpenPopupList.push(a)-1
392 };
393 Rico._checkEscKey=function(b){if(Rico.eventKey(b)!=27){return true
394 }while(Rico._OpenPopupList.length>0){var a=Rico._OpenPopupList.pop();
395 if(a&&a.visible()){a.openIndex=-1;
396 Rico.eventStop(b);
397 a.closeFunc();
398 return false
399 }}return true
400 };
401 Rico.eventBind(document,"keyup",Rico.eventHandle(Rico,"_checkEscKey"));
402 Rico.Popup=function(b,a){this.initialize(b,a)
403 };
404 Rico.Popup.prototype={initialize:function(b,a){this.options={hideOnClick:false,ignoreClicks:false,position:"absolute",shadow:true,zIndex:2,canDrag:false,dragElement:false,closeFunc:false};
405 this.openIndex=-1;
406 if(b){this.setDiv(b,a)
407 }},createContainer:function(a){this.setDiv(document.createElement("div"),a);
408 if(a&&a.parent){a.parent.appendChild(this.container)
409 }else{document.getElementsByTagName("body")[0].appendChild(this.container)
410 }},setDiv:function(c,b){Rico.extend(this.options,b||{});
411 this.container=Rico.$(c);
412 if(this.options.position=="auto"){this.position=Rico.getStyle(this.container,"position").toLowerCase()
413 }else{this.position=this.container.style.position=this.options.position
414 }this.content=document.createElement("div");
415 while(this.container.firstChild){this.content.appendChild(this.container.firstChild)
416 }this.container.appendChild(this.content);
417 this.content.className="RicoPopupContent";
418 if(this.position!="absolute"){return
419 }if(this.options.closeFunc){this.closeFunc=this.options.closeFunc
420 }else{var a=this;
421 this.closeFunc=function(){a.closePopup()
422 }
423 }this.container.style.top="0px";
424 this.container.style.left="0px";
425 this.container.style.display="none";
426 if(this.options.zIndex>=0){this.container.style.zIndex=this.options.zIndex
427 }if(Rico.isIE&&Rico.ieVersion<7&&this.options.shim!==false){this.content.style.position="relative";
428 this.content.style.zIndex=2;
429 this.ifr=document.createElement("iframe");
430 this.ifr.className="RicoShim";
431 this.ifr.frameBorder=0;
432 this.ifr.src="javascript:'';";
433 this.container.appendChild(this.ifr)
434 }Rico.applyShadow(this.container,this.options.shadow);
435 if(this.options.hideOnClick){Rico.eventBind(document,"click",Rico.eventHandle(this,"_docClick"))
436 }this.dragEnabled=false;
437 this.mousedownHandler=Rico.eventHandle(this,"_startDrag");
438 this.dragHandler=Rico.eventHandle(this,"_drag");
439 this.dropHandler=Rico.eventHandle(this,"_endDrag");
440 if(this.options.canDrag){this.enableDragging()
441 }if(this.options.ignoreClicks||this.options.canDrag){this.ignoreClicks()
442 }},clearContent:function(){this.content.innerHTML=""
443 },setContent:function(a){this.content.innerHTML=a
444 },enableDragging:function(){if(!this.dragEnabled&&this.options.dragElement){Rico.eventBind(this.options.dragElement,"mousedown",this.mousedownHandler);
445 this.dragEnabled=true
446 }return this.dragEnabled
447 },disableDragging:function(){if(!this.dragEnabled){return
448 }Rico.eventUnbind(this.options.dragElement,"mousedown",this.mousedownHandler);
449 this.dragEnabled=false
450 },setZ:function(a){this.container.style.zIndex=a
451 },ignoreClicks:function(){Rico.eventBind(this.container,"click",Rico.eventHandle(this,"_ignoreClick"))
452 },_ignoreClick:function(a){if(a.stopPropagation){a.stopPropagation()
453 }else{a.cancelBubble=true
454 }return true
455 },_docClick:function(a){this.closeFunc();
456 return true
457 },move:function(b,a){if(typeof b=="number"){this.container.style.left=b+"px"
458 }if(typeof a=="number"){this.container.style.top=a+"px"
459 }},_startDrag:function(b){var a=Rico.eventElement(b);
460 this.container.style.cursor="move";
461 this.lastMouse=Rico.eventClient(b);
462 Rico.eventBind(document,"mousemove",this.dragHandler);
463 Rico.eventBind(document,"mouseup",this.dropHandler);
464 Rico.eventStop(b)
465 },_drag:function(d){var b=Rico.eventClient(d);
466 var c=parseInt(this.container.style.left,10)+b.x-this.lastMouse.x;
467 var a=parseInt(this.container.style.top,10)+b.y-this.lastMouse.y;
468 this.move(c,a);
469 this.lastMouse=b;
470 Rico.eventStop(d)
471 },_endDrag:function(){this.container.style.cursor="";
472 Rico.eventUnbind(document,"mousemove",this.dragHandler);
473 Rico.eventUnbind(document,"mouseup",this.dropHandler)
474 },openPopup:function(b,a){this.move(b,a);
475 this.container.style.display="";
476 if(this.container.id){Rico.log("openPopup "+this.container.id+" at "+b+","+a)
477 }Rico._AddOpenPopup(this)
478 },centerPopup:function(){this.openPopup();
479 var d=this.container.offsetWidth;
480 var c=this.container.offsetHeight;
481 var a=this.container.parentNode.offsetWidth;
482 var b=this.container.parentNode.offsetHeight;
483 this.move(parseInt(Math.max((a-d)/2,0),10),parseInt(Math.max((b-c)/2,0),10))
484 },visible:function(){return Rico.visible(this.container)
485 },closePopup:function(){Rico._RemoveOpenPopup(this);
486 if(!Rico.visible(this.container)){return
487 }if(this.container.id){Rico.log("closePopup "+this.container.id)
488 }if(this.dragEnabled){this._endDrag()
489 }this.container.style.display="none";
490 if(this.options.onClose){this.options.onClose()
491 }}};
492 Rico.closeButton=function(d){var b=document.createElement("a");
493 b.className="RicoCloseAnchor";
494 if(Rico.theme.closeAnchor){Rico.addClass(b,Rico.theme.closeAnchor)
495 }var c=b.appendChild(document.createElement("span"));
496 c.title=Rico.getPhraseById("close");
497 new Rico.HoverSet([b],{hoverClass:Rico.theme.hover||"ricoCloseHover"});
498 Rico.addClass(c,Rico.theme.close||"rico-icon RicoClose");
499 Rico.eventBind(b,"click",d);
500 return b
501 };
502 Rico.floatButton=function(b,e,f){var c=document.createElement("a");
503 c.className="RicoButtonAnchor";
504 Rico.addClass(c,Rico.theme.buttonAnchor||"RicoButtonAnchorNative");
505 var d=c.appendChild(document.createElement("span"));
506 if(f){d.title=f
507 }d.className=Rico.theme[b.toLowerCase()]||"rico-icon Rico"+b;
508 Rico.eventBind(c,"click",e,false);
509 new Rico.HoverSet([c]);
510 return c
511 };
512 Rico.clearButton=function(b){var a=document.createElement("span");
513 a.title=Rico.getPhraseById("clear");
514 a.className="ricoClear";
515 Rico.addClass(a,Rico.theme.clear||"rico-icon ricoClearNative");
516 Rico.eventBind(a,"click",b);
517 return a
518 };
519 Rico.Window=function(c,a,b){this.initialize(c,a,b)
520 };
521 Rico.Window.prototype={initialize:function(c,a,b){a=a||{overflow:"auto"};
522 Rico.extend(this,new Rico.Popup());
523 this.titleDiv=document.createElement("div");
524 this.options.canDrag=true;
525 this.options.dragElement=this.titleDiv;
526 this.createContainer(a);
527 this.content.appendChild(this.titleDiv);
528 b=Rico.$(b);
529 this.contentDiv=b||document.createElement("div");
530 this.content.appendChild(this.contentDiv);
531 this.titleDiv.className="ricoTitle";
532 if(Rico.theme.dialogTitle){Rico.addClass(this.titleDiv,Rico.theme.dialogTitle)
533 }this.titleDiv.style.position="relative";
534 this.titleContent=document.createElement("span");
535 this.titleContent.className="ricoTitleSpan";
536 this.titleDiv.appendChild(this.titleContent);
537 this.titleDiv.appendChild(Rico.closeButton(Rico.eventHandle(this,"closeFunc")));
538 if(!c&&b){c=b.title;
539 b.title=""
540 }this.setTitle(c||"&nbsp;");
541 this.contentDiv.className="ricoContent";
542 if(Rico.theme.dialogContent){Rico.addClass(this.contentDiv,Rico.theme.dialogContent)
543 }this.contentDiv.style.position="relative";
544 if(a.height){this.contentDiv.style.height=a.height
545 }if(a.width){this.contentDiv.style.width=a.width
546 }if(a.overflow){this.contentDiv.style.overflow=a.overflow
547 }Rico.addClass(this.content,"ricoWindow");
548 if(Rico.theme.dialog){Rico.addClass(this.container,Rico.theme.dialog)
549 }this.content=this.contentDiv
550 },setTitle:function(a){this.titleContent.innerHTML=a
551 }};
552 Rico.Menu=function(a){this.initialize(a)
553 };
554 Rico.Menu.prototype={initialize:function(a){Rico.extend(this,new Rico.Popup());
555 Rico.extend(this.options,{width:"15em",arrowColor:"b",showDisabled:false,hideOnClick:true});
556 if(typeof a=="string"){this.options.width=a
557 }else{Rico.extend(this.options,a||{})
558 }this.hideFunc=null;
559 this.highlightElem=null
560 },createDiv:function(a){if(this.container){return
561 }var b=this;
562 var c={closeFunc:function(){b.cancelmenu()
563 }};
564 if(a){c.parent=a
565 }this.createContainer(c);
566 this.content.className=Rico.isWebKit?"ricoMenuSafari":"ricoMenu";
567 this.content.style.width=this.options.width;
568 this.direction=Rico.direction(this.container);
569 this.hidemenu();
570 this.itemCount=0
571 },showmenu:function(b,c){Rico.eventStop(b);
572 this.hideFunc=c;
573 if(this.content.childNodes.length==0){this.cancelmenu();
574 return false
575 }var a=Rico.eventClient(b);
576 this.openmenu(a.x,a.y,0,0)
577 },openmenu:function(g,f,j,e,a){var h=g+(a?0:Rico.docScrollLeft());
578 this.container.style.visibility="hidden";
579 this.container.style.display="block";
580 var i=this.container.offsetWidth;
581 var b=this.content.offsetWidth;
582 if(this.direction=="rtl"){if(h>i+j){h-=b+j
583 }}else{if(g+i>Rico.windowWidth()){h-=b+j-2
584 }}var d=Rico.docScrollTop();
585 var c=f+(a?0:d);
586 if(f+this.container.offsetHeight-d>Rico.windowHeight()){c=Math.max(c-this.content.offsetHeight+e,0)
587 }this.openPopup(h,c);
588 this.container.style.visibility="visible";
589 return false
590 },clearMenu:function(){this.clearContent();
591 this.defaultAction=null;
592 this.itemCount=0
593 },addMenuHeading:function(b){var a=document.createElement("div");
594 a.innerHTML=b;
595 a.className="ricoMenuHeading";
596 this.content.appendChild(a)
597 },addMenuBreak:function(){var a=document.createElement("div");
598 a.className="ricoMenuBreak";
599 this.content.appendChild(a)
600 },addSubMenuItem:function(b,e,g){var d=this.direction=="rtl"?"left":"right";
601 var c=this.addMenuItem(b,null,true,null,g);
602 c.className="ricoSubMenu";
603 var f=c.appendChild(document.createElement("div"));
604 f.className="rico-icon rico-"+d+"-"+this.options.arrowColor;
605 Rico.setStyle(f,{position:"absolute",top:"2px"});
606 f.style[d]="0px";
607 c.RicoSubmenu=e;
608 Rico.eventBind(c,"mouseover",Rico.eventHandle(this,"showSubMenu"))
609 },showSubMenu:function(c){if(this.openSubMenu){this.hideSubMenu()
610 }var b=Rico.eventElement(c);
611 if(!b.RicoSubmenu){b=b.parentNode
612 }if(!b.RicoSubmenu){return
613 }this.openSubMenu=b.RicoSubmenu;
614 this.openMenuAnchor=b;
615 if(Rico.hasClass(b,"ricoSubMenu")){Rico.removeClass(b,"ricoSubMenu");
616 Rico.addClass(b,"ricoSubMenuOpen")
617 }b.RicoSubmenu.openmenu(parseInt(this.container.style.left)+b.offsetWidth,parseInt(this.container.style.top)+b.offsetTop,b.offsetWidth-2,b.offsetHeight+2,true)
618 },hideSubMenu:function(){if(this.openMenuAnchor){Rico.removeClass(this.openMenuAnchor,"ricoSubMenuOpen");
619 Rico.addClass(this.openMenuAnchor,"ricoSubMenu");
620 this.openMenuAnchor=null
621 }if(this.openSubMenu){this.openSubMenu.hidemenu();
622 this.openSubMenu=null
623 }},addMenuItemId:function(c,b,a,e,d){if(arguments.length<3){a=true
624 }this.addMenuItem(Rico.getPhraseById(c),b,a,e,d)
625 },addMenuItem:function(b,e,d,g,f){if(arguments.length>=3&&!d&&!this.options.showDisabled){return null
626 }this.itemCount++;
627 var c=document.createElement(typeof e=="string"?"a":"div");
628 if(arguments.length<3||d){if(typeof e=="string"){c.href=e;
629 if(f){c.target=f
630 }}else{if(f=="event"){Rico.eventBind(c,"click",e)
631 }else{c.onclick=e
632 }}c.className="enabled";
633 if(this.defaultAction==null){this.defaultAction=e
634 }}else{c.disabled=true;
635 c.className="disabled"
636 }c.innerHTML=b;
637 if(typeof g=="string"){c.title=g
638 }c=this.content.appendChild(c);
639 Rico.eventBind(c,"mouseover",Rico.eventHandle(this,"mouseOver"));
640 Rico.eventBind(c,"mouseout",Rico.eventHandle(this,"mouseOut"));
641 return c
642 },mouseOver:function(b){if(this.highlightElem&&this.highlightElem.className=="enabled-hover"){this.highlightElem.className="enabled";
643 this.highlightElem=null
644 }var a=Rico.eventElement(b);
645 if(a.parentNode==this.openMenuAnchor){a=a.parentNode
646 }if(this.openMenuAnchor&&this.openMenuAnchor!=a){this.hideSubMenu()
647 }if(a.className=="enabled"){a.className="enabled-hover";
648 this.highlightElem=a
649 }},mouseOut:function(b){var a=Rico.eventElement(b);
650 if(a.className=="enabled-hover"){a.className="enabled"
651 }if(this.highlightElem==a){this.highlightElem=null
652 }},cancelmenu:function(){if(!this.visible()){return
653 }if(this.hideFunc){this.hideFunc()
654 }this.hideFunc=null;
655 this.hidemenu()
656 },hidemenu:function(){if(this.openSubMenu){this.openSubMenu.hidemenu()
657 }this.closePopup()
658 }};
659 Rico.SelectionSet=function(b,a){this.initialize(b,a)
660 };
661 Rico.SelectionSet.prototype={initialize:function(e,b){Rico.log("SelectionSet#initialize");
662 this.options=b||{};
663 if(typeof e=="string"){e=Rico.select(e)
664 }this.previouslySelected=[];
665 this.selectionSet=[];
666 this.selectedClassName=this.options.selectedClass||Rico.theme.selected||"selected";
667 this.selectNode=this.options.selectNode||function(f){return f
668 };
669 this.onSelect=this.options.onSelect;
670 this.onFirstSelect=this.options.onFirstSelect;
671 var a=this;
672 this.clickHandler=function(f){a.selectIndex(f)
673 };
674 this.selectedIndex=-1;
675 for(var c=0;
676 c<e.length;
677 c++){this.add(e[c])
678 }if(!this.options.noDefault){var d=this.options.cookieName?this.getCookie():0;
679 this.selectIndex(d||this.options.selectedIndex||0)
680 }},getCookie:function(){var b=Rico.getCookie(this.options.cookieName);
681 if(!b){return 0
682 }var a=parseInt(b);
683 return a<this.selectionSet.length?a:0
684 },reset:function(){this.previouslySelected=[];
685 this._notifySelected(this.selectedIndex)
686 },clearSelected:function(){if(this.selected){Rico.removeClass(this.selectNode(this.selected),this.selectedClassName)
687 }},getIndex:function(b){for(var a=0;
688 a<this.selectionSet.length;
689 a++){if(b==this.selectionSet[a]){return a
690 }}return -1
691 },select:function(b){if(this.selected==b){return
692 }var a=this.getIndex(b);
693 if(a>=0){this.selectIndex(a)
694 }},_notifySelected:function(a){if(a<0){return
695 }var b=this.selectionSet[a];
696 if(this.options.cookieName){Rico.setCookie(this.options.cookieName,a,this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
697 }if(this.onFirstSelect&&!this.previouslySelected[a]){this.onFirstSelect(b,a);
698 this.previouslySelected[a]=true
699 }if(this.onSelect){try{this.onSelect(a)
700 }catch(c){}}},selectIndex:function(a){if(this.selectedIndex==a||a>=this.selectionSet.length){return
701 }this.clearSelected();
702 this._notifySelected(a);
703 this.selectedIndex=a;
704 this.selected=this.selectionSet[a].element;
705 Rico.addClass(this.selectNode(this.selected),this.selectedClassName)
706 },nextSelectIndex:function(){return(this.selectedIndex+1)%this.selectionSet.length
707 },nextSelectItem:function(){return this.selectionSet[this.nextSelectIndex()]
708 },selectNext:function(){this.selectIndex(this.nextSelectIndex())
709 },add:function(b){var a=this.selectionSet.length;
710 this.selectionSet[a]=new Rico._SelectionItem(b,a,this.clickHandler)
711 },remove:function(b){if(b==this.selected){this.clearSelected()
712 }var a=this.getIndex(b);
713 if(a<0){return
714 }this.selectionSet[a].remove();
715 this.selectionSet.splice(a,1)
716 },removeAll:function(){this.clearSelected();
717 while(this.selectionSet.length>0){this.selectionSet.pop().remove()
718 }}};
719 Rico._SelectionItem=function(b,a,c){this.add(b,a,c)
720 };
721 Rico._SelectionItem.prototype={add:function(b,a,c){this.element=b;
722 this.index=a;
723 this.callback=c;
724 this.handle=Rico.eventHandle(this,"click");
725 Rico.eventBind(b,"click",this.handle)
726 },click:function(a){this.callback(this.index)
727 },remove:function(){Rico.eventUnbind(this.element,"click",this.handle)
728 }};
729 Rico.HoverSet=function(b,a){this.initialize(b,a)
730 };
731 Rico.HoverSet.prototype={initialize:function(c,a){Rico.log("HoverSet#initialize");
732 a=a||{};
733 this.hoverClass=a.hoverClass||Rico.theme.hover||"hover";
734 this.hoverFunc=a.hoverNodes||function(d){return[d]
735 };
736 this.hoverSet=[];
737 if(!c){return
738 }for(var b=0;
739 b<c.length;
740 b++){this.add(c[b])
741 }},add:function(a){this.hoverSet.push(new Rico._HoverItem(a,this.hoverFunc,this.hoverClass))
742 },removeAll:function(){while(this.hoverSet.length>0){this.hoverSet.pop().remove()
743 }}};
744 Rico._HoverItem=function(b,a,c){this.add(b,a,c)
745 };
746 Rico._HoverItem.prototype={add:function(b,a,c){this.element=b;
747 this.selectFunc=a;
748 this.hoverClass=c;
749 this.movehandle=Rico.eventHandle(this,"move");
750 this.outhandle=Rico.eventHandle(this,"mouseout");
751 Rico.eventBind(b,"mousemove",this.movehandle);
752 Rico.eventBind(b,"mouseout",this.outhandle)
753 },move:function(c){var a=this.selectFunc(this.element);
754 for(var b=0;
755 b<a.length;
756 b++){Rico.addClass(a[b],this.hoverClass)
757 }},mouseout:function(c){var a=this.selectFunc(this.element);
758 for(var b=0;
759 b<a.length;
760 b++){Rico.removeClass(a[b],this.hoverClass)
761 }},remove:function(){Rico.eventUnbind(element,"mousemove",this.movehandle);
762 Rico.eventUnbind(element,"mouseout",this.outhandle)
763 }};
764 Rico.ContentTransitionBase=function(){};
765 Rico.ContentTransitionBase.prototype={initBase:function(e,d,b){this.options=b||{};
766 this.titles=e;
767 this.contents=d;
768 this.hoverSet=new Rico.HoverSet(e,b);
769 for(var c=0;
770 c<d.length;
771 c++){if(d[c]){Rico.hide(d[c])
772 }}var a=this;
773 this.selectionSet=new Rico.SelectionSet(e,Rico.extend(b,{onSelect:function(f){a._finishSelect(f)
774 }}))
775 },reset:function(){this.selectionSet.reset()
776 },select:function(a){this.selectionSet.selectIndex(a)
777 },_finishSelect:function(b){Rico.log("ContentTransitionBase#_finishSelect");
778 var a=this.contents[b];
779 if(!a){alert("Internal error: no panel @index="+b);
780 return
781 }if(this.selected==a){return
782 }if(this.transition){if(this.selected){this.transition(a)
783 }else{a.style.display="block"
784 }}else{if(this.selected){Rico.hide(this.selected)
785 }a.style.display="block"
786 }this.selected=a
787 },addBase:function(b,a){this.titles.push(b);
788 this.contents.push(a);
789 this.hoverSet.add(b);
790 this.selectionSet.add(b);
791 Rico.hide(a)
792 },removeAll:function(){this.hoverSet.removeAll();
793 this.selectionSet.removeAll()
794 }};
795 Rico.Accordion=function(b,a){this.initialize(b,a)
796 };
797 Rico.Accordion.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(g,e){g=Rico.$(g);
798 g.style.overflow="hidden";
799 g.className=e.accClass||Rico.theme.accordion||"Rico_accordion";
800 if(typeof e.panelWidth=="number"){e.panelWidth+="px"
801 }if(e.panelWidth){g.style.width=e.panelWidth
802 }var d=Rico.getDirectChildrenByTag(g,"div");
803 var c,j=[],h=[];
804 for(var f=0;
805 f<d.length;
806 f++){c=Rico.getDirectChildrenByTag(d[f],"div");
807 if(c.length>=2){c[0].className=e.titleClass||Rico.theme.accTitle||"Rico_accTitle";
808 c[1].className=e.contentClass||Rico.theme.accContent||"Rico_accContent";
809 j.push(c[0]);
810 h.push(c[1]);
811 var b=Rico.wrapChildren(c[0],"","","a");
812 b.href="javascript:void(0)"
813 }}Rico.log("creating Rico.Accordion for "+g.id+" with "+j.length+" panels");
814 this.initBase(j,h,e);
815 this.selected.style.height=this.options.panelHeight+"px";
816 this.totSteps=(typeof e.duration=="number"?e.duration:200)/25
817 },transition:function(b){if(!this.options.noAnimate){this.closing=this.selected;
818 this.opening=b;
819 this.curStep=0;
820 var a=this;
821 this.timer=setInterval(function(){a.step()
822 },25)
823 }else{b.style.height=this.options.panelHeight+"px";
824 if(this.selected){Rico.hide(this.selected)
825 }b.style.display="block"
826 }},step:function(){this.curStep++;
827 var a=Math.round(this.curStep/this.totSteps*this.options.panelHeight);
828 this.opening.style.height=a+"px";
829 this.closing.style.height=(this.options.panelHeight-a)+"px";
830 if(this.curStep==1){this.opening.style.paddingTop=this.opening.style.paddingBottom="0px";
831 this.opening.style.display="block"
832 }if(this.curStep==this.totSteps){clearInterval(this.timer);
833 this.opening.style.paddingTop=this.opening.style.paddingBottom="";
834 Rico.hide(this.closing)
835 }},setPanelHeight:function(a){this.options.panelHeight=a;
836 this.selected.style.height=this.options.panelHeight+"px"
837 }});
838 Rico.TabbedPanel=function(b,a){this.initialize(b,a)
839 };
840 Rico.TabbedPanel.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(d,l){d=Rico.$(d);
841 l=l||{};
842 if(typeof l.panelWidth=="number"){l.panelWidth+="px"
843 }if(typeof l.panelHeight=="number"){l.panelHeight+="px"
844 }d.className=l.tabClass||Rico.theme.tabPanel||"Rico_tabPanel";
845 if(l.panelWidth){d.style.width=l.panelWidth
846 }var g=[];
847 var k=d.childNodes;
848 for(var e=0;
849 e<k.length;
850 e++){if(k[e]&&k[e].tagName&&k[e].tagName.match(/^div|ul$/i)){g.push(k[e])
851 }}if(g.length<2){return
852 }var c=g[0].tagName.toLowerCase()=="ul"?"li":"div";
853 g[0].className=l.navContainerClass||Rico.theme.tabNavContainer||"Rico_tabNavContainer";
854 g[0].style.listStyle="none";
855 g[1].className=l.contentContainerClass||Rico.theme.tabContentContainer||"Rico_tabContentContainer";
856 var f=Rico.getDirectChildrenByTag(g[0],c);
857 var b=Rico.getDirectChildrenByTag(g[1],"div");
858 var j=Rico.direction(d);
859 if(!l.corners){l.corners="top"
860 }for(var e=0;
861 e<f.length;
862 e++){if(j=="rtl"){Rico.setStyle(f[e],{"float":"right"})
863 }f[e].className=l.titleClass||Rico.theme.tabTitle||"Rico_tabTitle";
864 var h=Rico.wrapChildren(f[e],"","","a");
865 h.href="javascript:void(0)";
866 b[e].className=l.contentClass||Rico.theme.tabContent||"Rico_tabContent";
867 if(l.panelHeight){b[e].style.overflow="auto"
868 }if(l.corners!="none"){if(l.panelHdrWidth){f[e].style.width=l.panelHdrWidth
869 }Rico.Corner.round(f[e],Rico.theme.tabCornerOptions||l)
870 }}l.selectedClass=Rico.theme.tabSelected||"selected";
871 this.initBase(f,b,l);
872 if(this.selected){this.transition(this.selected)
873 }},transition:function(a){Rico.log("TabbedPanel#transition "+typeof(a));
874 if(this.selected){Rico.hide(this.selected)
875 }Rico.show(a);
876 if(this.options.panelHeight){a.style.height=this.options.panelHeight
877 }}});
878 Rico.Corner={round:function(b,a){b=Rico.$(b);
879 this.options={corners:"all",bgColor:"fromParent",compact:false,nativeCorners:false};
880 Rico.extend(this.options,a||{});
881 if(typeof(Rico.getStyle(b,"border-radius"))=="string"){this._roundCornersStdCss(b)
882 }else{if(typeof(Rico.getStyle(b,"-webkit-border-radius"))=="string"){this._roundCornersWebKit(b)
883 }else{if(typeof(Rico.getStyle(b,"-moz-border-radius"))=="string"){this._roundCornersMoz(b)
884 }else{if(!this.options.nativeCorners){this._roundCornersImpl(b)
885 }}}}},_roundCornersStdCss:function(b){var a=this.options.compact?"4px":"8px";
886 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{borderRadius:a})
887 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{borderTopLeftRadius:a})
888 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{borderTopRightRadius:a})
889 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{borderBottomLeftRadius:a})
890 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{borderBottomRightRadius:a})
891 }}},_roundCornersWebKit:function(b){var a=this.options.compact?"4px":"8px";
892 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{WebkitBorderRadius:a})
893 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{WebkitBorderTopLeftRadius:a})
894 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{WebkitBorderTopRightRadius:a})
895 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{WebkitBorderBottomLeftRadius:a})
896 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{WebkitBorderBottomRightRadius:a})
897 }}},_roundCornersMoz:function(b){var a=this.options.compact?"4px":"8px";
898 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{MozBorderRadius:a})
899 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{MozBorderRadiusTopleft:a})
900 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{MozBorderRadiusTopright:a})
901 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{MozBorderRadiusBottomleft:a})
902 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{MozBorderRadiusBottomright:a})
903 }}},_roundCornersImpl:function(b){var a=this.options.bgColor=="fromParent"?this._background(b.parentNode):this.options.bgColor;
904 b.style.position="relative";
905 if(this._hasString(this.options.corners,"all","top","tl")){this._createCorner(b,"top","left",a)
906 }if(this._hasString(this.options.corners,"all","top","tr")){this._createCorner(b,"top","right",a)
907 }if(this._hasString(this.options.corners,"all","bottom","bl")){this._createCorner(b,"bottom","left",a)
908 }if(this._hasString(this.options.corners,"all","bottom","br")){this._createCorner(b,"bottom","right",a)
909 }},_createCorner:function(b,c,f,k){var n=document.createElement("div");
910 n.className="ricoCorner";
911 Rico.setStyle(n,{width:"6px",height:"5px"});
912 var o=Rico.getStyle(b,"border-"+c+"-style");
913 var a=o=="none"?k:Rico.getStyle(b,"border-"+c+"-color");
914 var j=o=="none"?"0px":"-1px";
915 n.style[c]=j;
916 n.style[f]=Rico.isIE&&Rico.ieVersion<7&&f=="right"&&o!="none"?"-2px":"-1px";
917 b.appendChild(n);
918 var h=[0,2,3,4,4];
919 if(c=="bottom"){h.reverse()
920 }var m=o=="none"?"0px none":"1px solid "+a;
921 var g=f=="left"?"Right":"Left";
922 for(var e=0;
923 e<h.length;
924 e++){var l=document.createElement("div");
925 Rico.setStyle(l,{backgroundColor:k,height:"1px"});
926 l.style["margin"+g]=h[e]+"px";
927 l.style["border"+g]=m;
928 n.appendChild(l)
929 }},_background:function(c){try{var a=Rico.getStyle(c,"backgroundColor");
930 if(a.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&c.parentNode){return this._background(c.parentNode)
931 }return a==null?"#ffffff":a
932 }catch(b){return"#ffffff"
933 }},_hasString:function(b){for(var a=1;
934 a<arguments.length;
935 a++){if(b.indexOf(arguments[a])>=0){return true
936 }}return false
937 }};
938 Rico.toColorPart=function(a){return Rico.zFill(a,2,16)
939 };
940 Rico.Color=function(c,b,a){this.initialize(c,b,a)
941 };
942 Rico.Color.prototype={initialize:function(c,b,a){this.rgb={r:c,g:b,b:a}
943 },setRed:function(a){this.rgb.r=a
944 },setGreen:function(a){this.rgb.g=a
945 },setBlue:function(a){this.rgb.b=a
946 },setHue:function(b){var a=this.asHSB();
947 a.h=b;
948 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
949 },setSaturation:function(b){var a=this.asHSB();
950 a.s=b;
951 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
952 },setBrightness:function(a){var c=this.asHSB();
953 c.b=a;
954 this.rgb=Rico.Color.HSBtoRGB(c.h,c.s,c.b)
955 },darken:function(b){var a=this.asHSB();
956 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.max(a.b-b,0))
957 },brighten:function(b){var a=this.asHSB();
958 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.min(a.b+b,1))
959 },blend:function(a){this.rgb.r=Math.floor((this.rgb.r+a.rgb.r)/2);
960 this.rgb.g=Math.floor((this.rgb.g+a.rgb.g)/2);
961 this.rgb.b=Math.floor((this.rgb.b+a.rgb.b)/2)
962 },isBright:function(){var a=this.asHSB();
963 return this.asHSB().b>0.5
964 },isDark:function(){return !this.isBright()
965 },asRGB:function(){return"rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")"
966 },asHex:function(){return"#"+Rico.toColorPart(this.rgb.r)+Rico.toColorPart(this.rgb.g)+Rico.toColorPart(this.rgb.b)
967 },asHSB:function(){return Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b)
968 },toString:function(){return this.asHex()
969 }};
970 Rico.Color.createFromHex=function(d){if(d.length==4){var b=d;
971 d="#";
972 for(var c=1;
973 c<4;
974 c++){d+=(b.charAt(c)+b.charAt(c))
975 }}if(d.indexOf("#")==0){d=d.substring(1)
976 }if(!d.match(/^[0-9A-Fa-f]{6}$/)){return null
977 }var f=d.substring(0,2);
978 var e=d.substring(2,4);
979 var a=d.substring(4,6);
980 return new Rico.Color(parseInt(f,16),parseInt(e,16),parseInt(a,16))
981 };
982 Rico.Color.createColorFromBackground=function(d){if(!d.style){return new Rico.Color(255,255,255)
983 }var b=Rico.getStyle(d,"background-color");
984 if(b.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&d.parentNode){return Rico.Color.createColorFromBackground(d.parentNode)
985 }if(b==null){return new Rico.Color(255,255,255)
986 }if(b.indexOf("rgb(")==0){var a=b.substring(4,b.length-1);
987 var c=a.split(",");
988 return new Rico.Color(parseInt(c[0],10),parseInt(c[1],10),parseInt(c[2],10))
989 }else{if(b.indexOf("#")==0){return Rico.Color.createFromHex(b)
990 }else{return new Rico.Color(255,255,255)
991 }}};
992 Rico.Color.HSBtoRGB=function(i,e,k){var c=0;
993 var d=0;
994 var l=0;
995 if(e==0){c=parseInt(k*255+0.5,10);
996 d=c;
997 l=c
998 }else{var g=(i-Math.floor(i))*6;
999 var j=g-Math.floor(g);
1000 var b=k*(1-e);
1001 var a=k*(1-e*j);
1002 var m=k*(1-(e*(1-j)));
1003 switch(parseInt(g,10)){case 0:c=(k*255+0.5);
1004 d=(m*255+0.5);
1005 l=(b*255+0.5);
1006 break;
1007 case 1:c=(a*255+0.5);
1008 d=(k*255+0.5);
1009 l=(b*255+0.5);
1010 break;
1011 case 2:c=(b*255+0.5);
1012 d=(k*255+0.5);
1013 l=(m*255+0.5);
1014 break;
1015 case 3:c=(b*255+0.5);
1016 d=(a*255+0.5);
1017 l=(k*255+0.5);
1018 break;
1019 case 4:c=(m*255+0.5);
1020 d=(b*255+0.5);
1021 l=(k*255+0.5);
1022 break;
1023 case 5:c=(k*255+0.5);
1024 d=(b*255+0.5);
1025 l=(a*255+0.5);
1026 break
1027 }}return{r:parseInt(c,10),g:parseInt(d,10),b:parseInt(l,10)}
1028 };
1029 Rico.Color.RGBtoHSB=function(a,f,l){var h;
1030 var e;
1031 var k;
1032 var m=(a>f)?a:f;
1033 if(l>m){m=l
1034 }var i=(a<f)?a:f;
1035 if(l<i){i=l
1036 }k=m/255;
1037 if(m!=0){e=(m-i)/m
1038 }else{e=0
1039 }if(e==0){h=0
1040 }else{var c=(m-a)/(m-i);
1041 var j=(m-f)/(m-i);
1042 var d=(m-l)/(m-i);
1043 if(a==m){h=d-j
1044 }else{if(f==m){h=2+c-d
1045 }else{h=4+j-c
1046 }}h=h/6;
1047 if(h<0){h=h+1
1048 }}return{h:h,s:e,b:k}
1049 };
1050 Rico.createXmlDocument=function(){if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);
1051 if(a.readyState==null){a.readyState=1;
1052 a.addEventListener("load",function(){a.readyState=4;
1053 if(typeof a.onreadystatechange=="function"){a.onreadystatechange()
1054 }},false)
1055 }return a
1056 }if(window.ActiveXObject){return Rico.tryFunctions(function(){return new ActiveXObject("MSXML2.DomDocument")
1057 },function(){return new ActiveXObject("Microsoft.DomDocument")
1058 },function(){return new ActiveXObject("MSXML.DomDocument")
1059 },function(){return new ActiveXObject("MSXML3.DomDocument")
1060 })||false
1061 }return null
1062 };
1063 Rico.CalendarControl=function(b,a){this.initialize(b,a)
1064 };
1065 Rico.CalendarControl.prototype={initialize:function(c,b){this.id=c;
1066 var a=new Date();
1067 Rico.extend(this,new Rico.Popup());
1068 Rico.extend(this.options,{ignoreClicks:true,startAt:0,showWeekNumber:0,showToday:1,dateFmt:"ISO8601",minDate:new Date(a.getFullYear()-50,0,1),maxDate:new Date(a.getFullYear()+50,11,31)});
1069 Rico.extend(this.options,b||{});
1070 this.close=this.closePopup;
1071 this.bPageLoaded=false;
1072 this.img=[];
1073 this.Holidays={};
1074 this.re=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
1075 this.setDateFmt(this.options.dateFmt)
1076 },setDateFmt:function(a){this.dateFmt=(a=="rico")?Rico.dateFmt:a;
1077 Rico.log(this.id+" date format set to "+this.dateFmt);
1078 this.dateParts={};
1079 if(this.re.exec(this.dateFmt)){this.dateParts[RegExp.$1]=0;
1080 this.dateParts[RegExp.$3]=1;
1081 this.dateParts[RegExp.$5]=2
1082 }},addHoliday:function(f,a,g,e,c,b){this.Holidays[this.holidayKey(g,a-1,f)]={desc:e,txtColor:b,bgColor:c||"#DDF"}
1083 },holidayKey:function(c,a,b){return"h"+Rico.zFill(c,4)+Rico.zFill(a,2)+Rico.zFill(b,2)
1084 },atLoad:function(){Rico.log("Calendar#atLoad: "+this.id);
1085 var d=Rico.$(this.id);
1086 if(d){this.setDiv(d)
1087 }else{this.createContainer();
1088 this.container.id=this.id
1089 }Rico.addClass(this.content,Rico.theme.calendar||"ricoCalContainer");
1090 this.direction=Rico.direction(this.container);
1091 var b,k,g,f,h,p,m,q,e;
1092 this.colStart=this.options.showWeekNumber?1:0;
1093 var l=7+this.colStart;
1094 this.maintab=document.createElement("table");
1095 this.maintab.cellSpacing=2;
1096 this.maintab.cellPadding=0;
1097 this.maintab.border=0;
1098 this.maintab.style.borderCollapse="separate";
1099 this.maintab.className=Rico.theme.calendarTable||"ricoCalTab";
1100 this.tbody=Rico.getTBody(this.maintab);
1101 this.tbody.className="ricoCalBody";
1102 this.thead=this.maintab.createTHead();
1103 b=this.thead.insertRow(-1);
1104 this.heading=b.insertCell(-1);
1105 this.heading.colSpan=l;
1106 this.content.style.display="block";
1107 if(this.position=="absolute"){this.content.style.width="auto";
1108 this.maintab.style.width="auto"
1109 }else{this.container.style.position="relative";
1110 this.heading.style.position="static";
1111 this.content.style.padding="0px";
1112 this.content.style.width="15em";
1113 this.maintab.style.width="100%"
1114 }this.heading.className="RicoCalHeading";
1115 if(Rico.theme.calendarHeading){Rico.addClass(this.heading,Rico.theme.calendarHeading)
1116 }this.navtab=this.heading.appendChild(document.createElement("table"));
1117 this.navrow=this.navtab.insertRow(-1);
1118 this._createTitleSection("Month");
1119 this.navrow.insertCell(-1).innerHTML="&nbsp;&nbsp;";
1120 this._createTitleSection("Year");
1121 new Rico.HoverSet(this.heading.getElementsByTagName("a"));
1122 if(this.position=="absolute"){this.heading.appendChild(Rico.closeButton(Rico.eventHandle(this,"close")))
1123 }this.styles=[];
1124 for(g=0;
1125 g<7;
1126 g++){b=this.tbody.insertRow(-1);
1127 b.className=g==0?"ricoCalDayNames":"row"+g;
1128 if(this.options.showWeekNumber){k=b.insertCell(-1);
1129 k.className="ricoCalWeekNum";
1130 if(g==0){k.innerHTML=Rico.getPhraseById("calWeekHdg")
1131 }}for(f=0;
1132 f<7;
1133 f++){k=b.insertCell(-1);
1134 if(g==0){p=(f+this.options.startAt)%7;
1135 k.innerHTML=Rico.dayAbbr(p);
1136 this.styles[f]="ricoCal"+p
1137 }else{k.className=this.styles[f];
1138 if(Rico.theme.calendarDay){Rico.addClass(k,Rico.theme.calendarDay)
1139 }}}}if(this.options.showToday){this.tfoot=this.maintab.createTFoot();
1140 this.tfoot.className="ricoCalFoot";
1141 b=this.tfoot.insertRow(-1);
1142 this.todayCell=b.insertCell(-1);
1143 this.todayCell.colSpan=l;
1144 this.todayCell.className=Rico.theme.calendarFooter||"ricoCalFoot";
1145 Rico.eventBind(this.todayCell,"click",Rico.eventHandle(this,"selectNow"),false)
1146 }this.content.appendChild(this.maintab);
1147 new Rico.HoverSet(this.tbody.getElementsByTagName("td"),{hoverNodes:function(a){return a.innerHTML.match(/^\d+$/)?[a]:[]
1148 }});
1149 this.monthPopup=new Rico.Popup(document.createElement("div"),{shim:false,zIndex:10});
1150 this.monthPopup.content.className="ricoCalMonthPrompt";
1151 e=document.createElement("table");
1152 e.className="ricoCalMenu";
1153 if(Rico.theme.calendarPopdown){Rico.addClass(e,Rico.theme.calendarPopdown)
1154 }e.cellPadding=2;
1155 e.cellSpacing=0;
1156 e.border=0;
1157 e.style.borderCollapse="separate";
1158 e.style.margin="0px";
1159 for(g=0;
1160 g<4;
1161 g++){b=e.insertRow(-1);
1162 for(f=0;
1163 f<3;
1164 f++){k=b.insertCell(-1);
1165 m=document.createElement("a");
1166 m.innerHTML=Rico.monthAbbr(g*3+f);
1167 m.name=g*3+f;
1168 if(Rico.theme.calendarDay){Rico.addClass(m,Rico.theme.calendarDay)
1169 }k.appendChild(m);
1170 Rico.eventBind(m,"click",Rico.eventHandle(this,"selectMonth"),false)
1171 }}new Rico.HoverSet(e.getElementsByTagName("a"));
1172 this.monthPopup.content.appendChild(e);
1173 this.container.appendChild(this.monthPopup.container);
1174 this.monthPopup.closePopup();
1175 this.yearPopup=new Rico.Popup(document.createElement("div"),{shim:false,zIndex:10});
1176 this.yearPopup.content.className="ricoCalYearPrompt";
1177 if(Rico.theme.calendarPopdown){Rico.addClass(this.yearPopup.content,Rico.theme.calendarPopdown)
1178 }var o=document.createElement("p");
1179 o.innerHTML=Rico.getPhraseById("calYearRange",this.options.minDate.getFullYear(),this.options.maxDate.getFullYear());
1180 var n=document.createElement("p");
1181 this.yearInput=n.appendChild(document.createElement("input"));
1182 this.yearInput.maxlength=4;
1183 this.yearInput.size=4;
1184 Rico.eventBind(this.yearInput,"keyup",Rico.eventHandle(this,"yearKey"),false);
1185 m=Rico.floatButton("Checkmark",Rico.eventHandle(this,"processPopUpYear"));
1186 n.appendChild(m);
1187 m=Rico.floatButton("Cancel",Rico.eventHandle(this,"popDownYear"));
1188 n.appendChild(m);
1189 this.yearPopup.content.appendChild(o);
1190 this.yearPopup.content.appendChild(n);
1191 this.container.appendChild(this.yearPopup.container);
1192 this.yearPopup.closePopup();
1193 m=this.content.getElementsByTagName("a");
1194 for(g=0;
1195 g<m.length;
1196 g++){m[g].href="javascript:void(0)"
1197 }Rico.eventBind(this.tbody,"click",Rico.eventHandle(this,"saveAndClose"));
1198 this.close();
1199 this.bPageLoaded=true
1200 },_createTitleSection:function(e){var d=["left","right"];
1201 if(this.direction=="rtl"){d.reverse()
1202 }var f=this.navrow.insertCell(-1);
1203 var b=f.appendChild(document.createElement("a"));
1204 b.className="Rico_"+d[0]+"Arrow";
1205 b.appendChild(this.createNavArrow("dec"+e,d[0]));
1206 f=this.navrow.insertCell(-1);
1207 b=f.appendChild(document.createElement("a"));
1208 Rico.eventBind(b,"click",Rico.eventHandle(this,"popUp"+e),false);
1209 this["title"+e]=b;
1210 f=this.navrow.insertCell(-1);
1211 b=f.appendChild(document.createElement("a"));
1212 b.className="Rico_"+d[1]+"Arrow";
1213 b.appendChild(this.createNavArrow("inc"+e,d[1]))
1214 },selectNow:function(){var a=new Date();
1215 this.dateNow=a.getDate();
1216 this.monthNow=a.getMonth();
1217 this.yearNow=a.getFullYear();
1218 this.monthSelected=this.monthNow;
1219 this.yearSelected=this.yearNow;
1220 this.constructCalendar()
1221 },createNavArrow:function(a,c){var b=document.createElement("span");
1222 b.className=Rico.theme[c+"Arrow"]||"rico-icon Rico_"+c+"Arrow";
1223 b.style.display="inline-block";
1224 Rico.eventBind(b,"click",Rico.eventHandle(this,a),false);
1225 return b
1226 },isValidMonth:function(a,b){if(a<this.options.minDate.getFullYear()){return false
1227 }if(a==this.options.minDate.getFullYear()&&b<this.options.minDate.getMonth()){return false
1228 }if(a>this.options.maxDate.getFullYear()){return false
1229 }if(a==this.options.maxDate.getFullYear()&&b>this.options.maxDate.getMonth()){return false
1230 }return true
1231 },incMonth:function(){var b=this.monthSelected+1;
1232 var a=this.yearSelected;
1233 if(b>11){b=0;
1234 a++
1235 }if(!this.isValidMonth(a,b)){return
1236 }this.monthSelected=b;
1237 this.yearSelected=a;
1238 this.constructCalendar()
1239 },decMonth:function(){var b=this.monthSelected-1;
1240 var a=this.yearSelected;
1241 if(b<0){b=11;
1242 a--
1243 }if(!this.isValidMonth(a,b)){return
1244 }this.monthSelected=b;
1245 this.yearSelected=a;
1246 this.constructCalendar()
1247 },selectMonth:function(b){var a=Rico.eventElement(b);
1248 this.monthSelected=parseInt(a.name,10);
1249 this.constructCalendar();
1250 Rico.eventStop(b)
1251 },openYrMo:function(b,a){if(this.direction=="rtl"){a=1-a
1252 }b.openPopup();
1253 var c=a?this.content.offsetWidth-b.container.offsetWidth-5:3;
1254 b.move(c,this.heading.offsetHeight+2)
1255 },popUpMonth:function(a){Rico.eventStop(a);
1256 if(this.monthPopup.visible()){this.popDownMonth();
1257 return false
1258 }this.popDownYear();
1259 this.openYrMo(this.monthPopup,0);
1260 return false
1261 },popDownMonth:function(){this.monthPopup.closePopup()
1262 },popDownYear:function(){this.yearPopup.closePopup();
1263 this.yearInput.disabled=true
1264 },popUpYear:function(b){Rico.eventStop(b);
1265 if(this.yearPopup.visible()){this.popDownYear();
1266 return false
1267 }this.popDownMonth();
1268 this.yearInput.disabled=false;
1269 this.yearInput.value="";
1270 this.openYrMo(this.yearPopup,1);
1271 var a=this;
1272 setTimeout(function(){a.yearInput.focus()
1273 },10);
1274 return false
1275 },yearKey:function(a){switch(Rico.eventKey(a)){case 27:this.popDownYear();
1276 Rico.eventStop(a);
1277 return false;
1278 case 13:this.processPopUpYear();
1279 Rico.eventStop(a);
1280 return false
1281 }return true
1282 },processPopUpYear:function(){var a=this.yearInput.value;
1283 a=parseInt(a,10);
1284 if(isNaN(a)||a<this.options.minDate.getFullYear()||a>this.options.maxDate.getFullYear()){alert(Rico.getPhraseById("calInvalidYear"))
1285 }else{this.yearSelected=a;
1286 this.popDownYear();
1287 this.constructCalendar()
1288 }},incYear:function(){if(this.yearSelected>=this.options.maxDate.getFullYear()){return
1289 }this.yearSelected++;
1290 this.constructCalendar()
1291 },decYear:function(){if(this.yearSelected<=this.options.minDate.getFullYear()){return
1292 }this.yearSelected--;
1293 this.constructCalendar()
1294 },WeekNbr:function(h,f,j){var g=new Date(h,f,j);
1295 var c=new Date(h,0,1);
1296 var e=7+1-c.getDay();
1297 if(e==8){e=1
1298 }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;
1299 var d=Math.floor((b-e+7)/7);
1300 if(d==0){h--;
1301 var a=new Date(h,0,1);
1302 var i=7+1-a.getDay();
1303 d=(i==2||i==8)?53:52
1304 }return d
1305 },constructCalendar:function(){var l=[31,0,31,30,31,30,31,31,30,31,30,31];
1306 var d=new Date(this.yearSelected,this.monthSelected,1);
1307 var j,e,f,b;
1308 if(typeof this.monthSelected!="number"||this.monthSelected>=12||this.monthSelected<0){alert("ERROR in calendar: monthSelected="+this.monthSelected);
1309 return
1310 }if(this.monthSelected==1){j=new Date(this.yearSelected,this.monthSelected+1,1);
1311 j=new Date(j-(24*60*60*1000));
1312 e=j.getDate()
1313 }else{e=l[this.monthSelected]
1314 }var n=d.getDay()-this.options.startAt;
1315 if(n<0){n+=7
1316 }this.popDownMonth();
1317 this.popDownYear();
1318 if(this.options.showWeekNumber){for(f=1;
1319 f<7;
1320 f++){this.tbody.rows[f].cells[0].innerHTML="&nbsp;"
1321 }}for(f=0;
1322 f<n;
1323 f++){this.resetCell(this.tbody.rows[1].cells[f+this.colStart])
1324 }for(var k=1,a=1;
1325 k<=e;
1326 k++,n++){b=n%7;
1327 if(this.options.showWeekNumber&&b==0){this.tbody.rows[a].cells[0].innerHTML=this.WeekNbr(this.yearSelected,this.monthSelected,k)
1328 }var m=this.tbody.rows[a].cells[b+this.colStart];
1329 m.innerHTML=k;
1330 m.className=this.styles[b];
1331 if((k==this.dateNow)&&(this.monthSelected==this.monthNow)&&(this.yearSelected==this.yearNow)){Rico.addClass(m,Rico.theme.calendarToday||"ricoCalToday")
1332 }if(Rico.theme.calendarDay){Rico.addClass(m,Rico.theme.calendarDay)
1333 }if((k==this.odateSelected)&&(this.monthSelected==this.omonthSelected)&&(this.yearSelected==this.oyearSelected)){Rico.addClass(m,Rico.theme.calendarSelectedDay||"ricoSelectedDay")
1334 }var g=this.Holidays[this.holidayKey(this.yearSelected,this.monthSelected,k)];
1335 if(!g){g=this.Holidays[this.holidayKey(0,this.monthSelected,k)]
1336 }m.style.color=g?g.txtColor:"";
1337 m.style.backgroundColor=g?g.bgColor:"";
1338 m.title=g?g.desc:"";
1339 m.style.visibility="visible";
1340 if(b==6){a++
1341 }}while(n<42){b=n%7;
1342 this.resetCell(this.tbody.rows[a].cells[b+this.colStart]);
1343 n++;
1344 if(b==6){a++
1345 }}this.titleMonth.innerHTML=Rico.monthAbbr(this.monthSelected);
1346 this.titleYear.innerHTML=this.yearSelected;
1347 if(this.todayCell){this.todayCell.innerHTML=Rico.getPhraseById("calToday",this.dateNow,Rico.monthAbbr(this.monthNow),this.yearNow,this.monthNow+1)
1348 }},resetCell:function(a){a.innerHTML="&nbsp;";
1349 a.title="";
1350 a.style.visibility="hidden"
1351 },saveAndClose:function(g){Rico.eventStop(g);
1352 var f=Rico.eventElement(g);
1353 var c=f.innerHTML.replace(/&nbsp;/g,"");
1354 if(c==""||f.className=="ricoCalWeekNum"){return
1355 }var b=parseInt(c,10);
1356 if(isNaN(b)){return
1357 }var h=new Date(this.yearSelected,this.monthSelected,b);
1358 var a=Rico.formatDate(h,this.dateFmt=="ISO8601"?"yyyy-mm-dd":this.dateFmt);
1359 if(this.returnValue){this.returnValue(a);
1360 this.close()
1361 }},open:function(b){if(!this.bPageLoaded){return
1362 }var a=new Date();
1363 this.dateNow=a.getDate();
1364 this.monthNow=a.getMonth();
1365 this.yearNow=a.getFullYear();
1366 this.oyearSelected=-1;
1367 if(typeof b=="object"){this.odateSelected=b.getDate();
1368 this.omonthSelected=b.getMonth();
1369 this.oyearSelected=b.getFullYear()
1370 }else{if(this.dateFmt=="ISO8601"){var c=Rico.setISO8601(b);
1371 if(c){this.odateSelected=c.getDate();
1372 this.omonthSelected=c.getMonth();
1373 this.oyearSelected=c.getFullYear()
1374 }}else{if(this.re.exec(b)){var f=[RegExp.$1,RegExp.$3,RegExp.$5];
1375 this.odateSelected=parseInt(f[this.dateParts.dd],10);
1376 this.omonthSelected=parseInt(f[this.dateParts.mm],10)-1;
1377 this.oyearSelected=parseInt(f[this.dateParts.yyyy],10);
1378 if(this.oyearSelected<100){this.oyearSelected+=this.yearNow-(this.yearNow%100);
1379 var e=this.options.maxDate.getFullYear();
1380 while(this.oyearSelected>e){this.oyearSelected-=100
1381 }}}else{if(b){alert("ERROR: invalid date passed to calendar ("+b+")")
1382 }}}}if(this.oyearSelected>0){this.dateSelected=this.odateSelected;
1383 this.monthSelected=this.omonthSelected;
1384 this.yearSelected=this.oyearSelected
1385 }else{this.dateSelected=this.dateNow;
1386 this.monthSelected=this.monthNow;
1387 this.yearSelected=this.yearNow
1388 }this.constructCalendar();
1389 this.openPopup()
1390 }};
1391 Rico.ColorPicker=function(b,a){this.initialize(b,a)
1392 };
1393 Rico.ColorPicker.prototype={initialize:function(h,c){this.id=h;
1394 this.currentValue="#FFFFFF";
1395 Rico.extend(this,new Rico.Popup());
1396 Rico.extend(this.options,{showColorCode:false,cellsPerRow:18,palette:[]});
1397 var f=["00","33","66","99","CC","FF"];
1398 for(var e=0;
1399 e<f.length;
1400 e++){for(var d=0;
1401 d<f.length;
1402 d++){for(var a=0;
1403 a<f.length;
1404 a++){this.options.palette.push(f[d]+f[e]+f[a])
1405 }}}Rico.extend(this.options,c||{})
1406 },atLoad:function(){this.createContainer();
1407 this.content.className="ricoColorPicker";
1408 var c=this.options.cellsPerRow;
1409 var d="<TABLE BORDER='1' CELLSPACING='1' CELLPADDING='0'>";
1410 for(var b=0;
1411 b<this.options.palette.length;
1412 b++){if((b%c)==0){d+="<TR>"
1413 }d+='<TD BGCOLOR="#'+this.options.palette[b]+'">&nbsp;</TD>';
1414 if(((b+1)>=this.options.palette.length)||(((b+1)%c)==0)){d+="</TR>"
1415 }}var a=Math.floor(c/2);
1416 if(this.options.showColorCode){d+="<TR><TD COLSPAN='"+a+"' ID='colorPickerSelectedColor'>&nbsp;</TD><TD COLSPAN='"+(c-a)+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue'>#FFFFFF</TD></TR>"
1417 }else{d+="<TR><TD COLSPAN='"+c+"' ID='colorPickerSelectedColor'>&nbsp;</TD></TR>"
1418 }d+="</TABLE>";
1419 this.content.innerHTML=d;
1420 this.open=this.openPopup;
1421 this.close=this.closePopup;
1422 Rico.eventBind(this.container,"mouseover",Rico.eventHandle(this,"highlightColor"),false);
1423 Rico.eventBind(this.container,"click",Rico.eventHandle(this,"selectColor"),false);
1424 this.close()
1425 },selectColor:function(a){Rico.eventStop(a);
1426 if(this.returnValue){this.returnValue(this.currentValue)
1427 }this.close()
1428 },highlightColor:function(b){var a=Rico.eventElement(b);
1429 if(!a.tagName||a.tagName.toLowerCase()!="td"){return
1430 }var g=Rico.Color.createColorFromBackground(a).toString();
1431 this.currentValue=g;
1432 Rico.setStyle("colorPickerSelectedColor",{backgroundColor:g});
1433 var f=Rico.$("colorPickerSelectedColorValue");
1434 if(f){f.innerHTML=g
1435 }}};
1436 Rico.dndMgrList=[];
1437 Rico.registerDraggable=function(b,a){if(typeof a!="number"){a=0
1438 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1439 }Rico.dndMgrList[a].registerDraggable(b)
1440 };
1441 Rico.registerDropZone=function(b,a){if(typeof a!="number"){a=0
1442 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1443 }Rico.dndMgrList[a].registerDropZone(b)
1444 };
1445 Rico.dndMgr=function(){this.initialize()
1446 };
1447 Rico.dndMgr.prototype={initialize:function(){this.dropZones=[];
1448 this.draggables=[];
1449 this.currentDragObjects=[];
1450 this.dragElement=null;
1451 this.lastSelectedDraggable=null;
1452 this.currentDragObjectVisible=false;
1453 this.interestedInMotionEvents=false;
1454 this._mouseDown=Rico.eventHandle(this,"_mouseDownHandler");
1455 this._mouseMove=Rico.eventHandle(this,"_mouseMoveHandler");
1456 this._mouseUp=Rico.eventHandle(this,"_mouseUpHandler")
1457 },registerDropZone:function(a){this.dropZones[this.dropZones.length]=a
1458 },deregisterDropZone:function(a){var d=new Array();
1459 var b=0;
1460 for(var c=0;
1461 c<this.dropZones.length;
1462 c++){if(this.dropZones[c]!=a){d[b++]=this.dropZones[c]
1463 }}this.dropZones=d
1464 },clearDropZones:function(){this.dropZones=new Array()
1465 },registerDraggable:function(a){this.draggables[this.draggables.length]=a;
1466 var b=a.getMouseDownHTMLElement();
1467 if(b!=null){b.ricoDraggable=a;
1468 Rico.eventBind(b,"mousedown",Rico.eventHandle(this,"_attachEvents"));
1469 Rico.eventBind(b,"mousedown",this._mouseDown)
1470 }},clearSelection:function(){for(var a=0;
1471 a<this.currentDragObjects.length;
1472 a++){this.currentDragObjects[a].deselect()
1473 }this.currentDragObjects=new Array();
1474 this.lastSelectedDraggable=null
1475 },hasSelection:function(){return this.currentDragObjects.length>0
1476 },setStartDragFromElement:function(a,c){this.origPos=Rico.cumulativeOffset(c);
1477 var b=Rico.eventClient(a);
1478 this.startx=b.x-this.origPos.left;
1479 this.starty=b.y-this.origPos.top;
1480 this.interestedInMotionEvents=this.hasSelection();
1481 Rico.eventStop(a)
1482 },updateSelection:function(a,b){if(!b){this.clearSelection()
1483 }if(a.isSelected()){this.currentDragObjects=this.currentDragObjects.without(a);
1484 a.deselect();
1485 if(a==this.lastSelectedDraggable){this.lastSelectedDraggable=null
1486 }}else{a.select();
1487 if(a.isSelected()){this.currentDragObjects.push(a);
1488 this.lastSelectedDraggable=a
1489 }}},_mouseDownHandler:function(f){if(!Rico.eventLeftClick(f)){return
1490 }var d=Rico.eventElement(f);
1491 var a=d.ricoDraggable;
1492 var c=d;
1493 while(a==null&&c.parentNode){c=c.parentNode;
1494 a=c.ricoDraggable
1495 }if(a==null){return
1496 }this.updateSelection(a,f.ctrlKey);
1497 if(this.hasSelection()){for(var b=0;
1498 b<this.dropZones.length;
1499 b++){this.dropZones[b].clearPositionCache()
1500 }}this.setStartDragFromElement(f,a.getMouseDownHTMLElement())
1501 },_mouseMoveHandler:function(a){if(!this.interestedInMotionEvents){return
1502 }if(!this.hasSelection()){return
1503 }if(!this.currentDragObjectVisible){this._startDrag(a)
1504 }if(!this.activatedDropZones){this._activateRegisteredDropZones()
1505 }this._updateDraggableLocation(a);
1506 this._updateDropZonesHover(a);
1507 Rico.eventStop(a)
1508 },_makeDraggableObjectVisible:function(b){if(!this.hasSelection()){return
1509 }var a;
1510 if(this.currentDragObjects.length>1){a=this.currentDragObjects[0].getMultiObjectDragGUI(this.currentDragObjects)
1511 }else{a=this.currentDragObjects[0].getSingleObjectDragGUI()
1512 }this.dragElemPosition=Rico.getStyle(a,"position");
1513 if(this.dragElemPosition!="absolute"){a.style.position="absolute"
1514 }if(a.parentNode==null||a.parentNode.nodeType==11){document.body.appendChild(a)
1515 }this.dragElement=a;
1516 this._updateDraggableLocation(b);
1517 this.currentDragObjectVisible=true
1518 },_leftOffset:function(a){return a.offsetX?document.body.scrollLeft:0
1519 },_topOffset:function(a){return a.offsetY?document.body.scrollTop:0
1520 },_updateDraggableLocation:function(b){var a=this.dragElement.style;
1521 var c=Rico.eventClient(b);
1522 a.left=(c.x+this._leftOffset(b)-this.startx)+"px";
1523 a.top=(c.y+this._topOffset(b)-this.starty)+"px"
1524 },_updateDropZonesHover:function(b){var a,c=this.dropZones.length;
1525 for(a=0;
1526 a<c;
1527 a++){if(!this._mousePointInDropZone(b,this.dropZones[a])){this.dropZones[a].hideHover()
1528 }}for(a=0;
1529 a<c;
1530 a++){if(this._mousePointInDropZone(b,this.dropZones[a])){if(this.dropZones[a].canAccept(this.currentDragObjects)){this.dropZones[a].showHover()
1531 }}}},_startDrag:function(b){for(var a=0;
1532 a<this.currentDragObjects.length;
1533 a++){this.currentDragObjects[a].startDrag()
1534 }this._makeDraggableObjectVisible(b)
1535 },_mouseUpHandler:function(b){if(!this.hasSelection()){return
1536 }if(!Rico.eventLeftClick(b)){return
1537 }this.interestedInMotionEvents=false;
1538 if(this._placeDraggableInDropZone(b)){this._completeDropOperation(b)
1539 }else{if(this.dragElement!=null){Rico.eventStop(b);
1540 var a=this;
1541 Rico.animate(this.dragElement,{duration:300,onEnd:function(){a._doCancelDragProcessing()
1542 }},{left:this.origPos.left,top:this.origPos.top})
1543 }}Rico.eventUnbind(document.body,"mousemove",this._mouseMove);
1544 Rico.eventUnbind(document.body,"mouseup",this._mouseUp)
1545 },_retTrue:function(){return true
1546 },_completeDropOperation:function(a){if(this.dragElement!=this.currentDragObjects[0].getMouseDownHTMLElement()){if(this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1547 }}this._deactivateRegisteredDropZones();
1548 this._endDrag();
1549 this.clearSelection();
1550 this.dragElement=null;
1551 this.currentDragObjectVisible=false;
1552 Rico.eventStop(a)
1553 },_doCancelDragProcessing:function(){this._cancelDrag();
1554 if(this.dragElement==this.currentDragObjects[0].getMouseDownHTMLElement()){this.dragElement.style.position=this.dragElemPosition
1555 }else{if(this.dragElement&&this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1556 }}this._deactivateRegisteredDropZones();
1557 this.dragElement=null;
1558 this.currentDragObjectVisible=false
1559 },_placeDraggableInDropZone:function(c){var a=false;
1560 var d=this.dropZones.length;
1561 for(var b=0;
1562 b<d;
1563 b++){if(this._mousePointInDropZone(c,this.dropZones[b])){if(this.dropZones[b].canAccept(this.currentDragObjects)){this.dropZones[b].hideHover();
1564 this.dropZones[b].accept(this.currentDragObjects);
1565 a=true;
1566 break
1567 }}}return a
1568 },_cancelDrag:function(){for(var a=0;
1569 a<this.currentDragObjects.length;
1570 a++){this.currentDragObjects[a].cancelDrag()
1571 }},_endDrag:function(){for(var a=0;
1572 a<this.currentDragObjects.length;
1573 a++){this.currentDragObjects[a].endDrag()
1574 }},_mousePointInDropZone:function(b,c){var a=c.getAbsoluteRect();
1575 var d=Rico.eventClient(b);
1576 return d.x>a.left+this._leftOffset(b)&&d.x<a.right+this._leftOffset(b)&&d.y>a.top+this._topOffset(b)&&d.y<a.bottom+this._topOffset(b)
1577 },_activateRegisteredDropZones:function(){var c=this.dropZones.length;
1578 for(var a=0;
1579 a<c;
1580 a++){var b=this.dropZones[a];
1581 if(b.canAccept(this.currentDragObjects)){b.activate()
1582 }}this.activatedDropZones=true
1583 },_deactivateRegisteredDropZones:function(){var b=this.dropZones.length;
1584 for(var a=0;
1585 a<b;
1586 a++){this.dropZones[a].deactivate()
1587 }this.activatedDropZones=false
1588 },_attachEvents:function(){Rico.eventBind(document.body,"mousemove",this._mouseMove);
1589 Rico.eventBind(document.body,"mouseup",this._mouseUp)
1590 }};
1591 Rico.Draggable=function(a,b){this.initialize(a,b)
1592 };
1593 Rico.Draggable.prototype={initialize:function(a,b){this.type=a;
1594 this.htmlElement=Rico.$(b);
1595 this.selected=false
1596 },getMouseDownHTMLElement:function(){return this.htmlElement
1597 },select:function(){this._select()
1598 },_select:function(){this.selected=true;
1599 if(this.showingSelected){return
1600 }this.showingSelected=true;
1601 var b=this.getMouseDownHTMLElement();
1602 var a=Rico.Color.createColorFromBackground(b);
1603 a.isBright()?a.darken(0.033):a.brighten(0.033);
1604 this.saveBackground=Rico.getStyle(b,"backgroundColor","background-color");
1605 b.style.backgroundColor=a.asHex()
1606 },deselect:function(){this.selected=false;
1607 if(!this.showingSelected){return
1608 }var a=this.getMouseDownHTMLElement();
1609 a.style.backgroundColor=this.saveBackground;
1610 this.showingSelected=false
1611 },isSelected:function(){return this.selected
1612 },startDrag:function(){},cancelDrag:function(){},endDrag:function(){},getSingleObjectDragGUI:function(){return this.htmlElement
1613 },getMultiObjectDragGUI:function(a){return this.htmlElement
1614 },getDroppedGUI:function(){return this.htmlElement
1615 },toString:function(){return this.type+":"+this.htmlElement+":"
1616 }};
1617 Rico.LiveGridDraggable=function(b,a,c){this.initialize(b,a,c)
1618 };
1619 Rico.LiveGridDraggable.prototype=Rico.extend(new Rico.Draggable(),{initialize:function(b,a,c){this.type="RicoCell";
1620 this.htmlElement=b.cell(a,c);
1621 this.liveGrid=b;
1622 this.dragRow=a;
1623 this.dragCol=c
1624 },select:function(){if(this.dragRow>=this.liveGrid.buffer.totalRows){return
1625 }this.selected=true;
1626 this.showingSelected=true
1627 },deselect:function(){this.selected=false;
1628 this.showingSelected=false
1629 },getSingleObjectDragGUI:function(){var a=document.createElement("div");
1630 a.className="LiveGridDraggable";
1631 a.style.width=(this.htmlElement.offsetWidth-10)+"px";
1632 a.innerHTML=this.htmlElement.innerHTML;
1633 return a
1634 }});
1635 Rico.Dropzone=function(a){this.initialize(a)
1636 };
1637 Rico.Dropzone.prototype={initialize:function(a){this.htmlElement=Rico.$(a);
1638 this.absoluteRect=null
1639 },getHTMLElement:function(){return this.htmlElement
1640 },clearPositionCache:function(){this.absoluteRect=null
1641 },getAbsoluteRect:function(){if(this.absoluteRect==null){var a=this.getHTMLElement();
1642 var b=Rico.viewportOffset(a);
1643 this.absoluteRect={top:b.top,left:b.left,bottom:b.top+a.offsetHeight,right:b.left+a.offsetWidth}
1644 }return this.absoluteRect
1645 },activate:function(){var c=this.getHTMLElement();
1646 if(c==null||this.showingActive){return
1647 }this.showingActive=true;
1648 this.saveBackgroundColor=c.style.backgroundColor;
1649 var b="#ffea84";
1650 var a=Rico.Color.createColorFromBackground(c);
1651 if(a==null){c.style.backgroundColor=b
1652 }else{a.isBright()?a.darken(0.2):a.brighten(0.2);
1653 c.style.backgroundColor=a.asHex()
1654 }},deactivate:function(){var a=this.getHTMLElement();
1655 if(a==null||!this.showingActive){return
1656 }a.style.backgroundColor=this.saveBackgroundColor;
1657 this.showingActive=false;
1658 this.saveBackgroundColor=null
1659 },showHover:function(){var a=this.getHTMLElement();
1660 if(a==null||this.showingHover){return
1661 }this.saveBorderWidth=a.style.borderWidth;
1662 this.saveBorderStyle=a.style.borderStyle;
1663 this.saveBorderColor=a.style.borderColor;
1664 this.showingHover=true;
1665 a.style.borderWidth="1px";
1666 a.style.borderStyle="solid";
1667 a.style.borderColor="#ffff00"
1668 },hideHover:function(){var a=this.getHTMLElement();
1669 if(a==null||!this.showingHover){return
1670 }a.style.borderWidth=this.saveBorderWidth;
1671 a.style.borderStyle=this.saveBorderStyle;
1672 a.style.borderColor=this.saveBorderColor;
1673 this.showingHover=false
1674 },canAccept:function(a){return true
1675 },accept:function(b){var d=this.getHTMLElement();
1676 if(d==null){return
1677 }var e=b.length;
1678 for(var a=0;
1679 a<e;
1680 a++){var c=b[a].getDroppedGUI();
1681 if(Rico.getStyle(c,"position")=="absolute"){c.style.position="static";
1682 c.style.top="";
1683 c.style.top=""
1684 }d.appendChild(c)
1685 }}};
1686 Rico.KeywordSearch=function(b,a){this.initialize(b,a)
1687 };
1688 Rico.KeywordSearch.prototype={initialize:function(b,a){this.id=b;
1689 Rico.extend(this,new Rico.Window(Rico.getPhraseById("keywordTitle"),a));
1690 Rico.addClass(this.content,"ricoKeywordSearch");
1691 Rico.extend(this.options,{listLength:10,maxSuggest:20,width:"12em"})
1692 },atLoad:function(){this.searchField=Rico.createFormField(this.contentDiv,"input","text",this.id+"_search");
1693 this.searchField.style.display="block";
1694 this.searchField.style.width=this.options.width;
1695 Rico.eventBind(this.searchField,"keyup",Rico.eventHandle(this,"filterKeypress"),false);
1696 this.selectList=Rico.createFormField(this.contentDiv,"select",null,this.id+"_list");
1697 this.selectList.size=this.options.listLength;
1698 this.selectList.style.display="block";
1699 this.selectList.style.width=this.options.width;
1700 Rico.eventBind(this.selectList,"change",Rico.eventHandle(this,"listClick"),false);
1701 this.close=this.closePopup;
1702 this.close()
1703 },open:function(a,b){this.column=b;
1704 this.grid=this.column.liveGrid;
1705 this.searchField.value="";
1706 this.selectList.options.length=0;
1707 this.openPopup();
1708 this.searchField.focus();
1709 this.selectValuesRequest("")
1710 },selectValuesRequest:function(c){var d=this.column.index;
1711 var b={};
1712 Rico.extend(b,this.grid.buffer.ajaxOptions);
1713 b.parameters={id:this.grid.tableId,offset:"0",page_size:this.options.maxSuggest,edit:d};
1714 b.parameters[this.grid.actionId]="query";
1715 if(c!=""&&c!="*"){if(c.indexOf("*")==-1){c="*"+c+"*"
1716 }b.parameters["f[1][op]"]="LIKE";
1717 b.parameters["f[1][len]"]=1;
1718 b.parameters["f[1][0]"]=c
1719 }var a=this;
1720 b.onComplete=function(e){a.selectValuesUpdate(e)
1721 };
1722 new Rico.ajaxRequest(this.grid.buffer.dataSource,b)
1723 },selectValuesUpdate:function(b){var a=b.responseXML.getElementsByTagName("ajax-response");
1724 Rico.log("selectValuesUpdate: "+b.status);
1725 if(a==null||a.length!=1){return
1726 }a=a[0];
1727 var h=a.getElementsByTagName("error");
1728 if(h.length>0){var f=Rico.getContentAsString(h[0],this.grid.buffer.isEncoded);
1729 Rico.log("Data provider returned an error:\n"+f);
1730 alert(Rico.getPhraseById("requestError",f));
1731 return null
1732 }this.selectList.options.length=0;
1733 a=a.getElementsByTagName("response")[0];
1734 var g=a.getElementsByTagName("rows")[0];
1735 var j=this.grid.buffer.dom2jstable(g);
1736 Rico.log("selectValuesUpdate: id="+this.selectList.id+" rows="+j.length);
1737 for(var d=0;
1738 d<j.length;
1739 d++){if(j[d].length>0){var e=j[d][0];
1740 var c=(j[d].length>1)?j[d][1]:e;
1741 Rico.addSelectOption(this.selectList,e,c)
1742 }}},filterKeypress:function(c){var a=Rico.eventElement(c);
1743 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
1744 }if(this.lastKeyFilter==a.value){return
1745 }var b=a.value;
1746 Rico.log("filterKeypress: "+this.index+" "+b);
1747 this.lastKeyFilter=b;
1748 this.selectValuesRequest(b)
1749 },listClick:function(c){var b=Rico.eventElement(c);
1750 if(b.tagName.toLowerCase()!="select"){return
1751 }if(this.returnValue){var a=b.options[b.selectedIndex];
1752 this.returnValue(a.value,a.innerHTML)
1753 }this.close()
1754 }};
1755 Rico.TreeControl=function(c,b,a){this.initialize(c,b,a)
1756 };
1757 Rico.TreeControl.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Popup());
1758 Rico.extend(this.options,{ignoreClicks:true,nodeIdDisplay:"none",showCheckBox:false,showFolders:false,showPlusMinus:true,showLines:true,defaultAction:Rico.eventHandle(this,"nodeClick"),height:"300px",width:"300px",leafIcon:"rico-icon rico-doc"});
1759 Rico.extend(this.options,a||{});
1760 this.id=c;
1761 this.dataSource=b;
1762 this.close=this.closePopup;
1763 this.hoverSet=new Rico.HoverSet([])
1764 },atLoad:function(){this.treeDiv=document.createElement("div");
1765 this.treeDiv.id=this.id;
1766 this.treeDiv.className="ricoTree";
1767 if(Rico.theme.treeContent){Rico.addClass(this.treeDiv,Rico.theme.treeContent)
1768 }this.treeDiv.style.height=this.options.height;
1769 this.treeDiv.style.width=this.options.width;
1770 this.createContainer();
1771 this.content.className=Rico.theme.tree||"ricoTreeContainer";
1772 this.content.appendChild(this.treeDiv);
1773 if(this.options.showCheckBox){this.buttonDiv=document.createElement("div");
1774 this.buttonDiv.style.width=this.options.width;
1775 this.buttonDiv.className="ricoTreeButtons";
1776 if(Rico.getStyle(this.container,"position")=="absolute"){var a=document.createElement("span");
1777 a.innerHTML=RicoTranslate.getPhraseById("treeSave");
1778 Rico.setStyle(a,{"float":"left",cursor:"pointer"});
1779 this.buttonDiv.appendChild(a);
1780 Rico.eventBind(a,"click",Rico.eventHandle(this,"saveSelection"))
1781 }var a=document.createElement("span");
1782 a.innerHTML=RicoTranslate.getPhraseById("treeClear");
1783 Rico.setStyle(a,{"float":"right",cursor:"pointer"});
1784 this.buttonDiv.appendChild(a);
1785 this.content.appendChild(this.buttonDiv);
1786 Rico.eventBind(a,"click",Rico.eventHandle(this,"clrCheckBoxEvent"))
1787 }this.close()
1788 },setTreeDiv:function(a){this.treeDiv=Rico.$(a);
1789 this.openPopup=function(){}
1790 },open:function(){this.openPopup();
1791 if(this.treeDiv.childNodes.length==0&&this.dataSource){this.loadXMLDoc()
1792 }},loadXMLDoc:function(c){var b={id:this.id};
1793 if(c){b.Parent=c
1794 }Rico.log("Tree loadXMLDoc: "+this.id);
1795 var a=this;
1796 new Rico.ajaxRequest(this.dataSource,{parameters:b,method:"get",onComplete:function(d){a.processResponse(d)
1797 }})
1798 },domID:function(b,a){return"RicoTree_"+a+"_"+this.id+"_"+b
1799 },processResponse:function(d){var b=d.responseXML.getElementsByTagName("ajax-response");
1800 if(b==null||b.length!=1){return
1801 }var f=b[0].getElementsByTagName("rows")[0];
1802 var g=f.getElementsByTagName("tr");
1803 var k=[];
1804 for(var e=0;
1805 e<g.length;
1806 e++){var l=g[e].getElementsByTagName("td");
1807 if(l.length<5){continue
1808 }var h=[];
1809 h[5]=this.options.leafIcon;
1810 for(var c=0;
1811 c<l.length;
1812 c++){h[c]=Rico.getContentAsString(l[c],true)
1813 }h[3]=h[3].match(/^0|L$/i)?0:1;
1814 h[4]=parseInt(h[4]);
1815 k.push(h)
1816 }for(var e=0;
1817 e<k.length;
1818 e++){var a=(e<k.length-1)&&(k[e][0]==k[e+1][0]);
1819 this.addNode(k[e][0],k[e][1],k[e][2],k[e][3],k[e][4],k[e][5],!a)
1820 }},addNode:function(q,l,t,f,u,s,k){var h=Rico.$(this.domID(q,"Parent"));
1821 var v=Rico.$(this.domID(q,"Children"));
1822 var a=h?h.TreeLevel+1:0;
1823 var b=document.createElement("table");
1824 var m=document.createElement("div");
1825 m.id=this.domID(l,"Children");
1826 m.className="ricoTreeBranch";
1827 m.style.display=h?"none":"";
1828 b.border=0;
1829 b.cellSpacing=0;
1830 b.cellPadding=0;
1831 b.id=this.domID(l,"Parent");
1832 b.TreeLevel=a;
1833 b.TreeContainer=f;
1834 b.TreeFetchedChildren=this.dataSource?false:true;
1835 var d=b.insertRow(0);
1836 var g=[];
1837 for(var r=0;
1838 r<a-1;
1839 r++){g[r]=d.insertCell(-1)
1840 }if(a>1){var e=h.getElementsByTagName("td");
1841 for(var r=0;
1842 r<a-2;
1843 r++){g[r].innerHTML=e[r].innerHTML
1844 }var w=document.createElement("div");
1845 w.className="rico-icon rico-tree-"+(v.nextSibling&&this.options.showLines?"nodeline":"nodeblank");
1846 g[a-2].appendChild(w)
1847 }if(a>0){var c=k&&this.options.showLines?"last":"";
1848 var o=this.options.showLines?"node":"";
1849 if(this.options.showPlusMinus&&f){var w=document.createElement("div");
1850 w.name=l;
1851 w.style.cursor="pointer";
1852 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1853 w.className="rico-icon rico-tree-"+o+"p"+c;
1854 d.insertCell(-1).appendChild(w)
1855 }else{if(this.options.showLines){var w=document.createElement("div");
1856 w.className="rico-icon rico-tree-node"+c;
1857 d.insertCell(-1).appendChild(w)
1858 }}if(this.options.showFolders&&(f||(s&&s!="none"))){var w=document.createElement("div");
1859 if(!f){w.className=s
1860 }else{w.name=l;
1861 w.style.cursor="pointer";
1862 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1863 w.className="rico-icon rico-folderclosed"
1864 }d.insertCell(-1).appendChild(w)
1865 }}if(u&&this.options.showCheckBox){var n=document.createElement("input");
1866 n.type="checkbox";
1867 n.value=l;
1868 d.insertCell(-1).appendChild(n)
1869 }if(u&&!this.options.showCheckBox){var p=document.createElement("a");
1870 if(typeof u=="string"){p.href=u
1871 }else{p.href="javascript:void(0)";
1872 Rico.eventBind(p,"click",this.options.defaultAction)
1873 }this.hoverSet.add(p)
1874 }else{var p=document.createElement("p")
1875 }p.id=this.domID(l,"Desc");
1876 p.className="ricoTreeLevel"+a;
1877 switch(this.options.nodeIdDisplay){case"last":t+=" ("+l+")";
1878 break;
1879 case"first":t=l+" - "+t;
1880 break;
1881 case"tooltip":p.title=l;
1882 break
1883 }p.appendChild(document.createTextNode(t));
1884 d.insertCell(-1).appendChild(p);
1885 var j=v||this.treeDiv;
1886 j.appendChild(b);
1887 j.appendChild(m)
1888 },nodeClick:function(c){var b=Rico.eventElement(c);
1889 if(this.returnValue){var a=this.domID("","Desc");
1890 this.returnValue(b.id.substr(a.length),b.innerHTML)
1891 }this.close()
1892 },saveSelection:function(a){if(this.returnValue){this.returnValue(this.getCheckedItems())
1893 }this.close()
1894 },getCheckedItems:function(){var b=this.treeDiv.getElementsByTagName("input");
1895 var c=[];
1896 for(var a=0;
1897 a<b.length;
1898 a++){if(b[a].type=="checkbox"&&b[a].checked){c.push(b[a].value)
1899 }}return c
1900 },setCheckBoxes:function(c){var b=this.treeDiv.getElementsByTagName("input");
1901 for(var a=0;
1902 a<b.length;
1903 a++){if(b[a].type=="checkbox"){b[a].checked=c
1904 }}},clrCheckBoxEvent:function(a){Rico.eventStop(a);
1905 this.setCheckBoxes(false)
1906 },clickBranch:function(h){var g=Rico.eventElement(h);
1907 var f=Rico.getParentByTagName(g,"table");
1908 if(!f||!f.TreeContainer){return
1909 }var c=f.id.split("_");
1910 c[1]="Children";
1911 var b=Rico.$(c.join("_"));
1912 Rico.toggle(b);
1913 if(g.tagName=="DIV"){var d=Rico.visible(b);
1914 if(g.className.match(/node(p|m)(last)?$/)){g.className=g.className.replace(/nodep|nodem/,"node"+(d?"m":"p"))
1915 }else{if(g.className.match(/folder(open|closed)$/)){g.className=g.className.replace(/folder(open|closed)/,"folder"+(d?"open":"closed"))
1916 }else{if(g.className.match(/\b(m|p)$/)){g.className=g.className.replace(/(p|m)$/,d?"m":"p")
1917 }}}}if(!f.TreeFetchedChildren){f.TreeFetchedChildren=1;
1918 this.loadXMLDoc(g.name)
1919 }}};
1920 if(typeof Rico=="undefined"){throw ("GridCommon requires the Rico JavaScript framework")
1921 }Rico.GridCommon={baseInit:function(){this.options={saveColumnInfo:{width:true,filter:false,sort:false},cookiePrefix:"RicoGrid.",allowColResize:true,windowResize:true,click:null,dblclick:null,contextmenu:null,menuEvent:null,defaultWidth:-1,scrollBarWidth:19,minScrollWidth:100,frozenColumns:0,exportWindow:"height=400,width=500,scrollbars=1,menubar=1,resizable=1,location=0,toolbar=0,status=0",exportStyleList:["background-color","color","text-align","font-weight","font-size","font-family"],exportImgTags:false,exportFormFields:true,FilterLocation:null,FilterAllToken:"___ALL___",columnSpecs:[]};
1922 this.hdrCells=[];
1923 this.headerColCnt=0;
1924 this.headerRowIdx=0;
1925 this.tabs=new Array(2);
1926 this.thead=new Array(2);
1927 this.tbody=new Array(2)
1928 },attachMenuEvents:function(){var a;
1929 if(!this.options.menuEvent||this.options.menuEvent=="none"){return
1930 }this.hideScroll=navigator.userAgent.match(/Macintosh\b.*\b(Firefox|Camino)\b/i)||(Rico.isOpera&&parseFloat(window.opera.version())<9.5);
1931 this.options[this.options.menuEvent]=Rico.eventHandle(this,"handleMenuClick");
1932 if(this.highlightDiv){switch(this.options.highlightElem){case"cursorRow":this.attachMenu(this.highlightDiv[0]);
1933 break;
1934 case"cursorCell":for(a=0;
1935 a<2;
1936 a++){this.attachMenu(this.highlightDiv[a])
1937 }break
1938 }}for(a=0;
1939 a<2;
1940 a++){this.attachMenu(this.tbody[a])
1941 }},attachMenu:function(a){if(this.options.click){Rico.eventBind(a,"click",this.options.click,false)
1942 }if(this.options.dblclick){if(Rico.isWebKit||Rico.isOpera){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleDblClick"),false)
1943 }else{Rico.eventBind(a,"dblclick",this.options.dblclick,false)
1944 }}if(this.options.contextmenu){if(Rico.isOpera||Rico.isKonqueror){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleContextMenu"),false)
1945 }else{Rico.eventBind(a,"contextmenu",this.options.contextmenu,false)
1946 }}},handleDblClick:function(b){var a=Rico.eventElement(b);
1947 if(this.dblClickElem==a){this.options.dblclick(b)
1948 }else{this.dblClickElem=a;
1949 this.safariTimer=Rico.runLater(300,this,"clearDblClick")
1950 }},clearDblClick:function(){this.dblClickElem=null
1951 },handleContextMenu:function(c){var a;
1952 if(typeof(c.which)=="number"){a=c.which
1953 }else{if(typeof(c.button)=="number"){a=c.button
1954 }else{return
1955 }}if(a==1&&c.ctrlKey){this.options.contextmenu(c)
1956 }},cancelMenu:function(){if(this.menu){this.menu.cancelmenu()
1957 }},getColumnInfo:function(f){Rico.log("getColumnInfo: len="+f.length);
1958 if(f.length==0){return 0
1959 }this.headerRowCnt=f.length;
1960 var d,h,e;
1961 for(d=0;
1962 d<this.headerRowCnt;
1963 d++){var b=f[d];
1964 var a=b.cells;
1965 if(d>=this.hdrCells.length){this.hdrCells[d]=[]
1966 }for(h=0;
1967 h<a.length;
1968 h++){var g={};
1969 g.cell=a[h];
1970 g.colSpan=a[h].colSpan||1;
1971 if(this.options.defaultWidth<0){g.initWidth=a[h].offsetWidth
1972 }this.hdrCells[d].push(g)
1973 }if(b.id.slice(-5)=="_main"){e=this.hdrCells[d].length;
1974 this.headerRowIdx=d
1975 }}if(!e){this.headerRowIdx=this.headerRowCnt-1;
1976 e=this.hdrCells[this.headerRowIdx].length
1977 }Rico.log("getColumnInfo: colcnt="+e);
1978 return e
1979 },addHeadingRow:function(g){var a=this.headerRowCnt++;
1980 this.hdrCells[a]=[];
1981 for(var e=0;
1982 e<2;
1983 e++){var k=this.thead[e].insertRow(-1);
1984 var f="ricoLG_hdg "+this.tableId+"_hdg"+a;
1985 if(g){f+=" "+g
1986 }k.className=f;
1987 var b=e==0?this.options.frozenColumns:this.headerColCnt-this.options.frozenColumns;
1988 for(var j=0;
1989 j<b;
1990 j++){var d=k.insertCell(-1);
1991 var i=Rico.wrapChildren(d,"ricoLG_col");
1992 Rico.wrapChildren(i,"ricoLG_cell");
1993 this.hdrCells[a].push({cell:d,colSpan:1})
1994 }}return a
1995 },createColumnArray:function(b){this.direction=Rico.getStyle(this.outerDiv,"direction").toLowerCase();
1996 this.align=this.direction=="rtl"?["right","left"]:["left","right"];
1997 Rico.log("createColumnArray: dir="+this.direction);
1998 this.columns=[];
1999 for(var e=0;
2000 e<this.headerColCnt;
2001 e++){Rico.log("createColumnArray: c="+e);
2002 var d=e<this.options.frozenColumns?0:1;
2003 var a=new Rico[b](this,e,this.hdrCells[this.headerRowIdx][e],d);
2004 this.columns.push(a);
2005 if(e>0){this.columns[e-1].next=a
2006 }}this.getCookie();
2007 Rico.runLater(100,this,"insertResizers")
2008 },insertResizers:function(){if(!this.options.allowColResize){return
2009 }for(var a=0;
2010 a<this.columns.length;
2011 a++){this.columns[a].insertResizer()
2012 }},createDivs:function(){Rico.log("createDivs start");
2013 this.outerDiv=this.createDiv("outer");
2014 if(Rico.theme.gridContainer){Rico.addClass(this.outerDiv,Rico.theme.gridContainer)
2015 }if(this.outerDiv.firstChild&&this.outerDiv.firstChild.tagName&&this.outerDiv.firstChild.tagName.toUpperCase()=="TABLE"){this.structTab=this.outerDiv.firstChild;
2016 this.structTabLeft=this.structTab.rows[0].cells[0];
2017 this.structTabUR=this.structTab.rows[0].cells[1];
2018 this.structTabLR=this.structTab.rows[1].cells[0]
2019 }else{this.structTab=document.createElement("table");
2020 this.structTab.border=0;
2021 this.structTab.cellPadding=0;
2022 this.structTab.cellSpacing=0;
2023 var b=this.structTab.insertRow(-1);
2024 b.vAlign="top";
2025 this.structTabLeft=b.insertCell(-1);
2026 this.structTabLeft.rowSpan=2;
2027 this.structTabLeft.style.padding="0px";
2028 this.structTabLeft.style.border="none";
2029 var d=this.structTab.insertRow(-1);
2030 d.vAlign="top";
2031 this.structTabUR=b.insertCell(-1);
2032 this.structTabUR.style.padding="0px";
2033 this.structTabUR.style.border="none";
2034 this.structTabLR=d.insertCell(-1);
2035 this.structTabLR.style.padding="0px";
2036 this.structTabLR.style.border="none";
2037 this.outerDiv.appendChild(this.structTab)
2038 }Rico.addClass(this.structTab,"ricoLG_StructTab");
2039 this.frozenTabs=this.createDiv("frozenTabs",this.structTabLeft);
2040 this.innerDiv=this.createDiv("inner",this.structTabUR);
2041 this.scrollDiv=this.createDiv("scroll",this.structTabLR);
2042 this.resizeDiv=this.createDiv("resize",this.outerDiv,true);
2043 this.messagePopup=new Rico.Popup();
2044 this.messagePopup.createContainer({hideOnEscape:false,hideOnClick:false,parent:this.outerDiv});
2045 this.messagePopup.content.className="ricoLG_messageDiv";
2046 if(Rico.theme.gridMessage){Rico.addClass(this.messagePopup.content,Rico.theme.gridMessage)
2047 }this.keywordPopup=new Rico.Window("",{zIndex:-1,parent:this.outerDiv});
2048 Rico.addClass(this.keywordPopup.container,"ricoLG_keywordDiv");
2049 var a=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
2050 a.innerHTML=Rico.getPhraseById("keywordPrompt");
2051 this.keywordBox=this.keywordPopup.contentDiv.appendChild(document.createElement("input"));
2052 this.keywordBox.size=20;
2053 Rico.eventBind(this.keywordBox,"keypress",Rico.eventHandle(this,"keywordKey"),false);
2054 this.keywordPopup.contentDiv.appendChild(Rico.floatButton("Checkmark",Rico.eventHandle(this,"processKeyword")));
2055 var c=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
2056 Rico.setStyle(c,{clear:"both"});
2057 Rico.log("createDivs end")
2058 },keywordKey:function(a){switch(Rico.eventKey(a)){case 27:this.closeKeyword();
2059 Rico.eventStop(a);
2060 return false;
2061 case 13:this.processKeyword();
2062 Rico.eventStop(a);
2063 return false
2064 }return true
2065 },openKeyword:function(a){this.keywordCol=a;
2066 this.keywordBox.value="";
2067 this.keywordPopup.setTitle(this.columns[a].displayName);
2068 this.keywordPopup.centerPopup();
2069 this.keywordBox.focus()
2070 },closeKeyword:function(){this.keywordPopup.closePopup();
2071 this.cancelMenu()
2072 },processKeyword:function(){var a=this.keywordBox.value;
2073 this.closeKeyword();
2074 this.columns[this.keywordCol].setFilterKW(a)
2075 },createDiv:function(c,a,b){var e=this.tableId+"_"+c+"Div";
2076 var d=document.getElementById(e);
2077 if(!d){d=document.createElement("div");
2078 d.id=e;
2079 if(a){a.appendChild(d)
2080 }}d.className="ricoLG_"+c+"Div";
2081 if(b){Rico.hide(d)
2082 }return d
2083 },baseSizeDivs:function(){this.setOtherHdrCellWidths();
2084 if(this.options.frozenColumns){Rico.show(this.tabs[0]);
2085 Rico.show(this.frozenTabs);
2086 this.hdrHt=Math.max(Rico.nan2zero(this.thead[0].offsetHeight),this.thead[1].offsetHeight);
2087 this.dataHt=Math.max(Rico.nan2zero(this.tbody[0].offsetHeight),this.tbody[1].offsetHeight);
2088 this.frzWi=this.borderWidth(this.tabs[0])
2089 }else{Rico.hide(this.tabs[0]);
2090 Rico.hide(this.frozenTabs);
2091 this.frzWi=0;
2092 this.hdrHt=this.thead[1].offsetHeight;
2093 this.dataHt=this.tbody[1].offsetHeight
2094 }var d,b;
2095 var c=this.borderWidth(this.columns[0].dataCell);
2096 Rico.log("baseSizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
2097 Rico.log(this.tableId+" frzWi="+this.frzWi+" borderWi="+c);
2098 for(b=0;
2099 b<this.options.frozenColumns;
2100 b++){if(this.columns[b].visible){this.frzWi+=parseInt(this.columns[b].colWidth,10)+c
2101 }}this.scrTabWi=this.borderWidth(this.tabs[1]);
2102 this.scrTabWi0=this.scrTabWi;
2103 Rico.log("scrTabWi: "+this.scrTabWi);
2104 for(b=this.options.frozenColumns;
2105 b<this.columns.length;
2106 b++){if(this.columns[b].visible){this.scrTabWi+=parseInt(this.columns[b].colWidth,10)+c
2107 }}this.scrWi=this.scrTabWi+this.options.scrollBarWidth;
2108 if(this.sizeTo=="parent"){if(Rico.isIE){Rico.hide(this.outerDiv)
2109 }d=this.outerDiv.parentNode.offsetWidth;
2110 if(Rico.isIE){Rico.show(this.outerDiv)
2111 }}else{d=Rico.windowWidth()-this.options.scrollBarWidth-8
2112 }if(this.outerDiv.parentNode.clientWidth>0){d=Math.min(this.outerDiv.parentNode.clientWidth,d)
2113 }var a=this.frzWi+this.scrWi-d;
2114 Rico.log("baseSizeDivs "+this.tableId+": scrWi="+this.scrWi+" wiLimit="+d+" overage="+a+" clientWidth="+this.outerDiv.parentNode.clientWidth);
2115 if(a>0&&this.options.frozenColumns<this.columns.length){this.scrWi=Math.max(this.scrWi-a,this.options.minScrollWidth)
2116 }this.scrollDiv.style.width=this.scrWi+"px";
2117 this.frozenTabs.style.width=this.frzWi+"px";
2118 this.outerDiv.style.width=(this.frzWi+this.scrWi)+"px"
2119 },borderWidth:function(c){var a=Rico.nan2zero(Rico.getStyle(c,"borderLeftWidth"));
2120 var b=Rico.nan2zero(Rico.getStyle(c,"borderRightWidth"));
2121 Rico.log((c.id||c.tagName)+" borderWidth: L="+a+", R="+b);
2122 return a+b
2123 },setOtherHdrCellWidths:function(){var k,g,f,a,l,b,m,d,e,h;
2124 for(a=0;
2125 a<this.hdrCells.length;
2126 a++){if(a==this.headerRowIdx){continue
2127 }Rico.log("setOtherHdrCellWidths: r="+a);
2128 k=g=0;
2129 while(g<this.headerColCnt&&k<this.hdrCells[a].length){b=this.hdrCells[a][k];
2130 m=b.cell;
2131 d=e=b.colSpan;
2132 for(l=f=0;
2133 f<d;
2134 f++,g++){if(this.columns[g].hdrCell.style.display=="none"){e--
2135 }else{if(this.columns[g].hdrColDiv.style.display!="none"){l+=parseInt(this.columns[g].colWidth,10)
2136 }}}if(!b.hdrColDiv||!b.hdrCellDiv){h=m.getElementsByTagName("div");
2137 b.hdrColDiv=(h.length<1)?Rico.wrapChildren(m,"ricoLG_col"):h[0];
2138 b.hdrCellDiv=(h.length<2)?Rico.wrapChildren(b.hdrColDiv,"ricoLG_cell"):h[1]
2139 }if(e==0){m.style.display="none"
2140 }else{if(l==0){b.hdrColDiv.style.display="none";
2141 m.colSpan=e
2142 }else{m.style.display="";
2143 b.hdrColDiv.style.display="";
2144 m.colSpan=e;
2145 b.hdrColDiv.style.width=l+"px"
2146 }}k++
2147 }}},initFilterImage:function(a){this.filterAnchor=document.getElementById(this.tableId+"_filterLink");
2148 if(!this.filterAnchor){return
2149 }this.filterRows=Rico.select("tr."+this.tableId+"_hdg"+a);
2150 if(this.filterRows.length!=2){return
2151 }for(var c=0,d=[];
2152 c<2;
2153 c++){d[c]=Rico.select(".ricoLG_cell",this.filterRows[c])
2154 }this.filterElements=d[0].concat(d[1]);
2155 this.saveHeight=this.filterElements[0].offsetHeight;
2156 var e=Rico.getStyle(this.filterElements[0],"paddingTop");
2157 var b=Rico.getStyle(this.filterElements[0],"paddingBottom");
2158 if(e){this.saveHeight-=parseInt(e,10)
2159 }if(b){this.saveHeight-=parseInt(b,10)
2160 }this.rowNum=a;
2161 this.setFilterImage(false)
2162 },toggleFilterRow:function(){if(Rico.visible(this.filterRows[0])){this.slideFilterUp()
2163 }else{this.slideFilterDown()
2164 }},setFilterImage:function(b){var a=Rico.getPhraseById((b?"show":"hide")+"FilterRow");
2165 this.filterAnchor.innerHTML='<img src="'+Rico.imgDir+"tableFilter"+(b?"Expand":"Collapse")+'.gif" alt="'+a+'" border="0">'
2166 },cell:function(a,b){return(0<=b&&b<this.columns.length&&a>=0)?this.columns[b].cell(a):null
2167 },availHt:function(){var a=Rico.cumulativeOffset(this.outerDiv);
2168 return Rico.windowHeight()-a.top-2*this.options.scrollBarWidth-15
2169 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
2170 this.hdrTabs[1].style.marginLeft=a
2171 },pluginScroll:function(){if(this.scrollPluggedIn){return
2172 }Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
2173 this.scrollPluggedIn=true
2174 },unplugScroll:function(){Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
2175 this.scrollPluggedIn=false
2176 },hideMsg:function(){this.messagePopup.closePopup()
2177 },showMsg:function(a){this.messagePopup.setContent(a);
2178 this.messagePopup.centerPopup();
2179 Rico.log("showMsg: "+a)
2180 },listInvisible:function(b){var c=[];
2181 for(var a=0;
2182 a<this.columns.length;
2183 a++){if(!this.columns[a].visible){c.push(b?this.columns[a][b]:this.columns[a])
2184 }}return c
2185 },firstVisible:function(){for(var a=0;
2186 a<this.columns.length;
2187 a++){if(this.columns[a].visible){return a
2188 }}return -1
2189 },showAll:function(){var b=this.listInvisible();
2190 for(var a=0;
2191 a<b.length;
2192 a++){b[a].showColumn()
2193 }},chooseColumns:function(){this.menu.cancelmenu();
2194 var a,f,b,e,d,c;
2195 if(!this.columnChooser){Rico.log("creating columnChooser");
2196 f=Rico.getStyle(this.outerDiv.offsetParent,"zIndex");
2197 if(typeof f!="number"){f=0
2198 }this.columnChooser=new Rico.Window(Rico.getPhraseById("gridChooseCols"),{zIndex:f+2,parent:this.outerDiv});
2199 Rico.addClass(this.columnChooser.container,"ricoLG_chooserDiv");
2200 c=this.columnChooser.contentDiv;
2201 for(a=0;
2202 a<this.columns.length;
2203 a++){b=this.columns[a];
2204 e=c.appendChild(document.createElement("div"));
2205 b.ChooserBox=Rico.createFormField(e,"input","checkbox");
2206 d=e.appendChild(document.createElement("span"));
2207 d.innerHTML=b.displayName;
2208 Rico.eventBind(b.ChooserBox,"click",Rico.eventHandle(b,"chooseColumn"),false)
2209 }}Rico.log("opening columnChooser");
2210 this.columnChooser.openPopup(3,this.hdrHt+3);
2211 for(a=0;
2212 a<this.columns.length;
2213 a++){this.columns[a].ChooserBox.checked=this.columns[a].visible;
2214 this.columns[a].ChooserBox.disabled=!this.columns[a].canHideShow()
2215 }},blankRow:function(a){for(var b=0;
2216 b<this.columns.length;
2217 b++){this.columns[b].clearCell(a)
2218 }},getExportStyles:function(a){var e=this.options.exportStyleList;
2219 var b=Rico.getStyle(a,"backgroundImage");
2220 if(!b||b=="none"){return e
2221 }for(var d=[],c=0;
2222 c<e.length;
2223 c++){if(e[c]!="background-color"&&e[c]!="color"){d.push(e[c])
2224 }}return d
2225 },exportStart:function(){var a,h,f,d,b,e,k,l;
2226 var g=this.getExportStyles(this.thead[0]);
2227 this.exportRows=[];
2228 this.exportText="<html><head></head><body><table border='1' cellspacing='0'>";
2229 for(h=0;
2230 h<this.columns.length;
2231 h++){if(this.columns[h].visible){this.exportText+="<col width='"+parseInt(this.columns[h].colWidth,10)+"'>"
2232 }}this.exportText+="<thead style='display: table-header-group;'>";
2233 if(this.exportHeader){this.exportText+=this.exportHeader
2234 }for(a=0;
2235 a<this.hdrCells.length;
2236 a++){if(this.hdrCells[a].length==0||!Rico.visible(this.hdrCells[a][0].cell.parentNode)){continue
2237 }this.exportText+="<tr>";
2238 for(h=0,f=0;
2239 h<this.hdrCells[a].length;
2240 h++){b=this.hdrCells[a][h];
2241 e=b.colSpan;
2242 for(d=0;
2243 d<b.colSpan;
2244 d++,f++){if(!this.columns[f].visible){e--
2245 }}if(e>0){k=Rico.select(".ricoLG_cell",b.cell);
2246 l=k&&k.length>0?k[0]:b.cell;
2247 this.exportText+="<td style='"+this.exportStyle(l,g)+"'";
2248 if(b.colSpan>1){this.exportText+=" colspan='"+e+"'"
2249 }this.exportText+=">"+Rico.getInnerText(l,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport")+"</td>"
2250 }}this.exportText+="</tr>"
2251 }this.exportText+="</thead><tbody>"
2252 },exportFinish:function(){if(this.hideMsg){this.hideMsg()
2253 }window.status=Rico.getPhraseById("exportComplete");
2254 if(this.exportRows.length>0){this.exportText+="<tr>"+this.exportRows.join("</tr><tr>")+"</tr>"
2255 }if(this.exportFooter){this.exportText+=this.exportFooter
2256 }this.exportText+="</tbody></table></body></html>";
2257 if(this.cancelMenu){this.cancelMenu()
2258 }var a=window.open("","_blank",this.options.exportWindow);
2259 if(a==null){alert(Rico.getPhraseById("disableBlocker"))
2260 }else{a.document.open();
2261 a.document.write(this.exportText);
2262 a.document.close()
2263 }this.exportText=undefined;
2264 this.exportRows=undefined
2265 },exportStyle:function(d,g){for(var b=0,c="";
2266 b<g.length;
2267 b++){try{var a=Rico.getStyle(d,g[b]);
2268 if(a){c+=g[b]+":"+a+";"
2269 }}catch(f){}}return c
2270 },getCookie:function(){var k=Rico.getCookie(this.options.cookiePrefix+this.tableId);
2271 if(!k){return
2272 }var f=k.split(",");
2273 for(var g=0;
2274 g<f.length;
2275 g++){var a=f[g].split(":");
2276 if(a.length!=2){continue
2277 }var h=parseInt(a[0].slice(1),10);
2278 if(h<0||h>=this.columns.length){continue
2279 }var e=this.columns[h];
2280 switch(a[0].charAt(0)){case"w":e.setColWidth(a[1]);
2281 e.customWidth=true;
2282 break;
2283 case"h":if(a[1].toLowerCase()=="true"){e.hideshow(true,true)
2284 }else{e.hideshow(false,true)
2285 }break;
2286 case"s":if(!this.options.saveColumnInfo.sort||!e.sortable){break
2287 }e.setSorted(a[1]);
2288 break;
2289 case"f":if(!this.options.saveColumnInfo.filter||!e.filterable){break
2290 }var d=a[1].split("~");
2291 e.filterOp=d.shift();
2292 e.filterValues=[];
2293 e.filterType=Rico.ColumnConst.USERFILTER;
2294 for(var b=0;
2295 b<d.length;
2296 b++){e.filterValues.push(unescape(d[b]))
2297 }break
2298 }}},setCookie:function(){var d=[];
2299 for(var e=0;
2300 e<this.columns.length;
2301 e++){var c=this.columns[e];
2302 if(this.options.saveColumnInfo.width){if(c.customWidth){d.push("w"+e+":"+c.colWidth)
2303 }if(c.customVisible){d.push("h"+e+":"+c.visible)
2304 }}if(this.options.saveColumnInfo.sort){if(c.currentSort!=Rico.ColumnConst.UNSORTED){d.push("s"+e+":"+c.currentSort)
2305 }}if(this.options.saveColumnInfo.filter&&c.filterType==Rico.ColumnConst.USERFILTER){var b=[c.filterOp];
2306 for(var a=0;
2307 a<c.filterValues.length;
2308 a++){b.push(escape(c.filterValues[a]))
2309 }d.push("f"+e+":"+b.join("~"))
2310 }}Rico.setCookie(this.options.cookiePrefix+this.tableId,d.join(","),this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
2311 }};
2312 Rico.ColumnConst={UNFILTERED:0,SYSTEMFILTER:1,USERFILTER:2,UNSORTED:0,SORT_ASC:"ASC",SORT_DESC:"DESC",MINWIDTH:10};
2313 Rico.TableColumnBase=function(){};
2314 Rico.TableColumnBase.prototype={baseInit:function(h,g,e,d){Rico.log("TableColumnBase.baseInit index="+g+" tabIdx="+d);
2315 this.liveGrid=h;
2316 this.index=g;
2317 this.hideWidth=Rico.isKonqueror||Rico.isWebKit||h.headerRowCnt>1?5:2;
2318 this.options=h.options;
2319 this.tabIdx=d;
2320 this.hdrCell=e.cell;
2321 this.body=document.getElementsByTagName("body")[0];
2322 this.displayName=this.getDisplayName(this.hdrCell);
2323 var c=this.hdrCell.getElementsByTagName("div");
2324 this.hdrColDiv=(c.length<1)?Rico.wrapChildren(this.hdrCell,"ricoLG_col"):c[0];
2325 this.hdrCellDiv=(c.length<2)?Rico.wrapChildren(this.hdrColDiv,"ricoLG_cell"):c[1];
2326 var f=d==0?g:g-h.options.frozenColumns;
2327 this.dataCell=h.tbody[d].rows[0].cells[f];
2328 c=this.dataCell.getElementsByTagName("div");
2329 this.dataColDiv=(c.length<1)?Rico.wrapChildren(this.dataCell,"ricoLG_col"):c[0];
2330 this.mouseDownHandler=Rico.eventHandle(this,"handleMouseDown");
2331 this.mouseMoveHandler=Rico.eventHandle(this,"handleMouseMove");
2332 this.mouseUpHandler=Rico.eventHandle(this,"handleMouseUp");
2333 this.mouseOutHandler=Rico.eventHandle(this,"handleMouseOut");
2334 this.format={type:"text"};
2335 var b=h.options.columnSpecs[g];
2336 if(typeof b=="object"){Rico.extend(this.format,b)
2337 }Rico.addClass(this.dataColDiv,this.colClassName());
2338 this.visible=true;
2339 if(typeof this.format.visible=="boolean"){this.visible=this.format.visible
2340 }this.sortable=typeof this.format.canSort=="boolean"?this.format.canSort:h.options.canSortDefault;
2341 this.currentSort=Rico.ColumnConst.UNSORTED;
2342 this.filterable=typeof this.format.canFilter=="boolean"?this.format.canFilter:h.options.canFilterDefault;
2343 this.filterType=Rico.ColumnConst.UNFILTERED;
2344 this.hideable=typeof this.format.canHide=="boolean"?this.format.canHide:h.options.canHideDefault;
2345 var a;
2346 switch(typeof this.format.width){case"number":a=this.format.width;
2347 break;
2348 case"string":a=parseInt(this.format.width,10);
2349 break;
2350 default:a=e.initWidth;
2351 break
2352 }a=(typeof(a)=="number")?Math.max(a,Rico.ColumnConst.MINWIDTH):h.options.defaultWidth;
2353 this.setColWidth(a);
2354 if(!this.visible){this.setDisplay("none")
2355 }},colClassName:function(){return this.format.ClassName?this.format.ClassName:this.liveGrid.tableId+"_col"+this.index
2356 },insertResizer:function(){if(this.format.noResize){return
2357 }var a=document.createElement("div");
2358 a.className="ricoLG_Resize";
2359 a.style[this.liveGrid.align[1]]="0px";
2360 this.hdrCellDiv.appendChild(a);
2361 Rico.eventBind(a,"mousedown",this.mouseDownHandler,false)
2362 },getDisplayName:function(a){var b=a.getElementsByTagName("A");
2363 if(b.length>0){return b[0].innerHTML
2364 }else{return Rico.stripTags(a.innerHTML)
2365 }},_clear:function(a){a.innerHTML="&nbsp;"
2366 },clearCell:function(b){var a=this.cell(b);
2367 this._clear(a,b);
2368 if(this.liveGrid.buffer&&this.liveGrid.buffer.options.acceptStyle){a.style.cssText=""
2369 }},dataTable:function(){return this.liveGrid.tabs[this.tabIdx]
2370 },numRows:function(){return this.dataColDiv.childNodes.length
2371 },clearColumn:function(){var b=this.numRows();
2372 for(var a=0;
2373 a<b;
2374 a++){this.clearCell(a)
2375 }},cell:function(a){return this.dataColDiv.childNodes[a]
2376 },getFormattedValue:function(c,a,d,b){return Rico.getInnerText(this.cell(c),a,d,b)
2377 },setColWidth:function(a){if(typeof a=="number"){a=parseInt(a,10);
2378 if(a<Rico.ColumnConst.MINWIDTH){return
2379 }a=a+"px"
2380 }Rico.log("setColWidth "+this.index+": "+a);
2381 this.colWidth=a;
2382 this.hdrColDiv.style.width=a;
2383 this.dataColDiv.style.width=a
2384 },pluginMouseEvents:function(){if(this.mousePluggedIn==true){return
2385 }Rico.eventBind(this.body,"mousemove",this.mouseMoveHandler,false);
2386 Rico.eventBind(this.body,"mouseup",this.mouseUpHandler,false);
2387 Rico.eventBind(this.body,"mouseout",this.mouseOutHandler,false);
2388 this.mousePluggedIn=true
2389 },unplugMouseEvents:function(){Rico.eventUnbind(this.body,"mousemove",this.mouseMoveHandler,false);
2390 Rico.eventUnbind(this.body,"mouseup",this.mouseUpHandler,false);
2391 Rico.eventUnbind(this.body,"mouseout",this.mouseOutHandler,false);
2392 this.mousePluggedIn=false
2393 },handleMouseDown:function(b){this.resizeStart=Rico.eventClient(b).x;
2394 this.origWidth=parseInt(this.colWidth,10);
2395 var a=Rico.positionedOffset(this.hdrCell);
2396 if(this.liveGrid.direction=="rtl"){this.edge=a.left;
2397 switch(this.tabIdx){case 0:this.edge+=this.liveGrid.innerDiv.offsetWidth;
2398 break;
2399 case 1:this.edge-=this.liveGrid.scrollDiv.scrollLeft;
2400 break
2401 }}else{this.edge=a.left+this.hdrCell.offsetWidth;
2402 if(this.tabIdx>0){this.edge+=Rico.nan2zero(this.liveGrid.tabs[0].offsetWidth)
2403 }}this.liveGrid.resizeDiv.style.left=this.edge+"px";
2404 this.liveGrid.resizeDiv.style.display="";
2405 this.liveGrid.outerDiv.style.cursor="e-resize";
2406 this.tmpHighlight=this.liveGrid.highlightEnabled;
2407 this.liveGrid.highlightEnabled=false;
2408 this.pluginMouseEvents();
2409 Rico.eventStop(b)
2410 },handleMouseMove:function(b){var c=Rico.eventClient(b).x-this.resizeStart;
2411 var a=(this.liveGrid.direction=="rtl")?this.origWidth-c:this.origWidth+c;
2412 if(a<Rico.ColumnConst.MINWIDTH){return
2413 }this.liveGrid.resizeDiv.style.left=(this.edge+c)+"px";
2414 this.colWidth=a;
2415 Rico.eventStop(b)
2416 },handleMouseUp:function(a){this.unplugMouseEvents();
2417 Rico.log("handleMouseUp "+this.liveGrid.tableId);
2418 this.liveGrid.outerDiv.style.cursor="";
2419 this.liveGrid.resizeDiv.style.display="none";
2420 this.setColWidth(this.colWidth);
2421 this.customWidth=true;
2422 this.liveGrid.setCookie();
2423 this.liveGrid.highlightEnabled=this.tmpHighlight;
2424 this.liveGrid.sizeDivs();
2425 Rico.eventStop(a)
2426 },handleMouseOut:function(b){var a=Rico.eventRelatedTarget(b)||b.toElement;
2427 while(a!=null&&a.nodeName.toLowerCase()!="body"){a=a.parentNode
2428 }if(a!=null&&a.nodeName.toLowerCase()=="body"){return true
2429 }this.handleMouseUp(b);
2430 return true
2431 },setDisplay:function(a){this.hdrCell.style.display=a;
2432 this.hdrColDiv.style.display=a;
2433 this.dataCell.style.display=a;
2434 this.dataColDiv.style.display=a
2435 },hideshow:function(b,a){this.setDisplay(b?"":"none");
2436 this.liveGrid.cancelMenu();
2437 this.visible=b;
2438 this.customVisible=true;
2439 if(a){return
2440 }this.liveGrid.setCookie();
2441 this.liveGrid.sizeDivs()
2442 },hideColumn:function(){Rico.log("hideColumn "+this.liveGrid.tableId);
2443 this.hideshow(false,false)
2444 },showColumn:function(){Rico.log("showColumn "+this.liveGrid.tableId);
2445 this.hideshow(true,false)
2446 },chooseColumn:function(b){var a=Rico.eventElement(b);
2447 this.hideshow(a.checked,false)
2448 },setImage:function(){if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.imgSort.style.display="inline-block";
2449 this.imgSort.className=Rico.theme.sortAsc||"rico-icon ricoLG_sortAsc"
2450 }else{if(this.currentSort==Rico.ColumnConst.SORT_DESC){this.imgSort.style.display="inline-block";
2451 this.imgSort.className=Rico.theme.sortDesc||"rico-icon ricoLG_sortDesc"
2452 }else{this.imgSort.style.display="none"
2453 }}if(this.filterType==Rico.ColumnConst.USERFILTER){this.imgFilter.style.display="inline-block";
2454 this.imgFilter.title=this.getFilterText()
2455 }else{this.imgFilter.style.display="none"
2456 }},canHideShow:function(){return this.hideable
2457 }};
2458 if(typeof Rico=="undefined"){throw ("SimpleGrid requires the Rico JavaScript framework")
2459 }Rico.SimpleGrid=function(b,a){this.initialize(b,a)
2460 };
2461 Rico.SimpleGrid.prototype={initialize:function(b,a){Rico.extend(this,Rico.GridCommon);
2462 this.baseInit();
2463 Rico.setDebugArea(b+"_debugmsgs");
2464 Rico.extend(this.options,a||{});
2465 this.tableId=b;
2466 Rico.log("SimpleGrid initialize start: "+b);
2467 this.createDivs();
2468 this.hdrTabs=new Array(2);
2469 this.simpleGridInit();
2470 Rico.log("SimpleGrid initialize end: "+b)
2471 },simpleGridInit:function(){var a;
2472 for(a=0;
2473 a<2;
2474 a++){Rico.log("simpleGridInit "+a);
2475 this.tabs[a]=Rico.$(this.tableId+"_tab"+a);
2476 if(!this.tabs[a]){return
2477 }this.hdrTabs[a]=Rico.$(this.tableId+"_tab"+a+"h");
2478 if(!this.hdrTabs[a]){return
2479 }this.thead[a]=this.hdrTabs[a];
2480 this.tbody[a]=this.tabs[a];
2481 this.headerColCnt=this.getColumnInfo(this.hdrTabs[a].rows);
2482 if(a==0){this.options.frozenColumns=this.headerColCnt
2483 }if(Rico.theme.gridheader){Rico.addClass(this.thead[a],Rico.theme.gridheader)
2484 }if(Rico.theme.gridcontent){Rico.addClass(this.tbody[a],Rico.theme.gridcontent)
2485 }}if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2486 return
2487 }this.createColumnArray("SimpleGridColumn");
2488 this.pageSize=this.columns[0].dataColDiv.childNodes.length;
2489 this.sizeDivs();
2490 if(typeof(this.options.FilterLocation)=="number"){this.createFilters(this.options.FilterLocation)
2491 }this.attachMenuEvents();
2492 this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2493 this.pluginScroll();
2494 if(this.options.windowResize){Rico.eventBind(window,"resize",Rico.eventHandle(this,"sizeDivs"),false)
2495 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
2496 },createFilters:function(a){if(a<0){a=this.addHeadingRow();
2497 this.sizeDivs()
2498 }for(var g=0;
2499 g<this.headerColCnt;
2500 g++){var d=this.columns[g];
2501 var e=d.format;
2502 if(typeof e.filterUI!="string"){continue
2503 }var k=this.hdrCells[a][g].cell;
2504 var j,b=this.filterId(g);
2505 var h=k.getElementsByTagName("div");
2506 switch(e.filterUI.charAt(0)){case"t":j=Rico.createFormField(h[1],"input","text",b,b);
2507 var m=e.filterUI.match(/\d+/);
2508 j.maxLength=e.Length||50;
2509 j.size=m?parseInt(m,10):10;
2510 Rico.eventBind(j,"keyup",Rico.eventHandle(d,"filterKeypress"),false);
2511 break;
2512 case"s":j=Rico.createFormField(h[1],"select",null,b);
2513 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
2514 this.getFilterValues(d);
2515 var l=Rico.keys(d.filterHash);
2516 l.sort();
2517 for(var f=0;
2518 f<l.length;
2519 f++){Rico.addSelectOption(j,l[f],l[f]||Rico.getPhraseById("filterBlank"))
2520 }Rico.eventBind(j,"change",Rico.eventHandle(d,"filterChange"),false);
2521 break
2522 }}this.initFilterImage(a)
2523 },getFilterValues:function(b){var e={};
2524 var f=b.numRows();
2525 for(var c=0;
2526 c<f;
2527 c++){var a=Rico.getInnerText(b.cell(c));
2528 var d=e[a];
2529 if(d){d.push(c)
2530 }else{e[a]=[c]
2531 }}b.filterHash=e
2532 },applyFilters:function(){var b=[];
2533 for(var f=0;
2534 f<this.columns.length;
2535 f++){if(this.columns[f].filterRows){b.push(this.columns[f].filterRows)
2536 }}if(b.length==0){this.showAllRows();
2537 return
2538 }for(var d=0;
2539 d<this.pageSize;
2540 d++){var e=true;
2541 for(var a=0;
2542 a<b.length;
2543 a++){if(b[a].indexOf(d)==-1){e=false;
2544 break
2545 }}if(e){this.showRow(d)
2546 }else{this.hideRow(d)
2547 }}this.sizeDivs()
2548 },handleScroll:function(b){var a=(-this.scrollDiv.scrollTop)+"px";
2549 this.tabs[0].style.marginTop=a;
2550 this.setHorizontalScroll()
2551 },registerScrollMenu:function(a){if(!this.menu){this.menu=a
2552 }a.grid=this;
2553 a.showmenu=a.showSimpleMenu;
2554 a.showSubMenu=a.showSimpleSubMenu;
2555 a.createDiv(this.outerDiv)
2556 },handleMenuClick:function(a){if(!this.menu){return
2557 }this.cancelMenu();
2558 this.menuCell=Rico.getParentByTagName(Rico.eventElement(a),"div");
2559 this.highlightEnabled=false;
2560 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
2561 }if(this.menu.buildGridMenu){this.menu.buildGridMenu(this.menuCell)
2562 }this.menu.showmenu(a,this.closeMenu.bind(this))
2563 },closeMenu:function(){if(this.hideScroll){this.scrollDiv.style.overflow=""
2564 }this.highlightEnabled=true
2565 },sizeDivs:function(){if(this.outerDiv.offsetParent.style.display=="none"){return
2566 }this.baseSizeDivs();
2567 var c=Math.max(this.options.maxHt||this.availHt(),50);
2568 var b=Math.min(this.hdrHt+this.dataHt,c);
2569 Rico.log("sizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
2570 this.dataHt=b-this.hdrHt;
2571 if(this.scrWi>0){this.dataHt+=this.options.scrollBarWidth
2572 }this.scrollDiv.style.height=this.dataHt+"px";
2573 this.frozenTabs.style.height=this.scrollDiv.clientHeight+"px";
2574 var a=2;
2575 this.innerDiv.style.width=(this.scrWi-this.options.scrollBarWidth+a)+"px";
2576 b+=a;
2577 this.resizeDiv.style.height=b+"px";
2578 this.handleScroll()
2579 },printVisible:function(){this.showMsg(Rico.getPhraseById("exportInProgress"));
2580 Rico.runLater(10,this,"_printVisible")
2581 },_printVisible:function(){this.exportStart();
2582 var f=this.getExportStyles(this.tbody[0]);
2583 for(var e=0;
2584 e<this.pageSize;
2585 e++){if(this.columns[0].cell(e).style.display=="none"){continue
2586 }var d="";
2587 for(var g=0;
2588 g<this.columns.length;
2589 g++){var b=this.columns[g];
2590 if(b.visible){var a=b.getFormattedValue(e,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport");
2591 if(b.format.exportPrefix){a=b.format.exportPrefix+a
2592 }if(a==""){a="&nbsp;"
2593 }d+="<td style='"+this.exportStyle(b.cell(e),f)+"'>"+a+"</td>"
2594 }}this.exportRows.push(d)
2595 }this.exportFinish()
2596 },hideRow:function(a){if(this.columns[0].cell(a).style.display=="none"){return
2597 }for(var b=0;
2598 b<this.columns.length;
2599 b++){this.columns[b].cell(a).style.display="none"
2600 }},showRow:function(a){if(this.columns[0].cell(a).style.display==""){return
2601 }for(var b=0;
2602 b<this.columns.length;
2603 b++){this.columns[b].cell(a).style.display=""
2604 }},searchRows:function(h,e,c){if(!e){return
2605 }var f=new RegExp(e);
2606 var d=this.columns[h].numRows();
2607 for(var g=0;
2608 g<d;
2609 g++){var b=this.cell(g,h).innerHTML;
2610 var a=(b.match(f)!=null);
2611 if(a!=c){this.hideRow(g)
2612 }}this.sizeDivs();
2613 this.handleScroll()
2614 },showAllRows:function(){for(var a=0;
2615 a<this.pageSize;
2616 a++){this.showRow(a)
2617 }this.sizeDivs()
2618 },openPopup:function(d,e){while(d&&!Rico.hasClass(d,"ricoLG_cell")){d=d.parentNode
2619 }if(!d){return false
2620 }var f=Rico.getParentByTagName(d,"td");
2621 var c=Math.floor(f.offsetLeft-this.scrollDiv.scrollLeft+f.offsetWidth/2);
2622 if(this.direction=="rtl"){if(c>this.width){c-=this.width
2623 }}else{if(c+this.width+this.options.margin>this.scrollDiv.clientWidth){c-=this.width
2624 }}e.divPopup.style.visibility="hidden";
2625 e.divPopup.style.display="block";
2626 var b=e.divPopup.offsetHeight;
2627 var a=Math.floor(d.offsetTop-this.scrollDiv.scrollTop+d.offsetHeight/2);
2628 if(a+b+e.options.margin>this.scrollDiv.clientHeight){a=Math.max(a-b,0)
2629 }e.openPopup(this.frzWi+c,this.hdrHt+a);
2630 e.divPopup.style.visibility="visible";
2631 return d
2632 }};
2633 if(Rico.Menu){Rico.extend(Rico.Menu.prototype,{showSimpleMenu:function(b,c){Rico.eventStop(b);
2634 this.hideFunc=c;
2635 if(this.div.childNodes.length==0){this.cancelmenu();
2636 return false
2637 }var a=Rico.eventElement(b);
2638 this.grid.openPopup(a,this);
2639 return a
2640 },showSimpleSubMenu:function(b,c){if(this.openSubMenu){this.hideSubMenu()
2641 }this.openSubMenu=c;
2642 this.openMenuAnchor=b;
2643 if(b.className=="ricoSubMenu"){b.className="ricoSubMenuOpen"
2644 }var e=parseInt(this.div.style.top,10);
2645 var d=parseInt(this.div.style.left,10);
2646 c.openPopup(d+b.offsetWidth,e+b.offsetTop);
2647 c.div.style.visibility="visible"
2648 }})
2649 }Rico.SimpleGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
2650 };
2651 Rico.SimpleGridColumn.prototype={initialize:function(a,d,c,b){Rico.extend(this,new Rico.TableColumnBase());
2652 this.baseInit(a,d,c,b)
2653 },setUnfiltered:function(){this.filterRows=null
2654 },filterChange:function(a){var b=Rico.eventElement(a);
2655 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
2656 }else{this.filterRows=this.filterHash[b.value]
2657 }this.liveGrid.applyFilters()
2658 },filterKeypress:function(f){var a=Rico.eventElement(f);
2659 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
2660 }if(this.lastKeyFilter==a.value){return
2661 }var b=a.value;
2662 Rico.log("filterKeypress: "+this.index+" "+b);
2663 this.lastKeyFilter=b;
2664 if(b){b=b.replace("\\","\\\\");
2665 b=b.replace("(","\\(").replace(")","\\)");
2666 b=b.replace(".","\\.");
2667 if(this.format.filterUI.indexOf("^")>0){b="^"+b
2668 }var d=new RegExp(b,"i");
2669 this.filterRows=[];
2670 var h=this.numRows();
2671 for(var c=0;
2672 c<h;
2673 c++){var g=Rico.getInnerText(this.cell(c));
2674 if(g.match(d)){this.filterRows.push(c)
2675 }}}else{this.setUnfiltered()
2676 }this.liveGrid.applyFilters()
2677 }};
2678 if(typeof Rico=="undefined"){throw ("LiveGrid requires the Rico JavaScript framework")
2679 }if(!Rico.Buffer){Rico.Buffer={}
2680 }Rico.Buffer.Base=function(b,a){this.initialize(b,a)
2681 };
2682 Rico.Buffer.Base.prototype={initialize:function(b,a){this.clear();
2683 this.updateInProgress=false;
2684 this.lastOffset=0;
2685 this.rcvdRowCount=false;
2686 this.foundRowCount=false;
2687 this.totalRows=0;
2688 this.rowcntContent="";
2689 this.rcvdOffset=-1;
2690 this.options={fixedHdrRows:0,canFilter:true,isEncoded:true,acceptStyle:false};
2691 Rico.extend(this.options,a||{});
2692 if(b){this.loadRowsFromTable(b,this.options.fixedHdrRows);
2693 b.parentNode.removeChild(b)
2694 }else{this.clear()
2695 }},registerGrid:function(a){this.liveGrid=a
2696 },setTotalRows:function(a){if(typeof(a)!="number"){a=this.size
2697 }if(this.totalRows==a){return
2698 }this.totalRows=a;
2699 if(!this.liveGrid){return
2700 }Rico.log("setTotalRows, newTotalRows="+a);
2701 switch(this.liveGrid.sizeTo){case"data":this.liveGrid.resizeWindow();
2702 break;
2703 case"datamax":this.liveGrid.setPageSize(a);
2704 break;
2705 default:this.liveGrid.updateHeightDiv();
2706 break
2707 }},loadRowsFromTable:function(h,g){var e=[];
2708 var a=h.getElementsByTagName("tr");
2709 for(var d=g||0;
2710 d<a.length;
2711 d++){var f=[];
2712 var c=a[d].getElementsByTagName("td");
2713 for(var b=0;
2714 b<c.length;
2715 b++){f[b]=c[b].innerHTML
2716 }e.push(f)
2717 }this.loadRows(e)
2718 },loadRowsFromArray:function(b){for(var c=0;
2719 c<b.length;
2720 c++){for(var a=0;
2721 a<b[c].length;
2722 a++){b[c][a]=b[c][a].toString()
2723 }}this.loadRows(b)
2724 },loadRows:function(a){this.baseRows=a;
2725 this.startPos=0;
2726 this.size=this.baseRows.length
2727 },dom2jstable:function(f){Rico.log("dom2jstable: encoded="+this.options.isEncoded);
2728 var e=[];
2729 var a=f.getElementsByTagName("tr");
2730 for(var d=0;
2731 d<a.length;
2732 d++){var g=[];
2733 var c=a[d].getElementsByTagName("td");
2734 for(var b=0;
2735 b<c.length;
2736 b++){g[b]=Rico.getContentAsString(c[b],this.options.isEncoded)
2737 }e.push(g)
2738 }return e
2739 },_blankRow:function(){var a=[];
2740 for(var b=0;
2741 b<this.liveGrid.columns.length;
2742 b++){a[b]=""
2743 }return a
2744 },deleteRows:function(b,a){this.baseRows.splice(b,typeof(a)=="number"?a:1);
2745 this.liveGrid.isPartialBlank=true;
2746 this.size=this.baseRows.length
2747 },insertRow:function(a){var b=this._blankRow();
2748 this.baseRows.splice(a,0,b);
2749 this.size=this.baseRows.length;
2750 this.liveGrid.isPartialBlank=true;
2751 if(this.startPos<0){this.startPos=0
2752 }return b
2753 },appendRows:function(b){var c=[];
2754 for(var a=0;
2755 a<b;
2756 a++){var d=this._blankRow();
2757 this.baseRows.push(d);
2758 c.push(d)
2759 }this.size=this.baseRows.length;
2760 this.liveGrid.isPartialBlank=true;
2761 if(this.startPos<0){this.startPos=0
2762 }return c
2763 },sortFunc:function(b){var a=this;
2764 switch(b){case"number":return function(d,c){return a._sortNumeric(d,c)
2765 };
2766 case"control":return function(d,c){return a._sortControl(d,c)
2767 };
2768 default:return function(d,c){return a._sortAlpha(d,c)
2769 }
2770 }},sortBuffer:function(b){if(!this.baseRows){this.delayedSortCol=b;
2771 return
2772 }this.liveGrid.showMsg(Rico.getPhraseById("sorting"));
2773 this.sortColumn=b;
2774 var a=this.liveGrid.columns[b];
2775 this.getValFunc=a._sortfunc;
2776 this.baseRows.sort(this.sortFunc(a.format.type));
2777 if(a.getSortDirection()=="DESC"){this.baseRows.reverse()
2778 }},_sortAlpha:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2779 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2780 if(e==f){return 0
2781 }if(e<f){return -1
2782 }return 1
2783 },_sortNumeric:function(d,c){var e=this.sortColumn<d.length?this.nan2zero(Rico.getInnerText(d[this.sortColumn])):0;
2784 var f=this.sortColumn<c.length?this.nan2zero(Rico.getInnerText(c[this.sortColumn])):0;
2785 return e-f
2786 },nan2zero:function(a){if(typeof(a)=="string"){a=parseFloat(a)
2787 }return isNaN(a)||typeof(a)=="undefined"?0:a
2788 },_sortControl:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2789 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2790 if(this.getValFunc){e=this.getValFunc(e);
2791 f=this.getValFunc(f)
2792 }if(e==f){return 0
2793 }if(e<f){return -1
2794 }return 1
2795 },clear:function(){this.baseRows=[];
2796 this.rows=[];
2797 this.startPos=-1;
2798 this.size=0;
2799 this.windowPos=0
2800 },isInRange:function(a){var b=Math.min(this.totalRows,a+this.liveGrid.pageSize);
2801 return(a>=this.startPos)&&(b<=this.endPos())
2802 },endPos:function(){return this.startPos+this.rows.length
2803 },fetch:function(a){Rico.log("fetch "+this.liveGrid.tableId+": offset="+a);
2804 this.applyFilters();
2805 this.setTotalRows();
2806 this.rcvdRowCount=true;
2807 this.foundRowCount=true;
2808 if(a<0){a=0
2809 }this.liveGrid.refreshContents(a);
2810 return
2811 },visibleRows:function(){return this.rows.slice(this.windowStart,this.windowEnd)
2812 },setWindow:function(b,a){this.windowStart=b-this.startPos;
2813 Rico.log("setWindow "+this.liveGrid.tableId+": "+b+", "+a+", newstart="+this.windowStart);
2814 this.windowEnd=Math.min(a,this.size);
2815 this.windowPos=b
2816 },isVisible:function(a){return a<this.rows.length&&a>=this.windowStart&&a<this.windowEnd
2817 },bufferRow:function(a){return this.windowStart+a
2818 },getWindowCell:function(c,b){var a=this.bufferRow(c);
2819 return this.isVisible(a)&&b<this.rows[a].length?this.rows[a][b]:null
2820 },getWindowStyle:function(c,b){var a=this.bufferRow(c);
2821 return this.attr&&this.isVisible(a)&&this.attr[a]&&b<this.attr[a].length?this.attr[a][b]:""
2822 },getWindowValue:function(b,a){return this.getWindowCell(b,a)
2823 },setWindowValue:function(d,b,c){var a=this.bufferRow(d);
2824 if(a>=this.windowEnd){return false
2825 }return this.setValue(a,b,c)
2826 },getCell:function(b,a){return b<this.size?this.rows[b][a]:null
2827 },getValue:function(b,a){return this.getCell(b,a)
2828 },setValue:function(d,b,c,a){if(d>=this.size){return false
2829 }if(!this.rows[d][b]){this.rows[d][b]={}
2830 }this.rows[d][b]=c;
2831 if(typeof a=="string"){this.rows[d][b]._style=a
2832 }this.rows[d][b].modified=true;
2833 return true
2834 },getRows:function(f,d){var e=f-this.startPos;
2835 var a=Math.min(e+d,this.size);
2836 var c=[];
2837 for(var b=e;
2838 b<a;
2839 b++){c.push(this.rows[b])
2840 }return c
2841 },applyFilters:function(){var g=[],k=[];
2842 var a,h,d,e,f,b;
2843 var j=this.liveGrid.columns;
2844 for(d=0,b=0;
2845 d<j.length;
2846 d++){h=j[d];
2847 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2848 }b++;
2849 if(h.filterOp=="LIKE"){k[d]=new RegExp(h.filterValues[0],"i")
2850 }}Rico.log("applyFilters: # of filters="+b);
2851 if(b==0){this.rows=this.baseRows
2852 }else{for(a=0;
2853 a<this.baseRows.length;
2854 a++){f=true;
2855 for(d=0;
2856 d<j.length&&f;
2857 d++){h=j[d];
2858 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2859 }switch(h.filterOp){case"LIKE":f=k[d].test(this.baseRows[a][d]);
2860 break;
2861 case"EQ":f=this.baseRows[a][d]==h.filterValues[0];
2862 break;
2863 case"NE":for(e=0;
2864 e<h.filterValues.length&&f;
2865 e++){f=this.baseRows[a][d]!=h.filterValues[e]
2866 }break;
2867 case"LE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])<=this.nan2zero(h.filterValues[0])
2868 }else{f=this.baseRows[a][d]<=h.filterValues[0]
2869 }break;
2870 case"GE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])>=this.nan2zero(h.filterValues[0])
2871 }else{f=this.baseRows[a][d]>=h.filterValues[0]
2872 }break;
2873 case"NULL":f=this.baseRows[a][d]=="";
2874 break;
2875 case"NOTNULL":f=this.baseRows[a][d]!="";
2876 break
2877 }}if(f){g.push(this.baseRows[a])
2878 }}this.rows=g
2879 }this.rowcntContent=this.size=this.rows.length
2880 },printAll:function(){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2881 Rico.runLater(10,this,"_printAll")
2882 },_printAll:function(){this.liveGrid.exportStart();
2883 this.exportBuffer(this.getRows(0,this.totalRows));
2884 this.liveGrid.exportFinish()
2885 },printVisible:function(){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2886 Rico.runLater(10,this,"_printVisible")
2887 },_printVisible:function(){this.liveGrid.exportStart();
2888 this.exportBuffer(this.visibleRows());
2889 this.liveGrid.exportFinish()
2890 },exportBuffer:function(l,f){var a,g,k,b,j;
2891 Rico.log("exportBuffer: "+l.length+" rows");
2892 var e=this.liveGrid.getExportStyles(this.liveGrid.tbody[0]);
2893 var i=[];
2894 var d=f||0;
2895 var h=this.liveGrid.columns;
2896 for(g=0;
2897 g<h.length;
2898 g++){if(h[g].visible){i[g]=this.liveGrid.exportStyle(h[g].cell(0),e)
2899 }}for(a=0;
2900 a<l.length;
2901 a++){j="";
2902 for(g=0;
2903 g<h.length;
2904 g++){if(!h[g].visible){continue
2905 }b=h[g];
2906 b.expStyle=i[g];
2907 k=b._export(l[a][g],l[a]);
2908 if(k==""){k="&nbsp;"
2909 }j+="<td style='"+b.expStyle+"'>"+k+"</td>"
2910 }this.liveGrid.exportRows.push(j);
2911 d++;
2912 if(d%10==0){window.status=Rico.getPhraseById("exportStatus",d)
2913 }}}};
2914 Rico.LiveGrid=function(c,a,b){this.initialize(c,a,b)
2915 };
2916 Rico.LiveGrid.prototype={initialize:function(e,b,d){Rico.extend(this,Rico.GridCommon);
2917 Rico.extend(this,Rico.LiveGridMethods);
2918 this.baseInit();
2919 this.tableId=e;
2920 this.buffer=b;
2921 this.actionId="_action_"+e;
2922 Rico.setDebugArea(e+"_debugmsgs");
2923 Rico.extend(this.options,{visibleRows:-3,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:Rico.theme.gridHighlightClass||"ricoLG_selection",maxPrint:5000,headingSort:"link",hdrIconsFirst:true});
2924 var c=this;
2925 this.options.sortHandler=function(){c.sortHandler()
2926 };
2927 this.options.filterHandler=function(){c.filterHandler()
2928 };
2929 this.options.onRefreshComplete=function(f,g){c.bookmarkHandler(f,g)
2930 };
2931 this.options.rowOverHandler=Rico.eventHandle(this,"rowMouseOver");
2932 this.options.mouseDownHandler=Rico.eventHandle(this,"selectMouseDown");
2933 this.options.mouseOverHandler=Rico.eventHandle(this,"selectMouseOver");
2934 this.options.mouseUpHandler=Rico.eventHandle(this,"selectMouseUp");
2935 Rico.extend(this.options,d||{});
2936 switch(typeof this.options.visibleRows){case"string":this.sizeTo=this.options.visibleRows;
2937 switch(this.options.visibleRows){case"data":this.options.visibleRows=-2;
2938 break;
2939 case"body":this.options.visibleRows=-3;
2940 break;
2941 case"parent":this.options.visibleRows=-4;
2942 break;
2943 case"datamax":this.options.visibleRows=-5;
2944 break;
2945 default:this.options.visibleRows=-1;
2946 break
2947 }break;
2948 case"number":switch(this.options.visibleRows){case -1:this.sizeTo="window";
2949 break;
2950 case -2:this.sizeTo="data";
2951 break;
2952 case -3:this.sizeTo="body";
2953 break;
2954 case -4:this.sizeTo="parent";
2955 break;
2956 case -5:this.sizeTo="datamax";
2957 break;
2958 default:this.sizeTo="fixed";
2959 break
2960 }break;
2961 default:this.sizeTo="body";
2962 this.options.visibleRows=-3;
2963 break
2964 }this.highlightEnabled=this.options.highlightSection>0;
2965 this.pageSize=0;
2966 this.createTables();
2967 if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2968 return
2969 }this.createColumnArray("LiveGridColumn");
2970 if(this.options.headingSort=="hover"){this.createHoverSet()
2971 }this.bookmark=document.getElementById(this.tableId+"_bookmark");
2972 this.sizeDivs();
2973 var a=-1;
2974 if(this.buffer.options.canFilter&&this.options.AutoFilter){a=this.addHeadingRow("ricoLG_FilterRow")
2975 }this.createDataCells(this.options.visibleRows);
2976 if(this.pageSize==0){return
2977 }this.buffer.registerGrid(this);
2978 if(this.buffer.setBufferSize){this.buffer.setBufferSize(this.pageSize)
2979 }this.scrollTimeout=null;
2980 this.lastScrollPos=0;
2981 this.attachMenuEvents();
2982 this.setSortUI(this.options.sortCol,this.options.sortDir);
2983 this.setImages();
2984 if(this.listInvisible().length==this.columns.length){this.columns[0].showColumn()
2985 }this.sizeDivs();
2986 this.scrollDiv.style.display="";
2987 if(this.buffer.totalRows>0){this.updateHeightDiv()
2988 }if(this.options.prefetchBuffer){if(this.bookmark){this.bookmark.innerHTML=Rico.getPhraseById("bookmarkLoading")
2989 }if(this.options.canFilterDefault&&this.options.getQueryParms){this.checkForFilterParms()
2990 }this.scrollToRow(this.options.offset);
2991 this.buffer.fetch(this.options.offset)
2992 }if(a>=0){this.createFilters(a)
2993 }this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2994 this.wheelEventFunc=Rico.eventHandle(this,"handleWheel");
2995 this.wheelEvent=(Rico.isIE||Rico.isOpera||Rico.isWebKit)?"mousewheel":"DOMMouseScroll";
2996 if(this.options.offset&&this.options.offset<this.buffer.totalRows){Rico.runLater(50,this,"scrollToRow",this.options.offset)
2997 }this.pluginScroll();
2998 this.setHorizontalScroll();
2999 Rico.log("setHorizontalScroll done");
3000 if(this.options.windowResize){Rico.runLater(100,this,"pluginWindowResize")
3001 }Rico.log("initialize complete for "+this.tableId);
3002 if(this.direction=="rtl"&&(!Rico.isWebKit||this.scrollDiv.clientLeft>0)){this.scrollTab.style.right="0px"
3003 }else{this.scrollTab.style.left="0px";
3004 Rico.setStyle(this.tabs[1],{"float":"left"})
3005 }}};
3006 Rico.LiveGridMethods={createHoverSet:function(){var a=[];
3007 for(var b=0;
3008 b<this.headerColCnt;
3009 b++){if(this.columns[b].sortable){a.push(this.columns[b].hdrCellDiv)
3010 }}this.hoverSet=new Rico.HoverSet(a)
3011 },checkForFilterParms:function(){var b=window.location.search;
3012 if(b.charAt(0)=="?"){b=b.substring(1)
3013 }var c=b.split("&");
3014 for(var a=0;
3015 a<c.length;
3016 a++){if(c[a].match(/^f\[\d+\]/)){this.buffer.options.requestParameters.push(c[a])
3017 }}},drillDown:function(g,f,h){var b=Rico.eventElement(g||window.event);
3018 b=Rico.getParentByTagName(b,"div","ricoLG_cell");
3019 if(!b){return -1
3020 }var a=this.winCellIndex(b);
3021 if(a.row>=this.buffer.totalRows){return -1
3022 }this.unhighlight();
3023 this.menuIdx=a;
3024 this.highlight(a);
3025 var c=this.buffer.getWindowCell(a.row,f);
3026 for(var d=3;
3027 d<arguments.length;
3028 d++){arguments[d].setDetailFilter(h,c)
3029 }return a.row
3030 },setDetailFilter:function(a,d){var b=this.columns[a];
3031 b.format.ColData=d;
3032 b.setSystemFilter("EQ",d)
3033 },createTables:function(){var f,g,b;
3034 var e=document.getElementById(this.tableId)||document.getElementById(this.tableId+"_outerDiv");
3035 if(!e){return false
3036 }if(e.tagName.toLowerCase()=="table"){var a=e.getElementsByTagName("thead");
3037 if(a.length==1){Rico.log("createTables: using thead section, id="+this.tableId);
3038 if(this.options.ColGroupsOnTabHdr&&this.options.ColGroups){var d=a[0].insertRow(0);
3039 this.insertPanelNames(d,0,this.options.frozenColumns,"ricoFrozen");
3040 this.insertPanelNames(d,this.options.frozenColumns,this.options.columnSpecs.length)
3041 }g=a[0].rows
3042 }else{Rico.log("createTables: using tbody section, id="+this.tableId);
3043 g=new Array(e.rows[0])
3044 }f=e
3045 }else{if(this.options.columnSpecs.length>0){if(!e.id.match(/_outerDiv$/)){f=e
3046 }Rico.log("createTables: inserting at "+e.tagName+", id="+this.tableId)
3047 }else{alert("ERROR!\n\nUnable to initialize '"+this.tableId+"'\n\nLiveGrid terminated");
3048 return false
3049 }}this.createDivs();
3050 this.scrollContainer=this.createDiv("scrollContainer",this.structTabLR);
3051 this.scrollContainer.appendChild(this.scrollDiv);
3052 this.scrollTab=this.createDiv("scrollTab",this.scrollContainer);
3053 this.shadowDiv=this.createDiv("shadow",this.scrollDiv);
3054 this.shadowDiv.style.direction="ltr";
3055 this.scrollDiv.style.display="none";
3056 this.scrollDiv.scrollTop=0;
3057 if(this.options.highlightMethod!="class"){this.highlightDiv=[];
3058 switch(this.options.highlightElem){case"menuRow":case"cursorRow":this.highlightDiv[0]=this.createDiv("highlight",this.outerDiv);
3059 this.highlightDiv[0].style.display="none";
3060 break;
3061 case"menuCell":case"cursorCell":for(b=0;
3062 b<2;
3063 b++){this.highlightDiv[b]=this.createDiv("highlight",b==0?this.frozenTabs:this.scrollTab);
3064 this.highlightDiv[b].style.display="none";
3065 this.highlightDiv[b].id+=b
3066 }break;
3067 case"selection":var h=this.options.highlightSection==1?this.frozenTabs:this.scrollTab;
3068 for(b=0;
3069 b<4;
3070 b++){this.highlightDiv[b]=this.createDiv("highlight",h);
3071 this.highlightDiv[b].style.display="none";
3072 this.highlightDiv[b].style.overflow="hidden";
3073 this.highlightDiv[b].id+=b;
3074 this.highlightDiv[b].style[b%2==0?"height":"width"]="0px"
3075 }break
3076 }}for(b=0;
3077 b<3;
3078 b++){this.tabs[b]=document.createElement("table");
3079 this.tabs[b].className=(b<2)?"ricoLG_table":"ricoLG_scrollTab";
3080 this.tabs[b].border=0;
3081 this.tabs[b].cellPadding=0;
3082 this.tabs[b].cellSpacing=0;
3083 this.tabs[b].id=this.tableId+"_tab"+b
3084 }for(b=0;
3085 b<2;
3086 b++){this.thead[b]=this.tabs[b].createTHead();
3087 this.thead[b].className="ricoLG_top";
3088 if(Rico.theme.gridheader){Rico.addClass(this.thead[b],Rico.theme.gridheader)
3089 }}for(b=0;
3090 b<2;
3091 b++){this.tbody[b]=Rico.getTBody(this.tabs[b==0?0:2]);
3092 this.tbody[b].className="ricoLG_bottom";
3093 if(Rico.theme.gridcontent){Rico.addClass(this.tbody[b],Rico.theme.gridcontent)
3094 }this.tbody[b].insertRow(-1)
3095 }this.frozenTabs.appendChild(this.tabs[0]);
3096 this.innerDiv.appendChild(this.tabs[1]);
3097 this.scrollTab.appendChild(this.tabs[2]);
3098 if(f){f.parentNode.insertBefore(this.outerDiv,f)
3099 }if(g){this.headerColCnt=this.getColumnInfo(g);
3100 this.loadHdrSrc(g)
3101 }else{this.createHdr(0,0,this.options.frozenColumns);
3102 this.createHdr(1,this.options.frozenColumns,this.options.columnSpecs.length);
3103 if(this.options.ColGroupsOnTabHdr&&this.options.ColGroups){this.insertPanelNames(this.thead[0].insertRow(0),0,this.options.frozenColumns);
3104 this.insertPanelNames(this.thead[1].insertRow(0),this.options.frozenColumns,this.options.columnSpecs.length)
3105 }for(b=0;
3106 b<2;
3107 b++){this.headerColCnt=this.getColumnInfo(this.thead[b].rows)
3108 }}for(var j=0;
3109 j<this.headerColCnt;
3110 j++){this.tbody[j<this.options.frozenColumns?0:1].rows[0].insertCell(-1)
3111 }if(f){e.parentNode.removeChild(e)
3112 }Rico.log("createTables end");
3113 return true
3114 },createDataCells:function(d){if(d<0){for(var a=0;
3115 a<this.options.minPageRows;
3116 a++){this.appendBlankRow()
3117 }this.sizeDivs();
3118 this.autoAppendRows(this.remainingHt())
3119 }else{for(var c=0;
3120 c<d;
3121 c++){this.appendBlankRow()
3122 }}var b=this.options.highlightSection;
3123 if(b&1){this.attachHighlightEvents(this.tbody[0])
3124 }if(b&2){this.attachHighlightEvents(this.tbody[1])
3125 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
3126 },createFilters:function(b){for(var h=0;
3127 h<this.headerColCnt;
3128 h++){var e=this.columns[h];
3129 var f=e.format;
3130 if(typeof f.filterUI!="string"){continue
3131 }var l=this.hdrCells[b][h].cell;
3132 var j,d=this.filterId(h);
3133 var i=l.getElementsByTagName("div");
3134 var g=Rico.getStyle(this.cell(0,h),"textAlign");
3135 i[1].style.textAlign=g;
3136 switch(f.filterUI.charAt(0)){case"t":j=Rico.createFormField(i[1],"input",Rico.inputtypes.search?"search":"text",d,d);
3137 var n=f.filterUI.match(/\d+/);
3138 j.maxLength=f.Length||50;
3139 j.size=n?parseInt(n,10):10;
3140 if(j.type!="search"){i[1].appendChild(Rico.clearButton(Rico.eventHandle(e,"filterClear")))
3141 }if(e.filterType==Rico.ColumnConst.USERFILTER&&e.filterOp=="LIKE"){var k=e.filterValues[0];
3142 if(k.charAt(0)=="*"){k=k.substr(1)
3143 }if(k.slice(-1)=="*"){k=k.slice(0,-1)
3144 }j.value=k;
3145 e.lastKeyFilter=k
3146 }Rico.eventBind(j,"keyup",Rico.eventHandle(e,"filterKeypress"),false);
3147 e.filterField=j;
3148 break;
3149 case"m":case"s":j=Rico.createFormField(i[1],"select",null,d);
3150 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
3151 e.filterField=j;
3152 var m={};
3153 Rico.extend(m,this.buffer.ajaxOptions);
3154 var a=typeof(f.filterCol)=="number"?f.filterCol:h;
3155 m.parameters={id:this.tableId,distinct:a};
3156 m.parameters[this.actionId]="query";
3157 m.onComplete=this.filterValuesUpdateFunc(h);
3158 new Rico.ajaxRequest(this.buffer.dataSource,m);
3159 break;
3160 case"c":if(typeof e._createFilters=="function"){e._createFilters(i[1],d)
3161 }break
3162 }}this.initFilterImage(b)
3163 },filterValuesUpdateFunc:function(b){var a=this;
3164 return function(c){a.filterValuesUpdate(b,c)
3165 }
3166 },filterValuesUpdate:function(a,g){var f=g.responseXML.getElementsByTagName("ajax-response");
3167 Rico.log("filterValuesUpdate: "+g.status);
3168 if(f==null||f.length!=1){return false
3169 }f=f[0];
3170 var n=f.getElementsByTagName("error");
3171 if(n.length>0){Rico.log("Data provider returned an error:\n"+Rico.getContentAsString(n[0],this.buffer.isEncoded));
3172 alert(Rico.getPhraseById("requestError",Rico.getContentAsString(n[0],this.buffer.isEncoded)));
3173 return false
3174 }f=f.getElementsByTagName("response")[0];
3175 var l=f.getElementsByTagName("rows")[0];
3176 var d=this.columns[parseInt(a,10)];
3177 var r=this.buffer.dom2jstable(l);
3178 var m,b,q;
3179 if(d.filterType==Rico.ColumnConst.USERFILTER&&d.filterOp=="EQ"){q=d.filterValues[0]
3180 }Rico.log("filterValuesUpdate: col="+a+" rows="+r.length);
3181 switch(d.format.filterUI.charAt(0)){case"m":d.mFilter=document.body.appendChild(document.createElement("div"));
3182 d.mFilter.className="ricoLG_mFilter";
3183 Rico.hide(d.mFilter);
3184 var e=d.mFilter.appendChild(document.createElement("div"));
3185 e.className="ricoLG_mFilter_content";
3186 var o=d.mFilter.appendChild(document.createElement("div"));
3187 o.className="ricoLG_mFilter_button";
3188 d.mFilterButton=o.appendChild(document.createElement("button"));
3189 d.mFilterButton.innerHTML=Rico.getPhraseById("ok");
3190 var j=Rico.isWebKit?"mousedown":"click";
3191 Rico.eventBind(d.filterField,j,Rico.eventHandle(d,"mFilterSelectClick"));
3192 Rico.eventBind(d.mFilterButton,"click",Rico.eventHandle(d,"mFilterFinish"));
3193 tab=e.appendChild(document.createElement("table"));
3194 tab.border=0;
3195 tab.cellPadding=2;
3196 tab.cellSpacing=0;
3197 var p=this.filterId(a)+"_";
3198 this.createMFilterItem(tab,this.options.FilterAllToken,Rico.getPhraseById("filterAll"),p+"all",Rico.eventHandle(d,"mFilterAllClick"));
3199 var k=Rico.eventHandle(d,"mFilterOtherClick");
3200 for(var h=0;
3201 h<r.length;
3202 h++){if(r[h].length>0){m=r[h][0];
3203 this.createMFilterItem(tab,m,m||Rico.getPhraseById("filterBlank"),p+h,k)
3204 }}d.mFilterInputs=e.getElementsByTagName("input");
3205 d.mFilterLabels=e.getElementsByTagName("label");
3206 d.mFilterFocus=d.mFilterInputs.length?d.mFilterInputs[0]:d.mFilterButton;
3207 break;
3208 case"s":for(var h=0;
3209 h<r.length;
3210 h++){if(r[h].length>0){m=r[h][0];
3211 b=Rico.addSelectOption(d.filterField,m,m||Rico.getPhraseById("filterBlank"));
3212 if(d.filterType==Rico.ColumnConst.USERFILTER&&m==q){b.selected=true
3213 }}}Rico.eventBind(d.filterField,"change",Rico.eventHandle(d,"filterChange"));
3214 break
3215 }return true
3216 },createMFilterItem:function(j,b,i,a,e){var f=j.insertRow(-1);
3217 f.vAlign="top";
3218 if(f.rowIndex%2==1){f.className="ricoLG_mFilter_oddrow"
3219 }var d=f.insertCell(-1);
3220 var c=f.insertCell(-1);
3221 var h=Rico.createFormField(d,"input","checkbox",a);
3222 h.value=b;
3223 h.checked=true;
3224 var g=c.appendChild(document.createElement("label"));
3225 g.htmlFor=a;
3226 g.innerHTML=i;
3227 Rico.eventBind(h,"click",e)
3228 },unplugHighlightEvents:function(){var a=this.options.highlightSection;
3229 if(a&1){this.detachHighlightEvents(this.tbody[0])
3230 }if(a&2){this.detachHighlightEvents(this.tbody[1])
3231 }},insertPanelNames:function(a,b,d,f){Rico.log("insertPanelNames: start="+b+" limit="+d);
3232 a.className="ricoLG_hdg";
3233 var i=-1,j,e=null,g=0;
3234 for(var h=b;
3235 h<d;
3236 h++){if(i==this.options.columnSpecs[h].ColGroupIdx){j++
3237 }else{if(e){e.colSpan=j
3238 }e=a.insertCell(-1);
3239 if(f){e.className=f
3240 }j=1;
3241 i=this.options.columnSpecs[h].ColGroupIdx;
3242 e.innerHTML=this.options.ColGroups[i]
3243 }}if(e){e.colSpan=j
3244 }},createHdr:function(d,g,b){Rico.log("createHdr: i="+d+" start="+g+" limit="+b);
3245 var a=this.thead[d].insertRow(-1);
3246 a.id=this.tableId+"_tab"+d+"h_main";
3247 a.className="ricoLG_hdg";
3248 for(var f=g;
3249 f<b;
3250 f++){var e=a.insertCell(-1);
3251 e.innerHTML=this.options.columnSpecs[f].Hdg
3252 }},loadHdrSrc:function(g){var b,d,j,e,f,a;
3253 Rico.log("loadHdrSrc start");
3254 for(b=0;
3255 b<2;
3256 b++){for(e=0;
3257 e<g.length;
3258 e++){f=this.thead[b].insertRow(-1);
3259 f.className="ricoLG_hdg "+this.tableId+"_hdg"+e
3260 }}if(g.length==1){a=g[0].cells;
3261 for(j=0;
3262 a.length>0;
3263 j++){this.thead[j<this.options.frozenColumns?0:1].rows[0].appendChild(a[0])
3264 }}else{for(e=0;
3265 e<g.length;
3266 e++){a=g[e].cells;
3267 for(j=0,d=0;
3268 a.length>0;
3269 j++){if(Rico.hasClass(a[0],"ricoFrozen")){if(e==this.headerRowIdx){this.options.frozenColumns=j+1
3270 }}else{d=1
3271 }this.thead[d].rows[e].appendChild(a[0])
3272 }}}Rico.log("loadHdrSrc end")
3273 },sizeDivs:function(){Rico.log("sizeDivs: "+this.tableId);
3274 this.unhighlight();
3275 this.baseSizeDivs();
3276 var d=this.firstVisible();
3277 if(this.pageSize==0||d<0){return
3278 }var c=this.columns[d].dataColDiv.offsetHeight;
3279 this.rowHeight=Math.round(c/this.pageSize);
3280 var b=this.dataHt;
3281 if(this.scrTabWi0==this.scrTabWi){this.innerDiv.style.height=(this.hdrHt+1)+"px";
3282 this.scrollDiv.style.overflowX="hidden"
3283 }else{this.scrollDiv.style.overflowX="scroll";
3284 b+=this.options.scrollBarWidth
3285 }this.scrollDiv.style.height=b+"px";
3286 this.innerDiv.style.width=(this.scrWi)+"px";
3287 this.scrollTab.style.width=(this.scrWi-this.options.scrollBarWidth)+"px";
3288 this.resizeDiv.style.height=(this.hdrHt+this.dataHt+1)+"px";
3289 Rico.log("sizeDivs scrHt="+b+" innerHt="+this.innerDiv.style.height+" rowHt="+this.rowHeight+" pageSize="+this.pageSize);
3290 var a=(this.scrWi-this.scrTabWi<this.options.scrollBarWidth)?2:0;
3291 this.shadowDiv.style.width=(this.scrTabWi+a)+"px";
3292 this.outerDiv.style.height=(this.hdrHt+b)+"px";
3293 this.setHorizontalScroll()
3294 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
3295 this.tabs[1].style.marginLeft=a;
3296 this.tabs[2].style.marginLeft=a
3297 },remainingHt:function(){var f=this.outerDiv.offsetHeight;
3298 var g=Rico.windowHeight();
3299 var e=Rico.isIE?15:10;
3300 if(!Rico.isIE&&window.frameElement&&window.frameElement.scrolling=="yes"&&this.sizeTo!="parent"){e+=this.options.scrollBarWidth
3301 }switch(this.sizeTo){case"window":var d=Rico.cumulativeOffset(this.outerDiv).top;
3302 Rico.log("remainingHt/window, winHt="+g+" tabHt="+f+" gridY="+d);
3303 return g-d-f-e;
3304 case"parent":var h=this.offsetFromParent(this.outerDiv);
3305 if(Rico.isIE){Rico.hide(this.outerDiv)
3306 }var b=this.outerDiv.parentNode.clientHeight;
3307 if(Rico.isIE){Rico.show(this.outerDiv)
3308 }Rico.log("remainingHt/parent, parentHt="+b+" offset="+h+" tabHt="+f);
3309 return b-f-h-e;
3310 case"data":case"body":var a=Rico.isIE?document.body.scrollHeight:document.body.offsetHeight;
3311 var c=g-a-e;
3312 if(!Rico.isWebKit){c-=this.options.scrollBarWidth
3313 }Rico.log("remainingHt, winHt="+g+" pageHt="+a+" remHt="+c);
3314 return c;
3315 default:Rico.log("remainingHt, winHt="+g+" tabHt="+f);
3316 if(this.sizeTo.slice(-1)=="%"){g*=parseFloat(this.sizeTo)/100
3317 }else{if(this.sizeTo.slice(-2)=="px"){g=parseInt(this.sizeTo,10)
3318 }}return g-f-e
3319 }},offsetFromParent:function(b){var a=0;
3320 var c=b.parentNode;
3321 do{a+=b.offsetTop||0;
3322 b=b.offsetParent;
3323 if(!b||b==null){break
3324 }var d=Rico.getStyle(b,"position");
3325 if(b.tagName=="BODY"||b.tagName=="HTML"||d=="absolute"){return a-c.offsetTop
3326 }}while(b!=c);
3327 return a
3328 },adjustPageSize:function(){var a=this.remainingHt();
3329 Rico.log("adjustPageSize remHt="+a+" lastRow="+this.lastRowPos);
3330 if(a>this.rowHeight){this.autoAppendRows(a)
3331 }else{if(a<0||this.sizeTo=="data"){this.autoRemoveRows(-a)
3332 }}},setPageSize:function(b){b=Math.min(b,this.options.maxPageRows);
3333 b=Math.max(b,this.options.minPageRows);
3334 this.sizeTo="fixed";
3335 var a=this.pageSize;
3336 while(this.pageSize>b){this.removeRow()
3337 }while(this.pageSize<b){this.appendBlankRow()
3338 }this.finishResize(a)
3339 },pluginWindowResize:function(){Rico.log("pluginWindowResize");
3340 this.resizeWindowHandler=Rico.eventHandle(this,"resizeWindow");
3341 Rico.eventBind(window,"resize",this.resizeWindowHandler,false)
3342 },unplugWindowResize:function(){if(!this.resizeWindowHandler){return
3343 }Rico.eventUnbind(window,"resize",this.resizeWindowHandler,false);
3344 this.resizeWindowHandler=null
3345 },resizeWindow:function(){Rico.log("resizeWindow "+this.tableId+" lastRow="+this.lastRowPos);
3346 if(this.resizeState=="finish"){Rico.log("resizeWindow postponed");
3347 this.resizeState="resize";
3348 return
3349 }if(!this.sizeTo||this.sizeTo=="fixed"){this.sizeDivs();
3350 return
3351 }if(this.sizeTo=="parent"&&Rico.getStyle(this.outerDiv.parentNode,"display")=="none"){return
3352 }var a=this.pageSize;
3353 this.adjustPageSize();
3354 this.finishResize(a)
3355 },finishResize:function(b){if(this.pageSize>b&&this.buffer.totalRows>0){this.isPartialBlank=true;
3356 var a=this.adjustRow(this.lastRowPos);
3357 this.buffer.fetch(a)
3358 }else{if(this.pageSize<b){if(this.options.onRefreshComplete){this.options.onRefreshComplete(this.contentStartPos,this.contentStartPos+this.pageSize-1)
3359 }}}this.resizeState="finish";
3360 Rico.runLater(20,this,"finishResize2");
3361 Rico.log("Resize "+this.tableId+" complete. old size="+b+" new size="+this.pageSize)
3362 },finishResize2:function(){this.sizeDivs();
3363 this.updateHeightDiv();
3364 if(this.resizeState=="resize"){this.resizeWindow()
3365 }else{this.resizeState=""
3366 }},topOfLastPage:function(){return Math.max(this.buffer.totalRows-this.pageSize,0)
3367 },updateHeightDiv:function(){var b=this.topOfLastPage();
3368 var a=b?this.scrollDiv.clientHeight+Math.floor(this.rowHeight*(b+0.4)):1;
3369 Rico.log("updateHeightDiv, ht="+a+" scrollDiv.clientHeight="+this.scrollDiv.clientHeight+" rowsNotDisplayed="+b);
3370 this.shadowDiv.style.height=a+"px"
3371 },autoRemoveRows:function(a){if(!this.rowHeight){return
3372 }var c=Math.ceil(a/this.rowHeight);
3373 if(this.sizeTo=="data"){c=Math.max(c,this.pageSize-this.buffer.totalRows)
3374 }Rico.log("autoRemoveRows overage="+a+" removeCnt="+c);
3375 for(var b=0;
3376 b<c;
3377 b++){this.removeRow()
3378 }},removeRow:function(){if(this.pageSize<=this.options.minPageRows){return
3379 }this.pageSize--;
3380 for(var b=0;
3381 b<this.headerColCnt;
3382 b++){var a=this.columns[b].cell(this.pageSize);
3383 this.columns[b].dataColDiv.removeChild(a)
3384 }},autoAppendRows:function(a){if(!this.rowHeight){return
3385 }var c=Math.floor(a/this.rowHeight);
3386 Rico.log("autoAppendRows overage="+a+" cnt="+c+" rowHt="+this.rowHeight);
3387 for(var b=0;
3388 b<c;
3389 b++){if(this.sizeTo=="data"&&this.pageSize>=this.buffer.totalRows){break
3390 }this.appendBlankRow()
3391 }},appendBlankRow:function(){if(this.pageSize>=this.options.maxPageRows){return
3392 }Rico.log("appendBlankRow #"+this.pageSize);
3393 var a=this.defaultRowClass(this.pageSize);
3394 for(var d=0;
3395 d<this.headerColCnt;
3396 d++){var b=document.createElement("div");
3397 b.className="ricoLG_cell "+a;
3398 b.id=this.tableId+"_"+this.pageSize+"_"+d;
3399 this.columns[d].dataColDiv.appendChild(b);
3400 if(this.columns[d]._create){this.columns[d]._create(b,this.pageSize)
3401 }else{b.innerHTML="&nbsp;"
3402 }if(this.columns[d].format.canDrag&&Rico.registerDraggable){Rico.registerDraggable(new Rico.LiveGridDraggable(this,this.pageSize,d),this.options.dndMgrIdx)
3403 }}this.pageSize++
3404 },defaultRowClass:function(b){var a;
3405 if(b%2==0){a="ricoLG_evenRow"
3406 }else{a="ricoLG_oddRow"
3407 }return a
3408 },handleMenuClick:function(f){if(!this.menu){return
3409 }this.cancelMenu();
3410 this.unhighlight();
3411 var b;
3412 var a=Rico.eventElement(f);
3413 if(a.className=="ricoLG_highlightDiv"){b=this.highlightIdx
3414 }else{a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3415 if(!a){return
3416 }b=this.winCellIndex(a);
3417 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3418 }}this.highlight(b);
3419 this.highlightEnabled=false;
3420 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
3421 }this.menuIdx=b;
3422 if(!this.menu.div){this.menu.createDiv()
3423 }this.menu.liveGrid=this;
3424 if(this.menu.buildGridMenu){var d=this.menu.buildGridMenu(b.row,b.column,b.tabIdx);
3425 if(!d){return
3426 }}if(this.options.highlightElem=="selection"&&!this.isSelected(b.cell)){this.selectCell(b.cell)
3427 }var c=this;
3428 this.menu.showmenu(f,function(){c.closeMenu()
3429 });
3430 return false
3431 },closeMenu:function(){if(!this.menuIdx){return
3432 }if(this.hideScroll){this.scrollDiv.style.overflow=""
3433 }this.highlightEnabled=true;
3434 this.menuIdx=null
3435 },winCellIndex:function(b){var d=b.id.lastIndexOf("_",b.id.length);
3436 var a=b.id.lastIndexOf("_",d-1)+1;
3437 var f=parseInt(b.id.substr(d+1));
3438 var e=parseInt(b.id.substr(a,d));
3439 return{row:e,column:f,tabIdx:this.columns[f].tabIdx,cell:b}
3440 },datasetIndex:function(b){var a=this.winCellIndex(b);
3441 a.row+=this.buffer.windowPos;
3442 a.onBlankRow=(a.row>=this.buffer.endPos());
3443 return a
3444 },attachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventBind(a,"mousedown",this.options.mouseDownHandler,false);
3445 a.ondrag=function(){return false
3446 };
3447 a.onselectstart=function(){return false
3448 };
3449 break;
3450 case"cursorRow":case"cursorCell":Rico.eventBind(a,"mouseover",this.options.rowOverHandler,false);
3451 break
3452 }},detachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventUnbind(a,"mousedown",this.options.mouseDownHandler,false);
3453 a.ondrag=null;
3454 a.onselectstart=null;
3455 break;
3456 case"cursorRow":case"cursorCell":Rico.eventUnbind(a,"mouseover",this.options.rowOverHandler,false);
3457 break
3458 }},getVisibleSelection:function(){var d=[];
3459 if(this.SelectIdxStart&&this.SelectIdxEnd){var b=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowStart);
3460 var a=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowEnd-1);
3461 var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3462 var f=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3463 for(var h=b;
3464 h<=a;
3465 h++){for(var j=g;
3466 j<=f;
3467 j++){d.push({row:h-this.buffer.windowStart,column:j})
3468 }}}if(this.SelectCtrl){for(var e=0;
3469 e<this.SelectCtrl.length;
3470 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})
3471 }}}return d
3472 },updateSelectOutline:function(){if(!this.SelectIdxStart||!this.SelectIdxEnd){return
3473 }var d=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3474 var c=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3475 if(d>c){this.HideSelection();
3476 return
3477 }var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3478 var e=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3479 var h=this.columns[g].cell(d-this.buffer.windowStart).offsetTop;
3480 var j=this.columns[g].cell(c-this.buffer.windowStart);
3481 var b=j.offsetTop+j.offsetHeight;
3482 var l=this.columns[g].dataCell.offsetLeft;
3483 var k=this.columns[e].dataCell.offsetLeft;
3484 var a=k+this.columns[e].dataCell.offsetWidth;
3485 this.highlightDiv[0].style.top=this.highlightDiv[3].style.top=this.highlightDiv[1].style.top=(this.hdrHt+h-1)+"px";
3486 this.highlightDiv[2].style.top=(this.hdrHt+b-1)+"px";
3487 this.highlightDiv[3].style.left=(l-2)+"px";
3488 this.highlightDiv[0].style.left=this.highlightDiv[2].style.left=(l-1)+"px";
3489 this.highlightDiv[1].style.left=(a-1)+"px";
3490 this.highlightDiv[0].style.width=this.highlightDiv[2].style.width=(a-l-1)+"px";
3491 this.highlightDiv[1].style.height=this.highlightDiv[3].style.height=(b-h)+"px";
3492 for(var f=0;
3493 f<4;
3494 f++){this.highlightDiv[f].style.display=""
3495 }},HideSelection:function(){var b;
3496 if(this.options.highlightMethod!="class"){for(b=0;
3497 b<this.highlightDiv.length;
3498 b++){this.highlightDiv[b].style.display="none"
3499 }}if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3500 Rico.log("HideSelection "+a.length);
3501 for(b=0;
3502 b<a.length;
3503 b++){this.unhighlightCell(this.columns[a[b].column].cell(a[b].row))
3504 }}},ShowSelection:function(){if(this.options.highlightMethod!="class"){this.updateSelectOutline()
3505 }if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3506 for(var b=0;
3507 b<a.length;
3508 b++){this.highlightCell(this.columns[a[b].column].cell(a[b].row))
3509 }}},ClearSelection:function(){Rico.log("ClearSelection");
3510 this.HideSelection();
3511 this.SelectIdxStart=null;
3512 this.SelectIdxEnd=null;
3513 this.SelectCtrl=[]
3514 },selectCell:function(a){this.ClearSelection();
3515 this.SelectIdxStart=this.SelectIdxEnd=this.datasetIndex(a);
3516 this.ShowSelection()
3517 },AdjustSelection:function(a){var b=this.datasetIndex(a);
3518 if(this.SelectIdxStart.tabIdx!=b.tabIdx){return
3519 }this.HideSelection();
3520 this.SelectIdxEnd=b;
3521 this.ShowSelection()
3522 },RefreshSelection:function(){var a=this.getVisibleSelection();
3523 for(var b=0;
3524 b<a.length;
3525 b++){this.columns[a[b].column].displayValue(a[b].row)
3526 }},FillSelection:function(b,f){if(this.SelectIdxStart&&this.SelectIdxEnd){var e=Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3527 var d=Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3528 var j=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3529 var g=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3530 for(var a=e;
3531 a<=d;
3532 a++){for(var k=j;
3533 k<=g;
3534 k++){this.buffer.setValue(a,k,b,f)
3535 }}}if(this.SelectCtrl){for(var h=0;
3536 h<this.SelectCtrl.length;
3537 h++){this.buffer.setValue(this.SelectCtrl[h].row,this.SelectCtrl[h].column,b,f)
3538 }}this.RefreshSelection()
3539 },selectMouseDown:function(d){if(this.highlightEnabled==false){return true
3540 }this.cancelMenu();
3541 var a=Rico.eventElement(d);
3542 if(!Rico.eventLeftClick(d)){return true
3543 }a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3544 if(!a){return true
3545 }Rico.eventStop(d);
3546 var c=this.datasetIndex(a);
3547 if(c.onBlankRow){return true
3548 }Rico.log("selectMouseDown @"+c.row+","+c.column);
3549 if(d.ctrlKey){if(!this.SelectIdxStart||this.options.highlightMethod!="class"){return true
3550 }if(!this.isSelected(a)){this.highlightCell(a);
3551 this.SelectCtrl.push(this.datasetIndex(a))
3552 }else{for(var b=0;
3553 b<this.SelectCtrl.length;
3554 b++){if(this.SelectCtrl[b].row==c.row&&this.SelectCtrl[b].column==c.column){this.unhighlightCell(a);
3555 this.SelectCtrl.splice(b,1);
3556 break
3557 }}}}else{if(d.shiftKey){if(!this.SelectIdxStart){return true
3558 }this.AdjustSelection(a)
3559 }else{this.selectCell(a);
3560 this.pluginSelect()
3561 }}return false
3562 },pluginSelect:function(){if(this.selectPluggedIn){return
3563 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3564 Rico.eventBind(a,"mouseover",this.options.mouseOverHandler,false);
3565 Rico.eventBind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3566 this.selectPluggedIn=true
3567 },unplugSelect:function(){if(!this.selectPluggedIn){return
3568 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3569 Rico.eventUnbind(a,"mouseover",this.options.mouseOverHandler,false);
3570 Rico.eventUnbind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3571 this.selectPluggedIn=false
3572 },selectMouseUp:function(b){this.unplugSelect();
3573 var a=Rico.eventElement(b);
3574 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3575 if(!a){return
3576 }if(this.SelectIdxStart&&this.SelectIdxEnd){this.AdjustSelection(a)
3577 }else{this.ClearSelection()
3578 }},selectMouseOver:function(b){var a=Rico.eventElement(b);
3579 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3580 if(!a){return
3581 }this.AdjustSelection(a);
3582 Rico.eventStop(b)
3583 },isSelected:function(a){if(this.options.highlightMethod!="outline"){return Rico.hasClass(a,this.options.highlightClass)
3584 }if(!this.SelectIdxStart||!this.SelectIdxEnd){return false
3585 }var c=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3586 var b=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3587 if(c>b){return false
3588 }var e=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3589 var d=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3590 var f=this.datasetIndex(a);
3591 return(c<=f.row&&f.row<=b&&e<=f.column&&f.column<=d)
3592 },highlightCell:function(a){Rico.addClass(a,this.options.highlightClass)
3593 },unhighlightCell:function(a){if(a){Rico.removeClass(a,this.options.highlightClass)
3594 }},selectRow:function(a){for(var b=0;
3595 b<this.columns.length;
3596 b++){this.highlightCell(this.columns[b].cell(a))
3597 }},unselectRow:function(a){for(var b=0;
3598 b<this.columns.length;
3599 b++){this.unhighlightCell(this.columns[b].cell(a))
3600 }},rowMouseOver:function(c){if(!this.highlightEnabled){return
3601 }var a=Rico.eventElement(c);
3602 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3603 if(!a){return
3604 }var b=this.winCellIndex(a);
3605 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3606 }this.highlight(b)
3607 },highlight:function(a){if(this.options.highlightMethod!="outline"){this.cursorSetClass(a)
3608 }if(this.options.highlightMethod!="class"){this.cursorOutline(a)
3609 }this.highlightIdx=a
3610 },cursorSetClass:function(e){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3611 }this.highlightCell(e.cell);
3612 break;
3613 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3614 }var b=this.options.highlightSection&1;
3615 var a=this.options.highlightSection&2;
3616 var f=b?0:this.options.frozenColumns;
3617 var d=a?this.columns.length:this.options.frozenColumns;
3618 for(var g=f;
3619 g<d;
3620 g++){this.highlightCell(this.columns[g].cell(e.row))
3621 }break;
3622 default:return
3623 }},cursorOutline:function(c){var d;
3624 switch(this.options.highlightElem){case"menuCell":case"cursorCell":d=this.highlightDiv[c.tabIdx];
3625 d.style.left=(this.columns[c.column].dataCell.offsetLeft-1)+"px";
3626 d.style.width=this.columns[c.column].colWidth;
3627 this.highlightDiv[1-c.tabIdx].style.display="none";
3628 break;
3629 case"menuRow":case"cursorRow":d=this.highlightDiv[0];
3630 var b=this.options.highlightSection&1;
3631 var a=this.options.highlightSection&2;
3632 d.style.left=b?"0px":this.frozenTabs.style.width;
3633 d.style.width=((b?this.frozenTabs.offsetWidth:0)+(a?this.innerDiv.offsetWidth:0)-4)+"px";
3634 break;
3635 default:return
3636 }d.style.top=(this.hdrHt+c.row*this.rowHeight-1)+"px";
3637 d.style.height=(this.rowHeight-1)+"px";
3638 d.style.display=""
3639 },unhighlight:function(){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3640 }if(!this.highlightDiv){return
3641 }for(var a=0;
3642 a<2;
3643 a++){this.highlightDiv[a].style.display="none"
3644 }break;
3645 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3646 }if(this.highlightDiv){this.highlightDiv[0].style.display="none"
3647 }break
3648 }},resetContents:function(){Rico.log("resetContents");
3649 this.ClearSelection();
3650 this.buffer.clear();
3651 this.clearRows();
3652 this.clearBookmark()
3653 },setImages:function(){for(var a=0;
3654 a<this.columns.length;
3655 a++){this.columns[a].setImage()
3656 }},findSortedColumn:function(){for(var a=0;
3657 a<this.columns.length;
3658 a++){if(this.columns[a].isSorted()){return a
3659 }}return -1
3660 },findColumnsBySpec:function(b,c){var a=[];
3661 for(var d=0;
3662 d<this.options.columnSpecs.length;
3663 d++){if(this.options.columnSpecs[d][b]==c){a.push(d)
3664 }}return a
3665 },setSortUI:function(c,b){Rico.log("setSortUI: "+c+" "+b);
3666 var a=this.findSortedColumn();
3667 if(a>=0){b=this.columns[a].getSortDirection()
3668 }else{if(typeof b!="string"){b=Rico.ColumnConst.SORT_ASC
3669 }else{b=b.toUpperCase();
3670 if(b!=Rico.ColumnConst.SORT_DESC){b=Rico.ColumnConst.SORT_ASC
3671 }}switch(typeof c){case"string":a=this.findColumnsBySpec("id",c);
3672 break;
3673 case"number":a=c;
3674 break
3675 }}if(typeof(a)!="number"||a<0){return
3676 }this.clearSort();
3677 this.columns[a].setSorted(b);
3678 this.buffer.sortBuffer(a)
3679 },clearSort:function(){for(var a=0;
3680 a<this.columns.length;
3681 a++){this.columns[a].setUnsorted()
3682 }},clearFilters:function(){for(var a=0;
3683 a<this.columns.length;
3684 a++){this.columns[a].setUnfiltered(true)
3685 }if(this.options.filterHandler){this.options.filterHandler()
3686 }},filterCount:function(){for(var a=0,b=0;
3687 a<this.columns.length;
3688 a++){if(this.columns[a].isFiltered()){b++
3689 }}return b
3690 },sortHandler:function(){this.cancelMenu();
3691 this.ClearSelection();
3692 this.setImages();
3693 var a=this.findSortedColumn();
3694 if(a<0){return
3695 }Rico.log("sortHandler: sorting column "+a);
3696 this.buffer.sortBuffer(a);
3697 this.clearRows();
3698 this.scrollDiv.scrollTop=0;
3699 this.buffer.fetch(0)
3700 },filterHandler:function(){Rico.log("filterHandler");
3701 this.cancelMenu();
3702 if(this.buffer.processingRequest){this.queueFilter=true;
3703 return
3704 }this.unplugScroll();
3705 this.ClearSelection();
3706 this.setImages();
3707 this.clearBookmark();
3708 this.clearRows();
3709 this.buffer.fetch(-1);
3710 Rico.runLater(10,this,"pluginScroll")
3711 },clearBookmark:function(){if(this.bookmark){this.bookmark.innerHTML="&nbsp;"
3712 }},bookmarkHandler:function(a,d){var b;
3713 if(isNaN(a)||!this.bookmark){return
3714 }var c=this.buffer.totalRows;
3715 if(c<d){d=c
3716 }if(c<=0){b=Rico.getPhraseById("bookmarkNoMatch")
3717 }else{if(d<0){b=Rico.getPhraseById("bookmarkNoRec")
3718 }else{if(this.buffer.foundRowCount){b=Rico.getPhraseById("bookmarkExact",a,d,c)
3719 }else{b=Rico.getPhraseById("bookmarkAbout",a,d,c)
3720 }}}this.bookmark.innerHTML=b
3721 },clearRows:function(){if(this.isBlank==true){return
3722 }for(var a=0;
3723 a<this.columns.length;
3724 a++){this.columns[a].clearColumn()
3725 }this.isBlank=true
3726 },refreshContents:function(j){Rico.log("refreshContents1 "+this.tableId+": startPos="+j+" lastRow="+this.lastRowPos+" PartBlank="+this.isPartialBlank+" pageSize="+this.pageSize);
3727 this.hideMsg();
3728 this.cancelMenu();
3729 this.unhighlight();
3730 if(this.queueFilter){Rico.log("refreshContents: cancelling refresh because filter has changed");
3731 this.queueFilter=false;
3732 this.filterHandler();
3733 return
3734 }this.highlightEnabled=this.options.highlightSection!="none";
3735 var h=this.buffer.startPos>j;
3736 var d=h?this.buffer.startPos:j;
3737 this.contentStartPos=d+1;
3738 var b=Math.min(this.buffer.startPos+this.buffer.size,j+this.pageSize);
3739 this.buffer.setWindow(d,b);
3740 Rico.log("refreshContents2 "+this.tableId+": cStartPos="+d+" cEndPos="+b+" vPrecedesBuf="+h+" b.startPos="+this.buffer.startPos);
3741 if(j==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3742 }this.isBlank=false;
3743 var m=this.options.onRefreshComplete;
3744 if((j+this.pageSize<this.buffer.startPos)||(this.buffer.startPos+this.buffer.size<j)||(this.buffer.size==0)){this.clearRows();
3745 if(m){m(this.contentStartPos,b)
3746 }return
3747 }Rico.log("refreshContents: contentStartPos="+d+" contentEndPos="+b+" viewPrecedesBuffer="+h);
3748 var n=b-d;
3749 var f=this.pageSize-n;
3750 var k=h?0:n;
3751 var e=h?f:0;
3752 for(var a=0;
3753 a<n;
3754 a++){for(var l=0;
3755 l<this.columns.length;
3756 l++){this.columns[l].displayValue(a+e)
3757 }}for(var g=0;
3758 g<f;
3759 g++){this.blankRow(g+k)
3760 }if(this.options.highlightElem=="selection"){this.ShowSelection()
3761 }this.isPartialBlank=f>0;
3762 this.lastRowPos=j;
3763 Rico.log("refreshContents complete, startPos="+j);
3764 if(m){m(this.contentStartPos,b)
3765 }},scrollToRow:function(a){var b=this.rowToPixel(a);
3766 Rico.log("scrollToRow, rowOffset="+a+" pixel="+b);
3767 this.scrollDiv.scrollTop=b;
3768 if(this.options.onscroll){this.options.onscroll(this,a)
3769 }},scrollUp:function(){this.moveRelative(-1)
3770 },scrollDown:function(){this.moveRelative(1)
3771 },pageUp:function(){this.moveRelative(-this.pageSize)
3772 },pageDown:function(){this.moveRelative(this.pageSize)
3773 },adjustRow:function(a){var b=this.topOfLastPage();
3774 if(b==0||!a){return 0
3775 }return Math.min(b,a)
3776 },rowToPixel:function(a){return this.adjustRow(a)*this.rowHeight
3777 },pixeltorow:function(c){var b=this.topOfLastPage();
3778 if(b==0){return 0
3779 }var a=parseInt(c/this.rowHeight,10);
3780 return Math.min(b,a)
3781 },moveRelative:function(b){var a=Math.max(this.scrollDiv.scrollTop+b*this.rowHeight,0);
3782 a=Math.min(a,this.scrollDiv.scrollHeight);
3783 this.scrollDiv.scrollTop=a
3784 },pluginScroll:function(){if(this.scrollPluggedIn){return
3785 }Rico.log("pluginScroll: wheelEvent="+this.wheelEvent);
3786 Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3787 for(var a=0;
3788 a<2;
3789 a++){Rico.eventBind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3790 }this.scrollPluggedIn=true
3791 },unplugScroll:function(){if(!this.scrollPluggedIn){return
3792 }Rico.log("unplugScroll");
3793 Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3794 for(var a=0;
3795 a<2;
3796 a++){Rico.eventUnbind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3797 }this.scrollPluggedIn=false
3798 },handleWheel:function(a){var b=0;
3799 if(a.wheelDelta){if(Rico.isOpera){b=a.wheelDelta/120
3800 }else{if(Rico.isWebKit){b=-a.wheelDelta/12
3801 }else{b=-a.wheelDelta/120
3802 }}}else{if(a.detail){b=a.detail/3
3803 }}if(b){this.moveRelative(b)
3804 }Rico.eventStop(a);
3805 return false
3806 },handleScroll:function(g){if(this.scrollTimeout){clearTimeout(this.scrollTimeout)
3807 }this.setHorizontalScroll();
3808 var a=this.scrollDiv.scrollTop;
3809 var b=this.lastScrollPos-a;
3810 if(b==0){return
3811 }var d=this.pixeltorow(a);
3812 if(d==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3813 }var f=new Date();
3814 Rico.log("handleScroll, newrow="+d+" scrtop="+a);
3815 if(this.options.highlightElem=="selection"){this.HideSelection()
3816 }this.buffer.fetch(d);
3817 if(this.options.onscroll){this.options.onscroll(this,d)
3818 }this.scrollTimeout=Rico.runLater(1200,this,"scrollIdle");
3819 this.lastScrollPos=this.scrollDiv.scrollTop;
3820 var c=new Date()
3821 },scrollIdle:function(){if(this.options.onscrollidle){this.options.onscrollidle()
3822 }}};
3823 Rico.LiveGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
3824 };
3825 Rico.LiveGridColumn.prototype={initialize:function(liveGrid,colIdx,hdrInfo,tabIdx){Rico.extend(this,new Rico.TableColumnBase());
3826 this.baseInit(liveGrid,colIdx,hdrInfo,tabIdx);
3827 this.buffer=liveGrid.buffer;
3828 if(typeof(this.format.type)!="string"||this.format.EntryType=="tinyMCE"){this.format.type="html"
3829 }if(typeof this.isNullable!="boolean"){this.isNullable=/number|date/.test(this.format.type)
3830 }this.isText=/html|text/.test(this.format.type);
3831 Rico.log(" sortable="+this.sortable+" filterable="+this.filterable+" hideable="+this.hideable+" isNullable="+this.isNullable+" isText="+this.isText);
3832 this.fixHeaders(this.liveGrid.tableId,this.options.hdrIconsFirst);
3833 if(this["format_"+this.format.type]){this._format=this["format_"+this.format.type]
3834 }if(this.format.control){if(typeof this.format.control=="string"){this.format.control=eval(this.format.control)
3835 }for(var property in this.format.control){if(property.charAt(0)=="_"){Rico.log("Copying control property "+property+" to "+this);
3836 this[property]=this.format.control[property]
3837 }}}},sortAsc:function(){this.setColumnSort(Rico.ColumnConst.SORT_ASC)
3838 },sortDesc:function(){this.setColumnSort(Rico.ColumnConst.SORT_DESC)
3839 },setColumnSort:function(a){this.liveGrid.clearSort();
3840 this.setSorted(a);
3841 if(this.liveGrid.options.saveColumnInfo.sort){this.liveGrid.setCookie()
3842 }if(this.options.sortHandler){this.options.sortHandler()
3843 }},isSortable:function(){return this.sortable
3844 },isSorted:function(){return this.currentSort!=Rico.ColumnConst.UNSORTED
3845 },getSortDirection:function(){return this.currentSort
3846 },toggleSort:function(){if(this.buffer&&this.buffer.totalRows==0){return
3847 }if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.sortDesc()
3848 }else{this.sortAsc()
3849 }},setUnsorted:function(){this.setSorted(Rico.ColumnConst.UNSORTED)
3850 },setSorted:function(a){this.currentSort=a
3851 },canFilter:function(){return this.filterable
3852 },getFilterText:function(){var c=[];
3853 for(var b=0;
3854 b<this.filterValues.length;
3855 b++){var a=this.filterValues[b];
3856 c.push(a==""?Rico.getPhraseById("filterBlank"):a)
3857 }switch(this.filterOp){case"EQ":return"= "+c.join(", ");
3858 case"NE":return Rico.getPhraseById("filterNot",c.join(", "));
3859 case"LE":return"<= "+c[0];
3860 case"GE":return">= "+c[0];
3861 case"LIKE":return Rico.getPhraseById("filterLike",c[0]);
3862 case"NULL":return Rico.getPhraseById("filterEmpty");
3863 case"NOTNULL":return Rico.getPhraseById("filterNotEmpty")
3864 }return"?"
3865 },getFilterQueryParm:function(){if(this.filterType==Rico.ColumnConst.UNFILTERED){return""
3866 }var a="&f["+this.index+"][op]="+this.filterOp;
3867 a+="&f["+this.index+"][len]="+this.filterValues.length;
3868 for(var b=0;
3869 b<this.filterValues.length;
3870 b++){a+="&f["+this.index+"]["+b+"]="+escape(this.filterValues[b])
3871 }return a
3872 },setUnfiltered:function(a){this.filterType=Rico.ColumnConst.UNFILTERED;
3873 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3874 }if(this.removeFilterFunc){this.removeFilterFunc()
3875 }if(this.options.filterHandler&&!a){this.options.filterHandler()
3876 }},setFilterEQ:function(){this.setUserFilter("EQ")
3877 },setFilterNE:function(){this.setUserFilter("NE")
3878 },addFilterNE:function(){this.filterValues.push(this.userFilter);
3879 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3880 }if(this.options.filterHandler){this.options.filterHandler()
3881 }},setFilterGE:function(){this.setUserFilter("GE")
3882 },setFilterLE:function(){this.setUserFilter("LE")
3883 },setFilterKW:function(a){if(a!=""&&a!=null){this.setFilter("LIKE",a,Rico.ColumnConst.USERFILTER)
3884 }else{this.setUnfiltered(false)
3885 }},setUserFilter:function(a){this.setFilter(a,this.userFilter,Rico.ColumnConst.USERFILTER)
3886 },setSystemFilter:function(a,b){this.setFilter(a,b,Rico.ColumnConst.SYSTEMFILTER)
3887 },setFilter:function(a,c,b,d){this.filterValues=typeof(c)=="object"?c:[c];
3888 this.filterType=b;
3889 this.filterOp=a;
3890 if(b==Rico.ColumnConst.USERFILTER&&this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3891 }this.removeFilterFunc=d;
3892 if(this.options.filterHandler){this.options.filterHandler()
3893 }},isFiltered:function(){return this.filterType==Rico.ColumnConst.USERFILTER
3894 },filterChange:function(a){var b=Rico.eventElement(a);
3895 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
3896 }else{this.setFilter("EQ",b.value,Rico.ColumnConst.USERFILTER,function(){b.selectedIndex=0
3897 })
3898 }},filterClear:function(a){this.filterField.value="";
3899 this.setUnfiltered()
3900 },filterKeypress:function(c){var a=Rico.eventElement(c);
3901 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
3902 }if(this.lastKeyFilter==a.value){return
3903 }var b=a.value;
3904 Rico.log("filterKeypress: "+this.index+" "+b);
3905 this.lastKeyFilter=b;
3906 if(b==""||b=="*"){this.setUnfiltered()
3907 }else{this.setFilter("LIKE",b,Rico.ColumnConst.USERFILTER,function(){a.value=""
3908 })
3909 }},mFilterSelectClick:function(a){Rico.eventStop(a);
3910 if(this.mFilter.style.display!="none"){this.mFilterFinish(a);
3911 if(Rico.isIE&&Rico.ieVersion<=6){this.filterField.focus()
3912 }else{this.filterField.blur()
3913 }}else{var b=Rico.cumulativeOffset(this.filterField);
3914 this.mFilter.style.top=(b.top+this.filterField.offsetHeight)+"px";
3915 this.mFilter.style.left=b.left+"px";
3916 this.mFilter.style.width=Math.min(this.filterField.offsetWidth,parseInt(this.colWidth,10))+"px";
3917 Rico.show(this.mFilter);
3918 this.mFilterFocus.focus()
3919 }},mFilterFinish:function(g){if(!this.mFilterChange){Rico.hide(this.mFilter);
3920 return
3921 }if(this.mFilterInputs[0].checked){this.mFilterReset();
3922 Rico.hide(this.mFilter);
3923 this.setUnfiltered();
3924 return
3925 }var c=[];
3926 var a=[];
3927 for(var d=1;
3928 d<this.mFilterInputs.length;
3929 d++){if(this.mFilterInputs[d].checked){c.push(this.mFilterInputs[d].value);
3930 a.push(this.mFilterLabels[d].innerHTML)
3931 }}if(c.length>0){var f=a.join(", ");
3932 this.filterField.options[0].text=f;
3933 this.filterField.title=f;
3934 Rico.hide(this.mFilter);
3935 this.mFilterChange=false;
3936 var b=this;
3937 this.setFilter("EQ",c,Rico.ColumnConst.USERFILTER,function(){b.mFilterReset()
3938 })
3939 }else{alert("Please select at least one value")
3940 }},mFilterReset:function(){var a=this.mFilterLabels[0].innerHTML;
3941 this.filterField.options[0].text=a;
3942 this.filterField.title=a
3943 },mFilterAllClick:function(c){var a=this.mFilterInputs[0].checked;
3944 for(var b=1;
3945 b<this.mFilterInputs.length;
3946 b++){this.mFilterInputs[b].checked=a
3947 }this.mFilterChange=true
3948 },mFilterOtherClick:function(a){this.mFilterInputs[0].checked=false;
3949 this.mFilterChange=true
3950 },format_text:function(a){if(typeof a!="string"){return"&nbsp;"
3951 }else{return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")
3952 }},format_number:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"
3953 }else{return Rico.formatNumber(a,this.format)
3954 }},format_datetime:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"
3955 }else{var b=Rico.setISO8601(a);
3956 if(!b){return a
3957 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3958 }},format_utcaslocaltime:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"
3959 }else{var c=new Date();
3960 var b=Rico.setISO8601(a,-c.getTimezoneOffset());
3961 if(!b){return a
3962 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3963 }},format_date:function(a){if(typeof a=="undefined"||a==null||a==""){return"&nbsp;"
3964 }else{var b=Rico.setISO8601(a);
3965 if(!b){return a
3966 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDate")+(this.format.suffix||"")
3967 }},fixHeaders:function(d,e){if(this.sortable){var c=Rico.eventHandle(this,"toggleSort");
3968 switch(this.options.headingSort){case"link":var b=Rico.wrapChildren(this.hdrCellDiv,"ricoSort",undefined,"a");
3969 b.href="javascript:void(0)";
3970 Rico.eventBind(b,"click",c);
3971 break;
3972 case"hover":Rico.eventBind(this.hdrCellDiv,"click",c);
3973 break
3974 }}this.imgFilter=document.createElement("span");
3975 this.imgFilter.style.display="none";
3976 this.imgFilter.className="rico-icon ricoLG_filterCol";
3977 this.imgSort=document.createElement("span");
3978 this.imgSort.style.display="none";
3979 this.imgSort.style.verticalAlign="top";
3980 if(e){this.hdrCellDiv.insertBefore(this.imgSort,this.hdrCellDiv.firstChild);
3981 this.hdrCellDiv.insertBefore(this.imgFilter,this.hdrCellDiv.firstChild)
3982 }else{this.hdrCellDiv.appendChild(this.imgFilter);
3983 this.hdrCellDiv.appendChild(this.imgSort)
3984 }if(!this.format.filterUI){Rico.eventBind(this.imgFilter,"click",Rico.eventHandle(this,"filterClick"),false)
3985 }},filterClick:function(a){if(this.filterType==Rico.ColumnConst.USERFILTER&&this.filterOp=="LIKE"){this.liveGrid.openKeyword(this.index)
3986 }},getValue:function(a){return this.buffer.getWindowCell(a,this.index)
3987 },getBufferStyle:function(a){return this.buffer.getWindowStyle(a,this.index)
3988 },setValue:function(b,a){this.buffer.setWindowValue(b,this.index,a)
3989 },_format:function(a){return a
3990 },_display:function(a,b){b.innerHTML=this._format(a)
3991 },_export:function(a){return this._format(a)
3992 },exportBuffer:function(a){return this._export(this.buffer.getValue(a,this.index))