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