1 Rico.applyShadow=function(b,a){if(typeof a=="undefined"){a=true
2 }if(a){Rico.addClass(b,"ricoShadow")
5 Rico._OpenPopupList=[];
6 Rico._RemoveOpenPopup=function(a){if(a.openIndex>=0&&a.openIndex<Rico._OpenPopupList.length){Rico._OpenPopupList.splice(a.openIndex,1)
9 Rico._AddOpenPopup=function(a){a.openIndex=Rico._OpenPopupList.push(a)-1
11 Rico._checkEscKey=function(b){if(Rico.eventKey(b)!=27){return true
12 }while(Rico._OpenPopupList.length>0){var a=Rico._OpenPopupList.pop();
13 if(a&&a.visible()){a.openIndex=-1;
19 Rico.eventBind(document,"keyup",Rico.eventHandle(Rico,"_checkEscKey"));
20 Rico.Popup=function(b,a){this.initialize(b,a)
22 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};
24 if(b){this.setDiv(b,a)
25 }},createContainer:function(a){this.setDiv(document.createElement("div"),a);
26 if(a&&a.parent){a.parent.appendChild(this.container)
27 }else{document.getElementsByTagName("body")[0].appendChild(this.container)
28 }},setDiv:function(c,b){Rico.extend(this.options,b||{});
29 this.container=Rico.$(c);
30 if(this.options.position=="auto"){this.position=Rico.getStyle(this.container,"position").toLowerCase()
31 }else{this.position=this.container.style.position=this.options.position
32 }this.content=document.createElement("div");
33 while(this.container.firstChild){this.content.appendChild(this.container.firstChild)
34 }this.container.appendChild(this.content);
35 this.content.className="RicoPopupContent";
36 this.content.style.position="relative";
37 if(this.position!="absolute"){return
38 }if(this.options.closeFunc){this.closeFunc=this.options.closeFunc
40 this.closeFunc=function(){a.closePopup()
42 }this.container.style.top="0px";
43 this.container.style.left="0px";
44 this.container.style.display="none";
45 if(this.options.zIndex>=0){this.container.style.zIndex=this.options.zIndex
46 }this.content.style.zIndex=2;
47 if(Rico.isIE&&Rico.ieVersion<7){this.ifr=document.createElement("iframe");
48 this.ifr.className="RicoShim";
49 this.ifr.frameBorder=0;
50 this.ifr.src="javascript:'';";
51 this.container.appendChild(this.ifr)
52 }Rico.applyShadow(this.container,this.options.shadow);
53 if(this.options.hideOnClick){Rico.eventBind(document,"click",Rico.eventHandle(this,"_docClick"))
54 }this.dragEnabled=false;
55 this.mousedownHandler=Rico.eventHandle(this,"_startDrag");
56 this.dragHandler=Rico.eventHandle(this,"_drag");
57 this.dropHandler=Rico.eventHandle(this,"_endDrag");
58 if(this.options.canDrag){this.enableDragging()
59 }if(this.options.ignoreClicks||this.options.canDrag){this.ignoreClicks()
60 }},clearContent:function(){this.content.innerHTML=""
61 },setContent:function(a){this.content.innerHTML=a
62 },enableDragging:function(){if(!this.dragEnabled&&this.options.dragElement){Rico.eventBind(this.options.dragElement,"mousedown",this.mousedownHandler);
64 }return this.dragEnabled
65 },disableDragging:function(){if(!this.dragEnabled){return
66 }Rico.eventUnbind(this.options.dragElement,"mousedown",this.mousedownHandler);
67 this.dragEnabled=false
68 },setZ:function(a){this.container.style.zIndex=a
69 },ignoreClicks:function(){Rico.eventBind(this.container,"click",Rico.eventHandle(this,"_ignoreClick"))
70 },_ignoreClick:function(a){if(a.stopPropagation){a.stopPropagation()
71 }else{a.cancelBubble=true
73 },_docClick:function(a){this.closeFunc();
75 },move:function(b,a){if(typeof b=="number"){this.container.style.left=b+"px"
76 }if(typeof a=="number"){this.container.style.top=a+"px"
77 }},_startDrag:function(b){var a=Rico.eventElement(b);
78 this.container.style.cursor="move";
79 this.lastMouse=Rico.eventClient(b);
80 Rico.eventBind(document,"mousemove",this.dragHandler);
81 Rico.eventBind(document,"mouseup",this.dropHandler);
83 },_drag:function(d){var b=Rico.eventClient(d);
84 var c=parseInt(this.container.style.left,10)+b.x-this.lastMouse.x;
85 var a=parseInt(this.container.style.top,10)+b.y-this.lastMouse.y;
89 },_endDrag:function(){this.container.style.cursor="";
90 Rico.eventUnbind(document,"mousemove",this.dragHandler);
91 Rico.eventUnbind(document,"mouseup",this.dropHandler)
92 },openPopup:function(b,a){if(typeof b=="number"){this.container.style.left=b+"px"
93 }if(typeof a=="number"){this.container.style.top=a+"px"
94 }this.container.style.display="";
95 if(this.container.id){Rico.log("openPopup "+this.container.id+" at "+b+","+a)
96 }Rico._AddOpenPopup(this)
97 },centerPopup:function(){this.openPopup();
98 var d=this.container.offsetWidth;
99 var c=this.container.offsetHeight;
100 var a=this.container.parentNode.offsetWidth;
101 var b=this.container.parentNode.offsetHeight;
102 this.move(parseInt(Math.max((a-d)/2,0),10),parseInt(Math.max((b-c)/2,0),10))
103 },visible:function(){return Rico.visible(this.container)
104 },closePopup:function(){Rico._RemoveOpenPopup(this);
105 if(!Rico.visible(this.container)){return
106 }if(this.container.id){Rico.log("closePopup "+this.container.id)
107 }if(this.dragEnabled){this._endDrag()
108 }this.container.style.display="none";
109 if(this.options.onClose){this.options.onClose()
111 Rico.closeButton=function(d){var b=document.createElement("a");
112 b.className="RicoCloseAnchor";
113 if(Rico.theme.closeAnchor){Rico.addClass(b,Rico.theme.closeAnchor)
114 }var c=b.appendChild(document.createElement("span"));
115 c.title=Rico.getPhraseById("close");
116 new Rico.HoverSet([b]);
117 Rico.addClass(c,Rico.theme.close||"rico-icon RicoClose");
118 Rico.eventBind(b,"click",d);
121 Rico.floatButton=function(b,e,f){var c=document.createElement("a");
122 c.className="RicoButtonAnchor";
123 Rico.addClass(c,Rico.theme.buttonAnchor||"RicoButtonAnchorNative");
124 var d=c.appendChild(document.createElement("span"));
126 }d.className=Rico.theme[b.toLowerCase()]||"rico-icon Rico"+b;
127 Rico.eventBind(c,"click",e,false);
128 new Rico.HoverSet([c]);
131 Rico.clearButton=function(b){var a=document.createElement("span");
132 a.title=Rico.getPhraseById("clear");
133 a.className="ricoClear";
134 Rico.addClass(a,Rico.theme.clear||"rico-icon ricoClearNative");
135 Rico.eventBind(a,"click",b);
138 Rico.Window=function(c,a,b){this.initialize(c,a,b)
140 Rico.Window.prototype={initialize:function(c,a,b){a=a||{overflow:"auto"};
141 Rico.extend(this,new Rico.Popup());
142 this.titleDiv=document.createElement("div");
143 this.options.canDrag=true;
144 this.options.dragElement=this.titleDiv;
145 this.createContainer(a);
146 this.content.appendChild(this.titleDiv);
148 this.contentDiv=b||document.createElement("div");
149 this.content.appendChild(this.contentDiv);
150 this.titleDiv.className="ricoTitle";
151 if(Rico.theme.dialogTitle){Rico.addClass(this.titleDiv,Rico.theme.dialogTitle)
152 }this.titleDiv.style.position="relative";
153 this.titleContent=document.createElement("span");
154 this.titleContent.className="ricoTitleSpan";
155 this.titleDiv.appendChild(this.titleContent);
156 this.titleDiv.appendChild(Rico.closeButton(Rico.eventHandle(this,"closeFunc")));
159 }this.setTitle(c||" ");
160 this.contentDiv.className="ricoContent";
161 if(Rico.theme.dialogContent){Rico.addClass(this.contentDiv,Rico.theme.dialogContent)
162 }this.contentDiv.style.position="relative";
163 if(a.height){this.contentDiv.style.height=a.height
164 }if(a.width){this.contentDiv.style.width=a.width
165 }if(a.overflow){this.contentDiv.style.overflow=a.overflow
166 }Rico.addClass(this.content,"ricoWindow");
167 if(Rico.theme.dialog){Rico.addClass(this.content,Rico.theme.dialog)
168 }this.content=this.contentDiv
169 },setTitle:function(a){this.titleContent.innerHTML=a
171 Rico.Menu=function(a){this.initialize(a)
173 Rico.Menu.prototype={initialize:function(a){Rico.extend(this,new Rico.Popup());
174 Rico.extend(this.options,{width:"15em",arrowColor:"b",showDisabled:false,hideOnClick:true});
175 if(typeof a=="string"){this.options.width=a
176 }else{Rico.extend(this.options,a||{})
178 this.highlightElem=null
179 },createDiv:function(a){if(this.container){return
181 var c={closeFunc:function(){b.cancelmenu()
184 }this.createContainer(c);
185 this.content.className=Rico.isWebKit?"ricoMenuSafari":"ricoMenu";
186 this.content.style.width=this.options.width;
187 this.direction=Rico.getStyle(this.container,"direction")||"ltr";
188 this.direction=this.direction.toLowerCase();
191 },showmenu:function(b,c){Rico.eventStop(b);
193 if(this.content.childNodes.length==0){this.cancelmenu();
195 }var a=Rico.eventClient(b);
196 this.openmenu(a.x,a.y,0,0)
197 },openmenu:function(g,f,j,e,a){var h=g+(a?0:Rico.docScrollLeft());
198 this.container.style.visibility="hidden";
199 this.container.style.display="block";
200 var i=this.container.offsetWidth;
201 var b=this.content.offsetWidth;
202 if(this.direction=="rtl"){if(h>i+j){h-=b+j
203 }}else{if(g+i>Rico.windowWidth()){h-=b+j-2
204 }}var d=Rico.docScrollTop();
206 if(f+this.container.offsetHeight-d>Rico.windowHeight()){c=Math.max(c-this.content.offsetHeight+e,0)
207 }this.openPopup(h,c);
208 this.container.style.visibility="visible";
210 },clearMenu:function(){this.clearContent();
211 this.defaultAction=null;
213 },addMenuHeading:function(b){var a=document.createElement("div");
215 a.className="ricoMenuHeading";
216 this.content.appendChild(a)
217 },addMenuBreak:function(){var a=document.createElement("div");
218 a.className="ricoMenuBreak";
219 this.content.appendChild(a)
220 },addSubMenuItem:function(b,e,g){var d=this.direction=="rtl"?"left":"right";
221 var c=this.addMenuItem(b,null,true,null,g);
222 c.className="ricoSubMenu";
223 var f=c.appendChild(document.createElement("div"));
224 f.className="rico-icon rico-"+d+"-"+this.options.arrowColor;
225 Rico.setStyle(f,{position:"absolute",top:"2px"});
228 Rico.eventBind(c,"mouseover",Rico.eventHandle(this,"showSubMenu"))
229 },showSubMenu:function(c){if(this.openSubMenu){this.hideSubMenu()
230 }var b=Rico.eventElement(c);
231 if(!b.RicoSubmenu){b=b.parentNode
232 }if(!b.RicoSubmenu){return
233 }this.openSubMenu=b.RicoSubmenu;
234 this.openMenuAnchor=b;
235 if(Rico.hasClass(b,"ricoSubMenu")){Rico.removeClass(b,"ricoSubMenu");
236 Rico.addClass(b,"ricoSubMenuOpen")
237 }b.RicoSubmenu.openmenu(parseInt(this.container.style.left)+b.offsetWidth,parseInt(this.container.style.top)+b.offsetTop,b.offsetWidth-2,b.offsetHeight+2,true)
238 },hideSubMenu:function(){if(this.openMenuAnchor){Rico.removeClass(this.openMenuAnchor,"ricoSubMenuOpen");
239 Rico.addClass(this.openMenuAnchor,"ricoSubMenu");
240 this.openMenuAnchor=null
241 }if(this.openSubMenu){this.openSubMenu.hidemenu();
242 this.openSubMenu=null
243 }},addMenuItemId:function(c,b,a,e,d){if(arguments.length<3){a=true
244 }this.addMenuItem(Rico.getPhraseById(c),b,a,e,d)
245 },addMenuItem:function(b,e,d,g,f){if(arguments.length>=3&&!d&&!this.options.showDisabled){return null
247 var c=document.createElement(typeof e=="string"?"a":"div");
248 if(arguments.length<3||d){if(typeof e=="string"){c.href=e;
250 }}else{if(f=="event"){Rico.eventBind(c,"click",e)
252 }}c.className="enabled";
253 if(this.defaultAction==null){this.defaultAction=e
254 }}else{c.disabled=true;
255 c.className="disabled"
257 if(typeof g=="string"){c.title=g
258 }c=this.content.appendChild(c);
259 Rico.eventBind(c,"mouseover",Rico.eventHandle(this,"mouseOver"));
260 Rico.eventBind(c,"mouseout",Rico.eventHandle(this,"mouseOut"));
262 },mouseOver:function(b){if(this.highlightElem&&this.highlightElem.className=="enabled-hover"){this.highlightElem.className="enabled";
263 this.highlightElem=null
264 }var a=Rico.eventElement(b);
265 if(a.parentNode==this.openMenuAnchor){a=a.parentNode
266 }if(this.openMenuAnchor&&this.openMenuAnchor!=a){this.hideSubMenu()
267 }if(a.className=="enabled"){a.className="enabled-hover";
269 }},mouseOut:function(b){var a=Rico.eventElement(b);
270 if(a.className=="enabled-hover"){a.className="enabled"
271 }if(this.highlightElem==a){this.highlightElem=null
272 }},cancelmenu:function(){if(!this.visible()){return
273 }if(this.hideFunc){this.hideFunc()
276 },hidemenu:function(){if(this.openSubMenu){this.openSubMenu.hidemenu()
279 Rico.SelectionSet=function(b,a){this.initialize(b,a)
281 Rico.SelectionSet.prototype={initialize:function(e,b){Rico.log("SelectionSet#initialize");
283 if(typeof e=="string"){e=Rico.select(e)
284 }this.previouslySelected=[];
285 this.selectionSet=[];
286 this.selectedClassName=this.options.selectedClass||Rico.theme.selected||"selected";
287 this.selectNode=this.options.selectNode||function(f){return f
289 this.onSelect=this.options.onSelect;
290 this.onFirstSelect=this.options.onFirstSelect;
292 this.clickHandler=function(f){a.selectIndex(f)
294 this.selectedIndex=-1;
298 }if(!this.options.noDefault){var d=this.options.cookieName?this.getCookie():0;
299 this.selectIndex(d||this.options.selectedIndex||0)
300 }},getCookie:function(){var b=Rico.getCookie(this.options.cookieName);
303 return a<this.selectionSet.length?a:0
304 },reset:function(){this.previouslySelected=[];
305 this._notifySelected(this.selectedIndex)
306 },clearSelected:function(){if(this.selected){Rico.removeClass(this.selectNode(this.selected),this.selectedClassName)
307 }},getIndex:function(b){for(var a=0;
308 a<this.selectionSet.length;
309 a++){if(b==this.selectionSet[a]){return a
311 },select:function(b){if(this.selected==b){return
312 }var a=this.getIndex(b);
313 if(a>=0){this.selectIndex(a)
314 }},_notifySelected:function(a){if(a<0){return
315 }var b=this.selectionSet[a];
316 if(this.options.cookieName){Rico.setCookie(this.options.cookieName,a,this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
317 }if(this.onFirstSelect&&!this.previouslySelected[a]){this.onFirstSelect(b,a);
318 this.previouslySelected[a]=true
319 }if(this.onSelect){try{this.onSelect(a)
320 }catch(c){}}},selectIndex:function(a){if(this.selectedIndex==a||a>=this.selectionSet.length){return
321 }this.clearSelected();
322 this._notifySelected(a);
323 this.selectedIndex=a;
324 this.selected=this.selectionSet[a].element;
325 Rico.addClass(this.selectNode(this.selected),this.selectedClassName)
326 },nextSelectIndex:function(){return(this.selectedIndex+1)%this.selectionSet.length
327 },nextSelectItem:function(){return this.selectionSet[this.nextSelectIndex()]
328 },selectNext:function(){this.selectIndex(this.nextSelectIndex())
329 },add:function(b){var a=this.selectionSet.length;
330 this.selectionSet[a]=new Rico._SelectionItem(b,a,this.clickHandler)
331 },remove:function(b){if(b==this.selected){this.clearSelected()
332 }var a=this.getIndex(b);
334 }this.selectionSet[a].remove();
335 this.selectionSet.splice(a,1)
336 },removeAll:function(){this.clearSelected();
337 while(this.selectionSet.length>0){this.selectionSet.pop().remove()
339 Rico._SelectionItem=function(b,a,c){this.add(b,a,c)
341 Rico._SelectionItem.prototype={add:function(b,a,c){this.element=b;
344 this.handle=Rico.eventHandle(this,"click");
345 Rico.eventBind(b,"click",this.handle)
346 },click:function(a){this.callback(this.index)
347 },remove:function(){Rico.eventUnbind(this.element,"click",this.handle)
349 Rico.HoverSet=function(b,a){this.initialize(b,a)
351 Rico.HoverSet.prototype={initialize:function(c,a){Rico.log("HoverSet#initialize");
353 this.hoverClass=a.hoverClass||Rico.theme.hover||"hover";
354 this.hoverFunc=a.hoverNodes||function(d){return[d]
361 }},add:function(a){this.hoverSet.push(new Rico._HoverItem(a,this.hoverFunc,this.hoverClass))
362 },removeAll:function(){while(this.hoverSet.length>0){this.hoverSet.pop().remove()
364 Rico._HoverItem=function(b,a,c){this.add(b,a,c)
366 Rico._HoverItem.prototype={add:function(b,a,c){this.element=b;
369 this.movehandle=Rico.eventHandle(this,"move");
370 this.outhandle=Rico.eventHandle(this,"mouseout");
371 Rico.eventBind(b,"mousemove",this.movehandle);
372 Rico.eventBind(b,"mouseout",this.outhandle)
373 },move:function(c){var a=this.selectFunc(this.element);
376 b++){Rico.addClass(a[b],this.hoverClass)
377 }},mouseout:function(c){var a=this.selectFunc(this.element);
380 b++){Rico.removeClass(a[b],this.hoverClass)
381 }},remove:function(){Rico.eventUnbind(element,"mousemove",this.movehandle);
382 Rico.eventUnbind(element,"mouseout",this.outhandle)
385 Rico.Effect.easeIn=function(a){return Math.sqrt(a)
387 Rico.Effect.easeOut=function(a){return a*a
389 Rico.ContentTransitionBase=function(){};
390 Rico.ContentTransitionBase.prototype={initBase:function(e,d,b){Rico.log("ContentTransitionBase#initBase");
391 if(typeof e=="string"){e=Rico.select(e)
392 }if(typeof d=="string"){d=Rico.select(d)
396 this.hoverSet=new Rico.HoverSet(e,b);
399 c++){if(d[c]){Rico.hide(d[c])
401 this.selectionSet=new Rico.SelectionSet(e,Rico.extend(b,{onSelect:function(f){a._finishSelect(f)
403 },reset:function(){this.selectionSet.reset()
404 },select:function(a){this.selectionSet.selectIndex(a)
405 },_finishSelect:function(b){Rico.log("ContentTransitionBase#_finishSelect");
406 var a=this.contents[b];
407 if(!a){alert("Internal error: no panel @index="+b);
409 }if(this.selected==a){return
410 }if(this.transition){if(this.selected){this.transition(a)
411 }else{a.style.display="block"
412 }}else{if(this.selected){Rico.hide(this.selected)
413 }a.style.display="block"
415 },addBase:function(b,a){this.titles.push(b);
416 this.contents.push(a);
417 this.hoverSet.add(b);
418 this.selectionSet.add(b);
420 },removeBase:function(a){},removeAll:function(){this.hoverSet.removeAll();
421 this.selectionSet.removeAll()
423 Rico.Accordion=function(b,a){this.initialize(b,a)
425 Rico.Accordion.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(g,e){g=Rico.$(g);
426 g.style.overflow="hidden";
427 g.className=e.accClass||Rico.theme.accordion||"Rico_accordion";
428 if(typeof e.panelWidth=="number"){e.panelWidth+="px"
429 }if(e.panelWidth){g.style.width=e.panelWidth
430 }var d=Rico.getDirectChildrenByTag(g,"div");
434 f++){c=Rico.getDirectChildrenByTag(d[f],"div");
435 if(c.length>=2){c[0].className=e.titleClass||Rico.theme.accTitle||"Rico_accTitle";
436 c[1].className=e.contentClass||Rico.theme.accContent||"Rico_accContent";
439 var b=Rico.wrapChildren(c[0],"","","a");
440 b.href="javascript:void(0)"
441 }}Rico.log("creating Rico.Accordion for "+g.id+" with "+j.length+" panels");
442 this.initBase(j,h,e);
443 this.selected.style.height=this.options.panelHeight+"px";
444 this.totSteps=(typeof e.duration=="number"?e.duration:200)/25
445 },transition:function(b){if(!this.options.noAnimate){this.closing=this.selected;
449 this.timer=setInterval(function(){a.step()
451 }else{b.style.height=this.options.panelHeight+"px";
452 if(this.selected){Rico.hide(this.selected)
453 }b.style.display="block"
454 }},step:function(){this.curStep++;
455 var a=Math.round(this.curStep/this.totSteps*this.options.panelHeight);
456 this.opening.style.height=a+"px";
457 this.closing.style.height=(this.options.panelHeight-a)+"px";
458 if(this.curStep==1){this.opening.style.paddingTop=this.opening.style.paddingBottom="0px";
459 this.opening.style.display="block"
460 }if(this.curStep==this.totSteps){clearInterval(this.timer);
461 this.opening.style.paddingTop=this.opening.style.paddingBottom="";
462 Rico.hide(this.closing)
463 }},setPanelHeight:function(a){this.options.panelHeight=a;
464 this.selected.style.height=this.options.panelHeight+"px"
466 Rico.TabbedPanel=function(b,a){this.initialize(b,a)
468 Rico.TabbedPanel.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(d,k){d=Rico.$(d);
470 if(typeof k.panelWidth=="number"){k.panelWidth+="px"
471 }if(typeof k.panelHeight=="number"){k.panelHeight+="px"
472 }d.className=k.tabClass||Rico.theme.tabPanel||"Rico_tabPanel";
473 if(k.panelWidth){d.style.width=k.panelWidth
478 e++){if(j[e]&&j[e].tagName&&j[e].tagName.match(/^div|ul$/i)){g.push(j[e])
479 }}if(g.length<2){return
480 }var c=g[0].tagName.toLowerCase()=="ul"?"li":"div";
481 g[0].className=k.navContainerClass||Rico.theme.tabNavContainer||"Rico_tabNavContainer";
482 g[0].style.listStyle="none";
483 g[1].className=k.contentContainerClass||Rico.theme.tabContentContainer||"Rico_tabContentContainer";
484 var f=Rico.getDirectChildrenByTag(g[0],c);
485 var b=Rico.getDirectChildrenByTag(g[1],"div");
486 if(!k.corners){k.corners="top"
489 e++){f[e].className=k.titleClass||Rico.theme.tabTitle||"Rico_tabTitle";
490 var h=Rico.wrapChildren(f[e],"","","a");
491 h.href="javascript:void(0)";
492 b[e].className=k.contentClass||Rico.theme.tabContent||"Rico_tabContent";
493 if(k.panelHeight){b[e].style.overflow="auto"
494 }if(k.corners!="none"){if(k.panelHdrWidth){f[e].style.width=k.panelHdrWidth
495 }Rico.Corner.round(f[e],Rico.theme.tabCornerOptions||k)
496 }}k.selectedClass=Rico.theme.tabSelected||"selected";
497 this.initBase(f,b,k);
498 if(this.selected){this.transition(this.selected)
499 }},transition:function(a){Rico.log("TabbedPanel#transition "+typeof(a));
500 if(this.selected){Rico.hide(this.selected)
502 if(this.options.panelHeight){a.style.height=this.options.panelHeight
504 Rico.Corner={round:function(b,a){b=Rico.$(b);
505 this.options={corners:"all",bgColor:"fromParent",compact:false,nativeCorners:false};
506 Rico.extend(this.options,a||{});
507 if(typeof(Rico.getStyle(b,"border-radius"))=="string"){this._roundCornersStdCss(b)
508 }else{if(typeof(Rico.getStyle(b,"-webkit-border-radius"))=="string"){this._roundCornersWebKit(b)
509 }else{if(typeof(Rico.getStyle(b,"-moz-border-radius"))=="string"){this._roundCornersMoz(b)
510 }else{if(!this.options.nativeCorners){this._roundCornersImpl(b)
511 }}}}},_roundCornersStdCss:function(b){var a=this.options.compact?"4px":"8px";
512 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{borderRadius:a})
513 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{borderTopLeftRadius:a})
514 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{borderTopRightRadius:a})
515 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{borderBottomLeftRadius:a})
516 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{borderBottomRightRadius:a})
517 }}},_roundCornersWebKit:function(b){var a=this.options.compact?"4px":"8px";
518 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{WebkitBorderRadius:a})
519 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{WebkitBorderTopLeftRadius:a})
520 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{WebkitBorderTopRightRadius:a})
521 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{WebkitBorderBottomLeftRadius:a})
522 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{WebkitBorderBottomRightRadius:a})
523 }}},_roundCornersMoz:function(b){var a=this.options.compact?"4px":"8px";
524 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{MozBorderRadius:a})
525 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{MozBorderRadiusTopleft:a})
526 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{MozBorderRadiusTopright:a})
527 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{MozBorderRadiusBottomleft:a})
528 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{MozBorderRadiusBottomright:a})
529 }}},_roundCornersImpl:function(b){var a=this.options.bgColor=="fromParent"?this._background(b.parentNode):this.options.bgColor;
530 b.style.position="relative";
531 if(this._hasString(this.options.corners,"all","top","tl")){this._createCorner(b,"top","left",a)
532 }if(this._hasString(this.options.corners,"all","top","tr")){this._createCorner(b,"top","right",a)
533 }if(this._hasString(this.options.corners,"all","bottom","bl")){this._createCorner(b,"bottom","left",a)
534 }if(this._hasString(this.options.corners,"all","bottom","br")){this._createCorner(b,"bottom","right",a)
535 }},_createCorner:function(b,c,f,k){var n=document.createElement("div");
536 n.className="ricoCorner";
537 Rico.setStyle(n,{width:"6px",height:"5px"});
538 var o=Rico.getStyle(b,"border-"+c+"-style");
539 var a=o=="none"?k:Rico.getStyle(b,"border-"+c+"-color");
540 var j=o=="none"?"0px":"-1px";
542 n.style[f]=Rico.isIE&&Rico.ieVersion<7&&f=="right"&&o!="none"?"-2px":"-1px";
545 if(c=="bottom"){h.reverse()
546 }var m=o=="none"?"0px none":"1px solid "+a;
547 var g=f=="left"?"Right":"Left";
550 e++){var l=document.createElement("div");
551 Rico.setStyle(l,{backgroundColor:k,height:"1px"});
552 l.style["margin"+g]=h[e]+"px";
553 l.style["border"+g]=m;
555 }},_background:function(c){try{var a=Rico.getStyle(c,"backgroundColor");
556 if(a.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&c.parentNode){return this._background(c.parentNode)
557 }return a==null?"#ffffff":a
558 }catch(b){return"#ffffff"
559 }},_hasString:function(b){for(var a=1;
561 a++){if(b.indexOf(arguments[a])>=0){return true
564 Rico.toColorPart=function(a){return Rico.zFill(a,2,16)
566 Rico.Color=function(c,b,a){this.initialize(c,b,a)
568 Rico.Color.prototype={initialize:function(c,b,a){this.rgb={r:c,g:b,b:a}
569 },setRed:function(a){this.rgb.r=a
570 },setGreen:function(a){this.rgb.g=a
571 },setBlue:function(a){this.rgb.b=a
572 },setHue:function(b){var a=this.asHSB();
574 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
575 },setSaturation:function(b){var a=this.asHSB();
577 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
578 },setBrightness:function(a){var c=this.asHSB();
580 this.rgb=Rico.Color.HSBtoRGB(c.h,c.s,c.b)
581 },darken:function(b){var a=this.asHSB();
582 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.max(a.b-b,0))
583 },brighten:function(b){var a=this.asHSB();
584 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.min(a.b+b,1))
585 },blend:function(a){this.rgb.r=Math.floor((this.rgb.r+a.rgb.r)/2);
586 this.rgb.g=Math.floor((this.rgb.g+a.rgb.g)/2);
587 this.rgb.b=Math.floor((this.rgb.b+a.rgb.b)/2)
588 },isBright:function(){var a=this.asHSB();
589 return this.asHSB().b>0.5
590 },isDark:function(){return !this.isBright()
591 },asRGB:function(){return"rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")"
592 },asHex:function(){return"#"+Rico.toColorPart(this.rgb.r)+Rico.toColorPart(this.rgb.g)+Rico.toColorPart(this.rgb.b)
593 },asHSB:function(){return Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b)
594 },toString:function(){return this.asHex()
596 Rico.Color.createFromHex=function(d){if(d.length==4){var b=d;
600 c++){d+=(b.charAt(c)+b.charAt(c))
601 }}if(d.indexOf("#")==0){d=d.substring(1)
602 }if(!d.match(/^[0-9A-Fa-f]{6}$/)){return null
603 }var f=d.substring(0,2);
604 var e=d.substring(2,4);
605 var a=d.substring(4,6);
606 return new Rico.Color(parseInt(f,16),parseInt(e,16),parseInt(a,16))
608 Rico.Color.createColorFromBackground=function(d){if(!d.style){return new Rico.Color(255,255,255)
609 }var b=Rico.getStyle(d,"background-color");
610 if(b.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&d.parentNode){return Rico.Color.createColorFromBackground(d.parentNode)
611 }if(b==null){return new Rico.Color(255,255,255)
612 }if(b.indexOf("rgb(")==0){var a=b.substring(4,b.length-1);
614 return new Rico.Color(parseInt(c[0],10),parseInt(c[1],10),parseInt(c[2],10))
615 }else{if(b.indexOf("#")==0){return Rico.Color.createFromHex(b)
616 }else{return new Rico.Color(255,255,255)
618 Rico.Color.HSBtoRGB=function(i,e,k){var c=0;
621 if(e==0){c=parseInt(k*255+0.5,10);
624 }else{var g=(i-Math.floor(i))*6;
625 var j=g-Math.floor(g);
628 var m=k*(1-(e*(1-j)));
629 switch(parseInt(g,10)){case 0:c=(k*255+0.5);
633 case 1:c=(a*255+0.5);
637 case 2:c=(b*255+0.5);
641 case 3:c=(b*255+0.5);
645 case 4:c=(m*255+0.5);
649 case 5:c=(k*255+0.5);
653 }}return{r:parseInt(c,10),g:parseInt(d,10),b:parseInt(l,10)}
655 Rico.Color.RGBtoHSB=function(a,f,l){var h;
666 }else{var c=(m-a)/(m-i);
670 }else{if(f==m){h=2+c-d
674 }}return{h:h,s:e,b:k}
676 Rico.createXmlDocument=function(){if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);
677 if(a.readyState==null){a.readyState=1;
678 a.addEventListener("load",function(){a.readyState=4;
679 if(typeof a.onreadystatechange=="function"){a.onreadystatechange()
682 }if(window.ActiveXObject){return Rico.tryFunctions(function(){return new ActiveXObject("MSXML2.DomDocument")
683 },function(){return new ActiveXObject("Microsoft.DomDocument")
684 },function(){return new ActiveXObject("MSXML.DomDocument")
685 },function(){return new ActiveXObject("MSXML3.DomDocument")
689 Rico.CalendarControl=function(b,a){this.initialize(b,a)
691 Rico.CalendarControl.prototype={initialize:function(c,b){this.id=c;
693 Rico.extend(this,new Rico.Popup());
694 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)});
695 Rico.extend(this.options,b||{});
696 this.close=this.closePopup;
697 this.bPageLoaded=false;
700 this.weekString=Rico.getPhraseById("calWeekHdg");
701 this.re=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
702 this.setDateFmt(this.options.dateFmt)
703 },setDateFmt:function(a){this.dateFmt=(a=="rico")?Rico.dateFmt:a;
704 Rico.log(this.id+" date format set to "+this.dateFmt);
706 if(this.re.exec(this.dateFmt)){this.dateParts[RegExp.$1]=0;
707 this.dateParts[RegExp.$3]=1;
708 this.dateParts[RegExp.$5]=2
709 }},addHoliday:function(f,a,g,e,c,b){this.Holidays[this.holidayKey(g,a-1,f)]={desc:e,txtColor:b,bgColor:c||"#DDF"}
710 },holidayKey:function(c,a,b){return"h"+Rico.zFill(c,4)+Rico.zFill(a,2)+Rico.zFill(b,2)
711 },atLoad:function(){Rico.log("Calendar#atLoad: "+this.id);
712 var d=Rico.$(this.id);
714 }else{this.createContainer();
715 this.container.id=this.id
716 }Rico.addClass(this.content,Rico.theme.calendar||"ricoCalContainer");
717 this.content.style.display="block";
718 this.heading=this.content.appendChild(document.createElement("div"));
719 this.heading.className="RicoCalHeading";
720 if(Rico.theme.calendarHeading){Rico.addClass(this.heading,Rico.theme.calendarHeading)
721 }var k=this._createTitleSection("Month");
722 this.heading.appendChild(k);
723 this.heading.appendChild(this._createTitleSection("Year"));
724 new Rico.HoverSet(this.heading.getElementsByTagName("a"));
725 if(this.position=="absolute"){this.heading.appendChild(Rico.closeButton(Rico.eventHandle(this,"close")))
726 }this.maintab=document.createElement("table");
727 this.maintab.cellSpacing=2;
728 this.maintab.cellPadding=0;
729 this.maintab.border=0;
730 this.maintab.style.borderCollapse="separate";
731 this.maintab.className="ricoCalTab";
732 if(Rico.theme.calendarTable){Rico.addClass(this.maintab,Rico.theme.calendarTable)
733 }this.tbody=Rico.getTBody(this.maintab);
734 var b,l,g,f,h,p,m,q,e;
735 this.colStart=this.options.showWeekNumber?1:0;
738 g++){b=this.tbody.insertRow(-1);
742 l++){b.insertCell(-1)
743 }}b=this.tbody.rows[0];
744 b.className="ricoCalDayNames";
745 if(this.options.showWeekNumber){b.cells[0].innerHTML=this.weekString;
748 g++){this.tbody.rows[g].cells[0].className="ricoCalWeekNum"
752 g++){p=(g+this.options.startAt)%7;
753 b.cells[g+this.colStart].innerHTML=Rico.dayAbbr(p);
754 this.styles[g]="ricoCal"+p
755 }if(this.options.showToday){this.tfoot=this.maintab.createTFoot();
756 b=this.tfoot.insertRow(-1);
757 this.todayCell=b.insertCell(-1);
758 this.todayCell.colSpan=7+this.colStart;
759 if(Rico.theme.calendarFooter){Rico.addClass(this.todayCell,Rico.theme.calendarFooter)
760 }Rico.eventBind(this.todayCell,"click",Rico.eventHandle(this,"selectNow"),false)
761 }this.content.appendChild(this.maintab);
762 new Rico.HoverSet(this.tbody.getElementsByTagName("td"),{hoverNodes:function(a){return a.innerHTML.match(/^\d+$/)?[a]:[]
764 this.monthPopup=new Rico.Popup(document.createElement("div"));
765 this.monthPopup.closePopup();
766 e=document.createElement("table");
767 e.className="ricoCalMenu";
768 if(Rico.theme.calendarPopdown){Rico.addClass(e,Rico.theme.calendarPopdown)
772 e.style.borderCollapse="separate";
773 e.style.margin="0px";
776 g++){b=e.insertRow(-1);
779 f++){l=b.insertCell(-1);
780 m=document.createElement("a");
781 m.innerHTML=Rico.monthAbbr(g*3+f);
783 if(Rico.theme.calendarDay){Rico.addClass(m,Rico.theme.calendarDay)
785 Rico.eventBind(m,"click",Rico.eventHandle(this,"selectMonth"),false)
786 }}new Rico.HoverSet(e.getElementsByTagName("a"));
787 this.monthPopup.content.appendChild(e);
788 this.container.appendChild(this.monthPopup.container);
789 this.yearPopup=new Rico.Popup(document.createElement("div"));
790 this.yearPopup.closePopup();
791 this.yearPopup.content.className="ricoCalYearPrompt";
792 if(Rico.theme.calendarPopdown){Rico.addClass(this.yearPopup.content,Rico.theme.calendarPopdown)
793 }var o=document.createElement("p");
794 o.innerHTML=Rico.getPhraseById("calYearRange",this.options.minDate.getFullYear(),this.options.maxDate.getFullYear());
795 var n=document.createElement("p");
796 this.yearInput=n.appendChild(document.createElement("input"));
797 this.yearInput.maxlength=4;
798 this.yearInput.size=4;
799 Rico.eventBind(this.yearInput,"keyup",Rico.eventHandle(this,"yearKey"),false);
800 m=Rico.floatButton("Checkmark",Rico.eventHandle(this,"processPopUpYear"));
802 m=Rico.floatButton("Cancel",Rico.eventHandle(this,"popDownYear"));
804 this.yearPopup.content.appendChild(o);
805 this.yearPopup.content.appendChild(n);
806 this.container.appendChild(this.yearPopup.container);
807 this.yearPopup.container.style.left="";
808 this.yearPopup.container.style.right="5px";
809 this.yearPopup.container.style.zIndex=10;
810 m=this.content.getElementsByTagName("a");
813 g++){m[g].href="javascript:void(0)"
814 }Rico.eventBind(this.tbody,"click",Rico.eventHandle(this,"saveAndClose"));
816 this.bPageLoaded=true
817 },_createTitleSection:function(d){var c=document.createElement("span");
818 c.className="RicoCal"+d+"Heading";
819 if(Rico.theme.calendarSubheading){Rico.addClass(c,Rico.theme.calendarSubheading)
820 }var b=c.appendChild(document.createElement("a"));
821 b.className="Rico_leftArrow";
822 b.appendChild(this.createNavArrow("dec"+d,"left"));
823 var b=c.appendChild(document.createElement("a"));
824 Rico.eventBind(b,"click",Rico.eventHandle(this,"popUp"+d),false);
826 b=c.appendChild(document.createElement("a"));
827 b.className="Rico_rightArrow";
828 b.appendChild(this.createNavArrow("inc"+d,"right"));
830 },selectNow:function(){var a=new Date();
831 this.dateNow=a.getDate();
832 this.monthNow=a.getMonth();
833 this.yearNow=a.getFullYear();
834 this.monthSelected=this.monthNow;
835 this.yearSelected=this.yearNow;
836 this.constructCalendar()
837 },createNavArrow:function(a,c){var b=document.createElement("span");
838 b.className=Rico.theme[c+"Arrow"]||"rico-icon Rico_"+c+"Arrow";
839 b.style.display="inline-block";
840 Rico.eventBind(b,"click",Rico.eventHandle(this,a),false);
842 },isValidMonth:function(a,b){if(a<this.options.minDate.getFullYear()){return false
843 }if(a==this.options.minDate.getFullYear()&&b<this.options.minDate.getMonth()){return false
844 }if(a>this.options.maxDate.getFullYear()){return false
845 }if(a==this.options.maxDate.getFullYear()&&b>this.options.maxDate.getMonth()){return false
847 },incMonth:function(){var b=this.monthSelected+1;
848 var a=this.yearSelected;
851 }if(!this.isValidMonth(a,b)){return
852 }this.monthSelected=b;
854 this.constructCalendar()
855 },decMonth:function(){var b=this.monthSelected-1;
856 var a=this.yearSelected;
859 }if(!this.isValidMonth(a,b)){return
860 }this.monthSelected=b;
862 this.constructCalendar()
863 },selectMonth:function(b){var a=Rico.eventElement(b);
864 this.monthSelected=parseInt(a.name,10);
865 this.constructCalendar();
867 },popUpMonth:function(a){Rico.eventStop(a);
868 if(this.monthPopup.visible()){this.popDownMonth();
871 if(Rico.isIE&&Rico.ieVersion<7){this.monthPopup.openPopup(null,this.heading.offsetHeight+2);
872 this.monthPopup.container.style.left=""
873 }else{this.monthPopup.openPopup(3,this.heading.offsetHeight+2)
875 },popDownMonth:function(){this.monthPopup.closePopup()
876 },popDownYear:function(){this.yearPopup.closePopup();
877 this.yearInput.disabled=true
878 },popUpYear:function(b){Rico.eventStop(b);
879 if(this.yearPopup.visible()){this.popDownYear();
881 }this.popDownMonth();
882 this.yearInput.disabled=false;
883 this.yearInput.value="";
884 this.yearPopup.openPopup(null,this.heading.offsetHeight+2);
886 setTimeout(function(){a.yearInput.focus()
889 },yearKey:function(a){switch(Rico.eventKey(a)){case 27:this.popDownYear();
892 case 13:this.processPopUpYear();
896 },processPopUpYear:function(){var a=this.yearInput.value;
898 if(isNaN(a)||a<this.options.minDate.getFullYear()||a>this.options.maxDate.getFullYear()){alert(Rico.getPhraseById("calInvalidYear"))
899 }else{this.yearSelected=a;
901 this.constructCalendar()
902 }},incYear:function(){if(this.yearSelected>=this.options.maxDate.getFullYear()){return
903 }this.yearSelected++;
904 this.constructCalendar()
905 },decYear:function(){if(this.yearSelected<=this.options.minDate.getFullYear()){return
906 }this.yearSelected--;
907 this.constructCalendar()
908 },WeekNbr:function(h,f,j){var g=new Date(h,f,j);
909 var c=new Date(h,0,1);
910 var e=7+1-c.getDay();
912 }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;
913 var d=Math.floor((b-e+7)/7);
915 var a=new Date(h,0,1);
916 var i=7+1-a.getDay();
919 },constructCalendar:function(){var l=[31,0,31,30,31,30,31,31,30,31,30,31];
920 var d=new Date(this.yearSelected,this.monthSelected,1);
922 if(typeof this.monthSelected!="number"||this.monthSelected>=12||this.monthSelected<0){alert("ERROR in calendar: monthSelected="+this.monthSelected);
924 }if(this.monthSelected==1){j=new Date(this.yearSelected,this.monthSelected+1,1);
925 j=new Date(j-(24*60*60*1000));
927 }else{e=l[this.monthSelected]
928 }var n=d.getDay()-this.options.startAt;
930 }this.popDownMonth();
932 if(this.options.showWeekNumber){for(f=1;
934 f++){this.tbody.rows[f].cells[0].innerHTML=" "
937 f++){this.resetCell(this.tbody.rows[1].cells[f+this.colStart])
941 if(this.options.showWeekNumber&&b==0){this.tbody.rows[a].cells[0].innerHTML=this.WeekNbr(this.yearSelected,this.monthSelected,k)
942 }var m=this.tbody.rows[a].cells[b+this.colStart];
944 m.className=this.styles[b];
945 if((k==this.dateNow)&&(this.monthSelected==this.monthNow)&&(this.yearSelected==this.yearNow)){Rico.addClass(m,Rico.theme.calendarToday||"ricoCalToday")
946 }if(Rico.theme.calendarDay){Rico.addClass(m,Rico.theme.calendarDay)
947 }if((k==this.odateSelected)&&(this.monthSelected==this.omonthSelected)&&(this.yearSelected==this.oyearSelected)){Rico.addClass(m,Rico.theme.calendarSelectedDay||"ricoSelectedDay")
948 }var g=this.Holidays[this.holidayKey(this.yearSelected,this.monthSelected,k)];
949 if(!g){g=this.Holidays[this.holidayKey(0,this.monthSelected,k)]
950 }m.style.color=g?g.txtColor:"";
951 m.style.backgroundColor=g?g.bgColor:"";
955 this.resetCell(this.tbody.rows[a].cells[b+this.colStart]);
958 }}this.titleMonth.innerHTML=Rico.monthAbbr(this.monthSelected);
959 this.titleYear.innerHTML=this.yearSelected;
960 if(this.todayCell){this.todayCell.innerHTML=Rico.getPhraseById("calToday",this.dateNow,Rico.monthAbbr(this.monthNow),this.yearNow,this.monthNow+1)
961 }},resetCell:function(a){a.innerHTML=" ";
962 a.className="ricoCalEmpty";
964 a.style.backgroundColor="";
966 },saveAndClose:function(g){Rico.eventStop(g);
967 var f=Rico.eventElement(g);
968 var c=f.innerHTML.replace(/ /g,"");
969 if(c==""||f.className=="ricoCalWeekNum"){return
970 }var b=parseInt(c,10);
972 }var h=new Date(this.yearSelected,this.monthSelected,b);
973 var a=Rico.formatDate(h,this.dateFmt=="ISO8601"?"yyyy-mm-dd":this.dateFmt);
974 if(this.returnValue){this.returnValue(a);
976 }},open:function(b){if(!this.bPageLoaded){return
978 this.dateNow=a.getDate();
979 this.monthNow=a.getMonth();
980 this.yearNow=a.getFullYear();
981 this.oyearSelected=-1;
982 if(typeof b=="object"){this.odateSelected=b.getDate();
983 this.omonthSelected=b.getMonth();
984 this.oyearSelected=b.getFullYear()
985 }else{if(this.dateFmt=="ISO8601"){var c=Rico.setISO8601(b);
986 if(c){this.odateSelected=c.getDate();
987 this.omonthSelected=c.getMonth();
988 this.oyearSelected=c.getFullYear()
989 }}else{if(this.re.exec(b)){var f=[RegExp.$1,RegExp.$3,RegExp.$5];
990 this.odateSelected=parseInt(f[this.dateParts.dd],10);
991 this.omonthSelected=parseInt(f[this.dateParts.mm],10)-1;
992 this.oyearSelected=parseInt(f[this.dateParts.yyyy],10);
993 if(this.oyearSelected<100){this.oyearSelected+=this.yearNow-(this.yearNow%100);
994 var e=this.options.maxDate.getFullYear();
995 while(this.oyearSelected>e){this.oyearSelected-=100
996 }}}else{if(b){alert("ERROR: invalid date passed to calendar ("+b+")")
997 }}}}if(this.oyearSelected>0){this.dateSelected=this.odateSelected;
998 this.monthSelected=this.omonthSelected;
999 this.yearSelected=this.oyearSelected
1000 }else{this.dateSelected=this.dateNow;
1001 this.monthSelected=this.monthNow;
1002 this.yearSelected=this.yearNow
1003 }this.constructCalendar();
1006 Rico.ColorPicker=function(b,a){this.initialize(b,a)
1008 Rico.ColorPicker.prototype={initialize:function(h,c){this.id=h;
1009 this.currentValue="#FFFFFF";
1010 Rico.extend(this,new Rico.Popup());
1011 Rico.extend(this.options,{showColorCode:false,cellsPerRow:18,palette:[]});
1012 var f=["00","33","66","99","CC","FF"];
1019 a++){this.options.palette.push(f[d]+f[e]+f[a])
1020 }}}Rico.extend(this.options,c||{})
1021 },atLoad:function(){this.createContainer();
1022 this.content.className="ricoColorPicker";
1023 var c=this.options.cellsPerRow;
1024 var d="<TABLE BORDER='1' CELLSPACING='1' CELLPADDING='0'>";
1026 b<this.options.palette.length;
1027 b++){if((b%c)==0){d+="<TR>"
1028 }d+='<TD BGCOLOR="#'+this.options.palette[b]+'"> </TD>';
1029 if(((b+1)>=this.options.palette.length)||(((b+1)%c)==0)){d+="</TR>"
1030 }}var a=Math.floor(c/2);
1031 if(this.options.showColorCode){d+="<TR><TD COLSPAN='"+a+"' ID='colorPickerSelectedColor'> </TD><TD COLSPAN='"+(c-a)+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue'>#FFFFFF</TD></TR>"
1032 }else{d+="<TR><TD COLSPAN='"+c+"' ID='colorPickerSelectedColor'> </TD></TR>"
1034 this.content.innerHTML=d;
1035 this.open=this.openPopup;
1036 this.close=this.closePopup;
1037 Rico.eventBind(this.container,"mouseover",Rico.eventHandle(this,"highlightColor"),false);
1038 Rico.eventBind(this.container,"click",Rico.eventHandle(this,"selectColor"),false);
1040 },selectColor:function(a){Rico.eventStop(a);
1041 if(this.returnValue){this.returnValue(this.currentValue)
1043 },highlightColor:function(b){var a=Rico.eventElement(b);
1044 if(!a.tagName||a.tagName.toLowerCase()!="td"){return
1045 }var g=Rico.Color.createColorFromBackground(a).toString();
1046 this.currentValue=g;
1047 Rico.setStyle("colorPickerSelectedColor",{backgroundColor:g});
1048 var f=Rico.$("colorPickerSelectedColorValue");
1052 Rico.registerDraggable=function(b,a){if(typeof a!="number"){a=0
1053 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1054 }Rico.dndMgrList[a].registerDraggable(b)
1056 Rico.registerDropZone=function(b,a){if(typeof a!="number"){a=0
1057 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1058 }Rico.dndMgrList[a].registerDropZone(b)
1060 Rico.dndMgr=function(){this.initialize()
1062 Rico.dndMgr.prototype={initialize:function(){this.dropZones=[];
1064 this.currentDragObjects=[];
1065 this.dragElement=null;
1066 this.lastSelectedDraggable=null;
1067 this.currentDragObjectVisible=false;
1068 this.interestedInMotionEvents=false;
1069 this._mouseDown=Rico.eventHandle(this,"_mouseDownHandler");
1070 this._mouseMove=Rico.eventHandle(this,"_mouseMoveHandler");
1071 this._mouseUp=Rico.eventHandle(this,"_mouseUpHandler")
1072 },registerDropZone:function(a){this.dropZones[this.dropZones.length]=a
1073 },deregisterDropZone:function(a){var d=new Array();
1076 c<this.dropZones.length;
1077 c++){if(this.dropZones[c]!=a){d[b++]=this.dropZones[c]
1079 },clearDropZones:function(){this.dropZones=new Array()
1080 },registerDraggable:function(a){this.draggables[this.draggables.length]=a;
1081 var b=a.getMouseDownHTMLElement();
1082 if(b!=null){b.ricoDraggable=a;
1083 Rico.eventBind(b,"mousedown",Rico.eventHandle(this,"_attachEvents"));
1084 Rico.eventBind(b,"mousedown",this._mouseDown)
1085 }},clearSelection:function(){for(var a=0;
1086 a<this.currentDragObjects.length;
1087 a++){this.currentDragObjects[a].deselect()
1088 }this.currentDragObjects=new Array();
1089 this.lastSelectedDraggable=null
1090 },hasSelection:function(){return this.currentDragObjects.length>0
1091 },setStartDragFromElement:function(a,c){this.origPos=Rico.cumulativeOffset(c);
1092 var b=Rico.eventClient(a);
1093 this.startx=b.x-this.origPos.left;
1094 this.starty=b.y-this.origPos.top;
1095 this.interestedInMotionEvents=this.hasSelection();
1097 },updateSelection:function(a,b){if(!b){this.clearSelection()
1098 }if(a.isSelected()){this.currentDragObjects=this.currentDragObjects.without(a);
1100 if(a==this.lastSelectedDraggable){this.lastSelectedDraggable=null
1102 if(a.isSelected()){this.currentDragObjects.push(a);
1103 this.lastSelectedDraggable=a
1104 }}},_mouseDownHandler:function(f){if(!Rico.eventLeftClick(f)){return
1105 }var d=Rico.eventElement(f);
1106 var a=d.ricoDraggable;
1108 while(a==null&&c.parentNode){c=c.parentNode;
1111 }this.updateSelection(a,f.ctrlKey);
1112 if(this.hasSelection()){for(var b=0;
1113 b<this.dropZones.length;
1114 b++){this.dropZones[b].clearPositionCache()
1115 }}this.setStartDragFromElement(f,a.getMouseDownHTMLElement())
1116 },_mouseMoveHandler:function(a){if(!this.interestedInMotionEvents){return
1117 }if(!this.hasSelection()){return
1118 }if(!this.currentDragObjectVisible){this._startDrag(a)
1119 }if(!this.activatedDropZones){this._activateRegisteredDropZones()
1120 }this._updateDraggableLocation(a);
1121 this._updateDropZonesHover(a);
1123 },_makeDraggableObjectVisible:function(b){if(!this.hasSelection()){return
1125 if(this.currentDragObjects.length>1){a=this.currentDragObjects[0].getMultiObjectDragGUI(this.currentDragObjects)
1126 }else{a=this.currentDragObjects[0].getSingleObjectDragGUI()
1127 }this.dragElemPosition=Rico.getStyle(a,"position");
1128 if(this.dragElemPosition!="absolute"){a.style.position="absolute"
1129 }if(a.parentNode==null||a.parentNode.nodeType==11){document.body.appendChild(a)
1130 }this.dragElement=a;
1131 this._updateDraggableLocation(b);
1132 this.currentDragObjectVisible=true
1133 },_leftOffset:function(a){return a.offsetX?document.body.scrollLeft:0
1134 },_topOffset:function(a){return a.offsetY?document.body.scrollTop:0
1135 },_updateDraggableLocation:function(b){var a=this.dragElement.style;
1136 var c=Rico.eventClient(b);
1137 a.left=(c.x+this._leftOffset(b)-this.startx)+"px";
1138 a.top=(c.y+this._topOffset(b)-this.starty)+"px"
1139 },_updateDropZonesHover:function(b){var a,c=this.dropZones.length;
1142 a++){if(!this._mousePointInDropZone(b,this.dropZones[a])){this.dropZones[a].hideHover()
1145 a++){if(this._mousePointInDropZone(b,this.dropZones[a])){if(this.dropZones[a].canAccept(this.currentDragObjects)){this.dropZones[a].showHover()
1146 }}}},_startDrag:function(b){for(var a=0;
1147 a<this.currentDragObjects.length;
1148 a++){this.currentDragObjects[a].startDrag()
1149 }this._makeDraggableObjectVisible(b)
1150 },_mouseUpHandler:function(b){if(!this.hasSelection()){return
1151 }if(!Rico.eventLeftClick(b)){return
1152 }this.interestedInMotionEvents=false;
1153 if(this._placeDraggableInDropZone(b)){this._completeDropOperation(b)
1154 }else{if(this.dragElement!=null){Rico.eventStop(b);
1156 Rico.animate(this.dragElement,{duration:300,onEnd:function(){a._doCancelDragProcessing()
1157 }},{left:this.origPos.left,top:this.origPos.top})
1158 }}Rico.eventUnbind(document.body,"mousemove",this._mouseMove);
1159 Rico.eventUnbind(document.body,"mouseup",this._mouseUp)
1160 },_retTrue:function(){return true
1161 },_completeDropOperation:function(a){if(this.dragElement!=this.currentDragObjects[0].getMouseDownHTMLElement()){if(this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1162 }}this._deactivateRegisteredDropZones();
1164 this.clearSelection();
1165 this.dragElement=null;
1166 this.currentDragObjectVisible=false;
1168 },_doCancelDragProcessing:function(){this._cancelDrag();
1169 if(this.dragElement==this.currentDragObjects[0].getMouseDownHTMLElement()){this.dragElement.style.position=this.dragElemPosition
1170 }else{if(this.dragElement&&this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1171 }}this._deactivateRegisteredDropZones();
1172 this.dragElement=null;
1173 this.currentDragObjectVisible=false
1174 },_placeDraggableInDropZone:function(c){var a=false;
1175 var d=this.dropZones.length;
1178 b++){if(this._mousePointInDropZone(c,this.dropZones[b])){if(this.dropZones[b].canAccept(this.currentDragObjects)){this.dropZones[b].hideHover();
1179 this.dropZones[b].accept(this.currentDragObjects);
1183 },_cancelDrag:function(){for(var a=0;
1184 a<this.currentDragObjects.length;
1185 a++){this.currentDragObjects[a].cancelDrag()
1186 }},_endDrag:function(){for(var a=0;
1187 a<this.currentDragObjects.length;
1188 a++){this.currentDragObjects[a].endDrag()
1189 }},_mousePointInDropZone:function(b,c){var a=c.getAbsoluteRect();
1190 var d=Rico.eventClient(b);
1191 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)
1192 },_activateRegisteredDropZones:function(){var c=this.dropZones.length;
1195 a++){var b=this.dropZones[a];
1196 if(b.canAccept(this.currentDragObjects)){b.activate()
1197 }}this.activatedDropZones=true
1198 },_deactivateRegisteredDropZones:function(){var b=this.dropZones.length;
1201 a++){this.dropZones[a].deactivate()
1202 }this.activatedDropZones=false
1203 },_attachEvents:function(){Rico.eventBind(document.body,"mousemove",this._mouseMove);
1204 Rico.eventBind(document.body,"mouseup",this._mouseUp)
1206 Rico.Draggable=function(a,b){this.initialize(a,b)
1208 Rico.Draggable.prototype={initialize:function(a,b){this.type=a;
1209 this.htmlElement=Rico.$(b);
1211 },getMouseDownHTMLElement:function(){return this.htmlElement
1212 },select:function(){this._select()
1213 },_select:function(){this.selected=true;
1214 if(this.showingSelected){return
1215 }this.showingSelected=true;
1216 var b=this.getMouseDownHTMLElement();
1217 var a=Rico.Color.createColorFromBackground(b);
1218 a.isBright()?a.darken(0.033):a.brighten(0.033);
1219 this.saveBackground=Rico.getStyle(b,"backgroundColor","background-color");
1220 b.style.backgroundColor=a.asHex()
1221 },deselect:function(){this.selected=false;
1222 if(!this.showingSelected){return
1223 }var a=this.getMouseDownHTMLElement();
1224 a.style.backgroundColor=this.saveBackground;
1225 this.showingSelected=false
1226 },isSelected:function(){return this.selected
1227 },startDrag:function(){},cancelDrag:function(){},endDrag:function(){},getSingleObjectDragGUI:function(){return this.htmlElement
1228 },getMultiObjectDragGUI:function(a){return this.htmlElement
1229 },getDroppedGUI:function(){return this.htmlElement
1230 },toString:function(){return this.type+":"+this.htmlElement+":"
1232 Rico.LiveGridDraggable=function(b,a,c){this.initialize(b,a,c)
1234 Rico.LiveGridDraggable.prototype=Rico.extend(new Rico.Draggable(),{initialize:function(b,a,c){this.type="RicoCell";
1235 this.htmlElement=b.cell(a,c);
1239 },select:function(){if(this.dragRow>=this.liveGrid.buffer.totalRows){return
1240 }this.selected=true;
1241 this.showingSelected=true
1242 },deselect:function(){this.selected=false;
1243 this.showingSelected=false
1244 },getSingleObjectDragGUI:function(){var a=document.createElement("div");
1245 a.className="LiveGridDraggable";
1246 a.style.width=(this.htmlElement.offsetWidth-10)+"px";
1247 a.innerHTML=this.htmlElement.innerHTML;
1250 Rico.Dropzone=function(a){this.initialize(a)
1252 Rico.Dropzone.prototype={initialize:function(a){this.htmlElement=Rico.$(a);
1253 this.absoluteRect=null
1254 },getHTMLElement:function(){return this.htmlElement
1255 },clearPositionCache:function(){this.absoluteRect=null
1256 },getAbsoluteRect:function(){if(this.absoluteRect==null){var a=this.getHTMLElement();
1257 var b=Rico.viewportOffset(a);
1258 this.absoluteRect={top:b.top,left:b.left,bottom:b.top+a.offsetHeight,right:b.left+a.offsetWidth}
1259 }return this.absoluteRect
1260 },activate:function(){var c=this.getHTMLElement();
1261 if(c==null||this.showingActive){return
1262 }this.showingActive=true;
1263 this.saveBackgroundColor=c.style.backgroundColor;
1265 var a=Rico.Color.createColorFromBackground(c);
1266 if(a==null){c.style.backgroundColor=b
1267 }else{a.isBright()?a.darken(0.2):a.brighten(0.2);
1268 c.style.backgroundColor=a.asHex()
1269 }},deactivate:function(){var a=this.getHTMLElement();
1270 if(a==null||!this.showingActive){return
1271 }a.style.backgroundColor=this.saveBackgroundColor;
1272 this.showingActive=false;
1273 this.saveBackgroundColor=null
1274 },showHover:function(){var a=this.getHTMLElement();
1275 if(a==null||this.showingHover){return
1276 }this.saveBorderWidth=a.style.borderWidth;
1277 this.saveBorderStyle=a.style.borderStyle;
1278 this.saveBorderColor=a.style.borderColor;
1279 this.showingHover=true;
1280 a.style.borderWidth="1px";
1281 a.style.borderStyle="solid";
1282 a.style.borderColor="#ffff00"
1283 },hideHover:function(){var a=this.getHTMLElement();
1284 if(a==null||!this.showingHover){return
1285 }a.style.borderWidth=this.saveBorderWidth;
1286 a.style.borderStyle=this.saveBorderStyle;
1287 a.style.borderColor=this.saveBorderColor;
1288 this.showingHover=false
1289 },canAccept:function(a){return true
1290 },accept:function(b){var d=this.getHTMLElement();
1295 a++){var c=b[a].getDroppedGUI();
1296 if(Rico.getStyle(c,"position")=="absolute"){c.style.position="static";
1301 Rico.KeywordSearch=function(b,a){this.initialize(b,a)
1303 Rico.KeywordSearch.prototype={initialize:function(b,a){this.id=b;
1304 Rico.extend(this,new Rico.Window(Rico.getPhraseById("keywordTitle"),a));
1305 Rico.addClass(this.content,"ricoKeywordSearch");
1306 Rico.extend(this.options,{listLength:10,maxSuggest:20,width:"12em"})
1307 },atLoad:function(){this.searchField=Rico.createFormField(this.contentDiv,"input","text",this.id+"_search");
1308 this.searchField.style.display="block";
1309 this.searchField.style.width=this.options.width;
1310 Rico.eventBind(this.searchField,"keyup",Rico.eventHandle(this,"filterKeypress"),false);
1311 this.selectList=Rico.createFormField(this.contentDiv,"select",null,this.id+"_list");
1312 this.selectList.size=this.options.listLength;
1313 this.selectList.style.display="block";
1314 this.selectList.style.width=this.options.width;
1315 Rico.eventBind(this.selectList,"change",Rico.eventHandle(this,"listClick"),false);
1316 this.close=this.closePopup;
1318 },open:function(a,b){this.column=b;
1319 this.grid=this.column.liveGrid;
1320 this.searchField.value="";
1321 this.selectList.options.length=0;
1323 this.searchField.focus();
1324 this.selectValuesRequest("")
1325 },selectValuesRequest:function(c){var d=this.column.index;
1327 Rico.extend(b,this.grid.buffer.ajaxOptions);
1328 b.parameters={id:this.grid.tableId,offset:"0",page_size:this.options.maxSuggest,edit:d};
1329 b.parameters[this.grid.actionId]="query";
1330 if(c!=""&&c!="*"){if(c.indexOf("*")==-1){c="*"+c+"*"
1331 }b.parameters["f[1][op]"]="LIKE";
1332 b.parameters["f[1][len]"]=1;
1333 b.parameters["f[1][0]"]=c
1335 b.onComplete=function(e){a.selectValuesUpdate(e)
1337 new Rico.ajaxRequest(this.grid.buffer.dataSource,b)
1338 },selectValuesUpdate:function(b){var a=b.responseXML.getElementsByTagName("ajax-response");
1339 Rico.log("selectValuesUpdate: "+b.status);
1340 if(a==null||a.length!=1){return
1342 var h=a.getElementsByTagName("error");
1343 if(h.length>0){var f=Rico.getContentAsString(h[0],this.grid.buffer.isEncoded);
1344 Rico.log("Data provider returned an error:\n"+f);
1345 alert(Rico.getPhraseById("requestError",f));
1347 }this.selectList.options.length=0;
1348 a=a.getElementsByTagName("response")[0];
1349 var g=a.getElementsByTagName("rows")[0];
1350 var j=this.grid.buffer.dom2jstable(g);
1351 Rico.log("selectValuesUpdate: id="+this.selectList.id+" rows="+j.length);
1354 d++){if(j[d].length>0){var e=j[d][0];
1355 var c=(j[d].length>1)?j[d][1]:e;
1356 Rico.addSelectOption(this.selectList,e,c)
1357 }}},filterKeypress:function(c){var a=Rico.eventElement(c);
1358 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
1359 }if(this.lastKeyFilter==a.value){return
1361 Rico.log("filterKeypress: "+this.index+" "+b);
1362 this.lastKeyFilter=b;
1363 this.selectValuesRequest(b)
1364 },listClick:function(c){var b=Rico.eventElement(c);
1365 if(b.tagName.toLowerCase()!="select"){return
1366 }if(this.returnValue){var a=b.options[b.selectedIndex];
1367 this.returnValue(a.value,a.innerHTML)
1370 Rico.TreeControl=function(c,b,a){this.initialize(c,b,a)
1372 Rico.TreeControl.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Popup());
1373 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"});
1374 Rico.extend(this.options,a||{});
1377 this.close=this.closePopup;
1378 this.hoverSet=new Rico.HoverSet([])
1379 },atLoad:function(){this.treeDiv=document.createElement("div");
1380 this.treeDiv.id=this.id;
1381 this.treeDiv.className="ricoTree";
1382 if(Rico.theme.treeContent){Rico.addClass(this.treeDiv,Rico.theme.treeContent)
1383 }this.treeDiv.style.height=this.options.height;
1384 this.treeDiv.style.width=this.options.width;
1385 this.createContainer();
1386 this.content.className=Rico.theme.tree||"ricoTreeContainer";
1387 this.content.appendChild(this.treeDiv);
1388 if(this.options.showCheckBox){this.buttonDiv=document.createElement("div");
1389 this.buttonDiv.style.width=this.options.width;
1390 this.buttonDiv.className="ricoTreeButtons";
1391 if(Rico.getStyle(this.container,"position")=="absolute"){var a=document.createElement("span");
1392 a.innerHTML=RicoTranslate.getPhraseById("treeSave");
1393 Rico.setStyle(a,{"float":"left",cursor:"pointer"});
1394 this.buttonDiv.appendChild(a);
1395 Rico.eventBind(a,"click",Rico.eventHandle(this,"saveSelection"))
1396 }var a=document.createElement("span");
1397 a.innerHTML=RicoTranslate.getPhraseById("treeClear");
1398 Rico.setStyle(a,{"float":"right",cursor:"pointer"});
1399 this.buttonDiv.appendChild(a);
1400 this.content.appendChild(this.buttonDiv);
1401 Rico.eventBind(a,"click",Rico.eventHandle(this,"clrCheckBoxEvent"))
1403 },setTreeDiv:function(a){this.treeDiv=Rico.$(a);
1404 this.openPopup=function(){}
1405 },open:function(){this.openPopup();
1406 if(this.treeDiv.childNodes.length==0&&this.dataSource){this.loadXMLDoc()
1407 }},loadXMLDoc:function(c){var b={id:this.id};
1409 }Rico.log("Tree loadXMLDoc: "+this.id);
1411 new Rico.ajaxRequest(this.dataSource,{parameters:b,method:"get",onComplete:function(d){a.processResponse(d)
1413 },domID:function(b,a){return"RicoTree_"+a+"_"+this.id+"_"+b
1414 },processResponse:function(d){var b=d.responseXML.getElementsByTagName("ajax-response");
1415 if(b==null||b.length!=1){return
1416 }var f=b[0].getElementsByTagName("rows")[0];
1417 var g=f.getElementsByTagName("tr");
1421 e++){var l=g[e].getElementsByTagName("td");
1422 if(l.length<5){continue
1424 h[5]=this.options.leafIcon;
1427 c++){h[c]=Rico.getContentAsString(l[c],true)
1428 }h[3]=h[3].match(/^0|L$/i)?0:1;
1429 h[4]=parseInt(h[4]);
1433 e++){var a=(e<k.length-1)&&(k[e][0]==k[e+1][0]);
1434 this.addNode(k[e][0],k[e][1],k[e][2],k[e][3],k[e][4],k[e][5],!a)
1435 }},addNode:function(q,l,t,f,u,s,k){var h=Rico.$(this.domID(q,"Parent"));
1436 var v=Rico.$(this.domID(q,"Children"));
1437 var a=h?h.TreeLevel+1:0;
1438 var b=document.createElement("table");
1439 var m=document.createElement("div");
1440 m.id=this.domID(l,"Children");
1441 m.className="ricoTreeBranch";
1442 m.style.display=h?"none":"";
1446 b.id=this.domID(l,"Parent");
1449 b.TreeFetchedChildren=this.dataSource?false:true;
1450 var d=b.insertRow(0);
1454 r++){g[r]=d.insertCell(-1)
1455 }if(a>1){var e=h.getElementsByTagName("td");
1458 r++){g[r].innerHTML=e[r].innerHTML
1459 }var w=document.createElement("div");
1460 w.className="rico-icon rico-tree-"+(v.nextSibling&&this.options.showLines?"nodeline":"nodeblank");
1461 g[a-2].appendChild(w)
1462 }if(a>0){var c=k&&this.options.showLines?"last":"";
1463 var o=this.options.showLines?"node":"";
1464 if(this.options.showPlusMinus&&f){var w=document.createElement("div");
1466 w.style.cursor="pointer";
1467 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1468 w.className="rico-icon rico-tree-"+o+"p"+c;
1469 d.insertCell(-1).appendChild(w)
1470 }else{if(this.options.showLines){var w=document.createElement("div");
1471 w.className="rico-icon rico-tree-node"+c;
1472 d.insertCell(-1).appendChild(w)
1473 }}if(this.options.showFolders&&(f||(s&&s!="none"))){var w=document.createElement("div");
1474 if(!f){w.className=s
1476 w.style.cursor="pointer";
1477 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1478 w.className="rico-icon rico-folderclosed"
1479 }d.insertCell(-1).appendChild(w)
1480 }}if(u&&this.options.showCheckBox){var n=document.createElement("input");
1483 d.insertCell(-1).appendChild(n)
1484 }if(u&&!this.options.showCheckBox){var p=document.createElement("a");
1485 if(typeof u=="string"){p.href=u
1486 }else{p.href="javascript:void(0)";
1487 Rico.eventBind(p,"click",this.options.defaultAction)
1488 }this.hoverSet.add(p)
1489 }else{var p=document.createElement("p")
1490 }p.id=this.domID(l,"Desc");
1491 p.className="ricoTreeLevel"+a;
1492 switch(this.options.nodeIdDisplay){case"last":t+=" ("+l+")";
1494 case"first":t=l+" - "+t;
1496 case"tooltip":p.title=l;
1498 }p.appendChild(document.createTextNode(t));
1499 d.insertCell(-1).appendChild(p);
1500 var j=v||this.treeDiv;
1503 },nodeClick:function(c){var b=Rico.eventElement(c);
1504 if(this.returnValue){var a=this.domID("","Desc");
1505 this.returnValue(b.id.substr(a.length),b.innerHTML)
1507 },saveSelection:function(a){if(this.returnValue){this.returnValue(this.getCheckedItems())
1509 },getCheckedItems:function(){var b=this.treeDiv.getElementsByTagName("input");
1513 a++){if(b[a].type=="checkbox"&&b[a].checked){c.push(b[a].value)
1515 },setCheckBoxes:function(c){var b=this.treeDiv.getElementsByTagName("input");
1518 a++){if(b[a].type=="checkbox"){b[a].checked=c
1519 }}},clrCheckBoxEvent:function(a){Rico.eventStop(a);
1520 this.setCheckBoxes(false)
1521 },clickBranch:function(h){var g=Rico.eventElement(h);
1522 var f=Rico.getParentByTagName(g,"table");
1523 if(!f||!f.TreeContainer){return
1524 }var c=f.id.split("_");
1526 var b=Rico.$(c.join("_"));
1528 if(g.tagName=="DIV"){var d=Rico.visible(b);
1529 if(g.className.match(/node(p|m)(last)?$/)){g.className=g.className.replace(/nodep|nodem/,"node"+(d?"m":"p"))
1530 }else{if(g.className.match(/folder(open|closed)$/)){g.className=g.className.replace(/folder(open|closed)/,"folder"+(d?"open":"closed"))
1531 }else{if(g.className.match(/\b(m|p)$/)){g.className=g.className.replace(/(p|m)$/,d?"m":"p")
1532 }}}}if(!f.TreeFetchedChildren){f.TreeFetchedChildren=1;
1533 this.loadXMLDoc(g.name)
1535 if(typeof Rico=="undefined"){throw ("GridCommon requires the Rico JavaScript framework")
1536 }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:[]};
1538 this.headerColCnt=0;
1539 this.headerRowIdx=0;
1540 this.tabs=new Array(2);
1541 this.thead=new Array(2);
1542 this.tbody=new Array(2)
1543 },attachMenuEvents:function(){var a;
1544 if(!this.options.menuEvent||this.options.menuEvent=="none"){return
1545 }this.hideScroll=navigator.userAgent.match(/Macintosh\b.*\b(Firefox|Camino)\b/i)||(Rico.isOpera&&parseFloat(window.opera.version())<9.5);
1546 this.options[this.options.menuEvent]=Rico.eventHandle(this,"handleMenuClick");
1547 if(this.highlightDiv){switch(this.options.highlightElem){case"cursorRow":this.attachMenu(this.highlightDiv[0]);
1549 case"cursorCell":for(a=0;
1551 a++){this.attachMenu(this.highlightDiv[a])
1555 a++){this.attachMenu(this.tbody[a])
1556 }},attachMenu:function(a){if(this.options.click){Rico.eventBind(a,"click",this.options.click,false)
1557 }if(this.options.dblclick){if(Rico.isWebKit||Rico.isOpera){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleDblClick"),false)
1558 }else{Rico.eventBind(a,"dblclick",this.options.dblclick,false)
1559 }}if(this.options.contextmenu){if(Rico.isOpera||Rico.isKonqueror){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleContextMenu"),false)
1560 }else{Rico.eventBind(a,"contextmenu",this.options.contextmenu,false)
1561 }}},handleDblClick:function(b){var a=Rico.eventElement(b);
1562 if(this.dblClickElem==a){this.options.dblclick(b)
1563 }else{this.dblClickElem=a;
1564 this.safariTimer=Rico.runLater(300,this,"clearDblClick")
1565 }},clearDblClick:function(){this.dblClickElem=null
1566 },handleContextMenu:function(c){var a;
1567 if(typeof(c.which)=="number"){a=c.which
1568 }else{if(typeof(c.button)=="number"){a=c.button
1570 }}if(a==1&&c.ctrlKey){this.options.contextmenu(c)
1571 }},cancelMenu:function(){if(this.menu){this.menu.cancelmenu()
1572 }},getColumnInfo:function(f){Rico.log("getColumnInfo: len="+f.length);
1573 if(f.length==0){return 0
1574 }this.headerRowCnt=f.length;
1577 d<this.headerRowCnt;
1580 if(d>=this.hdrCells.length){this.hdrCells[d]=[]
1585 g.colSpan=a[h].colSpan||1;
1586 if(this.options.defaultWidth<0){g.initWidth=a[h].offsetWidth
1587 }this.hdrCells[d].push(g)
1588 }if(b.id.slice(-5)=="_main"){e=this.hdrCells[d].length;
1590 }}if(!e){this.headerRowIdx=this.headerRowCnt-1;
1591 e=this.hdrCells[this.headerRowIdx].length
1592 }Rico.log("getColumnInfo: colcnt="+e);
1594 },addHeadingRow:function(g){var a=this.headerRowCnt++;
1595 this.hdrCells[a]=[];
1598 e++){var k=this.thead[e].insertRow(-1);
1599 var f="ricoLG_hdg "+this.tableId+"_hdg"+a;
1602 var b=e==0?this.options.frozenColumns:this.headerColCnt-this.options.frozenColumns;
1605 j++){var d=k.insertCell(-1);
1606 var i=Rico.wrapChildren(d,"ricoLG_col");
1607 Rico.wrapChildren(i,"ricoLG_cell");
1608 this.hdrCells[a].push({cell:d,colSpan:1})
1610 },createColumnArray:function(b){this.direction=Rico.getStyle(this.outerDiv,"direction").toLowerCase();
1611 this.align=this.direction=="rtl"?["right","left"]:["left","right"];
1612 Rico.log("createColumnArray: dir="+this.direction);
1615 e<this.headerColCnt;
1616 e++){Rico.log("createColumnArray: c="+e);
1617 var d=e<this.options.frozenColumns?0:1;
1618 var a=new Rico[b](this,e,this.hdrCells[this.headerRowIdx][e],d);
1619 this.columns.push(a);
1620 if(e>0){this.columns[e-1].next=a
1622 Rico.runLater(100,this,"insertResizers")
1623 },insertResizers:function(){if(!this.options.allowColResize){return
1625 a<this.columns.length;
1626 a++){this.columns[a].insertResizer()
1627 }},createDivs:function(){Rico.log("createDivs start");
1628 this.outerDiv=this.createDiv("outer");
1629 if(Rico.theme.gridContainer){Rico.addClass(this.outerDiv,Rico.theme.gridContainer)
1630 }if(this.outerDiv.firstChild&&this.outerDiv.firstChild.tagName&&this.outerDiv.firstChild.tagName.toUpperCase()=="TABLE"){this.structTab=this.outerDiv.firstChild;
1631 this.structTabLeft=this.structTab.rows[0].cells[0];
1632 this.structTabUR=this.structTab.rows[0].cells[1];
1633 this.structTabLR=this.structTab.rows[1].cells[0]
1634 }else{this.structTab=document.createElement("table");
1635 this.structTab.border=0;
1636 this.structTab.cellPadding=0;
1637 this.structTab.cellSpacing=0;
1638 var b=this.structTab.insertRow(-1);
1640 this.structTabLeft=b.insertCell(-1);
1641 this.structTabLeft.rowSpan=2;
1642 this.structTabLeft.style.padding="0px";
1643 this.structTabLeft.style.border="none";
1644 var d=this.structTab.insertRow(-1);
1646 this.structTabUR=b.insertCell(-1);
1647 this.structTabUR.style.padding="0px";
1648 this.structTabUR.style.border="none";
1649 this.structTabLR=d.insertCell(-1);
1650 this.structTabLR.style.padding="0px";
1651 this.structTabLR.style.border="none";
1652 this.outerDiv.appendChild(this.structTab)
1653 }Rico.addClass(this.structTab,"ricoLG_StructTab");
1654 this.frozenTabs=this.createDiv("frozenTabs",this.structTabLeft);
1655 this.innerDiv=this.createDiv("inner",this.structTabUR);
1656 this.scrollDiv=this.createDiv("scroll",this.structTabLR);
1657 this.resizeDiv=this.createDiv("resize",this.outerDiv,true);
1658 this.messagePopup=new Rico.Popup();
1659 this.messagePopup.createContainer({hideOnEscape:false,hideOnClick:false,parent:this.outerDiv});
1660 this.messagePopup.content.className="ricoLG_messageDiv";
1661 if(Rico.theme.gridMessage){Rico.addClass(this.messagePopup.content,Rico.theme.gridMessage)
1662 }this.keywordPopup=new Rico.Window("",{zIndex:-1,parent:this.outerDiv});
1663 Rico.addClass(this.keywordPopup.container,"ricoLG_keywordDiv");
1664 var a=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
1665 a.innerHTML=Rico.getPhraseById("keywordPrompt");
1666 this.keywordBox=this.keywordPopup.contentDiv.appendChild(document.createElement("input"));
1667 this.keywordBox.size=20;
1668 Rico.eventBind(this.keywordBox,"keypress",Rico.eventHandle(this,"keywordKey"),false);
1669 this.keywordPopup.contentDiv.appendChild(Rico.floatButton("Checkmark",Rico.eventHandle(this,"processKeyword")));
1670 var c=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
1671 Rico.setStyle(c,{clear:"both"});
1672 Rico.log("createDivs end")
1673 },keywordKey:function(a){switch(Rico.eventKey(a)){case 27:this.closeKeyword();
1676 case 13:this.processKeyword();
1680 },openKeyword:function(a){this.keywordCol=a;
1681 this.keywordBox.value="";
1682 this.keywordPopup.setTitle(this.columns[a].displayName);
1683 this.keywordPopup.centerPopup();
1684 this.keywordBox.focus()
1685 },closeKeyword:function(){this.keywordPopup.closePopup();
1687 },processKeyword:function(){var a=this.keywordBox.value;
1688 this.closeKeyword();
1689 this.columns[this.keywordCol].setFilterKW(a)
1690 },createDiv:function(c,a,b){var e=this.tableId+"_"+c+"Div";
1691 var d=document.getElementById(e);
1692 if(!d){d=document.createElement("div");
1694 if(a){a.appendChild(d)
1695 }}d.className="ricoLG_"+c+"Div";
1698 },baseSizeDivs:function(){this.setOtherHdrCellWidths();
1699 if(this.options.frozenColumns){Rico.show(this.tabs[0]);
1700 Rico.show(this.frozenTabs);
1701 this.hdrHt=Math.max(Rico.nan2zero(this.thead[0].offsetHeight),this.thead[1].offsetHeight);
1702 this.dataHt=Math.max(Rico.nan2zero(this.tbody[0].offsetHeight),this.tbody[1].offsetHeight);
1703 this.frzWi=this.borderWidth(this.tabs[0])
1704 }else{Rico.hide(this.tabs[0]);
1705 Rico.hide(this.frozenTabs);
1707 this.hdrHt=this.thead[1].offsetHeight;
1708 this.dataHt=this.tbody[1].offsetHeight
1710 var c=this.borderWidth(this.columns[0].dataCell);
1711 Rico.log("baseSizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
1712 Rico.log(this.tableId+" frzWi="+this.frzWi+" borderWi="+c);
1714 b<this.options.frozenColumns;
1715 b++){if(this.columns[b].visible){this.frzWi+=parseInt(this.columns[b].colWidth,10)+c
1716 }}this.scrTabWi=this.borderWidth(this.tabs[1]);
1717 this.scrTabWi0=this.scrTabWi;
1718 Rico.log("scrTabWi: "+this.scrTabWi);
1719 for(b=this.options.frozenColumns;
1720 b<this.columns.length;
1721 b++){if(this.columns[b].visible){this.scrTabWi+=parseInt(this.columns[b].colWidth,10)+c
1722 }}this.scrWi=this.scrTabWi+this.options.scrollBarWidth;
1723 if(this.sizeTo=="parent"){if(Rico.isIE){Rico.hide(this.outerDiv)
1724 }d=this.outerDiv.parentNode.offsetWidth;
1725 if(Rico.isIE){Rico.show(this.outerDiv)
1726 }}else{d=Rico.windowWidth()-this.options.scrollBarWidth-8
1727 }if(this.outerDiv.parentNode.clientWidth>0){d=Math.min(this.outerDiv.parentNode.clientWidth,d)
1728 }var a=this.frzWi+this.scrWi-d;
1729 Rico.log("baseSizeDivs "+this.tableId+": scrWi="+this.scrWi+" wiLimit="+d+" overage="+a+" clientWidth="+this.outerDiv.parentNode.clientWidth);
1730 if(a>0&&this.options.frozenColumns<this.columns.length){this.scrWi=Math.max(this.scrWi-a,this.options.minScrollWidth)
1731 }this.scrollDiv.style.width=this.scrWi+"px";
1732 this.frozenTabs.style.width=this.frzWi+"px";
1733 this.outerDiv.style.width=(this.frzWi+this.scrWi)+"px"
1734 },borderWidth:function(c){var a=Rico.nan2zero(Rico.getStyle(c,"borderLeftWidth"));
1735 var b=Rico.nan2zero(Rico.getStyle(c,"borderRightWidth"));
1736 Rico.log((c.id||c.tagName)+" borderWidth: L="+a+", R="+b);
1738 },setOtherHdrCellWidths:function(){var k,g,f,a,l,b,m,d,e,h;
1740 a<this.hdrCells.length;
1741 a++){if(a==this.headerRowIdx){continue
1742 }Rico.log("setOtherHdrCellWidths: r="+a);
1744 while(g<this.headerColCnt&&k<this.hdrCells[a].length){b=this.hdrCells[a][k];
1749 f++,g++){if(this.columns[g].hdrCell.style.display=="none"){e--
1750 }else{if(this.columns[g].hdrColDiv.style.display!="none"){l+=parseInt(this.columns[g].colWidth,10)
1751 }}}if(!b.hdrColDiv||!b.hdrCellDiv){h=m.getElementsByTagName("div");
1752 b.hdrColDiv=(h.length<1)?Rico.wrapChildren(m,"ricoLG_col"):h[0];
1753 b.hdrCellDiv=(h.length<2)?Rico.wrapChildren(b.hdrColDiv,"ricoLG_cell"):h[1]
1754 }if(e==0){m.style.display="none"
1755 }else{if(l==0){b.hdrColDiv.style.display="none";
1757 }else{m.style.display="";
1758 b.hdrColDiv.style.display="";
1760 b.hdrColDiv.style.width=l+"px"
1762 }}},initFilterImage:function(a){this.filterAnchor=document.getElementById(this.tableId+"_filterLink");
1763 if(!this.filterAnchor){return
1764 }this.filterRows=Rico.select("tr."+this.tableId+"_hdg"+a);
1765 if(this.filterRows.length!=2){return
1768 c++){d[c]=Rico.select(".ricoLG_cell",this.filterRows[c])
1769 }this.filterElements=d[0].concat(d[1]);
1770 this.saveHeight=this.filterElements[0].offsetHeight;
1771 var e=Rico.getStyle(this.filterElements[0],"paddingTop");
1772 var b=Rico.getStyle(this.filterElements[0],"paddingBottom");
1773 if(e){this.saveHeight-=parseInt(e,10)
1774 }if(b){this.saveHeight-=parseInt(b,10)
1776 this.setFilterImage(false)
1777 },toggleFilterRow:function(){if(Rico.visible(this.filterRows[0])){this.slideFilterUp()
1778 }else{this.slideFilterDown()
1779 }},setFilterImage:function(b){var a=Rico.getPhraseById((b?"show":"hide")+"FilterRow");
1780 this.filterAnchor.innerHTML='<img src="'+Rico.imgDir+"tableFilter"+(b?"Expand":"Collapse")+'.gif" alt="'+a+'" border="0">'
1781 },cell:function(a,b){return(0<=b&&b<this.columns.length&&a>=0)?this.columns[b].cell(a):null
1782 },availHt:function(){var a=Rico.cumulativeOffset(this.outerDiv);
1783 return Rico.windowHeight()-a.top-2*this.options.scrollBarWidth-15
1784 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
1785 this.hdrTabs[1].style.marginLeft=a
1786 },pluginScroll:function(){if(this.scrollPluggedIn){return
1787 }Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
1788 this.scrollPluggedIn=true
1789 },unplugScroll:function(){Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
1790 this.scrollPluggedIn=false
1791 },hideMsg:function(){this.messagePopup.closePopup()
1792 },showMsg:function(a){this.messagePopup.setContent(a);
1793 this.messagePopup.centerPopup();
1794 Rico.log("showMsg: "+a)
1795 },listInvisible:function(b){var c=[];
1797 a<this.columns.length;
1798 a++){if(!this.columns[a].visible){c.push(b?this.columns[a][b]:this.columns[a])
1800 },firstVisible:function(){for(var a=0;
1801 a<this.columns.length;
1802 a++){if(this.columns[a].visible){return a
1804 },showAll:function(){var b=this.listInvisible();
1807 a++){b[a].showColumn()
1808 }},chooseColumns:function(){this.menu.cancelmenu();
1810 if(!this.columnChooser){Rico.log("creating columnChooser");
1811 f=Rico.getStyle(this.outerDiv.offsetParent,"zIndex");
1812 if(typeof f!="number"){f=0
1813 }this.columnChooser=new Rico.Window(Rico.getPhraseById("gridChooseCols"),{zIndex:f+2,parent:this.outerDiv});
1814 Rico.addClass(this.columnChooser.container,"ricoLG_chooserDiv");
1815 c=this.columnChooser.contentDiv;
1817 a<this.columns.length;
1818 a++){b=this.columns[a];
1819 e=c.appendChild(document.createElement("div"));
1820 b.ChooserBox=Rico.createFormField(e,"input","checkbox");
1821 d=e.appendChild(document.createElement("span"));
1822 d.innerHTML=b.displayName;
1823 Rico.eventBind(b.ChooserBox,"click",Rico.eventHandle(b,"chooseColumn"),false)
1824 }}Rico.log("opening columnChooser");
1825 this.columnChooser.openPopup(1,this.hdrHt);
1827 a<this.columns.length;
1828 a++){this.columns[a].ChooserBox.checked=this.columns[a].visible;
1829 this.columns[a].ChooserBox.disabled=!this.columns[a].canHideShow()
1830 }},blankRow:function(a){for(var b=0;
1831 b<this.columns.length;
1832 b++){this.columns[b].clearCell(a)
1833 }},getExportStyles:function(a){var e=this.options.exportStyleList;
1834 var b=Rico.getStyle(a,"backgroundImage");
1835 if(!b||b=="none"){return e
1838 c++){if(e[c]!="background-color"&&e[c]!="color"){d.push(e[c])
1840 },exportStart:function(){var a,h,f,d,b,e,k,l;
1841 var g=this.getExportStyles(this.thead[0]);
1843 this.exportText="<html><head></head><body><table border='1' cellspacing='0'>";
1845 h<this.columns.length;
1846 h++){if(this.columns[h].visible){this.exportText+="<col width='"+parseInt(this.columns[h].colWidth,10)+"'>"
1847 }}this.exportText+="<thead style='display: table-header-group;'>";
1848 if(this.exportHeader){this.exportText+=this.exportHeader
1850 a<this.hdrCells.length;
1851 a++){if(this.hdrCells[a].length==0||!Rico.visible(this.hdrCells[a][0].cell.parentNode)){continue
1852 }this.exportText+="<tr>";
1854 h<this.hdrCells[a].length;
1855 h++){b=this.hdrCells[a][h];
1859 d++,f++){if(!this.columns[f].visible){e--
1860 }}if(e>0){k=Rico.select(".ricoLG_cell",b.cell);
1861 l=k&&k.length>0?k[0]:b.cell;
1862 this.exportText+="<td style='"+this.exportStyle(l,g)+"'";
1863 if(b.colSpan>1){this.exportText+=" colspan='"+e+"'"
1864 }this.exportText+=">"+Rico.getInnerText(l,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport")+"</td>"
1865 }}this.exportText+="</tr>"
1866 }this.exportText+="</thead><tbody>"
1867 },exportFinish:function(){if(this.hideMsg){this.hideMsg()
1868 }window.status=Rico.getPhraseById("exportComplete");
1869 if(this.exportRows.length>0){this.exportText+="<tr>"+this.exportRows.join("</tr><tr>")+"</tr>"
1870 }if(this.exportFooter){this.exportText+=this.exportFooter
1871 }this.exportText+="</tbody></table></body></html>";
1872 if(this.cancelMenu){this.cancelMenu()
1873 }var a=window.open("","_blank",this.options.exportWindow);
1874 if(a==null){alert(Rico.getPhraseById("disableBlocker"))
1875 }else{a.document.open();
1876 a.document.write(this.exportText);
1878 }this.exportText=undefined;
1879 this.exportRows=undefined
1880 },exportStyle:function(d,g){for(var b=0,c="";
1882 b++){try{var a=Rico.getStyle(d,g[b]);
1883 if(a){c+=g[b]+":"+a+";"
1884 }}catch(f){}}return c
1885 },getCookie:function(){var k=Rico.getCookie(this.options.cookiePrefix+this.tableId);
1887 }var f=k.split(",");
1890 g++){var a=f[g].split(":");
1891 if(a.length!=2){continue
1892 }var h=parseInt(a[0].slice(1),10);
1893 if(h<0||h>=this.columns.length){continue
1894 }var e=this.columns[h];
1895 switch(a[0].charAt(0)){case"w":e.setColWidth(a[1]);
1898 case"h":if(a[1].toLowerCase()=="true"){e.hideshow(true,true)
1899 }else{e.hideshow(false,true)
1901 case"s":if(!this.options.saveColumnInfo.sort||!e.sortable){break
1904 case"f":if(!this.options.saveColumnInfo.filter||!e.filterable){break
1905 }var d=a[1].split("~");
1906 e.filterOp=d.shift();
1908 e.filterType=Rico.ColumnConst.USERFILTER;
1911 b++){e.filterValues.push(unescape(d[b]))
1913 }}},setCookie:function(){var d=[];
1915 e<this.columns.length;
1916 e++){var c=this.columns[e];
1917 if(this.options.saveColumnInfo.width){if(c.customWidth){d.push("w"+e+":"+c.colWidth)
1918 }if(c.customVisible){d.push("h"+e+":"+c.visible)
1919 }}if(this.options.saveColumnInfo.sort){if(c.currentSort!=Rico.ColumnConst.UNSORTED){d.push("s"+e+":"+c.currentSort)
1920 }}if(this.options.saveColumnInfo.filter&&c.filterType==Rico.ColumnConst.USERFILTER){var b=[c.filterOp];
1922 a<c.filterValues.length;
1923 a++){b.push(escape(c.filterValues[a]))
1924 }d.push("f"+e+":"+b.join("~"))
1925 }}Rico.setCookie(this.options.cookiePrefix+this.tableId,d.join(","),this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
1927 Rico.ColumnConst={UNFILTERED:0,SYSTEMFILTER:1,USERFILTER:2,UNSORTED:0,SORT_ASC:"ASC",SORT_DESC:"DESC",MINWIDTH:10};
1928 Rico.TableColumnBase=function(){};
1929 Rico.TableColumnBase.prototype={baseInit:function(h,g,e,d){Rico.log("TableColumnBase.init index="+g+" tabIdx="+d);
1932 this.hideWidth=Rico.isKonqueror||Rico.isWebKit||h.headerRowCnt>1?5:2;
1933 this.options=h.options;
1935 this.hdrCell=e.cell;
1936 this.body=document.getElementsByTagName("body")[0];
1937 this.displayName=this.getDisplayName(this.hdrCell);
1938 var c=this.hdrCell.getElementsByTagName("div");
1939 this.hdrColDiv=(c.length<1)?Rico.wrapChildren(this.hdrCell,"ricoLG_col"):c[0];
1940 this.hdrCellDiv=(c.length<2)?Rico.wrapChildren(this.hdrColDiv,"ricoLG_cell"):c[1];
1941 var f=d==0?g:g-h.options.frozenColumns;
1942 this.dataCell=h.tbody[d].rows[0].cells[f];
1943 c=this.dataCell.getElementsByTagName("div");
1944 this.dataColDiv=(c.length<1)?Rico.wrapChildren(this.dataCell,"ricoLG_col"):c[0];
1945 this.mouseDownHandler=Rico.eventHandle(this,"handleMouseDown");
1946 this.mouseMoveHandler=Rico.eventHandle(this,"handleMouseMove");
1947 this.mouseUpHandler=Rico.eventHandle(this,"handleMouseUp");
1948 this.mouseOutHandler=Rico.eventHandle(this,"handleMouseOut");
1949 this.fieldName="col"+this.index;
1950 this.format={type:"text"};
1951 var b=h.options.columnSpecs[g];
1952 if(typeof b=="object"){Rico.extend(this.format,b)
1953 }Rico.addClass(this.dataColDiv,this.colClassName());
1955 if(typeof this.format.visible=="boolean"){this.visible=this.format.visible
1956 }Rico.log("TableColumn.init index="+g+" fieldName="+this.fieldName);
1957 this.sortable=typeof this.format.canSort=="boolean"?this.format.canSort:h.options.canSortDefault;
1958 this.currentSort=Rico.ColumnConst.UNSORTED;
1959 this.filterable=typeof this.format.canFilter=="boolean"?this.format.canFilter:h.options.canFilterDefault;
1960 this.filterType=Rico.ColumnConst.UNFILTERED;
1961 this.hideable=typeof this.format.canHide=="boolean"?this.format.canHide:h.options.canHideDefault;
1963 switch(typeof this.format.width){case"number":a=this.format.width;
1965 case"string":a=parseInt(this.format.width,10);
1967 default:a=e.initWidth;
1969 }a=(typeof(a)=="number")?Math.max(a,Rico.ColumnConst.MINWIDTH):h.options.defaultWidth;
1970 this.setColWidth(a);
1971 if(!this.visible){this.setDisplay("none")
1972 }},colClassName:function(){return this.format.ClassName?this.format.ClassName:this.liveGrid.tableId+"_col"+this.index
1973 },insertResizer:function(){if(this.format.noResize){return
1974 }var a=document.createElement("div");
1975 a.className="ricoLG_Resize";
1976 a.style[this.liveGrid.align[1]]="0px";
1977 this.hdrCellDiv.appendChild(a);
1978 Rico.eventBind(a,"mousedown",this.mouseDownHandler,false)
1979 },getDisplayName:function(a){var b=a.getElementsByTagName("A");
1980 if(b.length>0){return b[0].innerHTML
1981 }else{return Rico.stripTags(a.innerHTML)
1982 }},_clear:function(a){a.innerHTML=" "
1983 },clearCell:function(b){var a=this.cell(b);
1985 if(this.liveGrid.buffer&&this.liveGrid.buffer.options.acceptStyle){a.style.cssText=""
1986 }},dataTable:function(){return this.liveGrid.tabs[this.tabIdx]
1987 },numRows:function(){return this.dataColDiv.childNodes.length
1988 },clearColumn:function(){var b=this.numRows();
1991 a++){this.clearCell(a)
1992 }},cell:function(a){return this.dataColDiv.childNodes[a]
1993 },getFormattedValue:function(c,a,d,b){return Rico.getInnerText(this.cell(c),a,d,b)
1994 },setColWidth:function(a){if(typeof a=="number"){a=parseInt(a,10);
1995 if(a<Rico.ColumnConst.MINWIDTH){return
1997 }Rico.log("setColWidth "+this.index+": "+a);
1999 this.hdrColDiv.style.width=a;
2000 this.dataColDiv.style.width=a
2001 },pluginMouseEvents:function(){if(this.mousePluggedIn==true){return
2002 }Rico.eventBind(this.body,"mousemove",this.mouseMoveHandler,false);
2003 Rico.eventBind(this.body,"mouseup",this.mouseUpHandler,false);
2004 Rico.eventBind(this.body,"mouseout",this.mouseOutHandler,false);
2005 this.mousePluggedIn=true
2006 },unplugMouseEvents:function(){Rico.eventUnbind(this.body,"mousemove",this.mouseMoveHandler,false);
2007 Rico.eventUnbind(this.body,"mouseup",this.mouseUpHandler,false);
2008 Rico.eventUnbind(this.body,"mouseout",this.mouseOutHandler,false);
2009 this.mousePluggedIn=false
2010 },handleMouseDown:function(b){this.resizeStart=Rico.eventClient(b).x;
2011 this.origWidth=parseInt(this.colWidth,10);
2012 var a=Rico.positionedOffset(this.hdrCell);
2013 if(this.liveGrid.direction=="rtl"){this.edge=a.left+this.liveGrid.options.scrollBarWidth;
2014 switch(this.tabIdx){case 0:this.edge+=this.liveGrid.innerDiv.offsetWidth;
2016 case 1:this.edge-=this.liveGrid.scrollDiv.scrollLeft;
2018 }}else{this.edge=a.left+this.hdrCell.offsetWidth;
2019 if(this.tabIdx>0){this.edge+=Rico.nan2zero(this.liveGrid.tabs[0].offsetWidth)
2020 }}this.liveGrid.resizeDiv.style.left=this.edge+"px";
2021 this.liveGrid.resizeDiv.style.display="";
2022 this.liveGrid.outerDiv.style.cursor="e-resize";
2023 this.tmpHighlight=this.liveGrid.highlightEnabled;
2024 this.liveGrid.highlightEnabled=false;
2025 this.pluginMouseEvents();
2027 },handleMouseMove:function(b){var c=Rico.eventClient(b).x-this.resizeStart;
2028 var a=(this.liveGrid.direction=="rtl")?this.origWidth-c:this.origWidth+c;
2029 if(a<Rico.ColumnConst.MINWIDTH){return
2030 }this.liveGrid.resizeDiv.style.left=(this.edge+c)+"px";
2033 },handleMouseUp:function(a){this.unplugMouseEvents();
2034 Rico.log("handleMouseUp "+this.liveGrid.tableId);
2035 this.liveGrid.outerDiv.style.cursor="";
2036 this.liveGrid.resizeDiv.style.display="none";
2037 this.setColWidth(this.colWidth);
2038 this.customWidth=true;
2039 this.liveGrid.setCookie();
2040 this.liveGrid.highlightEnabled=this.tmpHighlight;
2041 this.liveGrid.sizeDivs();
2043 },handleMouseOut:function(b){var a=Rico.eventRelatedTarget(b)||b.toElement;
2044 while(a!=null&&a.nodeName.toLowerCase()!="body"){a=a.parentNode
2045 }if(a!=null&&a.nodeName.toLowerCase()=="body"){return true
2046 }this.handleMouseUp(b);
2048 },setDisplay:function(a){this.hdrCell.style.display=a;
2049 this.hdrColDiv.style.display=a;
2050 this.dataCell.style.display=a;
2051 this.dataColDiv.style.display=a
2052 },hideshow:function(b,a){this.setDisplay(b?"":"none");
2053 this.liveGrid.cancelMenu();
2055 this.customVisible=true;
2057 }this.liveGrid.setCookie();
2058 this.liveGrid.sizeDivs()
2059 },hideColumn:function(){Rico.log("hideColumn "+this.liveGrid.tableId);
2060 this.hideshow(false,false)
2061 },showColumn:function(){Rico.log("showColumn "+this.liveGrid.tableId);
2062 this.hideshow(true,false)
2063 },chooseColumn:function(b){var a=Rico.eventElement(b);
2064 this.hideshow(a.checked,false)
2065 },setImage:function(){if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.imgSort.style.display="inline-block";
2066 this.imgSort.className=Rico.theme.sortAsc||"rico-icon ricoLG_sortAsc"
2067 }else{if(this.currentSort==Rico.ColumnConst.SORT_DESC){this.imgSort.style.display="inline-block";
2068 this.imgSort.className=Rico.theme.sortDesc||"rico-icon ricoLG_sortDesc"
2069 }else{this.imgSort.style.display="none"
2070 }}if(this.filterType==Rico.ColumnConst.USERFILTER){this.imgFilter.style.display="inline-block";
2071 this.imgFilter.title=this.getFilterText()
2072 }else{this.imgFilter.style.display="none"
2073 }},canHideShow:function(){return this.hideable
2075 if(typeof Rico=="undefined"){throw ("SimpleGrid requires the Rico JavaScript framework")
2076 }Rico.SimpleGrid=function(b,a){this.initialize(b,a)
2078 Rico.SimpleGrid.prototype={initialize:function(b,a){Rico.extend(this,Rico.GridCommon);
2080 Rico.setDebugArea(b+"_debugmsgs");
2081 Rico.extend(this.options,a||{});
2083 Rico.log("SimpleGrid initialize start: "+b);
2085 this.hdrTabs=new Array(2);
2086 this.simpleGridInit();
2087 Rico.log("SimpleGrid initialize end: "+b)
2088 },simpleGridInit:function(){var a;
2091 a++){Rico.log("simpleGridInit "+a);
2092 this.tabs[a]=Rico.$(this.tableId+"_tab"+a);
2093 if(!this.tabs[a]){return
2094 }this.hdrTabs[a]=Rico.$(this.tableId+"_tab"+a+"h");
2095 if(!this.hdrTabs[a]){return
2096 }this.thead[a]=this.hdrTabs[a];
2097 this.tbody[a]=this.tabs[a];
2098 this.headerColCnt=this.getColumnInfo(this.hdrTabs[a].rows);
2099 if(a==0){this.options.frozenColumns=this.headerColCnt
2100 }if(Rico.theme.gridheader){Rico.addClass(this.thead[a],Rico.theme.gridheader)
2101 }if(Rico.theme.gridcontent){Rico.addClass(this.tbody[a],Rico.theme.gridcontent)
2102 }}if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2104 }this.createColumnArray("SimpleGridColumn");
2105 this.pageSize=this.columns[0].dataColDiv.childNodes.length;
2107 if(typeof(this.options.FilterLocation)=="number"){this.createFilters(this.options.FilterLocation)
2108 }this.attachMenuEvents();
2109 this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2110 this.pluginScroll();
2111 if(this.options.windowResize){Rico.eventBind(window,"resize",Rico.eventHandle(this,"sizeDivs"),false)
2112 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
2113 },createFilters:function(a){if(a<0){a=this.addHeadingRow();
2116 g<this.headerColCnt;
2117 g++){var d=this.columns[g];
2119 if(typeof e.filterUI!="string"){continue
2120 }var k=this.hdrCells[a][g].cell;
2121 var j,b=this.filterId(g);
2122 var h=k.getElementsByTagName("div");
2123 switch(e.filterUI.charAt(0)){case"t":j=Rico.createFormField(h[1],"input","text",b,b);
2124 var m=e.filterUI.match(/\d+/);
2125 j.maxLength=e.Length||50;
2126 j.size=m?parseInt(m,10):10;
2127 Rico.eventBind(j,"keyup",Rico.eventHandle(d,"filterKeypress"),false);
2129 case"s":j=Rico.createFormField(h[1],"select",null,b);
2130 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
2131 this.getFilterValues(d);
2132 var l=Rico.keys(d.filterHash);
2136 f++){Rico.addSelectOption(j,l[f],l[f]||Rico.getPhraseById("filterBlank"))
2137 }Rico.eventBind(j,"change",Rico.eventHandle(d,"filterChange"),false);
2139 }}this.initFilterImage(a)
2140 },getFilterValues:function(b){var e={};
2144 c++){var a=Rico.getInnerText(b.cell(c));
2149 },applyFilters:function(){var b=[];
2151 f<this.columns.length;
2152 f++){if(this.columns[f].filterRows){b.push(this.columns[f].filterRows)
2153 }}if(b.length==0){this.showAllRows();
2160 a++){if(b[a].indexOf(d)==-1){e=false;
2162 }}if(e){this.showRow(d)
2163 }else{this.hideRow(d)
2165 },handleScroll:function(b){var a=(-this.scrollDiv.scrollTop)+"px";
2166 this.tabs[0].style.marginTop=a;
2167 this.setHorizontalScroll()
2168 },registerScrollMenu:function(a){if(!this.menu){this.menu=a
2170 a.showmenu=a.showSimpleMenu;
2171 a.showSubMenu=a.showSimpleSubMenu;
2172 a.createDiv(this.outerDiv)
2173 },handleMenuClick:function(a){if(!this.menu){return
2175 this.menuCell=Rico.getParentByTagName(Rico.eventElement(a),"div");
2176 this.highlightEnabled=false;
2177 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
2178 }if(this.menu.buildGridMenu){this.menu.buildGridMenu(this.menuCell)
2179 }this.menu.showmenu(a,this.closeMenu.bind(this))
2180 },closeMenu:function(){if(this.hideScroll){this.scrollDiv.style.overflow=""
2181 }this.highlightEnabled=true
2182 },sizeDivs:function(){if(this.outerDiv.offsetParent.style.display=="none"){return
2183 }this.baseSizeDivs();
2184 var c=Math.max(this.options.maxHt||this.availHt(),50);
2185 var b=Math.min(this.hdrHt+this.dataHt,c);
2186 Rico.log("sizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
2187 this.dataHt=b-this.hdrHt;
2188 if(this.scrWi>0){this.dataHt+=this.options.scrollBarWidth
2189 }this.scrollDiv.style.height=this.dataHt+"px";
2190 this.frozenTabs.style.height=this.scrollDiv.clientHeight+"px";
2192 this.innerDiv.style.width=(this.scrWi-this.options.scrollBarWidth+a)+"px";
2194 this.resizeDiv.style.height=b+"px";
2196 },printVisible:function(){this.showMsg(Rico.getPhraseById("exportInProgress"));
2197 Rico.runLater(10,this,"_printVisible")
2198 },_printVisible:function(){this.exportStart();
2199 var f=this.getExportStyles(this.tbody[0]);
2202 e++){if(this.columns[0].cell(e).style.display=="none"){continue
2205 g<this.columns.length;
2206 g++){var b=this.columns[g];
2207 if(b.visible){var a=b.getFormattedValue(e,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport");
2208 if(b.format.exportPrefix){a=b.format.exportPrefix+a
2209 }if(a==""){a=" "
2210 }d+="<td style='"+this.exportStyle(b.cell(e),f)+"'>"+a+"</td>"
2211 }}this.exportRows.push(d)
2212 }this.exportFinish()
2213 },hideRow:function(a){if(this.columns[0].cell(a).style.display=="none"){return
2215 b<this.columns.length;
2216 b++){this.columns[b].cell(a).style.display="none"
2217 }},showRow:function(a){if(this.columns[0].cell(a).style.display==""){return
2219 b<this.columns.length;
2220 b++){this.columns[b].cell(a).style.display=""
2221 }},searchRows:function(h,e,c){if(!e){return
2222 }var f=new RegExp(e);
2223 var d=this.columns[h].numRows();
2226 g++){var b=this.cell(g,h).innerHTML;
2227 var a=(b.match(f)!=null);
2228 if(a!=c){this.hideRow(g)
2231 },showAllRows:function(){for(var a=0;
2233 a++){this.showRow(a)
2235 },openPopup:function(d,e){while(d&&!Rico.hasClass(d,"ricoLG_cell")){d=d.parentNode
2236 }if(!d){return false
2237 }var f=Rico.getParentByTagName(d,"td");
2238 var c=Math.floor(f.offsetLeft-this.scrollDiv.scrollLeft+f.offsetWidth/2);
2239 if(this.direction=="rtl"){if(c>this.width){c-=this.width
2240 }}else{if(c+this.width+this.options.margin>this.scrollDiv.clientWidth){c-=this.width
2241 }}e.divPopup.style.visibility="hidden";
2242 e.divPopup.style.display="block";
2243 var b=e.divPopup.offsetHeight;
2244 var a=Math.floor(d.offsetTop-this.scrollDiv.scrollTop+d.offsetHeight/2);
2245 if(a+b+e.options.margin>this.scrollDiv.clientHeight){a=Math.max(a-b,0)
2246 }e.openPopup(this.frzWi+c,this.hdrHt+a);
2247 e.divPopup.style.visibility="visible";
2250 if(Rico.Menu){Rico.extend(Rico.Menu.prototype,{showSimpleMenu:function(b,c){Rico.eventStop(b);
2252 if(this.div.childNodes.length==0){this.cancelmenu();
2254 }var a=Rico.eventElement(b);
2255 this.grid.openPopup(a,this);
2257 },showSimpleSubMenu:function(b,c){if(this.openSubMenu){this.hideSubMenu()
2258 }this.openSubMenu=c;
2259 this.openMenuAnchor=b;
2260 if(b.className=="ricoSubMenu"){b.className="ricoSubMenuOpen"
2261 }var e=parseInt(this.div.style.top,10);
2262 var d=parseInt(this.div.style.left,10);
2263 c.openPopup(d+b.offsetWidth,e+b.offsetTop);
2264 c.div.style.visibility="visible"
2266 }Rico.SimpleGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
2268 Rico.SimpleGridColumn.prototype={initialize:function(a,d,c,b){Rico.extend(this,new Rico.TableColumnBase());
2269 this.baseInit(a,d,c,b)
2270 },setUnfiltered:function(){this.filterRows=null
2271 },filterChange:function(a){var b=Rico.eventElement(a);
2272 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
2273 }else{this.filterRows=this.filterHash[b.value]
2274 }this.liveGrid.applyFilters()
2275 },filterKeypress:function(f){var a=Rico.eventElement(f);
2276 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
2277 }if(this.lastKeyFilter==a.value){return
2279 Rico.log("filterKeypress: "+this.index+" "+b);
2280 this.lastKeyFilter=b;
2281 if(b){b=b.replace("\\","\\\\");
2282 b=b.replace("(","\\(").replace(")","\\)");
2283 b=b.replace(".","\\.");
2284 if(this.format.filterUI.indexOf("^")>0){b="^"+b
2285 }var d=new RegExp(b,"i");
2287 var h=this.numRows();
2290 c++){var g=Rico.getInnerText(this.cell(c));
2291 if(g.match(d)){this.filterRows.push(c)
2292 }}}else{this.setUnfiltered()
2293 }this.liveGrid.applyFilters()
2295 if(typeof Rico=="undefined"){throw ("LiveGrid requires the Rico JavaScript framework")
2296 }if(!Rico.Buffer){Rico.Buffer={}
2297 }Rico.Buffer.Base=function(b,a){this.initialize(b,a)
2299 Rico.Buffer.Base.prototype={initialize:function(b,a){this.clear();
2300 this.updateInProgress=false;
2302 this.rcvdRowCount=false;
2303 this.foundRowCount=false;
2305 this.rowcntContent="";
2307 this.options={fixedHdrRows:0,canFilter:true,isEncoded:true,acceptStyle:false};
2308 Rico.extend(this.options,a||{});
2309 if(b){this.loadRowsFromTable(b,this.options.fixedHdrRows);
2310 b.parentNode.removeChild(b)
2312 }},registerGrid:function(a){this.liveGrid=a
2313 },setTotalRows:function(a){if(typeof(a)!="number"){a=this.size
2314 }if(this.totalRows==a){return
2316 if(!this.liveGrid){return
2317 }Rico.log("setTotalRows, newTotalRows="+a);
2318 switch(this.liveGrid.sizeTo){case"data":this.liveGrid.resizeWindow();
2320 case"datamax":this.liveGrid.setPageSize(a);
2322 default:this.liveGrid.updateHeightDiv();
2324 }},loadRowsFromTable:function(h,g){var e=[];
2325 var a=h.getElementsByTagName("tr");
2329 var c=a[d].getElementsByTagName("td");
2332 b++){f[b]=c[b].innerHTML
2335 },loadRowsFromArray:function(b){for(var c=0;
2339 a++){b[c][a]=b[c][a].toString()
2341 },loadRows:function(a){this.baseRows=a;
2343 this.size=this.baseRows.length
2344 },dom2jstable:function(f){Rico.log("dom2jstable: encoded="+this.options.isEncoded);
2346 var a=f.getElementsByTagName("tr");
2350 var c=a[d].getElementsByTagName("td");
2353 b++){g[b]=Rico.getContentAsString(c[b],this.options.isEncoded)
2356 },_blankRow:function(){var a=[];
2358 b<this.liveGrid.columns.length;
2361 },deleteRows:function(b,a){this.baseRows.splice(b,typeof(a)=="number"?a:1);
2362 this.liveGrid.isPartialBlank=true;
2363 this.size=this.baseRows.length
2364 },insertRow:function(a){var b=this._blankRow();
2365 this.baseRows.splice(a,0,b);
2366 this.size=this.baseRows.length;
2367 this.liveGrid.isPartialBlank=true;
2368 if(this.startPos<0){this.startPos=0
2370 },appendRows:function(b){var c=[];
2373 a++){var d=this._blankRow();
2374 this.baseRows.push(d);
2376 }this.size=this.baseRows.length;
2377 this.liveGrid.isPartialBlank=true;
2378 if(this.startPos<0){this.startPos=0
2380 },sortFunc:function(b){var a=this;
2381 switch(b){case"number":return function(d,c){return a._sortNumeric(d,c)
2383 case"control":return function(d,c){return a._sortControl(d,c)
2385 default:return function(d,c){return a._sortAlpha(d,c)
2387 }},sortBuffer:function(b){if(!this.baseRows){this.delayedSortCol=b;
2389 }this.liveGrid.showMsg(Rico.getPhraseById("sorting"));
2391 var a=this.liveGrid.columns[b];
2392 this.getValFunc=a._sortfunc;
2393 this.baseRows.sort(this.sortFunc(a.format.type));
2394 if(a.getSortDirection()=="DESC"){this.baseRows.reverse()
2395 }},_sortAlpha:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2396 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2400 },_sortNumeric:function(d,c){var e=this.sortColumn<d.length?this.nan2zero(Rico.getInnerText(d[this.sortColumn])):0;
2401 var f=this.sortColumn<c.length?this.nan2zero(Rico.getInnerText(c[this.sortColumn])):0;
2403 },nan2zero:function(a){if(typeof(a)=="string"){a=parseFloat(a)
2404 }return isNaN(a)||typeof(a)=="undefined"?0:a
2405 },_sortControl:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2406 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2407 if(this.getValFunc){e=this.getValFunc(e);
2408 f=this.getValFunc(f)
2412 },clear:function(){this.baseRows=[];
2417 },isInRange:function(a){var b=Math.min(this.totalRows,a+this.liveGrid.pageSize);
2418 return(a>=this.startPos)&&(b<=this.endPos())
2419 },endPos:function(){return this.startPos+this.rows.length
2420 },fetch:function(a){Rico.log("fetch "+this.liveGrid.tableId+": offset="+a);
2421 this.applyFilters();
2422 this.setTotalRows();
2423 this.rcvdRowCount=true;
2424 this.foundRowCount=true;
2426 }this.liveGrid.refreshContents(a);
2428 },visibleRows:function(){return this.rows.slice(this.windowStart,this.windowEnd)
2429 },setWindow:function(b,a){this.windowStart=b-this.startPos;
2430 Rico.log("setWindow "+this.liveGrid.tableId+": "+b+", "+a+", newstart="+this.windowStart);
2431 this.windowEnd=Math.min(a,this.size);
2433 },isVisible:function(a){return a<this.rows.length&&a>=this.windowStart&&a<this.windowEnd
2434 },bufferRow:function(a){return this.windowStart+a
2435 },getWindowCell:function(c,b){var a=this.bufferRow(c);
2436 return this.isVisible(a)&&b<this.rows[a].length?this.rows[a][b]:null
2437 },getWindowStyle:function(c,b){var a=this.bufferRow(c);
2438 return this.attr&&this.isVisible(a)&&b<this.attr[a].length?this.attr[a][b]:""
2439 },getWindowValue:function(b,a){return this.getWindowCell(b,a)
2440 },setWindowValue:function(d,b,c){var a=this.bufferRow(d);
2441 if(a>=this.windowEnd){return false
2442 }return this.setValue(a,b,c)
2443 },getCell:function(b,a){return b<this.size?this.rows[b][a]:null
2444 },getValue:function(b,a){return this.getCell(b,a)
2445 },setValue:function(d,b,c,a){if(d>=this.size){return false
2446 }if(!this.rows[d][b]){this.rows[d][b]={}
2448 if(typeof a=="string"){this.rows[d][b]._style=a
2449 }this.rows[d][b].modified=true;
2451 },getRows:function(f,d){var e=f-this.startPos;
2452 var a=Math.min(e+d,this.size);
2456 b++){c.push(this.rows[b])
2458 },applyFilters:function(){var g=[],k=[];
2460 var j=this.liveGrid.columns;
2464 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2466 if(h.filterOp=="LIKE"){k[d]=new RegExp(h.filterValues[0],"i")
2467 }}Rico.log("applyFilters: # of filters="+b);
2468 if(b==0){this.rows=this.baseRows
2470 a<this.baseRows.length;
2475 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2476 }switch(h.filterOp){case"LIKE":f=k[d].test(this.baseRows[a][d]);
2478 case"EQ":f=this.baseRows[a][d]==h.filterValues[0];
2481 e<h.filterValues.length&&f;
2482 e++){f=this.baseRows[a][d]!=h.filterValues[e]
2484 case"LE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])<=this.nan2zero(h.filterValues[0])
2485 }else{f=this.baseRows[a][d]<=h.filterValues[0]
2487 case"GE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])>=this.nan2zero(h.filterValues[0])
2488 }else{f=this.baseRows[a][d]>=h.filterValues[0]
2490 case"NULL":f=this.baseRows[a][d]=="";
2492 case"NOTNULL":f=this.baseRows[a][d]!="";
2494 }}if(f){g.push(this.baseRows[a])
2496 }this.rowcntContent=this.size=this.rows.length
2497 },printAll:function(){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2498 Rico.runLater(10,this,"_printAll")
2499 },_printAll:function(){this.liveGrid.exportStart();
2500 this.exportBuffer(this.getRows(0,this.totalRows));
2501 this.liveGrid.exportFinish()
2502 },printVisible:function(){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2503 Rico.runLater(10,this,"_printVisible")
2504 },_printVisible:function(){this.liveGrid.exportStart();
2505 this.exportBuffer(this.visibleRows());
2506 this.liveGrid.exportFinish()
2507 },exportBuffer:function(l,f){var a,g,k,b,j;
2508 Rico.log("exportBuffer: "+l.length+" rows");
2509 var e=this.liveGrid.getExportStyles(this.liveGrid.tbody[0]);
2512 var h=this.liveGrid.columns;
2515 g++){if(h[g].visible){i[g]=this.liveGrid.exportStyle(h[g].cell(0),e)
2521 g++){if(!h[g].visible){continue
2524 k=b._export(l[a][g],l[a]);
2525 if(k==""){k=" "
2526 }j+="<td style='"+b.expStyle+"'>"+k+"</td>"
2527 }this.liveGrid.exportRows.push(j);
2529 if(d%10==0){window.status=Rico.getPhraseById("exportStatus",d)
2531 Rico.LiveGrid=function(c,a,b){this.initialize(c,a,b)
2533 Rico.LiveGrid.prototype={initialize:function(e,b,d){Rico.extend(this,Rico.GridCommon);
2534 Rico.extend(this,Rico.LiveGridMethods);
2538 this.actionId="_action_"+e;
2539 Rico.setDebugArea(e+"_debugmsgs");
2540 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});
2542 this.options.sortHandler=function(){c.sortHandler()
2544 this.options.filterHandler=function(){c.filterHandler()
2546 this.options.onRefreshComplete=function(f,g){c.bookmarkHandler(f,g)
2548 this.options.rowOverHandler=Rico.eventHandle(this,"rowMouseOver");
2549 this.options.mouseDownHandler=Rico.eventHandle(this,"selectMouseDown");
2550 this.options.mouseOverHandler=Rico.eventHandle(this,"selectMouseOver");
2551 this.options.mouseUpHandler=Rico.eventHandle(this,"selectMouseUp");
2552 Rico.extend(this.options,d||{});
2553 switch(typeof this.options.visibleRows){case"string":this.sizeTo=this.options.visibleRows;
2554 switch(this.options.visibleRows){case"data":this.options.visibleRows=-2;
2556 case"body":this.options.visibleRows=-3;
2558 case"parent":this.options.visibleRows=-4;
2560 case"datamax":this.options.visibleRows=-5;
2562 default:this.options.visibleRows=-1;
2565 case"number":switch(this.options.visibleRows){case -1:this.sizeTo="window";
2567 case -2:this.sizeTo="data";
2569 case -3:this.sizeTo="body";
2571 case -4:this.sizeTo="parent";
2573 case -5:this.sizeTo="datamax";
2575 default:this.sizeTo="fixed";
2578 default:this.sizeTo="body";
2579 this.options.visibleRows=-3;
2581 }this.highlightEnabled=this.options.highlightSection>0;
2583 this.createTables();
2584 if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2586 }this.createColumnArray("LiveGridColumn");
2587 if(this.options.headingSort=="hover"){this.createHoverSet()
2588 }this.bookmark=document.getElementById(this.tableId+"_bookmark");
2591 if(this.buffer.options.canFilter&&this.options.AutoFilter){a=this.addHeadingRow("ricoLG_FilterRow")
2592 }this.createDataCells(this.options.visibleRows);
2593 if(this.pageSize==0){return
2594 }this.buffer.registerGrid(this);
2595 if(this.buffer.setBufferSize){this.buffer.setBufferSize(this.pageSize)
2596 }this.scrollTimeout=null;
2597 this.lastScrollPos=0;
2598 this.attachMenuEvents();
2599 this.setSortUI(this.options.sortCol,this.options.sortDir);
2601 if(this.listInvisible().length==this.columns.length){this.columns[0].showColumn()
2603 this.scrollDiv.style.display="";
2604 if(this.buffer.totalRows>0){this.updateHeightDiv()
2605 }if(this.options.prefetchBuffer){if(this.bookmark){this.bookmark.innerHTML=Rico.getPhraseById("bookmarkLoading")
2606 }if(this.options.canFilterDefault&&this.options.getQueryParms){this.checkForFilterParms()
2607 }this.scrollToRow(this.options.offset);
2608 this.buffer.fetch(this.options.offset)
2609 }if(a>=0){this.createFilters(a)
2610 }this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2611 this.wheelEventFunc=Rico.eventHandle(this,"handleWheel");
2612 this.wheelEvent=(Rico.isIE||Rico.isOpera||Rico.isWebKit)?"mousewheel":"DOMMouseScroll";
2613 if(this.options.offset&&this.options.offset<this.buffer.totalRows){Rico.runLater(50,this,"scrollToRow",this.options.offset)
2614 }this.pluginScroll();
2615 this.setHorizontalScroll();
2616 Rico.log("setHorizontalScroll done");
2617 if(this.options.windowResize){Rico.runLater(100,this,"pluginWindowResize")
2618 }Rico.log("initialize complete for "+this.tableId)
2620 Rico.LiveGridMethods={createHoverSet:function(){var a=[];
2622 b<this.headerColCnt;
2623 b++){if(this.columns[b].sortable){a.push(this.columns[b].hdrCellDiv)
2624 }}this.hoverSet=new Rico.HoverSet(a)
2625 },checkForFilterParms:function(){var b=window.location.search;
2626 if(b.charAt(0)=="?"){b=b.substring(1)
2627 }var c=b.split("&");
2630 a++){if(c[a].match(/^f\[\d+\]/)){this.buffer.options.requestParameters.push(c[a])
2631 }}},drillDown:function(g,f,h){var b=Rico.eventElement(g||window.event);
2632 b=Rico.getParentByTagName(b,"div","ricoLG_cell");
2634 }var a=this.winCellIndex(b);
2635 if(a.row>=this.buffer.totalRows){return -1
2636 }this.unhighlight();
2639 var c=this.buffer.getWindowCell(a.row,f);
2642 d++){arguments[d].setDetailFilter(h,c)
2644 },setDetailFilter:function(a,d){var b=this.columns[a];
2646 b.setSystemFilter("EQ",d)
2647 },createTables:function(){var f,g,b;
2648 var e=document.getElementById(this.tableId)||document.getElementById(this.tableId+"_outerDiv");
2650 }if(e.tagName.toLowerCase()=="table"){var a=e.getElementsByTagName("thead");
2651 if(a.length==1){Rico.log("createTables: using thead section, id="+this.tableId);
2652 if(this.options.ColGroupsOnTabHdr&&this.options.ColGroups){var d=a[0].insertRow(0);
2653 this.insertPanelNames(d,0,this.options.frozenColumns,"ricoFrozen");
2654 this.insertPanelNames(d,this.options.frozenColumns,this.options.columnSpecs.length)
2656 }else{Rico.log("createTables: using tbody section, id="+this.tableId);
2657 g=new Array(e.rows[0])
2659 }else{if(this.options.columnSpecs.length>0){if(!e.id.match(/_outerDiv$/)){f=e
2660 }Rico.log("createTables: inserting at "+e.tagName+", id="+this.tableId)
2661 }else{alert("ERROR!\n\nUnable to initialize '"+this.tableId+"'\n\nLiveGrid terminated");
2663 }}this.createDivs();
2664 this.scrollContainer=this.createDiv("scrollContainer",this.structTabLR);
2665 this.scrollContainer.appendChild(this.scrollDiv);
2666 this.scrollTab=this.createDiv("scrollTab",this.scrollContainer);
2667 this.shadowDiv=this.createDiv("shadow",this.scrollDiv);
2668 this.shadowDiv.style.direction="ltr";
2669 this.scrollDiv.style.display="none";
2670 this.scrollDiv.scrollTop=0;
2671 if(this.options.highlightMethod!="class"){this.highlightDiv=[];
2672 switch(this.options.highlightElem){case"menuRow":case"cursorRow":this.highlightDiv[0]=this.createDiv("highlight",this.outerDiv);
2673 this.highlightDiv[0].style.display="none";
2675 case"menuCell":case"cursorCell":for(b=0;
2677 b++){this.highlightDiv[b]=this.createDiv("highlight",b==0?this.frozenTabs:this.scrollTab);
2678 this.highlightDiv[b].style.display="none";
2679 this.highlightDiv[b].id+=b
2681 case"selection":var h=this.options.highlightSection==1?this.frozenTabs:this.scrollTab;
2684 b++){this.highlightDiv[b]=this.createDiv("highlight",h);
2685 this.highlightDiv[b].style.display="none";
2686 this.highlightDiv[b].style.overflow="hidden";
2687 this.highlightDiv[b].id+=b;
2688 this.highlightDiv[b].style[b%2==0?"height":"width"]="0px"
2692 b++){this.tabs[b]=document.createElement("table");
2693 this.tabs[b].className=(b<2)?"ricoLG_table":"ricoLG_scrollTab";
2694 this.tabs[b].border=0;
2695 this.tabs[b].cellPadding=0;
2696 this.tabs[b].cellSpacing=0;
2697 this.tabs[b].id=this.tableId+"_tab"+b
2700 b++){this.thead[b]=this.tabs[b].createTHead();
2701 this.thead[b].className="ricoLG_top";
2702 if(Rico.theme.gridheader){Rico.addClass(this.thead[b],Rico.theme.gridheader)
2705 b++){this.tbody[b]=Rico.getTBody(this.tabs[b==0?0:2]);
2706 this.tbody[b].className="ricoLG_bottom";
2707 if(Rico.theme.gridcontent){Rico.addClass(this.tbody[b],Rico.theme.gridcontent)
2708 }this.tbody[b].insertRow(-1)
2709 }this.frozenTabs.appendChild(this.tabs[0]);
2710 this.innerDiv.appendChild(this.tabs[1]);
2711 this.scrollTab.appendChild(this.tabs[2]);
2712 if(f){f.parentNode.insertBefore(this.outerDiv,f)
2713 }if(g){this.headerColCnt=this.getColumnInfo(g);
2715 }else{this.createHdr(0,0,this.options.frozenColumns);
2716 this.createHdr(1,this.options.frozenColumns,this.options.columnSpecs.length);
2717 if(this.options.ColGroupsOnTabHdr&&this.options.ColGroups){this.insertPanelNames(this.thead[0].insertRow(0),0,this.options.frozenColumns);
2718 this.insertPanelNames(this.thead[1].insertRow(0),this.options.frozenColumns,this.options.columnSpecs.length)
2721 b++){this.headerColCnt=this.getColumnInfo(this.thead[b].rows)
2723 j<this.headerColCnt;
2724 j++){this.tbody[j<this.options.frozenColumns?0:1].rows[0].insertCell(-1)
2725 }if(f){e.parentNode.removeChild(e)
2726 }Rico.log("createTables end");
2728 },createDataCells:function(d){if(d<0){for(var a=0;
2729 a<this.options.minPageRows;
2730 a++){this.appendBlankRow()
2732 this.autoAppendRows(this.remainingHt())
2735 c++){this.appendBlankRow()
2736 }}var b=this.options.highlightSection;
2737 if(b&1){this.attachHighlightEvents(this.tbody[0])
2738 }if(b&2){this.attachHighlightEvents(this.tbody[1])
2739 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
2740 },createFilters:function(b){for(var h=0;
2741 h<this.headerColCnt;
2742 h++){var e=this.columns[h];
2744 if(typeof f.filterUI!="string"){continue
2745 }var l=this.hdrCells[b][h].cell;
2746 var j,d=this.filterId(h);
2747 var i=l.getElementsByTagName("div");
2748 var g=Rico.getStyle(this.cell(0,h),"textAlign");
2749 i[1].style.textAlign=g;
2750 switch(f.filterUI.charAt(0)){case"t":j=Rico.createFormField(i[1],"input",Rico.inputtypes.search?"search":"text",d,d);
2751 var n=f.filterUI.match(/\d+/);
2752 j.maxLength=f.Length||50;
2753 j.size=n?parseInt(n,10):10;
2754 if(j.type!="search"){i[1].appendChild(Rico.clearButton(Rico.eventHandle(e,"filterClear")))
2755 }if(e.filterType==Rico.ColumnConst.USERFILTER&&e.filterOp=="LIKE"){var k=e.filterValues[0];
2756 if(k.charAt(0)=="*"){k=k.substr(1)
2757 }if(k.slice(-1)=="*"){k=k.slice(0,-1)
2760 }Rico.eventBind(j,"keyup",Rico.eventHandle(e,"filterKeypress"),false);
2763 case"m":case"s":j=Rico.createFormField(i[1],"select",null,d);
2764 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
2767 Rico.extend(m,this.buffer.ajaxOptions);
2768 var a=typeof(f.filterCol)=="number"?f.filterCol:h;
2769 m.parameters={id:this.tableId,distinct:a};
2770 m.parameters[this.actionId]="query";
2771 m.onComplete=this.filterValuesUpdateFunc(h);
2772 new Rico.ajaxRequest(this.buffer.dataSource,m);
2774 case"c":if(typeof e._createFilters=="function"){e._createFilters(i[1],d)
2776 }}this.initFilterImage(b)
2777 },filterValuesUpdateFunc:function(b){var a=this;
2778 return function(c){a.filterValuesUpdate(b,c)
2780 },filterValuesUpdate:function(a,g){var f=g.responseXML.getElementsByTagName("ajax-response");
2781 Rico.log("filterValuesUpdate: "+g.status);
2782 if(f==null||f.length!=1){return false
2784 var n=f.getElementsByTagName("error");
2785 if(n.length>0){Rico.log("Data provider returned an error:\n"+Rico.getContentAsString(n[0],this.buffer.isEncoded));
2786 alert(Rico.getPhraseById("requestError",Rico.getContentAsString(n[0],this.buffer.isEncoded)));
2788 }f=f.getElementsByTagName("response")[0];
2789 var l=f.getElementsByTagName("rows")[0];
2790 var d=this.columns[parseInt(a,10)];
2791 var r=this.buffer.dom2jstable(l);
2793 if(d.filterType==Rico.ColumnConst.USERFILTER&&d.filterOp=="EQ"){q=d.filterValues[0]
2794 }Rico.log("filterValuesUpdate: col="+a+" rows="+r.length);
2795 switch(d.format.filterUI.charAt(0)){case"m":d.mFilter=document.body.appendChild(document.createElement("div"));
2796 d.mFilter.className="ricoLG_mFilter";
2797 Rico.hide(d.mFilter);
2798 var e=d.mFilter.appendChild(document.createElement("div"));
2799 e.className="ricoLG_mFilter_content";
2800 var o=d.mFilter.appendChild(document.createElement("div"));
2801 o.className="ricoLG_mFilter_button";
2802 d.mFilterButton=o.appendChild(document.createElement("button"));
2803 d.mFilterButton.innerHTML=Rico.getPhraseById("ok");
2804 var j=Rico.isWebKit?"mousedown":"click";
2805 Rico.eventBind(d.filterField,j,Rico.eventHandle(d,"mFilterSelectClick"));
2806 Rico.eventBind(d.mFilterButton,"click",Rico.eventHandle(d,"mFilterFinish"));
2807 tab=e.appendChild(document.createElement("table"));
2811 var p=this.filterId(a)+"_";
2812 this.createMFilterItem(tab,this.options.FilterAllToken,Rico.getPhraseById("filterAll"),p+"all",Rico.eventHandle(d,"mFilterAllClick"));
2813 var k=Rico.eventHandle(d,"mFilterOtherClick");
2816 h++){if(r[h].length>0){m=r[h][0];
2817 this.createMFilterItem(tab,m,m||Rico.getPhraseById("filterBlank"),p+h,k)
2818 }}d.mFilterInputs=e.getElementsByTagName("input");
2819 d.mFilterLabels=e.getElementsByTagName("label");
2820 d.mFilterFocus=d.mFilterInputs.length?d.mFilterInputs[0]:d.mFilterButton;
2822 case"s":for(var h=0;
2824 h++){if(r[h].length>0){m=r[h][0];
2825 b=Rico.addSelectOption(d.filterField,m,m||Rico.getPhraseById("filterBlank"));
2826 if(d.filterType==Rico.ColumnConst.USERFILTER&&m==q){b.selected=true
2827 }}}Rico.eventBind(d.filterField,"change",Rico.eventHandle(d,"filterChange"));
2830 },createMFilterItem:function(j,b,i,a,e){var f=j.insertRow(-1);
2832 if(f.rowIndex%2==1){f.className="ricoLG_mFilter_oddrow"
2833 }var d=f.insertCell(-1);
2834 var c=f.insertCell(-1);
2835 var h=Rico.createFormField(d,"input","checkbox",a);
2838 var g=c.appendChild(document.createElement("label"));
2841 Rico.eventBind(h,"click",e)
2842 },unplugHighlightEvents:function(){var a=this.options.highlightSection;
2843 if(a&1){this.detachHighlightEvents(this.tbody[0])
2844 }if(a&2){this.detachHighlightEvents(this.tbody[1])
2845 }},insertPanelNames:function(a,b,d,f){Rico.log("insertPanelNames: start="+b+" limit="+d);
2846 a.className="ricoLG_hdg";
2847 var i=-1,j,e=null,g=0;
2850 h++){if(i==this.options.columnSpecs[h].ColGroupIdx){j++
2851 }else{if(e){e.colSpan=j
2852 }e=a.insertCell(-1);
2855 i=this.options.columnSpecs[h].ColGroupIdx;
2856 e.innerHTML=this.options.ColGroups[i]
2858 }},createHdr:function(d,g,b){Rico.log("createHdr: i="+d+" start="+g+" limit="+b);
2859 var a=this.thead[d].insertRow(-1);
2860 a.id=this.tableId+"_tab"+d+"h_main";
2861 a.className="ricoLG_hdg";
2864 f++){var e=a.insertCell(-1);
2865 e.innerHTML=this.options.columnSpecs[f].Hdg
2866 }},loadHdrSrc:function(g){var b,d,j,e,f,a;
2867 Rico.log("loadHdrSrc start");
2872 e++){f=this.thead[b].insertRow(-1);
2873 f.className="ricoLG_hdg "+this.tableId+"_hdg"+e
2874 }}if(g.length==1){a=g[0].cells;
2877 j++){this.thead[j<this.options.frozenColumns?0:1].rows[0].appendChild(a[0])
2883 j++){if(Rico.hasClass(a[0],"ricoFrozen")){if(e==this.headerRowIdx){this.options.frozenColumns=j+1
2885 }this.thead[d].rows[e].appendChild(a[0])
2886 }}}Rico.log("loadHdrSrc end")
2887 },sizeDivs:function(){Rico.log("sizeDivs: "+this.tableId);
2889 this.baseSizeDivs();
2890 var d=this.firstVisible();
2891 if(this.pageSize==0||d<0){return
2892 }var c=this.columns[d].dataColDiv.offsetHeight;
2893 this.rowHeight=Math.round(c/this.pageSize);
2895 if(this.scrTabWi0==this.scrTabWi){this.innerDiv.style.height=(this.hdrHt+1)+"px";
2896 this.scrollDiv.style.overflowX="hidden"
2897 }else{this.scrollDiv.style.overflowX="scroll";
2898 b+=this.options.scrollBarWidth
2899 }this.scrollDiv.style.height=b+"px";
2900 this.innerDiv.style.width=(this.scrWi)+"px";
2901 this.scrollTab.style.width=(this.scrWi-this.options.scrollBarWidth)+"px";
2902 this.resizeDiv.style.height=(this.hdrHt+this.dataHt+1)+"px";
2903 Rico.log("sizeDivs scrHt="+b+" innerHt="+this.innerDiv.style.height+" rowHt="+this.rowHeight+" pageSize="+this.pageSize);
2904 var a=(this.scrWi-this.scrTabWi<this.options.scrollBarWidth)?2:0;
2905 this.shadowDiv.style.width=(this.scrTabWi+a)+"px";
2906 this.outerDiv.style.height=(this.hdrHt+b)+"px";
2907 this.setHorizontalScroll()
2908 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
2909 this.tabs[1].style.marginLeft=a;
2910 this.tabs[2].style.marginLeft=a
2911 },remainingHt:function(){var f=this.outerDiv.offsetHeight;
2912 var g=Rico.windowHeight();
2913 var e=Rico.isIE?15:10;
2914 if(!Rico.isIE&&window.frameElement&&window.frameElement.scrolling=="yes"&&this.sizeTo!="parent"){e+=this.options.scrollBarWidth
2915 }switch(this.sizeTo){case"window":var d=Rico.cumulativeOffset(this.outerDiv).top;
2916 Rico.log("remainingHt/window, winHt="+g+" tabHt="+f+" gridY="+d);
2918 case"parent":var h=this.offsetFromParent(this.outerDiv);
2919 if(Rico.isIE){Rico.hide(this.outerDiv)
2920 }var b=this.outerDiv.parentNode.clientHeight;
2921 if(Rico.isIE){Rico.show(this.outerDiv)
2922 }Rico.log("remainingHt/parent, parentHt="+b+" offset="+h+" tabHt="+f);
2924 case"data":case"body":var a=Rico.isIE?document.body.scrollHeight:document.body.offsetHeight;
2926 if(!Rico.isWebKit){c-=this.options.scrollBarWidth
2927 }Rico.log("remainingHt, winHt="+g+" pageHt="+a+" remHt="+c);
2929 default:Rico.log("remainingHt, winHt="+g+" tabHt="+f);
2930 if(this.sizeTo.slice(-1)=="%"){g*=parseFloat(this.sizeTo)/100
2931 }else{if(this.sizeTo.slice(-2)=="px"){g=parseInt(this.sizeTo,10)
2933 }},offsetFromParent:function(b){var a=0;
2935 do{a+=b.offsetTop||0;
2937 if(!b||b==null){break
2938 }var d=Rico.getStyle(b,"position");
2939 if(b.tagName=="BODY"||b.tagName=="HTML"||d=="absolute"){return a-c.offsetTop
2942 },adjustPageSize:function(){var a=this.remainingHt();
2943 Rico.log("adjustPageSize remHt="+a+" lastRow="+this.lastRowPos);
2944 if(a>this.rowHeight){this.autoAppendRows(a)
2945 }else{if(a<0||this.sizeTo=="data"){this.autoRemoveRows(-a)
2946 }}},setPageSize:function(b){b=Math.min(b,this.options.maxPageRows);
2947 b=Math.max(b,this.options.minPageRows);
2948 this.sizeTo="fixed";
2949 var a=this.pageSize;
2950 while(this.pageSize>b){this.removeRow()
2951 }while(this.pageSize<b){this.appendBlankRow()
2952 }this.finishResize(a)
2953 },pluginWindowResize:function(){Rico.log("pluginWindowResize");
2954 this.resizeWindowHandler=Rico.eventHandle(this,"resizeWindow");
2955 Rico.eventBind(window,"resize",this.resizeWindowHandler,false)
2956 },unplugWindowResize:function(){if(!this.resizeWindowHandler){return
2957 }Rico.eventUnbind(window,"resize",this.resizeWindowHandler,false);
2958 this.resizeWindowHandler=null
2959 },resizeWindow:function(){Rico.log("resizeWindow "+this.tableId+" lastRow="+this.lastRowPos);
2960 if(this.resizeState=="finish"){Rico.log("resizeWindow postponed");
2961 this.resizeState="resize";
2963 }if(!this.sizeTo||this.sizeTo=="fixed"){this.sizeDivs();
2965 }if(this.sizeTo=="parent"&&Rico.getStyle(this.outerDiv.parentNode,"display")=="none"){return
2966 }var a=this.pageSize;
2967 this.adjustPageSize();
2968 this.finishResize(a)
2969 },finishResize:function(b){if(this.pageSize>b&&this.buffer.totalRows>0){this.isPartialBlank=true;
2970 var a=this.adjustRow(this.lastRowPos);
2971 this.buffer.fetch(a)
2972 }else{if(this.pageSize<b){if(this.options.onRefreshComplete){this.options.onRefreshComplete(this.contentStartPos,this.contentStartPos+this.pageSize-1)
2973 }}}this.resizeState="finish";
2974 Rico.runLater(20,this,"finishResize2");
2975 Rico.log("Resize "+this.tableId+" complete. old size="+b+" new size="+this.pageSize)
2976 },finishResize2:function(){this.sizeDivs();
2977 this.updateHeightDiv();
2978 if(this.resizeState=="resize"){this.resizeWindow()
2979 }else{this.resizeState=""
2980 }},topOfLastPage:function(){return Math.max(this.buffer.totalRows-this.pageSize,0)
2981 },updateHeightDiv:function(){var b=this.topOfLastPage();
2982 var a=b?this.scrollDiv.clientHeight+Math.floor(this.rowHeight*(b+0.4)):1;
2983 Rico.log("updateHeightDiv, ht="+a+" scrollDiv.clientHeight="+this.scrollDiv.clientHeight+" rowsNotDisplayed="+b);
2984 this.shadowDiv.style.height=a+"px"
2985 },autoRemoveRows:function(a){if(!this.rowHeight){return
2986 }var c=Math.ceil(a/this.rowHeight);
2987 if(this.sizeTo=="data"){c=Math.max(c,this.pageSize-this.buffer.totalRows)
2988 }Rico.log("autoRemoveRows overage="+a+" removeCnt="+c);
2991 b++){this.removeRow()
2992 }},removeRow:function(){if(this.pageSize<=this.options.minPageRows){return
2995 b<this.headerColCnt;
2996 b++){var a=this.columns[b].cell(this.pageSize);
2997 this.columns[b].dataColDiv.removeChild(a)
2998 }},autoAppendRows:function(a){if(!this.rowHeight){return
2999 }var c=Math.floor(a/this.rowHeight);
3000 Rico.log("autoAppendRows overage="+a+" cnt="+c+" rowHt="+this.rowHeight);
3003 b++){if(this.sizeTo=="data"&&this.pageSize>=this.buffer.totalRows){break
3004 }this.appendBlankRow()
3005 }},appendBlankRow:function(){if(this.pageSize>=this.options.maxPageRows){return
3006 }Rico.log("appendBlankRow #"+this.pageSize);
3007 var a=this.defaultRowClass(this.pageSize);
3009 d<this.headerColCnt;
3010 d++){var b=document.createElement("div");
3011 b.className="ricoLG_cell "+a;
3012 b.id=this.tableId+"_"+this.pageSize+"_"+d;
3013 this.columns[d].dataColDiv.appendChild(b);
3014 if(this.columns[d].format.canDrag&&Rico.registerDraggable){Rico.registerDraggable(new Rico.LiveGridDraggable(this,this.pageSize,d),this.options.dndMgrIdx)
3015 }b.innerHTML=" ";
3016 if(this.columns[d]._create){this.columns[d]._create(b,this.pageSize)
3018 },defaultRowClass:function(b){var a;
3019 if(b%2==0){a="ricoLG_evenRow"
3020 }else{a="ricoLG_oddRow"
3022 },handleMenuClick:function(f){if(!this.menu){return
3026 var a=Rico.eventElement(f);
3027 if(a.className=="ricoLG_highlightDiv"){b=this.highlightIdx
3028 }else{a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3030 }b=this.winCellIndex(a);
3031 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3032 }}this.highlight(b);
3033 this.highlightEnabled=false;
3034 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
3036 if(!this.menu.div){this.menu.createDiv()
3037 }this.menu.liveGrid=this;
3038 if(this.menu.buildGridMenu){var d=this.menu.buildGridMenu(b.row,b.column,b.tabIdx);
3040 }}if(this.options.highlightElem=="selection"&&!this.isSelected(b.cell)){this.selectCell(b.cell)
3042 this.menu.showmenu(f,function(){c.closeMenu()
3045 },closeMenu:function(){if(!this.menuIdx){return
3046 }if(this.hideScroll){this.scrollDiv.style.overflow=""
3047 }this.highlightEnabled=true;
3049 },winCellIndex:function(b){var d=b.id.lastIndexOf("_",b.id.length);
3050 var a=b.id.lastIndexOf("_",d-1)+1;
3051 var f=parseInt(b.id.substr(d+1));
3052 var e=parseInt(b.id.substr(a,d));
3053 return{row:e,column:f,tabIdx:this.columns[f].tabIdx,cell:b}
3054 },datasetIndex:function(b){var a=this.winCellIndex(b);
3055 a.row+=this.buffer.windowPos;
3056 a.onBlankRow=(a.row>=this.buffer.endPos());
3058 },attachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventBind(a,"mousedown",this.options.mouseDownHandler,false);
3059 a.ondrag=function(){return false
3061 a.onselectstart=function(){return false
3064 case"cursorRow":case"cursorCell":Rico.eventBind(a,"mouseover",this.options.rowOverHandler,false);
3066 }},detachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventUnbind(a,"mousedown",this.options.mouseDownHandler,false);
3068 a.onselectstart=null;
3070 case"cursorRow":case"cursorCell":Rico.eventUnbind(a,"mouseover",this.options.rowOverHandler,false);
3072 }},getVisibleSelection:function(){var d=[];
3073 if(this.SelectIdxStart&&this.SelectIdxEnd){var b=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowStart);
3074 var a=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowEnd-1);
3075 var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3076 var f=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3081 j++){d.push({row:h-this.buffer.windowStart,column:j})
3082 }}}if(this.SelectCtrl){for(var e=0;
3083 e<this.SelectCtrl.length;
3084 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})
3086 },updateSelectOutline:function(){if(!this.SelectIdxStart||!this.SelectIdxEnd){return
3087 }var d=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3088 var c=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3089 if(d>c){this.HideSelection();
3091 }var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3092 var e=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3093 var h=this.columns[g].cell(d-this.buffer.windowStart).offsetTop;
3094 var j=this.columns[g].cell(c-this.buffer.windowStart);
3095 var b=j.offsetTop+j.offsetHeight;
3096 var l=this.columns[g].dataCell.offsetLeft;
3097 var k=this.columns[e].dataCell.offsetLeft;
3098 var a=k+this.columns[e].dataCell.offsetWidth;
3099 this.highlightDiv[0].style.top=this.highlightDiv[3].style.top=this.highlightDiv[1].style.top=(this.hdrHt+h-1)+"px";
3100 this.highlightDiv[2].style.top=(this.hdrHt+b-1)+"px";
3101 this.highlightDiv[3].style.left=(l-2)+"px";
3102 this.highlightDiv[0].style.left=this.highlightDiv[2].style.left=(l-1)+"px";
3103 this.highlightDiv[1].style.left=(a-1)+"px";
3104 this.highlightDiv[0].style.width=this.highlightDiv[2].style.width=(a-l-1)+"px";
3105 this.highlightDiv[1].style.height=this.highlightDiv[3].style.height=(b-h)+"px";
3108 f++){this.highlightDiv[f].style.display=""
3109 }},HideSelection:function(){var b;
3110 if(this.options.highlightMethod!="class"){for(b=0;
3111 b<this.highlightDiv.length;
3112 b++){this.highlightDiv[b].style.display="none"
3113 }}if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3114 Rico.log("HideSelection "+a.length);
3117 b++){this.unhighlightCell(this.columns[a[b].column].cell(a[b].row))
3118 }}},ShowSelection:function(){if(this.options.highlightMethod!="class"){this.updateSelectOutline()
3119 }if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3122 b++){this.highlightCell(this.columns[a[b].column].cell(a[b].row))
3123 }}},ClearSelection:function(){Rico.log("ClearSelection");
3124 this.HideSelection();
3125 this.SelectIdxStart=null;
3126 this.SelectIdxEnd=null;
3128 },selectCell:function(a){this.ClearSelection();
3129 this.SelectIdxStart=this.SelectIdxEnd=this.datasetIndex(a);
3130 this.ShowSelection()
3131 },AdjustSelection:function(a){var b=this.datasetIndex(a);
3132 if(this.SelectIdxStart.tabIdx!=b.tabIdx){return
3133 }this.HideSelection();
3134 this.SelectIdxEnd=b;
3135 this.ShowSelection()
3136 },RefreshSelection:function(){var a=this.getVisibleSelection();
3139 b++){this.columns[a[b].column].displayValue(a[b].row)
3140 }},FillSelection:function(b,f){if(this.SelectIdxStart&&this.SelectIdxEnd){var e=Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3141 var d=Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3142 var j=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3143 var g=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3148 k++){this.buffer.setValue(a,k,b,f)
3149 }}}if(this.SelectCtrl){for(var h=0;
3150 h<this.SelectCtrl.length;
3151 h++){this.buffer.setValue(this.SelectCtrl[h].row,this.SelectCtrl[h].column,b,f)
3152 }}this.RefreshSelection()
3153 },selectMouseDown:function(d){if(this.highlightEnabled==false){return true
3155 var a=Rico.eventElement(d);
3156 if(!Rico.eventLeftClick(d)){return true
3157 }a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3160 var c=this.datasetIndex(a);
3161 if(c.onBlankRow){return true
3162 }Rico.log("selectMouseDown @"+c.row+","+c.column);
3163 if(d.ctrlKey){if(!this.SelectIdxStart||this.options.highlightMethod!="class"){return true
3164 }if(!this.isSelected(a)){this.highlightCell(a);
3165 this.SelectCtrl.push(this.datasetIndex(a))
3167 b<this.SelectCtrl.length;
3168 b++){if(this.SelectCtrl[b].row==c.row&&this.SelectCtrl[b].column==c.column){this.unhighlightCell(a);
3169 this.SelectCtrl.splice(b,1);
3171 }}}}else{if(d.shiftKey){if(!this.SelectIdxStart){return true
3172 }this.AdjustSelection(a)
3173 }else{this.selectCell(a);
3176 },pluginSelect:function(){if(this.selectPluggedIn){return
3177 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3178 Rico.eventBind(a,"mouseover",this.options.mouseOverHandler,false);
3179 Rico.eventBind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3180 this.selectPluggedIn=true
3181 },unplugSelect:function(){if(!this.selectPluggedIn){return
3182 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3183 Rico.eventUnbind(a,"mouseover",this.options.mouseOverHandler,false);
3184 Rico.eventUnbind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3185 this.selectPluggedIn=false
3186 },selectMouseUp:function(b){this.unplugSelect();
3187 var a=Rico.eventElement(b);
3188 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3190 }if(this.SelectIdxStart&&this.SelectIdxEnd){this.AdjustSelection(a)
3191 }else{this.ClearSelection()
3192 }},selectMouseOver:function(b){var a=Rico.eventElement(b);
3193 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3195 }this.AdjustSelection(a);
3197 },isSelected:function(a){if(this.options.highlightMethod!="outline"){return Rico.hasClass(a,this.options.highlightClass)
3198 }if(!this.SelectIdxStart||!this.SelectIdxEnd){return false
3199 }var c=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3200 var b=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3201 if(c>b){return false
3202 }var e=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3203 var d=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3204 var f=this.datasetIndex(a);
3205 return(c<=f.row&&f.row<=b&&e<=f.column&&f.column<=d)
3206 },highlightCell:function(a){Rico.addClass(a,this.options.highlightClass)
3207 },unhighlightCell:function(a){if(a){Rico.removeClass(a,this.options.highlightClass)
3208 }},selectRow:function(a){for(var b=0;
3209 b<this.columns.length;
3210 b++){this.highlightCell(this.columns[b].cell(a))
3211 }},unselectRow:function(a){for(var b=0;
3212 b<this.columns.length;
3213 b++){this.unhighlightCell(this.columns[b].cell(a))
3214 }},rowMouseOver:function(c){if(!this.highlightEnabled){return
3215 }var a=Rico.eventElement(c);
3216 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3218 }var b=this.winCellIndex(a);
3219 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3221 },highlight:function(a){if(this.options.highlightMethod!="outline"){this.cursorSetClass(a)
3222 }if(this.options.highlightMethod!="class"){this.cursorOutline(a)
3223 }this.highlightIdx=a
3224 },cursorSetClass:function(e){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3225 }this.highlightCell(e.cell);
3227 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3228 }var b=this.options.highlightSection&1;
3229 var a=this.options.highlightSection&2;
3230 var f=b?0:this.options.frozenColumns;
3231 var d=a?this.columns.length:this.options.frozenColumns;
3234 g++){this.highlightCell(this.columns[g].cell(e.row))
3237 }},cursorOutline:function(c){var d;
3238 switch(this.options.highlightElem){case"menuCell":case"cursorCell":d=this.highlightDiv[c.tabIdx];
3239 d.style.left=(this.columns[c.column].dataCell.offsetLeft-1)+"px";
3240 d.style.width=this.columns[c.column].colWidth;
3241 this.highlightDiv[1-c.tabIdx].style.display="none";
3243 case"menuRow":case"cursorRow":d=this.highlightDiv[0];
3244 var b=this.options.highlightSection&1;
3245 var a=this.options.highlightSection&2;
3246 d.style.left=b?"0px":this.frozenTabs.style.width;
3247 d.style.width=((b?this.frozenTabs.offsetWidth:0)+(a?this.innerDiv.offsetWidth:0)-4)+"px";
3250 }d.style.top=(this.hdrHt+c.row*this.rowHeight-1)+"px";
3251 d.style.height=(this.rowHeight-1)+"px";
3253 },unhighlight:function(){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3254 }if(!this.highlightDiv){return
3257 a++){this.highlightDiv[a].style.display="none"
3259 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3260 }if(this.highlightDiv){this.highlightDiv[0].style.display="none"
3262 }},resetContents:function(){Rico.log("resetContents");
3263 this.ClearSelection();
3264 this.buffer.clear();
3266 this.clearBookmark()
3267 },setImages:function(){for(var a=0;
3268 a<this.columns.length;
3269 a++){this.columns[a].setImage()
3270 }},findSortedColumn:function(){for(var a=0;
3271 a<this.columns.length;
3272 a++){if(this.columns[a].isSorted()){return a
3274 },findColumnName:function(a){for(var b=0;
3275 b<this.columns.length;
3276 b++){if(this.columns[b].fieldName==a){return b
3278 },findColumnsBySpec:function(b,c){var a=[];
3280 d<this.options.columnSpecs.length;
3281 d++){if(this.options.columnSpecs[d][b]==c){a.push(d)
3283 },setSortUI:function(b,c){Rico.log("setSortUI: "+b+" "+c);
3284 var a=this.findSortedColumn();
3285 if(a>=0){c=this.columns[a].getSortDirection()
3286 }else{if(typeof c!="string"){c=Rico.ColumnConst.SORT_ASC
3287 }else{c=c.toUpperCase();
3288 if(c!=Rico.ColumnConst.SORT_DESC){c=Rico.ColumnConst.SORT_ASC
3289 }}switch(typeof b){case"string":a=this.findColumnName(b);
3293 }}if(typeof(a)!="number"||a<0){return
3295 this.columns[a].setSorted(c);
3296 this.buffer.sortBuffer(a)
3297 },clearSort:function(){for(var a=0;
3298 a<this.columns.length;
3299 a++){this.columns[a].setUnsorted()
3300 }},clearFilters:function(){for(var a=0;
3301 a<this.columns.length;
3302 a++){this.columns[a].setUnfiltered(true)
3303 }if(this.options.filterHandler){this.options.filterHandler()
3304 }},filterCount:function(){for(var a=0,b=0;
3305 a<this.columns.length;
3306 a++){if(this.columns[a].isFiltered()){b++
3308 },sortHandler:function(){this.cancelMenu();
3309 this.ClearSelection();
3311 var a=this.findSortedColumn();
3313 }Rico.log("sortHandler: sorting column "+a);
3314 this.buffer.sortBuffer(a);
3316 this.scrollDiv.scrollTop=0;
3317 this.buffer.fetch(0)
3318 },filterHandler:function(){Rico.log("filterHandler");
3320 if(this.buffer.processingRequest){this.queueFilter=true;
3322 }this.unplugScroll();
3323 this.ClearSelection();
3325 this.clearBookmark();
3327 this.buffer.fetch(-1);
3328 Rico.runLater(10,this,"pluginScroll")
3329 },clearBookmark:function(){if(this.bookmark){this.bookmark.innerHTML=" "
3330 }},bookmarkHandler:function(a,d){var b;
3331 if(isNaN(a)||!this.bookmark){return
3332 }var c=this.buffer.totalRows;
3334 }if(c<=0){b=Rico.getPhraseById("bookmarkNoMatch")
3335 }else{if(d<0){b=Rico.getPhraseById("bookmarkNoRec")
3336 }else{if(this.buffer.foundRowCount){b=Rico.getPhraseById("bookmarkExact",a,d,c)
3337 }else{b=Rico.getPhraseById("bookmarkAbout",a,d,c)
3338 }}}this.bookmark.innerHTML=b
3339 },clearRows:function(){if(this.isBlank==true){return
3341 a<this.columns.length;
3342 a++){this.columns[a].clearColumn()
3344 },refreshContents:function(j){Rico.log("refreshContents1 "+this.tableId+": startPos="+j+" lastRow="+this.lastRowPos+" PartBlank="+this.isPartialBlank+" pageSize="+this.pageSize);
3348 if(this.queueFilter){Rico.log("refreshContents: cancelling refresh because filter has changed");
3349 this.queueFilter=false;
3350 this.filterHandler();
3352 }this.highlightEnabled=this.options.highlightSection!="none";
3353 var h=this.buffer.startPos>j;
3354 var d=h?this.buffer.startPos:j;
3355 this.contentStartPos=d+1;
3356 var b=Math.min(this.buffer.startPos+this.buffer.size,j+this.pageSize);
3357 this.buffer.setWindow(d,b);
3358 Rico.log("refreshContents2 "+this.tableId+": cStartPos="+d+" cEndPos="+b+" vPrecedesBuf="+h+" b.startPos="+this.buffer.startPos);
3359 if(j==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3360 }this.isBlank=false;
3361 var m=this.options.onRefreshComplete;
3362 if((j+this.pageSize<this.buffer.startPos)||(this.buffer.startPos+this.buffer.size<j)||(this.buffer.size==0)){this.clearRows();
3363 if(m){m(this.contentStartPos,b)
3365 }Rico.log("refreshContents: contentStartPos="+d+" contentEndPos="+b+" viewPrecedesBuffer="+h);
3367 var f=this.pageSize-n;
3373 l<this.columns.length;
3374 l++){this.columns[l].displayValue(a+e)
3377 g++){this.blankRow(g+k)
3378 }if(this.options.highlightElem=="selection"){this.ShowSelection()
3379 }this.isPartialBlank=f>0;
3381 Rico.log("refreshContents complete, startPos="+j);
3382 if(m){m(this.contentStartPos,b)
3383 }},scrollToRow:function(a){var b=this.rowToPixel(a);
3384 Rico.log("scrollToRow, rowOffset="+a+" pixel="+b);
3385 this.scrollDiv.scrollTop=b;
3386 if(this.options.onscroll){this.options.onscroll(this,a)
3387 }},scrollUp:function(){this.moveRelative(-1)
3388 },scrollDown:function(){this.moveRelative(1)
3389 },pageUp:function(){this.moveRelative(-this.pageSize)
3390 },pageDown:function(){this.moveRelative(this.pageSize)
3391 },adjustRow:function(a){var b=this.topOfLastPage();
3392 if(b==0||!a){return 0
3393 }return Math.min(b,a)
3394 },rowToPixel:function(a){return this.adjustRow(a)*this.rowHeight
3395 },pixeltorow:function(c){var b=this.topOfLastPage();
3397 }var a=parseInt(c/this.rowHeight,10);
3398 return Math.min(b,a)
3399 },moveRelative:function(b){var a=Math.max(this.scrollDiv.scrollTop+b*this.rowHeight,0);
3400 a=Math.min(a,this.scrollDiv.scrollHeight);
3401 this.scrollDiv.scrollTop=a
3402 },pluginScroll:function(){if(this.scrollPluggedIn){return
3403 }Rico.log("pluginScroll: wheelEvent="+this.wheelEvent);
3404 Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3407 a++){Rico.eventBind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3408 }this.scrollPluggedIn=true
3409 },unplugScroll:function(){if(!this.scrollPluggedIn){return
3410 }Rico.log("unplugScroll");
3411 Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3414 a++){Rico.eventUnbind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3415 }this.scrollPluggedIn=false
3416 },handleWheel:function(a){var b=0;
3417 if(a.wheelDelta){if(Rico.isOpera){b=a.wheelDelta/120
3418 }else{if(Rico.isWebKit){b=-a.wheelDelta/12
3419 }else{b=-a.wheelDelta/120
3420 }}}else{if(a.detail){b=a.detail/3
3421 }}if(b){this.moveRelative(b)
3424 },handleScroll:function(g){if(this.scrollTimeout){clearTimeout(this.scrollTimeout)
3425 }this.setHorizontalScroll();
3426 var a=this.scrollDiv.scrollTop;
3427 var b=this.lastScrollPos-a;
3429 }var d=this.pixeltorow(a);
3430 if(d==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3432 Rico.log("handleScroll, newrow="+d+" scrtop="+a);
3433 if(this.options.highlightElem=="selection"){this.HideSelection()
3434 }this.buffer.fetch(d);
3435 if(this.options.onscroll){this.options.onscroll(this,d)
3436 }this.scrollTimeout=Rico.runLater(1200,this,"scrollIdle");
3437 this.lastScrollPos=this.scrollDiv.scrollTop;
3439 },scrollIdle:function(){if(this.options.onscrollidle){this.options.onscrollidle()
3441 Rico.LiveGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
3443 Rico.LiveGridColumn.prototype={initialize:function(liveGrid,colIdx,hdrInfo,tabIdx){Rico.extend(this,new Rico.TableColumnBase());
3444 this.baseInit(liveGrid,colIdx,hdrInfo,tabIdx);
3445 this.buffer=liveGrid.buffer;
3446 if(typeof(this.format.type)!="string"||this.format.EntryType=="tinyMCE"){this.format.type="html"
3447 }if(typeof this.isNullable!="boolean"){this.isNullable=/number|date/.test(this.format.type)
3448 }this.isText=/html|text/.test(this.format.type);
3449 Rico.log(" sortable="+this.sortable+" filterable="+this.filterable+" hideable="+this.hideable+" isNullable="+this.isNullable+" isText="+this.isText);
3450 this.fixHeaders(this.liveGrid.tableId,this.options.hdrIconsFirst);
3451 if(this["format_"+this.format.type]){this._format=this["format_"+this.format.type]
3452 }if(this.format.control){if(typeof this.format.control=="string"){this.format.control=eval(this.format.control)
3453 }for(var property in this.format.control){if(property.charAt(0)=="_"){Rico.log("Copying control property "+property+" to "+this);
3454 this[property]=this.format.control[property]
3455 }}}},sortAsc:function(){this.setColumnSort(Rico.ColumnConst.SORT_ASC)
3456 },sortDesc:function(){this.setColumnSort(Rico.ColumnConst.SORT_DESC)
3457 },setColumnSort:function(a){this.liveGrid.clearSort();
3459 if(this.liveGrid.options.saveColumnInfo.sort){this.liveGrid.setCookie()
3460 }if(this.options.sortHandler){this.options.sortHandler()
3461 }},isSortable:function(){return this.sortable
3462 },isSorted:function(){return this.currentSort!=Rico.ColumnConst.UNSORTED
3463 },getSortDirection:function(){return this.currentSort
3464 },toggleSort:function(){if(this.buffer&&this.buffer.totalRows==0){return
3465 }if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.sortDesc()
3466 }else{this.sortAsc()
3467 }},setUnsorted:function(){this.setSorted(Rico.ColumnConst.UNSORTED)
3468 },setSorted:function(a){this.currentSort=a
3469 },canFilter:function(){return this.filterable
3470 },getFilterText:function(){var c=[];
3472 b<this.filterValues.length;
3473 b++){var a=this.filterValues[b];
3474 c.push(a==""?Rico.getPhraseById("filterBlank"):a)
3475 }switch(this.filterOp){case"EQ":return"= "+c.join(", ");
3476 case"NE":return Rico.getPhraseById("filterNot",c.join(", "));
3477 case"LE":return"<= "+c[0];
3478 case"GE":return">= "+c[0];
3479 case"LIKE":return Rico.getPhraseById("filterLike",c[0]);
3480 case"NULL":return Rico.getPhraseById("filterEmpty");
3481 case"NOTNULL":return Rico.getPhraseById("filterNotEmpty")
3483 },getFilterQueryParm:function(){if(this.filterType==Rico.ColumnConst.UNFILTERED){return""
3484 }var a="&f["+this.index+"][op]="+this.filterOp;
3485 a+="&f["+this.index+"][len]="+this.filterValues.length;
3487 b<this.filterValues.length;
3488 b++){a+="&f["+this.index+"]["+b+"]="+escape(this.filterValues[b])
3490 },setUnfiltered:function(a){this.filterType=Rico.ColumnConst.UNFILTERED;
3491 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3492 }if(this.removeFilterFunc){this.removeFilterFunc()
3493 }if(this.options.filterHandler&&!a){this.options.filterHandler()
3494 }},setFilterEQ:function(){this.setUserFilter("EQ")
3495 },setFilterNE:function(){this.setUserFilter("NE")
3496 },addFilterNE:function(){this.filterValues.push(this.userFilter);
3497 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3498 }if(this.options.filterHandler){this.options.filterHandler()
3499 }},setFilterGE:function(){this.setUserFilter("GE")
3500 },setFilterLE:function(){this.setUserFilter("LE")
3501 },setFilterKW:function(a){if(a!=""&&a!=null){this.setFilter("LIKE",a,Rico.ColumnConst.USERFILTER)
3502 }else{this.setUnfiltered(false)
3503 }},setUserFilter:function(a){this.setFilter(a,this.userFilter,Rico.ColumnConst.USERFILTER)
3504 },setSystemFilter:function(a,b){this.setFilter(a,b,Rico.ColumnConst.SYSTEMFILTER)
3505 },setFilter:function(a,c,b,d){this.filterValues=typeof(c)=="object"?c:[c];
3508 if(b==Rico.ColumnConst.USERFILTER&&this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3509 }this.removeFilterFunc=d;
3510 if(this.options.filterHandler){this.options.filterHandler()
3511 }},isFiltered:function(){return this.filterType==Rico.ColumnConst.USERFILTER
3512 },filterChange:function(a){var b=Rico.eventElement(a);
3513 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
3514 }else{this.setFilter("EQ",b.value,Rico.ColumnConst.USERFILTER,function(){b.selectedIndex=0
3516 }},filterClear:function(a){this.filterField.value="";
3517 this.setUnfiltered()
3518 },filterKeypress:function(c){var a=Rico.eventElement(c);
3519 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
3520 }if(this.lastKeyFilter==a.value){return
3522 Rico.log("filterKeypress: "+this.index+" "+b);
3523 this.lastKeyFilter=b;
3524 if(b==""||b=="*"){this.setUnfiltered()
3525 }else{this.setFilter("LIKE",b,Rico.ColumnConst.USERFILTER,function(){a.value=""
3527 }},mFilterSelectClick:function(a){Rico.eventStop(a);
3528 if(this.mFilter.style.display!="none"){this.mFilterFinish(a);
3529 if(Rico.isIE&&Rico.ieVersion<=6){this.filterField.focus()
3530 }else{this.filterField.blur()
3531 }}else{var b=Rico.cumulativeOffset(this.filterField);
3532 this.mFilter.style.top=(b.top+this.filterField.offsetHeight)+"px";
3533 this.mFilter.style.left=b.left+"px";
3534 this.mFilter.style.width=Math.min(this.filterField.offsetWidth,parseInt(this.colWidth,10))+"px";
3535 Rico.show(this.mFilter);
3536 this.mFilterFocus.focus()
3537 }},mFilterFinish:function(g){if(!this.mFilterChange){Rico.hide(this.mFilter);
3539 }if(this.mFilterInputs[0].checked){this.mFilterReset();
3540 Rico.hide(this.mFilter);
3541 this.setUnfiltered();
3546 d<this.mFilterInputs.length;
3547 d++){if(this.mFilterInputs[d].checked){c.push(this.mFilterInputs[d].value);
3548 a.push(this.mFilterLabels[d].innerHTML)
3549 }}if(c.length>0){var f=a.join(", ");
3550 this.filterField.options[0].text=f;
3551 this.filterField.title=f;
3552 Rico.hide(this.mFilter);
3553 this.mFilterChange=false;
3555 this.setFilter("EQ",c,Rico.ColumnConst.USERFILTER,function(){b.mFilterReset()
3557 }else{alert("Please select at least one value")
3558 }},mFilterReset:function(){var a=this.mFilterLabels[0].innerHTML;
3559 this.filterField.options[0].text=a;
3560 this.filterField.title=a
3561 },mFilterAllClick:function(c){var a=this.mFilterInputs[0].checked;
3563 b<this.mFilterInputs.length;
3564 b++){this.mFilterInputs[b].checked=a
3565 }this.mFilterChange=true
3566 },mFilterOtherClick:function(a){this.mFilterInputs[0].checked=false;
3567 this.mFilterChange=true
3568 },format_text:function(a){if(typeof a!="string"){return" "
3569 }else{return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")
3570 }},format_number:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3571 }else{return Rico.formatNumber(a,this.format)
3572 }},format_datetime:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3573 }else{var b=Rico.setISO8601(a);
3575 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3576 }},format_utcaslocaltime:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3577 }else{var c=new Date();
3578 var b=Rico.setISO8601(a,-c.getTimezoneOffset());
3580 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3581 }},format_date:function(a){if(typeof a=="undefined"||a==null||a==""){return" "
3582 }else{var b=Rico.setISO8601(a);
3584 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDate")+(this.format.suffix||"")
3585 }},fixHeaders:function(d,e){if(this.sortable){var c=Rico.eventHandle(this,"toggleSort");
3586 switch(this.options.headingSort){case"link":var b=Rico.wrapChildren(this.hdrCellDiv,"ricoSort",undefined,"a");
3587 b.href="javascript:void(0)";
3588 Rico.eventBind(b,"click",c);
3590 case"hover":Rico.eventBind(this.hdrCellDiv,"click",c);
3592 }}this.imgFilter=document.createElement("span");
3593 this.imgFilter.style.display="none";
3594 this.imgFilter.className="rico-icon ricoLG_filterCol";
3595 this.imgSort=document.createElement("span");
3596 this.imgSort.style.display="none";
3597 this.imgSort.style.verticalAlign="top";
3598 if(e){this.hdrCellDiv.insertBefore(this.imgSort,this.hdrCellDiv.firstChild);
3599 this.hdrCellDiv.insertBefore(this.imgFilter,this.hdrCellDiv.firstChild)
3600 }else{this.hdrCellDiv.appendChild(this.imgFilter);
3601 this.hdrCellDiv.appendChild(this.imgSort)
3602 }if(!this.format.filterUI){Rico.eventBind(this.imgFilter,"click",Rico.eventHandle(this,"filterClick"),false)
3603 }},filterClick:function(a){if(this.filterType==Rico.ColumnConst.USERFILTER&&this.filterOp=="LIKE"){this.liveGrid.openKeyword(this.index)
3604 }},getValue:function(a){return this.buffer.getWindowCell(a,this.index)
3605 },getBufferStyle:function(a){return this.buffer.getWindowStyle(a,this.index)
3606 },setValue:function(b,a){this.buffer.setWindowValue(b,this.index,a)
3607 },_format:function(a){return a
3608 },_display:function(a,b){b.innerHTML=this._format(a)
3609 },_export:function(a){return this._format(a)
3610 },exportBuffer:function(a){return this._export(this.buffer.getValue(a,this.index))
3611 },displayValue:function(c){var a=this.getValue(c);
3612 if(a==null){this.clearCell(c);
3614 }var b=this.cell(c);
3615 this._display(a,b,c);
3616 if(this.buffer.options.acceptStyle){b.style.cssText=this.getBufferStyle(c)
3618 Rico.TableColumn={};
3619 Rico.TableColumn.checkboxKey=function(a){this.initialize(a)
3621 Rico.TableColumn.checkboxKey.prototype={initialize:function(a){this._checkboxes=[];
3625 },_create:function(a,b){this._checkboxes[b]=Rico.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);
3626 this._spans[b]=Rico.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);
3628 Rico.eventBind(this._checkboxes[b],"click",Rico.eventHandle(this,"_onclick"))
3629 },_onclick:function(c){var b=Event.element(c);
3630 var d=parseInt(b.id.substr((b.id.lastIndexOf("_",b.id.length)+1)));
3631 var a=this.getValue(d);
3632 if(b.checked){this._addChecked(a)
3633 }else{this._remChecked(a)
3634 }},_clear:function(b,c){var a=this._checkboxes[c];
3636 a.style.display="none";
3637 this._spans[c].innerHTML=""
3638 },_display:function(a,c,d){var b=this._checkboxes[d];
3640 b.checked=this._KeyHash[a];
3641 if(this._showKey){this._spans[d].innerHTML=a
3642 }},_SelectedKeys:function(){return Rico.keys(this._KeyHash)
3643 },_addChecked:function(a){this._KeyHash[a]=1
3644 },_remChecked:function(a){delete this._KeyHash[a]
3646 Rico.TableColumn.checkbox=function(b,c,a,d){this.initialize(b,c,a,d)
3648 Rico.TableColumn.checkbox.prototype={initialize:function(b,c,a,d){this._checkedValue=b;
3649 this._uncheckedValue=c;
3650 this._defaultValue=a||false;
3651 this._readOnly=d||false;
3653 },_create:function(a,b){this._checkboxes[b]=Rico.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);
3655 if(this._readOnly){this._checkboxes[b].disabled=true
3656 }else{Rico.eventBind(this._checkboxes[b],"click",Rico.eventHandle(this,"_onclick"))
3657 }},_onclick:function(c){var a=Event.element(c);
3658 var d=parseInt(a.id.substr((a.id.lastIndexOf("_",a.id.length)+1)));
3659 var b=a.checked?this._checkedValue:this._uncheckedValue;
3661 },_clear:function(b,c){var a=this._checkboxes[c];
3662 a.checked=this._defaultValue;
3663 a.style.display="none"
3664 },_display:function(a,c,d){var b=this._checkboxes[d];
3666 b.checked=(a==this._checkedValue)
3668 Rico.TableColumn.textbox=function(c,b,a){this.initialize(c,b,a)
3670 Rico.TableColumn.textbox.prototype={initialize:function(c,b,a){this._boxSize=c;
3672 this._readOnly=a||false;
3674 },_create:function(b,c){var a=Rico.createFormField(b,"input","text",this.liveGrid.tableId+"_txtbox_"+this.index+"_"+c);
3675 a.size=this._boxSize;
3676 a.maxLength=this._boxMaxLen;
3677 this._textboxes[c]=a;
3679 if(this._readOnly){a.disabled=true
3680 }else{Rico.eventBind(a,"change",Rico.eventHandle(this,"_onchange"))
3681 }},_onchange:function(b){var a=Event.element(b);
3682 var c=parseInt(a.id.substr((a.id.lastIndexOf("_",a.id.length)+1)));
3683 this.setValue(c,a.value)
3684 },_clear:function(b,c){var a=this._textboxes[c];
3686 a.style.display="none"
3687 },_display:function(a,c,d){var b=this._textboxes[d];
3691 Rico.TableColumn.HighlightCell=function(a,c,e,b,d){this.initialize(a,c,e,b,d)
3693 Rico.TableColumn.HighlightCell.prototype={initialize:function(a,c,e,b,d){this._chkcol=a;
3696 this._highlightColor=e;
3697 this._highlightBackground=b
3698 },_clear:function(a,b){a.style.color="";
3699 a.style.backgroundColor="";
3700 a.innerHTML=" "
3701 },_display:function(b,d,e){var a=this.liveGrid.buffer.getWindowValue(e,this._chkcol);
3703 switch(this._chkop){case"!=":c=(a!=this._chkval);
3705 case">":c=(a>this._chkval);
3707 case"<":c=(a<this._chkval);
3709 case">=":c=(a>=this._chkval);
3711 case"<=":c=(a<=this._chkval);
3713 case"abs>":c=(Math.abs(a)>this._chkval);
3715 case"abs<":c=(Math.abs(a)<this._chkval);
3717 case"abs>=":c=(Math.abs(a)>=this._chkval);
3719 case"abs<=":c=(Math.abs(a)<=this._chkval);
3721 default:c=(a==this._chkval);
3723 }d.style.color=c?this._highlightColor:"";
3724 d.style.backgroundColor=c?this._highlightBackground:"";
3725 d.innerHTML=this._format(b)
3727 Rico.TableColumn.bgColor=function(){};
3728 Rico.TableColumn.bgColor.prototype={_clear:function(a,b){a.style.backgroundColor=""
3729 },_display:function(a,b,c){b.style.backgroundColor=a
3731 Rico.TableColumn.link=function(a,c,b){this.initialize(a,c,b)
3733 Rico.TableColumn.link.prototype={initialize:function(a,c,b){this._href=a;
3737 },_create:function(a,b){this._anchors[b]=Rico.createFormField(a,"a",null,this.liveGrid.tableId+"_a_"+this.index+"_"+b);
3738 if(this._target){this._anchors[b].target=this._target
3740 },_clear:function(a,b){this._anchors[b].href="";
3741 this._anchors[b].innerHTML=""
3742 },_display:function(b,d,f){var c=this.liveGrid.buffer;
3743 var a=this._href=="self"?b:this._href.replace(/\{\d+\}/g,function(g){var h=parseInt(g.substr(1),10);
3744 return encodeURIComponent(c.getWindowValue(f,h))
3746 var e=this._linktext||b;
3747 if(a&&e){this._anchors[f].href=a;
3748 this._anchors[f].innerHTML=e
3749 }else{this._clear(d,f)
3751 Rico.TableColumn.image=function(a,b){this.initialize(a,b)
3753 Rico.TableColumn.image.prototype={initialize:function(a,b){this._img=[];
3756 },_create:function(a,b){this._img[b]=Rico.createFormField(a,"img",null,this.liveGrid.tableId+"_img_"+this.index+"_"+b);
3758 },_clear:function(b,c){var a=this._img[c];
3759 a.style.display="none";
3761 },_display:function(b,c,d){var a=this._img[d];
3762 this._img[d].src=this._prefix+b+this._suffix;
3765 Rico.TableColumn.lookup=function(c,a,b){this.initialize(c,a,b)
3767 Rico.TableColumn.lookup.prototype={initialize:function(d,a,c){this._map=d;
3768 this._defaultCode=a||"";
3769 this._defaultDesc=c||" ";
3771 this._sortfunc=function(e){return b._sortvalue(e)
3774 this._descriptions=[]
3775 },_create:function(a,b){this._descriptions[b]=Rico.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);
3776 this._codes[b]=Rico.createFormField(a,"input","hidden",this.liveGrid.tableId+"_code_"+this.index+"_"+b);
3778 },_clear:function(a,b){this._codes[b].value=this._defaultCode;
3779 this._descriptions[b].innerHTML=this._defaultDesc
3780 },_sortvalue:function(a){return this._getdesc(a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")
3781 },_getdesc:function(a){var b=this._map[a];
3782 return(typeof b=="string")?b:this._defaultDesc
3783 },_export:function(a){return this._getdesc(a)
3784 },_display:function(a,b,c){this._codes[c].value=a;
3785 this._descriptions[c].innerHTML=this._getdesc(a)
3787 Rico.TableColumn.MultiLine=function(){};
3788 Rico.TableColumn.MultiLine.prototype={_display:function(a,c,d){var b=document.createElement("div");
3789 b.innerHTML=this._format(a);
3790 b.style.height="100%";
3791 if(c.firstChild){c.replaceChild(b,c.firstChild)
3792 }else{c.appendChild(b)
3794 if(typeof Rico=="undefined"){throw ("GridMenu requires the Rico JavaScript framework")
3795 }Rico.GridMenu=function(a){this.initialize(a)
3797 Rico.GridMenu.prototype={initialize:function(a){this.options={width:"18em",dataMenuHandler:null};
3798 Rico.extend(this.options,a||{});
3799 Rico.extend(this,new Rico.Menu(this.options));
3800 this.sortmenu=new Rico.Menu({width:"15em"});
3801 this.filtermenu=new Rico.Menu({width:"22em"});
3802 this.exportmenu=new Rico.Menu({width:"24em"});
3803 this.hideshowmenu=new Rico.Menu({width:"22em"});
3805 this.sortmenu.createDiv();
3806 this.filtermenu.createDiv();
3807 this.exportmenu.createDiv();
3808 this.hideshowmenu.createDiv()
3809 },buildGridMenu:function(a,i){this.clearMenu();
3810 var o=this.liveGrid;
3813 var n=o.options.maxPrint;
3816 if(this.options.dataMenuHandler){var l=this.options.dataMenuHandler(o,a,i,b);
3817 if(!l){return(this.itemCount>0)
3818 }}if(d.sortable&&m>0){this.sortmenu.clearMenu();
3819 this.addSubMenuItem(Rico.getPhraseById("gridmenuSortBy",d.displayName),this.sortmenu,false);
3820 this.sortmenu.addMenuItemId("gridmenuSortAsc",function(){d.sortAsc()
3822 this.sortmenu.addMenuItemId("gridmenuSortDesc",function(){d.sortDesc()
3824 }this.filtermenu.clearMenu();
3825 if(d.canFilter()){this.addSubMenuItem(Rico.getPhraseById("gridmenuFilterBy",d.displayName),this.filtermenu,false);
3826 if(!d.format.filterUI&&(!b||d.filterType==Rico.ColumnConst.USERFILTER)){d.userFilter=d.getValue(a);
3827 if(d.filterType==Rico.ColumnConst.USERFILTER){this.filtermenu.addMenuItemId("gridmenuRemoveFilter",function(){d.setUnfiltered(false)
3829 if(d.filterOp=="LIKE"){this.filtermenu.addMenuItemId("gridmenuChgKeyword",function(){o.openKeyword(i)
3831 }if(d.filterOp=="NE"&&!b){this.filtermenu.addMenuItemId("gridmenuExcludeAlso",function(){d.addFilterNE()
3833 }}else{if(!b){this.filtermenu.addMenuItemId("gridmenuInclude",function(){d.setFilterEQ()
3835 this.filtermenu.addMenuItemId("gridmenuGreaterThan",function(){d.setFilterGE()
3836 },d.userFilter!="");
3837 this.filtermenu.addMenuItemId("gridmenuLessThan",function(){d.setFilterLE()
3838 },d.userFilter!="");
3839 if(d.isText){this.filtermenu.addMenuItemId("gridmenuContains",function(){o.openKeyword(i)
3841 }this.filtermenu.addMenuItemId("gridmenuExclude",function(){d.setFilterNE()
3843 }}}if(o.filterCount()>0){this.filtermenu.addMenuItemId("gridmenuRemoveAll",function(){o.clearFilters()
3845 }this.filtermenu.addMenuItemId("gridmenuRefresh",function(){o.filterHandler()
3847 }this.exportmenu.clearMenu();
3848 if(n>0){this.addSubMenuItem(Rico.getPhraseById("gridmenuExport"),this.exportmenu,false);
3849 if(f.printVisibleSQL&&typeof(f.dataSource)=="string"){this.exportmenu.addMenuItemId("gridmenuExportVis2Web",function(){f.printVisibleSQL("html")
3851 this.exportmenu.addMenuItemId("gridmenuExportAll2Web",function(){f.printAllSQL("html")
3853 this.exportmenu.addMenuBreak();
3854 this.exportmenu.addMenuItemId("gridmenuExportVis2SS",function(){f.printVisibleSQL("xl")
3856 this.exportmenu.addMenuItemId("gridmenuExportAll2SS",function(){f.printAllSQL("xl")
3858 }else{this.exportmenu.addMenuItemId("gridmenuExportVis2Web",function(){f.printVisible()
3860 this.exportmenu.addMenuItemId("gridmenuExportAll2Web",function(){f.printAll()
3862 }}var k=o.listInvisible();
3865 j++){if(k[j].canHideShow()){e++
3866 }}if(e>0||d.canHideShow()){this.hideshowmenu.clearMenu();
3867 this.addSubMenuItem(Rico.getPhraseById("gridmenuHideShow"),this.hideshowmenu,false);
3868 this.hideshowmenu.addMenuItemId("gridmenuChooseCols",function(){o.chooseColumns()
3870 var h=o.columns.length-k.length;
3871 var g=(h>1&&d.visible&&d.canHideShow());
3872 this.hideshowmenu.addMenuItem(Rico.getPhraseById("gridmenuHide",d.displayName),function(){d.hideColumn()
3874 if(k.length>1){this.hideshowmenu.addMenuItemId("gridmenuShowAll",function(){o.showAll()
3878 if(typeof Rico=="undefined"){throw ("LiveGridAjax requires the Rico JavaScript framework")
3879 }if(!Rico.Buffer){Rico.Buffer={}
3880 }Rico.Buffer.AjaxXML=function(c,b,a){this.initialize(c,b,a)
3882 Rico.Buffer.AjaxXML.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Buffer.Base());
3883 Rico.extend(this,Rico.Buffer.AjaxXMLMethods);
3885 this.options.bufferTimeout=20000;
3886 this.options.requestParameters=[];
3887 this.options.waitMsg=Rico.getPhraseById("waitForData");
3888 this.options.canFilter=true;
3889 this.options.fmt="xml";
3890 Rico.extend(this.options,b||{});
3891 this.ajaxOptions={parameters:null,method:"get"};
3892 Rico.extend(this.ajaxOptions,a||{});
3893 this.requestCount=0;
3894 this.processingRequest=false;
3895 this.pendingRequest=-2;
3896 this.fetchData=true;
3899 Rico.Buffer.AjaxXMLMethods={fetch:function(b){if(this.fetchData){this.foundRowCount=true;
3900 this.fetchData=false;
3901 this.processingRequest=true;
3902 this.liveGrid.showMsg(this.options.waitMsg);
3903 this.timeoutHandler=Rico.runLater(this.options.bufferTimeout,this,"handleTimedOut");
3904 this.ajaxOptions.parameters=this.formQueryHashXML(0,-1);
3905 Rico.log("sending request");
3907 if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=function(c){a.ajaxUpdate(b,c)
3909 new Rico.ajaxRequest(this.dataSource,this.ajaxOptions)
3910 }else{this.ajaxOptions.onComplete=function(d,f,c,e){a.jsUpdate(b,d,f,c,e)
3912 this.dataSource(this.ajaxOptions)
3913 }}else{if(b<0){this.applyFilters();
3914 this.setTotalRows(this.size);
3916 }this.liveGrid.refreshContents(b)
3917 }},handleTimedOut:function(){Rico.log("Request Timed Out");
3918 this.liveGrid.showMsg(Rico.getPhraseById("requestTimedOut"))
3919 },formQueryHashXML:function(e,c){var d={id:this.liveGrid.tableId,page_size:(typeof c=="number")?c:this.totalRows,offset:e.toString()};
3920 if(!this.foundRowCount){d.get_total="true"
3921 }if(this.options.requestParameters){for(var f=0;
3922 f<this.options.requestParameters.length;
3923 f++){var g=this.options.requestParameters[f];
3924 if(g.name!=undefined&&g.value!=undefined){d[g.name]=g.value
3925 }else{var b=g.indexOf("=");
3926 var h=g.substring(0,b);
3927 var a=g.substring(b+1);
3930 },clearTimer:function(){if(typeof this.timeoutHandler!="number"){return
3931 }window.clearTimeout(this.timeoutHandler);
3932 delete this.timeoutHandler
3933 },jsUpdate:function(a,c,e,b,d){this.clearTimer();
3934 this.processingRequest=false;
3935 Rico.log("jsUpdate: "+arguments.length);
3936 if(d){Rico.log("jsUpdate: received error="+d);
3937 this.liveGrid.showMsg(Rico.getPhraseById("requestError",d));
3939 }this.rcvdRows=c.length;
3940 if(typeof b=="number"){this.rowcntContent=b.toString();
3941 this.rcvdRowCount=true;
3942 this.foundRowCount=true;
3943 Rico.log("jsUpdate: found RowCount="+this.rowcntContent)
3944 }this.updateBuffer(a,c,e);
3945 if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()
3946 }this.updateGrid(a);
3947 if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()
3948 }if(this.pendingRequest>=-1){var f=this.pendingRequest;
3949 Rico.log("jsUpdate: found pending request for offset="+f);
3950 this.pendingRequest=-2;
3952 }},ajaxUpdate:function(a,c){this.clearTimer();
3953 this.processingRequest=false;
3954 if(c.status!=200){Rico.log("ajaxUpdate: received http error="+c.status);
3955 this.liveGrid.showMsg(Rico.getPhraseById("httpError",c.status));
3957 }this._responseHandler=this["processResponse"+this.options.fmt.toUpperCase()];
3958 if(!this._responseHandler(a,c)){return
3959 }if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()
3960 }this.updateGrid(a);
3961 if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()
3962 }if(this.pendingRequest>=-1){var b=this.pendingRequest;
3963 Rico.log("ajaxUpdate: found pending request for offset="+b);
3964 this.pendingRequest=-2;
3966 }},processResponseXML:function(k,f){var o=f.responseXML;
3967 if(f.responseText.substring(0,4)=="<!--"){var m=f.responseText.indexOf("-->");
3968 if(m==-1){this.liveGrid.showMsg("Web server error - client side debugging may be enabled");
3970 }o=Rico.createXmlDocument();
3971 o.loadXML(f.responseText.substring(m+3))
3972 }if(!o){alert("Data provider returned an invalid XML response");
3973 Rico.log("Data provider returned an invalid XML response");
3975 }var d=o.getElementsByTagName("ajax-response");
3976 if(d==null||d.length!=1){alert("Received invalid response from server");
3978 }Rico.log("Processing ajax-response");
3980 this.rcvdRowCount=false;
3982 var a=b.getElementsByTagName("debug");
3985 g++){Rico.log("ajaxUpdate: debug msg "+g+": "+Rico.getContentAsString(a[g],this.options.isEncoded))
3986 }var l=b.getElementsByTagName("error");
3987 if(l.length>0){var c=Rico.getContentAsString(l[0],this.options.isEncoded);
3988 alert("Data provider returned an error:\n"+c);
3989 Rico.log("Data provider returned an error:\n"+c);
3991 }var j=b.getElementsByTagName("rows")[0];
3992 if(!j){Rico.log("ajaxUpdate: invalid response");
3993 this.liveGrid.showMsg(Rico.getPhraseById("invalidResponse"));
3995 }var n=b.getElementsByTagName("rowcount");
3996 if(n&&n.length==1){this.rowcntContent=Rico.getContentAsString(n[0],this.options.isEncoded);
3997 this.rcvdRowCount=true;
3998 this.foundRowCount=true;
3999 Rico.log("ajaxUpdate: found RowCount="+this.rowcntContent)
4000 }this.updateUI=j.getAttribute("update_ui")=="true";
4001 this.rcvdOffset=j.getAttribute("offset");
4002 Rico.log("ajaxUpdate: rcvdOffset="+this.rcvdOffset);
4003 var h=this.dom2jstable(j);
4004 var e=(this.options.acceptStyle)?this.dom2jstableStyle(j):false;
4005 this.rcvdRows=h.length;
4006 this.updateBuffer(k,h,e);
4008 },dom2jstableStyle:function(e,b){var a=this.options.acceptStyle;
4009 Rico.log("dom2jstableStyle start");
4011 var g=e.getElementsByTagName("tr");
4015 var h=g[d].getElementsByTagName("td");
4018 c++){k[c]=h[c].getAttribute("style")||""
4020 }Rico.log("dom2jstableStyle end");
4022 },processResponseJSON:function(a,d){var c=Rico.getJSON(d);
4023 if(!c||c==null){alert("Data provider returned an invalid JSON response");
4024 Rico.log("Data provider returned an invalid JSON response");
4026 }if(c.debug){for(var b=0;
4028 b++){Rico.writeDebugMsg("debug msg "+b+": "+c.debug[b])
4029 }}if(c.error){alert("Data provider returned an error:\n"+c.error);
4030 Rico.writeDebugMsg("Data provider returned an error:\n"+c.error);
4032 }if(c.rowcount){this.rowcntContent=c.rowcount;
4033 this.rcvdRowCount=true;
4034 this.foundRowCount=true;
4035 Rico.writeDebugMsg("loadRows, found RowCount="+c.rowcount)
4036 }this.rcvdRows=c.rows.length;
4037 this.updateBuffer(a,c.rows,c.styles);
4039 },updateBuffer:function(c,a,b){this.baseRows=a;
4041 Rico.log("updateBuffer: # of rows="+this.rcvdRows);
4042 this.rcvdRowCount=true;
4043 this.rowcntContent=this.rcvdRows;
4044 if(typeof this.delayedSortCol=="number"){this.sortBuffer(this.delayedSortCol)
4045 }this.applyFilters();
4047 },updateGrid:function(f){Rico.log("updateGrid, size="+this.size+" rcv cnt type="+typeof(this.rowcntContent));
4049 if(this.rcvdRowCount==true){Rico.log("found row cnt: "+this.rowcntContent);
4050 var d=parseInt(this.rowcntContent,10);
4051 var b=this.totalRows;
4052 if(!isNaN(d)&&d!=b){this.setTotalRows(d);
4053 e=Math.min(this.liveGrid.topOfLastPage(),f);
4054 Rico.log("updateGrid: new rowcnt="+d+" newpos="+e);
4055 if(b==0&&this.liveGrid.sizeTo=="data"){Rico.runLater(100,this.liveGrid,"adjustPageSize")
4056 }this.liveGrid.scrollToRow(e);
4057 if(this.isInRange(e)){this.liveGrid.refreshContents(e)
4060 }}else{var a=f+this.rcvdRows;
4061 if(a>this.totalRows){var c=a;
4062 Rico.log("extending totrows to "+c);
4063 this.setTotalRows(c)
4064 }}e=this.liveGrid.pixeltorow(this.liveGrid.scrollDiv.scrollTop);
4065 Rico.log("updateGrid: newpos="+e);
4066 this.liveGrid.refreshContents(e)
4068 Rico.Buffer.AjaxSQL=function(c,b,a){this.initialize(c,b,a)
4070 Rico.Buffer.AjaxSQL.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Buffer.AjaxXML());
4071 Rico.extend(this,Rico.Buffer.AjaxSQLMethods);
4073 this.options.canFilter=true;
4074 this.options.largeBufferSize=7;
4075 this.options.nearLimitFactor=1;
4076 Rico.extend(this.options,b||{});
4077 Rico.extend(this.ajaxOptions,a||{})
4079 Rico.Buffer.AjaxSQLMethods={registerGrid:function(a){this.liveGrid=a;
4080 this.sessionExpired=false;
4081 this.timerMsg=document.getElementById(a.tableId+"_timer");
4082 if(this.options.TimeOut&&this.timerMsg){if(!this.timerMsg.title){this.timerMsg.title=Rico.getPhraseById("sessionExpireMinutes")
4083 }this.restartSessionTimer()
4084 }},setBufferSize:function(a){this.maxFetchSize=Math.max(50,parseInt(this.options.largeBufferSize*a,10));
4085 this.nearLimit=parseInt(this.options.nearLimitFactor*a,10);
4086 this.maxBufferSize=this.maxFetchSize*3
4087 },restartSessionTimer:function(){if(this.sessionExpired==true){return
4088 }this.sessionEndTime=(new Date()).getTime()+this.options.TimeOut*60000;
4089 if(this.sessionTimer){clearTimeout(this.sessionTimer)
4090 }this.updateSessionTimer()
4091 },updateSessionTimer:function(){var b=(new Date()).getTime();
4092 if(b>this.sessionEndTime){this.displaySessionTimer(Rico.getPhraseById("sessionExpired"));
4093 this.timerMsg.style.backgroundColor="red";
4094 this.sessionExpired=true
4095 }else{var a=Math.ceil((this.sessionEndTime-b)/60000);
4096 this.displaySessionTimer(a);
4097 this.sessionTimer=Rico.runLater(10000,this,"updateSessionTimer")
4098 }},displaySessionTimer:function(a){this.timerMsg.innerHTML=" "+a+" "
4099 },refresh:function(b){var a=this.liveGrid.lastRowPos;
4101 if(b){this.setTotalRows(0);
4102 this.foundRowCount=false
4103 }this.liveGrid.clearBookmark();
4104 this.liveGrid.clearRows();
4106 },fetch:function(e){Rico.log("AjaxSQL fetch: offset="+e+", lastOffset="+this.lastOffset);
4107 if(this.processingRequest){Rico.log("AjaxSQL fetch: queue request");
4108 this.pendingRequest=e;
4110 }if(e<0){this.clear();
4111 this.setTotalRows(0);
4112 this.foundRowCount=false;
4114 }var d=this.lastOffset;
4116 if(this.isInRange(e)){Rico.log("AjaxSQL fetch: in buffer");
4117 this.liveGrid.refreshContents(e);
4118 if(e>d){if(e+this.liveGrid.pageSize<this.endPos()-this.nearLimit){return
4119 }if(this.endPos()==this.totalRows&&this.foundRowCount){return
4120 }}else{if(e<d){if(e>this.startPos+this.nearLimit){return
4121 }if(this.startPos==0){return
4123 }}}if(e>=this.totalRows&&this.foundRowCount){return
4124 }this.processingRequest=true;
4125 Rico.log("AjaxSQL fetch: processing offset="+e);
4126 var c=this.getFetchOffset(e);
4127 var a=this.getFetchSize(c);
4129 this.liveGrid.showMsg(this.options.waitMsg);
4130 this.timeoutHandler=Rico.runLater(this.options.bufferTimeout,this,"handleTimedOut");
4131 this.ajaxOptions.parameters=this.formQueryHashSQL(c,a,this.options.fmt);
4132 this.requestCount++;
4133 Rico.log("sending req #"+this.requestCount);
4135 if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=function(g){b.ajaxUpdate(c,g)
4137 new Rico.ajaxRequest(this.dataSource,this.ajaxOptions)
4138 }else{this.ajaxOptions.onComplete=function(h,j,g,i){b.jsUpdate(c,h,j,g,i)
4140 this.dataSource(this.ajaxOptions)
4141 }},formQueryHashSQL:function(g,h,d){var k=this.formQueryHashXML(g,h);
4142 k[this.liveGrid.actionId]="query";
4144 }Rico.extend(k,this.sortParm);
4146 b<this.liveGrid.columns.length;
4147 b++){var j=this.liveGrid.columns[b];
4148 if(j.filterType==Rico.ColumnConst.UNFILTERED){continue
4149 }var a=typeof(j.format.filterCol)=="number"?j.format.filterCol:j.index;
4150 k["f["+a+"][op]"]=j.filterOp;
4151 k["f["+a+"][len]"]=j.filterValues.length;
4153 e<j.filterValues.length;
4154 e++){var f=j.filterValues[e];
4155 if(j.filterOp=="LIKE"&&f.indexOf("*")==-1){f="*"+f+"*"
4156 }k["f["+a+"]["+e+"]"]=f
4158 },getFetchSize:function(a){var b=0;
4159 if(a>=this.startPos){var c=this.maxFetchSize+a;
4161 if(a==0&&b<this.maxFetchSize){b=this.maxFetchSize
4162 }Rico.log("getFetchSize/append, adjustedSize="+b+" adjustedOffset="+a+" endFetchOffset="+c)
4163 }else{b=Math.min(this.startPos-a,this.maxFetchSize)
4165 },getFetchOffset:function(b){var a=b;
4166 if(b>this.startPos){a=Math.max(b,this.endPos())
4167 }else{if(b+this.maxFetchSize>=this.startPos){a=Math.max(this.startPos-this.maxFetchSize,0)
4169 },updateBuffer:function(d,a,b){Rico.log("updateBuffer: start="+d+", # of rows="+this.rcvdRows);
4170 if(this.rows.length==0){this.rows=a;
4173 }else{if(d>this.startPos){if(this.startPos+this.rows.length<d){this.rows=a;
4176 }else{this.rows=this.rows.concat(a.slice(0,a.length));
4177 if(this.attr){this.attr=this.attr.concat(b.slice(0,b.length))
4178 }if(this.rows.length>this.maxBufferSize){var c=this.rows.length;
4179 this.rows=this.rows.slice(this.rows.length-this.maxBufferSize,this.rows.length);
4180 if(this.attr){this.attr=this.attr.slice(this.attr.length-this.maxBufferSize,this.attr.length)
4181 }this.startPos=this.startPos+(c-this.rows.length)
4182 }}}else{if(d+a.length<this.startPos){this.rows=a
4183 }else{this.rows=a.slice(0,this.startPos).concat(this.rows);
4184 if(this.maxBufferSize&&this.rows.length>this.maxBufferSize){this.rows=this.rows.slice(0,this.maxBufferSize)
4186 }}this.size=this.rows.length
4187 },sortBuffer:function(b){this.sortParm={};
4188 var a=this.liveGrid.columns[b];
4189 if(this.options.sortParmFmt){this.sortParm.sort_col=a[this.options.sortParmFmt];
4190 this.sortParm.sort_dir=a.getSortDirection()
4191 }else{this.sortParm["s"+b]=a.getSortDirection()
4193 },printAllSQL:function(a){var c=this.formQueryHashSQL(0,this.liveGrid.options.maxPrint,a);
4194 c.hidden=this.liveGrid.listInvisible("index").join(",");
4195 var b=this.dataSource+"?"+Rico.toQueryString(c);
4196 window.open(b,"",this.liveGrid.options.exportWindow)
4197 },printVisibleSQL:function(a){var c=this.formQueryHashSQL(this.liveGrid.contentStartPos-1,this.liveGrid.pageSize,a);
4198 c.hidden=this.liveGrid.listInvisible("index").join(",");
4199 var b=this.dataSource+"?"+Rico.toQueryString(c);
4200 window.open(b,"",this.liveGrid.options.exportWindow)
4201 },_printAll:function(){this.liveGrid.exportStart();
4202 this.ajaxOptions.parameters=this.formQueryHashSQL(0,this.liveGrid.options.maxPrint);
4204 this.ajaxOptions.onComplete=function(){a._jsExport()
4206 this.dataSource(this.ajaxOptions)
4207 },_jsExport:function(b,d,a,c){Rico.log("_jsExport: "+arguments.length);
4208 if(c){Rico.log("_jsExport: received error="+c);
4209 this.liveGrid.showMsg(Rico.getPhraseById("requestError",c));
4211 }this.exportBuffer(b,0);
4212 this.liveGrid.exportFinish()
4214 if(typeof Rico=="undefined"){throw ("LiveGridForms requires the Rico JavaScript framework")
4215 }Rico.TableEdit=function(a){this.initialize(a)
4217 Rico.TableEdit.prototype={initialize:function(b){Rico.log("Rico.TableEdit initialize: "+b.tableId);
4219 this.options={maxDisplayLen:20,panelHeight:200,panelWidth:500,compact:false,RecordName:Rico.getPhraseById("record"),updateURL:window.location.href,showSaveMsg:"errors"};
4220 Rico.extend(this.options,b.options);
4223 this.menu.options.dataMenuHandler=function(d,f,g,e){return a.editMenu(d,f,g,e)
4225 this.menu.ignoreClicks();
4226 this.editText=Rico.getPhraseById("editRecord",this.options.RecordName);
4227 this.cloneText=Rico.getPhraseById("cloneRecord",this.options.RecordName);
4228 this.delText=Rico.getPhraseById("deleteRecord",this.options.RecordName);
4229 this.addText=Rico.getPhraseById("addRecord",this.options.RecordName);
4230 this.buttonHover=new Rico.HoverSet();
4231 this.dateRegExp=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
4232 Rico.EditControls.atLoad();
4233 this.createKeyArray();
4234 this.createEditDiv();
4235 this.saveMsg=Rico.$(b.tableId+"_savemsg");
4236 Rico.eventBind(document,"click",Rico.eventHandle(this,"clearSaveMsg"));
4237 this.extraMenuItems=[];
4238 this.responseHandler=function(){a.processResponse()
4240 Rico.log("Rico.TableEdit.initialize complete")
4241 },createKeyArray:function(){this.keys=[];
4243 a<this.grid.columns.length;
4244 a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.isKey){this.keys.push({colidx:a})
4245 }}},createEditDiv:function(){this.requestCount=1;
4246 this.formPopup=this.createWindow();
4247 Rico.addClass(this.formPopup.content.parentNode,"ricoLG_editDiv");
4248 if(this.options.canEdit||this.options.canAdd){this.startForm();
4249 this.createForm(this.form)
4250 }else{var a=this.createButton(Rico.getPhraseById("close"));
4251 Rico.eventBind(a,"click",Rico.eventHandle(this,"cancelEdit"),false);
4252 this.createForm(this.formPopup.contentDiv)
4253 }this.editDivCreated=true;
4254 this.responseDialog=this.grid.createDiv("editResponse",document.body);
4255 this.responseDialog.style.display="none";
4256 var b=document.createElement("button");
4257 b.appendChild(document.createTextNode("OK"));
4258 Rico.eventBind(b,"click",Rico.eventHandle(this,"ackResponse"));
4259 this.responseDialog.appendChild(b);
4260 this.responseDiv=this.grid.createDiv("editResponseText",this.responseDialog);
4261 if(this.panelGroup){Rico.log("createEditDiv complete, requestCount="+this.requestCount);
4262 Rico.runLater(50,this,"initPanelGroup")
4263 }},createWindow:function(){var a=this;
4264 return new Rico.Window("",{closeFunc:function(){a.makeFormInvisible()
4265 },overflow:this.options.ColGroups?"hidden":"auto"})
4266 },initPanelGroup:function(){this.requestCount--;
4267 Rico.log("initPanelGroup: "+this.requestCount);
4268 if(this.requestCount>0){return
4269 }var a=parseInt(this.options.panelWidth,10);
4270 if(this.form){if(Rico.isWebKit){this.formPopup.container.style.display="block"
4271 }this.options.bgColor=Rico.Color.createColorFromBackground(this.form).toString()
4272 }this.formPopup.container.style.display="none";
4273 this.formPanels=new Rico.TabbedPanel(this.panelGroup,this.options)
4274 },notEmpty:function(a){return typeof(a)!="undefined"
4275 },startForm:function(){this.form=document.createElement("form");
4276 this.form.onsubmit=function(){return false
4278 this.form.autocomplete="off";
4279 this.formPopup.contentDiv.appendChild(this.form);
4280 var e=document.createElement("div");
4281 e.className="ButtonBar";
4282 var d=e.appendChild(this.createButton(Rico.getPhraseById("saveRecord",this.options.RecordName)));
4283 Rico.eventBind(d,"click",Rico.eventHandle(this,"TESubmit"),false);
4284 d=e.appendChild(this.createButton(Rico.getPhraseById("cancel")));
4285 Rico.eventBind(d,"click",Rico.eventHandle(this,"cancelEdit"),false);
4286 this.form.appendChild(e);
4287 this.hiddenFields=document.createElement("div");
4288 this.hiddenFields.style.display="none";
4289 this.action=this.appendHiddenField(this.grid.actionId,"");
4292 c<this.grid.columns.length;
4293 c++){a=this.grid.columns[c].format;
4294 if(a&&a.FormView&&a.FormView=="hidden"){this.appendHiddenField(a.FieldName,a.ColData)
4297 b++){this.keys[b].keyField=this.appendHiddenField("_k"+this.keys[b].colidx,"")
4298 }this.form.appendChild(this.hiddenFields)
4299 },createButton:function(b){var a=document.createElement("a");
4300 a.href="javascript:void(0)";
4302 a.className="RicoButton";
4303 if(Rico.theme.button){Rico.addClass(a,Rico.theme.button)
4304 }this.buttonHover.add(a);
4306 },createPanel:function(c){var e=false;
4308 b<this.grid.columns.length;
4309 b++){var a=this.grid.columns[b].format;
4311 }if(!a.EntryType){continue
4312 }if(a.EntryType=="H"){continue
4313 }if(a.FormView&&a.FormView=="hidden"){continue
4314 }var d=a.ColGroupIdx||0;
4317 }}if(!e){return null
4318 }this.panelHdr[c]=document.createElement("li");
4319 this.panelHdr[c].innerHTML=this.options.ColGroups[c];
4320 this.panelHdrs.appendChild(this.panelHdr[c]);
4321 this.panelContent[c]=document.createElement("div");
4322 this.panelContents.appendChild(this.panelContent[c]);
4323 this.panelActualIdx[c]=this.panelCnt++;
4324 return this.createFormTable(this.panelContent[c],"tabContent")
4325 },createForm:function(e){var c,f,a,d,b=[];
4328 this.panelContent=[];
4329 if(this.options.ColGroups){this.panelGroup=document.createElement("div");
4330 this.panelGroup.className="tabPanelGroup";
4331 this.panelHdrs=document.createElement("ul");
4332 this.panelGroup.appendChild(this.panelHdrs);
4333 this.panelContents=document.createElement("div");
4334 this.panelContents.className="tabContentContainer";
4335 this.panelGroup.appendChild(this.panelContents);
4336 this.panelActualIdx=[];
4337 e.appendChild(this.panelGroup);
4338 if(this.grid.direction=="rtl"){for(c=this.options.ColGroups.length-1;
4340 c--){b[c]=this.createPanel(c)
4342 c<this.options.ColGroups.length;
4343 c++){b[c]=this.createPanel(c)
4344 }}e.appendChild(this.panelGroup)
4345 }else{f=document.createElement("div");
4346 f.className="noTabContent";
4347 b[0]=this.createFormTable(f);
4350 c<this.grid.columns.length;
4351 c++){a=this.grid.columns[c].format;
4353 }d=a.ColGroupIdx||0;
4354 if(b[d]){this.appendFormField(this.grid.columns[c],b[d])
4355 }if(typeof a.pattern=="string"){switch(a.pattern){case"email":a.regexp=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
4357 case"float-unsigned":a.regexp=/^\d+(\.\d+)?$/;
4359 case"float-signed":a.regexp=/^[-+]?\d+(\.\d+)?$/;
4361 case"int-unsigned":a.regexp=/^\d+$/;
4363 case"int-signed":a.regexp=/^[-+]?\d+$/;
4365 default:a.regexp=new RegExp(a.pattern);
4367 }}}},createFormTable:function(b){var a=document.createElement("table");
4371 },appendHiddenField:function(a,b){var c=Rico.createFormField(this.hiddenFields,"input","hidden",a,a);
4374 },appendFormField:function(c,i){var b=c.format;
4375 if(!b.EntryType){return
4376 }if(b.EntryType=="H"){return
4377 }if(b.FormView){return
4378 }Rico.log("appendFormField: "+c.displayName+" - "+b.EntryType);
4379 var j=b.noFormBreak&&i.rows.length>0?i.rows[i.rows.length-1]:i.insertRow(-1);
4380 var h=j.insertCell(-1);
4382 if(h.noWrap){h.noWrap=true
4383 }var f=j.insertCell(-1);
4384 if(f.noWrap){f.noWrap=true
4385 }h.id="lbl_"+b.FieldName;
4386 var e,a=b.FieldName;
4387 switch(b.EntryType){case"TA":case"tinyMCE":e=Rico.createFormField(f,"textarea",null,a);
4388 e.cols=b.TxtAreaCols;
4389 e.rows=b.TxtAreaRows;
4390 e.innerHTML=b.ColData;
4391 h.style.verticalAlign="top";
4393 case"R":case"RL":e=Rico.createFormField(f,"div",null,a);
4394 if(b.DescriptionField){e.RicoUpdate=b.DescriptionField
4395 }if(b.MultiSelect){Rico.addClass(e,"MultiSelect")
4396 }if(b.isNullable&&!b.MultiSelect){this.addSelectNone(e)
4397 }this.selectValuesRequest(e,c);
4399 case"N":e=Rico.createFormField(f,"select",null,a);
4400 if(b.isNullable){this.addSelectNone(e)
4401 }Rico.eventBind(e,"change",Rico.eventHandle(this,"checkSelectNew"));
4402 this.selectValuesRequest(e,c);
4403 e=document.createElement("span");
4404 e.className="ricoEditLabel";
4405 e.id="labelnew__"+b.FieldName;
4406 e.innerHTML=" "+Rico.getPhraseById("formNewValue").replace(" "," ");
4408 a="textnew__"+b.FieldName;
4409 e=Rico.createFormField(f,"input","text",a,a);
4411 case"S":case"SL":if(b.ReadOnly){e=Rico.createFormField(f,"input","text",a,a);
4413 }else{e=Rico.createFormField(f,"select",null,a);
4414 if(b.MultiSelect){e.multiple=true
4415 }if(b.SelectRows){e.size=parseInt(b.SelectRows,10)
4416 }if(b.isNullable&&!b.MultiSelect){this.addSelectNone(e)
4417 }if(b.DescriptionField){e.RicoUpdate=b.DescriptionField;
4418 Rico.eventBind(e,"change",Rico.eventHandle(this,"selectClick"),false)
4419 }this.selectValuesRequest(e,c)
4421 case"D":if(!b.isNullable){b.required=true
4422 }if(!b.dateFmt){b.dateFmt=Rico.dateFmt
4423 }if(!b.Help){b.Help=b.dateFmt
4424 }if(typeof b.min=="string"){b.min=Rico.setISO8601(b.min)||new Date(b.min)
4425 }if(typeof b.max=="string"){b.max=Rico.setISO8601(b.max)||new Date(b.max)
4426 }if(Rico.inputtypes.date){e=Rico.createFormField(f,"input","date",a,a);
4427 e.required=b.required;
4428 if(b.min){e.min=Rico.toISO8601String(b.min,3)
4429 }if(b.max){e.max=Rico.toISO8601String(b.max,3)
4430 }e.required=b.required;
4432 }else{e=Rico.createFormField(f,"input","text",a,a)
4433 }this.initField(e,b);
4435 case"I":if(!b.isNullable){b.required=true
4436 }if(!b.pattern){b.pattern="int-signed"
4437 }if(Rico.inputtypes.number){e=Rico.createFormField(f,"input","number",a,a);
4438 e.required=b.required;
4442 }else{e=Rico.createFormField(f,"input","text",a,a)
4443 }if(typeof b.min=="string"){b.min=parseInt(b.min,10)
4444 }if(typeof b.max=="string"){b.max=parseInt(b.max,10)
4445 }this.initField(e,b);
4447 case"F":if(!b.isNullable){b.required=true
4448 }if(!b.pattern){b.pattern="float-signed"
4449 }e=Rico.createFormField(f,"input","text",a,a);
4450 this.initField(e,b);
4451 if(typeof b.min=="string"){b.min=parseFloat(b.min)
4452 }if(typeof b.max=="string"){b.max=parseFloat(b.max)
4454 default:e=Rico.createFormField(f,"input","text",a,a);
4455 if(!b.isNullable&&b.EntryType!="T"){b.required=true
4456 }this.initField(e,b);
4458 }if(e&&b.SelectCtl){Rico.EditControls.applyTo(c,e)
4460 h.className="ricoEditLabel";
4461 if(b.Help){h.title=b.Help;
4462 g=" <span class='rico-icon rico-info'></span>"
4463 }var d=b.EntryType.length>1&&b.EntryType.charAt(1)=="L"?c.next.displayName:c.displayName;
4465 },addSelectNone:function(a){this.addSelectOption(a,this.options.TableSelectNone,Rico.getPhraseById("selectNone"))
4466 },initField:function(b,a){if(a.Length){b.maxLength=a.Length;
4467 b.size=Math.min(a.Length,this.options.maxDisplayLen)
4469 },selectClick:function(c){var b=Rico.eventElement(c);
4470 if(b.readOnly){Rico.eventStop(c);
4472 }if(b.RicoUpdate){var a=b.options[b.selectedIndex];
4473 Rico.$(b.RicoUpdate).value=a.innerHTML
4474 }},radioClick:function(c){var b=Rico.eventElement(c);
4475 if(b.readOnly){Rico.eventStop(c);
4477 }var a=Rico.getParentByTagName(b,"div");
4478 if(a.RicoUpdate){Rico.$(a.RicoUpdate).value=b.nextSibling.innerHTML
4479 }},checkSelectNew:function(a){this.updateSelectNew(Rico.eventElement(a))
4480 },updateSelectNew:function(b){var a=(b.value==this.options.TableSelectNew)?"":"hidden";
4481 Rico.$("labelnew__"+b.id).style.visibility=a;
4482 Rico.$("textnew__"+b.id).style.visibility=a
4483 },selectValuesRequest:function(g,f){var a=f.format;
4484 if(a.SelectValues){var b=a.SelectValues.split(",");
4487 e++){this.addSelectOption(g,b[e],b[e],e)
4488 }}else{this.requestCount++;
4490 Rico.extend(d,this.grid.buffer.ajaxOptions);
4491 d.parameters={id:this.grid.tableId,offset:"0",page_size:"-1",edit:f.index};
4492 d.parameters[this.grid.actionId]="query";
4493 d.onComplete=function(h){c.selectValuesUpdate(g,h)
4495 new Rico.ajaxRequest(this.grid.buffer.dataSource,d);
4496 Rico.log("selectValuesRequest: "+a.FieldName)
4497 }},selectValuesUpdate:function(a,c){var b=c.responseXML.getElementsByTagName("ajax-response");
4498 Rico.log("selectValuesUpdate: "+c.status);
4499 if(b==null||b.length!=1){return
4501 var j=b.getElementsByTagName("error");
4502 if(j.length>0){var g=Rico.getContentAsString(j[0],this.grid.buffer.isEncoded);
4503 Rico.log("Data provider returned an error:\n"+g);
4504 alert(Rico.getPhraseById("requestError",g));
4506 }b=b.getElementsByTagName("response")[0];
4507 var h=b.getElementsByTagName("rows")[0];
4508 var k=this.grid.buffer.dom2jstable(h);
4509 Rico.log("selectValuesUpdate: id="+a.id+" rows="+k.length);
4512 e++){if(k[e].length>0){var f=k[e][0];
4513 var d=(k[e].length>1)?k[e][1]:f;
4514 this.addSelectOption(a,f,d,e)
4515 }}if(Rico.$("textnew__"+a.id)){this.addSelectOption(a,this.options.TableSelectNew,Rico.getPhraseById("selectNewVal"))
4516 }if(this.panelGroup){Rico.runLater(50,this,"initPanelGroup")
4517 }},addSelectOption:function(c,e,f,a){switch(c.tagName.toLowerCase()){case"div":var b=Rico.createFormField(c,"input",Rico.hasClass(c,"MultiSelect")?"checkbox":"radio",c.id+"_"+a,c.id);
4519 var d=document.createElement("label");
4523 Rico.eventBind(b,"click",Rico.eventHandle(this,"radioClick"),false);
4525 case"select":Rico.addSelectOption(c,e,f);
4527 }},clearSaveMsg:function(){if(this.saveMsg){this.saveMsg.innerHTML=""
4528 }},addMenuItem:function(c,b,a){this.extraMenuItems.push({menuText:c,menuAction:b,enabled:a})
4529 },editMenu:function(d,h,j,e){this.clearSaveMsg();
4530 if(this.grid.buffer.sessionExpired==true||this.grid.buffer.startPos<0){return false
4532 var g=Rico.$("pageTitle");
4533 var f=g?g.innerHTML:document.title;
4534 this.menu.addMenuHeading(f);
4536 if(e==false){for(var b=0;
4537 b<this.extraMenuItems.length;
4538 b++){this.menu.addMenuItem(this.extraMenuItems[b].menuText,this.extraMenuItems[b].menuAction,this.extraMenuItems[b].enabled)
4539 }this.menu.addMenuItem(this.editText,function(){a.editRecord()
4541 this.menu.addMenuItem(this.delText,function(){a.deleteRecord()
4542 },this.canDelete(h));
4543 if(this.options.canClone){this.menu.addMenuItem(this.cloneText,function(){a.cloneRecord()
4544 },this.canAdd(h)&&this.canEdit(h))
4545 }}this.menu.addMenuItem(this.addText,function(){a.addRecord()
4548 },canAdd:function(a){return(typeof this.options.canAdd=="function")?this.options.canAdd(a):this.options.canAdd
4549 },canEdit:function(a){return(typeof this.options.canEdit=="function")?this.options.canEdit(a):this.options.canEdit
4550 },canDelete:function(a){return(typeof this.options.canDelete=="function")?this.options.canDelete(a):this.options.canDelete
4551 },cancelEdit:function(a){Rico.eventStop(a);
4552 this.makeFormInvisible();
4553 this.grid.highlightEnabled=true;
4554 this.menu.cancelmenu();
4556 },setField:function(g,m){var p=this.grid.columns[g].format;
4557 var k=Rico.$(p.FieldName);
4560 }Rico.log("setField: "+p.FieldName+"="+m);
4561 switch(k.tagName.toUpperCase()){case"DIV":c=k.getElementsByTagName("INPUT");
4563 if(p.MultiSelect&&m){n=m.split(",");
4570 j++){c[j].checked=f[c[j].value]==1
4572 case"INPUT":if(p.EntryType=="D"&&m!=p.ColData){n=m.split(/\s|T/);
4574 if(this.isTextInput(k)){var l=Rico.setISO8601(m);
4575 if(l){m=Rico.formatDate(l,p.dateFmt)
4578 case"SELECT":b=k.options;
4580 if(p.MultiSelect&&m){n=m.split(",");
4586 j++){b[j].selected=f[b[j].value]==1
4589 j++){if(b[j].value==m){k.selectedIndex=j;
4591 }}}if(p.EntryType=="N"){h=Rico.$("textnew__"+k.id);
4592 if(!h){alert('Warning: unable to find id "textnew__'+k.id+'"')
4594 if(k.selectedIndex!=j){k.selectedIndex=b.length-1
4595 }this.updateSelectNew(k)
4597 case"TEXTAREA":k.value=m;
4598 if(p.EntryType=="tinyMCE"&&typeof(tinyMCE)!="undefined"&&this.initialized){if(tinyMCE.updateContent){tinyMCE.updateContent(k.id)
4599 }else{tinyMCE.execInstanceCommand(k.id,"mceSetContent",false,m)
4601 }},setReadOnly:function(h){for(var g,f=0;
4602 f<this.grid.columns.length;
4603 f++){var b=this.grid.columns[f].format;
4605 }var k=Rico.$(b.FieldName);
4607 }switch(h){case"ins":g=!b.Writeable||b.ReadOnly||b.UpdateOnly;
4609 case"upd":g=!b.Writeable||b.ReadOnly||b.InsertOnly;
4613 }switch(k.tagName.toUpperCase()){case"DIV":var c=k.getElementsByTagName("INPUT");
4616 d++){c[d].disabled=g
4618 case"SELECT":if(b.EntryType=="N"){var a=Rico.$("textnew__"+k.id);
4622 case"TEXTAREA":case"INPUT":k.disabled=g;
4623 if(b.selectIcon){b.selectIcon.style.display=g?"none":""
4625 }}},hideResponse:function(a){this.responseDiv.innerHTML=a;
4626 this.responseDialog.style.display="none"
4627 },showResponse:function(){var a=Rico.cumulativeOffset(this.grid.outerDiv);
4628 a.top+=Rico.docScrollTop();
4629 this.responseDialog.style.top=a.top+"px";
4630 this.responseDialog.style.left=a.left+"px";
4631 this.responseDialog.style.display=""
4632 },processResponse:function(g){var d,f=true;
4633 Rico.log("Processing response from form submittal");
4634 this.responseDiv.innerHTML=g.responseText;
4635 var e=Rico.select(".ricoFormResponse",this.responseDiv);
4636 if(e){var c=Rico.trim(e[0].className).split(/\s+/)[1];
4637 d=Rico.getPhraseById(c,this.options.RecordName)
4638 }else{var b=this.responseDiv.childNodes;
4639 for(var a=b.length-1;
4641 a--){if(b[a].nodeType==1&&b[a].nodeName!="P"&&b[a].nodeName!="DIV"&&b[a].nodeName!="BR"){this.responseDiv.removeChild(b[a])
4642 }}d=Rico.stripTags(this.responseDiv.innerHTML);
4643 f=(d.toLowerCase().indexOf("error")==-1)
4644 }if(f&&this.options.showSaveMsg!="full"){this.hideResponse("");
4645 this.grid.resetContents();
4646 this.grid.buffer.foundRowCount=false;
4647 this.grid.buffer.fetch(this.grid.lastRowPos||0);
4648 if(this.saveMsg){this.saveMsg.innerHTML=" "+d+" "
4649 }}this.processCallback(this.options.onSubmitResponse);
4650 Rico.log("Processing response completed")
4651 },processCallback:function(callback){switch(typeof callback){case"string":return eval(callback);
4652 case"function":return callback()
4653 }},ackResponse:function(a){this.hideResponse("");
4654 this.grid.highlightEnabled=true
4655 },cloneRecord:function(){this.formPopup.setTitle(this.cloneText);
4656 this.displayEditForm("ins")
4657 },editRecord:function(){this.formPopup.setTitle(this.editText);
4658 this.displayEditForm("upd")
4659 },displayEditForm:function(e){this.grid.highlightEnabled=false;
4660 this.menu.cancelmenu();
4661 this.hideResponse(Rico.getPhraseById("saving"));
4662 this.grid.outerDiv.style.cursor="auto";
4663 this.action.value=e;
4665 d<this.grid.columns.length;
4666 d++){var f=this.grid.columns[d];
4667 if(f.format){var b=f.getValue(this.rowIdx);
4669 if(f.format.selectDesc){if(f.format.EntryType.length>1&&f.format.EntryType.charAt(1)=="L"){b=this.grid.columns[d+1].getValue(this.rowIdx)
4671 if(b===""){b=" "
4672 }f.format.selectDesc.innerHTML=b
4673 }if(f.format.SelectCtl){Rico.EditControls.displayClrImg(f,!f.format.InsertOnly)
4674 }}}this.setReadOnly(e);
4677 a++){this.keys[a].keyField.value=this.grid.buffer.getWindowValue(this.rowIdx,this.keys[a].colidx)
4678 }this.makeFormVisible(this.rowIdx)
4679 },addPrepare:function(){this.hideResponse(Rico.getPhraseById("saving"));
4681 this.setReadOnly("ins");
4682 this.action.value="ins";
4684 a<this.grid.columns.length;
4685 a++){var b=this.grid.columns[a];
4686 if(b.format){this.setField(a,b.format.ColData);
4687 if(b.format.SelectCtl){Rico.EditControls.resetValue(b);
4688 Rico.EditControls.displayClrImg(b,!b.format.UpdateOnly)
4689 }}}},addRecord:function(){this.menu.cancelmenu();
4690 this.formPopup.setTitle(this.addText);
4692 this.makeFormVisible(-1);
4693 if(this.formPanels){this.formPanels.select(0)
4694 }},drillDown:function(b,a,c){return this.grid.drillDown.apply(this.grid,arguments)
4695 },setDetailFilter:function(a,b){this.grid.setDetailFilter(a,b)
4696 },makeFormVisible:function(k){this.formPopup.container.style.display="block";
4697 var c=this.formPopup.container.offsetWidth;
4698 var h=Rico.cumulativeOffset(this.grid.outerDiv);
4699 var d=Rico.windowWidth();
4700 this.formPopup.container.style.left=c+h.left>d?(d-c)+"px":(h.left+1)+"px";
4701 var g=Rico.docScrollTop();
4702 var a=this.formPopup.container.offsetHeight;
4703 var f=h.top+this.grid.hdrHt+g;
4704 var b=Rico.windowHeight()+g;
4705 if(k>=0){f+=(k+1)*this.grid.rowHeight;
4706 if(f+a>b){f-=(a+this.grid.rowHeight)
4707 }}else{if(f+a>b){f=b-a-2
4708 }}if(this.processCallback(this.options.formOpen)===false){return
4709 }this.formPopup.openPopup(null,Math.max(f,g));
4710 this.formPopup.container.style.visibility="visible";
4711 Rico.EditControls.setZ(Rico.getStyle(this.formPopup.container,"zIndex"));
4712 if(this.initialized){return
4715 e<this.grid.columns.length;
4716 e++){j=this.grid.columns[e].format;
4717 if(!j||!j.EntryType||!j.FieldName){continue
4718 }switch(j.EntryType){case"tinyMCE":if(typeof tinyMCE!="undefined"){tinyMCE.execCommand("mceAddControl",true,j.FieldName)
4720 }}this.initialized=true
4721 },makeFormInvisible:function(){for(var a=0;
4722 a<this.grid.columns.length;
4723 a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.SelectCtl){Rico.EditControls.close(this.grid.columns[a].format.SelectCtl)
4724 }}this.formPopup.container.style.visibility="hidden";
4725 this.formPopup.closePopup();
4726 this.processCallback(this.options.formClose)
4727 },getConfirmDesc:function(a){return Rico.stripTags(this.grid.cell(a,this.options.ConfirmDeleteCol).innerHTML).replace(" "," ")
4728 },deleteRecord:function(){this.menu.cancelmenu();
4730 switch(this.options.ConfirmDeleteCol){case -1:f=Rico.getPhraseById("thisRecord",this.options.RecordName);
4732 case -2:for(var b=0;
4734 b++){var c=this.keys[b].colidx;
4735 var a=this.grid.columns[c].format;
4736 if(a.EntryType.length>1&&a.EntryType.charAt(1)=="L"){c++
4737 }var e=Rico.stripTags(this.grid.cell(rowIdx,c).innerHTML).replace(/ /g," ");
4739 }f+=this.grid.columns[c].displayName+" "+e
4741 default:f='"'+Rico.truncate(this.getConfirmDesc(this.rowIdx),50)+'"';
4743 }if(!this.options.ConfirmDelete.valueOf||confirm(Rico.getPhraseById("confirmDelete",f))){this.hideResponse(Rico.getPhraseById("deleting"));
4744 this.showResponse();
4746 d[this.grid.actionId]="del";
4749 b++){var c=this.keys[b].colidx;
4750 var e=this.grid.columns[c].getValue(this.rowIdx);
4752 }new Rico.ajaxRequest(this.options.updateURL,{parameters:d,method:"post",onComplete:this.responseHandler})
4753 }this.menu.cancelmenu()
4754 },validationMsg:function(d,c,e){var b=this.grid.columns[c];
4755 if(this.formPanels){this.formPanels.select(this.panelActualIdx[b.format.ColGroupIdx])
4756 }var a=Rico.stripTags(b.formLabel.innerHTML).replace(/ /g," ");
4757 var f=Rico.getPhraseById(e,' "'+a+'"');
4758 Rico.log(" Validation error: "+f);
4759 if(b.format.Help){f+="\n\n"+b.format.Help
4761 setTimeout(function(){try{d.focus();
4765 },isTextInput:function(a){if(!a){return false
4766 }if(a.tagName.toLowerCase()!="input"){return false
4767 }if(a.type.toLowerCase()!="text"){return false
4768 }if(a.readOnly){return false
4769 }if(!Rico.visible(a)){return false
4771 },parseDate:function(c,e){dateParts={};
4772 if(!this.dateRegExp.exec(e)){return NaN
4773 }dateParts[RegExp.$1]=0;
4774 dateParts[RegExp.$3]=1;
4775 dateParts[RegExp.$5]=2;
4776 var i=c.split(/\D/);
4778 var b=g.getFullYear();
4779 if(i.length==2&&dateParts.yyyy==2){i.push(b)
4780 }if(i.length!=3){return NaN
4781 }var a=parseInt(i[dateParts.dd],10);
4782 if(a==0||a>31){return NaN
4783 }var f=parseInt(i[dateParts.mm],10)-1;
4785 }var h=parseInt(i[dateParts.yyyy],10);
4786 if(h<100){h+=b-(b%100)
4787 }g.setFullYear(h,f,a);
4789 },TESubmit:function(j){var g,h,k,l,f,d,c=[];
4791 Rico.log("Event: TESubmit called to validate input");
4793 g<this.grid.columns.length;
4794 g++){l=this.grid.columns[g].format;
4795 if(!l||!l.EntryType||!l.FieldName){continue
4796 }f=Rico.$(l.FieldName);
4797 if(!this.isTextInput(f)){continue
4798 }switch(this.action.value){case"ins":h=!l.Writeable||l.ReadOnly||l.UpdateOnly;
4800 case"upd":h=!l.Writeable||l.ReadOnly||l.InsertOnly;
4805 }Rico.log(" Validating field #"+g+" EntryType="+l.EntryType+" ("+l.FieldName+")");
4806 if(f.value.length==0){if(l.required){return this.validationMsg(f,g,"formPleaseEnter")
4808 }}if(f.value.length>0&&l.regexp&&!l.regexp.test(f.value)){return this.validationMsg(f,g,"formInvalidFmt")
4809 }switch(l.EntryType.charAt(0)){case"I":d=parseInt(f.value,10);
4811 case"F":d=parseFloat(f.value);
4813 case"D":d=this.parseDate(f.value,l.dateFmt);
4814 if(isNaN(d)){return this.validationMsg(f,g,"formInvalidFmt")
4819 }if(typeof l.min!="undefined"&&!isNaN(d)&&d<l.min){return this.validationMsg(f,g,"formOutOfRange")
4820 }if(typeof l.max!="undefined"&&!isNaN(d)&&d>l.max){return this.validationMsg(f,g,"formOutOfRange")
4821 }}if(this.processCallback(this.options.formSubmit)===false){return false
4823 g<this.grid.columns.length;
4824 g++){l=this.grid.columns[g].format;
4825 if(!l||!l.EntryType||!l.FieldName){continue
4826 }if(l.EntryType.charAt(0)!="N"){continue
4827 }var a=Rico.$(l.FieldName);
4828 if(!a||a.value!=this.options.TableSelectNew){continue
4829 }var b=Rico.$("textnew__"+a.id).value;
4830 this.addSelectOption(a,b,b)
4833 g++){c[g].e.value=Rico.formatDate(c[g].v,"yyyy-mm-dd")
4834 }if(typeof tinyMCE!="undefined"){tinyMCE.triggerSave()
4835 }this.makeFormInvisible();
4837 this.menu.cancelmenu();
4839 },sendForm:function(){this.setReadOnly("reset");
4840 this.showResponse();
4841 Rico.log("sendForm: "+this.grid.tableId);
4842 Rico.ajaxSubmit(this.form,this.options.updateURL,{method:"post",onComplete:this.responseHandler})
4844 Rico.EditControls={widgetList:{},elemList:{},zIndex:0,register:function(b,c){this.widgetList[b.id]={imgsrc:c,widget:b,currentEl:""};
4846 b.returnValue=function(d,e){a.setValue(b,d,e)
4848 Rico.log("Rico.EditControls.register:"+b.id)
4849 },setZ:function(a){this.zIndex=Math.max(this.zIndex,a+10)
4850 },atLoad:function(){for(var b in this.widgetList){var a=this.widgetList[b].widget;
4851 if(a.atLoad&&!a.atLoadComplete){Rico.log("Rico.EditControls.atLoad: "+b);
4853 a.atLoadComplete=true
4854 }}},applyTo:function(e,f){var c=this.widgetList[e.format.SelectCtl];
4856 }Rico.log("Rico.EditControls.applyTo: "+e.displayName+" : "+e.format.SelectCtl);
4857 var a,d=document.createElement("span");
4858 if(c.imgsrc.indexOf(".")==-1&&c.imgsrc.indexOf("/")==-1){a=document.createElement("span");
4859 a.className=c.imgsrc
4860 }else{a=document.createElement("img");
4862 }a.style.verticalAlign="top";
4863 a.style.marginLeft="4px";
4864 a.style.cursor="pointer";
4865 a.id=this.imgId(e.format.FieldName);
4866 Rico.eventBind(a,"click",Rico.eventHandle(this,"processClick"));
4867 f.parentNode.appendChild(d);
4868 f.parentNode.appendChild(a);
4869 f.style.display="none";
4871 if(e.format.isNullable){b=Rico.clearButton(Rico.eventHandle(this,"processClear"));
4873 f.parentNode.appendChild(b)
4874 }this.elemList[a.id]={descSpan:d,inputCtl:f,widget:c.widget,listObj:c,column:e,clrimg:b};
4875 e.format.selectIcon=a;
4876 e.format.selectDesc=d
4877 },displayClrImg:function(c,a){var b=this.elemList[this.imgId(c.format.FieldName)];
4878 if(b&&b.clrimg){b.clrimg.style.display=a?"inline-block":"none"
4879 }},processClear:function(c){var b=Rico.eventElement(c);
4880 var a=this.elemList[b.id.slice(0,-6)];
4882 }a.inputCtl.value="";
4883 a.descSpan.innerHTML=a.column._format("")
4884 },processClick:function(c){var b=Rico.eventElement(c);
4885 var a=this.elemList[b.id];
4887 }if(a.listObj.currentEl==b.id&&a.widget.container.style.display!="none"){a.widget.close();
4888 a.listObj.currentEl=""
4889 }else{a.listObj.currentEl=b.id;
4890 Rico.log("Rico.EditControls.processClick: "+a.widget.id+" : "+a.inputCtl.value);
4891 a.widget.container.style.zIndex=this.zIndex;
4892 a.widget.open(a.inputCtl.value,a.column);
4893 Rico.positionCtlOverIcon(a.widget.container,b)
4894 }},imgId:function(a){return"icon_"+a
4895 },resetValue:function(c){var b=this.elemList[this.imgId(c.format.FieldName)];
4897 }b.inputCtl.value=c.format.ColData;
4898 var a=c._format(c.format.ColData);
4899 if(a===""){a=" "
4900 }b.descSpan.innerHTML=a
4901 },setValue:function(e,a,d){var b=this.widgetList[e.id];
4905 }var c=this.elemList[f];
4907 }c.inputCtl.value=a;
4908 if(!d){d=c.column._format(a)
4909 }c.descSpan.innerHTML=d;
4910 if(c.column.format.DescriptionField){Rico.$(c.column.format.DescriptionField).value=d
4911 }},close:function(b){var a=this.widgetList[b];
4913 }if(a.widget.container.style.display!="none"){a.widget.close()
4916 Rico.addPhraseId("bookmarkExact","Listing records $1 - $2 of $3");
4917 Rico.addPhraseId("bookmarkAbout","Listing records $1 - $2 of more than $3");
4918 Rico.addPhraseId("bookmarkNoRec","No records");
4919 Rico.addPhraseId("bookmarkNoMatch","No matching records");
4920 Rico.addPhraseId("bookmarkLoading","Loading...");
4921 Rico.addPhraseId("sorting","Sorting...");
4922 Rico.addPhraseId("exportStatus","Exporting row $1");
4923 Rico.addPhraseId("filterAll","(all)");
4924 Rico.addPhraseId("filterBlank","(blank)");
4925 Rico.addPhraseId("filterEmpty","(empty)");
4926 Rico.addPhraseId("filterNotEmpty","(not empty)");
4927 Rico.addPhraseId("filterLike","contains: $1");
4928 Rico.addPhraseId("filterNot","not: $1");
4929 Rico.addPhraseId("requestError","The request for data returned an error:\n$1");
4930 Rico.addPhraseId("keywordPrompt","Enter keyword to search for (use * as a wildcard):");
4931 Rico.addPhraseId("keywordTitle","Keyword Search");
4932 Rico.addPhraseId("ok","OK");
4933 Rico.addPhraseId("gridmenuSortBy","Sort by: $1");
4934 Rico.addPhraseId("gridmenuSortAsc","Ascending");
4935 Rico.addPhraseId("gridmenuSortDesc","Descending");
4936 Rico.addPhraseId("gridmenuFilterBy","Filter by: $1");
4937 Rico.addPhraseId("gridmenuRefresh","Refresh");
4938 Rico.addPhraseId("gridmenuChgKeyword","Change keyword...");
4939 Rico.addPhraseId("gridmenuExcludeAlso","Exclude this value also");
4940 Rico.addPhraseId("gridmenuInclude","Include only this value");
4941 Rico.addPhraseId("gridmenuGreaterThan","Greater than or equal to this value");
4942 Rico.addPhraseId("gridmenuLessThan","Less than or equal to this value");
4943 Rico.addPhraseId("gridmenuContains","Contains keyword...");
4944 Rico.addPhraseId("gridmenuExclude","Exclude this value");
4945 Rico.addPhraseId("gridmenuRemoveFilter","Remove filter");
4946 Rico.addPhraseId("gridmenuRemoveAll","Remove all filters");
4947 Rico.addPhraseId("gridmenuExport","Print/Export");
4948 Rico.addPhraseId("gridmenuExportVis2Web","Visible rows to web page");
4949 Rico.addPhraseId("gridmenuExportAll2Web","All rows to web page");
4950 Rico.addPhraseId("gridmenuExportVis2SS","Visible rows to spreadsheet");
4951 Rico.addPhraseId("gridmenuExportAll2SS","All rows to spreadsheet");
4952 Rico.addPhraseId("gridmenuHideShow","Hide/Show");
4953 Rico.addPhraseId("gridmenuChooseCols","Choose columns...");
4954 Rico.addPhraseId("gridmenuHide","Hide: $1");
4955 Rico.addPhraseId("gridmenuShow","Show: $1");
4956 Rico.addPhraseId("gridmenuShowAll","Show All");
4957 Rico.addPhraseId("sessionExpireMinutes","minutes before your session expires");
4958 Rico.addPhraseId("sessionExpired","EXPIRED");
4959 Rico.addPhraseId("requestTimedOut","Request for data timed out!");
4960 Rico.addPhraseId("waitForData","Waiting for data...");
4961 Rico.addPhraseId("httpError","Received HTTP error: $1");
4962 Rico.addPhraseId("invalidResponse","Server returned an invalid response");
4963 Rico.addPhraseId("gridChooseCols","Choose columns");
4964 Rico.addPhraseId("exportComplete","Exporting complete");
4965 Rico.addPhraseId("exportInProgress","Export in progress...");
4966 Rico.addPhraseId("disableBlocker","You need to disable your browser's pop-up blocker before exporting.");
4967 Rico.addPhraseId("showFilterRow","Show filter row");
4968 Rico.addPhraseId("hideFilterRow","Hide filter row");
4969 Rico.addPhraseId("selectNone","(none)");
4970 Rico.addPhraseId("selectNewVal","(new value)");
4971 Rico.addPhraseId("record","record");
4972 Rico.addPhraseId("thisRecord","this $1");
4973 Rico.addPhraseId("confirmDelete","Are you sure you want to delete $1?");
4974 Rico.addPhraseId("deleting","Deleting...");
4975 Rico.addPhraseId("formPleaseEnter","Please enter a value for $1");
4976 Rico.addPhraseId("formInvalidFmt","Invalid format for $1");
4977 Rico.addPhraseId("formOutOfRange","Value is out of range for $1");
4978 Rico.addPhraseId("formNewValue","new value:");
4979 Rico.addPhraseId("saving","Saving...");
4980 Rico.addPhraseId("clear","clear");
4981 Rico.addPhraseId("close","Close");
4982 Rico.addPhraseId("saveRecord","Save $1");
4983 Rico.addPhraseId("cancel","Cancel");
4984 Rico.addPhraseId("editRecord","Edit $1");
4985 Rico.addPhraseId("deleteRecord","Delete this $1");
4986 Rico.addPhraseId("cloneRecord","Clone $1");
4987 Rico.addPhraseId("addRecord","Add new $1");
4988 Rico.addPhraseId("addedSuccessfully","$1 added successfully");
4989 Rico.addPhraseId("deletedSuccessfully","$1 deleted successfully");
4990 Rico.addPhraseId("updatedSuccessfully","$1 updated successfully");
4991 Rico.addPhraseId("treeSave","Save Selection");
4992 Rico.addPhraseId("treeClear","Clear All");
4993 Rico.addPhraseId("calToday","Today is $1 $2 $3");
4994 Rico.addPhraseId("calWeekHdg","Wk");
4995 Rico.addPhraseId("calYearRange","Year ($1-$2)");
4996 Rico.addPhraseId("calInvalidYear","Invalid year");
4999 Rico.dateFmt="mm/dd/yyyy";
5000 Rico.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];
5001 Rico.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];