b48b3fa3573c82d2c53917faabb4695931c6f75e
[infodrom/rico3] / ricoClient / js / rico_min.js
1 Rico.applyShadow=function(b,a){if(typeof a=="undefined"){a=true
2 }if(a){Rico.addClass(b,"ricoShadow")
3 }return b
4 };
5 Rico._OpenPopupList=[];
6 Rico._RemoveOpenPopup=function(a){if(a.openIndex>=0&&a.openIndex<Rico._OpenPopupList.length){Rico._OpenPopupList.splice(a.openIndex,1)
7 }a.openIndex=-1
8 };
9 Rico._AddOpenPopup=function(a){a.openIndex=Rico._OpenPopupList.push(a)-1
10 };
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;
14 Rico.eventStop(b);
15 a.closeFunc();
16 return false
17 }}return true
18 };
19 Rico.eventBind(document,"keyup",Rico.eventHandle(Rico,"_checkEscKey"));
20 Rico.Popup=function(b,a){this.initialize(b,a)
21 };
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};
23 this.openIndex=-1;
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
39 }else{var a=this;
40 this.closeFunc=function(){a.closePopup()
41 }
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);
63 this.dragEnabled=true
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
72 }return true
73 },_docClick:function(a){this.closeFunc();
74 return true
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);
82 Rico.eventStop(b)
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;
86 this.move(c,a);
87 this.lastMouse=b;
88 Rico.eventStop(d)
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()
110 }}};
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);
119 return b
120 };
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"));
125 if(f){d.title=f
126 }d.className=Rico.theme[b.toLowerCase()]||"rico-icon Rico"+b;
127 Rico.eventBind(c,"click",e,false);
128 new Rico.HoverSet([c]);
129 return c
130 };
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);
136 return a
137 };
138 Rico.Window=function(c,a,b){this.initialize(c,a,b)
139 };
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);
147 b=Rico.$(b);
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")));
157 if(!c&&b){c=b.title;
158 b.title=""
159 }this.setTitle(c||"&nbsp;");
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
170 }};
171 Rico.Menu=function(a){this.initialize(a)
172 };
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||{})
177 }this.hideFunc=null;
178 this.highlightElem=null
179 },createDiv:function(a){if(this.container){return
180 }var b=this;
181 var c={closeFunc:function(){b.cancelmenu()
182 }};
183 if(a){c.parent=a
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();
189 this.hidemenu();
190 this.itemCount=0
191 },showmenu:function(b,c){Rico.eventStop(b);
192 this.hideFunc=c;
193 if(this.content.childNodes.length==0){this.cancelmenu();
194 return false
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();
205 var c=f+(a?0:d);
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";
209 return false
210 },clearMenu:function(){this.clearContent();
211 this.defaultAction=null;
212 this.itemCount=0
213 },addMenuHeading:function(b){var a=document.createElement("div");
214 a.innerHTML=b;
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"});
226 f.style[d]="0px";
227 c.RicoSubmenu=e;
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
246 }this.itemCount++;
247 var c=document.createElement(typeof e=="string"?"a":"div");
248 if(arguments.length<3||d){if(typeof e=="string"){c.href=e;
249 if(f){c.target=f
250 }}else{if(f=="event"){Rico.eventBind(c,"click",e)
251 }else{c.onclick=e
252 }}c.className="enabled";
253 if(this.defaultAction==null){this.defaultAction=e
254 }}else{c.disabled=true;
255 c.className="disabled"
256 }c.innerHTML=b;
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"));
261 return c
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";
268 this.highlightElem=a
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()
274 }this.hideFunc=null;
275 this.hidemenu()
276 },hidemenu:function(){if(this.openSubMenu){this.openSubMenu.hidemenu()
277 }this.closePopup()
278 }};
279 Rico.SelectionSet=function(b,a){this.initialize(b,a)
280 };
281 Rico.SelectionSet.prototype={initialize:function(e,b){Rico.log("SelectionSet#initialize");
282 this.options=b||{};
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
288 };
289 this.onSelect=this.options.onSelect;
290 this.onFirstSelect=this.options.onFirstSelect;
291 var a=this;
292 this.clickHandler=function(f){a.selectIndex(f)
293 };
294 this.selectedIndex=-1;
295 for(var c=0;
296 c<e.length;
297 c++){this.add(e[c])
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);
301 if(!b){return 0
302 }var a=parseInt(b);
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
310 }}return -1
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);
333 if(a<0){return
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()
338 }}};
339 Rico._SelectionItem=function(b,a,c){this.add(b,a,c)
340 };
341 Rico._SelectionItem.prototype={add:function(b,a,c){this.element=b;
342 this.index=a;
343 this.callback=c;
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)
348 }};
349 Rico.HoverSet=function(b,a){this.initialize(b,a)
350 };
351 Rico.HoverSet.prototype={initialize:function(c,a){Rico.log("HoverSet#initialize");
352 a=a||{};
353 this.hoverClass=a.hoverClass||Rico.theme.hover||"hover";
354 this.hoverFunc=a.hoverNodes||function(d){return[d]
355 };
356 this.hoverSet=[];
357 if(!c){return
358 }for(var b=0;
359 b<c.length;
360 b++){this.add(c[b])
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()
363 }}};
364 Rico._HoverItem=function(b,a,c){this.add(b,a,c)
365 };
366 Rico._HoverItem.prototype={add:function(b,a,c){this.element=b;
367 this.selectFunc=a;
368 this.hoverClass=c;
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);
374 for(var b=0;
375 b<a.length;
376 b++){Rico.addClass(a[b],this.hoverClass)
377 }},mouseout:function(c){var a=this.selectFunc(this.element);
378 for(var b=0;
379 b<a.length;
380 b++){Rico.removeClass(a[b],this.hoverClass)
381 }},remove:function(){Rico.eventUnbind(element,"mousemove",this.movehandle);
382 Rico.eventUnbind(element,"mouseout",this.outhandle)
383 }};
384 Rico.Effect={};
385 Rico.Effect.easeIn=function(a){return Math.sqrt(a)
386 };
387 Rico.Effect.easeOut=function(a){return a*a
388 };
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)
393 }this.options=b||{};
394 this.titles=e;
395 this.contents=d;
396 this.hoverSet=new Rico.HoverSet(e,b);
397 for(var c=0;
398 c<d.length;
399 c++){if(d[c]){Rico.hide(d[c])
400 }}var a=this;
401 this.selectionSet=new Rico.SelectionSet(e,Rico.extend(b,{onSelect:function(f){a._finishSelect(f)
402 }}))
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);
408 return
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"
414 }this.selected=a
415 },addBase:function(b,a){this.titles.push(b);
416 this.contents.push(a);
417 this.hoverSet.add(b);
418 this.selectionSet.add(b);
419 Rico.hide(a)
420 },removeBase:function(a){},removeAll:function(){this.hoverSet.removeAll();
421 this.selectionSet.removeAll()
422 }};
423 Rico.Accordion=function(b,a){this.initialize(b,a)
424 };
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");
431 var c,j=[],h=[];
432 for(var f=0;
433 f<d.length;
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";
437 j.push(c[0]);
438 h.push(c[1]);
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;
446 this.opening=b;
447 this.curStep=0;
448 var a=this;
449 this.timer=setInterval(function(){a.step()
450 },25)
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"
465 }});
466 Rico.TabbedPanel=function(b,a){this.initialize(b,a)
467 };
468 Rico.TabbedPanel.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(d,k){d=Rico.$(d);
469 k=k||{};
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
474 }var g=[];
475 var j=d.childNodes;
476 for(var e=0;
477 e<j.length;
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"
487 }for(var e=0;
488 e<f.length;
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)
501 }Rico.show(a);
502 if(this.options.panelHeight){a.style.height=this.options.panelHeight
503 }}});
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";
541 n.style[c]=j;
542 n.style[f]=Rico.isIE&&Rico.ieVersion<7&&f=="right"&&o!="none"?"-2px":"-1px";
543 b.appendChild(n);
544 var h=[0,2,3,4,4];
545 if(c=="bottom"){h.reverse()
546 }var m=o=="none"?"0px none":"1px solid "+a;
547 var g=f=="left"?"Right":"Left";
548 for(var e=0;
549 e<h.length;
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;
554 n.appendChild(l)
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;
560 a<arguments.length;
561 a++){if(b.indexOf(arguments[a])>=0){return true
562 }}return false
563 }};
564 Rico.toColorPart=function(a){return Rico.zFill(a,2,16)
565 };
566 Rico.Color=function(c,b,a){this.initialize(c,b,a)
567 };
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();
573 a.h=b;
574 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
575 },setSaturation:function(b){var a=this.asHSB();
576 a.s=b;
577 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
578 },setBrightness:function(a){var c=this.asHSB();
579 c.b=a;
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()
595 }};
596 Rico.Color.createFromHex=function(d){if(d.length==4){var b=d;
597 d="#";
598 for(var c=1;
599 c<4;
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))
607 };
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);
613 var c=a.split(",");
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)
617 }}};
618 Rico.Color.HSBtoRGB=function(i,e,k){var c=0;
619 var d=0;
620 var l=0;
621 if(e==0){c=parseInt(k*255+0.5,10);
622 d=c;
623 l=c
624 }else{var g=(i-Math.floor(i))*6;
625 var j=g-Math.floor(g);
626 var b=k*(1-e);
627 var a=k*(1-e*j);
628 var m=k*(1-(e*(1-j)));
629 switch(parseInt(g,10)){case 0:c=(k*255+0.5);
630 d=(m*255+0.5);
631 l=(b*255+0.5);
632 break;
633 case 1:c=(a*255+0.5);
634 d=(k*255+0.5);
635 l=(b*255+0.5);
636 break;
637 case 2:c=(b*255+0.5);
638 d=(k*255+0.5);
639 l=(m*255+0.5);
640 break;
641 case 3:c=(b*255+0.5);
642 d=(a*255+0.5);
643 l=(k*255+0.5);
644 break;
645 case 4:c=(m*255+0.5);
646 d=(b*255+0.5);
647 l=(k*255+0.5);
648 break;
649 case 5:c=(k*255+0.5);
650 d=(b*255+0.5);
651 l=(a*255+0.5);
652 break
653 }}return{r:parseInt(c,10),g:parseInt(d,10),b:parseInt(l,10)}
654 };
655 Rico.Color.RGBtoHSB=function(a,f,l){var h;
656 var e;
657 var k;
658 var m=(a>f)?a:f;
659 if(l>m){m=l
660 }var i=(a<f)?a:f;
661 if(l<i){i=l
662 }k=m/255;
663 if(m!=0){e=(m-i)/m
664 }else{e=0
665 }if(e==0){h=0
666 }else{var c=(m-a)/(m-i);
667 var j=(m-f)/(m-i);
668 var d=(m-l)/(m-i);
669 if(a==m){h=d-j
670 }else{if(f==m){h=2+c-d
671 }else{h=4+j-c
672 }}h=h/6;
673 if(h<0){h=h+1
674 }}return{h:h,s:e,b:k}
675 };
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()
680 }},false)
681 }return a
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")
686 })||false
687 }return null
688 };
689 Rico.CalendarControl=function(b,a){this.initialize(b,a)
690 };
691 Rico.CalendarControl.prototype={initialize:function(c,b){this.id=c;
692 var a=new Date();
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;
698 this.img=[];
699 this.Holidays={};
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);
705 this.dateParts={};
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 e=Rico.$(this.id);
713 if(e){this.setDiv(e)
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.maintab=document.createElement("table");
719 this.maintab.cellSpacing=2;
720 this.maintab.cellPadding=0;
721 this.maintab.border=0;
722 this.maintab.style.borderCollapse="separate";
723 this.maintab.className="ricoCalTab";
724 if(Rico.theme.calendarTable){Rico.addClass(this.maintab,Rico.theme.calendarTable)
725 }this.tbody=Rico.getTBody(this.maintab);
726 var d,l,h,g,k,n,m,o,f;
727 this.colStart=this.options.showWeekNumber?1:0;
728 for(h=0;
729 h<7;
730 h++){d=this.tbody.insertRow(-1);
731 d.className="row"+h;
732 for(l=0;
733 l<7+this.colStart;
734 l++){d.insertCell(-1)
735 }}d=this.tbody.rows[0];
736 d.className="ricoCalDayNames";
737 if(this.options.showWeekNumber){d.cells[0].innerHTML=this.weekString;
738 for(h=0;
739 h<7;
740 h++){this.tbody.rows[h].cells[0].className="ricoCalWeekNum"
741 }}this.styles=[];
742 for(h=0;
743 h<7;
744 h++){n=(h+this.options.startAt)%7;
745 d.cells[h+this.colStart].innerHTML=Rico.dayAbbr(n);
746 this.styles[h]="ricoCal"+n
747 }this.heading=this.content.appendChild(document.createElement("div"));
748 this.heading.className="RicoCalHeading";
749 if(Rico.theme.calendarHeading){Rico.addClass(this.heading,Rico.theme.calendarHeading)
750 }var b=this.heading.appendChild(document.createElement("div"));
751 b.className="RicoCalHeadingInner";
752 b.appendChild(this._createTitleSection("Month"));
753 b.appendChild(this._createTitleSection("Year"));
754 new Rico.HoverSet(this.heading.getElementsByTagName("a"));
755 new Rico.HoverSet(this.tbody.getElementsByTagName("td"),{hoverNodes:function(a){return a.innerHTML.match(/^\d+$/)?[a]:[]
756 }});
757 if(this.position=="absolute"){this.heading.appendChild(Rico.closeButton(Rico.eventHandle(this,"close")))
758 }if(this.options.showToday){this.tfoot=this.maintab.createTFoot();
759 d=this.tfoot.insertRow(-1);
760 this.todayCell=d.insertCell(-1);
761 this.todayCell.colSpan=7+this.colStart;
762 if(Rico.theme.calendarFooter){Rico.addClass(this.todayCell,Rico.theme.calendarFooter)
763 }Rico.eventBind(this.todayCell,"click",Rico.eventHandle(this,"selectNow"),false)
764 }this.content.appendChild(this.maintab);
765 this.monthPopup=new Rico.Popup(document.createElement("div"));
766 this.monthPopup.closePopup();
767 f=document.createElement("table");
768 f.className="ricoCalMenu";
769 if(Rico.theme.calendarPopdown){Rico.addClass(f,Rico.theme.calendarPopdown)
770 }f.cellPadding=2;
771 f.cellSpacing=0;
772 f.border=0;
773 f.style.borderCollapse="separate";
774 f.style.margin="0px";
775 for(h=0;
776 h<4;
777 h++){d=f.insertRow(-1);
778 for(g=0;
779 g<3;
780 g++){l=d.insertCell(-1);
781 m=document.createElement("a");
782 m.innerHTML=Rico.monthAbbr(h*3+g);
783 m.name=h*3+g;
784 if(Rico.theme.calendarDay){Rico.addClass(m,Rico.theme.calendarDay)
785 }l.appendChild(m);
786 Rico.eventBind(m,"click",Rico.eventHandle(this,"selectMonth"),false)
787 }}new Rico.HoverSet(f.getElementsByTagName("a"));
788 this.monthPopup.content.appendChild(f);
789 this.container.appendChild(this.monthPopup.container);
790 this.yearPopup=new Rico.Popup(document.createElement("div"));
791 this.yearPopup.closePopup();
792 this.yearPopup.content.className="ricoCalYearPrompt";
793 if(Rico.theme.calendarPopdown){Rico.addClass(this.yearPopup.content,Rico.theme.calendarPopdown)
794 }var f=document.createElement("table");
795 f.cellPadding=2;
796 f.cellSpacing=0;
797 f.border=0;
798 f.style.borderCollapse="separate";
799 f.style.margin="0px";
800 d=f.insertRow(-1);
801 this.yearLabel=d.insertCell(-1);
802 this.yearLabel.colSpan=3;
803 this.yearLabel.innerHTML=Rico.getPhraseById("calYearRange",this.options.minDate.getFullYear(),this.options.maxDate.getFullYear());
804 d=f.insertRow(-1);
805 l=d.insertCell(-1);
806 this.yearInput=l.appendChild(document.createElement("input"));
807 this.yearInput.maxlength=4;
808 this.yearInput.size=4;
809 Rico.eventBind(this.yearInput,"keyup",Rico.eventHandle(this,"yearKey"),false);
810 l=d.insertCell(-1);
811 var m=Rico.floatButton("Checkmark",Rico.eventHandle(this,"processPopUpYear"));
812 Rico.setStyle(m.firstChild,{margin:"0px",padding:"0px",border:"none"});
813 l.appendChild(m);
814 l=d.insertCell(-1);
815 m=Rico.floatButton("Cancel",Rico.eventHandle(this,"popDownYear"));
816 Rico.setStyle(m.firstChild,{margin:"0px",padding:"0px",border:"none"});
817 l.appendChild(m);
818 this.yearPopup.content.appendChild(f);
819 this.container.appendChild(this.yearPopup.container);
820 this.yearPopup.container.style.left="";
821 this.yearPopup.container.style.right="5px";
822 this.yearPopup.container.style.zIndex=10;
823 m=this.content.getElementsByTagName("a");
824 for(h=0;
825 h<m.length;
826 h++){m[h].href="javascript:void(0)"
827 }Rico.eventBind(this.tbody,"click",Rico.eventHandle(this,"saveAndClose"));
828 this.close();
829 this.bPageLoaded=true
830 },_createTitleSection:function(d){var c=document.createElement("span");
831 c.className="RicoCal"+d+"Heading";
832 if(Rico.theme.calendarSubheading){Rico.addClass(c,Rico.theme.calendarSubheading)
833 }var b=c.appendChild(document.createElement("a"));
834 b.className="Rico_leftArrow";
835 if(Rico.theme.leftArrowAnchor){Rico.addClass(b,Rico.theme.leftArrowAnchor)
836 }b.appendChild(this.createNavArrow("dec"+d,"left"));
837 b=c.appendChild(document.createElement("a"));
838 b.style.display="inline";
839 Rico.eventBind(b,"click",Rico.eventHandle(this,"popUp"+d),false);
840 this["title"+d]=b;
841 b=c.appendChild(document.createElement("a"));
842 b.className="Rico_rightArrow";
843 if(Rico.theme.rightArrowAnchor){Rico.addClass(b,Rico.theme.rightArrowAnchor)
844 }b.appendChild(this.createNavArrow("inc"+d,"right"));
845 return c
846 },selectNow:function(){var a=new Date();
847 this.dateNow=a.getDate();
848 this.monthNow=a.getMonth();
849 this.yearNow=a.getFullYear();
850 this.monthSelected=this.monthNow;
851 this.yearSelected=this.yearNow;
852 this.constructCalendar()
853 },createNavArrow:function(a,c){var b=document.createElement("span");
854 b.className=Rico.theme[c+"Arrow"]||"rico-icon Rico_"+c+"Arrow";
855 Rico.eventBind(b,"click",Rico.eventHandle(this,a),false);
856 return b
857 },isValidMonth:function(a,b){if(a<this.options.minDate.getFullYear()){return false
858 }if(a==this.options.minDate.getFullYear()&&b<this.options.minDate.getMonth()){return false
859 }if(a>this.options.maxDate.getFullYear()){return false
860 }if(a==this.options.maxDate.getFullYear()&&b>this.options.maxDate.getMonth()){return false
861 }return true
862 },incMonth:function(){var b=this.monthSelected+1;
863 var a=this.yearSelected;
864 if(b>11){b=0;
865 a++
866 }if(!this.isValidMonth(a,b)){return
867 }this.monthSelected=b;
868 this.yearSelected=a;
869 this.constructCalendar()
870 },decMonth:function(){var b=this.monthSelected-1;
871 var a=this.yearSelected;
872 if(b<0){b=11;
873 a--
874 }if(!this.isValidMonth(a,b)){return
875 }this.monthSelected=b;
876 this.yearSelected=a;
877 this.constructCalendar()
878 },selectMonth:function(b){var a=Rico.eventElement(b);
879 this.monthSelected=parseInt(a.name,10);
880 this.constructCalendar();
881 Rico.eventStop(b)
882 },popUpMonth:function(a){Rico.eventStop(a);
883 if(this.monthPopup.visible()){this.popDownMonth();
884 return
885 }this.popDownYear();
886 if(Rico.isIE&&Rico.ieVersion<7){this.monthPopup.openPopup(null,this.heading.offsetHeight+2);
887 this.monthPopup.container.style.left=""
888 }else{this.monthPopup.openPopup(3,this.heading.offsetHeight+2)
889 }return false
890 },popDownMonth:function(){this.monthPopup.closePopup()
891 },popDownYear:function(){this.yearPopup.closePopup();
892 this.yearInput.disabled=true
893 },popUpYear:function(a){Rico.eventStop(a);
894 if(this.yearPopup.visible()){this.popDownYear();
895 return
896 }this.popDownMonth();
897 this.yearPopup.openPopup(null,this.heading.offsetHeight+2);
898 this.yearInput.disabled=false;
899 this.yearInput.value="";
900 this.yearInput.focus();
901 return false
902 },yearKey:function(a){switch(Rico.eventKey(a)){case 27:this.popDownYear();
903 Rico.eventStop(a);
904 return false;
905 case 13:this.processPopUpYear();
906 Rico.eventStop(a);
907 return false
908 }return true
909 },processPopUpYear:function(){var a=this.yearInput.value;
910 a=parseInt(a,10);
911 if(isNaN(a)||a<this.options.minDate.getFullYear()||a>this.options.maxDate.getFullYear()){alert(Rico.getPhraseById("calInvalidYear"))
912 }else{this.yearSelected=a;
913 this.popDownYear();
914 this.constructCalendar()
915 }},incYear:function(){if(this.yearSelected>=this.options.maxDate.getFullYear()){return
916 }this.yearSelected++;
917 this.constructCalendar()
918 },decYear:function(){if(this.yearSelected<=this.options.minDate.getFullYear()){return
919 }this.yearSelected--;
920 this.constructCalendar()
921 },WeekNbr:function(h,f,j){var g=new Date(h,f,j);
922 var c=new Date(h,0,1);
923 var e=7+1-c.getDay();
924 if(e==8){e=1
925 }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;
926 var d=Math.floor((b-e+7)/7);
927 if(d==0){h--;
928 var a=new Date(h,0,1);
929 var i=7+1-a.getDay();
930 d=(i==2||i==8)?53:52
931 }return d
932 },constructCalendar:function(){var l=[31,0,31,30,31,30,31,31,30,31,30,31];
933 var d=new Date(this.yearSelected,this.monthSelected,1);
934 var j,e,f,b;
935 if(typeof this.monthSelected!="number"||this.monthSelected>=12||this.monthSelected<0){alert("ERROR in calendar: monthSelected="+this.monthSelected);
936 return
937 }if(this.monthSelected==1){j=new Date(this.yearSelected,this.monthSelected+1,1);
938 j=new Date(j-(24*60*60*1000));
939 e=j.getDate()
940 }else{e=l[this.monthSelected]
941 }var n=d.getDay()-this.options.startAt;
942 if(n<0){n+=7
943 }this.popDownMonth();
944 this.popDownYear();
945 if(this.options.showWeekNumber){for(f=1;
946 f<7;
947 f++){this.tbody.rows[f].cells[0].innerHTML="&nbsp;"
948 }}for(f=0;
949 f<n;
950 f++){this.resetCell(this.tbody.rows[1].cells[f+this.colStart])
951 }for(var k=1,a=1;
952 k<=e;
953 k++,n++){b=n%7;
954 if(this.options.showWeekNumber&&b==0){this.tbody.rows[a].cells[0].innerHTML=this.WeekNbr(this.yearSelected,this.monthSelected,k)
955 }var m=this.tbody.rows[a].cells[b+this.colStart];
956 m.innerHTML=k;
957 m.className=this.styles[b];
958 if((k==this.dateNow)&&(this.monthSelected==this.monthNow)&&(this.yearSelected==this.yearNow)){Rico.addClass(m,Rico.theme.calendarToday||"ricoCalToday")
959 }if(Rico.theme.calendarDay){Rico.addClass(m,Rico.theme.calendarDay)
960 }if((k==this.odateSelected)&&(this.monthSelected==this.omonthSelected)&&(this.yearSelected==this.oyearSelected)){Rico.addClass(m,Rico.theme.calendarSelectedDay||"ricoSelectedDay")
961 }var g=this.Holidays[this.holidayKey(this.yearSelected,this.monthSelected,k)];
962 if(!g){g=this.Holidays[this.holidayKey(0,this.monthSelected,k)]
963 }m.style.color=g?g.txtColor:"";
964 m.style.backgroundColor=g?g.bgColor:"";
965 m.title=g?g.desc:"";
966 if(b==6){a++
967 }}while(n<42){b=n%7;
968 this.resetCell(this.tbody.rows[a].cells[b+this.colStart]);
969 n++;
970 if(b==6){a++
971 }}this.titleMonth.innerHTML=Rico.monthAbbr(this.monthSelected);
972 this.titleYear.innerHTML=this.yearSelected;
973 if(this.todayCell){this.todayCell.innerHTML=Rico.getPhraseById("calToday",this.dateNow,Rico.monthAbbr(this.monthNow),this.yearNow,this.monthNow+1)
974 }},resetCell:function(a){a.innerHTML="&nbsp;";
975 a.className="ricoCalEmpty";
976 a.style.color="";
977 a.style.backgroundColor="";
978 a.title=""
979 },saveAndClose:function(g){Rico.eventStop(g);
980 var f=Rico.eventElement(g);
981 var c=f.innerHTML.replace(/&nbsp;/g,"");
982 if(c==""||f.className=="ricoCalWeekNum"){return
983 }var b=parseInt(c,10);
984 if(isNaN(b)){return
985 }var h=new Date(this.yearSelected,this.monthSelected,b);
986 var a=Rico.formatDate(h,this.dateFmt=="ISO8601"?"yyyy-mm-dd":this.dateFmt);
987 if(this.returnValue){this.returnValue(a);
988 this.close()
989 }},open:function(b){if(!this.bPageLoaded){return
990 }var a=new Date();
991 this.dateNow=a.getDate();
992 this.monthNow=a.getMonth();
993 this.yearNow=a.getFullYear();
994 this.oyearSelected=-1;
995 if(typeof b=="object"){this.odateSelected=b.getDate();
996 this.omonthSelected=b.getMonth();
997 this.oyearSelected=b.getFullYear()
998 }else{if(this.dateFmt=="ISO8601"){var c=Rico.setISO8601(b);
999 if(c){this.odateSelected=c.getDate();
1000 this.omonthSelected=c.getMonth();
1001 this.oyearSelected=c.getFullYear()
1002 }}else{if(this.re.exec(b)){var f=[RegExp.$1,RegExp.$3,RegExp.$5];
1003 this.odateSelected=parseInt(f[this.dateParts.dd],10);
1004 this.omonthSelected=parseInt(f[this.dateParts.mm],10)-1;
1005 this.oyearSelected=parseInt(f[this.dateParts.yyyy],10);
1006 if(this.oyearSelected<100){this.oyearSelected+=this.yearNow-(this.yearNow%100);
1007 var e=this.options.maxDate.getFullYear();
1008 while(this.oyearSelected>e){this.oyearSelected-=100
1009 }}}else{if(b){alert("ERROR: invalid date passed to calendar ("+b+")")
1010 }}}}if(this.oyearSelected>0){this.dateSelected=this.odateSelected;
1011 this.monthSelected=this.omonthSelected;
1012 this.yearSelected=this.oyearSelected
1013 }else{this.dateSelected=this.dateNow;
1014 this.monthSelected=this.monthNow;
1015 this.yearSelected=this.yearNow
1016 }this.constructCalendar();
1017 this.openPopup()
1018 }};
1019 Rico.ColorPicker=function(b,a){this.initialize(b,a)
1020 };
1021 Rico.ColorPicker.prototype={initialize:function(h,c){this.id=h;
1022 this.currentValue="#FFFFFF";
1023 Rico.extend(this,new Rico.Popup());
1024 Rico.extend(this.options,{showColorCode:false,cellsPerRow:18,palette:[]});
1025 var f=["00","33","66","99","CC","FF"];
1026 for(var e=0;
1027 e<f.length;
1028 e++){for(var d=0;
1029 d<f.length;
1030 d++){for(var a=0;
1031 a<f.length;
1032 a++){this.options.palette.push(f[d]+f[e]+f[a])
1033 }}}Rico.extend(this.options,c||{})
1034 },atLoad:function(){this.createContainer();
1035 this.content.className="ricoColorPicker";
1036 var c=this.options.cellsPerRow;
1037 var d="<TABLE BORDER='1' CELLSPACING='1' CELLPADDING='0'>";
1038 for(var b=0;
1039 b<this.options.palette.length;
1040 b++){if((b%c)==0){d+="<TR>"
1041 }d+='<TD BGCOLOR="#'+this.options.palette[b]+'">&nbsp;</TD>';
1042 if(((b+1)>=this.options.palette.length)||(((b+1)%c)==0)){d+="</TR>"
1043 }}var a=Math.floor(c/2);
1044 if(this.options.showColorCode){d+="<TR><TD COLSPAN='"+a+"' ID='colorPickerSelectedColor'>&nbsp;</TD><TD COLSPAN='"+(c-a)+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue'>#FFFFFF</TD></TR>"
1045 }else{d+="<TR><TD COLSPAN='"+c+"' ID='colorPickerSelectedColor'>&nbsp;</TD></TR>"
1046 }d+="</TABLE>";
1047 this.content.innerHTML=d;
1048 this.open=this.openPopup;
1049 this.close=this.closePopup;
1050 Rico.eventBind(this.container,"mouseover",Rico.eventHandle(this,"highlightColor"),false);
1051 Rico.eventBind(this.container,"click",Rico.eventHandle(this,"selectColor"),false);
1052 this.close()
1053 },selectColor:function(a){Rico.eventStop(a);
1054 if(this.returnValue){this.returnValue(this.currentValue)
1055 }this.close()
1056 },highlightColor:function(b){var a=Rico.eventElement(b);
1057 if(!a.tagName||a.tagName.toLowerCase()!="td"){return
1058 }var g=Rico.Color.createColorFromBackground(a).toString();
1059 this.currentValue=g;
1060 Rico.setStyle("colorPickerSelectedColor",{backgroundColor:g});
1061 var f=Rico.$("colorPickerSelectedColorValue");
1062 if(f){f.innerHTML=g
1063 }}};
1064 Rico.dndMgrList=[];
1065 Rico.registerDraggable=function(b,a){if(typeof a!="number"){a=0
1066 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1067 }Rico.dndMgrList[a].registerDraggable(b)
1068 };
1069 Rico.registerDropZone=function(b,a){if(typeof a!="number"){a=0
1070 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1071 }Rico.dndMgrList[a].registerDropZone(b)
1072 };
1073 Rico.dndMgr=function(){this.initialize()
1074 };
1075 Rico.dndMgr.prototype={initialize:function(){this.dropZones=[];
1076 this.draggables=[];
1077 this.currentDragObjects=[];
1078 this.dragElement=null;
1079 this.lastSelectedDraggable=null;
1080 this.currentDragObjectVisible=false;
1081 this.interestedInMotionEvents=false;
1082 this._mouseDown=Rico.eventHandle(this,"_mouseDownHandler");
1083 this._mouseMove=Rico.eventHandle(this,"_mouseMoveHandler");
1084 this._mouseUp=Rico.eventHandle(this,"_mouseUpHandler")
1085 },registerDropZone:function(a){this.dropZones[this.dropZones.length]=a
1086 },deregisterDropZone:function(a){var d=new Array();
1087 var b=0;
1088 for(var c=0;
1089 c<this.dropZones.length;
1090 c++){if(this.dropZones[c]!=a){d[b++]=this.dropZones[c]
1091 }}this.dropZones=d
1092 },clearDropZones:function(){this.dropZones=new Array()
1093 },registerDraggable:function(a){this.draggables[this.draggables.length]=a;
1094 var b=a.getMouseDownHTMLElement();
1095 if(b!=null){b.ricoDraggable=a;
1096 Rico.eventBind(b,"mousedown",Rico.eventHandle(this,"_attachEvents"));
1097 Rico.eventBind(b,"mousedown",this._mouseDown)
1098 }},clearSelection:function(){for(var a=0;
1099 a<this.currentDragObjects.length;
1100 a++){this.currentDragObjects[a].deselect()
1101 }this.currentDragObjects=new Array();
1102 this.lastSelectedDraggable=null
1103 },hasSelection:function(){return this.currentDragObjects.length>0
1104 },setStartDragFromElement:function(a,c){this.origPos=Rico.cumulativeOffset(c);
1105 var b=Rico.eventClient(a);
1106 this.startx=b.x-this.origPos.left;
1107 this.starty=b.y-this.origPos.top;
1108 this.interestedInMotionEvents=this.hasSelection();
1109 Rico.eventStop(a)
1110 },updateSelection:function(a,b){if(!b){this.clearSelection()
1111 }if(a.isSelected()){this.currentDragObjects=this.currentDragObjects.without(a);
1112 a.deselect();
1113 if(a==this.lastSelectedDraggable){this.lastSelectedDraggable=null
1114 }}else{a.select();
1115 if(a.isSelected()){this.currentDragObjects.push(a);
1116 this.lastSelectedDraggable=a
1117 }}},_mouseDownHandler:function(f){if(!Rico.eventLeftClick(f)){return
1118 }var d=Rico.eventElement(f);
1119 var a=d.ricoDraggable;
1120 var c=d;
1121 while(a==null&&c.parentNode){c=c.parentNode;
1122 a=c.ricoDraggable
1123 }if(a==null){return
1124 }this.updateSelection(a,f.ctrlKey);
1125 if(this.hasSelection()){for(var b=0;
1126 b<this.dropZones.length;
1127 b++){this.dropZones[b].clearPositionCache()
1128 }}this.setStartDragFromElement(f,a.getMouseDownHTMLElement())
1129 },_mouseMoveHandler:function(a){if(!this.interestedInMotionEvents){return
1130 }if(!this.hasSelection()){return
1131 }if(!this.currentDragObjectVisible){this._startDrag(a)
1132 }if(!this.activatedDropZones){this._activateRegisteredDropZones()
1133 }this._updateDraggableLocation(a);
1134 this._updateDropZonesHover(a);
1135 Rico.eventStop(a)
1136 },_makeDraggableObjectVisible:function(b){if(!this.hasSelection()){return
1137 }var a;
1138 if(this.currentDragObjects.length>1){a=this.currentDragObjects[0].getMultiObjectDragGUI(this.currentDragObjects)
1139 }else{a=this.currentDragObjects[0].getSingleObjectDragGUI()
1140 }this.dragElemPosition=Rico.getStyle(a,"position");
1141 if(this.dragElemPosition!="absolute"){a.style.position="absolute"
1142 }if(a.parentNode==null||a.parentNode.nodeType==11){document.body.appendChild(a)
1143 }this.dragElement=a;
1144 this._updateDraggableLocation(b);
1145 this.currentDragObjectVisible=true
1146 },_leftOffset:function(a){return a.offsetX?document.body.scrollLeft:0
1147 },_topOffset:function(a){return a.offsetY?document.body.scrollTop:0
1148 },_updateDraggableLocation:function(b){var a=this.dragElement.style;
1149 var c=Rico.eventClient(b);
1150 a.left=(c.x+this._leftOffset(b)-this.startx)+"px";
1151 a.top=(c.y+this._topOffset(b)-this.starty)+"px"
1152 },_updateDropZonesHover:function(b){var a,c=this.dropZones.length;
1153 for(a=0;
1154 a<c;
1155 a++){if(!this._mousePointInDropZone(b,this.dropZones[a])){this.dropZones[a].hideHover()
1156 }}for(a=0;
1157 a<c;
1158 a++){if(this._mousePointInDropZone(b,this.dropZones[a])){if(this.dropZones[a].canAccept(this.currentDragObjects)){this.dropZones[a].showHover()
1159 }}}},_startDrag:function(b){for(var a=0;
1160 a<this.currentDragObjects.length;
1161 a++){this.currentDragObjects[a].startDrag()
1162 }this._makeDraggableObjectVisible(b)
1163 },_mouseUpHandler:function(b){if(!this.hasSelection()){return
1164 }if(!Rico.eventLeftClick(b)){return
1165 }this.interestedInMotionEvents=false;
1166 if(this._placeDraggableInDropZone(b)){this._completeDropOperation(b)
1167 }else{if(this.dragElement!=null){Rico.eventStop(b);
1168 var a=this;
1169 Rico.animate(this.dragElement,{duration:300,onEnd:function(){a._doCancelDragProcessing()
1170 }},{left:this.origPos.left,top:this.origPos.top})
1171 }}Rico.eventUnbind(document.body,"mousemove",this._mouseMove);
1172 Rico.eventUnbind(document.body,"mouseup",this._mouseUp)
1173 },_retTrue:function(){return true
1174 },_completeDropOperation:function(a){if(this.dragElement!=this.currentDragObjects[0].getMouseDownHTMLElement()){if(this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1175 }}this._deactivateRegisteredDropZones();
1176 this._endDrag();
1177 this.clearSelection();
1178 this.dragElement=null;
1179 this.currentDragObjectVisible=false;
1180 Rico.eventStop(a)
1181 },_doCancelDragProcessing:function(){this._cancelDrag();
1182 if(this.dragElement==this.currentDragObjects[0].getMouseDownHTMLElement()){this.dragElement.style.position=this.dragElemPosition
1183 }else{if(this.dragElement&&this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1184 }}this._deactivateRegisteredDropZones();
1185 this.dragElement=null;
1186 this.currentDragObjectVisible=false
1187 },_placeDraggableInDropZone:function(c){var a=false;
1188 var d=this.dropZones.length;
1189 for(var b=0;
1190 b<d;
1191 b++){if(this._mousePointInDropZone(c,this.dropZones[b])){if(this.dropZones[b].canAccept(this.currentDragObjects)){this.dropZones[b].hideHover();
1192 this.dropZones[b].accept(this.currentDragObjects);
1193 a=true;
1194 break
1195 }}}return a
1196 },_cancelDrag:function(){for(var a=0;
1197 a<this.currentDragObjects.length;
1198 a++){this.currentDragObjects[a].cancelDrag()
1199 }},_endDrag:function(){for(var a=0;
1200 a<this.currentDragObjects.length;
1201 a++){this.currentDragObjects[a].endDrag()
1202 }},_mousePointInDropZone:function(b,c){var a=c.getAbsoluteRect();
1203 var d=Rico.eventClient(b);
1204 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)
1205 },_activateRegisteredDropZones:function(){var c=this.dropZones.length;
1206 for(var a=0;
1207 a<c;
1208 a++){var b=this.dropZones[a];
1209 if(b.canAccept(this.currentDragObjects)){b.activate()
1210 }}this.activatedDropZones=true
1211 },_deactivateRegisteredDropZones:function(){var b=this.dropZones.length;
1212 for(var a=0;
1213 a<b;
1214 a++){this.dropZones[a].deactivate()
1215 }this.activatedDropZones=false
1216 },_attachEvents:function(){Rico.eventBind(document.body,"mousemove",this._mouseMove);
1217 Rico.eventBind(document.body,"mouseup",this._mouseUp)
1218 }};
1219 Rico.Draggable=function(a,b){this.initialize(a,b)
1220 };
1221 Rico.Draggable.prototype={initialize:function(a,b){this.type=a;
1222 this.htmlElement=Rico.$(b);
1223 this.selected=false
1224 },getMouseDownHTMLElement:function(){return this.htmlElement
1225 },select:function(){this._select()
1226 },_select:function(){this.selected=true;
1227 if(this.showingSelected){return
1228 }this.showingSelected=true;
1229 var b=this.getMouseDownHTMLElement();
1230 var a=Rico.Color.createColorFromBackground(b);
1231 a.isBright()?a.darken(0.033):a.brighten(0.033);
1232 this.saveBackground=Rico.getStyle(b,"backgroundColor","background-color");
1233 b.style.backgroundColor=a.asHex()
1234 },deselect:function(){this.selected=false;
1235 if(!this.showingSelected){return
1236 }var a=this.getMouseDownHTMLElement();
1237 a.style.backgroundColor=this.saveBackground;
1238 this.showingSelected=false
1239 },isSelected:function(){return this.selected
1240 },startDrag:function(){},cancelDrag:function(){},endDrag:function(){},getSingleObjectDragGUI:function(){return this.htmlElement
1241 },getMultiObjectDragGUI:function(a){return this.htmlElement
1242 },getDroppedGUI:function(){return this.htmlElement
1243 },toString:function(){return this.type+":"+this.htmlElement+":"
1244 }};
1245 Rico.LiveGridDraggable=function(b,a,c){this.initialize(b,a,c)
1246 };
1247 Rico.LiveGridDraggable.prototype=Rico.extend(new Rico.Draggable(),{initialize:function(b,a,c){this.type="RicoCell";
1248 this.htmlElement=b.cell(a,c);
1249 this.liveGrid=b;
1250 this.dragRow=a;
1251 this.dragCol=c
1252 },select:function(){if(this.dragRow>=this.liveGrid.buffer.totalRows){return
1253 }this.selected=true;
1254 this.showingSelected=true
1255 },deselect:function(){this.selected=false;
1256 this.showingSelected=false
1257 },getSingleObjectDragGUI:function(){var a=document.createElement("div");
1258 a.className="LiveGridDraggable";
1259 a.style.width=(this.htmlElement.offsetWidth-10)+"px";
1260 a.innerHTML=this.htmlElement.innerHTML;
1261 return a
1262 }});
1263 Rico.Dropzone=function(a){this.initialize(a)
1264 };
1265 Rico.Dropzone.prototype={initialize:function(a){this.htmlElement=Rico.$(a);
1266 this.absoluteRect=null
1267 },getHTMLElement:function(){return this.htmlElement
1268 },clearPositionCache:function(){this.absoluteRect=null
1269 },getAbsoluteRect:function(){if(this.absoluteRect==null){var a=this.getHTMLElement();
1270 var b=Rico.viewportOffset(a);
1271 this.absoluteRect={top:b.top,left:b.left,bottom:b.top+a.offsetHeight,right:b.left+a.offsetWidth}
1272 }return this.absoluteRect
1273 },activate:function(){var c=this.getHTMLElement();
1274 if(c==null||this.showingActive){return
1275 }this.showingActive=true;
1276 this.saveBackgroundColor=c.style.backgroundColor;
1277 var b="#ffea84";
1278 var a=Rico.Color.createColorFromBackground(c);
1279 if(a==null){c.style.backgroundColor=b
1280 }else{a.isBright()?a.darken(0.2):a.brighten(0.2);
1281 c.style.backgroundColor=a.asHex()
1282 }},deactivate:function(){var a=this.getHTMLElement();
1283 if(a==null||!this.showingActive){return
1284 }a.style.backgroundColor=this.saveBackgroundColor;
1285 this.showingActive=false;
1286 this.saveBackgroundColor=null
1287 },showHover:function(){var a=this.getHTMLElement();
1288 if(a==null||this.showingHover){return
1289 }this.saveBorderWidth=a.style.borderWidth;
1290 this.saveBorderStyle=a.style.borderStyle;
1291 this.saveBorderColor=a.style.borderColor;
1292 this.showingHover=true;
1293 a.style.borderWidth="1px";
1294 a.style.borderStyle="solid";
1295 a.style.borderColor="#ffff00"
1296 },hideHover:function(){var a=this.getHTMLElement();
1297 if(a==null||!this.showingHover){return
1298 }a.style.borderWidth=this.saveBorderWidth;
1299 a.style.borderStyle=this.saveBorderStyle;
1300 a.style.borderColor=this.saveBorderColor;
1301 this.showingHover=false
1302 },canAccept:function(a){return true
1303 },accept:function(b){var d=this.getHTMLElement();
1304 if(d==null){return
1305 }var e=b.length;
1306 for(var a=0;
1307 a<e;
1308 a++){var c=b[a].getDroppedGUI();
1309 if(Rico.getStyle(c,"position")=="absolute"){c.style.position="static";
1310 c.style.top="";
1311 c.style.top=""
1312 }d.appendChild(c)
1313 }}};
1314 Rico.KeywordSearch=function(b,a){this.initialize(b,a)
1315 };
1316 Rico.KeywordSearch.prototype={initialize:function(b,a){this.id=b;
1317 Rico.extend(this,new Rico.Window(Rico.getPhraseById("keywordTitle"),a));
1318 Rico.addClass(this.content,"ricoKeywordSearch");
1319 Rico.extend(this.options,{listLength:10,maxSuggest:20,width:"12em"})
1320 },atLoad:function(){this.searchField=Rico.createFormField(this.contentDiv,"input","text",this.id+"_search");
1321 this.searchField.style.display="block";
1322 this.searchField.style.width=this.options.width;
1323 Rico.eventBind(this.searchField,"keyup",Rico.eventHandle(this,"filterKeypress"),false);
1324 this.selectList=Rico.createFormField(this.contentDiv,"select",null,this.id+"_list");
1325 this.selectList.size=this.options.listLength;
1326 this.selectList.style.display="block";
1327 this.selectList.style.width=this.options.width;
1328 Rico.eventBind(this.selectList,"change",Rico.eventHandle(this,"listClick"),false);
1329 this.close=this.closePopup;
1330 this.close()
1331 },open:function(a,b){this.column=b;
1332 this.grid=this.column.liveGrid;
1333 this.searchField.value="";
1334 this.selectList.options.length=0;
1335 this.openPopup();
1336 this.searchField.focus();
1337 this.selectValuesRequest("")
1338 },selectValuesRequest:function(c){var d=this.column.index;
1339 var b={};
1340 Rico.extend(b,this.grid.buffer.ajaxOptions);
1341 b.parameters={id:this.grid.tableId,offset:"0",page_size:this.options.maxSuggest,edit:d};
1342 b.parameters[this.grid.actionId]="query";
1343 if(c!=""&&c!="*"){if(c.indexOf("*")==-1){c="*"+c+"*"
1344 }b.parameters["f[1][op]"]="LIKE";
1345 b.parameters["f[1][len]"]=1;
1346 b.parameters["f[1][0]"]=c
1347 }var a=this;
1348 b.onComplete=function(e){a.selectValuesUpdate(e)
1349 };
1350 new Rico.ajaxRequest(this.grid.buffer.dataSource,b)
1351 },selectValuesUpdate:function(b){var a=b.responseXML.getElementsByTagName("ajax-response");
1352 Rico.log("selectValuesUpdate: "+b.status);
1353 if(a==null||a.length!=1){return
1354 }a=a[0];
1355 var h=a.getElementsByTagName("error");
1356 if(h.length>0){var f=Rico.getContentAsString(h[0],this.grid.buffer.isEncoded);
1357 Rico.log("Data provider returned an error:\n"+f);
1358 alert(Rico.getPhraseById("requestError",f));
1359 return null
1360 }this.selectList.options.length=0;
1361 a=a.getElementsByTagName("response")[0];
1362 var g=a.getElementsByTagName("rows")[0];
1363 var j=this.grid.buffer.dom2jstable(g);
1364 Rico.log("selectValuesUpdate: id="+this.selectList.id+" rows="+j.length);
1365 for(var d=0;
1366 d<j.length;
1367 d++){if(j[d].length>0){var e=j[d][0];
1368 var c=(j[d].length>1)?j[d][1]:e;
1369 Rico.addSelectOption(this.selectList,e,c)
1370 }}},filterKeypress:function(c){var a=Rico.eventElement(c);
1371 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
1372 }if(this.lastKeyFilter==a.value){return
1373 }var b=a.value;
1374 Rico.log("filterKeypress: "+this.index+" "+b);
1375 this.lastKeyFilter=b;
1376 this.selectValuesRequest(b)
1377 },listClick:function(c){var b=Rico.eventElement(c);
1378 if(b.tagName.toLowerCase()!="select"){return
1379 }if(this.returnValue){var a=b.options[b.selectedIndex];
1380 this.returnValue(a.value,a.innerHTML)
1381 }this.close()
1382 }};
1383 Rico.TreeControl=function(c,b,a){this.initialize(c,b,a)
1384 };
1385 Rico.TreeControl.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Popup());
1386 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"});
1387 Rico.extend(this.options,a||{});
1388 this.id=c;
1389 this.dataSource=b;
1390 this.close=this.closePopup;
1391 this.hoverSet=new Rico.HoverSet([])
1392 },atLoad:function(){this.treeDiv=document.createElement("div");
1393 this.treeDiv.id=this.id;
1394 this.treeDiv.className="ricoTree";
1395 if(Rico.theme.treeContent){Rico.addClass(this.treeDiv,Rico.theme.treeContent)
1396 }this.treeDiv.style.height=this.options.height;
1397 this.treeDiv.style.width=this.options.width;
1398 this.createContainer();
1399 this.content.className=Rico.theme.tree||"ricoTreeContainer";
1400 this.content.appendChild(this.treeDiv);
1401 if(this.options.showCheckBox){this.buttonDiv=document.createElement("div");
1402 this.buttonDiv.style.width=this.options.width;
1403 this.buttonDiv.className="ricoTreeButtons";
1404 if(Rico.getStyle(this.container,"position")=="absolute"){var a=document.createElement("span");
1405 a.innerHTML=RicoTranslate.getPhraseById("treeSave");
1406 Rico.setStyle(a,{"float":"left",cursor:"pointer"});
1407 this.buttonDiv.appendChild(a);
1408 Rico.eventBind(a,"click",Rico.eventHandle(this,"saveSelection"))
1409 }var a=document.createElement("span");
1410 a.innerHTML=RicoTranslate.getPhraseById("treeClear");
1411 Rico.setStyle(a,{"float":"right",cursor:"pointer"});
1412 this.buttonDiv.appendChild(a);
1413 this.content.appendChild(this.buttonDiv);
1414 Rico.eventBind(a,"click",Rico.eventHandle(this,"clrCheckBoxEvent"))
1415 }this.close()
1416 },setTreeDiv:function(a){this.treeDiv=Rico.$(a);
1417 this.openPopup=function(){}
1418 },open:function(){this.openPopup();
1419 if(this.treeDiv.childNodes.length==0&&this.dataSource){this.loadXMLDoc()
1420 }},loadXMLDoc:function(c){var b={id:this.id};
1421 if(c){b.Parent=c
1422 }Rico.log("Tree loadXMLDoc: "+this.id);
1423 var a=this;
1424 new Rico.ajaxRequest(this.dataSource,{parameters:b,method:"get",onComplete:function(d){a.processResponse(d)
1425 }})
1426 },domID:function(b,a){return"RicoTree_"+a+"_"+this.id+"_"+b
1427 },processResponse:function(d){var b=d.responseXML.getElementsByTagName("ajax-response");
1428 if(b==null||b.length!=1){return
1429 }var f=b[0].getElementsByTagName("rows")[0];
1430 var g=f.getElementsByTagName("tr");
1431 var k=[];
1432 for(var e=0;
1433 e<g.length;
1434 e++){var l=g[e].getElementsByTagName("td");
1435 if(l.length<5){continue
1436 }var h=[];
1437 h[5]=this.options.leafIcon;
1438 for(var c=0;
1439 c<l.length;
1440 c++){h[c]=Rico.getContentAsString(l[c],true)
1441 }h[3]=h[3].match(/^0|L$/i)?0:1;
1442 h[4]=parseInt(h[4]);
1443 k.push(h)
1444 }for(var e=0;
1445 e<k.length;
1446 e++){var a=(e<k.length-1)&&(k[e][0]==k[e+1][0]);
1447 this.addNode(k[e][0],k[e][1],k[e][2],k[e][3],k[e][4],k[e][5],!a)
1448 }},addNode:function(q,l,t,f,u,s,k){var h=Rico.$(this.domID(q,"Parent"));
1449 var v=Rico.$(this.domID(q,"Children"));
1450 var a=h?h.TreeLevel+1:0;
1451 var b=document.createElement("table");
1452 var m=document.createElement("div");
1453 m.id=this.domID(l,"Children");
1454 m.className="ricoTreeBranch";
1455 m.style.display=h?"none":"";
1456 b.border=0;
1457 b.cellSpacing=0;
1458 b.cellPadding=0;
1459 b.id=this.domID(l,"Parent");
1460 b.TreeLevel=a;
1461 b.TreeContainer=f;
1462 b.TreeFetchedChildren=this.dataSource?false:true;
1463 var d=b.insertRow(0);
1464 var g=[];
1465 for(var r=0;
1466 r<a-1;
1467 r++){g[r]=d.insertCell(-1)
1468 }if(a>1){var e=h.getElementsByTagName("td");
1469 for(var r=0;
1470 r<a-2;
1471 r++){g[r].innerHTML=e[r].innerHTML
1472 }var w=document.createElement("div");
1473 w.className="rico-icon rico-tree-"+(v.nextSibling&&this.options.showLines?"nodeline":"nodeblank");
1474 g[a-2].appendChild(w)
1475 }if(a>0){var c=k&&this.options.showLines?"last":"";
1476 var o=this.options.showLines?"node":"";
1477 if(this.options.showPlusMinus&&f){var w=document.createElement("div");
1478 w.name=l;
1479 w.style.cursor="pointer";
1480 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1481 w.className="rico-icon rico-tree-"+o+"p"+c;
1482 d.insertCell(-1).appendChild(w)
1483 }else{if(this.options.showLines){var w=document.createElement("div");
1484 w.className="rico-icon rico-tree-node"+c;
1485 d.insertCell(-1).appendChild(w)
1486 }}if(this.options.showFolders&&(f||(s&&s!="none"))){var w=document.createElement("div");
1487 if(!f){w.className=s
1488 }else{w.name=l;
1489 w.style.cursor="pointer";
1490 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1491 w.className="rico-icon rico-folderclosed"
1492 }d.insertCell(-1).appendChild(w)
1493 }}if(u&&this.options.showCheckBox){var n=document.createElement("input");
1494 n.type="checkbox";
1495 n.value=l;
1496 d.insertCell(-1).appendChild(n)
1497 }if(u&&!this.options.showCheckBox){var p=document.createElement("a");
1498 if(typeof u=="string"){p.href=u
1499 }else{p.href="javascript:void(0)";
1500 Rico.eventBind(p,"click",this.options.defaultAction)
1501 }this.hoverSet.add(p)
1502 }else{var p=document.createElement("p")
1503 }p.id=this.domID(l,"Desc");
1504 p.className="ricoTreeLevel"+a;
1505 switch(this.options.nodeIdDisplay){case"last":t+=" ("+l+")";
1506 break;
1507 case"first":t=l+" - "+t;
1508 break;
1509 case"tooltip":p.title=l;
1510 break
1511 }p.appendChild(document.createTextNode(t));
1512 d.insertCell(-1).appendChild(p);
1513 var j=v||this.treeDiv;
1514 j.appendChild(b);
1515 j.appendChild(m)
1516 },nodeClick:function(c){var b=Rico.eventElement(c);
1517 if(this.returnValue){var a=this.domID("","Desc");
1518 this.returnValue(b.id.substr(a.length),b.innerHTML)
1519 }this.close()
1520 },saveSelection:function(a){if(this.returnValue){this.returnValue(this.getCheckedItems())
1521 }this.close()
1522 },getCheckedItems:function(){var b=this.treeDiv.getElementsByTagName("input");
1523 var c=[];
1524 for(var a=0;
1525 a<b.length;
1526 a++){if(b[a].type=="checkbox"&&b[a].checked){c.push(b[a].value)
1527 }}return c
1528 },setCheckBoxes:function(c){var b=this.treeDiv.getElementsByTagName("input");
1529 for(var a=0;
1530 a<b.length;
1531 a++){if(b[a].type=="checkbox"){b[a].checked=c
1532 }}},clrCheckBoxEvent:function(a){Rico.eventStop(a);
1533 this.setCheckBoxes(false)
1534 },clickBranch:function(h){var g=Rico.eventElement(h);
1535 var f=Rico.getParentByTagName(g,"table");
1536 if(!f||!f.TreeContainer){return
1537 }var c=f.id.split("_");
1538 c[1]="Children";
1539 var b=Rico.$(c.join("_"));
1540 Rico.toggle(b);
1541 if(g.tagName=="DIV"){var d=Rico.visible(b);
1542 if(g.className.match(/node(p|m)(last)?$/)){g.className=g.className.replace(/nodep|nodem/,"node"+(d?"m":"p"))
1543 }else{if(g.className.match(/folder(open|closed)$/)){g.className=g.className.replace(/folder(open|closed)/,"folder"+(d?"open":"closed"))
1544 }else{if(g.className.match(/\b(m|p)$/)){g.className=g.className.replace(/(p|m)$/,d?"m":"p")
1545 }}}}if(!f.TreeFetchedChildren){f.TreeFetchedChildren=1;
1546 this.loadXMLDoc(g.name)
1547 }}};
1548 if(typeof Rico=="undefined"){throw ("GridCommon requires the Rico JavaScript framework")
1549 }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:"dblclick",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:[]};
1550 this.colWidths=[];
1551 this.hdrCells=[];
1552 this.headerColCnt=0;
1553 this.headerRowIdx=0;
1554 this.tabs=new Array(2);
1555 this.thead=new Array(2);
1556 this.tbody=new Array(2)
1557 },attachMenuEvents:function(){var a;
1558 if(!this.options.menuEvent||this.options.menuEvent=="none"){return
1559 }this.hideScroll=navigator.userAgent.match(/Macintosh\b.*\b(Firefox|Camino)\b/i)||(Rico.isOpera&&parseFloat(window.opera.version())<9.5);
1560 this.options[this.options.menuEvent]=Rico.eventHandle(this,"handleMenuClick");
1561 if(this.highlightDiv){switch(this.options.highlightElem){case"cursorRow":this.attachMenu(this.highlightDiv[0]);
1562 break;
1563 case"cursorCell":for(a=0;
1564 a<2;
1565 a++){this.attachMenu(this.highlightDiv[a])
1566 }break
1567 }}for(a=0;
1568 a<2;
1569 a++){this.attachMenu(this.tbody[a])
1570 }},attachMenu:function(a){if(this.options.click){Rico.eventBind(a,"click",this.options.click,false)
1571 }if(this.options.dblclick){if(Rico.isWebKit||Rico.isOpera){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleDblClick"),false)
1572 }else{Rico.eventBind(a,"dblclick",this.options.dblclick,false)
1573 }}if(this.options.contextmenu){if(Rico.isOpera||Rico.isKonqueror){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleContextMenu"),false)
1574 }else{Rico.eventBind(a,"contextmenu",this.options.contextmenu,false)
1575 }}},handleDblClick:function(b){var a=Rico.eventElement(b);
1576 if(this.dblClickElem==a){this.options.dblclick(b)
1577 }else{this.dblClickElem=a;
1578 this.safariTimer=Rico.runLater(300,this,"clearDblClick")
1579 }},clearDblClick:function(){this.dblClickElem=null
1580 },handleContextMenu:function(c){var a;
1581 if(typeof(c.which)=="number"){a=c.which
1582 }else{if(typeof(c.button)=="number"){a=c.button
1583 }else{return
1584 }}if(a==1&&c.ctrlKey){this.options.contextmenu(c)
1585 }},cancelMenu:function(){if(this.menu){this.menu.cancelmenu()
1586 }},getColumnInfo:function(f){Rico.log("getColumnInfo: len="+f.length);
1587 if(f.length==0){return 0
1588 }this.headerRowCnt=f.length;
1589 var d,h,e;
1590 for(d=0;
1591 d<this.headerRowCnt;
1592 d++){var b=f[d];
1593 var a=b.cells;
1594 if(d>=this.hdrCells.length){this.hdrCells[d]=[]
1595 }for(h=0;
1596 h<a.length;
1597 h++){var g={};
1598 g.cell=a[h];
1599 g.colSpan=a[h].colSpan||1;
1600 if(this.options.defaultWidth<0){g.initWidth=a[h].offsetWidth
1601 }this.hdrCells[d].push(g)
1602 }if(b.id.slice(-5)=="_main"){e=this.hdrCells[d].length;
1603 this.headerRowIdx=d
1604 }}if(!e){this.headerRowIdx=this.headerRowCnt-1;
1605 e=this.hdrCells[this.headerRowIdx].length
1606 }Rico.log("getColumnInfo: colcnt="+e);
1607 return e
1608 },addHeadingRow:function(g){var a=this.headerRowCnt++;
1609 this.hdrCells[a]=[];
1610 for(var e=0;
1611 e<2;
1612 e++){var k=this.thead[e].insertRow(-1);
1613 var f="ricoLG_hdg "+this.tableId+"_hdg"+a;
1614 if(g){f+=" "+g
1615 }k.className=f;
1616 var b=e==0?this.options.frozenColumns:this.headerColCnt-this.options.frozenColumns;
1617 for(var j=0;
1618 j<b;
1619 j++){var d=k.insertCell(-1);
1620 var i=Rico.wrapChildren(d,"ricoLG_col");
1621 Rico.wrapChildren(i,"ricoLG_cell");
1622 this.hdrCells[a].push({cell:d,colSpan:1})
1623 }}return a
1624 },createColumnArray:function(b){this.direction=Rico.getStyle(this.outerDiv,"direction").toLowerCase();
1625 this.align=this.direction=="rtl"?["right","left"]:["left","right"];
1626 Rico.log("createColumnArray: dir="+this.direction);
1627 this.columns=[];
1628 for(var e=0;
1629 e<this.headerColCnt;
1630 e++){Rico.log("createColumnArray: c="+e);
1631 var d=e<this.options.frozenColumns?0:1;
1632 var a=new Rico[b](this,e,this.hdrCells[this.headerRowIdx][e],d);
1633 this.columns.push(a);
1634 if(e>0){this.columns[e-1].next=a
1635 }}this.getCookie();
1636 Rico.runLater(100,this,"insertResizers")
1637 },insertResizers:function(){if(!this.options.allowColResize){return
1638 }for(var a=0;
1639 a<this.columns.length;
1640 a++){this.columns[a].insertResizer()
1641 }},createDivs:function(){Rico.log("createDivs start");
1642 this.outerDiv=this.createDiv("outer");
1643 if(Rico.theme.gridContainer){Rico.addClass(this.outerDiv,Rico.theme.gridContainer)
1644 }if(this.outerDiv.firstChild&&this.outerDiv.firstChild.tagName&&this.outerDiv.firstChild.tagName.toUpperCase()=="TABLE"){this.structTab=this.outerDiv.firstChild;
1645 this.structTabLeft=this.structTab.rows[0].cells[0];
1646 this.structTabUR=this.structTab.rows[0].cells[1];
1647 this.structTabLR=this.structTab.rows[1].cells[0]
1648 }else{this.structTab=document.createElement("table");
1649 this.structTab.border=0;
1650 this.structTab.cellPadding=0;
1651 this.structTab.cellSpacing=0;
1652 var b=this.structTab.insertRow(-1);
1653 b.vAlign="top";
1654 this.structTabLeft=b.insertCell(-1);
1655 this.structTabLeft.rowSpan=2;
1656 this.structTabLeft.style.padding="0px";
1657 this.structTabLeft.style.border="none";
1658 var d=this.structTab.insertRow(-1);
1659 d.vAlign="top";
1660 this.structTabUR=b.insertCell(-1);
1661 this.structTabUR.style.padding="0px";
1662 this.structTabUR.style.border="none";
1663 this.structTabLR=d.insertCell(-1);
1664 this.structTabLR.style.padding="0px";
1665 this.structTabLR.style.border="none";
1666 this.outerDiv.appendChild(this.structTab)
1667 }Rico.addClass(this.structTab,"ricoLG_StructTab");
1668 this.frozenTabs=this.createDiv("frozenTabs",this.structTabLeft);
1669 this.innerDiv=this.createDiv("inner",this.structTabUR);
1670 this.scrollDiv=this.createDiv("scroll",this.structTabLR);
1671 this.resizeDiv=this.createDiv("resize",this.outerDiv,true);
1672 this.messagePopup=new Rico.Popup();
1673 this.messagePopup.createContainer({hideOnEscape:false,hideOnClick:false,parent:this.outerDiv});
1674 this.messagePopup.content.className="ricoLG_messageDiv";
1675 if(Rico.theme.gridMessage){Rico.addClass(this.messagePopup.content,Rico.theme.gridMessage)
1676 }this.keywordPopup=new Rico.Window("",{zIndex:-1,parent:this.outerDiv});
1677 Rico.addClass(this.keywordPopup.container,"ricoLG_keywordDiv");
1678 var a=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
1679 a.innerHTML=Rico.getPhraseById("keywordPrompt");
1680 this.keywordBox=this.keywordPopup.contentDiv.appendChild(document.createElement("input"));
1681 this.keywordBox.size=20;
1682 Rico.eventBind(this.keywordBox,"keypress",Rico.eventHandle(this,"keywordKey"),false);
1683 this.keywordPopup.contentDiv.appendChild(Rico.floatButton("Checkmark",Rico.eventHandle(this,"processKeyword")));
1684 var c=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
1685 Rico.setStyle(c,{clear:"both"});
1686 Rico.log("createDivs end")
1687 },keywordKey:function(a){switch(Rico.eventKey(a)){case 27:this.closeKeyword();
1688 Rico.eventStop(a);
1689 return false;
1690 case 13:this.processKeyword();
1691 Rico.eventStop(a);
1692 return false
1693 }return true
1694 },openKeyword:function(a){this.keywordCol=a;
1695 this.keywordBox.value="";
1696 this.keywordPopup.setTitle(this.columns[a].displayName);
1697 this.keywordPopup.centerPopup();
1698 this.keywordBox.focus()
1699 },closeKeyword:function(){this.keywordPopup.closePopup();
1700 this.cancelMenu()
1701 },processKeyword:function(){var a=this.keywordBox.value;
1702 this.closeKeyword();
1703 this.columns[this.keywordCol].setFilterKW(a)
1704 },createDiv:function(c,a,b){var e=this.tableId+"_"+c+"Div";
1705 var d=document.getElementById(e);
1706 if(!d){d=document.createElement("div");
1707 d.id=e;
1708 if(a){a.appendChild(d)
1709 }}d.className="ricoLG_"+c+"Div";
1710 if(b){Rico.hide(d)
1711 }return d
1712 },baseSizeDivs:function(){this.setOtherHdrCellWidths();
1713 if(this.options.frozenColumns){Rico.show(this.tabs[0]);
1714 Rico.show(this.frozenTabs);
1715 this.hdrHt=Math.max(Rico.nan2zero(this.thead[0].offsetHeight),this.thead[1].offsetHeight);
1716 this.dataHt=Math.max(Rico.nan2zero(this.tbody[0].offsetHeight),this.tbody[1].offsetHeight);
1717 this.frzWi=this.borderWidth(this.tabs[0])
1718 }else{Rico.hide(this.tabs[0]);
1719 Rico.hide(this.frozenTabs);
1720 this.frzWi=0;
1721 this.hdrHt=this.thead[1].offsetHeight;
1722 this.dataHt=this.tbody[1].offsetHeight
1723 }var d,b;
1724 var c=this.borderWidth(this.columns[0].dataCell);
1725 Rico.log("baseSizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
1726 Rico.log(this.tableId+" frzWi="+this.frzWi+" borderWi="+c);
1727 for(b=0;
1728 b<this.options.frozenColumns;
1729 b++){if(this.columns[b].visible){this.frzWi+=parseInt(this.columns[b].colWidth,10)+c
1730 }}this.scrTabWi=this.borderWidth(this.tabs[1]);
1731 this.scrTabWi0=this.scrTabWi;
1732 Rico.log("scrTabWi: "+this.scrTabWi);
1733 for(b=this.options.frozenColumns;
1734 b<this.columns.length;
1735 b++){if(this.columns[b].visible){this.scrTabWi+=parseInt(this.columns[b].colWidth,10)+c
1736 }}this.scrWi=this.scrTabWi+this.options.scrollBarWidth;
1737 if(this.sizeTo=="parent"){if(Rico.isIE){Rico.hide(this.outerDiv)
1738 }d=this.outerDiv.parentNode.offsetWidth;
1739 if(Rico.isIE){Rico.show(this.outerDiv)
1740 }}else{d=Rico.windowWidth()-this.options.scrollBarWidth-8
1741 }if(this.outerDiv.parentNode.clientWidth>0){d=Math.min(this.outerDiv.parentNode.clientWidth,d)
1742 }var a=this.frzWi+this.scrWi-d;
1743 Rico.log("baseSizeDivs "+this.tableId+": scrWi="+this.scrWi+" wiLimit="+d+" overage="+a+" clientWidth="+this.outerDiv.parentNode.clientWidth);
1744 if(a>0&&this.options.frozenColumns<this.columns.length){this.scrWi=Math.max(this.scrWi-a,this.options.minScrollWidth)
1745 }this.scrollDiv.style.width=this.scrWi+"px";
1746 this.frozenTabs.style.width=this.frzWi+"px";
1747 this.outerDiv.style.width=(this.frzWi+this.scrWi)+"px"
1748 },borderWidth:function(c){var a=Rico.nan2zero(Rico.getStyle(c,"borderLeftWidth"));
1749 var b=Rico.nan2zero(Rico.getStyle(c,"borderRightWidth"));
1750 Rico.log((c.id||c.tagName)+" borderWidth: L="+a+", R="+b);
1751 return a+b
1752 },setOtherHdrCellWidths:function(){var k,g,f,a,l,b,m,d,e,h;
1753 for(a=0;
1754 a<this.hdrCells.length;
1755 a++){if(a==this.headerRowIdx){continue
1756 }Rico.log("setOtherHdrCellWidths: r="+a);
1757 k=g=0;
1758 while(g<this.headerColCnt&&k<this.hdrCells[a].length){b=this.hdrCells[a][k];
1759 m=b.cell;
1760 d=e=b.colSpan;
1761 for(l=f=0;
1762 f<d;
1763 f++,g++){if(this.columns[g].hdrCell.style.display=="none"){e--
1764 }else{if(this.columns[g].hdrColDiv.style.display!="none"){l+=parseInt(this.columns[g].colWidth,10)
1765 }}}if(!b.hdrColDiv||!b.hdrCellDiv){h=m.getElementsByTagName("div");
1766 b.hdrColDiv=(h.length<1)?Rico.wrapChildren(m,"ricoLG_col"):h[0];
1767 b.hdrCellDiv=(h.length<2)?Rico.wrapChildren(b.hdrColDiv,"ricoLG_cell"):h[1]
1768 }if(e==0){m.style.display="none"
1769 }else{if(l==0){b.hdrColDiv.style.display="none";
1770 m.colSpan=e
1771 }else{m.style.display="";
1772 b.hdrColDiv.style.display="";
1773 m.colSpan=e;
1774 b.hdrColDiv.style.width=l+"px"
1775 }}k++
1776 }}},initFilterImage:function(a){this.filterAnchor=document.getElementById(this.tableId+"_filterLink");
1777 if(!this.filterAnchor){return
1778 }this.filterRows=Rico.select("tr."+this.tableId+"_hdg"+a);
1779 if(this.filterRows.length!=2){return
1780 }for(var c=0,d=[];
1781 c<2;
1782 c++){d[c]=Rico.select(".ricoLG_cell",this.filterRows[c])
1783 }this.filterElements=d[0].concat(d[1]);
1784 this.saveHeight=this.filterElements[0].offsetHeight;
1785 var e=Rico.getStyle(this.filterElements[0],"paddingTop");
1786 var b=Rico.getStyle(this.filterElements[0],"paddingBottom");
1787 if(e){this.saveHeight-=parseInt(e,10)
1788 }if(b){this.saveHeight-=parseInt(b,10)
1789 }this.rowNum=a;
1790 this.setFilterImage(false)
1791 },toggleFilterRow:function(){if(Rico.visible(this.filterRows[0])){this.slideFilterUp()
1792 }else{this.slideFilterDown()
1793 }},setFilterImage:function(b){var a=Rico.getPhraseById((b?"show":"hide")+"FilterRow");
1794 this.filterAnchor.innerHTML='<img src="'+Rico.imgDir+"tableFilter"+(b?"Expand":"Collapse")+'.gif" alt="'+a+'" border="0">'
1795 },cell:function(a,b){return(0<=b&&b<this.columns.length&&a>=0)?this.columns[b].cell(a):null
1796 },availHt:function(){var a=Rico.cumulativeOffset(this.outerDiv);
1797 return Rico.windowHeight()-a.top-2*this.options.scrollBarWidth-15
1798 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
1799 this.hdrTabs[1].style.marginLeft=a
1800 },pluginScroll:function(){if(this.scrollPluggedIn){return
1801 }Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
1802 this.scrollPluggedIn=true
1803 },unplugScroll:function(){Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
1804 this.scrollPluggedIn=false
1805 },hideMsg:function(){this.messagePopup.closePopup()
1806 },showMsg:function(a){this.messagePopup.setContent(a);
1807 this.messagePopup.centerPopup();
1808 Rico.log("showMsg: "+a)
1809 },listInvisible:function(b){var c=[];
1810 for(var a=0;
1811 a<this.columns.length;
1812 a++){if(!this.columns[a].visible){c.push(b?this.columns[a][b]:this.columns[a])
1813 }}return c
1814 },firstVisible:function(){for(var a=0;
1815 a<this.columns.length;
1816 a++){if(this.columns[a].visible){return a
1817 }}return -1
1818 },showAll:function(){var b=this.listInvisible();
1819 for(var a=0;
1820 a<b.length;
1821 a++){b[a].showColumn()
1822 }},chooseColumns:function(){this.menu.cancelmenu();
1823 var a,f,b,e,d,c;
1824 if(!this.columnChooser){Rico.log("creating columnChooser");
1825 f=Rico.getStyle(this.outerDiv.offsetParent,"zIndex");
1826 if(typeof f!="number"){f=0
1827 }this.columnChooser=new Rico.Window(Rico.getPhraseById("gridChooseCols"),{zIndex:f+2,parent:this.outerDiv});
1828 Rico.addClass(this.columnChooser.container,"ricoLG_chooserDiv");
1829 c=this.columnChooser.contentDiv;
1830 for(a=0;
1831 a<this.columns.length;
1832 a++){b=this.columns[a];
1833 e=c.appendChild(document.createElement("div"));
1834 b.ChooserBox=Rico.createFormField(e,"input","checkbox");
1835 d=e.appendChild(document.createElement("span"));
1836 d.innerHTML=b.displayName;
1837 Rico.eventBind(b.ChooserBox,"click",Rico.eventHandle(b,"chooseColumn"),false)
1838 }}Rico.log("opening columnChooser");
1839 this.columnChooser.openPopup(1,this.hdrHt);
1840 for(a=0;
1841 a<this.columns.length;
1842 a++){this.columns[a].ChooserBox.checked=this.columns[a].visible;
1843 this.columns[a].ChooserBox.disabled=!this.columns[a].canHideShow()
1844 }},blankRow:function(a){for(var b=0;
1845 b<this.columns.length;
1846 b++){this.columns[b].clearCell(a)
1847 }},getExportStyles:function(a){var e=this.options.exportStyleList;
1848 var b=Rico.getStyle(a,"backgroundImage");
1849 if(!b||b=="none"){return e
1850 }for(var d=[],c=0;
1851 c<e.length;
1852 c++){if(e[c]!="background-color"&&e[c]!="color"){d.push(e[c])
1853 }}return d
1854 },exportStart:function(){var a,h,f,d,b,e,k,l;
1855 var g=this.getExportStyles(this.thead[0]);
1856 this.exportRows=[];
1857 this.exportText="<html><head></head><body><table border='1' cellspacing='0'>";
1858 for(h=0;
1859 h<this.columns.length;
1860 h++){if(this.columns[h].visible){this.exportText+="<col width='"+parseInt(this.columns[h].colWidth,10)+"'>"
1861 }}this.exportText+="<thead style='display: table-header-group;'>";
1862 if(this.exportHeader){this.exportText+=this.exportHeader
1863 }for(a=0;
1864 a<this.hdrCells.length;
1865 a++){if(this.hdrCells[a].length==0||!Rico.visible(this.hdrCells[a][0].cell.parentNode)){continue
1866 }this.exportText+="<tr>";
1867 for(h=0,f=0;
1868 h<this.hdrCells[a].length;
1869 h++){b=this.hdrCells[a][h];
1870 e=b.colSpan;
1871 for(d=0;
1872 d<b.colSpan;
1873 d++,f++){if(!this.columns[f].visible){e--
1874 }}if(e>0){k=Rico.select(".ricoLG_cell",b.cell);
1875 l=k&&k.length>0?k[0]:b.cell;
1876 this.exportText+="<td style='"+this.exportStyle(l,g)+"'";
1877 if(b.colSpan>1){this.exportText+=" colspan='"+e+"'"
1878 }this.exportText+=">"+Rico.getInnerText(l,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport")+"</td>"
1879 }}this.exportText+="</tr>"
1880 }this.exportText+="</thead><tbody>"
1881 },exportFinish:function(){if(this.hideMsg){this.hideMsg()
1882 }window.status=Rico.getPhraseById("exportComplete");
1883 if(this.exportRows.length>0){this.exportText+="<tr>"+this.exportRows.join("</tr><tr>")+"</tr>"
1884 }if(this.exportFooter){this.exportText+=this.exportFooter
1885 }this.exportText+="</tbody></table></body></html>";
1886 if(this.cancelMenu){this.cancelMenu()
1887 }var a=window.open("","_blank",this.options.exportWindow);
1888 if(a==null){alert(Rico.getPhraseById("disableBlocker"))
1889 }else{a.document.open();
1890 a.document.write(this.exportText);
1891 a.document.close()
1892 }this.exportText=undefined;
1893 this.exportRows=undefined
1894 },exportStyle:function(d,g){for(var b=0,c="";
1895 b<g.length;
1896 b++){try{var a=Rico.getStyle(d,g[b]);
1897 if(a){c+=g[b]+":"+a+";"
1898 }}catch(f){}}return c
1899 },getCookie:function(){var k=Rico.getCookie(this.options.cookiePrefix+this.tableId);
1900 if(!k){return
1901 }var f=k.split(",");
1902 for(var g=0;
1903 g<f.length;
1904 g++){var a=f[g].split(":");
1905 if(a.length!=2){continue
1906 }var h=parseInt(a[0].slice(1),10);
1907 if(h<0||h>=this.columns.length){continue
1908 }var e=this.columns[h];
1909 switch(a[0].charAt(0)){case"w":e.setColWidth(a[1]);
1910 e.customWidth=true;
1911 break;
1912 case"h":if(a[1].toLowerCase()=="true"){e.hideshow(true,true)
1913 }else{e.hideshow(false,true)
1914 }break;
1915 case"s":if(!this.options.saveColumnInfo.sort||!e.sortable){break
1916 }e.setSorted(a[1]);
1917 break;
1918 case"f":if(!this.options.saveColumnInfo.filter||!e.filterable){break
1919 }var d=a[1].split("~");
1920 e.filterOp=d.shift();
1921 e.filterValues=[];
1922 e.filterType=Rico.ColumnConst.USERFILTER;
1923 for(var b=0;
1924 b<d.length;
1925 b++){e.filterValues.push(unescape(d[b]))
1926 }break
1927 }}},setCookie:function(){var d=[];
1928 for(var e=0;
1929 e<this.columns.length;
1930 e++){var c=this.columns[e];
1931 if(this.options.saveColumnInfo.width){if(c.customWidth){d.push("w"+e+":"+c.colWidth)
1932 }if(c.customVisible){d.push("h"+e+":"+c.visible)
1933 }}if(this.options.saveColumnInfo.sort){if(c.currentSort!=Rico.ColumnConst.UNSORTED){d.push("s"+e+":"+c.currentSort)
1934 }}if(this.options.saveColumnInfo.filter&&c.filterType==Rico.ColumnConst.USERFILTER){var b=[c.filterOp];
1935 for(var a=0;
1936 a<c.filterValues.length;
1937 a++){b.push(escape(c.filterValues[a]))
1938 }d.push("f"+e+":"+b.join("~"))
1939 }}Rico.setCookie(this.options.cookiePrefix+this.tableId,d.join(","),this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
1940 }};
1941 Rico.ColumnConst={UNFILTERED:0,SYSTEMFILTER:1,USERFILTER:2,UNSORTED:0,SORT_ASC:"ASC",SORT_DESC:"DESC",MINWIDTH:10,DOLLAR:{type:"number",prefix:"$",decPlaces:2,ClassName:"alignright"},EURO:{type:"number",prefix:"&euro;",decPlaces:2,ClassName:"alignright"},PERCENT:{type:"number",suffix:"%",decPlaces:2,multiplier:100,ClassName:"alignright"},QTY:{type:"number",decPlaces:0,ClassName:"alignright"},DEFAULT:{type:"showTags"}};
1942 Rico.TableColumnBase=function(){};
1943 Rico.TableColumnBase.prototype={baseInit:function(h,g,e,d){Rico.log("TableColumnBase.init index="+g+" tabIdx="+d);
1944 this.liveGrid=h;
1945 this.index=g;
1946 this.hideWidth=Rico.isKonqueror||Rico.isWebKit||h.headerRowCnt>1?5:2;
1947 this.options=h.options;
1948 this.tabIdx=d;
1949 this.hdrCell=e.cell;
1950 this.body=document.getElementsByTagName("body")[0];
1951 this.displayName=this.getDisplayName(this.hdrCell);
1952 var c=this.hdrCell.getElementsByTagName("div");
1953 this.hdrColDiv=(c.length<1)?Rico.wrapChildren(this.hdrCell,"ricoLG_col"):c[0];
1954 this.hdrCellDiv=(c.length<2)?Rico.wrapChildren(this.hdrColDiv,"ricoLG_cell"):c[1];
1955 var f=d==0?g:g-h.options.frozenColumns;
1956 this.dataCell=h.tbody[d].rows[0].cells[f];
1957 c=this.dataCell.getElementsByTagName("div");
1958 this.dataColDiv=(c.length<1)?Rico.wrapChildren(this.dataCell,"ricoLG_col"):c[0];
1959 this.mouseDownHandler=Rico.eventHandle(this,"handleMouseDown");
1960 this.mouseMoveHandler=Rico.eventHandle(this,"handleMouseMove");
1961 this.mouseUpHandler=Rico.eventHandle(this,"handleMouseUp");
1962 this.mouseOutHandler=Rico.eventHandle(this,"handleMouseOut");
1963 this.fieldName="col"+this.index;
1964 var b=h.options.columnSpecs[g];
1965 this.format=Rico.extend({},Rico.ColumnConst.DEFAULT);
1966 switch(typeof b){case"object":if(typeof b.format=="string"){Rico.extend(this.format,Rico.ColumnConst[b.format.toUpperCase()])
1967 }Rico.extend(this.format,b);
1968 break;
1969 case"string":if(b.slice(0,4)=="spec"){b=b.slice(4).toUpperCase()
1970 }if(typeof Rico.ColumnConst[b]=="object"){Rico.extend(this.format,Rico.ColumnConst[b])
1971 }break
1972 }Rico.addClass(this.dataColDiv,this.colClassName());
1973 this.visible=true;
1974 if(typeof this.format.visible=="boolean"){this.visible=this.format.visible
1975 }Rico.log("TableColumn.init index="+g+" fieldName="+this.fieldName);
1976 this.sortable=typeof this.format.canSort=="boolean"?this.format.canSort:h.options.canSortDefault;
1977 this.currentSort=Rico.ColumnConst.UNSORTED;
1978 this.filterable=typeof this.format.canFilter=="boolean"?this.format.canFilter:h.options.canFilterDefault;
1979 this.filterType=Rico.ColumnConst.UNFILTERED;
1980 this.hideable=typeof this.format.canHide=="boolean"?this.format.canHide:h.options.canHideDefault;
1981 var a;
1982 switch(typeof this.format.width){case"number":a=this.format.width;
1983 break;
1984 case"string":a=parseInt(this.format.width,10);
1985 break;
1986 default:a=e.initWidth;
1987 break
1988 }a=(typeof(a)=="number")?Math.max(a,Rico.ColumnConst.MINWIDTH):h.options.defaultWidth;
1989 this.setColWidth(a);
1990 if(!this.visible){this.setDisplay("none")
1991 }},colClassName:function(){return this.format.ClassName?this.format.ClassName:this.liveGrid.tableId+"_col"+this.index
1992 },insertResizer:function(){if(this.format.noResize){return
1993 }var a=document.createElement("div");
1994 a.className="ricoLG_Resize";
1995 a.style[this.liveGrid.align[1]]="0px";
1996 this.hdrCellDiv.appendChild(a);
1997 Rico.eventBind(a,"mousedown",this.mouseDownHandler,false)
1998 },getDisplayName:function(a){var b=a.getElementsByTagName("A");
1999 if(b.length>0){return b[0].innerHTML
2000 }else{return Rico.stripTags(a.innerHTML)
2001 }},_clear:function(a){a.innerHTML="&nbsp;"
2002 },clearCell:function(d){var c=this.cell(d);
2003 this._clear(c,d);
2004 if(!this.liveGrid.buffer){return
2005 }var b=this.liveGrid.buffer.options.acceptAttr;
2006 for(var a=0;
2007 a<b.length;
2008 a++){switch(b[a]){case"style":c.style.cssText="";
2009 break;
2010 case"class":c.className="";
2011 break;
2012 default:c["_"+b[a]]="";
2013 break
2014 }}},dataTable:function(){return this.liveGrid.tabs[this.tabIdx]
2015 },numRows:function(){return this.dataColDiv.childNodes.length
2016 },clearColumn:function(){var b=this.numRows();
2017 for(var a=0;
2018 a<b;
2019 a++){this.clearCell(a)
2020 }},cell:function(a){return this.dataColDiv.childNodes[a]
2021 },getFormattedValue:function(c,a,d,b){return Rico.getInnerText(this.cell(c),a,d,b)
2022 },setColWidth:function(a){if(typeof a=="number"){a=parseInt(a,10);
2023 if(a<Rico.ColumnConst.MINWIDTH){return
2024 }a=a+"px"
2025 }Rico.log("setColWidth "+this.index+": "+a);
2026 this.colWidth=a;
2027 this.hdrColDiv.style.width=a;
2028 this.dataColDiv.style.width=a
2029 },pluginMouseEvents:function(){if(this.mousePluggedIn==true){return
2030 }Rico.eventBind(this.body,"mousemove",this.mouseMoveHandler,false);
2031 Rico.eventBind(this.body,"mouseup",this.mouseUpHandler,false);
2032 Rico.eventBind(this.body,"mouseout",this.mouseOutHandler,false);
2033 this.mousePluggedIn=true
2034 },unplugMouseEvents:function(){Rico.eventUnbind(this.body,"mousemove",this.mouseMoveHandler,false);
2035 Rico.eventUnbind(this.body,"mouseup",this.mouseUpHandler,false);
2036 Rico.eventUnbind(this.body,"mouseout",this.mouseOutHandler,false);
2037 this.mousePluggedIn=false
2038 },handleMouseDown:function(b){this.resizeStart=Rico.eventClient(b).x;
2039 this.origWidth=parseInt(this.colWidth,10);
2040 var a=Rico.positionedOffset(this.hdrCell);
2041 if(this.liveGrid.direction=="rtl"){this.edge=a.left+this.liveGrid.options.scrollBarWidth;
2042 switch(this.tabIdx){case 0:this.edge+=this.liveGrid.innerDiv.offsetWidth;
2043 break;
2044 case 1:this.edge-=this.liveGrid.scrollDiv.scrollLeft;
2045 break
2046 }}else{this.edge=a.left+this.hdrCell.offsetWidth;
2047 if(this.tabIdx>0){this.edge+=Rico.nan2zero(this.liveGrid.tabs[0].offsetWidth)
2048 }}this.liveGrid.resizeDiv.style.left=this.edge+"px";
2049 this.liveGrid.resizeDiv.style.display="";
2050 this.liveGrid.outerDiv.style.cursor="e-resize";
2051 this.tmpHighlight=this.liveGrid.highlightEnabled;
2052 this.liveGrid.highlightEnabled=false;
2053 this.pluginMouseEvents();
2054 Rico.eventStop(b)
2055 },handleMouseMove:function(b){var c=Rico.eventClient(b).x-this.resizeStart;
2056 var a=(this.liveGrid.direction=="rtl")?this.origWidth-c:this.origWidth+c;
2057 if(a<Rico.ColumnConst.MINWIDTH){return
2058 }this.liveGrid.resizeDiv.style.left=(this.edge+c)+"px";
2059 this.colWidth=a;
2060 Rico.eventStop(b)
2061 },handleMouseUp:function(a){this.unplugMouseEvents();
2062 Rico.log("handleMouseUp "+this.liveGrid.tableId);
2063 this.liveGrid.outerDiv.style.cursor="";
2064 this.liveGrid.resizeDiv.style.display="none";
2065 this.setColWidth(this.colWidth);
2066 this.customWidth=true;
2067 this.liveGrid.setCookie();
2068 this.liveGrid.highlightEnabled=this.tmpHighlight;
2069 this.liveGrid.sizeDivs();
2070 Rico.eventStop(a)
2071 },handleMouseOut:function(b){var a=Rico.eventRelatedTarget(b)||b.toElement;
2072 while(a!=null&&a.nodeName.toLowerCase()!="body"){a=a.parentNode
2073 }if(a!=null&&a.nodeName.toLowerCase()=="body"){return true
2074 }this.handleMouseUp(b);
2075 return true
2076 },setDisplay:function(a){this.hdrCell.style.display=a;
2077 this.hdrColDiv.style.display=a;
2078 this.dataCell.style.display=a;
2079 this.dataColDiv.style.display=a
2080 },hideshow:function(b,a){this.setDisplay(b?"":"none");
2081 this.liveGrid.cancelMenu();
2082 this.visible=b;
2083 this.customVisible=true;
2084 if(a){return
2085 }this.liveGrid.setCookie();
2086 this.liveGrid.sizeDivs()
2087 },hideColumn:function(){Rico.log("hideColumn "+this.liveGrid.tableId);
2088 this.hideshow(false,false)
2089 },showColumn:function(){Rico.log("showColumn "+this.liveGrid.tableId);
2090 this.hideshow(true,false)
2091 },chooseColumn:function(b){var a=Rico.eventElement(b);
2092 this.hideshow(a.checked,false)
2093 },setImage:function(){if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.imgSort.style.display="inline-block";
2094 this.imgSort.className=Rico.theme.sortAsc||"rico-icon ricoLG_sortAsc"
2095 }else{if(this.currentSort==Rico.ColumnConst.SORT_DESC){this.imgSort.style.display="inline-block";
2096 this.imgSort.className=Rico.theme.sortDesc||"rico-icon ricoLG_sortDesc"
2097 }else{this.imgSort.style.display="none"
2098 }}if(this.filterType==Rico.ColumnConst.USERFILTER){this.imgFilter.style.display="inline-block";
2099 this.imgFilter.title=this.getFilterText()
2100 }else{this.imgFilter.style.display="none"
2101 }},canHideShow:function(){return this.hideable
2102 }};
2103 if(typeof Rico=="undefined"){throw ("SimpleGrid requires the Rico JavaScript framework")
2104 }Rico.SimpleGrid=function(b,a){this.initialize(b,a)
2105 };
2106 Rico.SimpleGrid.prototype={initialize:function(b,a){Rico.extend(this,Rico.GridCommon);
2107 this.baseInit();
2108 Rico.setDebugArea(b+"_debugmsgs");
2109 Rico.extend(this.options,a||{});
2110 this.tableId=b;
2111 Rico.log("SimpleGrid initialize start: "+b);
2112 this.createDivs();
2113 this.hdrTabs=new Array(2);
2114 this.simpleGridInit();
2115 Rico.log("SimpleGrid initialize end: "+b)
2116 },simpleGridInit:function(){var a;
2117 for(a=0;
2118 a<2;
2119 a++){Rico.log("simpleGridInit "+a);
2120 this.tabs[a]=document.getElementById(this.tableId+"_tab"+a);
2121 if(!this.tabs[a]){return
2122 }this.hdrTabs[a]=document.getElementById(this.tableId+"_tab"+a+"h");
2123 if(!this.hdrTabs[a]){return
2124 }this.thead[a]=this.hdrTabs[a];
2125 this.tbody[a]=this.tabs[a];
2126 this.headerColCnt=this.getColumnInfo(this.hdrTabs[a].rows);
2127 if(a==0){this.options.frozenColumns=this.headerColCnt
2128 }if(Rico.theme.gridheader){Rico.addClass(this.thead[a],Rico.theme.gridheader)
2129 }if(Rico.theme.gridcontent){Rico.addClass(this.tbody[a],Rico.theme.gridcontent)
2130 }}if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2131 return
2132 }this.createColumnArray("SimpleGridColumn");
2133 this.pageSize=this.columns[0].dataColDiv.childNodes.length;
2134 this.sizeDivs();
2135 if(typeof(this.options.FilterLocation)=="number"){this.createFilters(this.options.FilterLocation)
2136 }this.attachMenuEvents();
2137 this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2138 this.pluginScroll();
2139 if(this.options.windowResize){Rico.eventBind(window,"resize",Rico.eventHandle(this,"sizeDivs"),false)
2140 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
2141 },createFilters:function(a){if(a<0){a=this.addHeadingRow();
2142 this.sizeDivs()
2143 }for(var g=0;
2144 g<this.headerColCnt;
2145 g++){var d=this.columns[g];
2146 var e=d.format;
2147 if(typeof e.filterUI!="string"){continue
2148 }var k=this.hdrCells[a][g].cell;
2149 var j,b=this.filterId(g);
2150 var h=k.getElementsByTagName("div");
2151 switch(e.filterUI.charAt(0)){case"t":j=Rico.createFormField(h[1],"input","text",b,b);
2152 var m=e.filterUI.match(/\d+/);
2153 j.maxLength=e.Length||50;
2154 j.size=m?parseInt(m,10):10;
2155 Rico.eventBind(j,"keyup",Rico.eventHandle(d,"filterKeypress"),false);
2156 break;
2157 case"s":j=Rico.createFormField(h[1],"select",null,b);
2158 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
2159 this.getFilterValues(d);
2160 var l=Rico.keys(d.filterHash);
2161 l.sort();
2162 for(var f=0;
2163 f<l.length;
2164 f++){Rico.addSelectOption(j,l[f],l[f]||Rico.getPhraseById("filterBlank"))
2165 }Rico.eventBind(j,"change",Rico.eventHandle(d,"filterChange"),false);
2166 break
2167 }}this.initFilterImage(a)
2168 },getFilterValues:function(b){var e={};
2169 var f=b.numRows();
2170 for(var c=0;
2171 c<f;
2172 c++){var a=Rico.getInnerText(b.cell(c));
2173 var d=e[a];
2174 if(d){d.push(c)
2175 }else{e[a]=[c]
2176 }}b.filterHash=e
2177 },applyFilters:function(){var b=[];
2178 for(var f=0;
2179 f<this.columns.length;
2180 f++){if(this.columns[f].filterRows){b.push(this.columns[f].filterRows)
2181 }}if(b.length==0){this.showAllRows();
2182 return
2183 }for(var d=0;
2184 d<this.pageSize;
2185 d++){var e=true;
2186 for(var a=0;
2187 a<b.length;
2188 a++){if(b[a].indexOf(d)==-1){e=false;
2189 break
2190 }}if(e){this.showRow(d)
2191 }else{this.hideRow(d)
2192 }}this.sizeDivs()
2193 },handleScroll:function(b){var a=(-this.scrollDiv.scrollTop)+"px";
2194 this.tabs[0].style.marginTop=a;
2195 this.setHorizontalScroll()
2196 },registerScrollMenu:function(a){if(!this.menu){this.menu=a
2197 }a.grid=this;
2198 a.showmenu=a.showSimpleMenu;
2199 a.showSubMenu=a.showSimpleSubMenu;
2200 a.createDiv(this.outerDiv)
2201 },handleMenuClick:function(a){if(!this.menu){return
2202 }this.cancelMenu();
2203 this.menuCell=Rico.getParentByTagName(Rico.eventElement(a),"div");
2204 this.highlightEnabled=false;
2205 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
2206 }if(this.menu.buildGridMenu){this.menu.buildGridMenu(this.menuCell)
2207 }this.menu.showmenu(a,this.closeMenu.bind(this))
2208 },closeMenu:function(){if(this.hideScroll){this.scrollDiv.style.overflow=""
2209 }this.highlightEnabled=true
2210 },sizeDivs:function(){if(this.outerDiv.offsetParent.style.display=="none"){return
2211 }this.baseSizeDivs();
2212 var c=Math.max(this.options.maxHt||this.availHt(),50);
2213 var b=Math.min(this.hdrHt+this.dataHt,c);
2214 Rico.log("sizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
2215 this.dataHt=b-this.hdrHt;
2216 if(this.scrWi>0){this.dataHt+=this.options.scrollBarWidth
2217 }this.scrollDiv.style.height=this.dataHt+"px";
2218 this.frozenTabs.style.height=this.scrollDiv.clientHeight+"px";
2219 var a=2;
2220 this.innerDiv.style.width=(this.scrWi-this.options.scrollBarWidth+a)+"px";
2221 b+=a;
2222 this.resizeDiv.style.height=b+"px";
2223 this.handleScroll()
2224 },printVisible:function(){this.showMsg(Rico.getPhraseById("exportInProgress"));
2225 Rico.runLater(10,this,"_printVisible")
2226 },_printVisible:function(){this.exportStart();
2227 var f=this.getExportStyles(this.tbody[0]);
2228 for(var e=0;
2229 e<this.pageSize;
2230 e++){if(this.columns[0].cell(e).style.display=="none"){continue
2231 }var d="";
2232 for(var g=0;
2233 g<this.columns.length;
2234 g++){var b=this.columns[g];
2235 if(b.visible){var a=b.getFormattedValue(e,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport");
2236 if(b.format.exportPrefix){a=b.format.exportPrefix+a
2237 }if(a==""){a="&nbsp;"
2238 }d+="<td style='"+this.exportStyle(b.cell(e),f)+"'>"+a+"</td>"
2239 }}this.exportRows.push(d)
2240 }this.exportFinish()
2241 },hideRow:function(a){if(this.columns[0].cell(a).style.display=="none"){return
2242 }for(var b=0;
2243 b<this.columns.length;
2244 b++){this.columns[b].cell(a).style.display="none"
2245 }},showRow:function(a){if(this.columns[0].cell(a).style.display==""){return
2246 }for(var b=0;
2247 b<this.columns.length;
2248 b++){this.columns[b].cell(a).style.display=""
2249 }},searchRows:function(h,e,c){if(!e){return
2250 }var f=new RegExp(e);
2251 var d=this.columns[h].numRows();
2252 for(var g=0;
2253 g<d;
2254 g++){var b=this.cell(g,h).innerHTML;
2255 var a=(b.match(f)!=null);
2256 if(a!=c){this.hideRow(g)
2257 }}this.sizeDivs();
2258 this.handleScroll()
2259 },showAllRows:function(){for(var a=0;
2260 a<this.pageSize;
2261 a++){this.showRow(a)
2262 }this.sizeDivs()
2263 },openPopup:function(d,e){while(d&&!Rico.hasClass(d,"ricoLG_cell")){d=d.parentNode
2264 }if(!d){return false
2265 }var f=Rico.getParentByTagName(d,"td");
2266 var c=Math.floor(f.offsetLeft-this.scrollDiv.scrollLeft+f.offsetWidth/2);
2267 if(this.direction=="rtl"){if(c>this.width){c-=this.width
2268 }}else{if(c+this.width+this.options.margin>this.scrollDiv.clientWidth){c-=this.width
2269 }}e.divPopup.style.visibility="hidden";
2270 e.divPopup.style.display="block";
2271 var b=e.divPopup.offsetHeight;
2272 var a=Math.floor(d.offsetTop-this.scrollDiv.scrollTop+d.offsetHeight/2);
2273 if(a+b+e.options.margin>this.scrollDiv.clientHeight){a=Math.max(a-b,0)
2274 }e.openPopup(this.frzWi+c,this.hdrHt+a);
2275 e.divPopup.style.visibility="visible";
2276 return d
2277 }};
2278 if(Rico.Menu){Rico.extend(Rico.Menu.prototype,{showSimpleMenu:function(b,c){Rico.eventStop(b);
2279 this.hideFunc=c;
2280 if(this.div.childNodes.length==0){this.cancelmenu();
2281 return false
2282 }var a=Rico.eventElement(b);
2283 this.grid.openPopup(a,this);
2284 return a
2285 },showSimpleSubMenu:function(b,c){if(this.openSubMenu){this.hideSubMenu()
2286 }this.openSubMenu=c;
2287 this.openMenuAnchor=b;
2288 if(b.className=="ricoSubMenu"){b.className="ricoSubMenuOpen"
2289 }var e=parseInt(this.div.style.top,10);
2290 var d=parseInt(this.div.style.left,10);
2291 c.openPopup(d+b.offsetWidth,e+b.offsetTop);
2292 c.div.style.visibility="visible"
2293 }})
2294 }Rico.SimpleGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
2295 };
2296 Rico.SimpleGridColumn.prototype={initialize:function(a,d,c,b){Rico.extend(this,new Rico.TableColumnBase());
2297 this.baseInit(a,d,c,b)
2298 },setUnfiltered:function(){this.filterRows=null
2299 },filterChange:function(a){var b=Rico.eventElement(a);
2300 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
2301 }else{this.filterRows=this.filterHash[b.value]
2302 }this.liveGrid.applyFilters()
2303 },filterKeypress:function(f){var a=Rico.eventElement(f);
2304 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
2305 }if(this.lastKeyFilter==a.value){return
2306 }var b=a.value;
2307 Rico.log("filterKeypress: "+this.index+" "+b);
2308 this.lastKeyFilter=b;
2309 if(b){b=b.replace("\\","\\\\");
2310 b=b.replace("(","\\(").replace(")","\\)");
2311 b=b.replace(".","\\.");
2312 if(this.format.filterUI.indexOf("^")>0){b="^"+b
2313 }var d=new RegExp(b,"i");
2314 this.filterRows=[];
2315 var h=this.numRows();
2316 for(var c=0;
2317 c<h;
2318 c++){var g=Rico.getInnerText(this.cell(c));
2319 if(g.match(d)){this.filterRows.push(c)
2320 }}}else{this.setUnfiltered()
2321 }this.liveGrid.applyFilters()
2322 }};
2323 if(typeof Rico=="undefined"){throw ("LiveGrid requires the Rico JavaScript framework")
2324 }if(!Rico.Buffer){Rico.Buffer={}
2325 }Rico.Buffer.Base=function(b,a){this.initialize(b,a)
2326 };
2327 Rico.Buffer.Base.prototype={initialize:function(b,a){this.clear();
2328 this.updateInProgress=false;
2329 this.lastOffset=0;
2330 this.rcvdRowCount=false;
2331 this.foundRowCount=false;
2332 this.totalRows=0;
2333 this.rowcntContent="";
2334 this.rcvdOffset=-1;
2335 this.options={fixedHdrRows:0,canFilter:true,isEncoded:true,acceptAttr:[]};
2336 Rico.extend(this.options,a||{});
2337 if(b){this.loadRowsFromTable(b,this.options.fixedHdrRows)
2338 }else{this.clear()
2339 }},registerGrid:function(a){this.liveGrid=a
2340 },setTotalRows:function(a){if(typeof(a)!="number"){a=this.size
2341 }if(this.totalRows==a){return
2342 }this.totalRows=a;
2343 if(!this.liveGrid){return
2344 }Rico.log("setTotalRows, newTotalRows="+a);
2345 switch(this.liveGrid.sizeTo){case"data":this.liveGrid.resizeWindow();
2346 break;
2347 case"datamax":this.liveGrid.setPageSize(a);
2348 break;
2349 default:this.liveGrid.updateHeightDiv();
2350 break
2351 }},loadRowsFromTable:function(h,g){var e=new Array();
2352 var a=h.getElementsByTagName("tr");
2353 for(var d=g||0;
2354 d<a.length;
2355 d++){var f=new Array();
2356 var c=a[d].getElementsByTagName("td");
2357 for(var b=0;
2358 b<c.length;
2359 b++){f[b]=c[b].innerHTML
2360 }e.push(f)
2361 }this.loadRows(e)
2362 },loadRowsFromArray:function(b){for(var c=0;
2363 c<b.length;
2364 c++){for(var a=0;
2365 a<b[c].length;
2366 a++){b[c][a]=b[c][a].toString()
2367 }}this.loadRows(b)
2368 },loadRows:function(a){this.baseRows=a;
2369 this.startPos=0;
2370 this.size=this.baseRows.length
2371 },dom2jstable:function(f){Rico.log("dom2jstable: encoded="+this.options.isEncoded);
2372 var e=new Array();
2373 var a=f.getElementsByTagName("tr");
2374 for(var d=0;
2375 d<a.length;
2376 d++){var g=new Array();
2377 var c=a[d].getElementsByTagName("td");
2378 for(var b=0;
2379 b<c.length;
2380 b++){g[b]=Rico.getContentAsString(c[b],this.options.isEncoded)
2381 }e.push(g)
2382 }return e
2383 },dom2jstableAttr:function(e,b){var h=this.options.acceptAttr;
2384 Rico.log("dom2jstableAttr start, # attr="+h.length);
2385 var f=new Array();
2386 var g=e.getElementsByTagName("tr");
2387 for(var d=b||0;
2388 d<g.length;
2389 d++){var m=new Array();
2390 var l=g[d].getElementsByTagName("td");
2391 for(var c=0;
2392 c<l.length;
2393 c++){m[c]={};
2394 for(var a=0;
2395 a<h.length;
2396 a++){m[c]["_"+h[a]]=l[c].getAttribute(h[a])
2397 }if(Rico.isIE){m[c]._class=l[c].getAttribute("className")
2398 }}f.push(m)
2399 }Rico.log("dom2jstableAttr end");
2400 return f
2401 },_blankRow:function(){var a=[];
2402 for(var b=0;
2403 b<this.liveGrid.columns.length;
2404 b++){a[b]=""
2405 }return a
2406 },deleteRows:function(b,a){this.baseRows.splice(b,typeof(a)=="number"?a:1);
2407 this.liveGrid.isPartialBlank=true;
2408 this.size=this.baseRows.length
2409 },insertRow:function(a){var b=this._blankRow();
2410 this.baseRows.splice(a,0,b);
2411 this.size=this.baseRows.length;
2412 this.liveGrid.isPartialBlank=true;
2413 if(this.startPos<0){this.startPos=0
2414 }return b
2415 },appendRows:function(b){var c=[];
2416 for(var a=0;
2417 a<b;
2418 a++){var d=this._blankRow();
2419 this.baseRows.push(d);
2420 c.push(d)
2421 }this.size=this.baseRows.length;
2422 this.liveGrid.isPartialBlank=true;
2423 if(this.startPos<0){this.startPos=0
2424 }return c
2425 },sortFunc:function(b){var a=this;
2426 switch(b){case"number":return function(d,c){return a._sortNumeric(d,c)
2427 };
2428 case"control":return function(d,c){return a._sortControl(d,c)
2429 };
2430 default:return function(d,c){return a._sortAlpha(d,c)
2431 }
2432 }},sortBuffer:function(b){if(!this.baseRows){this.delayedSortCol=b;
2433 return
2434 }this.liveGrid.showMsg(Rico.getPhraseById("sorting"));
2435 this.sortColumn=b;
2436 var a=this.liveGrid.columns[b];
2437 this.getValFunc=a._sortfunc;
2438 this.baseRows.sort(this.sortFunc(a.format.type));
2439 if(a.getSortDirection()=="DESC"){this.baseRows.reverse()
2440 }},_sortAlpha:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2441 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2442 if(e==f){return 0
2443 }if(e<f){return -1
2444 }return 1
2445 },_sortNumeric:function(d,c){var e=this.sortColumn<d.length?this.nan2zero(Rico.getInnerText(d[this.sortColumn])):0;
2446 var f=this.sortColumn<c.length?this.nan2zero(Rico.getInnerText(c[this.sortColumn])):0;
2447 return e-f
2448 },nan2zero:function(a){if(typeof(a)=="string"){a=parseFloat(a)
2449 }return isNaN(a)||typeof(a)=="undefined"?0:a
2450 },_sortControl:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2451 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2452 if(this.getValFunc){e=this.getValFunc(e);
2453 f=this.getValFunc(f)
2454 }if(e==f){return 0
2455 }if(e<f){return -1
2456 }return 1
2457 },clear:function(){this.baseRows=[];
2458 this.rows=[];
2459 this.startPos=-1;
2460 this.size=0;
2461 this.windowPos=0
2462 },isInRange:function(a){var b=Math.min(this.totalRows,a+this.liveGrid.pageSize);
2463 return(a>=this.startPos)&&(b<=this.endPos())
2464 },endPos:function(){return this.startPos+this.rows.length
2465 },fetch:function(a){Rico.log("fetch "+this.liveGrid.tableId+": offset="+a);
2466 this.applyFilters();
2467 this.setTotalRows();
2468 this.rcvdRowCount=true;
2469 this.foundRowCount=true;
2470 if(a<0){a=0
2471 }this.liveGrid.refreshContents(a);
2472 return
2473 },visibleRows:function(){return this.rows.slice(this.windowStart,this.windowEnd)
2474 },setWindow:function(b,a){this.windowStart=b-this.startPos;
2475 Rico.log("setWindow "+this.liveGrid.tableId+": "+b+", "+a+", newstart="+this.windowStart);
2476 this.windowEnd=Math.min(a,this.size);
2477 this.windowPos=b
2478 },isVisible:function(a){return a<this.rows.length&&a>=this.windowStart&&a<this.windowEnd
2479 },bufferRow:function(a){return this.windowStart+a
2480 },getWindowCell:function(c,b){var a=this.bufferRow(c);
2481 return this.isVisible(a)&&b<this.rows[a].length?this.rows[a][b]:null
2482 },getWindowAttr:function(c,b){var a=this.bufferRow(c);
2483 return this.attr&&this.isVisible(a)&&b<this.attr[a].length?this.attr[a][b]:null
2484 },getWindowValue:function(b,a){return this.getWindowCell(b,a)
2485 },setWindowValue:function(d,b,c){var a=this.bufferRow(d);
2486 if(a>=this.windowEnd){return false
2487 }return this.setValue(a,b,c)
2488 },getCell:function(b,a){return b<this.size?this.rows[b][a]:null
2489 },getValue:function(b,a){return this.getCell(b,a)
2490 },setValue:function(d,b,c,a){if(d>=this.size){return false
2491 }if(!this.rows[d][b]){this.rows[d][b]={}
2492 }this.rows[d][b]=c;
2493 if(typeof a=="string"){this.rows[d][b]._style=a
2494 }this.rows[d][b].modified=true;
2495 return true
2496 },getRows:function(f,d){var e=f-this.startPos;
2497 var a=Math.min(e+d,this.size);
2498 var c=new Array();
2499 for(var b=e;
2500 b<a;
2501 b++){c.push(this.rows[b])
2502 }return c
2503 },applyFilters:function(){var g=[],k=[];
2504 var a,h,d,e,f,b;
2505 var j=this.liveGrid.columns;
2506 for(d=0,b=0;
2507 d<j.length;
2508 d++){h=j[d];
2509 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2510 }b++;
2511 if(h.filterOp=="LIKE"){k[d]=new RegExp(h.filterValues[0],"i")
2512 }}Rico.log("applyFilters: # of filters="+b);
2513 if(b==0){this.rows=this.baseRows
2514 }else{for(a=0;
2515 a<this.baseRows.length;
2516 a++){f=true;
2517 for(d=0;
2518 d<j.length&&f;
2519 d++){h=j[d];
2520 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2521 }switch(h.filterOp){case"LIKE":f=k[d].test(this.baseRows[a][d]);
2522 break;
2523 case"EQ":f=this.baseRows[a][d]==h.filterValues[0];
2524 break;
2525 case"NE":for(e=0;
2526 e<h.filterValues.length&&f;
2527 e++){f=this.baseRows[a][d]!=h.filterValues[e]
2528 }break;
2529 case"LE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])<=this.nan2zero(h.filterValues[0])
2530 }else{f=this.baseRows[a][d]<=h.filterValues[0]
2531 }break;
2532 case"GE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])>=this.nan2zero(h.filterValues[0])
2533 }else{f=this.baseRows[a][d]>=h.filterValues[0]
2534 }break;
2535 case"NULL":f=this.baseRows[a][d]=="";
2536 break;
2537 case"NOTNULL":f=this.baseRows[a][d]!="";
2538 break
2539 }}if(f){g.push(this.baseRows[a])
2540 }}this.rows=g
2541 }this.rowcntContent=this.size=this.rows.length
2542 },printAll:function(){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2543 Rico.runLater(10,this,"_printAll")
2544 },_printAll:function(){this.liveGrid.exportStart();
2545 this.exportBuffer(this.getRows(0,this.totalRows));
2546 this.liveGrid.exportFinish()
2547 },printVisible:function(){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2548 Rico.runLater(10,this,"_printVisible")
2549 },_printVisible:function(){this.liveGrid.exportStart();
2550 this.exportBuffer(this.visibleRows());
2551 this.liveGrid.exportFinish()
2552 },exportBuffer:function(l,f){var a,g,k,b,j;
2553 Rico.log("exportBuffer: "+l.length+" rows");
2554 var e=this.liveGrid.getExportStyles(this.liveGrid.tbody[0]);
2555 var i=[];
2556 var d=f||0;
2557 var h=this.liveGrid.columns;
2558 for(g=0;
2559 g<h.length;
2560 g++){if(h[g].visible){i[g]=this.liveGrid.exportStyle(h[g].cell(0),e)
2561 }}for(a=0;
2562 a<l.length;
2563 a++){j="";
2564 for(g=0;
2565 g<h.length;
2566 g++){if(!h[g].visible){continue
2567 }b=h[g];
2568 b.expStyle=i[g];
2569 k=b._export(l[a][g],l[a]);
2570 if(k==""){k="&nbsp;"
2571 }j+="<td style='"+b.expStyle+"'>"+k+"</td>"
2572 }this.liveGrid.exportRows.push(j);
2573 d++;
2574 if(d%10==0){window.status=Rico.getPhraseById("exportStatus",d)
2575 }}}};
2576 Rico.LiveGrid=function(c,a,b){this.initialize(c,a,b)
2577 };
2578 Rico.LiveGrid.prototype={initialize:function(e,b,d){Rico.extend(this,Rico.GridCommon);
2579 Rico.extend(this,Rico.LiveGridMethods);
2580 this.baseInit();
2581 this.tableId=e;
2582 this.buffer=b;
2583 this.actionId="_action_"+e;
2584 Rico.setDebugArea(e+"_debugmsgs");
2585 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});
2586 var c=this;
2587 this.options.sortHandler=function(){c.sortHandler()
2588 };
2589 this.options.filterHandler=function(){c.filterHandler()
2590 };
2591 this.options.onRefreshComplete=function(f,g){c.bookmarkHandler(f,g)
2592 };
2593 this.options.rowOverHandler=Rico.eventHandle(this,"rowMouseOver");
2594 this.options.mouseDownHandler=Rico.eventHandle(this,"selectMouseDown");
2595 this.options.mouseOverHandler=Rico.eventHandle(this,"selectMouseOver");
2596 this.options.mouseUpHandler=Rico.eventHandle(this,"selectMouseUp");
2597 Rico.extend(this.options,d||{});
2598 switch(typeof this.options.visibleRows){case"string":this.sizeTo=this.options.visibleRows;
2599 switch(this.options.visibleRows){case"data":this.options.visibleRows=-2;
2600 break;
2601 case"body":this.options.visibleRows=-3;
2602 break;
2603 case"parent":this.options.visibleRows=-4;
2604 break;
2605 case"datamax":this.options.visibleRows=-5;
2606 break;
2607 default:this.options.visibleRows=-1;
2608 break
2609 }break;
2610 case"number":switch(this.options.visibleRows){case -1:this.sizeTo="window";
2611 break;
2612 case -2:this.sizeTo="data";
2613 break;
2614 case -3:this.sizeTo="body";
2615 break;
2616 case -4:this.sizeTo="parent";
2617 break;
2618 case -5:this.sizeTo="datamax";
2619 break;
2620 default:this.sizeTo="fixed";
2621 break
2622 }break;
2623 default:this.sizeTo="body";
2624 this.options.visibleRows=-3;
2625 break
2626 }this.highlightEnabled=this.options.highlightSection>0;
2627 this.pageSize=0;
2628 this.createTables();
2629 if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2630 return
2631 }this.createColumnArray("LiveGridColumn");
2632 if(this.options.headingSort=="hover"){this.createHoverSet()
2633 }this.bookmark=document.getElementById(this.tableId+"_bookmark");
2634 this.sizeDivs();
2635 var a=this.buffer.options.canFilter?this.options.FilterLocation:false;
2636 if(typeof(a)=="number"&&a<0){a=this.addHeadingRow("ricoLG_FilterRow")
2637 }this.createDataCells(this.options.visibleRows);
2638 if(this.pageSize==0){return
2639 }this.buffer.registerGrid(this);
2640 if(this.buffer.setBufferSize){this.buffer.setBufferSize(this.pageSize)
2641 }this.scrollTimeout=null;
2642 this.lastScrollPos=0;
2643 this.attachMenuEvents();
2644 this.setSortUI(this.options.sortCol,this.options.sortDir);
2645 this.setImages();
2646 if(this.listInvisible().length==this.columns.length){this.columns[0].showColumn()
2647 }this.sizeDivs();
2648 this.scrollDiv.style.display="";
2649 if(this.buffer.totalRows>0){this.updateHeightDiv()
2650 }if(this.options.prefetchBuffer){if(this.bookmark){this.bookmark.innerHTML=Rico.getPhraseById("bookmarkLoading")
2651 }if(this.options.canFilterDefault&&this.options.getQueryParms){this.checkForFilterParms()
2652 }this.scrollToRow(this.options.offset);
2653 this.buffer.fetch(this.options.offset)
2654 }if(typeof(a)=="number"){this.createFilters(a)
2655 }this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2656 this.wheelEventFunc=Rico.eventHandle(this,"handleWheel");
2657 this.wheelEvent=(Rico.isIE||Rico.isOpera||Rico.isWebKit)?"mousewheel":"DOMMouseScroll";
2658 if(this.options.offset&&this.options.offset<this.buffer.totalRows){Rico.runLater(50,this,"scrollToRow",this.options.offset)
2659 }this.pluginScroll();
2660 this.setHorizontalScroll();
2661 Rico.log("setHorizontalScroll done");
2662 if(this.options.windowResize){Rico.runLater(100,this,"pluginWindowResize")
2663 }Rico.log("initialize complete for "+this.tableId)
2664 }};
2665 Rico.LiveGridMethods={createHoverSet:function(){var a=[];
2666 for(var b=0;
2667 b<this.headerColCnt;
2668 b++){if(this.columns[b].sortable){a.push(this.columns[b].hdrCellDiv)
2669 }}this.hoverSet=new Rico.HoverSet(a)
2670 },checkForFilterParms:function(){var b=window.location.search;
2671 if(b.charAt(0)=="?"){b=b.substring(1)
2672 }var c=b.split("&");
2673 for(var a=0;
2674 a<c.length;
2675 a++){if(c[a].match(/^f\[\d+\]/)){this.buffer.options.requestParameters.push(c[a])
2676 }}},drillDown:function(g,f,h){var b=Rico.eventElement(g||window.event);
2677 b=Rico.getParentByTagName(b,"div","ricoLG_cell");
2678 if(!b){return -1
2679 }var a=this.winCellIndex(b);
2680 if(a.row>=this.buffer.totalRows){return -1
2681 }this.unhighlight();
2682 this.menuIdx=a;
2683 this.highlight(a);
2684 var c=this.buffer.getWindowCell(a.row,f);
2685 for(var d=3;
2686 d<arguments.length;
2687 d++){arguments[d].setDetailFilter(h,c)
2688 }return a.row
2689 },setDetailFilter:function(a,d){var b=this.columns[a];
2690 b.format.ColData=d;
2691 b.setSystemFilter("EQ",d)
2692 },createTables:function(){var f,g,b;
2693 var e=document.getElementById(this.tableId)||document.getElementById(this.tableId+"_outerDiv");
2694 if(!e){return false
2695 }if(e.tagName.toLowerCase()=="table"){var a=e.getElementsByTagName("thead");
2696 if(a.length==1){Rico.log("createTables: using thead section, id="+this.tableId);
2697 if(this.options.PanelNamesOnTabHdr&&this.options.panels){var d=a[0].insertRow(0);
2698 this.insertPanelNames(d,0,this.options.frozenColumns,"ricoFrozen");
2699 this.insertPanelNames(d,this.options.frozenColumns,this.options.columnSpecs.length)
2700 }g=a[0].rows
2701 }else{Rico.log("createTables: using tbody section, id="+this.tableId);
2702 g=new Array(e.rows[0])
2703 }f=e
2704 }else{if(this.options.columnSpecs.length>0){if(!e.id.match(/_outerDiv$/)){f=e
2705 }Rico.log("createTables: inserting at "+e.tagName+", id="+this.tableId)
2706 }else{alert("ERROR!\n\nUnable to initialize '"+this.tableId+"'\n\nLiveGrid terminated");
2707 return false
2708 }}this.createDivs();
2709 this.scrollContainer=this.createDiv("scrollContainer",this.structTabLR);
2710 this.scrollContainer.appendChild(this.scrollDiv);
2711 this.scrollTab=this.createDiv("scrollTab",this.scrollContainer);
2712 this.shadowDiv=this.createDiv("shadow",this.scrollDiv);
2713 this.shadowDiv.style.direction="ltr";
2714 this.scrollDiv.style.display="none";
2715 this.scrollDiv.scrollTop=0;
2716 if(this.options.highlightMethod!="class"){this.highlightDiv=[];
2717 switch(this.options.highlightElem){case"menuRow":case"cursorRow":this.highlightDiv[0]=this.createDiv("highlight",this.outerDiv);
2718 this.highlightDiv[0].style.display="none";
2719 break;
2720 case"menuCell":case"cursorCell":for(b=0;
2721 b<2;
2722 b++){this.highlightDiv[b]=this.createDiv("highlight",b==0?this.frozenTabs:this.scrollTab);
2723 this.highlightDiv[b].style.display="none";
2724 this.highlightDiv[b].id+=b
2725 }break;
2726 case"selection":var h=this.options.highlightSection==1?this.frozenTabs:this.scrollTab;
2727 for(b=0;
2728 b<4;
2729 b++){this.highlightDiv[b]=this.createDiv("highlight",h);
2730 this.highlightDiv[b].style.display="none";
2731 this.highlightDiv[b].style.overflow="hidden";
2732 this.highlightDiv[b].id+=b;
2733 this.highlightDiv[b].style[b%2==0?"height":"width"]="0px"
2734 }break
2735 }}for(b=0;
2736 b<3;
2737 b++){this.tabs[b]=document.createElement("table");
2738 this.tabs[b].className="ricoLG_table";
2739 this.tabs[b].border=0;
2740 this.tabs[b].cellPadding=0;
2741 this.tabs[b].cellSpacing=0;
2742 this.tabs[b].id=this.tableId+"_tab"+b
2743 }for(b=0;
2744 b<2;
2745 b++){this.thead[b]=this.tabs[b].createTHead();
2746 Rico.addClass(this.tabs[b],"ricoLG_top");
2747 if(Rico.theme.gridheader){Rico.addClass(this.thead[b],Rico.theme.gridheader)
2748 }}for(b=0;
2749 b<2;
2750 b++){this.tbody[b]=Rico.getTBody(this.tabs[b==0?0:2]);
2751 this.tbody[b].className="ricoLG_bottom";
2752 if(Rico.theme.gridcontent){Rico.addClass(this.tbody[b],Rico.theme.gridcontent)
2753 }this.tbody[b].insertRow(-1)
2754 }this.frozenTabs.appendChild(this.tabs[0]);
2755 this.innerDiv.appendChild(this.tabs[1]);
2756 this.scrollTab.appendChild(this.tabs[2]);
2757 if(f){f.parentNode.insertBefore(this.outerDiv,f)
2758 }if(g){this.headerColCnt=this.getColumnInfo(g);
2759 this.loadHdrSrc(g)
2760 }else{this.createHdr(0,0,this.options.frozenColumns);
2761 this.createHdr(1,this.options.frozenColumns,this.options.columnSpecs.length);
2762 if(this.options.PanelNamesOnTabHdr&&this.options.panels){this.insertPanelNames(this.thead[0].insertRow(0),0,this.options.frozenColumns);
2763 this.insertPanelNames(this.thead[1].insertRow(0),this.options.frozenColumns,this.options.columnSpecs.length)
2764 }for(b=0;
2765 b<2;
2766 b++){this.headerColCnt=this.getColumnInfo(this.thead[b].rows)
2767 }}for(var j=0;
2768 j<this.headerColCnt;
2769 j++){this.tbody[j<this.options.frozenColumns?0:1].rows[0].insertCell(-1)
2770 }if(f){e.parentNode.removeChild(e)
2771 }Rico.log("createTables end");
2772 return true
2773 },createDataCells:function(d){if(d<0){for(var a=0;
2774 a<this.options.minPageRows;
2775 a++){this.appendBlankRow()
2776 }this.sizeDivs();
2777 this.autoAppendRows(this.remainingHt())
2778 }else{for(var c=0;
2779 c<d;
2780 c++){this.appendBlankRow()
2781 }}var b=this.options.highlightSection;
2782 if(b&1){this.attachHighlightEvents(this.tbody[0])
2783 }if(b&2){this.attachHighlightEvents(this.tbody[1])
2784 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
2785 },createFilters:function(b){for(var h=0;
2786 h<this.headerColCnt;
2787 h++){var e=this.columns[h];
2788 var f=e.format;
2789 if(typeof f.filterUI!="string"){continue
2790 }var l=this.hdrCells[b][h].cell;
2791 var j,d=this.filterId(h);
2792 var i=l.getElementsByTagName("div");
2793 var g=Rico.getStyle(this.cell(0,h),"textAlign");
2794 i[1].style.textAlign=g;
2795 switch(f.filterUI.charAt(0)){case"t":j=Rico.createFormField(i[1],"input","text",d,d);
2796 var n=f.filterUI.match(/\d+/);
2797 j.maxLength=f.Length||50;
2798 j.size=n?parseInt(n,10):10;
2799 i[1].appendChild(Rico.clearButton(Rico.eventHandle(e,"filterClear")));
2800 if(e.filterType==Rico.ColumnConst.USERFILTER&&e.filterOp=="LIKE"){var k=e.filterValues[0];
2801 if(k.charAt(0)=="*"){k=k.substr(1)
2802 }if(k.slice(-1)=="*"){k=k.slice(0,-1)
2803 }j.value=k;
2804 e.lastKeyFilter=k
2805 }Rico.eventBind(j,"keyup",Rico.eventHandle(e,"filterKeypress"),false);
2806 e.filterField=j;
2807 break;
2808 case"m":case"s":j=Rico.createFormField(i[1],"select",null,d);
2809 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
2810 e.filterField=j;
2811 var m={};
2812 Rico.extend(m,this.buffer.ajaxOptions);
2813 var a=typeof(f.filterCol)=="number"?f.filterCol:h;
2814 m.parameters={id:this.tableId,distinct:a};
2815 m.parameters[this.actionId]="query";
2816 m.onComplete=this.filterValuesUpdateFunc(h);
2817 new Rico.ajaxRequest(this.buffer.dataSource,m);
2818 break;
2819 case"c":if(typeof e._createFilters=="function"){e._createFilters(i[1],d)
2820 }break
2821 }}this.initFilterImage(b)
2822 },filterValuesUpdateFunc:function(b){var a=this;
2823 return function(c){a.filterValuesUpdate(b,c)
2824 }
2825 },filterValuesUpdate:function(a,g){var f=g.responseXML.getElementsByTagName("ajax-response");
2826 Rico.log("filterValuesUpdate: "+g.status);
2827 if(f==null||f.length!=1){return false
2828 }f=f[0];
2829 var n=f.getElementsByTagName("error");
2830 if(n.length>0){Rico.log("Data provider returned an error:\n"+Rico.getContentAsString(n[0],this.buffer.isEncoded));
2831 alert(Rico.getPhraseById("requestError",Rico.getContentAsString(n[0],this.buffer.isEncoded)));
2832 return false
2833 }f=f.getElementsByTagName("response")[0];
2834 var l=f.getElementsByTagName("rows")[0];
2835 var d=this.columns[parseInt(a,10)];
2836 var r=this.buffer.dom2jstable(l);
2837 var m,b,q;
2838 if(d.filterType==Rico.ColumnConst.USERFILTER&&d.filterOp=="EQ"){q=d.filterValues[0]
2839 }Rico.log("filterValuesUpdate: col="+a+" rows="+r.length);
2840 switch(d.format.filterUI.charAt(0)){case"m":d.mFilter=document.body.appendChild(document.createElement("div"));
2841 d.mFilter.className="ricoLG_mFilter";
2842 Rico.hide(d.mFilter);
2843 var e=d.mFilter.appendChild(document.createElement("div"));
2844 e.className="ricoLG_mFilter_content";
2845 var o=d.mFilter.appendChild(document.createElement("div"));
2846 o.className="ricoLG_mFilter_button";
2847 d.mFilterButton=o.appendChild(document.createElement("button"));
2848 d.mFilterButton.innerHTML=Rico.getPhraseById("ok");
2849 var j=Rico.isWebKit?"mousedown":"click";
2850 Rico.eventBind(d.filterField,j,Rico.eventHandle(d,"mFilterSelectClick"));
2851 Rico.eventBind(d.mFilterButton,"click",Rico.eventHandle(d,"mFilterFinish"));
2852 tab=e.appendChild(document.createElement("table"));
2853 tab.border=0;
2854 tab.cellPadding=2;
2855 tab.cellSpacing=0;
2856 var p=this.filterId(a)+"_";
2857 this.createMFilterItem(tab,this.options.FilterAllToken,Rico.getPhraseById("filterAll"),p+"all",Rico.eventHandle(d,"mFilterAllClick"));
2858 var k=Rico.eventHandle(d,"mFilterOtherClick");
2859 for(var h=0;
2860 h<r.length;
2861 h++){if(r[h].length>0){m=r[h][0];
2862 this.createMFilterItem(tab,m,m||Rico.getPhraseById("filterBlank"),p+h,k)
2863 }}d.mFilterInputs=e.getElementsByTagName("input");
2864 d.mFilterLabels=e.getElementsByTagName("label");
2865 d.mFilterFocus=d.mFilterInputs.length?d.mFilterInputs[0]:d.mFilterButton;
2866 break;
2867 case"s":for(var h=0;
2868 h<r.length;
2869 h++){if(r[h].length>0){m=r[h][0];
2870 b=Rico.addSelectOption(d.filterField,m,m||Rico.getPhraseById("filterBlank"));
2871 if(d.filterType==Rico.ColumnConst.USERFILTER&&m==q){b.selected=true
2872 }}}Rico.eventBind(d.filterField,"change",Rico.eventHandle(d,"filterChange"));
2873 break
2874 }return true
2875 },createMFilterItem:function(j,b,i,a,e){var f=j.insertRow(-1);
2876 f.vAlign="top";
2877 if(f.rowIndex%2==1){f.className="ricoLG_mFilter_oddrow"
2878 }var d=f.insertCell(-1);
2879 var c=f.insertCell(-1);
2880 var h=Rico.createFormField(d,"input","checkbox",a);
2881 h.value=b;
2882 h.checked=true;
2883 var g=c.appendChild(document.createElement("label"));
2884 g.htmlFor=a;
2885 g.innerHTML=i;
2886 Rico.eventBind(h,"click",e)
2887 },unplugHighlightEvents:function(){var a=this.options.highlightSection;
2888 if(a&1){this.detachHighlightEvents(this.tbody[0])
2889 }if(a&2){this.detachHighlightEvents(this.tbody[1])
2890 }},insertPanelNames:function(a,b,d,f){Rico.log("insertPanelNames: start="+b+" limit="+d);
2891 a.className="ricoLG_hdg";
2892 var i=-1,j,e=null,g=0;
2893 for(var h=b;
2894 h<d;
2895 h++){if(i==this.options.columnSpecs[h].panelIdx){j++
2896 }else{if(e){e.colSpan=j
2897 }e=a.insertCell(-1);
2898 if(f){e.className=f
2899 }j=1;
2900 i=this.options.columnSpecs[h].panelIdx;
2901 e.innerHTML=this.options.panels[i]
2902 }}if(e){e.colSpan=j
2903 }},createHdr:function(d,g,b){Rico.log("createHdr: i="+d+" start="+g+" limit="+b);
2904 var a=this.thead[d].insertRow(-1);
2905 a.id=this.tableId+"_tab"+d+"h_main";
2906 a.className="ricoLG_hdg";
2907 for(var f=g;
2908 f<b;
2909 f++){var e=a.insertCell(-1);
2910 e.innerHTML=this.options.columnSpecs[f].Hdg
2911 }},loadHdrSrc:function(g){var b,d,j,e,f,a;
2912 Rico.log("loadHdrSrc start");
2913 for(b=0;
2914 b<2;
2915 b++){for(e=0;
2916 e<g.length;
2917 e++){f=this.thead[b].insertRow(-1);
2918 f.className="ricoLG_hdg "+this.tableId+"_hdg"+e
2919 }}if(g.length==1){a=g[0].cells;
2920 for(j=0;
2921 a.length>0;
2922 j++){this.thead[j<this.options.frozenColumns?0:1].rows[0].appendChild(a[0])
2923 }}else{for(e=0;
2924 e<g.length;
2925 e++){a=g[e].cells;
2926 for(j=0,d=0;
2927 a.length>0;
2928 j++){if(a[0].className=="ricoFrozen"){if(e==this.headerRowIdx){this.options.frozenColumns=j+1
2929 }}else{d=1
2930 }this.thead[d].rows[e].appendChild(a[0])
2931 }}}Rico.log("loadHdrSrc end")
2932 },sizeDivs:function(){Rico.log("sizeDivs: "+this.tableId);
2933 this.unhighlight();
2934 this.baseSizeDivs();
2935 var d=this.firstVisible();
2936 if(this.pageSize==0||d<0){return
2937 }var c=this.columns[d].dataColDiv.offsetHeight;
2938 this.rowHeight=Math.round(c/this.pageSize);
2939 var b=this.dataHt;
2940 if(this.scrTabWi0==this.scrTabWi){this.innerDiv.style.height=(this.hdrHt+1)+"px";
2941 this.scrollDiv.style.overflowX="hidden"
2942 }else{this.scrollDiv.style.overflowX="scroll";
2943 b+=this.options.scrollBarWidth
2944 }this.scrollDiv.style.height=b+"px";
2945 this.innerDiv.style.width=(this.scrWi)+"px";
2946 this.scrollTab.style.width=(this.scrWi-this.options.scrollBarWidth)+"px";
2947 this.resizeDiv.style.height=(this.hdrHt+this.dataHt+1)+"px";
2948 Rico.log("sizeDivs scrHt="+b+" innerHt="+this.innerDiv.style.height+" rowHt="+this.rowHeight+" pageSize="+this.pageSize);
2949 var a=(this.scrWi-this.scrTabWi<this.options.scrollBarWidth)?2:0;
2950 this.shadowDiv.style.width=(this.scrTabWi+a)+"px";
2951 this.outerDiv.style.height=(this.hdrHt+b)+"px";
2952 this.setHorizontalScroll()
2953 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
2954 this.tabs[1].style.marginLeft=a;
2955 this.tabs[2].style.marginLeft=a
2956 },remainingHt:function(){var f=this.outerDiv.offsetHeight;
2957 var g=Rico.windowHeight();
2958 var e=Rico.isIE?15:10;
2959 if(!Rico.isIE&&window.frameElement&&window.frameElement.scrolling=="yes"&&this.sizeTo!="parent"){e+=this.options.scrollBarWidth
2960 }switch(this.sizeTo){case"window":var d=Rico.cumulativeOffset(this.outerDiv).top;
2961 Rico.log("remainingHt/window, winHt="+g+" tabHt="+f+" gridY="+d);
2962 return g-d-f-e;
2963 case"parent":var h=this.offsetFromParent(this.outerDiv);
2964 if(Rico.isIE){Rico.hide(this.outerDiv)
2965 }var b=this.outerDiv.parentNode.clientHeight;
2966 if(Rico.isIE){Rico.show(this.outerDiv)
2967 }Rico.log("remainingHt/parent, parentHt="+b+" offset="+h+" tabHt="+f);
2968 return b-f-h-e;
2969 case"data":case"body":var a=Rico.isIE?document.body.scrollHeight:document.body.offsetHeight;
2970 var c=g-a-e;
2971 if(!Rico.isWebKit){c-=this.options.scrollBarWidth
2972 }Rico.log("remainingHt, winHt="+g+" pageHt="+a+" remHt="+c);
2973 return c;
2974 default:Rico.log("remainingHt, winHt="+g+" tabHt="+f);
2975 if(this.sizeTo.slice(-1)=="%"){g*=parseFloat(this.sizeTo)/100
2976 }else{if(this.sizeTo.slice(-2)=="px"){g=parseInt(this.sizeTo,10)
2977 }}return g-f-e
2978 }},offsetFromParent:function(b){var a=0;
2979 var c=b.parentNode;
2980 do{a+=b.offsetTop||0;
2981 b=b.offsetParent;
2982 if(!b||b==null){break
2983 }var d=Rico.getStyle(b,"position");
2984 if(b.tagName=="BODY"||b.tagName=="HTML"||d=="absolute"){return a-c.offsetTop
2985 }}while(b!=c);
2986 return a
2987 },adjustPageSize:function(){var a=this.remainingHt();
2988 Rico.log("adjustPageSize remHt="+a+" lastRow="+this.lastRowPos);
2989 if(a>this.rowHeight){this.autoAppendRows(a)
2990 }else{if(a<0||this.sizeTo=="data"){this.autoRemoveRows(-a)
2991 }}},setPageSize:function(b){b=Math.min(b,this.options.maxPageRows);
2992 b=Math.max(b,this.options.minPageRows);
2993 this.sizeTo="fixed";
2994 var a=this.pageSize;
2995 while(this.pageSize>b){this.removeRow()
2996 }while(this.pageSize<b){this.appendBlankRow()
2997 }this.finishResize(a)
2998 },pluginWindowResize:function(){Rico.log("pluginWindowResize");
2999 this.resizeWindowHandler=Rico.eventHandle(this,"resizeWindow");
3000 Rico.eventBind(window,"resize",this.resizeWindowHandler,false)
3001 },unplugWindowResize:function(){if(!this.resizeWindowHandler){return
3002 }Rico.eventUnbind(window,"resize",this.resizeWindowHandler,false);
3003 this.resizeWindowHandler=null
3004 },resizeWindow:function(){Rico.log("resizeWindow "+this.tableId+" lastRow="+this.lastRowPos);
3005 if(this.resizeState=="finish"){Rico.log("resizeWindow postponed");
3006 this.resizeState="resize";
3007 return
3008 }if(!this.sizeTo||this.sizeTo=="fixed"){this.sizeDivs();
3009 return
3010 }if(this.sizeTo=="parent"&&Rico.getStyle(this.outerDiv.parentNode,"display")=="none"){return
3011 }var a=this.pageSize;
3012 this.adjustPageSize();
3013 this.finishResize(a)
3014 },finishResize:function(b){if(this.pageSize>b&&this.buffer.totalRows>0){this.isPartialBlank=true;
3015 var a=this.adjustRow(this.lastRowPos);
3016 this.buffer.fetch(a)
3017 }else{if(this.pageSize<b){if(this.options.onRefreshComplete){this.options.onRefreshComplete(this.contentStartPos,this.contentStartPos+this.pageSize-1)
3018 }}}this.resizeState="finish";
3019 Rico.runLater(20,this,"finishResize2");
3020 Rico.log("Resize "+this.tableId+" complete. old size="+b+" new size="+this.pageSize)
3021 },finishResize2:function(){this.sizeDivs();
3022 this.updateHeightDiv();
3023 if(this.resizeState=="resize"){this.resizeWindow()
3024 }else{this.resizeState=""
3025 }},topOfLastPage:function(){return Math.max(this.buffer.totalRows-this.pageSize,0)
3026 },updateHeightDiv:function(){var b=this.topOfLastPage();
3027 var a=b?this.scrollDiv.clientHeight+Math.floor(this.rowHeight*(b+0.4)):1;
3028 Rico.log("updateHeightDiv, ht="+a+" scrollDiv.clientHeight="+this.scrollDiv.clientHeight+" rowsNotDisplayed="+b);
3029 this.shadowDiv.style.height=a+"px"
3030 },autoRemoveRows:function(a){if(!this.rowHeight){return
3031 }var c=Math.ceil(a/this.rowHeight);
3032 if(this.sizeTo=="data"){c=Math.max(c,this.pageSize-this.buffer.totalRows)
3033 }Rico.log("autoRemoveRows overage="+a+" removeCnt="+c);
3034 for(var b=0;
3035 b<c;
3036 b++){this.removeRow()
3037 }},removeRow:function(){if(this.pageSize<=this.options.minPageRows){return
3038 }this.pageSize--;
3039 for(var b=0;
3040 b<this.headerColCnt;
3041 b++){var a=this.columns[b].cell(this.pageSize);
3042 this.columns[b].dataColDiv.removeChild(a)
3043 }},autoAppendRows:function(a){if(!this.rowHeight){return
3044 }var c=Math.floor(a/this.rowHeight);
3045 Rico.log("autoAppendRows overage="+a+" cnt="+c+" rowHt="+this.rowHeight);
3046 for(var b=0;
3047 b<c;
3048 b++){if(this.sizeTo=="data"&&this.pageSize>=this.buffer.totalRows){break
3049 }this.appendBlankRow()
3050 }},appendBlankRow:function(){if(this.pageSize>=this.options.maxPageRows){return
3051 }Rico.log("appendBlankRow #"+this.pageSize);
3052 var a=this.defaultRowClass(this.pageSize);
3053 for(var d=0;
3054 d<this.headerColCnt;
3055 d++){var b=document.createElement("div");
3056 b.className="ricoLG_cell "+a;
3057 b.id=this.tableId+"_"+this.pageSize+"_"+d;
3058 this.columns[d].dataColDiv.appendChild(b);
3059 if(this.columns[d].format.canDrag&&Rico.registerDraggable){Rico.registerDraggable(new Rico.LiveGridDraggable(this,this.pageSize,d),this.options.dndMgrIdx)
3060 }b.innerHTML="&nbsp;";
3061 if(this.columns[d]._create){this.columns[d]._create(b,this.pageSize)
3062 }}this.pageSize++
3063 },defaultRowClass:function(b){var a;
3064 if(b%2==0){a="ricoLG_evenRow"
3065 }else{a="ricoLG_oddRow"
3066 }return a
3067 },handleMenuClick:function(f){if(!this.menu){return
3068 }this.cancelMenu();
3069 this.unhighlight();
3070 var b;
3071 var a=Rico.eventElement(f);
3072 if(a.className=="ricoLG_highlightDiv"){b=this.highlightIdx
3073 }else{a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3074 if(!a){return
3075 }b=this.winCellIndex(a);
3076 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3077 }}this.highlight(b);
3078 this.highlightEnabled=false;
3079 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
3080 }this.menuIdx=b;
3081 if(!this.menu.div){this.menu.createDiv()
3082 }this.menu.liveGrid=this;
3083 if(this.menu.buildGridMenu){var d=this.menu.buildGridMenu(b.row,b.column,b.tabIdx);
3084 if(!d){return
3085 }}if(this.options.highlightElem=="selection"&&!this.isSelected(b.cell)){this.selectCell(b.cell)
3086 }var c=this;
3087 this.menu.showmenu(f,function(){c.closeMenu()
3088 });
3089 return false
3090 },closeMenu:function(){if(!this.menuIdx){return
3091 }if(this.hideScroll){this.scrollDiv.style.overflow=""
3092 }this.highlightEnabled=true;
3093 this.menuIdx=null
3094 },winCellIndex:function(b){var d=b.id.lastIndexOf("_",b.id.length);
3095 var a=b.id.lastIndexOf("_",d-1)+1;
3096 var f=parseInt(b.id.substr(d+1));
3097 var e=parseInt(b.id.substr(a,d));
3098 return{row:e,column:f,tabIdx:this.columns[f].tabIdx,cell:b}
3099 },datasetIndex:function(b){var a=this.winCellIndex(b);
3100 a.row+=this.buffer.windowPos;
3101 a.onBlankRow=(a.row>=this.buffer.endPos());
3102 return a
3103 },attachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventBind(a,"mousedown",this.options.mouseDownHandler,false);
3104 a.ondrag=function(){return false
3105 };
3106 a.onselectstart=function(){return false
3107 };
3108 break;
3109 case"cursorRow":case"cursorCell":Rico.eventBind(a,"mouseover",this.options.rowOverHandler,false);
3110 break
3111 }},detachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventUnbind(a,"mousedown",this.options.mouseDownHandler,false);
3112 a.ondrag=null;
3113 a.onselectstart=null;
3114 break;
3115 case"cursorRow":case"cursorCell":Rico.eventUnbind(a,"mouseover",this.options.rowOverHandler,false);
3116 break
3117 }},getVisibleSelection:function(){var d=[];
3118 if(this.SelectIdxStart&&this.SelectIdxEnd){var b=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowStart);
3119 var a=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowEnd-1);
3120 var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3121 var f=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3122 for(var h=b;
3123 h<=a;
3124 h++){for(var j=g;
3125 j<=f;
3126 j++){d.push({row:h-this.buffer.windowStart,column:j})
3127 }}}if(this.SelectCtrl){for(var e=0;
3128 e<this.SelectCtrl.length;
3129 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})
3130 }}}return d
3131 },updateSelectOutline:function(){if(!this.SelectIdxStart||!this.SelectIdxEnd){return
3132 }var d=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3133 var c=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3134 if(d>c){this.HideSelection();
3135 return
3136 }var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3137 var e=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3138 var h=this.columns[g].cell(d-this.buffer.windowStart).offsetTop;
3139 var j=this.columns[g].cell(c-this.buffer.windowStart);
3140 var b=j.offsetTop+j.offsetHeight;
3141 var l=this.columns[g].dataCell.offsetLeft;
3142 var k=this.columns[e].dataCell.offsetLeft;
3143 var a=k+this.columns[e].dataCell.offsetWidth;
3144 this.highlightDiv[0].style.top=this.highlightDiv[3].style.top=this.highlightDiv[1].style.top=(this.hdrHt+h-1)+"px";
3145 this.highlightDiv[2].style.top=(this.hdrHt+b-1)+"px";
3146 this.highlightDiv[3].style.left=(l-2)+"px";
3147 this.highlightDiv[0].style.left=this.highlightDiv[2].style.left=(l-1)+"px";
3148 this.highlightDiv[1].style.left=(a-1)+"px";
3149 this.highlightDiv[0].style.width=this.highlightDiv[2].style.width=(a-l-1)+"px";
3150 this.highlightDiv[1].style.height=this.highlightDiv[3].style.height=(b-h)+"px";
3151 for(var f=0;
3152 f<4;
3153 f++){this.highlightDiv[f].style.display=""
3154 }},HideSelection:function(){var b;
3155 if(this.options.highlightMethod!="class"){for(b=0;
3156 b<this.highlightDiv.length;
3157 b++){this.highlightDiv[b].style.display="none"
3158 }}if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3159 Rico.log("HideSelection "+a.length);
3160 for(b=0;
3161 b<a.length;
3162 b++){this.unhighlightCell(this.columns[a[b].column].cell(a[b].row))
3163 }}},ShowSelection:function(){if(this.options.highlightMethod!="class"){this.updateSelectOutline()
3164 }if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3165 for(var b=0;
3166 b<a.length;
3167 b++){this.highlightCell(this.columns[a[b].column].cell(a[b].row))
3168 }}},ClearSelection:function(){Rico.log("ClearSelection");
3169 this.HideSelection();
3170 this.SelectIdxStart=null;
3171 this.SelectIdxEnd=null;
3172 this.SelectCtrl=[]
3173 },selectCell:function(a){this.ClearSelection();
3174 this.SelectIdxStart=this.SelectIdxEnd=this.datasetIndex(a);
3175 this.ShowSelection()
3176 },AdjustSelection:function(a){var b=this.datasetIndex(a);
3177 if(this.SelectIdxStart.tabIdx!=b.tabIdx){return
3178 }this.HideSelection();
3179 this.SelectIdxEnd=b;
3180 this.ShowSelection()
3181 },RefreshSelection:function(){var a=this.getVisibleSelection();
3182 for(var b=0;
3183 b<a.length;
3184 b++){this.columns[a[b].column].displayValue(a[b].row)
3185 }},FillSelection:function(b,f){if(this.SelectIdxStart&&this.SelectIdxEnd){var e=Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3186 var d=Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3187 var j=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3188 var g=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3189 for(var a=e;
3190 a<=d;
3191 a++){for(var k=j;
3192 k<=g;
3193 k++){this.buffer.setValue(a,k,b,f)
3194 }}}if(this.SelectCtrl){for(var h=0;
3195 h<this.SelectCtrl.length;
3196 h++){this.buffer.setValue(this.SelectCtrl[h].row,this.SelectCtrl[h].column,b,f)
3197 }}this.RefreshSelection()
3198 },selectMouseDown:function(d){if(this.highlightEnabled==false){return true
3199 }this.cancelMenu();
3200 var a=Rico.eventElement(d);
3201 if(!Rico.eventLeftClick(d)){return true
3202 }a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3203 if(!a){return true
3204 }Rico.eventStop(d);
3205 var c=this.datasetIndex(a);
3206 if(c.onBlankRow){return true
3207 }Rico.log("selectMouseDown @"+c.row+","+c.column);
3208 if(d.ctrlKey){if(!this.SelectIdxStart||this.options.highlightMethod!="class"){return true
3209 }if(!this.isSelected(a)){this.highlightCell(a);
3210 this.SelectCtrl.push(this.datasetIndex(a))
3211 }else{for(var b=0;
3212 b<this.SelectCtrl.length;
3213 b++){if(this.SelectCtrl[b].row==c.row&&this.SelectCtrl[b].column==c.column){this.unhighlightCell(a);
3214 this.SelectCtrl.splice(b,1);
3215 break
3216 }}}}else{if(d.shiftKey){if(!this.SelectIdxStart){return true
3217 }this.AdjustSelection(a)
3218 }else{this.selectCell(a);
3219 this.pluginSelect()
3220 }}return false
3221 },pluginSelect:function(){if(this.selectPluggedIn){return
3222 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3223 Rico.eventBind(a,"mouseover",this.options.mouseOverHandler,false);
3224 Rico.eventBind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3225 this.selectPluggedIn=true
3226 },unplugSelect:function(){if(!this.selectPluggedIn){return
3227 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3228 Rico.eventUnbind(a,"mouseover",this.options.mouseOverHandler,false);
3229 Rico.eventUnbind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3230 this.selectPluggedIn=false
3231 },selectMouseUp:function(b){this.unplugSelect();
3232 var a=Rico.eventElement(b);
3233 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3234 if(!a){return
3235 }if(this.SelectIdxStart&&this.SelectIdxEnd){this.AdjustSelection(a)
3236 }else{this.ClearSelection()
3237 }},selectMouseOver:function(b){var a=Rico.eventElement(b);
3238 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3239 if(!a){return
3240 }this.AdjustSelection(a);
3241 Rico.eventStop(b)
3242 },isSelected:function(a){if(this.options.highlightMethod!="outline"){return Rico.hasClass(a,this.options.highlightClass)
3243 }if(!this.SelectIdxStart||!this.SelectIdxEnd){return false
3244 }var c=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3245 var b=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3246 if(c>b){return false
3247 }var e=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3248 var d=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3249 var f=this.datasetIndex(a);
3250 return(c<=f.row&&f.row<=b&&e<=f.column&&f.column<=d)
3251 },highlightCell:function(a){Rico.addClass(a,this.options.highlightClass)
3252 },unhighlightCell:function(a){if(a){Rico.removeClass(a,this.options.highlightClass)
3253 }},selectRow:function(a){for(var b=0;
3254 b<this.columns.length;
3255 b++){this.highlightCell(this.columns[b].cell(a))
3256 }},unselectRow:function(a){for(var b=0;
3257 b<this.columns.length;
3258 b++){this.unhighlightCell(this.columns[b].cell(a))
3259 }},rowMouseOver:function(c){if(!this.highlightEnabled){return
3260 }var a=Rico.eventElement(c);
3261 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3262 if(!a){return
3263 }var b=this.winCellIndex(a);
3264 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3265 }this.highlight(b)
3266 },highlight:function(a){if(this.options.highlightMethod!="outline"){this.cursorSetClass(a)
3267 }if(this.options.highlightMethod!="class"){this.cursorOutline(a)
3268 }this.highlightIdx=a
3269 },cursorSetClass:function(e){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3270 }this.highlightCell(e.cell);
3271 break;
3272 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3273 }var b=this.options.highlightSection&1;
3274 var a=this.options.highlightSection&2;
3275 var f=b?0:this.options.frozenColumns;
3276 var d=a?this.columns.length:this.options.frozenColumns;
3277 for(var g=f;
3278 g<d;
3279 g++){this.highlightCell(this.columns[g].cell(e.row))
3280 }break;
3281 default:return
3282 }},cursorOutline:function(c){var d;
3283 switch(this.options.highlightElem){case"menuCell":case"cursorCell":d=this.highlightDiv[c.tabIdx];
3284 d.style.left=(this.columns[c.column].dataCell.offsetLeft-1)+"px";
3285 d.style.width=this.columns[c.column].colWidth;
3286 this.highlightDiv[1-c.tabIdx].style.display="none";
3287 break;
3288 case"menuRow":case"cursorRow":d=this.highlightDiv[0];
3289 var b=this.options.highlightSection&1;
3290 var a=this.options.highlightSection&2;
3291 d.style.left=b?"0px":this.frozenTabs.style.width;
3292 d.style.width=((b?this.frozenTabs.offsetWidth:0)+(a?this.innerDiv.offsetWidth:0)-4)+"px";
3293 break;
3294 default:return
3295 }d.style.top=(this.hdrHt+c.row*this.rowHeight-1)+"px";
3296 d.style.height=(this.rowHeight-1)+"px";
3297 d.style.display=""
3298 },unhighlight:function(){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3299 }if(!this.highlightDiv){return
3300 }for(var a=0;
3301 a<2;
3302 a++){this.highlightDiv[a].style.display="none"
3303 }break;
3304 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3305 }if(this.highlightDiv){this.highlightDiv[0].style.display="none"
3306 }break
3307 }},resetContents:function(){Rico.log("resetContents");
3308 this.ClearSelection();
3309 this.buffer.clear();
3310 this.clearRows();
3311 this.clearBookmark()
3312 },setImages:function(){for(var a=0;
3313 a<this.columns.length;
3314 a++){this.columns[a].setImage()
3315 }},findSortedColumn:function(){for(var a=0;
3316 a<this.columns.length;
3317 a++){if(this.columns[a].isSorted()){return a
3318 }}return -1
3319 },findColumnName:function(a){for(var b=0;
3320 b<this.columns.length;
3321 b++){if(this.columns[b].fieldName==a){return b
3322 }}return -1
3323 },findColumnsBySpec:function(b,c){var a=[];
3324 for(var d=0;
3325 d<this.options.columnSpecs.length;
3326 d++){if(this.options.columnSpecs[d][b]==c){a.push(d)
3327 }}return a
3328 },setSortUI:function(b,c){Rico.log("setSortUI: "+b+" "+c);
3329 var a=this.findSortedColumn();
3330 if(a>=0){c=this.columns[a].getSortDirection()
3331 }else{if(typeof c!="string"){c=Rico.ColumnConst.SORT_ASC
3332 }else{c=c.toUpperCase();
3333 if(c!=Rico.ColumnConst.SORT_DESC){c=Rico.ColumnConst.SORT_ASC
3334 }}switch(typeof b){case"string":a=this.findColumnName(b);
3335 break;
3336 case"number":a=b;
3337 break
3338 }}if(typeof(a)!="number"||a<0){return
3339 }this.clearSort();
3340 this.columns[a].setSorted(c);
3341 this.buffer.sortBuffer(a)
3342 },clearSort:function(){for(var a=0;
3343 a<this.columns.length;
3344 a++){this.columns[a].setUnsorted()
3345 }},clearFilters:function(){for(var a=0;
3346 a<this.columns.length;
3347 a++){this.columns[a].setUnfiltered(true)
3348 }if(this.options.filterHandler){this.options.filterHandler()
3349 }},filterCount:function(){for(var a=0,b=0;
3350 a<this.columns.length;
3351 a++){if(this.columns[a].isFiltered()){b++
3352 }}return b
3353 },sortHandler:function(){this.cancelMenu();
3354 this.ClearSelection();
3355 this.setImages();
3356 var a=this.findSortedColumn();
3357 if(a<0){return
3358 }Rico.log("sortHandler: sorting column "+a);
3359 this.buffer.sortBuffer(a);
3360 this.clearRows();
3361 this.scrollDiv.scrollTop=0;
3362 this.buffer.fetch(0)
3363 },filterHandler:function(){Rico.log("filterHandler");
3364 this.cancelMenu();
3365 if(this.buffer.processingRequest){this.queueFilter=true;
3366 return
3367 }this.unplugScroll();
3368 this.ClearSelection();
3369 this.setImages();
3370 this.clearBookmark();
3371 this.clearRows();
3372 this.buffer.fetch(-1);
3373 Rico.runLater(10,this,"pluginScroll")
3374 },clearBookmark:function(){if(this.bookmark){this.bookmark.innerHTML="&nbsp;"
3375 }},bookmarkHandler:function(a,d){var b;
3376 if(isNaN(a)||!this.bookmark){return
3377 }var c=this.buffer.totalRows;
3378 if(c<d){d=c
3379 }if(c<=0){b=Rico.getPhraseById("bookmarkNoMatch")
3380 }else{if(d<0){b=Rico.getPhraseById("bookmarkNoRec")
3381 }else{if(this.buffer.foundRowCount){b=Rico.getPhraseById("bookmarkExact",a,d,c)
3382 }else{b=Rico.getPhraseById("bookmarkAbout",a,d,c)
3383 }}}this.bookmark.innerHTML=b
3384 },clearRows:function(){if(this.isBlank==true){return
3385 }for(var a=0;
3386 a<this.columns.length;
3387 a++){this.columns[a].clearColumn()
3388 }this.isBlank=true
3389 },refreshContents:function(j){Rico.log("refreshContents1 "+this.tableId+": startPos="+j+" lastRow="+this.lastRowPos+" PartBlank="+this.isPartialBlank+" pageSize="+this.pageSize);
3390 this.hideMsg();
3391 this.cancelMenu();
3392 this.unhighlight();
3393 if(this.queueFilter){Rico.log("refreshContents: cancelling refresh because filter has changed");
3394 this.queueFilter=false;
3395 this.filterHandler();
3396 return
3397 }this.highlightEnabled=this.options.highlightSection!="none";
3398 var h=this.buffer.startPos>j;
3399 var d=h?this.buffer.startPos:j;
3400 this.contentStartPos=d+1;
3401 var b=Math.min(this.buffer.startPos+this.buffer.size,j+this.pageSize);
3402 this.buffer.setWindow(d,b);
3403 Rico.log("refreshContents2 "+this.tableId+": cStartPos="+d+" cEndPos="+b+" vPrecedesBuf="+h+" b.startPos="+this.buffer.startPos);
3404 if(j==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3405 }this.isBlank=false;
3406 var m=this.options.onRefreshComplete;
3407 if((j+this.pageSize<this.buffer.startPos)||(this.buffer.startPos+this.buffer.size<j)||(this.buffer.size==0)){this.clearRows();
3408 if(m){m(this.contentStartPos,b)
3409 }return
3410 }Rico.log("refreshContents: contentStartPos="+d+" contentEndPos="+b+" viewPrecedesBuffer="+h);
3411 var n=b-d;
3412 var f=this.pageSize-n;
3413 var k=h?0:n;
3414 var e=h?f:0;
3415 for(var a=0;
3416 a<n;
3417 a++){for(var l=0;
3418 l<this.columns.length;
3419 l++){this.columns[l].displayValue(a+e)
3420 }}for(var g=0;
3421 g<f;
3422 g++){this.blankRow(g+k)
3423 }if(this.options.highlightElem=="selection"){this.ShowSelection()
3424 }this.isPartialBlank=f>0;
3425 this.lastRowPos=j;
3426 Rico.log("refreshContents complete, startPos="+j);
3427 if(m){m(this.contentStartPos,b)
3428 }},scrollToRow:function(a){var b=this.rowToPixel(a);
3429 Rico.log("scrollToRow, rowOffset="+a+" pixel="+b);
3430 this.scrollDiv.scrollTop=b;
3431 if(this.options.onscroll){this.options.onscroll(this,a)
3432 }},scrollUp:function(){this.moveRelative(-1)
3433 },scrollDown:function(){this.moveRelative(1)
3434 },pageUp:function(){this.moveRelative(-this.pageSize)
3435 },pageDown:function(){this.moveRelative(this.pageSize)
3436 },adjustRow:function(a){var b=this.topOfLastPage();
3437 if(b==0||!a){return 0
3438 }return Math.min(b,a)
3439 },rowToPixel:function(a){return this.adjustRow(a)*this.rowHeight
3440 },pixeltorow:function(c){var b=this.topOfLastPage();
3441 if(b==0){return 0
3442 }var a=parseInt(c/this.rowHeight,10);
3443 return Math.min(b,a)
3444 },moveRelative:function(b){var a=Math.max(this.scrollDiv.scrollTop+b*this.rowHeight,0);
3445 a=Math.min(a,this.scrollDiv.scrollHeight);
3446 this.scrollDiv.scrollTop=a
3447 },pluginScroll:function(){if(this.scrollPluggedIn){return
3448 }Rico.log("pluginScroll: wheelEvent="+this.wheelEvent);
3449 Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3450 for(var a=0;
3451 a<2;
3452 a++){Rico.eventBind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3453 }this.scrollPluggedIn=true
3454 },unplugScroll:function(){if(!this.scrollPluggedIn){return
3455 }Rico.log("unplugScroll");
3456 Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3457 for(var a=0;
3458 a<2;
3459 a++){Rico.eventUnbind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3460 }this.scrollPluggedIn=false
3461 },handleWheel:function(a){var b=0;
3462 if(a.wheelDelta){if(Rico.isOpera){b=a.wheelDelta/120
3463 }else{if(Rico.isWebKit){b=-a.wheelDelta/12
3464 }else{b=-a.wheelDelta/120
3465 }}}else{if(a.detail){b=a.detail/3
3466 }}if(b){this.moveRelative(b)
3467 }Rico.eventStop(a);
3468 return false
3469 },handleScroll:function(g){if(this.scrollTimeout){clearTimeout(this.scrollTimeout)
3470 }this.setHorizontalScroll();
3471 var a=this.scrollDiv.scrollTop;
3472 var b=this.lastScrollPos-a;
3473 if(b==0){return
3474 }var d=this.pixeltorow(a);
3475 if(d==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3476 }var f=new Date();
3477 Rico.log("handleScroll, newrow="+d+" scrtop="+a);
3478 if(this.options.highlightElem=="selection"){this.HideSelection()
3479 }this.buffer.fetch(d);
3480 if(this.options.onscroll){this.options.onscroll(this,d)
3481 }this.scrollTimeout=Rico.runLater(1200,this,"scrollIdle");
3482 this.lastScrollPos=this.scrollDiv.scrollTop;
3483 var c=new Date()
3484 },scrollIdle:function(){if(this.options.onscrollidle){this.options.onscrollidle()
3485 }}};
3486 Rico.LiveGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
3487 };
3488 Rico.LiveGridColumn.prototype={initialize:function(liveGrid,colIdx,hdrInfo,tabIdx){Rico.extend(this,new Rico.TableColumnBase());
3489 this.baseInit(liveGrid,colIdx,hdrInfo,tabIdx);
3490 this.buffer=liveGrid.buffer;
3491 if(typeof(this.format.type)!="string"||this.format.EntryType=="tinyMCE"){this.format.type="raw"
3492 }if(typeof this.isNullable!="boolean"){this.isNullable=/number|date/.test(this.format.type)
3493 }this.isText=/raw|text|showTags/.test(this.format.type);
3494 Rico.log(" sortable="+this.sortable+" filterable="+this.filterable+" hideable="+this.hideable+" isNullable="+this.isNullable+" isText="+this.isText);
3495 this.fixHeaders(this.liveGrid.tableId,this.options.hdrIconsFirst);
3496 if(this["format_"+this.format.type]){this._format=this["format_"+this.format.type]
3497 }if(this.format.control){if(typeof this.format.control=="string"){this.format.control=eval(this.format.control)
3498 }for(var property in this.format.control){if(property.charAt(0)=="_"){Rico.log("Copying control property "+property+" to "+this);
3499 this[property]=this.format.control[property]
3500 }}}},sortAsc:function(){this.setColumnSort(Rico.ColumnConst.SORT_ASC)
3501 },sortDesc:function(){this.setColumnSort(Rico.ColumnConst.SORT_DESC)
3502 },setColumnSort:function(a){this.liveGrid.clearSort();
3503 this.setSorted(a);
3504 if(this.liveGrid.options.saveColumnInfo.sort){this.liveGrid.setCookie()
3505 }if(this.options.sortHandler){this.options.sortHandler()
3506 }},isSortable:function(){return this.sortable
3507 },isSorted:function(){return this.currentSort!=Rico.ColumnConst.UNSORTED
3508 },getSortDirection:function(){return this.currentSort
3509 },toggleSort:function(){if(this.buffer&&this.buffer.totalRows==0){return
3510 }if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.sortDesc()
3511 }else{this.sortAsc()
3512 }},setUnsorted:function(){this.setSorted(Rico.ColumnConst.UNSORTED)
3513 },setSorted:function(a){this.currentSort=a
3514 },canFilter:function(){return this.filterable
3515 },getFilterText:function(){var c=[];
3516 for(var b=0;
3517 b<this.filterValues.length;
3518 b++){var a=this.filterValues[b];
3519 c.push(a==""?Rico.getPhraseById("filterBlank"):a)
3520 }switch(this.filterOp){case"EQ":return"= "+c.join(", ");
3521 case"NE":return Rico.getPhraseById("filterNot",c.join(", "));
3522 case"LE":return"<= "+c[0];
3523 case"GE":return">= "+c[0];
3524 case"LIKE":return Rico.getPhraseById("filterLike",c[0]);
3525 case"NULL":return Rico.getPhraseById("filterEmpty");
3526 case"NOTNULL":return Rico.getPhraseById("filterNotEmpty")
3527 }return"?"
3528 },getFilterQueryParm:function(){if(this.filterType==Rico.ColumnConst.UNFILTERED){return""
3529 }var a="&f["+this.index+"][op]="+this.filterOp;
3530 a+="&f["+this.index+"][len]="+this.filterValues.length;
3531 for(var b=0;
3532 b<this.filterValues.length;
3533 b++){a+="&f["+this.index+"]["+b+"]="+escape(this.filterValues[b])
3534 }return a
3535 },setUnfiltered:function(a){this.filterType=Rico.ColumnConst.UNFILTERED;
3536 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3537 }if(this.removeFilterFunc){this.removeFilterFunc()
3538 }if(this.options.filterHandler&&!a){this.options.filterHandler()
3539 }},setFilterEQ:function(){this.setUserFilter("EQ")
3540 },setFilterNE:function(){this.setUserFilter("NE")
3541 },addFilterNE:function(){this.filterValues.push(this.userFilter);
3542 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3543 }if(this.options.filterHandler){this.options.filterHandler()
3544 }},setFilterGE:function(){this.setUserFilter("GE")
3545 },setFilterLE:function(){this.setUserFilter("LE")
3546 },setFilterKW:function(a){if(a!=""&&a!=null){this.setFilter("LIKE",a,Rico.ColumnConst.USERFILTER)
3547 }else{this.setUnfiltered(false)
3548 }},setUserFilter:function(a){this.setFilter(a,this.userFilter,Rico.ColumnConst.USERFILTER)
3549 },setSystemFilter:function(a,b){this.setFilter(a,b,Rico.ColumnConst.SYSTEMFILTER)
3550 },setFilter:function(a,c,b,d){this.filterValues=typeof(c)=="object"?c:[c];
3551 this.filterType=b;
3552 this.filterOp=a;
3553 if(b==Rico.ColumnConst.USERFILTER&&this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3554 }this.removeFilterFunc=d;
3555 if(this.options.filterHandler){this.options.filterHandler()
3556 }},isFiltered:function(){return this.filterType==Rico.ColumnConst.USERFILTER
3557 },filterChange:function(a){var b=Rico.eventElement(a);
3558 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
3559 }else{this.setFilter("EQ",b.value,Rico.ColumnConst.USERFILTER,function(){b.selectedIndex=0
3560 })
3561 }},filterClear:function(a){this.filterField.value="";
3562 this.setUnfiltered()
3563 },filterKeypress:function(c){var a=Rico.eventElement(c);
3564 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
3565 }if(this.lastKeyFilter==a.value){return
3566 }var b=a.value;
3567 Rico.log("filterKeypress: "+this.index+" "+b);
3568 this.lastKeyFilter=b;
3569 if(b==""||b=="*"){this.setUnfiltered()
3570 }else{this.setFilter("LIKE",b,Rico.ColumnConst.USERFILTER,function(){a.value=""
3571 })
3572 }},mFilterSelectClick:function(a){Rico.eventStop(a);
3573 if(this.mFilter.style.display!="none"){this.mFilterFinish(a);
3574 if(Rico.isIE&&Rico.ieVersion<=6){this.filterField.focus()
3575 }else{this.filterField.blur()
3576 }}else{var b=Rico.cumulativeOffset(this.filterField);
3577 this.mFilter.style.top=(b.top+this.filterField.offsetHeight)+"px";
3578 this.mFilter.style.left=b.left+"px";
3579 this.mFilter.style.width=Math.min(this.filterField.offsetWidth,parseInt(this.colWidth,10))+"px";
3580 Rico.show(this.mFilter);
3581 this.mFilterFocus.focus()
3582 }},mFilterFinish:function(g){if(!this.mFilterChange){Rico.hide(this.mFilter);
3583 return
3584 }if(this.mFilterInputs[0].checked){this.mFilterReset();
3585 Rico.hide(this.mFilter);
3586 this.setUnfiltered();
3587 return
3588 }var c=[];
3589 var a=[];
3590 for(var d=1;
3591 d<this.mFilterInputs.length;
3592 d++){if(this.mFilterInputs[d].checked){c.push(this.mFilterInputs[d].value);
3593 a.push(this.mFilterLabels[d].innerHTML)
3594 }}if(c.length>0){var f=a.join(", ");
3595 this.filterField.options[0].text=f;
3596 this.filterField.title=f;
3597 Rico.hide(this.mFilter);
3598 this.mFilterChange=false;
3599 var b=this;
3600 this.setFilter("EQ",c,Rico.ColumnConst.USERFILTER,function(){b.mFilterReset()
3601 })
3602 }else{alert("Please select at least one value")
3603 }},mFilterReset:function(){var a=this.mFilterLabels[0].innerHTML;
3604 this.filterField.options[0].text=a;
3605 this.filterField.title=a
3606 },mFilterAllClick:function(c){var a=this.mFilterInputs[0].checked;
3607 for(var b=1;
3608 b<this.mFilterInputs.length;
3609 b++){this.mFilterInputs[b].checked=a
3610 }this.mFilterChange=true
3611 },mFilterOtherClick:function(a){this.mFilterInputs[0].checked=false;
3612 this.mFilterChange=true
3613 },format_text:function(a){if(typeof a!="string"){return"&nbsp;"
3614 }else{return Rico.stripTags(a)
3615 }},format_showTags:function(a){if(typeof a!="string"){return"&nbsp;"
3616 }else{return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")
3617 }},format_number:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"
3618 }else{return Rico.formatNumber(a,this.format)
3619 }},format_datetime:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"
3620 }else{var b=Rico.setISO8601(a);
3621 if(!b){return a
3622 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3623 }},format_UTCasLocalTime:function(a){if(typeof a=="undefined"||a==""||a==null){return"&nbsp;"
3624 }else{var c=new Date();
3625 var b=Rico.setISO8601(a,-c.getTimezoneOffset());
3626 if(!b){return a
3627 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3628 }},format_date:function(a){if(typeof a=="undefined"||a==null||a==""){return"&nbsp;"
3629 }else{var b=Rico.setISO8601(a);
3630 if(!b){return a
3631 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDate")+(this.format.suffix||"")
3632 }},fixHeaders:function(d,e){if(this.sortable){var c=Rico.eventHandle(this,"toggleSort");
3633 switch(this.options.headingSort){case"link":var b=Rico.wrapChildren(this.hdrCellDiv,"ricoSort",undefined,"a");
3634 b.href="javascript:void(0)";
3635 Rico.eventBind(b,"click",c);
3636 break;
3637 case"hover":Rico.eventBind(this.hdrCellDiv,"click",c);
3638 break
3639 }}this.imgFilter=document.createElement("span");
3640 this.imgFilter.style.display="none";
3641 this.imgFilter.className="rico-icon ricoLG_filterCol";
3642 this.imgSort=document.createElement("span");
3643 this.imgSort.style.display="none";
3644 this.imgSort.style.verticalAlign="top";
3645 if(e){this.hdrCellDiv.insertBefore(this.imgSort,this.hdrCellDiv.firstChild);
3646 this.hdrCellDiv.insertBefore(this.imgFilter,this.hdrCellDiv.firstChild)
3647 }else{this.hdrCellDiv.appendChild(this.imgFilter);
3648 this.hdrCellDiv.appendChild(this.imgSort)
3649 }if(!this.format.filterUI){Rico.eventBind(this.imgFilter,"click",Rico.eventHandle(this,"filterClick"),false)
3650 }},filterClick:function(a){if(this.filterType==Rico.ColumnConst.USERFILTER&&this.filterOp=="LIKE"){this.liveGrid.openKeyword(this.index)
3651 }},getValue:function(a){return this.buffer.getWindowCell(a,this.index)
3652 },getBufferAttr:function(a){return this.buffer.getWindowAttr(a,this.index)
3653 },setValue:function(b,a){this.buffer.setWindowValue(b,this.index,a)
3654 },_format:function(a){return a
3655 },_display:function(a,b){b.innerHTML=this._format(a)
3656 },_export:function(a){return this._format(a)
3657 },exportBuffer:function(a){return this._export(this.buffer.getValue(a,this.index))
3658 },displayValue:function(f){var a=this.getValue(f);
3659 if(a==null){this.clearCell(f);
3660 return
3661 }var e=this.cell(f);
3662 this._display(a,e,f);
3663 var d=this.buffer.options.acceptAttr;
3664 if(d.length==0){return
3665 }var c=this.getBufferAttr(f);
3666 if(c==null){return
3667 }for(var b=0;
3668 b<d.length;
3669 b++){c=c["_"+d[b]]||"";
3670 switch(d[b]){case"style":e.style.cssText=c;
3671 break;
3672 case"class":e.className=c;
3673 break;
3674 default:e["_"+d[b]]=c;
3675 break
3676 }}}};
3677 Rico.TableColumn={};
3678 Rico.TableColumn.checkboxKey=function(a){this.initialize(a)
3679 };
3680 Rico.TableColumn.checkboxKey.prototype={initialize:function(a){this._checkboxes=[];
3681 this._spans=[];
3682 this._KeyHash={};
3683 this._showKey=a
3684 },_create:function(a,b){this._checkboxes[b]=Rico.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);
3685 this._spans[b]=Rico.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);
3686 this._clear(a,b);
3687 Rico.eventBind(this._checkboxes[b],"click",Rico.eventHandle(this,"_onclick"))
3688 },_onclick:function(c){var b=Event.element(c);
3689 var d=parseInt(b.id.substr((b.id.lastIndexOf("_",b.id.length)+1)));
3690 var a=this.getValue(d);
3691 if(b.checked){this._addChecked(a)
3692 }else{this._remChecked(a)
3693 }},_clear:function(b,c){var a=this._checkboxes[c];
3694 a.checked=false;
3695 a.style.display="none";
3696 this._spans[c].innerHTML=""
3697 },_display:function(a,c,d){var b=this._checkboxes[d];
3698 b.style.display="";
3699 b.checked=this._KeyHash[a];
3700 if(this._showKey){this._spans[d].innerHTML=a
3701 }},_SelectedKeys:function(){return Rico.keys(this._KeyHash)
3702 },_addChecked:function(a){this._KeyHash[a]=1
3703 },_remChecked:function(a){delete this._KeyHash[a]
3704 }};
3705 Rico.TableColumn.checkbox=function(b,c,a,d){this.initialize(b,c,a,d)
3706 };
3707 Rico.TableColumn.checkbox.prototype={initialize:function(b,c,a,d){this._checkedValue=b;
3708 this._uncheckedValue=c;
3709 this._defaultValue=a||false;
3710 this._readOnly=d||false;
3711 this._checkboxes=[]
3712 },_create:function(a,b){this._checkboxes[b]=Rico.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);
3713 this._clear(a,b);
3714 if(this._readOnly){this._checkboxes[b].disabled=true
3715 }else{Rico.eventBind(this._checkboxes[b],"click",Rico.eventHandle(this,"_onclick"))
3716 }},_onclick:function(c){var a=Event.element(c);
3717 var d=parseInt(a.id.substr((a.id.lastIndexOf("_",a.id.length)+1)));
3718 var b=a.checked?this._checkedValue:this._uncheckedValue;
3719 this.setValue(d,b)
3720 },_clear:function(b,c){var a=this._checkboxes[c];
3721 a.checked=this._defaultValue;
3722 a.style.display="none"
3723 },_display:function(a,c,d){var b=this._checkboxes[d];
3724 b.style.display="";
3725 b.checked=(a==this._checkedValue)
3726 }};
3727 Rico.TableColumn.textbox=function(c,b,a){this.initialize(c,b,a)
3728 };
3729 Rico.TableColumn.textbox.prototype={initialize:function(c,b,a){this._boxSize=c;
3730 this._boxMaxLen=b;
3731 this._readOnly=a||false;
3732 this._textboxes=[]
3733 },_create:function(b,c){var a=Rico.createFormField(b,"input","text",this.liveGrid.tableId+"_txtbox_"+this.index+"_"+c);
3734 a.size=this._boxSize;
3735 a.maxLength=this._boxMaxLen;
3736 this._textboxes[c]=a;
3737 this._clear(b,c);
3738 if(this._readOnly){a.disabled=true
3739 }else{Rico.eventBind(a,"change",Rico.eventHandle(this,"_onchange"))
3740 }},_onchange:function(b){var a=Event.element(b);
3741 var c=parseInt(a.id.substr((a.id.lastIndexOf("_",a.id.length)+1)));
3742 this.setValue(c,a.value)
3743 },_clear:function(b,c){var a=this._textboxes[c];
3744 a.value="";
3745 a.style.display="none"
3746 },_display:function(a,c,d){var b=this._textboxes[d];
3747 b.style.display="";
3748 b.value=a
3749 }};
3750 Rico.TableColumn.HighlightCell=function(a,c,e,b,d){this.initialize(a,c,e,b,d)
3751 };
3752 Rico.TableColumn.HighlightCell.prototype={initialize:function(a,c,e,b,d){this._chkcol=a;
3753 this._chkval=c;
3754 this._chkop=d;
3755 this._highlightColor=e;
3756 this._highlightBackground=b
3757 },_clear:function(a,b){a.style.color="";
3758 a.style.backgroundColor="";
3759 a.innerHTML="&nbsp;"
3760 },_display:function(b,d,e){var a=this.liveGrid.buffer.getWindowValue(e,this._chkcol);
3761 var c;
3762 switch(this._chkop){case"!=":c=(a!=this._chkval);
3763 break;
3764 case">":c=(a>this._chkval);
3765 break;
3766 case"<":c=(a<this._chkval);
3767 break;
3768 case">=":c=(a>=this._chkval);
3769 break;
3770 case"<=":c=(a<=this._chkval);
3771 break;
3772 case"abs>":c=(Math.abs(a)>this._chkval);
3773 break;
3774 case"abs<":c=(Math.abs(a)<this._chkval);
3775 break;
3776 case"abs>=":c=(Math.abs(a)>=this._chkval);
3777 break;
3778 case"abs<=":c=(Math.abs(a)<=this._chkval);
3779 break;
3780 default:c=(a==this._chkval);
3781 break
3782 }d.style.color=c?this._highlightColor:"";
3783 d.style.backgroundColor=c?this._highlightBackground:"";
3784 d.innerHTML=this._format(b)
3785 }};
3786 Rico.TableColumn.bgColor=function(){};
3787 Rico.TableColumn.bgColor.prototype={_clear:function(a,b){a.style.backgroundColor=""
3788 },_display:function(a,b,c){b.style.backgroundColor=a
3789 }};
3790 Rico.TableColumn.link=function(a,c,b){this.initialize(a,c,b)
3791 };
3792 Rico.TableColumn.link.prototype={initialize:function(a,c,b){this._href=a;
3793 this._target=c;
3794 this._linktext=b;
3795 this._anchors=[]
3796 },_create:function(a,b){this._anchors[b]=Rico.createFormField(a,"a",null,this.liveGrid.tableId+"_a_"+this.index+"_"+b);
3797 if(this._target){this._anchors[b].target=this._target
3798 }this._clear(a,b)
3799 },_clear:function(a,b){this._anchors[b].href="";
3800 this._anchors[b].innerHTML=""
3801 },_display:function(b,d,f){var c=this.liveGrid.buffer;
3802 var a=this._href=="self"?b:this._href.replace(/\{\d+\}/g,function(g){var h=parseInt(g.substr(1),10);
3803 return encodeURIComponent(c.getWindowValue(f,h))
3804 });
3805 var e=this._linktext||b;
3806 if(a&&e){this._anchors[f].href=a;
3807 this._anchors[f].innerHTML=e
3808 }else{this._clear(d,f)
3809 }}};
3810 Rico.TableColumn.image=function(a,b){this.initialize(a,b)
3811 };
3812 Rico.TableColumn.image.prototype={initialize:function(a,b){this._img=[];
3813 this._prefix=a||"";
3814 this._suffix=b||""
3815 },_create:function(a,b){this._img[b]=Rico.createFormField(a,"img",null,this.liveGrid.tableId+"_img_"+this.index+"_"+b);
3816 this._clear(a,b)
3817 },_clear:function(b,c){var a=this._img[c];
3818 a.style.display="none";
3819 a.src=""
3820 },_display:function(b,c,d){var a=this._img[d];
3821 this._img[d].src=this._prefix+b+this._suffix;
3822 a.style.display=""
3823 }};
3824 Rico.TableColumn.lookup=function(c,a,b){this.initialize(c,a,b)
3825 };
3826 Rico.TableColumn.lookup.prototype={initialize:function(d,a,c){this._map=d;
3827 this._defaultCode=a||"";
3828 this._defaultDesc=c||"&nbsp;";
3829 var b=this;
3830 this._sortfunc=function(e){return b._sortvalue(e)
3831 };
3832 this._codes=[];
3833 this._descriptions=[]
3834 },_create:function(a,b){this._descriptions[b]=Rico.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);
3835 this._codes[b]=Rico.createFormField(a,"input","hidden",this.liveGrid.tableId+"_code_"+this.index+"_"+b);
3836 this._clear(a,b)
3837 },_clear:function(a,b){this._codes[b].value=this._defaultCode;
3838 this._descriptions[b].innerHTML=this._defaultDesc
3839 },_sortvalue:function(a){return this._getdesc(a).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ")
3840 },_getdesc:function(a){var b=this._map[a];
3841 return(typeof b=="string")?b:this._defaultDesc
3842 },_export:function(a){return this._getdesc(a)
3843 },_display:function(a,b,c){this._codes[c].value=a;
3844 this._descriptions[c].innerHTML=this._getdesc(a)
3845 }};
3846 Rico.TableColumn.MultiLine=function(){};
3847 Rico.TableColumn.MultiLine.prototype={_display:function(a,c,d){var b=document.createElement("div");
3848 b.innerHTML=this._format(a);
3849 b.style.height="100%";
3850 if(c.firstChild){c.replaceChild(b,c.firstChild)
3851 }else{c.appendChild(b)
3852 }}};
3853 if(typeof Rico=="undefined"){throw ("GridMenu requires the Rico JavaScript framework")
3854 }Rico.GridMenu=function(a){this.initialize(a)
3855 };
3856 Rico.GridMenu.prototype={initialize:function(a){this.options={width:"18em",dataMenuHandler:null};
3857 Rico.extend(this.options,a||{});
3858 Rico.extend(this,new Rico.Menu(this.options));
3859 this.sortmenu=new Rico.Menu({width:"15em"});
3860 this.filtermenu=new Rico.Menu({width:"22em"});
3861 this.exportmenu=new Rico.Menu({width:"24em"});
3862 this.hideshowmenu=new Rico.Menu({width:"22em"});
3863 this.createDiv();
3864 this.sortmenu.createDiv();
3865 this.filtermenu.createDiv();
3866 this.exportmenu.createDiv();
3867 this.hideshowmenu.createDiv()
3868 },buildGridMenu:function(a,i){this.clearMenu();
3869 var o=this.liveGrid;
3870 var f=o.buffer;
3871 var m=f.totalRows;
3872 var n=o.options.maxPrint;
3873 var b=(a>=m);
3874 var d=o.columns[i];
3875 if(this.options.dataMenuHandler){var l=this.options.dataMenuHandler(o,a,i,b);
3876 if(!l){return(this.itemCount>0)
3877 }}if(d.sortable&&m>0){this.sortmenu.clearMenu();
3878 this.addSubMenuItem(Rico.getPhraseById("gridmenuSortBy",d.displayName),this.sortmenu,false);
3879 this.sortmenu.addMenuItemId("gridmenuSortAsc",function(){d.sortAsc()
3880 },true);
3881 this.sortmenu.addMenuItemId("gridmenuSortDesc",function(){d.sortDesc()
3882 },true)
3883 }this.filtermenu.clearMenu();
3884 if(d.canFilter()&&!d.format.filterUI&&(!b||d.filterType==Rico.ColumnConst.USERFILTER)){this.addSubMenuItem(Rico.getPhraseById("gridmenuFilterBy",d.displayName),this.filtermenu,false);
3885 d.userFilter=d.getValue(a);
3886 if(d.filterType==Rico.ColumnConst.USERFILTER){this.filtermenu.addMenuItemId("gridmenuRemoveFilter",function(){d.setUnfiltered(false)
3887 },true);
3888 if(d.filterOp=="LIKE"){this.filtermenu.addMenuItemId("gridmenuChgKeyword",function(){o.openKeyword(i)
3889 },true)
3890 }if(d.filterOp=="NE"&&!b){this.filtermenu.addMenuItemId("gridmenuExcludeAlso",function(){d.addFilterNE()
3891 },true)
3892 }}else{if(!b){this.filtermenu.addMenuItemId("gridmenuInclude",function(){d.setFilterEQ()
3893 },true);
3894 this.filtermenu.addMenuItemId("gridmenuGreaterThan",function(){d.setFilterGE()
3895 },d.userFilter!="");
3896 this.filtermenu.addMenuItemId("gridmenuLessThan",function(){d.setFilterLE()
3897 },d.userFilter!="");
3898 if(d.isText){this.filtermenu.addMenuItemId("gridmenuContains",function(){o.openKeyword(i)
3899 },true)
3900 }this.filtermenu.addMenuItemId("gridmenuExclude",function(){d.setFilterNE()
3901 },true)
3902 }}if(o.filterCount()>0){this.filtermenu.addMenuItemId("gridmenuRefresh",function(){o.filterHandler()
3903 },true);
3904 this.filtermenu.addMenuItemId("gridmenuRemoveAll",function(){o.clearFilters()
3905 },true)
3906 }}else{if(o.filterCount()>0){this.addSubMenuItem(Rico.getPhraseById("gridmenuFilterBy",d.displayName),this.filtermenu,false);
3907 this.filtermenu.addMenuItemId("gridmenuRemoveAll",function(){o.clearFilters()
3908 },true)
3909 }}this.exportmenu.clearMenu();
3910 if(f.printVisibleSQL&&typeof(f.dataSource)=="string"){this.addSubMenuItem(Rico.getPhraseById("gridmenuExport"),this.exportmenu,false);
3911 this.exportmenu.addMenuItemId("gridmenuExportVis2Web",function(){f.printVisibleSQL("html")
3912 });
3913 this.exportmenu.addMenuItemId("gridmenuExportAll2Web",function(){f.printAllSQL("html")
3914 },f.totalRows<=n);
3915 this.exportmenu.addMenuBreak();
3916 this.exportmenu.addMenuItemId("gridmenuExportVis2SS",function(){f.printVisibleSQL("xl")
3917 });
3918 this.exportmenu.addMenuItemId("gridmenuExportAll2SS",function(){f.printAllSQL("xl")
3919 },f.totalRows<=n)
3920 }else{if(n>0&&m>0){this.addSubMenuItem(Rico.getPhraseById("gridmenuExport"),this.exportmenu,false);
3921 this.exportmenu.addMenuItemId("gridmenuExportVis2Web",function(){f.printVisible()
3922 });
3923 this.exportmenu.addMenuItemId("gridmenuExportAll2Web",function(){f.printAll()
3924 },f.totalRows<=n)
3925 }}var k=o.listInvisible();
3926 for(var e=0,j=0;
3927 j<k.length;
3928 j++){if(k[j].canHideShow()){e++
3929 }}if(e>0||d.canHideShow()){this.hideshowmenu.clearMenu();
3930 this.addSubMenuItem(Rico.getPhraseById("gridmenuHideShow"),this.hideshowmenu,false);
3931 this.hideshowmenu.addMenuItemId("gridmenuChooseCols",function(){o.chooseColumns()
3932 },true,false);
3933 var h=o.columns.length-k.length;
3934 var g=(h>1&&d.visible&&d.canHideShow());
3935 this.hideshowmenu.addMenuItem(Rico.getPhraseById("gridmenuHide",d.displayName),function(){d.hideColumn()
3936 },g);
3937 if(k.length>1){this.hideshowmenu.addMenuItemId("gridmenuShowAll",function(){o.showAll()
3938 })
3939 }}return true
3940 }};
3941 if(typeof Rico=="undefined"){throw ("LiveGridAjax requires the Rico JavaScript framework")
3942 }if(!Rico.Buffer){Rico.Buffer={}
3943 }Rico.Buffer.AjaxXML=function(c,b,a){this.initialize(c,b,a)
3944 };
3945 Rico.Buffer.AjaxXML.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Buffer.Base());
3946 Rico.extend(this,Rico.Buffer.AjaxXMLMethods);
3947 this.dataSource=c;
3948 this.options.bufferTimeout=20000;
3949 this.options.requestParameters=[];
3950 this.options.waitMsg=Rico.getPhraseById("waitForData");
3951 this.options.canFilter=true;
3952 this.options.fmt="xml";
3953 Rico.extend(this.options,b||{});
3954 this.ajaxOptions={parameters:null,method:"get"};
3955 Rico.extend(this.ajaxOptions,a||{});
3956 this.requestCount=0;
3957 this.processingRequest=false;
3958 this.pendingRequest=-2;
3959 this.fetchData=true;
3960 this.sortParm={}
3961 }};
3962 Rico.Buffer.AjaxXMLMethods={fetch:function(b){if(this.fetchData){this.foundRowCount=true;
3963 this.fetchData=false;
3964 this.processingRequest=true;
3965 this.liveGrid.showMsg(this.options.waitMsg);
3966 this.timeoutHandler=Rico.runLater(this.options.bufferTimeout,this,"handleTimedOut");
3967 this.ajaxOptions.parameters=this.formQueryHashXML(0,-1);
3968 Rico.log("sending request");
3969 var a=this;
3970 if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=function(c){a.ajaxUpdate(b,c)
3971 };
3972 new Rico.ajaxRequest(this.dataSource,this.ajaxOptions)
3973 }else{this.ajaxOptions.onComplete=function(d,f,c,e){a.jsUpdate(b,d,f,c,e)
3974 };
3975 this.dataSource(this.ajaxOptions)
3976 }}else{if(b<0){this.applyFilters();
3977 this.setTotalRows(this.size);
3978 b=0
3979 }this.liveGrid.refreshContents(b)
3980 }},handleTimedOut:function(){Rico.log("Request Timed Out");
3981 this.liveGrid.showMsg(Rico.getPhraseById("requestTimedOut"))
3982 },formQueryHashXML:function(e,c){var d={id:this.liveGrid.tableId,page_size:(typeof c=="number")?c:this.totalRows,offset:e.toString()};
3983 if(!this.foundRowCount){d.get_total="true"
3984 }if(this.options.requestParameters){for(var f=0;
3985 f<this.options.requestParameters.length;
3986 f++){var g=this.options.requestParameters[f];
3987 if(g.name!=undefined&&g.value!=undefined){d[g.name]=g.value
3988 }else{var b=g.indexOf("=");
3989 var h=g.substring(0,b);
3990 var a=g.substring(b+1);
3991 d[h]=a
3992 }}}return d
3993 },clearTimer:function(){if(typeof this.timeoutHandler!="number"){return
3994 }window.clearTimeout(this.timeoutHandler);
3995 delete this.timeoutHandler
3996 },jsUpdate:function(a,c,f,b,d){this.clearTimer();
3997 this.processingRequest=false;
3998 Rico.log("jsUpdate: "+arguments.length);
3999 if(d){Rico.log("jsUpdate: received error="+d);
4000 this.liveGrid.showMsg(Rico.getPhraseById("requestError",d));
4001 return
4002 }this.rcvdRows=c.length;
4003 if(typeof b=="number"){this.rowcntContent=b.toString();
4004 this.rcvdRowCount=true;
4005 this.foundRowCount=true;
4006 Rico.log("jsUpdate: found RowCount="+this.rowcntContent)
4007 }this.updateBuffer(a,c,f);
4008 if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()
4009 }this.updateGrid(a);
4010 if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()
4011 }if(this.pendingRequest>=-1){var e=this.pendingRequest;
4012 Rico.log("jsUpdate: found pending request for offset="+e);
4013 this.pendingRequest=-2;
4014 this.fetch(e)
4015 }},ajaxUpdate:function(a,c){this.clearTimer();
4016 this.processingRequest=false;
4017 if(c.status!=200){Rico.log("ajaxUpdate: received http error="+c.status);
4018 this.liveGrid.showMsg(Rico.getPhraseById("httpError",c.status));
4019 return
4020 }this._responseHandler=this["processResponse"+this.options.fmt.toUpperCase()];
4021 if(!this._responseHandler(a,c)){return
4022 }if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()
4023 }this.updateGrid(a);
4024 if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()
4025 }if(this.pendingRequest>=-1){var b=this.pendingRequest;
4026 Rico.log("ajaxUpdate: found pending request for offset="+b);
4027 this.pendingRequest=-2;
4028 this.fetch(b)
4029 }},processResponseXML:function(k,f){var o=f.responseXML;
4030 if(f.responseText.substring(0,4)=="<!--"){var m=f.responseText.indexOf("-->");
4031 if(m==-1){this.liveGrid.showMsg("Web server error - client side debugging may be enabled");
4032 return false
4033 }o=Rico.createXmlDocument();
4034 o.loadXML(f.responseText.substring(m+3))
4035 }if(!o){alert("Data provider returned an invalid XML response");
4036 Rico.log("Data provider returned an invalid XML response");
4037 return false
4038 }var e=o.getElementsByTagName("ajax-response");
4039 if(e==null||e.length!=1){return false
4040 }this.rcvdRows=0;
4041 this.rcvdRowCount=false;
4042 var c=e[0];
4043 var a=c.getElementsByTagName("debug");
4044 for(var g=0;
4045 g<a.length;
4046 g++){Rico.log("ajaxUpdate: debug msg "+g+": "+Rico.getContentAsString(a[g],this.options.isEncoded))
4047 }var l=c.getElementsByTagName("error");
4048 if(l.length>0){var d=Rico.getContentAsString(l[0],this.options.isEncoded);
4049 alert("Data provider returned an error:\n"+d);
4050 Rico.log("Data provider returned an error:\n"+d);
4051 return false
4052 }var j=c.getElementsByTagName("rows")[0];
4053 if(!j){Rico.log("ajaxUpdate: invalid response");
4054 this.liveGrid.showMsg(Rico.getPhraseById("invalidResponse"));
4055 return false
4056 }var n=c.getElementsByTagName("rowcount");
4057 if(n&&n.length==1){this.rowcntContent=Rico.getContentAsString(n[0],this.options.isEncoded);
4058 this.rcvdRowCount=true;
4059 this.foundRowCount=true;
4060 Rico.log("ajaxUpdate: found RowCount="+this.rowcntContent)
4061 }this.updateUI=j.getAttribute("update_ui")=="true";
4062 this.rcvdOffset=j.getAttribute("offset");
4063 Rico.log("ajaxUpdate: rcvdOffset="+this.rcvdOffset);
4064 var h=this.dom2jstable(j);
4065 var b=(this.options.acceptAttr.length>0)?this.dom2jstableAttr(j):false;
4066 this.rcvdRows=h.length;
4067 this.updateBuffer(k,h,b);
4068 return true
4069 },processResponseJSON:function(a,d){var c=Rico.getJSON(d);
4070 if(!c||c==null){alert("Data provider returned an invalid JSON response");
4071 Rico.log("Data provider returned an invalid JSON response");
4072 return false
4073 }if(c.debug){for(var b=0;
4074 b<c.debug.length;
4075 b++){Rico.writeDebugMsg("debug msg "+b+": "+c.debug[b])
4076 }}if(c.error){alert("Data provider returned an error:\n"+c.error);
4077 Rico.writeDebugMsg("Data provider returned an error:\n"+c.error);
4078 return false
4079 }if(c.rowcount){this.rowcntContent=c.rowcount;
4080 this.rcvdRowCount=true;
4081 this.foundRowCount=true;
4082 Rico.writeDebugMsg("loadRows, found RowCount="+c.rowcount)
4083 }this.rcvdRows=c.rows.length;
4084 this.updateBuffer(a,c.rows);
4085 return true
4086 },updateBuffer:function(c,a,b){this.baseRows=a;
4087 this.attr=b;
4088 Rico.log("updateBuffer: # of rows="+this.rcvdRows);
4089 this.rcvdRowCount=true;
4090 this.rowcntContent=this.rcvdRows;
4091 if(typeof this.delayedSortCol=="number"){this.sortBuffer(this.delayedSortCol)
4092 }this.applyFilters();
4093 this.startPos=0
4094 },updateGrid:function(f){Rico.log("updateGrid, size="+this.size+" rcv cnt type="+typeof(this.rowcntContent));
4095 var e;
4096 if(this.rcvdRowCount==true){Rico.log("found row cnt: "+this.rowcntContent);
4097 var d=parseInt(this.rowcntContent,10);
4098 var b=this.totalRows;
4099 if(!isNaN(d)&&d!=b){this.setTotalRows(d);
4100 e=Math.min(this.liveGrid.topOfLastPage(),f);
4101 Rico.log("updateGrid: new rowcnt="+d+" newpos="+e);
4102 if(b==0&&this.liveGrid.sizeTo=="data"){Rico.runLater(100,this.liveGrid,"adjustPageSize")
4103 }this.liveGrid.scrollToRow(e);
4104 if(this.isInRange(e)){this.liveGrid.refreshContents(e)
4105 }else{this.fetch(e)
4106 }return
4107 }}else{var a=f+this.rcvdRows;
4108 if(a>this.totalRows){var c=a;
4109 Rico.log("extending totrows to "+c);
4110 this.setTotalRows(c)
4111 }}e=this.liveGrid.pixeltorow(this.liveGrid.scrollDiv.scrollTop);
4112 Rico.log("updateGrid: newpos="+e);
4113 this.liveGrid.refreshContents(e)
4114 }};
4115 Rico.Buffer.AjaxSQL=function(c,b,a){this.initialize(c,b,a)
4116 };
4117 Rico.Buffer.AjaxSQL.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Buffer.AjaxXML());
4118 Rico.extend(this,Rico.Buffer.AjaxSQLMethods);
4119 this.dataSource=c;
4120 this.options.canFilter=true;
4121 this.options.largeBufferSize=7;
4122 this.options.nearLimitFactor=1;
4123 Rico.extend(this.options,b||{});
4124 Rico.extend(this.ajaxOptions,a||{})
4125 }};
4126 Rico.Buffer.AjaxSQLMethods={registerGrid:function(a){this.liveGrid=a;
4127 this.sessionExpired=false;
4128 this.timerMsg=document.getElementById(a.tableId+"_timer");
4129 if(this.options.TimeOut&&this.timerMsg){if(!this.timerMsg.title){this.timerMsg.title=Rico.getPhraseById("sessionExpireMinutes")
4130 }this.restartSessionTimer()
4131 }},setBufferSize:function(a){this.maxFetchSize=Math.max(50,parseInt(this.options.largeBufferSize*a,10));
4132 this.nearLimit=parseInt(this.options.nearLimitFactor*a,10);
4133 this.maxBufferSize=this.maxFetchSize*3
4134 },restartSessionTimer:function(){if(this.sessionExpired==true){return
4135 }this.sessionEndTime=(new Date()).getTime()+this.options.TimeOut*60000;
4136 if(this.sessionTimer){clearTimeout(this.sessionTimer)
4137 }this.updateSessionTimer()
4138 },updateSessionTimer:function(){var b=(new Date()).getTime();
4139 if(b>this.sessionEndTime){this.displaySessionTimer(Rico.getPhraseById("sessionExpired"));
4140 this.timerMsg.style.backgroundColor="red";
4141 this.sessionExpired=true
4142 }else{var a=Math.ceil((this.sessionEndTime-b)/60000);
4143 this.displaySessionTimer(a);
4144 this.sessionTimer=Rico.runLater(10000,this,"updateSessionTimer")
4145 }},displaySessionTimer:function(a){this.timerMsg.innerHTML="&nbsp;"+a+"&nbsp;"
4146 },refresh:function(b){var a=this.liveGrid.lastRowPos;
4147 this.clear();
4148 if(b){this.setTotalRows(0);
4149 this.foundRowCount=false
4150 }this.liveGrid.clearBookmark();
4151 this.liveGrid.clearRows();
4152 this.fetch(a)
4153 },fetch:function(e){Rico.log("AjaxSQL fetch: offset="+e+", lastOffset="+this.lastOffset);
4154 if(this.processingRequest){Rico.log("AjaxSQL fetch: queue request");
4155 this.pendingRequest=e;
4156 return
4157 }if(e<0){this.clear();
4158 this.setTotalRows(0);
4159 this.foundRowCount=false;
4160 e=0
4161 }var d=this.lastOffset;
4162 this.lastOffset=e;
4163 if(this.isInRange(e)){Rico.log("AjaxSQL fetch: in buffer");
4164 this.liveGrid.refreshContents(e);
4165 if(e>d){if(e+this.liveGrid.pageSize<this.endPos()-this.nearLimit){return
4166 }if(this.endPos()==this.totalRows&&this.foundRowCount){return
4167 }}else{if(e<d){if(e>this.startPos+this.nearLimit){return
4168 }if(this.startPos==0){return
4169 }}else{return
4170 }}}if(e>=this.totalRows&&this.foundRowCount){return
4171 }this.processingRequest=true;
4172 Rico.log("AjaxSQL fetch: processing offset="+e);
4173 var c=this.getFetchOffset(e);
4174 var a=this.getFetchSize(c);
4175 var f=false;
4176 this.liveGrid.showMsg(this.options.waitMsg);
4177 this.timeoutHandler=Rico.runLater(this.options.bufferTimeout,this,"handleTimedOut");
4178 this.ajaxOptions.parameters=this.formQueryHashSQL(c,a,this.options.fmt);
4179 this.requestCount++;
4180 Rico.log("sending req #"+this.requestCount);
4181 var b=this;
4182 if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=function(g){b.ajaxUpdate(c,g)
4183 };
4184 new Rico.ajaxRequest(this.dataSource,this.ajaxOptions)
4185 }else{this.ajaxOptions.onComplete=function(h,j,g,i){b.jsUpdate(c,h,j,g,i)
4186 };
4187 this.dataSource(this.ajaxOptions)
4188 }},formQueryHashSQL:function(g,h,d){var k=this.formQueryHashXML(g,h);
4189 k[this.liveGrid.actionId]="query";
4190 if(d){k._fmt=d
4191 }Rico.extend(k,this.sortParm);
4192 for(var b=0;
4193 b<this.liveGrid.columns.length;
4194 b++){var j=this.liveGrid.columns[b];
4195 if(j.filterType==Rico.ColumnConst.UNFILTERED){continue
4196 }var a=typeof(j.format.filterCol)=="number"?j.format.filterCol:j.index;
4197 k["f["+a+"][op]"]=j.filterOp;
4198 k["f["+a+"][len]"]=j.filterValues.length;
4199 for(var e=0;
4200 e<j.filterValues.length;
4201 e++){var f=j.filterValues[e];
4202 if(j.filterOp=="LIKE"&&f.indexOf("*")==-1){f="*"+f+"*"
4203 }k["f["+a+"]["+e+"]"]=f
4204 }}return k
4205 },getFetchSize:function(a){var b=0;
4206 if(a>=this.startPos){var c=this.maxFetchSize+a;
4207 b=c-a;
4208 if(a==0&&b<this.maxFetchSize){b=this.maxFetchSize
4209 }Rico.log("getFetchSize/append, adjustedSize="+b+" adjustedOffset="+a+" endFetchOffset="+c)
4210 }else{b=Math.min(this.startPos-a,this.maxFetchSize)
4211 }return b
4212 },getFetchOffset:function(b){var a=b;
4213 if(b>this.startPos){a=Math.max(b,this.endPos())
4214 }else{if(b+this.maxFetchSize>=this.startPos){a=Math.max(this.startPos-this.maxFetchSize,0)
4215 }}return a
4216 },updateBuffer:function(d,a,b){Rico.log("updateBuffer: start="+d+", # of rows="+this.rcvdRows);
4217 if(this.rows.length==0){this.rows=a;
4218 this.attr=b;
4219 this.startPos=d
4220 }else{if(d>this.startPos){if(this.startPos+this.rows.length<d){this.rows=a;
4221 this.attr=b;
4222 this.startPos=d
4223 }else{this.rows=this.rows.concat(a.slice(0,a.length));
4224 if(this.attr){this.attr=this.attr.concat(b.slice(0,b.length))
4225 }if(this.rows.length>this.maxBufferSize){var c=this.rows.length;
4226 this.rows=this.rows.slice(this.rows.length-this.maxBufferSize,this.rows.length);
4227 if(this.attr){this.attr=this.attr.slice(this.attr.length-this.maxBufferSize,this.attr.length)
4228 }this.startPos=this.startPos+(c-this.rows.length)
4229 }}}else{if(d+a.length<this.startPos){this.rows=a
4230 }else{this.rows=a.slice(0,this.startPos).concat(this.rows);
4231 if(this.maxBufferSize&&this.rows.length>this.maxBufferSize){this.rows=this.rows.slice(0,this.maxBufferSize)
4232 }}this.startPos=d
4233 }}this.size=this.rows.length
4234 },sortBuffer:function(b){this.sortParm={};
4235 var a=this.liveGrid.columns[b];
4236 if(this.options.sortParmFmt){this.sortParm.sort_col=a[this.options.sortParmFmt];
4237 this.sortParm.sort_dir=a.getSortDirection()
4238 }else{this.sortParm["s"+b]=a.getSortDirection()
4239 }this.clear()
4240 },printAllSQL:function(a){var c=this.formQueryHashSQL(0,this.liveGrid.options.maxPrint,a);
4241 c.hidden=this.liveGrid.listInvisible("index").join(",");
4242 var b=this.dataSource+"?"+Rico.toQueryString(c);
4243 window.open(b,"",this.liveGrid.options.exportWindow)
4244 },printVisibleSQL:function(a){var c=this.formQueryHashSQL(this.liveGrid.contentStartPos-1,this.liveGrid.pageSize,a);
4245 c.hidden=this.liveGrid.listInvisible("index").join(",");
4246 var b=this.dataSource+"?"+Rico.toQueryString(c);
4247 window.open(b,"",this.liveGrid.options.exportWindow)
4248 },_printAll:function(){this.liveGrid.exportStart();
4249 this.ajaxOptions.parameters=this.formQueryHashSQL(0,this.liveGrid.options.maxPrint);
4250 var a=this;
4251 this.ajaxOptions.onComplete=function(){a._jsExport()
4252 };
4253 this.dataSource(this.ajaxOptions)
4254 },_jsExport:function(b,d,a,c){Rico.log("_jsExport: "+arguments.length);
4255 if(c){Rico.log("_jsExport: received error="+c);
4256 this.liveGrid.showMsg(Rico.getPhraseById("requestError",c));
4257 return
4258 }this.exportBuffer(b,0);
4259 this.liveGrid.exportFinish()
4260 }};
4261 if(typeof Rico=="undefined"){throw ("LiveGridForms requires the Rico JavaScript framework")
4262 }Rico.TableEdit=function(a){this.initialize(a)
4263 };
4264 Rico.TableEdit.prototype={initialize:function(b){Rico.log("Rico.TableEdit initialize: "+b.tableId);
4265 this.grid=b;
4266 this.options={maxDisplayLen:20,panelHeight:200,panelWidth:500,compact:false,RecordName:Rico.getPhraseById("record"),updateURL:window.location.href,showSaveMsg:"errors"};
4267 Rico.extend(this.options,b.options);
4268 var a=this;
4269 this.hasWF2=(document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("WebForms","2.0"));
4270 this.menu=b.menu;
4271 this.menu.options.dataMenuHandler=function(d,f,g,e){return a.editMenu(d,f,g,e)
4272 };
4273 this.menu.ignoreClicks();
4274 this.editText=Rico.getPhraseById("editRecord",this.options.RecordName);
4275 this.cloneText=Rico.getPhraseById("cloneRecord",this.options.RecordName);
4276 this.delText=Rico.getPhraseById("deleteRecord",this.options.RecordName);
4277 this.addText=Rico.getPhraseById("addRecord",this.options.RecordName);
4278 this.buttonHover=new Rico.HoverSet();
4279 this.dateRegExp=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
4280 Rico.EditControls.atLoad();
4281 this.createKeyArray();
4282 this.createEditDiv();
4283 this.saveMsg=Rico.$(b.tableId+"_savemsg");
4284 Rico.eventBind(document,"click",Rico.eventHandle(this,"clearSaveMsg"));
4285 this.extraMenuItems=[];
4286 this.responseHandler=function(){a.processResponse()
4287 };
4288 Rico.log("Rico.TableEdit.initialize complete, hasWF2="+this.hasWF2)
4289 },createKeyArray:function(){this.keys=[];
4290 for(var a=0;
4291 a<this.grid.columns.length;
4292 a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.isKey){this.keys.push({colidx:a})
4293 }}},createEditDiv:function(){this.requestCount=1;
4294 this.formPopup=this.createWindow();
4295 Rico.addClass(this.formPopup.content.parentNode,"ricoLG_editDiv");
4296 if(this.options.canEdit||this.options.canAdd){this.startForm();
4297 this.createForm(this.form)
4298 }else{var a=this.createButton(Rico.getPhraseById("close"));
4299 Rico.eventBind(a,"click",Rico.eventHandle(this,"cancelEdit"),false);
4300 this.createForm(this.formPopup.contentDiv)
4301 }this.editDivCreated=true;
4302 this.responseDialog=this.grid.createDiv("editResponse",document.body);
4303 this.responseDialog.style.display="none";
4304 var b=document.createElement("button");
4305 b.appendChild(document.createTextNode("OK"));
4306 Rico.eventBind(b,"click",Rico.eventHandle(this,"ackResponse"));
4307 this.responseDialog.appendChild(b);
4308 this.responseDiv=this.grid.createDiv("editResponseText",this.responseDialog);
4309 if(this.panelGroup){Rico.log("createEditDiv complete, requestCount="+this.requestCount);
4310 Rico.runLater(50,this,"initPanelGroup")
4311 }},createWindow:function(){var a=this;
4312 return new Rico.Window("",{closeFunc:function(){a.makeFormInvisible()
4313 },overflow:this.options.panels?"hidden":"auto"})
4314 },initPanelGroup:function(){this.requestCount--;
4315 Rico.log("initPanelGroup: "+this.requestCount);
4316 if(this.requestCount>0){return
4317 }var a=parseInt(this.options.panelWidth,10);
4318 if(this.form){if(Rico.isWebKit){this.formPopup.container.style.display="block"
4319 }this.options.bgColor=Rico.Color.createColorFromBackground(this.form).toString()
4320 }this.formPopup.container.style.display="none";
4321 this.formPanels=new Rico.TabbedPanel(this.panelGroup,this.options)
4322 },notEmpty:function(a){return typeof(a)!="undefined"
4323 },startForm:function(){this.form=document.createElement("form");
4324 this.form.onsubmit=function(){return false
4325 };
4326 this.form.autocomplete="off";
4327 this.formPopup.contentDiv.appendChild(this.form);
4328 var e=document.createElement("div");
4329 e.className="ButtonBar";
4330 var d=e.appendChild(this.createButton(Rico.getPhraseById("saveRecord",this.options.RecordName)));
4331 Rico.eventBind(d,"click",Rico.eventHandle(this,"TESubmit"),false);
4332 d=e.appendChild(this.createButton(Rico.getPhraseById("cancel")));
4333 Rico.eventBind(d,"click",Rico.eventHandle(this,"cancelEdit"),false);
4334 this.form.appendChild(e);
4335 this.hiddenFields=document.createElement("div");
4336 this.hiddenFields.style.display="none";
4337 this.action=this.appendHiddenField(this.grid.actionId,"");
4338 var c,a;
4339 for(c=0;
4340 c<this.grid.columns.length;
4341 c++){a=this.grid.columns[c].format;
4342 if(a&&a.FormView&&a.FormView=="hidden"){this.appendHiddenField(a.FieldName,a.ColData)
4343 }}for(var b=0;
4344 b<this.keys.length;
4345 b++){this.keys[b].keyField=this.appendHiddenField("_k"+this.keys[b].colidx,"")
4346 }this.form.appendChild(this.hiddenFields)
4347 },createButton:function(b){var a=document.createElement("a");
4348 a.href="javascript:void(0)";
4349 a.innerHTML=b;
4350 a.className="RicoButton";
4351 if(Rico.theme.button){Rico.addClass(a,Rico.theme.button)
4352 }this.buttonHover.add(a);
4353 return a
4354 },createPanel:function(c){var e=false;
4355 for(var b=0;
4356 b<this.grid.columns.length;
4357 b++){var a=this.grid.columns[b].format;
4358 if(!a){continue
4359 }if(!a.EntryType){continue
4360 }if(a.EntryType=="H"){continue
4361 }if(a.FormView&&a.FormView=="hidden"){continue
4362 }var d=a.panelIdx||0;
4363 if(d==c){e=true;
4364 break
4365 }}if(!e){return null
4366 }this.panelHdr[c]=document.createElement("li");
4367 this.panelHdr[c].innerHTML=this.options.panels[c];
4368 this.panelHdrs.appendChild(this.panelHdr[c]);
4369 this.panelContent[c]=document.createElement("div");
4370 this.panelContents.appendChild(this.panelContent[c]);
4371 this.panelActualIdx[c]=this.panelCnt++;
4372 return this.createFormTable(this.panelContent[c],"tabContent")
4373 },createForm:function(e){var c,f,a,d,b=[];
4374 this.panelCnt=0;
4375 this.panelHdr=[];
4376 this.panelContent=[];
4377 if(this.options.panels){this.panelGroup=document.createElement("div");
4378 this.panelGroup.className="tabPanelGroup";
4379 this.panelHdrs=document.createElement("ul");
4380 this.panelGroup.appendChild(this.panelHdrs);
4381 this.panelContents=document.createElement("div");
4382 this.panelContents.className="tabContentContainer";
4383 this.panelGroup.appendChild(this.panelContents);
4384 this.panelActualIdx=[];
4385 e.appendChild(this.panelGroup);
4386 if(this.grid.direction=="rtl"){for(c=this.options.panels.length-1;
4387 c>=0;
4388 c--){b[c]=this.createPanel(c)
4389 }}else{for(c=0;
4390 c<this.options.panels.length;
4391 c++){b[c]=this.createPanel(c)
4392 }}e.appendChild(this.panelGroup)
4393 }else{f=document.createElement("div");
4394 f.className="noTabContent";
4395 b[0]=this.createFormTable(f);
4396 e.appendChild(f)
4397 }for(c=0;
4398 c<this.grid.columns.length;
4399 c++){a=this.grid.columns[c].format;
4400 if(!a){continue
4401 }d=a.panelIdx||0;
4402 if(b[d]){this.appendFormField(this.grid.columns[c],b[d])
4403 }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))$/;
4404 break;
4405 case"float-unsigned":a.regexp=/^\d+(\.\d+)?$/;
4406 break;
4407 case"float-signed":a.regexp=/^[-+]?\d+(\.\d+)?$/;
4408 break;
4409 case"int-unsigned":a.regexp=/^\d+$/;
4410 break;
4411 case"int-signed":a.regexp=/^[-+]?\d+$/;
4412 break;
4413 default:a.regexp=new RegExp(a.pattern);
4414 break
4415 }}}},createFormTable:function(b){var a=document.createElement("table");
4416 a.border=0;
4417 b.appendChild(a);
4418 return a
4419 },appendHiddenField:function(a,b){var c=Rico.createFormField(this.hiddenFields,"input","hidden",a,a);
4420 c.value=b;
4421 return c
4422 },appendFormField:function(c,i){var b=c.format;
4423 if(!b.EntryType){return
4424 }if(b.EntryType=="H"){return
4425 }if(b.FormView){return
4426 }Rico.log("appendFormField: "+c.displayName+" - "+b.EntryType);
4427 var j=b.noFormBreak&&i.rows.length>0?i.rows[i.rows.length-1]:i.insertRow(-1);
4428 var h=j.insertCell(-1);
4429 c.formLabel=h;
4430 if(h.noWrap){h.noWrap=true
4431 }var f=j.insertCell(-1);
4432 if(f.noWrap){f.noWrap=true
4433 }h.id="lbl_"+b.FieldName;
4434 var e,a=b.FieldName;
4435 switch(b.EntryType){case"TA":case"tinyMCE":e=Rico.createFormField(f,"textarea",null,a);
4436 e.cols=b.TxtAreaCols;
4437 e.rows=b.TxtAreaRows;
4438 e.innerHTML=b.ColData;
4439 h.style.verticalAlign="top";
4440 break;
4441 case"R":case"RL":e=Rico.createFormField(f,"div",null,a);
4442 if(b.DescriptionField){e.RicoUpdate=b.DescriptionField
4443 }if(b.MultiSelect){Rico.addClass(e,"MultiSelect")
4444 }if(b.isNullable&&!b.MultiSelect){this.addSelectNone(e)
4445 }this.selectValuesRequest(e,c);
4446 break;
4447 case"N":e=Rico.createFormField(f,"select",null,a);
4448 if(b.isNullable){this.addSelectNone(e)
4449 }Rico.eventBind(e,"change",Rico.eventHandle(this,"checkSelectNew"));
4450 this.selectValuesRequest(e,c);
4451 e=document.createElement("span");
4452 e.className="ricoEditLabel";
4453 e.id="labelnew__"+b.FieldName;
4454 e.innerHTML="&nbsp;&nbsp;&nbsp;"+Rico.getPhraseById("formNewValue").replace(" ","&nbsp;");
4455 f.appendChild(e);
4456 a="textnew__"+b.FieldName;
4457 e=Rico.createFormField(f,"input","text",a,a);
4458 break;
4459 case"S":case"SL":if(b.ReadOnly){e=Rico.createFormField(f,"input","text",a,a);
4460 this.initField(e,b)
4461 }else{e=Rico.createFormField(f,"select",null,a);
4462 if(b.MultiSelect){e.multiple=true
4463 }if(b.SelectRows){e.size=parseInt(b.SelectRows,10)
4464 }if(b.isNullable&&!b.MultiSelect){this.addSelectNone(e)
4465 }if(b.DescriptionField){e.RicoUpdate=b.DescriptionField;
4466 Rico.eventBind(e,"change",Rico.eventHandle(this,"selectClick"),false)
4467 }this.selectValuesRequest(e,c)
4468 }break;
4469 case"D":if(!b.isNullable){b.required=true
4470 }if(!b.dateFmt){b.dateFmt=Rico.dateFmt
4471 }if(!b.Help){b.Help=b.dateFmt
4472 }if(typeof b.min=="string"){b.min=Rico.setISO8601(b.min)||new Date(b.min)
4473 }if(typeof b.max=="string"){b.max=Rico.setISO8601(b.max)||new Date(b.max)
4474 }if(this.hasWF2){e=Rico.createFormField(f,"input","date",a,a);
4475 e.required=b.required;
4476 if(b.min){e.min=Rico.toISO8601String(b.min,3)
4477 }if(b.max){e.max=Rico.toISO8601String(b.max,3)
4478 }e.required=b.required;
4479 b.SelectCtl=null
4480 }else{e=Rico.createFormField(f,"input","text",a,a)
4481 }this.initField(e,b);
4482 break;
4483 case"I":if(!b.isNullable){b.required=true
4484 }if(!b.pattern){b.pattern="int-signed"
4485 }if(this.hasWF2){e=Rico.createFormField(f,"input","number",a,a);
4486 e.required=b.required;
4487 e.min=b.min;
4488 e.max=b.max;
4489 e.step=1
4490 }else{e=Rico.createFormField(f,"input","text",a,a)
4491 }if(typeof b.min=="string"){b.min=parseInt(b.min,10)
4492 }if(typeof b.max=="string"){b.max=parseInt(b.max,10)
4493 }this.initField(e,b);
4494 break;
4495 case"F":if(!b.isNullable){b.required=true
4496 }if(!b.pattern){b.pattern="float-signed"
4497 }e=Rico.createFormField(f,"input","text",a,a);
4498 this.initField(e,b);
4499 if(typeof b.min=="string"){b.min=parseFloat(b.min)
4500 }if(typeof b.max=="string"){b.max=parseFloat(b.max)
4501 }break;
4502 default:e=Rico.createFormField(f,"input","text",a,a);
4503 if(!b.isNullable&&b.EntryType!="T"){b.required=true
4504 }this.initField(e,b);
4505 break
4506 }if(e&&b.SelectCtl){Rico.EditControls.applyTo(c,e)
4507 }var g="";
4508 h.className="ricoEditLabel";
4509 if(b.Help){h.title=b.Help;
4510 g="&nbsp;<span class='rico-icon rico-info'></span>"
4511 }var d=b.EntryType.length>1&&b.EntryType.charAt(1)=="L"?c.next.displayName:c.displayName;
4512 h.innerHTML=d+g
4513 },addSelectNone:function(a){this.addSelectOption(a,this.options.TableSelectNone,Rico.getPhraseById("selectNone"))
4514 },initField:function(b,a){if(a.Length){b.maxLength=a.Length;
4515 b.size=Math.min(a.Length,this.options.maxDisplayLen)
4516 }b.value=a.ColData
4517 },selectClick:function(c){var b=Rico.eventElement(c);
4518 if(b.readOnly){Rico.eventStop(c);
4519 return false
4520 }if(b.RicoUpdate){var a=b.options[b.selectedIndex];
4521 Rico.$(b.RicoUpdate).value=a.innerHTML
4522 }},radioClick:function(c){var b=Rico.eventElement(c);
4523 if(b.readOnly){Rico.eventStop(c);
4524 return false
4525 }var a=Rico.getParentByTagName(b,"div");
4526 if(a.RicoUpdate){Rico.$(a.RicoUpdate).value=b.nextSibling.innerHTML
4527 }},checkSelectNew:function(a){this.updateSelectNew(Rico.eventElement(a))
4528 },updateSelectNew:function(b){var a=(b.value==this.options.TableSelectNew)?"":"hidden";
4529 Rico.$("labelnew__"+b.id).style.visibility=a;
4530 Rico.$("textnew__"+b.id).style.visibility=a
4531 },selectValuesRequest:function(g,f){var a=f.format;
4532 if(a.SelectValues){var b=a.SelectValues.split(",");
4533 for(var e=0;
4534 e<b.length;
4535 e++){this.addSelectOption(g,b[e],b[e],e)
4536 }}else{this.requestCount++;
4537 var d={},c=this;
4538 Rico.extend(d,this.grid.buffer.ajaxOptions);
4539 d.parameters={id:this.grid.tableId,offset:"0",page_size:"-1",edit:f.index};
4540 d.parameters[this.grid.actionId]="query";
4541 d.onComplete=function(h){c.selectValuesUpdate(g,h)
4542 };
4543 new Rico.ajaxRequest(this.grid.buffer.dataSource,d);
4544 Rico.log("selectValuesRequest: "+a.FieldName)
4545 }},selectValuesUpdate:function(a,c){var b=c.responseXML.getElementsByTagName("ajax-response");
4546 Rico.log("selectValuesUpdate: "+c.status);
4547 if(b==null||b.length!=1){return
4548 }b=b[0];
4549 var j=b.getElementsByTagName("error");
4550 if(j.length>0){var g=Rico.getContentAsString(j[0],this.grid.buffer.isEncoded);
4551 Rico.log("Data provider returned an error:\n"+g);
4552 alert(Rico.getPhraseById("requestError",g));
4553 return
4554 }b=b.getElementsByTagName("response")[0];
4555 var h=b.getElementsByTagName("rows")[0];
4556 var k=this.grid.buffer.dom2jstable(h);
4557 Rico.log("selectValuesUpdate: id="+a.id+" rows="+k.length);
4558 for(var e=0;
4559 e<k.length;
4560 e++){if(k[e].length>0){var f=k[e][0];
4561 var d=(k[e].length>1)?k[e][1]:f;
4562 this.addSelectOption(a,f,d,e)
4563 }}if(Rico.$("textnew__"+a.id)){this.addSelectOption(a,this.options.TableSelectNew,Rico.getPhraseById("selectNewVal"))
4564 }if(this.panelGroup){Rico.runLater(50,this,"initPanelGroup")
4565 }},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);
4566 b.value=e;
4567 var d=document.createElement("label");
4568 d.innerHTML=f;
4569 d.htmlFor=b.id;
4570 c.appendChild(d);
4571 Rico.eventBind(b,"click",Rico.eventHandle(this,"radioClick"),false);
4572 break;
4573 case"select":Rico.addSelectOption(c,e,f);
4574 break
4575 }},clearSaveMsg:function(){if(this.saveMsg){this.saveMsg.innerHTML=""
4576 }},addMenuItem:function(c,b,a){this.extraMenuItems.push({menuText:c,menuAction:b,enabled:a})
4577 },editMenu:function(d,h,j,e){this.clearSaveMsg();
4578 if(this.grid.buffer.sessionExpired==true||this.grid.buffer.startPos<0){return false
4579 }this.rowIdx=h;
4580 var g=Rico.$("pageTitle");
4581 var f=g?g.innerHTML:document.title;
4582 this.menu.addMenuHeading(f);
4583 var a=this;
4584 if(e==false){for(var b=0;
4585 b<this.extraMenuItems.length;
4586 b++){this.menu.addMenuItem(this.extraMenuItems[b].menuText,this.extraMenuItems[b].menuAction,this.extraMenuItems[b].enabled)
4587 }this.menu.addMenuItem(this.editText,function(){a.editRecord()
4588 },this.canEdit(h));
4589 this.menu.addMenuItem(this.delText,function(){a.deleteRecord()
4590 },this.canDelete(h));
4591 if(this.options.canClone){this.menu.addMenuItem(this.cloneText,function(){a.cloneRecord()
4592 },this.canAdd(h)&&this.canEdit(h))
4593 }}this.menu.addMenuItem(this.addText,function(){a.addRecord()
4594 },this.canAdd(h));
4595 return true
4596 },canAdd:function(a){return(typeof this.options.canAdd=="function")?this.options.canAdd(a):this.options.canAdd
4597 },canEdit:function(a){return(typeof this.options.canEdit=="function")?this.options.canEdit(a):this.options.canEdit
4598 },canDelete:function(a){return(typeof this.options.canDelete=="function")?this.options.canDelete(a):this.options.canDelete
4599 },cancelEdit:function(a){Rico.eventStop(a);
4600 this.makeFormInvisible();
4601 this.grid.highlightEnabled=true;
4602 this.menu.cancelmenu();
4603 return false
4604 },setField:function(g,m){var p=this.grid.columns[g].format;
4605 var k=Rico.$(p.FieldName);
4606 var n,j,f,c,b,h;
4607 if(!k){return
4608 }Rico.log("setField: "+p.FieldName+"="+m);
4609 switch(k.tagName.toUpperCase()){case"DIV":c=k.getElementsByTagName("INPUT");
4610 f={};
4611 if(p.MultiSelect&&m){n=m.split(",");
4612 for(var j=0;
4613 j<n.length;
4614 j++){f[n[j]]=1
4615 }}else{f[m]=1
4616 }for(j=0;
4617 j<c.length;
4618 j++){c[j].checked=f[c[j].value]==1
4619 }break;
4620 case"INPUT":if(p.EntryType=="D"&&m!=p.ColData){n=m.split(/\s|T/);
4621 m=n[0];
4622 if(this.isTextInput(k)){var l=Rico.setISO8601(m);
4623 if(l){m=Rico.formatDate(l,p.dateFmt)
4624 }}}k.value=m;
4625 break;
4626 case"SELECT":b=k.options;
4627 f={};
4628 if(p.MultiSelect&&m){n=m.split(",");
4629 for(var j=0;
4630 j<n.length;
4631 j++){f[n[j]]=1
4632 }for(j=0;
4633 j<b.length;
4634 j++){b[j].selected=f[b[j].value]==1
4635 }}else{for(j=0;
4636 j<b.length;
4637 j++){if(b[j].value==m){k.selectedIndex=j;
4638 break
4639 }}}if(p.EntryType=="N"){h=Rico.$("textnew__"+k.id);
4640 if(!h){alert('Warning: unable to find id "textnew__'+k.id+'"')
4641 }h.value=m;
4642 if(k.selectedIndex!=j){k.selectedIndex=b.length-1
4643 }this.updateSelectNew(k)
4644 }return;
4645 case"TEXTAREA":k.value=m;
4646 if(p.EntryType=="tinyMCE"&&typeof(tinyMCE)!="undefined"&&this.initialized){if(tinyMCE.updateContent){tinyMCE.updateContent(k.id)
4647 }else{tinyMCE.execInstanceCommand(k.id,"mceSetContent",false,m)
4648 }}return
4649 }},setReadOnly:function(h){for(var g,f=0;
4650 f<this.grid.columns.length;
4651 f++){var b=this.grid.columns[f].format;
4652 if(!b){continue
4653 }var k=Rico.$(b.FieldName);
4654 if(!k){continue
4655 }switch(h){case"ins":g=!b.Writeable||b.ReadOnly||b.UpdateOnly;
4656 break;
4657 case"upd":g=!b.Writeable||b.ReadOnly||b.InsertOnly;
4658 break;
4659 default:g=false;
4660 break
4661 }switch(k.tagName.toUpperCase()){case"DIV":var c=k.getElementsByTagName("INPUT");
4662 for(var d=0;
4663 d<c.length;
4664 d++){c[d].disabled=g
4665 }break;
4666 case"SELECT":if(b.EntryType=="N"){var a=Rico.$("textnew__"+k.id);
4667 a.disabled=g
4668 }k.disabled=g;
4669 break;
4670 case"TEXTAREA":case"INPUT":k.disabled=g;
4671 if(b.selectIcon){b.selectIcon.style.display=g?"none":""
4672 }break
4673 }}},hideResponse:function(a){this.responseDiv.innerHTML=a;
4674 this.responseDialog.style.display="none"
4675 },showResponse:function(){var a=Rico.cumulativeOffset(this.grid.outerDiv);
4676 a.top+=Rico.docScrollTop();
4677 this.responseDialog.style.top=a.top+"px";
4678 this.responseDialog.style.left=a.left+"px";
4679 this.responseDialog.style.display=""
4680 },processResponse:function(g){var d,f=true;
4681 Rico.log("Processing response from form submittal");
4682 this.responseDiv.innerHTML=g.responseText;
4683 var e=Rico.select(".ricoFormResponse",this.responseDiv);
4684 if(e){var c=Rico.trim(e[0].className).split(/\s+/)[1];
4685 d=Rico.getPhraseById(c,this.options.RecordName)
4686 }else{var b=this.responseDiv.childNodes;
4687 for(var a=b.length-1;
4688 a>=0;
4689 a--){if(b[a].nodeType==1&&b[a].nodeName!="P"&&b[a].nodeName!="DIV"&&b[a].nodeName!="BR"){this.responseDiv.removeChild(b[a])
4690 }}d=Rico.stripTags(this.responseDiv.innerHTML);
4691 f=(d.toLowerCase().indexOf("error")==-1)
4692 }if(f&&this.options.showSaveMsg!="full"){this.hideResponse("");
4693 this.grid.resetContents();
4694 this.grid.buffer.foundRowCount=false;
4695 this.grid.buffer.fetch(this.grid.lastRowPos||0);
4696 if(this.saveMsg){this.saveMsg.innerHTML="&nbsp;"+d+"&nbsp;"
4697 }}this.processCallback(this.options.onSubmitResponse);
4698 Rico.log("Processing response completed")
4699 },processCallback:function(callback){switch(typeof callback){case"string":return eval(callback);
4700 case"function":return callback()
4701 }},ackResponse:function(a){this.hideResponse("");
4702 this.grid.highlightEnabled=true
4703 },cloneRecord:function(){this.formPopup.setTitle(this.cloneText);
4704 this.displayEditForm("ins")
4705 },editRecord:function(){this.formPopup.setTitle(this.editText);
4706 this.displayEditForm("upd")
4707 },displayEditForm:function(e){this.grid.highlightEnabled=false;
4708 this.menu.cancelmenu();
4709 this.hideResponse(Rico.getPhraseById("saving"));
4710 this.grid.outerDiv.style.cursor="auto";
4711 this.action.value=e;
4712 for(var d=0;
4713 d<this.grid.columns.length;
4714 d++){var f=this.grid.columns[d];
4715 if(f.format){var b=f.getValue(this.rowIdx);
4716 this.setField(d,b);
4717 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)
4718 }b=f._format(b);
4719 if(b===""){b="&nbsp;"
4720 }f.format.selectDesc.innerHTML=b
4721 }if(f.format.SelectCtl){Rico.EditControls.displayClrImg(f,!f.format.InsertOnly)
4722 }}}this.setReadOnly(e);
4723 for(var a=0;
4724 a<this.keys.length;
4725 a++){this.keys[a].keyField.value=this.grid.buffer.getWindowValue(this.rowIdx,this.keys[a].colidx)
4726 }this.makeFormVisible(this.rowIdx)
4727 },addPrepare:function(){this.hideResponse(Rico.getPhraseById("saving"));
4728 this.form.reset();
4729 this.setReadOnly("ins");
4730 this.action.value="ins";
4731 for(var a=0;
4732 a<this.grid.columns.length;
4733 a++){var b=this.grid.columns[a];
4734 if(b.format){this.setField(a,b.format.ColData);
4735 if(b.format.SelectCtl){Rico.EditControls.resetValue(b);
4736 Rico.EditControls.displayClrImg(b,!b.format.UpdateOnly)
4737 }}}},addRecord:function(){this.menu.cancelmenu();
4738 this.formPopup.setTitle(this.addText);
4739 this.addPrepare();
4740 this.makeFormVisible(-1);
4741 if(this.formPanels){this.formPanels.select(0)
4742 }},drillDown:function(b,a,c){return this.grid.drillDown.apply(this.grid,arguments)
4743 },setDetailFilter:function(a,b){this.grid.setDetailFilter(a,b)
4744 },makeFormVisible:function(k){this.formPopup.container.style.display="block";
4745 var c=this.formPopup.container.offsetWidth;
4746 var h=Rico.cumulativeOffset(this.grid.outerDiv);
4747 var d=Rico.windowWidth();
4748 this.formPopup.container.style.left=c+h.left>d?(d-c)+"px":(h.left+1)+"px";
4749 var g=Rico.docScrollTop();
4750 var a=this.formPopup.container.offsetHeight;
4751 var f=h.top+this.grid.hdrHt+g;
4752 var b=Rico.windowHeight()+g;
4753 if(k>=0){f+=(k+1)*this.grid.rowHeight;
4754 if(f+a>b){f-=(a+this.grid.rowHeight)
4755 }}else{if(f+a>b){f=b-a-2
4756 }}if(this.processCallback(this.options.formOpen)===false){return
4757 }this.formPopup.openPopup(null,Math.max(f,g));
4758 this.formPopup.container.style.visibility="visible";
4759 Rico.EditControls.setZ(Rico.getStyle(this.formPopup.container,"zIndex"));
4760 if(this.initialized){return
4761 }var e,j;
4762 for(e=0;
4763 e<this.grid.columns.length;
4764 e++){j=this.grid.columns[e].format;
4765 if(!j||!j.EntryType||!j.FieldName){continue
4766 }switch(j.EntryType){case"tinyMCE":if(typeof tinyMCE!="undefined"){tinyMCE.execCommand("mceAddControl",true,j.FieldName)
4767 }break
4768 }}this.initialized=true
4769 },makeFormInvisible:function(){for(var a=0;
4770 a<this.grid.columns.length;
4771 a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.SelectCtl){Rico.EditControls.close(this.grid.columns[a].format.SelectCtl)
4772 }}this.formPopup.container.style.visibility="hidden";
4773 this.formPopup.closePopup();
4774 this.processCallback(this.options.formClose)
4775 },getConfirmDesc:function(a){return Rico.stripTags(this.grid.cell(a,this.options.ConfirmDeleteCol).innerHTML).replace("&nbsp;"," ")
4776 },deleteRecord:function(){this.menu.cancelmenu();
4777 var f;
4778 switch(this.options.ConfirmDeleteCol){case -1:f=Rico.getPhraseById("thisRecord",this.options.RecordName);
4779 break;
4780 case -2:for(var b=0;
4781 b<this.keys.length;
4782 b++){var c=this.keys[b].colidx;
4783 var a=this.grid.columns[c].format;
4784 if(a.EntryType.length>1&&a.EntryType.charAt(1)=="L"){c++
4785 }var e=Rico.stripTags(this.grid.cell(rowIdx,c).innerHTML).replace(/&nbsp;/g," ");
4786 if(f){f+=", "
4787 }f+=this.grid.columns[c].displayName+" "+e
4788 }break;
4789 default:f='"'+Rico.truncate(this.getConfirmDesc(this.rowIdx),50)+'"';
4790 break
4791 }if(!this.options.ConfirmDelete.valueOf||confirm(Rico.getPhraseById("confirmDelete",f))){this.hideResponse(Rico.getPhraseById("deleting"));
4792 this.showResponse();
4793 var d={};
4794 d[this.grid.actionId]="del";
4795 for(var b=0;
4796 b<this.keys.length;
4797 b++){var c=this.keys[b].colidx;
4798 var e=this.grid.columns[c].getValue(this.rowIdx);
4799 d["_k"+c]=e