	
/*
Copyright (c) 2001, 2008
Alpha Software, Inc.

This JavaScript library is licensed exclusively for use with Alpha Five, 
Alpha Five Application Server and Alpha Five Run Engine. It is specifically 
not licensed for use on a server that does not have installed on it, a 
licensed copy of the Alpha Five Application Server.
*/



function $(){if(arguments.length==1){var ele=arguments[0];if(typeof ele=='string'){if(document.getElementById(ele))ele=document.getElementById(ele);else if(document.getElementsByName(ele).length>0)ele=document.getElementsByName(ele);else ele=false;}
return ele;}else{var objArr=new Array();var ele=new Object();for(var i=0;i<arguments.length;i++){if(typeof ele=='string'){if(document.getElementById(arguments[i]))ele=document.getElementById(arguments[i]);else if(document.getElementsByName(arguments[i]).length>0)ele=document.getElementsByName(arguments[i]);else ele=false;}
objArr[i]=ele;}
return objArr;}}
function $n(){if(arguments.length==1){var ele=arguments[0];if(typeof ele=='string'){if(document.getElementsByName(ele).length>0)ele=document.getElementsByName(ele);else if(document.getElementById(ele))ele=[document.getElementById(ele)];else ele=[];}
return ele;}else{var objArr=new Array();for(var i=0;i<arguments.length;i++){var ele=arguments[i];if(document.getElementsByName(ele).length>0)ele=document.getElementsByName(ele);else if(document.getElementById(ele))ele=[document.getElementById(ele)];else ele=[];objArr[i]=ele;}
return objArr;}}
function $isChild(ele,pEle){ele=$(ele);pEle=$(pEle);while(ele.tagName.toLowerCase()!='body'){if(ele==pEle)return true;ele=ele.parentNode;}
return false;}
function $cetp(eles,pEle){if(eles.tagName){if($isChild(eles,pEle))return eles;else return false;}else{var eles2=new Array();for(var i=0;i<eles.length;i++){if($isChild(eles[i],pEle)){eles2.push(eles[i]);}}
if(eles2.length>0)return eles2;else return false;}}
function $ae(obj,type,fn){if(obj.attachEvent){obj['e'+type+fn]=fn;obj[type+fn]=function(){obj['e'+type+fn](window.event);}
obj.attachEvent('on'+type,obj[type+fn]);}else
obj.addEventListener(type,fn,false);}
function $re(obj,type,fn){if(obj.detachEvent){obj.detachEvent('on'+type,obj[type+fn]);obj[type+fn]=null;}else
obj.removeEventListener(type,fn,false);}
function $ga(obj,att){if(typeof obj=='string')obj=$n(obj);var pEle=typeof arguments[2]!='undefined'?arguments[2]:false;if(pEle=='')pEle=false;if(pEle)obj=$cetp(obj,pEle);if(obj==false)return false;if(!obj.tagName){var attArr=new Array();for(var i=0;i<obj.length;i++){if(typeof obj[i]!='object')obj[i]=$(obj[i]);if(typeof att=='object'){for(var j=0;j<att.length;i++)
attArr[attArr.length]=obj[i].getAttribute(att[j]);}else{attArr[attArr.length]=obj[i].getAttribute(att);}}
return attArr;}else{if(typeof att=='object'){var attArr=new Array();for(var i=0;i<att.length;i++)
attArr[i]=obj.getAttribute(att[i]);return attArr;}else{return obj.getAttribute(att);}}}
function $sa(obj,att,val){if(typeof obj=='string')obj=$n(obj);var pEle=typeof arguments[3]!='undefined'?arguments[3]:false;if(pEle=='')pEle=false;if(pEle)obj=$cetp(obj,pEle);if(obj==false)return false;if(!obj.tagName){for(var i=0;i<obj.length;i++){if(typeof obj[i]!='object')obj[i]=$(obj[i]);if(typeof att=='object'){for(var j=0;j<att.length;i++)
obj[i].setAttribute(att[j],val[j]);}else{obj[i].setAttribute(att,val);}}}else{if(typeof att=='object'){for(var i=0;i<att.length;i++)
obj.setAttribute(att[i],val[i]);}else{obj.setAttribute(att,val);}}}
function $gv(obj){var pEle=typeof arguments[1]!='undefined'?arguments[1]:false;if(obj.constructor==Array){var objArr=new Array();var tag='';for(var i=0;i<obj.length;i++){objArr[i]=$gvs(obj[i],pEle);}
return objArr;}else{return $gvs(obj,pEle);}}
function $gvs(obj){var pEle=typeof arguments[1]!='undefined'?arguments[1]:false;if(pEle=='')pEle=false;var honorHTML=typeof arguments[2]!='undefined'?arguments[2]:true;if(typeof obj=='string')obj=$n(obj);if(obj.tagName)obj=[obj];if(pEle)obj=$cetp(obj,pEle);var tag='';var type='';var tArr=new Array();var notArray=false;for(var i=0;i<obj.length;i++){tag=obj[i].tagName.toLowerCase();if(tag=='input')type=obj[i].type.toLowerCase();else type='';if(type=='checkbox'||type=='radio'){if(obj[i].checked==true)tArr.push(obj[i].value);if((type=='checkbox'&&obj.length==1)||type=='radio')notArray=true;}else if(tag=='input'||tag=='textarea'){tArr.push(obj[i].value);notArray=true;}else if(tag=='select'){if(obj[i].multiple==true){for(var j=0;j<obj[i].options.length;j++){if(obj[i].options[j].selected==true)
tArr.push(obj[i].options[j].value);}}else{tArr.push(obj[i].value);notArray=true;}}else if(tag=='img'){tArr.push(obj[i].src);}else{if(honorHTML)tArr.push(obj[i].innerHTML);else if(obj[i].textContent)tArr.push(obj[i].textContent);else if(obj[i].innerText)tArr.push(obj[i].innerText);else tArr.push(obj[i].innerHTML);notArray=true;}}
if(notArray){if(tArr.length==0)return'';else return tArr[0];}else return tArr;}
function $sv(obj,val){var pEle=typeof arguments[2]!='undefined'?arguments[2]:false;if(obj.constructor==Array){if(typeof val=='object'){for(var i=0;i<obj.length;i++){$svs(obj[i],val[i],pEle);}}else{for(var i=0;i<obj.length;i++){$svs(obj[i],val,pEle);}}}else{$svs(obj,val,pEle);}}
function $svs(obj,val){var pEle=typeof arguments[2]!='undefined'?arguments[2]:false;if(pEle=='')pEle=false;var honorHTML=typeof arguments[3]!='undefined'?arguments[3]:true;if(typeof obj=='string')obj=$n(obj);if(obj.tagName)obj=[obj];if(pEle)obj=$cetp(obj,pEle);var tag='';var type='';var ele=new Object();for(var i=0;i<obj.length;i++){ele=obj[i];tag=ele.tagName.toLowerCase();if(tag=='input')type=ele.type.toLowerCase();else type='';if(type=='checkbox'||type=='radio'){if(val.constructor==Array){if($u.a.find(val,ele.value)!=-1)ele.checked=true;else ele.checked=false;}else if(typeof val=='boolean'){ele.checked=val;}else{if(ele.value==val)ele.checked=true;else ele.checked=false;}}else if(tag=='select'){if(val.constructor==Array){for(var j=0;j<ele.options.length;j++){if($u.a.find(val,ele.options[j].value)!=-1)ele.options[j].selected=true;else ele.options[j].selected=false;}}else{ele.value=val;}}else if(tag=='input'||tag=='textarea'){if(val.constructor==Array)ele.value=val.join('\n');else ele.value=val;}else if(tag=='img'){if(val.constructor==Array){if(val[0])ele.src=val[0];if(val[1])ele.title=val[1];}else ele.src=val;}else if(tag=='a'){if(val.constructor==Array){if(val[0]){if(honorHTML)ele.innerHTML=val[0];else ele.innerHTML=val[0].replace(/\n/g,'\n<br/>');}
if(val[1])ele.href=''+val[1];if(val[2])ele.title=val[2];}else{if(honorHTML)ele.innerHTML=val;else ele.innerHTML=val.replace(/\n/g,'\n<br/>');}}else{if(val.constructor==Array)val=val.join('\n');else val=''+val;if(honorHTML)ele.innerHTML=val;else ele.innerHTML=val.replace(/\n/g,'\n<br/>');}}}
function $gvById(obj){if(typeof obj=='object'){var objArr=new Array();for(var i=0;i<obj.length;i++)
objArr[i]=$gv($(obj[i]));return objArr;}else{return $gv($(obj));}}
function $svById(obj,val){if(typeof obj=='object'){for(var i=0;i<obj.length;i++)
$sv($(obj[i]),val[i]);}else{$sv($(obj),val);}}
function $gs(obj){if(typeof obj=='string')obj=$n(obj);var pEle=typeof arguments[1]!='undefined'?arguments[1]:false;if(pEle=='')pEle=false;if(pEle)obj=$cetp(obj,pEle);if(obj==false)return false;if(!obj.tagName){var styleArr=new Array();var tObj=new Object();for(var i=0;i<obj.length;i++){tObj=$(obj[i]);styleArr[styleArr.length]=tObj.style.cssText;}
return styleArr;}else{return obj.style.cssText;}}
function $ss(obj,styleObj){if(typeof obj=='string')obj=$n(obj);var pEle=typeof arguments[2]!='undefined'?arguments[2]:false;if(pEle=='')pEle=false;if(pEle)obj=$cetp(obj,pEle);if(obj==false)return false;if(!obj.tagName){var tObj=new Object();for(var i=0;i<obj.length;i++){tObj=$(obj[i]);if(typeof styleObj=='string')tObj.style.cssText=styleObj;else for(var prop in styleObj)tObj.style[prop]=styleObj[prop];}}else{if(typeof styleObj=='string')obj.style.cssText=styleObj;else for(var prop in styleObj)obj.style[prop]=styleObj[prop];}}
function $scn(obj,val){if(typeof obj=='string')obj=$n(obj);var pEle=typeof arguments[2]!='undefined'?arguments[2]:false;if(pEle=='')pEle=false;if(pEle)obj=$cetp(obj,pEle);if(obj==false)return false;if(!obj.tagName){var tObj=new Object();for(var i=0;i<obj.length;i++){tObj=$(obj[i]);tObj.className=val;}}else obj.className=val;}
function $acn(obj,val){if(typeof obj=='string')obj=$n(obj);var pEle=typeof arguments[2]!='undefined'?arguments[2]:false;if(pEle=='')pEle=false;if(pEle)obj=$cetp(obj,pEle);if(obj==false)return false;if(!obj.tagName){var tObj=new Object();for(var i=0;i<obj.length;i++){tObj=$(obj[i]);if(String(' '+tObj.className+' ').search(' '+val+' ')==-1)tObj.className=$u.s.aTrim(tObj.className+' '+val);}}else if(String(' '+obj.className+' ').search(' '+val+' ')==-1)obj.className=$u.s.lTrim(obj.className+' '+val);}
function $rcn(obj,val){if(typeof obj=='string')obj=$n(obj);var pEle=typeof arguments[2]!='undefined'?arguments[2]:false;if(pEle=='')pEle=false;if(pEle)obj=$cetp(obj,pEle);if(obj==false)return false;if(!obj.tagName){var tObj=new Object();for(var i=0;i<obj.length;i++){tObj=$(obj[i]);tObj.className=$u.s.aTrim($u.s.tran(' '+tObj.className+' ',' '+val+' ',' '));}}else obj.className=$u.s.aTrim($u.s.tran(' '+obj.className+' ',' '+val+' ',' '));}
function $cdn(obj){var n;if(typeof obj=='string'){n=document.createTextNode(obj);}else{n=document.createElement(obj.tagName);delete obj.tagName;if(obj.children){if(obj.children.constructor==Array){for(var i=0;i<obj.children.length;i++)n.appendChild($cdn(obj.children[i]));}else{n.appendChild($cdn(obj.children));}
delete obj.children;}
for(var attr in obj){if(attr!='style')n[attr]=obj[attr];else $ss(n,obj[attr]);}}
return n}
function $swto(objId){var obj=$(objId);var y=$gpt(obj);var x=$gpl(obj);window.scrollTo(x,y);}
function $sor(chObj,obj,type){type=type.toLowerCase();var w=obj.offsetWidth;var h=obj.offsetHeight;if(type!='hw'&&type!='h'){var wOff=arguments[3]?arguments[3]:0;var hOff=arguments[4]?arguments[4]:0;}else{var wOff=arguments[4]?arguments[4]:0;var hOff=arguments[3]?arguments[3]:0;}
if(wOff<1&&wOff>0)wOff=Math.round(w*Math.abs(wOff-1));if(hOff<1&&hOff>0)hOff=Math.round(h*Math.abs(hOff-1));if(type=='w')chObj.style.width=(w-wOff)+'px';else if(type=='h')chObj.style.height=(h-hOff)+'px';else if(type=='wh'||type=='hw'){chObj.style.width=(w-wOff)+'px';chObj.style.height=(h-hOff)+'px';}}
function $gpl(obj){var ignoreNonPos=typeof arguments[1]!='undefined'?arguments[1]:false;var lPos=obj.offsetLeft;if(ignoreNonPos&&!(obj.style.position=='absolute'||obj.style.position=='relative'))lPos=0;var pEle=obj.offsetParent;while(pEle!=null){if(!ignoreNonPos)lPos+=pEle.offsetLeft;else if(ignoreNonPos&&(pEle.style.position=='absolute'||pEle.style.position=='relative'))lPos+=pEle.offsetLeft;pEle=pEle.offsetParent;}
pEle=obj.parentNode;if(pEle.tagName.toLowerCase()!='html'&&pEle.tagName.toLowerCase()!='body'){while(pEle.tagName.toLowerCase()!='body'){if(!ignoreNonPos)lPos-=pEle.scrollLeft;else if(ignoreNonPos&&(pEle.style.position=='absolute'||pEle.style.position=='relative'))lPos-=pEle.scrollLeft;pEle=pEle.parentNode;}}
return lPos;}
function $gpt(obj){var ignoreNonPos=typeof arguments[1]!='undefined'?arguments[1]:false;var tPos=obj.offsetTop;if(ignoreNonPos&&!(obj.style.position=='absolute'||obj.style.position=='relative'))tPos=0;var pEle=obj.offsetParent;while(pEle!=null){if(!ignoreNonPos)tPos+=pEle.offsetTop;else if(ignoreNonPos&&(pEle.style.position=='absolute'||pEle.style.position=='relative'))tPos+=pEle.offsetTop;pEle=pEle.offsetParent;}
pEle=obj.parentNode;if(pEle.tagName.toLowerCase()!='html'&&pEle.tagName.toLowerCase()!='body'){while(pEle.tagName.toLowerCase()!='body'){if(!ignoreNonPos)tPos-=pEle.scrollTop;else if(ignoreNonPos&&(pEle.style.position=='absolute'||pEle.style.position=='relative'))tPos-=pEle.scrollTop;pEle=pEle.parentNode;}}
return tPos;}
function $po(chObj,obj,type){var mOff=arguments[3]?arguments[3]:0;var sOff=arguments[4]?arguments[4]:0;var pTop=$gpt(obj);var pLeft=$gpl(obj);var pWidth=obj.offsetWidth;var pHeight=obj.offsetHeight;var cTop=$gpt(chObj.parentNode,true);var cLeft=$gpl(chObj.parentNode,true);var cWidth=chObj.offsetWidth;var cHeight=chObj.offsetHeight;if(isNaN(type)){if(typeof type=='string'){type=type.toLowerCase();if(typeof window.innerWidth=='number'){var pageWidth=window.innerWidth;var pageHeight=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){var pageWidth=document.documentElement.clientWidth;var pageHeight=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){var pageWidth=document.body.clientWidth;var pageHeight=document.body.clientHeight;}
if(typeof window.pageYOffset=='number'){pageWidth=pageWidth+window.pageXOffset;pageHeight=pageHeight+window.pageYOffset;}else if(document.documentElement&&typeof document.documentElement.scrollLeft!='undefined'){pageWidth=pageWidth+document.documentElement.scrollLeft;pageHeight=pageHeight+document.documentElement.scrollTop;}else if(document.body&&typeof document.body.scrollLeft!='undefined'){pageWidth=pageWidth+document.body.scrollLeft;pageHeight=pageHeight+document.body.scrollTop;}
if(type=='dropdown'){type=14;if(pTop+pHeight+cHeight>pageHeight&&pTop-cHeight>0)type=2;if((pLeft+sOff)+cWidth>pageWidth)pLeft=(pageWidth-cWidth)-sOff;}else if(type=='dropdown-right'){type=15;if(pTop+pHeight+cHeight>pageHeight&&pTop-cHeight>0)type=3;if((pLeft+(pWidth-cWidth)-sOff)<0)pLeft=(cWidth-pWidth)+sOff;}else if(type=='flyout'){type=8;if(pLeft+pWidth+cWidth>pageWidth&&pLeft-cWidth>0)type=5;if((pTop+sOff)+cHeight>pageHeight)pTop=(pageHeight-cHeight)-sOff;}else if(type=='flyout-bottom'){type=12;if(pLeft+pWidth+cWidth>pageWidth&&pLeft-cWidth>0)type=9;if((pTop-(cHeight-pHeight)-sOff)<0)pTop=(cHeight-pHeight)+sOff;}else if(type=='popup'){type=6;if(pTop+cHeight>pageHeight&&pTop-cHeight>0)type=10;if((pLeft+sOff)+cWidth>pageWidth)pLeft=(pageWidth-cWidth)-sOff;}else if(type=='popup-bottom'){type=10;if((pTop-(cHeight-pHeight)-sOff)<0)pTop=(cHeight-pHeight)+sOff;if((pLeft+sOff)+cWidth>pageWidth)pLeft=(pageWidth-cWidth)-sOff;}}else type=14;}
switch(type){case(1):chObj.style.left=(pLeft-cWidth-mOff-cLeft)+'px';chObj.style.top=(pTop-cHeight-sOff-cTop)+'px';break
case(2):chObj.style.left=(pLeft+sOff-cLeft)+'px';chObj.style.top=(pTop-cHeight-mOff-cTop)+'px';break
case(3):chObj.style.left=(pLeft+(pWidth-cWidth)-sOff-cLeft)+'px';chObj.style.top=(pTop-cHeight-mOff-cTop)+'px';break
case(4):chObj.style.left=(pLeft+pWidth+mOff-cLeft)+'px';chObj.style.top=(pTop-cHeight-sOff-cTop)+'px';break
case(5):chObj.style.left=(pLeft-cWidth-mOff-cLeft)+'px';chObj.style.top=(pTop+sOff-cTop)+'px';break
case(6):chObj.style.left=(pLeft+sOff-cLeft)+'px';chObj.style.top=(pTop+mOff-cTop)+'px';break
case(7):chObj.style.left=(pLeft+pWidth-cWidth-sOff-cLeft)+'px';chObj.style.top=(pTop+mOff-cTop)+'px';break
case(8):chObj.style.left=(pLeft+pWidth+mOff-cLeft)+'px';chObj.style.top=(pTop+sOff-cTop)+'px';break
case(9):chObj.style.left=(pLeft-cWidth-mOff-cLeft)+'px';chObj.style.top=(pTop-(cHeight-pHeight)-sOff-cTop)+'px';break
case(10):chObj.style.left=(pLeft+sOff-cLeft)+'px';chObj.style.top=(pTop-(cHeight-pHeight)-mOff-cTop)+'px';break
case(11):chObj.style.left=(pLeft+pWidth-cWidth-sOff-cLeft)+'px';chObj.style.top=(pTop-(cHeight-pHeight)-mOff-cTop)+'px';break
case(12):chObj.style.left=(pLeft+pWidth+mOff-cLeft)+'px';chObj.style.top=(pTop-(cHeight-pHeight)-sOff-cTop)+'px';break
case(13):chObj.style.left=(pLeft-cWidth-mOff-cLeft)+'px';chObj.style.top=(pTop+pHeight+sOff-cTop)+'px';break
case(14):chObj.style.left=(pLeft+sOff-cLeft)+'px';chObj.style.top=(pTop+pHeight+mOff-cTop)+'px';break
case(15):chObj.style.left=(pLeft+(pWidth-cWidth)-sOff-cLeft)+'px';chObj.style.top=(pTop+pHeight+mOff-cTop)+'px';break
case(16):chObj.style.left=(pLeft+pWidth+mOff-cLeft)+'px';chObj.style.top=(pTop+pHeight+sOff-cTop)+'px';break
case(17):chObj.style.left=(pLeft+Math.round(pWidth/2)-Math.round(cWidth/2)+sOff-cLeft)+'px';chObj.style.top=(pTop-cHeight-mOff-cTop)+'px';break
case(18):chObj.style.left=(pLeft-cWidth-mOff-cLeft)+'px';chObj.style.top=(pTop+Math.round(pHeight/2)-Math.round(cHeight/2)+sOff-cTop)+'px';break
case(19):chObj.style.left=(pLeft+Math.round(pWidth/2)-Math.round(cWidth/2)+sOff-cLeft)+'px';chObj.style.top=(pTop+Math.round(pHeight/2)-Math.round(cHeight/2)+mOff-cTop)+'px';break
case(20):chObj.style.left=(pLeft+pWidth+mOff-cLeft)+'px';chObj.style.top=(pTop+Math.round(pHeight/2)-Math.round(cHeight/2)+sOff-cTop)+'px';break
case(21):chObj.style.left=(pLeft+Math.round(pWidth/2)-Math.round(cWidth/2)+sOff-cLeft)+'px';chObj.style.top=(pTop+pHeight+mOff-cTop)+'px';break}}
var Class={create:function(){var baseKlass=null
var props=new Array();for(var i=0;i<arguments.length;i++)props[i]=arguments[i];if(props[0])if(props[0].constructor==Function)baseKlass=props.shift();klass=function(){this.initialize.apply(this,arguments);}
klass.superclass=baseKlass;if(baseKlass){var tempKlass=function(){};tempKlass.prototype=baseKlass.prototype;klass.prototype=new tempKlass;}
for(var i=0;i<props.length;i++)$u.o.assign(klass.prototype,props[i]);if(!klass.prototype.initialize)klass.prototype.initialize=function(){};klass.prototype.constructor=klass;return klass;},superclassMethod:function(klass,method,args,context){if(klass.constructor.superclass.prototype[method]){if(klass.constructor.superclass.prototype[method].constructor==Function){if(!context)klass.constructor.superclass.prototype[method].apply(klass,args);else klass.constructor.superclass.prototype[method].apply(context,args);}}}}
function $if(expr,tVal,fVal){return expr?tVal:fVal;}
var $u={comma:',',decimal:'.',currency:'$',days:['sunday','monday','tuesday','wednesday','thursday','friday','saturday'],daysShort:['sun','mon','tue','wed','thur','fri','sat'],months:['january','february','march','april','may','june','july','august','september','october','november','december'],monthsShort:['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],compare:function(obj1,obj2){if(obj1==obj2)
return true;var val1=$u.o.toJSON(obj1);var val2=$u.o.toJSON(obj2);if(val1==val2)
return true;return false;},s:{toNum:function(str){str=str.toString();if(str.search('\\(')!=-1)str='-'+str;var regEx=RegExp('[^\-0-9'+$u.decimal+']');str=str.split(regEx).join('');if(str.indexOf('-')!=-1){var negNum=(str.indexOf('-')==0)?true:false;var regEx=RegExp('[^0-9'+$u.decimal+']');str=$if(negNum,'-','')+str.split(regEx).join('');}
str=str.replace($u.decimal,'.');return Number(str);},toBool:function(str){str=str.toString();if(str=='')return false;str=$u.s.aTrim(str).toLowerCase();if(str=='true'||str=='t'||str=='yes'||str=='1'||str=='.t.'){return true;}else
return false;},lTrim:function(str,tc){str=str.toString();if(!tc||tc=='')tc=' ';while(tc.indexOf(str.charAt(0))!=-1){str=str.substring(1,str.length);if(str.length==0)return'';}
return str;},substr:function(str,start,sLength){str=str.toString();if(start<0)start=str.length+start;if(typeof sLength=='undefined')return str.substr(start);else return str.substr(start,sLength);},rTrim:function(str,tc){str=str.toString();if(!tc||tc=='')tc=' ';while(tc.indexOf(str.charAt(str.length-1))!=-1){str=str.substring(0,str.length-1);if(str.length==0)return'';}
return str;},aTrim:function(str,tc){str=str.toString();if(!tc||tc=='')tc=' ';str=this.lTrim(str,tc);str=this.rTrim(str,tc);return str;},tran:function(str,sStr,rStr){str=str.toString();if(typeof sStr=='object'){for(var i=0;i<sStr.length;i++){var arr=str.split(sStr[i]);str=arr.join(rStr[i]);}}else{var arr=str.split(sStr);str=arr.join(rStr);}
return str;},word:function(str,num,sep){str=str.toString();if(sep=='')sep=' ';var arr=str.split(sep);if(Math.abs(num)>arr.length)return'';else if(num>-1)return arr[num-1];else return arr[arr.length+num];},ellipse:function(str,len){str=str.toString();var elpStr=(arguments[3])?arguments[3]:'...';var align=(arguments[2])?arguments[2].substring(0,1).toLowerCase():'l';if(align=='r'){str=str.substring(0,len-elpStr.length)+elpStr;}else if(align=='c'){var lLen=Math.round((len-elpStr.length)/2);var rLen=str.length-(len-elpStr.length-lLen);str=str.substring(0,lLen)+elpStr+str.substring(rLen,str.length);}else{str=elpStr+str.substring(str.length-(len-elpStr.length),str.length);}
return str;},pad:function(str,padLen,padStr){str=str.toString();var align=arguments[3]?arguments[3].toLowerCase():'l';if(padLen==-1){return str;}else if(str.length>padLen){return str.substr(0,padLen);}else{padStr=$u.s.replicate(padStr,padLen)
if(align=='l'){return padStr.substring(0,padLen-str.length)+str;}else if(align=='r'){return str+padStr.substring(0,padLen-str.length);}else if(align=='c'){padLen=padLen-str.length;var lLen=Math.round(padLen/2);var rLen=padLen-lLen;return padStr.substring(0,lLen)+str+padStr.substring(0,rLen);}}},replicate:function(str,repNum){str=str.toString();var repArr=new Array();for(var i=0;i<repNum;i++)repArr.push(str);return repArr.join('');},changeCase:function(str,type){str=str.toString();type=type.toLowerCase();switch(type){case('u'):return str.toUpperCase();break
case('l'):return str.toLowerCase();break
case('fu'):return str.substr(0,1).toUpperCase()+str.substr(1);break
case('furl'):return str.substr(0,1).toUpperCase()+str.substr(1).toLowerCase();break
case('wfu'):var wordsArr=str.split(' ');for(var i=0;i<wordsArr.length;i++)wordsArr[i]=$u.s.changeCase(wordsArr[i],'fu');return wordsArr.join(' ');break
case('wfurl'):str=str.toLowerCase();var wordsArr=str.split(' ');for(var i=0;i<wordsArr.length;i++)wordsArr[i]=$u.s.changeCase(wordsArr[i],'fu');return wordsArr.join(' ');break}}},n:{toStr:function(valNum){if(typeof valNum=='string')return valNum;var decNum=arguments[1]?arguments[1]:-1;var format=arguments[2]?arguments[2].toUpperCase():'';if(format.indexOf('B')!=-1&&valNum==0)return'';var comma=(format.indexOf(',')!=-1)?true:false;var prefixNeg=(format.indexOf('-')!=-1)?true:false;var parenNeg=(format.indexOf('(')!=-1)?true:false;var negStr=valNum<0?'-':'';var prefix=arguments[3]?arguments[3]:'';var suffix=arguments[4]?arguments[4]:'';if(decNum!=-1)valNum=$u.n.round(Math.abs(valNum),decNum);else valNum=Math.abs(valNum);var str=String(valNum);var intStr=$u.s.word(str,1,'.');var decStr=$u.s.word(str,2,'.');if(decNum!=-1){if(!decStr)decStr='0';if(decStr.length!=decNum)decStr=$u.s.pad(decStr,decNum,'0','r');}
if(comma&&intStr.length>3){var intArr=new Array();var placeInc=Math.round((intStr.length/3)+.49);intStr=$u.s.pad(intStr,placeInc*3,'0','l')
intArr.push($u.s.lTrim(intStr.substr(0,3),'0'));for(var i=1;i<placeInc;i++){intArr.push(intStr.substr(i*3,3));}
intStr=intArr.join($u.comma);}
if(prefixNeg&&negStr!='')prefix=negStr+prefix;else if(parenNeg&&negStr!=''){prefix='('+prefix;suffix=suffix+')';}else intStr=negStr+intStr;if(decStr!='')return prefix+intStr+$u.decimal+decStr+suffix;else return prefix+intStr+suffix;},toPlaceStr:function(num){num=Math.round(num);var numStr=String(num);var numEnd=parseInt(numStr.slice(-2));if(numEnd>3&&numEnd<21)
return numStr+'th';var numEnd=parseInt(numStr.slice(-1));if(numEnd==1)
return numStr+'st';else if(numEnd==2)
return numStr+'nd';else if(numEnd==3)
return numStr+'rd';else
return numStr+'th';},round:function(valNum,decNum){if(!isNaN(valNum)&&!isNaN(decNum)){var dir=typeof arguments[2]!='undefined'?arguments[2].substr(0,1).toLowerCase():'';var tempDecNum=Math.pow(10,decNum);if(dir=='u')return(Math.round((valNum*tempDecNum)+.49999)/tempDecNum);else if(dir=='d')return(Math.round((valNum*tempDecNum)-.49999)/tempDecNum);else return(Math.round(valNum*tempDecNum)/tempDecNum);}}},a:{find:function(){var arr=arguments[0];var val=arguments[1];var searchAll=typeof arguments[2]!='undefined'?arguments[2]:false;var exactMatch=typeof arguments[3]!='undefined'?arguments[3]:true;var indxArr=Array();if(exactMatch==true){for(var i=0;i<arr.length;i++){if(arr[i]==val){indxArr.push(i);if(searchAll!=true)break;}}}else{for(var i=0;i<arr.length;i++){if(String(arr[i]).indexOf(String(val))!=-1){indxArr.push(i);if(searchAll!=true)break;}}}
if(indxArr.length==0)
indxArr.push(-1);if(searchAll==true){return indxArr;}else{return indxArr[0];}},compare:function(a,b){var type=arguments[2]?arguments[2]:'<';if(typeof a!='object')
a=new Array(a);if(typeof b!='object')
b=new Array(b);var indx=new Array();var tArr=new Array();if(type=='>'){for(var i=0;i<a.length;i++){indx=$u.a.find(b,a[i]);if(indx==-1)
tArr[tArr.length]=a[i];}}else if(type=='='){for(var i=0;i<b.length;i++){indx=$u.a.find(a,b[i]);if(indx!=-1)
Arr[tArr.length]=b[i];}}else{for(var i=0;i<b.length;i++){indx=$u.a.find(a,b[i]);if(indx==-1)
tArr[tArr.length]=b[i];}}
return tArr;},dedup:function(arr){var tArr=new Array();for(var i=0;i<arr.length;i++){if($u.a.find(tArr,arr[i])==-1)
tArr[tArr.length]=arr[i];}
return tArr;},copy:function(arr){return new Array(arr);}},o:{assign:function(objD,obj){var lAssign=typeof arguments[2]!='undefined'?arguments[2]:false
if(lAssign){for(var prop in obj){if(typeof obj[prop]=='object'&&typeof objD[prop]=='object'){if(!objD[prop])objD[prop]=new Object(obj[prop]);else $u.o.assign(objD[prop],obj[prop],lAssign);}else if(typeof objD[prop]=='undefined')objD[prop]=obj[prop];}}else{for(var prop in obj){if(typeof obj[prop]=='object'){if(!objD[prop]||typeof objD[prop]!='object')objD[prop]=new Object(obj[prop]);else $u.o.assign(objD[prop],obj[prop],lAssign);}else objD[prop]=obj[prop];}}},toJSON:function(obj){var type=typeof(obj);if(type=='object'){var propArr=new Array();if(obj.length){for(var i=0;i<obj.length;i++)propArr.push($u.o.toJSON(obj[i]));return'['+propArr.join(', ')+']';}else{for(var prop in obj)propArr.push(prop+': '+$u.o.toJSON(obj[prop]));return'{'+propArr.join(', ')+'}';}}else if(type=='number')return String(obj);else if(type=='boolean')return obj?'true':'false';else if(type=='date')return'Date(\''+obj+'\')';else return'\''+$u.s.tran($u.s.tran(obj,'\'','\\\''),'\n','\\n')+'\'';},toParams:function(obj){var prefix=arguments[1]||'';prefix=prefix.replace(/%/g,"%25").replace(/\+/g,"%2B").replace(/\=/g,"%3D").replace(/\\/g,"%5C").replace(/&/g,"%26").replace(/\n/g,"%0D%0A").replace(/\r/g,"");var type=typeof(obj);if(type=='object'){if(obj==null)return prefix+"=";var propArr=new Array();if(obj.length){var prefixArrIt=$u.s.tran(prefix,'[]','[..]');for(var i=0;i<obj.length;i++){if(i==0){if(typeof obj[i]=='object'){propArr.push($u.o.toParams(obj[i],prefix+'[]'));}else{propArr.push(prefix+'[]='+$u.o.toParams(obj[i]));}}else{if(typeof obj[i]=='object'){propArr.push($u.o.toParams(obj[i],prefixArrIt+'[]'));}else{propArr.push(prefixArrIt+'[]='+$u.o.toParams(obj[i]));}}}
return propArr.join('&');}else{if(prefix!='')prefix=prefix+'.';var prefixArrIt=$u.s.tran(prefix,'[]','[..]');var propCount=0;var propStr='';for(var prop in obj){propStr=prop;propStr=propStr.replace(/%/g,"%25").replace(/\+/g,"%2B").replace(/\=/g,"%3D").replace(/\\/g,"%5C").replace(/&/g,"%26").replace(/\n/g,"%0D%0A").replace(/\r/g,"");if(propCount==0){if(typeof obj[prop]=='object'){propArr.push($u.o.toParams(obj[prop],prefix+prop));}else{propArr.push(prefix+propStr+'='+$u.o.toParams(obj[prop]));}}else{if(typeof obj[prop]=='object'){propArr.push($u.o.toParams(obj[prop],prefixArrIt+prop));}else{propArr.push(prefixArrIt+propStr+'='+$u.o.toParams(obj[prop]));}}
propCount++}
return propArr.join('&');}}else{if(type=='number')return String(obj);else if(type=='boolean')return obj?'.t.':'.f.';else return''+obj.replace(/%/g,"%25").replace(/\+/g,"%2B").replace(/\=/g,"%3D").replace(/\\/g,"%5C").replace(/&/g,"%26").replace(/\n/g,"%0D%0A").replace(/\r/g,"");}}},d:{toStr:function(dObj,frm){if(frm.indexOf('[mm]')!=-1)
frm=frm.replace('[mm]',$u.s.pad(''+(dObj.getMonth()+1),2,'0'));else if(frm.indexOf('[m]')!=-1)
frm=frm.replace('[m]',''+(dObj.getMonth()+1));else if(frm.indexOf('[month]')!=-1)
frm=frm.replace('[month]',$u.months[dObj.getMonth()]);else if(frm.indexOf('[Month]')!=-1)
frm=frm.replace('[Month]',$u.s.changeCase($u.months[dObj.getMonth()],'fu'));else if(frm.indexOf('[MONTH]')!=-1)
frm=frm.replace('[MONTH]',$u.months[dObj.getMonth()].toUpperCase());else if(frm.indexOf('[mon]')!=-1)
frm=frm.replace('[mon]',$u.monthsShort[dObj.getMonth()]);else if(frm.indexOf('[Mon]')!=-1)
frm=frm.replace('[Mon]',$u.s.changeCase($u.monthsShort[dObj.getMonth()],'fu'));else if(frm.indexOf('[MON]')!=-1)
frm=frm.replace('[MON]',$u.monthsShort[dObj.getMonth()].toUpperCase());if(frm.indexOf('[dd]')!=-1)
frm=frm.replace('[dd]',$u.s.pad(''+(dObj.getDate()),2,'0'));else if(frm.indexOf('[d]')!=-1)
frm=frm.replace('[d]',''+(dObj.getDate()));else if(frm.indexOf('[ddx]')!=-1)
frm=frm.replace('[ddx]',$u.s.pad($u.n.toPlaceStr(dObj.getDate()),2,'0'));else if(frm.indexOf('[dx]')!=-1)
frm=frm.replace('[dx]',$u.n.toPlaceStr(dObj.getDate()));else if(frm.indexOf('[DDX]')!=-1)
frm=frm.replace('[DDX]',$u.s.pad($u.n.toPlaceStr(dObj.getDate()),2,'0').toUpperCase());else if(frm.indexOf('[DX]')!=-1)
frm=frm.replace('[DX]',$u.n.toPlaceStr(dObj.getDate()).toUpperCase());if(frm.indexOf('[yy]')!=-1)
frm=frm.replace('[yy]',(''+dObj.getFullYear()).substr(2));else if(frm.indexOf('[yyyy]')!=-1)
frm=frm.replace('[yyyy]',''+dObj.getFullYear());if(frm.indexOf('[wday]')!=-1)
frm=frm.replace('[wday]',$u.days[dObj.getDay()]);else if(frm.indexOf('[Wday]')!=-1)
frm=frm.replace('[Wday]',$u.s.changeCase($u.days[dObj.getDay()],'fu'));else if(frm.indexOf('[WDAY]')!=-1)
frm=frm.replace('[WDAY]',$u.days[dObj.getDay()].toUpperCase());else if(frm.indexOf('[wd]')!=-1)
frm=frm.replace('[wd]',$u.daysShort[dObj.getDay()]);else if(frm.indexOf('[Wd]')!=-1)
frm=frm.replace('[Wd]',$u.s.changeCase($u.daysShort[dObj.getDay()],'fu'));else if(frm.indexOf('[WD]')!=-1)
frm=frm.replace('[WD]',$u.daysShort[dObj.getDay()].toUpperCase());var hr=dObj.getHours();var mer=hr>11?'pm':'am';if(hr==0)hr=24;if(frm.indexOf('[t:h]')!=-1){if(hr>12)hr=hr-12;frm=frm.replace('[t:h]',''+hr);}else if(frm.indexOf('[t:hh]')!=-1){if(hr>12)hr=hr-12;frm=frm.replace('[t:hh]',$u.s.pad(''+hr,2,'0'));}else if(frm.indexOf('[t:mh]')!=-1)
frm=frm.replace('[t:mh]',''+hr);else if(frm.indexOf('[t:mhh]')!=-1)
frm=frm.replace('[t:mhh]',$u.s.pad(''+hr,2,'0'));if(frm.indexOf('[t:m]')!=-1)
frm=frm.replace('[t:m]',''+(dObj.getMinutes()+1));else if(frm.indexOf('[t:mm]')!=-1)
frm=frm.replace('[t:mm]',$u.s.pad(''+(dObj.getMinutes()+1),2,'0'));if(frm.indexOf('[t:s]')!=-1)
frm=frm.replace('[t:s]',''+(dObj.getSeconds()+1));else if(frm.indexOf('[t:ss]')!=-1)
frm=frm.replace('[t:ss]',$u.s.pad(''+(dObj.getSeconds()+1),2,'0'));if(frm.indexOf('[t:am]')!=-1)
frm=frm.replace('[t:am]',mer);if(frm.indexOf('[t:a]')!=-1)
frm=frm.replace('[t:a]',mer.substr(0,1));else if(frm.indexOf('[t:AM]')!=-1)
frm=frm.replace('[t:AM]',mer.toUpperCase());else if(frm.indexOf('[t:A]')!=-1)
frm=frm.replace('[t:A]',mer.substr(0,1).toUpperCase());return frm;}},b:{toStr:function(valBool,rTrue,rFalse){return valBool?rTrue:rFalse;}}}
if(!$e){var $e={loaded:false,_e:[],_de:[],_ue:[],add:function(evntEle,evntType,evntFunc){var evntScope=arguments[3]?arguments[3]:null;var scopeOverride=(typeof arguments[4]!='undefined'&&arguments[4]!=null)?arguments[4]:false;var groupName=arguments[5]?arguments[5]:'';if(evntEle&&evntEle.length&&!evntEle.tagName&&typeof evntEle!='string'&&!evntEle.alert&&typeof evntEle[0]!='undefined'){var returnBool=true;for(var i=0;i<evntEle.length;i++){returnBool=(($e.add(evntEle[i],evntType,evntFunc,evntScope,scopeOverride,groupName))&&returnBool)}
return returnBool;}
if($e.loaded){var ele=$(evntEle);if(!ele)return false;var cScope=(scopeOverride)?evntScope:ele;var wFunc=function(e){return evntFunc.call(cScope,$e.getEvent(e),evntScope);};if(evntType=='load'){wFunc();delete wFunc
delete ele;delete cScope;return true;}else if(evntType=='unload'){$e._ue.push([ele,evntType,evntFunc,wFunc,evntScope,scopeOverride,groupName]);return true;}
$e._e.push([ele,evntType,evntFunc,wFunc,evntScope,scopeOverride,groupName]);if(ele.addEventListener)ele.addEventListener(evntType,wFunc,false);else if(ele.attachEvent)ele.attachEvent('on'+evntType,wFunc);}else{$e._de.push([evntEle,evntType,evntFunc,evntScope,scopeOverride,groupName]);}
return true;},remove:function(ele,evntType,evntFunc){if(typeof ele=='string'){ele=$(ele);}else if(ele&&ele.length&&!ele.tagName&&typeof ele!='string'&&!ele.alert&&typeof ele[0]!='undefined'){var returnBool=true;for(var i=0;i<ele.length;i++){returnBool=($e.remove(ele[i],evntType,evntFunc)&&returnBool)}
return returnBool;}
var eObj=null;var eIndx=arguments[3]?arguments[3]:$e._wf(ele,evntType,evntFunc);if(eIndx==-1){for(var i=0;i<$e._ue.length;i++){if($e._ue[i]){if($e._ue[i][0]==ele&&$e._ue[i][1]==evntType&&$e._ue[i][2]==evntFunc){delete $e._ue[i][2];delete $e._ue[i];return true;}}}
return false;}
eObj=$e._e[eIndx];if(ele.removeEventListener)ele.removeEventListener(evntType,eObj[3],false);else if(ele.detachEvent)ele.detachEvent('on'+evntType,eObj[3]);delete $e._e[eIndx][3];delete $e._e[eIndx][2];delete $e._e[eIndx];return true;},removeGroup:function(gName){for(var i=0;i<$e._e.length;i++){var eObj=$e._e[i];if(eObj){if(eObj[6]==gName)$e.remove(eObj[0],eObj[1],eObj[2],i);}}
for(var i=0;i<$e._ue.length;i++){if($e._ue[i]){if($e._ue[i][6]==gName){delete $e._ue[i][0];delete $e._ue[i][3];delete $e._ue[i][2];delete $e._ue[i];}}}},execute:function(ele,evntType){var ele=$(ele);if(!ele)return false;if(ele['on'+evntType])ele['on'+evntType]();for(var i=0;i<$e._e.length;i++){if($e._e[i]){if($e._e[i][0]==ele&&$e._e[i][1]==evntType){$e._e[i][3]();}}}},executeGroup:function(gName){for(var i=0;i<$e._e.length;i++){var eObj=$e._e[i];if(eObj){if(eObj[6]==gName)eObj[3]();}}},getEvent:function(e){var evnt=e||window.event;return evnt},getCharCode:function(e){e=$e.getEvent(e);return e.charCode||e.keyCode;},stopEvent:function(e){e=$e.getEvent(e);$e.stopPropagation(e);$e.preventDefault(e);},stopPropagation:function(e){e=$e.getEvent(e);if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;},preventDefault:function(e){e=$e.getEvent(e);if(e.preventDefault)e.preventDefault();else e.returnValue=false;},_wf:function(eEle,eType,eFn){for(var i=0;i<$e._e.length;i++){if($e._e[i])
if($e._e[i][0]==eEle&&$e._e[i][1]==eType&&$e._e[i][2]==eFn)return i;}
return-1},_pageLoad:function(){if(!$e.loaded){$e.loaded=true;for(var i=0;i<$e._de.length;i++)$e.add.call($e,$e._de[i][0],$e._de[i][1],$e._de[i][2],$e._de[i][3],$e._de[i][4],$e._de[i][5]);if($e.onLoaded.constructor==Function)$e.onLoaded();}},_pageUnload:function(e){for(var i=0;i<$e._ue.length;i++){if($e._ue[i]){$e._ue[i][3](e);delete $e._ue[i][0];delete $e._ue[i][3];delete $e._ue[i][2];delete $e._ue[i];}}
for(var i=0;i<$e._e.length;i++){if($e._e[i]){if(typeof $e._e[i][0].tagName=='string'){if($e._e[i][0])$e.remove($e._e[i][0],$e._e[i][1],$e._e[i][2],i);}else{delete $e._e[i][3];delete $e._e[i][2];delete $e._e[i];}}}},onLoaded:0}
$ae(window,'load',$e._pageLoad);$ae(window,'unload',$e._pageUnload);}
var $a=new Object();$a.simple=Class.create();$a.simple.prototype={initialize:function(url,options){this.transport=this.getTransport();this.method=options.method||'post';this.async=options.async||true;this.handleGeneric=options.handleGeneric||false;this.handleType=options.handleType||'eval';this.handleContext=options.handleContext||false;if(this.handleGeneric==true){if(this.handleType=='eval'){this.handle=$a._rh._eval;}}else{this.handle=options.handle||null;}
this.errorHandle=options.errorHandle||$a._rh._error;this.errorHandleContext=options.errorHandleContext||null;this.data=options.data||'';if(typeof A5!='undefined'){if(typeof A5.ajax!='undefined'){if(typeof A5.ajax.addParamRequiredData!='undefined')this.data=A5.ajax.addParamRequiredData(this.data);}}
this.fill=$(options.fill)||null;this.url=url;this._secondChance=true;this.request();},request:function(){this.transport.open(this.method,this.url,this.async);var func=this.onChange;var context=this;this.transport.onreadystatechange=function(){return func.call(context);};if(this.method=='post'){this.transport.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=UTF-8');if(this.transport.overrideMimeType){this.transport.overrideMimeType('text/html; charset=UTF-8');}}
this.transport.send(this.data);},onChange:function(){if(this.transport.readyState==4&&this.transport.status==200){var func=this.handle;var funcContext=this.handleContext||func;var context=this;if(func)setTimeout(function(){return func.call(funcContext,context.transport);},10);var obj=this.fill;if(obj)setTimeout(function(){return $svs(obj,context.transport.responseText);},10);}else if(this.transport.readyState==4&&this.transport.status==408&&this._secondChance){this.request();this._secondChance=false;}else if(this.transport.readyState==4&&this.transport.status!=200){var func=this.errorHandle;var funcContext=this.errorHandleContext||func;var context=this;if(func)setTimeout(function(){return func.call(funcContext,context.transport);},10);var obj=this.fill;if(obj)setTimeout(function(){return $svs(obj,context.transport.responseText);},10);}},getTransport:function(){if(window.ActiveXObject)return new ActiveXObject('Microsoft.XMLHTTP');else if(window.XMLHttpRequest)return new XMLHttpRequest();else return false;}}
$a._rh={_eval:function(obj){if(obj.responseText)eval(obj.responseText);},_error:function(obj){var pText=obj.responseText;if(pText.search('</body>')!=-1)pText=$u.s.word($u.s.word(pText,2,'<body>'),1,'</body>');var pText=$u.s.aTrim(pText.replace(/(<([^>]+)>)/ig,''),'\n\r  ');if(pText!='')alert('XHTTPRequest Error:\n\n'+pText);}}

	
/*
Copyright (c) 2001, 2008
Alpha Software, Inc.

This JavaScript library is licensed exclusively for use with Alpha Five, 
Alpha Five Application Server and Alpha Five Run Engine. It is specifically 
not licensed for use on a server that does not have installed on it, a 
licensed copy of the Alpha Five Application Server.
*/



var AUI=new Object();AUI.u={getVPSize:function(){if(typeof window.innerWidth=='number')
return{width:window.innerWidth,height:window.innerHeight};else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
return{width:document.body.clientWidth,height:document.body.clientHeight};},getVPScroll:function(){if(typeof window.pageYOffset=='number')
return{'x':window.pageXOffset,'y':window.pageYOffset};else if(document.documentElement&&typeof document.documentElement.scrollLeft!='undefined')
return{'x':document.documentElement.scrollLeft,'y':document.documentElement.scrollTop};else if(document.body&&typeof document.body.scrollLeft!='undefined')
return{'x':document.body.scrollLeft,'y':document.body.scrollTop};},getPosition:function(ele){ele=$(ele);var elePos={x:$gpl(ele),y:$gpt(ele)};if(typeof arguments[1]=='object'){arguments[1].x=elePos.x;arguments[1].y=elePos.y;}
return elePos;},getSize:function(ele){ele=$(ele);var eleSize={width:ele.offsetWidth,height:ele.offsetHeight};if(typeof arguments[1]=='object'){arguments[1].width=eleSize.width;arguments[1].height=eleSize.height;}
return eleSize;},getMetrics:function(ele){ele=$(ele);ele=$(ele);var eleMetrics={x:$gpl(ele),y:$gpt(ele),width:ele.offsetWidth,height:ele.offsetHeight};eleMetrics.x2=eleMetrics.x+eleMetrics.width;eleMetrics.y2=eleMetrics.y+eleMetrics.height;if(typeof arguments[1]=='object'){arguments[1].x=eleMetrics.x;arguments[1].y=eleMetrics.y;arguments[1].width=eleMetrics.width;arguments[1].height=eleMetrics.height;arguments[1].x2=eleMetrics.x2;arguments[1].y2=eleMetrics.y2;}
return eleMetrics;}}
AUI.KeyWatcher=Class.create();AUI.KeyWatcher.prototype={initialize:function(keys){this.keys=keys;this.shift=false;this.ctrl=false;this.alt=false;this.context=0;this.targetWindow=0;this._on=false;if(typeof arguments[1]=='object')this.context=arguments[1];if(typeof arguments[2]!='undefined')this.targetWindow=arguments[2];this._kwEventId='A5KeyWatch'+this._kwIndx[0];this._kwIndx[0]++;},on:function(){if(!this._on){if(this.targetWindow==0){$e.add(document.documentElement,'keydown',this._keyDown,this,false,this._kwEventId);$e.add(document.documentElement,'keyup',this._keyUp,this,false,this._kwEventId);}else{$e.add(this.targetWindow.document.documentElement,'keydown',this._keyDown,this,false,this._kwEventId);$e.add(this.targetWindow.document.documentElement,'keyup',this._keyUp,this,false,this._kwEventId);}
this._on=true;}},off:function(){if(this._on){$e.removeGroup(this._kwEventId);this._on=false;}},_keyDown:function(e,classInstance){e=$e.getEvent(e);var keyCode=e.charCode||e.keyCode;if(keyCode==16||keyCode==17||keyCode==18){if(keyCode==16)classInstance.shift=true;else if(keyCode==17)classInstance.ctrl=true;else if(keyCode==18)classInstance.alt=true;}else{if(typeof e.shiftKey!='undefined'){classInstance.shift=e.shiftKey;classInstance.ctrl=e.ctrlKey;classInstance.alt=e.altKey;}
if(keyCode==32)keyCode='SPACE';else if(keyCode==13)keyCode='ENTER';else if(keyCode==9)keyCode='TAB';else if(keyCode==8)keyCode='BACKSPACE';else if(keyCode==37)keyCode='LEFT';else if(keyCode==38)keyCode='UP';else if(keyCode==39)keyCode='RIGHT';else if(keyCode==40)keyCode='DOWN';else if(keyCode==27)keyCode='ESCAPE';else if(keyCode==33)keyCode='PAGEUP';else if(keyCode==34)keyCode='PAGEDOWN';else if(keyCode==35)keyCode='END';else if(keyCode==36)keyCode='HOME';else if(keyCode==45)keyCode='INSERT';else if(keyCode==46)keyCode='DELETE';else if(keyCode==112)keyCode='F1';else if(keyCode==113)keyCode='F2';else if(keyCode==114)keyCode='F3';else if(keyCode==115)keyCode='F4';else if(keyCode==116)keyCode='F5';else if(keyCode==117)keyCode='F6';else if(keyCode==118)keyCode='F7';else if(keyCode==119)keyCode='F8';else if(keyCode==120)keyCode='F9';else if(keyCode==121)keyCode='F10';else if(keyCode==122)keyCode='F11';else if(keyCode==123)keyCode='F12';else if(String.fromCharCode)keyCode=String.fromCharCode(keyCode).toUpperCase();var perfix='';var stopEvent=false;if(classInstance.ctrl)perfix='CTRL+';if(classInstance.alt)perfix=perfix+'ALT+';if(classInstance.shift)perfix=perfix+'SHIFT+';keyCode=perfix+keyCode;for(var i=0;i<classInstance.keys.length;i++){if(classInstance.keys[i].key.toUpperCase()==keyCode){if(typeof classInstance.context=='object')stopEvent=classInstance.keys[i].handle.call(classInstance.context);else stopEvent=classInstance.keys[i].handle();if(stopEvent==true){$e.stopEvent(e);return false;}else break;}}}},_keyUp:function(e,classInstance){e=$e.getEvent(e);var keyCode=e.charCode||e.keyCode;if(keyCode==16)classInstance.shift=false;else if(keyCode==17)classInstance.ctrl=false;else if(keyCode==18)classInstance.alt=false;},_kwIndx:[0]}
AUI.WaitDialog={setGlobal:function(settings){if($('AUIPageWaitDialog'))document.body.removeChild($('AUIPageWaitDialog'));var content=typeof settings.content!='undefined'?settings.content:'Loading...';var className=typeof settings.className!='undefined'?settings.className:'';var lockControl=typeof settings.lockControl!='undefined'?settings.lockControl:false;var lockClassName=typeof settings.lockClassName!='undefined'?settings.lockClassName:'';if(lockControl)AUI.LockUI.page(lockClassName);var node=document.createElement('div');node.id='AUIPageWaitDialog';node.onclick=$e.stopEvent;node.onmousedown=$e.stopEvent;node.onmouseup=$e.stopEvent;node.className=className;node.style.position='absolute';node.innerHTML=content;document.body.appendChild(node);var vpSize=AUI.u.getVPSize();var vpScroll=AUI.u.getVPScroll();node.style.top=Math.round(((vpSize.height)/2)-(node.offsetHeight/2)+vpScroll.y)+'px';node.style.left=Math.round(((vpSize.width)/2)-(node.offsetWidth/2)+vpScroll.x)+'px';},clearGlobal:function(){if($('AUIPageWaitDialog'))document.body.removeChild($('AUIPageWaitDialog'));var unlockUI=typeof arguments[0]!='undefined'?arguments[0]:true;if(unlockUI)AUI.LockUI.pageFree();},addLocal:function(eleId,settings){var parEle=$(eleId);if(parEle!=undefined){if($(eleId+'_AUIWaitDialog'))document.body.removeChild($(eleId+'_AUIWaitDialog'));var content=typeof settings.content!='undefined'?settings.content:'Loading...';var location=typeof settings.location!='undefined'?settings.location:'element';var className=typeof settings.className!='undefined'?settings.className:'';var lockControl=typeof settings.lockControl!='undefined'?settings.lockControl:false;var lockClassName=typeof settings.lockClassName!='undefined'?settings.lockClassName:'';if(lockControl)AUI.LockUI.element(parEle,lockClassName);var node=document.createElement('div');node.id=eleId+'_AUIWaitDialog';node.onclick=$e.stopEvent;node.onmousedown=$e.stopEvent;node.onmouseup=$e.stopEvent;node.className=className;node.style.position='absolute';node.innerHTML=content;document.body.appendChild(node);if(location=='page'){var vpSize=AUI.u.getVPSize();var vpScroll=AUI.u.getVPScroll();node.style.top=Math.round(((vpSize.height)/2)-(node.offsetHeight/2)+vpScroll.y)+'px';node.style.left=Math.round(((vpSize.width)/2)-(node.offsetWidth/2)+vpScroll.x)+'px';}else
$po(node,parEle,19,0,0);}},clearLocal:function(eleId){if($(eleId+'_AUIWaitDialog'))document.body.removeChild($(eleId+'_AUIWaitDialog'));AUI.LockUI.elementFree(eleId);}}
AUI.LockUI={element:function(ele,className){ele=$(ele);var id=ele.id+'_AUILockUI';if($(id))document.body.removeChild($(id));var node=document.createElement('div');node.id=id;node.onclick=$e.stopEvent;node.onmousedown=$e.stopEvent;node.onmouseup=$e.stopEvent;node.className=className;node.style.position='absolute';document.body.appendChild(node);$po(node,ele,6,0,0);node.style.width=ele.offsetWidth+'px';node.style.height=ele.offsetHeight+'px';AUI.LockUI._eles.push(ele.id);delete node;},_elementSize:function(eleID){ele=$(eleID);node=$(eleID+'_AUILockUI');if(!node)return false;$po(node,ele,6,0,0);node.style.width=ele.offsetWidth+'px';node.style.height=ele.offsetHeight+'px';},elementFree:function(ele){ele=$(ele);var id=ele.id+'_AUILockUI';if($(id))document.body.removeChild($(id));var arrIndx=$u.a.find(AUI.LockUI._eles,ele.id);if(arrIndx>-1)AUI.LockUI._eles=AUI.LockUI._eles.slice(0,arrIndx).concat(AUI.LockUI._eles.slice(arrIndx,AUI.LockUI._eles.length));;},page:function(className){var zIndex=typeof arguments[1]!='undefined'?arguments[1]:-1;this._plLevel.push(zIndex);if($('AUILockUIPage')){var node=$('AUILockUIPage');if(zIndex==-1)node.style.zIndex='';else node.style.zIndex=''+(zIndex);return false;}
var node=document.createElement('div');node.id='AUILockUIPage';node.onclick=$e.stopEvent;node.onmousedown=$e.stopEvent;node.onmouseup=$e.stopEvent;node.className=className;node.style.position='absolute';node.style.top='0px';node.style.left='0px';if(zIndex==-1)node.style.zIndex='';else node.style.zIndex=''+(zIndex);document.body.insertBefore(node,document.body.firstChild);var pageWidth=document.documentElement.clientWidth;var pageHeight=document.documentElement.clientHeight;pageWidth=$if(pageWidth<document.documentElement.scrollWidth,document.documentElement.scrollWidth,pageWidth);pageHeight=$if(pageHeight<document.documentElement.scrollHeight,document.documentElement.scrollHeight,pageHeight);node.style.width=(pageWidth-2)+'px';node.style.height=(pageHeight-2)+'px';$e.add(window,'resize',AUI.LockUI._pageSize);return this._plLevel.length-1;},_pageSize:function(){var node=$('AUILockUIPage');if(!node)return false;node.style.width='0px';node.style.height='0px';if(document.all&&navigator.appName!='Opera')setTimeout(AUI.LockUI._pageSizeComplete,0);else AUI.LockUI._pageSizeComplete();},_pageSizeComplete:function(){var node=$('AUILockUIPage');if(!node)return false;var pageWidth=document.documentElement.clientWidth;var pageHeight=document.documentElement.clientHeight;pageWidth=$if(pageWidth<document.documentElement.scrollWidth,document.documentElement.scrollWidth,pageWidth);pageHeight=$if(pageHeight<document.documentElement.scrollHeight,document.documentElement.scrollHeight,pageHeight);node.style.width=(pageWidth-2)+'px';node.style.height=(pageHeight-2)+'px';},pageFree:function(){if($('AUILockUIPage')){this._plLevel.pop();if(this._plLevel.length==0)document.body.removeChild($('AUILockUIPage'));else{$('AUILockUIPage').style.zIndex=''+this._plLevel[this._plLevel.length-1];}}},_eles:[],_pageLocked:false,_plLevel:[]}
$e.add(window,'resize',function(){if(AUI.LockUI._pageLocked)AUI.LockUI._pageSize();for(var i=0;i<AUI.LockUI._eles;i++)AUI.LockUI._elementSize(AUI.LockUI._eles[i])});AUI.Drag={create:function(hEle,sObj){hEle=$(hEle);var obj={dragElementId:'',coord:'page',snap:1,snapToCenter:false,constrainX:false,constrainY:false};$u.o.assign(obj,sObj);if(obj.dragElementId=='')obj.dragElementId=hEle.id;this._cacheSettings(hEle,obj);$e.add(hEle,'mousedown',AUI.Drag._startDrag);hEle.unselectable='on';$e.add(hEle,'selectstart',function(e){$e.stopEvent($e.getEvent(e));return false;});$e.add(hEle,'dragstart',function(e){$e.stopEvent($e.getEvent(e));return false;});},disable:function(ele){$sa(ele,'AUIDragDisable','true');},enable:function(ele){$sa(ele,'AUIDragDisable','false');},destroy:function(hEle){delete hEle.AUIDragHCoord;delete hEle.AUIDragHSnap;delete hEle.AUIDragHSnapToCenter;delete hEle.AUIDragHConstrainX;delete hEle.AUIDragHConstrainY;delete hEle.AUIDragHOnDragStart;delete hEle.AUIDragHWhileDrag;delete hEle.AUIDragHOnDragEnd;$e.remove(hEle,'mousedown',AUI.Drag._startDrag);$e.remove(hEle,'selectstart',function(e){var evnt=e||window.event;$e.stopEvent(evnt);return false;});$e.remove(hEle,'dragstart',function(e){var evnt=e||window.event;$e.stopEvent(evnt);return false;});},_s:{},_cacheSettings:function(hEle,sObj){$sa(hEle,'AUIDragHCoord',sObj.coord);$sa(hEle,'AUIDragHSnap',sObj.snap);$sa(hEle,'AUIDragHSnapToCenter',sObj.snapToCenter);$sa(hEle,'AUIDragHConstrainX',sObj.constrainX);$sa(hEle,'AUIDragHConstrainY',sObj.constrainY);$sa(hEle,'AUIDragHDragElementId',sObj.dragElementId);hEle.AUIDragHOnDragStart=typeof sObj.onDragStart!='undefined'?sObj.onDragStart:'';hEle.AUIDragHWhileDrag=typeof sObj.whileDrag!='undefined'?sObj.whileDrag:'';hEle.AUIDragHOnDragEnd=typeof sObj.onDragEnd!='undefined'?sObj.onDragEnd:'';},_retrieveSettings:function(hEle){AUI.Drag._s.coord=$ga(hEle,'AUIDragHCoord').toLowerCase();AUI.Drag._s.snap=$ga(hEle,'AUIDragHSnap');AUI.Drag._s.snapToCenter=$u.s.toBool(''+$ga(hEle,'AUIDragHSnapToCenter'));AUI.Drag._s.constrainX=$u.s.toBool(''+$ga(hEle,'AUIDragHConstrainX'));AUI.Drag._s.constrainY=$u.s.toBool(''+$ga(hEle,'AUIDragHConstrainY'));AUI.Drag._s.dragElementId=$ga(hEle,'AUIDragHDragElementId');AUI.Drag._s.onDragStart=hEle.AUIDragHOnDragStart;AUI.Drag._s.whileDrag=hEle.AUIDragHWhileDrag;AUI.Drag._s.onDragEnd=hEle.AUIDragHOnDragEnd;AUI.Drag._s.constraintTop=0;AUI.Drag._s.constraintLeft=0;AUI.Drag._s.constraintBottom=Math.max(document.body.offsetHeight,document.documentElement.clientHeight);AUI.Drag._s.constraintRight=document.body.offsetWidth;AUI.Drag._s.offsetX=0;AUI.Drag._s.offsetY=0;AUI.Drag._s.x=0;AUI.Drag._s.y=0;AUI.Drag._s._snapOffsetX=0;AUI.Drag._s._snapOffsetY=0;},_startDrag:function(e){$e.stopEvent(e);AUI.Drag._retrieveSettings(this);var dObj=$(AUI.Drag._s.dragElementId);if($ga(this,'AUIDragDisable')=='true'||$ga(dObj,'AUIDragDisable')=='true')return false;$e.add(document,'mouseup',AUI.Drag._endDrag);if(AUI.Drag._s.coord=='parent'||AUI.Drag._s.coord=='custom')$e.add(document,'mousemove',AUI.Drag._whileDragBound);else $e.add(document,'mousemove',AUI.Drag._whileDrag);if(AUI.Drag._s.onDragStart.constructor==Function)AUI.Drag._s.onDragStart(e,AUI.Drag._s);if(AUI.Drag._s.coord=='parent'){AUI.Drag._s.constraintBottom=dObj.parentNode.offsetHeight-dObj.offsetHeight;AUI.Drag._s.constraintRight=dObj.parentNode.offsetWidth-dObj.offsetWidth;}
if(AUI.Drag._s.snapToCenter){AUI.Drag._s._snapOffsetX=Math.round(dObj.offsetWidth/2);AUI.Drag._s._snapOffsetY=Math.round(dObj.offsetHeight/2);AUI.Drag._s.constraintTop=AUI.Drag._s.constraintTop-AUI.Drag._s._snapOffsetY;AUI.Drag._s.constraintLeft=AUI.Drag._s.constraintLeft-AUI.Drag._s._snapOffsetX;AUI.Drag._s.constraintBottom=AUI.Drag._s.constraintBottom+AUI.Drag._s._snapOffsetY;AUI.Drag._s.constraintRight=AUI.Drag._s.constraintRight+AUI.Drag._s._snapOffsetX;}
AUI.Drag._s.offsetX=e.clientX-dObj.offsetLeft;AUI.Drag._s.offsetY=e.clientY-dObj.offsetTop;return false;},_whileDrag:function(e){var evnt=e||window.event;var dObj=$(AUI.Drag._s.dragElementId);var tempY=(evnt.clientY-AUI.Drag._s.offsetY);var tempX=(evnt.clientX-AUI.Drag._s.offsetX);tempY=Math.round(Math.round((tempY-AUI.Drag._s._snapOffsetY)/AUI.Drag._s.snap)*AUI.Drag._s.snap)+AUI.Drag._s._snapOffsetY;tempX=Math.round(Math.round((tempX-AUI.Drag._s._snapOffsetX)/AUI.Drag._s.snap)*AUI.Drag._s.snap)+AUI.Drag._s._snapOffsetX;if(!AUI.Drag._s.constrainY&&tempY!=AUI.Drag._s.y)dObj.style.top=tempY+'px';if(!AUI.Drag._s.constrainX&&tempX!=AUI.Drag._s.x)dObj.style.left=tempX+'px';AUI.Drag._s.x=tempX;AUI.Drag._s.y=tempY;if(AUI.Drag._s.whileDrag.constructor==Function&&((!AUI.Drag._s.constrainX&&tempX!=AUI.Drag._s.x)||(!AUI.Drag._s.constrainY&&tempY!=AUI.Drag._s.y))){AUI.Drag._s.x=tempX;AUI.Drag._s.y=tempY;AUI.Drag._s.whileDrag(evnt,AUI.Drag._s);}
AUI.Drag._s.x=tempX;AUI.Drag._s.y=tempY;},_whileDragBound:function(e){var evnt=e||window.event;var dObj=$(AUI.Drag._s.dragElementId);var tempY=Math.max(Math.min((evnt.clientY-AUI.Drag._s.offsetY),AUI.Drag._s.constraintBottom),AUI.Drag._s.constraintTop);var tempX=Math.max(Math.min((evnt.clientX-AUI.Drag._s.offsetX),AUI.Drag._s.constraintRight),AUI.Drag._s.constraintLeft);tempY=Math.round(Math.round((tempY-AUI.Drag._s._snapOffsetY)/AUI.Drag._s.snap)*AUI.Drag._s.snap)+AUI.Drag._s._snapOffsetY;tempX=Math.round(Math.round((tempX-AUI.Drag._s._snapOffsetX)/AUI.Drag._s.snap)*AUI.Drag._s.snap)+AUI.Drag._s._snapOffsetX;if(!AUI.Drag._s.constrainY&&tempY!=AUI.Drag._s.y)dObj.style.top=tempY+'px';if(!AUI.Drag._s.constrainX&&tempX!=AUI.Drag._s.x)dObj.style.left=tempX+'px';if(AUI.Drag._s.whileDrag.constructor==Function&&((!AUI.Drag._s.constrainX&&tempX!=AUI.Drag._s.x)||(!AUI.Drag._s.constrainY&&tempY!=AUI.Drag._s.y))){AUI.Drag._s.x=tempX;AUI.Drag._s.y=tempY;AUI.Drag._s.whileDrag(evnt,AUI.Drag._s);}
AUI.Drag._s.x=tempX;AUI.Drag._s.y=tempY;},_endDrag:function(e){var evnt=e||window.event;$e.remove(document,'mouseup',AUI.Drag._endDrag);if(AUI.Drag._s.coord=='parent'||AUI.Drag._s.coord=='custom')$e.remove(document,'mousemove',AUI.Drag._whileDragBound);else $e.remove(document,'mousemove',AUI.Drag._whileDrag);if(AUI.Drag._s.onDragEnd.constructor==Function)AUI.Drag._s.onDragEnd(evnt,AUI.Drag._s);}}
AUI.Resize={create:function(hEle,sObj){hEle=$(hEle);var obj={resizeElementId:'',snap:1,type:'br',lockRatio:false,minWidth:1,minHeight:1,maxWidth:-1,maxHeight:-1};$u.o.assign(obj,sObj);if(obj.resizeElementId=='')obj.resizeElementId=hEle.id;this._cacheSettings(hEle,obj);$e.add(hEle,'mousedown',AUI.Resize._startResize);hEle.unselectable='on';$e.add(hEle,'selectstart',function(e){$e.stopEvent($e.getEvent(e));return false;});$e.add(hEle,'dragstart',function(e){$e.stopEvent($e.getEvent(e));return false;});},disable:function(ele){$sa(ele,'AUIResizeDisable','true');},enable:function(ele){$sa(ele,'AUIResizeDisable','false');},destroy:function(hEle){delete hEle.AUIResizeHType;delete hEle.AUIResizeHSnap;delete hEle.AUIResizeHLockRatio;delete hEle.AUIResizeHMinWidth;delete hEle.AUIResizeHMinHeight;delete hEle.AUIResizeHMaxWidth;delete hEle.AUIResizeHMaxHeight;delete hEle.AUIResizeHOnResizeStart;delete hEle.AUIResizeHWhileResize;delete hEle.AUIResizeHOnResizeEnd;$e.remove(hEle,'mousedown',AUI.Resize._startResize);$e.remove(hEle,'selectstart',function(e){var evnt=e||window.event;$e.stopEvent(evnt);return false;});$e.remove(hEle,'dragstart',function(e){var evnt=e||window.event;$e.stopEvent(evnt);return false;});},_s:{},_cacheSettings:function(hEle,sObj){$sa(hEle,'AUIResizeHType',sObj.type);$sa(hEle,'AUIResizeHSnap',sObj.snap);$sa(hEle,'AUIResizeHLockRatio',sObj.lockRatio);$sa(hEle,'AUIResizeHMinWidth',sObj.minWidth);$sa(hEle,'AUIResizeHMinHeight',sObj.minHeight);$sa(hEle,'AUIResizeHMaxWidth',sObj.maxWidth);$sa(hEle,'AUIResizeHMaxHeight',sObj.maxHeight);$sa(hEle,'AUIResizeHResizeElementId',sObj.resizeElementId);hEle.AUIResizeHOnResizeStart=typeof sObj.onResizeStart!='undefined'?sObj.onResizeStart:'';hEle.AUIResizeHWhileResize=typeof sObj.whileResize!='undefined'?sObj.whileResize:'';hEle.AUIResizeHOnResizeEnd=typeof sObj.onResizeEnd!='undefined'?sObj.onResizeEnd:'';},_retrieveSettings:function(hEle){AUI.Resize._s.type=$ga(hEle,'AUIResizeHType').toLowerCase();AUI.Resize._s.snap=$ga(hEle,'AUIResizeHSnap');AUI.Resize._s.lockRatio=$u.s.toBool(''+$ga(hEle,'AUIResizeHLockRatio'));AUI.Resize._s.minWidth=Number($ga(hEle,'AUIResizeHMinWidth'));AUI.Resize._s.minHeight=Number($ga(hEle,'AUIResizeHMinHeight'));AUI.Resize._s.maxWidth=Number($ga(hEle,'AUIResizeHMaxWidth'));AUI.Resize._s.maxHeight=Number($ga(hEle,'AUIResizeHMaxHeight'));AUI.Resize._s.resizeElementId=$ga(hEle,'AUIResizeHResizeElementId');AUI.Resize._s.onResizeStart=hEle.AUIResizeHOnResizeStart;AUI.Resize._s.whileResize=hEle.AUIResizeHWhileResize;AUI.Resize._s.onResizeEnd=hEle.AUIResizeHOnResizeEnd;AUI.Resize._s.initialMouseX=0;AUI.Resize._s.initialMouseY=0;AUI.Resize._s.x=0;AUI.Resize._s.y=0;AUI.Resize._s.width=0;AUI.Resize._s.height=0;AUI.Resize._s.initialX=0;AUI.Resize._s.initialY=0;AUI.Resize._s.initialWidth=0;AUI.Resize._s.initialHeight=0;},_startResize:function(e){$e.stopEvent(e);AUI.Resize._retrieveSettings(this);var dObj=$(AUI.Resize._s.resizeElementId);if($ga(this,'AUIResizeDisable')=='true'||$ga(dObj,'AUIResizeDisable')=='true')return false;$e.add(document,'mouseup',AUI.Resize._endResize);$e.add(document,'mousemove',AUI.Resize._whileResize);if(AUI.Resize._s.onResizeStart.constructor==Function)AUI.Resize._s.onResizeStart(e,AUI.Resize._s);AUI.Resize._s.initialMouseX=e.clientX;AUI.Resize._s.initialMouseY=e.clientY;AUI.Resize._s.x=dObj.offsetLeft;AUI.Resize._s.y=dObj.offsetTop;AUI.Resize._s.initialX=AUI.Resize._s.x;AUI.Resize._s.initialY=AUI.Resize._s.y;AUI.Resize._s.width=dObj.offsetWidth;AUI.Resize._s.height=dObj.offsetHeight;AUI.Resize._s.initialWidth=AUI.Resize._s.width;AUI.Resize._s.initialHeight=AUI.Resize._s.height;return false;},_whileResize:function(e){var evnt=e||window.event;var dObj=$(AUI.Resize._s.resizeElementId);var resized=false;var tempX=(evnt.clientX-AUI.Resize._s.initialMouseX);var tempY=(evnt.clientY-AUI.Resize._s.initialMouseY);if(AUI.Resize._s.lockRatio){tempX=Math.max(tempX,tempY);tempY=tempX;}
if(AUI.Resize._s.type.indexOf('l')!=-1)tempX=tempX*-1;if(AUI.Resize._s.type.indexOf('t')!=-1)tempY=tempY*-1;if(AUI.Resize._s.type.indexOf('c')!=-1||AUI.Resize._s.type.indexOf('h')!=-1)tempX=tempX*2;if(AUI.Resize._s.type.indexOf('c')!=-1||AUI.Resize._s.type.indexOf('v')!=-1)tempY=tempY*2;var tempWidth=(Math.round((AUI.Resize._s.initialWidth+tempX)/AUI.Resize._s.snap)*AUI.Resize._s.snap);var tempHeight=(Math.round((AUI.Resize._s.initialHeight+tempY)/AUI.Resize._s.snap)*AUI.Resize._s.snap);tempWidth=Math.max(tempWidth,AUI.Resize._s.minWidth);tempHeight=Math.max(tempHeight,AUI.Resize._s.minHeight);if(AUI.Resize._s.maxWidth>AUI.Resize._s.minWidth)tempWidth=Math.min(tempWidth,AUI.Resize._s.maxWidth);if(AUI.Resize._s.maxHeight>AUI.Resize._s.minHeight)tempHeight=Math.min(tempHeight,AUI.Resize._s.maxHeight);if(tempWidth!=AUI.Resize._s.width){resized=true;if(AUI.Resize._s.type.indexOf('l')!=-1){resized=true;dObj.style.width=tempWidth+'px';dObj.style.left=(AUI.Resize._s.initialX-(tempWidth-AUI.Resize._s.initialWidth))+'px';}else if(AUI.Resize._s.type.indexOf('r')!=-1){resized=true;dObj.style.width=tempWidth+'px';}else if(AUI.Resize._s.type.indexOf('c')!=-1||AUI.Resize._s.type.indexOf('h')!=-1){resized=true;dObj.style.width=tempWidth+'px';dObj.style.left=(AUI.Resize._s.initialX-Math.round((tempWidth-AUI.Resize._s.initialWidth)/2))+'px';}}
if(tempHeight!=AUI.Resize._s.height){if(AUI.Resize._s.type.indexOf('t')!=-1){resized=true;dObj.style.height=tempHeight+'px';dObj.style.top=(AUI.Resize._s.initialX-(tempHeight-AUI.Resize._s.initialHeight))+'px';}else if(AUI.Resize._s.type.indexOf('b')!=-1){resized=true;dObj.style.height=tempHeight+'px';}else if(AUI.Resize._s.type.indexOf('c')!=-1||AUI.Resize._s.type.indexOf('v')!=-1){resized=true;dObj.style.height=tempHeight+'px';dObj.style.top=(AUI.Resize._s.initialX-Math.round((tempHeight-AUI.Resize._s.initialHeight)/2))+'px';}}
if(resized){AUI.Resize._s.x=dObj.offsetLeft;AUI.Resize._s.x=dObj.offsetHeight;AUI.Resize._s.width=tempWidth;AUI.Resize._s.height=tempHeight;if(AUI.Resize._s.whileResize.constructor==Function){AUI.Resize._s.whileResize(evnt,AUI.Resize._s);}}},_endResize:function(e){var evnt=e||window.event;$e.stopEvent(evnt);$e.remove(document,'mouseup',AUI.Resize._endResize);$e.remove(document,'mousemove',AUI.Resize._whileResize);if(AUI.Resize._s.onResizeEnd.constructor==Function)AUI.Resize._s.onResizeEnd(evnt,AUI.Resize._s);}}

	
/*
Copyright (c) 2001, 2008
Alpha Software, Inc.

This JavaScript library is licensed exclusively for use with Alpha Five, 
Alpha Five Application Server and Alpha Five Run Engine. It is specifically 
not licensed for use on a server that does not have installed on it, a 
licensed copy of the Alpha Five Application Server.
*/



function a5_AJAX_GridAction(action,gridID,url,data){a5_AJAX_Form(action,gridID,url,data)}
function a5_AJAX_GridSubmit(submitAction,gridID,gridPart,url){var optionalData=typeof arguments[4]!='undefined'?arguments[4]:'';var action=submitAction;var formID=gridID+'_'+gridPart+'.FORM';var stateInfoID=gridID+'.STATEINFO';a5_AJAX_Form(action,formID,url,optionalData,true,stateInfoID,'__form')}
function a5_AJAX_Form(action,formID,url){var optionalData=typeof arguments[3]!='undefined'?arguments[3]:'';var flagSubmitData=typeof arguments[4]!='undefined'?arguments[4]:false;if(typeof arguments[5]=='undefined'){var stateID=formID+'.STATEINFO';}
else
{var stateID=arguments[5];}
var nameSpace=typeof arguments[6]!='undefined'?arguments[6]:'';var removeEvents=typeof arguments[7]!='undefined'?arguments[7]:true;var data='';var stateInfo=$(stateID).value?$(stateID).value:'';var stateInfoArray=stateInfo.split('&');var finalStateInfoArray=new Array();if($(formID)&&$ga(formID,'A5DataRegion')!='A5DataRegion')a5_AJAX_FormPrepare(formID);if(action=='submit:dirty')
{data=a5_AJAX_Form_RegionHarvest(formID,false,true,nameSpace,removeEvents);data=$u.s.rTrim(data,' &')+'&'+'__FormID='+formID+'&__FormAction=submit';}
else if(action=='submit:all'||action=='submit')
{data=a5_AJAX_Form_RegionHarvest(formID,true,true,nameSpace,removeEvents);data=$u.s.rTrim(data,' &')+'&'+'__FormID='+formID+'&__FormAction=submit';}
else if(action=='submit:new'||flagSubmitData)
{data=a5_AJAX_Form_RegionHarvest(formID,true,false,nameSpace,removeEvents);var actionName=$if(action=='submit:new','submit',action);data=$u.s.rTrim(data,' &')+'&'+'__FormID='+formID+'&__FormAction='+actionName;}
else data='__FormAction='+action+'&'+'__FormID='+formID;var URLInfo=document.URL;URLInfo=URLInfo.split('?').slice(1).join('?');URLInfo=URLInfo.replace(/\%22/g,'"');URLInfo=URLInfo.replace(/\%3C/g,'<');URLInfo=URLInfo.replace(/\%3E/g,'>');URLInfo=URLInfo.replace(/\%20/g,' ');URLInfo=URLInfo.split('&');var tempArg='';for(var i=0;i<URLInfo.length;i++){tempArg=URLInfo[i].split('=');URLInfo[i]=tempArg[0]+'='+urlencode(tempArg.slice(1).join('='));}
URLInfo=URLInfo.join('&');if(URLInfo!='')URLInfo=URLInfo+'&';if(stateInfo!='')stateInfo=stateInfo+'&';if(optionalData!='')optionalData=optionalData+'&';data=URLInfo+stateInfo+optionalData+data;if(data!=''){data=data+'&__Ajax=true';}
else{data='__Ajax=true';}
data=$u.s.tran(data,'\n','%0D%0A');data=A5.ajax.addParamRequiredData(data);new $a.simple(url,{data:data,handleGeneric:true,method:'post'})}
function a5_AJAX_Form_SetFocus(){var ele=this.parentNode;while(ele.getAttribute('A5DataRegion')!='A5DataRegion'){if(ele.tagName.toLowerCase()=='body')return;ele=ele.parentNode;}
ele.setAttribute('A5FocusControl',this.name);}
function a5_AJAX_Form_SetDirty(){if(this.readOnly||this.disabled)return false;var isDirty=false;var ele=this.parentNode;while(ele.getAttribute('A5DataRegion')!='A5DataRegion'){if(ele.tagName.toLowerCase()=='body')return;ele=ele.parentNode;}
if(this.tagName.toLowerCase()=='input'&&(this.type.toLowerCase()=='radio'||this.type.toLowerCase()=='checkbox')){var eles=$cetp($n(this.name),ele);var values=$gvs(eles,this.parentNode);if(values.constructor!=Array)values=[values];if(values.join('||A5ARRAYSEP||')!=eles[0].getAttribute('A5OriginalValue')){for(var i=0;i<eles.length;i++)eles[i].setAttribute('A5IsDirty','true');isDirty=true;}else for(var i=0;i<eles.length;i++)eles[i].setAttribute('A5IsDirty','false');}else{var val=$gvs(this);if(val==this.getAttribute('A5WatermarkText'))val='';if(val!=this.getAttribute('A5OriginalValue')){this.setAttribute('A5IsDirty','true');isDirty=true;}else this.setAttribute('A5IsDirty','false');}
if(isDirty){if(ele.getAttribute('A5IsDirty')!='true'){ele.setAttribute('A5IsDirty','true');var funcCall=ele.getAttribute('A5OnDirty');if(funcCall!='')eval(funcCall);}}}
function a5_AJAX_Form_SetDirtyControl(ele){a5_AJAX_Form_SetDirty.call($(ele));}
function a5_AJAX_Form_ErrorsSet(eTargs,eHTML,eleCNs,eEleCNs){var baseEleCN='';var baseEEleCN='';var curEleCN='';var curEEleCN='';if(typeof eleCNs=='string')baseEleCN=eleCNs;if(typeof eEleCNs=='string')baseEEleCN=eEleCNs;var ele=new Object();var eleCtl=new Object();var errorArr=new Array();for(var i=0;i<eTargs.length;i++){curEleCN=typeof eleCNs=='object'&&eleCNs[i]?eleCNs[i]:baseEleCN;curEEleCN=typeof eEleCNs=='object'&&eEleCNs[i]?eEleCNs[i]:baseEEleCN;ele=$(eTargs[i]+'.ERRORMSG');eleCtl=$(eTargs[i]);if(ele)ele.innerHTML=eHTML[i];if(curEEleCN!=''&&ele)$acn(ele,curEEleCN);if(curEleCN!='')$acn(eleCtl,curEleCN);$sa(eleCtl,'A5IsDirty','true');eleCtl=eleCtl.parentNode;while(eleCtl.getAttribute('A5DataRegion')!='A5DataRegion'){if(eleCtl.tagName.toLowerCase()=='body')return;eleCtl=eleCtl.parentNode;}
eleCtl.setAttribute('A5IsDirty','true');errorArr[i]={id:eTargs[i],errorEleClassName:curEEleCN,eleClassName:curEleCN};}
return errorArr;}
function a5_AJAX_Form_ErrorsClear(errorArr){var ele=new Object();for(var i=0;i<errorArr.length;i++){ele=$(errorArr[i].id+'.ERRORMSG')
if(ele)ele.innerHTML='';if(errorArr[i].errorEleClassName!='')$rcn(ele,errorArr[i].errorEleClassName);if(errorArr[i].eleClassName!='')$rcn($(errorArr[i].id),errorArr[i].eleClassName);}
return new Array();}
function a5_AJAX_FormPrepare(regionID){var rObj=new Array();if(typeof regionID=='object'&&regionID.length){for(var i=0;i<regionID.length;i++)rObj[rObj.length]=$(regionID[i]);}else{rObj=[$(regionID)];}
var val='';for(var i=0;i<rObj.length;i++){var eles=rObj[i].getElementsByTagName('input');for(var j=0;j<eles.length;j++){val=$gvs(eles[j].name,rObj[i]);if(val==eles[j].getAttribute('A5WatermarkText'))val='';if(typeof val=='object')val=val.join('||A5ARRAYSEP||');eles[j].setAttribute('A5OriginalValue',val);if(eles[j].type=='radio'||eles[j].type=='checkbox')$e.add(eles[j],'click',a5_AJAX_Form_SetDirty,null,false,rObj.id+'Events');}
$e.add(eles,'change',a5_AJAX_Form_SetDirty,null,false,rObj.id+'Events');$e.add(eles,'keyup',a5_AJAX_Form_SetDirty,null,false,rObj.id+'Events');$e.add(eles,'focus',a5_AJAX_Form_SetFocus,null,false,rObj.id+'Events');eles=rObj[i].getElementsByTagName('select');for(var j=0;j<eles.length;j++){val=$gvs(eles[j].name,rObj[i]);if(typeof val=='object')val=val.join('||A5ARRAYSEP||');eles[j].setAttribute('A5OriginalValue',val);}
$e.add(eles,'change',a5_AJAX_Form_SetDirty,null,false,rObj.id+'Events');$e.add(eles,'keyup',a5_AJAX_Form_SetDirty,null,false,rObj.id+'Events');$e.add(eles,'focus',a5_AJAX_Form_SetFocus,null,false,rObj.id+'Events');eles=rObj[i].getElementsByTagName('textarea');for(var j=0;j<eles.length;j++){val=$gvs(eles[j].name,rObj[i]);if(val==eles[j].getAttribute('A5WatermarkText'))val='';if(typeof val=='object')val=val.join('||A5ARRAYSEP||');eles[j].setAttribute('A5OriginalValue',val);}
$e.add(eles,'change',a5_AJAX_Form_SetDirty,null,false,rObj.id+'Events');$e.add(eles,'keyup',a5_AJAX_Form_SetDirty,null,false,rObj.id+'Events');$e.add(eles,'focus',a5_AJAX_Form_SetFocus,null,false,rObj.id+'Events');rObj[i].setAttribute('A5IsDirty','false');rObj[i].setAttribute('A5DataRegion','A5DataRegion');}}
function a5_AJAX_Callback(url,data){if(data!='')data=data+'&__Ajax=true';else data='__Ajax=true';data=A5.ajax.addParamRequiredData(data);new $a.simple(url,{data:data,handleGeneric:true,method:'post'})}
function a5_AJAX_Form_populateSelect(curID,curValue,clearOld,popList){curObj=document.getElementById(curID)
if(clearOld){if(curObj.options.length>0){for(var i=(curObj.options.length-1);i>=0;i--){curObj.options[i]=null;}
curObj.options[0]=null;}
curIndx=0}
else{curIndx=curObj.options.length}
var optArr=new Array()
optArr=popList.split('\n')
if(optArr.length>0){var optTempArr=new Array()
for(i=0;i<optArr.length;i++){optTempArr=optArr[i].split('|')
if(optTempArr.length>1){curObj.options[curIndx]=new Option(optTempArr[0],optTempArr[1])}
else{curObj.options[curIndx]=new Option(optTempArr[0],optTempArr[0])}
curIndx++}}
otpValFound=false
if(curObj.options.length>0){for(i=0;i<curObj.options.length;i++){if(curObj.options[i].value==curValue){otpValFound=true
curObj.options.selectedIndex=i
break;}}
if(otpValFound==false){curObj.options[curObj.options.length]=new Option(curValue,curValue)
curObj.options.selectedIndex=curObj.options.length-1}}}
function a5_AJAX_Form_RegionHarvest(regionID){var sendAllNewValues=typeof arguments[1]!='undefined'?arguments[1]:false;var sendOldValues=typeof arguments[2]!='undefined'?arguments[2]:true;var nameSpace=typeof arguments[3]!='undefined'?arguments[3]:'';if(nameSpace!='')nameSpace=nameSpace+'.';var removeEvents=typeof arguments[4]!='undefined'?arguments[4]:true;var rObj=new Array();if(typeof regionID=='object'&&regionID.length){for(var i=0;i<regionID.length;i++)rObj[rObj.length]=$(regionID[i]);}else{rObj=[$(regionID)];}
var eles=new Object();var val='';var valArr=new Array();var curVal=new Array();var usedNames=new Array();var dirtyRegions=new Array();var dirtyValues=new Array();var isDirty=false;for(var i=0;i<rObj.length;i++){if(removeEvents)$e.removeGroup(rObj[i].id+'Events');if(rObj[i].getAttribute('A5IsDirty')=='true'||sendAllNewValues){dirtyRegions[dirtyRegions.length]=rObj[i].id;eles=rObj[i].getElementsByTagName('input');for(var j=0;j<eles.length;j++){if(eles[j].getAttribute('A5HarvestIgnore')!='true'&&typeof eles[j].getAttribute('A5OriginalValue')=='string'){if(eles[j].type.toLowerCase()=='radio'){if($u.a.find(usedNames,eles[j].name)==-1){usedNames[usedNames.length]=eles[j].name;if(sendOldValues)valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,eles[j].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||'));isDirty=eles[j].getAttribute('A5IsDirty')=='true'?true:false;if(isDirty||sendAllNewValues){if(isDirty)dirtyValues[dirtyValues.length]=eles[j].name;valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,$gvs($n(eles[j].name),rObj[i]));}}}else if(eles[j].type.toLowerCase()=='checkbox'){if($u.a.find(usedNames,eles[j].name)==-1){usedNames[usedNames.length]=eles[j].name;if(sendOldValues)valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,eles[j].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||'));isDirty=eles[j].getAttribute('A5IsDirty')=='true'?true:false;if(isDirty||sendAllNewValues){if(isDirty)dirtyValues[dirtyValues.length]=eles[j].name;valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,$gvs($n(eles[j].name),rObj[i]));}}}else if(eles[j].type.toLowerCase()=='text'||eles[j].type=='hidden'||eles[j].type=='password'||eles[j].type==''){if(sendOldValues)valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,eles[j].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||'));isDirty=eles[j].getAttribute('A5IsDirty')=='true'?true:false;if(isDirty||sendAllNewValues){if(isDirty)dirtyValues[dirtyValues.length]=eles[j].name;val=$gvs(eles[j],rObj[i]);if(val==eles[j].getAttribute('A5WatermarkText'))val='';valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,val);}}}}
eles=rObj[i].getElementsByTagName('select');for(var j=0;j<eles.length;j++){if(eles[j].getAttribute('A5HarvestIgnore')!='true'&&typeof eles[j].getAttribute('A5OriginalValue')=='string'){if(sendOldValues)valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,eles[j].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||'));isDirty=eles[j].getAttribute('A5IsDirty')=='true'?true:false;if(isDirty||sendAllNewValues){if(isDirty)dirtyValues[dirtyValues.length]=eles[j].name;valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,$gvs(eles[j],rObj[i]));}}}
eles=rObj[i].getElementsByTagName('textarea');for(var j=0;j<eles.length;j++){if(eles[j].getAttribute('A5HarvestIgnore')!='true'&&typeof eles[j].getAttribute('A5OriginalValue')=='string'){if(sendOldValues)valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,eles[j].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||'));isDirty=eles[j].getAttribute('A5IsDirty')=='true'?true:false;if(isDirty||sendAllNewValues){if(isDirty)dirtyValues[dirtyValues.length]=eles[j].name;val=$gvs(eles[j],rObj[i]);if(val==eles[j].getAttribute('A5WatermarkText'))val='';valArr[valArr.length]=a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,val);}}}}}
return'a5DirtyRegions='+dirtyRegions.join('\n')+'&'+'a5RegionsDirtyValues='+dirtyValues.join('\n')+'&'+valArr.join('&');}
function a5_AJAX_Form_SubmitValueParam(eleName,eleValue){if(typeof eleValue!='undefined'){if(eleValue.constructor==Array){var valArr=new Array();if(eleValue.length==0){return urlencode(eleName)+'=';}else
{for(var j=0;j<eleValue.length;j++){valArr[valArr.length]=urlencode(eleName)+'='+urlencode(eleValue[j]);}
return valArr.join('&');}}else return urlencode(eleName)+'='+urlencode(''+eleValue);}}
function urlencode(text){text=text.replace(/%/g,"%25");text=text.replace(/\+/g,"%2B");text=text.replace(/\=/g,"%3D");text=text.replace(/\\/g,"%5C");text=text.replace(/&/g,"%26");text=text.replace(/\n/g,"%0D%0A");text=text.replace(/\r/g,"");return text}
function a5_AJAX_FormReset(regionID){var keepOldValues=typeof arguments[1]=='undefined'?false:arguments[1];var rObj=new Array();if(typeof regionID=='object'&&regionID.length){for(var i=0;i<regionID.length;i++)rObj[rObj.length]=$(regionID[i]);}else{rObj=[$(regionID)];}
var values='';for(var i=0;i<rObj.length;i++){var eles=rObj[i].getElementsByTagName('input');for(var j=0;j<eles.length;j++){if(keepOldValues){values=eles[j].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||');if(values.length==1)values=values[0];$svs($n(eles[j].name),values);}else eles[j].setAttribute('A5OriginalValue',Array().concat($gvs(eles[j].name,rObj[i])).join('||A5ARRAYSEP||'));eles[j].setAttribute('A5IsDirty','false');}
eles=rObj[i].getElementsByTagName('select');for(var j=0;j<eles.length;j++){if(keepOldValues){values=eles[j].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||');if(values.length==1)values=values[0];$svs($n(eles[j].name),values);}else eles[j].setAttribute('A5OriginalValue',Array().concat($gvs(eles[j].name,rObj[i])).join('||A5ARRAYSEP||'));eles[j].setAttribute('A5IsDirty','false');}
eles=rObj[i].getElementsByTagName('textarea');for(var j=0;j<eles.length;j++){if(keepOldValues){values=eles[j].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||');if(values.length==1)values=values[0];$svs($n(eles[j].name),values);}else eles[j].setAttribute('A5OriginalValue',Array().concat($gvs(eles[j].name,rObj[i])).join('||A5ARRAYSEP||'));eles[j].setAttribute('A5IsDirty','false');}
ele=rObj[i];if(ele.getAttribute('A5IsDirty')=='true'){var funcCall=ele.getAttribute('A5OnClean');if(funcCall!='')eval(funcCall);ele.setAttribute('A5IsDirty','false');}}}
a5_AJAX_autoSuggest=Class.create();a5_AJAX_autoSuggest.prototype={initialize:function(targetId,settings){this.targetId=targetId;$u.o.assign(this,{url:'',data:'',dynamicHandle:0,minimum:1,width:'',height:'',contextControls:0,columns:0,className:'',item:{className:'',selectedClassName:'',keyClassName:''},title:{className:'',location:'none'},onSelect:0});if(typeof a5_AJAX_autoSuggestDefaults!='undefined')$u.o.assign(this,a5_AJAX_autoSuggestDefaults);$u.o.assign(this,settings);$e.add(targetId,'focus',this._focus,this,true);$e.add(targetId,'blur',this._hideMatchList,this,true);$e.add(targetId,'keyup',this._getList,this,true);this._kw=new AUI.KeyWatcher([{key:'enter',handle:this._selectCurValue},{key:'up',handle:this._prevValue},{key:'down',handle:this._nextValue}],this);this._listValue=0;this._listTotal=0;this._list=[];this._parseColumns();var ele=document.createElement('div');ele.id=this.targetId+'.LIST';ele.className=this.className;ele.style.position='absolute';ele.style.display='none';ele.style.height=this.height;ele.style.width=this.width;ele.style.overflow='auto';ele.style.zIndex='10000';$(targetId).parentNode.insertBefore(ele,$(targetId));},_parseColumns:function(e){if(this.columns.constructor==Array){var keyFlag=false;var colTitle='';for(var i=0;i<this.columns.length;i++){if(typeof this.columns[i]=='object'){$u.o.assign(this.columns[i],this._defaultColumn,true);if(!keyFlag&&this.columns[i].key)keyFlag=true;else if(keyFlag&&this.columns[i].key)this.columns[i].key=false;}else{colTitle=this.columns[i];this.columns[i]=new Object();$u.o.assign(this.columns[i],this._defaultColumn);this.columns[i].title=''+colTitle;}}
if(!keyFlag){this.columns[0].key=true;}}else{var colTitle=this.columns;this.columns=new Array();$u.o.assign(this.columns[0],this._defaultColumn);this.columns[0].title=''+colTitle;this.columns[0].key=true;}},_focus:function(e){e=$e.getEvent(e);var lObj=$(this.targetId+'.LIST');$po(lObj,$(this.targetId),14,2,0);this._kw.on();},_hideMatchList:function(e){var lObj=$(this.targetId+'.LIST');classInst=this;setTimeout(function(){classInst._hideMatchListComplete();},400);},_hideMatchListComplete:function(){var lObj=$(this.targetId+'.LIST');lObj.style.display='none';this._kw.off();},_selectValue:function(e,classInst){var indx=Number(this.getAttribute('A5SuggestIndex'));var val=typeof classInst._list[indx]!='undefined'?classInst._list[indx]:'';var finVal=val;if(finVal.constructor==Array){var keyIndx=0;for(var i=0;i<classInst.columns.length;i++){if(classInst.columns[i].key){keyIndx=i;break;}}
finVal=finVal[keyIndx];}
if(finVal!='')$(classInst.targetId).value=finVal;if(classInst.onSelect.constructor==Function)classInst.onSelect(val);},_selectCurValue:function(e){var val=typeof this._list[this._listValue]!='undefined'?this._list[this._listValue]:'';var finVal=val;if(finVal.constructor==Array){var keyIndx=0;for(var i=0;i<this.columns.length;i++){if(this.columns[i].key){keyIndx=i;break;}}
finVal=finVal[keyIndx];}
if(finVal!='')$(this.targetId).value=finVal;if(this.onSelect.constructor==Function)this.onSelect(val);var lObj=$(this.targetId+'.LIST');lObj.style.display='none';},_nextValue:function(e){if(this._listValue<this._listTotal-1){$(this.targetId+'.LIST.'+this._listValue).className=this.item.className;this._listValue=this._listValue+1;$(this.targetId+'.LIST.'+this._listValue).className=this.item.selectedClassName;this._scrollToEntry();}},_prevValue:function(e){if(this._listValue>0){$(this.targetId+'.LIST.'+this._listValue).className=this.item.className;this._listValue=this._listValue-1;$(this.targetId+'.LIST.'+this._listValue).className=this.item.selectedClassName;this._scrollToEntry();}},_scrollToEntry:function(){var ele=$(this.targetId+'.LIST.'+this._listValue);var cEle=$(this.targetId+'.LIST');if(cEle.scrollTop>ele.offsetTop)cEle.scrollTop=ele.offsetTop-2;else if(cEle.scrollTop+cEle.offsetHeight<(ele.offsetTop+ele.offsetHeight))cEle.scrollTop=ele.offsetTop+(ele.offsetHeight)-cEle.offsetHeight;},_getList:function(e){e=$e.getEvent(e);var keyCode=e.charCode||e.keyCode;if(keyCode==13||keyCode==37||keyCode==38||keyCode==39||keyCode==40)return false;if(this.delay>0){clearTimeout(this._delayTO);classInst=this;this._delayTO=setTimeout(function(){classInst._getListComplete();delete classInst;},this.delay);}else this._getListComplete();},_getListComplete:function(){var lObj=$(this.targetId+'.LIST');var tObj=$(this.targetId)
if(tObj.value.length<this.minimum){lObj.style.display='none';return'';}
if(this.dynamicHandle.constructor==Function){var dArr=this.dynamicHandle(tObj.value);if(typeof dArr!='undefined'){if(dArr.constructor==Array){this.populateList(dArr);}}
return'';}
var tData=this.data;if(tData!='')tData=tData+'&';if(this.contextControls.constructor==Array){var eles=new Object();var varName='';for(var i=0;i<this.contextControls.length;i++){eles=$(this.contextControls[i]);if(!eles.tagName)varName=eles[0].name;else varName=eles.name;if(varName!='')tData=tData+a5_AJAX_Form_SubmitValueParam(varName,$gvs(eles))+'&';}}
tData=tData+a5_AJAX_Form_SubmitValueParam(tObj.name,tObj.value);a5_AJAX_Callback(this.url,tData);},populateList:function(dArr){var lObj=$(this.targetId+'.LIST');this._list=dArr;this._listTotal=dArr.length;if(dArr.length>0){var html=Array();html[html.length]='<table id="'+this.targetId+'.LISTTABLE" cellspacing="0">'
if(this.title.location=='top'||this.title.location=='both'){html[html.length]='<tr class="'+this.title.className+'">';for(var i=0;i<this.columns.length;i++)html[html.length]='<td>'+this.columns[i].title+'</td>';html[html.length]='</tr>';}
if(dArr[0].constructor==Array){for(var i=0;i<dArr.length;i++){html[html.length]='<tr id="'+this.targetId+'.LIST.'+i+'" A5SuggestIndex="'+i+'" class="'+$if(i==0,this.item.selectedClassName,this.item.className)+'">';for(var j=0;j<this.columns.length;j++){if(this.columns[j].key)html[html.length]='<td class="'+this.item.keyClassName+'">'+dArr[i][j]+'</td>';else html[html.length]='<td>'+dArr[i][j]+'</td>';}
html[html.length]='</tr>';}}else{for(var i=0;i<dArr.length;i++){html[html.length]='<tr id="'+this.targetId+'.LIST.'+i+'" A5SuggestIndex="'+i+'" class="'+$if(i==0,this.item.selectedClassName,this.item.className)+'">';html[html.length]='<td class="'+this.item.keyClassName+'">'+dArr[i]+'</td>';html[html.length]='</tr>';}}
if(this.title.location=='bottom'||this.title.location=='both'){html[html.length]='<tr class="'+this.title.className+'">';for(var i=0;i<this.columns.length;i++)html[html.length]='<td>'+this.columns[i].title+'</td>';html[html.length]='</tr>';}
html[html.length]='</table>';lObj.innerHTML=html.join('');for(var i=0;i<dArr.length;i++){$e.add($(this.targetId+'.LIST.'+i),'click',this._selectValue,this);}
lObj.style.display='block';lObj.style.height=this.height;var tObj=$(this.targetId+'.LISTTABLE');lObj.style.display='block';lObj.style.height=this.height;if(lObj.offsetHeight>tObj.offsetHeight){lObj.style.height='';}
if(this.width!=''){if(lObj.clientWidth>tObj.offsetWidth)tObj.style.width=lObj.clientWidth+'px';}else{lObj.style.width=(tObj.offsetWidth+22)+'px';if(lObj.clientWidth>tObj.offsetWidth)tObj.style.width=lObj.clientWidth+'px';}
this._scrollToEntry();}else{lObj.style.display='none';}
this._listValue=0;},_defaultColumn:{title:'',type:'text',key:false}}
a5_AJAX_editCombo=Class.create();a5_AJAX_editCombo.prototype={initialize:function(targetId,buttonId,settings){this.targetId=targetId;this.buttonId=buttonId;$u.o.assign(this,{data:[],width:'',height:'',columns:0,className:'',item:{className:'',selectedClassName:'',keyClassName:''},title:{className:'',location:'none'},onSelect:0});if(typeof a5_AJAX_editComboDefaults!='undefined')$u.o.assign(this,a5_AJAX_editComboDefaults);$u.o.assign(this,settings);$e.add(targetId,'focus',this._focus,this,true);$e.add(targetId,'blur',this._hideMatchList,this,true);$e.add(targetId,'keyup',this._autoComplete,this,true);$e.add(buttonId,'click',this._getFullList,this,true);this._kw=new AUI.KeyWatcher([{key:'enter',handle:this._selectCurValue},{key:'up',handle:this._prevValue},{key:'down',handle:this._nextValue}],this);this._listValue=0;this._listTotal=0;this._list=[];this._keyIndex=-1;this._timeout=0;this._hasFocus=false;this._parseColumns();var ele=document.createElement('div');ele.id=this.targetId+'.LIST';ele.className=this.className;ele.style.position='absolute';ele.style.display='none';ele.style.width=this.width;ele.style.height=this.height;ele.style.overflow='auto';ele.style.zIndex='10000';$e.add(ele,'mousedown',this._stopBlur,this,true);$e.add(ele,'focus',this._stopBlur,this,true);$(targetId).parentNode.insertBefore(ele,$(targetId));},fixButtonPosition:function(){var widthAdjust=typeof arguments[0]!='undefined'?arguments[0]:-3;var heightAdjust=typeof arguments[1]!='undefined'?arguments[1]:0;var xAdjust=typeof arguments[2]!='undefined'?arguments[2]:-2;var yAdjust=typeof arguments[3]!='undefined'?arguments[3]:0;var iEle=$(this.targetId);var bEle=$(this.buttonId);bEle.style.height=(iEle.offsetHeight+heightAdjust)+'px';bEle.style.width=(iEle.offsetHeight+widthAdjust)+'px';bEle.style.left=(($gpl(iEle)+iEle.offsetWidth)-$gpl(bEle)+xAdjust)+'px';bEle.style.top=($gpt(iEle)-$gpt(bEle)+yAdjust)+'px';},_stopBlur:function(e){e=$e.getEvent(e);$e.stopEvent(e);this._timeout=clearTimeout(this._timeout);this._hasFocus=true;$(this.targetId).focus();return false;},_parseColumns:function(e){if(this.columns.constructor==Array){var keyFlag=false;var colTitle='';for(var i=0;i<this.columns.length;i++){if(typeof this.columns[i]=='object'){$u.o.assign(this.columns[i],this._defaultColumn,true);if(!keyFlag&&this.columns[i].key){keyFlag=true;this._keyIndex=i;}else if(keyFlag&&this.columns[i].key)this.columns[i].key=false;}else{colTitle=this.columns[i];this.columns[i]=new Object();$u.o.assign(this.columns[i],this._defaultColumn);this.columns[i].title=''+colTitle;}}
if(!keyFlag){this.columns[0].key=true;this._keyIndex=0;}}else{var colTitle=this.columns;this.columns=new Array();this.columns[0]=new Object();$u.o.assign(this.columns[0],this._defaultColumn);this.columns[0].title=''+colTitle;this.columns[0].key=true;}},_focus:function(e){if(this._hasFocus==false){e=$e.getEvent(e);var lObj=$(this.targetId+'.LIST');$po(lObj,$(this.targetId),14,2,0);this._kw.on();this._hasFocus=true;}},_hideMatchList:function(e){var lObj=$(this.targetId+'.LIST');classInst=this;this._hasFocus=false;this._timeout=setTimeout(function(){classInst._hideMatchListComplete();},400);},_hideMatchListComplete:function(){var lObj=$(this.targetId+'.LIST');lObj.style.display='none';this._kw.off();},_selectValue:function(e,classInst){var indx=Number(this.getAttribute('A5EditComboIndex'));var val=typeof classInst._list[indx]!='undefined'?classInst._list[indx]:'';var finVal=val;if(finVal.constructor==Array){var keyIndx=0;for(var i=0;i<classInst.columns.length;i++){if(classInst.columns[i].key){keyIndx=i;break;}}
finVal=finVal[keyIndx];}
if(finVal!='')$(classInst.targetId).value=finVal;if(classInst.onSelect.constructor==Function)classInst.onSelect(val);var lObj=$(classInst.targetId+'.LIST');lObj.style.display='none';classInst._stopBlur(e)},_selectCurValue:function(e){var val=typeof this._list[this._listValue]!='undefined'?this._list[this._listValue]:'';var finVal=val;if(finVal.constructor==Array){var keyIndx=0;for(var i=0;i<this.columns.length;i++){if(this.columns[i].key){keyIndx=i;break;}}
finVal=finVal[keyIndx];}
if(finVal!='')$(this.targetId).value=finVal;if(this.onSelect.constructor==Function)this.onSelect(val);var lObj=$(this.targetId+'.LIST');lObj.style.display='none';},_nextValue:function(e){if(this._listValue<this._listTotal-1){$(this.targetId+'.LIST.'+this._listValue).className=this.item.className;this._listValue=this._listValue+1;$(this.targetId+'.LIST.'+this._listValue).className=this.item.selectedClassName;this._scrollToEntry();}},_prevValue:function(e){if(this._listValue>0){$(this.targetId+'.LIST.'+this._listValue).className=this.item.className;this._listValue=this._listValue-1;$(this.targetId+'.LIST.'+this._listValue).className=this.item.selectedClassName;this._scrollToEntry();}},_scrollToEntry:function(){var ele=$(this.targetId+'.LIST.'+this._listValue);var cEle=$(this.targetId+'.LIST');if(cEle.scrollTop>ele.offsetTop)cEle.scrollTop=ele.offsetTop-2;else if(cEle.scrollTop+cEle.offsetHeight<(ele.offsetTop+ele.offsetHeight))cEle.scrollTop=ele.offsetTop+(ele.offsetHeight)-cEle.offsetHeight;},_autoComplete:function(e){e=$e.getEvent(e);var keyCode=e.charCode||e.keyCode;if(keyCode==13||keyCode==37||keyCode==38||keyCode==39||keyCode==40)return false;var lObj=$(this.targetId+'.LIST');var tObj=$(this.targetId)
if(tObj.value.length<this.minimum){lObj.style.display='none';return'';}
var dArr=new Array();var curVal=tObj.value;curVal=curVal.toLowerCase();curValLen=curVal.length;if(this.data[0].constructor!=Array&&curValLen>0){for(var i=0;i<this.data.length;i++){if(curVal==this.data[i].substr(0,curValLen).toLowerCase())dArr[dArr.length]=this.data[i];}}else if(curValLen>0){for(var i=0;i<this.data.length;i++){if(curVal==this.data[i][this._keyIndex].substr(0,curValLen).toLowerCase())dArr[dArr.length]=this.data[i];}}
this._getList(dArr);},_getFullList:function(){var dArr=this.data;clearTimeout(this._timeout);this._timeout=0;this._kw.off();$(this.targetId).focus();this._getList(dArr);},_getList:function(dArr){var lObj=$(this.targetId+'.LIST');this._list=dArr;this._listTotal=dArr.length;this._listValue=0;var curVal=$(this.targetId).value;if(this._list.length>0){var html=Array();html[html.length]='<table id="'+this.targetId+'.LISTTABLE" id="'+this.targetId+'.LIST.TABLE" cellspacing="0">'
if(this.title.location=='top'||this.title.location=='both'){html[html.length]='<tr class="'+this.title.className+'">';for(var i=0;i<this.columns.length;i++)html[html.length]='<td>'+this.columns[i].title+'</td>';html[html.length]='</tr>';}
if(dArr[0].constructor==Array){for(var i=0;i<dArr.length;i++){html[html.length]='<tr id="'+this.targetId+'.LIST.'+i+'" A5EditComboIndex="'+i+'" class="'+this.item.className+'">';for(var j=0;j<this.columns.length;j++){if(this.columns[j].key){if(curVal==dArr[i][j])this._listValue=i;html[html.length]='<td class="'+this.item.keyClassName+'">'+dArr[i][j]+'</td>';}else html[html.length]='<td>'+dArr[i][j]+'</td>';}
html[html.length]='</tr>';}}else{for(var i=0;i<dArr.length;i++){if(curVal==dArr[i])this._listValue=i;html[html.length]='<tr id="'+this.targetId+'.LIST.'+i+'" A5EditComboIndex="'+i+'" class="'+this.item.className+'">';html[html.length]='<td class="'+this.item.keyClassName+'">'+dArr[i]+'</td>';html[html.length]='</tr>';}}
if(this.title.location=='bottom'||this.title.location=='both'){html[html.length]='<tr class="'+this.title.className+'">';for(var i=0;i<this.columns.length;i++)html[html.length]='<td>'+this.columns[i].title+'</td>';html[html.length]='</tr>';}
html[html.length]='</table>';lObj.innerHTML=html.join('');$(this.targetId+'.LIST.'+this._listValue).className=this.item.selectedClassName;for(var i=0;i<dArr.length;i++){$e.add($(this.targetId+'.LIST.'+i),'click',this._selectValue,this);}
lObj.style.height=this.height;var tObj=$(this.targetId+'.LISTTABLE');lObj.style.display='block';lObj.style.height=this.height;if(lObj.offsetHeight>tObj.offsetHeight){lObj.style.height='';}
if(this.width!=''){if(lObj.clientWidth>tObj.offsetWidth)tObj.style.width=lObj.clientWidth+'px';}else{lObj.style.width=(tObj.offsetWidth+22)+'px';if(lObj.clientWidth>tObj.offsetWidth)tObj.style.width=lObj.clientWidth+'px';}
this._scrollToEntry();}else{lObj.style.display='none';}},_defaultColumn:{title:'',type:'text',key:false}}
a5_AJAX_tree=Class.create();a5_AJAX_tree.prototype={initialize:function(contId,data,options){this.contId=contId
var fullOptions={inputId:'',focusClassName:'',multiple:false,separator:'.',loadingMessage:'Loading...',dynamicDataURL:'',dynamicDataHandle:'',node:{className:'',selectedClassName:'',labelClassName:'',icon:'',expandedIcon:'',collapsedIcon:'',leaf:{firstImage:'',image:'',lastImage:''},branch:{firstExpandedImage:'',firstCollapsedImage:'',firstExpandedHoverImage:'',firstCollapsedHoverImage:'',expandedImage:'',collapsedImage:'',expandedHoverImage:'',collapsedHoverImage:'',lastExpandedImage:'',lastCollapsedImage:'',lastExpandedHoverImage:'',lastCollapsedHoverImage:''}},branch:{className:'',lineImage:'',nullImage:''},onFocus:0,onBlur:0,onRightClick:0,onNodeSelect:0,onNodeClick:0,onNodeExpand:0,onNodeCollapse:0,selection:[],value:[],_hasFocus:false};$u.o.assign(fullOptions,options);if(typeof a5_AJAX_treeDefaults!='undefined')$u.o.assign(fullOptions,a5_AJAX_treeDefaults);if(fullOptions.node.collapsedIcon=='')fullOptions.node.collapsedIcon=fullOptions.node.icon;if(fullOptions.node.expandedIcon=='')fullOptions.node.expandedIcon=fullOptions.node.collapsedIcon;if(fullOptions.node.selectedCollapsedIcon=='')fullOptions.node.selectedCollapsedIcon=fullOptions.node.selectedIcon;if(fullOptions.node.selectedExpandedIcon=='')fullOptions.node.selectedExpandedIcon=fullOptions.node.selectedCollapsedIcon;if(fullOptions.branch.lineImage=='')fullOptions.branch.lineImage=fullOptions.branch.nullImage;if(fullOptions.node.leaf.image=='')fullOptions.node.leaf.image=fullOptions.branch.nullImage;if(fullOptions.node.branch.expandedImage=='')fullOptions.node.branch.expandedImage=fullOptions.branch.nullImage;if(fullOptions.node.branch.collapsedImage=='')fullOptions.node.branch.collapsedImage=fullOptions.branch.nullImage;if(fullOptions.node.leaf.firstImage=='')fullOptions.node.leaf.firstImage=fullOptions.node.leaf.image;if(fullOptions.node.leaf.lastImage=='')fullOptions.node.leaf.lastImage=fullOptions.node.leaf.image;if(fullOptions.node.branch.firstExpandedImage=='')fullOptions.node.branch.firstExpandedImage=fullOptions.node.branch.expandedImage;if(fullOptions.node.branch.lastExpandedImage=='')fullOptions.node.branch.lastExpandedImage=fullOptions.node.branch.expandedImage;if(fullOptions.node.branch.firstCollapsedImage=='')fullOptions.node.branch.firstCollapsedImage=fullOptions.node.branch.collapsedImage;if(fullOptions.node.branch.lastCollapsedImage=='')fullOptions.node.branch.lastCollapsedImage=fullOptions.node.branch.collapsedImage;if(fullOptions.node.branch.firstExpandedHoverImage=='')fullOptions.node.branch.firstExpandedHoverImage=fullOptions.node.branch.expandedHoverImage;if(fullOptions.node.branch.lastExpandedHoverImage=='')fullOptions.node.branch.lastExpandedHoverImage=fullOptions.node.branch.expandedHoverImage;if(fullOptions.node.branch.firstCollapsedHoverImage=='')fullOptions.node.branch.firstCollapsedHoverImage=fullOptions.node.branch.collapsedHoverImage;if(fullOptions.node.branch.lastCollapsedHoverImage=='')fullOptions.node.branch.lastCollapsedHoverImage=fullOptions.node.branch.collapsedHoverImage;$u.o.assign(this,fullOptions);this.populate(data);this._keyWatch=new AUI.KeyWatcher([{key:'up',handle:this._keyPrevNode},{key:'down',handle:this._keyNextNode},{key:'left',handle:this._keyBranchNode},{key:'right',handle:this._keyChildNode},{key:'enter',handle:this._keyEnter},{key:'tab',handle:this._blur},{key:'shift+tab',handle:this._blur}],this);var contElement=$(contId);var HTMLFocusCatcher=document.createElement('input');HTMLFocusCatcher.id=contId+'.FOCUSCATCHER';HTMLFocusCatcher.readonly=true;HTMLFocusCatcher.style.position='absolute';HTMLFocusCatcher.style.top='-20px';HTMLFocusCatcher.style.left='-20px';HTMLFocusCatcher.style.height='1px';HTMLFocusCatcher.style.width='1px';HTMLFocusCatcher.style.fontSize='0px';$e.add(HTMLFocusCatcher,'focus',this._focus,this,true);$e.add(contElement,'click',this._focus,this,true);$e.add(contElement,'contextmenu',this._rClick,this,true);contElement.parentNode.insertBefore(HTMLFocusCatcher,contElement);},populate:function(data){this.data=this._expandTreeData(data);var HTMLNodes=this._generateHTMLNodes([],[],this.data,true,'');HTMLNodes.id=this.contId+'.TREE';var contElement=$(this.contId);contElement.innerHTML='';contElement.insertBefore(HTMLNodes,contElement.lastChild);},populateNode:function(nodeLoc,data){data=this._expandTreeData(data);var nodeImages=new Array();nodeImages[nodeImages.length]=$if(nodeLoc[0]==this.data.length-1,this.branch.nullImage,this.branch.lineImage);var dataNode=this.data[nodeLoc[0]];for(var i=1;i<nodeLoc.length;i++){nodeImages[i]=$if(nodeLoc[i]==dataNode.children.length-1,this.branch.nullImage,this.branch.lineImage);dataNode=dataNode.children[nodeLoc[i]];}
dataNode.children=data;dataNode.location=nodeLoc;dataNode.expanded=true;var HTMLNodes=this._generateHTMLNodes(nodeLoc,nodeImages,data,true,dataNode.branchClassName);$(this.contId+'.'+nodeLoc.join('.')).appendChild(HTMLNodes);var iNode=$(this.contId+'.'+dataNode.location.join('.')+'.LABEL').previousSibling;$e.remove(iNode,'mouseup',this._clickToggleBranch);$e.add(iNode,'mouseup',this._clickToggleBranch,this);if(this.node.branch.collapsedHoverImage!=''||dataNode.collapsedHoverImage!=''){$e.remove(iNode,'mouseover',this._nodeImageMouseOver);$e.remove(iNode,'mouseout',this._nodeImageMouseOut);$e.add(iNode,'mouseover',this._nodeImageMouseOver,this);$e.add(iNode,'mouseout',this._nodeImageMouseOut,this);}
if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.expandedImage);},getDataNode:function(dataLoc){if(dataLoc.length==0)return 0;var dataNode=this.data[dataLoc[0]];if(typeof dataLoc[0]=='number'){var dataNode=this.data[dataLoc[0]];var parsedNodeLoc=[dataLoc[0]];}else{for(var i=0;i<this.data.length;i++){if(this.data[i].value.toLowerCase()==String(dataLoc[0]).toLowerCase()){var dataNode=this.data[i];var parsedNodeLoc=[i];break;}}}
for(var i=1;i<dataLoc.length;i++){if(typeof dataLoc[i]=='number'){dataNode=dataNode.children[dataLoc[i]];parsedNodeLoc[parsedNodeLoc.length]=dataLoc[i];}else{for(var j=0;j<dataNode.children.length;j++){if(dataNode.children[j].value.toLowerCase()==String(dataLoc[i]).toLowerCase()){dataNode=dataNode.children[j];parsedNodeLoc[parsedNodeLoc.length]=j;break;}}}}
dataNode.location=parsedNodeLoc;return dataNode;},scrollToNode:function(dataNode){var bId=this.contId+'.'+dataNode.location.join('.')+'.LABEL';if($(bId)){var bNode=$(bId);var cEle=$(this.contId);if(cEle.scrollTop>bNode.offsetTop-(bNode.parentNode.offsetHeight*2))cEle.scrollTop=bNode.offsetTop-(bNode.parentNode.offsetHeight*2)
else if(cEle.scrollTop+cEle.offsetHeight<bNode.offsetTop)cEle.scrollTop=bNode.offsetTop+(bNode.parentNode.offsetHeight)-cEle.offsetHeight;cEle.scrollLeft=bNode.offsetLeft-40;}},setValue:function(){this._deselectAll();var selClassName='';var dataNode=new Object();var dataLoc=0;var valArr=0;var valStart=arguments.length-1;if(this.multiple)valStart=0;for(var i=valStart;i<arguments.length;i++){dataNode=0;if(arguments[i].constructor==Array)dataNode=this.getDataNode(arguments[i]);else{valArr=String(arguments[i]).split(this.separator);if(valArr.length>1)dataNode=this.getDataNode(valArr);else{dataLoc=new Array();this._getDataNodeFromValue(arguments[i],this.data,dataLoc);dataLoc.reverse();dataNode=this.getDataNode(dataLoc);}}
if(typeof dataNode=='object'){selClassName=this._gDef(dataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$acn($(this.contId+'.'+dataNode.location.join('.')).firstChild,selClassName);this.selection[this.selection.length]=dataNode;}}},_expandTreeData:function(data){var tempData=new Object();for(var i=0;i<data.length;i++){if(typeof data[i]!='object'){tempData={html:''+$u.s.tran(data[i],['<','>'],['&lt;','&gt;']),value:''+data[i]};$u.o.assign(tempData,this._defaultNode,true);data[i]=tempData;}else{if(typeof data[i].value!='undefined')data[i].defaultValue=false;$u.o.assign(data[i],this._defaultNode,true);if(data[i].value==''&&data[i].html!='')data[i].value=data[i].html;else if(data[i].html==''&&data[i].value!='')data[i].html=$u.s.tran(data[i].value,['<','>'],['&lt;','&gt;']);if(data[i].children.constructor==Array)data[i].children=this._expandTreeData(data[i].children);}
if(i==data.length-1)data[i].isLast=true;else data[i].isLast=false;}
return data;},_getPrevVisDataNode:function(dataNode){var dataLoc=new Array();for(var i=0;i<dataNode.location.length;i++)dataLoc[i]=dataNode.location[i];if(dataLoc[dataLoc.length-1]==0){dataLoc.pop();return this.getDataNode(dataLoc);}else{dataLoc[dataLoc.length-1]--;var newDataNode=this.getDataNode(dataLoc);while(newDataNode.expanded){dataLoc.push(newDataNode.children.length-1);newDataNode=this.getDataNode(dataLoc);}
return newDataNode;}},_getNextVisDataNode:function(dataNode){var dataLoc=new Array();for(var i=0;i<dataNode.location.length;i++)dataLoc[i]=dataNode.location[i];if(dataNode.isLast&&!dataNode.expanded){dataLoc.pop();if(dataLoc.length==0)return false;var newDataNode=this.getDataNode(dataLoc);while(newDataNode.isLast){dataLoc.pop();if(dataLoc.length==0)return false;newDataNode=this.getDataNode(dataLoc);}
dataLoc[dataLoc.length-1]++;return this.getDataNode(dataLoc);}else{if(dataNode.expanded){dataLoc[dataLoc.length]=0;return this.getDataNode(dataLoc);}else{dataLoc[dataLoc.length-1]++;return this.getDataNode(dataLoc);}}},_getDataNodeFromValue:function(value,data,dataLoc){var dataNode=0;for(var i=0;i<data.length;i++){if(data[i].value==value){dataLoc[0]=i;break;}
if(data[i].children.constructor==Array)this._getDataNodeFromValue(value,data[i].children,dataLoc);if(dataLoc.length>0){dataLoc.push(i);break;}}},_getDataNodeValue:function(dataNode){if(dataNode.defaultValue){var valDataNode=new Object();var valDataLoc=new Array();var curValue='';for(var i=0;i<dataNode.location.length;i++)valDataLoc[i]=dataNode.location[i];for(var i=valDataLoc.length-1;i>=0;i--){valDataNode=this.getDataNode(valDataLoc);curValue=$if(i!=0,this.separator,'')+valDataNode.value+curValue;valDataLoc.pop();}
return curValue;}else{return dataNode.value;}},_generateHTMLNodes:function(parentNodeLocs,parentNodeLineImages,data,expanded,branchClassName){var ulNode=document.createElement('ul');var liNode=new Object();var divNode=new Object();var buttonNode=new Object();var tempNode=new Object();var tempNodeloc=new Array();var tempLineImages=new Array();var joinedParentLocs=parentNodeLocs.join('.');var baseId='';var isLast=false;var curIcon='';ulNode.className=this._gDef(branchClassName,this.branch.className);ulNode.style.margin='0px';ulNode.style.padding='0px';ulNode.style.listStyle='none';if(!expanded)ulNode.style.display='none';ulNode.unselectable='on';for(var i=0;i<data.length;i++){baseId=$if(joinedParentLocs!='',this.contId+'.'+joinedParentLocs+'.'+i,this.contId+'.'+i);liNode=document.createElement('li');liNode.style.margin='0px';liNode.style.padding='0px';liNode.id=baseId;liNode.setAttribute('A5AJAXTreeNodeLocation',$if(joinedParentLocs!='',joinedParentLocs+'.'+i,i))
liNode.unselectable='on';divNode=document.createElement('div');divNode.className=this._gDef(data[i].className,this.node.className);divNode.style.whiteSpace='nowrap';divNode.unselectable='on';if(i==data.length-1)isLast=true;for(var j=0;j<parentNodeLineImages.length;j++){tempNode=document.createElement('img');tempNode.src=parentNodeLineImages[j];tempNode.style.verticalAlign='middle';tempNode.align='absmiddle';divNode.appendChild(tempNode);}
buttonNode=document.createElement('a');buttonNode.tabIndex=1;buttonNode.href="#";$e.add(buttonNode,'mouseup',this._clickNode,this);buttonNode.className=this._gDef(data[i].labelClassName,this.node.labelClassName);buttonNode.id=baseId+'.LABEL';buttonNode.unselectable='on';if(typeof data[i].children=='object'||typeof data[i].children=='string'){if(data[i].children.constructor!=Array)data[i].expanded=false;tempNode=document.createElement('img');if(data[i].expanded){curIcon=this._gDef(data[i].expandedIcon,this.node.expandedIcon);if(i==0&&parentNodeLocs.length==0)tempNode.src=this._gDef(data[i].expandedImage,this.node.branch.firstExpandedImage);else if(isLast)tempNode.src=this._gDef(data[i].expandedImage,this.node.branch.lastExpandedImage);else tempNode.src=this._gDef(data[i].expandedImage,this.node.branch.expandedImage);}else{curIcon=this._gDef(data[i].collapsedIcon,this.node.collapsedIcon);if(i==0&&parentNodeLocs.length==0)tempNode.src=this._gDef(data[i].collapsedImage,this.node.branch.firstCollapsedImage);else if(isLast)tempNode.src=this._gDef(data[i].collapsedImage,this.node.branch.lastCollapsedImage);else tempNode.src=this._gDef(data[i].collapsedImage,this.node.branch.collapsedImage);}
if(this.node.branch.collapsedHoverImage!=''||data[i].collapsedHoverImage!=''){$e.add(tempNode,'mouseover',this._nodeImageMouseOver,this);$e.add(tempNode,'mouseout',this._nodeImageMouseOut,this);}
tempNode.style.verticalAlign='middle';tempNode.align='absmiddle';$e.add(tempNode,'mouseup',this._clickToggleBranch,this);divNode.appendChild(tempNode);if(curIcon!=''){buttonNode.innerHTML='<img id="'+baseId+'.LABELICON" src="'+curIcon+'" style="border: none" align="absmiddle" /> '+data[i].html;}else{buttonNode.innerHTML=data[i].html;}
divNode.appendChild(buttonNode);if(data[i].children.constructor==Array){if(parentNodeLocs.length==0){tempNodeLocs=new Array();tempLineImages=new Array();}else{tempNodeLocs=parentNodeLocs.concat([]);tempLineImages=parentNodeLineImages.concat([]);}
tempNodeLocs[tempNodeLocs.length]=i;tempLineImages[tempLineImages.length]=$if(isLast,this.branch.nullImage,this.branch.lineImage);liNode.appendChild(divNode);liNode.appendChild(this._generateHTMLNodes(tempNodeLocs,tempLineImages,data[i].children,data[i].expanded,data[i].branchClassName));}else liNode.appendChild(divNode);}else{tempNode=document.createElement('img');if(i==0&&parentNodeLocs.length==0)tempNode.src=this._gDef(data[i].image,this.node.leaf.firstImage);else if(isLast)tempNode.src=this._gDef(data[i].image,this.node.leaf.lastImage);else tempNode.src=this._gDef(data[i].image,this.node.leaf.image);tempNode.style.verticalAlign='middle';tempNode.align='absmiddle';divNode.appendChild(tempNode);curIcon=this._gDef(data[i].icon,this.node.icon);if(curIcon!=''){buttonNode.innerHTML='<img id="'+baseId+'.LABELICON" src="'+curIcon+'" style="border: none" align="absmiddle" /> '+data[i].html;}else{buttonNode.innerHTML=data[i].html;}
divNode.appendChild(buttonNode);liNode.appendChild(divNode);}
ulNode.appendChild(liNode);}
return ulNode;},_clickToggleBranch:function(e,classInstance){var liEle=this.parentNode.parentNode;var dataLocArr=String(liEle.getAttribute('A5AJAXTreeNodeLocation')).split('.');for(var i=0;i<dataLocArr.length;i++)dataLocArr[i]=Number(dataLocArr[i]);var dataNode=classInstance.getDataNode(dataLocArr,false);classInstance._toggleBranch(dataNode,true);},_toggleBranch:function(dataNode){if(dataNode.children.constructor!=Array){if(dataNode.dynamicDataHandle.constructor==Function||this.dynamicDataHandle.constructor==Function){if(dataNode.dynamicDataHandle.constructor==Function)var resData=dataNode.dynamicDataHandle(dataNode);else var resData=this.dynamicDataHandle(dataNode);if(resData.constructor==Array){this.populateNode(dataNode.location,resData);if(dataNode.onExpand.constructor==Function)dataNode.onExpand(dataNode);else if(this.onNodeExpand.constructor==Function)this.onNodeExpand(dataNode);}}else{var curValue=urlencode(this._getDataNodeValue(dataNode));var dataURL='';if(typeof dataNode.children=='object'){if(dataNode.children.url)dataURL=dataNode.children.url;if(dataURL=='')dataURL=this.dynamicDataURL;if(dataURL!='')new $a.simple(dataURL,{data:A5.ajax.addParamRequiredData($if(dataNode.children.data,dataNode.children.data+'&','')+'A5AJAXTreeNodeLoaction=['+dataNode.location.join(',')+']&A5AJAXTreeNodeValue='+curValue+'&__Ajax=true'),handle:this._responseHandle,handleContext:this})}else{dataURL=''+dataNode.children;if(dataURL.substr(0,1)=='?')dataURL=this.dynamicDataURL;if(dataURL!='')new $a.simple(dataURL,{data:A5.ajax.addParamRequiredData('A5AJAXTreeNodeLoaction=['+dataNode.location.join(',')+']&A5AJAXTreeNodeValue='+curValue+'&__Ajax=true'),handle:this._responseHandle,handleContext:this})}
$(this.contId+'.'+dataNode.location.join('.')+'.LABEL').innerHTML=this.loadingMessage;}
var iNode=$(this.contId+'.'+dataNode.location.join('.')+'.LABEL').previousSibling;if(arguments[1]){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.firstExpandedHoverImage,dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.lastExpandedHoverImage,dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.expandedHoverImage,dataNode.expandedImage,this.node.branch.expandedImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.expandedImage);}
dataNode.expanded=true;}else{var iNode=$(this.contId+'.'+dataNode.location.join('.')+'.LABEL').previousSibling;var bNode=$(this.contId+'.'+dataNode.location.join('.')).lastChild;while(!bNode.tagName){bNode=bNode.previousSibling;}
if(bNode.style.display=='none'){if(arguments[1]){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.firstExpandedHoverImage,dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.lastExpandedHoverImage,dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.expandedHoverImage,dataNode.expandedImage,this.node.branch.expandedImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.expandedImage);}
var curIcon=this._gDef(dataNode.expandedIcon,this.node.expandedIcon);if(curIcon!=''){if($(this.contId+'.'+dataNode.location.join('.')+'.LABELICON')){$(this.contId+'.'+dataNode.location.join('.')+'.LABELICON').src=curIcon;}}
bNode.style.display='block';dataNode.expanded=true;if(dataNode.onExpand.constructor==Function)dataNode.onExpand(dataNode);else if(this.onNodeExpand.constructor==Function)this.onNodeExpand(dataNode);}else{if(arguments[1]){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.collapsedHoverImage,this.node.branch.firstCollapsedHoverImage,dataNode.collapsedImage,this.node.branch.firstCollapsedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.collapsedHoverImage,this.node.branch.lastCollapsedHoverImage,dataNode.collapsedImage,this.node.branch.lastCollapsedImage);else iNode.src=this._gDef(dataNode.collapsedHoverImage,this.node.branch.collapsedHoverImage,dataNode.collapsedImage,this.node.branch.collapsedImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.collapsedImage,this.node.branch.firstCollapsedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.collapsedImage,this.node.branch.lastCollapsedImage);else iNode.src=this._gDef(dataNode.collapsedImage,this.node.branch.collapsedImage);}
var curIcon=this._gDef(dataNode.collapsedIcon,this.node.collapsedIcon);if(curIcon!=''){if($(this.contId+'.'+dataNode.location.join('.')+'.LABELICON')){$(this.contId+'.'+dataNode.location.join('.')+'.LABELICON').src=curIcon;}}
bNode.style.display='none';dataNode.expanded=false;if(dataNode.onCollapse.constructor==Function)dataNode.onCollapse(dataNode);else if(this.onNodeCollapse.constructor==Function)this.onNodeCollapse(dataNode);}}},_selectNode:function(dataNode){var curValue=[];var selClassName='';if(this.multiple&&(this._keyWatch.ctrl||this._keyWatch.shift)){var addToSel=true;for(var i=0;i<this.selection.length;i++){if(this.selection[i].location.join('.')==dataNode.location.join('.')){selClassName=this._gDef(this.selection[i].selectedClassName,this.node.selectedClassName);if(selClassName!='')$rcn($(this.contId+'.'+this.selection[i].location.join('.')).firstChild,selClassName);this.selection.splice(i,1);addToSel=false;break;}}
if(addToSel){selClassName=this._gDef(dataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$acn($(this.contId+'.'+dataNode.location.join('.')).firstChild,selClassName);this.selection[this.selection.length]=dataNode;}}else{this._deselectAll();selClassName=this._gDef(dataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$acn($(this.contId+'.'+dataNode.location.join('.')).firstChild,selClassName);this.selection[0]=dataNode;}
for(var i=0;i<this.selection.length;i++){curValue[i]=this._getDataNodeValue(this.selection[i])}
this.value=curValue;if(this.inputId!='')$(this.inputId).value=curValue.join('\n');if(dataNode.onSelect.constructor==Function)dataNode.onSelect(dataNode);else if(this.onNodeSelect.constructor==Function)this.onNodeSelect(dataNode);},_deselectAll:function(){var oldDataNode=new Object();for(var i=0;i<this.selection.length;i++){oldDataNode=this.selection[i];if(typeof oldDataNode=='object'){selClassName=this._gDef(oldDataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$rcn($(this.contId+'.'+oldDataNode.location.join('.')).firstChild,selClassName);}}
this.selection=new Array();},_nodeImageMouseOver:function(e,classInstance){var liEle=this.parentNode.parentNode;var dataLocArr=String(liEle.getAttribute('A5AJAXTreeNodeLocation')).split('.');for(var i=0;i<dataLocArr.length;i++)dataLocArr[i]=Number(dataLocArr[i]);var dataNode=classInstance.getDataNode(dataLocArr,false);if(dataNode.expanded){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)this.src=classInstance._gDef(dataNode.expandedHoverImage,classInstance.node.branch.firstExpandedHoverImage);else if(dataNode.isLast)this.src=classInstance._gDef(dataNode.expandedHoverImage,classInstance.node.branch.lastExpandedHoverImage);else this.src=classInstance._gDef(dataNode.expandedHoverImage,classInstance.node.branch.expandedHoverImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)this.src=classInstance._gDef(dataNode.collapsedHoverImage,classInstance.node.branch.firstCollapsedHoverImage);else if(dataNode.isLast)this.src=classInstance._gDef(dataNode.collapsedHoverImage,classInstance.node.branch.lastCollapsedHoverImage);else this.src=classInstance._gDef(dataNode.collapsedHoverImage,classInstance.node.branch.collapsedHoverImage);}},_nodeImageMouseOut:function(e,classInstance){var liEle=this.parentNode.parentNode;var dataLocArr=String(liEle.getAttribute('A5AJAXTreeNodeLocation')).split('.');for(var i=0;i<dataLocArr.length;i++)dataLocArr[i]=Number(dataLocArr[i]);var dataNode=classInstance.getDataNode(dataLocArr,false);if(dataNode.expanded){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)this.src=classInstance._gDef(dataNode.expandedImage,classInstance.node.branch.firstExpandedImage);else if(dataNode.isLast)this.src=classInstance._gDef(dataNode.expandedImage,classInstance.node.branch.lastExpandedImage);else this.src=classInstance._gDef(dataNode.expandedImage,classInstance.node.branch.expandedImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)this.src=classInstance._gDef(dataNode.collapsedImage,classInstance.node.branch.firstCollapsedImage);else if(dataNode.isLast)this.src=classInstance._gDef(dataNode.collapsedImage,classInstance.node.branch.lastCollapsedImage);else this.src=classInstance._gDef(dataNode.collapsedImage,classInstance.node.branch.collapsedImage);}},_clickNode:function(e,classInstance){$(classInstance.contId+'.FOCUSCATCHER').focus();var liEle=this.parentNode.parentNode;var dataLocArr=String(liEle.getAttribute('A5AJAXTreeNodeLocation')).split('.');for(var i=0;i<dataLocArr.length;i++)dataLocArr[i]=Number(dataLocArr[i]);var dataNode=classInstance.getDataNode(dataLocArr,false);classInstance._selectNode(dataNode);if(dataNode.onClick.constructor==Function)dataNode.onClick(dataNode);else if(classInstance.onNodeClick.constructor==Function)classInstance.onNodeClick(dataNode);},_keyPrevNode:function(){var oldDataNode=this.selection[this.selection.length-1];if(typeof oldDataNode=='object'){if(oldDataNode.location.join('')!='0'){var dataNode=this._getPrevVisDataNode(oldDataNode);this._selectNode(dataNode);this.scrollToNode(dataNode);}}else{this._selectNode(this.getDataNode([0]));}},_keyNextNode:function(){var oldDataNode=this.selection[this.selection.length-1];if(typeof oldDataNode=='object'){var dataNode=this._getNextVisDataNode(oldDataNode);if(typeof dataNode.location!='undefined'){this._selectNode(dataNode);this.scrollToNode(dataNode);}}else{this._selectNode(this.getDataNode([0]));}},_keyBranchNode:function(){var oldDataNode=this.selection[this.selection.length-1];if(typeof oldDataNode=='object'){if(oldDataNode.expanded==true){this._toggleBranch(oldDataNode);}else{var dataLoc=new Array();for(var i=0;i<oldDataNode.location.length-1;i++)dataLoc[i]=oldDataNode.location[i];if(dataLoc.length>0)this._selectNode(this.getDataNode(dataLoc));}}else{this._selectNode(this.getDataNode([0]));}},_keyChildNode:function(){var oldDataNode=this.selection[this.selection.length-1];if(typeof oldDataNode=='object'){if(oldDataNode.expanded==false&&(typeof oldDataNode.children=='object'||typeof oldDataNode.children=='string')){this._toggleBranch(oldDataNode);}else if(typeof oldDataNode.children=='object'||typeof oldDataNode.children=='string'){var dataNode=this._getNextVisDataNode(oldDataNode);if(typeof dataNode.location!='undefined'){this._selectNode(dataNode);this.scrollToNode(dataNode);}}}else{this._selectNode(this.getDataNode([0]));}},_keyEnter:function(){var dataNode=this.selection[this.selection.length-1];if(typeof dataNode=='object'){if(typeof dataNode.children=='object'||typeof dataNode.children=='string')this._toggleBranch(dataNode);else{if(dataNode.onClick.constructor==Function)dataNode.onClick(dataNode);else if(this.onNodeClick.constructor==Function)this.onNodeClick(dataNode);}}},_rClick:function(e,classInstance){if(classInstance.onRightClick.constructor==Function){classInstance.onRightClick();e=$e.getEvent(e);$e.stopEvent(e);return false;}},_focus:function(e){if(this._hasFocus==false){$(this.contId+'.FOCUSCATCHER').style.top=$gpt($(this.contId))+'px';this._keyWatch.on();this._hasFocus=true;$e.add(document.documentElement,'click',this._blur,this,true);if(this.focusClassName!='')$acn($(this.contId),this.focusClassName);if(this.onFocus.constructor==Function)this.onBlur();}
e=$e.getEvent(e);$e.stopEvent(e);return false;},_blur:function(){this._hasFocus=false;this._keyWatch.off();if(this.focusClassName!='')$rcn($(this.contId),this.focusClassName);$e.remove(document.documentElement,'click',this._blur);if(this.onBlur.constructor==Function)this.onBlur();},_responseHandle:function(obj){var resJSON=eval('('+obj.responseText+')');this.populateNode(resJSON.location,resJSON.data);var dataNode=this.getDataNode(resJSON.location);var baseId=this.contId+'.'+resJSON.location.join('.');var buttonNode=$(baseId+'.LABEL');var curIcon=this._gDef(dataNode.expandedIcon,this.node.expandedIcon);if(curIcon!=''){buttonNode.innerHTML='<img id="'+baseId+'.LABELICON" src="'+curIcon+'" style="border: none" align="absmiddle" /> '+dataNode.html;}else{buttonNode.innerHTML=dataNode.html;}
if(dataNode.onExpand.constructor==Function)dataNode.onExpand(dataNode);else if(this.onNodeExpand.constructor==Function)this.onNodeExpand(dataNode);},_gDef:function(val,dVal){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_defaultNode:{html:'',value:'',children:0,className:'',selectedClassName:'',labelClassName:'',branchClassName:'',icon:'',expandedIcon:'',collapsedIcon:'',image:'',expandedImage:'',collapsedImage:'',expandedHoverImage:'',collapsedHoverImage:'',onSelect:0,onClick:0,onExpand:0,onCollapse:0,dynamicDataHandle:0,expanded:false,defaultValue:true}}
a5_AJAX_window=Class.create();a5_AJAX_window.prototype={initialize:function(settings){this._dlgId='A5dlg'+this._dlgIndx[0];$u.o.assign(this,{className:'',style:'',lockUIClassName:'',title:{html:'',className:'',style:'',imageClose:'',show:true},body:{html:'',contentId:'',className:'',style:'',width:'',height:''},footer:{className:'',style:'',buttons:[],show:true},onClose:0,modal:true,autoPosition:true,autoShow:false});if(typeof a5_AJAX_windowDefaults!='undefined')$u.o.assign(this,a5_AJAX_windowDefaults);$u.o.assign(this,settings);var HTMLDlgEle=document.createElement('div');HTMLDlgEle.id=this._dlgId;HTMLDlgEle.className=this.className;HTMLDlgEle.style.display='none';HTMLDlgEle.style.position='absolute';this._zIndex=500+this._dlgIndx[0];HTMLDlgEle.style.zIndex=''+this._zIndex;var HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._dlgId+'.TITLE';HTMLDlgEle.appendChild(HTMLDlgTmplEle);HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._dlgId+'.BODY';HTMLDlgEle.appendChild(HTMLDlgTmplEle);HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._dlgId+'.FOOTER';HTMLDlgEle.appendChild(HTMLDlgTmplEle);document.body.appendChild(HTMLDlgEle);this._lockIndex=-1;if(this.body.contentId!=''){if($(this.body.contentId)){$(this._dlgId+'.BODY').appendChild($(this.body.contentId));}}
if(this.autoShow)this.show();AUI.Drag.create($(this._dlgId+'.TITLE'),{dragElementId:this._dlgId,onDragStart:function(){var ele=$(this.dragElementId);for(var i=1;i<ele.childNodes.length;i++){if(typeof ele.childNodes[i].tagName!='undefined'){ele.childNodes[i].style.visibility='hidden';}}
ele.style.opacity='.5';ele.style.filter='alpha(opacity=50)';},onDragEnd:function(){var ele=$(this.dragElementId);for(var i=0;i<ele.childNodes.length;i++){if(typeof ele.childNodes[i].tagName!='undefined')ele.childNodes[i].style.visibility='';}
ele.style.opacity='';ele.style.filter='';}});this._dlgIndx[0]=this._dlgIndx[0]+1;},position:function(val1,val2){var wEle=$(this._dlgId);if(val1.toLowerCase()=='center'){var vpSize=AUI.u.getVPSize();var vpScroll=AUI.u.getVPScroll();wEle.style.top=Math.max(Math.round(((vpSize.height)/2)-(wEle.offsetHeight/2)+vpScroll.y),0)+'px';wEle.style.left=Math.max(Math.round(((vpSize.width)/2)-(wEle.offsetWidth/2)+vpScroll.x),0)+'px';}else if(val1.toLowerCase()=='dropdown'){var pEle=$(val2);if(pEle){$po(wEle,pEle,'dropdown');}}else if(typeof val1!='undefined'&&typeof val2!='undefined'){if(typeof val1=='Number')wEle.style.top=val1+'px';else wEle.style.top=val1;if(typeof val2=='Number')wEle.style.left=val2+'px';else wEle.style.left=val2;}},resize:function(wSize,hSize){this.body.width=wSize;this.body.height=hSize;$(this._dlgId).style.width=this.body.width;var bEle=$(this._dlgId+'.BODY');bEle.style.height=this.body.height;if(this.body.width!='')bEle.style.overflowX='auto';else bEle.style.overflowX='';if(this.body.height!='')bEle.style.overflowy='auto';else bEle.style.overflowy='';},refresh:function(){if($(this._dlgId+'.TITLE.CLOSE')){var ele=$(this._dlgId+'.TITLE.CLOSE');ele.style.display='none';var classInst=this;setTimeout(function(){classInst._refreshComplete();delete classInst;},10)}},_refreshComplete:function(){var ele=$(this._dlgId+'.TITLE.CLOSE');ele.style.display='';},show:function(){this._generateHTML();var wEle=$(this._dlgId);wEle.style.zIndex=this._zIndex;wEle.style.display='block';if(typeof arguments[0]!='undefined')this.position.apply(this,arguments);else if(this.autoPosition)this.position('center');if(this.modal)this._lockIndex=AUI.LockUI.page(this.lockUIClassName,this._zIndex);},hide:function(){if(this.modal)AUI.LockUI.pageFree();$(this._dlgId).style.display='none';this._lockIndex=-1;},_generateHTML:function(){var HTMLBEle=new Object();var tEle=$(this._dlgId+'.TITLE');var bEle=$(this._dlgId+'.BODY');var fEle=$(this._dlgId+'.FOOTER');$ss(tEle,this.title.style);$ss(bEle,this.body.style);$ss(fEle,this.footer.style);if(this.title.show){tEle.innerHTML=this.title.html;if(this.title.imageClose!=''){HTMLBEle=document.createElement('img');HTMLBEle.src=this.title.imageClose;HTMLBEle.id=this._dlgId+'.TITLE.CLOSE';HTMLBEle.style.position='absolute';HTMLBEle.style.right='2px';HTMLBEle.style.cursor='default';HTMLBEle.value='cancel';$e.add(HTMLBEle,'click',this._closeWindow,this);tEle.insertBefore(HTMLBEle,tEle.firstChild);}
tEle.className=this.title.className;tEle.style.display='block';}else tEle.style.display='none';if(this.body.contentId=='')bEle.innerHTML=this.body.html;bEle.className=this.body.className;bEle.style.height=this.body.height;if(this.body.width!='')bEle.style.overflowX='auto';else bEle.style.overflowX='';if(this.body.height!='')bEle.style.overflowy='auto';else bEle.style.overflowy='';if(this.footer.show){fEle.innerHTML='';for(var i=0;i<this.footer.buttons.length;i++){$u.o.assign(this.footer.buttons[i],this._buttonDefaults,true);HTMLBEle=document.createElement('button');HTMLBEle.className=this.footer.buttons[i].className;HTMLBEle.style.width=this.footer.buttons[i].width;HTMLBEle.innerHTML=this.footer.buttons[i].html;$sa(HTMLBEle,'A5Value',this.footer.buttons[i].value);$e.add(HTMLBEle,'click',this._closeWindow,this);fEle.appendChild(HTMLBEle);HTMLBEle=document.createTextNode(' ');fEle.appendChild(HTMLBEle);}
fEle.className=this.footer.className;fEle.style.display='block';}else fEle.style.display='none';var wEle=$(this._dlgId);wEle.style.width=this.body.width;wEle.className=this.className;},_closeWindow:function(e,classInst){var closeWindow=true;if(classInst.onClose!=0)closeWindow=classInst.onClose($ga(this,'A5Value'));if(closeWindow)classInst.hide();},_buttonDefaults:{html:'',value:'',width:'',className:''},_dlgIndx:[0]}
var a5_msg_box={show:function(title,html,type,handle){if(this._dlg==0){this._dlg=new a5_AJAX_window({title:{html:'',imageClose:'images/$$window.button.close.png.a5image'},body:{html:'',width:''},footer:{buttons:[]},modal:true,autoShow:false,onClose:function(val){var result=this.handle(val);if(typeof result!='boolean')result=true;return result;}});}else{this._dlg._zIndex=500+this._dlg._dlgIndx[0]+1;if(this._dlg._lockIndex!=-1)AUI.LockUI._plLevel=AUI.LockUI._plLevel.splice(this._dlg._lockIndex,1);}
if(typeof a5_AJAX_windowDefaults!='undefined')$u.o.assign(this._dlg,a5_AJAX_windowDefaults);this._dlg.title.html=title;this._dlg.body.html=html;this._dlg.handle=handle;this._dlg.body.width=this.width;this._dlg.body.height=this.height;if(this.className!='')this._dlg.className=this.className;if(this.lockUIClassName!='')this._dlg.lockUIClassName=this.lockUIClassName;if(this.titleClassName!='')this._dlg.title.className=this.titleClassName;if(this.bodyClassName!='')this._dlg.body.className=this.bodyClassName;if(this.footerClassName!='')this._dlg.footer.className=this.footerClassName;if(this.closeButtonImage!='')this._dlg.title.imageClose=this.closeButtonImage;if(this.buttonClassName=='')this.buttonClassName=this._dlg._buttonDefaults.className;if(this.buttonWidth=='')this.buttonWidth=this._dlg._buttonDefaults.width;type=type.toLowerCase();this._dlg.footer.show=true;if(type=='o'){this._dlg.footer.buttons=[{html:'OK',value:'ok',className:this.buttonClassName,width:this.buttonWidth}];}else if(type=='oc'){this._dlg.footer.buttons=[{html:'OK',value:'ok',className:this.buttonClassName,width:this.buttonWidth},{html:'Cancel',value:'cancel',className:this.buttonClassName,width:this.buttonWidth}];}else if(type=='yn'){this._dlg.footer.buttons=[{html:'Yes',value:'yes',className:this.buttonClassName,width:this.buttonWidth},{html:'No',value:'no',className:this.buttonClassName,width:this.buttonWidth}];}else if(type=='ync'){this._dlg.footer.buttons=[{html:'Yes',value:'yes',className:this.buttonClassName,width:this.buttonWidth},{html:'No',value:'no',className:this.buttonClassName,width:this.buttonWidth},{html:'Cancel',value:'cancel',className:this.buttonClassName,width:this.buttonWidth}];}else{this._dlg.footer.buttons=[];this._dlg.footer.show=false;}
this._dlg.show();},hide:function(){this._dlg.hide();},className:'',titleClassName:'',bodyClassName:'',footerClassName:'',buttonClassName:'',buttonWidth:'',closeButtonImage:'',lockUIClassName:'',width:'',height:'',_dlg:0}
a5_AJAX_accordion=Class.create();a5_AJAX_accordion.prototype={initialize:function(contId,panes){this.contId=contId;var settings=typeof arguments[2]=='object'?arguments[2]:{};$u.o.assign(this,{titleClassName:'',titleSelectedClassName:'',titleDisabledClassName:'',paneClassName:'',paneWidth:'',paneHeight:'',onChange:0,onBeforeChange:0,onRightClick:0,onDynamicLoad:0,singleBand:true,animation:{show:{type:'',duration:500},hide:{type:'',duration:500}}},true);if(typeof a5_AJAX_accordionDefaults!='undefined')$u.o.assign(this,a5_AJAX_accordionDefaults);if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'accordion');if(typeof settings.titleClassName!='undefined'){if(settings.titleClassName.charAt(0)=='+')settings.titleClassName=this.titleClassName+' '+settings.titleClassName.substr(1);}
if(typeof settings.titleSelectedClassName!='undefined'){if(settings.titleSelectedClassName.charAt(0)=='+')settings.titleSelectedClassName=this.titleSelectedClassName+' '+settings.titleSelectedClassName.substr(1);}
if(typeof settings.titleDisabledClassName!='undefined'){if(settings.titleDisabledClassName.charAt(0)=='+')settings.titleDisabledClassName=this.titleDisabledClassName+' '+settings.titleDisabledClassName.substr(1);}
if(typeof settings.paneClassName!='undefined'){if(settings.paneClassName.charAt(0)=='+')settings.paneClassName=this.paneClassName+' '+settings.paneClassName.substr(1);}
$u.o.assign(this,settings);$(contId).style.width=this.paneWidth;var ele=new Object();this.bands=new Array();this.value=new Array();for(var i=0;i<panes.length;i++){this.bands[i]=new Object();$u.o.assign(this.bands[i],this._parseBand(panes[i]));if(this.bands[i].titleClassName.charAt(0)=='+')this.bands[i].titleClassName=this.titleClassName+' '+this.bands[i].titleClassName.substr(1);if(this.bands[i].titleSelectedClassName.charAt(0)=='+')this.bands[i].titleSelectedClassName=this.titleSelectedClassName+' '+this.bands[i].titleSelectedClassName.substr(1);if(this.bands[i].titleDisabledClassName.charAt(0)=='+')this.bands[i].titleDisabledClassName=this.titleDisabledClassName+' '+this.bands[i].titleDisabledClassName.substr(1);if(this.bands[i].paneClassName.charAt(0)=='+')this.bands[i].paneClassName=this.paneClassName+' '+this.bands[i].paneClassName.substr(1);ele=$(contId+'.'+i+'.TITLE');if(typeof ele!='undefined'){$e.add(ele,'click',this._selectBand,this);$e.add(ele,'contextmenu',this._rClick,this);if(!this.bands[i].expanded&&this.bands[i].show)ele.className=this._gDef(this.bands[i].titleClassName,this.titleClassName);else ele.className=this._gDef(this.bands[i].titleSelectedClassName,this.titleSelectedClassName);if(!this.bands[i].show)ele.style.display='none';if(this.bands[i].disabled)ele.className=this._gDef(this.bands[i].titleDisabledClassName,this.titleDisabledClassName);ele.setAttribute('A5AccordionCtrlIndex',''+i);}
ele=$(contId+'.'+i+'.PANE');if(typeof ele!='undefined'){ele.className=this._gDef(this.bands[i].paneClassName,this.paneClassName);ele.style.height=this._gDef(this.bands[i].paneHeight,this.paneHeight);if(!this.bands[i].expanded||!this.bands[i].show||this.bands[i].disabled)ele.style.display='none';else ele.style.display='block';}
if(this.bands[i].expanded&&this.bands[i].show&&!this.bands[i].disabled){this.value.push(this.bands[i].value);if(this.bands[i].onDynamicLoad.constructor==Function)this.bands[i].onDynamicLoad.call(this,this.bands[i]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.bands[i]);this.bands[i]._loaded=true;}}
this._curBandIndx=-1;},select:function(band){var toggle=typeof arguments[1]!='undefined'?arguments[1]:false;if(band.constructor!=Array)band=[band];for(var i=0;i<band.length;i++){var tIndx=this._getBandIndex(band[i]);if(this.bands[tIndx].show&&!this.bands[tIndx].disabled){var fResult=true;var poEle=false;if(this.bands[tIndx].onBeforeChange.constructor==Function)fResult=this.bands[tIndx].onBeforeChange.call(this,this.bands[tIndx]);else if(this.onBeforeChange.constructor==Function)fResult=this.onBeforeChange.call(this,this.bands[tIndx]);if(fResult){if(typeof this.bands[this._curBandIndx]!='undefined'&&this.singleBand){if(this.bands[this._curBandIndx].disabled)$(this.contId+'.'+this._curBandIndx+'.TITLE').className=this._gDef(this.bands[this._curBandIndx].titleDisabledClassName,this.titleDisabledClassName);else $(this.contId+'.'+this._curBandIndx+'.TITLE').className=this._gDef(this.bands[this._curBandIndx].titleClassName,this.titleClassName);var pEle=$(this.contId+'.'+this._curBandIndx+'.PANE');if(this.animation.hide.type=='slide'&&typeof jQuery!='undefined')jQuery(pEle).slideUp(this.animation.hide.duration);else A5.u.element.hide(pEle,this.animation.hide);for(var j=0;j<this.value.length;j++)if(this.value[j]==this.bands[this._curBandIndx].value)this.value.splice(j,1);this.bands[this._curBandIndx].expanded=false;}
if(!(this.singleBand&&this._curBandIndx==tIndx)){this._curBandIndx=tIndx;var pEle=$(this.contId+'.'+this._curBandIndx+'.PANE');if(pEle.style.display=='none'){$(this.contId+'.'+this._curBandIndx+'.TITLE').className=this._gDef(this.bands[this._curBandIndx].titleSelectedClassName,this.titleSelectedClassName);if(this.animation.show.type=='slide'&&typeof jQuery!='undefined')jQuery(pEle).slideDown(this.animation.show.duration);else A5.u.element.show(pEle,this.animation.show);this.value.push(this.bands[this._curBandIndx].value);if(!this.bands[tIndx]._loaded){if(this.bands[tIndx].onDynamicLoad.constructor==Function)this.bands[tIndx].onDynamicLoad.call(this,this.bands[tIndx]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.bands[tIndx]);this.bands[tIndx]._loaded=true;}
this.bands[this._curBandIndx].expanded=true;}else if(toggle){if(this.bands[this._curBandIndx].disabled)ele.className=this._gDef(this.bands[this._curBandIndx].titleDisabledClassName,this.titleDisabledClassName);else $(this.contId+'.'+this._curBandIndx+'.TITLE').className=this._gDef(this.bands[this._curBandIndx].titleClassName,this.titleClassName);if(this.animation.hide.type=='slide'&&typeof jQuery!='undefined')jQuery(pEle).slideUp(this.animation.hide.duration);else A5.u.element.hide(pEle,this.animation.hide);for(var j=0;j<this.value.length;j++)if(this.value[j]==this.bands[this._curBandIndx].value)this.value.splice(j,1);this.bands[this._curBandIndx].expanded=false;}}else this._curBandIndx=-1;if(this.bands[tIndx].onChange.constructor==Function)this.bands[tIndx].onChange.call(this,this.bands[tIndx]);else if(this.onChange.constructor==Function)this.onChange.call(this,this.bands[tIndx]);}}}},reset:function(){if(arguments.length==0){for(var i=0;i<this.bands.length;i++){this.bands[i]._loaded=false;if($(this.contId+'.'+i+'.PANE').style.display!='none'){if(this.bands[i].onDynamicLoad.constructor==Function)this.bands[i].onDynamicLoad.call(this,this.bands[i]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.bands[i]);}}}else{var tIndx=-1;for(var i=0;i<arguments.length;i++){tIndx=this._getBandIndex(arguments[i]);this.bands[tIndx]._loaded=false;if($(this.contId+'.'+tIndx+'.PANE').style.display!='none'){if(this.bands[tIndx].onDynamicLoad.constructor==Function)this.bands[tIndx].onDynamicLoad.call(this,this.bands[tIndx]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.bands[tIndx]);}}}},populateBand:function(band,html){var tIndx=this._getBandIndex(band);$(this.contId+'.'+tIndx+'.PANE').innerHTML=html;},hideBand:function(band){var tIndx=this._getBandIndex(band);this.bands[tIndx].show=false;var ele=$(this.contId+'.'+tIndx+'.TITLE');if(typeof ele!='undefined')ele.style.display='none';var ele=$(this.contId+'.'+tIndx+'.PANE');if(typeof ele!='undefined')ele.style.display='none';},showBand:function(band){var tIndx=this._getBandIndex(band);this.bands[tIndx].show=true;var ele=$(this.contId+'.'+tIndx+'.TITLE');if(typeof ele!='undefined'){ele.style.display='';if(this.bands[tIndx].disabled)ele.className=this._gDef(this.bands[tIndx].titleDisabledClassName,this.titleDisabledClassName);else $(this.contId+'.'+tIndx+'.TITLE').className=this._gDef(this.bands[tIndx].titleClassName,this.titleClassName);}},disableBand:function(band){var tIndx=this._getBandIndex(band);this.bands[tIndx].disabled=true;var ele=$(this.contId+'.'+tIndx+'.TITLE');if(typeof ele!='undefined')ele.className=this._gDef(this.bands[tIndx].titleDisabledClassName,this.titleDisabledClassName);var ele=$(this.contId+'.'+tIndx+'.PANE');if(typeof ele!='undefined')ele.style.display='none';},enableBand:function(band){var tIndx=this._getBandIndex(band);this.bands[tIndx].disabled=false;var ele=$(this.contId+'.'+tIndx+'.TITLE');if(typeof ele!='undefined')ele.className=this._gDef(this.bands[tIndx].titleClassName,this.titleClassName);},addBand:function(pane,paneHTML){if(typeof pane!='object')pane={html:pane};var tIndx=this.bands.length;this.bands[tIndx]=new Object();$u.o.assign(this.bands[tIndx],this._parseBand(pane));var ele=document.createElement('a');ele.id=this.contId+'.'+tIndx+'.TITLE';ele.href="#";if(!this.bands[tIndx].expanded&&this.bands[tIndx].show)ele.className=this._gDef(this.bands[tIndx].titleClassName,this.titleClassName);else ele.className=this._gDef(this.bands[tIndx].titleSelectedClassName,this.titleSelectedClassName);if(!this.bands[tIndx].show)ele.style.display='none';if(this.bands[tIndx].disabled)ele.className=this._gDef(this.bands[tIndx].titleDisabledClassName,this.titleDisabledClassName);ele.innerHTML=this.bands[tIndx].html;$(this.contId).appendChild(ele);if(typeof ele!='undefined'){$e.add(ele,'click',this._selectBand,this);$e.add(ele,'contextmenu',this._rClick,this);if(!this.bands[tIndx].show)ele.style.display='none';ele.setAttribute('A5AccordionCtrlIndex',''+tIndx);}
ele=document.createElement('div');ele.id=this.contId+'.'+tIndx+'.PANE';ele.innerHTML=paneHTML;ele.className=this._gDef(this.bands[tIndx].paneClassName,this.paneClassName);ele.style.height=this._gDef(this.bands[tIndx].paneHeight,this.paneHeight);$(this.contId).appendChild(ele);if(!this.bands[tIndx].expanded||!this.bands[tIndx].show||this.bands[tIndx].disabled)ele.style.display='none';else{ele.style.display='block';this.value.push(this.bands[tIndx].value);if(this.bands[tIndx].onDynamicLoad.constructor==Function)this.bands[tIndx].onDynamicLoad.call(this,this.bands[tIndx]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.bands[tIndx]);this.bands[tIndx]._loaded=true;}},removeBand:function(band){var tIndx=this._getBandIndex(band);$(this.contId).removeChild($(this.contId+'.'+tIndx+'.TITLE'));$(this.contId).removeChild($(this.contId+'.'+tIndx+'.PANE'));var ele=new Object();for(var i=tIndx+1;i<this.bands.length;i++){ele=$(this.contId+'.'+i+'.TITLE');ele.id=this.contId+'.'+(i-1)+'.TITLE';ele.setAttribute('A5AccordionCtrlIndex',''+(i-1));ele=$(this.contId+'.'+i+'.PANE');ele.id=this.contId+'.'+(i-1)+'.PANE';}
this.bands.splice(tIndx,1);},_getBandIndex:function(val){if(typeof val=='number')return val;else{for(var i=0;i<this.bands.length;i++)if(val==this.bands[i].value)return i;return 0;}},_selectBand:function(e,classInst){var tIndx=Number(this.getAttribute('A5AccordionCtrlIndex'));classInst.select(tIndx,true);e=$e.getEvent(e);$e.stopEvent(e);return false;},_rClick:function(e,classInst){var tIndx=Number(this.getAttribute('A5AccordionCtrlIndex'));e=$e.getEvent(e);$e.stopEvent(e);if(classInst.bands[tIndx].onRightClick.constructor==Function)classInst.bands[tIndx].onRightClick.call(classInst,classInst.bands[tIndx]);else if(classInst.onRightClick.constructor==Function)classInst.onRightClick.call(classInst,classInst.bands[tIndx]);return false;},_parseBand:function(pane){$u.o.assign(pane,this._defaultBand,true)
if(pane.html=='')pane.html=pane.value;if(pane.value=='')pane.value=pane.html;return pane;},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_defaultBand:{html:'',value:'',titleClassName:'',titleSelectedClassName:'',titleDisabledClassName:'',paneClassName:'',paneHeight:'',show:true,disabled:false,expanded:false,onChange:0,onBeforeChange:0,onRightClick:0,onDynamicLoad:0,_loaded:false}}
a5_AJAX_tab=Class.create();a5_AJAX_tab.prototype={initialize:function(contId,panes){this.contId=contId;var settings=typeof arguments[2]=='object'?arguments[2]:{};$u.o.assign(this,{tabClassName:'',tabSelectedClassName:'',tabDisabledClassName:'',paneClassName:'',paneWidth:'',paneHeight:'',onChange:0,onBeforeChange:0,onRightClick:0,onDynamicLoad:0,initialTab:0,animation:{show:{type:'',duration:500},hide:{type:'',duration:500}}},true);if(typeof a5_AJAX_tabDefaults!='undefined')$u.o.assign(this,a5_AJAX_tabDefaults);if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'tab');if(typeof settings.tabClassName!='undefined'){if(settings.tabClassName.charAt(0)=='+')settings.tabClassName=this.tabClassName+' '+settings.tabClassName.substr(1);}
if(typeof settings.tabSelectedClassName!='undefined'){if(settings.tabSelectedClassName.charAt(0)=='+')settings.tabSelectedClassName=this.tabSelectedClassName+' '+settings.tabSelectedClassName.substr(1);}
if(typeof settings.tabDisabledClassName!='undefined'){if(settings.tabDisabledClassName.charAt(0)=='+')settings.tabDisabledClassName=this.tabDisabledClassName+' '+settings.tabDisabledClassName.substr(1);}
if(typeof settings.paneClassName!='undefined'){if(settings.paneClassName.charAt(0)=='+')settings.paneClassName=this.paneClassName+' '+settings.paneClassName.substr(1);}
$u.o.assign(this,settings);var ele=new Object();this.panes=new Array();for(var i=0;i<panes.length;i++){this.panes[i]=new Object();$u.o.assign(this.panes[i],this._parsePane(panes[i]));if(this.panes[i].tabClassName.charAt(0)=='+')this.panes[i].tabClassName=this.tabClassName+' '+this.panes[i].tabClassName.substr(1);if(this.panes[i].tabSelectedClassName.charAt(0)=='+')this.panes[i].tabSelectedClassName=this.tabSelectedClassName+' '+this.panes[i].tabSelectedClassName.substr(1);if(this.panes[i].tabDisabledClassName.charAt(0)=='+')this.panes[i].tabDisabledClassName=this.tabDisabledClassName+' '+this.panes[i].tabDisabledClassName.substr(1);if(this.panes[i].paneClassName.charAt(0)=='+')this.panes[i].paneClassName=this.paneClassName+' '+this.panes[i].paneClassName.substr(1);ele=$(contId+'.'+i+'.TAB');if(typeof ele!='undefined'){$e.add(ele,'click',this._selectTab,this);$e.add(ele,'contextmenu',this._rClick,this);if(i!=this.initialTab)ele.className=this._gDef(this.panes[i].tabClassName,this.tabClassName);else ele.className=this._gDef(this.panes[i].tabSelectedClassName,this.tabSelectedClassName);if(!this.panes[i].show)ele.style.display='none';if(this.panes[i].disabled)ele.className=this._gDef(this.panes[i].tabDisabledClassName,this.tabDisabledClassName);ele.setAttribute('A5TabCtrlIndex',''+i);}
ele=$(contId+'.'+i+'.PANE');if(typeof ele!='undefined'){ele.className=this._gDef(this.panes[i].paneClassName,this.paneClassName);ele.style.width=this._gDef(this.panes[i].paneWidth,this.paneWidth);ele.style.height=this._gDef(this.panes[i].paneHeight,this.paneHeight);if(i!=this.initialTab)ele.style.display='none';else ele.style.display='block';}}
if(this.panes.length>this.initialTab){this._curTabIndx=this.initialTab;this.value=this.panes[this._curTabIndx].value;if(this.panes[this._curTabIndx].onDynamicLoad.constructor==Function)this.panes[this._curTabIndx].onDynamicLoad.call(this,this.panes[this._curTabIndx]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.panes[this._curTabIndx]);this.panes[this._curTabIndx]._loaded=true;}},select:function(tab){var tIndx=this._getTabIndex(tab);if(tIndx!=this._curTabIndx&&this.panes[tIndx].show&&!this.panes[tIndx].disabled){var fResult=true;if(this.panes[tIndx].onBeforeChange.constructor==Function)fResult=this.panes[tIndx].onBeforeChange.call(this,this.panes[tIndx]);else if(this.onBeforeChange.constructor==Function)fResult=this.onBeforeChange.call(this,this.panes[tIndx]);if(fResult){if(typeof this.panes[this._curTabIndx]!='undefined'){if(this.panes[this._curTabIndx].disabled)$(this.contId+'.'+this._curTabIndx+'.TAB').className=this._gDef(this.panes[this._curTabIndx].tabDisabledClassName,this.tabDisabledClassName);else $(this.contId+'.'+this._curTabIndx+'.TAB').className=this._gDef(this.panes[this._curTabIndx].tabClassName,this.tabClassName);var pEle=$(this.contId+'.'+this._curTabIndx+'.PANE');var classInst=this;this._curTabIndx=tIndx;var tAnim={};$u.o.assign(tAnim,this.animation.hide)
tAnim.onComplete=function(){classInst._selectComplete();delete classInst;};A5.u.element.hide(pEle,tAnim);}else{this._curTabIndx=tIndx;this._selectComplete();}}}},_selectComplete:function(){this.value=this.panes[this._curTabIndx].value;$(this.contId+'.'+this._curTabIndx+'.TAB').className=this._gDef(this.panes[this._curTabIndx].tabSelectedClassName,this.tabSelectedClassName);var pEle=$(this.contId+'.'+this._curTabIndx+'.PANE');A5.u.element.show(pEle,this.animation.show);if(this.panes[this._curTabIndx].onChange.constructor==Function)this.panes[this._curTabIndx].onChange.call(this,this.panes[this._curTabIndx]);else if(this.onChange.constructor==Function)this.onChange.call(this,this.panes[this._curTabIndx]);if(!this.panes[this._curTabIndx]._loaded){if(this.panes[this._curTabIndx].onDynamicLoad.constructor==Function)this.panes[this._curTabIndx].onDynamicLoad.call(this,this.panes[this._curTabIndx]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.panes[this._curTabIndx]);this.panes[this._curTabIndx]._loaded=true}},reset:function(){if(arguments.length==0){for(var i=0;i<this.panes.length;i++){this.panes[i]._loaded=false;if(i==this._curTabIndx){if(this.panes[i].onDynamicLoad.constructor==Function)this.panes[i].onDynamicLoad.call(this,this.panes[i]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.panes[i]);}}}else{var tIndx=-1;for(var i=0;i<arguments.length;i++){tIndx=this._getTabIndex(arguments[i]);this.panes[tIndx]._loaded=false;if(tIndx==this._curTabIndx){if(this.panes[tIndx].onDynamicLoad.constructor==Function)this.panes[tIndx].onDynamicLoad.call(this,this.panes[tIndx]);else if(this.onDynamicLoad.constructor==Function)this.onDynamicLoad.call(this,this.panes[tIndx]);}}}},populatePane:function(tab,html){var tIndx=this._getTabIndex(tab);$(this.contId+'.'+tIndx+'.PANE').innerHTML=html;},hideTab:function(tab){var tIndx=this._getTabIndex(tab);this.panes[tIndx].show=false;var ele=$(this.contId+'.'+tIndx+'.TAB');if(typeof ele!='undefined')ele.style.display='none';if(tIndx==this._curTabIndx)this.select(this._getNextAvalibleTab(tIndx));},showTab:function(tab){var tIndx=this._getTabIndex(tab);this.panes[tIndx].show=true;var ele=$(this.contId+'.'+tIndx+'.TAB');if(typeof ele!='undefined')ele.style.display='';},disableTab:function(tab){var tIndx=this._getTabIndex(tab);this.panes[tIndx].disabled=true;var ele=$(this.contId+'.'+tIndx+'.TAB');if(typeof ele!='undefined')ele.className=this._gDef(this.panes[tIndx].tabDisabledClassName,this.tabDisabledClassName);if(tIndx==this._curTabIndx)this.select(this._getNextAvalibleTab(tIndx));},enableTab:function(tab){var tIndx=this._getTabIndex(tab);this.panes[tIndx].disabled=false;var ele=$(this.contId+'.'+tIndx+'.TAB');if(typeof ele!='undefined')ele.className=this._gDef(this.panes[tIndx].tabClassName,this.tabClassName);},addTab:function(pane,paneHTML){var tIndx=this.panes.length;this.panes[tIndx]=new Object();$u.o.assign(this.panes[tIndx],this._parsePane(pane));var ele=document.createElement('a');ele.id=this.contId+'.'+tIndx+'.TAB';ele.href="#";if(this.panes[tIndx].disabled)ele.className=this._gDef(this.panes[tIndx].tabDisabledClassName,this.tabDisabledClassName);else ele.className=this._gDef(this.panes[tIndx].tabClassName,this.tabClassName);if(!this.panes[tIndx].show)ele.style.display='none';ele.innerHTML=this.panes[tIndx].html;if(this.panes.length>1)$(this.contId+'.TABBAND').insertBefore(ele,$(this.contId+'.'+(tIndx-1)+'.TAB').nextSibling);else $(this.contId+'.TABBAND').insertBefore(ele,$(this.contId+'.TABBAND').lastChild);if(typeof ele!='undefined'){$e.add(ele,'click',this._selectTab,this);$e.add(ele,'contextmenu',this._rClick,this);if(!this.panes[tIndx].show)ele.style.display='none';ele.setAttribute('A5TabCtrlIndex',''+tIndx);}
ele=document.createElement('div');ele.id=this.contId+'.'+tIndx+'.PANE';ele.innerHTML=paneHTML;ele.className=this._gDef(this.panes[tIndx].paneClassName,this.paneClassName);ele.style.width=this._gDef(this.panes[tIndx].paneWidth,this.paneWidth);ele.style.height=this._gDef(this.panes[tIndx].paneHeight,this.paneHeight);ele.style.display='none';$(this.contId+'.PANES').appendChild(ele);},removeTab:function(tab){var tIndx=this._getTabIndex(tab);$(this.contId+'.TABBAND').removeChild($(this.contId+'.'+tIndx+'.TAB'));$(this.contId+'.PANES').removeChild($(this.contId+'.'+tIndx+'.PANE'));var ele=new Object();for(var i=tIndx+1;i<this.panes.length;i++){ele=$(this.contId+'.'+i+'.TAB');ele.id=this.contId+'.'+(i-1)+'.TAB';ele.setAttribute('A5TabCtrlIndex',''+(i-1));ele=$(this.contId+'.'+i+'.PANE');ele.id=this.contId+'.'+(i-1)+'.PANE';}
this.panes.splice(tIndx,1);if(tIndx==this._curTabIndx)this.select(this._getNextAvalibleTab(tIndx));else if(tIndx<this._curTabIndx)this._curTabIndx=this._curTabIndx-1;},_getTabIndex:function(val){if(typeof val=='number')return val;else{for(var i=0;i<this.panes.length;i++)if(val==this.panes[i].value)return i;return 0;}},_selectTab:function(e,classInst){var tIndx=Number(this.getAttribute('A5TabCtrlIndex'));classInst.select(tIndx);e=$e.getEvent(e);$e.stopEvent(e);return false;},_rClick:function(e,classInst){var tIndx=Number(this.getAttribute('A5TabCtrlIndex'));e=$e.getEvent(e);$e.stopEvent(e);if(classInst.panes[tIndx].onRightClick.constructor==Function)classInst.panes[tIndx].onRightClick.call(classInst,classInst.panes[tIndx]);else if(classInst.onRightClick.constructor==Function)classInst.onRightClick.call(classInst,classInst.panes[tIndx]);return false;},_getNextAvalibleTab:function(curIndex){for(var i=curIndex-1;i>-1;i--)if(!this.panes[i].disabled&&this.panes[i].show)return i;for(var i=curIndex+1;i<this.panes.length;i++)if(!this.panes[i].disabled&&this.panes[i].show)return i;return 0;},_parsePane:function(pane){if(typeof pane!='object')pane={html:pane};$u.o.assign(pane,this._defaultPane,true)
if(pane.html=='')pane.html=pane.value;if(pane.value=='')pane.value=pane.html;return pane;},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_defaultPane:{html:'',value:'',tabClassName:'',tabSelectedClassName:'',tabDisabledClassName:'',paneClassName:'',paneWidth:'',paneHeight:'',show:true,disabled:false,onChange:0,onBeforeChange:0,onRightClick:0,onDynamicLoad:0,_loaded:false}}
a5_AJAX_genie=Class.create();a5_AJAX_genie.prototype={initialize:function(contId,panes,settings){this.contId=contId;$u.o.assign(this,settings);$u.o.assign(this,{buttonMode:'hide',onCancel:0,onPrevious:0,onNext:0,onBeforeNext:0,onNavigateTo:0,onDone:0},true);this.panes=new Array();for(var i=0;i<panes.length;i++){this.panes[i]=new Object();$u.o.assign(this.panes[i],this._parsePane(panes[i],$if(i==panes.length-1,true,false)));if(i>0)$(this.contId+'.'+this.panes[i].name).style.display='none';else $(this.contId+'.'+this.panes[i].name).style.display='';}
var ele=$(this.contId+'.CANCEL');if(typeof ele!='undefined')$e.add(ele,'click',this._cancel,this,true);ele=$(this.contId+'.PREV');if(typeof ele!='undefined')$e.add(ele,'click',this._prev,this,true);if(this.buttonMode=='disable'||this.buttonMode=='swap'){ele.disabled=true;}else{ele.style.display='none';}
ele=$(this.contId+'.NEXT');if(typeof ele!='undefined')$e.add(ele,'click',this._next,this,true);ele=$(this.contId+'.DONE');if(typeof ele!='undefined')$e.add(ele,'click',this._done,this,true);if(this.buttonMode=='disable'){ele.disabled=true;}else{ele.style.display='none';}
this._prevPane=[0];this._curPane=0;},disableNext:function(){var ele=$(this.contId+'.NEXT');if(typeof ele!='undefined')ele.disabled=true;var ele=$(this.contId+'.DONE');if(typeof ele!='undefined')ele.disabled=true;},enableNext:function(){var ele=$(this.contId+'.NEXT');if(typeof ele!='undefined')ele.disabled=false;var ele=$(this.contId+'.DONE');if(typeof ele!='undefined')ele.disabled=false;},next:function(){this._prevPane.push(this._curPane);$(this.contId+'.'+this.panes[this._curPane].name).style.display='none';if(this.panes[this._curPane].nextPane!=''){for(var i=0;i<this.panes.length;i++){if(this.panes[i].name==this.panes[this._curPane].nextPane){this._curPane=i;break;}}}else this._curPane=this._curPane+1;$(this.contId+'.'+this.panes[this._curPane].name).style.display='';if(this.panes[this._curPane].isLast){var ele=$(this.contId+'.DONE');ele.disabled=false;ele.style.display='';ele=$(this.contId+'.NEXT');if(this.buttonMode=='disable'){ele.disabled=true;}else{ele.style.display='none';}}
var ele=$(this.contId+'.PREV');ele.disabled=false;ele.style.display='';if(this.panes[this._curPane].onNext.constructor==Function)this.panes[this._curPane].onNext.call(this,this.panes[this._curPane]);else if(this.onNext.constructor==Function)this.onNext.call(this,this.panes[this._curPane]);if(this.panes[this._curPane].onNavigateTo.constructor==Function)this.panes[this._curPane].onNavigateTo.call(this,this.panes[this._curPane]);else if(this.onNavigateTo.constructor==Function)this.onNavigateTo.call(this,this.panes[this._curPane]);},_next:function(){var fResult=true;if(this.panes[this._curPane].onBeforeNext.constructor==Function)fResult=this.panes[this._curPane].onBeforeNext.call(this,this.panes[this._curPane]);else if(this.onBeforeNext.constructor==Function)fResult=this.onBeforeNext.call(this,this.panes[this._curPane]);if(typeof fResult!='undefined'&&!fResult)return false;this.next();},_prev:function(){if(this._prevPane.length==2){var ele=$(this.contId+'.PREV');if(this.buttonMode=='disable'||this.buttonMode=='swap'){ele.disabled=true;}else{ele.style.display='none';}}
$(this.contId+'.'+this.panes[this._curPane].name).style.display='none';if(this.panes[this._curPane].isLast){var ele=$(this.contId+'.NEXT');ele.disabled=false;ele.style.display='';ele=$(this.contId+'.DONE');if(this.buttonMode=='disable'){ele.disabled=true;}else{ele.style.display='none';}}
this._curPane=this._prevPane[this._prevPane.length-1];this._prevPane.pop();$(this.contId+'.'+this.panes[this._curPane].name).style.display='';if(this.panes[this._curPane].onPrevious.constructor==Function)this.panes[this._curPane].onPrevious.call(this,this.panes[this._curPane]);else if(this.onPrevious.constructor==Function)this.onPrevious.call(this,this.panes[this._curPane]);if(this.panes[this._curPane].onNavigateTo.constructor==Function)this.panes[this._curPane].onNavigateTo.call(this,this.panes[this._curPane]);else if(this.onNavigateTo.constructor==Function)this.onNavigateTo.call(this,this.panes[this._curPane]);},_cancel:function(){if(this.panes[this._curPane].onCancel.constructor==Function)this.panes[this._curPane].onCancel.call(this,this.panes[this._curPane]);else if(this.onCancel.constructor==Function)this.onCancel.call(this,this.panes[this._curPane]);},_done:function(){if(this.panes[this._curPane].onDone.constructor==Function)this.panes[this._curPane].onDone.call(this,this.panes[this._curPane]);else if(this.onDone.constructor==Function)this.onDone.call(this,this.panes[this._curPane]);},_parsePane:function(pane,lastPane){if(typeof pane!='object')pane={name:''+pane};if(lastPane)pane.isLast=true;$u.o.assign(pane,this._defaultPane,true);return pane;},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_defaultPane:{name:'',nextPane:'',isLast:false,onCancel:0,onPrevious:0,onNext:0,onBeforeNext:0,onNavigateTo:0,onDone:0}}
a5_AJAX_repeatingForm=Class.create();a5_AJAX_repeatingForm.prototype={initialize:function(contId,tmlp,fields,data){this.contId=contId;this.html=tmlp;this.fields=fields;this.data=data;this.order=new Array();this._curRowIndx=-1;this._curFieldId='';if(this.html.constructor==Array)this.html=this.html.join('\n');var settings=typeof arguments[4]=='object'?arguments[4]:{};$u.o.assign(this,{rowClassName:'',rowAltClassName:'',rowFocusClassName:'',onAdd:0,onRemove:0,onClear:0,onMove:0,dropDownLocation:8,dropDownXOffset:0,dropDownYOffset:0,menuLocation:'dropdown',menuXOffset:1,menuYOffset:1},true);if(typeof a5_AJAX_repeatingFormDefaults!='undefined')$u.o.assign(this,a5_AJAX_repeatingFormDefaults);$u.o.assign(this,settings);for(var i=0;i<this.fields.length;i++){this.fields[i]=this._parseField(this.fields[i]);}
var rEle=new Object();for(var i=0;i<this.data.length;i++){if(!$(this.contId+'.'+i)){rEle=this._renderRow(i);$(this.contId).appendChild(rEle);}
this._initializeFields(i);this.order.push(i);}
this._reband();if($(this.contId+'.DROPDOWN'))$e.add(this.contId+'.DROPDOWN','mousedown',this._showMenu,this,true);if($(this.contId+'.INSERTBEFORE'))$e.add(this.contId+'.INSERTBEFORE','mousedown',this._insertBeforeRow,this,true);if($(this.contId+'.INSERTAFTER'))$e.add(this.contId+'.INSERTAFTER','mousedown',this._insertAfterRow,this,true);if($(this.contId+'.REMOVE'))$e.add(this.contId+'.REMOVE','mousedown',this._removeRow,this,true);if($(this.contId+'.CLEAR'))$e.add(this.contId+'.CLEAR','mousedown',this._clearRow,this,true);if($(this.contId+'.MOVEUP'))$e.add(this.contId+'.MOVEUP','mousedown',this._moveRowUp,this,true);if($(this.contId+'.MOVEDOWN'))$e.add(this.contId+'.MOVEDOWN','mousedown',this._moveRowDown,this,true);if($(this.contId+'.MOVEFIRST'))$e.add(this.contId+'.MOVEFIRST','mousedown',this._moveRowFirst,this,true);if($(this.contId+'.MOVELAST'))$e.add(this.contId+'.MOVELAST','mousedown',this._moveRowLast,this,true);if(this.order.length==0){indx=this.data.length;var newData={};for(var i=0;i<this.fields.length;i++)newData[this.fields[i].name]=this.fields[i].defaultValue;this.data.push(newData);var rEle=new Object();rEle=this._renderRow(indx);$(this.contId).appendChild(rEle);this._initializeFields(indx);this.order=[indx];}},addRow:function(newData){var indx=this.data.length;for(var i=0;i<this.fields.length;i++)if(typeof newData[this.fields[i].name]=='undefined')newData[this.fields[i].name]=this.fields[i].defaultValue;this.data.push(newData);rEle=this._renderRow(indx);$(this.contId).appendChild(rEle);this._initializeFields(indx);this.order.push(indx);this._reband();if(this.onAdd.constructor==Function)fResult=this.onAdd.call(this,indx,this.order.length-1);},removeRow:function(indx){$(this.contId+'.'+indx).style.display='none';for(var i=0;i<this.order.length;i++){if(this.order[i]==indx){this.order.splice(i,1);break;}}
this._reband();if(this.onRemove.constructor==Function)fResult=this.onRemove.call(this,indx,i);if(this.order.length==0){indx=this.data.length;var newData={};for(var i=0;i<this.fields.length;i++)newData[this.fields[i].name]=this.fields[i].defaultValue;this.data.push(newData);var rEle=new Object();rEle=this._renderRow(indx);$(this.contId).appendChild(rEle);this._initializeFields(indx);this.order=[indx];}},clearRow:function(indx){var fEle=new Object();for(var i=0;i<this.fields.length;i++){this.data[indx][this.fields[i].name]=this.fields[i].defaultValue;fEle=$n(this.contId+'.'+indx+'.'+this.fields[i].name);$svs(fEle,this.data[indx][this.fields[i].name]);}
this._reband();if(this.onClear.constructor==Function)fResult=this.onClear.call(this,indx);},clear:function(){var createNew=typeof arguments[0]!='undefined'?arguments[0]:true;var pEle=$(this.contId);$e.removeGroup(this.contId+'.EVENTS');for(var i=0;i<this.data.length;i++){pEle.removeChild($(this.contId+'.'+i));}
this.data=new Array();this.order=new Array();if(createNew){var indx=0;var newData={};for(var i=0;i<this.fields.length;i++)newData[this.fields[i].name]=this.fields[i].defaultValue;this.data.push(newData);var rEle=new Object();rEle=this._renderRow(indx);$(this.contId).appendChild(rEle);this._initializeFields(indx);this.order=[indx];}},moveRow:function(dIndx,oIndx){var oldOIndx=-1;for(var i=0;i<this.order.length;i++)if(this.order[i]==dIndx)oldOIndx=i;if(oIndx>oldOIndx)$(this.contId).insertBefore($(this.contId+'.'+dIndx),$(this.contId+'.'+this.order[oIndx]).nextSibling);else $(this.contId).insertBefore($(this.contId+'.'+dIndx),$(this.contId+'.'+this.order[oIndx]));this.order.splice(oldOIndx,1);this.order.splice(oIndx,0,dIndx);this._reband();if(this.onMove.constructor==Function)fResult=this.onMove.call(this,dIndx,oldOIndx,oIndx);},getData:function(){var indxvar=typeof arguments[0]!='undefined'?arguments[0]:'';var r=new Object();r.oldData=new Array();r.data=new Array();for(var i=0;i<this.order.length;i++){r.data[i]=new Object();r.oldData[i]=new Object();for(var j=0;j<this.fields.length;j++){r.data[i][this.fields[j].name]=$gvs(this.contId+'.'+this.order[i]+'.'+this.fields[j].name);if(this.fields[j].type=='number')r.data[i][this.fields[j].name]=$u.s.toNum(r.data[i][this.fields[j].name]);$u.o.assign(r.oldData[i],this.data[this.order[i]]);}
if(indxvar!=''){r.data[i][indxvar]=this.order[i];r.oldData[i][indxvar]=this.order[i];}}
return r;},getDataForCallback:function(){var prefix=typeof arguments[0]!='undefined'?arguments[0]:'';if(prefix!='')prefix=prefix+'.';var indxvar=typeof arguments[1]!='undefined'?arguments[1]:'';var r=this.getData(indxvar);var arr=new Array();var rd='';for(var i=0;i<this.fields.length;i++){if(typeof r.data[0][this.fields[i].name]=='object'){for(var j=0;j<r.data.length;j++){rd=r.data[j][this.fields[i].name];if(rd.constructor==Array)rd=rd.join('\n');else rd='';arr[arr.length]=prefix+this.fields[i].name+'['+(j+1)+']='+urlencode(rd);rd=r.oldData[j][this.fields[i].name];if(rd.constructor==Array)rd=rd.join('\n');else rd='';arr[arr.length]=prefix+'old.'+this.fields[i].name+'['+(j+1)+']='+urlencode(rd);}}else{for(var j=0;j<r.data.length;j++){arr[arr.length]=prefix+this.fields[i].name+'['+(j+1)+']='+urlencode(r.data[j][this.fields[i].name]);arr[arr.length]=prefix+'old.'+this.fields[i].name+'['+(j+1)+']='+urlencode(r.oldData[j][this.fields[i].name]);}}}
for(var i=0;i<r.data.length;i++){arr[arr.length]=prefix+indxvar+'['+(i+1)+']='+r.data[i][indxvar];arr[arr.length]=prefix+'old.'+indxvar+'['+(i+1)+']='+r.oldData[i][indxvar];}
return arr.join('&');},_renderRow:function(indx){var ele=document.createElement('div');ele.id=this.contId+'.'+indx;ele.className=this.rowClassName;ele.innerHTML=this.html.replace(/\{INDEX\}/g,''+indx);return ele;},_initializeFields:function(indx){var fEle=new Object();for(var i=0;i<this.fields.length;i++){fEle=$n(this.contId+'.'+indx+'.'+this.fields[i].name);$svs(fEle,this.data[indx][this.fields[i].name]);$sa(fEle,'A5RepeatingFormIndex',''+indx);$sa(fEle,'A5HarvestIgnore','true');$e.add(fEle,'focus',this._showDropdown,this,false,this.contId+'.EVENTS');$e.add(fEle,'blur',this._hideDropdown,this,false,this.contId+'.EVENTS');}},_insertBeforeRow:function(){var indx=this.data.length;var newData={};for(var i=0;i<this.fields.length;i++)newData[this.fields[i].name]=this.fields[i].defaultValue;this.data.push(newData);var rEle=new Object();rEle=this._renderRow(indx);$(this.contId).insertBefore(rEle,$(this.contId+'.'+this._curRowIndx));this._initializeFields(indx);for(var i=0;i<this.order.length;i++){if(this.order[i]==this._curRowIndx){this.order.splice(i,0,indx);break;}}
if(this.onAdd.constructor==Function)fResult=this.onAdd.call(this,indx,i);this._hideMenu();this._reband();},_insertAfterRow:function(){var indx=this.data.length;var newData={};for(var i=0;i<this.fields.length;i++)newData[this.fields[i].name]=this.fields[i].defaultValue;this.data.push(newData);var rEle=new Object();rEle=this._renderRow(indx);$(this.contId).insertBefore(rEle,$(this.contId+'.'+this._curRowIndx).nextSibling);this._initializeFields(indx);for(var i=0;i<this.order.length;i++){if(this.order[i]==this._curRowIndx){this.order.splice(i+1,0,indx);break;}}
if(this.onAdd.constructor==Function)fResult=this.onAdd.call(this,indx,i+1);this._hideMenu();this._reband();},_removeRow:function(){this.removeRow(this._curRowIndx);this._hideMenu();},_clearRow:function(){this.clearRow(this._curRowIndx);this._hideMenu(true);},_moveRowUp:function(){var oIndx=-1;for(var i=1;i<this.order.length;i++){if(this._curRowIndx==this.order[i]){oIndx=i-1;break;}}
if(oIndx!=-1)this.moveRow(this._curRowIndx,oIndx);this._hideMenu(true);},_moveRowDown:function(){var oIndx=-1;for(var i=0;i<this.order.length-1;i++){if(this._curRowIndx==this.order[i]){oIndx=i+1;break;}}
if(oIndx!=-1)this.moveRow(this._curRowIndx,oIndx);this._hideMenu(true);},_moveRowFirst:function(){this.moveRow(this._curRowIndx,0);this._hideMenu(true);},_moveRowLast:function(){this.moveRow(this._curRowIndx,this.order.length-1);this._hideMenu(true);},_showDropdown:function(e,classInst){if($(classInst.contId+'.'+classInst._curRowIndx))$rcn($(classInst.contId+'.'+classInst._curRowIndx),classInst.rowFocusClassName);var trIndx=Number($ga(this,'A5RepeatingFormIndex'));if(trIndx!=classInst._curRowIndx)$(classInst.contId+'.MENU').style.display='none';classInst._curRowIndx=trIndx;classInst._curFieldId=this.id;clearTimeout(classInst._tBarTimeout);$acn($(classInst.contId+'.'+classInst._curRowIndx),classInst.rowFocusClassName);var ele=$(classInst.contId+'.DROPDOWN');ele.style.display='';$po(ele,$(classInst.contId+'.'+classInst._curRowIndx),classInst.dropDownLocation,classInst.dropDownXOffset,classInst.dropDownYOffset-$(classInst.contId).scrollTop);},_hideDropdown:function(e,classInst){classInst._tBarTimeout=setTimeout(function(){classInst._hideDropdownComplete();},200);},_hideDropdownComplete:function(){$rcn($(this.contId+'.'+this._curRowIndx),this.rowFocusClassName);$(this.contId+'.DROPDOWN').style.display='none';$(this.contId+'.MENU').style.display='none';},_showMenu:function(e){var ele=$(this.contId+'.MENU');ele.style.display='';$po(ele,$(this.contId+'.DROPDOWN'),this.menuLocation,this.menuXOffset,this.menuYOffset);setTimeout(Function('$(\''+this._curFieldId+'\').focus()'),10);},_hideMenu:function(){var rFocus=typeof arguments[0]!='undefined'?arguments[0]:false;var ele=$(this.contId+'.MENU');ele.style.display='none';if(rFocus)setTimeout(Function('$(\''+this._curFieldId+'\').focus()'),10);},_parseField:function(field){if(typeof field!='object')field={name:field};$u.o.assign(field,{name:'',type:'string',defaultValue:''},true);return field;},_reband:function(){if(this.rowAltClassName!=''){for(var i=0;i<this.order.length;i++){if(i-(Math.floor(i/2)*2)==0)$(this.contId+'.'+this.order[i]).className=this.rowClassName;else $(this.contId+'.'+this.order[i]).className=this.rowAltClassName;}}}}
if(typeof A5=='undefined')var A5=new Object();A5.form=new Object();A5.form.submit=a5_AJAX_Form;A5.form.prepare=a5_AJAX_FormPrepare;A5.form.harvest=a5_AJAX_Form_RegionHarvest;A5.form.reset=a5_AJAX_FormReset;A5.form.setErrors=a5_AJAX_Form_ErrorsSet;A5.form.clearErrors=a5_AJAX_Form_ErrorsClear;A5.form.populateSelect=function(eleId,currValue,data,clearExistingEntries){if(typeof clearExistingEntries=='string'){a5_AJAX_Form_populateSelect(eleId,currValue,data,clearExistingEntries);return false;}
var ele=$(eleId);var currIndex=0;if(clearExistingEntries){if(ele.options.length>0){for(var i=ele.options.length-1;i>=0;i--)ele.options[i]=null;ele.options[0]=null;}}else currIndex=ele.options.length;for(var i=0;i<data.length;i++){if(data[i].constructor==Array){if(data[i].length>1){ele.options[currIndex]=new Option(data[i][0],data[i][1]);}else{ele.options[currIndex]=new Option(data[i][0],data[i][0]);}}else{ele.options[currIndex]=new Option(data[i],data[i]);}
currIndex++;}
var optionFound=false;if(ele.options.length>0){for(var i=0;i<ele.options.length;i++){if(ele.options[i].value==currValue){optionFound=true;ele.options.selectedIndex=i;break;}}
if(optionFound==false){ele.options[ele.options.length]=new Option(currValue,currValue);ele.options.selectedIndex=ele.options.length-1;}}}
A5.form.setCtrlDirty=a5_AJAX_Form_SetDirtyControl;A5.form._setDirty=a5_AJAX_Form_SetDirty;A5.form._setFocus=a5_AJAX_Form_SetFocus;A5.grid=new Object();A5.grid.action=a5_AJAX_GridAction;A5.grid.submit=a5_AJAX_GridSubmit;A5.ajax=new Object();A5.ajax.buildURLParam=a5_AJAX_Form_SubmitValueParam;A5.ajax.callback=a5_AJAX_Callback;A5.ajax.urlEncode=urlencode;if(!A5.ajax.addURLRequiredData)A5.ajax.addURLRequiredData=function(url){return url;};if(!A5.ajax.addParamRequiredData)A5.ajax.addParamRequiredData=function(data){return data;};A5.Accordion=a5_AJAX_accordion;A5.Tab=a5_AJAX_tab;A5.Genie=a5_AJAX_genie;A5.RepeatingForm=a5_AJAX_repeatingForm;A5.Watch={_w:{},add:function(wName,wTarg,wSettings){var eles2=new Array();if(wTarg.constructor==Array){for(var i=0;i<wTarg.length;i++)eles2.push($(wTarg[i]));}else eles2.push($(wTarg));var wNames='';var eleIds=new Array();for(var i=0;i<eles2.length;i++){eleIds.push(eles2[i].id);if($ga(eles2[i],'A5WatchNames')==''||$ga(eles2[i],'A5WatchNames')==null){$e.add(eles2[i],'change',this._onChange);if(eles2[i].tagName.toLowerCase()=='input'&&(eles2[i].type.toLowerCase()=='radio'||eles2[i].type.toLowerCase()=='checkbox'))$e.add(eles2[i],'click',this._onChange);$sa(eles2[i],'A5WatchNames',wName);}else{wNames=$ga(eles2[i],'A5WatchNames');wNames=wNames.split(';');if($u.a.find(wNames,wName)==-1){wNames.push(wName);$sa(eles2[i],'A5WatchNames',wNames.join(';'));}}}
if(typeof wSettings.data=='undefined')wSettings.data={};else if(typeof wSettings.data!='object')wSettings.data={value:wSettings.data};$u.o.assign(wSettings.data,{external:false,initial:false});if(typeof wSettings.fireInitial=='undefined')wSettings.fireInitial=true;this._w[wName]={ids:eleIds,data:wSettings.data,onChange:wSettings.onChange}
if(wSettings.fireInitial){var tempData=new Object();$u.o.assign(tempData,wSettings.data);tempData.external=true;tempData.initial=true;wSettings.onChange.call(eles2[0],tempData);}},remove:function(wName){var wIds=this._w[wName].ids;var ele=0;var wNameIndx=-1;for(var i=0;i<wIds.length;i++){ele=$(wIds[i]);wNames=$ga(ele,'A5WatchNames');if(wNames!=''){wNames=wNames.split(';');if(wNames.length==1){$e.remove(ele,'change',this._onChange);if(ele.tagName.toLowerCase()=='input'&&(ele.type.toLowerCase()=='radio'||ele.type.toLowerCase()=='checkbox'))$e.remove(ele,'click',this._onChange);$sa(ele,'A5WatchNames','');}else{wNameIndx=$u.a.find(wNames,wName);wNames.splice(wNameIndx,1);$sa(ele,'A5WatchNames',wNames.join(';'));}}}
delete this._w[wName];},fire:function(wName){if(typeof this._w[wName]!='undefined'){var wIds=this._w[wName].ids;var ele=$(wIds[0]);var tempData=new Object();$u.o.assign(tempData,this._w[wName].data);tempData.external=true;this._w[wName].onChange.call(ele,tempData);}},_onChange:function(){var wNames=$ga(this,'A5WatchNames');wNames=wNames.split(';');setTimeout(Function('var wNames = '+$u.o.toJSON(wNames)+'; for(var i=0; i<wNames.length; i++) if(A5.Watch._w[wNames[i]]) A5.Watch._w[wNames[i]].onChange.call(this,A5.Watch._w[wNames[i]].data);'),1);}}
A5.RichTextEdit=Class.create();A5.RichTextEdit.prototype={initialize:function(ctrlId,settings){if(!$(ctrlId))return false;this.ctrlId=ctrlId;$u.o.assign(settings,{defaultLinkedCSS:'',defaultCSS:'',onStateChange:0,onChange:0},true);$u.o.assign(this,settings);if(this.defaultCSS.constructor==Array)this.defaultCSS.join('\n');else if(this.defaultCSS.constructor!=String)this.defaultCSS='';this.defaultCSS='table, td {border: 1px dashed #aaa;}'+this.defaultCSS;var tEle=$(ctrlId);var iEle=document.createElement('iframe');iEle.id=ctrlId+'.HTMLEDITOR';if(tEle.style.width!='')iEle.style.width=tEle.style.width;else iEle.style.width=tEle.offsetWidth+'px';if(tEle.style.height!='')iEle.style.height=tEle.style.height;else iEle.style.height=tEle.offsetHeight+'px';iEle.style.overflow='auto';iEle.frameBorder='0';iEle.border='0';iEle.className=tEle.className;tEle.parentNode.insertBefore(iEle,tEle);tEle.style.display='none';this._iEle=iEle;this._tEle=tEle;if(document.all&&navigator.appName!='Opera'){this._iEle.contentWindow.document.designMode='on';this._eDoc=this._iEle.contentWindow.document;$e.add(this._iEle.contentWindow,'focus',this._focus,this,true);$e.add(this._iEle.contentWindow,'blur',this._blur,this,true);this.focus();}else{this._iEle.contentDocument.designMode='on';this._iEle.style.lineHeight='0';this._eDoc=this._iEle.contentDocument;$e.add(this._eDoc,'focus',this._focus,this,true);$e.add(this._eDoc,'blur',this._blur,this,true);}
this._eDoc.open();var initHTML=tEle.value;if(initHTML=='')initHTML='';this._eDoc.write('<head>'+$if(this.defaultLinkedCSS!='','<link rel="stylesheet" type="text/css" href="'+this.defaultLinkedCSS+'" />','')+$if(this.defaultCSS!='','<style type="text/css">'+this.defaultCSS+'</style>','')+'</head><body>'+initHTML+'</body>');this._eDoc.close();$e.add(this._eDoc,'keyup',this._getState,this,true);$e.add(this._eDoc,'keydown',this._keyDown,this,true);$e.add(this._eDoc,'mouseup',this._getState,this,true);this.state={bold:false,underline:false,italic:false,strikeThrough:false,justifyLeft:true,justifyCenter:false,justifyRight:false,justifyFull:false,fontName:'',fontSize:'',unorderedList:false,orderedList:false,canUndo:false,canRedo:false}
if(this.onStateChange.constructor==Function)this.onStateChange();this._blurTO=0;var classInst=this;setTimeout(function(){classInst._getClassNames();delete classInst;},10);this._kw=new AUI.KeyWatcher([{key:'ctrl+b',handle:this.bold},{key:'ctrl+i',handle:this.italic},{key:'ctrl+u',handle:this.underline}],this,this._iEle.contentWindow);},command:function(type){this._iEle.contentWindow.focus();var data=typeof(arguments[1]!='undefined')?arguments[1]:null;var lType=type.toLowerCase();if(lType=='backcolor'){var ele=this._getSelElement();if(!ele.tagName)return false;var tagName=ele.tagName.toLowerCase();var validTags=['p','pre','div','td','th','li','h1','h2','h3','h4','h5','h6','blockquote','dd','dt','legend','fieldset','caption','body'];if($u.a.find(validTags,tagName)==-1){while($u.a.find(validTags,tagName)==-1){ele=ele.parentNode;if(ele.tagName)tagName=ele.tagName.toLowerCase();}}
if($u.a.find(validTags,tagName)==-1)return false;if(ele.tagName.toLowerCase()!='body')ele.style.backgroundColor=data;}else if(lType=='hilitecolor'){if(!navigator.userAgent.toLowerCase().match('firefox'))type='backcolor';if(this._eDoc.queryCommandEnabled(type))this._eDoc.execCommand(type,false,data);}else if(lType=='insertdate'){var dt=new Date()
dt=$u.d.toStr(dt,'[mm]/[dd]/[yyyy]');this._insertHTML('',''+dt);}else if(lType=='inserttime'){var tt=new Date()
tt=$u.d.toStr(tt,'[t:h]:[t:m][t:am]');this._insertHTML('',''+tt);}else if(lType=='inserttable'){data=data.split(',');data[0]=$u.s.toNum(data[0]);data[1]=$u.s.toNum(data[1]);var tableHTML=new Array();for(var i=0;i<data[1];i++){tableHTML.push(' <tr>');for(var j=0;j<data[0];j++){tableHTML.push('  <td>&nbsp;</td>');}
tableHTML.push(' </tr>');}
this._insertHTML('table',tableHTML.join('\n'));}else if(lType=='inserttablecolumn'){var ele=this._getSelElement();if(!ele.tagName)return false;if(ele.tagName.toLowerCase()!='td'){while(ele.tagName.toLowerCase()!='td')ele=ele.parentNode;}
if(ele.tagName.toLowerCase()!='td')return false;var cellIndx=ele.cellIndex;if(data!=null){if(data.toLowerCase()=='after')cellIndx=cellIndx+1;}
while(ele.tagName.toLowerCase()!='table')ele=ele.parentNode;for(var i=0;i<ele.rows.length;i++){ele.rows[i].insertCell(cellIndx);ele.rows[i].cells[cellIndx].innerHTML='&nbsp;';}}else if(lType=='inserttablerow'){var ele=this._getSelElement();if(!ele.tagName)return false;if(ele.tagName.toLowerCase()!='td'){while(ele.tagName.toLowerCase()!='td')ele=ele.parentNode;}
if(ele.tagName.toLowerCase()!='td')return false;var rowIndx=ele.parentNode.rowIndex;if(data!=null){if(data.toLowerCase()=='after')rowIndx=rowIndx+1;}
while(ele.tagName.toLowerCase()!='table')ele=ele.parentNode;var totalCells=0;for(var i=0;i<ele.rows.length;i++)totalCells=Math.max(totalCells,ele.rows[i].cells.length);ele.insertRow(rowIndx);for(var i=0;i<totalCells;i++){ele.rows[rowIndx].insertCell(i);ele.rows[rowIndx].cells[i].innerHTML='&nbsp;';}}else if(lType=='deletetablecolumn'){var ele=this._getSelElement();if(!ele.tagName)return false;if(ele.tagName.toLowerCase()!='td'){while(ele.tagName.toLowerCase()!='td')ele=ele.parentNode;}
if(ele.tagName.toLowerCase()!='td')return false;var cellIndx=ele.cellIndex;while(ele.tagName.toLowerCase()!='table')ele=ele.parentNode;for(var i=0;i<ele.rows.length;i++){ele.rows[i].deleteCell(cellIndx);}}else if(lType=='deletetablerow'){var ele=this._getSelElement();if(!ele.tagName)return false;if(ele.tagName.toLowerCase()!='td'){while(ele.tagName.toLowerCase()!='td')ele=ele.parentNode;}
if(ele.tagName.toLowerCase()!='td')return false;var rowIndx=ele.parentNode.rowIndex;while(ele.tagName.toLowerCase()!='table')ele=ele.parentNode;ele.deleteRow(rowIndx);}else if(lType=='setclassname'){var ele=this._getSelElement();if(ele.tagName.toLowerCase()!='body')ele.className=data;}else if(lType=='cut'||lType=='copy'||lType=='paste'){if(navigator.userAgent.toLowerCase().match('firefox')){alert('Firefox does not support '+lType+'. Use keyboard shortcut to '+lType+'.');}else this._eDoc.execCommand(type,false,data);}else{if(document.all&&navigator.appName!='Opera'){var range=this._eDoc.selection.createRange();range.expand('character');var range2=this._eDoc.selection.createRange();range2.expand('textedit');var node=range2.parentElement();while(node.tagName.toLowerCase()!='body')node=node.parentNode;if(node.innerHTML==this._eDoc.body.innerHTML){if(this._eDoc.queryCommandEnabled(type))this._eDoc.execCommand(type,false,data);}}else{if(this._eDoc.queryCommandEnabled(type))this._eDoc.execCommand(type,false,data);}}
this._getState();this.focus();},bold:function(){this.command('bold');return true;},italic:function(){this.command('italic');return true;},underline:function(){this.command('underline');return true;},toggleDesignMode:function(){var show=true;if(typeof arguments[0]!='undefined'){if(arguments[0].toLowerCase()=='code'||arguments[0].toLowerCase()=='textarea')show=false;if((this._iEle.style.display!='none'&&show)||(this._iEle.style.display=='none'&&!show))return false;}else{if(this._iEle.style.display!='none')show=false;}
if(show){if(this._tEle.value!=this.getHTML()){this.setHTML(this._tEle.value);}
this._iEle.style.display='';this._tEle.style.display='none';}else{this._tEle.value=this.getHTML();this._iEle.style.display='none';this._tEle.style.display='';}},getHTML:function(){var html=String(this._eDoc.body.innerHTML);html=html.replace(RegExp('\r','g'),'');html=html.replace(RegExp('\<p','gi'),'<div');html=html.replace(RegExp('\</p\>','gi'),'</div>');return html;},setHTML:function(html){this._eDoc.body.innerHTML=html;if(document.all&&navigator.appName!='Opera'){this._iEle.style.display='none';this._iEle.style.display='';}},focus:function(){if(document.all&&navigator.appName!='Opera'){this._iEle.style.visibility='hidden';this._iEle.style.overflow='hidden';this._iEle.style.visibility='';this._iEle.style.overflow='';}
this._iEle.contentWindow.focus();},_keyDown:function(e){var keyCode=e.charCode||e.keyCode;if(keyCode==9){var isList=false;var ele=this._getSelElement();while(ele.tagName.toLowerCase()!='body'){if(ele.tagName.toLowerCase()=='li'){isList=true;break;}
ele=ele.parentNode;}
$e.preventDefault(e);if(isList){if(e.shiftKey)this.command('outdent');else this.command('indent');}else if(!e.shiftKey)this._insertHTML('','&nbsp;&nbsp;&nbsp;&nbsp;');}},_getState:function(e){if(document.all&&navigator.appName!='Opera'){}
if(window.getSelection){var selection=this._iEle.contentWindow.getSelection();var range=selection.getRangeAt(0);var node=range.commonAncestorContainer;if(typeof node.tagName!='undefined')if(node.tagName.toLowerCase()=='html')return false;}
var oldState=$u.o.toJSON(this.state);this.state.bold=this._eDoc.queryCommandState('bold');this.state.underline=this._eDoc.queryCommandState('underline');this.state.italic=this._eDoc.queryCommandState('italic');this.state.strikeThrough=this._eDoc.queryCommandState('strikethrough');this.state.justifyLeft=this._eDoc.queryCommandState('justifyLeft');this.state.justifyCenter=this._eDoc.queryCommandState('justifyCenter');this.state.justifyRight=this._eDoc.queryCommandState('justifyRight');this.state.justifyFull=this._eDoc.queryCommandState('justifyFull');if(!this.state.justifyLeft&&!this.state.justifyCenter&&!this.state.justifyRight&&!this.state.justifyFull)this.state.justifyLeft=true;this.state.fontName=String(this._eDoc.queryCommandValue('fontName'));this.state.fontSize=String(this._eDoc.queryCommandValue('fontSize'));this.state.unorderedList=this._eDoc.queryCommandState('InsertUnorderedList');this.state.orderedList=this._eDoc.queryCommandState('InsertOrderedList');var newState=$u.o.toJSON(this.state);if(oldState!=newState){if(this.onStateChange.constructor==Function)this.onStateChange();}
this._tEle.value=this.getHTML();if(e){if(e.type.toLowerCase()=='keyup'){var keyCode=e.charCode||e.keyCode;if(!(keyCode>=16&&keyCode<=18)&&!(keyCode>=37&&keyCode<=40)&&keyCode!=27&&!(keyCode>=33&&keyCode<=36)&&keyCode!=45&&!(keyCode>=112&&keyCode<=123)){if(this.onChange.constructor==Function)this.onChange();}}}else if(this.onChange.constructor==Function)this.onChange();},_insertHTML:function(tagName,tagContent){this._iEle.contentWindow.focus();var attrContent=typeof arguments[2]!='undefined'?arguments[2]:{};var range;if(this._eDoc.selection&&this._eDoc.selection.createRange&&navigator.appName!='Opera'){range=this._eDoc.selection.createRange();var range2=this._eDoc.selection.createRange();range2.expand('textedit');if(range2.parentElement().innerHTML==this._eDoc.body.innerHTML){var attrArray=new Array();for(var prop in attrContent){attrArray.push(' ');if(prop=='style'){var sArr=new Array();for(var sProp in attrContent[prop]){sArr.push(sProp+': '+attrContent[prop][sProp]+';');}
sArr=sArr.join(' ');attrArray.push('style="'+sArr+'"');}else attrArray.push(prop+'="'+$u.s.tran(attrContent[prop],'"','\\"')+'"');}
attrArray=attrArray.join('');if(tagName!='')range.pasteHTML('<'+tagName+attrArray+'>'+tagContent+'</'+tagName+'>');else range.pasteHTML(tagContent);}}else if(window.getSelection){var selection=this._iEle.contentWindow.getSelection();range=selection.getRangeAt(0);range.deleteContents();if(tagName!=''){var pEle=this._eDoc.createElement(tagName);pEle.innerHTML=tagContent;for(var prop in attrContent){if(prop=='style')$ss(pEle,attrContent[prop]);else pEle[prop]=attrContent[prop];}
if(this._eDoc.body.innerHTML==''){this._eDoc.body.appendChild(pEle)}else{range.insertNode(pEle);}}else{if(this._eDoc.queryCommandEnabled('inserthtml'))this._eDoc.execCommand('inserthtml',false,tagContent);}}},_getSelElement:function(){var range;if(this._eDoc.selection&&this._eDoc.selection.createRange&&navigator.appName!='Opera'){range=this._eDoc.selection.createRange();range.expand('character');return range.parentElement();}else if(window.getSelection){var selection=this._iEle.contentWindow.getSelection();if(!selection.anchorNode.tagName)return selection.anchorNode.parentNode;else return selection.anchorNode;}
return false;},_getClassNames:function(){var classList=new Array();var fClassList=new Array();var ssRules=0;for(var i=0;i<this._eDoc.styleSheets.length;i++){ssRules=false;if(this._eDoc.styleSheets[i].cssRules)ssRules=this._eDoc.styleSheets[i].cssRules;else if(this._eDoc.styleSheets[i].rules)ssRules=this._eDoc.styleSheets[i].rules;if(ssRules){for(var j=0;j<ssRules.length;j++){classList=classList.concat(String(ssRules[j].selectorText).split(','));}}}
var tSel1=0;for(var i=0;i<classList.length;i++){if(classList[i].indexOf('.')!=-1){tSel1=classList[i].split('.');tSel1.shift();for(var j=0;j<tSel1.length;j++){tSel1[j]=$u.s.tran(tSel1[j],[' ','\n',':'],[' ',' ',' ']);tSel1[j]=$u.s.word(tSel1[j],1,' ');}
fClassList=fClassList.concat(tSel1);}}
fClassList=$u.a.dedup(fClassList);},_focus:function(){clearTimeout(this._blurTO);this._kw.on();},_blur:function(){var classInst=this;this._blurTO=setTimeout(function(){classInst._completeBlur();},100);},_completeBlur:function(){this._kw.off();}}
A5.RichTextEditor=Class.create();A5.RichTextEditor.prototype={initialize:function(ctrlId,settings){if(!$(ctrlId))return false;this.ctrlId=ctrlId;$u.o.assign(settings,{isPopup:false,onSave:0,onEdit:0,onChange:0,defaultLinkedCSS:'',defaultCSS:'',buttonClassName:'',buttonCheckedClassName:'',insertImage:{relativePath:'',styleName:'',titleText:'Insert Image',bodyText:'File:',editWatermarkText:'',editImage:''},insertFile:{relativePath:'',styleName:'',titleText:'Insert File',bodyText:'File:',editWatermarkText:'',editImage:''},popupWindow:{},insertWindow:{}},true);$u.o.assign(settings.popupWindow,{baseCtrlId:this.ctrlId,title:{show:false},header:{show:false},body:{content:{type:'element',elementId:this.ctrlId+'.window'}},footer:{show:false},type:'modal',resize:'both',autoShow:false,autoPosition:false,onResize:function(){var ele=$(this.baseCtrlId+'.HTMLEDITOR');var tEle=$(this.baseCtrlId);if(tEle.style.display=='none'){ele.style.height=(ele.offsetHeight+(AUI.Resize._s.height-AUI.Resize._s.initialHeight))+'px';ele.style.width='100%';tEle.style.height=ele.style.height;tEle.style.width='100%';}else{tEle.style.height=(tEle.offsetHeight+(AUI.Resize._s.height-AUI.Resize._s.initialHeight))+'px';tEle.style.width='100%';ele.style.height=tEle.style.height;ele.style.width='100%';}
ele=$(this.getWindowId('body'));ele.style.height='';if($(this.getWindowId('body-container')).style.width!=''){$(this.baseCtrlId+'.window.body').style.width='';$(this.baseCtrlId+'.window').style.width='';}
return true;}});$u.o.assign(settings.insertWindow,{baseCtrlId:this.ctrlId,title:{html:'Insert',tools:{items:[A5._windowDefaults.title.tools.defaults.close]}},header:{show:false},body:{content:{type:'url',url:'about:blank'}},footer:{show:false},type:'modal',resize:'both',autoShow:false,autoPosition:true});$u.o.assign(this,settings);if(this.isPopup){this._window=new A5.Window(this.popupWindow);}
this._iWindow=new A5.Window(this.insertWindow);$e.add(this._iWindow.getWindowId(),'a5insert',function(e,classInst){classInst._iWindow.hide();var insertType=$ga(this,'a5inserttype');if(insertType=='image'){var imageToInsert=$ga(this,'a5imagetoinsert');classInst._rteObj.command('insertimage',imageToInsert);}else if(insertType=='file'){var fileToInsert=$ga(this,'a5filetoinsert');var fileToInsertShort=fileToInsert.split('/').pop();classInst._rteObj._insertHTML('a',fileToInsertShort,{href:fileToInsert,target:'_blank'});}},this);this._rteObj=new A5.RichTextEdit(this.ctrlId,{onStateChange:function(){if(this.state.bold)$scn(this.ctrlId+'.bold',this.buttonCheckedClassName);else $scn(this.ctrlId+'.bold',this.buttonClassName);if(this.state.italic)$scn(this.ctrlId+'.italic',this.buttonCheckedClassName);else $scn(this.ctrlId+'.italic',this.buttonClassName);if(this.state.underline)$scn(this.ctrlId+'.underline',this.buttonCheckedClassName);else $scn(this.ctrlId+'.underline',this.buttonClassName);if(this.state.justifyLeft)$scn(this.ctrlId+'.justifyLeft',this.buttonCheckedClassName);else $scn(this.ctrlId+'.justifyLeft',this.buttonClassName);if(this.state.justifyCenter)$scn(this.ctrlId+'.justifyCenter',this.buttonCheckedClassName);else $scn(this.ctrlId+'.justifyCenter',this.buttonClassName);if(this.state.justifyRight)$scn(this.ctrlId+'.justifyRight',this.buttonCheckedClassName);else $scn(this.ctrlId+'.justifyRight',this.buttonClassName);if(this.state.justifyFull)$scn(this.ctrlId+'.justifyFull',this.buttonCheckedClassName);else $scn(this.ctrlId+'.justifyFull',this.buttonClassName);if(this.state.unorderedList)$scn(this.ctrlId+'.unorderedList',this.buttonCheckedClassName);else $scn(this.ctrlId+'.unorderedList',this.buttonClassName);if(this.state.orderedList)$scn(this.ctrlId+'.orderedList',this.buttonCheckedClassName);else $scn(this.ctrlId+'.orderedList',this.buttonClassName);if(this.state.fontName=='')$svs(this.ctrlId+'.fontName.value','Font name');else{if(typeof this.state.fontName=='string')$svs(this.ctrlId+'.fontName.value',this.state.fontName);else $svs(this.ctrlId+'.fontName.value','Font name');}
if(this.state.fontSize=='')$svs(this.ctrlId+'.fontSize.value','Font size');else{var val=$u.s.toNum(''+this.state.fontSize);var entry=['Font size','1 (8pt)','2 (10pt)','3 (12pt)','4 (14pt)','5 (18pt)','6 (24pt)','7 (36pt)'];if(val>entry.length)val=0;$svs(this.ctrlId+'.fontSize.value',entry[val]);}
mEle=$(this.ctrlId+'.format.menu');if(mEle){if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._formatMenuHide);}}
var mEle=$(this.ctrlId+'.fontName.menu');if(mEle){if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._fontNameMenuHide);}}
mEle=$(this.ctrlId+'.fontSize.menu');if(mEle){if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._fontNameMenuHide);}}
mEle=$(this.ctrlId+'.colorMenu');if(mEle){if(mEle.style.display!='none'){mEle.style.display='none';$(this.ctrlId+'.colorMenu.noColor').style.display='none';$e.remove(document.body,'mouseup',this._fontNameMenuHide);}}
mEle=$(this.ctrlId+'.tableMenu');if(mEle){if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._fontNameMenuHide);}}},onChange:this.onChange,defaultLinkedCSS:this.defaultLinkedCSS,defaultCSS:this.defaultCSS,buttonClassName:this.buttonClassName,buttonCheckedClassName:this.buttonCheckedClassName});$e.add(this.ctrlId+'.format','click',this._formatMenuShow,this,true);$e.add(this.ctrlId+'.fontName','click',this._fontNameMenuShow,this,true);$e.add(this.ctrlId+'.fontSize','click',this._fontSizeMenuShow,this,true);$e.add(this.ctrlId+'.foreColor','click',this._foreColorMenuShow,this,true);$e.add(this.ctrlId+'.hiliteColor','click',this._hiliteColorMenuShow,this,true);$e.add(this.ctrlId+'.backColor','click',this._backColorMenuShow,this,true);$e.add(this.ctrlId+'.table','click',this._tableMenuShow,this,true);if(this.isPopup){this._window.hide();}},command:function(type){var data=typeof(arguments[1]!='undefined')?arguments[1]:null;this._rteObj.command(type,data);},edit:function(tCtrlId){var ele=$(tCtrlId);this._rteObj.setHTML($gvs(ele));var tDCtrlId=tCtrlId;if(ele.style.display=='none'&&$(tDCtrlId+'.DISPLAY'))tDCtrlId=tDCtrlId+'.DISPLAY';this._window.show('popup',tDCtrlId);this._tCtrlId=tCtrlId;if(this.onEdit.constructor==Function)this.onEdit();this._rteObj.focus();},save:function(){$svs(this._tCtrlId,this._rteObj.getHTML());if(this.onSave.constructor==Function)this.onSave();this.hide();},resize:function(nWidth,nHeight){var ele=$(this.ctrlId+'.HTMLEDITOR');if(typeof nWidth=='number')nWidth=nWidth+'px';if(typeof nHeight=='number')nHeight=nHeight+'px';ele.style.width=nWidth;ele.style.height=nHeight;ele=$(this.ctrlId);ele.style.width=nWidth;ele.style.height=nHeight;},hide:function(){this._window.hide();},toggleDesignMode:function(){this._rteObj.toggleDesignMode(arguments[0]);},insert:function(insertType){if(insertType=='image'){this._iWindow.setTitle(this.insertImage.titleText);this._iWindow.body.content.url='__a5FileUploadMasterPage.a5w?fileUploadUrl=__a5HTMLEditorFileInsertPage.a5w&fileUploadAutoUpload=true&fileUploadText='+this.insertImage.bodyText+'&fileSelectImg='+this.insertImage.editImage+'&fileBoxWaterMark='+this.insertImage.editWatermarkText+'&stylesheetName='+this.insertImage.styleName+'&insertType=image&relativePath='+this.insertImage.relativePath+'&windowID='+this._iWindow.getWindowId();}else{this._iWindow.setTitle(this.insertFile.titleText);this._iWindow.body.content.url='__a5FileUploadMasterPage.a5w?fileUploadUrl=__a5HTMLEditorFileInsertPage.a5w&fileUploadAutoUpload=true&fileUploadText='+this.insertFile.bodyText+'&fileSelectImg='+this.insertFile.editImage+'&fileBoxWaterMark='+this.insertFile.editWatermarkText+'&stylesheetName='+this.insertFile.styleName+'&insertType=file&relativePath='+this.insertFile.relativePath+'&windowID='+this._iWindow.getWindowId();}
this._iWindow.refresh();this._iWindow.show();},_fontNameMenuShow:function(e){$e.stopEvent(e);var ele=$(this.ctrlId+'.fontName');var mEle=$(this.ctrlId+'.fontName.menu');mEle.style.display='';$po(mEle,ele,'dropdown');$e.add(document.body,'mouseup',this._fontNameMenuHide,this,true);return false;},_fontNameMenuHide:function(){var mEle=$(this.ctrlId+'.fontName.menu');if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._fontNameMenuHide);}},_fontSizeMenuShow:function(e){$e.stopEvent(e);var ele=$(this.ctrlId+'.fontSize');var mEle=$(this.ctrlId+'.fontSize.menu');mEle.style.display='';$po(mEle,ele,'dropdown');$e.add(document.body,'mouseup',this._fontSizeMenuHide,this,true);return false;},_fontSizeMenuHide:function(){var mEle=$(this.ctrlId+'.fontSize.menu');if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._fontSizeMenuHide);}},_foreColorMenuShow:function(e){$e.stopEvent(e);this._colorTarget='foreColor';var ele=$(this.ctrlId+'.foreColor');var mEle=$(this.ctrlId+'.colorMenu');mEle.style.display='';$po(mEle,ele,'dropdown');$e.add(document.body,'mouseup',this._foreColorMenuHide,this,true);return false;},_foreColorMenuHide:function(){var mEle=$(this.ctrlId+'.colorMenu');if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._foreColorMenuHide);}},_hiliteColorMenuShow:function(e){$e.stopEvent(e);this._colorTarget='hilitecolor';var ele=$(this.ctrlId+'.hiliteColor');var mEle=$(this.ctrlId+'.colorMenu');mEle.style.display='';$po(mEle,ele,'dropdown');$e.add(document.body,'mouseup',this._hiliteColorMenuHide,this,true);return false;},_hiliteColorMenuHide:function(){var mEle=$(this.ctrlId+'.colorMenu');if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._hiliteColorMenuHide);}},_backColorMenuShow:function(e){$e.stopEvent(e);this._colorTarget='backColor';var ele=$(this.ctrlId+'.backColor');var mEle=$(this.ctrlId+'.colorMenu');$(this.ctrlId+'.colorMenu.noColor').style.display='';mEle.style.display='';$po(mEle,ele,'dropdown');$e.add(document.body,'mouseup',this._backColorMenuHide,this,true);return false;},_backColorMenuHide:function(){var mEle=$(this.ctrlId+'.colorMenu');if(mEle.style.display!='none'){mEle.style.display='none';$(this.ctrlId+'.colorMenu.noColor').style.display='none';$e.remove(document.body,'mouseup',this._backColorMenuHide);}},_tableMenuShow:function(e){$e.stopEvent(e);var ele=$(this.ctrlId+'.table');var mEle=$(this.ctrlId+'.tableMenu');mEle.style.display='';$po(mEle,ele,'dropdown');$e.add(document.body,'mouseup',this._tableMenuHide,this,true);return false;},_tableMenuHide:function(){var mEle=$(this.ctrlId+'.tableMenu');if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._tableMenuHide);}},_tableMenuSizeHighlight:function(col,row){for(var i=1;i<=10;i++){for(var j=1;j<=8;j++){if(i<=col&&j<=row){$(this.ctrlId+'.tbl.'+i+'x'+j).firstChild.style.background='#ccc';}else{$(this.ctrlId+'.tbl.'+i+'x'+j).firstChild.style.background='white';}}}},_formatMenuShow:function(e){$e.stopEvent(e);var ele=$(this.ctrlId+'.format');var mEle=$(this.ctrlId+'.format.menu');mEle.style.display='';$po(mEle,ele,'dropdown');$e.add(document.body,'mouseup',this._formatMenuHide,this,true);return false;},_formatMenuHide:function(){var mEle=$(this.ctrlId+'.format.menu');if(mEle.style.display!='none'){mEle.style.display='none';$e.remove(document.body,'mouseup',this._formatMenuHide);}}}
A5.windows={_w:{},get:function(targ){if(typeof targ=='number')return A5.windows._w[''+targ];},getFromElement:function(targ){var ele=$(targ);if(ele){while((ele.getAttribute('A5WindowType')==''||ele.getAttribute('A5WindowType')==null)&&ele.tagName.toLowerCase()!='body')ele=ele.parentNode;if(String(ele.getAttribute('A5WindowType'))!=''){targ=ele.id.substr(5);return A5.windows._w[targ];}}},getTop:function(){var max=0;var topIndx=0;for(var prop in A5.windows._w){if(!A5.windows._w[prop].hidden){if(A5.windows._w[prop]._zIndex>max){max=A5.windows._w[prop]._zIndex;topIndx=A5.windows._w[prop]._windowCurIndx;}}}
if(topIndx!=0)return A5.windows._w[''+topIndx];},_hidePopups:function(){var winChain=[arguments[0]];if(typeof arguments[0]=='number')winChain=A5.windows._w[''+arguments[0]]._winChain;for(var prop in A5.windows._w){if(!A5.windows._w[prop].hidden){if(A5.windows._w[prop].type=='popup'&&$u.a.find(winChain,A5.windows._w[prop]._windowCurIndx)==-1)A5.windows._w[prop].hide();}}}}
$e.add(window,'unload',function(){for(var prop in A5.windows._w)delete A5.windows._w[prop];});A5.Window=Class.create();A5.Window.prototype={initialize:function(settings){this._windowId='A5dlg'+this._windowIndx[0];this._windowCurIndx=this._windowIndx[0];this._zIndex=500+this._windowCurIndx;this._isMaximized=false;$u.o.assign(this,{type:'',theme:'',autoPosition:true,autoShow:false,resize:'none',className:'',outerWrapClassName:'',innerWrapClassName:'',activeClassName:'',adjustmentClassName:'',style:0,width:'',height:'',lockUIClassName:'',title:{html:'',location:'',direction:'',className:'',style:0,show:true,tools:{inset:'2px',items:[]}},header:{className:'',style:0,show:false,html:''},tbar:{className:'',style:0,show:false,html:''},body:{className:'',style:0,content:{type:'',elementId:'',html:'',url:''}},buttons:{className:'',style:0,show:false,items:[]},bbar:{className:'',style:0,show:false,html:''},footer:{className:'',style:0,show:false,html:''},resizer:{className:'',style:0,thumbImage:''},animation:{disabled:false,show:{type:'',duration:500},hide:{type:'',duration:500}},_defaultTools:{},disableMove:false,disableResize:false,onInitialize:0,onBeforeShow:0,onShow:0,onBeforeHide:0,onHide:0,onFocus:0,onMove:0,onResize:0});if(typeof A5._windowDefaults!='undefined')$u.o.assign(this,A5._windowDefaults);if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'window');$u.o.assign(this,settings);if(this.type==''){this.type='modeless';}else this.type=this.type.toLowerCase();if(this.type!='modal'&&this.type!='popup')this.type='modeless';this._maxDlgZIndx[0]=this._zIndex;this.resize=this.resize.toLowerCase();var resizeRegEx=RegExp('[^A-z]');if(this.resize.split(resizeRegEx).join('')=='widthheight'||this.resize.split(resizeRegEx).join('')=='heightwidth')this.resize='both';else if(this.resize!='height'&&this.resize!='width'&&this.resize!='both')this.resize='none';this.title.location=this.title.location.toLowerCase();if(this.title.location!='bottom')this.title.location=='top';this.body.content.type=this.body.content.type.toLowerCase();if(this.body.content.type!='element'&&this.body.content.type!='url'&&this.body.content.type!='blank')this.body.content.type='static';if(typeof this.autoPosition=='boolean'){if(this.autoPosition)this.autoPosition='center';else this.autoPosition='none';}else if(this.autoPosition!='center'&&this.autoPosition!='none'&&this.autoPosition!='in-view')this.autoPosition='center';if((this.animation.show.type==''||this.animation.show.type.toLowerCase()=='none')&&(this.animation.hide.type==''||this.animation.hide.type.toLowerCase()=='none'))this.animation.disabled=true;this.hidden=true;var HTMLDlgMainEle=document.createElement('div');HTMLDlgMainEle.id=this._windowId;$sa(HTMLDlgMainEle,'A5WindowIndex',this._windowCurIndx);$sa(HTMLDlgMainEle,'A5WindowType',this.type);$sa(HTMLDlgMainEle,'A5WindowBodyType',$if(this.body.content.type=='url','iframe','div'));$sa(HTMLDlgMainEle,'A5WindowActiveClassName',this.activeClassName);$sa(HTMLDlgMainEle,'A5WindowAdjustClassName',this.adjustmentClassName);HTMLDlgMainEle.className=this.className;if(typeof this.style=='object'||typeof this.style=='string')$ss(HTMLDlgMainEle,this.style);if(this.animation.disabled){if(document.all&&navigator.appName!='Opera')HTMLDlgMainEle.style.display='none';else HTMLDlgMainEle.style.visibility='hidden';}else HTMLDlgMainEle.style.display='none';HTMLDlgMainEle.style.position='absolute';HTMLDlgMainEle.style.top='0px';HTMLDlgMainEle.style.left='0px';HTMLDlgMainEle.style.padding='0px';HTMLDlgMainEle.style.zIndex=''+this._zIndex;HTMLDlgEle=document.createElement('div');HTMLDlgEle.id=this._windowId+'.INNER';HTMLDlgEle.className=this.outerWrapClassName;$ss(HTMLDlgEle,' box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');if(document.all)HTMLDlgEle.style.width='100%';HTMLDlgMainEle.appendChild(HTMLDlgEle);var HTMLDlgTitleEle=document.createElement('div');HTMLDlgTitleEle.id=this._windowId+'.TITLE';HTMLDlgTitleEle.className=this.title.className;if(typeof this.title.style=='object'||typeof this.title.style=='string')$ss(HTMLDlgTitleEle,this.title.style);if(!this.title.show)HTMLDlgTitleEle.style.display='none';$sa(HTMLDlgTitleEle,'A5WindowDisplayElement',$if(this.title.show,'true','false'));if(this.resize=='both')$e.add(HTMLDlgTitleEle,'dblclick',this.toggleMaximize,this,true);if(this.title.location!='bottom')HTMLDlgEle.appendChild(HTMLDlgTitleEle);var HTMLDlgTmplEle2=document.createElement('span');HTMLDlgTmplEle2.id=this._windowId+'.TITLE.TEXT';HTMLDlgTitleEle.appendChild(HTMLDlgTmplEle2);HTMLDlgTmplEle2=document.createElement('div');HTMLDlgTmplEle2.id=this._windowId+'.TITLE.TOOLS';HTMLDlgTmplEle2.style.position='absolute';if(this.title.direction.toLowerCase()=='rtl'){HTMLDlgTitleEle.style.textAlign='right';HTMLDlgTmplEle2.style.left=this.title.tools.inset;}else HTMLDlgTmplEle2.style.right=this.title.tools.inset;var HTMLBEle=0;$e.add(HTMLDlgTmplEle2,'mousedown',function(e){$e.stopEvent(e);return false;});HTMLDlgTitleEle.insertBefore(HTMLDlgTmplEle2,HTMLDlgTitleEle.firstChild);HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._windowId+'.HEADER';HTMLDlgTmplEle.className=this.header.className;if(typeof this.header.style=='object'||typeof this.header.style=='string')$ss(HTMLDlgTmplEle,this.header.style);if(!this.header.show)HTMLDlgTmplEle.style.display='none';$sa(HTMLDlgTmplEle,'A5WindowDisplayElement',$if(this.header.show,'true','false'));HTMLDlgTmplEle.innerHTML=this.header.html;HTMLDlgEle.appendChild(HTMLDlgTmplEle);var HTMLDlgBodyContEle=document.createElement('div');HTMLDlgBodyContEle.id=this._windowId+'.BODYCONTAINER';HTMLDlgBodyContEle.className=this.innerWrapClassName;HTMLDlgEle.appendChild(HTMLDlgBodyContEle);HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._windowId+'.TBAR';HTMLDlgTmplEle.className=this.tbar.className;if(typeof this.tbar.style=='object'||typeof this.tbar.style=='string')$ss(HTMLDlgTmplEle,this.tbar.style);if(!this.tbar.show)HTMLDlgTmplEle.style.display='none';$sa(HTMLDlgTmplEle,'A5WindowDisplayElement',$if(this.tbar.show,'true','false'));HTMLDlgTmplEle.innerHTML=this.tbar.html;HTMLDlgBodyContEle.appendChild(HTMLDlgTmplEle);if(this.body.content.type=='url'){HTMLDlgTmplEle=document.createElement('iframe');HTMLDlgTmplEle.frameBorder='0';HTMLDlgTmplEle.border='0';}else HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._windowId+'.BODY';HTMLDlgTmplEle.className=this.body.className;if(typeof this.body.style=='object'||typeof this.body.style=='string')$ss(HTMLDlgTmplEle,this.body.style);if(this.body.content.type=='url'){HTMLDlgTmplEle.style.padding='0px';HTMLDlgTmplEle.style.width='100%';if(!document.all)HTMLDlgTmplEle.style.marginBottom='-2px';}
HTMLDlgBodyContEle.appendChild(HTMLDlgTmplEle);HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._windowId+'.BUTTONS';HTMLDlgTmplEle.className=this.buttons.className;if(typeof this.buttons.style=='object'||typeof this.buttons.style=='string')$ss(HTMLDlgTmplEle,this.buttons.style);if(this.buttons.items.length>0&&!this.buttons.show)this.buttons.show=true;if(!this.buttons.show)HTMLDlgTmplEle.style.display='none';$sa(HTMLDlgTmplEle,'A5WindowDisplayElement',$if(this.buttons.show,'true','false'));HTMLDlgBodyContEle.appendChild(HTMLDlgTmplEle);HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._windowId+'.BBAR';HTMLDlgTmplEle.className=this.bbar.className;if(typeof this.bbar.style=='object'||typeof this.bbar.style=='string')$ss(HTMLDlgTmplEle,this.bbar.style);if(!this.bbar.show)HTMLDlgTmplEle.style.display='none';$sa(HTMLDlgTmplEle,'A5WindowDisplayElement',$if(this.bbar.show,'true','false'));HTMLDlgTmplEle.innerHTML=this.bbar.html;HTMLDlgBodyContEle.appendChild(HTMLDlgTmplEle);HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._windowId+'.FOOTER';HTMLDlgTmplEle.className=this.footer.className;if(typeof this.footer.style=='object'||typeof this.footer.style=='string')$ss(HTMLDlgTmplEle,this.footer.style);if(!this.footer.show)HTMLDlgTmplEle.style.display='none';$sa(HTMLDlgTmplEle,'A5WindowDisplayElement',$if(this.footer.show,'true','false'));HTMLDlgTmplEle.innerHTML=this.footer.html;HTMLDlgEle.appendChild(HTMLDlgTmplEle);if(this.title.location=='bottom')HTMLDlgEle.appendChild(HTMLDlgTitleEle);if(this.resize!='none'){HTMLDlgTmplEle=document.createElement('div');HTMLDlgTmplEle.id=this._windowId+'.RESIZER';HTMLDlgTmplEle.className=this.resizer.className;if(typeof this.resizer.style=='object'||typeof this.resizer.style=='string')$ss(HTMLDlgTmplEle,this.resizer.style);if(this.resizer.thumbImage!=''&&(this.resize=='width'||this.resize=='both')){var HTMLIEle=document.createElement('img');HTMLIEle.src=this.resizer.thumbImage;HTMLIEle.id=this._windowId+'.RESIZERTHUMB';HTMLIEle.style.position='absolute';HTMLIEle.style.right='0px';HTMLIEle.style.bottom='0px';var resizeType='br';HTMLIEle.style.cursor='se-resize';if(this.resize=='width'){resizeType='r';HTMLIEle.style.cursor='e-resize';}
HTMLDlgTmplEle.appendChild(HTMLIEle);AUI.Resize.create(HTMLIEle,{resizeElementId:this._windowId,type:resizeType,minHeight:55,onResizeStart:function(e,sObj){var ele=$(this.resizeElementId+'.BODYCONTAINER');sObj.bodyWidth=ele.offsetWidth;var ele=$(this.resizeElementId+'.BODY');if(sObj.type!='r')sObj.bodyHeight=ele.offsetHeight;else sObj.bodyHeight=ele.style.height;ele=$(this.resizeElementId);var hOff=Math.min(4,Math.max(ele.offsetHeight-ele.clientHeight,0));var wOff=Math.min(4,Math.max(ele.offsetWidth-ele.clientWidth,0));ele.style.width=(ele.offsetWidth-wOff)+'px';ele.style.height=(ele.offsetHeight-hOff)+'px';ele.style.padding='0px';$e.execute(ele,'mousedown');if(document.all&&navigator.appName!='Opera')ele.firstChild.style.display='none';else ele.firstChild.style.visibility='hidden';$(this.resizeElementId+'.TITLE.TOOLS').style.display='none';$(this.resizeElementId+'.RESIZERTHUMB').style.display='none';var adjClassName=$ga(ele,'A5WindowAdjustClassName');if(adjClassName!='')$acn(ele,adjClassName);},onResizeEnd:function(e,sObj){var bcEle=$(this.resizeElementId+'.BODYCONTAINER');bcEle.style.width=(sObj.bodyWidth+(sObj.width-sObj.initialWidth))+'px';var ele=$(this.resizeElementId+'.BODY');if(document.all&&navigator.appName!='Opera')$(this.resizeElementId).firstChild.style.display='';else $(this.resizeElementId).firstChild.style.visibility='';if(ele.tagName.toLowerCase()=='iframe'){var sizeAdj=(ele.offsetWidth-ele.clientWidth)+(bcEle.offsetWidth-bcEle.clientWidth);ele.style.width=(bcEle.offsetWidth-sizeAdj)+'px';}
if(sObj.type!='r')ele.style.height=(sObj.bodyHeight+(sObj.height-sObj.initialHeight))+'px';else ele.style.height=sObj.bodyHeight;$(this.resizeElementId+'.HEADER').style.width=ele.style.width;$(this.resizeElementId+'.FOOTER').style.width=ele.style.width;ele=$(this.resizeElementId);ele.style.width='';ele.style.height='';ele.style.padding='';var adjClassName=$ga(ele,'A5WindowAdjustClassName');if(adjClassName!='')$rcn(ele,adjClassName);$(this.resizeElementId+'.TITLE.TOOLS').style.display='';$(this.resizeElementId+'.RESIZERTHUMB').style.display='';$e.execute(ele,'resizeComplete');}});}
HTMLDlgEle.appendChild(HTMLDlgTmplEle);if(this.resize=='height'||this.resize=='both'){HTMLDlgTmplEle.style.cursor='s-resize';AUI.Resize.create(HTMLDlgTmplEle,{resizeElementId:this._windowId,type:'b',minHeight:50,onResizeStart:function(e,sObj){var ele=$(this.resizeElementId);var hOff=Math.min(4,Math.max(ele.offsetHeight-ele.clientHeight,0));var wOff=Math.min(4,Math.max(ele.offsetWidth-ele.clientWidth,0));ele.style.width=(ele.offsetWidth-wOff)+'px';ele.style.height=(ele.offsetHeight-hOff)+'px';ele.style.padding='0px';$e.execute(ele,'mousedown');sObj.bodyHeight=$(this.resizeElementId+'.BODY').offsetHeight;if(document.all&&navigator.appName!='Opera')ele.firstChild.style.display='none';else ele.firstChild.style.visibility='hidden';$(this.resizeElementId+'.TITLE.TOOLS').style.display='none';var adjClassName=$ga(ele,'A5WindowAdjustClassName');if(adjClassName!='')$acn(ele,adjClassName);},onResizeEnd:function(e,sObj){var ele=$(this.resizeElementId);if(document.all&&navigator.appName!='Opera')ele.firstChild.style.display='';else ele.firstChild.style.visibility='';$(this.resizeElementId+'.TITLE.TOOLS').style.display='';ele.style.width='';ele.style.height='';ele.style.padding='';var adjClassName=$ga(ele,'A5WindowAdjustClassName');if(adjClassName!='')$rcn(ele,adjClassName);var eleB=$(this.resizeElementId+'.BODY');eleB.style.height=(sObj.bodyHeight+(sObj.height-sObj.initialHeight))+'px';$e.execute(ele,'resizeComplete');}});}}
$e.add(HTMLDlgMainEle,'click',function(e){$e.stopPropagation(e);});$e.add(HTMLDlgMainEle,'mousedown',function(){A5.windows._hidePopups(this._windowCurIndx);if(this.type!='modal')this._moveToFront();},this,true);if(this.onResize.constructor==Function){$e.add(HTMLDlgMainEle,'resizeComplete',function(){this.onResize();},this,true);}
if(this.onMove.constructor==Function){$e.add(HTMLDlgMainEle,'dragComplete',function(){this.onMove();},this,true);}
if($('AUILockUIPage'))document.body.insertBefore(HTMLDlgMainEle,$('AUILockUIPage').nextSibling);else document.body.insertBefore(HTMLDlgMainEle,document.body.firstChild);this._lockIndex=-1;if(this.body.content.type=='element'){if($(this.body.content.elementId)){var contentEle=$(this.body.content.elementId);$(this._windowId+'.BODY').appendChild(contentEle);contentEle.style.display='';delete contentEle;}}
this._tools=new Array();for(var i=0;i<this.title.tools.items.length;i++){this.addTool(this.title.tools.items[i]);}
this._buttons=new Array();for(var i=0;i<this.buttons.items.length;i++){this.addButton(this.buttons.items[i]);}
AUI.Drag.create($(this._windowId+'.TITLE'),{coord:'custom',dragElementId:this._windowId,onDragStart:function(){var ele=$(this.dragElementId);$e.execute(ele,'mousedown');for(var i=0;i<ele.firstChild.childNodes.length;i++){if(typeof ele.firstChild.childNodes[i].tagName!='undefined'){if(ele.firstChild.childNodes[i].id!=this.dragElementId+'.TITLE')ele.firstChild.childNodes[i].style.visibility='hidden';}}
var adjClassName=$ga(ele,'A5WindowAdjustClassName');if(adjClassName!='')$acn(ele,adjClassName);},onDragEnd:function(){var ele=$(this.dragElementId);for(var i=0;i<ele.firstChild.childNodes.length;i++){if(typeof ele.firstChild.childNodes[i].tagName!='undefined')ele.firstChild.childNodes[i].style.visibility='';}
var adjClassName=$ga(ele,'A5WindowAdjustClassName');if(adjClassName!='')$rcn(ele,adjClassName);$e.execute(ele,'dragComplete');}});this.setMoveDisabled(this.disableMove);this.setResizeDisabled(this.disableResize);A5.windows._w[''+this._windowIndx[0]]=this;this._a={};this._winChain=[this._windowCurIndx];if(this.type=='popup')this._popupHide=function(){this.hide();};this._windowIndx[0]=this._windowIndx[0]+1;this._initShow=false;this._resize();this.setTitle(this.title.html);if(this.autoShow)this.show();},show:function(){if(this.hidden){if(this.onBeforeShow.constructor==Function){var result=this.onBeforeShow.call(this);if(typeof result!='boolean')result=true;if(!result)return false;}
var wEle=$(this._windowId);if(this.activeClassName!='')$acn(wEle,this.activeClassName);this._moveToFront();if(this.animation.disabled){if(document.all&&navigator.appName!='Opera')wEle.style.display='';else wEle.style.visibility='';if(typeof arguments[0]!='undefined')this.setPosition.apply(this,arguments);else if(this.autoPosition!='none'&&this._initShow)this.setPosition(this.autoPosition);else if(!this._initShow){this.setPosition('center');if(this.onInitialize.constructor==Function)this.onInitialize.call(this);this._initShow=true;}}else{wEle.style.display='';wEle.style.visibility='hidden';if(typeof arguments[0]!='undefined')this.setPosition.apply(this,arguments);else if(this.autoPosition!='none'&&this._initShow)this.setPosition(this.autoPosition);else if(!this._initShow){this.setPosition('center');if(this.onInitialize.constructor==Function)this.onInitialize.call(this);this._initShow=true;}
wEle.style.visibility='';wEle.style.display='none';A5.u.element.show(wEle,this.animation.show);}
if(this.body.content.type=='url'){var bcEle=$(this._windowId+'.BODYCONTAINER');var bEle=$(this._windowId+'.BODY');if(document.all&&bcEle.style.width==''){this.width='4in';bcEle.style.width=this.width;}
var sizeAdj=(bEle.offsetWidth-bEle.clientWidth)+(bcEle.offsetWidth-bcEle.clientWidth);bEle.style.width=(bcEle.offsetWidth-sizeAdj)+'px';}
if(!this._initShow)this.refresh();if(this.onFocus.constructor==Function)this.onFocus.call(this);if(typeof this._targetId!='undefined'){var pWin=A5.windows.getFromElement(this._targetId);this._winChain=[];if(pWin)this._winChain=this._winChain.concat(pWin._winChain);this._winChain.push(this._windowCurIndx);}
if(this.type=='modal'){this._lockIndex=AUI.LockUI.page(this.lockUIClassName,this._zIndex);$e.add('AUILockUIPage','click',A5.windows._hidePopups);}else if(this.type=='popup'){var classInst=this;setTimeout(function(){$e.add(document.documentElement,'click',classInst._popupHide,classInst,true);delete classInst;},10);}
A5.windows._hidePopups(this._windowCurIndx);this.hidden=false;if(this.onShow.constructor==Function)this.onShow.call(this);}else this.focus();},hide:function(){if(!this.hidden){if(this.onBeforeHide.constructor==Function){var result=this.onBeforeHide.call(this);if(typeof result!='boolean')result=true;if(!result)return false;}
if(this.type=='modal')AUI.LockUI.pageFree();else if(this.type=='popup')$e.remove(document.documentElement,'click',this._popupHide);var wEle=$(this._windowId);if(this.animation.disabled){if(document.all&&navigator.appName!='Opera')wEle.style.display='none';else wEle.style.visibility='hidden';}else A5.u.element.hide(wEle,this.animation.hide);if(this.activeClassName!='')$rcn(wEle,this.activeClassName);this._lockIndex=-1;this.hidden=true;if(this.onHide.constructor==Function)this.onHide.call(this);this._focusTopWindow();}},focus:function(){this._moveToFront();if(this.onFocus.constructor==Function)this.onFocus.call(this);},refresh:function(){if(this.body.content.type=='static'){$(this._windowId+'.BODY').innerHTML=this.body.content.html;}else if(this.body.content.type=='url'){$(this._windowId+'.BODY').src=A5.ajax.addURLRequiredData(this.body.content.url);}},maximize:function(){if(!this._isMaximized){this._maxSizeAdjust=-2;var cs=AUI.u.getVPSize();var wEle=$(this._windowId);var bEle=$(this._windowId+'.BODY');cs.width=cs.width-(wEle.offsetWidth-bEle.offsetWidth)+this._maxSizeAdjust;cs.height=cs.height-(wEle.offsetHeight-bEle.offsetHeight)+this._maxSizeAdjust;this._restoreScroll=AUI.u.getVPScroll();this._restoreTop=wEle.style.top;this._restoreLeft=wEle.style.left;this._restoreWidth=bEle.style.width;this._restoreHeight=bEle.style.height;this.setPosition('0px','0px');this.setSize(cs.width+'px',cs.height+'px');AUI.Drag.disable(this._windowId);AUI.Resize.disable(this._windowId);this.focus();$e.add(window,'resize',this._keepMaximized,this,true);this._isMaximized=true;}},restore:function(){if(this._isMaximized){document.body.style.overflow='';this.setPosition(this._restoreTop,this._restoreLeft);this.setSize(this._restoreWidth,this._restoreHeight);this.setMoveDisabled(this.disableMove);this.setResizeDisabled(this.disableResize);window.scrollTo(this._restoreScroll.x,this._restoreScroll.y);this.focus();$e.remove(window,'resize',this._keepMaximized);this._isMaximized=false;}},toggleMaximize:function(){if(this._isMaximized)this.restore();else this.maximize();},addButton:function(btnObj){var fEle=$(this._windowId+'.BUTTONS');$u.o.assign(btnObj,this._buttonDefaults,true);if(btnObj.name=='')btnObj.name=btnObj.html.split(RegExp('[^A-z ]')).join('');this._buttons.push(new A5.Button(btnObj));var HTMLBEle=this._buttons[this._buttons.length-1].create({'id':this._windowId+'.BUTTON.'+btnObj.name,'A5WindowButtonType':'button','A5WindowButtonIndex':''+(this._buttons.length-1),'A5WindowButtonName':btnObj.name});$e.add(HTMLBEle,'click',this._windowAction,this);HTMLBEle.style.width=btnObj.width;fEle.appendChild(HTMLBEle);if(btnObj.show==false)this._buttons[this._buttons.length-1].setDisplay(false);if(btnObj.disabled)this._buttons[this._buttons.length-1].setDisabled(true);fEle.appendChild(document.createTextNode(' '));},removeButton:function(btnName){var fEle=$(this._windowId+'.BUTTONS');for(var i=this._buttons.length-1;i>=0;i--){$sa(this._windowId+'.BUTTON.'+this._buttons[i].name,'A5WindowButtonIndex',i-1);if(this._buttons[i].name==btnName){this._buttons.splice(i,1);$e.remove(this._windowId+'.BUTTON.'+btnName,'click',this._windowAction);fEle.removeChild($(this._windowId+'.BUTTON.'+btnName));break;}}},setButtonDisabled:function(btnName,disableBool){for(var i=this._buttons.length-1;i>=0;i--){if(this._buttons[i].name==btnName){this._buttons[i].setDisabled(disableBool);break;}}},setButtonDisplay:function(btnName,displayBool){for(var i=this._buttons.length-1;i>=0;i--){if(this._buttons[i].name==btnName){this._buttons[i].setDisplay(displayBool);break;}}},getButton:function(btnName){for(var i=this._buttons.length-1;i>=0;i--){if(this._buttons[i].name==btnName)return this._buttons[i];}
return false;},clearButtons:function(){var fEle=$(this._windowId+'.BUTTONS');for(var i=this._buttons.length-1;i>=0;i--){$e.remove(this._windowId+'.BUTTON.'+this._buttons[i].name,'click',this._windowAction);}
fEle.innerHTML='&nbsp;';this._buttons=new Array();},addTool:function(toolObj){var tEle=$(this._windowId+'.TITLE.TOOLS');if(typeof toolObj=='string'){if(typeof this._defaultTools[toolObj]=='object')toolObj=this._defaultTools[toolObj];else return false;}
$u.o.assign(toolObj,this._toolDefaults,true);var HTMLBEle=document.createElement('input');HTMLBEle.type='image';HTMLBEle.id=this._windowId+'.TITLE.TOOLS.'+toolObj.name;HTMLBEle.src=toolObj.image;HTMLBEle.style.cursor='default';if(toolObj.imageHover!=''){$e.add(HTMLBEle,'mouseover',Function('this.src = \''+toolObj.imageHover+'\';'));$e.add(HTMLBEle,'mouseout',Function('this.src = \''+toolObj.image+'\';'));}else toolObj.imageHover=toolObj.image;if(toolObj.imagePressed!=''){$e.add(HTMLBEle,'mousedown',Function('this.src = \''+toolObj.imagePressed+'\';'));$e.add(HTMLBEle,'mouseup',Function('this.src = \''+toolObj.imageHover+'\';'));}
if(toolObj.disabled){HTMLBEle.disabled=true;$acn(HTMLBEle,toolObj.disabledClassName);}else{HTMLBEle.disabled=false;$rcn(HTMLBEle,toolObj.disabledClassName);}
if(!toolObj.show)HTMLBEle.style.display='none';else HTMLBEle.style.display='';$sa(HTMLBEle,'A5WindowButtonType','tool');$sa(HTMLBEle,'A5WindowButtonName',toolObj.name);$sa(HTMLBEle,'A5WindowButtonIndex',''+this._tools.length);$e.add(HTMLBEle,'click',this._windowAction,this);tEle.appendChild(HTMLBEle);this._tools.push(toolObj);},removeTool:function(toolName){var tEle=$(this._windowId+'.TITLE.TOOLS');for(var i=this._tools.length-1;i>=0;i--){$sa(this._windowId+'.'+this._tools[i].name,'A5WindowButtonIndex',i-1);if(this._tools[i].name==toolName){this._tools.splice(i,1);$e.remove(this._windowId+'.TITLE.TOOLS.'+toolName,'click',this._windowAction);tEle.removeChild($(this._windowId+'.TITLE.TOOLS.'+toolName));break;}}},setToolDisabled:function(toolName,disableBool){for(var i=this._tools.length-1;i>=0;i--){if(this._tools[i].name==toolName){this._tools[i].disabled=disableBool;var bEle=$(this._windowId+'.TITLE.TOOLS.'+toolName);if(disableBool){bEle.disabled=true;if(this._tools[i].disabledClassName!='')$acn(bEle,this._tools[i].disabledClassName);}else{bEle.disabled=false;if(this._tools[i].disabledClassName!='')$rcn(bEle,this._tools[i].disabledClassName);}
break;}}},setToolDisplay:function(toolName,displayBool){for(var i=this._tools.length-1;i>=0;i--){if(this._tools[i].name==toolName){var bEle=$(this._windowId+'.TITLE.TOOLS.'+toolName);if(displayBool)bEle.style.display='';else bEle.style.display='none';break;}}},clearTools:function(){var tEle=$(this._windowId+'.TITLE.TOOLS');for(var i=this._tools.length-1;i>=0;i--){$e.remove(this._windowId+'.TITLE.TOOL.'+this._tools[i].name,'click',this._windowAction);}
tEle.innerHTML='&nbsp;';this._tools=new Array();},setPosition:function(val1,val2){var wEle=$(this._windowId);if(val1.toLowerCase()=='center'){var vpSize=AUI.u.getVPSize();var vpScroll=AUI.u.getVPScroll();wEle.style.top=Math.max(Math.round(((vpSize.height)/2)-(wEle.offsetHeight/2)+vpScroll.y),0)+'px';wEle.style.left=Math.max(Math.round(((vpSize.width)/2)-(wEle.offsetWidth/2)+vpScroll.x),0)+'px';}else if(val1.toLowerCase()=='in-view'){var vpScroll=AUI.u.getVPScroll();var vpSize=AUI.u.getVPSize();if(vpScroll.y+vpSize.height<wEle.offsetTop+wEle.offsetHeight||vpScroll.y>wEle.offsetTop)wEle.style.top=Math.max(Math.round(((vpSize.height)/2)-(wEle.offsetHeight/2)+vpScroll.y),0)+'px';if(vpScroll.x+vpSize.width<wEle.offsetLeft+wEle.offsetWidth||vpScroll.x>wEle.offsetLeft)wEle.style.left=Math.max(Math.round(((vpSize.width)/2)-(wEle.offsetWidth/2)+vpScroll.x),0)+'px';}else if(val1.toLowerCase()=='dropdown'||val1.toLowerCase()=='dropdown-right'||val1.toLowerCase()=='flyout'||val1.toLowerCase()=='flyout-bottom'||val1.toLowerCase()=='popup'||val1.toLowerCase()=='popup-bottom'){var pEle=$(val2);if(pEle){$po(wEle,pEle,val1.toLowerCase());}}else if(typeof val1!='undefined'&&typeof val2!='undefined'){if(typeof val1=='Number')wEle.style.top=val1+'px';else wEle.style.top=val1;if(typeof val2=='Number')wEle.style.left=val2+'px';else wEle.style.left=val2;}
if(this.onMove.constructor==Function)this.onMove();},setSize:function(wSize,hSize){this.width=wSize;this.height=hSize;this._resize();if(this.onResize.constructor==Function)this.onResize();},setTitle:function(title){this.title.html=title;if(this.title.html=='')this.title.html='&nbsp;';$(this._windowId+'.TITLE.TEXT').innerHTML=title;},setDisplay:function(part,show){part=part.toLowerCase();var eleId=this.getWindowId(part);if(eleId!=this._windowId){var ele=$(eleId);if(!show)ele.style.display='none';else ele.style.display='';$sa(ele,'A5WindowDisplayElement',$if(show,'true','false'));}},setMoveDisabled:function(disableBool){if(disableBool)AUI.Drag.disable(this._windowId);else AUI.Drag.enable(this._windowId);this.disableMove=disableBool;},setResizeDisabled:function(disableBool){if(disableBool)AUI.Resize.disable(this._windowId);else AUI.Resize.enable(this._windowId);this.disableResize=disableBool;},addAction:function(name,func){this._a[name]=func;},getWindowId:function(part){part=typeof arguments[0]!='undefined'?arguments[0].toString():'';part=part.toLowerCase();var eleId=this._windowId;if(part=='title')eleId=eleId+'.TITLE';else if(part=='header')eleId=eleId+'.HEADER';else if(part=='body-container')eleId=eleId+'.BODYCONTAINER';else if(part=='tbar')eleId=eleId+'.TBAR';else if(part=='body')eleId=eleId+'.BODY';else if(part=='bbar')eleId=eleId+'.BBAR';else if(part=='buttons')eleId=eleId+'.BUTTONS';else if(part=='footer')eleId=eleId+'.FOOTER';return eleId;},_resize:function(){var bcEle=$(this._windowId+'.BODYCONTAINER');var bEle=$(this._windowId+'.BODY');bcEle.style.width=this.width;bEle.style.height=this.height;if(this.body.content.type=='url'&&!this.hidden){if(document.all&&this.width==''){this.width='4in';bcEle.style.width=this.width;}
var sizeAdj=(bEle.offsetWidth-bEle.clientWidth)+(bcEle.offsetWidth-bcEle.clientWidth);bEle.style.width=(bcEle.offsetWidth-sizeAdj)+'px';}},_keepMaximized:function(){var cs=AUI.u.getVPSize();var wEle=$(this._windowId);var bEle=$(this._windowId+'.BODY');cs.width=cs.width-(wEle.offsetWidth-bEle.offsetWidth)+this._maxSizeAdjust;cs.height=cs.height-(wEle.offsetHeight-bEle.offsetHeight)+this._maxSizeAdjust;this.setSize(cs.width+'px',cs.height+'px');},_focusTopWindow:function(){var ele=0;var maxVZ=0;var wZIndex=0;var topIndx=-1;for(var i=this._windowIndx[0]-1;i>=0;i--){ele=$('A5dlg'+i);if(ele.style.visibility!='hidden'){wZIndex=Number(ele.style.zIndex);if(wZIndex>maxVZ){maxVZ=wZIndex
topIndx=i;}}}
$e.execute($('A5dlg'+topIndx),'mousedown');},_moveToFront:function(){var ele=$(this._windowId);var bEle=0;var tWZIndex=Number(ele.style.zIndex);if(tWZIndex==this._maxDlgZIndx[0]&&this._initShow)return false;ele.style.zIndex=''+(this._maxDlgZIndx[0]);this._zIndex=this._maxDlgZIndx[0];var wType='';var fExt='';var bType='';var aClassName='';var wZIndex=0;var modalIndex=0;if(AUI.LockUI._plLevel)modalIndex=AUI.LockUI._plLevel.length-1;for(var i=this._windowIndx[0]-1;i>=0;i--){ele=$('A5dlg'+i);wType=$ga(ele,'A5WindowType');bType=$ga(ele,'A5WindowBodyType');aClassName=$ga(ele,'A5WindowActiveClassName');if(i!=this._windowCurIndx){if(aClassName!='')$rcn(ele,aClassName);if(bType=='iframe'){bEle=$('A5dlg'+i+'.BODY');fExt=bEle.src.toString().split('.').pop().substr(0,3).toLowerCase();if(fExt=='pdf')bEle.style.visibility='hidden';}
wZIndex=Number(ele.style.zIndex);if(wZIndex>tWZIndex){ele.style.zIndex=''+(wZIndex-1);if(wType=='modal'&&ele.style.display!='none'&&ele.style.display!='hidden'){AUI.LockUI._plLevel[modalIndex]=AUI.LockUI._plLevel[modalIndex]-1;modalIndex--;}}}else{if(aClassName!='')$acn(ele,aClassName);if(bType=='iframe'){$('A5dlg'+i+'.BODY').style.visibility='';}}}
if(AUI.LockUI._plLevel.length!=0){var newZIndx=0;for(var i=0;i<AUI.LockUI._plLevel.length;i++)newZIndx=Math.max(newZIndx,AUI.LockUI._plLevel[i]);$('AUILockUIPage').style.zIndex=''+newZIndx;}},_windowAction:function(e,classInst){var index=Number($ga(this,'A5WindowButtonIndex'));var type=$ga(this,'A5WindowButtonType');if(index>=0){var action='';if(type=='tool'&&typeof classInst._tools[index]!=undefined){if(classInst._tools[index].action.constructor==Function){classInst._tools[index].action.call(classInst);}else{action=classInst._tools[index].action.toString().toLowerCase();}}else if(type=='button'&&typeof classInst._buttons[index]!=undefined){if(classInst._buttons[index].action.constructor==Function){classInst._buttons[index].action.call(classInst);}else{action=classInst._buttons[index].action.toString().toLowerCase();}}
if(action!=''){if(action=='close'||action=='cancel'||action=='hide')classInst.hide();else if(action=='refresh')classInst.refresh();else if(action=='maximize')classInst.maximize();else if(action=='restore')classInst.restore();else if(action=='togglemaximize')classInst.toggleMaximize();else if(typeof classInst._a[action]!='undefined')classInst._a[action].call(classInst);}}},_buttonDefaults:{html:'',action:'close',name:'',disabled:false,show:true,width:''},_toolDefaults:{image:'',imageHover:'',imagePressed:'',action:'close',name:'',disabled:false,show:true,className:'',disabledClassName:'',style:0},_windowIndx:[0],_maxDlgZIndx:[0]}
A5.msgBox={show:function(title,html,type){if(this._window==0){this._window=new A5.Window({theme:this.theme,type:'modal',_msgBoxAction:'cancel',autoShow:false,onBeforeHide:function(){var result=this.handle(this._msgBoxAction);if(typeof result!='boolean')result=true;return result;}});if(typeof A5._windowDefaults!='undefined'){if(typeof A5._windowDefaults.title!='undefined'){if(typeof A5._windowDefaults.title.tools!='undefined'){if(typeof A5._windowDefaults.title.tools.defaults!='undefined'){if(typeof A5._windowDefaults.title.tools.defaults.close!='undefined')this._window.addTool(A5._windowDefaults.title.tools.defaults.close);}}}}}else{this._window._msgBoxAction='cancel';if(this._window._lockIndex!=-1)AUI.LockUI._plLevel=AUI.LockUI._plLevel.splice(this._window._lockIndex,1);}
this._window.body.content.html=html;if(typeof arguments[3]!='undefined')this._window.handle=arguments[3];else this._window.handle=function(){};if(this.className!='')this._window.className=this.className;if(this.lockUIClassName!='')this._window.lockUIClassName=this.lockUIClassName;if(this.titleClassName!='')this._window.title.className=this.titleClassName;if(this.bodyClassName!='')this._window.body.className=this.bodyClassName;if(this.footerClassName!='')this._window.BUTTONS.className=this.footerClassName;if(this.closeButtonImage!='')this._window.title.imageClose=this.closeButtonImage;if(this.buttonClassName=='')this.buttonClassName=this._window._buttonDefaults.className;if(this.buttonWidth=='')this.buttonWidth=this._window._buttonDefaults.width;type=type.toLowerCase();this._window.setToolDisplay('close',true);var showButtons=true;var buttons=0;var obutton={className:this.buttonClassName,width:this.buttonWidth};var cbutton={className:this.buttonClassName,width:this.buttonWidth};var ybutton={className:this.buttonClassName,width:this.buttonWidth};var nbutton={className:this.buttonClassName,width:this.buttonWidth};$u.o.assign(obutton,this.buttons.ok);$u.o.assign(cbutton,this.buttons.cancel);$u.o.assign(ybutton,this.buttons.yes);$u.o.assign(nbutton,this.buttons.no);obutton.action=function(){this._msgBoxAction='ok';this.hide();};cbutton.action=function(){this._msgBoxAction='cancel';this.hide();};ybutton.action=function(){this._msgBoxAction='yes';this.hide();};nbutton.action=function(){this._msgBoxAction='no';this.hide();};if(type=='o'){buttons=[obutton];}else if(type=='oc'){buttons=[obutton,cbutton];}else if(type=='yn'){buttons=[ybutton,nbutton];}else if(type=='ync'){buttons=[ybutton,nbutton,cbutton];}else{buttons=[];showButtons=false;if(type=='wait')this._window.setToolDisplay('close',false);}
if(showButtons){this._window.clearButtons();for(var i=0;i<buttons.length;i++){this._window.addButton(buttons[i]);}
this._window.setDisplay('buttons',true);}else{this._window.setDisplay('buttons',false);}
this._window.setTitle(title);this._window.setSize(this.width,this.height);this._window.refresh();this._window.show();},hide:function(){if(typeof this._window!='undefined')this._window.hide();},theme:'',className:'',titleClassName:'',bodyClassName:'',footerClassName:'',buttonClassName:'',buttonWidth:'',closeButtonImage:'',lockUIClassName:'',width:'',height:'',buttons:{ok:{html:'OK'},cancel:{html:'Cancel'},yes:{html:'Yes'},no:{html:'No'}},_window:0,_win:{}}
A5.TabBand=Class.create();A5.TabBand.prototype={initialize:function(ctrlId,items){var settings=typeof arguments[2]=='object'?arguments[2]:{};$u.o.assign(this,{location:'top',className:'',separator:{className:'',show:false},tab:{className:'',selectedClassName:'',disabledClassName:''},scrollButtons:{prevClassName:'',prevDisabledClassName:'',prevImage:'',prevDisabledImage:'',nextClassName:'',nextDisabledClassName:'',nextImage:'',nextDisabledImage:''},tools:{className:'',items:[]},onBeforeChange:0,onChange:0,onRightClick:0,onInitial:0,onBeforeRemove:0,onRemove:0},true);if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'tabBand');if(typeof settings.className!='undefined'){if(settings.className.charAt(0)=='+')settings.className=this.className+' '+settings.className.substr(1);}
if(typeof settings.separator!='undefined'){if(typeof settings.separator.className!='undefined'){if(settings.separator.className.charAt(0)=='+')settings.separator.className=this.separator.className+' '+settings.separator.className.substr(1);}}
if(typeof settings.tab!='undefined'){if(typeof settings.tab.className!='undefined'){if(settings.tab.className.charAt(0)=='+')settings.tab.className=this.tab.className+' '+settings.tab.className.substr(1);}
if(typeof settings.tab.selectedClassName!='undefined'){if(settings.tab.selectedClassName.charAt(0)=='+')settings.tab.selectedClassName=this.tab.selectedClassName+' '+settings.tab.selectedClassName.substr(1);}
if(typeof settings.tab.disabledClassName!='undefined'){if(settings.tab.disabledClassName.charAt(0)=='+')settings.tab.disabledClassName=this.tab.disabledClassName+' '+settings.tab.disabledClassName.substr(1);}}
if(typeof settings.scrollButtons!='undefined'){if(typeof settings.scrollButtons.prevClassName!='undefined'){if(settings.scrollButtons.prevClassName.charAt(0)=='+')settings.scrollButtons.prevClassName=this.scrollButtons.prevClassName+' '+settings.scrollButtons.prevClassName.substr(1);}
if(typeof settings.scrollButtons.prevDisabledClassName!='undefined'){if(settings.scrollButtons.prevDisabledClassName.charAt(0)=='+')settings.scrollButtons.prevDisabledClassName=this.scrollButtons.prevDisabledClassName+' '+settings.scrollButtons.prevDisabledClassName.substr(1);}
if(typeof settings.scrollButtons.nextClassName!='undefined'){if(settings.scrollButtons.nextClassName.charAt(0)=='+')settings.scrollButtons.nextClassName=this.scrollButtons.nextClassName+' '+settings.scrollButtons.nextClassName.substr(1);}
if(typeof settings.scrollButtons.nextDisabledClassName!='undefined'){if(settings.scrollButtons.nextDisabledClassName.charAt(0)=='+')settings.scrollButtons.nextDisabledClassName=this.scrollButtons.nextDisabledClassName+' '+settings.scrollButtons.nextDisabledClassName.substr(1);}}
$u.o.assign(this,settings);this.location=this.location.toLowerCase();if(this.location!='bottom')this.location='top';this.ctrlId=ctrlId;var ele=$(this.ctrlId);ele.innerHTML='';ele.className=this.className;ele.style.overflow='hidden';ele.style.position='relative';var tblEle=document.createElement('table');tblEle.id=this.ctrlId+'.TABTABLE';tblEle.cellSpacing=0;tblEle.cellPadding=0;tblEle.style.position='relative';ele.appendChild(tblEle);tblEle.insertRow(0);var ptbEle=document.createElement('div');ptbEle.id=this.ctrlId+'.PTOOLBAR';ptbEle.style.position='absolute';ptbEle.style.left='0px';if(this.location=='bottom')ptbEle.style.top='0px';else ptbEle.style.bottom='0px';var ntbEle=document.createElement('div');ntbEle.id=this.ctrlId+'.NTOOLBAR';ntbEle.style.position='absolute';ntbEle.style.right='0px';if(this.location=='bottom')ntbEle.style.top='0px';else ntbEle.style.bottom='0px';ele.appendChild(ptbEle);ele.appendChild(ntbEle);var pbEle=document.createElement('a');pbEle.id=this.ctrlId+'.PREV';pbEle.className=this.scrollButtons.prevClassName;pbEle.innerHTML='<img id="'+this.ctrlId+'.PREVIMG" src="'+this.scrollButtons.prevImage+'" style="border: none;" /> ';pbEle.style.display='none';ptbEle.appendChild(pbEle);$e.add(pbEle,'click',this._scrollPrev,this,true);$e.add(pbEle,'dlbclick',this._scrollPrev,this,true);var nbEle=document.createElement('a');nbEle.id=this.ctrlId+'.NEXT';nbEle.className=this.scrollButtons.nextClassName;nbEle.innerHTML='<img id="'+this.ctrlId+'.NEXTIMG" src="'+this.scrollButtons.nextImage+'" style="border: none;" /> ';nbEle.style.display='none';ntbEle.appendChild(nbEle);$e.add(nbEle,'click',this._scrollNext,this,true);$e.add(nbEle,'dblclick',this._scrollNext,this,true);this._firstTabIndx=-1;this._lastTabIndx=-1;this._items=new Array();for(var i=0;i<items.length;i++){this._add(items[i]);}
this._firstTabIndx=this._getFirstAvailableTab();this._lastTabIndx=this._getLastAvailableTab();this._canScroll=false;this._scrollTab=this._firstTabIndx;this._scrollOffset=0;this._scrollTempOffset=0;this._scrollAnimateInc=0;this._scrollTO=0;this._scrollRJ=false;this._canScrollNext=true;this._canScrollPrev=false;this._setScrollDisabled('p',false);if(this.separator.show){var sepEle=document.createElement('div');sepEle.className=this.separator.className;if(this.location=='bottom'){ele.insertBefore(sepEle,ele.firstChild);ptbEle.style.top=sepEle.offsetHeight+'px';ntbEle.style.top=sepEle.offsetHeight+'px';}else{ele.appendChild(sepEle);ptbEle.style.bottom=sepEle.offsetHeight+'px';ntbEle.style.bottom=sepEle.offsetHeight+'px';}
ptbEle.style.display='none';ptbEle.style.display='';ntbEle.style.display='none';ntbEle.style.display='';}
this.refresh();this.value='';$e.add(window,'resize',this.refresh,this,true);},add:function(tObj){this._add(tObj);this._firstTabIndx=this._getFirstAvailableTab();this._lastTabIndx=this._getLastAvailableTab();this.refresh();},_add:function(tObj){tObj=this._parseTab(tObj);var tIndx=this._items.length;this._items.push(tObj);var tbEle=$(this.ctrlId);var tEle=document.createElement('a');tEle.href="#";tEle.className=this._gDef(tObj.className,this.tab.className);if(tObj.disabled)$acn(tEle,this._gDef(tObj.disabledClassName,this.tab.disabledClassName));else
if(!tObj.show)tEle.style.display='none';tEle.innerHTML='<span>&nbsp;'+tObj.html+'&nbsp;</span>';if(tObj.close){var iEle=document.createElement('img');iEle.src=this._gDef(tObj.closeIcon,this.tab.closeIcon);iEle.style.verticalAlign='top';iEle.style.borderStyle='none';tEle.appendChild(iEle);$e.add(iEle,'mouseover',this._closeMOver,this);$e.add(iEle,'mouseout',this._closeMOut,this);$e.add(iEle,'click',this._close,this);}
var tblEle=$(this.ctrlId+'.TABTABLE');var cellIndx=tblEle.rows[0].cells.length;tblEle.rows[0].insertCell(cellIndx);tblEle.rows[0].cells[cellIndx].appendChild(tEle);$e.add(tEle,'click',this._click,this);$e.add(tEle,'contextmenu',this._rClick,this);},remove:function(tId){var tIndx=this._getTabIndex(tId);if(tIndx==-1)return false;var fResult=true;if(this._items[tIndx].onBeforeRemove.constructor==Function)fResult=this._items[tIndx].onBeforeRemove.call(this,this._items[tIndx]);else if(this.onBeforeRemove.constructor==Function)fResult=this.onBeforeRemove.call(this,this._items[tIndx]);if(fResult){var tEle=this._getTab(tIndx);$e.remove(tEle,'click',this._click);$e.remove(tEle,'contextmenu',this._rClick);if(tEle.lastChild.tagName){if(tEle.lastChild.tagName.toLowerCase()=='img'){$e.remove(tEle.lastChild,'mouseover',this._closeMOver);$e.remove(tEle.lastChild,'mouseout',this._closeMOut);$e.remove(tEle.lastChild,'click',this._close);}}
delete tEle;if(tIndx<this._scrollTab)this._scrollTab--;$(this.ctrlId+'.TABTABLE').rows[0].deleteCell(tIndx);if(this._items[tIndx].onRemove.constructor==Function)this._items[tIndx].onRemove.call(this,this._items[tIndx]);else if(this.onRemove.constructor==Function)this.onRemove.call(this,this._items[tIndx]);this._items.splice(tIndx,1);}
this.refresh();if(tIndx==this._curTabIndx){if(typeof this._items[tIndx]!='undefined'){if(!this._items[tIndx].disabled&&this._items[tIndx].show){this._curTabIndx=-1;this.select(tIndx);return false;}}
this.select(this._getNearestAvailableTab(this._curTabIndx));}else{if(this._curTabIndx>tIndx)this._curTabIndx--;}
if(this._items.length==0)this._curTabIndx=-1;},enable:function(tId){var tIndx=this._getTabIndex(tId);if(tIndx==-1)return false;this._items[tIndx].disabled=false;var ele=this._getTab(tIndx);if(ele)$rcn(ele,this._gDef(this._items[tIndx].className,this.tab.className));this.refresh();},disable:function(tId){var tIndx=this._getTabIndex(tId);if(tIndx==-1)return false;this._items[tIndx].disabled=true;var ele=this._getTab(tIndx);if(ele)$acn(ele,this._gDef(this._items[tIndx].disabledClassName,this.tab.disabledClassName));this.refresh();},show:function(tId){var tIndx=this._getTabIndex(tId);if(tIndx==-1)return false;this._items[tIndx].show=true;var ele=this._getTab(tIndx);if(ele)ele.style.display='';this.refresh();},hide:function(tId){var tIndx=this._getTabIndex(tId);if(tIndx==-1)return false;this._items[tIndx].show=false;var ele=this._getTab(tIndx);if(ele)ele.style.display='none';this.refresh();if(tIndx==this._curTabIndx)this.select(this._getNearestAvailableTab(this._curTabIndx));},select:function(tId){var tIndx=this._getTabIndex(tId);if(tIndx==-1)return false;if(tIndx!=this._curTabIndx&&this._items[tIndx].show&&!this._items[tIndx].disabled){var fResult=true;if(this._items[tIndx].onBeforeChange.constructor==Function)fResult=this._items[tIndx].onBeforeChange.call(this,this._items[tIndx]);else if(this.onBeforeChange.constructor==Function)fResult=this.onBeforeChange.call(this,this._items[tIndx]);if(fResult){if(typeof this._items[this._curTabIndx]!='undefined'){if(this._items[this._curTabIndx].disabled)this._getTab(this._curTabIndx).className=this._gDef(this._items[this._curTabIndx].disabledClassName,this.tab.disabledClassName);else this._getTab(this._curTabIndx).className=this._gDef(this._items[this._curTabIndx].className,this.tab.className);}
this._curTabIndx=tIndx;this.value=this._items[this._curTabIndx].value;this._getTab(this._curTabIndx).className=this._gDef(this._items[this._curTabIndx].selectedClassName,this.tab.selectedClassName);if(this._items[tIndx].onChange.constructor==Function)this._items[tIndx].onChange.call(this,this._items[tIndx]);else if(this.onChange.constructor==Function)this.onChange.call(this,this._items[tIndx]);if(!this._items[tIndx]._initial){if(this._items[tIndx].onInitial.constructor==Function)this._items[tIndx].onInitial.call(this,this._items[tIndx]);else if(this.onInitial.constructor==Function)this.onInitial.call(this,this._items[tIndx]);this._items[tIndx]._initial=true;}
this.scrollTo(tIndx);}}},reset:function(){var tIndx=this._getTabIndex(tId);if(tIndx==-1)return false;if(tIndx!=this._curTabIndx){this._items[tIndx]._initial=false;}else{if(this._items[tIndx].onInitial.constructor==Function)this._items[tIndx].onInitial.call(this,this._items[tIndx]);else if(this.onInitial.constructor==Function)this.onInitial.call(this,this._items[tIndx]);}},refresh:function(){var tbEle=$(this.ctrlId);var tblEle=$(this.ctrlId+'.TABTABLE');var pbEle=$(this.ctrlId+'.PREV');var nbEle=$(this.ctrlId+'.NEXT');this._firstTabIndx=this._getFirstAvailableTab();this._lastTabIndx=this._getLastAvailableTab();if(tblEle.offsetWidth+6>tbEle.offsetWidth&&!this._canScroll){pbEle.style.display='';nbEle.style.display='';tblEle.style.marginLeft=(pbEle.offsetWidth)+'px';this._canScroll=true;}else if(tblEle.offsetWidth+6<=tbEle.offsetWidth&&this._canScroll){pbEle.style.display='none';nbEle.style.display='none';tblEle.style.left='';tblEle.style.marginLeft='';this._setScrollDisabled('p',false);this._canScrollPrev=false;this._setScrollDisabled('n',true);this._canScrollNext=true;this._scrollTab=this._firstTabIndx;this._scrollOffset=0;this._scrollRJ=false;this._canScroll=false;}else if(this._canScroll){var ptbEle=$(this.ctrlId+'.PTOOLBAR');var ntbEle=$(this.ctrlId+'.NTOOLBAR');if((tblEle.offsetWidth-this._scrollOffset)<(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth))this._scrollTab=this._items.length-1;this._scrollReset();}},scrollTo:function(tId){if(!this._canScroll)return false;var scrollAnimate=typeof arguments[1]!='undefined'?arguments[1]:true;var tIndx=this._getTabIndex(tId);if(tIndx==-1)return false;else if(!this._items[tIndx].show)return false;var tbEle=$(this.ctrlId);var tblEle=$(this.ctrlId+'.TABTABLE');var ptbEle=$(this.ctrlId+'.PTOOLBAR');var ntbEle=$(this.ctrlId+'.NTOOLBAR');var tEle=tblEle.rows[0].cells[tIndx];if((tEle.offsetLeft+tEle.offsetWidth-this._scrollOffset)>(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth)||(tblEle.offsetWidth-this._scrollOffset)<(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth)){this._scrollRJ=true;this._scrollTab=tIndx;this._scrollOffset=tblEle.rows[0].cells[this._scrollTab].offsetLeft+tblEle.rows[0].cells[this._scrollTab].offsetWidth+4;this._scrollOffset=this._scrollOffset-(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth);this._scrollAnimate(scrollAnimate);if(this._scrollTab==this._lastTabIndx){this._setScrollDisabled('n',false);this._canScrollNext=false;}
this._setScrollDisabled('p',true);this._canScrollPrev=true;}else if(tEle.offsetLeft<this._scrollOffset){this._scrollRJ=false;this._scrollTab=tIndx;this._scrollOffset=tblEle.rows[0].cells[this._scrollTab].offsetLeft;this._scrollAnimate(scrollAnimate);if(this._scrollTab==this._firstTabIndx){this._setScrollDisabled('p',false);this._canScrollPrev=false;}
this._setScrollDisabled('n',true);this._canScrollNext=true;}},setHTML:function(tId,html){var tIndx=this._getTabIndex(tId);this._items[tIndx].html=html;$(this.ctrlId+'.TABTABLE').rows[0].cells[tIndx].firstChild.firstChild.innerHTML='&nbsp;'+html+'&nbsp;';},_scrollReset:function(){if(this._scrollTab==-1)return false;var tbEle=$(this.ctrlId);var tblEle=$(this.ctrlId+'.TABTABLE');var ptbEle=$(this.ctrlId+'.PTOOLBAR');var ntbEle=$(this.ctrlId+'.NTOOLBAR');var tEle=tblEle.rows[0].cells[this._scrollTab];if(tblEle.offsetWidth-this._scrollOffset<(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth)){this._scrollRJ=true;this._scrollTab=this._lastTabIndx;this._scrollOffset=tEle.offsetLeft+tEle.offsetWidth+4;this._scrollOffset=this._scrollOffset-(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth);this._scrollAnimate(true);}else{if(this._scrollRJ){this._scrollOffset=tEle.offsetLeft+tEle.offsetWidth+4;this._scrollOffset=this._scrollOffset-(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth);if(this._scrollOffset<0){this._scrollOffset=0;this._scrollTab=this._firstTabIndx;this._scrollRJ=false;}
this._scrollAnimate(true);}else if(this._scrollOffset!=tEle.offsetLeft){this._scrollOffset=tEle.offsetLeft;this._scrollAnimate(true);}}
if(this._scrollTab==this._lastTabIndx&&this._canScrollNext){this._setScrollDisabled('n',false);this._canScrollNext=false;}else if(this._scrollTab!=this._lastTabIndx&&!this._canScrollNext){this._setScrollDisabled('n',true);this._canScrollNext=true;}
if(this._scrollTab==this._firstTabIndx&&this._canScrollPrev){this._setScrollDisabled('p',false);this._canScrollPrev=false;}else if(this._scrollTab!=this._lastTabIndx&&!this._canScrollNext){this._setScrollDisabled('p',true);this._canScrollPrev=true;}},_scrollPrev:function(){if(this._canScrollPrev){var tbEle=$(this.ctrlId);var tblEle=$(this.ctrlId+'.TABTABLE');var ptbEle=$(this.ctrlId+'.PTOOLBAR');var ntbEle=$(this.ctrlId+'.NTOOLBAR');this._scrollTab=this._getPrevAvailableTab(this._scrollTab);if(this._scrollTab==-1){this._scrollRJ=false;this._scrollTab=this._firstTabIndx;}
if(this._scrollRJ){this._scrollOffset=tblEle.rows[0].cells[this._scrollTab].offsetLeft+tblEle.rows[0].cells[this._scrollTab].offsetWidth+4;this._scrollOffset=this._scrollOffset-(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth);if(this._scrollOffset<0){this._scrollOffset=0;this._scrollTab=this._firstTabIndx;this._scrollRJ=false;}
this._scrollAnimate(true);}else{this._scrollOffset=tblEle.rows[0].cells[this._scrollTab].offsetLeft;this._scrollAnimate(true);}
if(this._scrollTab==this._firstTabIndx&&this._canScrollPrev){this._setScrollDisabled('p',false);this._canScrollPrev=false;}else if(this._scrollTab!=this._lastTabIndx&&!this._canScrollNext){this._setScrollDisabled('p',true);this._canScrollPrev=true;}
if(!this._canScrollNext){this._setScrollDisabled('n',true);this._canScrollNext=true;}}},_scrollNext:function(){if(this._canScrollNext){var tbEle=$(this.ctrlId);var tblEle=$(this.ctrlId+'.TABTABLE');var ptbEle=$(this.ctrlId+'.PTOOLBAR');var ntbEle=$(this.ctrlId+'.NTOOLBAR');var nextTab=this._getNextAvailableTab(this._scrollTab);if(!this._scrollRJ){if((tblEle.offsetWidth-this._scrollOffset-tblEle.rows[0].cells[this._scrollTab].offsetWidth)<(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth)){this._scrollRJ=true;nextTab=this._lastTabIndx;}else{this._scrollTab=nextTab;this._scrollOffset=tblEle.rows[0].cells[this._scrollTab].offsetLeft;this._scrollAnimate(true);}}
if(this._scrollRJ){this._scrollTab=nextTab;this._scrollOffset=tblEle.rows[0].cells[this._scrollTab].offsetLeft+tblEle.rows[0].cells[this._scrollTab].offsetWidth+4;this._scrollOffset=this._scrollOffset-(tbEle.offsetWidth-ptbEle.offsetWidth-ntbEle.offsetWidth);this._scrollAnimate(true);}
if(this._scrollTab==this._lastTabIndx&&this._canScrollNext){this._setScrollDisabled('n',false);this._canScrollNext=false;}else if(this._scrollTab!=this._lastTabIndx&&!this._canScrollNext){this._setScrollDisabled('n',true);this._canScrollNext=true;}
if(!this._canScrollPrev){this._setScrollDisabled('p',true);this._canScrollPrev=true;}}},_scrollAnimate:function(){var tblEle=$(this.ctrlId+'.TABTABLE');if(typeof arguments[0]!='undefined'){if(arguments[0]){clearTimeout(this._scrollTO);this._scrollAnimateInc=5;}else{tblEle.style.left='-'+this._scrollOffset+'px';this._scrollTempOffset=this._scrollOffset;return false;}}
this._scrollAnimateInc--;if(this._scrollAnimateInc==0){tblEle.style.left='-'+this._scrollOffset+'px';this._scrollTempOffset=this._scrollOffset;}else{this._scrollTempOffset=Math.round(this._scrollOffset-((this._scrollOffset-this._scrollTempOffset)/2.5));tblEle.style.left='-'+this._scrollTempOffset+'px';var classInst=this;this._scrollTO=setTimeout(function(){classInst._scrollAnimate();delete classInst;},30);}},_setScrollDisabled:function(dir,state){if(dir=='p'){if(state){$(this.ctrlId+'.PREV').className=this.scrollButtons.prevClassName;$(this.ctrlId+'.PREVIMG').src=this.scrollButtons.prevImage;}else{$(this.ctrlId+'.PREV').className=this._gDef(this.scrollButtons.prevDisabledClassName,this.scrollButtons.prevClassName);$(this.ctrlId+'.PREVIMG').src=this._gDef(this.scrollButtons.prevDisabledImage,this.scrollButtons.prevImage);}}else{if(state){$(this.ctrlId+'.NEXT').className=this.scrollButtons.nextClassName;$(this.ctrlId+'.NEXTIMG').src=this.scrollButtons.nextImage;}else{$(this.ctrlId+'.NEXT').className=this._gDef(this.scrollButtons.nextDisabledClassName,this.scrollButtons.nextClassName);$(this.ctrlId+'.NEXTIMG').src=this._gDef(this.scrollButtons.nextDisabledImage,this.scrollButtons.nextImage);}}},_close:function(e,classInst){var tIndx=this.parentNode.parentNode.cellIndex;if(!classInst._items[tIndx].disabled)classInst.remove(tIndx);$e.stopEvent(e);return false;},_closeMOver:function(e,classInst){var tIndx=this.parentNode.parentNode.cellIndex;this.src=classInst._gDef(classInst._items[tIndx].closeIconHover,classInst.tab.closeIconHover);},_closeMOut:function(e,classInst){var tIndx=this.parentNode.parentNode.cellIndex;this.src=classInst._gDef(classInst._items[tIndx].closeIcon,classInst.tab.closeIcon);},_click:function(e,classInst){var tIndx=this.parentNode.cellIndex;classInst.select(tIndx);e=$e.getEvent(e);$e.stopEvent(e);return false;},_rClick:function(e,classInst){var tIndx=this.parentNode.cellIndex;e=$e.getEvent(e);$e.stopEvent(e);if(classInst._items[tIndx].onRightClick.constructor==Function)classInst._items[tIndx].onRightClick.call(classInst,classInst._items[tIndx]);else if(classInst.onRightClick.constructor==Function)classInst.onRightClick.call(classInst,classInst._items[tIndx]);return false;},_getTab:function(val){if(val>=0&&val<this._items.length){var cEle=$(this.ctrlId+'.TABTABLE').rows[0].cells[val];var tEle=cEle.firstChild;return tEle;}
return false;},_getTabIndex:function(val){if(typeof val=='number')return val;else{for(var i=0;i<this._items.length;i++)if(val==this._items[i].value)return i;return-1;}},_getNextAvailableTab:function(curIndex){for(var i=curIndex+1;i<this._items.length;i++)if(!this._items[i].disabled&&this._items[i].show)return i;return-1;},_getPrevAvailableTab:function(curIndex){for(var i=curIndex-1;i>-1;i--)if(!this._items[i].disabled&&this._items[i].show)return i;return-1;},_getNearestAvailableTab:function(curIndex){for(var i=curIndex-1;i>-1;i--)if(!this._items[i].disabled&&this._items[i].show)return i;for(var i=curIndex+1;i<this._items.length;i++)if(!this._items[i].disabled&&this._items[i].show)return i;return-1;},_getLastAvailableTab:function(){for(var i=this._items.length-1;i>-1;i--)if(!this._items[i].disabled&&this._items[i].show)return i;return-1;},_getFirstAvailableTab:function(curIndex){for(var i=0;i<this._items.length;i++)if(!this._items[i].disabled&&this._items[i].show)return i;return-1;},_parseTab:function(tObj){if(typeof tObj!='object')tObj={html:tObj.toString()};if(typeof tObj.close=='undefined')tObj.close=this.tab.close;$u.o.assign(tObj,this._defaultTab,true)
if(tObj.html=='')tObj.html=tObj.value;if(tObj.value=='')tObj.value=tObj.html;if(typeof tObj.className!='undefined'){if(tObj.className.charAt(0)=='+')tObj.className=this.tab.className+' '+tObj.className.substr(1);}
if(typeof tObj.selectedClassName!='undefined'){if(tObj.selectedClassName.charAt(0)=='+')tObj.selectedClassName=this.tab.selectedClassName+' '+tObj.selectedClassName.substr(1);}
if(typeof tObj.disabledClassName!='undefined'){if(tObj.disabledClassName.charAt(0)=='+')tObj.disabledClassName=this.tab.disabledClassName+' '+tObj.disabledClassName.substr(1);}
return tObj;},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_defaultTab:{html:'',value:'',className:'',selectedClassName:'',disabledClassName:'',close:false,closeIcon:'',closeIconHover:'',show:true,disabled:false,onChange:0,onBeforeChange:0,onRightClick:0,onInitial:0,onBeforeRemove:0,onRemove:0,_initial:false}}
A5.TabbedInterfaceComponentHelper=Class.create();A5.TabbedInterfaceComponentHelper.prototype={initialize:function(tbiId,settings){this.tbiId=tbiId;$u.o.assign(settings,{compact:false,fill:false,minHeight:0,tabBand:{},pane:{padding:4,header:{className:'',style:0},footer:{className:'',style:0}}},true);if(typeof settings.tabBand.hide=='undefined')settings.tabBand.hide=settings.compact;$u.o.assign(this,settings);this.tabBand.onBeforeChange=function(item){if(this.value){if(this.value!=''){if($(this.value)){var ele=$(this.value);if(document.all&&navigator.appName!='Opera')ele.style.display='none';else ele.style.visibility='hidden';}}}
var indx=-1;for(var i=0;i<this._panes.length;i++){if(this._panes[i]._id==item.value){indx=i;break;}}
var canChange=true;if(indx>-1){if(this._panes[indx].onBeforeChange.constructor==Function)canChange=this._panes[indx].onBeforeChange.call(this._tbObj,this._panes[indx]);}
return canChange;}
this.tabBand.onChange=function(item){if(this.value){if(this.value!=''){var ele=$(this.value);if(document.all&&navigator.appName!='Opera')ele.style.display='';else ele.style.visibility='';if(this._paneHeight){$(this.value+'.PANE').style.height=(this._paneHeight-$(this.value+'.HEADER').offsetHeight-$(this.value+'.FOOTER').offsetHeight)+'px';}
var indx=-1;for(var i=0;i<this._panes.length;i++){if(this._panes[i]._id==item.value){indx=i;break;}}
if($(this.tbiId+'.TITLE'))$(this.tbiId+'.TITLE').innerHTML=item.html+'&nbsp;';if($(this.tbiId+'.CLOSE')){if(item.close)$(this.tbiId+'.CLOSE').style.display='';else $(this.tbiId+'.CLOSE').style.display='none';}
if($(this.tbiId+'.PREV')){if(indx>0)$(this.tbiId+'.PREV').src=this.scrollButtons.prevImage;else if(this.scrollButtons.prevDisabledImage!='')$(this.tbiId+'.PREV').src=this.scrollButtons.prevDisabledImage;}
if($(this.tbiId+'.NEXT')){if(indx<this._panes.length-1)$(this.tbiId+'.NEXT').src=this.scrollButtons.nextImage;else if(this.scrollButtons.nextDisabledImage!='')$(this.tbiId+'.NEXT').src=this.scrollButtons.nextDisabledImage;}
if(this._panes[indx].autoRefresh){if(this._panes[indx].type=='static'){$(this.value+'.CONTENT').innerHTML=this._panes[indx].html;}else if(this._panes[indx].type=='dynamic'){$(this.value+'.CONTENT').innerHTML=this._panes[indx].html;var data=this._panes[indx].data+$if(this._panes[indx].data!='','&','')+A5.ajax.buildURLParam('_containerId',this._panes[indx]._id+'.CONTENT');A5.ajax.callback(this._panes[indx].url,data);}else if(this._panes[indx].type=='url'){var url=this._panes[indx].url
if(this._panes[indx].data!='')url=url+'?'+this._panes[indx].data;$(this.value+'.PANE').src=A5.ajax.addURLRequiredData(url);}else if(this._panes[indx].type=='grid'){var data=this._panes[indx].data;$u.o.assign(data,{gridDiv:this._panes[indx]._id+'.CONTENT'});A5.component.runGrid(data);}else if(this._panes[indx].type=='dialog2'||this._panes[indx].type=='customComponent'){var data=this._panes[indx].data;var divIDProp=this._panes[indx].type+'Div';data[divIDProp]=this._panes[indx]._id+'.CONTENT'
A5.component.runGenericComponent(data);}else if(this._panes[indx].type=='report'){var data=this._panes[indx].data;$u.o.assign(data,{reportIFrame:this._panes[indx]._id+'.PANE'});A5.component.runReport(data);}}
if(indx>-1){if(this._panes[indx].onChange.constructor==Function)this._panes[indx].onChange.call(this._tbObj,this._panes[indx]);}}}}
this.tabBand.onBeforeRemove=function(item){var result=true;if(item.paneType=='grid'){var gridObjName=item.name.toUpperCase()+'_GridObj';if(window[gridObjName]){if(!window[gridObjName]._confirmAction())result=false;}}
var indx=-1;for(var i=0;i<this._panes.length;i++){if(this._panes[i]._id==item.value){indx=i;break;}}
var userResult=true
if(indx>-1){if(this._panes[indx].onBeforeRemove.constructor==Function)userResult=this._panes[indx].onBeforeRemove.call(this._tbObj,this._panes[indx]);}
return result&&userResult;}
this.tabBand.onRemove=function(item){var indx=-1;for(var i=0;i<this._panes.length;i++){if(this._panes[i]._id==item.value){indx=i;break;}}
$(this.tbiId+'.PANES').removeChild($(item.value));if(indx>-1){if(this._panes[indx].onRemove.constructor==Function)this._panes[indx].onRemove.call(this._tbObj,this._panes[indx]);}
this._panes.splice(indx,1);}
this._tbObj=new A5.TabBand(tbiId+'.TABBAND',[],this.tabBand);this._tbObj.tbiId=tbiId;$(this.tbiId+'.TABBAND').style.display='none';this._tbObj._panes=[];this._curPaneId='';this._paneIndx=0;this._rlTO=0;if($(this.tbiId+'.CLOSE'))$(this.tbiId+'.PREV').src=this._tbObj.tab.closeIcon;if($(this.tbiId+'.PREV'))$(this.tbiId+'.PREV').src=this._tbObj.scrollButtons.prevImage;if($(this.tbiId+'.NEXT'))$(this.tbiId+'.NEXT').src=this._tbObj.scrollButtons.nextImage;if(this.fill){$e.add(document.body,'load',this._refreshLayout,this,true);$e.add(window,'resize',this._refreshLayout,this,true);}},add:function(pSettings){$u.o.assign(pSettings,this._dPane,true);pSettings._id=this.tbiId+'.PANE.'+this._paneIndx;if(pSettings.title=='')pSettings.title=pSettings.name;else if(pSettings.name=='')pSettings.name=pSettings.title;if(!pSettings.multiple){for(var i=0;i<this._tbObj._panes.length;i++){if(pSettings.name==this._tbObj._panes[i].name){this._tbObj.select(this._tbObj._panes[i]._id);this._tbObj.setHTML(i,pSettings.title);if(this._tbObj._panes[i].autoRefreshOnAdd&&!this._tbObj._panes[i].autoRefresh){if(this._tbObj._panes[i].type=='static'){$(this.value+'.CONTENT').innerHTML=this._tbObj._panes[i].html;}else if(this._tbObj._panes[i].type=='dynamic'){$(this.value+'.CONTENT').innerHTML=this._tbObj._panes[i].html;var data=this._tbObj._panes[i].data+$if(this._tbObj._panes[i].data!='','&','')+A5.ajax.buildURLParam('_containerId',this._tbObj._panes[i]._id+'.CONTENT');A5.ajax.callback(this._tbObj._panes[i].url,data);}else if(this._tbObj._panes[i].type=='url'){var url=this._tbObj._panes[i].url
if(this._tbObj._panes[i].data!='')url=url+'?'+this._tbObj._panes[i].data;$(pSettings._id+'.PANE').src=A5.ajax.addURLRequiredData(url);}else if(this._tbObj._panes[i].type=='grid'){var data=this._tbObj._panes[i].data;$u.o.assign(data,{gridDiv:this._tbObj._panes[i]._id+'.CONTENT'});A5.component.runGrid(data);}else if(this._tbObj._panes[i].type=='dialog2'||this._tbObj._panes[i].type=='customComponent'){var data=this._tbObj._panes[i].data;var divIDProp=this._tbObj._panes[i].type+'Div';data[divIDProp]=this._tbObj._panes[i]._id+'.CONTENT'
A5.component.runGenericComponent(data);}else if(this._tbObj._panes[i].type=='report'){var data=this._tbObj._panes[i].data;$u.o.assign(data,{reportIFrame:this._tbObj._panes[i]._id+'.PANE'});A5.component.runReport(data);}}
this._showMenu(false);return false;}}}
if(!this.tabBand.hide)$(this.tbiId+'.TABBAND').style.display='';var pEle=$(this.tbiId+'.PANES');var cEle=document.createElement('div');cEle.id=pSettings._id;cEle.style.position='absolute';cEle.style.top='0px';cEle.style.left='0px';cEle.style.width='100%';if(document.all&&navigator.appName!='Opera')cEle.style.display='none';else cEle.style.visibility='hidden';pEle.appendChild(cEle);var ele=document.createElement('div');ele.id=pSettings._id+'.HEADER';ele.className=this._gDef(pSettings.header.className,this.pane.header.className);var tStyle=$if(pSettings.header.style!=0,pSettings.header.style,this.pane.header.style);if(typeof tStyle=='object'||typeof tStyle=='string')$ss(ele,tStyle);if(!pSettings.header.show)ele.style.display='none';ele.innerHTML=pSettings.header.html;cEle.appendChild(ele);if(pSettings.type=='static'||pSettings.type=='dynamic'||pSettings.type=='grid'||pSettings.type=='dialog2'||pSettings.type=='customComponent'){ele=document.createElement('div');ele.id=pSettings._id+'.PANE';ele.style.position='relative';ele.style.overflow='auto';ele.style.height='0px';var sEle=document.createElement('div');sEle.id=pSettings._id+'.CONTENT';sEle.style.padding=this.pane.padding+'px';ele.appendChild(sEle);cEle.appendChild(ele);sEle.innerHTML=pSettings.html;if(pSettings.type=='dynamic'){var data=pSettings.data+$if(pSettings.data!='','&','')+A5.ajax.buildURLParam('_containerId',pSettings._id+'.CONTENT');if(!pSettings.autoRefresh)A5.ajax.callback(pSettings.url,data)}else if(pSettings.type=='grid'){var data=pSettings.data;$u.o.assign(data,{gridDiv:pSettings._id+'.CONTENT'});A5.component.runGrid(data);}else if(pSettings.type=='dialog2'||pSettings.type=='customComponent'){var data=pSettings.data;var divIDProp=pSettings.type+'Div';data[divIDProp]=pSettings._id+'.CONTENT'
A5.component.runGenericComponent(data);}}else if(pSettings.type=='url'||pSettings.type=='report'){ele=document.createElement('iframe');ele.id=pSettings._id+'.PANE';ele.frameBorder='0';ele.border='0';ele.style.width='100%';ele.style.margin='0px';ele.style.marginBottom='-2px';ele.style.height='0px';var url=pSettings.url;if(pSettings.data!='')url=url+'?'+pSettings.data;cEle.appendChild(ele);if(pSettings.type=='report'){var data=pSettings.data;$u.o.assign(data,{reportIFrame:pSettings._id+'.PANE'});A5.component.runReport(data);}else{ele.src=url;}}else if(this._tbObj._panes.length==0){pEle.innerHTML='';$(this.tbiId+'.TABBAND').style.display='none';return false;}
ele=document.createElement('div');ele.id=pSettings._id+'.FOOTER';ele.className=this._gDef(pSettings.footer.className,this.pane.footer.className);tStyle=$if(pSettings.footer.style!=0,pSettings.footer.style,this.pane.footer.style);if(typeof tStyle=='object'||typeof tStyle=='string')$ss(ele,tStyle);if(!pSettings.footer.show)ele.style.display='none';ele.innerHTML=pSettings.footer.html;cEle.appendChild(ele);this._tbObj._panes.push(pSettings);this._tbObj.add({html:pSettings.title,value:pSettings._id,name:pSettings.name,paneType:pSettings.type,close:pSettings.close,onRightClick:pSettings.onRightClick,onInitial:pSettings.onInitial});this._tbObj.select(pSettings._id);this._paneIndx++;this._showMenu(false);return true;},getElement:function(paneName){var part=typeof arguments[1]!='undefined'?arguments[1]:'';var idPrefix='';var type='';for(var i=0;i<this._tbObj._panes.length;i++){if(paneName==this._tbObj._panes[i].name){idPrefix=this._tbObj._panes[i]._id;type=this._tbObj._panes[i].type;}}
if(idPrefix!=''){if(part=='header')return $(idPrefix+'.HEADER');else if(part=='footer')return $(idPrefix+'.FOOTER');else{if(type=='url'||type=='report')return $(idPrefix+'.PANE');else return $(idPrefix+'.CONTENT');}}
return false;},_showMenu:function(val){if(this.compact){$(this.tbiId+'.TITLEPANEL').style.height='';if(val){$(this.tbiId+'.TITLEPANEL').style.height=$(this.tbiId+'.TITLEPANEL').offsetHeight+'px';$(this.tbiId+'.MENUPANEL').style.display='';$(this.tbiId+'.CONTENTPANEL').style.display='none';$(this.tbiId+'.PANETITLE').style.display='none';$(this.tbiId+'.MENUTITLE').style.display='';}else{$(this.tbiId+'.MENUPANEL').style.display='none';$(this.tbiId+'.CONTENTPANEL').style.display='';$(this.tbiId+'.PANETITLE').style.display='';$(this.tbiId+'.MENUTITLE').style.display='none';}}
if(this.fill)this.refreshLayout();},_refreshLayout:function(){var classInst=this;clearTimeout(this._rlTO);this._rlTO=setTimeout(function(){classInst.refreshLayout();delete classInst;},100);},refreshLayout:function(){var ele=$(this.tbiId);var mEle=$(this.tbiId+'.MENU');var cs=AUI.u.getVPSize();var pageHeight=document.documentElement.offsetHeight;var borderHeight=ele.offsetHeight-ele.clientHeight;if(pageHeight==cs.height)pageHeight=document.body.scrollHeight;else if(pageHeight>cs.height&&(document.all&&navigator.appName!='Opera'))pageHeight=document.body.clientHeight;var newHeight=(cs.height-(borderHeight+pageHeight-ele.offsetHeight));if(newHeight<30)return false;if(newHeight<this.minHeight)newHeight=this.minHeight;if(ele.style.height==newHeight+'px')return false;ele.style.height=newHeight+'px';if(mEle&&$(this.tbiId+'.MENUPANEL').style.display!='none'){mEle.style.height='';var menuHeight=newHeight-4;if($(this.tbiId+'.MENUPANEL_HEADER'))menuHeight-=$(this.tbiId+'.MENUPANEL_HEADER').offsetHeight;var mcEle=false;for(var i=0;i<mEle.childNodes.length;i++){if(typeof mEle.childNodes[i].tagName!='undefined'){mcEle=mEle.childNodes[i];break;}}
mEle.style.overflow='auto';if(mcEle)menuHeight-=(mEle.scrollHeight-mcEle.scrollHeight);mEle.style.height=menuHeight+'px';}
if(this._tbObj.value){if(this._tbObj.value!=''){var pEle=$(this._tbObj.value+'.PANE');if(this.tabBand.hide)this._tbObj._paneHeight=(newHeight-1);else this._tbObj._paneHeight=(newHeight-$(this.tbiId+'.TABBAND').offsetHeight-1);if(pEle)pEle.style.height=(this._tbObj._paneHeight-$(this._tbObj.value+'.HEADER').offsetHeight-$(this._tbObj.value+'.FOOTER').offsetHeight)+'px';$(this.tbiId+'.PANES').style.height=this._tbObj._paneHeight+'px';}}},setTabHTML:function(tName,tHTML){for(var i=0;i<this._tbObj._panes.length;i++){if(tName==this._tbObj._panes[i].name){this._tbObj.setHTML(i,tHTML);}}},closeOpenPanes:function(){for(var i=this._tbObj._panes.length-1;i>=0;i--){if(this._tbObj._panes[i].close)this._tbObj.remove(i);}},selectPane:function(title){for(var i=0;i<tbiObj._tbObj._panes.length;i++){if(tbiObj._tbObj._panes[i].title==title){tbiObj._tbObj.select(i);break;}}},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_dPane:{name:'',title:'',type:'static',html:'',url:'',data:'',close:true,autoRefresh:false,autoRefreshOnAdd:false,multiple:false,onChange:0,onBeforeChange:0,onRightClick:0,onInitial:0,onBeforeRemove:0,onRemove:0,header:{className:'',style:0,show:false,html:''},footer:{className:'',style:0,show:false,html:''}}}
A5.Tree=Class.create({initialize:function(contId,data,options){this.contId=contId
var fullOptions={inputId:'',focusClassName:'',multiple:false,loopNavigate:false,loopNavigateNullSelection:true,allowNullSelection:true,separator:'.',loadingMessage:'Loading...',dynamicDataURL:'',dynamicDataURLParams:'',dynamicDataHandle:'',node:{className:'',hoverClassName:'',selectedClassName:'',labelClassName:'',icon:'',expandedIcon:'',collapsedIcon:'',leaf:{firstImage:'',image:'',lastImage:''},branch:{firstExpandedImage:'',firstCollapsedImage:'',firstExpandedHoverImage:'',firstCollapsedHoverImage:'',expandedImage:'',collapsedImage:'',expandedHoverImage:'',collapsedHoverImage:'',lastExpandedImage:'',lastCollapsedImage:'',lastExpandedHoverImage:'',lastCollapsedHoverImage:''}},branch:{className:'',lineImage:'',nullImage:''},onFocus:0,onBlur:0,onNodeSelect:0,onNodeClick:0,onNodeExpand:0,onNodeCollapse:0,onNodeDraw:0,onRightClick:0,selection:[],value:[],_hasFocus:false};$u.o.assign(fullOptions,options);if(typeof A5._treeDefaults!='undefined')$u.o.assign(fullOptions,A5._treeDefaults);if(typeof fullOptions.theme!='undefined')A5.themes.assign(fullOptions,fullOptions.theme,'tree');if(fullOptions.node.collapsedIcon=='')fullOptions.node.collapsedIcon=fullOptions.node.icon;if(fullOptions.node.expandedIcon=='')fullOptions.node.expandedIcon=fullOptions.node.collapsedIcon;if(fullOptions.node.selectedCollapsedIcon=='')fullOptions.node.selectedCollapsedIcon=fullOptions.node.selectedIcon;if(fullOptions.node.selectedExpandedIcon=='')fullOptions.node.selectedExpandedIcon=fullOptions.node.selectedCollapsedIcon;if(fullOptions.branch.lineImage=='')fullOptions.branch.lineImage=fullOptions.branch.nullImage;if(fullOptions.node.leaf.image=='')fullOptions.node.leaf.image=fullOptions.branch.nullImage;if(fullOptions.node.branch.expandedImage=='')fullOptions.node.branch.expandedImage=fullOptions.branch.nullImage;if(fullOptions.node.branch.collapsedImage=='')fullOptions.node.branch.collapsedImage=fullOptions.branch.nullImage;if(fullOptions.node.leaf.firstImage=='')fullOptions.node.leaf.firstImage=fullOptions.node.leaf.image;if(fullOptions.node.leaf.lastImage=='')fullOptions.node.leaf.lastImage=fullOptions.node.leaf.image;if(fullOptions.node.branch.firstExpandedImage=='')fullOptions.node.branch.firstExpandedImage=fullOptions.node.branch.expandedImage;if(fullOptions.node.branch.lastExpandedImage=='')fullOptions.node.branch.lastExpandedImage=fullOptions.node.branch.expandedImage;if(fullOptions.node.branch.firstCollapsedImage=='')fullOptions.node.branch.firstCollapsedImage=fullOptions.node.branch.collapsedImage;if(fullOptions.node.branch.lastCollapsedImage=='')fullOptions.node.branch.lastCollapsedImage=fullOptions.node.branch.collapsedImage;if(fullOptions.node.branch.firstExpandedHoverImage=='')fullOptions.node.branch.firstExpandedHoverImage=fullOptions.node.branch.expandedHoverImage;if(fullOptions.node.branch.lastExpandedHoverImage=='')fullOptions.node.branch.lastExpandedHoverImage=fullOptions.node.branch.expandedHoverImage;if(fullOptions.node.branch.firstCollapsedHoverImage=='')fullOptions.node.branch.firstCollapsedHoverImage=fullOptions.node.branch.collapsedHoverImage;if(fullOptions.node.branch.lastCollapsedHoverImage=='')fullOptions.node.branch.lastCollapsedHoverImage=fullOptions.node.branch.collapsedHoverImage;$u.o.assign(this,fullOptions);this.populate(data);this._keyWatch=new AUI.KeyWatcher([{key:'up',handle:this._keyPrevNode},{key:'down',handle:this._keyNextNode},{key:'home',handle:this._keyFirstNode},{key:'end',handle:this._keyLastNode},{key:'left',handle:this._keyBranchNode},{key:'right',handle:this._keyChildNode},{key:'enter',handle:this._keyEnter}],this);var contElement=$(contId);var HTMLFocusCatcher=document.createElement('button');HTMLFocusCatcher.id=contId+'.FOCUSCATCHER';$ss(HTMLFocusCatcher,'position: absolute; font-size: 0px; outline: none; opacity: 0; filter: alpha(opacity=0); height: 0px; width: '+contElement.offsetWidth+'px')
$e.add(HTMLFocusCatcher,'keydown',function(e){var keyCode=e.charCode||e.keyCode;if(keyCode!=9)$e.preventDefault(e);});$e.add(HTMLFocusCatcher,'keypress',function(e){var keyCode=e.charCode||e.keyCode;if(keyCode!=9)$e.preventDefault(e);});$e.add(HTMLFocusCatcher,'focus',this._focus,this,true);$e.add(contElement,'click',this._focus,this,true);$e.add(contElement,'contextmenu',this._rClick,this,true);contElement.parentNode.insertBefore(HTMLFocusCatcher,contElement);if(!this.allowNullSelection&&data.length!=0)this._selectNode(this.getDataNode([0]));},populate:function(data){$e.removeGroup(this.contId+'.EVENTS');this.data=this._expandTreeData(data);var HTMLNodes=this._generateHTMLNodes([],[],this.data,true,'');HTMLNodes.id=this.contId+'.TREE';var contElement=$(this.contId);contElement.innerHTML='';contElement.insertBefore(HTMLNodes,contElement.lastChild);},populateNode:function(nodeLoc,data){data=this._expandTreeData(data);var nodeImages=new Array();nodeImages[nodeImages.length]=$if(nodeLoc[0]==this.data.length-1,this.branch.nullImage,this.branch.lineImage);var dataNode=this.data[nodeLoc[0]];for(var i=1;i<nodeLoc.length;i++){nodeImages[i]=$if(nodeLoc[i]==dataNode.children.length-1,this.branch.nullImage,this.branch.lineImage);dataNode=dataNode.children[nodeLoc[i]];}
dataNode.children=data;dataNode.location=nodeLoc;dataNode.expanded=true;var HTMLNodes=this._generateHTMLNodes(nodeLoc,nodeImages,data,true,dataNode.branchClassName);$(this.contId+'.'+nodeLoc.join('.')).appendChild(HTMLNodes);var iNode=$(this.contId+'.'+dataNode.location.join('.')+'.LABEL').previousSibling;$e.remove(iNode,'mouseup',this._clickToggleBranch);$e.add(iNode,'mouseup',this._clickToggleBranch,this,false,this.contId+'.EVENTS');if(this.node.branch.collapsedHoverImage!=''||dataNode.collapsedHoverImage!=''){$e.remove(iNode,'mouseover',this._nodeImageMouseOver);$e.remove(iNode,'mouseout',this._nodeImageMouseOut);$e.add(iNode,'mouseover',this._nodeImageMouseOver,this,false,this.contId+'.EVENTS');$e.add(iNode,'mouseout',this._nodeImageMouseOut,this,false,this.contId+'.EVENTS');}
if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.expandedImage);},getDataNode:function(dataLoc){if(dataLoc.length==0)return 0;var dataNode=this.data[dataLoc[0]];if(typeof dataLoc[0]=='number'){var dataNode=this.data[dataLoc[0]];var parsedNodeLoc=[dataLoc[0]];}else{for(var i=0;i<this.data.length;i++){if(this.data[i].value.toLowerCase()==String(dataLoc[0]).toLowerCase()){var dataNode=this.data[i];var parsedNodeLoc=[i];break;}}}
for(var i=1;i<dataLoc.length;i++){if(typeof dataLoc[i]=='number'){dataNode=dataNode.children[dataLoc[i]];parsedNodeLoc[parsedNodeLoc.length]=dataLoc[i];}else{for(var j=0;j<dataNode.children.length;j++){if(dataNode.children[j].value.toLowerCase()==String(dataLoc[i]).toLowerCase()){dataNode=dataNode.children[j];parsedNodeLoc[parsedNodeLoc.length]=j;break;}}}}
dataNode.location=parsedNodeLoc;return dataNode;},scrollToNode:function(dataNode){var bId=this.contId+'.'+dataNode.location.join('.')+'.LABEL';if($(bId)){var bNode=$(bId);var cEle=$(this.contId);if(cEle.scrollTop>bNode.offsetTop-(bNode.parentNode.offsetHeight*2))cEle.scrollTop=bNode.offsetTop-(bNode.parentNode.offsetHeight*2)
else if(cEle.scrollTop+cEle.offsetHeight<bNode.offsetTop)cEle.scrollTop=bNode.offsetTop+(bNode.parentNode.offsetHeight)-cEle.offsetHeight;cEle.scrollLeft=bNode.offsetLeft-40;}},setValue:function(){this._deselectAll();var selClassName='';var dataNode=new Object();var dataLoc=0;var valArr=0;var valStart=arguments.length-1;if(this.multiple)valStart=0;for(var i=valStart;i<arguments.length;i++){dataNode=0;if(arguments[i].constructor==Array)dataNode=this.getDataNode(arguments[i]);else{valArr=String(arguments[i]).split(this.separator);if(valArr.length>1)dataNode=this.getDataNode(valArr);else{dataLoc=new Array();this._getDataNodeFromValue(arguments[i],this.data,dataLoc);dataLoc.reverse();dataNode=this.getDataNode(dataLoc);}}
if(typeof dataNode=='object'){selClassName=this._gDef(dataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$acn($(this.contId+'.'+dataNode.location.join('.')).firstChild,selClassName);this.selection[this.selection.length]=dataNode;}}
if(this.inputId!='')$(this.inputId).value=this.value.join('\n');},navigate:function(dir){if(dir.toLowerCase().substr(0,4)=='prev')this._keyPrevNode();else if(dir.toLowerCase()=='next')this._keyNextNode();else if(dir.toLowerCase()=='out')this._keyBranchNode();else if(dir.toLowerCase()=='in')this._keyChildNode();else if(dir.toLowerCase()=='home')this._keyFirstNode();else if(dir.toLowerCase()=='end')this._keyLastNode();else if(dir.toLowerCase()=='enter')this._keyEnter();},_expandTreeData:function(data){var tempData=new Object();for(var i=0;i<data.length;i++){if(typeof data[i]!='object'){tempData={html:''+$u.s.tran(data[i],['<','>'],['&lt;','&gt;']),value:''+data[i]};$u.o.assign(tempData,this._defaultNode,true);data[i]=tempData;}else{if(typeof data[i].value!='undefined')data[i].defaultValue=false;$u.o.assign(data[i],this._defaultNode,true);if(data[i].value==''&&data[i].html!='')data[i].value=data[i].html;else if(data[i].html==''&&data[i].value!='')data[i].html=$u.s.tran(data[i].value,['<','>'],['&lt;','&gt;']);if(data[i].children.constructor==Array)data[i].children=this._expandTreeData(data[i].children);}
if(i==data.length-1)data[i].isLast=true;else data[i].isLast=false;}
return data;},_getFirstVisDataNode:function(){return this.getDataNode([0]);},_getLastVisDataNode:function(){var dataNode=this.data[this.data.length-1];var dataLoc=new Array();dataLoc.push(this.data.length-1);while(dataNode.children.constructor==Array&&dataNode.expanded){dataLoc.push(dataNode.children.length-1);dataNode=dataNode.children[dataNode.children.length-1];}
return this.getDataNode(dataLoc);},_getPrevVisDataNode:function(dataNode){var dataLoc=new Array();for(var i=0;i<dataNode.location.length;i++)dataLoc[i]=dataNode.location[i];if(dataLoc.length==1&&dataLoc[0]==0){if(this.loopNavigate){if(this.allowNullSelection&&this.loopNavigateNullSelection)return false;else return this._getLastVisDataNode();}
return dataNode;}
if(dataLoc[dataLoc.length-1]==0){dataLoc.pop();return this.getDataNode(dataLoc);}else{dataLoc[dataLoc.length-1]--;var newDataNode=this.getDataNode(dataLoc);while(newDataNode.expanded){dataLoc.push(newDataNode.children.length-1);newDataNode=this.getDataNode(dataLoc);}
return newDataNode;}},_getNextVisDataNode:function(dataNode){var dataLoc=new Array();for(var i=0;i<dataNode.location.length;i++)dataLoc[i]=dataNode.location[i];if(dataNode.isLast&&!dataNode.expanded){dataLoc.pop();if(dataLoc.length==0){if(this.loopNavigate){if(this.allowNullSelection&&this.loopNavigateNullSelection)return false;else return this._getFirstVisDataNode();}
return dataNode;}
var newDataNode=this.getDataNode(dataLoc);while(newDataNode.isLast){dataLoc.pop();if(dataLoc.length==0){if(this.loopNavigate){if(this.allowNullSelection&&this.loopNavigateNullSelection)return false;else return this._getFirstVisDataNode();}
return dataNode;}
newDataNode=this.getDataNode(dataLoc);}
dataLoc[dataLoc.length-1]++;return this.getDataNode(dataLoc);}else{if(dataNode.expanded){dataLoc[dataLoc.length]=0;return this.getDataNode(dataLoc);}else{dataLoc[dataLoc.length-1]++;return this.getDataNode(dataLoc);}}},_getDataNodeFromValue:function(value,data,dataLoc){var dataNode=0;for(var i=0;i<data.length;i++){if(data[i].value==value){dataLoc[0]=i;break;}
if(data[i].children.constructor==Array)this._getDataNodeFromValue(value,data[i].children,dataLoc);if(dataLoc.length>0){dataLoc.push(i);break;}}},_getDataNodeValue:function(dataNode){if(dataNode.defaultValue){var valDataNode=new Object();var valDataLoc=new Array();var curValue='';for(var i=0;i<dataNode.location.length;i++)valDataLoc[i]=dataNode.location[i];for(var i=valDataLoc.length-1;i>=0;i--){valDataNode=this.getDataNode(valDataLoc);curValue=$if(i!=0,this.separator,'')+valDataNode.value+curValue;valDataLoc.pop();}
return curValue;}else{return dataNode.value;}},_generateHTMLNodes:function(parentNodeLocs,parentNodeLineImages,data,expanded,branchClassName){var ulNode=document.createElement('ul');var liNode=new Object();var divNode=new Object();var buttonNode=new Object();var tempNode=new Object();var tempNodeloc=new Array();var tempLineImages=new Array();var joinedParentLocs=parentNodeLocs.join('.');var baseId='';var isLast=false;var curIcon='';var hasONDEvnt=this.onNodeDraw.constructor==Function;ulNode.className=this._gDef(branchClassName,this.branch.className);ulNode.style.margin='0px';ulNode.style.padding='0px';ulNode.style.listStyle='none';if(!expanded)ulNode.style.display='none';ulNode.unselectable='on';for(var i=0;i<data.length;i++){baseId=$if(joinedParentLocs!='',this.contId+'.'+joinedParentLocs+'.'+i,this.contId+'.'+i);liNode=document.createElement('li');liNode.style.margin='0px';liNode.style.padding='0px';liNode.id=baseId;liNode.setAttribute('A5TreeNodeLocation',$if(joinedParentLocs!='',joinedParentLocs+'.'+i,i))
liNode.unselectable='on';divNode=document.createElement('div');divNode.className=this._gDef(data[i].className,this.node.className);divNode.style.whiteSpace='nowrap';divNode.unselectable='on';if(i==data.length-1)isLast=true;for(var j=0;j<parentNodeLineImages.length;j++){tempNode=document.createElement('img');tempNode.src=parentNodeLineImages[j];tempNode.style.verticalAlign='middle';tempNode.align='absmiddle';divNode.appendChild(tempNode);}
buttonNode=document.createElement('a');buttonNode.tabIndex=-1;buttonNode.href="#";$e.add(buttonNode,'mouseup',this._clickNode,this,false,this.contId+'.EVENTS');$e.add(buttonNode,'mouseover',this._mOverNode,this,false,this.contId+'.EVENTS');$e.add(buttonNode,'mouseout',this._mOutNode,this,false,this.contId+'.EVENTS');$sa(buttonNode,'A5TreeNodeHoverClassName',this._gDef(data[i].hoverClassName,this.node.hoverClassName));buttonNode.className=this._gDef(data[i].labelClassName,this.node.labelClassName);buttonNode.id=baseId+'.LABEL';buttonNode.unselectable='on';if(typeof data[i].children=='object'||typeof data[i].children=='string'){if(data[i].children.constructor!=Array)data[i].expanded=false;tempNode=document.createElement('img');if(data[i].expanded){curIcon=this._gDef(data[i].expandedIcon,this.node.expandedIcon);if(i==0&&parentNodeLocs.length==0)tempNode.src=this._gDef(data[i].expandedImage,this.node.branch.firstExpandedImage);else if(isLast)tempNode.src=this._gDef(data[i].expandedImage,this.node.branch.lastExpandedImage);else tempNode.src=this._gDef(data[i].expandedImage,this.node.branch.expandedImage);}else{curIcon=this._gDef(data[i].collapsedIcon,this.node.collapsedIcon);if(i==0&&parentNodeLocs.length==0)tempNode.src=this._gDef(data[i].collapsedImage,this.node.branch.firstCollapsedImage);else if(isLast)tempNode.src=this._gDef(data[i].collapsedImage,this.node.branch.lastCollapsedImage);else tempNode.src=this._gDef(data[i].collapsedImage,this.node.branch.collapsedImage);}
if(this.node.branch.collapsedHoverImage!=''||data[i].collapsedHoverImage!=''){$e.add(tempNode,'mouseover',this._nodeImageMouseOver,this,false,this.contId+'.EVENTS');$e.add(tempNode,'mouseout',this._nodeImageMouseOut,this,false,this.contId+'.EVENTS');}
tempNode.style.verticalAlign='middle';tempNode.align='absmiddle';$e.add(tempNode,'mouseup',this._clickToggleBranch,this,false,this.contId+'.EVENTS');divNode.appendChild(tempNode);if(curIcon!=''){buttonNode.innerHTML='<img id="'+baseId+'.LABELICON" src="'+curIcon+'" style="border: none" align="absmiddle" /> '+data[i].html;}else{buttonNode.innerHTML=data[i].html;}
divNode.appendChild(buttonNode);if(data[i].children.constructor==Array){if(parentNodeLocs.length==0){tempNodeLocs=new Array();tempLineImages=new Array();}else{tempNodeLocs=parentNodeLocs.concat([]);tempLineImages=parentNodeLineImages.concat([]);}
tempNodeLocs[tempNodeLocs.length]=i;tempLineImages[tempLineImages.length]=$if(isLast,this.branch.nullImage,this.branch.lineImage);liNode.appendChild(divNode);liNode.appendChild(this._generateHTMLNodes(tempNodeLocs,tempLineImages,data[i].children,data[i].expanded,data[i].branchClassName));}else liNode.appendChild(divNode);}else{tempNode=document.createElement('img');if(i==0&&parentNodeLocs.length==0)tempNode.src=this._gDef(data[i].image,this.node.leaf.firstImage);else if(isLast)tempNode.src=this._gDef(data[i].image,this.node.leaf.lastImage);else tempNode.src=this._gDef(data[i].image,this.node.leaf.image);tempNode.style.verticalAlign='middle';tempNode.align='absmiddle';divNode.appendChild(tempNode);curIcon=this._gDef(data[i].icon,this.node.icon);if(curIcon!=''){buttonNode.innerHTML='<img id="'+baseId+'.LABELICON" src="'+curIcon+'" style="border: none" align="absmiddle" /> '+data[i].html;}else{buttonNode.innerHTML=data[i].html;}
divNode.appendChild(buttonNode);liNode.appendChild(divNode);}
ulNode.appendChild(liNode);if(hasONDEvnt)this.onNodeDraw.call(this,buttonNode,data[i],i);}
return ulNode;},_clickToggleBranch:function(e,classInstance){var liEle=this.parentNode.parentNode;var dataLocArr=String(liEle.getAttribute('A5TreeNodeLocation')).split('.');for(var i=0;i<dataLocArr.length;i++)dataLocArr[i]=Number(dataLocArr[i]);var dataNode=classInstance.getDataNode(dataLocArr,false);classInstance._toggleBranch(dataNode,true);},_toggleBranch:function(dataNode){if(dataNode.children.constructor!=Array){if(dataNode.dynamicDataHandle.constructor==Function||this.dynamicDataHandle.constructor==Function){if(dataNode.dynamicDataHandle.constructor==Function)var resData=dataNode.dynamicDataHandle(dataNode);else var resData=this.dynamicDataHandle(dataNode);if(resData.constructor==Array){this.populateNode(dataNode.location,resData);if(dataNode.onExpand.constructor==Function)dataNode.onExpand(dataNode);else if(this.onNodeExpand.constructor==Function)this.onNodeExpand(dataNode);}}else{var curValue=urlencode(this._getDataNodeValue(dataNode));var dataURL='';var dataURLParams='';if(this.dynamicDataURLParams.constructor==Function)dataURLParams='&'+this.dynamicDataURLParams(dataNode);else if(this.dynamicDataURLParams!='')dataURLParams='&'+this.dynamicDataURLParams;if(typeof dataNode.children=='object'){if(dataNode.children.url)dataURL=dataNode.children.url;if(dataURL=='')dataURL=this.dynamicDataURL;if(dataURL!='')new $a.simple(dataURL,{data:$if(dataNode.children.data,dataNode.children.data+'&','')+'A5AJAXTreeNodeLocation=['+dataNode.location.join(',')+']&A5AJAXTreeNodeValue='+curValue+'&__Ajax=true'+dataURLParams,handle:this._responseHandle,handleContext:this})}else{dataURL=''+dataNode.children;if(dataURL.substr(0,1)=='?')dataURL=this.dynamicDataURL;if(dataURL!='')new $a.simple(dataURL,{data:'A5AJAXTreeNodeLocation=['+dataNode.location.join(',')+']&A5AJAXTreeNodeValue='+curValue+'&__Ajax=true'+dataURLParams,handle:this._responseHandle,handleContext:this})}
$(this.contId+'.'+dataNode.location.join('.')+'.LABEL').innerHTML=this.loadingMessage;}
var iNode=$(this.contId+'.'+dataNode.location.join('.')+'.LABEL').previousSibling;if(arguments[1]){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.firstExpandedHoverImage,dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.lastExpandedHoverImage,dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.expandedHoverImage,dataNode.expandedImage,this.node.branch.expandedImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.expandedImage);}
dataNode.expanded=true;}else{var iNode=$(this.contId+'.'+dataNode.location.join('.')+'.LABEL').previousSibling;var bNode=$(this.contId+'.'+dataNode.location.join('.')).lastChild;while(!bNode.tagName){bNode=bNode.previousSibling;}
if(bNode.style.display=='none'){if(arguments[1]){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.firstExpandedHoverImage,dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.lastExpandedHoverImage,dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedHoverImage,this.node.branch.expandedHoverImage,dataNode.expandedImage,this.node.branch.expandedImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.firstExpandedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.lastExpandedImage);else iNode.src=this._gDef(dataNode.expandedImage,this.node.branch.expandedImage);}
var curIcon=this._gDef(dataNode.expandedIcon,this.node.expandedIcon);if(curIcon!=''){if($(this.contId+'.'+dataNode.location.join('.')+'.LABELICON')){$(this.contId+'.'+dataNode.location.join('.')+'.LABELICON').src=curIcon;}}
bNode.style.display='block';dataNode.expanded=true;if(dataNode.onExpand.constructor==Function)dataNode.onExpand(dataNode);else if(this.onNodeExpand.constructor==Function)this.onNodeExpand(dataNode);}else{if(arguments[1]){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.collapsedHoverImage,this.node.branch.firstCollapsedHoverImage,dataNode.collapsedImage,this.node.branch.firstCollapsedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.collapsedHoverImage,this.node.branch.lastCollapsedHoverImage,dataNode.collapsedImage,this.node.branch.lastCollapsedImage);else iNode.src=this._gDef(dataNode.collapsedHoverImage,this.node.branch.collapsedHoverImage,dataNode.collapsedImage,this.node.branch.collapsedImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)iNode.src=this._gDef(dataNode.collapsedImage,this.node.branch.firstCollapsedImage);else if(dataNode.isLast)iNode.src=this._gDef(dataNode.collapsedImage,this.node.branch.lastCollapsedImage);else iNode.src=this._gDef(dataNode.collapsedImage,this.node.branch.collapsedImage);}
var curIcon=this._gDef(dataNode.collapsedIcon,this.node.collapsedIcon);if(curIcon!=''){if($(this.contId+'.'+dataNode.location.join('.')+'.LABELICON')){$(this.contId+'.'+dataNode.location.join('.')+'.LABELICON').src=curIcon;}}
bNode.style.display='none';dataNode.expanded=false;if(dataNode.onCollapse.constructor==Function)dataNode.onCollapse(dataNode);else if(this.onNodeCollapse.constructor==Function)this.onNodeCollapse(dataNode);}}},_selectNode:function(dataNode){var curValue=[];var selClassName='';if(this.multiple&&(this._keyWatch.ctrl||this._keyWatch.shift)){var addToSel=true;for(var i=0;i<this.selection.length;i++){if(this.selection[i].location.join('.')==dataNode.location.join('.')){selClassName=this._gDef(this.selection[i].selectedClassName,this.node.selectedClassName);if(selClassName!='')$rcn($(this.contId+'.'+this.selection[i].location.join('.')).firstChild,selClassName);this.selection.splice(i,1);addToSel=false;break;}}
if(addToSel){selClassName=this._gDef(dataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$acn($(this.contId+'.'+dataNode.location.join('.')).firstChild,selClassName);this.selection[this.selection.length]=dataNode;}}else{this._deselectAll();selClassName=this._gDef(dataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$acn($(this.contId+'.'+dataNode.location.join('.')).firstChild,selClassName);this.selection[0]=dataNode;}
for(var i=0;i<this.selection.length;i++){curValue[i]=this._getDataNodeValue(this.selection[i])}
this.value=curValue;if(this.inputId!='')$(this.inputId).value=curValue.join('\n');if(dataNode.onSelect.constructor==Function)dataNode.onSelect(dataNode);else if(this.onNodeSelect.constructor==Function)this.onNodeSelect(dataNode);},_deselectAll:function(){var oldDataNode=new Object();for(var i=0;i<this.selection.length;i++){oldDataNode=this.selection[i];if(typeof oldDataNode=='object'){selClassName=this._gDef(oldDataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$rcn($(this.contId+'.'+oldDataNode.location.join('.')).firstChild,selClassName);}}
this.selection=new Array();this.value=new Array();},_nodeImageMouseOver:function(e,classInstance){var liEle=this.parentNode.parentNode;var dataLocArr=String(liEle.getAttribute('A5TreeNodeLocation')).split('.');for(var i=0;i<dataLocArr.length;i++)dataLocArr[i]=Number(dataLocArr[i]);var dataNode=classInstance.getDataNode(dataLocArr,false);if(dataNode.expanded){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)this.src=classInstance._gDef(dataNode.expandedHoverImage,classInstance.node.branch.firstExpandedHoverImage);else if(dataNode.isLast)this.src=classInstance._gDef(dataNode.expandedHoverImage,classInstance.node.branch.lastExpandedHoverImage);else this.src=classInstance._gDef(dataNode.expandedHoverImage,classInstance.node.branch.expandedHoverImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)this.src=classInstance._gDef(dataNode.collapsedHoverImage,classInstance.node.branch.firstCollapsedHoverImage);else if(dataNode.isLast)this.src=classInstance._gDef(dataNode.collapsedHoverImage,classInstance.node.branch.lastCollapsedHoverImage);else this.src=classInstance._gDef(dataNode.collapsedHoverImage,classInstance.node.branch.collapsedHoverImage);}},_nodeImageMouseOut:function(e,classInstance){var liEle=this.parentNode.parentNode;var dataLocArr=String(liEle.getAttribute('A5TreeNodeLocation')).split('.');for(var i=0;i<dataLocArr.length;i++)dataLocArr[i]=Number(dataLocArr[i]);var dataNode=classInstance.getDataNode(dataLocArr,false);if(dataNode.expanded){if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)this.src=classInstance._gDef(dataNode.expandedImage,classInstance.node.branch.firstExpandedImage);else if(dataNode.isLast)this.src=classInstance._gDef(dataNode.expandedImage,classInstance.node.branch.lastExpandedImage);else this.src=classInstance._gDef(dataNode.expandedImage,classInstance.node.branch.expandedImage);}else{if(dataNode.location[dataNode.location.length-1]==0&&dataNode.location.length==1)this.src=classInstance._gDef(dataNode.collapsedImage,classInstance.node.branch.firstCollapsedImage);else if(dataNode.isLast)this.src=classInstance._gDef(dataNode.collapsedImage,classInstance.node.branch.lastCollapsedImage);else this.src=classInstance._gDef(dataNode.collapsedImage,classInstance.node.branch.collapsedImage);}},_clickNode:function(e,classInstance){$(classInstance.contId+'.FOCUSCATCHER').focus();classInstance._keyWatch.shift=false;classInstance._keyWatch.ctrl=false;if(typeof e.shiftKey!='undefined'){classInstance._keyWatch.shift=e.shiftKey;classInstance._keyWatch.ctrl=e.ctrlKey;}
var liEle=this.parentNode.parentNode;var dataLocArr=String(liEle.getAttribute('A5TreeNodeLocation')).split('.');for(var i=0;i<dataLocArr.length;i++)dataLocArr[i]=Number(dataLocArr[i]);var dataNode=classInstance.getDataNode(dataLocArr,false);classInstance._selectNode(dataNode);if(dataNode.onClick.constructor==Function)dataNode.onClick(dataNode);else if(classInstance.onNodeClick.constructor==Function)classInstance.onNodeClick(dataNode);},_mOverNode:function(e,classInstance){var hoverCN=$ga(this,'A5TreeNodeHoverClassName');if(hoverCN!='')$acn(this.parentNode,hoverCN);},_mOutNode:function(e,classInstance){var hoverCN=$ga(this,'A5TreeNodeHoverClassName');if(hoverCN!='')$rcn(this.parentNode,hoverCN);},_keyPrevNode:function(){var oldDataNode=this.selection[this.selection.length-1];if(typeof oldDataNode=='object'){var dataNode=this._getPrevVisDataNode(oldDataNode);if(typeof dataNode.location!='undefined'){this._selectNode(dataNode);this.scrollToNode(dataNode);}else{this._deselectAll();}}else{this._selectNode(this._getLastVisDataNode());}},_keyNextNode:function(){var oldDataNode=this.selection[this.selection.length-1];if(typeof oldDataNode=='object'){var dataNode=this._getNextVisDataNode(oldDataNode);if(typeof dataNode.location!='undefined'){this._selectNode(dataNode);this.scrollToNode(dataNode);}else{this._deselectAll();}}else{this._selectNode(this._getFirstVisDataNode());}},_keyFirstNode:function(){this._selectNode(this._getFirstVisDataNode());},_keyLastNode:function(){this._selectNode(this._getLastVisDataNode());},_keyBranchNode:function(){var oldDataNode=this.selection[this.selection.length-1];if(typeof oldDataNode=='object'){if(oldDataNode.expanded==true){this._toggleBranch(oldDataNode);}else{var dataLoc=new Array();for(var i=0;i<oldDataNode.location.length-1;i++)dataLoc[i]=oldDataNode.location[i];if(dataLoc.length>0)this._selectNode(this.getDataNode(dataLoc));}}else{this._selectNode(this.getDataNode([0]));}},_keyChildNode:function(){var oldDataNode=this.selection[this.selection.length-1];if(typeof oldDataNode=='object'){if(oldDataNode.expanded==false&&(typeof oldDataNode.children=='object'||typeof oldDataNode.children=='string')){this._toggleBranch(oldDataNode);}else if(typeof oldDataNode.children=='object'||typeof oldDataNode.children=='string'){var dataNode=this._getNextVisDataNode(oldDataNode);if(typeof dataNode.location!='undefined'){this._selectNode(dataNode);this.scrollToNode(dataNode);}}}else{this._selectNode(this.getDataNode([0]));}},_keyEnter:function(){var dataNode=this.selection[this.selection.length-1];if(typeof dataNode=='object'){if(typeof dataNode.children=='object'||typeof dataNode.children=='string')this._toggleBranch(dataNode);else{if(dataNode.onClick.constructor==Function)dataNode.onClick(dataNode);else if(this.onNodeClick.constructor==Function)this.onNodeClick(dataNode);}}},_rClick:function(e,classInstance){if(classInstance.onRightClick.constructor==Function){classInstance.onRightClick();e=$e.getEvent(e);$e.stopEvent(e);return false;}},_focus:function(e){if(this._hasFocus==false){this._keyWatch.on();this._hasFocus=true;$e.executeGroup('A5ControlsFocusCatcher');$e.removeGroup('A5ControlsFocusCatcher');$e.add(document.documentElement,'click',this._blur,this,true,'A5ControlsFocusCatcher');if(this.focusClassName!='')$acn($(this.contId),this.focusClassName);if(this.onFocus.constructor==Function)this.onFocus();}
e=$e.getEvent(e);$e.stopEvent(e);return false;},_blur:function(){this._hasFocus=false;this._keyWatch.off();if(this.focusClassName!='')$rcn($(this.contId),this.focusClassName);$e.remove(document.documentElement,'click',this._blur);if(this.onBlur.constructor==Function)this.onBlur();},_responseHandle:function(obj){var resJSON=eval('('+obj.responseText+')');this.populateNode(resJSON.location,resJSON.data);var dataNode=this.getDataNode(resJSON.location);var baseId=this.contId+'.'+resJSON.location.join('.');var buttonNode=$(baseId+'.LABEL');var curIcon=this._gDef(dataNode.expandedIcon,this.node.expandedIcon);if(curIcon!=''){buttonNode.innerHTML='<img id="'+baseId+'.LABELICON" src="'+curIcon+'" style="border: none" align="absmiddle" /> '+dataNode.html;}else{buttonNode.innerHTML=dataNode.html;}
if(dataNode.onExpand.constructor==Function)dataNode.onExpand(dataNode);else if(this.onNodeExpand.constructor==Function)this.onNodeExpand(dataNode);},_gDef:function(val,dVal){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_defaultNode:{html:'',value:'',children:0,className:'',selectedClassName:'',hoverClassName:'',labelClassName:'',branchClassName:'',icon:'',expandedIcon:'',collapsedIcon:'',image:'',expandedImage:'',collapsedImage:'',expandedHoverImage:'',collapsedHoverImage:'',onSelect:0,onClick:0,onExpand:0,onCollapse:0,dynamicDataHandle:0,expanded:false,defaultValue:true}});A5.ListBox=Class.create();A5.ListBox.prototype={initialize:function(contId,data,settings){this.contId=contId;$u.o.assign(this,{theme:'',inputId:'',focusClassName:'',multiple:false,loopNavigate:false,loopNavigateNullSelection:true,allowNullSelection:true,columns:0,item:{columns:[],className:'',hoverClassName:'',selectedClassName:'',style:0,titleClassName:'',separatorClassName:'',template:'',calculateValue:0},onFocus:0,onBlur:0,onRightClick:0,onSelect:0,onClick:0,onDblClick:0,onItemDraw:0,selection:[],value:[],_hasFocus:false});if(typeof A5._listBoxDefaults!='undefined')$u.o.assign(this,A5._listBoxDefaults);if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'listbox');$u.o.assign(this,settings);if(typeof this.item.template=='object')this.item.template=this.item.template.join('');if(this.item.template!=''&&this.item.calculateValue.constructor!=Function){this.item.calculateValue=function(data){var val=new Array();for(prop in data)val.push(data[prop]);return val.join('\n');}}
this._colDefaultVals={};for(var i=0;i<this.item.columns.length;i++){if(typeof this.item.columns[i]=='string')this.item.columns[i]={name:this.item.columns[i]};$u.o.assign(this.item.columns[i],this._cDefaults,true);this._colDefaultVals[this.item.columns[i].name]=this.item.columns[i].defaultValue;}
var contEle=$(this.contId);contEle.style.position='relative';this._keyWatch=new AUI.KeyWatcher([{key:'up',handle:this._keyPrevItem},{key:'down',handle:this._keyNextItem},{key:'left',handle:this._keyPrevItem},{key:'right',handle:this._keyNextItem},{key:'home',handle:this._keyFirstItem},{key:'end',handle:this._keyLastItem},{key:'enter',handle:this._keyEnter}],this);this._hasFocus=false;var contEle=$(contId);var HTMLFocusCatcher=document.createElement('button');HTMLFocusCatcher.id=contId+'.FOCUSCATCHER';$ss(HTMLFocusCatcher,'position: absolute; font-size: 0px; outline: none; opacity: 0; filter: alpha(opacity=0); height: 0px; width: '+contEle.offsetWidth+'px')
$e.add(HTMLFocusCatcher,'keydown',function(e){var keyCode=e.charCode||e.keyCode;if(keyCode!=9)$e.preventDefault(e);});$e.add(HTMLFocusCatcher,'keypress',function(e){var keyCode=e.charCode||e.keyCode;if(keyCode!=9)$e.preventDefault(e);});$e.add(HTMLFocusCatcher,'focus',this._focus,this,true);$e.add(contEle,'click',this._focus,this,true);$e.add(contEle,'contextmenu',this._rClick,this,true);contEle.parentNode.insertBefore(HTMLFocusCatcher,contEle);this.populate(data);},populate:function(data){this._data=[];for(var i=0;i<data.length;i++)this._data[i]=data[i];var lEle=$(this.contId);$e.removeGroup(this.contId+'.EVENTS');lEle.innerHTML='';this._hasOIDEvnt=this.onItemDraw.constructor==Function;this._values=new Array();var strData='';var colIndx=0;var rowIndx=0;var tEle=lEle;if(this.columns>1){var tblEle=document.createElement('table');tblEle.cellPadding='0';tblEle.cellSpacing='0';tblEle.insertRow(0);lEle.appendChild(tblEle);}
if(this.item.template==''){for(var i=0;i<this._data.length;i++){strData='';if(typeof this._data[i]=='string')strData=this._data[i];else if(typeof this._data[i]=='object'){if(typeof this._data[i]['*title']!='undefined')strData='*title';else if(typeof this._data[i]['*static']!='undefined')strData='*static';}
if(this.columns>1){if(strData=='-'||strData=='*title'||strData=='*static'){rowIndx++;tblEle.insertRow(rowIndx);tEle=tblEle.rows[rowIndx].insertCell(0);tEle.colSpan=this.columns;colIndx=this.columns;}else if(colIndx==this.columns){rowIndx++;tblEle.insertRow(rowIndx);tEle=tblEle.rows[rowIndx].insertCell(0);colIndx=1}else{tEle=tblEle.rows[rowIndx].insertCell(colIndx);colIndx++;}}
if(strData=='-'||strData=='*title'||strData=='*static'){this._renderSep(this._data[i],i,tEle);this._data.splice(i,1);i--;}else this._renderSimpleItem(this._data[i],i,tEle);}}else{for(var i=0;i<this._data.length;i++){strData='';if(typeof this._data[i]=='string')strData=this._data[i];else if(typeof this._data[i]=='object'){if(typeof this._data[i]['*title']!='undefined')strData='*title';else if(typeof this._data[i]['*static']!='undefined')strData='*static';}
if(strData=='-'||strData=='*title'||strData=='*static'){this._renderSep(this._data[i],i,tEle);this._data.splice(i,1);i--;}else{$u.o.assign(this._data[i],this._colDefaultVals,true);this._renderItem(this._data[i],i,tEle);}}}
if(!this.allowNullSelection&&data.length!=0)this._selectItem(0);},setValue:function(val){if(val.constructor==Array){if(val.length==0){if(this.allowNullSelection){this._deselectAll();if(this.onSelect.constructor==Function)this.onSelect();}}else{if(this.multiple){this._deselectAll()
for(var i=0;i<val.length;i++)this._selectItem(this._getIndex(val[i]),true);}else{this._selectItem(this._getIndex(val.pop()));}}}else{if(val==''){if(this.allowNullSelection){this._deselectAll();if(this.onSelect.constructor==Function)this.onSelect();}}else this._selectItem(this._getIndex(val));}
if(this.inputId!='')$(this.inputId).value=this.value.join('\n');},scrollToItem:function(val){val=this._getIndex(val);var eleId=this.contId+'.'+val;if($(eleId)){var ele=$(eleId);var cEle=$(this.contId);if(cEle.scrollTop>(ele.offsetTop-2))cEle.scrollTop=(ele.offsetTop-2);else if((cEle.scrollTop+cEle.offsetHeight)<(ele.offsetTop+ele.offsetHeight-2))cEle.scrollTop=(ele.offsetTop+ele.offsetHeight+2-cEle.offsetHeight);}},navigate:function(dir){if(dir.toLowerCase().substr(0,4)=='prev')this._keyPrevItem();else if(dir.toLowerCase()=='next')this._keyNextItem();else if(dir.toLowerCase()=='home')this._keyFirstItem();else if(dir.toLowerCase()=='end')this._keyLastItem();},_getIndex:function(val){var indx=this.allowNullSelection?-1:0;if(typeof val!='number'){for(var i=0;i<this._values.length;i++){if(this._values[i]==val){indx=i;break;}}}else indx=val
return indx;},_renderItem:function(iData,indx,lEle){var tHTML=this.item.template;for(var prop in iData)tHTML=tHTML.split('{'+prop+'}').join(iData[prop]);this._renderItemLow(tHTML,this.item.calculateValue(iData),indx,lEle,iData);},_renderSimpleItem:function(iData,indx,lEle){this._renderItemLow(iData.toString(),iData.toString(),indx,lEle,iData);},_renderItemLow:function(html,value,indx,lEle,iData){var ele=document.createElement('a');ele.id=this.contId+'.'+indx;ele.innerHTML=html;ele.href='#';ele.tabIndex=-1;ele.className=this.item.className;if(typeof this.item.style=='object'||typeof this.item.style=='string')$ss(ele,this.item.style);this._values.push(value);$sa(ele,'A5ListIndex',''+indx);$e.add(ele,'click',this._onClick,this,false,this.contId+'.EVENTS');$e.add(ele,'dblclick',this._onDblClick,this,false,this.contId+'.EVENTS');$e.add(ele,'mouseover',this._mOver,this,false,this.contId+'.EVENTS');$e.add(ele,'mouseout',this._mOut,this,false,this.contId+'.EVENTS');lEle.appendChild(ele);if(this._hasOIDEvnt)this.onItemDraw.call(this,ele,iData,indx);},_renderSep:function(sep,indx,lEle){if(sep=='-'){var ele=document.createElement('hr');ele.className=this.item.separatorClassName;}else if(sep['*title']){var ele=document.createElement('div');ele.className=this.item.titleClassName;ele.innerHTML=sep['*title'];}else if(sep['*static']){var ele=document.createElement('div');ele.className=this.item.className;ele.innerHTML=sep['*static'];}
lEle.appendChild(ele);if(this._hasOIDEvnt)this.onItemDraw.call(this,ele,sep,indx);},_selectItem:function(indx){var multiOverride=typeof arguments[1]!='undefined'?arguments[1]:false;var addToSel=indx==-1?false:true;if(this.multiple&&(this._keyWatch.ctrl||this._keyWatch.shift||multiOverride)){for(var i=0;i<this.selection.length;i++){if(this.selection[i]==indx){this.selection.splice(i,1);this.value.splice(i,1);$rcn(this.contId+'.'+indx,this.item.selectedClassName);addToSel=false;break;}}}else{this._deselectAll();}
if(addToSel||(!this.allowNullSelection&&this.selection.length==0)){this.value.push(this._values[indx]);this.selection.push(indx);$acn(this.contId+'.'+indx,this.item.selectedClassName);this.scrollToItem(indx);if(this.onSelect.constructor==Function)this.onSelect();}
if(this.inputId!='')$(this.inputId).value=this.value.join('\n');},_deselectAll:function(){for(var i=0;i<this.selection.length;i++)$rcn(this.contId+'.'+this.selection[i],this.item.selectedClassName);this.value=new Array();this.selection=new Array();},_onClick:function(e,classInst){$(classInst.contId+'.FOCUSCATCHER').focus();classInst._keyWatch.shift=false;classInst._keyWatch.ctrl=false;if(typeof e.shiftKey!='undefined'){classInst._keyWatch.shift=e.shiftKey;classInst._keyWatch.ctrl=e.ctrlKey;}
var indx=Number($ga(this,'A5ListIndex'));classInst._selectItem(indx);if(classInst.onClick.constructor==Function)classInst.onClick();$e.stopEvent(e);return false;},_onDblClick:function(e,classInst){if(classInst.onDblClick.constructor==Function)classInst.onDblClick();$e.stopEvent(e);return false;},_mOver:function(e,classInst){if(classInst.item.hoverClassName!='')$acn(this,classInst.item.hoverClassName);},_mOut:function(e,classInst){if(classInst.item.hoverClassName!='')$rcn(this,classInst.item.hoverClassName);},_keyPrevItem:function(){oldIndx=this.selection[this.selection.length-1];if(typeof oldIndx!='undefined'){if(oldIndx>0){oldIndx=oldIndx-1;this._selectItem(oldIndx);}else if(this.loopNavigate){if(this.loopNavigateNullSelection&&this.allowNullSelection){this._deselectAll();if(this.onSelect.constructor==Function)this.onSelect();}else this._selectItem(this._values.length-1);}}else{if(this.loopNavigate)this._selectItem(this._values.length-1);else this._selectItem(0);}},_keyNextItem:function(){oldIndx=this.selection[this.selection.length-1];if(typeof oldIndx!='undefined'){if(oldIndx<this._values.length-1){oldIndx=oldIndx+1;this._selectItem(oldIndx);}else if(this.loopNavigate){if(this.loopNavigateNullSelection&&this.allowNullSelection){this._deselectAll();if(this.onSelect.constructor==Function)this.onSelect();}else this._selectItem(0);}}else{this._selectItem(0);}},_keyFirstItem:function(){this._selectItem(0);},_keyLastItem:function(){this._selectItem(this._values.length-1);},_keyEnter:function(){if(this.onClick.constructor==Function)this.onClick();if(this.onDblClick.constructor==Function)this.onDblClick();},_rClick:function(e,classInstance){if(classInstance.onRightClick.constructor==Function){classInstance.onRightClick();$e.stopEvent(e);return false;}},_focus:function(e){if(this._hasFocus==false){this._keyWatch.on();this._hasFocus=true;$e.executeGroup('A5ControlsFocusCatcher');$e.removeGroup('A5ControlsFocusCatcher');$e.add(document.documentElement,'click',this._blur,this,true,'A5ControlsFocusCatcher');if(this.focusClassName!='')$acn($(this.contId),this.focusClassName);if(this.onFocus.constructor==Function)this.onFocus();}
$e.stopEvent(e);return false;},_blur:function(){this._hasFocus=false;this._keyWatch.off();if(this.focusClassName!='')$rcn($(this.contId),this.focusClassName);$e.remove(document.documentElement,'click',this._blur);if(this.onBlur.constructor==Function)this.onBlur();},_cDefaults:{name:'',defaultValue:''}}
A5.edit={getSelection:function(ele){ele.focus();var startPos=ele.value.length;var endPos=startPos;if(ele.setSelectionRange){startPos=ele.selectionStart;endPos=ele.selectionEnd;var len=Math.max(startPos,endPos)-Math.min(startPos,endPos);startPos=Math.min(startPos,endPos)
endPos=startPos+len;}else if(document.selection&&document.selection.createRange){var dRange=document.selection.createRange();dRange.collapse();if(ele.tagName.toLowerCase()=='textarea'){var range=document.body.createTextRange();range.moveToElementText(ele);}else var range=ele.createTextRange();var len=0;if(range.parentElement()==dRange.parentElement()){range.setEndPoint('EndToStart',dRange);startPos=range.text.replace(/\r/g,'').length;len=dRange.text.replace(/\r/g,'').length;endPos=startPos+len;}}
return{start:startPos,end:endPos,length:len};},setSelection:function(ele,startPos,endPos){if(typeof endPos=='undefined')endPos=startPos;var rsp=Math.min(startPos,endPos);var rep=Math.max(startPos,endPos);if(ele.setSelectionRange)ele.setSelectionRange(rsp,rep);else if(document.selection){var range=ele.createTextRange();range.moveStart('character',rsp);range.collapse();if(rsp!=rep)range.moveEnd('character',rep-rsp);range.select();}}}
A5.Edit=Class.create();A5.Edit.prototype={initialize:function(settings){if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'edit');$u.o.assign(this,settings);this._editPrepare();},bind:function(ctrl){if(ctrl.constructor==Array){for(var i=0;i<ctrl.length;i++)this._bind($(ctrl[i]));}else this._bind($(ctrl));},_bind:function(ele){if($ga(ele,'A5ControlBound')=='true')return true;$e.add(ele,'focus',this._focus,this);$e.add(ele,'blur',this._blur,this);$e.add(ele,'keydown',this._keyDown,this);$e.add(ele,'keypress',this._keyPress,this);this._editBind(ele);$sa(ele,'A5ControlBound','true');},setValue:function(val){if(typeof arguments[1]!='undefined'){var ele=$(arguments[1]);var oldVal=$gvs(ele);if(oldVal!=val){this._editBeforeUpdate(ele);$svs(ele,val);this._editUpdate(ele);}}else{var ele=0;var oldVal='';for(var i=0;i<this._editIds.length;i++){ele=$(this._editIds[i]);var oldVal=$gvs(ele);if(oldVal!=val){this._editBeforeUpdate(ele);$svs(ele,val);this._editUpdate(ele);}}}},insertValue:function(val,commit){var ele=$(this._targetId);var data=this._editValSplit(ele,true);var aVal=data.vals[data.selIndx];aVal.val=val;var offset=aVal.offset+val.length;if(commit&&this._multi.auto.separate&&data.selIndx==data.vals.length-1){if(this.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++)oldSeps.push(data.vals[i].sep);aVal.sep=this.multiple.auto.separator.call(this,oldSeps);}else aVal.sep=this.multiple.auto.separator;offset=offset+aVal.sep.length;if(this.format.showMask)data.vals.push({val:this.format._pMask.blankValue,sep:'',offset:0});}
ele.value=this._editValJoin(data);A5.edit.setSelection(ele,offset);return offset;},_editPrepare:function(){var oldWMStyle='';if(typeof this.watermark!='undefined'){if(typeof this.watermark.style!='undefined')oldWMStyle=this.watermark.style;}
$u.o.assign(this,{format:{type:'',mask:'',showMask:false,number:{},parseIn:'string',parseOut:0},watermark:{text:'',className:'',style:'color: gray;'},multiple:{allow:false,separators:0,auto:{separator:0,persist:false}}},true);if(this.watermark.className!='')this.watermark.style=oldWMStyle;this.format.type=this.format.type.toLowerCase();this._editTargetId='';if(this.format.type=='custom'){if(this.format.parseIn.constructor==Function)this.format._customIn=this.format.parseIn;else{if(this.format.parseIn=='number')this.format._customIn=function(val){return $u.s.toNum(val);};else if(this.format.parseIn=='boolean')this.format._customIn=function(val){return $u.s.toBool(val);};else this.format._customIn=function(val){return val.toString();};}
if(this.format.parseOut.constructor==Function)this.format._customOut=this.format.parseOut;else this.format._customOut=function(val){return val;};}else if(this.format.type=='number'&&this.format.number.constructor!=Function)this.format._number=this._editParseNumber(this.format.number);else if(this.format.type=='mask'){if(this.format.mask.constructor!=Function)this.format._pMask=this._editParseMask(this.format.mask);else this.format._pMask=this._editParseMask(this.format.mask.call(this));}
this._editIds=new Array();this._fakeOnChange=0;},_editBind:function(ele){var eId=ele.id!=''?ele.id:ele.name;this._editIds.push(eId);this._editSetWatermark(ele);},_editBeforeUpdate:function(ele){this._editClearWatermark(ele);},_editUpdate:function(ele){if(ele.value!=''&&(this.format.type=='custom'||this.format.type=='mask'||this.format.type=='number')){var tempEditTargetId=this._editTargetId;this._editTargetId=ele.id;this._multi=this._editParseMultiVal();var data=this._editValSplit(ele,false);if(this.format.type=='custom'){for(var i=0;i<data.vals.length;i++)data.vals[i].val=this.format._customOut.call(ele,this.format._customIn.call(ele,data.vals[i].val));}else if(this.format.type=='number'){if(this.format.number.constructor==Function)var numberObj=this._editParseNumber(this.format.number.call(this));else var numberObj=this.format._number;var maxLen=ele.maxLength;if(maxLen>500)maxLen=-1;for(var i=0;i<data.vals.length;i++)data.vals[i].val=this._editNumberOut(this._editNumberIn(data.vals[i].val,numberObj),numberObj,maxLen);}else if(this.format.type=='mask'){for(var j=0;j<data.vals.length;j++){val=data.vals[j].val;var pVal='';var iPoint=0;if(this.format.mask.constructor==Function)pMask=this._editParseMask(this.format.mask.call(this));else pMask=this.format._pMask;var mask=pMask.mask;for(var i=0;i<val.length;i++){var keyCode=val.substr(i,1);while(typeof mask[iPoint]=='string'&&mask.length>iPoint){pVal=pVal.substr(0,iPoint)+mask[iPoint]+pVal.substr(iPoint+1);if(mask[iPoint]==keyCode){i++;keyCode=val.substr(i,1);}
iPoint++;}
if(keyCode.match(mask[iPoint])){pVal=pVal.substr(0,iPoint)+keyCode+pVal.substr(iPoint+1);iPoint=iPoint+1;}
while(typeof mask[iPoint]=='string'&&mask.length>iPoint){pVal=pVal.substr(0,iPoint)+mask[iPoint]+pVal.substr(iPoint+1);if(mask[iPoint]==keyCode){i++;keyCode=val.substr(i,1);}
iPoint++;}}
data.vals[j].val=pVal;}}
this._editTargetId=tempEditTargetId;this._multi=this._editParseMultiVal();ele.value=this._editValJoin(data);}else this._editSetWatermark(ele);},_editParseNumber:function(num){$u.o.assign(num,{blank:false,blankValue:0,negative:'-',hasMax:false,hasMin:false,max:100,min:0,decimal:'.',round:-1,roundDirection:'',comma:'',prefix:'',suffix:'',fill:''},true);num.negative=num.negative.toLowerCase();return num;},_editParseMask:function(mask){pMask=new Object();pMask.mask=new Array();for(var i=0;i<mask.length;i++){if(mask.substr(i,1)=='\\'){pMask.mask.push(mask.substr(i+1,1));i++;}else if(mask.substr(i,1)=='L')pMask.mask.push(/[A-Z]/);else if(mask.substr(i,1)=='l')pMask.mask.push(/[A-z]/);else if(mask.substr(i,1)=='#')pMask.mask.push(/[0-9\.\-]/);else if(mask.substr(i,1)=='N')pMask.mask.push(/[A-Z0-9\.\-]/);else if(mask.substr(i,1)=='n')pMask.mask.push(/[A-z0-9\.\-]/);else if(mask.substr(i,1)=='A')pMask.mask.push(/[A-Z0-9]/);else if(mask.substr(i,1)=='a')pMask.mask.push(/[A-z0-9]/);else if(mask.substr(i,1)=='0')pMask.mask.push(/[0-9]/);else if(mask.substr(i,1)=='&')pMask.mask.push(/./);else pMask.mask.push(mask.substr(i,1));}
pMask.blankValue=new Array();for(var i=0;i<pMask.mask.length;i++){if(typeof pMask.mask[i]=='string')pMask.blankValue.push(pMask.mask[i]);else pMask.blankValue.push('_');}
pMask.blankValue=pMask.blankValue.join('');return pMask;},_editParseMultiVal:function(){var pMulti={allow:this.multiple.allow,'sep':[],regEx:'',keyBuffer:'',auto:{separate:false,persist:this.multiple.auto.persist}};if(pMulti.allow){if(typeof this.multiple.separators=='string')pMulti.sep=[this.multiple.separators];else if(this.multiple.separators.constructor==Function){pMulti.sep=this.multiple.separators.call(this);if(typeof pMulti.sep=='string')pMulti.sep=[pMulti.sep];}else if(this.multiple.separators.constructor==Array){for(var i=0;i<this.multiple.separators.length;i++)pMulti.sep.push(this.multiple.separators[i]);}
if(pMulti.sep.length==0)pMulti.allow=false;else{pMulti.sep.sort(function(a,b){return b.length-a.length;});var regExArr=new Array();for(var i=0;i<pMulti.sep.length;i++)regExArr.push(pMulti.sep[i].replace(/[\\\.\^\$\*\+\?\{\}\[\]\(\)\|]/g,function(val){return'\\'+val;}));pMulti.regEx=RegExp(regExArr.join('|'),'g');}
if((typeof this.multiple.auto.separator=='string'&&this.multiple.auto.separator!='')||this.multiple.auto.separator.constructor==Function)pMulti.auto.separate=true;}
return pMulti;},_editSetWatermark:function(ele){if(((typeof this.watermark.text=='string'&&this.watermark.text!='')||this.watermark.text.constructor==Function)&&ele.value==''){if(this.watermark.text.constructor==Function)ele.value=this.watermark.text.call(this,ele);else ele.value=this.watermark.text;$sa(ele,'A5WatermarkText',ele.value);if(this.watermark.className!='')$acn(ele,this.watermark.className);var oldStyle=$gs(ele);$sa(ele,'A5WatermarkOldStyle',oldStyle);$ss(ele,oldStyle+';'+this.watermark.style);}},_editClearWatermark:function(ele){if(ele.value==$ga(ele,'A5WatermarkText')){ele.value='';if(this.watermark.className!='')$rcn(ele,this.watermark.className);$ss(ele,$ga(ele,'A5WatermarkOldStyle'));}},_editMaskKeyPress:function(e,ele,pMask){var keyCode=0;if(typeof e.which=='number')keyCode=e.which;else if(typeof e.charCode=='number')keyCode=e.charCode;else keyCode=e.keyCode;if(keyCode==8||keyCode==9||keyCode==13||keyCode==27)keyCode=0;if(keyCode!=0&&!e.ctrlKey&&!e.altKey){$e.stopEvent(e);if(this._fakeOnChange!=-1)this._fakeOnChange=1;var mask=pMask.mask;var data=this._editValSplit(ele,true);var aVal=data.vals[data.selIndx];var sel=A5.edit.getSelection(ele);var iPoint=sel.start-aVal.offset;if(iPoint>=mask.length&&!this._multi.auto.persist){this._multi.keyBuffer+=String.fromCharCode(keyCode).toLowerCase();var sLen=this._multi.keyBuffer.length;var sMat=new Array();for(var i=0;i<this._multi.sep.length;i++)if(this._multi.sep[i].substr(0,sLen).toLowerCase()==this._multi.keyBuffer)sMat.push(i);if(sMat.length==1){aVal.sep=this._multi.sep[sMat[0]];if(this.format.showMask&&data.vals.length-1==data.selIndx)data.vals.push({val:pMask.blankValue,sep:'',offset:0})
ele.value=this._editValJoin(data);A5.edit.setSelection(ele,iPoint+aVal.offset+aVal.sep.length);}else if(sMat.length==0)this._multi.keyBuffer='';}else{this._multi.keyBuffer='';var value=aVal.val;while(typeof mask[iPoint]=='string'&&mask.length>iPoint){value=value.substr(0,iPoint)+mask[iPoint]+value.substr(iPoint+1);iPoint=iPoint+1;}
keyCode=String.fromCharCode(keyCode);if(keyCode.match(mask[iPoint])){value=value.substr(0,iPoint)+keyCode+value.substr(iPoint+1);iPoint=iPoint+1;}
while(typeof mask[iPoint]=='string'&&mask.length>iPoint){value=value.substr(0,iPoint)+mask[iPoint]+value.substr(iPoint+1);iPoint=iPoint+1;}
aVal.val=value;if(data.selIndx==data.vals.length-1&&iPoint==mask.length&&this._multi.auto.separate){if(this.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++)oldSeps.push(data.vals[i].sep);aVal.sep=this.multiple.auto.separator.call(this,oldSeps);}else aVal.sep=this.multiple.auto.separator;if(this.format.showMask)data.vals.push({val:pMask.blankValue,sep:'',offset:0})
iPoint+=aVal.sep.length;}
ele.value=this._editValJoin(data);A5.edit.setSelection(ele,iPoint+aVal.offset);}
return false;}},_editMaskKeyDown:function(e,ele,pMask){var keyCode=e.charCode||e.keyCode;if(this.format.showMask){if(keyCode==8||keyCode==46){$e.stopEvent(e);if(this._fakeOnChange!=-1)this._fakeOnChange=1;var data=this._editValSplit(ele,true);var oldLen=data.vals.length;var sel=A5.edit.getSelection(ele);var mValue=pMask.blankValue;if(sel.length==0){var aVal=data.vals[data.selIndx];var sStart=sel.start-aVal.offset;var sEnd=sel.end-aVal.offset;var value=aVal.val;if(keyCode==8&&sStart>0){value=value.substr(0,sStart-1)+mValue.substr(sStart-1,1)+value.substr(sStart);sel.start--;}else if(keyCode==46&&sStart<value.length){value=value.substr(0,sStart)+mValue.substr(sStart,1)+value.substr(sStart+1);sel.start++;}
if(value==mValue&&data.vals.length>1){delete aVal;data.vals.splice(data.selIndx,1);if(data.selIndx==data.vals.length){data.vals[data.vals.length-1].sep='';if(keyCode==46)sel.start=data.vals[data.vals.length-1].offset;}else if(keyCode==46)sel.start-=mValue.length;}else aVal.val=value;}else{for(var i=data.vals.length-1;i>=0;i--){if(data.vals[i].offset>=sel.start&&data.vals[i].offset+data.vals[i].val.length<=sel.end)data.vals.splice(i,1);else if((data.vals[i].offset<sel.start&&data.vals[i].offset+data.vals[i].val.length>sel.start)||(data.vals[i].offset<sel.end&&data.vals[i].offset+data.vals[i].val.length>sel.end)){var sStart=sel.start-data.vals[i].offset;var sEnd=sel.end-data.vals[i].offset;var sLen=sEnd-Math.max(sStart,0);data.vals[i].val=data.vals[i].val.substr(0,sStart)+mValue.substr(sStart,sLen)+data.vals[i].val.substr(sEnd);}}}
if(oldLen!=data.vals.length&&this._multi.auto.persist){if(this.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++){data.vals[i].sep=this.multiple.auto.separator.call(this,oldSeps);oldSeps.push(data.vals[i].sep);}}else for(var i=0;i<data.vals.length-1;i++)data.vals[i].sep=this.multiple.auto.separator;}
ele.value=this._editValJoin(data);A5.edit.setSelection(ele,sel.start);return false;}}else if(keyCode==8||keyCode==46)this._fakeOnChange=-1;},_editNumberIn:function(str,num){str=str.toString();var negNum=false;if(num.negative.indexOf('(')!=-1&&str.indexOf('(')!=-1)negNum=true;else if(str.indexOf('-')!=-1)negNum=true;var regEx=RegExp('[^0-9'+num.decimal+']');str=str.split(regEx).join('');str=$if(negNum,'-','')+str.split(regEx).join('');str=str.replace(num.decimal,'.');return Number(str);},_editNumberOut:function(valNum,num,maxLen){var comma=num.comma!=''?true:false;var neg=valNum<0?true:false;var prefix=num.prefix;var suffix=num.suffix;if(num.round>=0)valNum=$u.n.round(valNum,num.round,num.roundDirection);if(num.blank&&valNum==num.blankValue)return'';if(num.hasMax)valNum=Math.min(valNum,num.max);if(num.hasMin)valNum=Math.max(valNum,num.min);valNum=Math.abs(valNum);var str=String(valNum);var intStr=$u.s.word(str,1,'.');var decStr=$u.s.word(str,2,'.');if(num.round>=0){if(!decStr)decStr='0';if(decStr.length!=num.round)decStr=$u.s.pad(decStr,num.round,'0','r');}
if(comma&&intStr.length>3){var intArr=new Array();var placeInc=Math.round((intStr.length/3)+.49);intStr=$u.s.pad(intStr,placeInc*3,'0','l')
intArr.push($u.s.lTrim(intStr.substr(0,3),'0'));for(var i=1;i<placeInc;i++){intArr.push(intStr.substr(i*3,3));}
intStr=intArr.join(num.comma);}
if(neg){if(num.negative=='p-')prefix=prefix+'-';else if(num.negative=='-s')suffix=' -'+suffix;else if(num.negative=='s-')suffix=suffix+'-';else if(num.negative.indexOf('(')!=-1){if(num.negative=='(p)')prefix='('+prefix+')';else if(num.negative=='(n)'||num.negative=='(ns)')prefix=prefix+'(';else prefix='('+prefix;if(num.negative=='(s)')suffix=' ('+suffix+')';else if(num.negative=='(n)'||num.negative=='(pn)')suffix=')'+suffix;else suffix=suffix+')';}else prefix='-'+prefix;}
var val=prefix+intStr+$if(decStr!='',num.decimal+decStr,'')+suffix;if(num.fill!=''&&maxLen>val.length){val=$u.s.pad(val,maxLen,num.fill,'l');}
return val;},_editValSplit:function(eleId,getIndx){var val=$gvs(eleId);val=val.replace(/\r/g,'');if(this._multi.allow){var data={selIndx:0,inSep:false,sel:{start:val.length,end:val.length,length:0},vals:[]};var indx=-1;var offset=0;var tVal='';var tSep='';if(getIndx){var sel=A5.edit.getSelection($(eleId));var tMat=val.substr(0,sel.start).match(this._multi.regEx);if(tMat)data.selIndx=tMat.length;data.sel.start=sel.start;data.sel.end=sel.end;data.sel.length=sel.length;}
if(val.length==0)data.vals.push({'val':'','sep':'','offset':0});else{while(val.length>0){indx=val.search(this._multi.regEx);if(indx>-1){tVal=val.substr(0,indx);val=val.substr(indx);for(var i=0;i<this._multi.sep.length;i++){if(val.substr(0,this._multi.sep[i].length)==this._multi.sep[i]){tSep=this._multi.sep[i];val=val.substr(this._multi.sep[i].length);break;}}
data.vals.push({'val':tVal,'sep':tSep,'offset':offset});offset=offset+tVal.length+tSep.length;}else{data.vals.push({'val':val,'sep':'','offset':offset});offset=offset+tVal.length;val='';}}}
if(data.vals[data.vals.length-1].sep!='')data.vals.push({'val':'','sep':'','offset':offset});if(data.vals[data.selIndx+1]&&getIndx){if(sel.start>=data.vals[data.selIndx+1].offset-data.vals[data.selIndx].sep.length)data.inSep=true;}
return data}else return{selIndx:0,inSep:false,sel:{start:val.length,end:val.length,length:0},vals:[{'val':val,sep:'',offset:0}]};},_editValJoin:function(data){var val=new Array();for(var i=0;i<data.vals.length;i++){val.push(data.vals[i].val);val.push(data.vals[i].sep);}
return val.join('');},_editFocus:function(e,ele){this._editTargetId=ele.id;var sel=A5.edit.getSelection(ele);this._editClearWatermark(ele);this._fakeOnChange=0;this._multi=this._editParseMultiVal();if(this.format.type=='mask'){if(this.format.mask.constructor==Function)this.format._pMask=this._editParseMask(this.format.mask.call(this));if(this.format.type=='mask'&&this.format.showMask){var data=this._editValSplit(ele,true);for(var i=0;i<data.vals.length;i++){if(data.vals[i].val=='')data.vals[i].val=this.format._pMask.blankValue;}
ele.value=this._editValJoin(data);A5.edit.setSelection(ele,sel.start);}}else if(this.format.type=='number'){if(this.format.number.constructor==Function)this.format._number=this._editParseNumber(this.format.number.call(this));var data=this._editValSplit(ele,true);var tOffset=0;for(var i=0;i<data.vals.length;i++){data.vals[i].oldOffset=data.vals[i].offset;data.vals[i].offset-=tOffset;data.vals[i].oldVal=data.vals[i].val;data.vals[i].val=''+this._editNumberIn(data.vals[i].val,this.format._number);if(data.vals[i].val==0&&data.vals.length-1==i)data.vals[i].val='';tOffset+=(data.vals[i].oldVal.length-data.vals[i].val.length);}
ele.value=this._editValJoin(data);sel.start=data.vals[data.selIndx].offset+String(this._editNumberIn(data.vals[data.selIndx].oldVal.substr(0,sel.start-data.vals[data.selIndx].oldOffset),this.format._number)).length;A5.edit.setSelection(ele,sel.start);}},_editBlur:function(e,ele){if(this.format.type=='custom'){var data=this._editValSplit(ele,false);for(var i=0;i<data.vals.length;i++){data.vals[i].val=this.format._customIn.call(ele,data.vals[i].val);data.vals[i].val=this.format._customOut.call(ele,data.vals[i].val);}
ele.value=this._editValJoin(data);}else if(this.format.type=='number'){var maxLen=ele.maxLength;if(maxLen>500)maxLen=-1;var data=this._editValSplit(ele,false);for(var i=0;i<data.vals.length;i++){data.vals[i].val=this._editNumberOut(this._editNumberIn(data.vals[i].val,this.format._number),this.format._number,maxLen);}
ele.value=this._editValJoin(data);}else if(this.format.type=='mask'&&this.format.showMask){var data=this._editValSplit(ele,false);for(var i=0;i<data.vals.length;i++){if(data.vals[i].val==this.format._pMask.blankValue)data.vals[i].val='';}
ele.value=this._editValJoin(data);}
if(this.format.type=='mask'&&this._fakeOnChange==1)$e.execute(ele,'change');this._editSetWatermark(ele);},_editKeyDown:function(e,ele){if(this.format.type=='mask')this._editMaskKeyDown(e,ele,this.format._pMask);},_editKeyPress:function(e,ele){if(this.format.type=='mask')this._editMaskKeyPress(e,ele,this.format._pMask);},_focus:function(e,classInst){classInst._editFocus(e,this);},_blur:function(e,classInst){classInst._editBlur(e,this);},_keyDown:function(e,classInst){classInst._editKeyDown(e,this);},_keyPress:function(e,classInst){classInst._editKeyPress(e,this);}}
A5.EditSuggest=Class.create(A5.Edit,{initialize:function(settings){$u.o.assign(this,{theme:'',content:{type:'',url:'',data:''},minimum:1,delay:100,selectionRequired:false,listbox:{theme:''},window:{theme:''},onSelect:0});if(typeof settings.theme!='undefined'){A5.themes.assign(this,settings.theme,'edit');var tTheme=settings.theme.split(':').shift();if(this.window.theme=='')this.window.theme=tTheme+':dropdown';if(this.listbox.theme=='')this.listbox.theme=tTheme+':dropdown';}
$u.o.assign(this,settings);this.content.type=this.content.type.toLowerCase();if(this.content.type==''&&this.content.url!='')this.content.type='url';else if(this.content.type==''&&this.content.data.constructor==Function)this.content.type='url';else if(this.content.type==''&&(this.content.data.constructor==Array||this.content.data!=''))this.content.type='static';$u.o.assign(this.window,{title:{show:false},body:{content:{type:'blank'},style:{padding:'0px',overflow:'auto'}},type:'popup',autoShow:false,autoPosition:false});$u.o.assign(this.listbox,{loopNavigate:true,onClick:function(){var ele=$(this._targetId)
ele.focus();$e.execute(ele,'a5listselection');}});var win=new A5.Window(this.window);this._listbox=new A5.ListBox(win.getWindowId('body'),[],this.listbox);this._listbox._window=win;if(this._listbox.item.calculateValue.constructor!=Function)this._listbox.item.calculateValue=function(data){return data;};this._editPrepare();this._value='';this._hasFocus=false;this._delayTO=0;this._oldIPoint=0;},bind:function(ctrl){if(ctrl.constructor==Array){for(var i=0;i<ctrl.length;i++)this._bind($(ctrl[i]));}else this._bind($(ctrl));},_bind:function(ele){if($ga(ele,'A5ControlBound')=='true')return true;$e.add(ele,'focus',this._focus,this);$e.add(ele,'blur',this._blur,this);$e.add(ele,'keydown',this._keyDown,this);$e.add(ele,'keyup',this._keyUp,this,true);$e.add(ele,'keypress',this._keyPress,this);$e.add(ele,'click',this._onClick,this);$e.add(ele,'a5listselection',this._listSelection,this);this._editBind(ele);$sa(ele,'A5ControlBound','true');},_focus:function(e,classInst){if(classInst._targetId!=this.id){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;}
classInst._targetId=this.id;classInst._listbox._targetId=this.id;classInst._listbox._window._targetId=this.id;classInst._initValue=$gvs(this);classInst._hasFocus=true;classInst._editFocus(e,this);},_blur:function(e,classInst){if(classInst.selectionRequired){var ele=$(classInst._targetId);var data=classInst._editValSplit(ele,false);var initVals=classInst._multi.allow?classInst._initValue.split(classInst._multi.regEx):[classInst._initValue];var remVal=true;for(var i=data.vals.length-1;i>=0;i--){remVal=true;if(data.vals[i].val!=''){for(var j=0;j<initVals.length;j++){if(initVals[j]==data.vals[i].val){remVal=false;break;}}}
if(remVal)data.vals.splice(i,1);}
if(classInst._multi.auto.separate&&classInst._multi.auto.persist){if(classInst.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++){data.vals[i].sep=classInst.multiple.auto.separator.call(classInst,oldSeps);oldSeps.push(data.vals[i].sep);}}else for(var i=0;i<data.vals.length-1;i++)data.vals[i].sep=classInst.multiple.auto.separator;}
data=classInst._editValJoin(data);if($gvs(ele)!=data)ele.value=data;}
classInst._hasFocus=false;classInst._editBlur(e,this);},_keyDown:function(e,classInst){classInst._editKeyDown(e,this);var keyCode=e.charCode||e.keyCode;if((keyCode==13||keyCode==9)&&!classInst._listbox._window.hidden){$e.stopEvent(e);classInst._listSelection(e,classInst);return false;}else if((keyCode==36||keyCode==35)&&!classInst._listbox._window.hidden&&classInst._listbox.value.length>0){$e.stopEvent(e);if(keyCode==36)classInst._listbox.navigate('home');else classInst._listbox.navigate('end');if(classInst._listbox.value.length!=0)classInst._setValue(classInst._listbox.value[0],false);else classInst._setValue(classInst._value,false);return false;}else if((keyCode==38||keyCode==40)){$e.stopPropagation(e);}},_keyUp:function(e){var keyCode=e.charCode||e.keyCode;var ignoreChr=[9,13,16,17,18,19,20,27,33,34,35,36,37,38,39,40,45,112,113,114,115,116,117,118,119,120,121,122,123];if(keyCode==38&&!this._listbox._window.hidden){this._listbox.navigate('prev');if(this._listbox.value.length!=0)this._setValue(this._listbox.value[0],false);else this._setValue(this._value,false);}else if(keyCode==40&&!this._listbox._window.hidden){this._listbox.navigate('next');if(this._listbox.value.length!=0)this._setValue(this._listbox.value[0],false);else this._setValue(this._value,false);}else if(keyCode==36||keyCode==35||keyCode==37||keyCode==39){var sel=A5.edit.getSelection($(this._targetId));this._oldIPoint=sel.start;}else if($u.a.find(ignoreChr,keyCode)==-1){if(keyCode==8||keyCode==46){var sel=A5.edit.getSelection($(this._targetId));this._oldIPoint=sel.start;}
if(this.delay>0){clearTimeout(this._delayTO);classInst=this;this._delayTO=setTimeout(function(){classInst._getListComplete();delete classInst;},this.delay);}else this._getListComplete();}},_onClick:function(e,classInst){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;},_listSelection:function(e,classInst){if(classInst._listbox.value.length!=0){var ele=$(classInst._targetId);A5.edit.setSelection(ele,classInst._oldIPoint);classInst._setValue(classInst._listbox.value[0],true);classInst._initValue=ele.value;if(classInst.onSelect.constructor==Function)classInst.onSelect.call(ele,classInst._listbox._data[classInst._listbox.selection[0]],classInst);}
classInst._listbox._window.hide();},_setValue:function(val,commit){var ele=$(this._targetId);var data=this._editValSplit(ele,true);var aVal=data.vals[data.selIndx];aVal.val=val;var offset=aVal.offset+val.length;if(commit&&this._multi.auto.separate&&data.selIndx==data.vals.length-1){if(this.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++)oldSeps.push(data.vals[i].sep);aVal.sep=this.multiple.auto.separator.call(this,oldSeps);}else aVal.sep=this.multiple.auto.separator;offset=offset+aVal.sep.length;if(this.format.showMask)data.vals.push({val:this.format._pMask.blankValue,sep:'',offset:0});}
ele.value=this._editValJoin(data);this._oldIPoint=offset;A5.edit.setSelection(ele,offset);},_getListComplete:function(){var ele=$(this._targetId);var data=this._editValSplit(ele,true);this._value=data.vals[data.selIndx].val;if(this._value.length<this.minimum){this._listbox._window.hide();return'';}
if(this.content.type=='dynamic'&&this.content.data.constructor==Function){var dArr=this.content.data.call(this,this._value);if(typeof dArr!='undefined'){if(dArr.constructor==Array){this.populateList(dArr);}}}else if(this.content.type=='static'){var data=new Array();if(this.content.data.constructor==Array)data=this.content.data;else data=this.content.data.split('\n');var curVal=this._value.toLowerCase();var curValLen=curVal.length;var dArr=new Array();for(var i=0;i<data.length;i++){if(curVal==this._listbox.item.calculateValue(data[i]).substr(0,curValLen).toLowerCase()){dArr[dArr.length]=data[i];}}
this.populateList(dArr);}else if(this.content.type=='url'){var tData='';if(this.content.data.constructor==Function)tData=this.content.data.call(this,ele);else tData=this.content.data;if(tData!='')tData=tData+'&';tData=tData+A5.ajax.buildURLParam($if(ele.name=='',ele.id,ele.name),this._value)+'&'+A5.ajax.buildURLParam('A5EditSuggestId',$if(ele.id=='',ele.name,ele.id));A5.ajax.callback(this.content.url,tData);}},populateList:function(dArr){var context=typeof arguments[1]!='undefined'?arguments[1]:this._targetId;if((context!=this._targetId&&context!='')||!this._hasFocus)return false;if(dArr.length>0){this._listbox.populate(dArr);this._listbox.setValue('');if(!this._listbox._window.hidden)this._listbox._window.hide();this._listbox._window.show('dropdown',this._targetId);}else{this._listbox._window.hide();}}});A5.EditButtonGroup=Class.create(A5.Edit,{initialize:function(settings){$u.o.assign(this,{theme:'',container:{className:'',hoverClassName:'',focusClassName:'',pressedClassName:'',style:0,editClassName:'',separatorClassName:'',button:{html:'',className:'',hoverClassName:'',pressedClassName:''}}});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'editButtonGroup');$u.o.assign(this,settings);this._editPrepare();this._buttonNum=0;this._buttonState=false;this._hasFocus=false;},create:function(s){var useContainer=typeof arguments[1]!='undefined'?arguments[1]:true;var HTMLIEle=document.createElement('input');if(typeof s=='object'){if(typeof s.className!='undefined'){HTMLIEle.className=s.className;delete s.className;}
if(typeof s.style!='undefined'){$ss(HTMLIEle,s.style);delete s.style;}
for(var attr in s)$sa(HTMLIEle,attr,s[attr]);}
if(HTMLIEle.id=='')HTMLIEle.id=A5.u.getUniqueId();if(useContainer){var HTMLCEle=document.createElement('table');HTMLCEle.id=HTMLIEle.id+'.CONTAINER';HTMLCEle.cellPadding='0';HTMLCEle.cellSpacing='0';HTMLCEle.className=this.container.className;if(typeof this.container.style!='number')$ss(HTMLCEle,this.container.style);$ss(HTMLCEle,'display: inline-table; *display: inline;');HTMLCEle.insertRow(0);var cellIndx=0;HTMLCEle.rows[0].insertCell(cellIndx);HTMLIEle.className=this.container.editClassName;$ss(HTMLIEle,'width: 100%; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');HTMLCEle.rows[0].cells[cellIndx].appendChild(HTMLIEle);cellIndx++;if(this.container.separatorClassName!=''){HTMLCEle.rows[0].insertCell(cellIndx);HTMLCEle.rows[0].cells[cellIndx].innerHTML='&nbsp;';HTMLCEle.rows[0].cells[cellIndx].className=this.container.separatorClassName;cellIndx++;}
HTMLCEle.rows[0].insertCell(cellIndx);HTMLCEle.rows[0].cells[cellIndx].id=HTMLIEle.id+'.BUTTON';HTMLCEle.rows[0].cells[cellIndx].className=this.container.button.className;HTMLCEle.rows[0].cells[cellIndx].innerHTML=this.container.button.html;HTMLCEle.rows[0].cells[cellIndx].style.width='0%';document.documentElement.appendChild(HTMLCEle);this._bind(HTMLIEle);return HTMLCEle;}else{this._bind(HTMLIEle);return HTMLIEle;}},bind:function(ctrl){if(ctrl.constructor==Array){for(var i=0;i<ctrl.length;i++){if(ctrl[i].constructor==Array)this._bind(ctrl[i][0],ctrl[i][1]);else this._bind(ctrl[i]);}}else{this._bind(ctrl,arguments[1]);}},_bind:function(ele){var ele=$(ele);if($ga(ele,'A5ControlBound')=='true')return true;var eleId=ele.id!=''?ele.id:ele.name;var cEle=$(eleId+'.CONTAINER');if(cEle&&this.container.hoverClassName!=''){$e.add(cEle,'mouseover',Function('$acn(this,\''+this.container.hoverClassName+'\')'));$e.add(cEle,'mouseout',Function('$rcn(this,\''+this.container.hoverClassName+'\')'));}
if(cEle&&this.container.button.hoverClassName){var bIndx=0;var cbEle=0;while($(eleId+'.CUSTOMBUTTON.'+bIndx)){cbEle=$(eleId+'.CUSTOMBUTTON.'+bIndx);$e.add(cbEle,'mousedown',this._bmDown,this);$e.add(cbEle,'mouseover',Function('$acn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $acn(this,\''+this.container.button.hoverClassName+'\')'));$e.add(cbEle,'mouseout',this._bmOut,this);$e.add(cbEle,'mouseup',this._bmUp,this);$sa(cbEle,'A5TargetInput',eleId);bIndx+=1;}}
$e.add(ele,'focus',this._focus,this);$e.add(ele,'blur',this._blur,this);$e.add(ele,'keydown',this._keyDown,this);$e.add(ele,'keypress',this._keyPress,this);this._editBind(ele);$sa(ele,'A5ControlBound','true');},setState:function(state){this._buttonState=state;var cEle=$(this._targetId+'.CONTAINER');if(cEle){if(state){if(!this._hasFocus&&this.container.focusClassName!='')$acn(cEle,this.container.focusClassName);if(this.container.pressedClassName!='')$acn(cEle,this.container.pressedClassName);if(this.container.button.pressedClassName!='')$acn($(this._targetId+'.CUSTOMBUTTON.'+this._buttonNum),this.container.button.pressedClassName);}else{if(this.container.pressedClassName!='')$rcn(cEle,this.container.pressedClassName);if(!this._hasFocus&&this.container.focusClassName!='')$rcn(cEle,this.container.focusClassName);if(this.container.button.pressedClassName!='')$rcn($(this._targetId+'.CUSTOMBUTTON.'+this._buttonNum),this.container.button.pressedClassName);}}},_bmDown:function(e,classInst){var tEleId=$ga(this,'A5TargetInput');var ele=$(tEleId);if(ele.disabled)return false;ele.focus();classInst._targetId=tEleId;classInst._buttonNum=Number(this.id.split('.').pop());$acn(this,classInst.container.button.pressedClassName);},_bmOut:function(e,classInst){var tEleId=$ga(this,'A5TargetInput');$rcn(tEleId+'.CONTAINER',classInst.container.hoverClassName);$rcn(this,classInst.container.button.hoverClassName);if(!classInst._buttonState)$rcn(this,classInst.container.button.pressedClassName)},_bmUp:function(e,classInst){if(!classInst._buttonState)$rcn(this,classInst.container.button.pressedClassName)},_focus:function(e,classInst){if(classInst._targetId!=this.id){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;}
classInst._targetId=this.id;classInst._initValue=$gvs(this);classInst._editFocus(e,this);classInst._hasFocus=true;var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!='')$acn(cEle,classInst.container.focusClassName);},_blur:function(e,classInst){classInst._editBlur(e,this);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!=''&&!classInst._buttonState)$rcn(cEle,classInst.container.focusClassName);classInst._hasFocus=false;}});A5.EditCombo=Class.create(A5.Edit,{initialize:function(data,settings){$u.o.assign(this,{theme:'',listbox:{theme:''},window:{theme:''},container:{className:'',hoverClassName:'',focusClassName:'',pressedClassName:'',style:0,editClassName:'',separatorClassName:'',button:{html:'',className:'',hoverClassName:'',pressedClassName:''}},filter:0,_dynamicData:false,selectionRequired:false,selectionRequiredFilterMode:'default',onSelect:0});if(typeof settings.theme!='undefined'){A5.themes.assign(this,settings.theme,'editButtonGroup');var tTheme=settings.theme.split(':').shift();if(this.window.theme=='')this.window.theme=tTheme+':dropdown';if(this.listbox.theme=='')this.listbox.theme=tTheme+':dropdown';}
$u.o.assign(this,settings);$u.o.assign(this.window,{title:{show:false},body:{content:{type:'blank'},style:{padding:'0px',overflow:'auto'}},type:'popup',autoShow:false,autoPosition:false,_container:{focusClassName:this.container.focusClassName,pressedClassName:this.container.pressedClassName,button:{pressedClassName:this.container.button.pressedClassName}},onShow:function(){var cEle=$(this._targetId+'.CONTAINER');if(cEle){if(this._container.pressedClassName!='')$acn(cEle,this._container.pressedClassName);if(this._container.button.pressedClassName!='')$acn($(this._targetId+'.BUTTON'),this._container.button.pressedClassName);}},onHide:function(){var cEle=$(this._targetId+'.CONTAINER');if(cEle){if(this._container.focusClassName!=''&&!this._makeSelection)$rcn(cEle,this._container.focusClassName);if(this._container.pressedClassName!='')$rcn(cEle,this._container.pressedClassName);if(this._container.button.pressedClassName!='')$rcn($(this._targetId+'.BUTTON'),this._container.button.pressedClassName);}
this._makeSelection=false;}});$u.o.assign(this.listbox,{loopNavigate:true,onClick:function(){var ele=$(this._targetId)
ele.focus();setTimeout(Function('$e.execute($(\''+this._targetId+'\'),\'a5listselection\');'),1);}});var win=new A5.Window(this.window);this._listbox=new A5.ListBox(win.getWindowId('body'),[],this.listbox);this._listbox._window=win;if(this._listbox.item.calculateValue.constructor!=Function)this._listbox.item.calculateValue=function(data){return data;};if(data.constructor==Function){this._dynamicData=data;data=[];}
this.setData(data);this._editPrepare();this._value='';this._oldIPoint=0;},setData:function(data){this._data=data;if(!this._listbox._window.hidden){var contextId=typeof arguments[1]!='undefined'?arguments[1]:'';if(contextId==''||contextId==this._targetId){var filterData=typeof arguments[2]!='undefined'?arguments[2]:false;if(filterData){var ele=$(this._targetId);var data=this._editValSplit(ele,true);this._value=data.vals[data.selIndx].val;var curVal=this._value.toLowerCase();var curValLen=curVal.length;if(this.filter.constructor==Function)this._data=this.filter.call(this,this._data);var dArr=new Array();for(var i=0;i<this._data.length;i++){if(curVal==String(this._listbox.item.calculateValue(this._data[i])).substr(0,curValLen).toLowerCase()){dArr[dArr.length]=this._data[i];}}
this._populateList(dArr,false);}else this._populateList(data,true);}}},create:function(s){var useContainer=typeof arguments[1]!='undefined'?arguments[1]:true;var HTMLIEle=document.createElement('input');if(typeof s=='object'){if(typeof s.className!='undefined'){HTMLIEle.className=s.className;delete s.className;}
if(typeof s.style!='undefined'){$ss(HTMLIEle,s.style);delete s.style;}
for(var attr in s)$sa(HTMLIEle,attr,s[attr]);}
if(HTMLIEle.id=='')HTMLIEle.id=A5.u.getUniqueId();if(useContainer){var HTMLCEle=document.createElement('table');HTMLCEle.id=HTMLIEle.id+'.CONTAINER';HTMLCEle.cellPadding='0';HTMLCEle.cellSpacing='0';HTMLCEle.className=this.container.className;if(typeof this.container.style!='number')$ss(HTMLCEle,this.container.style);$ss(HTMLCEle,'display: inline-table; *display: inline;');HTMLCEle.insertRow(0);var cellIndx=0;HTMLCEle.rows[0].insertCell(cellIndx);HTMLIEle.className=this.container.editClassName;$ss(HTMLIEle,'width: 100%; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');HTMLCEle.rows[0].cells[cellIndx].appendChild(HTMLIEle);cellIndx++;if(this.container.separatorClassName!=''){HTMLCEle.rows[0].insertCell(cellIndx);HTMLCEle.rows[0].cells[cellIndx].innerHTML='&nbsp;';HTMLCEle.rows[0].cells[cellIndx].className=this.container.separatorClassName;cellIndx++;}
HTMLCEle.rows[0].insertCell(cellIndx);HTMLCEle.rows[0].cells[cellIndx].id=HTMLIEle.id+'.BUTTON';HTMLCEle.rows[0].cells[cellIndx].className=this.container.button.className;HTMLCEle.rows[0].cells[cellIndx].innerHTML=this.container.button.html;HTMLCEle.rows[0].cells[cellIndx].style.width='0%';document.documentElement.appendChild(HTMLCEle);this._bind(HTMLIEle);return HTMLCEle;}else{this._bind(HTMLIEle);return HTMLIEle;}},bind:function(ctrl){if(ctrl.constructor==Array){for(var i=0;i<ctrl.length;i++){if(ctrl[i].constructor==Array)this._bind(ctrl[i][0],ctrl[i][1]);else this._bind(ctrl[i]);}}else{this._bind(ctrl,arguments[1]);}},_bind:function(ele){var ele=$(ele);if($ga(ele,'A5ControlBound')=='true')return true;var eleId=ele.id!=''?ele.id:ele.name;var cEle=$(eleId+'.CONTAINER');if(cEle&&this.container.hoverClassName!=''){$e.add(cEle,'mouseover',Function('$acn(this,\''+this.container.hoverClassName+'\')'));$e.add(cEle,'mouseout',Function('$rcn(this,\''+this.container.hoverClassName+'\')'));}
var bEleId=typeof arguments[1]!='undefined'?arguments[1]:'';var bEle=false;if(bEleId==''){if($(eleId+'.BUTTON'))bEle=$(eleId+'.BUTTON');}else bEle=$(bEleId);if(bEle){$sa(bEle,'A5TargetInput',eleId);$e.add(bEle,'click',this._bOnClick,this);if(cEle&&this.container.button.hoverClassName){$e.add(bEle,'mouseover',Function('$acn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $acn(this,\''+this.container.button.hoverClassName+'\')'));$e.add(bEle,'mouseout',Function('$rcn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $rcn(this,\''+this.container.button.hoverClassName+'\')'));}}else $sa(ele,'A5HasButton','false');if(cEle&&this.container.button.hoverClassName){var bIndx=0;var cbEle=0;while($(eleId+'.CUSTOMBUTTON.'+bIndx)){cbEle=$(eleId+'.CUSTOMBUTTON.'+bIndx);$e.add(cbEle,'mousedown',Function('$acn(this,\''+this.container.button.pressedClassName+'\')'));$e.add(cbEle,'mouseover',Function('$acn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $acn(this,\''+this.container.button.hoverClassName+'\')'));$e.add(cbEle,'mouseout',Function('$rcn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $rcn(this,\''+this.container.button.hoverClassName+'\'); $rcn(this,\''+this.container.button.pressedClassName+'\')'));$e.add(cbEle,'mouseup',Function('$rcn(this,\''+this.container.button.pressedClassName+'\')'));bIndx+=1;}}
$e.add(ele,'focus',this._focus,this);$e.add(ele,'blur',this._blur,this);$e.add(ele,'keydown',this._keyDown,this);$e.add(ele,'keyup',this._keyUp,this,true);$e.add(ele,'keypress',this._keyPress,this);$e.add(ele,'mouseup',this._mUp,this);$e.add(ele,'a5listselection',this._listSelection,this);this._editBind(ele);$sa(ele,'A5ControlBound','true');},_focus:function(e,classInst){if(classInst._targetId!=this.id){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;}
classInst._targetId=this.id;classInst._listbox._targetId=classInst._targetId;classInst._listbox._window._targetId=classInst._targetId;classInst._initValue=$gvs(this);classInst._editFocus(e,this);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!='')$acn(cEle,classInst.container.focusClassName);},_blur:function(e,classInst){if(classInst.selectionRequired){var val=$gvs(this);if(val!=classInst._initValue&&val!='')$svs(this,classInst._initValue);}
classInst._editBlur(e,this);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!=''&&classInst._listbox._window.hidden)$rcn(cEle,classInst.container.focusClassName);},_mUp:function(e,classInst){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;if($ga(this,'A5HasButton')=='false'||classInst.selectionRequired){if(this.disabled)return false;if(classInst._targetId!=this.id){classInst._targetId=this.id;classInst._listbox._targetId=this.id;classInst._listbox._window._targetId=this.id;classInst._initValue=$gvs(this.id);}
setTimeout(function(){classInst._getFullList();},0);}},_bOnClick:function(e,classInst){$e.stopEvent(e);var tEleId=$ga(this,'A5TargetInput');var ele=$(tEleId);if(ele.disabled)return false;ele.focus();var sel=A5.edit.getSelection(ele);classInst._oldIPoint=sel.start;classInst._targetId=tEleId;classInst._listbox._targetId=tEleId;classInst._listbox._window._targetId=tEleId;classInst._initValue=$gvs(tEleId);setTimeout(function(){classInst._getFullList();},0);return false;},_keyDown:function(e,classInst){if(!classInst.selectionRequired&&classInst.selectionRequiredFilterMode!='progressive')classInst._editKeyDown(e,this);var keyCode=e.charCode||e.keyCode;if((keyCode==13||keyCode==9)&&!classInst._listbox._window.hidden){$e.stopEvent(e);classInst._listSelection(e,classInst);return false;}else if((keyCode==36||keyCode==35)&&!classInst._listbox._window.hidden&&classInst._listbox.value.length>0){$e.stopEvent(e);if(keyCode==36)classInst._listbox.navigate('home');else classInst._listbox.navigate('end');if(classInst._listbox.value.length!=0)classInst._oldIPoint=classInst.insertValue(classInst._listbox.value[0],false);else classInst._oldIPoint=classInst.insertValue(classInst._value,false);return false;}else if((keyCode==38||keyCode==40)){if(e.altKey){if(classInst._listbox._window.hidden)classInst._getFullList();else classInst._listbox._window.hide();}
$e.stopPropagation(e);$e.stopEvent(e);}},_keyUp:function(e){var keyCode=e.charCode||e.keyCode;var ignoreChr=[9,13,16,17,18,19,20,27,33,34,35,36,37,38,39,40,45,112,113,114,115,116,117,118,119,120,121,122,123];if(keyCode==38&&!this._listbox._window.hidden){this._listbox.navigate('prev');if(this._listbox.value.length!=0)this._oldIPoint=this.insertValue(this._listbox.value[0],false);else this._oldIPoint=this.insertValue(this._value,false);}else if(keyCode==40&&!this._listbox._window.hidden){this._listbox.navigate('next');if(this._listbox.value.length!=0)this._oldIPoint=this.insertValue(this._listbox.value[0],false);else this._oldIPoint=this.insertValue(this._value,false);}else if(keyCode==36||keyCode==35||keyCode==37||keyCode==39){var sel=A5.edit.getSelection($(this._targetId));this._oldIPoint=sel.start;}else if((keyCode==8||keyCode==46)&&this.selectionRequired){var ele=$(this._targetId);var data=this._editValSplit(ele,true);var offset=data.vals[data.selIndx].offset;var oldLen=data.vals.length;if(data.sel.length==0){if(keyCode==8&&data.sel.start!=0){if(data.vals.length-1==data.selIndx&&data.vals[data.selIndx].val==''){data.vals.splice(data.selIndx,1);if(data.selIndx>0)data.vals[data.selIndx-1].sep='';}else{if(data.vals[data.selIndx].offset==data.sel.start&&data.selIndx>0)data.selIndx--;else if(data.selIndx>0&&data.vals[data.selIndx].sep!=''&&!data.inSep){data.vals[data.selIndx-1].sep=data.vals[data.selIndx].sep;offset=data.vals[data.selIndx-1].offset+data.vals[data.selIndx-1].val.length;}else offset=data.vals[data.selIndx].offset;data.vals.splice(data.selIndx,1);}}else if(keyCode==46&&data.sel.start!=ele.value.length){if(data.inSep&&data.vals[data.selIndx].sep!=''){offset=offset+data.vals[data.selIndx].val.length;if(data.vals.length-1==data.selIndx)data.vals[data.selIndx].sep='';else{data.vals[data.selIndx].sep=data.vals[data.selIndx+1].sep;data.vals.splice(data.selIndx+1,1);}}else data.vals.splice(data.selIndx,1);}}else{for(var i=data.vals.length-1;i>=0;i--){if(data.vals[i].offset+data.vals[i].val.length>=data.sel.start&&data.vals[i].offset<=data.sel.end){offset=data.vals[i].offset;data.vals.splice(i,1);}}}
if(oldLen!=data.vals.length&&this._multi.auto.persist){if(this.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++){data.vals[i].sep=this.multiple.auto.separator.call(this,oldSeps);oldSeps.push(data.vals[i].sep);}}else{for(var i=0;i<data.vals.length-1;i++)data.vals[i].sep=this.multiple.auto.separator;}}
ele.value=this._editValJoin(data);this._initValue=ele.value;this._oldIPoint=offset;A5.edit.setSelection(ele,offset);}else if($u.a.find(ignoreChr,keyCode)==-1&&(!this.selectionRequired||this.selectionRequiredFilterMode=='progressive')){var ele=$(this._targetId);var data=this._editValSplit(ele,true);this._value=data.vals[data.selIndx].val;var curVal=this._value.toLowerCase();var curValLen=curVal.length;if(this._dynamicData.constructor==Function)this._data=this._dynamicData.call(this,this._targetId,true);var data=this._data;if(this.filter.constructor==Function)data=this.filter.call(this,data);var dArr=new Array();for(var i=0;i<data.length;i++){if(curVal==String(this._listbox.item.calculateValue(data[i])).substr(0,curValLen).toLowerCase()||data[i]['*title']||data[i]['*static']||data[i]=='-'){dArr[dArr.length]=data[i];}}
this._populateList(dArr);}},_keyPress:function(e,classInst){if(classInst.selectionRequired&&classInst.selectionRequiredFilterMode!='progressive'){var keyCode=0;if(typeof e.which=='number')keyCode=e.which;else if(typeof e.charCode=='number')keyCode=e.charCode;else keyCode=e.keyCode;if(keyCode!=9&&e.keyCode!=37&&e.keyCode!=39)$e.stopEvent(e);if(keyCode==8||keyCode==9||keyCode==13||keyCode==27)keyCode=0;if(keyCode!=0&&!e.ctrlKey&&!e.altKey){keyCode=String.fromCharCode(keyCode).toLowerCase();if(classInst._listbox._window.hidden)classInst._getFullList();var selIndx=-1;var startSearch=classInst._listbox.selection[0];if(typeof startSearch=='undefined')startSearch=-1;for(var i=startSearch+1;i<classInst._listbox._values.length;i++){if(keyCode==String(classInst._listbox._values[i]).substr(0,1).toLowerCase()){selIndx=i;break;}}
if(selIndx==-1){for(var i=0;i<=startSearch;i++){if(keyCode==String(classInst._listbox._values[i]).substr(0,1).toLowerCase()){selIndx=i;break;}}}
if(selIndx!=-1)classInst._oldIPoint=classInst.insertValue(classInst._listbox.item.calculateValue(classInst._data[selIndx]),false);else if(!classInst._multi.auto.persist){var data=classInst._editValSplit(this,true);var aVal=data.vals[data.selIndx];classInst._multi.keyBuffer+=keyCode;var sLen=classInst._multi.keyBuffer.length;var sMat=new Array();for(var i=0;i<classInst._multi.sep.length;i++)if(classInst._multi.sep[i].substr(0,sLen).toLowerCase()==classInst._multi.keyBuffer)sMat.push(i);if(sMat.length==1){var ele=$(classInst._targetId);aVal.sep=classInst._multi.sep[sMat[0]];if(classInst.format.showMask&&data.vals.length-1==data.selIndx)data.vals.push({val:classInst.format._pMask.blankValue,sep:'',offset:0});ele.value=classInst._editValJoin(data);classInst._initValue=ele.value;A5.edit.setSelection(ele,aVal.offset+aVal.val.length+aVal.sep.length);classInst._multi.keyBuffer='';}else if(sMat.length==0){classInst._multi.keyBuffer='';classInst._oldIPoint=classInst.insertValue('',false);}}else classInst._oldIPoint=classInst.insertValue('',false);classInst._listbox._selectItem(selIndx);}}else classInst._editKeyPress(e,this);},_listSelection:function(e,classInst){if(classInst._listbox.value.length!=0){var ele=$(classInst._targetId);A5.edit.setSelection(ele,classInst._oldIPoint);classInst._oldIPoint=classInst.insertValue(classInst._listbox.value[0],true);classInst._initValue=ele.value;if(classInst.onSelect.constructor==Function)classInst.onSelect.call(ele,classInst._listbox._data[classInst._listbox.selection[0]],classInst);}
classInst._listbox._window._makeSelection=true;classInst._listbox._window.hide();},_getFullList:function(){var ele=$(this._targetId);var data=this._editValSplit(ele,true);this._value=data.vals[data.selIndx].val;if(this._dynamicData.constructor==Function)this._data=this._dynamicData.call(this,this._targetId,false);var dArr=this._data;if(this.filter.constructor==Function)dArr=this.filter.call(this,dArr);this._populateList(dArr,true);},_populateList:function(dArr){var getFullList=typeof arguments[1]!='undefined'?arguments[1]:false;var cEle=$(this._targetId+'.CONTAINER');if(dArr.length>0){this._listbox.populate(dArr);var data=this._editValSplit($(this._targetId),true);this._listbox.setValue(data.vals[data.selIndx].val);if(!this._listbox._window.hidden)this._listbox._window.hide();this._listbox._window.show('dropdown',$if(cEle,cEle,this._targetId));}else if(getFullList){this._listbox.populate([]);if(!this._listbox._window.hidden)this._listbox._window.hide();this._listbox._window.show('dropdown',$if(cEle,cEle,this._targetId));}else{this._listbox._window.hide();}}});A5.EditTree=Class.create(A5.Edit,{initialize:function(data,settings){$u.o.assign(this,{tree:{theme:''},window:{theme:''},container:{className:'',hoverClassName:'',focusClassName:'',pressedClassName:'',style:0,editClassName:'',separatorClassName:'',button:{html:'',className:'',hoverClassName:'',pressedClassName:''}},selectionRequired:false,onSelect:0});if(typeof settings.theme!='undefined'){A5.themes.assign(this,settings.theme,'editButtonGroup');var tTheme=settings.theme.split(':').shift();if(this.window.theme=='')this.window.theme=tTheme+':dropdown';if(this.tree.theme=='')this.tree.theme=tTheme+':dropdown';}
$u.o.assign(this,settings);this.setData(data);$u.o.assign(this.window,{title:{show:false},body:{content:{type:'blank'},style:{padding:'0px',overflow:'auto'}},type:'popup',autoShow:false,autoPosition:false,_container:{focusClassName:this.container.focusClassName,pressedClassName:this.container.pressedClassName,button:{pressedClassName:this.container.button.pressedClassName}},onShow:function(){var cEle=$(this._targetId+'.CONTAINER');if(cEle){if(this._container.pressedClassName!='')$acn(cEle,this._container.pressedClassName);if(this._container.button.pressedClassName!='')$acn($(this._targetId+'.BUTTON'),this._container.button.pressedClassName);}},onHide:function(){var cEle=$(this._targetId+'.CONTAINER');if(cEle){if(this._container.focusClassName!=''&&!this._makeSelection)$rcn(cEle,this._container.focusClassName);if(this._container.pressedClassName!='')$rcn(cEle,this._container.pressedClassName);if(this._container.button.pressedClassName!='')$rcn($(this._targetId+'.BUTTON'),this._container.button.pressedClassName);}
this._makeSelection=false;}});$u.o.assign(this.tree,{loopNavigate:true,_onSelect:this.onSelect,onNodeClick:function(data){if(!data.children){var ele=$(this._targetId)
ele.focus();setTimeout(Function('$e.execute($(\''+this._targetId+'\'),\'a5treeselection\');'),1);}}});var win=new A5.Window(this.window);this._tree=new A5.Tree(win.getWindowId('body'),data,this.tree);this._tree._window=win;this._editPrepare();this._value='';this._oldIPoint=0;},setData:function(data){this._data=data;},create:function(s){var useContainer=typeof arguments[1]!='undefined'?arguments[1]:true;var HTMLIEle=document.createElement('input');if(typeof s=='object'){if(typeof s.className!='undefined'){HTMLIEle.className=s.className;delete s.className;}
if(typeof s.style!='undefined'){$ss(HTMLIEle,s.style);delete s.style;}
for(var attr in s)$sa(HTMLIEle,attr,s[attr]);}
if(HTMLIEle.id=='')HTMLIEle.id=A5.u.getUniqueId();if(useContainer){var HTMLCEle=document.createElement('table');HTMLCEle.id=HTMLIEle.id+'.CONTAINER';HTMLCEle.cellPadding='0';HTMLCEle.cellSpacing='0';HTMLCEle.className=this.container.className;if(typeof this.container.style!='number')$ss(HTMLCEle,this.container.style);$ss(HTMLCEle,'display: inline-table; *display: inline;');HTMLCEle.insertRow(0);var cellIndx=0;HTMLCEle.rows[0].insertCell(cellIndx);HTMLIEle.className=this.container.editClassName;$ss(HTMLIEle,'width: 100%; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');HTMLCEle.rows[0].cells[cellIndx].appendChild(HTMLIEle);cellIndx++;if(this.container.separatorClassName!=''){HTMLCEle.rows[0].insertCell(cellIndx);HTMLCEle.rows[0].cells[cellIndx].innerHTML='&nbsp;';HTMLCEle.rows[0].cells[cellIndx].className=this.container.separatorClassName;cellIndx++;}
HTMLCEle.rows[0].insertCell(cellIndx);HTMLCEle.rows[0].cells[cellIndx].id=HTMLIEle.id+'.BUTTON';HTMLCEle.rows[0].cells[cellIndx].className=this.container.button.className;HTMLCEle.rows[0].cells[cellIndx].innerHTML=this.container.button.html;HTMLCEle.rows[0].cells[cellIndx].style.width='0%';document.documentElement.appendChild(HTMLCEle);this._bind(HTMLIEle);return HTMLCEle;}else{this._bind(HTMLIEle);return HTMLIEle;}},bind:function(ctrl){if(ctrl.constructor==Array){for(var i=0;i<ctrl.length;i++){if(ctrl[i].constructor==Array)this._bind(ctrl[i][0],ctrl[i][1]);else this._bind(ctrl[i]);}}else{this._bind(ctrl,arguments[1]);}},_bind:function(ele){var ele=$(ele);if($ga(ele,'A5ControlBound')=='true')return true;var eleId=ele.id!=''?ele.id:ele.name;var cEle=$(eleId+'.CONTAINER');if(cEle&&this.container.hoverClassName!=''){$e.add(cEle,'mouseover',Function('$acn(this,\''+this.container.hoverClassName+'\')'));$e.add(cEle,'mouseout',Function('$rcn(this,\''+this.container.hoverClassName+'\')'));}
var bEleId=typeof arguments[1]!='undefined'?arguments[1]:'';var bEle=false;if(bEleId==''){if($(eleId+'.BUTTON'))bEle=$(eleId+'.BUTTON');}else bEle=$(bEleId);if(bEle){$sa(bEle,'A5TargetInput',eleId);$e.add(bEle,'click',this._bOnClick,this);if(cEle&&this.container.button.hoverClassName){$e.add(bEle,'mouseover',Function('$acn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $acn(this,\''+this.container.button.hoverClassName+'\')'));$e.add(bEle,'mouseout',Function('$rcn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $rcn(this,\''+this.container.button.hoverClassName+'\')'));}}else $sa(ele,'A5HasButton','false');if(cEle&&this.container.button.hoverClassName){var bIndx=0;var cbEle=0;while($(eleId+'.CUSTOMBUTTON.'+bIndx)){cbEle=$(eleId+'.CUSTOMBUTTON.'+bIndx);$e.add(cbEle,'mousedown',Function('$acn(this,\''+this.container.button.pressedClassName+'\')'));$e.add(cbEle,'mouseover',Function('$acn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $acn(this,\''+this.container.button.hoverClassName+'\')'));$e.add(cbEle,'mouseout',Function('$rcn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $rcn(this,\''+this.container.button.hoverClassName+'\'); $rcn(this,\''+this.container.button.pressedClassName+'\')'));$e.add(cbEle,'mouseup',Function('$rcn(this,\''+this.container.button.pressedClassName+'\')'));bIndx+=1;}}
$e.add(ele,'focus',this._focus,this);$e.add(ele,'blur',this._blur,this);$e.add(ele,'keydown',this._keyDown,this);$e.add(ele,'keyup',this._keyUp,this,true);$e.add(ele,'keypress',this._keyPress,this);$e.add(ele,'mouseup',this._mUp,this);$e.add(ele,'a5treeselection',this._treeSelection,this);this._editBind(ele);$sa(ele,'A5ControlBound','true');},_focus:function(e,classInst){if(classInst._targetId!=this.id){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;}
classInst._targetId=this.id;classInst._tree._targetId=classInst._targetId;classInst._tree._window._targetId=classInst._targetId;classInst._initValue=$gvs(this);classInst._editFocus(e,this);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!='')$acn(cEle,classInst.container.focusClassName);},_blur:function(e,classInst){if(classInst.selectionRequired){var val=$gvs(this);if(val!=classInst._initValue&&val!='')$svs(this,classInst._initValue);}
classInst._editBlur(e,this);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!=''&&classInst._tree._window.hidden)$rcn(cEle,classInst.container.focusClassName);},_mUp:function(e,classInst){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;if($ga(this,'A5HasButton')=='false'||classInst.selectionRequired){if(this.disabled)return false;if(classInst._targetId!=this.id){classInst._targetId=this.id;classInst._tree._targetId=this.id;classInst._tree._window._targetId=this.id;classInst._initValue=$gvs(this.id);}
setTimeout(function(){classInst._treeShow();},0);}},_bOnClick:function(e,classInst){$e.stopEvent(e);var tEleId=$ga(this,'A5TargetInput');var ele=$(tEleId);if(ele.disabled)return false;ele.focus();var sel=A5.edit.getSelection(ele);classInst._oldIPoint=sel.start;classInst._targetId=tEleId;classInst._tree._targetId=tEleId;classInst._tree._window._targetId=tEleId;classInst._initValue=$gvs(ele);setTimeout(function(){classInst._treeShow();},0);return false;},_keyDown:function(e,classInst){classInst._editKeyDown(e,this);var keyCode=e.charCode||e.keyCode;if((keyCode==13||keyCode==9)&&!classInst._tree._window.hidden){$e.stopEvent(e);classInst._tree.navigate('enter');return false;}else if((keyCode==36||keyCode==35||keyCode==37||keyCode==39)&&!classInst._tree._window.hidden&&classInst._tree.value.length>0){$e.stopEvent(e);if(keyCode==36)classInst._tree.navigate('home');else if(keyCode==35)classInst._tree.navigate('end');else if(keyCode==37)classInst._tree.navigate('out');else if(keyCode==39)classInst._tree.navigate('in');if(classInst._tree.value.length!=0)$svs(classInst._targetId,classInst._tree.value[0]);else $svs(classInst._targetId,classInst._value);return false;}else if((keyCode==38||keyCode==40)){if(e.altKey){if(classInst._tree._window.hidden)classInst._treeShow();else classInst._tree._window.hide();}else if(!classInst._tree._window.hidden){if(keyCode==38)classInst._tree.navigate('prev');else classInst._tree.navigate('next');if(classInst._tree.value.length!=0)classInst._oldIPoint=classInst.insertValue(classInst._tree.value[0],false);else classInst._oldIPoint=classInst.insertValue(classInst._value,false);}
$e.stopPropagation(e);$e.stopEvent(e);}},_keyUp:function(e){var keyCode=e.charCode||e.keyCode;if(keyCode==36||keyCode==35||keyCode==37||keyCode==39){var sel=A5.edit.getSelection($(this._targetId));this._oldIPoint=sel.start;}else if((keyCode==8||keyCode==46)&&this.selectionRequired){var ele=$(this._targetId);var data=this._editValSplit(ele,true);var offset=data.vals[data.selIndx].offset;var oldLen=data.vals.length;if(data.sel.length==0){if(keyCode==8&&data.sel.start!=0){if(data.vals.length-1==data.selIndx&&data.vals[data.selIndx].val==''){data.vals.splice(data.selIndx,1);if(data.selIndx>0)data.vals[data.selIndx-1].sep='';}else{if(data.vals[data.selIndx].offset==data.sel.start&&data.selIndx>0)data.selIndx--;else if(data.selIndx>0&&data.vals[data.selIndx].sep!=''&&!data.inSep){data.vals[data.selIndx-1].sep=data.vals[data.selIndx].sep;offset=data.vals[data.selIndx-1].offset+data.vals[data.selIndx-1].val.length;}else offset=data.vals[data.selIndx].offset;data.vals.splice(data.selIndx,1);}}else if(keyCode==46&&data.sel.start!=ele.value.length){if(data.inSep&&data.vals[data.selIndx].sep!=''){offset=offset+data.vals[data.selIndx].val.length;if(data.vals.length-1==data.selIndx)data.vals[data.selIndx].sep='';else{data.vals[data.selIndx].sep=data.vals[data.selIndx+1].sep;data.vals.splice(data.selIndx+1,1);}}else data.vals.splice(data.selIndx,1);}}else{for(var i=data.vals.length-1;i>=0;i--){if(data.vals[i].offset+data.vals[i].val.length>=data.sel.start&&data.vals[i].offset<=data.sel.end){offset=data.vals[i].offset;data.vals.splice(i,1);}}}
if(oldLen!=data.vals.length&&this._multi.auto.persist){if(this.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++){data.vals[i].sep=this.multiple.auto.separator.call(this,oldSeps);oldSeps.push(data.vals[i].sep);}}else{for(var i=0;i<data.vals.length-1;i++)data.vals[i].sep=this.multiple.auto.separator;}}
ele.value=this._editValJoin(data);this._initValue=ele.value;this._oldIPoint=offset;A5.edit.setSelection(ele,offset);}},_keyPress:function(e,classInst){if(classInst.selectionRequired){var keyCode=0;if(typeof e.which=='number')keyCode=e.which;else if(typeof e.charCode=='number')keyCode=e.charCode;else keyCode=e.keyCode;if(keyCode!=9&&e.keyCode!=37&&e.keyCode!=39)$e.stopEvent(e);if(keyCode==8||keyCode==9||keyCode==13||keyCode==27)keyCode=0;if(keyCode!=0&&!e.ctrlKey&&!e.altKey){keyCode=String.fromCharCode(keyCode).toLowerCase();var data=classInst._editValSplit(this,true);var aVal=data.vals[data.selIndx];if(aVal.val!=''){if(!classInst._multi.auto.persist){classInst._multi.keyBuffer+=keyCode;var sLen=classInst._multi.keyBuffer.length;var sMat=new Array();for(var i=0;i<classInst._multi.sep.length;i++)if(classInst._multi.sep[i].substr(0,sLen).toLowerCase()==classInst._multi.keyBuffer)sMat.push(i);if(sMat.length==1){aVal.sep=classInst._multi.sep[sMat[0]];if(classInst.format.showMask&&data.vals.length-1==data.selIndx)data.vals.push({val:classInst.format._pMask.blankValue,sep:'',offset:0});this.value=classInst._editValJoin(data);classInst._initValue=this.value;A5.edit.setSelection(this,aVal.offset+aVal.val.length+aVal.sep.length);classInst._multi.keyBuffer='';}else if(sMat.length==0)classInst._multi.keyBuffer='';}else if(data.selIndx==data.vals.length-1&&aVal.sep==''){classInst._oldIPoint=classInst.insertValue(aVal.val,true);classInst._initValue=this.value;}}}}else classInst._editKeyPress(e,this);},_treeShow:function(){if(!this._tree._window.hidden)this._tree._window.hide();var data=this._editValSplit($(this._targetId),true);this._tree.setValue(data.vals[data.selIndx].val);var cEle=$(this._targetId+'.CONTAINER');this._tree._window.show('dropdown',$if(cEle,cEle,this._targetId));},_treeSelection:function(e,classInst){if(classInst._tree.value.length!=0){var ele=$(classInst._targetId);A5.edit.setSelection(ele,classInst._oldIPoint);classInst._oldIPoint=classInst.insertValue(classInst._tree.value[0],true);classInst._initValue=ele.value;}
classInst._tree._window._makeSelection=true;classInst._tree._window.hide();}});A5.Button=Class.create();A5.Button.prototype={initialize:function(settings){$u.o.assign(this,{style:0,className:'',hoverClassName:'',pressedClassName:'',disabledClassName:'',iconStyle:0,iconClassName:'',html:'',icon:'',hoverIcon:'',pressedIcon:'',disabledIcon:'',layout:'icon text',tip:'',animation:{show:{type:'',duration:500},hide:{type:'',duration:500}},onClick:0,watches:[],_hasIcon:false});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'button');$u.o.assign(this,settings);if(this.icon!=''&&this.layout.search('icon')!=-1)this._hasIcon=true;this._buttonIds=new Array();},create:function(s){var HTMLBEle=document.createElement('button');if(typeof s=='object'){if(typeof s.className!='undefined'){HTMLBEle.className=s.className;delete s.className;}
if(typeof s.style!='undefined'){$ss(HTMLBEle,s.style);delete s.style;}
for(var attr in s)$sa(HTMLBEle,attr,s[attr]);}
if(HTMLBEle.id=='')HTMLBEle.id=A5.u.getUniqueId();this._bind(HTMLBEle);return HTMLBEle;},bind:function(ctrl){if(ctrl.constructor==Array){for(var i=0;i<ctrl.length;i++)this._bind($(ctrl[i]));}else this._bind($(ctrl));},_bind:function(ele){if($ga(ele,'A5ControlBound')=='true')return true;if(ele.length){for(var i=0;i<ele.length;i++){if(ele[i].id=='')ele[i].id=ele[i].name+'.'+i;this._bind(ele[i]);}
return false;}
if(this.className!='')$acn(ele,this.className);if(typeof this.style=='object'||typeof this.style=='string')$ss(ele,this.style);$e.remove(ele,'mouseover',this._mOver);$e.remove(ele,'mouseout',this._mOut);$e.remove(ele,'mousedown',this._mDown);$e.remove(ele,'mouseup',this._mUp);$e.remove(ele,'click',this._mClick);$e.add(ele,'mouseover',this._mOver,this);$e.add(ele,'mouseout',this._mOut,this);$e.add(ele,'mousedown',this._mDown,this);$e.add(ele,'mouseup',this._mUp,this);$e.add(ele,'click',this._mClick,this);this._setContent(ele);this._buttonIds.push(ele.id);if(this.watches.length>0){var wName=ele.id!=''?ele.id:ele.name;for(var i=0;i<this.watches.length;i++){if(typeof this.watches[i].onChange!='undefined'){var wData=new Object();var wTarg=new Array();if(typeof this.watches[i].data!='undefined'){if(this.watches[i].data.constructor==Function)wData=this.watches[i].data.call(ele);else if(typeof this.watches[i].data=='object')$u.o.assign(wData,this.watches[i].data);}
if(typeof this.watches[i].watch!='undefined'){if(this.watches[i].watch.constructor==Function)wTarg=this.watches[i].watch.call(ele,wData);else if(typeof this.watches[i].watch=='object')$u.o.assign(wData,this.watches[i].watch);}
A5.Watch.add(wName,wTarg,{data:wData,onChange:this.watches[i].onChange});}}}
$sa(ele,'A5ControlBound','true');},setDisabled:function(val){var eles=this._getButtons(arguments[1]);if(eles){if(val){for(var i=0;i<eles.length;i++){eles[i].disabled=true;if(this._hasIcon&&this.disabledIcon!='')$(eles[i].id+'.ICON').src=this.disabledIcon;}
if(this.disabledClassName!='')$acn(eles,this.disabledClassName);}else{for(var i=0;i<eles.length;i++){eles[i].disabled=false;if(this._hasIcon)$(eles[i].id+'.ICON').src=this.icon;}
if(this.disabledClassName!='')$rcn(eles,this.disabledClassName);}}},setDisplay:function(val){var eles=this._getButtons(arguments[1]);if(eles){if(val){for(var i=0;i<eles.length;i++)A5.u.element.show(eles[i],this.animation.show);}else{for(var i=0;i<eles.length;i++)A5.u.element.hide(eles[i],this.animation.hide);}}},refresh:function(){var eles=this._getButtons(arguments[0]);if(eles){for(var i=0;i<eles.length;i++)this._setContent(eles[i]);}},_setContent:function(ele){var bc=typeof arguments[1]!='undefined'?arguments[1]:{hasIcon:this._hasIcon,html:this.html,tip:this.tip,icon:this.icon,hoverIcon:this.hoverIcon,pressedIcon:this.pressedIcon,disabledIcon:this.disabledIcon};if(bc.icon!=''&&this.layout.search('icon')!=-1)bc.hasIcon=true;var iHTML=bc.hasIcon?'<img id="'+ele.id+'.ICON" src="'+bc.icon+'" class="'+this.iconClassName+'" style="vertical-align: middle; border: none;" />':'';var fHTML='';if(this.layout=='icon')fHTML=iHTML;else if(this.layout=='text')fHTML=bc.html;else if(this.layout=='icon text')fHTML=iHTML+' '+bc.html;else if(this.layout=='text icon')fHTML=bc.html+' '+iHTML;else if(this.layout=='icon/text')fHTML=iHTML+'<br />'+bc.html;else if(this.layout=='text/icon')fHTML=bc.html+'<br />'+iHTML;ele.innerHTML=fHTML;ele.title=bc.tip;var iEle=$(ele.id+'.ICON');if(typeof this.iconStyle=='object'||typeof this.iconStyle=='string')$ss(iEle,this.iconStyle);},_getButtons:function(eles){var elesR=new Array();var ele=0;if(typeof eles=='undefined'){for(var i=0;i<this._buttonIds.length;i++){ele=$(this._buttonIds[i])
if(ele)elesR.push(ele);}}else{if(eles.constructor==Array){for(var i=0;i<eles.length;i++){ele=$(eles[i])
if(ele)elesR.push(ele);}}else{if($(eles))elesR.push($(eles));}}
if(elesR.length==0)return false;else return elesR;},_mOver:function(e,classInst){if(!this.disabled){if(classInst.hoverClassName!='')$acn(this,classInst.hoverClassName);if(classInst._hasIcon&&classInst.hoverIcon!='')$(this.id+'.ICON').src=classInst.hoverIcon;}},_mOut:function(e,classInst){if(classInst.hoverClassName!='')$rcn(this,classInst.hoverClassName);if(classInst.pressedClassName!='')$rcn(this,classInst.pressedClassName);if(classInst._hasIcon){if(!this.disabled||this.disabledIcon=='')$(this.id+'.ICON').src=classInst.icon;else $(this.id+'.ICON').src=classInst.disabledIcon;}},_mDown:function(e,classInst){if(!this.disabled){if(classInst.pressedClassName!='')$acn(this,classInst.pressedClassName);if(classInst._hasIcon&&classInst.pressedIcon!='')$(this.id+'.ICON').src=classInst.pressedIcon;}},_mUp:function(e,classInst){if(classInst.pressedClassName!='')$rcn(this,classInst.pressedClassName);if(this.disabled&&this.disabledIcon!='')$(this.id+'.ICON').src=classInst.disabledIcon;else if(classInst._hasIcon&&classInst.hoverIcon!='')$(this.id+'.ICON').src=classInst.hoverIcon;else if(classInst._hasIcon)$(this.id+'.ICON').src=classInst.icon;},_mClick:function(e,classInst){if(!this.disabled){if(classInst.onClick.constructor==Function)classInst.onClick.call(this,classInst);}}}
A5.ButtonToggle=Class.create(A5.Button,{initialize:function(settings){this._states=0;if(typeof arguments[1]!='undefined')this._states=arguments[1];$u.o.assign(this,{type:'two-state',style:0,className:'',hoverClassName:'',pressedClassName:'',disabledClassName:'',iconStyle:0,iconClassName:'',html:'',icon:'',hoverIcon:'',pressedIcon:'',disabledIcon:'',layout:'icon text',tip:'',onClick:0,watches:[],_hasIcon:false});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'button');$u.o.assign(this,settings);if(this.icon!=''&&this.layout.search('icon')!=-1)this._hasIcon=true;this._buttonIds=new Array();},setValue:function(val){var eles=this._getButtons(arguments[1]);if(eles){if(this.type=='multi-state'&&typeof val=='number'){this._states[val]
for(var i=0;i<eles.length;i++)this._setContent(eles[i],this._states[val]);$sa(eles,'A5ButtonState',''+val);}else{if(val){if(this.pressedClassName!='')$acn(eles,this.pressedClassName);$sa(eles,'A5ButtonState','true');}else{if(this.pressedClassName!='')$rcn(eles,this.pressedClassName);$sa(eles,'A5ButtonState','false');}}}},getValue:function(){var eles=this._getButtons(arguments[0]);if(eles){if(this.type=='multi-state'){if(eles.length==1)return Number($ga(eles[0],'A5ButtonState'));else{var val=[];for(var i=0;i<eles.length;i++)val.push(Number($ga(eles[i],'A5ButtonState')));}
return val;}else{if(eles.length==1)return $u.s.toBool($ga(eles[0],'A5ButtonState'));else{var val=[];for(var i=0;i<eles.length;i++)val.push($u.s.toBool($ga(eles[i],'A5ButtonState')));}
return val;}}
if(this.type=='multi-state')return-1;else return false;},_mOver:function(e,classInst){if(!this.disabled){if(classInst.hoverClassName!='')$acn(this,classInst.hoverClassName);if(classInst._hasIcon&&classInst.hoverIcon!=''&&$ga(this,'A5ButtonState')!='true')$(this.id+'.ICON').src=classInst.hoverIcon;}},_mOut:function(e,classInst){if(classInst.hoverClassName!='')$rcn(this,classInst.hoverClassName);if($ga(this,'A5ButtonState')!='true'){if(classInst.pressedClassName!='')$rcn(this,classInst.pressedClassName);if(classInst._hasIcon){if(!this.disabled||this.disabledIcon=='')$(this.id+'.ICON').src=classInst.icon;else $(this.id+'.ICON').src=classInst.disabledIcon;}}},_mUp:function(e,classInst){if($ga(this,'A5ButtonState')=='true'||classInst.type=='multi-state'){if(classInst.pressedClassName!='')$rcn(this,classInst.pressedClassName);if(this.disabled&&classInst.disabledIcon!='')$(this.id+'.ICON').src=classInst.disabledIcon;else if(classInst._hasIcon&&classInst.hoverIcon!='')$(this.id+'.ICON').src=classInst.hoverIcon;else if(classInst._hasIcon)$(this.id+'.ICON').src=classInst.icon;}},_mClick:function(e,classInst){if(!this.disabled){if(classInst.type=='multi-state'){var state=$ga(this,'A5ButtonState');if(typeof state=='string')state=Number(state);else state=0;if(state+1<classInst._states.length)state++;else state=0;classInst._setContent(this,classInst._states[state]);$sa(this,'A5ButtonState',''+state);}else{var state=true;if($ga(this,'A5ButtonState')!='true'){if(classInst.pressedClassName!='')$acn(this,classInst.pressedClassName);$sa(this,'A5ButtonState','true');}else{if(classInst.pressedClassName!='')$rcn(this,classInst.pressedClassName);$sa(this,'A5ButtonState','false');state=false;}}
if(classInst.onClick.constructor==Function)classInst.onClick.call(this,classInst,state);}}});A5.ButtonDropdown=Class.create(A5.Button,{initialize:function(settings){this._control=0;if(typeof arguments[1]!='undefined')this._control=arguments[1];$u.o.assign(this,{type:'',style:0,className:'',hoverClassName:'',pressedClassName:'',disabledClassName:'',contentClassName:'',iconStyle:0,iconClassName:'',html:'',icon:'',hoverIcon:'',pressedIcon:'',disabledIcon:'',layout:'icon text',dropdown:{location:'right',className:'',hoverClassName:'',html:'',icon:''},tip:'',defaultValue:'',onClick:0,watches:[],_hasIcon:false});if(typeof settings.type=='string'){if(settings.type!='split')settings.type='dropdown';}else settings.type='dropdown'
if(typeof settings.theme!='undefined'){if(settings.type=='split')A5.themes.assign(this,settings.theme,'buttonSplit');else A5.themes.assign(this,settings.theme,'buttonDropdown');}
$u.o.assign(this,settings);if(this.icon!=''&&this.layout.search('icon')!=-1)this._hasIcon=true;if(typeof this._control=='object'||typeof this._control=='function'){if(typeof this._control.onHide=='function'){this._control._onHide=this._control.onHide;this._control.onHide=Function('$sa(this._targetId,\'A5ButtonState\',\'false\'); $e.execute(this._targetId,\'mouseup\'); this._onHide();');}else this._control.onHide=Function('$sa(this._targetId,\'A5ButtonState\',\'false\'); $e.execute(this._targetId,\'mouseup\');');}
this._buttonIds=[];this._buttonContent={};},refresh:function(){var eles=this._getButtons(arguments[0]);if(eles){for(var i=0;i<eles.length;i++){if(typeof this._buttonContent[eles[i].id]!='undefined')this._setContent(eles[i],this._buttonContent[eles[i].id]);else this._setContent(eles[i]);}}},setState:function(ele,val){ele=$(ele);if(val){$sa(ele,'A5ButtonState','true');if(this.pressedClassName!='')$acn(ele,this.pressedClassName);if(this._hasIcon&&this.pressedIcon!='')$(ele.id+'.ICON').src=this.pressedIcon;}else{$sa(ele,'A5ButtonState','false');if(this.pressedClassName!='')$rcn(ele,this.pressedClassName);if(this.disabled&&this.disabledIcon!='')$(ele.id+'.ICON').src=this.disabledIcon;else if(this._hasIcon&&this.hoverIcon!=''&&$ga(ele,'A5ButtonMOver')=='true')$(ele.id+'.ICON').src=this.hoverIcon;else if(this._hasIcon)$(ele.id+'.ICON').src=this.icon;}},setContent:function(content){var eles=this._getButtons(arguments[1]);if(eles){var tempData={hasIcon:this._hasIcon,html:this.html,tip:this.tip,icon:this.icon,hoverIcon:this.hoverIcon,pressedIcon:this.pressedIcon,disabledIcon:this.disabledIcon};if(typeof content=='object')$u.o.assign(content,tempData,true);for(var i=0;i<eles.length;i++){if(typeof content=='object'){this._setContent(eles[i],content);this._buttonContent[eles[i].id]=content;}else{this._setContent(eles[i]);delete this._buttonContent[eles[i].id];}}}},clearContent:function(){this._buttonContent={}
this.refresh();},_bind:function(ele){if($ga(ele,'A5ControlBound')=='true')return true;if(ele.length){for(var i=0;i<ele.length;i++){if(ele[i].id=='')ele[i].id=ele[i].name+'.'+i;this._bind(ele[i]);}
return false;}
if(this.className!='')$acn(ele,this.className);if(typeof this.style=='object'||typeof this.style=='string')$ss(ele,this.style);$e.remove(ele,'mouseover',this._mOver);$e.remove(ele,'mouseout',this._mOut);$e.remove(ele,'mousemove',this._mMove);$e.remove(ele,'mousedown',this._mDown);$e.remove(ele,'mouseup',this._mUp);$e.remove(ele,'click',this._mClick);$e.add(ele,'mouseover',this._mOver,this);$e.add(ele,'mouseout',this._mOut,this);$e.add(ele,'mousemove',this._mMove,this);$e.add(ele,'mousedown',this._mDown,this);$e.add(ele,'mouseup',this._mUp,this);$e.add(ele,'click',this._mClick,this);this._setContentInit(ele);this._buttonIds.push(ele.id);if(this.watches.length>0){var wName=ele.id!=''?ele.id:ele.name;for(var i=0;i<this.watches.length;i++){if(typeof this.watches[i].onChange!='undefined'){var wData=new Object();var wTarg=new Array();if(typeof this.watches[i].data!='undefined'){if(this.watches[i].data.constructor==Function)wData=this.watches[i].data.call(ele);else if(typeof this.watches[i].data=='object')$u.o.assign(wData,this.watches[i].data);}
if(typeof this.watches[i].watch!='undefined'){if(this.watches[i].watch.constructor==Function)wTarg=this.watches[i].watch.call(ele,wData);else if(typeof this.watches[i].watch=='object')$u.o.assign(wData,this.watches[i].watch);}
A5.Watch.add(wName,wTarg,{data:wData,onChange:this.watches[i].onChange});}}}
$sa(ele,'A5ControlBound','true');},_setContentInit:function(ele){if(this.dropdown.location=='bottom')ele.innerHTML='<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;"><tr><td id="'+ele.id+'.CONTENT" class="'+this.contentClassName+'" style="white-space: nowrap;"></td></tr><tr><td id="'+ele.id+'.SPLIT" class="'+this.dropdown.className+'"><span style="white-space: nowrap;"></span></td></tr></table>';else ele.innerHTML='<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;"><tr><td id="'+ele.id+'.CONTENT" class="'+this.contentClassName+'" style="white-space: nowrap;"></td><td id="'+ele.id+'.SPLIT" class="'+this.dropdown.className+'"><span style="white-space: nowrap;"></span></td></tr></table>';$ss(ele,$gs(ele)+'; overflow: visible; -webkit-appearance: none; -webkit-box-sizing: content-box; -webkit-box-align: start; -webkit-border-fit: lines; -webkit-margin-collapse: discard;');this._setContent(ele);},_setContent:function(ele){var bc=typeof arguments[1]!='undefined'?arguments[1]:{hasIcon:this._hasIcon,html:this.html,tip:this.tip,icon:this.icon,hoverIcon:this.hoverIcon,pressedIcon:this.pressedIcon,disabledIcon:this.disabledIcon};if(bc.icon!=''&&this.layout.search('icon')!=-1)bc.hasIcon=true;var iHTML=bc.hasIcon?'<img id="'+ele.id+'.ICON" src="'+bc.icon+'" class="'+this.iconClassName+'" style="vertical-align: middle; border: none;" />':'';var fHTML='';var eles=ele.getElementsByTagName('td');var cEle=0;var sEle=0;for(var i=0;i<eles.length;i++){if(eles[i].id==ele.id+'.CONTENT')cEle=eles[i];else if(eles[i].id==ele.id+'.SPLIT')sEle=eles[i];}
if(this.layout=='icon')fHTML=iHTML;else if(this.layout=='text')fHTML=bc.html;else if(this.layout=='icon text')fHTML=iHTML+' '+bc.html;else if(this.layout=='text icon')fHTML=bc.html+' '+iHTML;else if(this.layout=='icon/text')fHTML=iHTML+'<br />'+bc.html;else if(this.layout=='text/icon')fHTML=bc.html+'<br />'+iHTML;cEle.innerHTML=fHTML;ele.title=bc.tip;fHTML='';if(this.dropdown.html!='')fHTML=this.dropdown.html;if(fHTML!=''&&this.dropdown.location=='bottom')fHTML=fHTML+'<br />';if(this.dropdown.icon!='')fHTML=fHTML+'<img src="'+this.dropdown.icon+'" />';sEle.firstChild.innerHTML=fHTML;if(ele.style.height!='')ele.firstChild.style.height=(ele.offsetHeight-2)+'px';if(ele.style.height!=''&&this.dropdown.location=='bottom')sEle.style.height=sEle.firstChild.offsetHeight+'px';else if(ele.style.width!=''&&this.dropdown.location!='bottom')sEle.style.width=sEle.firstChild.offsetWidth+'px';var iEle=$(ele.id+'.ICON');if(typeof this.iconStyle=='object'||typeof this.iconStyle=='string')$ss(iEle,this.iconStyle);},_parseValues:function(){this._data=[];var tempData={hasIcon:this.hasIcon,html:this.html,tip:this.tip,icon:this.icon,hoverIcon:this.hoverIcon,pressedIcon:this.pressedIcon,disabledIcon:this.disabledIcon};this._data.push(tempData);this._data[0].value='';if(this.data.constructor==Array){for(var i=0;i<this.data.length;i++){if(typeof this.data[i]=='object'){this._data.push(this.data[i]);if(typeof this._data[i+1].value=='undefined'&&typeof this._data[i+1].html!='undefined')this._data[i+1].value=this._data[i+1].html;}else this._data.push({html:''+this.data[i],value:''+this.data[i]});$u.o.assign(this._data[i+1],tempData,true);if(this._data[i+1].icon!=''&&this.layout.search('icon')!=-1)this._data[i+1]._hasIcon=true;}}},_mOver:function(e,classInst){$sa(this,'A5ButtonMOver','true');if(!this.disabled){if(classInst.hoverClassName!='')$acn(this,classInst.hoverClassName);if(classInst._hasIcon&&classInst.hoverIcon!=''&&$ga(this,'A5ButtonState')!='true')$(this.id+'.ICON').src=classInst.hoverIcon;if(classInst.type=='split'&&classInst.dropdown.hoverClassName!=''){var sEle=$(this.id+'.SPLIT');classInst._sl=$gpl(sEle);classInst._st=$gpt(sEle);}}},_mOut:function(e,classInst){$sa(this,'A5ButtonMOver','false');if(classInst.hoverClassName!='')$rcn(this,classInst.hoverClassName);if(classInst.dropdown.hoverClassName!='')$rcn($(this.id+'.SPLIT'),classInst.dropdown.hoverClassName);if($ga(this,'A5ButtonState')!='true'){if(classInst.pressedClassName!='')$rcn(this,classInst.pressedClassName);if(classInst._hasIcon){if(!this.disabled||this.disabledIcon=='')$(this.id+'.ICON').src=classInst.icon;else $(this.id+'.ICON').src=classInst.disabledIcon;}}},_mMove:function(e,classInst){if(!this.disabled&&classInst.type=='split'&&classInst.dropdown.hoverClassName!=''){if(e.pageX===undefined){var pageX=e.clientX+document.documentElement.scrollLeft;var pageY=e.clientY+document.documentElement.scrollTop;}else{var pageX=e.pageX;var pageY=e.pageY;}
var sEle=$(this.id+'.SPLIT');if((pageX>=classInst._sl&&pageX<=classInst._sl+sEle.offsetWidth)&&(pageY>=classInst._st&&pageY<=classInst._st+sEle.offsetHeight))$acn(sEle,classInst.dropdown.hoverClassName);else $rcn(sEle,classInst.dropdown.hoverClassName);}},_mDown:function(e,classInst){if(!this.disabled){if(classInst.pressedClassName!='')$acn(this,classInst.pressedClassName);if(classInst._hasIcon&&classInst.pressedIcon!='')$(this.id+'.ICON').src=classInst.pressedIcon;}},_mUp:function(e,classInst){if($ga(this,'A5ButtonState')!='true'){if(classInst.pressedClassName!='')$rcn(this,classInst.pressedClassName);if(this.disabled&&this.disabledIcon!='')$(this.id+'.ICON').src=classInst.disabledIcon;else if(classInst._hasIcon&&classInst.hoverIcon!=''&&$ga(this,'A5ButtonMOver')=='true')$(this.id+'.ICON').src=classInst.hoverIcon;else if(classInst._hasIcon)$(this.id+'.ICON').src=classInst.icon;}},_mClick:function(e,classInst){if(!this.disabled){var clickType='normal';var showDD=false;if(classInst.type=='split'){if(e.pageX===undefined){var pageX=e.clientX+document.documentElement.scrollLeft;var pageY=e.clientY+document.documentElement.scrollTop;}else{var pageX=e.pageX;var pageY=e.pageY;}
var sEle=$(this.id+'.SPLIT');var cl=$gpl(sEle);var ct=$gpt(sEle);if((pageX>=cl&&pageX<=cl+sEle.offsetWidth)&&(pageY>=ct&&pageY<=ct+sEle.offsetHeight))clickType='split';if(clickType=='split'&&(typeof classInst._control=='object'||typeof classInst._control=='function'))showDD=true;}else if(typeof classInst._control=='object'||typeof classInst._control=='function')showDD=true;if(showDD){classInst._control._targetId=this.id;if(classInst._control.show)classInst._control.show('dropdown',this);if(classInst.pressedClassName!='')$acn(this,classInst.pressedClassName);if(classInst._hasIcon&&classInst.pressedIcon!='')$(this.id+'.ICON').src=classInst.pressedIcon;$sa(this,'A5ButtonState','true');}
if(classInst.onClick.constructor==Function){classInst.onClick.call(this,classInst,clickType);}}}});A5.Menubar=Class.create({initialize:function(contId,data,settings){if(!$(contId))return false;this.contId=contId;$u.o.assign(this,{theme:'',layout:'horizontal',item:{style:0,className:'',hoverClassName:'',pressedClassName:'',disabledClassName:'',cascadeClassName:'',separatorClassName:'',dropdown:{mode:'click'}}},true);if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'menubar');$u.o.assign(this,settings);this.data=data;this._render();},setDisplay:function(name,val){var indx=this._gIndex(name);if(indx!=-1){if(val){A5.u.element.show($(this.data[indx]._id));this.data[indx].show=true;}else{A5.u.element.hide($(this.data[indx]._id));this.data[indx].show=false;}}},setDisabled:function(name,val){var indx=this._gIndex(name);if(indx!=-1){if(val){$acn(this.data[indx]._id,this.item.disabledClassName);this.data[indx].disabled=true;}else{$rcn(this.data[indx]._id,this.item.disabledClassName);this.data[indx].disabled=false;}}},setState:function(name,val){var indx=this._gIndex(name);if(indx!=-1){if(val){$acn(this.data[indx]._id,this.item.pressedClassName);if(this.data[indx]._hasDropdown)this.data[indx].dropdown._state=true;this.data[indx]._state=true;}else{$rcn(this.data[indx]._id,this.item.pressedClassName);if(this.data[indx]._hasDropdown)this.data[indx].dropdown._state=false;this.data[indx]._state=false;}}},_render:function(){var ele=0;var cEle=$(this.contId);for(var i=0;i<this.data.length;i++){if(this.data[i]=='-')this.data[i]={type:'separator'};$u.o.assign(this.data[i],this._defaultItem,true);this.data[i]._id=this.contId+'.ITEM'+i;this.data[i]._state=false;if(this.data[i].type=='custom'){ele=document.createElement('span');ele.className=this._gDef(this.data[i].className,this.item.className);ele.innerHTML=this.data[i].html;}else if(this.data[i].type=='separator'){ele=document.createElement('span');ele.className=this._gDef(this.data[i].className,this.item.separatorClassName);ele.innerHTML=this.data[i].html;}else{if(this.data[i].html=='')this.data[i].html=this.data[i].name;if(this.data[i].name=='')this.data[i].name=this.data[i].html;if(this.data[i].dropdown.show)this.data[i]._hasDropdown=true;ele=document.createElement('a');ele.className=this._gDef(this.data[i].className,this.item.className);ele.href='#';var html=this.data[i].html;if(this.data[i].icon!='')html='<img src="'+this.data[i].icon+'" /> '+html;if(this.data[i]._hasDropdown){this.data[i].dropdown._pressedClassName=this._gDef(this.data[i].pressedClassName,this.item.pressedClassName);this.data[i].dropdown._id=this.data[i]._id;this.data[i].dropdown._state=false;this.data[i].dropdown._onShow=this.data[i].dropdown.onShow;this.data[i].dropdown.onShow=function(){if(this._onShow.constructor==Function)this._onShow();if(!this._state)$acn(this._id,this._pressedClassName);}
this.data[i].dropdown._onHide=this.data[i].dropdown.onHide;this.data[i].dropdown.onHide=function(){if(this._onHide.constructor==Function)this._onHide();if(!this._state)$rcn(this._id,this._pressedClassName);}
if(this._gDef(this.data[i].cascadeClassName,this.item.cascadeClassName)!=''){html='<span class="'+this._gDef(this.data[i].cascadeClassName,this.item.cascadeClassName)+'" style="display: block;">'+html+'</span>';}}
ele.innerHTML=html;$e.add(ele,'mouseover',this._iMOver,this);$e.add(ele,'mouseout',this._iMOut,this);$e.add(ele,'mousedown',this._iMDown,this);$e.add(ele,'mouseup',this._iMUp,this);$e.add(ele,'click',this._iClick,this);}
ele.id=this.data[i]._id;$sa(ele,'A5MenuBarItemIndex',''+i);if(typeof this.data[i].style=='object'||typeof this.data[i].style=='string')$ss(ele,this.data[i].style);else if((typeof this.item.style=='object'||typeof this.item.style=='string')&&this.data[i].type!='separator')$ss(ele,this.item.style);if(this.layout=='vertical')ele.style.display='block';else ele.style.display='inline-block';cEle.appendChild(ele);if(this.data[i].show==false)A5.u.element.hide(ele);if(this.data[i].disabled==true)$acn(ele,this.item.disabledClassName);if(this.data[i].onInitialize.constructor==Function)this.data[i].onInitialize.call(this,this.data[i]);}},_iMOver:function(e,classInst){var indx=Number($ga(this,'A5MenuBarItemIndex'));$acn(this,classInst._gDef(classInst.data[indx].hoverClassName,classInst.item.hoverClassName));if(classInst.item.dropdown.mode=='mouseover'){for(var i=0;i<classInst.data.length;i++){if(classInst.data[i].dropdown.hide)classInst.data[i].dropdown.hide();}
if(classInst.data[indx]._hasDropdown){if(classInst.layout=='vertical')classInst.data[indx].dropdown.show('flyout',this);else classInst.data[indx].dropdown.show('dropdown',this);}}},_iMOut:function(e,classInst){var indx=Number($ga(this,'A5MenuBarItemIndex'));$rcn(this,classInst._gDef(classInst.data[indx].hoverClassName,classInst.item.hoverClassName));if(!classInst.data[indx]._state&&!classInst.data[indx]._hasDropdown)$rcn(classInst.data[indx]._id,classInst._gDef(classInst.data[indx].pressedClassName,classInst.item.pressedClassName));},_iMDown:function(e,classInst){var indx=Number($ga(this,'A5MenuBarItemIndex'));if(!classInst.data[indx]._state&&!classInst.data[indx]._hasDropdown)$acn(classInst.data[indx]._id,classInst._gDef(classInst.data[indx].pressedClassName,classInst.item.pressedClassName));for(var i=0;i<classInst.data.length;i++){if(classInst.data[i].dropdown.hide)classInst.data[i].dropdown.hide();}
if(classInst.item.dropdown.mode!='mouseover'){if(classInst.data[indx]._hasDropdown){if(classInst.layout=='vertical')classInst.data[indx].dropdown.show('flyout',this);else classInst.data[indx].dropdown.show('dropdown',this);}}},_iMUp:function(e,classInst){var indx=Number($ga(this,'A5MenuBarItemIndex'));if(!classInst.data[indx]._state&&!classInst.data[indx]._hasDropdown)$rcn(classInst.data[indx]._id,classInst._gDef(classInst.data[indx].pressedClassName,classInst.item.pressedClassName));},_iClick:function(e,classInst){$e.stopEvent(e);var indx=Number($ga(this,'A5MenuBarItemIndex'));if(classInst.data[indx].onClick.constructor==Function)classInst.data[indx].onClick.call(this,classInst);},_gIndex:function(name){if(typeof name=='number'&&(name>-1&&name<this.data.length))return name;else{for(var i=0;i<this.data.length;i++){if(this.data[i].name=name)return i;}}
return-1;},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_defaultItem:{type:'item',html:'',icon:'',name:'',show:true,disabled:false,style:0,className:'',hoverClassName:'',pressedClassName:'',disabledClassName:'',cascadeClassName:'',onClick:0,onInitialize:0,dropdown:0,_hasDropdown:false}});A5.Menu=Class.create();A5.Menu.prototype={initialize:function(data,settings){this._menuId='A5menu'+this._menuIndx[0];$u.o.assign(this,{className:'',innerClassName:'',iconColumn:{show:true,className:'',preventIndentClassName:'',width:''},closeOnLeave:false,closeWait:200,cascadeOffsetX:0,cascadeOffsetY:0,dynamicDataURL:'',loadingMessage:'Loading...',item:{className:'',labelClassName:'',hoverClassName:'',selectedClassName:'',disabledClassName:'',disabledHoverClassName:'',cascadeClassName:'',separatorClassName:'',titleClassName:'',radioImage:'',checkImage:''},animation:{show:{type:'',duration:500},hide:{type:'',duration:500}},onClick:0,onFocus:0,onShow:0,onHide:0,_showIt:0,_data:[]});if(typeof A5._menuDefaults!='undefined')$u.o.assign(this,A5._menuDefaults);if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'menu');$u.o.assign(this,settings);this._v=new Object();this._dmg=new Object();this.populate(data);this._menuIndx[0]=this._menuIndx[0]+1;this._lastDir='';this._curLevel=0;this._menuShown=[];this._timeout=0;this._focus=[];this._keyWatch=new AUI.KeyWatcher([{key:'up',handle:this._keyPrev},{key:'down',handle:this._keyNext},{key:'home',handle:this._keyHome},{key:'end',handle:this._keyLastEnd},{key:'left',handle:this._keyOut},{key:'right',handle:this._keyIn},{key:'enter',handle:this._keyEnter}],this);},populate:function(data){if(data.constructor==Function||data.constructor==Object){this._dmg['*top']=data;this._genMenu([],0,'');this._data=[];}else if(data.constructor==String){if(data.substr(0,1)=='?')this._dmg['*top']={data:data.substr(1)};else this._dmg['*top']={url:data};this._genMenu([],0,'');this._data=[];}else{this._genMenu(data,0,'');this._data=data;}},populateItem:function(loc,data){var level=$if(loc.constructor==Array,loc.length,1);var item=this._gItem(this._data,loc);if(item){if(item.type=='item'){var ele=$(item._id)
ele.firstChild.className=this._gDef(item.cascadeClassName,this.item.cascadeClassName);item.children=data;$sa(ele,'A5MenuHasChild','true');$sa(ele,'A5MenuChildId',this._menuId+'.'+item._loc+'.MENU');this._genMenu(item.children,level,item._loc+'.');}}},show:function(val1,val2){var mEle=$(this._menuId+'.MENU');A5.u.element.show(mEle,this.animation.show);if(val1.toLowerCase()=='dropdown'||val1.toLowerCase()=='dropdown-right'||val1.toLowerCase()=='flyout'||val1.toLowerCase()=='flyout-bottom'||val1.toLowerCase()=='popup'||val1.toLowerCase()=='popup-bottom'){var pEle=$(val2);if(pEle)$po(mEle,pEle,val1.toLowerCase());}else if(typeof val1!='undefined'&&typeof val2!='undefined'){if(typeof val1=='Number')mEle.style.top=val1+'px';else mEle.style.top=val1;if(typeof val2=='Number')mEle.style.left=val2+'px';else mEle.style.left=val2;}
this._curLevel=0;this._showIt++;this._menuShown=new Array(this._menuId+'.MENU');this._focus=[];$(this._menuId+'.FOCUSCATCHER').focus();if(typeof this._dmg['*top']!='undefined'){if(this._dmg['*top'].constructor==Function){var dataArr=this._dmg['*top'].call(this,{});this._genMenu(dataArr,0,'');this._data=dataArr;}else{var dataURL=this._dmg['*top'].url;if(dataURL=='')dataURL=this.dynamicDataURL;if(dataURL!=''){new $a.simple(dataURL,{data:$if(this._dmg['*top'].data,this._dmg['*top'].data+'&','')+'A5MenuLocation=[]&A5MenuValue=&__Ajax=true',handle:this._responseHandle,handleContext:this});this.populate([{type:'custom',html:this.loadingMessage}]);}}}
if(this.onShow.constructor==Function)this.onShow.call(this);var classInst=this;setTimeout(function(){$e.add(document.documentElement,'click',classInst.hide,classInst,true);delete classInst;},10);},hide:function(){var itemId='';for(var i=0;i<this._menuShown.length;i++){A5.u.element.hide($(this._menuShown[i]),this.animation.hide);itemId=this._menuShown[i].split('.');itemId.pop();itemId=itemId.join('.');ele=$(itemId);$rcn(ele,this._gDef($ga(ele,'A5MenuHoverClassName'),this.item.hoverClassName));$rcn(ele,this._gDef($ga(ele,'A5MenuDisabledHoverClassName'),this.item.disabledHoverClassName));}
this._menuShown=new Array();ele=$(this._menuId+'.'+this._focus.join('.'));$rcn(ele,this._gDef($ga(ele,'A5MenuHoverClassName'),this.item.hoverClassName));$rcn(ele,this._gDef($ga(ele,'A5MenuDisabledHoverClassName'),this.item.disabledHoverClassName));$e.remove(document.documentElement,'click',this.hide);if(this.onHide.constructor==Function)this.onHide.call(this);},setDisplay:function(loc,val){var item=this._gItem(this._data,loc);if(item){if(val)$(item._id).style.display='block';else $(item._id).style.display='none';}},setDisabled:function(loc,val){var item=this._gItem(this._data,loc);if(item){var ele=$(item._id);if(val){ele.className=this._gDef(item.className,this.item.className)+' '+this._gDef(item.disabledClassName,this.item.disabledClassName);$sa(ele,'A5MenuDisabled','true');}else{ele.className=this._gDef(item.className,this.item.className);$sa(ele,'A5MenuDisabled','false');}}},setValue:function(varName,val){this._v[varName]=val;var data=typeof arguments[2]!='undefined'?arguments[2]:this._data;for(var i=0;i<data.length;i++){if(data[i].type=='item'&&data[i].variable==varName){if(val==data[i].name)$acn(data[i]._id,this._gDef(data[i].selectedClassName,this.item.selectedClassName));else $rcn(data[i]._id,this._gDef(data[i].selectedClassName,this.item.selectedClassName));}else if(data[i].type=='radio'&&data[i].variable==varName){if(val==data[i].name)$(data[i]._id+'.ICON').style.visibility='';else $(data[i]._id+'.ICON').style.visibility='hidden';}else if(data[i].type=='check'&&data[i].variable==varName){if(val)$(data[i]._id+'.ICON').style.visibility='';else $(data[i]._id+'.ICON').style.visibility='hidden';}else if(data[i].type=='radio-group'&&data[i].variable==varName){for(var j=0;j<data[i].data.length;j++){if(data[i].data[j].value==val)$acn(data[i]._id+':'+j,this._gDef(data[i].selectedClassName,this.item.selectedClassName));else $rcn(data[i]._id+':'+j,this._gDef(data[i].selectedClassName,this.item.selectedClassName));}}
if(data[i].children.constructor==Array)this.setValue(varName,val,data[i].children);}},getValue:function(varName){return this._v[varName];},navigate:function(dir){dir=dir.toLowerCase();this._lastDir=dir;if(this._focus.length==0){if(this._itemFocus(this._gItemRel(this._data,-1,1)))return true;}else{var item=this._gItem(this._data,this._focus);if(item.type=='radio-group'){if(dir.substr(0,4)=='prev'&&item._focus>item._cols-1){this._menuRGItemMOver.call($(item._id+':'+(item._focus-item._cols)),{},this);return true;}else if(dir=='next'&&item._focus<item.data.length-item._cols){this._menuRGItemMOver.call($(item._id+':'+(item._focus+item._cols)),{},this);return true;}else if(dir=='in'&&item._focus+1<item.data.length){this._menuRGItemMOver.call($(item._id+':'+(item._focus+1)),{},this);return true;}else if(dir=='out'&&item._focus-1>-1){this._menuRGItemMOver.call($(item._id+':'+(item._focus-1)),{},this);return true;}}
return this._navigate(dir);}},_navigate:function(dir){this._menuItemMOut.call($(this._menuId+'.'+this._focus.join('.')),{},this);if(dir.substr(0,4)=='prev'||dir=='next'||dir=='home'||dir=='end'){var level=this._focus.length;var curItem=this._focus.pop();if(this._focus.length==0)var data=this._data;else var data=this._gItem(this._data,this._focus).children;if(dir.substr(0,4)=='prev'){if(this._itemFocus(this._gItemRel(data,curItem,-1)))return true;}else if(dir=='next'){if(this._itemFocus(this._gItemRel(data,curItem,1)))return true;}else if(dir=='home'){if(this._itemFocus(this._gItemRel(data,-1,1)))return true;}else if(dir=='end'){if(this._itemFocus(this._gItemRel(data,data.length,-1)))return true;}}else if(dir=='in'){var data=this._gItem(this._data,this._focus).children;if(this._itemFocus(this._gItemRel(data,-1,1)))return true;}else if(dir=='out'&&this._focus.length>1){this._focus.pop();if(this._itemFocus(this._gItem(this._data,this._focus)))return true;}else if(dir=='enter'){var item=this._gItem(this._data,this._focus);if((item.type=='item'||item.type=='radio'||item.type=='check'||item.type=='radio-group')&&item.children==0){if(item.variable!=''){if(item.type=='radio')this.setValue(item.variable,item.name);else if(item.type=='check')this.setValue(item.variable,!this._v[item.variable]);else if(item.type=='radio-group'&&item._focus>-1)this.setValue(item.variable,item.data[item._focus].value);}
if(item.onClick.constructor==Function)item.onClick.call(this,item);else if(this.onClick.constructor==Function)this.onClick.call(this,item);if(!item.preventHide)this.hide();return true;}else if(item.children!=0){var data=this._gItem(this._data,this._focus).children;if(this._itemFocus(this._gItemRel(data,-1,1)))return true;}else this.hide();}
this._menuItemMOver.call($(this._menuId+'.'+this._focus.join('.')),{},this);},_genMenu:function(menuDef,level,loc){if($(this._menuId+'.'+loc+'MENU')){var mEle=$(this._menuId+'.'+loc+'MENU');$e.removeGroup(this._menuId+'.'+loc+'MENU');}else{var mEle=document.createElement('div');document.body.insertBefore(mEle,document.body.firstChild);mEle.id=this._menuId+'.'+loc+'MENU';mEle.style.display='none';mEle.style.position='absolute';mEle.style.zIndex=''+(1000+level);$e.add(mEle,'click',function(e){$e.stopEvent(e);return false;});}
mEle.className=this.className;var micShow=false;for(var i=0;i<menuDef.length;i++){menuDef[i]=this._parseMenuItem(menuDef[i],loc+i);menuDef[i]._index=i;if(menuDef[i].icon!=''||menuDef[i].type=='radio'||menuDef[i].type=='check')micShow=true;}
if(typeof this.iconColumn.show=='boolean')micShow=this.iconColumn.show;else if(this.iconColumn.show!='auto')micShow=true;if(micShow){mEle.innerHTML='<div class="'+this.iconColumn.className+'"><div class="'+this.innerClassName+'"></div></div>';var mcEle=mEle.firstChild.firstChild;}else{mEle.innerHTML='<div class="'+this.innerClassName+'"></div>';var mcEle=mEle.firstChild;}
if(level==0){var HTMLFocusCatcher=document.createElement('a');HTMLFocusCatcher.href='#';HTMLFocusCatcher.id=this._menuId+'.FOCUSCATCHER';$ss(HTMLFocusCatcher,'font-size: 0px; display: block; height: 0px; width: 0px; overflow: hidden; outline-style: none; position: absolute;')
HTMLFocusCatcher.tabIndex='-1';$e.add(HTMLFocusCatcher,'focus',this._mFocus,this,true);$e.add(HTMLFocusCatcher,'blur',this._mBlur,this,true);$e.add(HTMLFocusCatcher,'click',function(e){$e.stopEvent(e);return false;});mEle.insertBefore(HTMLFocusCatcher,mEle.firstChild);}
for(var i=0;i<menuDef.length;i++){mcEle.appendChild(this._genMenuItem(menuDef[i],level,loc+i,micShow,this._menuId+'.'+loc+'MENU'));if(menuDef[i].children.constructor==Array)this._genMenu(menuDef[i].children,level+1,loc+i+'.');if(menuDef[i].onInitialize.constructor==Function)menuDef[i].onInitialize.call(this,menuDef[i]);}
$e.add(mEle,'mouseover',this._menuMOver,this,false,this._menuId+'.'+loc+'MENU');$e.add(mEle,'mouseout',this._menuMOut,this,false,this._menuId+'.'+loc+'MENU');},_genMenuItem:function(item,level,loc,micShow,egName){var hasChildren=item.children.constructor==Array;if(item.type=='item'||item.type=='radio'||item.type=='check'){var ele=document.createElement('a');ele.className=this._gDef(item.className,this.item.className);ele.href='#';if(item.type=='radio'){ele.innerHTML='<span style="display: block;"><div style="width: '+this.iconColumn.width+'; float: left;"><img id="'+item._id+'.ICON" src="'+this.item.radioImage+'" style="visibility: hidden; border: none;" align="top" /></div><span class="'+this._gDef(item.labelClassName,this.item.labelClassName)+'">'+item.html+'</span><br style="clear: both;" /></span></span>';}else if(item.type=='check'){ele.innerHTML='<span style="display: block;"><div style="width: '+this.iconColumn.width+'; float: left;"><img id="'+item._id+'.ICON" src="'+this.item.checkImage+'" style="visibility: hidden; border: none;" align="top" /></div><span class="'+this._gDef(item.labelClassName,this.item.labelClassName)+'">'+item.html+'</span><br style="clear: both;" /></span></span>';}else{if(micShow)ele.innerHTML='<span'+$if(hasChildren,' class="'+this._gDef(item.cascadeClassName,this.item.cascadeClassName)+'"','')+' style="display: block;"><div style="width: '+this.iconColumn.width+'; float: left;">'+$if(item.icon!='','<img id="'+item._id+'.ICON" src="'+item.icon+'" style="border: none;" align="top" />','<img id="'+item._id+'.ICON" src="'+this.item.radioImage+'" style="visibility: hidden; width: 1px; height: 1px;" align="top" />')+'</div><span class="'+this._gDef(item.labelClassName,this.item.labelClassName)+'">'+item.html+'</span><br style="clear: both;" /></span></span>';else ele.innerHTML='<span'+$if(hasChildren,' class="'+this._gDef(item.cascadeClassName,this.item.cascadeClassName)+'"','')+' style="display: block;"><span class="'+this._gDef(item.labelClassName,this.item.labelClassName)+'">'+item.html+'</span><br style="clear: both;" /></span></span>';}
if(item.style)$ss(ele,item.style);}else if(item.type=='custom'){var ele=document.createElement('div');ele.className=this._gDef(item.className,this.item.className);if(item.style)$ss(ele,item.style);ele.innerHTML='<div'+$if(micShow&&!item.preventIndent,' style="padding-left: '+this.iconColumn.width+'"','')+'>'+item.html+'</div>';}else if(item.type=='radio-group'){var ele=document.createElement('div');var sEle=document.createElement('div');if(micShow&&!item.preventIndent)sEle.style.paddingLeft=this.iconColumn.width;ele.appendChild(sEle);var tblEle=document.createElement('table');tblEle.cellSpacing='0';tblEle.cellPadding='0';sEle.appendChild(tblEle);var aEle=0;var cols=1;var rows=0;var dataIndx=0;var className=this._gDef(item.className,this.item.className);if(typeof item.columns=='number')cols=item.columns;else cols=Math.round(Math.sqrt(item.data.length));cols=Math.max(cols,1);rows=Math.round(item.data.length/cols);for(var i=0;i<rows;i++){tblEle.insertRow(i);for(var j=0;j<cols;j++){tblEle.rows[i].insertCell(j);if(dataIndx<item.data.length){if(typeof item.data[dataIndx]!='object')item.data[dataIndx]={value:item.data[dataIndx],html:item.data[dataIndx]}
$u.o.assign(item.data[dataIndx],{value:'',html:''},true);if(item.data[dataIndx].value=='')item.data[dataIndx].value=item.html;if(item.data[dataIndx].html=='')item.data[dataIndx].html=item.value;var aEle=document.createElement('a');aEle.className=className;aEle.href='#';aEle.id=item._id+':'+dataIndx;aEle.innerHTML=item.data[dataIndx].html;$sa(aEle,'A5MenuLocation',loc);$sa(aEle,'A5MenuHoverClassName',item.hoverClassName);$sa(aEle,'A5MenuDisabledHoverClassName',item.disabledHoverClassName);$sa(aEle,'A5MenuItemGroupIndex',String(dataIndx));$e.add(aEle,'mouseover',this._menuRGItemMOver,this,false,egName);$e.add(aEle,'mouseout',this._menuRGItemMOut,this,false,egName);$e.add(aEle,'click',this._menuItemClick,this,false,egName);if(item.style)$ss(aEle,item.style);aEle.style.display='block';tblEle.rows[i].cells[j].appendChild(aEle);}else tblEle.rows[i].cells[j].innerHTML='&nbsp;';dataIndx++;}}
item._cols=cols;item._rows=rows;}else if(item.type=='separator'){var ele=document.createElement('div');ele.id=item._id;if(!item.preventIndent)ele.className=this._gDef(item.className,this.item.className);else ele.className=this.iconColumn.preventIndentClassName;if(item.style)$ss(ele,item.style);ele.innerHTML='<div class="'+this._gDef(item.className,this.item.separatorClassName)+'"'+$if(micShow&&!item.preventIndent,' style="margin-left: '+this.iconColumn.width+'"','')+'></div>'
return ele}else if(item.type=='title'){var ele=document.createElement('div');ele.id=item._id;ele.className=this._gDef(item.className,this.item.titleClassName);if(item.style)$ss(ele,item.style);ele.innerHTML=item.html;return ele}
ele.id=item._id;ele.style.display='block';if(hasChildren){$sa(ele,'A5MenuHasChild','true');$sa(ele,'A5MenuChildId',this._menuId+'.'+loc+'.MENU');}else{$sa(ele,'A5MenuHasChild','flase');$sa(ele,'A5MenuChildId','');}
$sa(ele,'A5MenuLevel',String(level));$sa(ele,'A5MenuLocation',loc);$sa(ele,'A5MenuHoverClassName',item.hoverClassName);$sa(ele,'A5MenuDisabledHoverClassName',item.disabledHoverClassName);$sa(ele,'A5MenuItemType',item.type);$e.add(ele,'mouseover',this._menuItemMOver,this,false,egName);$e.add(ele,'mouseout',this._menuItemMOut,this,false,egName);if(item.type!='radio-group')$e.add(ele,'click',this._menuItemClick,this,false,egName);if(!item.preventIndent)return ele;else{var cEle=document.createElement('div');cEle.className=this.iconColumn.preventIndentClassName;cEle.appendChild(ele);return cEle;}},_parseMenuItem:function(item,loc){if(typeof item!='object'){if(item=='-'){item={type:'separator'}}else item={name:String(item)};}
$u.o.assign(item,{name:'',html:'',icon:'',type:'',variable:'',style:false,className:'',labelClassName:'',hoverClassName:'',selectedClassName:'',disabledClassName:'',disabledHoverClassName:'',cascadeClassName:'',preventHide:false,preventIndent:false,onClick:0,onFocus:0,onInitialize:0,children:0},true);item._id=this._menuId+'.'+loc;item._loc=loc;item._dynamic=false;if(item.name=='')item.name=item.html;if(item.html=='')item.html=item.name;item.type=item.type.toLowerCase();if(item.type!='separator'&&item.type!='title'&&item.type!='radio'&&item.type!='check'&&item.type!='radio-group'&&item.type!='custom')item.type='item';if(item.type=='radio-group')item._focus=-1;if((item.type=='radio-group'||item.type=='radio'||item.type=='check')&&item.variable!=''){if(typeof this._v[item.variable]=='undefined')this._v[item.variable]=null;}
if(item.children.constructor==Function||item.children.constructor==Object){this._dmg[item._loc]=item.children;item.children=[];item._dynamic=true;}else if(item.children.constructor==String){if(item.children.substr(0,1)=='?')this._dmg[item._loc]={data:item.children.substr(1)};else this._dmg[item._loc]={url:item.children};item.children=[];item._dynamic=true;}
return item;},_menuItemMOver:function(e,classInst){var loc=$ga(this,'A5MenuLocation');loc=loc.split('.');for(var i=0;i<loc.length;i++)loc[i]=Number(loc[i]);var item=classInst._gItem(classInst._data,loc);ele=$(classInst._menuId+'.'+classInst._focus.join('.'));if(ele.id!=this.id&&$ga(ele,'A5MenuHasChild')!='true'){$rcn(ele,classInst._gDef($ga(ele,'A5MenuHoverClassName'),classInst.item.hoverClassName));$rcn(ele,classInst._gDef($ga(ele,'A5MenuDisabledHoverClassName'),classInst.item.disabledHoverClassName));}
if(this.id+'.MENU'!=classInst._menuShown[classInst._menuShown.length-1]){var curLevel=Number($ga(this,'A5MenuLevel'));var menuToShow=$ga(this,'A5MenuChildId');var ele=0;var menusToHide=classInst._menuShown.slice(curLevel+1);classInst._menuShown.splice(curLevel+1,classInst._menuShown.length-curLevel);for(var i=0;i<menusToHide.length;i++){if(menuToShow!=menusToHide[i]){A5.u.element.hide($(menusToHide[i]),classInst.animation.hide);itemId=menusToHide[i].split('.');itemId.pop();itemId=itemId.join('.');ele=$(itemId);$rcn(ele,classInst._gDef($ga(ele,'A5MenuHoverClassName'),classInst.item.hoverClassName));$rcn(ele,classInst._gDef($ga(ele,'A5MenuDisabledHoverClassName'),classInst.item.disabledHoverClassName));}}
if((item.type=='item'||item.type=='radio'||item.type=='check')&&$ga(this,'A5MenuDisabled')!='true'){$acn(this,classInst._gDef($ga(this,'A5MenuHoverClassName'),classInst.item.hoverClassName));if($ga(this,'A5MenuHasChild')=='true'){ele=$(menuToShow);classInst._menuShown.push(menuToShow);if(item._dynamic&&classInst._showIt>$u.s.toNum(''+$ga(this,'A5MenuChildLastRefresh'))){if(classInst._dmg[item._loc].constructor==Function)classInst.populateItem(loc,classInst._dmg[item._loc].call(classInst,item));else{var dataURL=classInst._dmg[item._loc].url;if(dataURL=='')dataURL=classInst.dynamicDataURL;if(dataURL!=''){new $a.simple(dataURL,{data:$if(classInst._dmg[item._loc].data,classInst._dmg[item._loc].data+'&','')+'A5MenuLocation=['+item._loc.split('.').join(',')+']&A5MenuValue='+item.name+'&__Ajax=true',handle:classInst._responseHandle,handleContext:classInst});classInst.populateItem(loc,[{type:'custom',html:classInst.loadingMessage}]);}}
$sa(this,'A5MenuChildLastRefresh',''+classInst._showIt);}
if(ele.style.display!='block'){A5.u.element.show(ele,classInst.animation.show);$po(ele,this,'flyout',classInst.cascadeOffsetX,classInst.cascadeOffsetY);classInst._curLevel=curLevel;}}}else if(item.type=='item'||item.type=='radio'||item.type=='check'){$acn(this,classInst._gDef($ga(this,'A5MenuDisabledHoverClassName'),classInst.item.disabledHoverClassName));}else if(item.type=='radio-group'&&arguments[2]){if(classInst._lastDir.substr(0,4)!='prev')classInst._menuRGItemMOver.call($(item._id+':0'),e,classInst);else classInst._menuRGItemMOver.call($(item._id+':'+(item._cols*(item._rows-1))),e,classInst);}}
classInst._focus=loc;$(classInst._menuId+'.FOCUSCATCHER').focus();},_menuItemMOut:function(e,classInst){var type=$ga(this,'A5MenuItemType');if(type=='item'||type=='radio'||type=='check'){if($ga(this,'A5MenuHasChild')!='true'){$rcn(this,classInst._gDef($ga(this,'A5MenuHoverClassName'),classInst.item.hoverClassName));$rcn(this,classInst._gDef($ga(this,'A5MenuDisabledHoverClassName'),classInst.item.disabledHoverClassName));}}if(type=='radio-group'){var fIndx=Number($ga(this,'A5MenuRGItemFocus'));if(fIndx>-1){$rcn(this.id+':'+fIndx,classInst._gDef($ga(this,'A5MenuHoverClassName'),classInst.item.hoverClassName));$rcn(this.id+':'+fIndx,classInst._gDef($ga(this,'A5MenuDisabledHoverClassName'),classInst.item.disabledHoverClassName));}}},_menuRGItemMOver:function(e,classInst){var loc=$ga(this,'A5MenuLocation');loc=loc.split('.');for(var i=0;i<loc.length;i++)loc[i]=Number(loc[i]);var item=classInst._gItem(classInst._data,loc);if(item._focus>-1)$rcn(item._id+':'+item._focus,classInst._gDef($ga(this,'A5MenuHoverClassName'),classInst.item.hoverClassName));item._focus=Number($ga(this,'A5MenuItemGroupIndex'));$sa(item._id,'A5MenuRGItemFocus',String(item._focus));$acn(this,classInst._gDef(item.hoverClassName,classInst.item.hoverClassName));},_menuRGItemMOut:function(e,classInst){$rcn(this,classInst._gDef($ga(this,'A5MenuHoverClassName'),classInst.item.hoverClassName));},_menuItemClick:function(e,classInst){var loc=$ga(this,'A5MenuLocation');loc=loc.split('.');var item=classInst._data[Number(loc[0])];for(var i=1;i<loc.length;i++){item=item.children[Number(loc[i])];}
if((item.type=='item'||item.type=='radio'||item.type=='check'||item.type=='radio-group')&&item.children==0){$e.stopEvent(e);if(item.variable!=''){if(item.type=='item'||item.type=='radio')classInst.setValue(item.variable,item.name);else if(item.type=='check')classInst.setValue(item.variable,!classInst._v[item.variable]);else if(item.type=='radio-group'&&item._focus>-1)classInst.setValue(item.variable,item.data[item._focus].value);}
if(item.onClick.constructor==Function)item.onClick.call(classInst,item);else if(classInst.onClick.constructor==Function)classInst.onClick.call(classInst,item);if(!item.preventHide)classInst.hide();return false;}else if(item.children!=0){if(item.onClick.constructor==Function)item.onClick.call(classInst,item);}},_menuMOver:function(e,classInst){clearTimeout(classInst._timeout);},_menuMOut:function(e,classInst){if(classInst.closeOnLeave){classInst._timeout=setTimeout(function(){classInst.hide();delete classInst;},classInst.closeWait);}},_itemFocus:function(item){if(item){var loc=item._loc;loc=loc.split('.');for(var i=0;i<loc.length;i++)loc[i]=Number(loc[i]);this._focus=loc;this._menuItemMOver.call($(item._id),{},this,true);if(item.onFocus.constructor==Function)item.onFocus.call(this,item);else if(this.onFocus.constructor==Function)this.onFocus.call(this,item);return true;}},_mFocus:function(){this._keyWatch.on();},_mBlur:function(){this._keyWatch.off();},_keyPrev:function(){this.navigate('prev');return true;},_keyNext:function(){this.navigate('next');return true;},_keyHome:function(){this.navigate('home');return true;},_keyLastEnd:function(){this.navigate('end');return true;},_keyOut:function(){this.navigate('out');return true;},_keyIn:function(){this.navigate('in');return true;},_keyEnter:function(){this.navigate('enter');return true;},_gItem:function(items,loc){var level=typeof arguments[2]!='undefined'?arguments[2]:0;if(loc.constructor==Array){var target=loc[level];var item=false;if(typeof target=='number')item=items[target];else{for(var i=0;i<items.length;i++){if(items[i].name==target)item=items[i];}}
if(loc.length-1>level&&item){return this._gItem(item.children,loc,level+1);}else return item;}else{if(typeof loc=='number')return items[loc];else{for(var i=0;i<items.length;i++){if(items[i].name==loc)return items[i];}}}
return false;},_gItemRel:function(items,start,step){var target=-1;var ele=0;start=start+step;for(var i=0;i<items.length;i++){itemIndx=start+(i*step);if(itemIndx<0)itemIndx=items.length+itemIndx;else if(itemIndx>items.length-1)itemIndx=itemIndx-items.length;if(items[itemIndx].type!='separator'&&items[itemIndx].type!='title'){ele=$(items[itemIndx]._id);return items[itemIndx];}}},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!='')return arguments[i];return'';},_responseHandle:function(obj){var resJSON=eval('('+obj.responseText+')');if(resJSON.location.length>0)this.populateItem(resJSON.location,resJSON.data);else this.populate(resJSON.data);},_menuIndx:[0]}
A5.ErrorHandler=Class.create();A5.ErrorHandler.prototype={initialize:function(settings){$u.o.assign(settings,{type:'block',className:'',inputClassName:'',icon:'',global:{contId:'',hoverClassName:'',hoverInputClassName:''}},true);$u.o.assign(this,settings);this._e=new Array();this._tipId='';this._tipTO=0;},set:function(errorId,errorMsg){if(errorId.constructor==Array){for(var i=0;i<errorId.length;i++){if(typeof errorMsg[i]!='undefined')this._createError(errorId[i],errorMsg[i]);var iEle=$(errorId);}}else this._createError(errorId,errorMsg);},clear:function(){if(arguments.length>0){var eToRem=new Array();if(typeof arguments[0]=='string')eToRem.push(arguments[0]);else eToRem=arguments[0];var indx=-1;for(var i=0;i<eToRem.length;i++){for(var j=0;j<this._e.length;j++){if(this._e[j].id==eToRem[i]){indx=j;break;}}
if(indx>-1)this._removeError(indx);}}else{if(this.type=='inline'){for(var i=0;i<this._e.length;i++){$(this._e[i].id+'.ERRORSPAN').style.display='none';$rcn(this._e[i].id,this.inputClassName);}}else if(this.type=='tip'){for(var i=0;i<this._e.length;i++){$e.remove($(this._e[i].id),'mouseover',this._mover);$e.remove($(this._e[i].id),'mouseout',this._mout);$rcn(this._e[i].id,this.inputClassName);$(this._e[i].id+'.ERRORTIPDIV').style.display='none';}}else if(this.type=='icon'){for(var i=0;i<this._e.length;i++){$(this._e[i].id+'.ERRORTIPICON').style.display='none';$rcn(this._e[i].id,this.inputClassName);}}else if(this.type=='global'){$e.removeGroup(this.global.contId);var globalEle=$(this.global.contId);globalEle.innerHTML='';globalEle.style.display='none';for(var i=0;i<this._e.length;i++){$e.remove($(this._e[i].id),'mouseover',this._mover);$e.remove($(this._e[i].id),'mouseout',this._mout);$rcn(this._e[i].id,this.inputClassName);}}else{for(var i=0;i<this._e.length;i++){$(this._e[i].id+'.ERRORDIV').style.display='none';$rcn(this._e[i].id,this.inputClassName);}}
this._e=new Array();}},_createError:function(errorId,errorMsg){var replacingError=false;for(var i=0;i<this._e.length;i++){if(this._e[i].id==errorId){replacingError=true;this._e[i].msg=errorMsg;break;}}
if(!replacingError)this._e.push({id:errorId,msg:errorMsg});if(this.type=='inline'){if($(errorId+'.ERRORSPAN')){var ele=$(errorId+'.ERRORSPAN');ele.innerHTML=errorMsg;ele.className=this.className;ele.style.display='';var iEle=$(errorId);if(iEle.tagName&&iEle.type!='checkbox')$acn(iEle,this.inputClassName);}else{var ele=document.createElement('span');ele.id=errorId+'.ERRORSPAN';ele.innerHTML=errorMsg;ele.className=this.className;var iEle=$(errorId);if(iEle.tagName){iEle.parentNode.insertBefore(ele,iEle.nextSibling);if(iEle.type!='checkbox')$acn(iEle,this.inputClassName);}else iEle[iEle.length-1].parentNode.insertBefore(ele,iEle[iEle.length-1].nextSibling);}}else if(this.type=='tip'){if($(errorId+'.ERRORTIPDIV')){var ele=$(errorId+'.ERRORTIPDIV');ele.innerHTML=errorMsg;ele.className=this.className;var iEle=$(errorId);if(iEle.tagName&&iEle.type!='checkbox')$acn(iEle,this.inputClassName);}else{var ele=document.createElement('div');ele.id=errorId+'.ERRORTIPDIV';ele.innerHTML=errorMsg;ele.className=this.className;ele.style.display='none';ele.style.position='absolute';ele.style.zIndex='5000';var iEle=$(errorId);if(iEle.tagName&&iEle.type!='checkbox')$acn(iEle,this.inputClassName);document.body.appendChild(ele);$e.add(ele,'mouseover',this._stopTO,this);$e.add(ele,'mouseout',this._mout,this);}
if(!replacingError){$e.add(iEle,'mouseover',this._mover,this);$e.add(iEle,'mouseout',this._mout,this);}}else if(this.type=='icon'){if($(errorId+'.ERRORTIPICON')){var iconEle=$(errorId+'.ERRORTIPICON');iconEle.src=this.icon;iconEle.style.display='';var ele=$(errorId+'.ERRORTIPICONDIV');ele.innerHTML=errorMsg;ele.className=this.className;var iEle=$(errorId);if(iEle.tagName&&iEle.type!='checkbox')$acn(iEle,this.inputClassName);}else{var iconEle=document.createElement('img');iconEle.src=this.icon;iconEle.id=errorId+'.ERRORTIPICON'
$ss(iconEle,'vertical-align: middle; margin-left: 2px;');var ele=document.createElement('div');ele.id=errorId+'.ERRORTIPICONDIV';ele.innerHTML=errorMsg;ele.className=this.className;ele.style.display='none';ele.style.position='absolute';ele.style.zIndex='5000';var iEle=$(errorId);if(iEle.tagName){iEle.parentNode.insertBefore(iconEle,iEle.nextSibling);if(iEle.type!='checkbox')$acn(iEle,this.inputClassName);}else iEle[iEle.length-1].parentNode.insertBefore(iconEle,iEle[iEle.length-1].nextSibling);document.body.appendChild(ele);$e.add(ele,'mouseover',this._stopTO,this);$e.add(ele,'mouseout',this._mout,this);$e.add(iconEle,'mouseover',this._mover,this);$e.add(iconEle,'mouseout',this._mout,this);}}else if(this.type=='global'){if(replacingError){var ele=$(errorId+'.ERRORGLOBALDIV');ele.innerHTML=ele.innerHTML+'<br />'+errorMsg;}else{var ele=document.createElement('div');ele.id=errorId+'.ERRORGLOBALDIV';ele.innerHTML=errorMsg;ele.className=this.className;$sa(ele,'A5ErrorId',errorId);var contEle=$(this.global.contId);contEle.appendChild(ele);contEle.style.display='';$e.add(ele,'mouseover',this._mover,this,false,this.global.contId);$e.add(ele,'mouseout',this._mout,this,false,this.global.contId);$e.add(ele,'click',this._globalSelect,this,false,this.global.contId);var iEle=$(errorId);if(iEle.tagName&&iEle.type!='checkbox')$acn(iEle,this.inputClassName);$e.add(iEle,'mouseover',this._mover,this);$e.add(iEle,'mouseout',this._mout,this);}}else{if($(errorId+'.ERRORDIV')){var ele=$(errorId+'.ERRORDIV');ele.innerHTML=errorMsg;ele.className=this.className;ele.style.display='';var iEle=$(errorId);if(iEle.tagName&&iEle.type!='checkbox')$acn(iEle,this.inputClassName);}else{var ele=document.createElement('div');ele.id=errorId+'.ERRORDIV';ele.innerHTML=errorMsg;ele.className=this.className;var iEle=$(errorId);if(iEle.tagName){iEle.parentNode.insertBefore(ele,iEle.nextSibling);if(iEle.type!='checkbox')$acn(iEle,this.inputClassName);}else iEle[iEle.length-1].parentNode.insertBefore(ele,iEle[iEle.length-1].nextSibling);}}},_removeError:function(indx){if(this.type=='inline'){$(this._e[indx].id+'.ERRORSPAN').style.display='none';$rcn(this._e[indx].id,this.inputClassName);}else if(this.type=='tip'){$e.remove($(this._e[indx].id),'mouseover',this._mover);$e.remove($(this._e[indx].id),'mouseout',this._mout);$rcn(this._e[indx].id,this.inputClassName);$(this._e[indx].id+'.ERRORTIPDIV').style.display='none';}else if(this.type=='icon'){$(this._e[indx].id+'.ERRORTIPICON').style.display='none';$(this._e[indx].id+'.ERRORTIPICONDIV').style.display='none';$rcn(this._e[indx].id,this.inputClassName);}else if(this.type=='global'){var ele=$(this._e[indx].id+'.ERRORGLOBALDIV');$e.remove(ele,'mouseover',this._mover);$e.remove(ele,'mouseout',this._mout);$e.remove(ele,'click',this._globalSelect);ele=ele.parentNode;ele.removeChild($(this._e[indx].id+'.ERRORGLOBALDIV'));$e.remove($(this._e[indx].id),'mouseover',this._mover);$e.remove($(this._e[indx].id),'mouseout',this._mout);$rcn(this._e[indx].id,this.inputClassName);}else{$(this._e[indx].id+'.ERRORDIV').style.display='none';$rcn(this._e[indx].id,this.inputClassName);}
this._e.splice(indx,1);},_mover:function(e,classInst){if(classInst.type=='tip'){if(this._tipId!='')classInst._moutComplete();classInst._tipId=classInst._gcn(this)+'.ERRORTIPDIV';var ele=$(classInst._tipId);ele.style.display='block';$po(ele,this,'dropdown',3);}else if(classInst.type=='icon'){if(this._tipId!='')classInst._moutComplete();classInst._tipId=classInst._gcn(this)+'DIV';var ele=$(classInst._tipId);ele.style.display='block';$po(ele,this,'dropdown-right',3);}else if(classInst.type=='global'){if($ga(this,'A5ErrorId')!=''&&typeof $ga(this,'A5ErrorId')=='string'){var ele=$($ga(this,'A5ErrorId'));if(classInst.global.hoverInputClassName!='')$acn(ele,classInst.global.hoverInputClassName);if(classInst.global.hoverClassName!='')$acn(this,classInst.global.hoverClassName);}else{var ele=$(classInst._gcn(this)+'.ERRORGLOBALDIV');if(classInst.global.hoverInputClassName!='')$acn(this,classInst.global.hoverInputClassName);if(classInst.global.hoverClassName!='')$acn(ele,classInst.global.hoverClassName);}}},_mout:function(e,classInst){if(classInst.type=='tip'){classInst._tipTO=setTimeout(function(){classInst._moutComplete();},300);}else if(classInst.type=='icon'){classInst._tipTO=setTimeout(function(){classInst._moutComplete();},300);}else if(classInst.type=='global'){if($ga(this,'A5ErrorId')!=''&&typeof $ga(this,'A5ErrorId')=='string'){var ele=$($ga(this,'A5ErrorId'));if(classInst.global.hoverInputClassName!='')$rcn(ele,classInst.global.hoverInputClassName);if(classInst.global.hoverClassName!='')$rcn(this,classInst.global.hoverClassName);}else{var ele=$(classInst._gcn(this)+'.ERRORGLOBALDIV');if(classInst.global.hoverInputClassName!='')$rcn(this,classInst.global.hoverInputClassName);if(classInst.global.hoverClassName!='')$rcn(ele,classInst.global.hoverClassName);}}},_moutComplete:function(){ele=$(this._tipId);if(ele)ele.style.display='none';this._tipId='';clearTimeout(this._tipTO);this._tipTO=0;},_stopTO:function(e,classInst){clearTimeout(classInst._tipTO);classInst._tipTO=0;},_globalSelect:function(e,classInst){var ele=$($ga(this,'A5ErrorId'));var pEle=ele;while(pEle.tagName.toLowerCase()!='body'){if(pEle.style.display=='none'||pEle.style.visibility=='hidden')return false;pEle=pEle.parentNode;}
if(ele.tagName){ele.focus();ele.select();}else ele[0].focus();},_gcn:function(ele){if(ele.id!='')return ele.id;else return ele.name;}}
Date.prototype.fromFormat=function(value,format){var switchYear=typeof arguments[2]=='number'?arguments[2]:50;if(switchYear>99||switchYear<0)switchYear=50;var rFrmt=this._parseFormat(format);var partValue='';this.setDate(1);for(var i=0;i<rFrmt.months.length;i++)value=value.replace(RegExp(rFrmt.months[i],'gi'),''+(i+1));for(var i=0;i<rFrmt.monthsShort.length;i++)value=value.replace(RegExp(rFrmt.monthsShort[i],'gi'),''+(i+1));var tValue=value.replace(/[^0-9]/g,'\n').split('\n');var pValue=new Array();for(var i=0;i<tValue.length;i++)if(tValue[i]!='')pValue.push(tValue[i]);var pValIndx=0;for(var i=0;i<rFrmt.formatContent.length;i++){if(rFrmt.formatContent[i]!=''){if(pValue[pValIndx])partValue=pValue[pValIndx];else break;if(rFrmt.formatContent[i]=='yyyy'){this.setFullYear($u.s.toNum(partValue));pValIndx++;}else if(rFrmt.formatContent[i]=='yy'||rFrmt.formatContent[i]=='y'){var num=$u.s.toNum(partValue);if(num<100)num=num+1900;if(num<1900+switchYear)num=num+100;this.setFullYear(num);pValIndx++;}else if(rFrmt.formatContent[i]=='MM'||rFrmt.formatContent[i]=='M'||rFrmt.formatContent[i].toLowerCase().substr(0,3)=='mon'){this.setMonth($u.s.toNum(partValue)-1);pValIndx++;}else if(rFrmt.formatContent[i]=='dd'||rFrmt.formatContent[i]=='d'||rFrmt.formatContent[i]=='x'){this.setDate($u.s.toNum(partValue));pValIndx++;}else if(rFrmt.formatContent[i]=='0h'||rFrmt.formatContent[i]=='h'){var amIndx=Math.max(Math.max($u.a.find(rFrmt.formatContent,'am'),$u.a.find(rFrmt.formatContent,'AM')),$u.a.find(rFrmt.formatContent,'A'));if(amIndx==-1)this.setHours($u.s.toNum(partValue));else{var amValue=value;for(var j=0;j<rFrmt.fromatMask.length;j++)amValue=amValue.replace(RegExp(rFrmt.fromatMask[j],'gi'),'');amValue=amValue.replace(/[0-9]/g,'');var num=$u.s.toNum(partValue);if(amValue.search(RegExp('p','i'))!=-1){if(num<12)num=num+12;this.setHours(num);}else if(amValue.search(RegExp('a','i'))!=-1){if(num==12)num=0;this.setHours(num);}else this.setHours(num);}
pValIndx++;}else if(rFrmt.formatContent[i]=='0m'||rFrmt.formatContent[i]=='m'){this.setMinutes($u.s.toNum(partValue));pValIndx++;}else if(rFrmt.formatContent[i]=='0s'||rFrmt.formatContent[i]=='s'){this.setSeconds($u.s.toNum(partValue));pValIndx++;}}}}
Date.prototype.toFormat=function(format){var rFrmt=this._parseFormat(format);var rVal=[];for(var i=0;i<rFrmt.fromatMask.length;i++){rVal.push(rFrmt.fromatMask[i]);if(rFrmt.formatContent[i]=='yyyy')rVal.push($u.s.pad(''+(this.getFullYear()),4,'0'));else if(rFrmt.formatContent[i]=='yy'||rFrmt.formatContent[i]=='y'){var num=Number(String(this.getFullYear()).substr(2));if(num>=100)num=num-100;rVal.push($u.s.pad(''+num,2,'0'));}else if(rFrmt.formatContent[i]=='MM')rVal.push($u.s.pad(''+(this.getMonth()+1),2,'0'));else if(rFrmt.formatContent[i]=='M')rVal.push(this.getMonth()+1);else if(rFrmt.formatContent[i].toLowerCase().substr(0,3)=='mon'){var caseChange='';if(rFrmt.formatContent[i].substr(1,1)=='O')caseChange='u';else if(rFrmt.formatContent[i].substr(0,1)=='m')caseChange='l';else if(rFrmt.formatContent[i].substr(0,1)=='M'&&rFrmt.formatContent[i].substr(1,1)=='o')caseChange='fu';if(rFrmt.formatContent[i].length==3)var curMonth=rFrmt.monthsShort[this.getMonth()];else var curMonth=rFrmt.months[this.getMonth()];curMonth=$u.s.changeCase(curMonth,caseChange);rVal.push(curMonth);}else if(rFrmt.formatContent[i]=='dd')rVal.push($u.s.pad(''+this.getDate(),2,'0'));else if(rFrmt.formatContent[i]=='d')rVal.push(this.getDate());else if(rFrmt.formatContent[i]=='x')rVal.push($u.n.toPlaceStr(this.getDate()));else if(rFrmt.formatContent[i].toLowerCase().substr(0,1)=='w'){if(rFrmt.formatContent[i]=='W')var curWDay=rFrmt.daysShort[this.getDay()].toUpperCase();else if(rFrmt.formatContent[i]=='w')var curWDay=rFrmt.daysShort[this.getDay()].toLowerCase();else{var caseChange='';if(rFrmt.formatContent[i].substr(1,1)=='E')caseChange='u';else if(rFrmt.formatContent[i].substr(0,1)=='w')caseChange='l';else if(rFrmt.formatContent[i].substr(0,1)=='W'&&rFrmt.formatContent[i].substr(1,1)=='e')caseChange='fu';var curWDay=$u.s.changeCase(rFrmt.days[this.getDay()],caseChange);}
rVal.push(curWDay);}else if(rFrmt.formatContent[i]=='0h'){if($u.a.find(rFrmt.formatContent,'am')==-1&&$u.a.find(rFrmt.formatContent,'AM')==-1&&$u.a.find(rFrmt.formatContent,'A')==-1)rVal.push($u.s.pad(''+this.getHours(),2,'0'));else{if(this.getHours()>12)rVal.push($u.s.pad(''+(this.getHours()-12),2,'0'));else if(this.getHours()==0)rVal.push('12');else rVal.push($u.s.pad(''+this.getHours(),2,'0'));}}else if(rFrmt.formatContent[i]=='h'){if($u.a.find(rFrmt.formatContent,'am')==-1&&$u.a.find(rFrmt.formatContent,'AM')==-1&&$u.a.find(rFrmt.formatContent,'A')==-1)rVal.push(this.getHours());else{if(this.getHours()>12)rVal.push(this.getHours()-12);else if(this.getHours()==0)rVal.push('12');else rVal.push(this.getHours());}}else if(rFrmt.formatContent[i]=='0m')rVal.push($u.s.pad(''+this.getMinutes(),2,'0'));else if(rFrmt.formatContent[i]=='m')rVal.push(this.getMinutes());else if(rFrmt.formatContent[i]=='0s')rVal.push($u.s.pad(''+this.getSeconds(),2,'0'));else if(rFrmt.formatContent[i]=='s')rVal.push(this.getSeconds());else if(rFrmt.formatContent[i]=='am'){if(this.getHours()>=12&&this.getHours()<24)rVal.push('pm');else rVal.push('am');}else if(rFrmt.formatContent[i]=='AM'){if(this.getHours()>=12&&this.getHours()<24)rVal.push('PM');else rVal.push('AM');}else if(rFrmt.formatContent[i]=='A'){if(this.getHours()>=12&&this.getHours()<24)rVal.push('P');else rVal.push('A');}}
return rVal.join('');}
Date.prototype._parseFormat=function(formatSettings){var rFrmt={format:'MM/dd/yyyy',fromatMask:[],fromatContent:[],days:['sunday','monday','tuesday','wednesday','thursday','friday','saturday'],daysShort:['sun','mon','tue','wed','thu','fri','sat'],months:['january','february','march','april','may','june','july','august','september','october','november','december'],monthsShort:['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec']}
if(typeof formatSettings=='string')rFrmt.format=formatSettings;else if(typeof formatSettings=='object'){if(formatSettings.parsed&&formatSettings.fromatMask&&formatSettings.formatContent)return formatSettings;if(formatSettings.months&&!formatSettings.monthsShort){formatSettings.monthsShort=new Array();for(var i=0;i<formatSettings.months.length;i++)formatSettings.monthsShort[i]=formatSettings.months[i].substr(0,3);}
if(formatSettings.days&&!formatSettings.daysShort){formatSettings.daysShort=new Array();for(var i=0;i<formatSettings.days.length;i++)formatSettings.daysShort[i]=formatSettings.days[i].substr(0,3);}
if(formatSettings.format){if(formatSettings.format=='')formatSettings.format='MM/dd/yyyy';}
$u.o.assign(rFrmt,formatSettings);}
var qFrmtsIndx=$u.a.find(['1-','2-','1/','2/','3','4','8','5-','6-','7-','5/','6/','7/','9-','10','11-','12-','11/','12/','11','12','3C','4C','8C','9C-','10C'],rFrmt.format);if(qFrmtsIndx!=-1){var qFrmtsMap=['MM-dd-yyyy','dd-MM-yyyy','MM/dd/yyyy','dd/MM/yyyy','d Month yyyy','Month d, yyyy','Month x, yyyy','MM-yy','MM-dd-yy','dd-MM-yy','MM/yy','MM/dd/yy','dd/MM/yy','dd-Mon-yy','dd Mon yyyy','yy-MM-dd','yyyy-MM-dd','yy/MM/dd','yyyy/MM/dd','yy.MM.dd','yyyy.MM.dd','d MONTH yyyy','MONTH d, yyyy','MONTH x, yyyy','d-MON-yy','d-MON-yyyy'];rFrmt.format=qFrmtsMap[qFrmtsIndx];}
var format=rFrmt.format;var search=[/([^\\])Weekday/g,/([^\\])WEEKDAY/g,/([^\\])weekday/g,,/([^\\])W/g,/([^\\])w/g,/([^\\])yyyy/g,/([^\\])yy/g,/([^\\])y/g,/([^\\])Month/g,/([^\\])MONTH/g,/([^\\])month/g,/([^\\])Mon/g,/([^\\])MON/g,/([^\\])mon/g,/([^\\])MM/g,/([^\\])M/g,/([^\\])dd/g,/([^\\])d/g,/([^\\])x/g,/([^\\])am/g,/([^\\])AM/g,/([^\\])A/g,/([^\\])0h/g,/([^\\])h/g,/([^\\])0m/g,/([^\\])m/g,/([^\\])0s/g,/([^\\])s/g];var formatMaskStr=' '+format;for(var i=0;i<search.length;i++)formatMaskStr=formatMaskStr.replace(search[i],'$1~~~~');formatMaskStr=formatMaskStr.substr(1);var fromatMask=formatMaskStr.split('~~~~');var formatContent=[];search=[/\\Weekday/g,/\\WEEKDAY/g,/\\weekday/g,/\\W/g,/\\w/g,/\\yyyy/g,/\\yy/g,/\\y/g,/\\Month/g,/\\MONTH/g,/\\month/g,/\\Mon/g,/\\MON/g,/\\mon/g,/\\MM/g,/\\M/g,/\\dd/g,/\\d/g,/\\x/g,/\\am/g,/\\AM/g,/\\A/g,/\\0h/g,/\\h/g,/\\0m/g,/\\m/g,/\\0s/g,/\\s/g];var replace=['Weekday','WEEKDAY','weekday','W','w','yyyy','yy','y','Month','MONTH','month','Mon','MON','mon','MM','M','dd','d','x','am','AM','A','0h','h','0m','m','0s','s'];for(var i=0;i<fromatMask.length;i++){format=format.substr(fromatMask[i].length);formatContent.push($u.s.word(format,1,fromatMask[i+1]));format=format.substr(formatContent[i].length);for(var j=0;j<search.length;j++)fromatMask[i]=fromatMask[i].replace(search[j],replace[j]);}
rFrmt.fromatMask=fromatMask;rFrmt.formatContent=formatContent;rFrmt.hasTime=$if($u.a.find(formatContent,'h')!=-1||$u.a.find(formatContent,'0h')!=-1,true,false);rFrmt.hasDate=$if($u.a.find(formatContent,'y')!=-1||$u.a.find(formatContent,'yy')!=-1||$u.a.find(formatContent,'yyyy')!=-1,true,false);rFrmt.secondsMode=$if($u.a.find(formatContent,'s')!=-1||$u.a.find(formatContent,'0s')!=-1,'normal','none');rFrmt.hasMeridian=$if($u.a.find(formatContent,'am')!=-1||$u.a.find(formatContent,'AM')!=-1||$u.a.find(formatContent,'A')!=-1,true,false);rFrmt.parsed=true;return rFrmt;}
A5.DatePicker=Class.create();A5.DatePicker.prototype={initialize:function(contId,settings){this.contId=contId;$u.o.assign(this,{inputId:'',days:['Sun','Mon','Tue','Wed','Thur','Fri','Sat'],months:['January','February','March','April','May','June','July','August','September','October','November','December'],startDay:0,disabledDates:{high:false,low:false,days:false},format:'MM/dd/yyyy',switchYear:50,date:0,width:'',height:'',className:'',style:0,calendar:{lockColumnWidth:true,daysOfWeek:{show:true,className:'',style:0},weeksOfYear:{show:false,className:'',style:0,headerClassName:''},date:{className:'',weekendClassName:'',todayClassName:'',style:0,item:{className:'',hoverClassName:'',selectedClassName:'',disabledClassName:'',outOfRangeClassName:'',style:0}}},navigator:{header:{className:'',style:0,prevIcon:'',nextIcon:'',prevIconHover:'',nextIconHover:'',todayButton:{show:false,location:'right',html:'Today',tip:'Select today\'s date'},item:{className:'',hoverClassName:'',selectedClassName:''}},panel:{className:'',style:0,edit:{className:'',style:0,icon:''},item:{className:'',hoverClassName:'',selectedClassName:'',disabledClassName:'',style:0}}},onItemDraw:0,onClick:0,onRightClick:0,onSelect:0,onNavigate:0,onMonthNavigate:0,onYearNavigate:0});if(typeof A5._datePickerDefaults!='undefined')$u.o.assign(this,A5._datePickerDefaults);if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'datePicker');$u.o.assign(this,settings);var validDate=false;var tempDate=new Date();this._parsedFormat=tempDate._parseFormat(this.format);if(this.date.constructor!=Date){if(typeof this.date=='string'){tempDate.fromFormat(this.date,this._parsedFormat,this.switchYear);this.date=tempDate;validDate=true;}else this.date=new Date();}else validDate=true;this._month=this.date.getMonth();this._year=this.date.getFullYear();this._oldMonth=this._month;this._oldYear=this._year;this._selDay=$if(validDate,this.date.getDate(),-1);this._selMonth=this._month;this._selYear=this._year;this._daysInMonth=0;this._daysInPrevMonth=0;this._monthStartDay=0;this._curPane='date';this._dd={high:false,low:false,days:[]}
this._dFocusId='';this._mFocusId='';this._yFocusId='';this._initRender();},refresh:function(){this._dd.low=false;this._dd.high=false;this._dd.days=false;if(this.disabledDates.low){var tempDate='';var tempDateParsed=new Date();if(this.disabledDates.low.constructor==Function)tempDate=this.disabledDates.low.call(this);else tempDate=this.disabledDates.low;if(typeof tempDate=='string'||tempDate.constructor==Date){if(typeof tempDate=='string')tempDateParsed.fromFormat(tempDate,this._parsedFormat,this.switchYear);else if(tempDate.constructor==Date)tempDateParsed=tempDate;this._dd.low=tempDateParsed;}}
if(this.disabledDates.high){var tempDate='';delete tempDateParsed;var tempDateParsed=new Date();if(this.disabledDates.high.constructor==Function)tempDate=this.disabledDates.high.call(this);else tempDate=this.disabledDates.high;if(typeof tempDate=='string'||tempDate.constructor==Date){if(typeof tempDate=='string')tempDateParsed.fromFormat(tempDate,this._parsedFormat,this.switchYear);else if(tempDate.constructor==Date)tempDateParsed=tempDate;this._dd.high=tempDateParsed;}}
if(this.disabledDates.days){if(this.disabledDates.days.constructor==Function){this._dd.days=new Array();$u.o.assign(this._dd.days,this.disabledDates.days.call(this));}else if(this.disabledDates.days.constructor==Array){this._dd.days=new Array();$u.o.assign(this._dd.days,this.disabledDates.days);}}
this._render();},nextMonth:function(){var yearNav=false;if(this._month==11){this._month=0;this._year++;if(this.onYearNavigate.constructor==Function)yearNav=true;}else this._month++;this._render();if(yearNav)this.onYearNavigate.call(this,this.date.toFormat(this._parsedFormat));if(this.onMonthNavigate.constructor==Function)this.onMonthNavigate.call(this,this.date.toFormat(this._parsedFormat));},prevMonth:function(){var yearNav=false;if(this._month==0){this._month=11;this._year--;if(this.onYearNavigate.constructor==Function)yearNav=true;}else this._month--;this._render();if(yearNav)this.onYearNavigate.call(this,this.date.toFormat(this._parsedFormat));if(this.onMonthNavigate.constructor==Function)this.onMonthNavigate.call(this,this.date.toFormat(this._parsedFormat));},nextYear:function(){this._year++;this._render();if(this.onYearNavigate.constructor==Function)this.onYearNavigate.call(this,this.date.toFormat(this._parsedFormat));if(this.onMonthNavigate.constructor==Function)this.onMonthNavigate.call(this,this.date.toFormat(this._parsedFormat));},prevYear:function(){this._year--;this._render();if(this.onYearNavigate.constructor==Function)this.onYearNavigate.call(this,this.date.toFormat(this._parsedFormat));if(this.onMonthNavigate.constructor==Function)this.onMonthNavigate.call(this,this.date.toFormat(this._parsedFormat));},setYear:function(year){this._year=year;this._render();if(this.onYearNavigate.constructor==Function)this.onYearNavigate.call(this,this.date.toFormat(this._parsedFormat));if(this.onMonthNavigate.constructor==Function)this.onMonthNavigate.call(this,this.date.toFormat(this._parsedFormat));},prevDecade:function(){if(this._dd.low){if(this._dd.low.getFullYear()<=this._decade)this._renderDecade(this._decade-10);}else this._renderDecade(this._decade-10);var ele=$(this.contId+'.DATEPICKER.YEAR.INPUT');ele.focus();ele.select();},nextDecade:function(){if(this._dd.high){if(this._dd.high.getFullYear()>=this._decade+10)this._renderDecade(this._decade+10);}else this._renderDecade(this._decade+10);var ele=$(this.contId+'.DATEPICKER.YEAR.INPUT');ele.focus();ele.select();},setValue:function(date){var validDate=false;if(date.constructor!=Date){if(typeof date=='string'){var tempDate=new Date();tempDate.fromFormat(date,this._parsedFormat,this.switchYear);this.date=tempDate;validDate=true;}}else{this.date=date;validDate=true;}
if(validDate){this._month=this.date.getMonth();this._year=this.date.getFullYear();this._oldMonth=this._month;this._oldYear=this._year;this._selDay=this.date.getDate();this._selMonth=this._month;this._selYear=this._year;this.date.setFullYear(this._selYear);this.date.setDate(1);this.date.setMonth(this._selMonth);this.date.setDate(this._selDay);this._togglePane('date');}else this._togglePane('date');this.refresh();},_monthPane:function(e){this._togglePane('month');$e.stopEvent(e);return false;},_yearPane:function(e){this._togglePane('year');$e.stopEvent(e);return false;},_monthClick:function(e,classInst){$e.stopEvent(e);if($ga(this,'A5DatePickerItemDisabled')=='true')return false;var month=this.id.split('.');month=Number(month.pop());classInst._month=month;classInst._render();classInst._togglePane('date');if(classInst.onMonthNavigate.constructor==Function)classInst.onMonthNavigate.call(classInst,classInst.date.toFormat(classInst._parsedFormat));return false;},_yearClick:function(e,classInst){$e.stopEvent(e);if($ga(this,'A5DatePickerItemDisabled')=='true')return false;var year=Number(this.innerHTML);classInst._year=year;classInst._render();classInst._togglePane('date');if(classInst.onYearNavigate.constructor==Function)classInst.onYearNavigate.call(classInst,classInst.date.toFormat(classInst._parsedFormat));if(classInst.onMonthNavigate.constructor==Function)classInst.onMonthNavigate.call(classInst,classInst.date.toFormat(classInst._parsedFormat));return false;},_prevDecade:function(e,classInst){classInst.prevDecade();$e.stopEvent(e);return false;},_nextDecade:function(e,classInst){classInst.nextDecade();$e.stopEvent(e);return false;},_inputYear:function(e,classInst){var keyCode=e.charCode||e.keyCode;if(keyCode==13||!keyCode){classInst.setYear($u.s.toNum(this.value));classInst._togglePane('date');}},_prevButton:function(e){if(this._curPane=='year')this.prevDecade();else if(this._curPane=='month')this.prevYear();else this.prevMonth();$e.stopEvent(e);return false;},_nextButton:function(e){if(this._curPane=='year')this.nextDecade();else if(this._curPane=='month')this.nextYear();else this.nextMonth();$e.stopEvent(e);return false;},_todayButton:function(e){var cDate=new Date();this._month=cDate.getMonth();this._year=cDate.getFullYear();this._oldMonth=this._month;this._oldYear=this._year;this._selDay=cDate.getDate();this._selMonth=this._month;this._selYear=this._year;this.date.setFullYear(this._selYear);this.date.setDate(1);this.date.setMonth(this._selMonth);this.date.setDate(this._selDay);this._togglePane('date');this.refresh();if($(this.inputId)){$svs(this.inputId,this.date.toFormat(this._parsedFormat));$e.execute(this.inputId,'change');}
if(this.onYearNavigate.constructor==Function)this.onYearNavigate.call(this,this.date.toFormat(this._parsedFormat));if(this.onMonthNavigate.constructor==Function)this.onMonthNavigate.call(this,this.date.toFormat(this._parsedFormat));if(this.onSelect.constructor==Function)this.onSelect.call(this,this.date.toFormat(this._parsedFormat));if(this.onClick.constructor==Function)this.onClick.call(this,this.date.toFormat(this._parsedFormat));$e.stopEvent(e);return false;},_dClick:function(e,classInst){$e.stopEvent(e);this.blur();if($ga(this,'A5DatePickerItemDisabled')=='true')return false;var day=Number($ga(this,'A5DatePickerDay'));var month=classInst._month+Number($ga(this,'A5DatePickerDayMonth'));var year=classInst._year;if(month==-1){year--;month=11;}else if(month==12){year++;month=0;}
var yearNav=false;var monthNav=false;if(classInst._year!=year&&classInst.onYearNavigate.constructor==Function)yearNav=true;if(classInst._month!=month&&classInst.onMonthNavigate.constructor==Function)monthNav=true;classInst._year=year;classInst._month=month;classInst._selDay=day;classInst._selMonth=classInst._month;classInst._selYear=classInst._year;classInst._render();classInst.date.setFullYear(classInst._selYear);classInst.date.setDate(1);classInst.date.setMonth(classInst._selMonth);classInst.date.setDate(classInst._selDay);if($(classInst.inputId)){$svs(classInst.inputId,classInst.date.toFormat(classInst._parsedFormat));$e.execute(classInst.inputId,'change');}
if(yearNav)classInst.onYearNavigate.call(classInst,classInst.date.toFormat(classInst._parsedFormat));if(monthNav)classInst.onMonthNavigate.call(classInst,classInst.date.toFormat(classInst._parsedFormat));if(classInst.onSelect.constructor==Function)classInst.onSelect.call(classInst,classInst.date.toFormat(classInst._parsedFormat));if(classInst.onClick.constructor==Function)classInst.onClick.call(classInst,classInst.date.toFormat(classInst._parsedFormat));return false;},_togglePane:function(type){var cEle=$(this.contId+'.DATEPICKER');var tEle=$(this.contId+'.DATEPICKER.TITLE');var dEle=$(this.contId+'.DATEPICKER.DATEPANE');var mEle=$(this.contId+'.DATEPICKER.MONTHPANE');var yEle=$(this.contId+'.DATEPICKER.YEARPANE');var paneHeight=dEle.offsetHeight+'px';if(type=='month'&&this._curPane!='month'){if(this._curPane=='date'){cEle.style.height=cEle.offsetHeight+'px';cEle.style.width=cEle.offsetWidth+'px';$(this.contId+'.DATEPICKER.MONTHTABLE').style.height=paneHeight;$(this.contId+'.DATEPICKER.YEARTABLE').style.height=paneHeight;}
dEle.style.display='none';mEle.style.display='';yEle.style.display='none';$acn(this.contId+'.DATEPICKER.MONTH',this.navigator.header.item.selectedClassName);$rcn(this.contId+'.DATEPICKER.YEAR',this.navigator.header.item.selectedClassName);this._curPane='month';}else if(type=='year'&&this._curPane!='year'){if(this._curPane=='date'){cEle.style.height=cEle.offsetHeight+'px';cEle.style.width=cEle.offsetWidth+'px';$(this.contId+'.DATEPICKER.MONTHTABLE').style.height=paneHeight;$(this.contId+'.DATEPICKER.YEARTABLE').style.height=paneHeight;}
dEle.style.display='none';mEle.style.display='none';yEle.style.display='';$rcn(this.contId+'.DATEPICKER.MONTH',this.navigator.header.item.selectedClassName);$acn(this.contId+'.DATEPICKER.YEAR',this.navigator.header.item.selectedClassName);var ele=$(this.contId+'.DATEPICKER.YEAR.INPUT');ele.focus();ele.select();this._curPane='year';}else{tEle.style.height='';tEle.style.display='';cEle.style.height='';cEle.style.width='';dEle.style.display='';mEle.style.display='none';yEle.style.display='none';$rcn(this.contId+'.DATEPICKER.MONTH',this.navigator.header.item.selectedClassName);$rcn(this.contId+'.DATEPICKER.YEAR',this.navigator.header.item.selectedClassName);this._curPane='date';}},_mOver:function(e,classInst){var fId='';if(classInst._curPane=='month')fId=classInst._mFocusId;else if(classInst._curPane=='year')fId=classInst._yFocusId;else fId=classInst._dFocusId;if(fId!=''){if(classInst._curPane=='month'||classInst._curPane=='year')$rcn(fId,classInst.navigator.panel.item.hoverClassName);else $rcn(fId,classInst.calendar.date.item.hoverClassName);}
fId='';if($ga(this,'A5DatePickerItemDisabled')!='true'){fId=this.id;if(classInst._curPane=='month'||classInst._curPane=='year')$acn(this,classInst.navigator.panel.item.hoverClassName);else $acn(this,classInst.calendar.date.item.hoverClassName);}
if(classInst._curPane=='month')classInst._mFocusId=fId;else if(classInst._curPane=='year')classInst._yFocusId=fId;else classInst._dFocusId=fId;},_mOut:function(e,classInst){if(classInst._curPane=='month')classInst._mFocusId='';else if(classInst._curPane=='year')classInst._yFocusId='';else classInst._dFocusId='';if(classInst._curPane=='month'||classInst._curPane=='year')$rcn(this,classInst.navigator.panel.item.hoverClassName);else $rcn(this,classInst.calendar.date.item.hoverClassName);},_nmOver:function(e,classInst){if(classInst.navigator.header.item.hoverClassName!='')$acn(this,classInst.navigator.header.item.hoverClassName);},_nmOut:function(e,classInst){if(classInst.navigator.header.item.hoverClassName!='')$rcn(this,classInst.navigator.header.item.hoverClassName);},_rClick:function(e,classInst){if(classInst.onRightClick.constructor==Function){if(this.id==classInst.contId+'.DATEPICKER')classInst.onRightClick(new Date(classInst._year,classInst._month,1),'datepicker');else if(classInst._curPane=='month')classInst.onRightClick(new Date(classInst._year,Number(this.id.split('.').pop()),1),'month');else if(classInst._curPane=='year')classInst.onRightClick(new Date(Number(this.innerHTML),classInst._month,1),'year');else{var day=Number($ga(this,'A5DatePickerDay'));var month=classInst._month+Number($ga(this,'A5DatePickerDayMonth'));var year=classInst._year;if(month==-1){year--;month=11;}else if(month==12){year++;month=0;}
classInst.onRightClick(new Date(year,month,day),'date');}
$e.stopEvent(e);return false;}},_render:function(){if(this._dd.low){if(this._dd.low.getFullYear()>=this._year){this._year=this._dd.low.getFullYear();if(this._dd.low.getMonth()>=this._month)this._month=this._dd.low.getMonth();}}
if(this._dd.high){if(this._dd.high.getFullYear()<=this._year){this._year=this._dd.high.getFullYear();if(this._dd.high.getMonth()<=this._month)this._month=this._dd.high.getMonth();}}
var cDate=new Date(this._year,this._month,1);var nDate=new Date();var tDay=nDate.getDate();var tMonth=nDate.getMonth();var tYear=nDate.getFullYear();this._monthStartDay=cDate.getDay();this._monthStartDay=this._monthStartDay-this.startDay;if(this._monthStartDay<0)this._monthStartDay=this._monthStartDay+7;if(this._month==11){nDate.setDate(1);nDate.setMonth(0);nDate.setFullYear(this._year+1);}else{nDate.setDate(1);nDate.setMonth(this._month+1);nDate.setFullYear(this._year);}
cDate.setDate(0);nDate.setDate(0);this._daysInMonth=nDate.getDate();this._daysInPrevMonth=cDate.getDate();var hasOIDEvnt=this.onItemDraw.constructor==Function;var tEle=$(this.contId+'.DATEPICKER');var cDay=1;var cMonth=$if(this._month==0,11,this._month-1);var cYear=$if(this._month==0,this._year-1,this._year);var cdClassName='';var cdDisable=false;var cDayOOR=true;if(this._monthStartDay>0)cDay=this._daysInPrevMonth+1-this._monthStartDay;else cDay=this._daysInPrevMonth-6;var cdEle=0;var ysDate=0;var wofVal=0;for(var i=2;i<8;i++){if(this.calendar.weeksOfYear.show){ysDate=new Date(cYear,0,1);wofVal=Math.ceil((((new Date(cYear,cMonth,cDay)-ysDate)/86400000)+ysDate.getDay()+1)/7);if(wofVal==0)wofVal=52;else if(wofVal==53)wofVal=1;tEle.rows[i].cells[0].innerHTML=wofVal;}
for(var j=1;j<8;j++){tEle.rows[i].cells[j].className=this._dcn[j-1];if(tYear==cYear&&tMonth==cMonth&&tDay==cDay)tEle.rows[i].cells[j].className=this._dcn[j-1]+' '+this.calendar.date.todayClassName;else tEle.rows[i].cells[j].className=this._dcn[j-1];cdEle=tEle.rows[i].cells[j].firstChild;cdDisable=false;if(this._dd.low){if(this._dd.low.getFullYear()>cYear)cdDisable=true;else if(this._dd.low.getFullYear()==cYear){if(this._dd.low.getMonth()>cMonth)cdDisable=true;else if(this._dd.low.getMonth()==cMonth&&this._dd.low.getDate()>cDay)cdDisable=true;}}
if(this._dd.high){if(this._dd.high.getFullYear()<cYear)cdDisable=true;else if(this._dd.high.getFullYear()==cYear){if(this._dd.high.getMonth()<cMonth)cdDisable=true;else if(this._dd.high.getMonth()==cMonth&&this._dd.high.getDate()<cDay)cdDisable=true;}}
if(this._dd.days){if($u.a.find(this._dd.days,this._di[j-1])!=-1)cdDisable=true;}
cdClassName=$if(cYear==this._selYear&&cMonth==this._selMonth&&cDay==this._selDay,this.calendar.date.item.className+' '+this.calendar.date.item.selectedClassName,this.calendar.date.item.className);if(cdDisable){$sa(cdEle,'A5DatePickerItemDisabled','true');cdClassName=cdClassName+' '+this.calendar.date.item.disabledClassName;}else $sa(cdEle,'A5DatePickerItemDisabled','false');$sa(cdEle,'A5DatePickerDay',''+cDay);cdEle.innerHTML=''+cDay;if(hasOIDEvnt)this.onItemDraw.call(this,cdEle,new Date(cYear,cMonth,cDay),'date');if(i<4){if(cDayOOR){cdEle.className=cdClassName+' '+this.calendar.date.item.outOfRangeClassName;$sa(cdEle,'A5DatePickerDayMonth','-1');}else{cdEle.className=cdClassName;$sa(cdEle,'A5DatePickerDayMonth','0');}
if(cDay==this._daysInPrevMonth){cDay=1;cDayOOR=false;cYear=$if(cMonth==11,cYear+1,cYear);cMonth=$if(cMonth==11,0,cMonth+1);}else cDay++;}else{if(cDayOOR){cdEle.className=cdClassName+' '+this.calendar.date.item.outOfRangeClassName;$sa(cdEle,'A5DatePickerDayMonth','1');}else{cdEle.className=cdClassName;$sa(cdEle,'A5DatePickerDayMonth','0');}
if(cDay==this._daysInMonth){cDay=1;cDayOOR=true;cYear=$if(cMonth==11,cYear+1,cYear);cMonth=$if(cMonth==11,0,cMonth+1);}else cDay++;}}}
$(this.contId+'.DATEPICKER.MONTH').innerHTML=this.months[this._month];$(this.contId+'.DATEPICKER.YEAR').innerHTML=this._year;$(this.contId+'.DATEPICKER.YEAR.INPUT').value=this._year;var mEle=0;var mClassName='';var mDisable=false;for(var i=0;i<12;i++){mEle=$(this.contId+'.DATEPICKER.MONTH.'+i);mDisable=false;if(this._dd.low){if(this._dd.low.getFullYear()>this._year)mDisable=true;else if(this._dd.low.getFullYear()==this._year&&this._dd.low.getMonth()>i)mDisable=true;}
if(this._dd.high){if(this._dd.high.getFullYear()<this._year)mDisable=true;else if(this._dd.high.getFullYear()==this._year&&this._dd.high.getMonth()<i)mDisable=true;}
if(i==this._month)mClassName=this.navigator.panel.item.className+' '+this.navigator.panel.item.selectedClassName;else mClassName=this.navigator.panel.item.className;if(mDisable){$sa(mEle,'A5DatePickerItemDisabled','true');mClassName=mClassName+' '+this.navigator.panel.item.disabledClassName;}else $sa(mEle,'A5DatePickerItemDisabled','false');mEle.className=mClassName;if(hasOIDEvnt)this.onItemDraw.call(this,mEle,new Date(this._year,i,1),'month');}
$rcn(this.contId+'.DATEPICKER.MONTH.'+this._oldMonth,this.navigator.panel.item.selectedClassName);$acn(this.contId+'.DATEPICKER.MONTH.'+this._month,this.navigator.panel.item.selectedClassName);this._renderDecade((Math.round((this._year-4.9999999)/10)*10));this._oldMonth=this._month;this._oldYear=this._year;},_renderDecade:function(decade){var ele=0;var yClassName='';var yDisable=false;var hasOIDEvnt=this.onItemDraw.constructor==Function;for(var i=0;i<10;i++){ele=$(this.contId+'.DATEPICKER.YEAR.'+i)
ele.innerHTML=String(decade+i);yDisable=false;if(this._dd.low)if(this._dd.low.getFullYear()>decade+i)yDisable=true;if(this._dd.high)if(this._dd.high.getFullYear()<decade+i)yDisable=true;if(decade+i==this._year)yClassName=this.navigator.panel.item.className+' '+this.navigator.panel.item.selectedClassName;else yClassName=this.navigator.panel.item.className;if(yDisable){$sa(ele,'A5DatePickerItemDisabled','true');yClassName=yClassName+' '+this.navigator.panel.item.disabledClassName;}else $sa(ele,'A5DatePickerItemDisabled','false');ele.className=yClassName;if(hasOIDEvnt)this.onItemDraw.call(this,ele,new Date(decade+i,1,1),'year');}
this._decade=decade;},_initRender:function(){var di=new Array();var dcn=new Array();for(var i=0;i<7;i++){di[i]=i+this.startDay;if(di[i]>6)di[i]=di[i]-7;if(this.calendar.date.className.constructor==Array){if(this.calendar.date.className[di[i]])dcn[i]=this.calendar.date.className[di[i]];else dcn[i]=this.calendar.date.weekendClassName;}else{if(di[i]==0||di[i]==6)dcn[i]=this.calendar.date.weekendClassName;else dcn[i]=this.calendar.date.className;}}
this._di=di;this._dcn=dcn;var weekOfYearDisplay='none';var dayOfWeekDisplay='none';var intersectionDisplay='none';var cellWidth='14.2%';if(this.calendar.daysOfWeek.show)dayOfWeekDisplay='';if(this.calendar.weeksOfYear.show){weekOfYearDisplay='';cellWidth='12.5%';}
if(this.calendar.daysOfWeek.show&&this.calendar.weeksOfYear.show)intersectionDisplay='';if(!this.calendar.lockColumnWidth)cellWidth='';var html=['<table id="{BASEID}.DATEPICKER" cellspacing="0" class="'+this.className+'" style="width: '+this.width+'; height: '+this.height+'; ">',' <tr>','  <th id="{BASEID}.DATEPICKER.TITLE" colspan="8" class="'+this.navigator.header.className+'">','   <div id="{BASEID}.DATEPICKER.PREVBUTTON" style="float: left;"><img src="'+this.navigator.header.prevIcon+'" align="top" /></div>','   <div id="{BASEID}.DATEPICKER.NEXTBUTTON" style="float: right;"><img src="'+this.navigator.header.nextIcon+'" align="top" /></div>','   <div id="{BASEID}.DATEPICKER.MONTHYEARBUTTONS"><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH" class="'+this.navigator.header.item.className+'"></a> <a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR" class="'+this.navigator.header.item.className+'"></a></div>','  </th>',' </tr>',' <tbody id="{BASEID}.DATEPICKER.DATEPANE">','  <tr>','   <td class="'+this.calendar.daysOfWeek.className+' '+this.calendar.weeksOfYear.headerClassName+'" style="width: '+cellWidth+'; display: '+intersectionDisplay+'"></td>','   <th class="'+this.calendar.daysOfWeek.className+'" style="width: '+cellWidth+'; display: '+dayOfWeekDisplay+';">'+this.days[di[0]]+'</th>','   <th class="'+this.calendar.daysOfWeek.className+'" style="width: '+cellWidth+'; display: '+dayOfWeekDisplay+';">'+this.days[di[1]]+'</th>','   <th class="'+this.calendar.daysOfWeek.className+'" style="width: '+cellWidth+'; display: '+dayOfWeekDisplay+';">'+this.days[di[2]]+'</th>','   <th class="'+this.calendar.daysOfWeek.className+'" style="width: '+cellWidth+'; display: '+dayOfWeekDisplay+';">'+this.days[di[3]]+'</th>','   <th class="'+this.calendar.daysOfWeek.className+'" style="width: '+cellWidth+'; display: '+dayOfWeekDisplay+';">'+this.days[di[4]]+'</th>','   <th class="'+this.calendar.daysOfWeek.className+'" style="width: '+cellWidth+'; display: '+dayOfWeekDisplay+';">'+this.days[di[5]]+'</th>','   <th class="'+this.calendar.daysOfWeek.className+'" style="width: '+cellWidth+'; display: '+dayOfWeekDisplay+';">'+this.days[di[6]]+'</th>','  </tr>'];for(var i=0;i<6;i++){html=html.concat(['  <tr>','   <td id="{BASEID}.DV'+i+'.0" class="'+this.calendar.weeksOfYear.className+'" align="center" vAlign="center" style="display: '+weekOfYearDisplay+'; width: '+cellWidth+';"></td>','   <td id="{BASEID}.DV'+i+'.1" class="'+dcn[0]+'" style="width: '+cellWidth+';"><a href="#" tabindex="-1" class="'+this.calendar.date.item.className+'">&nbsp;</a></td>','   <td id="{BASEID}.DV'+i+'.2" class="'+dcn[1]+'" style="width: '+cellWidth+';"><a href="#" tabindex="-1" class="'+this.calendar.date.item.className+'">&nbsp;</a></td>','   <td id="{BASEID}.DV'+i+'.3" class="'+dcn[2]+'" style="width: '+cellWidth+';"><a href="#" tabindex="-1" class="'+this.calendar.date.item.className+'">&nbsp;</a></td>','   <td id="{BASEID}.DV'+i+'.4" class="'+dcn[3]+'" style="width: '+cellWidth+';"><a href="#" tabindex="-1" class="'+this.calendar.date.item.className+'">&nbsp;</a></td>','   <td id="{BASEID}.DV'+i+'.5" class="'+dcn[4]+'" style="width: '+cellWidth+';"><a href="#" tabindex="-1" class="'+this.calendar.date.item.className+'">&nbsp;</a></td>','   <td id="{BASEID}.DV'+i+'.6" class="'+dcn[5]+'" style="width: '+cellWidth+';"><a href="#" tabindex="-1" class="'+this.calendar.date.item.className+'">&nbsp;</a></td>','   <td id="{BASEID}.DV'+i+'.7" class="'+dcn[6]+'" style="width: '+cellWidth+';"><a href="#" tabindex="-1" class="'+this.calendar.date.item.className+'">&nbsp;</a></td>','  </tr>']);}
html=html.concat([' </tbody>',' <tbody id="{BASEID}.DATEPICKER.MONTHPANE" style="display: none;">','  <tr>','   <td class="'+this.navigator.panel.className+'" colspan="8" style="padding: 0px;">','    <table id="{BASEID}.DATEPICKER.MONTHTABLE" cellspacing="0" cellpadding="2" style="width: 100%; height: 100%;">','     <tr>','      <td style="width:33%"><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.0" class="'+this.navigator.panel.item.className+'">'+this.months[0]+'</a></td>','      <td style="width:34%"><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.1" class="'+this.navigator.panel.item.className+'">'+this.months[1]+'</a></td>','      <td style="width:33%"><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.2" class="'+this.navigator.panel.item.className+'">'+this.months[2]+'</a></td>','     </tr>','     <tr>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.3" class="'+this.navigator.panel.item.className+'">'+this.months[3]+'</a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.4" class="'+this.navigator.panel.item.className+'">'+this.months[4]+'</a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.5" class="'+this.navigator.panel.item.className+'">'+this.months[5]+'</a></td>','     </tr>','     <tr>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.6" class="'+this.navigator.panel.item.className+'">'+this.months[6]+'</a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.7" class="'+this.navigator.panel.item.className+'">'+this.months[7]+'</a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.8" class="'+this.navigator.panel.item.className+'">'+this.months[8]+'</a></td>','     </tr>','     <tr>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.9" class="'+this.navigator.panel.item.className+'">'+this.months[9]+'</a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.10" class="'+this.navigator.panel.item.className+'">'+this.months[10]+'</a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.11" class="'+this.navigator.panel.item.className+'">'+this.months[11]+'</a></td>','     </tr>','    </table>','   </td>','  </tr>',' </tbody>',' <tbody id="{BASEID}.DATEPICKER.YEARPANE" style="display: none;">','  <tr>','   <td class="'+this.navigator.panel.className+'" colspan="8" style="padding: 0px;">','    <table id="{BASEID}.DATEPICKER.YEARTABLE" cellspacing="0" cellpadding="2" style="width: 100%; height: 100%;">','     <tr>','      <td colspan="4" align="center">','       <input id="{BASEID}.DATEPICKER.YEAR.INPUT" size="4" class="'+this.navigator.panel.edit.className+'" style="text-align: center;" />','       <img id="{BASEID}.DATEPICKER.YEAR.INPUTCOMMIT" src="'+this.navigator.panel.edit.icon+'" align="top" />','      </td>','     </tr>','     <tr>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.PREVDEC" class="'+this.navigator.panel.item.className+'">&laquo;</a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.0" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.1" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.2" class="'+this.navigator.panel.item.className+'"></a></td>','     </tr>','     <tr>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.3" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.4" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.5" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.6" class="'+this.navigator.panel.item.className+'"></a></td>','     </tr>','     <tr>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.7" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.8" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.9" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.NEXTDEC" class="'+this.navigator.panel.item.className+'">&raquo;</a></td>','     </tr>','    </table>','   </td>','  </tr>',' </tbody>','</table>']);html=html.join('\n');html=$u.s.tran(html,'{BASEID}',this.contId);$(this.contId).innerHTML=html;if(this.navigator.header.todayButton.show){var ele=document.createElement('a');ele.href='#';ele.tabIndex='-1';ele.id=this.contId+'.DATEPICKER.TODAYBUTTON';ele.className=this.navigator.header.item.className;ele.title=this.navigator.header.todayButton.tip;ele.innerHTML=this.navigator.header.todayButton.html;var tempEle=$(this.contId+'.DATEPICKER.TITLE');if(this.navigator.header.todayButton.location=='center'){tempEle=$(this.contId+'.DATEPICKER.MONTHYEARBUTTONS');tempEle.appendChild(document.createTextNode(' - '));tempEle.appendChild(ele);}else if(this.navigator.header.todayButton.location=='left'){$ss(ele,'float: left;');tempEle.insertBefore(ele,$(this.contId+'.DATEPICKER.NEXTBUTTON'));}else{$ss(ele,'float: right;');tempEle.insertBefore(ele,$(this.contId+'.DATEPICKER.MONTHYEARBUTTONS'));}
$e.add(ele,'click',this._todayButton,this,true);$e.add(ele,'mouseover',this._nmOver,this);$e.add(ele,'mouseout',this._nmOut,this);}
var tEle=$(this.contId+'.DATEPICKER');if(typeof this.style=='object'||typeof this.style=='string')$ss(tEle,this.style);$e.add(tEle,'contextmenu',this._rClick,this);var eles=$(this.contId+'.DATEPICKER.DATEPANE').getElementsByTagName('a');$e.add(eles,'click',this._dClick,this);$e.add(eles,'mouseover',this._mOver,this);$e.add(eles,'mouseout',this._mOut,this);$e.add(eles,'contextmenu',this._rClick,this);if(typeof this.calendar.date.item.style=='object'||typeof this.calendar.date.item.style=='string')$ss(eles,this.calendar.date.item.style);if(typeof this.calendar.date.style=='object'||typeof this.calendar.date.style=='string'){for(var i=2;i<8;i++){for(var j=1;j<8;j++){$ss(tEle.rows[i].cells[j],this.calendar.date.style);if(cellWidth!='')tEle.rows[i].cells[j].style.width=cellWidth;}}}
if(typeof this.calendar.daysOfWeek.style=='object'||typeof this.calendar.daysOfWeek.style=='string'){for(var j=1;j<8;j++){$ss(tEle.rows[1].cells[j],this.calendar.daysOfWeek.style);if(this.calendar.daysOfWeek.show)tEle.rows[2].cells[j].style.display='';else tEle.rows[1].cells[j].style.display='none';}}
if(typeof this.calendar.weeksOfYear.style=='object'||typeof this.calendar.weeksOfYear.style=='string'){for(var i=1;i<8;i++){$ss(tEle.rows[i].cells[0],this.calendar.weeksOfYear.style);if(i==1){if(this.calendar.daysOfWeek.show&&this.calendar.weeksOfYear.show)tEle.rows[i].cells[0].style.display='';else tEle.rows[i].cells[0].style.display='none';}else{if(this.calendar.weeksOfYear.show)tEle.rows[i].cells[0].style.display='';else tEle.rows[i].cells[0].style.display='none';}}}
eles=$(this.contId+'.DATEPICKER.MONTHPANE').getElementsByTagName('a');$e.add(eles,'mouseover',this._mOver,this);$e.add(eles,'mouseout',this._mOut,this);$e.add(eles,'contextmenu',this._rClick,this);if(typeof this.navigator.panel.item.style=='object'||typeof this.navigator.panel.item.style=='string')$ss(eles,this.navigator.panel.item.style);eles=$(this.contId+'.DATEPICKER.YEARPANE').getElementsByTagName('a');$e.add(eles,'mouseover',this._mOver,this);$e.add(eles,'mouseout',this._mOut,this);$e.add(eles,'contextmenu',this._rClick,this);if(typeof this.navigator.panel.item.style=='object'||typeof this.navigator.panel.item.style=='string')$ss(eles,this.navigator.panel.item.style);if(typeof this.navigator.panel.edit.style=='object'||typeof this.navigator.panel.edit.style=='string')$ss(this.contId+'.DATEPICKER.YEAR.INPUT',this.navigator.panel.edit.style);$e.add(this.contId+'.DATEPICKER.MONTH','click',this._monthPane,this,true);$e.add(this.contId+'.DATEPICKER.YEAR','click',this._yearPane,this,true);$e.add([this.contId+'.DATEPICKER.MONTH',this.contId+'.DATEPICKER.YEAR'],'mouseover',this._nmOver,this);$e.add([this.contId+'.DATEPICKER.MONTH',this.contId+'.DATEPICKER.YEAR'],'mouseout',this._nmOut,this);$e.add(this.contId+'.DATEPICKER.PREVBUTTON','click',this._prevButton,this,true);$e.add(this.contId+'.DATEPICKER.NEXTBUTTON','click',this._nextButton,this,true);if(typeof this.navigator.header.style=='object'||typeof this.navigator.header.style=='string')$ss(this.contId+'.DATEPICKER.TITLE',this.navigator.header.style);if(typeof this.navigator.panel.style=='object'||typeof this.navigator.panel.style=='string'){$ss($(this.contId+'.DATEPICKER.MONTHPANE').rows[0].cells[0],this.navigator.panel.style);$ss($(this.contId+'.DATEPICKER.YEARPANE').rows[0].cells[0],this.navigator.panel.style);}
$e.add(this.contId+'.DATEPICKER.YEAR.INPUT','keypress',this._inputYear,this);$e.add(this.contId+'.DATEPICKER.YEAR.INPUTCOMMIT','click',this._inputYear,this);$e.add([this.contId+'.DATEPICKER.MONTH.0',this.contId+'.DATEPICKER.MONTH.1',this.contId+'.DATEPICKER.MONTH.2',this.contId+'.DATEPICKER.MONTH.3',this.contId+'.DATEPICKER.MONTH.4',this.contId+'.DATEPICKER.MONTH.5',this.contId+'.DATEPICKER.MONTH.6',this.contId+'.DATEPICKER.MONTH.7',this.contId+'.DATEPICKER.MONTH.8',this.contId+'.DATEPICKER.MONTH.9',this.contId+'.DATEPICKER.MONTH.10',this.contId+'.DATEPICKER.MONTH.11'],'click',this._monthClick,this);$e.add([this.contId+'.DATEPICKER.YEAR.0',this.contId+'.DATEPICKER.YEAR.1',this.contId+'.DATEPICKER.YEAR.2',this.contId+'.DATEPICKER.YEAR.3',this.contId+'.DATEPICKER.YEAR.4',this.contId+'.DATEPICKER.YEAR.5',this.contId+'.DATEPICKER.YEAR.6',this.contId+'.DATEPICKER.YEAR.7',this.contId+'.DATEPICKER.YEAR.8',this.contId+'.DATEPICKER.YEAR.9'],'click',this._yearClick,this);$e.add(this.contId+'.DATEPICKER.YEAR.PREVDEC','click',this._prevDecade,this);$e.add(this.contId+'.DATEPICKER.YEAR.NEXTDEC','click',this._nextDecade,this);this.refresh();}}
A5.TimePicker=Class.create();A5.TimePicker.prototype={initialize:function(contId,settings){this.contId=contId;$u.o.assign(this,{inputId:'',format:'h:0m am',switchYear:50,time:0,hours:0,minutes:0,seconds:0,className:'',style:0,edit:{className:'',buttonClassName:'',buttonImage:'',menu:{}},meridianClassName:'',mouseWheelEdit:true,onRightClick:0,onChange:0,onHourChange:0,onMinuteChange:0,onSecondChange:0});if(typeof A5._timePickerDefaults!='undefined')$u.o.assign(this,A5._timePickerDefaults);if(typeof settings.theme!='undefined'){A5.themes.assign(this,settings.theme,'timePicker');this.edit.menu.theme=settings.theme.split(':').shift();}
$u.o.assign(this,settings);$u.o.assign(this.edit.menu,{iconColumn:{show:false},_onSelect:this.onSelect,onClick:function(){$(this._targetId).focus();var val='';var idArr=this._targetId.split('.');var idType=idArr.pop();if(idType=='H')val=this.getValue('hours');else if(idType=='M')val=this.getValue('minutes');else if(idType=='S')val=this.getValue('seconds');if(idType=='H'){if((val.toUpperCase().search('PM')!=-1&&$u.s.toNum(val)!=12)||(val.toUpperCase().search('AM')!=-1&&$u.s.toNum(val)==12))val=$u.s.toNum(val)+12;else val=$u.s.toNum(val);if(val==24)val=0;if(this._hasMeridian){if(val>=12){$svs(idArr.join('.')+'.A','PM');val=val-12;}else $svs(idArr.join('.')+'.A','AM');}}
$svs(this._targetId,val);$e.execute(this._targetId,'change');}});var tempDate=new Date();this._parsedFormat=tempDate._parseFormat(this.format);if(this.time.constructor!=Date){if(typeof this.time=='string'){tempDate.fromFormat(this.time,this._parsedFormat,this.switchYear);this.time=tempDate;}else this.time=new Date();}
this._initRender();this._menu=new A5.Menu([{type:'radio-group',name:'hours',variable:'hours',data:this._getHours()},{type:'radio-group',name:'minutes',variable:'minutes',data:this._getMinutes()},{type:'radio-group',name:'seconds',variable:'seconds',data:this._getSeconds()}],this.edit.menu);},refresh:function(){var hour=this.time.getHours();var min=this.time.getMinutes();var sec=this.time.getSeconds();var mer='AM';if(this._parsedFormat.hasMeridian&&hour>=12){hour=hour-12;if(hour==0)hour=12;mer='PM';}else if(this._parsedFormat.hasMeridian&&hour==0){hour=12;}
if(min<10)min='0'+min;else min=''+min;if(sec<10)sec='0'+sec;else sec=''+sec;hour=''+hour;$svs(this.contId+'.H',hour);$svs(this.contId+'.M',min);$svs(this.contId+'.S',sec);$svs(this.contId+'.A',mer);},setValue:function(time){if(time.constructor!=Date){if(typeof time=='string'){var tempDate=new Date();tempDate.fromFormat(time,this._parsedFormat,this.switchYear);this.time=tempDate;}}else this.time=time;this.refresh();},_getHours:function(){var data=new Array();if(this.hours.constructor==Array)data=this.hours;else if(this.hours.constructor==Function)data=this.hours(this.time);else{var set=1;if(typeof this.hours=='number')step=Math.max(this.hours,1);if(this._parsedFormat.hasMeridian){for(var i=0;i<24;i=i+step){if(i==0)data.push('12am');else if(i<12)data.push(i+'am');else if(i==12)data.push('12pm');else data.push((i-12)+'pm');}}else{for(var i=0;i<24;i=i+step)data.push(''+i);}}
return data;},_getMinutes:function(){var data=new Array();if(this.minutes.constructor==Array)data=this.minutes;else if(this.minutes.constructor==Function)data=this.minutes(this.time);else{var step=1;if(typeof this.minutes=='number')step=Math.max(this.minutes,1);for(var i=0;i<60;i=i+step){if(i<10)data.push('0'+i);else data.push(''+i);}}
return data;},_getSeconds:function(){var data=new Array();if(this.seconds.constructor==Array)data=this.hours;else if(this.seconds.constructor==Function)data=this.seconds(this.time);else{var step=1;if(typeof this.seconds=='number')step=Math.max(this.seconds,1);for(var i=0;i<60;i=i+step){if(i<10)data.push('0'+i);else data.push(''+i);}}
return data;},_eScroll:function(e,classInst){$e.stopEvent(e);var delta=false;if(e.wheelDelta)delta=e.wheelDelta/120;else if(e.detail)delta=-e.detail/3;if(delta){var type=this.id.split('.').pop();if(type=='H')var data=classInst._getHours();else if(type=='M')var data=classInst._getMinutes();else if(type=='S')var data=classInst._getSeconds();var tData=new Array();var tVal=this.value;for(var i=0;i<data.length;i++)tData.push(String(data[i]).toUpperCase());var indx=$u.a.find(tData,tVal);if(indx==-1&&type=='H'&&classInst._parsedFormat.hasMeridian){tVal=tVal+$gvs(classInst.contId+'.A');indx=$u.a.find(tData,tVal);}else if(indx==-1){for(var i=0;i<tData.length;i++)tData[i]=$u.s.toNum(''+tData[i]);indx=$u.a.find(tData,$u.s.toNum(tVal));}
if(indx!=-1){indx=$u.a.find(tData,tVal);indx=indx+delta;if(indx>data.length-1)indx=0;else if(indx<0)indx=data.length-1;}else indx=0;var val=data[indx]
if(type=='H'){if(val.toUpperCase().search('PM')!=-1)val=$u.s.toNum(val)+12;else val=$u.s.toNum(val);if(classInst._parsedFormat.hasMeridian){if(val>=12){val=val-12;if(val==0)val=12;$svs(classInst.contId+'.A','PM');}else if(val==0){val=12;$svs(classInst.contId+'.A','AM');}else $svs(classInst.contId+'.A','AM');}}else{val=$u.s.toNum(val);if(val<10)val='0'+val;}
this.value=val;$e.execute(this,'change');}
return false;},_eChange:function(e,classInst){var type=this.id.split('.').pop();if(type=='H'){if(classInst._parsedFormat.hasMeridian){var hour=Number(this.value);if($gvs(classInst.contId+'.A')=='PM'&&hour!=12)hour=hour+12;classInst.time.setHours(hour);var mer='AM';if(hour==24)hor=0
if(hour>=12){hour=hour-12;if(hour==0)hour=12;mer='PM';}else if(hour==0)hour=12;$svs(classInst.contId+'.H',''+hour);$svs(classInst.contId+'.A',''+mer);}else classInst.time.setHours(this.value);if(classInst.onHourChange.constructor==Function)classInst.onHourChange(classInst.time);if(classInst.onChange.constructor==Function)classInst.onChange(classInst.time);}else if(type=='M'){classInst.time.setMinutes(this.value);if(classInst.onMinuteChange.constructor==Function)classInst.onMinuteChange(classInst.time);if(classInst.onChange.constructor==Function)classInst.onChange(classInst.time);}else if(type=='S'){classInst.time.setSeconds(this.value);if(classInst.onSecondChange.constructor==Function)classInst.onSecondChange(classInst.time);if(classInst.onChange.constructor==Function)classInst.onChange(classInst.time);}
if($(classInst.inputId)){$svs(classInst.inputId,classInst.time.toFormat(classInst._parsedFormat));$e.execute(classInst.inputId,'change');}},_ddShow:function(e,classInst){$e.stopEvent(e);var type=this.id.split('.');type=type[type.length-2];classInst._menu.setDisplay('hours',false);classInst._menu.setDisplay('minutes',false);classInst._menu.setDisplay('seconds',false);if(type=='H'){classInst._menu.setDisplay('hours',true);var hour=classInst.time.getHours();if(classInst._parsedFormat.hasMeridian){if(hour==0||hour==24)classInst._menu.setValue('hours','12am');else if(hour==12)classInst._menu.setValue('hours','12pm');else if(hour<12)classInst._menu.setValue('hours',hour+'am');else classInst._menu.setValue('hours',(hour-12)+'pm');}else classInst._menu.setValue('hours',''+hour);}else if(type=='M'){classInst._menu.setDisplay('minutes',true);classInst._menu.setValue('minutes',$gvs(classInst.contId+'.M'));}else if(type=='S'){classInst._menu.setDisplay('seconds',true);classInst._menu.setValue('seconds',$gvs(classInst.contId+'.S'));}
classInst._menu._targetId=classInst.contId+'.'+type;classInst._menu._hasMeridian=classInst._parsedFormat.hasMeridian;classInst._menu.show('dropdown',this);return false;},_mClick:function(e,classInst){$e.stopEvent(e);if(this.innerHTML=='AM')classInst.time.setHours(classInst.time.getHours()+12);else classInst.time.setHours(classInst.time.getHours()-12);classInst.refresh();if(classInst.onHourChange.constructor==Function)classInst.onHourChange(classInst.time);if(classInst.onChange.constructor==Function)classInst.onChange(classInst.time);if($(classInst.inputId)){$svs(classInst.inputId,classInst.time.toFormat(classInst._parsedFormat));$e.execute(classInst.inputId,'change');}
return false;},_rClick:function(e,classInstance){if(classInstance.onRightClick.constructor==Function){classInstance.onRightClick();$e.stopEvent(e);return false;}},_initRender:function(){var html=new Array();html=html.concat(['<table id="'+this.contId+'.TABLE" class="'+this.className+'" border="0" cellspacing="0" cellpadding="0">',' <tr>','  <td><input id="'+this.contId+'.H" class="'+this.edit.className+'" size="2" maxlength="2" /></td>','  <td>:</td>','  <td><input id="'+this.contId+'.M" class="'+this.edit.className+'" size="2" maxlength="2" /></td>']);if(this._parsedFormat.secondsMode!='none'){html=html.concat(['  <td>:</td>','  <td><input id="'+this.contId+'.S" class="'+this.edit.className+'" size="2" maxlength="2" /></td>']);}
if(this._parsedFormat.hasMeridian)html.push('<td><a href="#" id="'+this.contId+'.A" class="'+this.meridianClassName+'">AM</a></td>');html=html.concat([' </tr>',' <tr>','  <td><a href="#" tabindex="-1" id="'+this.contId+'.H.DD" class="'+this.edit.buttonClassName+'" style="font: 0pt arial;"><img src="'+this.edit.buttonImage+'" style="border: none;" /></a></td>','  <td style="font-size: 0px;"></td>','  <td><a href="#" tabindex="-1" id="'+this.contId+'.M.DD" class="'+this.edit.buttonClassName+'" style="font: 0pt arial;"><img src="'+this.edit.buttonImage+'" style="border: none;" /></a></td>']);if(this._parsedFormat.secondsMode!='none'){html=html.concat(['  <td></td>','  <td><a href="#" tabindex="-1" id="'+this.contId+'.S.DD" class="'+this.edit.buttonClassName+'" style="font: 0pt arial;"><img src="'+this.edit.buttonImage+'" style="border: none;" /></a></td>']);}
if(this._parsedFormat.hasMeridian)html.push('<td></td>');if(typeof this.style=='object'||typeof this.style=='string')$ss(this.contId+'.TABLE',this.style);html=html.concat([' </tr>','</table>']);var cEle=$(this.contId);cEle.innerHTML=html.join('\n');$e.add(cEle,'contextmenu',this._rClick,this);if(this.mouseWheelEdit){$e.add([this.contId+'.H',this.contId+'.M',this.contId+'.S'],'mousewheel',this._eScroll,this);$e.add([this.contId+'.H',this.contId+'.M',this.contId+'.S'],'DOMMouseScroll',this._eScroll,this);}
$e.add([this.contId+'.H',this.contId+'.M',this.contId+'.S'],'change',this._eChange,this);$e.add([this.contId+'.H.DD',this.contId+'.M.DD',this.contId+'.S.DD'],'click',this._ddShow,this);if(this._parsedFormat.hasMeridian)$e.add(this.contId+'.A','click',this._mClick,this);this.refresh();}}
A5.DateTimePicker=Class.create();A5.DateTimePicker.prototype={initialize:function(contId,settings){this.contId=contId;$u.o.assign(this,{inputId:'',format:'MM/dd/yyyy h:0m am',switchYear:50,date:0,combinedContainer:{layout:'time/date',className:''},datePicker:{},timePicker:{},onChange:0});if(typeof A5._dateTimePickerDefaults!='undefined')$u.o.assign(this,A5._dateTimePickerDefaults);if(typeof settings.theme!='undefined'){A5.themes.assign(this,settings.theme,'dateTimePicker');var tTheme=settings.theme.split(':').shift();this.datePicker.theme=tTheme;this.timePicker.theme=tTheme;}
$u.o.assign(this,settings);var tempDate=new Date();this._parsedFormat=tempDate._parseFormat(this.format);var hasDate=this._parsedFormat.hasDate;var hasTime=this._parsedFormat.hasTime;if(this.date.constructor!=Date){if(typeof this.date=='string'){tempDate.fromFormat(this.date,this._parsedFormat,this.switchYear);this.date=tempDate;}else this.date=new Date();}
this.datePicker.date=this.date;this.datePicker.format=this.format;this.datePicker.switchYear=this.switchYear;this.datePicker.inputId=this.contId+'.DT';this.timePicker.time=this.date;this.timePicker.format=this.format;this.timePicker.switchYear=this.switchYear;this.timePicker.inputId=this.contId+'.DT';this.isCombined=false;if(hasDate&&hasTime){var tcHTML='<td id="'+this.contId+'.T" align="center" valign="center"></td>';var dcHTML='<td id="'+this.contId+'.D" align="center" valign="center"></td>';var cHTML=tcHTML+'</tr><tr>'+dcHTML;var cLayout=this.combinedContainer.layout.toLowerCase();if(cLayout=='time date')cHTML=tcHTML+dcHTML;else if(cLayout=='date time')cHTML=dcHTML+tcHTML;else if(cLayout=='date/time')cHTML=dcHTML+'</tr><tr>'+tcHTML;$(this.contId).innerHTML='<input type="hidden" id="'+this.contId+'.DT" /><table class="'+this.combinedContainer.className+'" cellspacing="0" cellpadding="2"><tr>'+cHTML+'</tr></table>';this._dp=new A5.DatePicker(this.contId+'.D',this.datePicker);this._tp=new A5.TimePicker(this.contId+'.T',this.timePicker);this.isCombined=true;}else if(hasDate){$(this.contId).innerHTML='<input type="hidden" id="'+this.contId+'.DT" /><div id="'+this.contId+'.D"></div>';this._dp=new A5.DatePicker(this.contId+'.D',this.datePicker);}else if(hasTime){$(this.contId).innerHTML='<input type="hidden" id="'+this.contId+'.DT" /><div id="'+this.contId+'.T"></div>';this._tp=new A5.TimePicker(this.contId+'.T',this.timePicker);}
$e.add(this.contId+'.DT','change',this._change,this,true);},setValue:function(date){if(date.constructor!=Date){if(typeof date=='string'){var tempDate=new Date();if(date!='')tempDate.fromFormat(date,this._parsedFormat,this.switchYear);date=tempDate;}else return false;}
this.date=date;if(this._parsedFormat.hasDate)this._dp.setValue(date);if(this._parsedFormat.hasTime)this._tp.setValue(date);},_change:function(){if(this.onChange.constructor==Function)this.onChange.call(this,this.date.toFormat(this._parsedFormat));if($(this.inputId)){$svs(this.inputId,this.date.toFormat(this._parsedFormat));$e.execute(this.inputId,'change');}}}
A5.EditDateTime=Class.create(A5.Edit,{initialize:function(settings){$u.o.assign(this,{theme:'',dateTime:{theme:''},window:{theme:'',autoGenerateButtons:true,title:{tools:{items:[]}},buttons:{items:[]}},container:{className:'',hoverClassName:'',focusClassName:'',pressedClassName:'',style:0,editClassName:'',separatorClassName:'',button:{html:'',className:'',hoverClassName:'',pressedClassName:''}},selectionRequired:false,onSelect:0});if(typeof settings.theme!='undefined'){A5.themes.assign(this,settings.theme,'editButtonGroup');var tTheme=settings.theme.split(':').shift();if(this.window.theme=='')this.window.theme=tTheme+':dropdown';if(this.dateTime.theme=='')this.dateTime.theme=tTheme+':dropdown';}
$u.o.assign(this,settings);var hasTCommit=false;var hasBCommit=false;for(var i=0;i<this.window.title.tools.items.length;i++){if(typeof this.window.title.tools.items[i].action!='undefined'){if(this.window.title.tools.items[i].action=='commit'){hasTCommit=true;break;}}}
if(this.window.autoGenerateButtons){this.window.buttons.items.push({html:'Close',action:'close'});this.window.buttons.items.push({html:'Done',action:'commit'});hasBCommit=true;}else{for(var i=0;i<this.window.buttons.items.length;i++){if(typeof this.window.buttons.items[i].action!='undefined'){if(this.window.buttons.items[i].action=='commit'){hasBCommit=true;break;}}}}
$u.o.assign(this.window,{title:{show:false},body:{content:{type:'blank'}},type:'popup',autoShow:false,autoPosition:false,_container:{focusClassName:this.container.focusClassName,pressedClassName:this.container.pressedClassName,button:{pressedClassName:this.container.button.pressedClassName}},onShow:function(){var cEle=$(this._targetId+'.CONTAINER');if(cEle){if(this._container.pressedClassName!='')$acn(cEle,this._container.pressedClassName);if(this._container.button.pressedClassName!='')$acn($(this._targetId+'.BUTTON'),this._container.button.pressedClassName);}},onHide:function(){var cEle=$(this._targetId+'.CONTAINER');if(cEle){if(this._container.focusClassName!=''&&!this._makeSelection)$rcn(cEle,this._container.focusClassName);if(this._container.pressedClassName!='')$rcn(cEle,this._container.pressedClassName);if(this._container.button.pressedClassName!='')$rcn($(this._targetId+'.BUTTON'),this._container.button.pressedClassName);}
this._makeSelection=false;}});$u.o.assign(this.dateTime,{onChange:function(){var ele=$(this._targetId)
ele.focus();$e.execute(ele,'a5datetimeselection');}});var win=new A5.Window(this.window);this._dateTime=new A5.DateTimePicker(win.getWindowId('body'),this.dateTime);this._dateTime._window=win;if(this._dateTime._parsedFormat.hasTime){if(hasTCommit)this._dateTime._window.setDisplay('title',true);if(hasBCommit)this._dateTime._window.setDisplay('buttons',true);this._dateTime.onChange=0;}else{if(hasTCommit)this._dateTime._window.setDisplay('title',false);if(hasBCommit)this._dateTime._window.setDisplay('buttons',false);}
this._dateTime._window.addAction('commit',function(){var ele=$(this._targetId);ele.focus();$e.execute(ele,'a5datetimeselection');});this._editPrepare();this._value='';this._oldIPoint=0;},create:function(s){var useContainer=typeof arguments[1]!='undefined'?arguments[1]:true;var HTMLIEle=document.createElement('input');if(typeof s=='object'){if(typeof s.className!='undefined'){HTMLIEle.className=s.className;delete s.className;}
if(typeof s.style!='undefined'){$ss(HTMLIEle,s.style);delete s.style;}
for(var attr in s)$sa(HTMLIEle,attr,s[attr]);}
if(HTMLIEle.id=='')HTMLIEle.id=A5.u.getUniqueId();if(useContainer){var HTMLCEle=document.createElement('table');HTMLCEle.id=HTMLIEle.id+'.CONTAINER';HTMLCEle.cellPadding='0';HTMLCEle.cellSpacing='0';HTMLCEle.className=this.container.className;if(typeof this.container.style!='number')$ss(HTMLCEle,this.container.style);$ss(HTMLCEle,'display: inline-table; *display: inline;');HTMLCEle.insertRow(0);var cellIndx=0;HTMLCEle.rows[0].insertCell(cellIndx);HTMLIEle.className=this.container.editClassName;$ss(HTMLIEle,'width: 100%; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');HTMLCEle.rows[0].cells[cellIndx].appendChild(HTMLIEle);cellIndx++;if(this.container.separatorClassName!=''){HTMLCEle.rows[0].insertCell(cellIndx);HTMLCEle.rows[0].cells[cellIndx].innerHTML='&nbsp;';HTMLCEle.rows[0].cells[cellIndx].className=this.container.separatorClassName;cellIndx++;}
HTMLCEle.rows[0].insertCell(cellIndx);HTMLCEle.rows[0].cells[cellIndx].id=HTMLIEle.id+'.BUTTON';HTMLCEle.rows[0].cells[cellIndx].className=this.container.button.className;HTMLCEle.rows[0].cells[cellIndx].innerHTML=this.container.button.html;HTMLCEle.rows[0].cells[cellIndx].style.width='0%';document.documentElement.appendChild(HTMLCEle);this._bind(HTMLIEle);return HTMLCEle;}else{this._bind(HTMLIEle);return HTMLIEle;}},bind:function(ctrl){if(ctrl.constructor==Array){for(var i=0;i<ctrl.length;i++){if(ctrl[i].constructor==Array)this._bind(ctrl[i][0],ctrl[i][1]);else this._bind(ctrl[i]);}}else{this._bind(ctrl,arguments[1]);}},_bind:function(ele){var ele=$(ele);if($ga(ele,'A5ControlBound')=='true')return true;var eleId=ele.id!=''?ele.id:ele.name;var cEle=$(eleId+'.CONTAINER');if(cEle&&this.container.hoverClassName!=''){$e.add(cEle,'mouseover',Function('$acn(this,\''+this.container.hoverClassName+'\')'));$e.add(cEle,'mouseout',Function('$rcn(this,\''+this.container.hoverClassName+'\')'));}
var bEleId=typeof arguments[1]!='undefined'?arguments[1]:'';var bEle=false;if(bEleId==''){if($(eleId+'.BUTTON'))bEle=$(eleId+'.BUTTON');}else bEle=$(bEleId);if(bEle){$sa(bEle,'A5TargetInput',eleId);$e.add(bEle,'click',this._bOnClick,this);if(cEle&&this.container.button.hoverClassName){$e.add(bEle,'mouseover',Function('$acn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $acn(this,\''+this.container.button.hoverClassName+'\')'));$e.add(bEle,'mouseout',Function('$rcn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $rcn(this,\''+this.container.button.hoverClassName+'\')'));}}else $sa(ele,'A5HasButton','false');if(cEle&&this.container.button.hoverClassName){var bIndx=0;var cbEle=0;while($(eleId+'.CUSTOMBUTTON.'+bIndx)){cbEle=$(eleId+'.CUSTOMBUTTON.'+bIndx);$e.add(cbEle,'mousedown',Function('$acn(this,\''+this.container.button.pressedClassName+'\')'));$e.add(cbEle,'mouseover',Function('$acn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $acn(this,\''+this.container.button.hoverClassName+'\')'));$e.add(cbEle,'mouseout',Function('$rcn(\''+eleId+'.CONTAINER\',\''+this.container.hoverClassName+'\'); $rcn(this,\''+this.container.button.hoverClassName+'\'); $rcn(this,\''+this.container.button.pressedClassName+'\')'));$e.add(cbEle,'mouseup',Function('$rcn(this,\''+this.container.button.pressedClassName+'\')'));bIndx+=1;}}
$e.add(ele,'focus',this._focus,this);$e.add(ele,'blur',this._blur,this);$e.add(ele,'keydown',this._keyDown,this);$e.add(ele,'keyup',this._keyUp,this,true);$e.add(ele,'keypress',this._keyPress,this);$e.add(ele,'mouseup',this._mUp,this);$e.add(ele,'a5datetimeselection',this._dtSelection,this);this._editBind(ele);$sa(ele,'A5ControlBound','true');},_focus:function(e,classInst){if(classInst._targetId!=this.id){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;}
classInst._targetId=this.id;classInst._dateTime._targetId=classInst._targetId;classInst._dateTime._window._targetId=classInst._targetId;classInst._initValue=$gvs(this);classInst._editFocus(e,this);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!='')$acn(cEle,classInst.container.focusClassName);},_blur:function(e,classInst){if(classInst.selectionRequired){var val=$gvs(this);if(val!=classInst._initValue&&val!='')$svs(this,classInst._initValue);}
classInst._editBlur(e,this);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!=''&&classInst._dateTime._window.hidden)$rcn(cEle,classInst.container.focusClassName);},_mUp:function(e,classInst){var sel=A5.edit.getSelection(this);classInst._oldIPoint=sel.start;if($ga(this,'A5HasButton')=='false'||classInst.selectionRequired){if(this.disabled)return false;if(classInst._targetId!=this.id){classInst._targetId=this.id;classInst._dateTime._targetId=classInst._targetId;classInst._dateTime._window._targetId=classInst._targetId;classInst._initValue=$gvs(this.id);}
var ele=this;setTimeout(function(){classInst._showDTP(ele);},0);}},_bOnClick:function(e,classInst){$e.stopEvent(e);var tEleId=$ga(this,'A5TargetInput');var ele=$(tEleId);if(ele.disabled)return false;ele.focus();var sel=A5.edit.getSelection(ele);classInst._oldIPoint=sel.start;classInst._targetId=tEleId;classInst._dateTime._targetId=classInst._targetId;classInst._dateTime._window._targetId=classInst._targetId;classInst._initValue=$gvs(ele);setTimeout(function(){classInst._showDTP(ele);},0);return false;},_keyUp:function(e){var keyCode=e.charCode||e.keyCode;if(keyCode==36||keyCode==35||keyCode==37||keyCode==39){var sel=A5.edit.getSelection($(this._targetId));this._oldIPoint=sel.start;}else if((keyCode==8||keyCode==46)&&this.selectionRequired){var ele=$(this._targetId);var data=this._editValSplit(ele,true);var offset=data.vals[data.selIndx].offset;var oldLen=data.vals.length;if(data.sel.length==0){if(keyCode==8&&data.sel.start!=0){if(data.vals.length-1==data.selIndx&&data.vals[data.selIndx].val==''){data.vals.splice(data.selIndx,1);if(data.selIndx>0)data.vals[data.selIndx-1].sep='';}else{if(data.vals[data.selIndx].offset==data.sel.start&&data.selIndx>0)data.selIndx--;else if(data.selIndx>0&&data.vals[data.selIndx].sep!=''&&!data.inSep){data.vals[data.selIndx-1].sep=data.vals[data.selIndx].sep;offset=data.vals[data.selIndx-1].offset+data.vals[data.selIndx-1].val.length;}else offset=data.vals[data.selIndx].offset;data.vals.splice(data.selIndx,1);}}else if(keyCode==46&&data.sel.start!=ele.value.length){if(data.inSep&&data.vals[data.selIndx].sep!=''){offset=offset+data.vals[data.selIndx].val.length;if(data.vals.length-1==data.selIndx)data.vals[data.selIndx].sep='';else{data.vals[data.selIndx].sep=data.vals[data.selIndx+1].sep;data.vals.splice(data.selIndx+1,1);}}else data.vals.splice(data.selIndx,1);}}else{for(var i=data.vals.length-1;i>=0;i--){if(data.vals[i].offset+data.vals[i].val.length>=data.sel.start&&data.vals[i].offset<=data.sel.end){offset=data.vals[i].offset;data.vals.splice(i,1);}}}
if(oldLen!=data.vals.length&&this._multi.auto.persist){if(this.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++){data.vals[i].sep=this.multiple.auto.separator.call(this,oldSeps);oldSeps.push(data.vals[i].sep);}}else{for(var i=0;i<data.vals.length-1;i++)data.vals[i].sep=this.multiple.auto.separator;}}
ele.value=this._editValJoin(data);this._initValue=ele.value;this._oldIPoint=offset;A5.edit.setSelection(ele,offset);}},_keyPress:function(e,classInst){if(classInst.selectionRequired){var keyCode=0;if(typeof e.which=='number')keyCode=e.which;else if(typeof e.charCode=='number')keyCode=e.charCode;else keyCode=e.keyCode;if(keyCode!=9&&e.keyCode!=37&&e.keyCode!=39)$e.stopEvent(e);if(keyCode==8||keyCode==9||keyCode==13||keyCode==27)keyCode=0;if(keyCode!=0&&!e.ctrlKey&&!e.altKey){keyCode=String.fromCharCode(keyCode).toLowerCase();var data=classInst._editValSplit(this,true);var aVal=data.vals[data.selIndx];if(aVal.val!=''){if(!classInst._multi.auto.persist){classInst._multi.keyBuffer+=keyCode;var sLen=classInst._multi.keyBuffer.length;var sMat=new Array();for(var i=0;i<classInst._multi.sep.length;i++)if(classInst._multi.sep[i].substr(0,sLen).toLowerCase()==classInst._multi.keyBuffer)sMat.push(i);if(sMat.length==1){aVal.sep=classInst._multi.sep[sMat[0]];if(classInst.format.showMask&&data.vals.length-1==data.selIndx)data.vals.push({val:classInst.format._pMask.blankValue,sep:'',offset:0});this.value=classInst._editValJoin(data);classInst._initValue=this.value;A5.edit.setSelection(this,aVal.offset+aVal.val.length+aVal.sep.length);classInst._multi.keyBuffer='';}else if(sMat.length==0)classInst._multi.keyBuffer='';}else if(data.selIndx==data.vals.length-1&&aVal.sep==''){classInst._oldIPoint=classInst.insertValue(aVal.val,true);classInst._initValue=this.value;}}}}else classInst._editKeyPress(e,this);},_showDTP:function(ele){this._targetId=ele.id;this._dateTime._targetId=ele.id;this._initValue=$gvs(ele);var data=this._editValSplit(ele,true);this._dateTime.setValue(data.vals[data.selIndx].val);this._dateTime._window.hide();this._dateTime._window.show('dropdown',ele);},_dtSelection:function(e,classInst){if(classInst._dateTime.date.getDate!=0){var ele=$(classInst._targetId);A5.edit.setSelection(ele,classInst._oldIPoint);classInst._setValue(classInst._dateTime.date.toFormat(classInst._dateTime._parsedFormat),true);classInst._initValue=ele.value;if(classInst.onSelect.constructor==Function)classInst.onSelect.call(ele,classInst._dateTime.date.toFormat(classInst._dateTime._parsedFormat),classInst);}
classInst._dateTime._window._makeSelection=true;classInst._dateTime._window.hide();},_setValue:function(val,commit){var ele=$(this._targetId);var data=this._editValSplit(ele,true);var aVal=data.vals[data.selIndx];aVal.val=val;var offset=aVal.offset+val.length;if(commit&&this._multi.auto.separate&&data.selIndx==data.vals.length-1){if(this.multiple.auto.separator.constructor==Function){var oldSeps=new Array();for(var i=0;i<data.vals.length-1;i++)oldSeps.push(data.vals[i].sep);aVal.sep=this.multiple.auto.separator.call(this,oldSeps);}else aVal.sep=this.multiple.auto.separator;offset=offset+aVal.sep.length;if(this.format.showMask)data.vals.push({val:this.format._pMask.blankValue,sep:'',offset:0});}
ele.value=this._editValJoin(data);this._oldIPoint=offset;A5.edit.setSelection(ele,offset);}});A5.commandHandler={_o:{},create:function(id,obj,settings){$u.o.assign(settings,{onAction:0,onSetProperty:0},true)
this._o[id]={o:obj,s:settings};},get:function(id){if(typeof this._o[id]!='undefined')return this._o[id].o;},action:function(id,action){if(typeof this._o[id]!='undefined'){if(this._o[id].s.onAction.constructor==Function)this._o[id].s.onAction.call(this._o[id].o,action);}},setProperty:function(id,prop,value){if(typeof this._o[id]!='undefined'){this._o[id][prop]=value;if(this._o[id].s.onSetProperty.constructor==Function)this._o[id].s.onSetProperty.call(this._o[id].o,prop);}},getProperty:function(id,prop){if(typeof this._o[id]!='undefined'){return this._o[id][prop];}
return null;}}
A5.Toolbar=Class.create();A5.Toolbar.prototype={initialize:function(contId,data,settings){this.contId=contId;$u.o.assign(this,{theme:'',style:0,className:'',globalProperties:{}});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'toolbar');$u.o.assign(this,settings);this.data=data;this.render();},getControl:function(name){for(var i=0;i<this.data.length;i++){if(typeof this.data[i]=='object'){if(this.data[i].name==name)return this.data[i];}}
return false;},render:function(){var cEle=$(this.contId);cEle.className=this.className;if(typeof this.style=='string')$ss(cEle,$gs(cEle)+this.style);for(var i=0;i<this.data.length;i++){if(typeof this.data[i].create!='undefined'){$u.o.assign(this.data[i],this.globalProperties,true);if(typeof this.data[i].createDefaults!='undefined')var ele=this.data[i].create(this.data[i].createDefaults);else var ele=this.data[i].create();cEle.appendChild(ele);}else if(this.data[i]=='-'){cEle.appendChild(document.createTextNode(' | '));}else if(typeof this.data[i]=='string'){var ele=document.createElement('span');ele.innerHTML=this.data[i];cEle.appendChild(ele);}}}}
A5.HTMLEditor=Class.create();A5.HTMLEditor.prototype={initialize:function(ctrlId,settings){if(!$(ctrlId))return false;this.ctrlId=ctrlId;this._htmlEdId='A5HTMLEDITOR'+this._htmlEdIndx[0];this._htmlEdIndx[0]++;$u.o.assign(settings,{theme:'',toolbar:{items:[],settings:{}},data:{className:[],font:[],format:[{value:'Normal',html:'<p style="margin: 0px;">Normal</p>',tag:'p'},{value:'Heading 1',html:'<h1 style="margin: 0px;">Heading 1</h1>',tag:'h1'},{value:'Heading 2',html:'<h2 style="margin: 0px;">Heading 2</h2>',tag:'h2'},{value:'Heading 3',html:'<h3 style="margin: 0px;">Heading 3</h3>',tag:'h3'},{value:'Heading 4',html:'<h4 style="margin: 0px;">Heading 4</h4>',tag:'h4'},{value:'Heading 5',html:'<h5 style="margin: 0px;">Heading 5</h5>',tag:'h5'},{value:'Heading 6',html:'<h6 style="margin: 0px;">Heading 6</h6>',tag:'h6'},{value:'Formatted',html:'<pre style="margin: 0px;">Formatted</pre>',tag:'pre'},{value:'Address',html:'<address style="margin: 0px;">Address</address>',tag:'address'}]},classNames:[],styleSheets:{css:'',linked:''},insert:{image:{allow:false,relativePath:'',styleName:'',titleText:'Insert Image',bodyText:'File:',editWatermarkText:'',editImage:''},file:{allow:false,relativePath:'',styleName:'',titleText:'Insert File',bodyText:'File:',editWatermarkText:'',editImage:''},window:{}},icons:{bold:'images/$$format.font.bold.png.a5image',italic:'images/$$format.font.italic.png.a5image',underline:'images/$$format.font.line.under.png.a5image',strike:'images/$$format.font.line.through.png.a5image',superScript:'images/$$format.text.superScript.png.a5image',subScript:'images/$$format.text.subScript.png.a5image',color:'images/$$format.font.color.png.a5image',highlightColor:'images/$$format.text.hilite.color.png.a5image',backgroundColor:'images/$$format.background.color.png.a5image',justifyLeft:'images/$$format.justify.left.png.a5image',justifyCenter:'images/$$format.justify.center.png.a5image',justifyRight:'images/$$format.justify.right.png.a5image',justify:'images/$$format.justify.justified.png.a5image',outdent:'images/$$format.indent.out.png.a5image',indent:'images/$$format.indent.png.a5image',bulletedList:'images/$$format.list.bulleted.png.a5image',numberedList:'images/$$format.list.numbered.png.a5image',insertTable:'images/$$layout.table.png.a5image',insertLink:'images/$$control.html.link.png.a5image',insertImage:'images/$$control.image.png.a5image',insertFile:'images/$$file.open.png.a5image',insertSymbol:'images/$$generic.pilcrow.png.a5image',clearFormat:'images/$$edit.clear.png.a5image',toggleCodeView:'images/$$code.xml.tag.png.a5image',tableInsertRowBefore:'images/$$layout.table.row.insert.before.png.a5image',tableInsertRowAfter:'images/$$layout.table.row.insert.after.png.a5image',tableInsertColumnBefore:'images/$$layout.table.col.insert.before.png.a5image',tableInsertColumnAfter:'images/$$layout.table.col.insert.after.png.a5image',tableDeleteRow:'images/$$layout.table.row.remove.png.a5image',tableDeleteColumn:'images/$$layout.table.col.remove.png.a5image'},onFocus:0,onBlur:0,onStateChange:0,onChange:0},true);$u.o.assign(settings.insert.window,{theme:settings.theme,baseCtrlId:this.ctrlId,title:{html:'Insert',tools:{items:[]}},header:{show:false},body:{content:{type:'url',url:'about:blank'}},footer:{show:false},type:'modal',resize:'both',autoShow:false,autoPosition:true});$u.o.assign(this,settings);this._iWindow=new A5.Window(this.insert.window);$e.add(this._iWindow.getWindowId(),'a5insert',function(e,classInst){classInst._iWindow.hide();var insertType=$ga(this,'a5inserttype');if(insertType=='image'){var imageToInsert=$ga(this,'a5imagetoinsert');classInst.command('insertimage',imageToInsert);}else if(insertType=='file'){var fileToInsert=$ga(this,'a5filetoinsert');var fileToInsertShort=fileToInsert.split('/').pop();classInst._edInsertHTML('a',fileToInsertShort,{href:fileToInsert,target:'_blank'});}},this);this._iWindow.addTool(this._iWindow._defaultTools['close']);if(this.styleSheets.css.constructor==Array)this.styleSheets.css.join('\n');else if(this.styleSheets.css.constructor!=String)this.styleSheets.css='';this.styleSheets.css='table, td {border: 1px dashed #aaa;}'+this.styleSheets.css;A5.commandHandler.create(this._htmlEdId,this,{onAction:function(action){action=action.split(':');var aName=action[0];if(aName=='format'){var fArr=[];var fResArr=[];for(var i=0;i<this.data.format.length;i++){fArr.push(this.data.format[i].value);fResArr.push(this.data.format[i].tag);}
var fVal=$u.a.find(fArr,action[1]);if(fVal>-1){fVal=fResArr[fVal];this.command('formatblock','<'+fVal+'>');}}else if(aName=='fontName')this.command('fontName',action[1]);else if(aName=='fontSize')this.command('fontSize',action[1]);else if(aName=='getColor')this._colorMenu(action[1]);else if(aName=='getSymbol')this._symbolMenu();else if(aName=='setColor'){var aColor=action[2];if(aColor=='no-color')aColor='';if(action[1]=='fontColor')this.command('foreColor',aColor);else if(action[1]=='highlightColor')this.command('hilitecolor',aColor);else if(action[1]=='backgroundColor')this.command('backColor',aColor);}else if(aName=='tableMenu')this._tblMenu();else if(aName=='toggleDesignMode')this.toggleDesignMode();else if(aName=='hideMenus'){if(this._tMenu)this._tMenu.hide();if(this._cMenu)this._cMenu.hide();if(this._sMenu)this._sMenu.hide();var ctrlObj=this._tbObj.getControl('fontName');if(ctrlObj)ctrlObj._listbox._window.hide();ctrlObj=this._tbObj.getControl('fontSize');if(ctrlObj)ctrlObj._listbox._window.hide();ctrlObj=this._tbObj.getControl('format');if(ctrlObj)ctrlObj._listbox._window.hide();ctrlObj=this._tbObj.getControl('className');if(ctrlObj)ctrlObj._listbox._window.hide();}else if(aName=='insertHTML')this._edInsertHTML('',action[1]);else if(aName=='clearButtonState'){var ctrlObj=this._tbObj.getControl(action[1]);if(ctrlObj)ctrlObj.setState($(ctrlObj._buttonIds[0]),false);}else if(aName=='insert'){if(action[1]=='image'){this._iWindow.setTitle(this.insert.image.titleText);this._iWindow.body.content.url='__a5FileUploadMasterPage.a5w?fileUploadUrl=__a5HTMLEditorFileInsertPage.a5w&fileUploadAutoUpload=true&fileUploadText='+this.insert.image.bodyText+'&fileSelectImg='+this.insert.image.editImage+'&fileBoxWaterMark='+this.insert.image.editWatermarkText+'&stylesheetName='+this.insert.image.styleName+'&insertType=image&relativePath='+this.insert.image.relativePath+'&windowID='+this._iWindow.getWindowId();}else{this._iWindow.setTitle(this.insert.file.titleText);this._iWindow.body.content.url='__a5FileUploadMasterPage.a5w?fileUploadUrl=__a5HTMLEditorFileInsertPage.a5w&fileUploadAutoUpload=true&fileUploadText='+this.insert.file.bodyText+'&fileSelectImg='+this.insert.file.editImage+'&fileBoxWaterMark='+this.insert.file.editWatermarkText+'&stylesheetName='+this.insert.file.styleName+'&insertType=file&relativePath='+this.insert.file.relativePath+'&windowID='+this._iWindow.getWindowId();}
this._iWindow.refresh();this._iWindow.show();}else if(aName=='command'&&action.length==3)this.command(action[1],action[2]);else if(aName=='command')this.command(action[1]);}});var tEle=$(ctrlId);var iEle=document.createElement('iframe');iEle.id=ctrlId+'.HTMLEDITOR';if(tEle.style.width!='')iEle.style.width=tEle.style.width;else iEle.style.width=tEle.offsetWidth+'px';if(tEle.style.height!='')iEle.style.height=tEle.style.height;else iEle.style.height=tEle.offsetHeight+'px';iEle.style.overflow='auto';iEle.frameBorder='0';iEle.border='0';iEle.className=tEle.className;tEle.parentNode.insertBefore(iEle,tEle);tEle.style.display='none';this._iEle=iEle;this._tEle=tEle;if(document.all&&navigator.appName!='Opera'){this._iEle.contentWindow.document.designMode='on';this._eDoc=this._iEle.contentWindow.document;$e.add(this._iEle.contentWindow,'focus',this._edFocus,this,true);$e.add(this._iEle.contentWindow,'blur',this._edBlur,this,true);this.focus();}else{this._iEle.contentDocument.designMode='on';this._iEle.style.lineHeight='0';this._eDoc=this._iEle.contentDocument;$e.add(this._eDoc,'focus',this._edFocus,this,true);$e.add(this._eDoc,'blur',this._edBlur,this,true);}
this._eDoc.open();var initHTML=tEle.value;if(initHTML=='')initHTML='';this._eDoc.write('<head>'+$if(this.styleSheets.linked!='','<link rel="stylesheet" type="text/css" href="'+this.styleSheets.linked+'" />','')+$if(this.styleSheets.css!='','<style type="text/css">'+this.styleSheets.css+'</style>','')+'</head><body>'+initHTML+'</body>');this._eDoc.close();$e.add(this._eDoc,'keyup',this._edGetState,this,true);$e.add(this._eDoc,'keydown',this._edKeyDown,this,true);$e.add(this._eDoc,'mouseup',this._edGetState,this,true);this.state={bold:false,underline:false,italic:false,strikeThrough:false,justifyLeft:true,justifyCenter:false,justifyRight:false,justifyFull:false,fontName:'',fontSize:'',unorderedList:false,orderedList:false,className:'',format:'',canUndo:false,canRedo:false}
if(this.onStateChange.constructor==Function)this.onStateChange();this._edBlurTO=0;this._kw=new AUI.KeyWatcher([{key:'ctrl+b',handle:Function('A5.commandHandler.action(\''+this._htmlEdId+'\',\'command:bold\'); return true;')},{key:'ctrl+i',handle:Function('A5.commandHandler.action(\''+this._htmlEdId+'\',\'command:italic\'); return true;')},{key:'ctrl+u',handle:Function('A5.commandHandler.action(\''+this._htmlEdId+'\',\'command:underline\'); return true;')}],this,this._iEle.contentWindow);this._edSelBookmark='';var classInst=this;setTimeout(function(){classInst._calcToolbar();classInst._edGetClassNames();delete classInst;},1);},command:function(type){this._iEle.contentWindow.focus();var data=typeof(arguments[1]!='undefined')?arguments[1]:null;var lType=type.toLowerCase();if(document.all&&navigator.appName!='Opera'){var range=this._eDoc.body.createTextRange();range.moveToBookmark(this._edSelBookmark);range.select();}
if(lType=='backcolor'){var ele=this._edGetSelElement();if(!ele.tagName)return false;var tagName=ele.tagName.toLowerCase();var validTags=['p','pre','div','td','th','li','h1','h2','h3','h4','h5','h6','blockquote','dd','dt','legend','fieldset','caption','body'];if($u.a.find(validTags,tagName)==-1){while($u.a.find(validTags,tagName)==-1){ele=ele.parentNode;if(ele.tagName)tagName=ele.tagName.toLowerCase();}}
if($u.a.find(validTags,tagName)==-1)return false;if(ele.tagName.toLowerCase()!='body')ele.style.backgroundColor=data;}else if(lType=='hilitecolor'){if(!navigator.userAgent.toLowerCase().match('firefox')&&!navigator.userAgent.toLowerCase().match('opera'))type='backcolor';if(this._eDoc.queryCommandEnabled(type))this._eDoc.execCommand(type,false,data);}else if(lType=='insertdate'){var dt=new Date()
dt=$u.d.toStr(dt,'[mm]/[dd]/[yyyy]');this._edInsertHTML('',''+dt);}else if(lType=='inserttime'){var tt=new Date()
tt=$u.d.toStr(tt,'[t:h]:[t:m][t:am]');this._edInsertHTML('',''+tt);}else if(lType=='inserttable'){data=data.split(',');data[0]=$u.s.toNum(data[0]);data[1]=$u.s.toNum(data[1]);var tableHTML=new Array();for(var i=0;i<data[1];i++){tableHTML.push(' <tr>');for(var j=0;j<data[0];j++){tableHTML.push('  <td>&nbsp;</td>');}
tableHTML.push(' </tr>');}
this._edInsertHTML('table',tableHTML.join('\n'));}else if(lType=='inserttablecolumn'){var ele=this._edGetSelElement();if(!ele.tagName)return false;if(ele.tagName.toLowerCase()!='td'){while(ele.tagName.toLowerCase()!='td')ele=ele.parentNode;}
if(ele.tagName.toLowerCase()!='td')return false;var cellIndx=ele.cellIndex;if(data!=null){if(data.toLowerCase()=='after')cellIndx=cellIndx+1;}
while(ele.tagName.toLowerCase()!='table')ele=ele.parentNode;for(var i=0;i<ele.rows.length;i++){ele.rows[i].insertCell(cellIndx);ele.rows[i].cells[cellIndx].innerHTML='&nbsp;';}}else if(lType=='inserttablerow'){var ele=this._edGetSelElement();if(!ele.tagName)return false;if(ele.tagName.toLowerCase()!='td'){while(ele.tagName.toLowerCase()!='td')ele=ele.parentNode;}
if(ele.tagName.toLowerCase()!='td')return false;var rowIndx=ele.parentNode.rowIndex;if(data!=null){if(data.toLowerCase()=='after')rowIndx=rowIndx+1;}
while(ele.tagName.toLowerCase()!='table')ele=ele.parentNode;var totalCells=0;for(var i=0;i<ele.rows.length;i++)totalCells=Math.max(totalCells,ele.rows[i].cells.length);ele.insertRow(rowIndx);for(var i=0;i<totalCells;i++){ele.rows[rowIndx].insertCell(i);ele.rows[rowIndx].cells[i].innerHTML='&nbsp;';}}else if(lType=='deletetablecolumn'){var ele=this._edGetSelElement();if(!ele.tagName)return false;if(ele.tagName.toLowerCase()!='td'){while(ele.tagName.toLowerCase()!='td')ele=ele.parentNode;}
if(ele.tagName.toLowerCase()!='td')return false;var cellIndx=ele.cellIndex;while(ele.tagName.toLowerCase()!='table')ele=ele.parentNode;for(var i=0;i<ele.rows.length;i++){ele.rows[i].deleteCell(cellIndx);}}else if(lType=='deletetablerow'){var ele=this._edGetSelElement();if(!ele.tagName)return false;if(ele.tagName.toLowerCase()!='td'){while(ele.tagName.toLowerCase()!='td')ele=ele.parentNode;}
if(ele.tagName.toLowerCase()!='td')return false;var rowIndx=ele.parentNode.rowIndex;while(ele.tagName.toLowerCase()!='table')ele=ele.parentNode;ele.deleteRow(rowIndx);}else if(lType=='setclassname'){var ele=this._edGetSelElement();if(ele.tagName.toLowerCase()!='body')ele.className=data;}else if(lType=='setstyle'){var ele=this._edGetSelElement();if(ele.tagName.toLowerCase()!='body')$ss(ele,data);}else if(lType=='cut'||lType=='copy'||lType=='paste'){if(navigator.userAgent.toLowerCase().match('firefox')){alert('Firefox does not support '+lType+'. Use keyboard shortcut to '+lType+'.');}else this._eDoc.execCommand(type,false,data);}else{if(document.all&&navigator.appName!='Opera'){var range=this._eDoc.selection.createRange();range.expand('character');var range2=this._eDoc.selection.createRange();range2.expand('textedit');var node=range2.parentElement();while(node.tagName.toLowerCase()!='body')node=node.parentNode;if(node.innerHTML==this._eDoc.body.innerHTML){if(this._eDoc.queryCommandEnabled(type))this._eDoc.execCommand(type,false,data);}}else{if(this._eDoc.queryCommandEnabled(type))this._eDoc.execCommand(type,false,data);}}
this._edGetState();this.focus();},toggleDesignMode:function(){var show=true;if(typeof arguments[0]!='undefined'){if(arguments[0].toLowerCase()=='code'||arguments[0].toLowerCase()=='textarea')show=false;if((this._iEle.style.display!='none'&&show)||(this._iEle.style.display=='none'&&!show))return false;}else{if(this._iEle.style.display!='none')show=false;}
if(show){if(this._tEle.value!=this.getHTML()){this.setHTML(this._tEle.value);}
this._iEle.style.display='';this._tEle.style.display='none';this.focus();}else{this._tEle.value=this.getHTML();this._iEle.style.display='none';this._tEle.style.display='';this._tEle.focus();}},getHTML:function(){var html=String(this._eDoc.body.innerHTML);if(this._iEle.style.display=='none')html=this._tEle.value;html=html.replace(RegExp('\r','g'),'');return html;},setHTML:function(html){this._eDoc.body.innerHTML=html;if(document.all&&navigator.appName!='Opera'){this._iEle.style.display='none';this._iEle.style.display='';}},focus:function(){if(document.all&&navigator.appName!='Opera'){this._iEle.style.visibility='hidden';this._iEle.style.overflow='hidden';this._iEle.style.visibility='';this._iEle.style.overflow='';}
this._iEle.contentWindow.focus();},_calcToolbar:function(){var ctrlId=this.ctrlId;if(!$(ctrlId+'.TOOLBAR')){var tbEle=document.createElement('div');tbEle.id=ctrlId+'.TOOLBAR';this._iEle.parentNode.insertBefore(tbEle,this._iEle);}
var tbArr=[new A5.EditCombo(this.data.format,{name:'format',createDefaults:{size:10},theme:this.theme,selectionRequired:true,listbox:{item:{template:'{html}',calculateValue:function(data){return data.value;}}},onSelect:function(data,classInst){A5.commandHandler.action(classInst.htmlEdId,'format:'+data.value);}}),' ',new A5.EditCombo([{value:'Times New Roman',html:'<span style="font-family: Times New Roman;">Times New Roman</span>'},{value:'Tahoma',html:'<span style="font-family: Tahoma;">Tahoma</span>'},{value:'Arial',html:'<span style="font-family: Arial;">Arial</span>'},{value:'Courier',html:'<span style="font-family: Courier;">Courier</span>'}],{name:'fontName',createDefaults:{size:20},theme:this.theme,selectionRequired:true,listbox:{item:{template:'{html}',calculateValue:function(data){return data.value;}}},onSelect:function(data,classInst){A5.commandHandler.action(classInst.htmlEdId,'fontName:'+data.value);}}),' ',new A5.EditCombo([{value:'1 (8pt)',html:'<span style="font-size: 8pt;">1 (8pt)</span>'},{value:'2 (10pt)',html:'<span style="font-size: 10pt;">2 (10pt)</span>'},{value:'3 (12pt)',html:'<span style="font-size: 12pt;">3 (12pt)</span>'},{value:'4 (14pt)',html:'<span style="font-size: 14pt;">4 (14pt)</span>'},{value:'5 (18pt)',html:'<span style="font-size: 18pt;">5 (18pt)</span>'},{value:'6 (24pt)',html:'<span style="font-size: 24pt;">6 (24pt)</span>'},{value:'7 (36pt)',html:'<span style="font-size: 36pt;">7 (36pt)</span>'}],{name:'fontSize',createDefaults:{size:7},theme:this.theme,selectionRequired:true,listbox:{item:{template:'{html}',calculateValue:function(data){return data.value;}}},onSelect:function(data,classInst){A5.commandHandler.action(classInst.htmlEdId,'fontSize:'+data.value.substr(0,1));}}),' ',new A5.ButtonToggle({name:'bold',tip:'Bold',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.bold,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:bold');}}),new A5.ButtonToggle({name:'italic',tip:'Italic',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.italic,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:italic');}}),new A5.ButtonToggle({name:'underline',tip:'Underline',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.underline,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:underline');}}),new A5.ButtonToggle({name:'strikethrough',tip:'Strikethrough',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.strike,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:strikethrough');}}),new A5.ButtonToggle({name:'superscript',tip:'Superscript',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.superScript,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:superscript');}}),new A5.ButtonToggle({name:'subscript',tip:'Subscript',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.subScript,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:subscript');}}),' ',new A5.ButtonDropdown({theme:this.theme+':toolbar',tip:'Font Color',layout:'icon',icon:this.icons.color,name:'fontColor',onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'getColor:fontColor');}}),new A5.ButtonDropdown({theme:this.theme+':toolbar',tip:'Highlight Color',layout:'icon',icon:this.icons.highlightColor,name:'highlightColor',onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'getColor:highlightColor');}}),new A5.ButtonDropdown({theme:this.theme+':toolbar',tip:'Background Color',layout:'icon',icon:this.icons.backgroundColor,name:'backgroundColor',onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'getColor:backgroundColor');}}),' ',new A5.ButtonToggle({name:'justifyLeft',tip:'Left',theme:this.theme+':toolbar',value:'left',layout:'icon',icon:this.icons.justifyLeft,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:justifyLeft');}}),new A5.ButtonToggle({name:'justifyCenter',tip:'Center',theme:this.theme+':toolbar',value:'center',layout:'icon',icon:this.icons.justifyCenter,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:justifyCenter');}}),new A5.ButtonToggle({name:'justifyRight',tip:'Right',theme:this.theme+':toolbar',value:'right',layout:'icon',icon:this.icons.justifyRight,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:justifyRight');}}),new A5.ButtonToggle({name:'justifyFull',tip:'Justified',theme:this.theme+':toolbar',value:'justified',layout:'icon',icon:this.icons.justify,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:justifyFull');}}),' ',new A5.Button({theme:this.theme+':toolbar',tip:'Outdent',layout:'icon',icon:this.icons.outdent,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:outdent');}}),new A5.Button({theme:this.theme+':toolbar',tip:'Indent',layout:'icon',icon:this.icons.indent,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:indent');}}),' ',new A5.ButtonToggle({name:'unorderedList',tip:'Unordered List',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.bulletedList,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:InsertUnorderedList');}}),new A5.ButtonToggle({name:'orderedList',tip:'Ordered List',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.numberedList,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:InsertOrderedList');}}),' ',new A5.ButtonDropdown({theme:this.theme+':toolbar',tip:'Insert Symbol',layout:'icon',icon:this.icons.insertSymbol,name:'symbol',onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'getSymbol');}}),new A5.ButtonDropdown({name:'tableMenu',tip:'Table',theme:this.theme+':toolbar',layout:'icon',icon:this.icons.insertTable,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'tableMenu');}})];if(this.insert.image.allow)tbArr.push(new A5.Button({theme:this.theme+':toolbar',tip:'Insert Image',layout:'icon',icon:this.icons.insertImage,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'insert:image');}}));if(this.insert.file.allow)tbArr.push(new A5.Button({theme:this.theme+':toolbar',tip:'Insert File',layout:'icon',icon:this.icons.insertFile,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'insert:file');}}));tbArr=tbArr.concat([' ',new A5.Button({theme:this.theme+':toolbar',tip:'Clear Format',layout:'icon',icon:this.icons.clearFormat,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'command:removeFormat');}}),' ',new A5.ButtonToggle({theme:this.theme+':toolbar',tip:'Toggle Code',layout:'icon',icon:this.icons.toggleCodeView,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'toggleDesignMode');}})]);this._tbObj=new A5.Toolbar(ctrlId+'.TOOLBAR',tbArr,{theme:this.theme,globalProperties:{htmlEdId:this._htmlEdId,createDefaults:{unselectable:'on'}}});},_calcToolbarControl:function(){},_colorMenu:function(cTarget){if(!this._cMenu){this._cMenu=new A5.Menu([{variable:'color',name:'no-color',html:'No Color'},{type:'title',html:'Preset Colors'},{type:'radio-group',preventIndent:true,columns:10,name:'color',variable:'color',data:[{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #ffffff;" title="#ffffff">&nbsp;</div>',value:'#ffffff'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #000000;" title="#000000">&nbsp;</div>',value:'#000000'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #eeece1;" title="#eeece1">&nbsp;</div>',value:'#eeece1'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #1f497d;" title="#1f497d">&nbsp;</div>',value:'#1f497d'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #4f81bd;" title="#4f81bd">&nbsp;</div>',value:'#4f81bd'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #c0504d;" title="#c0504d">&nbsp;</div>',value:'#c0504d'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #9bbb59;" title="#9bbb59">&nbsp;</div>',value:'#9bbb59'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #8064a2;" title="#8064a2">&nbsp;</div>',value:'#8064a2'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #4bacc6;" title="#4bacc6">&nbsp;</div>',value:'#4bacc6'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #f79646;" title="#f79646">&nbsp;</div>',value:'#f79646'}]},{type:'separator',preventIndent:true},{type:'radio-group',preventIndent:true,columns:10,name:'color',variable:'color',data:[{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #f2f2f2;" title="#f2f2f2">&nbsp;</div>',value:'#f2f2f2'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #7f7f7f;" title="#7f7f7f">&nbsp;</div>',value:'#7f7f7f'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #ddd9c3;" title="#ddd9c3">&nbsp;</div>',value:'#ddd9c3'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #c6d9f0;" title="#c6d9f0">&nbsp;</div>',value:'#c6d9f0'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #dbe5f1;" title="#dbe5f1">&nbsp;</div>',value:'#dbe5f1'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #f2dcdb;" title="#f2dcdb">&nbsp;</div>',value:'#f2dcdb'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #ebf1dd;" title="#ebf1dd">&nbsp;</div>',value:'#ebf1dd'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #e5e0ec;" title="#e5e0ec">&nbsp;</div>',value:'#e5e0ec'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #dbeef3;" title="#dbeef3">&nbsp;</div>',value:'#dbeef3'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #fdeada;" title="#fdeada">&nbsp;</div>',value:'#fdeada'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #d8d8d8;" title="#d8d8d8">&nbsp;</div>',value:'#d8d8d8'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #595959;" title="#595959">&nbsp;</div>',value:'#595959'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #c4bd97;" title="#c4bd97">&nbsp;</div>',value:'#c4bd97'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #8db3e2;" title="#8db3e2">&nbsp;</div>',value:'#8db3e2'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #b8cce4;" title="#b8cce4">&nbsp;</div>',value:'#b8cce4'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #e5b9b7;" title="#e5b9b7">&nbsp;</div>',value:'#e5b9b7'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #d7e3bc;" title="#d7e3bc">&nbsp;</div>',value:'#d7e3bc'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #ccc1d9;" title="#ccc1d9">&nbsp;</div>',value:'#ccc1d9'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #b7dde8;" title="#b7dde8">&nbsp;</div>',value:'#b7dde8'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #fbd5b5;" title="#fbd5b5">&nbsp;</div>',value:'#fbd5b5'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #bfbfbf;" title="#bfbfbf">&nbsp;</div>',value:'#bfbfbf'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #3f3f3f;" title="#3f3f3f">&nbsp;</div>',value:'#3f3f3f'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #938953;" title="#938953">&nbsp;</div>',value:'#938953'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #548dd4;" title="#548dd4">&nbsp;</div>',value:'#548dd4'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #95b3d7;" title="#95b3d7">&nbsp;</div>',value:'#95b3d7'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #d99694;" title="#d99694">&nbsp;</div>',value:'#d99694'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #c3d69b;" title="#c3d69b">&nbsp;</div>',value:'#c3d69b'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #b2a2c7;" title="#b2a2c7">&nbsp;</div>',value:'#b2a2c7'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #92cddc;" title="#92cddc">&nbsp;</div>',value:'#92cddc'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #fac08f;" title="#fac08f">&nbsp;</div>',value:'#fac08f'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #a5a5a5;" title="#a5a5a5">&nbsp;</div>',value:'#a5a5a5'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #262626;" title="#262626">&nbsp;</div>',value:'#262626'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #494429;" title="#494429">&nbsp;</div>',value:'#494429'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #17365d;" title="#17365d">&nbsp;</div>',value:'#17365d'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #366092;" title="#366092">&nbsp;</div>',value:'#366092'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #953734;" title="#953734">&nbsp;</div>',value:'#953734'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #76923c;" title="#76923c">&nbsp;</div>',value:'#76923c'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #5f497a;" title="#5f497a">&nbsp;</div>',value:'#5f497a'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #31859b;" title="#31859b">&nbsp;</div>',value:'#31859b'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #e36c09;" title="#e36c09">&nbsp;</div>',value:'#e36c09'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #a5a5a5;" title="#a5a5a5">&nbsp;</div>',value:'#a5a5a5'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #0c0c0c;" title="#0c0c0c">&nbsp;</div>',value:'#0c0c0c'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #1d1b10;" title="#1d1b10">&nbsp;</div>',value:'#1d1b10'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #0f243e;" title="#0f243e">&nbsp;</div>',value:'#0f243e'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #244061;" title="#244061">&nbsp;</div>',value:'#244061'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #632423;" title="#632423">&nbsp;</div>',value:'#632423'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #4f6128;" title="#4f6128">&nbsp;</div>',value:'#4f6128'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #3f3151;" title="#3f3151">&nbsp;</div>',value:'#3f3151'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #205867;" title="#205867">&nbsp;</div>',value:'#205867'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #974806;" title="#974806">&nbsp;</div>',value:'#974806'}]},{type:'title',html:'Standard Colors'},{type:'radio-group',preventIndent:true,columns:10,name:'color',variable:'color',data:[{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #c00000;" title="#c00000">&nbsp;</div>',value:'#c00000'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #ff0000;" title="#ff0000">&nbsp;</div>',value:'#ff0000'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #ffc000;" title="#ffc000">&nbsp;</div>',value:'#ffc000'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #ffff00;" title="#ffff00">&nbsp;</div>',value:'#ffff00'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #92d050;" title="#92d050">&nbsp;</div>',value:'#92d050'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #00b050;" title="#00b050">&nbsp;</div>',value:'#00b050'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #00b0f0;" title="#00b0f0">&nbsp;</div>',value:'#00b0f0'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #0070c0;" title="#0070c0">&nbsp;</div>',value:'#0070c0'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #002060;" title="#002060">&nbsp;</div>',value:'#002060'},{html:'<div style="border: solid 1px #aaa; width: 11px; height: 11px; font-size: 0px; background: #7030a0;" title="#7030a0">&nbsp;</div>',value:'#7030a0'}]}],{theme:this.theme,htmlEdId:this._htmlEdId,iconColumn:{show:true},onClick:function(){A5.commandHandler.action(this.htmlEdId,'setColor:'+this.cTarget+':'+this.getValue('color'));},onHide:function(){A5.commandHandler.action(this.htmlEdId,'clearButtonState:'+this.cTarget);}});}
var ctrlObj=this._tbObj.getControl(cTarget);var ele=$(ctrlObj._buttonIds[0]);var showNoColor=false;if(cTarget=='backgroundColor')showNoColor=true;this._cMenu.hide();this._cMenu.cTarget=cTarget;this._cMenu.setValue('color','');this._cMenu.setDisplay([0],showNoColor);this._cMenu.show('dropdown',ele);ctrlObj.setState(ele,true);},_tblMenu:function(){if(!this._tMenu){this._tMenu=new A5.Menu([{type:'custom',preventIndent:true,html:'<table id="'+this._htmlEdId+'.INSERTTABLE"></table>',onInitialize:function(item){var tEle=$(this._tblId);tEle.cellSpacing='0';tEle.cellPadding='1';$e.add(tEle,'mouseout',this._tblMOut,this);for(var i=0;i<8;i++){tEle.insertRow(i);for(var j=0;j<10;j++){tEle.rows[i].insertCell(j);tEle.rows[i].cells[j].innerHTML='<div style="width: 12px; height: 12px; background: #ffffff; border: solid 1px #aaa; font: 0pt arial;">&nbsp;</div>';$sa(tEle.rows[i].cells[j],'A5TableRows',''+(i+1));$sa(tEle.rows[i].cells[j],'A5TableCols',''+(j+1));$e.add(tEle.rows[i].cells[j],'mouseover',this._tblCellMOver,this);$e.add(tEle.rows[i].cells[j],'click',this._tblCellOnClick,this);}}
tEle.insertRow(8);tEle.rows[8].insertCell(0);tEle.rows[8].cells[0].colSpan='10';tEle.rows[8].cells[0].style.textAlign='center';tEle.rows[8].cells[0].innerHTML='0x0';}},{type:'separator',preventIndent:true},{html:'Insert Row Before',icon:this.icons.tableInsertRowBefore,onClick:function(){A5.commandHandler.action(this.htmlEdId,'command:inserttablerow:before');}},{html:'Insert Row After',icon:this.icons.tableInsertRowAfter,onClick:function(){A5.commandHandler.action(this.htmlEdId,'command:inserttablerow:after');}},{html:'Insert Column Before',icon:this.icons.tableInsertColumnBefore,onClick:function(){A5.commandHandler.action(this.htmlEdId,'command:inserttablecolumn:before');}},{html:'Insert Column After',icon:this.icons.tableInsertColumnAfter,onClick:function(){A5.commandHandler.action(this.htmlEdId,'command:inserttablecolumn:after');}},{html:'Remove Row',icon:this.icons.tableDeleteRow,onClick:function(){A5.commandHandler.action(this.htmlEdId,'command:deletetablerow');}},{html:'Remove Column',icon:this.icons.tableDeleteColumn,onClick:function(){A5.commandHandler.action(this.htmlEdId,'command:deletetablecolumn');}}],{theme:this.theme,htmlEdId:this._htmlEdId,onHide:function(){A5.commandHandler.action(this.htmlEdId,'clearButtonState:tableMenu');},_tblId:this._htmlEdId+'.INSERTTABLE',_tblCellMOver:function(e,classInst){var tEle=$(classInst._tblId);var sRows=Number($ga(this,'A5TableRows'));var sCols=Number($ga(this,'A5TableCols'));for(var i=0;i<8;i++){for(var j=0;j<10;j++){if(i<sRows&&j<sCols)tEle.rows[i].cells[j].firstChild.style.background='#ccc';else tEle.rows[i].cells[j].firstChild.style.background='#fff';}}
tEle.rows[8].cells[0].innerHTML=sCols+'x'+sRows;},_tblMOut:function(e,classInst){var tEle=$(classInst._tblId);for(var i=0;i<8;i++){for(var j=0;j<10;j++)tEle.rows[i].cells[j].firstChild.style.background='#fff';}
tEle.rows[8].cells[0].innerHTML='0x0';},_tblCellOnClick:function(e,classInst){var sRows=Number($ga(this,'A5TableRows'));var sCols=Number($ga(this,'A5TableCols'));A5.commandHandler.action(classInst.htmlEdId,'command:insertTable:'+sCols+','+sRows);classInst.hide();}});}
var ctrlObj=this._tbObj.getControl('tableMenu');var ele=$(ctrlObj._buttonIds[0]);var notInTable=true;var htmlEle=this._edGetSelElement();if(htmlEle){while(htmlEle.tagName.toLowerCase()!='body'){if(htmlEle.tagName.toLowerCase()=='td'){notInTable=false;break;}
htmlEle=htmlEle.parentNode;}}else notInTable=false;this._tMenu.setDisabled([2],notInTable);this._tMenu.setDisabled([3],notInTable);this._tMenu.setDisabled([4],notInTable);this._tMenu.setDisabled([5],notInTable);this._tMenu.setDisabled([6],notInTable);this._tMenu.setDisabled([7],notInTable);this._tMenu.show('dropdown',ele);ctrlObj.setState(ele,true);},_symbolMenu:function(){if(!this._sMenu){this._sMenu=new A5.Menu([{type:'radio-group',preventIndent:true,columns:8,name:'symbol',variable:'symbol',data:['&euro;','&cent;','&pound;','&yen;','&curren;','&copy;','&reg;','&trade;','&plusmn;','&ne;','&asymp;','&le;','&ge;','&divide;','&times;','&infin;','&frac12;','&frac14;','&frac34;','&sup2;','&sup3;','&permil;','&para;','&sect;','&alpha;','&beta;','&Delta;','&micro;','&Omega;','&Sigma;','&Oslash;','&ang;','&ordm;','&laquo;','&raquo;','&middot;','&bull;','&dagger;','&Dagger;','&fnof;']}],{theme:this.theme,htmlEdId:this._htmlEdId,iconColumn:{show:true},onClick:function(item){A5.commandHandler.action(this.htmlEdId,'insertHTML:'+this.getValue('symbol'));},onHide:function(){A5.commandHandler.action(this.htmlEdId,'clearButtonState:symbol');}});}
var ctrlObj=this._tbObj.getControl('symbol');var ele=$(ctrlObj._buttonIds[0]);this._sMenu.setValue('symbol','');this._sMenu.show('dropdown',ele);ctrlObj.setState(ele,true);},_edInsertHTML:function(tagName,tagContent){this._iEle.contentWindow.focus();var attrContent=typeof arguments[2]!='undefined'?arguments[2]:{};var range;if(this._eDoc.selection&&this._eDoc.selection.createRange&&navigator.appName!='Opera'){range=this._eDoc.selection.createRange();var range2=this._eDoc.selection.createRange();range2.expand('textedit');var pEle=range2.parentElement();while(pEle.tagName.toLowerCase()!='body')pEle=pEle.parentNode;if(pEle.innerHTML==this._eDoc.body.innerHTML){var attrArray=new Array();for(var prop in attrContent){attrArray.push(' ');if(prop=='style'){var sArr=new Array();for(var sProp in attrContent[prop]){sArr.push(sProp+': '+attrContent[prop][sProp]+';');}
sArr=sArr.join(' ');attrArray.push('style="'+sArr+'"');}else attrArray.push(prop+'="'+$u.s.tran(attrContent[prop],'"','\\"')+'"');}
attrArray=attrArray.join('');if(tagName!='')range.pasteHTML('<'+tagName+attrArray+'>'+tagContent+'</'+tagName+'>');else range.pasteHTML(tagContent);}}else if(window.getSelection){var selection=this._iEle.contentWindow.getSelection();range=selection.getRangeAt(0);range.deleteContents();if(tagName!=''){var pEle=this._eDoc.createElement(tagName);pEle.innerHTML=tagContent;for(var prop in attrContent){if(prop=='style')$ss(pEle,attrContent[prop]);else pEle[prop]=attrContent[prop];}
if(this._eDoc.body.innerHTML==''){this._eDoc.body.appendChild(pEle)}else{range.insertNode(pEle);}}else{if(this._eDoc.queryCommandEnabled('inserthtml'))this._eDoc.execCommand('inserthtml',false,tagContent);}}},_edGetSelElement:function(){var range;if(this._eDoc.selection&&this._eDoc.selection.createRange&&navigator.appName!='Opera'){range=this._eDoc.selection.createRange();if(range.parentElement){range.expand('character');return range.parentElement();}}else if(window.getSelection){var selection=this._iEle.contentWindow.getSelection();if(!selection.anchorNode.tagName)return selection.anchorNode.parentNode;else return selection.anchorNode;}
return false;},_edGetClassNames:function(){var classList=new Array();var fClassList=new Array();var ssRules=0;for(var i=0;i<this._eDoc.styleSheets.length;i++){ssRules=false;if(this._eDoc.styleSheets[i].cssRules)ssRules=this._eDoc.styleSheets[i].cssRules;else if(this._eDoc.styleSheets[i].rules)ssRules=this._eDoc.styleSheets[i].rules;if(ssRules){for(var j=0;j<ssRules.length;j++){classList=classList.concat(String(ssRules[j].selectorText).split(','));}}}
var tSel1=0;for(var i=0;i<classList.length;i++){if(classList[i].indexOf('.')!=-1){tSel1=classList[i].split('.');tSel1.shift();for(var j=0;j<tSel1.length;j++){tSel1[j]=$u.s.tran(tSel1[j],[' ','\n',':'],[' ',' ',' ']);tSel1[j]=$u.s.word(tSel1[j],1,' ');}
fClassList=fClassList.concat(tSel1);}}
fClassList=$u.a.dedup(fClassList);},_edKeyDown:function(e){var keyCode=e.charCode||e.keyCode;if(keyCode==9){var isList=false;var ele=this._edGetSelElement();while(ele.tagName.toLowerCase()!='body'){if(ele.tagName.toLowerCase()=='li'){isList=true;break;}
ele=ele.parentNode;}
$e.preventDefault(e);if(isList){if(e.shiftKey)this.command('outdent');else this.command('indent');}else if(!e.shiftKey)this._edInsertHTML('','&nbsp;&nbsp;&nbsp;&nbsp;');}},_edGetState:function(e){if(document.all&&navigator.appName!='Opera'&&!window.getSelection){this._iEle.style.display='none';this._iEle.style.display='';}
if(window.getSelection){var selection=this._iEle.contentWindow.getSelection();var range=selection.getRangeAt(0);var node=range.commonAncestorContainer;if(typeof node.tagName!='undefined')if(node.tagName.toLowerCase()=='html')return false;}
if(this._eDoc.selection&&this._eDoc.selection.createRange&&navigator.appName!='Opera'){var range=this._eDoc.selection.createRange();if(typeof range.text!='undefined'){this._edSelBookmark=range.getBookmark();}}
var oldState=$u.o.toJSON(this.state);this.state.bold=this._eDoc.queryCommandState('bold');this.state.underline=this._eDoc.queryCommandState('underline');this.state.italic=this._eDoc.queryCommandState('italic');this.state.strikeThrough=this._eDoc.queryCommandState('strikethrough');this.state.superScript=this._eDoc.queryCommandState('superscript');this.state.subScript=this._eDoc.queryCommandState('subscript');this.state.justifyLeft=this._eDoc.queryCommandState('justifyLeft');this.state.justifyCenter=this._eDoc.queryCommandState('justifyCenter');this.state.justifyRight=this._eDoc.queryCommandState('justifyRight');this.state.justifyFull=this._eDoc.queryCommandState('justifyFull');if(!this.state.justifyLeft&&!this.state.justifyCenter&&!this.state.justifyRight&&!this.state.justifyFull)this.state.justifyLeft=true;this.state.fontName=String(this._eDoc.queryCommandValue('fontName'));this.state.fontSize=String(this._eDoc.queryCommandValue('fontSize'));this.state.unorderedList=this._eDoc.queryCommandState('InsertUnorderedList');this.state.orderedList=this._eDoc.queryCommandState('InsertOrderedList');var ele=this._edGetSelElement();if(ele)this.state.className=ele.className;else this.state.className='';this.state.format=this.data.format[0].value;var fType=this._eDoc.queryCommandValue('formatblock').toLowerCase();for(var i=0;i<this.data.format.length;i++){if(fType==this.data.format[i].tag.toLowerCase()||fType==this.data.format[i].value.toLowerCase()){this.state.format=this.data.format[i].value;break;}}
var newState=$u.o.toJSON(this.state);if(oldState!=newState){if(this.onStateChange.constructor==Function)this.onStateChange();var ctrlObj=this._tbObj.getControl('bold');if(ctrlObj)ctrlObj.setValue(this.state.bold);ctrlObj=this._tbObj.getControl('italic');if(ctrlObj)ctrlObj.setValue(this.state.italic);ctrlObj=this._tbObj.getControl('underline');if(ctrlObj)ctrlObj.setValue(this.state.underline);ctrlObj=this._tbObj.getControl('strikethrough');if(ctrlObj)ctrlObj.setValue(this.state.strikeThrough);ctrlObj=this._tbObj.getControl('subscript');if(ctrlObj)ctrlObj.setValue(this.state.subScript);ctrlObj=this._tbObj.getControl('superscript');if(ctrlObj)ctrlObj.setValue(this.state.superScript);ctrlObj=this._tbObj.getControl('justifyLeft');if(ctrlObj)ctrlObj.setValue(this.state.justifyLeft);ctrlObj=this._tbObj.getControl('justifyCenter');if(ctrlObj)ctrlObj.setValue(this.state.justifyCenter);ctrlObj=this._tbObj.getControl('justifyRight');if(ctrlObj)ctrlObj.setValue(this.state.justifyRight);ctrlObj=this._tbObj.getControl('justifyFull');if(ctrlObj)ctrlObj.setValue(this.state.justifyFull);ctrlObj=this._tbObj.getControl('unorderedList');if(ctrlObj)ctrlObj.setValue(this.state.unorderedList);ctrlObj=this._tbObj.getControl('orderedList');if(ctrlObj)ctrlObj.setValue(this.state.orderedList);ctrlObj=this._tbObj.getControl('format');if(ctrlObj){if(typeof this.state.format=='string')ctrlObj.setValue(this.state.format);else ctrlObj.setValue('Font name');}
ctrlObj=this._tbObj.getControl('fontName');if(ctrlObj){if(this.state.fontName=='')ctrlObj.setValue('Font name');else{if(typeof this.state.fontName=='string')ctrlObj.setValue(this.state.fontName);else ctrlObj.setValue('Font name');}}
ctrlObj=this._tbObj.getControl('fontSize');if(ctrlObj){if(this.state.fontSize=='')ctrlObj.setValue('Font size');else{var val=$u.s.toNum(''+this.state.fontSize);var entry=['Font size','1 (8pt)','2 (10pt)','3 (12pt)','4 (14pt)','5 (18pt)','6 (24pt)','7 (36pt)'];if(val>entry.length)val=0;ctrlObj.setValue(entry[val]);}}
ctrlObj=this._tbObj.getControl('className');if(ctrlObj){if(this.state.className==''||String(this.state.className).toLowerCase()=='apple-style-span')ctrlObj.setValue('Apply class name');else{if(typeof this.state.className=='string')ctrlObj.setValue(this.state.className);else ctrlObj.setValue('Apply class name');}}}
this._tEle.value=this.getHTML();if(e){if(e.type.toLowerCase()=='keyup'){var keyCode=e.charCode||e.keyCode;if(!(keyCode>=16&&keyCode<=18)&&!(keyCode>=37&&keyCode<=40)&&keyCode!=27&&!(keyCode>=33&&keyCode<=36)&&keyCode!=45&&!(keyCode>=112&&keyCode<=123)){if(this.onChange.constructor==Function)this.onChange();}}}else if(this.onChange.constructor==Function)this.onChange();},_edFocus:function(){clearTimeout(this._edBlurTO);this._kw.on();if(this.onFocus.constructor==Function)this.onFocus.call(this);A5.commandHandler.action(this._htmlEdId,'hideMenus');},_edBlur:function(){var classInst=this;this._edBlurTO=setTimeout(function(){classInst._edCompleteBlur();delete classInst;},100);},_edCompleteBlur:function(){this._kw.off();if(this.onBlur.constructor==Function)this.onBlur.call(this);},_htmlEdIndx:[0]}
A5.PopupHTMLEditor=Class.create();A5.PopupHTMLEditor.prototype={initialize:function(settings){$u.o.assign(settings,{theme:'',className:'',window:{theme:'',type:'popup',resize:'both',autoSize:true,buttons:{items:[{html:'Save',action:'commit'},{html:'Cancel'}]}},editor:{theme:''},onCommit:0},true);if(settings.window.theme=='')settings.window.theme=settings.theme+':dropdown';if(settings.editor.theme=='')settings.editor.theme=settings.theme;$u.o.assign(this,settings);$u.o.assign(this.window,{tbar:{show:true},body:{content:{type:'blank'}},onShow:function(){this.onResize();},onResize:function(){var tEle=$(this.getWindowId()+'.EDITOR');var iEle=$(this.getWindowId()+'.EDITOR.HTMLEDITOR');var bEle=tEle.parentNode;tEle.style.height='10px';iEle.style.height='10px';var tempHeight=bEle.parentNode.offsetHeight-((bEle.offsetTop-bEle.parentNode.offsetTop)*2);tempHeight=Math.max(tempHeight,10);tEle.style.height=tempHeight+'px';iEle.style.height=tempHeight+'px';tEle.style.width=iEle.parentNode.offsetWidth+'px';iEle.style.width=iEle.parentNode.offsetWidth+'px';},_onCommit:this.onCommit});this._win=new A5.Window(this.window);this._win.addAction('commit',function(){var html=this._hEd.getHTML();$svs(this._targetId,html);$svs(this._targetId+'.DISPLAY',html);$svs(this._targetId+'.PREVIEW',html);$e.execute(this._targetId,'change');this.hide();if(this._onCommit.constructor==Function)this._onCommit(html);});},setValue:function(val){if(typeof arguments[1]!='undefined'){var ele=$(arguments[1]);if($gvs(ele)!=val){$svs(ele,val);$svs(ele.id+'.DISPLAY',val);$svs(ele.id+'.PREVIEW',val);}}},edit:function(ele){if(!this._win._hEd){$(this._win.getWindowId('body')).innerHTML='<div style="position: relative;"><textarea id="'+this._win.getWindowId()+'.EDITOR" class="'+this.className+'" style="position: absolute; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;"></textarea></div>';$(this._win.getWindowId('tbar')).innerHTML='<div id="'+this._win.getWindowId()+'.EDITOR.TOOLBAR"></div>';this._win._hEd=new A5.HTMLEditor(this._win.getWindowId()+'.EDITOR',this.editor);this._win._hEd._iWindow._targetId=this._win.getWindowId()+'.EDITOR';$ss(this._win._hEd._iEle,$gs(this._win._hEd._iEle)+' box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;')
$e.add(this._win.getWindowId('tbar'),'mousedown',Function('A5.commandHandler.action(\''+this._win._hEd._htmlEdId+'\',\'hideMenus\');'))
var classInst=this;setTimeout(function(){classInst.edit(ele);delete classInst;delete ele;},10);return true;}
ele=$(ele);this._win._hEd.setHTML($gvs(ele));this._win._targetId=ele.id;if($(ele.id+'.DISPLAY'))ele=$(ele.id+'.DISPLAY');else if($(ele.id+'.PREVIEW'))ele=$(ele.id+'.PREVIEW');this._win.show('dropdown',ele);if(this.window.autoSize){var bcEle=$(this._win._windowId+'.BODYCONTAINER');var bEle=$(this._win._windowId+'.BODY');var eEle=this._win._hEd._iEle;if(eEle.style.display=='none')eEle=this._win._hEd._tEle;var w=ele.offsetWidth+($(this._win._windowId+'.BODYCONTAINER').offsetWidth-eEle.offsetWidth);var h=ele.offsetHeight+($(this._win._windowId+'.BODY').offsetHeight-eEle.offsetHeight);this._win.setSize(w+'px',h+'px');}
this._win._hEd.focus();var wEle=$(this._win._windowId);wEle.style.top=Math.max(($gpt(ele)-this._win._hEd._tEle.parentNode.offsetTop)-1,0)+'px';wEle.style.left=Math.max(($gpl(ele)-this._win._hEd._tEle.parentNode.offsetLeft)-1,0)+'px';},bind:function(ctrl){if(ctrl.constructor==Array){for(var i=0;i<ctrl.length;i++)this._bind($(ctrl[i]));}else this._bind($(ctrl));},_bind:function(ele){if($ga(ele,'A5ControlBound')=='true')return true;var dEle=$(ele.id+'.DISPLAY');if(!dEle)dEle=$(ele.id+'.PREVIEW');var bEle=$(ele.id+'.BUTTON');if(!dEle){dEle=document.createElement('div');dEle.id=ele.id+'.PREVIEW';dEle.className=ele.className;$ss(dEle,$gs(ele));ele.style.display='none';dEle.style.display='inline-block';ele.parentNode.insertBefore(dEle,ele);}
$sa(dEle,'A5TargetID',ele.id);dEle.innerHTML=ele.value;if(bEle){$sa(bEle,'A5TargetID',ele.id);$e.add(bEle,'click',function(e,classInst){classInst.edit($ga(this,'A5TargetID'));},this);$e.add(dEle,'dblclick',function(e,classInst){classInst.edit($ga(this,'A5TargetID'));},this);}else $e.add(dEle,'click',function(e,classInst){classInst.edit($ga(this,'A5TargetID'));},this);$sa(ele,'A5ControlBound','true');}}
if(typeof A5.themes=='undefined'){A5.themes={_t:{},add:function(sName,sObj){if(typeof this._t[sName]=='undefined')this._t[sName]={};$u.o.assign(this._t[sName],sObj);},assign:function(classInst,sPath,sType){sPath=sPath.split(':');var sName=sPath.shift();if(typeof this._t[sName]!='undefined'){var sObj=this._t[sName];if(typeof sObj[sType]!='undefined'){var stObj=sObj[sType];if(sPath.length>0){for(var i=sPath.length-1;i>=0;i--){if(typeof stObj[sPath.join(':')]!='undefined'){$u.o.assign(classInst,stObj[sPath.join(':')]);return true;}
sPath.pop();}}
if(typeof stObj.base!='undefined')$u.o.assign(classInst,stObj.base);return true;}}}}}
A5.u={_uIdIndx:0,getUniqueId:function(){A5.u._uIdIndx++;return'A5UID'+A5.u._uIdIndx;},element:{toggle:function(ele,anim){if(typeof anim!='object')anim={};if(ele.style.display=='none'){if(typeof anim.show!='undefined')A5.u.element.show(ele,anim.show);else A5.u.element.show(ele,anim);}else{if(typeof anim.hide!='undefined')A5.u.element.hide(ele,anim.hide);else A5.u.element.hide(ele,anim);}},hide:function(ele,anim){if(ele.style.display=='none')return false;if(typeof anim!='object')anim={};var animTypes=['fade','slide','blind','clip','drop','explode','fold','puff','scale','size','pulsate'];var func=typeof anim.onComplete!='undefined'?anim.onComplete:null;if($u.a.find(animTypes,anim.type)!=-1&&typeof jQuery!='undefined'){if(jQuery(ele).queue().length!=0)return false;if(anim.type=='slide')jQuery(ele).slideUp(anim.duration,func);else if(anim.type=='fade')jQuery(ele).fadeOut(anim.duration,func);else jQuery(ele).hide(anim.type,anim.duration,func);}else{$sa(ele,'A5StyleDisplay',ele.style.display);ele.style.display='none';if(func)func();}},show:function(ele,anim){if(ele.style.display!='none')return false;if(typeof anim!='object')anim={};var animTypes=['fade','slide','blind','clip','drop','explode','fold','puff','scale','size','pulsate'];var func=typeof anim.onComplete!='undefined'?anim.onComplete:null;if($u.a.find(animTypes,anim.type)!=-1&&typeof jQuery!='undefined'){if(jQuery(ele).queue().length!=0)return false;if(anim.type=='slide')jQuery(ele).slideDown(anim.duration,func);else if(anim.type=='fade')jQuery(ele).fadeIn(anim.duration,func);else jQuery(ele).show(anim.type,anim.duration,func);}else{var dVal=$ga(ele,'A5StyleDisplay');if(typeof dVal=='string')ele.style.display=dVal;else ele.style.display='';if(func)func();}}}}

	
/*
Copyright (c) 2001, 2008
Alpha Software, Inc.

This JavaScript library is licensed exclusively for use with Alpha Five, 
Alpha Five Application Server and Alpha Five Run Engine. It is specifically 
not licensed for use on a server that does not have installed on it, a 
licensed copy of the Alpha Five Application Server.
*/



function load_date_picker(target,old_date,settings){settings.contID=target+'_CalendarCont';if(old_date==$ga(target,'A5WatermarkText'))old_date='';style=settings.style
path=settings.path
use_select=settings.use_select
format=settings.format
low_year=settings.low_year
high_year=settings.high_year
switch_year=settings.switch_year
if(!settings.months)settings.months=['January','February','March','April','May','June','July','August','September','October','November','December'];if(!settings.days)settings.days=['Sun','Mon','Tue','Wed','Thur','Fri','Sat'];if(!settings.start_day)settings.start_day=1;if(!settings.todayText)settings.todayText='Today';if(!settings.closeText)settings.closeText='Close';object_name=$if(settings.object_name,settings.object_name,target+'_DateSet');if(settings.cellpadding!=undefined){cur_cellpadding=settings.cellpadding}
else{cur_cellpadding=2}
if(settings.cellspacing!=undefined){cur_cellspacing=settings.cellspacing}
else{cur_cellspacing=0}
month_type=1
if(format.search('mm')!=-1){month_type=1}
else if(format.search('m')!=-1){month_type=8}
else if(format.search('month')!=-1){month_type=5}
else if(format.search('MONTH')!=-1){month_type=6}
else if(format.search('Month')!=-1){month_type=7}
else if(format.search('mon')!=-1){month_type=2}
else if(format.search('MON')!=-1){month_type=3}
else if(format.search('Mon')!=-1){month_type=4}
day_type=1
if(format.search('dd')!=-1){day_type=1}
else if(format.search('d')!=-1){day_type=2}
else if(format.search('x')!=-1){day_type=3}
var old_date_obj=new Date()
if(old_date==''){old_day=old_date_obj.getDate()
old_month=old_date_obj.getMonth()
old_year=old_date_obj.getFullYear()
second_date=0}
else{if(old_date.slice(old_date.length-2)=='..'){second_date=1}
else{second_date=0}
var tDate_arr=old_date.split(/[^0-9A-z]/);var date_arr=new Array();for(var i=0;i<tDate_arr.length;i++){if(tDate_arr[i]!=''){date_arr.push(tDate_arr[i]);}}
if(day_type==1){day_loc=format.search('dd')}
else if(day_type==2){day_loc=format.search('d')}
else if(day_type==3){day_loc=format.search('x')}
if(month_type==1){month_loc=format.search('mm')}
else if(month_type==8){month_loc=format.search('m')}
else if(month_type==5){month_loc=format.search('mon')}
else if(month_type==6){month_loc=format.search('MON')}
else if(month_type==7){month_loc=format.search('Mon')}
else if(month_type==2){month_loc=format.search('mon')}
else if(month_type==3){month_loc=format.search('MON')}
else if(month_type==4){month_loc=format.search('Mon')}
year_loc=format.search('yy')
if(day_type==3){if(day_loc>month_loc){if(day_loc>year_loc){day_val=parseInt(date_arr[2])}
else{day_val=parseInt(date_arr[1])}}
else{if(day_loc>year_loc){day_val=parseInt(date_arr[1])}
else{day_val=parseInt(date_arr[0])}}}
else{if(day_loc>month_loc){if(day_loc>year_loc){day_val=Number(date_arr[2])}
else{day_val=Number(date_arr[1])}}
else{if(day_loc>year_loc){day_val=Number(date_arr[1])}
else{day_val=Number(date_arr[0])}}}
if(month_type==1||month_type==8){if(month_loc>day_loc){if(month_loc>year_loc){month_val=Number(date_arr[2])}
else{month_val=Number(date_arr[1])}}
else{if(month_loc>year_loc){month_val=Number(date_arr[1])}
else{month_val=Number(date_arr[0])}}}
else if(month_type==2||month_type==3||month_type==4){if(month_loc>day_loc){if(month_loc>year_loc){month_val=get_num_month(settings,date_arr[2])}
else{month_val=get_num_month(settings,date_arr[1])}}
else{if(month_loc>year_loc){month_val=get_num_month(settings,date_arr[1])}
else{month_val=get_num_month(settings,date_arr[0])}}}
else{if(month_loc>day_loc){if(month_loc>year_loc){month_val=get_num_month(settings,date_arr[2])}
else{month_val=get_num_month(settings,date_arr[1])}}
else{if(month_loc>year_loc){month_val=get_num_month(settings,date_arr[1])}
else{month_val=get_num_month(settings,date_arr[0])}}}
if(year_loc>month_loc){if(year_loc>day_loc){year_val=Number(date_arr[2])}
else{year_val=Number(date_arr[1])}}
else{if(month_loc>day_loc){year_val=Number(date_arr[1])}
else{year_val=Number(date_arr[0])}}
if(day_val>0&&day_val<32){old_day=day_val}
else{old_day=old_date_obj.getDate()}
if(month_val>0&&month_val<13){old_month=(month_val-1)}
else{old_month=old_date_obj.getMonth()}
if(isNaN(year_val)){year_val=old_date_obj.getFullYear()}
if(format.search('yyyy')>=0){if(year_val<10){year_val='0'+year_val}
old_year=year_val}
else if(year_val>999){if(year_val<10){year_val='0'+year_val}
old_year=year_val}
else{test_val=Number(year_val)
if(year_val<10){year_val='0'+year_val}
if(test_val>=switch_year){new_val='19'+year_val
old_year=Number(new_val)}
else{new_val='20'+year_val
old_year=Number(new_val)}}}
if(use_select==1){month_html='&nbsp;<select id="'+settings.contID+'.sel_month" class="'+style+'Select" onchange="fill_calendar(document.getElementById(\''+settings.contID+'.sel_month\').value,document.getElementById(\''+settings.contID+'.sel_year\').value,'+object_name+','+month_type+','+day_type+')" value="'+old_month+'">\n'
for(var i=0;i<12;i++){if(old_month==i)month_html=month_html+'<option value="'+i+'" selected>'+settings.months[i]+'</option>\n'
else month_html=month_html+'<option value="'+i+'">'+settings.months[i]+'</option>\n'}
month_html=month_html+'</select>'
year_html='<select id="'+settings.contID+'.sel_year" class="'+style+'Select" onchange="fill_calendar(document.getElementById(\''+settings.contID+'.sel_month\').value,document.getElementById(\''+settings.contID+'.sel_year\').value,'+object_name+','+month_type+','+day_type+')" value="'+old_year+'">\n'
for(i=low_year;i<=high_year;i++){if(i==old_year){year_html=year_html+'<option value="'+i+'" selected>'+i+'</option>\n'}
else{year_html=year_html+'<option value="'+i+'">'+i+'</option>\n'}}
year_html=year_html+'</select>';month_year_html=month_html+' '+year_html+'&nbsp;'}
else{month_html=settings.months[old_month];year_html=''+old_year;month_year_html='<div id="'+settings.contID+'_date_display" style="width:125px">'+month_html+' '+year_html+'</div>';}
calendar_html='<table cellspacing="'+cur_cellspacing+'" cellpadding="'+cur_cellpadding+'" class="table" style="width: 100%">\n<tr>\n';var day_of_the_week=settings.start_day;for(i=0;i<=6;i++){calendar_html=calendar_html+'<th class="calendar" align="center" style="width:14.3%">'+settings.days[day_of_the_week-1]+'</th>\n';day_of_the_week++;if(day_of_the_week>7)day_of_the_week=day_of_the_week-7}
calendar_html=calendar_html+'</tr>\n';for(i=1;i<=6;i++){calendar_html=calendar_html+'<tr>\n'
for(j=1;j<=7;j++){if(j==1||j==7){calendar_html=calendar_html+'<td id="'+settings.contID+'_1_w_'+i+'_d_'+j+'" class="weekend" align="center">&nbsp;</td>\n'}
else{calendar_html=calendar_html+'<td id="'+settings.contID+'_1_w_'+i+'_d_'+j+'" class="workday" align="center">&nbsp;</td>\n'}}
calendar_html=calendar_html+'</tr>\n'}
calendar_html=calendar_html+'</table>\n'
var old_date_obj=new Date()
new_html='<table id="cal_layout_table" cellpadding="0" cellspacing="0" border="0">\n'+'<tr>\n'+'<td align="center">\n'+'<table cellpadding="0" cellspacing="0" border="0">\n'+'<tr>\n'+'<td align="center" nowrap>'+'<a href="#" onclick="prev_year('+object_name+','+month_type+','+day_type+'); return false"><img src="'+path+style+'/PrevYear.png" alt="Previous Year" border="0"></a>'+'<a href="#" onclick="prev_month('+object_name+','+month_type+','+day_type+'); return false"><img src="'+path+style+'/PrevMonth.png" alt="Previous Month" border="0"></a>'+'</td>\n'+'<td align="center" nowrap>'+month_year_html+'</td>\n'+'<td align="center" nowrap>'+'<a href="#" onclick="next_month('+object_name+','+month_type+','+day_type+'); return false"><img src="'+path+style+'/NextMonth.png" alt="Next Month" border="0"></a>'+'<a href="#" onclick="next_year('+object_name+','+month_type+','+day_type+'); return false"><img src="'+path+style+'/NextYear.png" alt="Next Year" border="0"></a>'+'</td>\n'+'</tr>\n'+'<tr>\n'+'<td style="height:5px" colspan="3"></td>\n'+'</tr>\n'+'<tr>\n'+'<td colspan="3">'+calendar_html+'</td>\n'+'</tr>\n'+'<tr>\n'+'<td style="height:5px" colspan="3"></td>\n'+'</tr>\n'+'<tr>\n'+'<td align="center" colspan="3">'+'<button class="CalendarButtons" onclick="set_date(1,'+old_date_obj.getDate()+','+object_name+','+month_type+','+day_type+')">'+settings.todayText+'</button> '+'<button class="CalendarButtons" onclick="hide_calendar('+object_name+')">'+settings.closeText+'</button>'+'</td>\n'+'</tr>\n'+'</table>\n'+'</td>\n'+'</tr>\n'+'</table>';if(!settings.object_name){settings.object_name=object_name;}
settings.target_input=target;settings.second_date=second_date;settings.old_year=old_year;settings.old_month=old_month;settings.old_day=old_day;settings.cur_year=old_year;settings.cur_month=old_month;settings.cur_day=old_day;if(!document.getElementById(settings.contID)){obj=document.createElement('div');obj.id=settings.contID;obj.className=style+'AltDataTD '+
style+'DataTD '+
style+'FormTABLE '+
style+'PageBODY';obj.style.borderStyle='solid';obj.style.borderColor='ThreeDShadow';obj.style.borderWidth='1px';obj.style.position='absolute';obj.style.top='0px';obj.style.left='0px';obj.style.padding='3px';obj.style.zIndex='1000';document.body.insertBefore(obj,document.body.firstChild);$e.add(settings.contID,'mousedown',$e.stopPropagation);}
if(document.all&&!window['XMLHttpRequest']){eles=document.body.getElementsByTagName('select');for(var i=0;i<eles.length;i++){if(eles[i].id!=settings.contID+'.sel_year'&&eles[i].id!=settings.contID+'.sel_month')eles[i].style.visibility='hidden';}}
settings._iframes=new Array();eles=document.body.getElementsByTagName('iframe');for(var i=0;i<eles.length;i++){if(eles[i].style.visibility!='hidden'&&eles[i].id!=''&&eles[i].src.toString().split('.').pop().substr(0,3).toLowerCase()=='pdf'){settings._iframes.push(eles[i].id);eles[i].style.visibility='hidden';}}
document.getElementById(settings.contID).style.display='block';document.getElementById(settings.contID).innerHTML=new_html;fill_calendar(old_month,old_year,settings,month_type,day_type);$po(document.getElementById(settings.contID),document.getElementById(target),'dropdown',-1)
$e.add(document.documentElement,'mousedown',hide_calendar_evnt,settings);}
function fill_calendar(cur_month,cur_year,settings,month_type,day_type){cur_month=Number(cur_month)
cur_year=Number(cur_year)
if(cur_month==settings.old_month&&cur_year==settings.old_year){cur_day=settings.old_day}else{cur_day=0}
delete date_obj
date_obj=new Date();if(cur_month==date_obj.getMonth()&&cur_year==date_obj.getFullYear()){cur_today=date_obj.getDate()
if(cur_day==cur_today){cur_day=0}}
else{cur_today=0}
date_obj.setDate(1);date_obj.setFullYear(cur_year);date_obj.setMonth(cur_month);start_day=date_obj.getDay();end_month_check_1=new Date(cur_year,cur_month+1,1);timeDifference=end_month_check_1-86400000;end_month_check_2=new Date(timeDifference);var days_in_month=end_month_check_2.getDate();var day_count=1;var day_of_the_week=settings.start_day;start_day=start_day-day_of_the_week+1;if(start_day<1)start_day=start_day+7
for(i=1;i<=6;i++){for(j=1;j<=7;j++){tar=document.getElementById(settings.contID+'_1_w_'+i+'_d_'+j)
if(i==1&&j<=start_day){tar.innerHTML='&nbsp;'
if(j==1||j==7){if(tar.className!="weekend"){tar.className="weekend"}}
else{if(tar.className!="workday"){tar.className="workday"}}}else{if(day_count<=days_in_month){if(cur_day==day_count){tar.innerHTML='<a href="#" onclick="set_date(0,'+day_count+','+settings.object_name+','+month_type+','+day_type+'); return false" class="selectedDay">'+day_count+'</a>'
tar.className="selectedDay"}else if(cur_today==day_count){tar.innerHTML='<a href="#" onclick="set_date(0,'+day_count+','+settings.object_name+','+month_type+','+day_type+'); return false" class="today">'+day_count+'</a>'
tar.className="today"}else{tar.innerHTML='<a href="#" onclick="set_date(0,'+day_count+','+settings.object_name+','+month_type+','+day_type+'); return false" class="weekday weekDay">'+day_count+'</a>'
if(day_of_the_week==1||day_of_the_week==7){if(tar.className!="weekend"){tar.className="weekend"}}
else{if(tar.className!="workday"){tar.className="workday"}}}
day_count++;}
else{tar.innerHTML='&nbsp;'
if(day_of_the_week==1||day_of_the_week==7){if(tar.className!="weekend"){tar.className="weekend"}}
else{if(tar.className!="workday"){tar.className="workday"}}}}
day_of_the_week++;if(day_of_the_week>7)day_of_the_week=day_of_the_week-7}}
if(settings.use_select==0){month_html=settings.months[cur_month];year_html=''+cur_year;month_year_html=month_html+' '+year_html;document.getElementById(settings.contID+'_date_display').innerHTML=month_year_html
settings.cur_month=cur_month;settings.cur_year=cur_year;}}
function prev_month(settings,month_type,day_type){if(settings.use_select==1){cur_month=Number(document.getElementById(settings.contID+'.sel_month').value)
cur_year=Number(document.getElementById(settings.contID+'.sel_year').value)
if(cur_month==0){document.getElementById(settings.contID+'.sel_month').value=11
document.getElementById(settings.contID+'.sel_year').value=cur_year-1}
else{document.getElementById(settings.contID+'.sel_month').value=cur_month-1}
fill_calendar(document.getElementById(settings.contID+'.sel_month').value,document.getElementById(settings.contID+'.sel_year').value,settings,month_type,day_type)}
else{cur_month=settings.cur_month
cur_year=settings.cur_year
if(cur_month==0){settings.cur_month=11
settings.cur_year=cur_year-1}
else{settings.cur_month=cur_month-1}
fill_calendar(settings.cur_month,settings.cur_year,settings,month_type,day_type)}}
function prev_year(settings,month_type,day_type){if(settings.use_select==1){cur_year=Number(document.getElementById(settings.contID+'.sel_year').value)
document.getElementById(settings.contID+'.sel_year').value=cur_year-1
fill_calendar(document.getElementById(settings.contID+'.sel_month').value,document.getElementById(settings.contID+'.sel_year').value,settings,month_type,day_type)}
else{cur_year=settings.cur_year
settings.cur_year=cur_year-1
fill_calendar(settings.cur_month,settings.cur_year,settings,month_type,day_type)}}
function next_month(settings,month_type,day_type){if(settings.use_select==1){cur_month=Number(document.getElementById(settings.contID+'.sel_month').value)
cur_year=Number(document.getElementById(settings.contID+'.sel_year').value)
if(cur_month==11){document.getElementById(settings.contID+'.sel_month').value=0
document.getElementById(settings.contID+'.sel_year').value=cur_year+1}
else{document.getElementById(settings.contID+'.sel_month').value=cur_month+1}
fill_calendar(document.getElementById(settings.contID+'.sel_month').value,document.getElementById(settings.contID+'.sel_year').value,settings,month_type,day_type)}
else{cur_month=Number(settings.cur_month)
cur_year=Number(settings.cur_year)
if(cur_month==11){settings.cur_month=0
settings.cur_year=cur_year+1}
else{settings.cur_month=cur_month+1}
fill_calendar(settings.cur_month,settings.cur_year,settings,month_type,day_type)}}
function next_year(settings,month_type,day_type){if(settings.use_select==1){cur_year=Number(document.getElementById(settings.contID+'.sel_year').value)
document.getElementById(settings.contID+'.sel_year').value=cur_year+1
fill_calendar(document.getElementById(settings.contID+'.sel_month').value,document.getElementById(settings.contID+'.sel_year').value,settings,month_type,day_type)}
else{cur_year=settings.cur_year
settings.cur_year=cur_year+1
fill_calendar(settings.cur_month,settings.cur_year,settings,month_type,day_type)}}
function set_date(style,cur_day,settings,month_type,day_type){if(style==1){var old_date_obj=new Date()
cur_month=old_date_obj.getMonth()
cur_year=old_date_obj.getFullYear()}
else{if(settings.use_select==1){cur_month=Number(document.getElementById(settings.contID+'.sel_month').value)
cur_year=Number(document.getElementById(settings.contID+'.sel_year').value)}
else{cur_month=settings.cur_month
cur_year=settings.cur_year}}
format=settings.format
cur_day=Number(cur_day)
if(day_type==1){cur_day_str=''
if(cur_day<10){cur_day_str='0'+cur_day}
else{cur_day_str=''+cur_day}
format=format.replace('dd',cur_day_str)}
else if(day_type==2){format=format.replace('d',cur_day)}
else if(day_type==3){cur_day_str=''
if(cur_day==1||cur_day==21||cur_day==31){cur_day_str=cur_day+'st'}
else if(cur_day==2||cur_day==22){cur_day_str=cur_day+'nd'}
else if(cur_day==3||cur_day==23){cur_day_str=cur_day+'rd'}
else{cur_day_str=cur_day+'th'}
format=format.replace('x',cur_day_str)}
cur_month=Number(cur_month)+1
if(month_type==1){cur_month_str=''
if(cur_month<10){cur_month_str='0'+cur_month}
else{cur_month_str=''+cur_month}
format=format.replace('mm',cur_month_str)}
else if(month_type==8){format=format.replace('m',cur_month)}
else if(month_type==5){format=format.replace('month',get_chr_month(settings,cur_month,month_type))}
else if(month_type==6){format=format.replace('MONTH',get_chr_month(settings,cur_month,month_type))}
else if(month_type==7){format=format.replace('Month',get_chr_month(settings,cur_month,month_type))}
else if(month_type==2){format=format.replace('mon',get_chr_month(settings,cur_month,month_type))}
else if(month_type==3){format=format.replace('MON',get_chr_month(settings,cur_month,month_type))}
else if(month_type==4){format=format.replace('Mon',get_chr_month(settings,cur_month,month_type))}
format=format.replace('mm',cur_month)
if(format.search('yyyy')>=0){format=format.replace('yyyy',cur_year)}
else{temp_year=String(cur_year)
temp_year=temp_year.slice(2)
format=format.replace('yy',temp_year)}
hide_calendar(settings);if(settings.second_date==0){document.getElementById(settings.target_input).value=format}
else{document.getElementById(settings.target_input).value=document.getElementById(settings.target_input).value+format}
if($e){if($e.execute){$e.execute(settings.target_input,'change');}}}
function hide_calendar_evnt(e,settings){hide_calendar(settings)}
function hide_calendar(settings){document.getElementById(settings.contID).style.display='none';if(document.all&&!window['XMLHttpRequest']){eles=document.body.getElementsByTagName('select');for(var i=0;i<eles.length;i++){eles[i].style.visibility='';}}
for(var i=0;i<settings._iframes.length;i++){document.getElementById(settings._iframes[i]).style.visibility='';}
$e.remove(document.documentElement,'mousedown',hide_calendar_evnt);}
function get_num_month(settings,month_to_convert){month_to_convert=month_to_convert.toLowerCase();month_to_convert=month_to_convert.substr(0,3);cur_month_num=1;for(var i=0;i<settings.months.length;i++){if(settings.months[i].substr(0,3).toLowerCase()==month_to_convert){cur_month_num=i+1;break;}}
return cur_month_num}
function get_chr_month(settings,cur_month,month_type){cur_chr_month=settings.months[cur_month-1];if(month_type==2||month_type==3||month_type==4){cur_chr_month=cur_chr_month.substr(0,3)}
if(month_type==2||month_type==5){cur_chr_month=cur_chr_month.toLowerCase()}
else if(month_type==3||month_type==6){cur_chr_month=cur_chr_month.toUpperCase()}
return cur_chr_month}

	
/*
Copyright (c) 2001, 2008
Alpha Software, Inc.

This JavaScript library is licensed exclusively for use with Alpha Five, 
Alpha Five Application Server and Alpha Five Run Engine. It is specifically 
not licensed for use on a server that does not have installed on it, a 
licensed copy of the Alpha Five Application Server.
*/



var Report=Class.create();Report.prototype={initialize:function(reportId,templateId){this.reportId=reportId;this.templateId=templateId;this._prepareReport($(this.reportId));},populate:function(data){var rEle=false;for(var prop in data){if(data[prop].constructor==Array){var rEle=$(this.reportId+'.'+prop);this._addRows(this.templateId+'.'+prop,this.templateId+'.'+prop,rEle,data[prop],false);}else{$svs(this.reportId+'.'+prop,data[prop]);}}
var reportState=data['*state'];if(reportState)
this._setState(reportState);},_prepareReport:function(ele){for(var i=0;i<ele.childNodes.length;i++){if(ele.childNodes[i].getAttribute){if(ele.childNodes[i].getAttribute('A5ReportDataIndex')!=''&&ele.childNodes[i].getAttribute('A5ReportDataIndex')){ele.childNodes[i].id=this.reportId+'.'+ele.childNodes[i].getAttribute('A5ReportDataIndex');}}
if(ele.childNodes[i].childNodes){if(ele.childNodes[i].childNodes.length!=0)this._prepareReport(ele.childNodes[i]);}}},_addRows:function(templateId,nodeId,tEle,data,flatten){var ele=false;var fAttr=$(templateId).getAttribute('A5ReportFlatten');if(fAttr!=''&&fAttr){flatten=$u.s.toBool(fAttr);}
var prop='';for(var i=0;i<data.length;i++){if(!flatten){ele=document.getElementById(templateId).cloneNode(true);ele.id=nodeId+'['+i+']';tEle.appendChild(ele);this._fillRow(ele,data[i],nodeId+'['+i+']');}else{if($(templateId)){ele=document.getElementById(templateId).cloneNode(true);ele.id=nodeId+'['+i+']';tEle.appendChild(ele);this._fillRow(ele,data[i],nodeId+'['+i+']');}}
for(prop in data[i]){if(data[i][prop].constructor==Array){this._createGroup(templateId+'.'+prop,nodeId+'['+i+'].'+prop,ele,data[i][prop],flatten);}}
if(flatten){if($(templateId+'~')){ele=document.getElementById(templateId+'~').cloneNode(true);ele.id=nodeId+'['+i+']~';tEle.appendChild(ele);this._fillRow(ele,data[i],nodeId+'['+i+']');}}}},_createGroup:function(templateId,nodeId,ele,data,flatten){if(flatten){this._addRows(templateId,nodeId,ele.parentNode,data,flatten);return false;}
var tEles=ele.getElementsByTagName('table');var ttEle=false;for(var i=0;i<tEles.length;i++){if(tEles[i].getAttribute('A5ReportGroupIndex')==templateId){ttEle=tEles[i];break;}}
if(ttEle){ttEle.id=nodeId;this._addRows(templateId,nodeId,ttEle,data,flatten);}},_fillRow:function(ele,data,nodeId){for(var i=0;i<ele.childNodes.length;i++){if(ele.childNodes[i].getAttribute){if(ele.childNodes[i].getAttribute('A5ReportDataIndex')!=''&&ele.childNodes[i].getAttribute('A5ReportDataIndex')){if(ele.childNodes[i].tagName.toLowerCase()=='img')ele.childNodes[i].src=data[ele.childNodes[i].getAttribute('A5ReportDataIndex')];else ele.childNodes[i].innerHTML=data[ele.childNodes[i].getAttribute('A5ReportDataIndex')];}
if(ele.childNodes[i].getAttribute('A5ReportDataAttrib')!=''){ele.childNodes[i].setAttribute('A5ReportDataAttrib',data[ele.childNodes[i].getAttribute('A5ReportDataAttrib')]);}
if(ele.childNodes[i].getAttribute('A5ReportConditionIndex')!=''&&ele.childNodes[i].getAttribute('A5ReportConditionIndex')){if(!data[ele.childNodes[i].getAttribute('A5ReportConditionIndex')]){ele.childNodes[i].style.display='none';}}
if(ele.childNodes[i].getAttribute('A5ReportRecordReference')!=''&&ele.childNodes[i].getAttribute('A5ReportRecordReference')){if(ele.childNodes[i].getAttribute('A5ReportRecordReference')!='.')ele.childNodes[i].setAttribute('A5ReportRecordReference',nodeId+'.'+ele.childNodes[i].getAttribute('A5ReportRecordReference'));else ele.childNodes[i].setAttribute('A5ReportRecordReference',nodeId);}
if(ele.childNodes[i].getAttribute('A5ReportGeneratedId')!=''&&ele.childNodes[i].getAttribute('A5ReportGeneratedId')){ele.childNodes[i].id=nodeId+'.'+ele.childNodes[i].getAttribute('A5ReportGeneratedId');}
if(ele.childNodes[i].getAttribute('A5ReportClassNameIndex')!=''&&ele.childNodes[i].getAttribute('A5ReportClassNameIndex')){$acn(ele.childNodes[i],data[ele.childNodes[i].getAttribute('A5ReportClassNameIndex')]);}}
if(ele.childNodes[i].childNodes){if(ele.childNodes[i].childNodes.length!=0)this._fillRow(ele.childNodes[i],data,nodeId);}}},_toggleBranch:function(branchId){var idArr=branchId.split('.');var groupName=idArr.pop();idArr=idArr.join('.');var ele=$(branchId);if(ele.style.display=='none'){ele.style.display='';$acn(idArr,groupName+'_isOpen');}else{ele.style.display='none';$rcn(idArr,groupName+'_isOpen');}},_toggleRow:function(buttonPtr,branchId){var ele=$(branchId);if(ele.style.display=='none'){ele.style.display='';$acn(buttonPtr,'A5ReportButtonExpanded');}else{ele.style.display='none';$rcn(buttonPtr,'A5ReportButtonExpanded');}},_toggleColumn:function(buttonPtr,colGroup){var tblName=buttonPtr.getAttribute('A5ReportRecordReference');var tbl=$(tblName);var classList=tbl.className;if(classList&&classList.indexOf('hide'+colGroup)>-1){$rcn(tbl,'hide'+colGroup);$acn(buttonPtr,'A5ReportButtonExpanded');}else{$acn(tbl,'hide'+colGroup);$rcn(buttonPtr,'A5ReportButtonExpanded');}},_setCurrentRow:function(currentState,prefix){var name=currentState['name'];var offset=currentState['offset'];var child=currentState['child'];var branchId=prefix+name;var idArr=branchId.split('.');var tbl=$(branchId);if(tbl){if(tbl.style.display=='none'){tbl.style.display='';$acn(idArr,name+'_isOpen');}}else{alert('Could not find branch '+branchId);return;}
if(child){this._setCurrentRow(child,prefix+name+'['+(offset-1)+'].');}else{var rowName=prefix+name+'['+(offset-1)+']';var rowEle=$(rowName);if(rowEle){rowEle.focus();rowEle.scrollIntoView();}}},_setState:function(reportState){var currentRow=reportState['current_row'];if(currentRow){this._setCurrentRow(currentRow,this.templateId+'.');}}}


A5.GridComponentHelper = Class.create();
A5.GridComponentHelper.prototype = {
	initialize: function(gridId,settings){
		this.gridId = gridId;
		
		$u.o.assign(settings,{
			ajaxURL: '',
			gridColumnInfo: [],
			detailViewColumnInfo: [],
			rowRefreshOnFocus: false,
			rowRefreshOnDirty: false,
			pageNumber: 0,
			pagesInGrid: 0,
			rowsPerPage: 0,
			actualRowsOnPage: 0,
			logicalRecordNumberFirstRecordOnPage: 0,
			_gridRowState: 'view',
			_detailViewState: 'view',
			fieldErrors: {
				type: '',
				className: '',
				inputClassName: '',
				icon: '',
				global: {
					contId: '',
					hoverClassName: '',
					hoverInputClassName: ''
				}
			},
			rowErrors: {
				showMessageBox: false,
				messageBoxTitle: 'Errors',
				style: 'width: 6in; height: 2in; color:red;'
			},
			detailViewDataPreFetch: false,
			detailViewRefreshOnDirty: false,
			detailViewScrollIntoView: false,
			detailViewAnimation: {show: {type: '', duration: 1000}, hide: {type: '', duration: 1000} },
			_readOnly: false,
			_embeddedMode: false,
			_batchChange: false,
			hasEditRowMenu: false,
			_editPermissions: {
				allowDelete: true,
				allowInsert: true,
				allowUpdate: true
			},
			onColumnSort: 0,
			onDetailViewNewRecord: 0
		},true);
		$u.o.assign(this,settings,true);

		this._gridRowWatches = new Object();
		this._detailViewWatches = new Object();
		this._gridWatches = new Object();
		this._searchWatches = new Object();
		this._searchValues = new Object();
		this.stateInfo = {};
		this._currentSubmitTimeStamp = false;
		this._submitTestInterval = 5000;
		
		this.fieldErrors.global.contId = this.gridId + '.GLOBALERRORS';
		this._eh = new A5.ErrorHandler(this.fieldErrors);
		this._reh = new A5.ErrorHandler({
			type: 'tip',
			className: 'errorTip',
			inputClassName: ''
		});
		this._gridColNames = new Array();
		for(var i = 0; i < this.gridColumnInfo.length; i++) {
			this._gridColNames.push(this.gridColumnInfo[i].name);
		}
		this._detailViewColNames = new Array();
		for(var i = 0; i < this.detailViewColumnInfo.length; i++) {
			this._detailViewColNames.push(this.detailViewColumnInfo[i].name);
		}
		
		
		this._searchColNames = new Array();
		if(this.searchColumnInfo) {
			for(var i = 0; i < this.searchColumnInfo.length; i++) {
				this._searchColNames.push(this.searchColumnInfo[i].name);
			}
		}		
		
		if(this.hasEditRowMenu) {
			this._rowMenuRow = 0;
			this._rowMenuTO = 0;
			this._rowMenuId = this.gridId + '.EDITROWMENU';
			$e.add(this._rowMenuId,'mouseover',this._rowMenuStopHide,this,true);
			$e.add(this._rowMenuId,'mouseout',this._rowMenuMOut,this);
		}
		
		if(this.rowOnDblClick.constructor != Function && typeof this.rowOnDblClick != 'string' ) {
			this.rowOnDblClick = '';
		}
		
		var ele = $(this.gridId+'.GRID_PART.FORM_CONTAINER_DIV');
		
		var HTMLFocusCatcher = document.createElement('input');
		HTMLFocusCatcher.id = this.gridId+'.FOCUSCATCHER';
		HTMLFocusCatcher.readonly = true;
		HTMLFocusCatcher.style.position = 'absolute';
		//HTMLFocusCatcher.style.top = $gpt(ele)+'px';
		HTMLFocusCatcher.style.left = '-5000px';
		HTMLFocusCatcher.style.height = '1px';
		HTMLFocusCatcher.style.width = '1px';
		HTMLFocusCatcher.style.fontSize = '0px';
		
		
		$e.add(HTMLFocusCatcher,'focus',this._setControlFocus,this);
		$e.add(HTMLFocusCatcher,'blur',this._setControlBlur,this);
		
		
		ele.parentNode.insertBefore(HTMLFocusCatcher,ele);
		
		this._focusRow = 0;
		this._selectedRow = 0;
		this._focusControl = '';
		this._focusRowTO = 0;
		this._helpTO = 0;
		this._detailViewRow = 0;
		this._detailViewIsDirty = false;
		
		this._cascadingSelectChoices = new Object();
		this._dVImages = new Object();
		
		
		
		this._kw = new AUI.KeyWatcher([
				{key: 'F1', handle: this._keyF1},
				{key: 'up', handle: this._keyPrevRow},
				{key: 'down', handle: this._keyNextRow},
				{key: 'F9', handle: this._keySave},
				{key: 'SHIFT+F9', handle: this._keySaveAll},
				{key: 'ENTER', handle: this._keyEnter},
				{key: 'PAGEUP', handle: this._keyPageUp},
				{key: 'PAGEDOWN', handle: this._keyPageDown},
				{key: 'F2', handle: this._keyOpenLookupWindow},
				{key: 'CTRL+D', handle: this._keyDeleteRecord},
				{key: 'ESCAPE', handle: this._keyEscape}
				
			],this);		
	
		this._dvkw = new AUI.KeyWatcher([
				{key: 'F1', handle: this._dvKeyF1},
				{key: 'F9', handle: this._dvKeySave},
				{key: 'CTRL+F9', handle: this._dvKeySaveAndEnter},
				{key: 'ESCAPE', handle: this._dvKeyEscape},
				{key: 'F2', handle: this._dvKeyOpenLookupWindow},
				{key: 'CTRL+D', handle: this._dvKeyDeleteRecord}
			],this);
	
		this._originalValues = new Array();
		this._originalNullValues = new Array();
		this._originalDVValues = new Array();
		this._originalDVNullValues = new Array();
		this._localDVNullValues = new Array();
		this._checkedRowKeys = new Array();
		this._openLookupWindows = new Array();
		this._openDVLookupWindows = new Array();
		
		this._qbeMenu = {
			c: ['EXACTMATCH','STARTSWITH','ENDSWITH','CONTAINS','GREATERTHAN','GREATERTHANOREQUALTO','LESSTHAN','LESSTHANOREQUALTO','WILDCARD','QBESYNTAX','ISBLANK','ISNULL','ISNOTBLANK','ISNOTNULL'],
			n: ['EXACTMATCH','GREATERTHAN','GREATERTHANOREQUALTO','LESSTHAN','LESSTHANOREQUALTO','QBESYNTAX','ISNULL','ISNOTNULL'],
			l: ['EXACTMATCH','ISNULL','ISNOTNULL'],
			d: ['EXACTMATCH','GREATERTHAN','GREATERTHANOREQUALTO','LESSTHAN','LESSTHANOREQUALTO','QBESYNTAX','ISBLANK','ISNULL','ISNOTBLANK','ISNOTNULL']
		}
		this._qbeMenu.e = this._qbeMenu.n;
		this._qbeMenu.t = this._qbeMenu.d;
		this._qbeMenu.y = this._qbeMenu.t;
		
		this._dvFloatingWindow = 0;
		this._floatingLookupWindow = {};
		
		this._defaultWindowSettings = new Object();
		this._defaultWindowSettings['dropdown'] = {
			type: 'popup',
			theme: this.styleName,
			title: {html: 'Null',show: false},
			body:  {content: {type: 'blank'}}
		};		
		
		this._genericWindow = new Object();
		
		var closeButton = {action: 'close',name: 'Close',image: 'images/$$window.button.close.png.a5image'};
		if(typeof A5.themes != 'undefined') {
			if(typeof A5.themes._t[this.styleName] != 'undefined') closeButton = A5.themes._t[this.styleName].window.base._defaultTools.close;
		}
		
		this._defaultWindowSettings['modal'] = {
			type: 'modal', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Customer Grid', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		this._defaultWindowSettings['modeless'] = {
			type: 'modeless', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Customer Grid', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		this._dirtyRows =  new Array();
		this._dirtyNewRows =  new Array();
		this._editModeRows =  new Array();
		this._isDirty = false;		
		
		this._fieldHelpers_S = new Object();
		this._fieldHelpers_G = new Object();
		this._fieldHelpers_DV = new Object();
		
		this._detailViewWindowState = '';
		
		this._refreshLinkedContentTO = 0;
		this._keyPageNavigateTO = 0;
		
		
		this._gridFilter = '';
		this._gridOrder = '';
		this._gridArguments = '';
		this._gridDBType = '';
		
		this._vars = {SESSION : {}, PAGEVARIABLE : {}};
		this._hiddenCols = new Array();
	
	},

	_destroy: function() {
		var ele = 0;
		for(var winName in this._genericWindow){
			ele = $(this._genericWindow[winName].getWindowId('body'));
			if(ele.tagName.toLowerCase() == 'div') ele.innerHTML = '';
		}
	},
	
	_executeEvent: function(eventName) {
		var result = true;
		var targs = new Array();
		for(var i = 1; i < arguments.length; i++) targs.push(arguments[i]);
		var tresult = false;
		if(typeof this[eventName] != 'undefined'  ) {

			if(this[eventName].constructor == Function) {
				tresult = this[eventName].apply(this,targs);
				if(typeof tresult == 'boolean') result = tresult;
			}
		}
		if(typeof this['_' +eventName] != 'undefined' ) {
			if(this['_'+eventName].constructor == Function) {
				tresult = this['_'+eventName].apply(this,targs);
				if(typeof tresult == 'boolean') result = result && tresult;
			}
			
		}
		//if(eventName == 'onRowSelect' || eventName == 'onRowStateChange' || eventName == 'onDetailViewStateChange') this._fireWatches('all');
		if(eventName == 'onRowSelect' || eventName == 'onRowStateChange' ) this._fireWatches('G',targs[0].rowNumber);
		if(eventName == 'onDetailViewStateChange' || eventName == 'afterDetailViewCancelEdits') this._fireWatches('D',1);
		if(eventName == 'afterDetailViewSubmit' || eventName == 'afterGridSubmit' || eventName == 'afterRowSubmit') this._currentSubmitTimeStamp = false;
		
		return result;
	},

	_getCurrentKey: function(rowNum) {
		if(typeof this._keys == 'undefined') {
			alert('Primary key for Grid was not defined.');
			return '';
		}
		return this._keys[rowNum-1].join('|||');
	},
	
	_setRowKeys: function(keys) {
		this._keys = keys;
	},
	
	_rowMenuMOver: function(e, classInst) {
		classInst._rowMenuStopHide();
		classInst._rowMenuRow = Number(this.id.split('.')[1].substr(1));
		var mEle = $(classInst._rowMenuId);
		$po(mEle,this,'dropdown');
		mEle.style.display = 'block';
	},
	
	_rowMenuMOut: function(e, classInst) {
		classInst._rowMenuTO = setTimeout(function(){classInst._rowMenuHide();},200)
	},
	
	_rowMenuHide: function() {
		$(this._rowMenuId).style.display = 'none';
	},
	
	_rowMenuStopHide: function() {
		clearTimeout(this._rowMenuTO);	
	},
	

	_setStateInfo: function(property,value) {
		var stateInfoID = this.gridId + '.STATEINFO';
		var stateInfo = $gvs(stateInfoID);
		var property2 = property + '=';
		var propertyLen = property2.length ;
		if(stateInfo.indexOf('&' + property2) != -1) {
			stateInfo = stateInfo.split('&');
			for(var i = stateInfo.length -1; i >= 0; i--) {
				if(stateInfo[i].substr(0,propertyLen) == property2) {
					stateInfo[i] = A5.ajax.buildURLParam(property,value);
					$svs(stateInfoID,stateInfo.join('&'));
					return true;
				}
			}
		} else {
			stateInfo = stateInfo + '&' + A5.ajax.buildURLParam(property,value);
			$svs(stateInfoID,stateInfo);
		}
	},
	
	
	setErrors: function(errors) {
		for(var i = 0; i < errors.length; i++) {
			var colName = '';
			var part = '';
			var rowNum = '';
			if(errors[i].id.split('.').length == 5) {
				colName = errors[i].id.split('.')[4];
				part = errors[i].id.split('.')[1];
				rowNum = errors[i].id.split('.')[3].replace('R','');
			} else if(errors[i].id.split('.').length == 4) {
				colName = errors[i].id.split('.')[3];
				part = 'G';
				rowNum = errors[i].id.split('.')[2].replace('R','');
			}
			this.activateControlContainer(colName,part,rowNum);
			this._eh.set(errors[i].id,errors[i].message);
		}
	},
	
	_dynamicMask: function(fnName) {
		if(window[this.format.maskFunctionName]) 
		{
			var id = this._editTargetId;
			id = id.split('.');
			id = id[1];
			var classInst = window[this.format.maskComponentObject];
			var e = {};
			e.rowNumber = classInst._selectedRow;
			if(id == 'S' || id == 'D') e.part = id;
			else e.part = 'G';
			return window[this.format.maskFunctionName].call(classInst,e);		
		}
		return '';
	},
	

	_getGridVariables: function(grid,detailView) {
		var data = typeof arguments[2] != 'undefined' ? arguments[2]: { };
		if(typeof data.rowNumber != 'undefined') var rowNumber = data.rowNumber;
		else var rowNumber = this._selectedRow;
		
		grid.recordsInGrid = 0;
		if(typeof this._rowsInGrid != 'undefined') grid.recordsInGrid = this._rowsInGrid;
		grid.rowState = this._gridRowState;
		grid.pageNumber = this.pageNumber;
		grid.pagesInGrid = this.pagesInGrid;
		if(rowNumber > 0) {
			grid.logicalRecordNumber = ((grid.pageNumber - 1) * this.rowsPerPage) + rowNumber;
		} else {
			grid.logicalRecordNumber = 0 
		}
		grid.isNewRecordRow = $if(rowNumber > 0, false, true);
		grid.hasDetailView = $if(this._detailViewColNames.length > 0, true,false);
		
		if(grid.hasDetailView==false) {
			grid.isDirty = this._isDirty;
			if(rowNumber > 0) {
				grid.isRowDirty = this._dirtyRows[rowNumber -1];
			} else {
				grid.isRowDirty = this._dirtyNewRows[(rowNumber* -1) -1];
			}
		} else {
			grid.isDirty = false;
			grid.isRowDirty = false;
		}
		
		grid.isOnFirstPage = $if(grid.pageNumber == 1,true,false);
		grid.isOnLastPage = $if(grid.pageNumber == grid.pagesInGrid, true, false);
		grid.hasNextPage = $if(grid.pageNumber < grid.pagesInGrid, true,false);
		grid.hasPrevPage = $if(grid.pageNumber > 1, true,false);
		if(grid.hasDetailView == false) {
			detailView.rowState = '';
			detailView.isOnFirstRecord = false;
			detailView.isOnLastRecord = false;
			detailView.hasNextRecord = false;
			detailView.hasNextRecord = false;
			detailView.isDirty = false;
		} else {
			detailView.rowState = this._detailViewState;
			detailView.isOnFirstRecord = $if(rowNumber == 1 && grid.pageNumber == 1,true,false);
			detailView.isOnLastRecord = $if( (rowNumber == this._rowsInGrid) && (grid.pageNumber == grid.pagesInGrid) , true, false);
			detailView.hasNextRecord =$if( (grid.pageNumber < grid.pagesInGrid) || (rowNumber <  this._rowsInGrid), true, false);
			detailView.hasPrevRecord = $if(grid.pageNumber == 1 && rowNumber == 1, false, true);
			detailView.isDirty = $if(this._detailViewIsDirty,true,false);
		}

		if( this.checkBoxSelector == 'singlePage') {
		    var count = 0;
		    var ele = '';
		    var txt = ''
		    for(var i = 1; i <= this._rowsInGrid; i++) {
		        ele = $(this.gridId + '.V.R' + i + '.__ROWCHECKBOX');
		        txt = $gvs(ele);
		        if( $gvs(ele) != '') count = count + 1;
		    }
		} else {
		    var count = this._checkedRowKeys.length
		}
		grid.checkedRowCount = count
		var eleCR = $(this.gridId + '.V.R' + rowNumber + '.__ROWCHECKBOX');
		grid.rowIsChecked = false;
		if($gvs(eleCR) != '') grid.rowIsChecked = true;
		
	},



	clearErrors: function() {
		
		if(typeof arguments[0] != 'undefined') {
			var errorsToClear = new Array();
			for(var i = 0; i < arguments[0].length; i++) {
				if(typeof arguments[0][i] == 'number') {
					for(var j = 0; j < this._eh._e.length; j++) {
						if(this._eh._e[j].id.indexOf('.R'+arguments[0][i]+'.') > -1) {
							errorsToClear.push(this._eh._e[j].id);
						}
					}
				} else {
					errorsToClear.push(arguments[0][i]);
				}
				
			}
			
			this._eh.clear(errorsToClear);
		} else {
			this._eh.clear();
		}
		
		this.clearDetailViewGlobalError();
		
	},

	_confirmAction: function() {
	
		if(this._readOnly) return true;
		var silentFlag = typeof arguments[0] != 'undefined' ? arguments[0] : false;
		if(this._isDirty) {
			if(!silentFlag) A5.msgBox.show(this.messages.t_dirtyRecordWarning,this.messages.dirtyRecordWarning,'O',function() {} );
			return false;
		} else if(this._detailViewIsDirty) {
			if(!silentFlag) A5.msgBox.show(this.messages.t_dirtyRecordWarning,this.messages.dirtyRecordWarning,'O',function() {} );
			return false;
		}
		return true;
	},

	setRowErrors: function(errors) {
		//when entire grid is editable, set the error state for a particular row in the grid.
		//shows the ErrorColumn and shows the error icon in this column.
		
		var errorMessages = new Array();
		
		
		
		this._showGridErrorColumn(true);
		for(var i = 0; i < errors.length; i++) {
			$acn(this.gridId +'.TD.R'+errors[i].row+'.__SYSTEM_ERRORCOLUMN','A5GridHasRowError');
			errors[i].id = this.gridId +'.R'+errors[i].row+'.__SYSTEM_ROWERROR';
			this._reh.set(errors[i].id,errors[i].message);
			errorMessages.push(errors[i].message);
		}
		
		if(this.rowErrors.showMessageBox == true) {
			var msgTxt = errorMessages.join('\n');
			msgTxt = '<div style="' + this.rowErrors.style + '">' + msgTxt + '</div>';
			A5.msgBox.show(this.rowErrors.messageBoxTitle,msgTxt,'O');
		}
		
		
	},
	
	_setCountInfo: function(a) {
			//js_pageNumber
			//js_pagesInGrid
			//js_rowsPerPage
			//js_actualRowsOnPage
			//js_LogicalRecordNumberFirstRecordOnPage
			this.pageNumber = a[0];
			this.pagesInGrid = a[1];
			this.rowsPerPage = a[2];
			this.actualRowsOnPage = a[3];
			this.logicalRecordNumberFirstRecordOnPage = a[4];
	},


	_columnTitlesShowHide: function(mode) {
		var eleT = $(this.gridId + '.COLUMNTITLES.TOP');
		var eleB = $(this.gridId + '.COLUMNTITLES.BOTTOM');
		if(eleT) eleT.style.display = mode;
		if(eleB) eleB.style.display = mode;
	},
	
	columnTitlesRefresh: function() {
		if(this._rowsInGrid == 0 && this.suppressTitlesIfNoRecords == true ) this._columnTitlesShowHide('none');
		else this._columnTitlesShowHide('');
	},
	


	clearRowErrors: function() {
		var rowsToClear = new Array();
		if(typeof arguments[0] != 'undefined') {
			for(var i = 0; i < arguments[0].length; i++) {
				$rcn(this.gridId +'.TD.R'+arguments[0][i]+'.__SYSTEM_ERRORCOLUMN','A5GridHasRowError');
				rowsToClear.push(this.gridId +'.R'+arguments[0][i]+'.__SYSTEM_ROWERROR');
			}
			this._reh.clear(rowsToClear);
			
			if(this._reh._e.length == 0) this._showGridErrorColumn(false);
			
		} else {
			for(var i = 0; i <= this._rowsInGrid ; i++) {
				$rcn(this.gridId +'.TD.R'+(i+1)+'.__SYSTEM_ERRORCOLUMN','A5GridHasRowError');
				rowsToClear.push(this.gridId +'.R'+(i+1)+'.__SYSTEM_ROWERROR');
			}
			this._reh.clear();
			this._showGridErrorColumn(false);
		}
	},

	refreshExternalTreeNavigator: function() {
		A5.ajax.callback(this.ajaxURL,'__FormID='+this.gridId+'&__FormAction=GenerateTreeBranches&__treeType=externalnavigator&__treeName=TREENAVIGATOR&__treeObject='+this.gridId+'_EXTERNALNAVIGATOR_TREENAVIGATOR&'+$gvs(this.gridId + '.STATEINFO'));
	},

	refreshRow: function(rowNum) {
		if(typeof arguments[0] == 'undefined') rowNum = this._selectedRow;
	
		if(typeof this._keys == 'undefined') {
			alert('Row can not be refreshed because it does not have a Primary Key'); 
			return false;
		}
	
		//don't refresh rows that are already dirty
		if(this._dirtyRows[rowNum-1]) return false;
		var methodType = 'gridEvent';
		if(typeof arguments[1] != 'undefined') {
			if(arguments[1] == true) methodType = 'controlDirty';
		}	
		
		var pkdata = this._getRowKey(rowNum);
		var regionId = this.gridId  + '.R' + rowNum;
		data = this._harvestGrid(regionId);
		if(data != '') data = '&' + data;
		if(pkdata != '') data = data + '&' + pkdata;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'refreshRow'})
		this._submitLow('refreshRow',this.gridId,this.ajaxURL,'__row=' + rowNum + '&__methodType=' + methodType + data);
	
	},
	

	sort: function(column){
		
		if(!this._executeEvent('canSort',{sortColumn: column})) return false;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'sort'})
		if(!this._confirmAction()) return false;
		var sDir = typeof arguments[1] != 'undefined' ? arguments[1] : '';
		column = '' + column;
		var x = column.split(':');
		if(typeof x[1] != 'undefined') {
			column = 'expression:' + urlencode(x[1]);
		}
		if(sDir.toLowerCase() == 'a'){
			this._submitLow('sortA',this.gridId,this.ajaxURL,'__sortcolumn=' + column +  '&__dvWindow=' + this._detailViewWindowState);
		} else if(sDir.toLowerCase() == 'd'){
			this._submitLow('sortD',this.gridId,this.ajaxURL,'__sortcolumn=' + column + '&__dvWindow=' + this._detailViewWindowState);
		} else {
			this._submitLow('sort',this.gridId,this.ajaxURL,'__sortcolumn=' + column+ '&__dvWindow=' + this._detailViewWindowState);
		}
		this.clearDetailViewGlobalError();
		return false;
	},
	
	pageNavigate: function(target) {
		if(!this._executeEvent('canPageNavigate',{target: target})) return false;
		var part = typeof arguments[1] != 'undefined' ? arguments[1] : 'G';
		var additionalData = typeof arguments[2] != 'undefined' ? arguments[2] : '';
		if(!this._confirmAction()) return false;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'PageNavigate'})
		this._submitLow('PageNavigate',this.gridId,this.ajaxURL,'__targetPage=' + target +'&__part=' + part + '&__dvWindow=' + this._detailViewWindowState +'&' + additionalData); 
		this.clearDetailViewGlobalError();
		return false;
	},
	
	groupBreakShowHide: function(groupLevel,id,mode) {
		if(id.replace(/\s/g,'') == '') id = 'NULLVALUE';
		var gobj = this._rowsInGroupHeader1[id];
		var rEle = '';
		var mode2 = '';
		
		if(mode == 'hide') mode2 = 'none';
		if(mode == 'show') mode2 = '';
		if(mode == 'toggle') {
			rEle = $(this.gridId + '.R' + gobj[0]);
			if(rEle) mode = rEle.style.display;
			if(mode == '') mode2 = 'none';
			else mode2 = '';
		
		}
		var isDeleted = '';
		var eleCloseIcon = $(this.gridId + '.GHCLOSE.' + gobj[0]);
		var eleOpenIcon = $(this.gridId + '.GHOPEN.' + gobj[0]);
		if(mode2 == 'none') {
			if(eleCloseIcon) eleCloseIcon.style.display = 'none';
			if(eleOpenIcon) eleOpenIcon.style.display = '';
		} else {
			if(eleCloseIcon) eleCloseIcon.style.display = '';
			if(eleOpenIcon) eleOpenIcon.style.display = 'none';
		
		}
		for(var rowNum in gobj){
			rEle = $(this.gridId + '.R' + gobj[rowNum]);
			if(rEle) {
				isDeleted = $u.s.toBool(''+$ga(rEle,'a5deletedrow'));
				if(!isDeleted ) rEle.style.display = mode2;
			}
		}
		if(typeof this._groupBreakState == 'undefined') this._groupBreakState = {};
		this._groupBreakState[id] = mode2;
	},
	
	_applyGroupBreakState: function() {
		var gobj = this._rowsInGroupHeader1;
		if(typeof this._groupBreakState == 'undefined') return false;
		var sobj = this._groupBreakState;
		var mode = '';
		for(var id in gobj) {
			mode = sobj[id];
			if(typeof mode != 'undefined') {
				if(mode == 'none') mode = 'hide';
				if(mode == '') mode = 'show';
				this.groupBreakShowHide(1,id,mode);
			}
		}
	
	},
	
	collapseAllRows: function() {
		var rEle = '';
		for(var i = 1; i <= this._rowsInGrid; i++) {
			rEle = $(this.gridId + '.R' + i);
			if(rEle) rEle.style.display = 'none';
			
			var eleCloseIcon = $(this.gridId + '.GHCLOSE.' + i);
			var eleOpenIcon = $(this.gridId + '.GHOPEN.' + i);
			if(eleCloseIcon) eleCloseIcon.style.display = 'none';
			if(eleOpenIcon) eleOpenIcon.style.display = '';
			
			
			
			}
	},
	
	refresh: function() {
			var refreshChoices = typeof arguments[0] != 'undefined' ? arguments[0] : false;
			if(!this._confirmAction()) return false;
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'refresh'})
			this._submitLow('PageNavigate',this.gridId,this.ajaxURL,'__targetPage=' + 'same' +'&__part=G&__refreshChoices=' + refreshChoices ); 
			this.clearDetailViewGlobalError();
			return false;
	},
	
	getParentObject: function() {
		if(this.parentAlias !='') return window[this.parentGridAlias+'_GridObj'];
		else return false;
	},
	
	
	setFocus: function(rowNum) {
		
		//if(!$(this.gridId+'.R'+(this._focusRow))) return false;
		if(!$(this.gridId+'.R'+(rowNum))) return false;
		
		if(this._focusRow != 0) {
			this._executeEvent('onRowBlur', {rowNumber: this._focusRow});
		}
		
		this._focusRow = rowNum;
		if(!this._editModeRows[this._focusRow-1]){
			this._focusRowClick.call($(this.gridId+'.R'+(this._focusRow)),null,this);
			$f(this.gridId+'.FOCUSCATCHER');
		} else {
			if(this._focusControl == '') {
				//this._focusControl = this._gridColNames[0];
				for(i=0;i<this.gridColumnInfo.length;i++) {
					if(this.gridColumnInfo[i].type.split(',')[0] != 'label' && this.gridColumnInfo[i].type.split(',')[0] != 'label-html') {
						this._focusControl = this.gridColumnInfo[i].name;
						break;						
					}
				}
			}
			
			if(this._focusControl != '') {
				//IE complains if you give focus to a disabled control
				var ele = $(this.gridId+'.V.R'+(this._focusRow)+'.'+this._focusControl);
				if(ele.disabled != true) {
					$f(this.gridId+'.V.R'+(this._focusRow)+'.'+this._focusControl);
				}
			}
		}
	},
	
	setSelectedRow: function(rowNum) {
		if(typeof jQuery != 'undefined') jQuery.noConflict();
		//alert('begin - ' + rowNum);
		if(typeof arguments[1] == 'boolean' && this._selectedRow != rowNum) var flagResynchLinkedContent = arguments[1];
		else var flagResynchLinkedContent = false;
		if(this._selectedRow != 0 && this._selectedRow <= this._rowsInGrid) {
			//$rcn(this.gridId+'.R'+this._selectedRow,this.rowSelectedClassName);
			if(this.rowSelectedClassName != '') this._removeRowClassName($(this.gridId+'.R'+this._selectedRow),this.rowSelectedClassName);
			if(this.hasRowSelectorIcon) {
				if(this._selectedRow < 0) {
					if(this.newRowSelectorIconOff != '') $(this.gridId + '.R' + this._selectedRow + '.__ROWSELECTOR').src = this.newRowSelectorIconOff;
					else $(this.gridId + '.R' + this._selectedRow + '.__ROWSELECTOR').style.visibility = 'hidden';

				} else {
					if(this.rowSelectorIconOff != '') $(this.gridId + '.R' + this._selectedRow + '.__ROWSELECTOR').src = this.rowSelectorIconOff;
					else $(this.gridId + '.R' + this._selectedRow + '.__ROWSELECTOR').style.visibility = 'hidden';
				}
			}
		}
		this._selectedRow = rowNum;
		if(this._selectedRow != 0 && this._selectedRow <= this._rowsInGrid) {
			//$acn(this.gridId+'.R'+rowNum,this.rowSelectedClassName);
			if(this.rowSelectedClassName != '') this._addRowClassName($(this.gridId+'.R'+rowNum),this.rowSelectedClassName);
			if(this.hasRowSelectorIcon) {
				var ele = $(this.gridId + '.R' + rowNum + '.__ROWSELECTOR');
				
				if(rowNum < 0) {
					ele.src = this.newRowSelectorIconOn;
					if(this.newRowSelectorIconOff == '') {
						ele.style.visibility = '';	
					}
				} else {
					ele.src = this.rowSelectorIconOn;
					if(this.rowSelectorIconOff == '') {
						ele.style.visibility = '';	
					}
				}
			}
		} else if(this._selectedRow > this._rowsInGrid)  {
			this._selectedRow = 0;
		}
		if(flagResynchLinkedContent) this._internalRefreshLinkedContent();
		//alert('xx ---- yyyyy' +rowNum);
		
		this._executeEvent('onRowSelect', {rowNumber: this._selectedRow});
		
	},
	
	_addRowClassName: function(ele,rowClassName) {
		for(var i = 0; i < ele.childNodes.length; i++) {
			if(ele.childNodes[i].tagName) {
				if(ele.childNodes[i].id != ele.id + '.__ROWEXPAND_TR') $acn(ele.childNodes[i],rowClassName);
			} 
		}
	},
	
	_removeRowClassName: function(ele,rowClassName) {
		for(var i = 0; i < ele.childNodes.length; i++) {
			if(ele.childNodes[i].tagName) $rcn(ele.childNodes[i],rowClassName);
		}
	},
	
	_selectAllRowCheckboxes: function(cvalue) {
		for(i=1;i<=this._rowsInGrid;i++) {
			$svs(this.gridId + '.V.R' + i + '.__ROWCHECKBOX',cvalue);
			this._setCheckedRow(i,cvalue);
		}
		this._fireWatches('all')		
	},
	
	saveSearchCriteria: function(name) {
		if(name=='') {
			alert('Name not specified.'); 
			return false;
		}
		this.submitSearchForm(false,name);
	},
	
	_executeLoadSavedSearch: function(eleName,flagExecute) {
		var ele = $(eleName);
		var nameSearch = $gvs(ele); 
		this.loadSavedSearch(nameSearch,flagExecute);  
		var cwin = A5.windows.getFromElement(ele);
		cwin.hide();
	},
	
	_executeSaveSavedSearch: function(eleName) {
	
		var ele = $(eleName);
		var nameSearch = $gvs(ele); 
		eleError = $(this.gridId + '.SAVESEARCHERROR');		
		if(nameSearch == '') {
			if(eleError) {
				eleError.style.display = '';
				eleError.innerHTML = this._saveSavedSearchDialog.warningBlankName;
				return false;
			}
		} else {
			eleError.style.display = 'none';
			this.saveSearchCriteria(nameSearch);
		}
	},
	
	loadSavedSearch: function(name,flagExecuteSearch) {
		if(typeof flagExecuteSearch == 'undefined') flagExecuteSearch = false;
		var data='_searchName=' + name + '&_execute=' + flagExecuteSearch;
		this.ajaxCallback('G','none','__a5systemLoadSavedSearch','',data);
	},
	
	loadSearchUI: function(ele) {
		var obj = {};
		obj = this._loadSavedSearchDialog;
		this._promptRepository(ele,obj);
	},
	
	saveSearchUI: function(ele) {
		var obj = {};
		obj = this._saveSavedSearchDialog;
		this._promptRepository(ele,obj);
	},
	
	
	_getRepositoryChoices: function(listBoxId,id,dataType,otherData) {
		var data = '_listBoxId=' + listBoxId + '&_idToPopulate=' + id + '&_repositoryDataType='+dataType;
		if(otherData!='') data = data + '&' + otherData;
		
		this.ajaxCallback('G','none','__a5LoadFromRepository','',data);
	},
	
	_promptRepository: function(objEle,obj) {
		var windowName = obj.windowName;
		var currWindow = this.getWindow(windowName);
		var windowDefObj = 	{
			type: 'modeless',
			body: {	content: {type: 'blank',elementId: '~'}},
			height: obj.windowHeight,
			width: obj.windowWidth,
			title: {html: 'Window',	location: 'top'},
			disableMove: true,
			animation: obj.windowAnimation,
			buttons: obj.windowButtons
			}
		if(!currWindow) {
			currWindow = this.createWindow(windowName,'dropdown',windowDefObj);		
		}	
		var windowDiv = currWindow.getWindowId('body');
		$(windowDiv).innerHTML = obj.windowHTML;
		currWindow.show('dropdown',objEle);
		if(obj.javascript) {
			eval(obj.javascript);
		}
	},

	
	submitSearchForm: function() {
		var flagRunSearch = typeof arguments[0] != 'undefined' ? arguments[0] : true;
		var savedSearchName = typeof arguments[1] != 'undefined' ? arguments[1] : '';
		
		if(flagRunSearch) {
			if(!this._executeEvent('canSearchSubmit',{})) return false;
			if(!this._confirmAction()) return false;
		}
		
		if(flagRunSearch) {
			if(this.onlyShowDetailViewOnRequest && this.detailViewPosition == 'page' && this.hideGridWhenDetailViewIsShown) {
				//this solves problem: DV set to hide Grid when DV is open. DV set to show new record when no records in query. When user clears search, Grid, not DV should be shown
				this._detailViewWindowState = 'closed';
			}		
		}
		
		var mapData = this.getMapDataFromSearchPart();
		
		var stateInfoID = this.gridId + '.STATEINFO';
		if(flagRunSearch) {
			var data = '_submitActionType=SubmitSearchForm';
		} else {
			var data = '_submitActionType=SaveSearchForm&_searchName='+savedSearchName;
		}
		data = data +   '&__dvWindow=' + this._detailViewWindowState;
		data = data +  mapData;
		if(flagRunSearch) {
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'submitSearchForm'})
		}
		this._submitLow('submit:new',this.gridId +'.SEARCH_PART.FORM',this.ajaxURL,data,true,stateInfoID,'__sf');
		return false;
	},
	
	getMapDataFromSearchPart: function() {

		var maps = '';
		var mapDataI = '';
		var mapData = '';
		if(this._searchPartMaps) maps = this._searchPartMaps;
		if(maps != '') {
			for(i=0;i<maps.length;i++) {
				var field = maps[i];
				var mapDataI = this['googleMap_SEARCH_' + field].computePostValues();
				mapDataI = mapDataI.split('&');
				var delim = 'GM_' + field;
				
				mapDataI = delim + '.' + mapDataI.join('&' +delim + '.');
				mapDataI = '&' + mapDataI;
				//mapDataI = mapDataI + '&' + delim + '._bounds=' + this['googleMap_SEARCH_' + field].map.getBounds();
				var mapObj = this['googleMap_SEARCH_' + field].map;
				var LatLngBounds=mapObj.getBounds();
				var NE= LatLngBounds.getNorthEast();
				var SW= LatLngBounds.getSouthWest();
				var NElat=NE.lat();
				var NElng=NE.lng();
				var SWlat=SW.lat();
				var SWlng=SW.lng();
				var mapData2 = '&' + delim+'._NElat=' + NElat + '&' + delim + '._NElng=' + NElng + '&' + delim + '._SWlat=' + SWlat + '&' + delim + '._SWlng=' + SWlng;
				mapData2 = mapData2 +'&' + delim + '._zoom=' + mapObj.getZoom();
				mapData = mapData + mapDataI + mapData2;
			}
		}
	
	
		return mapData;
	
	},
	
	clearAllSearchPartMaps: function() {
		var maps = '';
		if(this._searchPartMaps) maps = this._searchPartMaps;
		if(maps == '') return false;
		for(i=0;i<maps.length;i++) {
			var field = maps[i];
			var mapDataI = this['googleMap_SEARCH_' + field].deleteOverlays();
		}
	},
	

	initializeAllSearchPartMaps: function() {
	var maps = '';
	if(this._searchPartMaps) maps = this._searchPartMaps;
		if(maps == '') return false;
		for(i=0;i<maps.length;i++) {
			var field = maps[i];
			var mapDataI = this['googleMap_SEARCH_' + field].initializeGoogleMap();
		}
	},
	
	
	clearSearchForm: function() {
		if(!this._executeEvent('canSearchClear',{})) return false;
		if(!this._confirmAction()) return false;
		
		if(this.onlyShowDetailViewOnRequest && this.detailViewPosition == 'page' && this.hideGridWhenDetailViewIsShown) {
			//this solves problem: DV set to hide Grid when DV is open. DV set to show new record when no records in query. When user clears search, Grid, not DV should be shown
			this._detailViewWindowState = 'closed';
		}		
		
		this._resetSearchForm();
		this.clearAllSearchPartMaps();
		//if map is set to radius, replaces the center marker.
		this.initializeAllSearchPartMaps();
		this._searchValues = new Object();
		var stateInfoID = this.gridId + '.STATEINFO';
		var data = '__clearSearch=yes&_submitActionType=ClearSearchForm'  + '&__dvWindow=' + this._detailViewWindowState;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'clearSearchForm'})
		this._submitLow('submit:new',this.gridId +'.SEARCH_PART.FORM',this.ajaxURL,data,true,stateInfoID,'__sf');
		return false;
		
	},
	


	_resetSearchForm: function() {
		var ele = 0;
		var val = '';
		
		if(this.searchPartIsKeyword) {
			$svs(this.gridId + '_KEYWORDSEARCH','');
		} else {
			for(var i=0; i < this.searchColumnInfo.length; i++) {
				if(this.searchColumnInfo[i].isRange) {
					ele = $n( 'S.FROM.' + this.searchColumnInfo[i].name);		
					ele = $cetp(ele,$(this.gridId+'.SEARCH_PART.FORM'));
					if(ele) {
						if(!ele.tagName) val = $ga(ele[0],'A5OriginalValue').split('||A5ARRAYSEP||');
						else val = $ga(ele,'A5OriginalValue').split('||A5ARRAYSEP||');
						if(val.length == 1) val = val[0];
						if(typeof this._fieldHelpers_S[this.searchColumnInfo[i].name] == 'object') {
							this._fieldHelpers_S[this.searchColumnInfo[i].name].setValue(val,ele[0]);
						} else {
							$svs(ele,val);
						}

						ele = $n( 'S._TO.' + this.searchColumnInfo[i].name);		
						ele = $cetp(ele,$(this.gridId+'.SEARCH_PART.FORM'));
						if(!ele.tagName) val = $ga(ele[0],'A5OriginalValue').split('||A5ARRAYSEP||');
						else val = $ga(ele,'A5OriginalValue').split('||A5ARRAYSEP||');
						if(val.length == 1) val = val[0];
						if(typeof this._fieldHelpers_S[this.searchColumnInfo[i].name] == 'object') {
							this._fieldHelpers_S[this.searchColumnInfo[i].name].setValue(val,ele[0]);
						} else {
							$svs(ele,val);
						}
					}


				
				} else {
					ele = $n( 'S.' + this.searchColumnInfo[i].name);		
					ele = $cetp(ele,$(this.gridId+'.SEARCH_PART.FORM'));
					if(ele) {
						val = $ga(ele[0],'A5OriginalValue').split('||A5ARRAYSEP||');
						if(val.length == 1) val = val[0];
						if(typeof this._fieldHelpers_S[this.searchColumnInfo[i].name] == 'object') {
							this._fieldHelpers_S[this.searchColumnInfo[i].name].setValue(val,ele[0]);
						} else {
							$svs(ele,val);
						}
					}
				}
			}
		}
	},

	showAlternateView: function(targetId) {
		var index = -1;
		var prop = 'id';
		var searchVal = targetId;
		for(var i = 0; i < this._altViews.length; i++) { 
			if(this._altViews[i][prop] == searchVal) {
			  index = i;
			  break;
			}
		}
		if(index == -1) return false;
		var idToShow = this._altViews[i].id;
		var eventName = this._altViews[i].onActivate;
		if(typeof eventName == 'function') {
			eventName();
		} else if(eventName != '') window[eventName].call(this);
		
		for(var i = 0; i < this._altViews.length; i++) { 
			var ele = $(this.gridId + '.ALTVIEW.' +this._altViews[i].id);
			if(ele) ele.style.display = 'none';
		}
		ele = $(this.gridId + '.ALTVIEW.' + targetId);
		if(ele) ele.style.display = '';
	},
	
	argumentsSubmit: function() {
		var data = '_submitActionType=SubmitArguments';
		var stateInfoID = this.gridId + '.STATEINFO';
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'submitArguments'})
		this._submitLow('submit:all',this.gridId+'.ARGUMENTS',this.ajaxURL,data,true,stateInfoID,'');
		return false;
	
	},
	
	argumentsCancel: function() {
		var data = '_submitActionType=CancelArguments';
		var stateInfoID = this.gridId + '.STATEINFO';
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'cancelArguments'})
		this._submitLow('submit:all',this.gridId+'.ARGUMENTS',this.ajaxURL,data,true,stateInfoID,'');
		return false;
	},
	
	showAll: function() {
		//turns off all filters in the Grid (other than base filters and linking filters)
		if(!this._confirmAction()) return false;
		ele = $(this.gridId +'.SEARCH_PART.FORM')
		if(ele) {
			//ele.reset()
			//A5.form.reset(this.gridId +'.SEARCH_PART.FORM');
			this._resetSearchForm();
		}
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'showAll'})
		this._submitLow('ShowAll',this.gridId,this.ajaxURL,'' ); 
	
	
	},
	
	hideNewRecordRows: function () {
		this._executeEvent('onNewRowsHide',{});
		if(this._dirtyNewRows) {
			if($u.a.find(this._dirtyNewRows,true) != -1) {
				if(!this._confirmAction()) return false;
			}	
		}
		var ele = ''
		for(var i = 0; i < this._newRowsInGrid; i++) {
			ele = this.gridId + '.R-' + (i+1);
			$(ele).style.display = 'none';
		}
	},
	
	showNewRecordRows: function () {
		var countRowsInEditMode = 0;
		for(var i = 1; i <= this._rowsInGrid; i++) {
			if(this._editModeRows[i-1]) countRowsInEditMode++;
		}
		if(this._executeEvent('canNewRowsShow',{rowsInEditMode: countRowsInEditMode}) == false) return false;
		this._executeEvent('onNewRowsShow',{});
		var ele = ''
		for(var i = 0; i < this._newRowsInGrid; i++) {
			ele = this.gridId + '.R-' + (i+1);
			$(ele).style.display = '';
		}
	},

	toggleNewRecordRows: function () {
		var ele =  this.gridId + '.R-1';
		var pEle = $(ele);
		if(pEle.style.display == 'none') {
			this.showNewRecordRows();
		} else {
			this.hideNewRecordRows();
		}
	},

	toggleEmbeddedSearchPartRow: function() {
		if(this.embedSearchPartStyle == 's') {
			var e = $(this.gridId + '.EMBEDDED_FREEFORM_SEARCH');
			if(this.animateSearchPart != '') {
				this._embeddedSearchIsOpen = $if(e.style.display == '',false,true);
				A5.anim.toggle(e,this.animateSearchPart);
			} else {
				if(e.style.display == '') e.style.display = 'none';
				else e.style.display = '';
				this._embeddedSearchIsOpen = $if(e.style.display == '',true,false);
			}
		} else {
			var e = $(this.gridId + '.SEARCH_PART.FORM');
			if(e.style.display == '') {
				e.style.display = 'none';
			} else {
				e.style.display = '';
			}
			this._embeddedSearchIsOpen = $if(e.style.display == '',true,false);
		}
		
	},

	
	
	
	toggleVisibility: function(part) {
		
			part = part.toUpperCase();
			if(part=='SEARCH_PART') {
				var titleH = $(this.gridId + '.SEARCH_PART.TITLE.HIDDEN');
				var titleS = $(this.gridId + '.SEARCH_PART.TITLE.SHOWN');
				var cont = $(this.gridId + '.SEARCH_PART.FORM_CONTAINER_DIV');
				
				var setting = '';
				if(titleH.style.display == 'none') {
					titleH.style.display = '';
					titleS.style.display = 'none';
					if(this.animateSearchPart!='') A5.anim.toggle(cont,this.animateSearchPart,'hide');
					else cont.style.display = 'none';
				} else {
					titleH.style.display = 'none';
					titleS.style.display = '';
					if(this.animateSearchPart!='') A5.anim.toggle(cont,this.animateSearchPart,'show');
					else cont.style.display = '';
					this.initializeAllSearchPartMaps();
					
				}
				
				/*
				if(this.animateSearchPart) {
					if(this.animateSearchPart != '') {
						A5.anim.toggle(cont,this.animateSearchPart);
					} else {
						cont.style.display = setting;
					}
				}
				*/
				
			}
	}, 
	
	quickSearch: function(searchFor) {
	
		/*Executes a quick search*/
		
		if(!this._executeEvent('canQuickSearch',{})) return false;
		
		if(searchFor.constructor == Array) searchFor = searchFor.join('\n');
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'quickSearch'})
		this._submitLow('QuickSearch',this.gridId,this.ajaxURL,'__quickSearch=' + urlencode(searchFor) + '&__dvWindow=' + this._detailViewWindowState ); 
		return false;
	},
	
	
	quickSearchClear: function() {
		this.quickSearch('');
	
	},
	
	
	
	setRowsPerPage: function(rows) {
		if(!this._executeEvent('canSetRowsPerPage',{})) return false;
		if(!this._confirmAction()) return false;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'setRowsPerPage'})
		this._submitLow('SetRowsPerPage',this.gridId,this.ajaxURL,'__rowsPerPage=' + rows); 
		return false;
	},
	
	
	
	gridFilterSet: function(filterExpression, orderExpression, filterParameters)
		{
		/*Set a user filter on the Grid using automation
		Example: to set the filter, but not order .gridFilterSet('city="boston",null,parameters)
		*/
		
		filterExpression = $if(filterExpression==undefined,'Null',filterExpression);
		orderExpression = $if(orderExpression==undefined,'Null',orderExpression);
		filterParameters = $if(filterParameters==undefined,'Null',filterParameters);
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'setGridFilter'})
		this._submitLow('SetGridFilter',this.gridId,this.ajaxURL,'__filterExpression=' + urlencode(filterExpression) +'&__orderExpression='+urlencode(orderExpression) +'&__filterParameters='+urlencode(filterParameters)); 
		return false;
		
	
	},
	
	gridFilterRemove: function()
		{
		/*Remove a previously set user filter on the Grid using automation*/
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'removeGridFilter'})
		this._submitLow('RemoveGridFilter',this.gridId,this.ajaxURL,''); 
				return false;
		
		
	},
	
	gridBaseFilterSet: function(filterExpression, orderExpression, filterParameters)
		{
		/*This replaces the filter that was set in the Query String.
	          User searches are additive to this query. 
	          I.e. this query is like a base query (in addition to the base query defined in the Grid itself)
	          
	          NOT YET IMPLEMENTED - not sure if it is a good idea. maybe should add a 
	          4th parameter that says that the filterExpression is encrypted.
		*/
		
		filterExpression = $if(filterExpression==undefined,'Null',filterExpression);
		orderExpression = $if(orderExpression==undefined,'Null',orderExpression);
		filterParameters = $if(filterParameters==undefined,'Null',filterParameters);
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'setGridBaseFilter'})
		this._submitLow('SetGridBaseFilter',this.gridId,this.ajaxURL,'__filterExpression=' + urlencode(filterExpression) +'&__orderExpression='+urlencode(orderExpression) +'&__filterParameters='+urlencode(filterParameters)); 
				return false;
	
	},
	
	

	gridLink: function(linkDefinition)
			{
			/*Set a Link on the Grid using automation.
			Example: .gridLink('firstname(C:sam),lastname(C:jones)');
			*/
			var data = '';
			data = '__LinkDefinition=' + urlencode(linkDefinition);
			
			var filterExpression = 'Null';
			if(typeof arguments[1] != 'undefined') filterExpression = arguments[1];
			var orderExpression = 'Null';
			if(typeof arguments[2] != 'undefined') orderExpression = arguments[2];
			
			data = data + '&__filterExpression=' + urlencode(filterExpression);
			data = data + '&__orderExpression='+ urlencode(orderExpression);
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'setGridLink'})
			this._submitLow('SetGridLink',this.gridId,this.ajaxURL,data); 
			return false;
			
		
		},
		
	gridUnlink: function()
			{
			
			var data = '';
			var filterExpression = 'Null';
			if(typeof arguments[0] != 'undefined') filterExpression = arguments[0];
			var orderExpression = 'Null';
			if(typeof arguments[1] != 'undefined') orderExpression = arguments[1];
						
			data = data + '__filterEpxression=' + urlencode(filterExpression);
			data = data + '&__orderExpression='+ urlencode(orderExpression);
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'removeGridLink'})
			this._submitLow('RemoveGridLink',this.gridId,this.ajaxURL,data); 
					return false;
			
			
		},
	
	fetchMoreRecords: function() {
		if(!this._hasMoreRecords) return false;
		var data = '__rowsInGrid=' + this._rowsInGrid;
		this._executeEvent('beforeFetchMoreRecords',{ajaxEvent: 'fetchMoreRecords'})
		var ele = $(this.gridId +'.FETCHMOREBTN');
		if(ele) ele.innerHTML = '<img src="'+this.waitIconSmall+'" />'
		this.pageNavigate('next-morerecords','G',data);
	},
	
	fetchExplicitRecord: function(pk) {
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'fetchExplicitRecord'})
		var data = '__pk=' + pk;
		data = data + '&__rowsInGrid=' + this._rowsInGrid;
		this.ajaxCallback('G','none','__a5systemFetchExplicitRecord','',data);
		
	},
	
	_registerLinkedGrid: function(lcsName,index,name) {
		if(typeof this._linkedGrids == 'undefined') this._linkedGrids = {};
		if(typeof this._linkedGrids[lcsName] == 'undefined') this._linkedGrids[lcsName] = {};
		//if(typeof this._linkedGrids[lcsName][index] == 'undefined') 
		this._linkedGrids[lcsName][index] = name;
	
	},
	
	cascadingDropdown: function(rowNumber, value,childControls,part,thisControl) {
		
		var data = '';
		data = data + '__dropdownValue=' + urlencode(value);
		data = data + '&__childControls=' + urlencode(childControls);
		data = data + '&__thisControl=' + urlencode(thisControl);
		data = data + '&__part=' + urlencode(part);
		//when a grid was being run as a lookup grid, __part was getting overwritten with the wrong value
		data = data + '&__part2=' + urlencode(part);
		data = data + '&_rowNumber=' + urlencode(rowNumber);
		
		
		var formData = '';
		if(part=='G') {
			var regionId = this.gridId  + '.R' + rowNumber;
			formData = this._harvestGrid(regionId);
			}
		if(part=='D') {
			formData = A5.form.harvest(this.gridId +'.DETAILVIEW_PART.FORM',true,true);
		}
		
		if(part=='S') {
			formData = A5.form.harvest(this.gridId +'.SEARCH_PART.FORM',true,true);
			}
		
		if(formData != '') data = formData + '&' + data
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'cascadingDropdown'})
		this._submitLow('CascadingDropdown',this.gridId,this.ajaxURL,data); 
					return false;
	},
	
	_getEditState: function(part,rowNum) {
		//for edit on demand, tell if row state is current edit or view
		var mode = '';
		if(part == 'D') {
			mode = this.detailViewEditMode;
			if(mode == 'on') return 'edit';
			if(mode == '') return 'view';
			if(mode == 'dvod') {
				if(typeof this._dvEditingMode == 'undefined') return 'view';
				else return this._dvEditingMode;
			}
		} else {
			mode = this.rowEditMode;
			if(mode == 'all') return 'edit';
			if(mode == '') return 'view';
			if(mode == 'rod' || mode == 'rod-s') {
				if(this._editModeRows[rowNum-1]) return 'edit';
				else return 'view';
			}
		
		}
	
	},
	

	
	_getRowKey: function(keyIndex) {
		if(typeof this._keys == 'undefined') return '';
	
		if(this._keys[keyIndex-1]) {
			var key = this._keys[keyIndex-1];
			var prefix = typeof arguments[1] != 'undefined' ? arguments[1] : 'KEYS';
			var data = new Array() ;
			if(key.constructor == Array) {
				for(var i = 0;i < key.length; i++) {
					data.push(A5.ajax.buildURLParam(prefix + '.R'+keyIndex+'[]',key[i]));
				}
			} else {
				data.push(A5.ajax.buildURLParam(prefix + '.R'+keyIndex+'[]',key));
			}
			
			return data.join('&');
			
		} else {
			return '';
		}
	},
	
	_setCheckedRow: function(rowNum,cvalue) {
		this._executeEvent('onGridRowCheck',{ rowNumber: rowNum, checkboxValue: cvalue })
		if(this.checkBoxSelector != 'multiplePage') return false;
		var key = this._keys[rowNum-1];
		var keystr = key.toString();
		if(cvalue == true) {
			for(var i=0; i < this._checkedRowKeys.length; i++) {
				if(this._checkedRowKeys[i].toString() == keystr) return false;
			}
			this._checkedRowKeys.push(key);
		} else {
			for(var i= this._checkedRowKeys.length -1; i >= 0 ; i--) {
				if(this._checkedRowKeys[i].toString() == keystr) {
					this._checkedRowKeys.splice(i,1);
					return false;
				}
			}
		}
	},
	
	
	_genericLinkedContentHandler: function(gridNumber,isLinkedContentSection, linkedContentName) {
		
		var selectedRow = this._selectedRow;
		
		var _gridRowNumber = 'Null';
		if(typeof arguments[3] != 'undefined') {
			//this argument is passed in in the case where the linked content is embedded into a Grid field
			_gridRowNumber = arguments[3];
			selectedRow = parseInt(_gridRowNumber);
		}
		
	
		
		var rowId = '' + selectedRow;
		var rowNum = selectedRow;
		var _hasParentRow = '';
		if(selectedRow > this._rowsInGrid || selectedRow < 0) _hasParentRow = 'true';
		else _hasParentRow = 'false';
	
		var callbackData = '_gridNumber='+gridNumber +'&_isLcs=' + isLinkedContentSection + '&_lcsName=' + linkedContentName;
		callbackData = callbackData + '&_selectedRow=' + selectedRow +'&_hasParentRow=' + _hasParentRow;
		this.ajaxCallback('G',selectedRow,'__a5systemLinkedContentHandler','',callbackData);
	},	
	

openLookup: function(part,rowNum,fieldName) {
	
		if(!this._executeEvent('canOpenLookup',{})) return false;
		
		var windowAttributesFirst = '';
		var windowAttributesSecond = '';
		if(typeof arguments[3] != 'undefined') windowAttributesFirst = arguments[3];
		if(typeof arguments[4] != 'undefined') windowAttributesSecond = arguments[4];
		
		var tempObj =  windowAttributesSecond.split(':');
		if(tempObj[0] == 'element') windowAttributesSecond = $(tempObj[1]);
	
	var openLW = this._openLookupWindows
		this._lookupRow = rowNum
		var lookupWindowId = this.gridId + '.GRID.LOOKUPWINDOW.' + fieldName;
		if(part=='DV') {
			openLW = this._openDVLookupWindows;
			lookupWindowId = this.gridId + '.DV.LOOKUPWINDOW.' + fieldName;
		}
		
		
		var data = '_part=' + part +'&_rowNumber='+rowNum +'&_field=' +fieldName;
		data = data+this._getData(part,rowNum,false);
		var eleCont = this.gridId + '_LOOKUP_'+fieldName+'.GRID_PART.FORM_CONTAINER_DIV'
		//if(part == 'DV') eleCont = this.gridId + '_LOOKUP_'+fieldName+'.DETAILVIEW_PART.FORM_CONTAINER_DIV'
		
		var lookupWorkingHTML = this.lookupFieldsWorkingMessages[fieldName];
		if(typeof lookupWorkingHTML == 'undefined' || lookupWorkingHTML == '') lookupWorkingHTML = '<div style="width: 4in; height: 3in"><img src="CSS/A5System/images/wait.gif" /> Working...</div>'; 
		
		var indxMustResetFilter = $u.a.find(this.lookupFieldsResetFilter,fieldName);
		var flagShowAllAfterSelect = false;
		if(indxMustResetFilter > -1) flagShowAllAfterSelect = true;
		
		//has the lookup window been instantiated?
		var indx = $u.a.find(openLW,fieldName);
		if(indx == -1) {
			//lookup window has not been instantiated
			var eleTemp = this.gridId + '.GRID.LOOKUPWINDOW.' + fieldName;
			if(part == 'DV') eleTemp = this.gridId + '.DV.LOOKUPWINDOW.' + fieldName;
			$(eleTemp).innerHTML = lookupWorkingHTML;
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'showLookupGrid'})
			this._submitLow('showLookupGrid',this.gridId,this.ajaxURL,data); 
		} else {
			//lookup window has been instantiated - send callback to refresh window
			//must filter be reset for this lookup field? 
			//if field has has a dynamicFilter, then Yes (must refresh Grid)
			//if field does not have a dynamicFilter, and field is in lookupFieldResetFilter, then Yes (must refresh Grid)
			var indxDynFilter = $u.a.find(this.lookupDynamicFilters,fieldName); 
			if(indxDynFilter != -1) {
				$(eleCont).innerHTML = lookupWorkingHTML;
				window[this.gridId + '_LOOKUP_'+fieldName+'_GridObj'].refreshLookupGrid(data);
			}
		}
		
		if(indx == -1) 	openLW.push(fieldName);
		$(lookupWindowId).style.display = 'block';
		if(part != 'DV') this.setSelectedRow(rowNum);
		var indx = $u.a.find(this.dropDownLookupWindows,fieldName);

		if(indx == -1) {
		
			if(windowAttributesFirst == '') {
				this._floatingLookupWindow[fieldName].show();
			} else {
				this._floatingLookupWindow[fieldName].show(windowAttributesFirst,windowAttributesSecond);
			}
		} else {
			if(part == 'DV') var ele = $(this.gridId + '.D.V.R1.' + fieldName);
			else var ele = $(this.gridId + '.V.R' + rowNum + '.' + fieldName);
			this._floatingLookupWindow[fieldName].show('dropdown',ele);
		}
		return false;
	},	
	
	
	
synchronizeGrid: function(go) {
		var arr = new Array();
		var flagRunningInWindow = true;
		if(typeof go.runningInWindow != 'undefined') flagRunningInWindow = go.runningInWindow;
		
		if(typeof go.linkedContentSectionName == 'undefined') go.linkedContentSectionName = '';
		
		if(go.localArguments == undefined) go.localArguments = '';
		if(go.parameterBucket == undefined) go.parameterBucket = '';
		if(go.argumentValueBucket == undefined) go.argumentValueBucket = '';
		
		if(typeof go._noParentRecord == 'undefined') go._noParentRecord = false;

		if(go._gridCurrentFilter == undefined) go._gridCurrentFilter = '';
		if(go._gridCurrentOrder == undefined) go._gridCurrentOrder = '';
		if(go._gridCurrentArguments == undefined) go._gridCurrentArguments = '';
		if(go._gridCurrentDBType == undefined) go._gridCurrentDBType = '';

		
		arr.push('__vp__fn=GR');
		arr.push('__vp__path=' + go.a5_default_path );
		arr.push(A5.ajax.buildURLParam('__vp__gridName',go.gridName));
		arr.push('__vp__div=' + go.gridDiv);
		arr.push('__vp__alias=' + go.alias);
		var flags = go.flagTimer + go.flagQueryEcho + go.flagDebugMode;
		arr.push('__vp__flags=' + flags);
		arr.push(A5.ajax.buildURLParam('__vp__userFilter',go.userFilter));
		arr.push(A5.ajax.buildURLParam('__vp__userOrder',go.userOrder));
		arr.push(A5.ajax.buildURLParam('__vp__baseFilter',go.baseFilter));
		arr.push(A5.ajax.buildURLParam('__vp__linkDefinition',go.linkDefinition));
		arr.push(A5.ajax.buildURLParam('__vp__arguments',go.arguments));
		arr.push(A5.ajax.buildURLParam('__vp__localArguments',go.localArguments));
		arr.push(A5.ajax.buildURLParam('__vp__parameterBucket',go.parameterBucket));
		arr.push(A5.ajax.buildURLParam('__vp__argumentValueBucket',go.argumentValueBucket));
		arr.push(A5.ajax.buildURLParam('__vp__placeHolderValues',go.placeHolderValues));
		
		arr.push(A5.ajax.buildURLParam('__vp___gridCurrentFilter',go._gridCurrentFilter));
		arr.push(A5.ajax.buildURLParam('__vp___gridCurrentOrder',go._gridCurrentOrder));
		arr.push(A5.ajax.buildURLParam('__vp___gridCurrentArguments',go._gridCurrentArguments));
		arr.push(A5.ajax.buildURLParam('__vp___gridCurrentDBType',go._gridCurrentDBType));
		arr.push(A5.ajax.buildURLParam('__vp___LCSName',go.linkedContentSectionName));
		arr.push(A5.ajax.buildURLParam('__vp___NoParentRecord',''+go._noParentRecord));
		arr.push(A5.ajax.buildURLParam('__synchronizeGrid','true'));
		

		var params = arr.join('&');
		params = $u.s.tran(params,'\n','%0D%0A');
			
		var pageVars = String(window.location);
		pageVars = pageVars.split('?');
		pageVars.shift();
		pageVars=pageVars.join('?');

		var data = pageVars;
	
		var formData = '';
		
		if(!go._noParentRecord) {
			if(go.sourceGridPart=='G') {
				var rowNumber = go.sourceGridRowNumber;
				var regionId = go.parentGridId + '.R' + rowNumber;
				formData = window[go.parentGridId + '_GridObj']._harvestGrid(regionId);
				}
			if(go.sourceGridPart=='D') {
				var rowNumber = 1;
				formData = A5.form.harvest(go.parentGridId +'.DETAILVIEW_PART.FORM',true,true);
			}
			
			if(go.sourceGridPart=='O') {
				var rowNumber = go.sourceGridRowNumber;
				formData = window[go.parentGridId + '_DlgObj']._harvestRow(rowNumber);
				
			}
		}

		var otherData = '_rowNumber=' +go.sourceGridRowNumber + '&__gridPart=' +go.sourceGridPart +'&__parentGridID=' + go.parentGridId  +'&__windowName=' + go.windowName ;
		if(formData != '') {
			formData = formData + '&' + data + '&' + otherData;
		} else {
			formData = otherData;
		}

		if(formData != '') data = formData + '&' + data
		
		data = params + '&' + data;
		data = data + '&__runningInWindow=' + flagRunningInWindow;
		
		
		
		if(flagRunningInWindow) {
			//$(go.gridDiv).innerHTML = go.workingMessage;
			if($(this.gridId + '.GRID_PART.FORM_CONTAINER_DIV')) $(this.gridId + '.GRID_PART.FORM_CONTAINER_DIV').innerHTML = go.workingMessage;
			if($(this.gridId + '.DETAILVIEW_PART.FORM_CONTAINER_DIV')) $(this.gridId + '.DETAILVIEW_PART.FORM_CONTAINER_DIV').innerHTML = '';
			
			if(go.sourceGridPart=='O') {
				var currWindow = window[go.parentGridId + '_DlgObj'].getWindow(go.windowName);
			} else {
				var currWindow = window[go.parentGridId + '_GridObj'].getWindow(go.windowName);
			}
			if(typeof go.windowPositionArg1 != 'undefined' ) currWindow.show(go.windowPositionArg1,go.windowPositionArg2);
			else currWindow.show('in-view');
			
		}
		
		
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'synchronizeGrid'})
		this._submitLow('SynchronizeGridInWindow',this.gridId,this.ajaxURL,data); 
		return false;
	
	
	},
		
	
	
	
	openChildGrid: function(go) {
		if(typeof go.setFocus == 'undefined') go.setFocus = 'true';
		if(typeof go.gridDiv == 'undefined') go.gridDiv = '';
		if(typeof go.centerFlags == 'undefined') go.centerFlags = '';
		if(typeof go.gridName == 'undefined') go.gridName = '';
		if(typeof go.alias == 'undefined') go.alias = go.gridName;
		if(typeof go.guid == 'undefined') go.guid = A5.ajax.guid() ;
		if(typeof go.submitCurrentFieldValues == 'undefined') go.submitCurrentFieldValues = false;
		if(typeof go.sourceGridPart == 'undefined') go.sourceGridPart = '';
		if(typeof go.sourceGridRowNumber == 'undefined') go.sourceGridRowNumber = 0;
		if(typeof go._gridCurrentFilter == 'undefined') go._gridCurrentFilter = '';
		if(typeof go._gridCurrentOrder == 'undefined') go._gridCurrentOrder = '';
		if(typeof go._gridCurrentArguments == 'undefined') go._gridCurrentArguments = '';
		if(typeof go._gridCurrentDBType == 'undefined') go._gridCurrentDBType = '';
		if(typeof go._thisGridAlias == 'undefined') go._thisGridAlias = '';
		if(typeof go.linkedContentSectionName == 'undefined') go.linkedContentSectionName = '';
		if(typeof go._thisGridGUID == 'undefined') go._thisGridGUID = '__unknown__';
		if(typeof go._noParentRecord == 'undefined') go._noParentRecord = false;
		

		
		if(go.gridDiv == '') {
			alert('Fatal Error. DIV to display Grid Component was not defined.');
			return false;
			}
		
		if(go.gridName == '') {
			go.gridName = $(go.gridDiv).innerHTML = 'Fatal error: Grid to display was not specified.';
			return false;
			}
		
		if(go.alias == '') {
			$(go.reportDiv).innerHTML = 'Fatal error: Grid alias was not specified.';
			return false;
			}
	
		if(go.workingMessage == undefined) go.workingMessage = '<img src="CSS/A5System/Images/wait.gif" /> Working...';
		if(go.flagTimer == undefined) go.flagTimer = 'F';
		if(go.flagQueryEcho == undefined) go.flagQueryEcho = 'F';
		if(go.flagDebugMode == undefined) go.flagDebugMode = 'F';
		if(go.userFilter == undefined) go.userFilter = '';
		if(go.baseFilter == undefined) go.baseFilter = '';
		if(go.linkDefinition == undefined) go.linkDefinition = '';
		if(go.arguments == undefined) go.arguments = '';
		if(go.localArguments == undefined) go.localArguments = '';
		if(go.parameterBucket == undefined) go.parameterBucket = '';
		if(go.argumentValueBucket == undefined) go.argumentValueBucket = '';
		if(go.placeHolderValues == undefined) go.placeHolderValues = '';
		if(go.userOrder == undefined) go.userOrder = '';
		if(go.overrideSettings == undefined) go.overrideSettings = '';
		if(go.linkDefinition == undefined) go.linkDefinition = '';
		
		
		var flags = go.flagTimer + go.flagQueryEcho + go.flagDebugMode;
		
		var arr = new Array();
		arr.push('__vp__fn=GR');
		arr.push('__vp__div=' + go.gridDiv);
		arr.push('__vp__centerFlags=' + go.centerFlags);
		arr.push(A5.ajax.buildURLParam('__vp__gridName',go.gridName));
		arr.push('__vp__path=' + go.a5_default_path );
		arr.push('__vp__guid=' + go.guid );
		arr.push('__vp__alias=' + go.alias);
		arr.push('__vp__flags=' + flags);
		
		arr.push(A5.ajax.buildURLParam('__vp__userFilter',go.userFilter));
		arr.push(A5.ajax.buildURLParam('__vp__userOrder',go.userOrder));
		arr.push(A5.ajax.buildURLParam('__vp__baseFilter',go.baseFilter));
		arr.push(A5.ajax.buildURLParam('__vp__linkDefinition',go.linkDefinition));
		arr.push(A5.ajax.buildURLParam('__vp__override',go.overrideSettings));
		arr.push(A5.ajax.buildURLParam('__vp__arguments',go.arguments));
		arr.push(A5.ajax.buildURLParam('__vp__localArguments',go.localArguments));
		arr.push(A5.ajax.buildURLParam('__vp__parameterBucket',go.parameterBucket));
		arr.push(A5.ajax.buildURLParam('__vp__argumentValueBucket',go.argumentValueBucket));
		arr.push(A5.ajax.buildURLParam('__vp__placeHolderValues',go.placeHolderValues));
		arr.push(A5.ajax.buildURLParam('__vp__setFocus',go.setFocus));
		
		arr.push(A5.ajax.buildURLParam('__vp___gridCurrentFilter',go._gridCurrentFilter));
		arr.push(A5.ajax.buildURLParam('__vp___gridCurrentOrder',go._gridCurrentOrder));
		arr.push(A5.ajax.buildURLParam('__vp___gridCurrentArguments',go._gridCurrentArguments));
		arr.push(A5.ajax.buildURLParam('__vp___gridCurrentDBType',go._gridCurrentDBType));
		arr.push(A5.ajax.buildURLParam('__vp___thisGridAlias',go._thisGridAlias));
		
		arr.push(A5.ajax.buildURLParam('__vp___thisGridGUID',go._thisGridGUID));
		
		arr.push(A5.ajax.buildURLParam('__vp___LCSName',go.linkedContentSectionName));
		arr.push(A5.ajax.buildURLParam('__vp___NoParentRecord','' +go._noParentRecord));
		
		arr.push(A5.ajax.buildURLParam('__openChildGrid','true'));
		
		
		
		var params = arr.join('&');
		
				
		params = $u.s.tran(params,'\n','%0D%0A');
		var fakeData = params
		
		var page = '&' + params + '._a5_ajax';
		
		var pageVars = String(window.location);
		pageVars = pageVars.split('?');
		pageVars.shift();
		pageVars=pageVars.join('?');
		
		//var data = '';
		var data = pageVars;
		
		//Submit form data if necessary to that filter and link can be based on edited data in current record
		
		

		if(go.submitCurrentFieldValues == true) {
			var formData = '';
			if(!go._noParentRecord) {
				if(go.sourceGridPart=='G') {
					var rowNumber = go.sourceGridRowNumber;
					var regionId = this.gridId  + '.R' + rowNumber;
					formData = this._harvestGrid(regionId);
					}
				if(go.sourceGridPart=='D') {
					var rowNumber = 1;
					formData = A5.form.harvest(this.gridId +'.DETAILVIEW_PART.FORM',true,true);
				}
			}
			
			var otherData = '_rowNumber=' +rowNumber + '&__gridPart=' +go.sourceGridPart + '&__useCurrentFieldValues=Yes';
			if(formData != '') {
				formData = formData + '&' + data + '&' + otherData;
			} else {
				formData = otherData;
			}
			
			if(formData != '') data = formData + '&' + data
		}
		
		data = data + '&' + fakeData;
		var page = '_dummyPage._a5_ajax';
		//tell the virtual page what the page type is - gr
		var page = '&__guid=' + go.guid +  '&__fn=gr' +  '._a5_ajax';
		
		
		

		
		$(go.gridDiv).innerHTML = go.workingMessage;
		
		data = A5.ajax.addParamRequiredData(data);
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'openChildGrid'})
		new $a.simple(page,{data:data, method:'post', handleGeneric:true});

	
	},
	
	
	refreshLookupGrid: function(data) {
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'refreshLookupGrid'})
		this._submitLow('refreshLookupGrid',this.gridId,this.ajaxURL,data); 
	},
	
	lookupGridSelectRow: function(parentGridId,fieldName, part, rowNum) {
		
		if(!this._executeEvent('canLookupGridSelectRow',{})) return false;

		if(part!='O') {	
			var lookupWindowId = parentGridId + '.GRID.LOOKUPWINDOW.' + fieldName;
			if(part=='DV') {
				lookupWindowId = parentGridId + '.DV.LOOKUPWINDOW.' + fieldName;
			}
			$(lookupWindowId).style.display = 'none';
		};
		var data = new Array();

		for(var i=0;i < this.lookupGridFieldsToReturn.length; i++) {
			for(var j = 0; j < this.gridColumnInfo.length; j++) {
				if(this.gridColumnInfo[j].name == this.lookupGridFieldsToReturn[i]) {
					if(this.gridColumnInfo[j].type.substr(0,4) == 'link' && this._originalValues[rowNum-1][j].constructor == Array) data.push(this._originalValues[rowNum-1][j][0]);
					else  data.push(this._originalValues[rowNum-1][j]);
					break;
				}
			}
		}
		if(part=='O') {
			window[parentGridId+'_DlgObj'].fillinLookupValues(data, fieldName, part, this.gridId);
		} else {
			window[parentGridId+'_GridObj'].fillinLookupValues(data, fieldName, part, this.gridId);
		}
	},
	
	fillinLookupValues: function(data, fieldName, part, lookupGridId) {

		this._floatingLookupWindow[fieldName].hide();
		if(part=='G') {
			this._populateDirtyRow(this._lookupRow, data, this.lookupFieldsToFillin[fieldName]); 
		} else if(part=='DV') {
			this._populateDirtyDetailView(this._lookupRow,data,this.lookupFieldsToFillin[fieldName]);
		}

		
		if(window[lookupGridId+'_GridObj'].flagResetFilterAfterSelect) {
			window[lookupGridId+'_GridObj'].showAll();
		}
		
		this._executeEvent('afterLookupGridFillinValues',{});
		
	},
	
	detailView: function(rowNumber) {
	
		if(!this._executeEvent('canDetailViewOpen',{rowNumber: rowNumber})) return false;
		if(!this._confirmAction()) return false;
		this._detailViewWindowState = 'open';
		var windowAttributesFirst = this._detailViewWindowPos1;
		var windowAttributesSecond = this._detailViewWindowPos2;
		windowAttributesSecond = windowAttributesSecond.replace(/___rowNumber___/g,''+rowNumber);
		windowAttributesSecond = windowAttributesSecond.replace(/___this___/g,this.gridId + '.R'+rowNumber);
		var tempObj =  windowAttributesSecond.split(':');
		if(tempObj[0] == 'element') windowAttributesSecond = $(tempObj[1]);
		
		if(this.detailViewDataPreFetch == false) {
			$e.removeGroup(this.gridId + '.DETAILVIEW_PART.FORMEvents');
			var keys = this._getRowKey(rowNumber);
			var data = '_rowNumber='+rowNumber +'&' + keys;
			if(windowAttributesFirst != '') {
				
				if(tempObj[0] == 'element') windowAttributesSecond = windowAttributesSecond.id;
				data = '_w1=' + windowAttributesFirst + '&_w2=' + windowAttributesSecond + '&' + data;
			}
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'showDetailView'})
			this._submitLow('ShowDetailView',this.gridId,this.ajaxURL,data); 
		} else {
			this.clearDetailViewGlobalError();
			this._detailViewRow = rowNumber;
			var data = new Array();
			for(var i = 0; i < this._originalDVValues[rowNumber -1 ].length; i++) {
				if(this._originalDVValues[rowNumber -1 ][i].constructor == Array) {
					data[i] = new Array();
					for(var j = 0; j < this._originalDVValues[rowNumber -1 ][i].length; j ++) {
						data[i][j] = this._originalDVValues[rowNumber -1 ][i][j];
					}
				} else data[i] = this._originalDVValues[rowNumber -1 ][i];
			}
			if(this.detailViewEditMode == 'dvod') {
				if(this._editModeRows[0]) {
					this.cancelEditDetailViewRecord();
				} else {
					this._populateDetailView(rowNumber, data, this._detailViewColNames,false,[],1,false);	
					this._executeEvent('afterDetailViewOpen',{rowNumber: rowNumber});
				}
			} else {
				//this._populateDetailView(rowNumber, data, this._detailViewColNames,false,[],1,false);
				this._populateDetailView(rowNumber, data, this._detailViewColNames,false,[],0,false);
				this._executeEvent('afterDetailViewOpen',{rowNumber: rowNumber});
			}
			if(this._originalDVNullValues.length > 0 ) {
				this._localDVNullValues[0] = this._originalDVNullValues[rowNumber -1];
			}
			this.setSelectedRow(rowNumber,true);
		
			if(this.detailViewPosition == 'popup') {
				//alert(windowAttributesFirst + '-' + windowAttributesSecond.id);
				$(this.gridId + '.DETAILVIEW_PART.COMPLETE').style.display = 'block';
				if(windowAttributesFirst == '') {
					this._dvFloatingWindow.show();
				} else {
					this._dvFloatingWindow.show(windowAttributesFirst,windowAttributesSecond);
				}
			} else if(this.detailViewPosition == 'inline') { 
				var eleDV = $(this.gridId + '.DETAILVIEW_PART.COMPLETE');
				eleDV.style.display = 'block';
				this._showInlineDetailView();
				eleDV.style.display = 'none';
				A5.u.element.show(eleDV,this.detailViewAnimation.show);
				
			} else {
				//$(this.gridId + '.DETAILVIEW_PART.COMPLETE').style.display = '';
				A5.u.element.show($(this.gridId + '.DETAILVIEW_PART.COMPLETE'),this.detailViewAnimation.show);
				if(this.detailViewScrollIntoView) {
					var dvId = this.gridId + '.DETAILVIEW_PART.COMPLETE'
					setTimeout(function() { 
						var dvele = $(dvId);
						if(dvele)  dvele.style.display = 'block';
						$swto(dvele);
						},100);
				}
			}
			this._executeEvent('onDetailViewRender',{rowNumber: this._detailViewRow});			
			//need to run ._setDetailViewControlsDisabledState() to cause combo box in editable DV that is 'edit on demand' to be disabled.
			this._setDetailViewControlsDisabledState();
			
		}
		
		if(this.detailViewPosition == 'page') {
			if(this.hideGridWhenDetailViewIsShown == true) {
				var ele = $(this.gridId + '.GRID_PART.FORM_CONTAINER_DIV');
				ele.style.display = 'none';
				if(this.detailViewDataPreFetch == false) {
					var eleDV = $(this.gridId + '.DETAILVIEW_PART.FORM_CONTAINER_DIV');
					eleDV.innerHTML = '<img src="CSS/A5System/images/wait.gif" />Working...';
				}
			}
		}
		//turn off gridKeywatches
		var classInst = this;
		setTimeout(function() {classInst._kw.off();},10);
		delete classInst;
		return false;
	},
	
	
	detailCancelNewRecord: function() {
		var nrEle =  $(this.gridId +'.DETAILVIEW_PART.NEWRECORDBUTTON');
		var cnrEle =  $(this.gridId +'.DETAILVIEW_PART.CANCELNEWRECORDBUTTON');
		if(this._detailViewOldRow > 0  && this._detailViewOldWindowState == 'open' ) {
				if(!this._confirmAction()) return false;
				this.detailView(this._detailViewOldRow);
		} else {
			//if you get here then the detail view was not open before going into the new record, so just close it
			this.closeDetailView();
		}
		nrEle.style.display = '';
		cnrEle.style.display = 'none';
		
		var mode = 'view';		
		this._detailViewState = mode;
		this._executeEvent('onDetailViewStateChange',{'mode': mode, 'isDirty': false, 'rowNumber': this._detailViewRow});
		
		
	},
	
	detailViewNewRecord: function() {
		if(!this._executeEvent('canDetailViewNewRecord',{})) return false;
		if(!this._confirmAction()) return false;
		this._detailViewOldRow = this._detailViewRow;
		this._detailViewOldWindowState = this._detailViewWindowState;
		this._detailViewWindowState = 'open';
		
		
		if(this.detailViewEditMode == 'dvod') {
			var ele = $(this.gridId + '.DETAILVIEW_PART.FORM_CONTAINER_DIV');
			this._detailViewHTMLCache = ele.innerHTML;
		}

		var data = '_rowsInGrid=' + this._rowsInGrid +'&_dvCurrentRow=' + this._detailViewRow;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'detailViewNewRecord'})
		this._submitLow('DetailViewNewRecord',this.gridId,this.ajaxURL,data); 
		
		/*
		//Send this command back as part of the response, or else you get screen flicker
		if(this.detailViewPosition == 'popup') {
			$(this.gridId + '.DETAILVIEW_PART.COMPLETE').style.display = 'block';
			this._dvFloatingWindow.show();
		}
		*/
		
		if(this.detailViewPosition == 'page') {
			if(this.hideGridWhenDetailViewIsShown == true) {
				var ele = $(this.gridId + '.GRID_PART.FORM_CONTAINER_DIV');
				ele.style.display = 'none';
				//don't condition on PreFetch mode since we always do a callback for the new record.
				//if(this.detailViewDataPreFetch == false) {
					var eleDV = $(this.gridId + '.DETAILVIEW_PART.FORM_CONTAINER_DIV');
					eleDV.innerHTML = '<img src="CSS/A5System/images/wait.gif" />Working...';
				//}
			}
		}		
		//this can get overwritten, so the same code is also added to the ajax callback		
		if($(this.gridId+'.DVTOOLBAR_VIEWMODE')) $(this.gridId+'.DVTOOLBAR_VIEWMODE').style.display = 'none';
		if($(this.gridId+'.DVTOOLBAR_CHANGEMODE')) $(this.gridId+'.DVTOOLBAR_CHANGEMODE').style.display = 'none';
		if($(this.gridId+'.DVTOOLBAR_ENTERMODE')) $(this.gridId+'.DVTOOLBAR_ENTERMODE').style.display = '';

		var mode = 'enter';		
		this._detailViewState = mode;
		this._executeEvent('onDetailViewStateChange',{'mode': mode, 'isDirty': false, 'rowNumber': this._detailViewRow});
		
		
		
	},
	
	
	detailViewRefresh: function() {
		if(this._detailViewRow == -1) return false;
		var pkdata = this._getRowKey(this._detailViewRow);
		var regionId = this.gridId  + '.D.R1';
		var data = '';
		if(pkdata != '') data = data + '&' + pkdata;
		data = data + '&' + '_rowNumber=' + this._detailViewRow +'&_submitActionType=detailViewRefresh';
		var stateInfoID = this.gridId + '.STATEINFO';
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'detailViewRefresh'})
		//false at end means do not remove events, or else events such as onBlur that were added will be removed.
		this._submitLow('submit:all',this.gridId + '.DETAILVIEW_PART.FORM',this.ajaxURL,data,true,stateInfoID,'',false);
	},
	
	detailViewNextRecord: function() {
	
		if(this._detailViewRow == -1) {
			this.detailViewLastRecord();
			return false;
		}
		var nextRow = -1;
		for(var i = this._detailViewRow + 1; i <= this._rowsInGrid; i++) {
			if($(this.gridId +'.R' + i).style.display != 'none') {
				nextRow = i;
				break;
			}
		}
		
		
		var currentPageNumber = this.pageNumber;
		var currentRow = this._detailViewRow;
		var pagesInGrid = this.pagesInGrid;
		var rig = this._rowsInGrid;
		var arop = this.actualRowsOnPage;
		
		if((currentPageNumber == pagesInGrid) && (currentRow == rig)) {
			return false;
		} else {
			if(nextRow == -1 ) this.pageNavigate('next','DV');
			else this.detailView(nextRow);
		}
	},
	
	detailViewFirstRecord: function() {
		/*
		var nextRow = -1;
		for(var i = this._detailViewRow + 1; i <= this._rowsInGrid; i++) {
			if($(this.gridId +'.R' + i).style.display != 'none') {
				nextRow = i;
				break;
			}
		}
		if(nextRow == -1 ) this.pageNavigate('next');
		else this.detailView(nextRow);
		*/

		if(this.pageNumber == 1) {
			this.detailView(1);
		} else {
			this.pageNavigate('first','DV');
		}
	},
	
	
	detailViewPreviousRecord: function() {
		var nextRow = -1;
		for(var i = this._detailViewRow - 1; i > 0; i--) {
			if($(this.gridId +'.R' + i).style.display != 'none') {
				nextRow = i;
				break;
			}
		}
		if(nextRow == -1 ) {
			if(this.pageNumber ==1 && this._detailViewRow == 1) {
				//do nothing - you are already on the first logical record	
				return false;
			} else {
				this.pageNavigate('prev-LastRecord','DV');
			}
		} else {
			this.detailView(nextRow);
		}
	},
	
	detailViewLastRecord: function() {
		if(this.pageNumber == this.pagesInGrid) {
			this.detailView(this.actualRowsOnPage);
		} else {
			this.pageNavigate('Last-LastRecord','DV');
		}
	},
	
	validateDetailView: function() {
		this.submitDetailView(false,true);
	},
	
	validateDetailViewField: function(fieldName) {
		this.submitDetailView(false,true,fieldName);
	},

	submitDetailView: function() {
		
		if(this._testAlreadySubmitting()) return false;
		
		if(this._detailViewIsDirty) {
			var validateMode = typeof arguments[1] != 'undefined' ? arguments[1] : false;
			var fieldToValidate = typeof arguments[2] != 'undefined' ? arguments[2] : '';
			if(validateMode != true) {
				if(!this._executeEvent('canDetailViewSubmit',{rowNumber: this._detailViewRow})) return false;
			}

			var data = this._getRowKey(this._detailViewRow);
			data = data + $if(data != '','&','') + '_rowNumber='+this._detailViewRow ;
			var submitActionType = $if(arguments[0],'saveDetailViewAndEnter','saveDetailView');
			if(validateMode) {
				submitActionType = 'validateDetailView';
				if(fieldToValidate != '') {
					submitActionType = 'validateDetailViewField&__fieldToValidate=' + fieldToValidate;
				}
			}
			data =  data + '&_detailViewRecord='+this._detailViewRow +'&_rowsInGrid=' + this._rowsInGrid +'&_submitActionType='+submitActionType;
			data = data +'&__dvWindow=' + this._detailViewWindowState;
			
			
			if(this._localDVNullValues.length > 0) {
				var nullData = '&__Nulls_1='+this._localDVNullValues[0].toString();
				data = data + nullData;
			}
			var stateInfoID = this.gridId + '.STATEINFO';
			
			var submitActionType = $if(arguments[0],'submitAndEnterDetailView','submitDetailView');
			if(validateMode) submitActionType = 'validateDetailView';

			this._executeEvent('beforeAjaxCallback',{ajaxEvent: submitActionType})
			//if we are in validate mode, last argument is false, which means do not remove the events
			this._submitLow('submit:all',this.gridId + '.DETAILVIEW_PART.FORM',this.ajaxURL,data,true,stateInfoID,'',!validateMode)
		}
		return false;
	},
	
	checkedRowsAction: function(actionName) {
		var data = this.getCheckedRows();
		data = A5.ajax.buildURLParam('_checkboxAction',actionName) + '&' + data 
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'checkedRowsAction'})
		A5.ajax.callback(this.ajaxURL,data);
	},
	
	
	getCheckedRows: function() {
		var data = new Array();
		var checkCount = 0;
		var checkedRows = $gvs(this.gridId + '.__ROWCHECKBOX');
		if(this.checkBoxSelector == 'multiplePage') {
			for(var i = 0; i < this._checkedRowKeys.length; i++) {
				data.push(A5.ajax.buildURLParam('checkedRows.key' + (i+1) + '[]',this._checkedRowKeys[i]));
				checkCount++;
			}
		} else if(this.checkBoxSelector == 'singlePage') {
			var key = '';
			for(var i = 0; i < checkedRows.length; i++) {
				if(typeof this._keys != 'undefined') {
					key = this._keys[Number(checkedRows[i]) -1]	;
					data.push(A5.ajax.buildURLParam('checkedRows.key' + (i+1) + '[]',key));
				}
				checkCount++;
			}
		}
		if(checkCount > 0) data.push(A5.ajax.buildURLParam('checkboxRows.rows[]',checkedRows));
		data.push(A5.ajax.buildURLParam('checkboxRows.countChecked',''+checkCount));
		data = data.join('&');	
		
		return data;
	},
	
	
	resetDetailView: function() {
		var classInst = this;
		
		if(!this._executeEvent('canDetailViewCancelEdits',{rowNumber: this._detailViewRow})) return false;

		
		A5.msgBox.show(this.messages.t_undoEditsWarning,this.messages.undoEditsWarning,'OC',function(action) { 
			if(action=='ok') {classInst._resetDetailViewWithoutConfirmation() };
		});
	},

	
	_resetDetailViewWithoutConfirmation: function() {
		if(this._detailViewIsDirty) {
			//A5.form.reset(this.gridId +'.DETAILVIEW_PART.FORM',true);
			if(this._detailViewRow < 0) {
				this._populateDetailView(-1,this._newDVValues,this._detailViewColNames);
			} else {
				if(this.detailViewDataPreFetch) {
					this._populateDetailView(this._detailViewRow,this._originalDVValues[this._detailViewRow -1],this._detailViewColNames);
				} else {
					//in non-prefecth mode, _originalDVValues[] has only one entry
					this._populateDetailView(1,this._originalDVValues[0],this._detailViewColNames);
				}
			}
			this.clearErrors();
			this.clearDetailViewGlobalError();
			var data = '';
			for(var i=0;i<this.detailViewColumnInfo.length;i++) {
				if(this.detailViewColumnInfo[i].type == 'select,label') {
					data = this._cascadingSelectChoices[this.gridId + '.D.V.R1.' + this.detailViewColumnInfo[i].name];
					if(data) {
						A5.form.populateSelect(	this.gridId + '.D.V.R1.' + this.detailViewColumnInfo[i].name, data.value, data.data, true);
					}
				}
			}
			this._executeEvent('afterDetailViewCancelEdits',{rowNumber: this._detailViewRow});
		}
		return false;
	},
	
	setRowCountMessage: function(action,val) {
		var eleT = $(this.gridId + '.RECORDCOUNT.TOP');
		var eleB = $(this.gridId + '.RECORDCOUNT.BOTTOM');
		var currentNumber = '';
		if(eleT && eleB) {
			currentNumber = $gvs(eleT);
		} else if(eleT) {
			currentNumber = $gvs(eleT);
		} else if(eleB) {
			currentNumber = $gvs(eleB);
		}
		if(currentNumber == '') return false;
		var newNumber = '';
		if(action=='I') {
			newNumber = parseInt(currentNumber) + 1;
		} else if(action=='D') {
			newNumber = parseInt(currentNumber) - 1;
		} else if(action=='R') {
			newNumber = val;
		}
		
		if(eleT) $svs(eleT,newNumber);
		if(eleB) $svs(eleB,newNumber);
		
	
	
	},
	
	deleteDetailViewRecord: function() {
		if(!this._executeEvent('canDetailViewDeleteRecord',{rowNumber: this._detailViewRow})) return false;
		var classInst = this;
		A5.msgBox.show(this.messages.t_deleteRow,this.messages.deleteRow,'OC',function(action) { 
			if(action=='ok') {
				classInst._deleteDetailViewRecordWithoutConfirmation()
			};
		} );
	},

	_deleteDetailViewRecordWithoutConfirmation: function() {
		var rowNumber = this._detailViewRow
		var data = this._getRowKey(this._detailViewRow);
		data = data + $if(data != '','&','') + '_rowNumber='+this._detailViewRow ;
		data = data + '&_submitActionType=DeleteDetailViewRecord';
		var stateInfoID = this.gridId + '.STATEINFO';
		if(this.detailViewEditMode == 'dvod') {
			var oldData = new Array();
			
			if(this.detailViewDataPreFetch) { 
				oldData = this._originalDVValues[rowNumber-1];
			} else {
				oldData = this._originalDVValues[0];
			}
			var tempData = new Array();
			for(var i = 0; i < oldData.length; i++) {
				tempData.push(A5.ajax.buildURLParam('old.V.R1.' + this.detailViewColumnInfo[i].name,oldData[i]));
			}
			tempData = tempData.join('&');
			data = data +'&' + tempData;
			var stateInfo = $(stateInfoID).value ? $(stateInfoID).value : '';
			if(stateInfo != '') data = data + '&' + stateInfo;
			data = '__FormAction=submit&__FormID=' + this.gridId + '.DETAILVIEW_PART.FORM&' + data;
			data = $u.s.tran(data,'\n','%0D%0A');
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'deleteDetailViewRecord'})
			A5.ajax.callback(this.ajaxURL,data);
		} else {
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'deleteDetailViewRecord'})
			this._submitLow('submit:all',this.gridId + '.DETAILVIEW_PART.FORM',this.ajaxURL,data,true,stateInfoID)
		}
	},
	
	setDetailViewGlobalError: function(txt) {
		if($(this.gridId + '.GLOBALERRORS')) {
			$(this.gridId + '.GLOBALERRORS').innerHTML = txt;
			$(this.gridId + '.GLOBALERRORS').style.display = 'block';
			}

		if(this.rowErrors.showMessageBox == true) {
			var msgTxt = txt;
			msgTxt = '<div style="' + this.rowErrors.style + '">' + msgTxt + '</div>';
			A5.msgBox.show(this.rowErrors.messageBoxTitle,msgTxt,'O');
		}
		
			
			
			
	},
	
	clearDetailViewGlobalError: function() {
		if($(this.gridId + '.GLOBALERRORS')) {
			$(this.gridId + '.GLOBALERRORS').innerHTML = '';
			$(this.gridId + '.GLOBALERRORS').style.display = 'none';
			}
	},
	
	closeParentContainer: function() {
		var eleWindow = this.gridId +'.GRID_PART.FORM_CONTAINER_DIV';
		closeParentA5Window(eleWindow);
		if(typeof tbiObj != 'undefined') {
			for(var i=0; i < tbiObj._tbObj._panes.length; i++) {
				if(tbiObj._tbObj._panes[i].name.toUpperCase() == this.gridId) {
					tbiObj._tbObj.remove(tbiObj._tbObj._panes[i]._id);
					break;
				}
			}
		}
	},
	
	closeDetailView: function() {

		
		if(!this._executeEvent('canDetailViewClose',{rowNumber: this._detailViewRow})) return false;
		if(!this._confirmAction()) return false;


		//if dv is 'editondemand' and you enter a new record, but abort without commit, then when you try to edit some existing row, it would still be in edit mode, but locked to prevent editing.		
		if(this.detailViewEditMode == 'dvod') {
			if(typeof this._detailViewHTMLCache != 'undefined') {
				var ele = $(this.gridId + '.DETAILVIEW_PART.FORM_CONTAINER_DIV');
				ele.innerHTML = this._detailViewHTMLCache;
				delete this._detailViewHTMLCache;
			}
		}

		
		if(this.detailViewPosition != 'popup')	{
			//if($(this.gridId + '.DETAILVIEW_PART.COMPLETE')) $(this.gridId + '.DETAILVIEW_PART.COMPLETE').style.display = 'none';
			if($(this.gridId + '.DETAILVIEW_PART.COMPLETE')) {
				if(this.detailViewPosition == 'inline') {
					var tAnim = {};
					$u.o.assign(tAnim,this.detailViewAnimation.hide);
					tAnim.onComplete = Function('$(\''+this.gridId+'.RDV\').style.display = \'none\';');
					A5.u.element.hide($(this.gridId + '.DETAILVIEW_PART.COMPLETE'),tAnim);
				} else A5.u.element.hide($(this.gridId + '.DETAILVIEW_PART.COMPLETE'),this.detailViewAnimation.hide);
			}
		} else {
			//this._dvFloatingWindow.hide();
			if(this._dvFloatingWindow.type == 'modal') AUI.LockUI.pageFree();
			else if(this._dvFloatingWindow.type == 'popup') $e.remove(document.documentElement,'click',this._dvFloatingWindow._popupHide);
			var wEle = $(this._dvFloatingWindow._windowId);
			if(this._dvFloatingWindow.animation.disabled) {
				if(document.all && navigator.appName != 'Opera') wEle.style.display = 'none';
				else wEle.style.visibility = 'hidden';
			} else A5.u.element.hide(wEle,this._dvFloatingWindow.animation.hide);
			if(this._dvFloatingWindow.activeClassName != '') $rcn(wEle,this._dvFloatingWindow.activeClassName);
			this._dvFloatingWindow._lockIndex = -1;
			this._dvFloatingWindow.hidden = true;
			this._dvFloatingWindow._focusTopWindow();			
		}

		this._detailViewWindowState = '';
		
		if(this.detailViewPosition == 'page') {
			if(this.hideGridWhenDetailViewIsShown == true) {
			var ele = $(this.gridId + '.GRID_PART.FORM_CONTAINER_DIV');
			ele.style.display = 'block';
			}
		}
		
		this._executeEvent('afterDetailViewClose',{rowNumber: this._detailViewRow})
		
	},
	
	detailViewToggle: function(rowNumber) {
		if(this._detailViewWindowState == '' || this._detailViewRow != rowNumber) {
			this.detailView(rowNumber);
		} else {
			this.closeDetailView()
		}
	},
	
	globalUpdate: function(rowNumber,obj) {
		var field = obj.fieldToUpdate;
		if(field=='<CurrentField>') field = this._focusControl;
		
		var id = this.gridId + '.V.R' + rowNumber +'.' + field;
		var ele = $(id);
		if(!ele) return false;
		
		if(obj.type == 'search') {
			obj.onlyUpdateBlankFields = false;
			var eleSearch = $(obj.elementIdSearchValue);
			if(!eleSearch) return false;
			var searchVal = $gvs(eleSearch);
			
			var eleReplace = $(obj.elementIdReplaceValue);
			if(!eleReplace) return false;
			var replaceVal = $gvs(eleReplace);
			
			var searchFlags = ""
			if(obj.allInstances) searchFlags = searchFlags + 'g';
			if(obj.caseInsensitive) searchFlags = searchFlags + 'i';
		} else {
			if(obj.sourceValue == 'ReadFromCurrentRow') {
				var sv = this.getValue('G',field,rowNumber);
			} else {
				var eleS = $(obj.sourceElementId);
				if(!eleS) return false;
				var sv = $gvs(eleS);
			}
		}
		var eleT = '';
		var valC = ''
		this._batchChange = true;
		var flagOKtoChange = true;
		var flagChecked = true;
		var eleChk = '';
		var promptResult = true;
		var msg = '';
		var flagSuppressPrompt = false;
		if(obj.rowsToUpdate.toLowerCase() != 'allnewrecordrows') {
			for(var i = 1; i<=this._rowsInGrid;i++) {
				flagSuppressPrompt = false;
				if(obj.rowsToUpdate.toLowerCase() == 'checkedrows') {
					eleChk = $(this.gridId + '.V.R'+i+'.__ROWCHECKBOX');
					if(eleChk) flagChecked = eleChk.checked;
					else flagChecked = true;
				}
				valC = this.getValue('G',field,i);
				if(obj.onlyUpdateBlankFields) {
					if( (valC == '' || valC == '&nbsp;') )  flagOKtoChange = true;
					else flagOKtoChange = false;
				} else flagOKtoChange = true;

				if(obj.type == 'search') {
					sv = this._searchReplace(valC,searchVal,replaceVal,searchFlags);
				}
				if(sv == valC) flagSuppressPrompt = true;

				if(flagChecked && flagOKtoChange && obj.promptForConfirmation && valC != '' && !flagSuppressPrompt) {
					var msg = obj.confirmationMessage;
					msg = msg.replace('[row]','' + i);
					msg = msg.replace('[old]',valC);
					msg = msg.replace('[new]',sv);
					var promptResult = confirm(msg);
				} else {
					promptResult = true;
				}
				if(sv == valC) flagOKtoChange = false;

				if(flagOKtoChange && flagChecked && promptResult ) {
					this.setValue('G',field,i,sv);
					this._setRowState(i,true);
				}
			}
		}
		flagNewRecordRowsVisible = false;
		var ele = $(this.gridId + '.R-1');
		if(ele) flagNewRecordRowsVisible = $if(ele.style.display == 'none',false,true);
		promptResult = true;
		if(flagNewRecordRowsVisible) {
			if(obj.rowsToUpdate.toLowerCase() == 'allvisiblerows' || obj.rowsToUpdate.toLowerCase() == 'allnewrecordrows') {
				for(var i = 1; i<= this._newRowsInGrid; i++) {
					flagSuppressPrompt = false;
					valC = this.getValue('G',field,i*-1);
					if(obj.onlyUpdateBlankFields) {
						if( (valC == '' || valC == '&nbsp;') )  flagOKtoChange = true;
						else flagOKtoChange = false;
					} else flagOKtoChange = true;
			
					if(obj.type == 'search') {
						sv = this._searchReplace(valC,searchVal,replaceVal,searchFlags);
					}
					if(sv == valC) flagSuppressPrompt = true;
					if(flagOKtoChange && obj.promptForConfirmation && valC != '' && !flagSuppressPrompt) {
						var msg = obj.confirmationMessage;
						msg = msg.replace('[row]','' + i +' (new record)');
						msg = msg.replace('[old]',valC);
						msg = msg.replace('[new]',sv);
						var promptResult = confirm(msg);
					} else {
						promptResult = true;
					}

					if(sv == valC) flagOKtoChange = false;
					
					if(flagOKtoChange) {
						this.setValue('G',field,i*-1,sv);
						this._setRowState(i*-1,true);
					}
				}
			}
		}
		this._batchChange = false;
	},
	
	
	
	_searchReplace: function (string,search,replace,flags) {
	    var r = search;
	    r = r.replace(/[\\\.\^\$\*\+\?\{\}\[\]\(\)\|]/g,function(val){
	               return '\\'+val;
	          });
	    var y = string.replace(RegExp(r,flags),replace);
	    return y;
	},

	
	rowExpand: function(rowNum) {
		//if this row is being expanded for the fist time, the ajax callback generates the animation code in the response
		var withAnimation = false;
		var withAnimation = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		if(this.rowExpandMode == 'single') {
			for(var i = 1; i <= this._rowsInGrid; i++) {
				if(i != rowNum) this.rowCollapse(i);
			}
		}
	
		if($(this.gridId+'.R' + rowNum + '.__ROWEXPAND_SEP')) $(this.gridId+'.R' + rowNum + '.__ROWEXPAND_SEP').style.display = '';
		trEle = $(this.gridId+'.R' + rowNum + '.__ROWEXPAND_TR');
		if(withAnimation) {
			var ele2 = $(this.gridId+'.R' + rowNum + '.__ROWEXPAND_DIV')
			ele2.style.display = 'none';
			var ele2JS = '#' +$u.s.tran(this.gridId+'.R' + rowNum + '.__ROWEXPAND_DIV','.','\\.');
		}
		trEle.style.display = '';
		if(withAnimation) {
			if(this.animationMethod == 'slide') jQuery(ele2JS).slideToggle(this.animationSpeed);
			if(this.animationMethod == 'fade') jQuery(ele2JS).fadeToggle(this.animationSpeed);
		}
		if(this.rowExpandAutoRefresh != true) $sa(trEle,'A5RowExpanded','true');
		$(this.gridId +'.R' + rowNum + '.__ROWEXPANDER').src = this.rowCollapseIcon;
	},
		
	rowCollapse: function(rowNum) {
		if(!this._executeEvent('canRowCollapse',{rowNumber: rowNum})) return false;
		if($(this.gridId+'.R' + rowNum + '.__ROWEXPAND_SEP')) $(this.gridId+'.R' + rowNum + '.__ROWEXPAND_SEP').style.display = 'none';
		
		var flagAnimate = false;
		if(this.rowExpandAnimation) flagAnimate = this.rowExpandAnimation ;
		if(flagAnimate) {
			var ele2JS = '#' +$u.s.tran(this.gridId+'.R' + rowNum + '.__ROWEXPAND_DIV','.','\\.');
			var eleTR = this.gridId+'.R' + rowNum + '.__ROWEXPAND_TR';
			if(this.animationMethod == 'slide') jQuery(ele2JS).slideToggle(this.animationSpeed,function() {$(eleTR).style.display = 'none';} );
			if(this.animationMethod == 'fade') jQuery(ele2JS).fadeToggle(this.animationSpeed,function() {$(eleTR).style.display = 'none';} );
		} else {
			$(this.gridId+'.R' + rowNum + '.__ROWEXPAND_TR').style.display = 'none';
		}
		$(this.gridId +'.R' + rowNum + '.__ROWEXPANDER').src = this.rowExpandIcon;
		this._executeEvent('afterRowCollapse',{rowNumber: rowNum});
	},
	
	
	rowExpandToggle: function(rowNum) {
		var flagAnimate = false;
		if(this.rowExpandAnimation) flagAnimate = this.rowExpandAnimation ;
		
		var trEle = $(this.gridId+'.R' + rowNum + '.__ROWEXPAND_TR');
		if(trEle == false) return false;
		
		var rowIsDirty = false;		
		if(rowNum > 0) {
			rowIsDirty = this._dirtyRows[rowNum -1];
		} else {
			rowIsDirty = this._dirtyNewRows[(rowNum* -1) -1];
		}
		
		
		if(trEle.style.display == 'none') {
			if(!this._executeEvent('canRowExpand',{rowNumber: rowNum, isDirty: rowIsDirty})) return false;
			if($ga(trEle,'A5RowExpanded') == 'true') {
				this.rowExpand(rowNum,flagAnimate);
				this._executeEvent('afterRowExpand',{rowNumber: rowNum});
			} else {
				//we will put the expand in the response from the callback. 
				//var data = '__FormId=' + this.gridId + '&__FormAction=expandRow&_rowNumber='+ rowNum;
				//A5.ajax.callback(this.ajaxURL,data);
				this.rowExpand(rowNum);
				
				var keys = this._getRowKey(rowNum);
				var data = '_rowNumber='+rowNum +'&' + keys;
				this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'expandRow'})
				
				if(this.rowExpandAutoRefresh) {
					var eleRE = $(this.gridId + '.R' + rowNum + '.__ROWEXPAND_DIV');
					eleRE.innerHTML  = this.rowExpandWorkingMessage;
				}
				
				this._submitLow('expandRow',this.gridId,this.ajaxURL,data); 
				return false;
				
			}
		} else {
			this.rowCollapse(rowNum);			
		}
	
	},
	
	showRowExpandGrid: function(gridNum,rowNum) {
		var keys = this._getRowKey(rowNum);
		var data = '_gridNumber=' + gridNum +'&_rowNumber='+rowNum +'&' + keys;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'expandRow'})
		this._submitLow('expandRowGrid',this.gridId,this.ajaxURL,data); 
		return false;
	},
	
	
	alphabetSearch: function(searchId) {
		if(!this._executeEvent('canAlphabetButtonSearch',{})) return false;
		var data = '_searchId='+searchId + '&__dvWindow=' + this._detailViewWindowState;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'alphabetButtonSearch'})
		this._submitLow('Search_AlphabetButtons',this.gridId,this.ajaxURL,data); 
		return false;
	},
	
	editRow: function(rowNumber) {
		/*check if this.rowEditMode is 'rod-s' (row on demand, one row at a time)
		if so, then check if the currently edited row is dirty. if so, then warn and abort.
		*/
		
		var newRecordRowsVisible = true;
		var pEle = $(this.gridId + '.R-1');
		if(pEle) newRecordRowsVisible = $if(pEle.style.display == 'none', false,true);
		
		if(!this._executeEvent('canRowSwitchToEditable',{'rowNumber': rowNumber, 'field': '', 'newRecordRowsVisible' : newRecordRowsVisible})) return false;
		var data = '';
		
		if(this.rowEditMode == 'rod-s') {
			if($u.a.find(this._dirtyRows,true) != -1) {
				if(!this._confirmAction()) return false;
			}
			//Need to send back the data for the row that was in edit mode so that the server
			//can conver that row back to view mode.
			var rowInEditModeNum = $u.a.find(this._editModeRows,true);
			var dataArr = new Array();
			if(rowInEditModeNum != -1) {
				for(var i = 0; i < this.gridColumnInfo.length; i++) {
					dataArr.push(A5.ajax.buildURLParam('V.R' + (rowInEditModeNum+1) + '.' + this.gridColumnInfo[i].name ,this._originalValues[rowInEditModeNum][i]) );
				}
				data = dataArr.join('&');
			} 
			data = '_existingRowInEditMode=' + (rowInEditModeNum+1) + $if(data != '','&' + data, '');
			
			var stateInfo = $(this.gridId +'.STATEINFO').value;
			if(stateInfo!='') data=data +'&' + stateInfo;
		}
		
		var keys = this._getRowKey(rowNumber);
		data = '_rowNumber='+rowNumber +'&' + keys + $if(data != '','&' + data, '');
		data = $u.s.tran(data,'\n','%0D%0A');
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'editRow'})
		this._submitLow('EditRow',this.gridId,this.ajaxURL,data); 
		return false;
	},
	
	editField: function(rowNumber, field) {
		if(!this._executeEvent('canRowSwitchToEditable',{'rowNumber': rowNumber, 'field': field})) return false;
		var data = '';
		if(this.rowEditMode == 'rod-s') {
			if(!this._confirmAction()) return false;
			//Need to send back the data for the row that was in edit mode so that the server
			//can conver that row back to view mode.
			var rowInEditModeNum = $u.a.find(this._editModeRows,true);
			var dataArr = new Array();
			if(rowInEditModeNum != -1) {
				for(var i = 0; i < this.gridColumnInfo.length; i++) {
					dataArr.push(A5.ajax.buildURLParam('V.R' + (rowInEditModeNum+1) + '.' + this.gridColumnInfo[i].name ,this._originalValues[rowInEditModeNum][i]) );
				}
				data = dataArr.join('&');
			} 
			data = '_existingRowInEditMode=' + (rowInEditModeNum+1) + $if(data != '','&' + data, '');
			
			var stateInfo = $(this.gridId +'.STATEINFO').value;
			if(stateInfo!='') data=data +'&' + stateInfo;
		}
		var keys = this._getRowKey(rowNumber);
		data = '_rowNumber='+rowNumber +'&_FieldName='+field +'&' + keys + $if(data != '','&' + data, '');
		data = $u.s.tran(data,'\n','%0D%0A');
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'editField'})
		this._submitLow('EditField',this.gridId,this.ajaxURL,data); 
		return false;
	},

	editFieldDV: function(field) {
		//var data = '';
		//var rowNumber = this._detailViewRowNumber;
		//var keys = this._getRowKey(rowNumber);
		//data = '_rowNumber='+rowNumber +'&_FieldName='+field +'&' + keys + $if(data != '','&' + data, '');
		//data = $u.s.tran(data,'\n','%0D%0A');
		//this._submitLow('EditField',this.gridId,this.ajaxURL,data); 
		this.editDetailViewRecord(field);
		return false;
	},

	deleteRow: function(rowNumber) {
		if(!this._executeEvent('canRowDelete',{rowNumber: rowNumber})) return false;
		var classInst = this;
		A5.msgBox.show(this.messages.t_deleteRow,this.messages.deleteRow,'OC',function(action) { 
			if(action=='ok') {classInst._deleteRowWithoutConfirmation(rowNumber) };
		} );
	},
	
	_deleteRowLow: function(rowNumber) {
		//used to delete a row in a Grid with a Detail View, when Detail View is not currently shown.
		if(!this._executeEvent('canRowDelete',{rowNumber: rowNumber})) return false;
		var classInst = this;
		A5.msgBox.show(this.messages.t_deleteRow,this.messages.deleteRow,'OC',function(action) { 
			if(action=='ok') {classInst._deleteRowWithoutConfirmationLow(rowNumber) };
		} );
	},
	
	_deleteRowWithoutConfirmationLow: function(rowNumber) {
		//handler for _deleteRowLow()
		var data = '_actualRowsOnPage=' + this.actualRowsOnPage;
		var h = [];
		var ele = 0;
		for(var i = 1;i<=this._rowsInGrid;i++) {
			ele = $(this.gridId + '.R' + i);
			if(ele.style.display == 'none') h.push(i);
		}
		var data2 = h.join(',');
		alert('hidden rows:' + data2);
		data = data + '&_rowsAlreadyHidden=' + data2 + '&_rowsInGrid=' + this._rowsInGrid;
		this.ajaxCallback('G','all','__A5SystemDeleteRowLow','',data);
	},

	_deleteRowWithoutConfirmation: function(rowNum) {
			var data = '';
			//var regionIds = new Array();
			var regionKeys = new Array();
			//$sa(this.gridId + '.R' + (rowNum),'A5IsDirty','true');
			//regionIds.push(this.gridId + '.R' + (rowNum));
			regionKeys.push(this._getRowKey((rowNum)));	
			//data = this._harvestGrid(regionIds);
			var dataArr = new Array();
			for(var i = 0; i < this.gridColumnInfo.length; i++) {
				dataArr.push(A5.ajax.buildURLParam('old.V.R' + rowNum + '.' + this.gridColumnInfo[i].name ,this._originalValues[rowNum-1][i]) );
			}
			data = dataArr.join('&');
			var stateInfo = $(this.gridId +'.STATEINFO').value;
			if(stateInfo!='') data=data +'&' + stateInfo;
			regionKeys = regionKeys.join('&');
			if(regionKeys!='') data=data +'&' + regionKeys;
			data = '_rowSubmitted='+rowNum+'&__FormAction=DeleteRow&_rowNumber='+rowNum+'&__FormID=' + this.gridId + '&' + data;
			data = $u.s.tran(data,'\n','%0D%0A');
			this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'deleteRecord'})
			A5.ajax.callback(this.ajaxURL,data);
			return false;
	},

	cancelEditDetailViewRecord: function() {
		if(!this._executeEvent('canDetailViewSwitchFromEditable',{'rowNumber' : this._detailViewRow})) return false;	
		if(this._detailViewIsDirty) {
				if(!this._executeEvent('canDetailViewCancelEdits',{'rowNumber' : this._detailViewRow})) return false;	
				var classInst = this;
				A5.msgBox.show(this.messages.t_cancelEditRow,this.messages.cancelEditRow,'OC',function(action) { 
							if(action=='ok') {classInst._cancelEditDetailViewRecordWithoutConfirmation(true) };
				} );
			} else {
				this._cancelEditDetailViewRecordWithoutConfirmation(false);
		}
	},
	

	cancelEditRow: function(rowNumber) {
		if(!this._executeEvent('canRowSwitchFromEditable',{'rowNumber' : rowNumber})) return false;	
		if(this._dirtyRows[rowNumber-1]) {
			if(!this._executeEvent('canRowCancelEdits',{'rowNumber' : rowNumber})) return false;	
			var classInst = this;
			A5.msgBox.show(this.messages.t_cancelEditRow,this.messages.cancelEditRow,'OC',function(action) { 
						if(action=='ok') {classInst._cancelEditRowWithoutConfirmation(rowNumber, true) };
			} );
		} else {
			this._cancelEditRowWithoutConfirmation(rowNumber, false);
		}
	},

	_cancelEditRowWithoutConfirmation: function(rowNum, isDirty) {
		/*Do cancel edit row without confirmation*/
		//var keys = this._getRowKey(rowNumber);
		//var data = '_rowNumber='+rowNumber +'&' + keys;


		var data = '';
		//var regionIds = new Array();
		var regionKeys = new Array();
		//$sa(this.gridId + '.R' + (rowNum),'A5IsDirty','true');
		//regionIds.push(this.gridId + '.R' + (rowNum));
		regionKeys.push(this._getRowKey((rowNum)));	
		//data = this._harvestGrid(regionIds);
		var dataArr = new Array();
		for(var i = 0; i < this.gridColumnInfo.length; i++) {
			dataArr.push(A5.ajax.buildURLParam('V.R' + rowNum + '.' + this.gridColumnInfo[i].name ,this._originalValues[rowNum-1][i]) );
		}
		data = dataArr.join('&');
		var stateInfo = $(this.gridId +'.STATEINFO').value;
		if(stateInfo!='') data=data +'&' + stateInfo;
		regionKeys = regionKeys.join('&');
		if(regionKeys!='') data=data +'&' + regionKeys;
		data = '_rowIsDirty='+isDirty + '&_rowSubmitted='+rowNum+'&__FormAction=DeleteRow&_rowNumber='+rowNum+'&__FormID=' + this.gridId + '&' + data;
		data = $u.s.tran(data,'\n','%0D%0A');		
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'cancelEditRow'})
		this._submitLow('CancelEditRow',this.gridId,this.ajaxURL,data); 
		
		return false;
	},


	_cancelEditDetailViewRecordWithoutConfirmation: function(isDirty) {
		var rowNum = this._detailViewRow
		var data = '';
		var regionKeys = new Array();
		regionKeys.push(this._getRowKey((rowNum)));	
		var dataArr = new Array();
		var rowData = new Array();
		if(this.detailViewDataPreFetch) rowData = this._originalDVValues[rowNum-1];
		else rowData = this._originalDVValues[0];
		
		for(var i = 0; i < this.detailViewColumnInfo.length; i++) {
			dataArr.push(A5.ajax.buildURLParam('V.R' + rowNum + '.' + this.detailViewColumnInfo[i].name ,rowData[i]) );
		}
		data = dataArr.join('&');
		var stateInfo = $(this.gridId +'.STATEINFO').value;
		if(stateInfo!='') data=data +'&' + stateInfo;
		regionKeys = regionKeys.join('&');
		if(regionKeys!='') data=data +'&' + regionKeys;
		data = '_rowIsDirty='+isDirty + '&_rowSubmitted='+rowNum+'&_rowNumber='+rowNum+'&__FormID=' + this.gridId + '&' + data;
		data = $u.s.tran(data,'\n','%0D%0A');		
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'cancelEditDetailViewRecord'})
		this._submitLow('CancelEditDetailViewRecord',this.gridId,this.ajaxURL,data);
		//this is wrong because it was causing this bug: edit detail view, cancel. undo changes button had not gone disabled.
		//this._detailViewIsDirty = false;
		return false;
	},

	editDetailViewRecord: function() {
		var fieldName = '';
		if(typeof arguments[0] != 'undefined') fieldName = arguments[0];
		if(!this._executeEvent('canDetailViewSwitchToEditable',{'rowNumber': this._detailViewRow, 'field': fieldName})) return false;		
		
		var keys = this._getRowKey(this._detailViewRow);
		var data = '';
		data = '_fieldName=' + fieldName+'&_rowNumber='+this._detailViewRow +'&' + keys + $if(data != '','&' + data, '');
		data = $u.s.tran(data,'\n','%0D%0A');
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'editDetailViewRecord'})
		this._submitLow('EditDetailViewRecord',this.gridId,this.ajaxURL,data); 
		return false;
	},
	
	clientSideValidateField: function(part,colName,rowNum) {
		
		var prefix = '';
		if(part=='G') {
			var colInfo = this.gridColumnInfo;
			var colNum = this._colNumFromName(this._gridColNames,colName);
			if(rowNum < 0) {
				if(!this._dirtyNewRows[Math.abs(rowNum)-1]) return false;
			} else if(!this._dirtyRows[rowNum-1]) return false;
			
		} else {
			var colInfo = this.detailViewColumnInfo;
			var colNum = this._colNumFromName(this._detailViewColNames,colName);
			var prefix = '.D';
		}
		if(typeof colInfo[colNum] != 'undefined') {
		
			if(typeof colInfo[colNum].validate != 'undefined') {
				var curValue = this.getValue(part,colName,rowNum);
				var result = colInfo[colNum].validate.call(this,curValue,colName,rowNum);
				if(typeof result == 'string') {
					this.setErrors([{id: this.gridId + prefix +'.V.R' + rowNum + '.' + colName, message: result}]);
				} else {
					this.clearErrors([this.gridId + prefix + '.V.R' + rowNum + '.' + colName]);
				}
			}
		}

	},
	
	_testAlreadySubmitting: function() {
		
		//prevent user from clicking submit while an existing submit is executing
		if(typeof this._currentSubmitTimeStamp == 'object') {
			var cTime = new Date();
			if(cTime.getTime() - this._currentSubmitTimeStamp.getTime() < this._submitTestInterval) return true;
		}
		this._currentSubmitTimeStamp = new Date();
		return false;
	
	},
	

	validateGridRow: function(rowNum) {
		this.submitGridPartRow(rowNum,true);
	},

	validateGridField: function(rowNum,fieldName) {
		this.submitGridPartRow(rowNum,true,fieldName);
	},
	
	submitGridPartRow: function(rowNum) {
		/*
		Submits a single dirty row. Contrast with .submitGridPart() which submits all dirty rows at once.
		*/
		if(this._testAlreadySubmitting()) return false;
		var fieldToValidate = '';
		var validateMode = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		fieldToValidate = typeof arguments[2] != 'undefined' ? arguments[2] : '';
		if(validateMode != true) {
			if(!this._executeEvent('canRowSubmit',{rowNumber: rowNum})) return false;
		}
		
		if(rowNum < 0) {
			if(this._dirtyNewRows[Math.abs(rowNum)-1]) {
				var data = '';
				var regionIds = new Array();
				$sa(this.gridId + '.R' + (rowNum),'A5IsDirty','true');
				regionIds.push(this.gridId + '.R' + (rowNum));
				data = this._harvestGrid(regionIds);
				var stateInfo = $(this.gridId +'.STATEINFO').value;
				if(stateInfo!='') data=data +'&' + stateInfo;
				var eventName = 'saveGridDataNewRow';
				if(validateMode) {
					eventName = 'validateGridDataNewRow';
					if(fieldToValidate != '') {
						eventName = 'validateGridDataNewRowField&__fieldToValidate=' + fieldToValidate;
					}
				}
				
				data = '_rowsInGrid='+this._rowsInGrid+'&_rowSubmitted='+rowNum+'&__FormAction='+eventName+'&__FormID=' + this.gridId + '&' + data;
				data = $u.s.tran(data,'\n','%0D%0A');
				
				var eventName2 = 'submitGridNewRow';
				if(validateMode) {
					eventName2 = 'validateGridNewRow';
					if(fieldToValidate != '') {
						eventName2 = 'validateNewGridField_'+fieldToValidate;
					}
				}
				
				this._executeEvent('beforeAjaxCallback',{ajaxEvent: eventName2})
				A5.ajax.callback(this.ajaxURL,data);
				return false;
			}		
		} else {
			if(this._dirtyRows[rowNum-1]) {
				var data = '';
				var regionIds = new Array();
				var regionKeys = new Array();
				$sa(this.gridId + '.R' + (rowNum),'A5IsDirty','true');
				regionIds.push(this.gridId + '.R' + (rowNum));
				regionKeys.push(this._getRowKey((rowNum)));	
				data = this._harvestGrid(regionIds);
				var stateInfo = $(this.gridId +'.STATEINFO').value;
				if(stateInfo!='') data=data +'&' + stateInfo;
				regionKeys = regionKeys.join('&');
				if(regionKeys!='') data=data +'&' + regionKeys;
				var eventName = 'saveGridDataRow';
				if(validateMode) {
					eventName = 'validateGridDataRow';
					if(fieldToValidate != '') {
						eventName = 'validateGridDataRowField&__fieldToValidate='+fieldToValidate;
					}
				}
				
				data = '_rowSubmitted='+rowNum+'&__FormAction='+eventName+'&__FormID=' + this.gridId + '&' + data;
				data = $u.s.tran(data,'\n','%0D%0A');
				
				var eventName2 = 'submitGridRow';
				if(validateMode) {
					eventName2 = 'validateGridRow';
					if(fieldToValidate != '') {
						eventName2 = 'validateGridField_'+fieldToValidate;
					}
				}
				
				this._executeEvent('beforeAjaxCallback',{ajaxEvent: eventName2})
				A5.ajax.callback(this.ajaxURL,data);
				return false;
			}
		}
	},
	
	validateGrid: function() {
		this.submitGridPart(false,'', true);
	},
	
	submitGridPart: function() {
		if($u.a.find(this._dirtyRows,true) == -1 && $u.a.find(this._dirtyNewRows,true) == -1) return false;
		/*currently if the user wants to confirm before submit, the function is called with arguments
		e.g. GRID1_GridObj.submitGridPart(true,'Are you sure you want to save');
		This information should be put in the GridHelper object at some point.
		*/
		if(this._testAlreadySubmitting()) return false;
		var validateMode = typeof arguments[2] != 'undefined' ? arguments[2] : false;
		if(validateMode != true) {
				if(!this._executeEvent('canGridSubmit',{})) return false;
		}
		
		
		if(typeof arguments[0] != 'undefined') {
			if(arguments[0] == true) {
				var message = typeof arguments[1] != 'undefined' ? arguments[1] : '';
				if(message == '') message = 'Submit changes?';
				var result = confirm(message);
				if(!result) return false;
			}
		}
		
		var data = '';
		var regionIds = new Array();
		var regionKeys = new Array();
		for(var i=1;i<=this._rowsInGrid;i++) {
			if(this._dirtyRows[i-1]) {
				$sa(this.gridId + '.R' + i,'A5IsDirty','true');
				regionIds.push(this.gridId + '.R' + i);
				regionKeys.push(this._getRowKey(i));	
			}
		}
		
		for(var i=1;i<=this._newRowsInGrid;i++) {
			if(this._dirtyNewRows[i-1]) {
				$sa(this.gridId + '.R-' + i,'A5IsDirty','true');
				regionIds.push(this.gridId + '.R-' + i);
			}
		}

		
		
		data = this._harvestGrid(regionIds);
		var stateInfo = $(this.gridId +'.STATEINFO').value;
		if(stateInfo!='') data=data +'&' + stateInfo;
		regionKeys = regionKeys.join('&');
		if(regionKeys!='') data=data +'&' + regionKeys;
		var actionName = 'saveGridData';
		if(validateMode) actionName = 'validateGridData';
		data = '_rowsInGrid='+this._rowsInGrid + '&__FormAction='+actionName+'&__FormID=' + this.gridId + '&' + data;
		
		data = $u.s.tran(data,'\n','%0D%0A');
		
		var eventName = 'submitGrid';
		if(validateMode) eventName = 'validateGrid';
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: eventName})
		A5.ajax.callback(this.ajaxURL,data);
		return false;
	},
	
	
	_currentGridQuery: function() {
		var data = new Array();
		data.push(A5.ajax.buildURLParam('_gridCurrentFilter',this._gridFilter));
		data.push(A5.ajax.buildURLParam('_gridCurrentOrder',this._gridOrder));
		data.push(A5.ajax.buildURLParam('_gridCurrentArguments',this._gridArguments ));
		data.push(A5.ajax.buildURLParam('_gridCurrentDBType',this._gridDBType));		
		return data.join('&');
	},
	
	exportData: function() {
		var exportFormat = typeof arguments[0] != 'undefined' ? arguments[0] : 'Excel';
		var maxRecords = typeof arguments[1] != 'undefined' ? arguments[1] : '10000';
		var exportHiddenFields = typeof arguments[2] != 'undefined' ? arguments[2] : 'Y';
		var useColumnHeadings = typeof arguments[3] != 'undefined' ? arguments[3] : 'Y';
		var moreData = '&_exportHiddenFields=' + exportHiddenFields + '&_useColHeadings=' + useColumnHeadings;
		var callbackData = '_csfilename=%3cDefault%3e&_exportDataType='+exportFormat+'&_recordSelection=Records%20in%20current%20query&_exportSource=1&_maxRecords='+maxRecords+'&_zip=N' + moreData;
		this.ajaxCallback('G',1,'__a5systemfileExport','',callbackData);
	},
	
	filterCheckedRows: function() {
		this.ajaxCallback('G',1,'__a5systemFilterCheckedRows','','');
	},
	
	ajaxCallback: function(part,rowNum,xbasicFunction) {
		part = part.toUpperCase().substring(0,1);
		var callbackURL = typeof arguments[3] != 'undefined' ? arguments[3] : '';	
		var otherData = typeof arguments[4] != 'undefined' ? arguments[4] : '';

		//rowNum can be 1, 2, 3, etc. or 1:none, 3:all etc

		//we want tempRowNum to be 1, 2, none, all so we can pass that into _getData(), and currentRowNum to be the actual current row number
		//if you pass in say 3, then tempRowNum and currentRowNum are both 3
		//but if you pass in 3:all, then tempRowNum = 'all' and currentRowNum = 3
		if(isNaN(rowNum)) {
			if(rowNum.toLowerCase() == 'all' || rowNum.toLowerCase() == 'all:all' ) {
				var tempRowNum = 'all';
				var currentRowNum = this._selectedRow;

			} else if (rowNum.toLowerCase() == 'none' || rowNum.toLowerCase() == 'none:none' ) {
				var tempRowNum = 'none';
				var currentRowNum = this._selectedRow;
			} else {
				if(rowNum.indexOf(':') == -1 ) {
				    var tempRowNum = 'all';
				    var currentRowNum = this._selectedRow;
				} else {
				    var rowNumC = new String(rowNum);
				    var currentRowNum = rowNumC.split(':')[0];
				var	tempRowNum = rowNumC.split(':')[1];
				};
			}
		} else {
			var tempRowNum = rowNum;
			var currentRowNum = rowNum;
		}

		var data = this._getData(part,tempRowNum);
		data = data + '&_part=' + part;
		data = data + '&'+this._currentGridQuery();
		data = data + '&_selectedGridPartRow=' + this._selectedRow;
				

		if(callbackURL == '') {
			data = '_XbasicFunction='+xbasicFunction+'&_currentRow='+currentRowNum+'&__FormAction=GenericAjaxCallback&__FormID=' + this.gridId+data;
			callbackURL = this.ajaxURL;
		} else {
			data = '_Action='+xbasicFunction+'&_currentRow='+currentRowNum+'&__FormAction=GenericAjaxCallback&__FormID=' + this.gridId+data;
		}
		if(otherData!='') data=data + '&' + otherData;
		A5.ajax.callback(callbackURL,data);
		return false;
	},	
	
	
	
	
	_getData: function(part,rowNum) {
		var flagIncludeStateInfo = typeof arguments[2] != 'undefined' ? arguments[2] : true;
		part = part.toUpperCase().substring(0,1);
		var data = '';
		var gridData = '';
		var regionKeys = new Array();
		if(part=='D') {
			rowNum = this._detailViewRow;
			regionKeys.push(this._getRowKey((rowNum)));	
			
			if(this.detailViewEditMode == '') {
				//detailview is not editable
			} else {
				//detailview is editable
				if(this._detailViewIsDirty) {
					//if detailview is dirty
					gridData = A5.form.harvest(this.gridId +'.DETAILVIEW_PART.FORM',true,true);
				} else {
					//if detailview is clean
					var dataArr = new Array();
					if(rowNum < 0) {
						for(var i = 0; i < this.detailViewColumnInfo.length; i++) {
							dataArr.push(A5.ajax.buildURLParam('old.V.R' + '1' + '.' + this.detailViewColumnInfo[i].name ,this._newDVValues[i]) );
							dataArr.push(A5.ajax.buildURLParam('V.R' + '1' + '.' + this.detailViewColumnInfo[i].name ,this._newDVValues[i]) );
						}

					} else {
						if(this.detailViewDataPreFetch) {
							for(var i = 0; i < this.detailViewColumnInfo.length; i++) {
								dataArr.push(A5.ajax.buildURLParam('old.V.R' + '1' + '.' + this.detailViewColumnInfo[i].name ,this._originalDVValues[rowNum-1][i]) );
								dataArr.push(A5.ajax.buildURLParam('V.R' + '1' + '.' + this.detailViewColumnInfo[i].name ,this._originalDVValues[rowNum-1][i]) );
							}
						} else {
							for(var i = 0; i < this.detailViewColumnInfo.length; i++) {
								dataArr.push(A5.ajax.buildURLParam('old.V.R' + '1' + '.' + this.detailViewColumnInfo[i].name ,this._originalDVValues[0][i]) );
								dataArr.push(A5.ajax.buildURLParam('V.R' + '1' + '.' + this.detailViewColumnInfo[i].name ,this._originalDVValues[0][i]) );
							}
						}
					}
					gridData = dataArr.join('&');
					gridData = gridData +'&_selectedGridRow=' + this._selectedRow;
				}
			}
		} else if (part == 'S') {
			gridData = A5.form.harvest(this.gridId +'.SEARCH_PART.FORM',true,true);
		
		} else {
			//grid part
			if(typeof rowNum == 'string') {
				if(rowNum.toLowerCase()=='all') {
					var regionIds = new Array();
					var dataArr = new Array();
					for(var i = 1; i <= this._rowsInGrid; i++) {
						regionKeys.push(this._getRowKey(i));
						if(this.rowEditMode != '') {
							if(this._dirtyRows[i-1]) {
								//row is dirty
								regionIds.push(this.gridId + '.R' + (i));
							} else {
								//row is clean
								for(var j = 0; j < this.gridColumnInfo.length; j++) {
									dataArr.push(A5.ajax.buildURLParam('V.R' + i + '.' + this.gridColumnInfo[j].name ,this._originalValues[i-1][j]) );
									dataArr.push(A5.ajax.buildURLParam('old.V.R' + i + '.' + this.gridColumnInfo[j].name ,this._originalValues[i-1][j]) );
								}
							}
						}
					}
					if(this.rowEditMode != '') {
						for(var i = 1; i <= this._newRowsInGrid; i++) {
							if(this._dirtyNewRows[i-1]) {
								//new row is dirty
								regionIds.push(this.gridId + '.R' + (i*-1));
							} else {
								//new row is clean
								for(var j = 0; j < this._newValues.length; j++) {
									dataArr.push(A5.ajax.buildURLParam('V.R-' + i + '.' + this.gridColumnInfo[j].name ,this._newValues[j]) );
									dataArr.push(A5.ajax.buildURLParam('old.V.R-' + i + '.' + this.gridColumnInfo[j].name ,this._newValues[j]) );
								}
							}
						}
					}
					if(regionIds.length > 0) gridData = this._harvestGrid(regionIds);
					if(dataArr.length > 0) gridData = gridData + $if(gridData != '', '&', '') + dataArr.join('&');
				} 
			} else {
				var rowIsDirty = false;
				if(rowNum < 0) rowIsDirty = this._dirtyNewRows[Math.abs(rowNum) -1];
				else rowIsDirty = this._dirtyRows[rowNum-1];
				
				if(rowNum > 0 ) regionKeys.push(this._getRowKey((rowNum)));	
				if(this.rowEditMode != '') {
					if(rowIsDirty) {
						//editable row is dirty
						var regionIds = new Array();
						regionIds.push(this.gridId + '.R' + (rowNum));
						gridData = this._harvestGrid(regionIds);			
					} else {
						//editable row is clean
						var dataArr = new Array();
						if(rowNum > 0) {
							for(var i = 0; i < this.gridColumnInfo.length; i++) {
								dataArr.push(A5.ajax.buildURLParam('V.R' + rowNum + '.' + this.gridColumnInfo[i].name ,this._originalValues[rowNum-1][i]) );
								dataArr.push(A5.ajax.buildURLParam('old.V.R' + rowNum + '.' + this.gridColumnInfo[i].name ,this._originalValues[rowNum-1][i]) );								
							}
						} else {
							//new row is clean
							for(var i = 0; i < this._newValues.length; i++) {
								dataArr.push(A5.ajax.buildURLParam('V.R' + rowNum + '.' + this.gridColumnInfo[i].name ,this._newValues[i]) );
								dataArr.push(A5.ajax.buildURLParam('old.V.R' + rowNum + '.' + this.gridColumnInfo[i].name ,this._newValues[i]) );								
							}
							
						}
						gridData = dataArr.join('&');
					}
				}
			}
		}
		
		regionKeys = regionKeys.join('&');
		var stateInfo = '';
		if(flagIncludeStateInfo) stateInfo = $(this.gridId +'.STATEINFO').value;
				
		
		if(regionKeys!='') data=data +'&' + regionKeys;
		if(gridData!='') data=data +'&' + gridData;
		if(stateInfo!='') data=data +'&' + stateInfo;
		var stateInfo2 = this.getStateInfo();
		if(stateInfo2 != '') data = data + '&' + stateInfo2;
		
		data = data + '&' + this.getCheckedRows();
		data = $u.s.tran(data,'\n','%0D%0A');
		return data;
	
	},
	
	harvestColumn: function(colName) {
		var delim = typeof arguments[1] != 'undefined' ? arguments[1] : ',';
		colName = colName.toUpperCase();
		var dataArr = [];
		var rEle = '';
		for(var i = 1; i <= this._rowsInGrid; i++) {
			rEle = $(this.gridId + '.R' + i);
			if(rEle) {
				if(rEle.style.display == '') {
					dataArr.push(this.getValue('G',colName,i));
				}
			}
		};
		var data = dataArr.join(delim);
		return data;	
	},
	
	getValue: function(part,name,row) {
		return this._getValue(part,name,row);
	},
	
	_hideSnakingColumnFieldLabels: function() {
		var ele = '';
		var indx = 0;
		for(var i= 0; i < this.gridColumnInfo.length; i++) {
			for(j = 1; j <= this._rowsInGrid; j++) {
				indx = $u.a.find(this._snakingRowsInFirstColumn,''+j);
				if(indx == -1) {
					ele = $(this.gridId + '.LBL.R' + j + '.' + this.gridColumnInfo[i].name).parentNode;
					if(ele) ele.style.display = 'none';
				}
			}
		}
	},
	
	
	_colNumFromName: function(colNames, colName) {
		var colNum = $u.a.find(colNames,colName);
		if(colNum == -1) colNum = $u.a.find(colNames,colName+'[]');
		return colNum;
	},
	
	_getValue: function(part,name,row) {
		part = part.toUpperCase();
		name = name.toUpperCase();
		var colNum = 0;
		var colType = '';
		
		if(part=='D') {
			colNum = this._colNumFromName(this._detailViewColNames,name);
			if(colNum == -1) return false;
			var dataType = this.detailViewColumnInfo[colNum].dataType;
			dataType = dataType.toUpperCase();
			if(colNum > -1) {
				name = this._detailViewColNames[colNum];
				colType = this.detailViewColumnInfo[colNum].type.split(',')[0];
				if(this._detailViewIsDirty) {
					if(colType != 'label' && colType != 'label-html'  && colType != 'link'  && colType != 'img' ) 	{
						//search by name
						var val = $gvs('V.R' + '1' + '.' + name, $(this.gridId + '.DETAILVIEW_PART.FORM'));
						if(val == $ga('V.R' + '1' + '.' + name, 'A5WatermarkText', $(this.gridId + '.DETAILVIEW_PART.FORM'))[0]) val = '';
						if(typeof dataType != 'undefined') { if(dataType == 'L') val = $u.s.toBool(val);}
						return val;
					}					
				}
				//colNum was found but DV is not dirty, OR control is a RO control - so use orig val array
				if(this._detailViewRow < 0) {
					if(colType == 'link') return this._newDVValues[colNum][0];
					else {
						var val = this._newDVValues[colNum];
						if(typeof dataType != 'undefined') { if(dataType == 'L') val = $u.s.toBool(val);}
						return val;
					}
				} else {
					if(this.detailViewDataPreFetch) {
						if(colType == 'link') return this._originalDVValues[this._detailViewRow -1][colNum][0];
						else {
							var val = this._originalDVValues[this._detailViewRow -1][colNum];
							if(typeof dataType != 'undefined') { if(dataType == 'L') val = $u.s.toBool(val);}
							return val;
						}
					} else {
						if(this._originalDVValues[0]) {
							if(colType == 'link') return this._originalDVValues[0][colNum][0];
							else {
								var val = this._originalDVValues[0][colNum];
								if(typeof dataType != 'undefined') { if(dataType == 'L') val = $u.s.toBool(val);}
								return val;
							}
						} else {
							var val =$gvs(this.gridId + '.D.V.R' + '1' + '.' + name);
							if(typeof dataType != 'undefined') { if(dataType == 'L') val = $u.s.toBool(val);}
							return val;
						}
					}
				}					
			} else {
				//field not found in column info - search by id
				var val = $gvs(this.gridId + '.D.V.R' + '1' + '.' + name);
				if(val == $ga(this.gridId + '.D.V.R' + '1' + '.' + name, 'A5WatermarkText')) val = '';
				if(typeof dataType != 'undefined') { if(dataType == 'L') val = $u.s.toBool(val);}
				return val;
			}
		} else if(part=='G') {
			var dataType = 
			
			colNum = this._colNumFromName(this._gridColNames,name);
			if(colNum == -1) return false;
			var dataType = this.gridColumnInfo[colNum].dataType;
			dataType = dataType.toUpperCase();
			if(colNum > -1) {
				name = this._gridColNames[colNum];
				colType = this.gridColumnInfo[colNum].type.split(',')[0];
				var isDirty = false;
				if(row <0) {
					if(this._dirtyNewRows[Math.abs(row)-1]) isDirty = this._dirtyNewRows[Math.abs(row)-1];
				} else {
					if(this._dirtyRows[(row)-1]) isDirty = this._dirtyRows[(row)-1];
				}
				if(isDirty) {
					if(colType != 'label' && colType != 'label-html' && colType != 'link'  && colType != 'img' ){
						var val = $gvs('V.R' + row + '.' + name, $(this.gridId + '.R' + row));
						if(val == $ga('V.R' + row + '.' + name, 'A5WatermarkText', $(this.gridId + '.R' + row))[0]) val = '';
						if(typeof dataType != 'undefined') {
							if(dataType == 'L') val = $u.s.toBool(val);
						}
						return val;
					}
				}
				//colNum was found but grid is not dirty, OR control is a RO control - so use orig val array
				if(this._originalValues[row -1] && this.rowEditMode != ''  ) {
					if(colType == 'link') return this._originalValues[row -1][colNum][0];
					else {
						var val = this._originalValues[row -1][colNum];
						
						if(typeof dataType != 'undefined') {
							if(dataType == 'L') val = $u.s.toBool(val);
						}
						return val;
						
					}
				} else {
					var val = $gvs(this.gridId + '.V.R' + row + '.' + name);
					if(val == $ga(this.gridId + '.V.R' + row + '.' + name, 'A5WatermarkText')) val = '';
					val = val.replace(/<span[^>]+A5HL="Y">([^<]+)<\/span>/gi,'$1');
					if(typeof dataType != 'undefined') {
						if(dataType == 'L') val = $u.s.toBool(val);
					}
					return val;
				}
				
			} else {
				var val = $gvs(this.gridId + '.V.R' + row + '.' + name);
				if(val == $ga(this.gridId + '.V.R' + row + '.' + name, 'A5WatermarkText')) val = '';
				if(typeof dataType != 'undefined') {
					if(dataType == 'L') val = $u.s.toBool(val);
				}
				return val;
			}
			
		} else if(part=='S') {
			var val = $gvs('S.' +  name,$(this.gridId + '.SEARCH_PART.FORM'));
			if(val == $ga(this.gridId +'.S.' +  name, 'A5WatermarkText')) val = '';
			return val;
		}
	},	
	
	
	_setCellStyles: function(rowNum,style) {
			var tbele = $(this.gridId + '.R' + rowNum);
			for(var i=0; i < tbele.rows.length; i++) {
				for(var j=0; j < tbele.rows[i].cells.length; j++) {
					var s = $gs(tbele.rows[i].cells[j]);
					s = $u.s.rTrim(s,';') + ';' + style;
					$ss(tbele.rows[i].cells[j],s);
				}
			}
	},
	

	_addCellClassNames: function(rowNum,className) {
		var tbele = $(this.gridId + '.R' + rowNum);
		for(var i=0; i < tbele.rows.length; i++) {
			for(var j=0; j < tbele.rows[i].cells.length; j++) {
				$acn(tbele.rows[i].cells[j],className);
			}
		}
	},
	
	_removeCellClassNames: function(rowNum,className) {
		var tbele = $(this.gridId + '.R' + rowNum);
		for(var i=0; i < tbele.rows.length; i++) {
			for(var j=0; j < tbele.rows[i].cells.length; j++) {
				$rcn(tbele.rows[i].cells[j],className);
			}
		}
	},
	
	setValue: function(part,name,row,value) {
		this._setValue(part,name,row,value);
	},
	
	_setValue: function(part,name,row,value) {
		name = name.toUpperCase();
		part = part.toUpperCase();
		var colNum = 0;
		var colType = '';
		var ele = false;
		var honorChange = typeof arguments[4] == 'boolean' ? arguments[4] : true;
		var curValue = '';
		if(part=='D') {
			honorChange = typeof value == 'boolean' ? value : true;
			//this was an attempt to make 'D' syntax work even if a row was supplied - but it fails
			//if(typeof value == 'undefined') value = row;
			value = row;
			colNum = this._colNumFromName(this._detailViewColNames,name);
			//if(value == $gvs('V.R1.'+name,$(this.gridId+'.DETAILVIEW_PART.FORM'))) honorChange = false;
			if(colNum > -1) {
				name = this._detailViewColNames[colNum];
				colType = this.detailViewColumnInfo[colNum].type.split(',')[0];
				//Make the value html safe
				if(colType == 'label' || colType == 'link') {
					if(value.constructor == Array) value[0] = String(value[0]).replace(/\&/g,'&amp;');
					else value = String(value).replace(/\&/g,'&amp;');
					if(colType == 'label'){
						if(this.detailViewColumnInfo[colNum].displayFormat == 'plain'){
							value = value.replace(/\</g,'&lt;');
							value = value.replace(/\>/g,'&gt;');
							value = value.replace(/\n/g,'<br/>');
						}
					}
				}				
				if(typeof this._fieldHelpers_DV[name] != 'undefined'){
					this._fieldHelpers_DV[name].setValue(value,this.gridId+'.D.V.R1.'+name);
					ele = $(this.gridId+'.D.V.R1.'+name);
				} else if(colType == 'label' || colType == 'label-html'  || colType == 'link'  || colType == 'img'){
					$svs(this.gridId+'.D.V.R1.'+name,value);
					ele = $(this.gridId+'.D.V.R1.'+name);
				} else if(colType == 'popup-rte'){
					$svs('V.R1.'+name,value,$(this.gridId+'.DETAILVIEW_PART.FORM'));
					$(this.gridId+'.V.R'+row+'.'+name+'.DISPLAY').innerHTML = value;
				} else if(colType == 'rte'){
					$svs('V.R1.'+name,value,$(this.gridId+'.DETAILVIEW_PART.FORM'));
					var rteObj = window[this.gridId + '_' + name + '_RTEObj'];
					if(typeof rteObj._rteObj != 'undefined') rteObj._rteObj.setHTML(value);
					else rteObj.setHTML(value);
				} else{
					$svs('V.R1.'+name,value,$(this.gridId+'.DETAILVIEW_PART.FORM'));
				}
			} else {
				$svs('V.R1.'+name,value,$(this.gridId+'.DETAILVIEW_PART.FORM'));
			}
			if(!ele && honorChange){
				ele = $n('V.R1.'+name);
				ele = $cetp(ele,$(this.gridId+'.DETAILVIEW_PART.FORM'));
				if(ele){
					for(var i=0;i<ele.length;i++) $e.execute(ele[i],'change');
				}
			} else if(honorChange) $e.execute(ele,'change');
		} else if(part=='G') {
			colNum = this._colNumFromName(this._gridColNames,name);
			//if(value == $gvs('V.R'+row+'.'+name,$(this.gridId+'.R'+row))) honorChange = false;

			if(colNum > -1) {
				name = this._gridColNames[colNum];
				colType = this.gridColumnInfo[colNum].type.split(',')[0];
				//Make the value html safe
				if(colType == 'label' || colType == 'link') {
					if(value.constructor == Array) value[0] = String(value[0]).replace(/\&/g,'&amp;');
					else value = String(value).replace(/\&/g,'&amp;');
					if(colType == 'label'){
						if(this.gridColumnInfo[colNum].displayFormat == 'plain'){
							value = value.replace(/\</g,'&lt;');
							value = value.replace(/\>/g,'&gt;');
							value = value.replace(/\n/g,'<br/>');
						}
					}
				}				

				if(typeof this._fieldHelpers_G[name] != 'undefined'){
					this._fieldHelpers_G[name].setValue(value,this.gridId+'.V.R'+row+'.'+name);
					ele = $(this.gridId+'.V.R'+row+'.'+name);
				} else if(colType == 'label' || colType == 'label-html' || colType == 'link'  || colType == 'img'){
					$svs(this.gridId+'.V.R'+row+'.'+name,value);
					ele = $(this.gridId+'.V.R'+row+'.'+name);
				} else if(colType == 'popup-rte'){
					$svs('V.R'+row+'.'+name,value,$(this.gridId+'.R'+row));
					$(this.gridId+'.V.R'+row+'.'+name+'.DISPLAY').innerHTML = value;
				} else{
					$svs('V.R'+row+'.'+name,value,$(this.gridId+'.R'+row));
				}
			} else {
				$svs('V.R'+row+'.'+name,value,$(this.gridId+'.R'+row));
			}
			if(!ele && honorChange){
				ele = $n('V.R'+row+'.'+name);
				ele = $cetp(ele,$(this.gridId+'.R'+row));
				if(ele){
					for(var i=0;i<ele.length;i++) $e.execute(ele[i],'change');
				}
			} else if(honorChange) {
				$e.execute(ele,'change');
			}
		} else if(part=='S') {
			honorChange = typeof value == 'boolean' ? value : true;
			value = row; 
			//if(value == $gvs('S.'+name,$(this.gridId+'.SEARCH_PART.FORM'))) honorChange = false;
			$svs('S.'+name,value,$(this.gridId+'.SEARCH_PART.FORM'));
			ele = $n('S.'+name);
			ele = $cetp(ele,$(this.gridId+'.SEARCH_PART.FORM'));
			if(ele && honorChange){
				for(var i=0;i<ele.length;i++) $e.execute(ele[i],'change');
			}
		}
	},	
	
	_harvestGrid: function(regionID){
		var nameSpace = typeof arguments[1] != 'undefined' ? arguments[1] : '';
		if (nameSpace != '') nameSpace = nameSpace + '.';
		var rObj = new Array();
		if(typeof regionID == 'object' && regionID.length){
			for(var i=0;i<regionID.length;i++) rObj[rObj.length] = $(regionID[i]);
		} else{
			rObj = [$(regionID)];
		}
		var val = '';
		var rowNum = 0;
		var colNum = 0;
		var eles = new Object();
		var valArr = new Array();
		var curVal = new Array();
		var usedNames = new Array();
		var dirtyRegions = new Array();
		var dirtyValues = new Array();
		var isDirty = false;
		var curOriginalVals = 0;
		if(this.rowEditMode != '') {
			for(var i=0;i<rObj.length;i++){
				dirtyRegions[dirtyRegions.length] = rObj[i].id;
				rowNum = Number(rObj[i].id.split('.')[1].substr(1));
				if(rowNum < 0) {
					curOriginalVals = this._newValues;
				} else {
					rowNum = rowNum -1;
					if(this._originalNullValues.length > 0) valArr.push(A5.ajax.buildURLParam('__Nulls_'+(rowNum+1),this._originalNullValues[rowNum].toString()));
					curOriginalVals = this._originalValues[rowNum];
				}
				eles = rObj[i].getElementsByTagName('input');
				//if grid has arguments that were prompted for at runtime curOriginalVals could be undefined
				if(typeof curOriginalVals == 'undefined') return false;
				
				for(var j=0;j<eles.length;j++){
					if(eles[j].getAttribute('A5HarvestIgnore') != 'true' && eles[j].id.split('.')[0] == this.gridId){
						colNum = this._colNumFromName(this._gridColNames,eles[j].name.split('.')[2]);
						if(eles[j].type.toLowerCase() == 'radio'){
							if($u.a.find(usedNames,eles[j].name) == -1){
								usedNames[usedNames.length] = eles[j].name;
								if(colNum > -1) valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,curOriginalVals[colNum]);
								isDirty = eles[j].getAttribute('A5IsDirty') == 'true' ? true : false;
								if(isDirty) dirtyValues[dirtyValues.length] = eles[j].name;
								valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,$gvs($n(eles[j].name),eles[j].parentNode));
							}
						} else if(eles[j].type.toLowerCase() == 'checkbox'){
							if($u.a.find(usedNames,eles[j].name) == -1){
								usedNames[usedNames.length] = eles[j].name;
								if(colNum > -1) valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,curOriginalVals[colNum]);
								isDirty = eles[j].getAttribute('A5IsDirty') == 'true' ? true : false;
								if(isDirty) dirtyValues[dirtyValues.length] = eles[j].name;
								valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,$gvs($n(eles[j].name),eles[j].parentNode));
							}

						} else if(eles[j].type.toLowerCase() == 'text' || eles[j].type == 'hidden' || eles[j].type == 'password'  || eles[j].type == ''){
							if(colNum > -1) valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,curOriginalVals[colNum]);
							isDirty = eles[j].getAttribute('A5IsDirty') == 'true' ? true : false;
							if(isDirty) dirtyValues[dirtyValues.length] = eles[j].name;
							val = $gvs(eles[j]);
							if(val == eles[j].getAttribute('A5WatermarkText')) val = '';
							valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,val);
						}
					}
				}
				eles = rObj[i].getElementsByTagName('select');
				for(var j=0;j<eles.length;j++){
					if(eles[j].getAttribute('A5HarvestIgnore') != 'true' && eles[j].id.split('.')[0] == this.gridId){
						colNum = this._colNumFromName(this._gridColNames,eles[j].name.split('.')[2]);
						if(colNum > -1) valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,curOriginalVals[colNum]);
						isDirty = eles[j].getAttribute('A5IsDirty') == 'true' ? true : false;
						if(isDirty) dirtyValues[dirtyValues.length] = eles[j].name;
						valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name,$gvs(eles[j]));
					}
				}
				eles = rObj[i].getElementsByTagName('textarea');
				for(var j=0;j<eles.length;j++){
					if(eles[j].getAttribute('A5HarvestIgnore') != 'true' && eles[j].id.split('.')[0] == this.gridId){
						colNum = this._colNumFromName(this._gridColNames,eles[j].name.split('.')[2]);
						if(colNum > -1) valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+'old.'+eles[j].name,curOriginalVals[colNum]);
						isDirty = eles[j].getAttribute('A5IsDirty') == 'true' ? true : false;
						if(isDirty) dirtyValues[dirtyValues.length] = eles[j].name;
						val = $gvs(eles[j]);
						if(val == eles[j].getAttribute('A5WatermarkText')) val = '';
						valArr[valArr.length] = a5_AJAX_Form_SubmitValueParam(nameSpace+eles[j].name, val);
					}
				}
			}
		}
		
		return 'a5DirtyRegions='+dirtyRegions.join('\n')+'&'+'a5RegionsDirtyValues='+dirtyValues.join('\n')+'&'+valArr.join('&');
	},	
	



	_populateRowViewMode: function(rowNum,data,ids) {
		//Used when row is in view mode (i.e. controls are all lables, and in the future, some radio buttons, and checkboxes)
		this._populateRow(rowNum,data,ids,false,[],true);
	},
	
	_populateRow: function(rowNum,data,ids) {
		//takes a row number, array of data and an array of control Names (without 'V.R5' prefix) and populates the controls.
		//marks each populated cell as 'clean'
		//marks the row as 'clean'
		//check to see if all rows are clean and if so, disabled 'submit' and 'cancel'.
		
		//if the optional parameter is set to true, then we don't try to set the row's 'clean' flag.
		//(reason is if the user clicks the deleteCheckbox in a row, the row is to be considered dirty, even though
		//all of the individual values are clean.
		
		var leaveRowStateUnchanged = typeof arguments[3] != 'undefined' ? arguments[3] : false;
		var ignoreColumns = typeof arguments[4] != 'undefined' ? arguments[4] : new Array();
		
		var typeIndex = 0;
		//_populateRow() can be used to populate the readonly version of each control.
		if(typeof arguments[5] != 'undefined') { 
			if(arguments[5]) typeIndex = 1;
		}

		if(this.rowEditMode == 'rod-s' || this.rowEditMode == 'rod') {
			if(this._editModeRows[rowNum-1] == false) typeIndex = 1;
		}
		
		
		
		
		var refreshOnEditMode = typeof arguments[6] != 'undefined' ? arguments[6] : false;
		
		var colNum = 0;
		var ele = 0;
		var colType = '';
		
		for(var i = 0; i < ids.length; i++) {
			if($u.a.find(ignoreColumns,ids[i]) == -1 ) {

				colNum = this._colNumFromName(this._gridColNames,ids[i]);
				colType = '';
				if(colNum > -1) {
					ids[i] = this._gridColNames[colNum];
					if(rowNum > 0) {
						if(!this._originalValues[rowNum-1]) this._originalValues[rowNum-1] = new Array();
						this._originalValues[rowNum-1][colNum] = data[i];	
					} 
					colType = this.gridColumnInfo[i].type.split(',')[typeIndex];
					//Make the value html safe
					//debugger;
					if(colType == 'label' || colType == 'link') {
						if(data[i].constructor == Array) data[i][0] = data[i][0].replace(/\&/g,'&amp;');
						else data[i] = data[i].replace(/\&/g,'&amp;');
						if(colType == 'label'){
							if(this.gridColumnInfo[colNum].displayFormat == 'plain') data[i] = data[i].replace(/\</g,'&lt;').replace(/\>/g,'&gt;').replace(/\n/g,'<br/>');
						}						
					}
					if(colType  == 'label' || colType == 'label-html' || colType  == 'link' || colType  == 'img' ) {
						ele = $n(this.gridId + '.V.R' + rowNum + '.' + ids[i]);
					} else	{
						ele = $n('V.R' + rowNum + '.' + ids[i]);
					}
				} else {
					ele = $n('V.R' + rowNum + '.' + ids[i]);
				}
				
				ele = $cetp(ele,$(this.gridId + '.R' + rowNum));
				if(!ele.tagName){
					var ele2 = new Array();
					for(var j=0;j<ele.length;j++) if(ele[j].id.split('.')[0] == this.gridId) ele2.push(ele[j]);
					if(ele2.length != 0) ele = ele2;
					else ele = false;
				}				
				if(ele) {
					if(!(refreshOnEditMode == true && $ga(ele[0],'A5IsDirty') == 'true' )) {
						if(typeof this._fieldHelpers_G[ids[i]] != 'undefined' ) {
							this._fieldHelpers_G[ids[i]].setValue(data[i],ele[0]);				
						} else {
							//false will change /n into <br>
							$svs(ele , data[i],false, false);
							if(colType == 'popup-rte') $(this.gridId + '.V.R' + rowNum + '.' + ids[i]+'.DISPLAY').innerHTML = data[i];
						}
						$sa(ele ,'A5IsDirty','false');
					}
				}
			}
			
		}
		if(!leaveRowStateUnchanged) {
			this._setRowState(rowNum,false);
		}
		
		
		this._fireWatches('G',rowNum);
		this._executeEvent('afterRowPopulate',{rowNumber: rowNum});
		
		
	},
	
	
	_populateDirtyRow: function(rowNum,data,ids) {
		//takes a row number, array of data and an array of control Names (without 'V.R5' prefix) and populates the controls.
		//marks the row as 'clean' or 'dirty' as appropriate
		//check to see if any rows is dirty, and if so, enables 'submit' and 'cancel'.
		//used after as submit if any rows in the submitted data had errors 
		// - after the submit, all rows are refreshed, and then the row with errors is repopulated with the edited value
		// so that the user has another shot as submitting the changes.
		var typeIndex = 0;
		var colNum = 0;
		var colType = '';
		var isDirty = false;
		var ele = 0;
		this._batchChange = true;
		for(var i = 0; i < ids.length; i++) {
			colNum = this._colNumFromName(this._gridColNames,ids[i]);
			if(colNum > -1) {
				ids[i] = this._gridColNames[colNum];
				colType = this.gridColumnInfo[i].type.split(',')[typeIndex];

				//Make the value html safe
				if(colType == 'label' || colType == 'link') {
					if(data[i].constructor == Array) data[i][0] = data[i][0].replace(/\&/g,'&amp;');
					else data[i] = data[i].replace(/\&/g,'&amp;');
					if(colType == 'label'){
						if(this.gridColumnInfo[colNum].displayFormat == 'plain') data[i] = data[i].replace(/\</g,'&lt;').replace(/\>/g,'&gt;').replace(/\n/g,'<br/>');
					}						
					
				}				
				
				if(colType == 'label' || colType == 'label-html' || colType == 'link' || colType == 'img') {
					ele = $n(this.gridId + '.V.R' + rowNum + '.' + ids[i]);
				} else if(colType == 'popup-rte') {
					ele = $n('V.R' + rowNum + '.' + ids[i]);
					$(this.gridId + '.V.R' + rowNum + '.' + ids[i]+'.DISPLAY').innerHTML = data[i];
				} else {
					ele = $n('V.R' + rowNum + '.' + ids[i]);
				}
				if(rowNum < 0 ) {
					if(this._newValues[colNum] != data[i]) {
						$sa(ele ,'A5IsDirty','true', $(this.gridId + '.R' + rowNum));
						isDirty = true;
						$e.execute(ele[0],'change');
					}
				} else {
					if(this._originalValues[rowNum-1][colNum] != data[i]) {
						$sa(ele ,'A5IsDirty','true', $(this.gridId + '.R' + rowNum));
						isDirty = true;
						$e.execute(ele[0],'change');
					}
				}
			} else {
				ele = $n('V.R' + rowNum + '.' + ids[i]);
				$sa(ele ,'A5IsDirty','true', $(this.gridId + '.R' + rowNum));
				isDirty = true;
				$e.execute(ele[0],'change');
			}
			ele = $cetp(ele,$(this.gridId + '.R' + rowNum));
			
			if(!ele.tagName){
				var ele2 = new Array();
				for(var j=0;j<ele.length;j++) if(ele[j].id.split('.')[0] == this.gridId) ele2.push(ele[j]);
				if(ele2.length != 0) ele = ele2;
				else ele = false;
			}			
			
			
			if(ele) {
				if(typeof this._fieldHelpers_G[ids[i]] != 'undefined' ) {
					this._fieldHelpers_G[ids[i]].setValue(data[i],ele[0]);				
				} else {
					//false will change /n into <br>
					$svs(ele , data[i],false, false);
				}			
			}			
		}
		this._batchChange = false;
		
		this._setRowState(rowNum,isDirty);
		this._fireWatches('G',rowNum);
		
		this._executeEvent('afterRowPopulate',{rowNumber: rowNum});
		
	},
	
	_populateDetailView: function(rowNum,data,ids) {
		var leaveRowStateUnchanged = typeof arguments[3] != 'undefined' ? arguments[3] : false;
		var ignoreColumns = typeof arguments[4] != 'undefined' ? arguments[4] : new Array();
		var typeIndex = 0;
		//_populateRow() can be used to populate the readonly version of each control.
		if(typeof arguments[5] != 'undefined') { 
			//if(arguments[5]) typeIndex = 1;
			//12/17/10 - A number was being passed in, not a t/f value
			typeIndex = arguments[5];

		}
		var executeOnDetailViewRender = typeof arguments[6] != 'undefined' ? arguments[6] : true;
		if(!leaveRowStateUnchanged) {
					
					//A5.form.reset(this.gridId +'.DETAILVIEW_PART.FORM');
					this._resetDetailViewForm();
					this._setDetailViewState(false);
		}
		var colNum = 0;
		var ele = 0;
		var colType = '';
		for(var i = 0; i < ids.length; i++) {
			if($u.a.find(ignoreColumns,ids[i]) == -1 ) {
				colNum = this._colNumFromName(this._detailViewColNames,ids[i]);
				if(colNum > -1) {
					ids[i] = this._detailViewColNames[colNum];
					if(rowNum > 0) {
						if(!this._originalDVValues[rowNum-1]) this._originalDVValues[rowNum-1] = new Array();
						this._originalDVValues[rowNum-1][colNum] = data[i];	
					}
					
					colType = this.detailViewColumnInfo[i].type.split(',')[typeIndex];
					//Make the value html safe
					if(colType == 'label' || colType == 'link') {
						if(data[i].constructor == Array) data[i][0] = data[i][0].replace(/\&/g,'&amp;');
						else data[i] = data[i].replace(/\&/g,'&amp;');
						if(colType == 'label'){
							if(this.detailViewColumnInfo[colNum].displayFormat == 'plain') data[i] = data[i].replace(/\</g,'&lt;').replace(/\>/g,'&gt;').replace(/\n/g,'<br/>');
						}						
					}					
					if(colType == 'label' || colType == 'label-html' || colType == 'link'  || colType == 'img' ) {
						ele = $n(this.gridId + '.D.V.R' + '1' + '.' + ids[i]);
					} else if(colType == 'popup-rte') {
						ele = $n('V.R' + '1' + '.' + ids[i]);
						$(this.gridId + '.D.V.R' + '1' + '.' + ids[i]+'.DISPLAY').innerHTML = data[i];
					} else if(colType == 'rte') {
						ele = $n('V.R' + '1' + '.' + ids[i]);
						var rteObj = window[this.gridId + '_' + ids[i] + '_RTEObj'];
						if(typeof rteObj._rteObj != 'undefined') rteObj._rteObj.setHTML(data[i]);
						else rteObj.setHTML(data[i]);
							
					} else	{
						ele = $n('V.R' + '1' + '.' + ids[i]);
					}
				} else {
					ele = $n('V.R' + '1' + '.' + ids[i]);
				}
				ele = $cetp(ele,$(this.gridId + '.DETAILVIEW_PART.FORM' ));
				if(ele) {
					if(typeof this._fieldHelpers_DV[ids[i]] != 'undefined' ) {
						this._fieldHelpers_DV[ids[i]].setValue(data[i],ele[0]);				
					} else {
						//false will change /n into <br>
						$svs(ele , data[i],false, false);	
					}
					$sa(ele ,'A5IsDirty','false');
					if(typeof data[i] == 'object') {
						$sa(ele,'A5OriginalValue',data[i].join('||A5ARRAYSEP||'));
					} else {
						$sa(ele,'A5OriginalValue',data[i]);
					}
				}
			}
		}
		this._fireWatches('D',1);
		if(executeOnDetailViewRender) this._executeEvent('onDetailViewRender',{rowNumber: this._detailViewRow});
	},


	_fireWatches: function(part,rowNum) {
		
		if(part=='G' || part == 'all') {
			if(typeof rowNum == 'number') {
				for(var gridWatch in this._gridWatches) {
					A5.Watch.fire(this.gridId+'.'+gridWatch);
				}
			
				for(var gridRowWatch in this._gridRowWatches) {
					A5.Watch.fire(this.gridId+'.R' + rowNum + '.'+gridRowWatch);
				}
			} else {

				for(var gridWatch in this._gridWatches) {
					A5.Watch.fire(this.gridId+'.'+gridWatch);
				}
				if(this.pagesInGrid != 0) {	

					for(var gridRowWatch in this._gridRowWatches) {
						for(var i = 1; i <= this._rowsInGrid; i++) {
							A5.Watch.fire(this.gridId+'.R' + i + '.'+gridRowWatch);
						}				
					}
				}
				for(var gridRowWatch in this._gridRowWatches) {
					for(var i = 1; i <= this._newRowsInGrid; i++) {
						A5.Watch.fire(this.gridId+'.R-' + i + '.'+gridRowWatch);
					}				
				}
			}
		} 
		if( (part=='D'|| part == 'all') && this._detailViewRow != 0) {
			for(var detailViewWatch in this._detailViewWatches) {
				A5.Watch.fire(this.gridId+'.DV.'+detailViewWatch);
			}
		} 
		if(part=='S' || part == 'all') {
			for(var searchWatch in this._searchWatches) {
				A5.Watch.fire(this.gridId+'.S.'+searchWatch);
			}
		}
	},

	_resetDetailViewForm: function() {
		var ele = 0;
		var pele = $(this.gridId +'.DETAILVIEW_PART.FORM');
		var val = '';
		var isDirty = false;
		for(var i=0; i < this.detailViewColumnInfo.length; i++) {
			ele = $n('V.R1.' + this.detailViewColumnInfo[i].name);
			delete ele2;
			var ele2 = new Array();
			isDirty = false;
			for(var j=0;j<ele.length;j++) {
				if($isChild(ele[j],pele)) {
					ele2.push(ele[j]);
					if($ga(ele[j],'A5IsDirty') == 'true') isDirty = true;
				}
			}
			
			if(isDirty) {
				val = $ga(ele2[0],'A5OriginalValue');
				val = val.split('||A5ARRAYSEP||');
			
				if(val.length == 1) val = val[0];
				if(typeof this._fieldHelpers_S[this.detailViewColumnInfo[i].name] == 'object') {
					this._fieldHelpers_S[this.detailViewColumnInfo[i].name].setValue(val,ele2);
				} else {
					$svs(ele2,val);
				}
				$sa(ele2,'A5IsDirty','false');
			}
		}
		$sa(pele,'A5IsDirty','false');
	},


	_populateDirtyDetailView: function(rowNum,data,ids) {
		var typeIndex = 0;
		var colNum = 0;
		var colType = '';
		var isDirty = false;
		var ele = 0;
		this._batchChange = true;
		for(var i = 0; i < ids.length; i++) {
			colNum = this._colNumFromName(this._detailViewColNames,ids[i]);
			if(colNum > -1) {
				ids[i] = this._detailViewColNames[colNum];
				colType = this.detailViewColumnInfo[i].type.split(',')[typeIndex];
				//Make the value html safe
				if(colType == 'label' || colType == 'link') {
					if(data[i].constructor == Array) data[i][0] = data[i][0].replace(/\&/g,'&amp;');
					else data[i] = data[i].replace(/\&/g,'&amp;');
					if(colType == 'label'){
						if(this.detailViewColumnInfo[colNum].displayFormat == 'plain') data[i] = data[i].replace(/\</g,'&lt;').replace(/\>/g,'&gt;').replace(/\n/g,'<br/>');
					}						
					
				}				
				if(colType == 'label' || colType == 'label-html' || colType == 'link' || colType == 'img') {
					ele = $n(this.gridId + '.D.V.R1.' + ids[i]);
				} else if(colType == 'popup-rte') {
					ele = $n('V.R1.' + ids[i]);
					$(this.gridId + '.D.V.R1.' + ids[i]+'.DISPLAY').innerHTML = data[i];
				} else if(colType == 'rte') {
					ele = $n('V.R' + '1' + '.' + ids[i]);
					window[this.gridId + '_' + ids[i] + '_RTEObj']._rteObj.setHTML(data[i]);
				} else {
					ele = $n('V.R1.' + ids[i]);
				}
				ele = $cetp(ele,$(this.gridId + '.DETAILVIEW_PART.FORM' ));
				if(ele) {
					if(ele.tagName) {
						val = ele.getAttribute('A5OriginalValue').split('||A5ARRAYSEP||');
					} else {
						val = ele[0].getAttribute('A5OriginalValue').split('||A5ARRAYSEP||');
					}
					if(val.toString() != data[i].toString()) {
						$sa(ele ,'A5IsDirty','true', $(this.gridId + '.DETAILVIEW_PART.FORM'));
						isDirty = true;
						$e.execute(ele[0],'change');
						//selwyn 7/9/11 - executing the the 'change' event set A5IsDirty back to false, so reset it to true
						$sa(ele ,'A5IsDirty','true', $(this.gridId + '.DETAILVIEW_PART.FORM'));
					}
				}
			} else {
				ele = $n('V.R1.' + ids[i]);
				ele = $cetp(ele,$(this.gridId + '.DETAILVIEW_PART.FORM' ));
				if(ele) {
					$sa(ele ,'A5IsDirty','true', $(this.gridId + '.DETAILVIEW_PART.FORM'));
					isDirty = true;
					$e.execute(ele[0],'change');
				}
			}
			
			if(ele) {
				if(typeof this._fieldHelpers_DV[ids[i]] != 'undefined' ) {
					this._fieldHelpers_DV[ids[i]].setValue(data[i],ele[0]);				
				} else {
					//false will change /n into <br>
					$svs(ele , data[i],$(this.gridId + '.D.R' + '1'), false);	
				}
			}
		}
		
		this._batchChange = false;
		
		if(isDirty) this._setDetailViewState(isDirty);
		this._fireWatches('D',1);
		//if(isDirty) this._setDVControlDirty();
		
	},



	_deleteRow: function(rowNum) {
		$(this.gridId + '.R' + rowNum).style.display = 'none';
		$sa(this.gridId + '.R' + rowNum,'A5DeletedRow','true');
		this._setRowState(rowNum,false);
		var focusRowNum = 0;
		for(var i = rowNum +1; i <= this._rowsInGrid; i++) {
			if($(this.gridId + '.R' + i).style.display != 'none') {
				focusRowNum = i;
				break;
			}
		}
		
		if(focusRowNum == 0) {
			for(var i = rowNum - 1; i > 0; i--) {
				if($(this.gridId + '.R' + i).style.display != 'none') {
					focusRowNum = i;
					break;
				}
			}
		}
		
		if(focusRowNum != 0) {
			this.setFocus(focusRowNum);
		} else {
			this._focusRow = 0;
		}
	},
	
	_setRowState: function(rowNum,isDirty) {
	
		var stateChange = false;
		if(rowNum < 0) {
			if(this._editPermissions.allowInsert == false) return false;
			if(this._dirtyNewRows[Math.abs(rowNum)-1] != isDirty) {
				stateChange = true;
				this._dirtyNewRows[Math.abs(rowNum)-1] = isDirty;
			}
		} else {
			if(this._editPermissions.allowUpdate == false && this._editPermissions.allowDelete == false) return false;
			if(this._dirtyRows[rowNum-1] != isDirty) {
				stateChange = true;
				this._dirtyRows[rowNum-1] = isDirty;
			}
		}
		if(stateChange) {
			
			var mode = 'view';
			
			if(isDirty) {
				if(rowNum < 0) mode = 'enter';
				else mode = 'change';
				$acn(this.gridId +'.TD.R'+(rowNum)+'.__SYSTEM_STATUSCOLUMN','A5GridRowIsDirty');
				this._gridRowState = mode;
				this._executeEvent('onRowStateChange',{'mode': mode, 'isDirty': true, 'rowNumber': rowNum});
			} else {
				$rcn(this.gridId +'.TD.R'+(rowNum)+'.__SYSTEM_STATUSCOLUMN','A5GridRowIsDirty');
				this._gridRowState = mode;
				this._executeEvent('onRowStateChange',{'mode': mode, 'isDirty': false, 'rowNumber': rowNum});
			}
			
			
			
			if(isDirty){
				if(($u.a.find(this._dirtyRows,true) != -1 || $u.a.find(this._dirtyNewRows,true) != -1) && !this._isDirty) {
					this._isDirty = true;
					
					this._enable(this.gridId + '.GRID_PART.SUBMITBUTTON_BOTTOM',true);
					this._enable(this.gridId + '.GRID_PART.CANCELBUTTON_BOTTOM',true);

					this._enable(this.gridId + '.GRID_PART.SUBMITBUTTON_TOP',true);
					this._enable(this.gridId + '.GRID_PART.CANCELBUTTON_TOP',true);
					this._executeEvent('onGridStateChange',{'isDirty': true});
					//if a row client-side expression references grid.isDirty, only the row with focus will get updated when the 
					//grid state changes. If you want to update all rows, then uncomment this code:
					//this._fireWatches('G','all');
					

				}
			} else{
				if(($u.a.find(this._dirtyRows,true) == -1 && $u.a.find(this._dirtyNewRows,true) == -1) && this._isDirty) {
					this._isDirty = false;
					
					this._enable(this.gridId + '.GRID_PART.SUBMITBUTTON_BOTTOM',false);
					this._enable(this.gridId + '.GRID_PART.CANCELBUTTON_BOTTOM',false);

					this._enable(this.gridId + '.GRID_PART.SUBMITBUTTON_TOP',false);
					this._enable(this.gridId + '.GRID_PART.CANCELBUTTON_TOP',false);
					this._executeEvent('onGridStateChange',{'isDirty': false});
					//see comment in the true block
				}
			}
		}
		
	},
	
	_setDetailViewImages: function(mode) {
		if(typeof mode == 'undefined') mode = 'view';
		var ele_cancelEdits = $(this.gridId + '.D.IMG.CANCELEDIT');
		var ele_save = $(this.gridId + '.D.IMG.SAVE');
		var ele_saveEnter = $(this.gridId + '.D.IMG.SAVEANDENTER');
		
		var nrEle =  $(this.gridId +'.DETAILVIEW_PART.NEWRECORDBUTTON');
		var cnrEle =  $(this.gridId +'.DETAILVIEW_PART.CANCELNEWRECORDBUTTON');
		
		if(mode == 'change') {
			if(ele_cancelEdits) ele_cancelEdits.src	= this._dVImages['cancelEdits'];
			if(ele_save) ele_save.src = this._dVImages['saveRecord'];
			if(ele_saveEnter) ele_saveEnter.src = this._dVImages['saveAndEnter'];
		} else if(mode == 'enter') {
			if(ele_cancelEdits) ele_cancelEdits.src = this._dVImages['cancelEdits'];
			if(ele_save) ele_save.src = this._dVImages['saveRecord'];
			if(ele_saveEnter) ele_saveEnter.src = this._dVImages['saveAndEnter'];
		} else if(mode == 'view') {
			if(ele_cancelEdits) ele_cancelEdits.src	= this._dVImages['d_cancelEdits'];
			if(ele_save) ele_save.src = this._dVImages['d_saveRecord'];
			if(ele_saveEnter) ele_saveEnter.src = this._dVImages['d_saveAndEnter'];
			if(nrEle) nrEle.style.display = '';
			if(cnrEle) cnrEle.style.display = 'none';
		}
	},

	
	_setDetailViewState: function(isDirty) {
		var mode = this._detailViewState;
		if(this._detailViewIsDirty != isDirty) {
			mode = 'view';
			if(this._detailViewRow < 0) mode = 'enter';

			if(mode=='enter') {
				if(this._editPermissions.allowInsert == false && isDirty) return false;
			} else if(mode == 'view') {
				if(this._editPermissions.allowUpdate == false && isDirty) return false;
			}
			
			if(isDirty){
				this._detailViewIsDirty = true;
				this._enable(this.gridId + '.DETAILVIEW_PART.SUBMITBUTTON',true);
				this._enable(this.gridId + '.DETAILVIEW_PART.CANCELEDITSBUTTON',true);
				this._enable(this.gridId + '.DETAILVIEW_PART.SAVEANDENTERBUTTON',true);
				if($(this.gridId+'.DVTOOLBAR_VIEWMODE')) $(this.gridId+'.DVTOOLBAR_VIEWMODE').style.display = 'none';
				if(this._detailViewRow == -1) {
					//enter mode
					if($(this.gridId+'.DVTOOLBAR_CHANGEMODE')) $(this.gridId+'.DVTOOLBAR_CHANGEMODE').style.display = 'none';
					if($(this.gridId+'.DVTOOLBAR_ENTERMODE')) $(this.gridId+'.DVTOOLBAR_ENTERMODE').style.display = '';
				} else {
					//change mode
					if($(this.gridId+'.DVTOOLBAR_CHANGEMODE')) $(this.gridId+'.DVTOOLBAR_CHANGEMODE').style.display = '';
					if($(this.gridId+'.DVTOOLBAR_ENTERMODE')) $(this.gridId+'.DVTOOLBAR_ENTERMODE').style.display = 'none';
				}
				if(this._detailViewRow < 0) mode = 'enter';
				else mode = 'change';
				this._detailViewState = mode;
				this._executeEvent('onDetailViewStateChange',{'mode': mode, 'isDirty': true, 'rowNumber': this._detailViewRow});
			} else{
				this._detailViewIsDirty = false;
				this._enable(this.gridId + '.DETAILVIEW_PART.SUBMITBUTTON',false);
				this._enable(this.gridId + '.DETAILVIEW_PART.CANCELEDITSBUTTON',false);
				this._enable(this.gridId + '.DETAILVIEW_PART.SAVEANDENTERBUTTON',false);
				if($(this.gridId+'.DVTOOLBAR_VIEWMODE')) $(this.gridId+'.DVTOOLBAR_VIEWMODE').style.display = '';
				if($(this.gridId+'.DVTOOLBAR_CHANGEMODE')) $(this.gridId+'.DVTOOLBAR_CHANGEMODE').style.display = 'none';
				if($(this.gridId+'.DVTOOLBAR_ENTERMODE')) $(this.gridId+'.DVTOOLBAR_ENTERMODE').style.display = 'none';
				this._detailViewState = mode;	
				this._executeEvent('onDetailViewStateChange',{'mode': mode, 'isDirty': false, 'rowNumber': this._detailViewRow});
			}
		} else {
			if(this._detailViewRow < 0 && mode == 'view') {
				mode = 'enter';
				this._detailViewState = mode;
				this._executeEvent('onDetailViewStateChange',{'mode': mode, 'isDirty': isDirty, 'rowNumber': this._detailViewRow});
			} else if(this._detailViewRow > 0 && mode == 'enter') {
				mode = 'view';
				this._detailViewState = mode;
				this._executeEvent('onDetailViewStateChange',{'mode': mode, 'isDirty': isDirty, 'rowNumber': this._detailViewRow});
			}
		}
		this._setDetailViewImages(mode);
		ele_delete = $(this.gridId + '.D.IMG.DELETE');
		if(this._detailViewRow == -1) {
			this._enable(this.gridId + '.DETAILVIEW_PART.DELETERECORDBUTTON',false);
			if(ele_delete) ele_delete.src = this._dVImages['d_deleteRecord'];
		} else {
			this._enable(this.gridId + '.DETAILVIEW_PART.DELETERECORDBUTTON',true);
			if(ele_delete) ele_delete.src = this._dVImages['deleteRecord'];
		}
	},
	
	_internalRefreshLinkedContent: function() {
		clearTimeout(this._refreshLinkedContentTO);
		var classInst = this;
		this._refreshLinkedContentTO = setTimeout(function() {
			classInst.refreshLinkedContent();
			delete classInst;
		},200);
	},
	
		
	refreshLinkedContent: function() {
			if(typeof this.linkedObjects !== 'undefined') {
				for(var i = 0; i < this.linkedObjects.length; i++) {
					if(window[this.linkedObjects[i]]) window[this.linkedObjects[i]].reset();
				}
			}
	},
	
	_resetRow: function(rowNum) {
		if(!this._executeEvent('canRowCancelEdits',{rowNumber: rowNum})) return false;
		var classInst = this;
		A5.msgBox.show(this.messages.t_undoEditsWarning,this.messages.undoEditsWarning,'OC',function(action) { 
			if(action=='ok') classInst._resetRowWithoutConfirmation(rowNum);
		});
	},
	
	_resetRowWithoutConfirmation: function(rowNum) {
		if(rowNum < 0) {
			this._populateRow(rowNum,this._newValues,this._gridColNames);
		} else {
			this._populateRow(rowNum,this._originalValues[rowNum-1],this._gridColNames);
			if($(this.gridId +'.TD.R'+rowNum+'.__SYSTEM_ERRORCOLUMN').className.search('A5GridHasRowError') != -1) this.refreshRow(rowNum);
		}
		var rowArray = new Array();
		rowArray.push(rowNum);
		this.clearRowErrors(rowArray);
		this.clearErrors([rowNum]);
		
		var data = '';
		for(var i=0;i<this.gridColumnInfo.length;i++) {
			if(this.gridColumnInfo[i].type == 'select,label') {
				data = this._cascadingSelectChoices[this.gridId + '.V.R' + rowNum + '.' + this.gridColumnInfo[i].name];
				if(data) {
					A5.form.populateSelect(	this.gridId + '.V.R' + rowNum + '.' + this.gridColumnInfo[i].name, data.value, data.data, true);
				}
			}
		
		}
		
		
		this._executeEvent('afterRowCancelEdits',{rowNumber: rowNum});
		this._executeEvent('afterCancelEdits',{rowNumber: rowNum});
		
	},


	resetGridPart: function() { 
		if(!this._executeEvent('canGridCancelEdits',{})) return false;

		var classInst = this;
		
		A5.msgBox.show(this.messages.t_undoAllEditsWarning,this.messages.undoAllEditsWarning,'OC',function(action) { 
			if(action=='ok') classInst._resetGridPartWithoutConfirmation();
		});
	},
	
	_resetGridPartWithoutConfirmation: function() {
		//Takes two optional arguments. true/false and the text of the confirmation message.
		if(typeof arguments[0] != 'undefined') {
			if(arguments[0] == true) {
				var message = typeof arguments[1] != 'undefined' ? arguments[1] : '';
				if(message == '') message = 'Cancel changes?';
				var result = confirm(message);
				if(!result) return false;
			}
		}

		for(var i=1;i<=this._rowsInGrid;i++) {
			if(this._dirtyRows[i-1]) this._resetRowWithoutConfirmation(i);
		}

		for(var i=1;i<=this._newRowsInGrid;i++) {
			if(this._dirtyNewRows[i-1]) this._resetRowWithoutConfirmation(i*-1);
		}
		
		this.clearErrors();
		this.clearRowErrors();
		this._executeEvent('afterGridCancelEdits',{});
	},
	
	
	populateDropdownBox: function(part,columnName,rowNum,data,clearExisting) {
		var ele = '';
		var curData = '';
		
		if(part=='G') {
			ele =  this.gridId + '.V.R'+rowNum+'.' + columnName;
			curData = this.getValue('G',columnName,rowNum);
		} else { 
			ele = this.gridId + '.D.V.R1.' + columnName;
			curData = this.getValue('D',columnName);
		}
		A5.form.populateSelect(ele,curData,data,clearExisting);
	},


	
	
	prepareSearch: function() {
	
		if(this.embeddedSearchPart) {	
			if(this.embedSearchPartStyle == 's') var e = $(this.gridId + '.EMBEDDED_FREEFORM_SEARCH');
			else var e = $(this.gridId + '.SEARCH_PART.FORM');
			
			if(typeof this._embeddedSearchIsOpen != 'undefined') {
				if(this._embeddedSearchIsOpen) e.style.display = '';
				else e.style.display = 'none';
			}
		}
	
		if($(this.gridId + '.SEARCH_PART.FORM')){
			A5.form.prepare(this.gridId + '.SEARCH_PART.FORM');
			if(this.embeddedSearchPart) {
				var ele = 0;
				for(var i=0; i<this.searchColumnInfo.length; i++) {
					ele = $(this.gridId + '.S.' + this.searchColumnInfo[i].name);
					$e.add(ele,'change',this._searchOnChange,this);
					if(this._searchValues[ele.id]) $svs(ele,this._searchValues[ele.id]);
					if(this.searchColumnInfo[i].isRange) {
						ele = $(this.gridId + '.S._TO.' + this.searchColumnInfo[i].name);
						$e.add(ele,'change',this._searchOnChange,this);
						if(this._searchValues[ele.id]) $svs(ele,this._searchValues[ele.id]);
					}
				}
				
				ele = $(this.gridId + '_SORTCOLUMN');
				if(ele) {
					$e.add(ele,'change',this._searchOnChange,this);
					if(this._searchValues[ele.id]) $svs(ele,this._searchValues[ele.id]);
				}
				ele = $(this.gridId + '_SORTDIR');
				if(ele) {
					$e.add(ele,'change',this._searchOnChange,this);
					if(this._searchValues[ele.id]) $svs(ele,this._searchValues[ele.id]);
				}
				ele = $(this.gridId + '_ROWCOUNT');
				if(ele) {
					$e.add(ele,'change',this._searchOnChange,this);
					if(this._searchValues[ele.id]) $svs(ele,this._searchValues[ele.id]);
				}
				//SORTCOLUMN, SORTDIR, ROWCOUNT
				
			}

			var sIndex = -1;
			for(var fHelper in this._fieldHelpers_S) {
				sIndex = $u.a.find(this._searchColNames,fHelper);
				this._fieldHelpers_S[fHelper].bind(this.gridId +'.S.' + fHelper);
				if(this.searchColumnInfo[sIndex].isRange) {
					this._fieldHelpers_S[fHelper].bind(this.gridId +'.S._TO.' + fHelper);
				}
			}



			for(var searchWatch in this._searchWatches) {
				var watchIds = new Array();

				//for(var i = 0;i<this._searchWatches[searchWatch].watch.length; i++) watchIds.push(this.gridId + '.S.' + this._searchWatches[searchWatch].watch[i]);
				var eleTagName = '';
				var eles = 0;
				for(var i = 0;i<this._searchWatches[searchWatch].watch.length; i++){
					if(this._searchWatches[searchWatch].watch[i] == this.gridId + '.STATEINFO') watchIds.push(this.gridId + '.STATEINFO');
					else {
						eleTagName = $(this.gridId + '.S.' + this._searchWatches[searchWatch].watch[i]).tagName.toLowerCase();
						if(eleTagName != 'input' && eleTagName != 'select' && eleTagName != 'textarea'){
							eles = $n('S.' + this._searchWatches[searchWatch].watch[i]);
							eles = $cetp(eles,$(this.gridId + '.SEARCH_PART.FORM'));
							for(var j=0;j<eles.length;j++) watchIds.push(eles[j].id);
						} else watchIds.push(this.gridId + '.S.' + this._searchWatches[searchWatch].watch[i]);
					}
				}	
				

				A5.Watch.add(this.gridId+'.S.'+searchWatch,watchIds,{
					data: {rowNumber: 1},
					onChange: this._searchWatches[searchWatch].onChange
				});
			}
		}
		
		this._executeEvent('onSearchRender',{});
	},
	
	_searchOnChange: function(e,classInst) {
		classInst._searchValues[this.id] = $gvs(this);
	},
	
	prepareGrid: function() {
		if(this._namedLayout) {
			if(!this._namedLayout=='') {
				var ele = $(this.gridId + '.NAMEDLAYOUTSELECTOR');
				if(ele) $svs(ele,this._namedLayout);
			}
		}
		this._dirtyRows =  new Array();
		this._dirtyNewRows =  new Array();
		this._editModeRows =  new Array();
		this._isDirty = false;
		if(this.pagesInGrid != 0) {
			for(var i=1;i<=this._rowsInGrid;i++) {
				this._prepareRow(i);
				}
		}
		for(var i=0;i<this.gridColumnInfo.length; i++) {
			$e.add(this.gridId+'.QBE.I.' + this.gridColumnInfo[i].name,'click',this._gridQBEMenu,this,false,this.gridId+'.GRID');
		}
		
		for(var i=1;i<=this._newRowsInGrid;i++) {
			this._prepareNewRow(i);
			}
		if(this.checkBoxSelector == 'multiplePage') {
			var keystr = '';
			for(var i = 0; i < this._keys.length; i++) {
				keystr = this._keys[i].toString();
				for(var j = 0; j < this._checkedRowKeys.length; j++) {
					if(keystr == this._checkedRowKeys[j].toString()) {
						$svs(this.gridId + '.V.R' + (i + 1 ) +'.__ROWCHECKBOX',true);
						break;
					}
				}
			}
		}
		$e.add(this.gridId+'.QBE.MENUFORM','click',function(e) {$e.stopPropagation(e);  },null,false,this.gridId+'.GRID');
		for(var i = 0; i < this._hiddenCols.length; i++) {
			this._showGridColumn(this._hiddenCols[i],false);
		}
		this._executeEvent('onGridRender',{});
		if(this.LCSName != '') this._LCS_clearLocks(this.LCSName);
		

		for(var gridWatch in this._gridWatches) {
			var watchIds = new Array();
			var eleTagName = '';
			var eles = 0;
			var tempEle = 0;
			var tempRowNum = 0;
			
			for(var i = 0;i<this._gridWatches[gridWatch].watch.length; i++){
				if(this._gridWatches[gridWatch].watch[i] == this.gridId + '.STATEINFO') watchIds.push(this.gridId + '.STATEINFO');
				else {
					if(this._gridWatches[gridWatch].target  == 'new' || this.pagesInGrid != 0) tempRowNum = -1;
					else tempRowNum = 1;
					tempEle = $(this.gridId + '.V.R'+tempRowNum+'.' + this._gridWatches[gridWatch].watch[i]);
					eleTagName = '';
					if(tempEle) eleTagName = tempEle.tagName.toLowerCase();
					if(eleTagName != 'input' && eleTagName != 'select' && eleTagName != 'textarea'){
						if(this._gridWatches[gridWatch].target != 'new'){
							if(this.pagesInGrid != 0) {
								for(var j=1;j<=this._rowsInGrid;j++){
									eles = $n('V.R' + j + '.' + this._gridWatches[gridWatch].watch[i]);
									eles = $cetp(eles,$(this.gridId + '.R' + j));
									for(var k=0;k<eles.length;k++) watchIds.push(eles[k].id);
								}
							}
						}
						if(this._gridWatches[gridWatch].target == 'new' || this._gridWatches[gridWatch].target == 'all'){
							for(var j=1;j<=this._newRowsInGrid;j++){
								eles = $n('V.R-' + j + '.' + this._gridWatches[gridWatch].watch[i]);
								eles = $cetp(eles,$(this.gridId + '.R-' + j));
								for(var k=0;k<eles.length;k++) watchIds.push(eles[k].id);
							}
						}
					} else {
						if(this._gridWatches[gridWatch].target != 'new'){
							if(this.pagesInGrid != 0) {
								for(var j=1;j<=this._rowsInGrid;j++) watchIds.push(this.gridId + '.V.R' + j + '.' + this._gridWatches[gridWatch].watch[i]);
							}
						}
						if(this._gridWatches[gridWatch].target == 'new' || this._gridWatches[gridWatch].target == 'all'){
							for(var j=1;j<=this._newRowsInGrid;j++) watchIds.push(this.gridId + '.V.R-' + j + '.' + this._gridWatches[gridWatch].watch[i]);
						}
					}
				}
			}			
			
			A5.Watch.add(this.gridId+'.'+gridWatch,watchIds,{
				onChange: this._gridWatches[gridWatch].onChange
			});
			
		}
		
		/*
		if($(this.gridId + '.GRIDSCROLLTABLE')) {
			var classInst = this;
			setTimeout(function() {
				if($(classInst.gridId + '.GRIDHEADERSCROLLTABLE')) $(classInst.gridId + '.GRIDHEADERSCROLLTABLE').style.width = $(classInst.gridId +'.GRIDSCROLLTABLE').offsetWidth + 'px';
				if($(classInst.gridId + '.GRIDFOOTERSCROLLTABLE')) $(classInst.gridId + '.GRIDFOOTERSCROLLTABLE').style.width = $(classInst.gridId +'.GRIDSCROLLTABLE').offsetWidth + 'px';
				classInst = null;
			},10);
		}
		*/
		
		
	},
	
	_LCS_clearLocks: function(name) {
		AUI.WaitDialog.clearLocal(this.parentGridAlias + '_LCS_' + name);
	},
	
	selectNamedLayout: function(name) {
		if(!this._executeEvent('canNamedLayoutSelect',{layoutName: name})) return false;
		this.ajaxCallback('G','none','__systemChangeLayoutName','','__selectedLayoutName='+name);
	},
	
	_setDetailViewControlsDisabledState: function() {
		var rele = $(this.gridId + '.DETAILVIEW_PART.FORM');
		if(this.detailViewEditMode == 'dvod' &&  this._editModeRows[0] != true && this._detailViewRow > 0 ) {
			eles = rele.getElementsByTagName('input');
			for(var i = 0; i < eles.length; i++) eles[i].disabled = true;
			eles = rele.getElementsByTagName('select');
			for(var i = 0; i < eles.length; i++) eles[i].disabled = true;
			eles = rele.getElementsByTagName('textarea');
			for(var i = 0; i < eles.length; i++) eles[i].disabled = true;			
		}
	},
	
	prepareDetailView: function() {
		if(this._detailViewRow == 0) {
			this._detailViewWindowState = '';
		} else {
			this._detailViewWindowState = 'open';
		}
		
		A5.form.prepare(this.gridId + '.DETAILVIEW_PART.FORM');
		var rele = $(this.gridId + '.DETAILVIEW_PART.FORM');
		$sa(rele,'A5OnDirty',this.gridId +'_GridObj._setDVControlDirty()');
		var eles = rele.getElementsByTagName('input');
		$e.add(eles,'focus',this._setDVControlFocus,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents');
		$e.add(eles,'blur',this._setDVControlBlur,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents');
		eles = rele.getElementsByTagName('select');
		$e.add(eles,'focus',this._setDVControlFocus,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents');
		$e.add(eles,'blur',this._setDVControlBlur,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents');
		
		for(var i=0;i<eles.length;i++) {
			if($ga(eles[i],'A5CascadingSelect') == 'true') {
				delete selectData;
				var selectData = new Object();
				selectData.value = eles[i].value;
				selectData.data = new Array();
				for(var j=0;j<eles[i].options.length;j++) {
					selectData.data.push([eles[i].options[j].text,eles[i].options[j].value]);
				}
				this._cascadingSelectChoices[eles[i].id] = selectData;
			}

		}
		
		eles = rele.getElementsByTagName('textarea');
		$e.add(eles,'focus',this._setDVControlFocus,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents');
		$e.add(eles,'blur',this._setDVControlBlur,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents');
		this._dvkw.off();
		
		this._setDetailViewState(false);
		this._setDetailViewControlsDisabledState();
		
		for(var fHelper in this._fieldHelpers_DV) {
			this._fieldHelpers_DV[fHelper].bind(this.gridId +'.D.V.R1.' + fHelper);
		}
		
		var fireWatchInitial = true;
		if(this._detailViewRow == 0) fireWatchInitial = false;
		
		for(var detailViewWatch in this._detailViewWatches) {
			var watchIds = new Array();
			//for(var i = 0;i<this._detailViewWatches[detailViewWatch].watch.length; i++) watchIds.push(this.gridId + '.D.V.R1.' + this._detailViewWatches[detailViewWatch].watch[i]);

			var eleTagName = '';
			var eles = 0;
			for(var i = 0;i<this._detailViewWatches[detailViewWatch].watch.length; i++){
				if(this._detailViewWatches[detailViewWatch].watch[i] == this.gridId + '.STATEINFO') watchIds.push(this.gridId + '.STATEINFO');
				else {
					tempEle = $(this.gridId + '.D.V.R1.' + this._detailViewWatches[detailViewWatch].watch[i]);
					eleTagName = '';
					if(tempEle) eleTagName = tempEle.tagName.toLowerCase();

					if(eleTagName != 'input' && eleTagName != 'select' && eleTagName != 'textarea'){
						eles = $n('V.R1.' + this._detailViewWatches[detailViewWatch].watch[i]);
						eles = $cetp(eles,$(this.gridId + '.DETAILVIEW_PART.FORM_CONTAINER_DIV'));
						for(var j=0;j<eles.length;j++) watchIds.push(eles[j].id);
					} else watchIds.push(this.gridId + '.D.V.R1.' + this._detailViewWatches[detailViewWatch].watch[i]);
				}
			}			

			
			A5.Watch.add(this.gridId+'.DV.'+detailViewWatch,watchIds,{
				fireInitial: fireWatchInitial,
				data: {rowNumber: this._detailViewRow},
				onChange: this._detailViewWatches[detailViewWatch].onChange
			});
		}
		
		if(this._detailViewRow > 0) this._executeEvent('onDetailViewRender',{rowNumber: this._detailViewRow});
		
		
		//ruud luiten
		//this solves problem: DV set to hide Grid when DV is open. DV set to show new record when no records in query. When user clears search, Grid, not DV should be shown
		if(this.detailViewPosition == 'page') {
			if(this.hideGridWhenDetailViewIsShown == true) {
				if(this._detailViewWindowState == 'open') {				
					var ele = $(this.gridId + '.GRID_PART.FORM_CONTAINER_DIV');
					ele.style.display = 'none';
				} 
			}
		}
		
		
		
	},

	animateToggle: function(ele) {
		var animateObj = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		if(typeof animateObj == 'boolean') animateObj = {type: 'slide', duration: 600};
		var pE = '';
		if(typeof ele == 'string') pE = $(ele);
		else pE = ele;
		if(!pE) return false;
		A5.u.element.toggle(pE,animateObj);
	},
	
	animateShow: function(ele) {
		var pE = '';
		if(typeof ele == 'string') pE = $(ele);
		else pE = ele;
		if(!pE) return false;
		if(pE.style.display == '') return false;
		this.animateToggle(ele,arguments[1]);
	},
	
	animateHide: function(ele) {
		var pE = '';
		if(typeof ele == 'string') pE = $(ele);
		else pE = ele;
		if(!pE) return false;
		if(pE.style.display == 'none') return false;
		this.animateToggle(ele,arguments[1]);
	},


	_showInlineDetailView: function() {
		if(this.detailViewPosition == 'inline') {
			var ele = $(this.gridId + '.RDV');
			if(this._detailViewRow == -1) {
				var pele = $(this.gridId + '.R' + this._rowsInGrid).nextSibling;
			} else { 
				var pele = $(this.gridId + '.R' + this._detailViewRow).nextSibling;
			}
			pele.parentNode.insertBefore(ele,pele);
			if($(this.gridId + '.DETAILVIEW_PART.COMPLETE').style.display == 'none') ele.style.display = 'none';
			else ele.style.display = '';
		}
	},
	
	
	
	_prepareRow: function(rowNum) {
		this._executeEvent('onRowRender',{rowNumber: rowNum});
		var rele = $(this.gridId + '.R' + rowNum);
		if(this.rowEditMode != '') {
			this._dirtyRows[rowNum-1] = false;
			if(this.rowEditMode == 'all' || this._editModeRows[rowNum-1]) {
				this._editModeRows[rowNum-1] = true;
			} else {
				this._editModeRows[rowNum-1] = false;
			}
			if(rele) {
				var eles = rele.getElementsByTagName('input');
				for(var i=0;i < eles.length; i++) {
					if($ga(eles[i],'A5HarvestIgnore') != 'true') {
						$e.add(eles[i],'keyup',this._setControlDirty,this,false,this.gridId+'.GRID');
						$e.add(eles[i],'change',this._setControlDirty,this,false,this.gridId+'.GRID');
						if(eles[i].type == 'checkbox' || eles[i].type == 'radio') $e.add(eles[i],'click',this._setControlDirty,this,false,this.gridId+'.GRID');
						if(!this._editModeRows[rowNum-1]) eles[i].disabled = true;
					}
				}
				$e.add(eles,'focus',this._setControlFocus,this,false,this.gridId+'.GRID');
				$e.add(eles,'blur',this._setControlBlur,this,false,this.gridId+'.GRID');
				eles = rele.getElementsByTagName('select');
				$e.add(eles,'keyup',this._setControlDirty,this,false,this.gridId+'.GRID');
				$e.add(eles,'change',this._setControlDirty,this,false,this.gridId+'.GRID');
				$e.add(eles,'focus',this._setControlFocus,this,false,this.gridId+'.GRID');
				$e.add(eles,'blur',this._setControlBlur,this,false,this.gridId+'.GRID');
				
				
				for(var i=0;i<eles.length;i++) {
					if($ga(eles[i],'A5CascadingSelect') == 'true') {
						delete selectData;
						var selectData = new Object();
						selectData.value = eles[i].value;
						selectData.data = new Array();
						for(var j=0;j<eles[i].options.length;j++) {
							selectData.data.push([eles[i].options[j].text,eles[i].options[j].value]);
						}
						this._cascadingSelectChoices[eles[i].id] = selectData;
					}
					if($ga(eles[i],'A5HarvestIgnore') != 'true') {
						if(!this._editModeRows[rowNum-1]) eles[i].disabled = true;
					}
				}
				
				
				eles = rele.getElementsByTagName('textarea');
				for(var i=0;i < eles.length; i++) {
					if($ga(eles[i],'A5HarvestIgnore') != 'true') {
						if(!this._editModeRows[rowNum-1]) eles[i].disabled = true;
					}
				}
				$e.add(eles,'keyup',this._setControlDirty,this,false,this.gridId+'.GRID');
				$e.add(eles,'change',this._setControlDirty,this,false,this.gridId+'.GRID');
				$e.add(eles,'focus',this._setControlFocus,this,false,this.gridId+'.GRID');
				$e.add(eles,'blur',this._setControlBlur,this,false,this.gridId+'.GRID');
				rele.setAttribute('A5DataRegion','A5DataRegion');
				if(this._editModeRows[rowNum-1]) {
					for(var fHelper in this._fieldHelpers_G) {
						this._fieldHelpers_G[fHelper].bind(this.gridId +'.V.R' + rowNum + '.' + fHelper);
					}
				}
			}
		}
		
		if(rele) {
			if(this.rowHoverClassName != '') {
				$e.add(rele,'mouseover',function (e,classInst){classInst._addRowClassName(this,classInst.rowHoverClassName);},this,false,this.gridId+'.GRID'); 
				$e.add(rele,'mouseout',function (e,classInst){classInst._removeRowClassName(this,classInst.rowHoverClassName);},this,false,this.gridId+'.GRID');
			}
			$e.add(rele,'click',this._focusRowClick,this,false,this.gridId+'.GRID');
			if(this.rowOnDblClick != '') {
				$e.add(rele,'dblclick',this._rowDblClick,this,false,this.gridId+'.GRID');
			}
			
			for(var gridRowWatch in this._gridRowWatches) {
				var watchIds = new Array();
				//for(var i = 0;i<this._gridRowWatches[gridRowWatch].watch.length; i++) watchIds.push(this.gridId + '.V.R' + rowNum + '.' + this._gridRowWatches[gridRowWatch].watch[i]);
				var eleTagName = '';
				var eles = 0;
				var tempEle = 0;
				for(var i = 0;i<this._gridRowWatches[gridRowWatch].watch.length; i++){
					if(this._gridRowWatches[gridRowWatch].watch[i] == this.gridId + '.STATEINFO') watchIds.push(this.gridId + '.STATEINFO');
					else {
						tempEle = $(this.gridId + '.V.R' + rowNum + '.' + this._gridRowWatches[gridRowWatch].watch[i]);
						eleTagName = '';
						if(tempEle) eleTagName = tempEle.tagName.toLowerCase();
						if(eleTagName != 'input' && eleTagName != 'select' && eleTagName != 'textarea'){
							eles = $n('V.R' + rowNum + '.' + this._gridRowWatches[gridRowWatch].watch[i]);
							eles = $cetp(eles,$(this.gridId + '.R' + rowNum));
							for(var j=0;j<eles.length;j++) watchIds.push(eles[j].id);
						} else watchIds.push(this.gridId + '.V.R' + rowNum + '.' + this._gridRowWatches[gridRowWatch].watch[i]);
					}
				}			
				A5.Watch.add(this.gridId+'.R' + rowNum + '.'+gridRowWatch,watchIds,{
					data: {rowNumber: rowNum},
					onChange: this._gridRowWatches[gridRowWatch].onChange
				});
			}		
		}
	},	
	
	_prepareNewRow: function(rowNum) {
		this._executeEvent('onRowRender',{rowNumber: rowNum*-1 });
		var rele = $(this.gridId + '.R-' + rowNum);
		if(rele) {
			$e.add(rele,'mouseover',function (e,classInst){classInst._addRowClassName(this,classInst.rowHoverClassName);},this,false,this.gridId+'.GRID'); 
			$e.add(rele,'mouseout',function (e,classInst){classInst._removeRowClassName(this,classInst.rowHoverClassName);},this,false,this.gridId+'.GRID');
		}
		this._dirtyNewRows[rowNum-1] = false;
		if(rele) {
			var eles = rele.getElementsByTagName('input');

			for(var i=0;i < eles.length; i++) {
				if($ga(eles[i],'A5HarvestIgnore') != 'true') {
					$e.add(eles[i],'keyup',this._setControlDirty,this,false,this.gridId+'.GRID');
					$e.add(eles[i],'change',this._setControlDirty,this,false,this.gridId+'.GRID');
					if(eles[i].type == 'checkbox' || eles[i].type == 'radio') $e.add(eles[i],'click',this._setControlDirty,this,false,this.gridId+'.GRID');
				}					
			}

			$e.add(eles,'focus',this._setControlFocus,this,false,this.gridId+'.GRID');
			$e.add(eles,'blur',this._setControlBlur,this,false,this.gridId+'.GRID');
			eles = rele.getElementsByTagName('select');
			$e.add(eles,'keyup',this._setControlDirty,this,false,this.gridId+'.GRID');
			$e.add(eles,'change',this._setControlDirty,this,false,this.gridId+'.GRID');
			$e.add(eles,'focus',this._setControlFocus,this,false,this.gridId+'.GRID');
			$e.add(eles,'blur',this._setControlBlur,this,false,this.gridId+'.GRID');

			for(var i=0;i<eles.length;i++) {
				if($ga(eles[i],'A5CascadingSelect') == 'true') {
					delete selectData;
					var selectData = new Object();
					selectData.value = eles[i].value;
					selectData.data = new Array();
					for(var j=0;j<eles[i].options.length;j++) {
						selectData.data.push([eles[i].options[j].text,eles[i].options[j].value]);
					}
					this._cascadingSelectChoices[eles[i].id] = selectData;
				}
			}


			eles = rele.getElementsByTagName('textarea');
			$e.add(eles,'keyup',this._setControlDirty,this,false,this.gridId+'.GRID');
			$e.add(eles,'change',this._setControlDirty,this,false,this.gridId+'.GRID');
			$e.add(eles,'focus',this._setControlFocus,this,false,this.gridId+'.GRID');
			$e.add(eles,'blur',this._setControlBlur,this,false,this.gridId+'.GRID');
			rele.setAttribute('A5DataRegion','A5DataRegion');
		
			
			for(var fHelper in this._fieldHelpers_G) {
				this._fieldHelpers_G[fHelper].bind(this.gridId +'.V.R-' + rowNum + '.' + fHelper);
			}

			for(var gridRowWatch in this._gridRowWatches) {
				var watchIds = new Array();
				//for(var i = 0;i<this._gridRowWatches[gridRowWatch].watch.length; i++) watchIds.push(this.gridId + '.V.R-' + rowNum + '.' + this._gridRowWatches[gridRowWatch].watch[i]);

				var eleTagName = '';
				var eles = 0;
				var tempEle = 0;
				for(var i = 0;i<this._gridRowWatches[gridRowWatch].watch.length; i++){
					if(this._gridRowWatches[gridRowWatch].watch[i] == this.gridId + '.STATEINFO') watchIds.push(this.gridId + '.STATEINFO');
					else {
						tempEle = $(this.gridId + '.V.R-' + rowNum + '.' + this._gridRowWatches[gridRowWatch].watch[i]);
						eleTagName = '';
						if(tempEle) eleTagName = tempEle.tagName.toLowerCase();


						if(eleTagName != 'input' && eleTagName != 'select' && eleTagName != 'textarea'){
							eles = $n('V.R-' + rowNum + '.' + this._gridRowWatches[gridRowWatch].watch[i]);
							eles = $cetp(eles,$(this.gridId + '.R-' + rowNum));
							for(var j=0;j<eles.length;j++) watchIds.push(eles[j].id);
						} else watchIds.push(this.gridId + '.V.R-' + rowNum + '.' + this._gridRowWatches[gridRowWatch].watch[i]);
					}
				}			
			
			
				A5.Watch.add(this.gridId+'.R-' + rowNum + '.'+gridRowWatch,watchIds,{
					data: {rowNumber: (rowNum*-1)},
					onChange: this._gridRowWatches[gridRowWatch].onChange
				});
			}
		}
		
	},
	
	_prepareRowEvents: function() {
		/*THIS IS OBSOLETE. SEE prepareGrid()
		if(this._rowsInGrid == 0) return false;
		var rowIds = new Array();
		for(var i=1;i<=this._rowsInGrid;i++) {
			rowIds.push(this.gridId + '.R' + i);		
		}
		$e.add(rowIds,'mouseover',function (e,classInst){$acn(this,classInst.rowHoverClassName);},this,false,this.gridId+'.GRID'); 
		$e.add(rowIds,'mouseout',function (e,classInst){$rcn(this,classInst.rowHoverClassName);},this,false,this.gridId+'.GRID');
		$e.add(rowIds,'click',this._focusRowClick,this,false,this.gridId+'.GRID');
		if(this.rowOnDblClick != '') {
			$e.add(rowIds,'dblclick',this._rowDblClick,this,false,this.gridId+'.GRID');
		}
		*/
	},

	_rowDblClick: function(e, classInst) {
		var rowNum = Number(this.id.split('.')[1].substr(1));
		if(classInst.rowOnDblClick.constructor == Function) {
			classInst.rowOnDblClick(rowNum);
		} else if(classInst.rowOnDblClick != '') {
			if(classInst[classInst.rowOnDblClick]) classInst[classInst.rowOnDblClick](rowNum);
		}
		
	},

	_setControlDirty: function(e,classInst) {
		classInst.setControlDirty(this,true);
	},
	
	
	_constrainElementsToParent: function(eles, pEle) {
		var eles2 = new Array();
		for(var i=0;i<eles.length;i++){
			if($isChild(eles[i],pEle)){
				eles2.push(eles[i]);
			}
		}
		return eles2;
	},
	
	setControlDirty: function(ele) {
		var setRowState = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		if(this._batchChange) setRowState = false;
		var rowNum = Number(ele.name.split('.')[1].substr(1));
		var columnNum = this._colNumFromName(this._gridColNames,ele.name.split('.')[2]);
		var eles = this._constrainElementsToParent($n(ele.name),$(this.gridId+'.R'+rowNum));
		if(rowNum < 0) {
			//new record row
			if(!$u.compare($gvs(eles),this._newValues[columnNum])) {
				$sa(eles,'A5IsDirty','true');
				if(setRowState) this._setRowState(rowNum,true);
			}		
		} else {
			if(this._originalValues[rowNum-1]) {
				if(!$u.compare($gvs(eles),this._originalValues[rowNum-1][columnNum])) {
					$sa(eles,'A5IsDirty','true');
					if(setRowState) {
						if(this.rowRefreshOnDirty && !this._dirtyRows[rowNum-1])  this.refreshRow(rowNum,true);
						this._setRowState(rowNum,true);
					}
				}
			}
		}
		
	},
	
	
	_focusRowClick: function(e,classInst){
		if(classInst._focusRow != 0 && classInst._focusRow != Number(this.id.split('.')[1].substr(1))) $rcn(classInst.gridId+'.R'+classInst._focusRow,classInst.rowSelectedClassName);
		else classInst._kw.on();
		classInst._focusRow = Number(this.id.split('.')[1].substr(1));
		if(classInst._focusControl == '') classInst._focusControl = classInst._gridColNames[0];
		if(!classInst._editModeRows[classInst._focusRow-1]) {
			var ele = $(classInst.gridId+'.FOCUSCATCHER');
			//ele.style.top = $gpt($(classInst.gridId+'.R'+classInst._focusRow))+'px';
			var rele = $(classInst.gridId+'.R'+classInst._focusRow);
			if(rele.offsetParent) ele.style.top = ($gpt(rele)-$gpt(rele.offsetParent))+'px';
			ele.blur();
			$f(ele);
		}
		//Until such time as we clarify focus and selected row behavior
		//when the user clicks on a row, make it the selected row
		classInst.setSelectedRow(classInst._focusRow,true);
	},	
	
	
	closeContainerWindow: function(ele) {
		//if grid is opened in a window, closes the container window
	    var cw = A5.windows.getFromElement(ele);
	    if(cw) cw.hide();
	},
	
	
	activateControlContainer: function(name,part,rowNum) {
		name = name.toUpperCase();
		part = part.toUpperCase();
		if(part == 'G') {
			if(typeof this._controlContainers_G != 'undefined') {
				var obj = this._controlContainers_G[name];
			}
		}
		if(part == 'D') {
			if(typeof this._controlContainers_D != 'undefined') {
				var obj = this._controlContainers_D[name];
			}
		}
		if(part == 'S') {
			if(typeof this._controlContainers_S != 'undefined') {
				var obj = this._controlContainers_S[name];
			}
		}
		if(typeof obj != 'object') return false;
		var containerName = '';
		for(var i = 0; i < obj.length; i++) {
			containerName = this.gridId + '_' + obj[i].tab +'R_' + rowNum +'Obj';
			window[containerName].select(''+obj[i].pane);
		}
	},
	

	
	_setControlFocus: function(e,classInst) {

		//check to see if the current control that has focus is the focus catcher ( a dummy control for rows that are not in edit mode)		
		//also checks to see if there is no focus row.
		if(this.id == classInst.gridId+'.FOCUSCATCHER' && classInst._focusRow == 0){
			classInst._focusRow = 1;
			if(classInst._editModeRows[0]){
				classInst._focusControl = classInst._gridColNames[0];
				$f(classInst.gridId+'.R'+(classInst._focusRow)+'.'+classInst._focusControl);
				classInst._kw.on();
				return false;				
			}
		}
		if(classInst._focusRow != 0){
			clearTimeout(classInst._focusRowTO);
			classInst._executeEvent('onRowBlur', {rowNumber: classInst._focusRow});
		} else classInst._kw.on();
		if(this.id != classInst.gridId+'.FOCUSCATCHER'){
			//protect against errors if user creates their own input control in a freeform section
			var nameSplit = this.name.split('.');
			if(nameSplit.length > 2) {
				if(Number(nameSplit[1]) != NaN) {
					classInst._focusRow = Number(nameSplit[1].substr(1));
					classInst._focusControl = nameSplit[2];
					classInst._executeEvent('onRowFocus', {rowNumber: classInst._focusRow});
				}
			}
		}
		classInst.setSelectedRow(classInst._focusRow, true);
	},
	
	_setControlBlur: function(e,classInst){
		if(classInst._focusRow != 0) classInst._focusRowTO = setTimeout(function(){classInst._completeControlBlur();},100);
		if(this.name != '') {
			var rowNum = Number(this.name.split('.')[1].substr(1));
			var colName = this.name.split('.')[2];
			//classInst.clientSideValidateField('G',colName,rowNum);
			//if you make a selection from an edit-combo, the validation was firing when you clicked in the edit-combo
			var classInst2 = classInst;
			setTimeout(function() {classInst2.clientSideValidateField('G',colName,rowNum); delete classInst2; },400);
		}
	},

	_completeControlBlur: function(){
		$rcn(this.gridId+'.R'+this._focusRow,this.rowSelectedClassName);
		this._focusRow = 0;
		this._kw.off();
	},

	_setDVControlFocus: function(e,classInst) {
		//$('GRID1.RECORDCOUNT.TOP').innerHTML = $('GRID1.RECORDCOUNT.TOP').innerHTML + 'focus: ' + this.id + '<br>';
		classInst._dvkw.on();
		//protect against errors if user creates their own input control in a freeform section
		if(this.name != '') {
			var nameSplit = this.name.split('.');
			if(nameSplit.length > 2) {
				classInst._dvFocusControl = nameSplit[2];
			}
		}

	},
	
	_setDVControlBlur: function(e,classInst){
		classInst._dvkw.off();
		classInst._dvFocusControl = '';
		if(this.name != '') {		
			var rowNum = Number(this.name.split('.')[1].substr(1));
			var colName = this.name.split('.')[2];
			//classInst.clientSideValidateField('D',colName,rowNum);
			//if you make a selection from an edit-combo, the validation was firing when you clicked in the edit-combo
			setTimeout(function() {classInst.clientSideValidateField('D',colName,rowNum); delete classInst; },400);
		}
	},

	_setDVControlDirty: function(){
		if(!this._detailViewIsDirty && !this._batchChange) {
			if(this.detailViewRefreshOnDirty) this.detailViewRefresh() ;
			this._setDetailViewState(true);
		} else if(this._batchChange) $sa(this.gridId + '.DETAILVIEW_PART.FORM','A5IsDirty','false');
	},

	
	_enable: function(ele,flag) {
		if($(ele)) ele = $(ele);
		else return false;
		
		if(flag) {
			ele.disabled = false;
			ele.setAttribute('A5Disabled','false');
			ele.style.opacity = ''; 
			ele.style.filter = '';
			var eles = ele.getElementsByTagName('img');
			$ss(eles,{opacity: '', filter: ''});
		} else {
			ele.disabled = true;
			ele.setAttribute('A5Disabled','true');
			ele.style.opacity = '.5'; 
			ele.style.filter = 'alpha(opacity: 50)';
			ele.style.zoom = '1';
			var eles = ele.getElementsByTagName('img');
			$ss(eles,{opacity: '.5', filter: 'alpha(opacity: 50)', zoom: '1'});
		}
	},
	
	_setInitialData: function(data) {
		this._originalValues = data;
	},
	
	_setInitialNulls: function(data) {
			this._originalNullValues = data;
	},
	
	_setInitialDVData: function(data) {
			this._originalDVValues = data;
		},
	
	
	_populateCont: function(contId,htmlText) {
		if($(contId)) {
			$(contId).innerHTML = htmlText;
		} 
			
	},
	
	_navInputOnKey: function(e,classInst) {
		var keyCode = e.charCode || e.keyCode;
		if(keyCode == 13) {
			classInst.pageNavigate(this.value);
		}
	},
	
	_showGridErrorColumn: function(show) {
		//to support legacy grids before v10.5 that use a different method of show/hide on error column 
		if(show) $rcn(this.gridId+'.GRID_PART.DATAREGION','A5GridHideErrorCol');
		else $acn(this.gridId+'.GRID_PART.DATAREGION','A5GridHideErrorCol');
		
		var ele = 0;
		var sdis = $if(show, '','none');
		
		for(var i = 1; i <= this._rowsInGrid; i++) {
			ele = $(this.gridId + '.TD.R' + i + '.__SYSTEM_ERRORCOLUMN');
			if(ele) ele.style.display = sdis;
			ele = $(this.gridId + '.TD.R' + i + '.__ROWEXPAND.__SYSTEM_ERRORCOLUMN');
			if(ele) ele.style.display = sdis;
		}
		for(var i = 1; i <= this._newRowsInGrid; i++) {
			ele = $(this.gridId + '.TD.R-' + i + '.__SYSTEM_ERRORCOLUMN');
			if(ele) ele.style.display = sdis;
			ele = $(this.gridId + '.TD.R-' + i + '.__ROWEXPAND.__SYSTEM_ERRORCOLUMN');
			if(ele) ele.style.display = sdis;
		}

		ele = $(this.gridId + '.COLUMNTITLES.TOP.__SYSTEM_ERRORCOLUMN');
		if(ele) ele.style.display = sdis;

		ele = $(this.gridId + '.COLUMNTITLES.BOTTOM.__SYSTEM_ERRORCOLUMN');
		if(ele) ele.style.display = sdis;
	
		ele = $(this.gridId + '.TD.R_QBE.__SYSTEM_ERRORCOLUMN');
		if(ele) ele.style.display = sdis;

		ele = $(this.gridId + '.TD.R_EMBSRC.__SYSTEM_ERRORCOLUMN');
		if(ele) ele.style.display = sdis;
	
		
	},
	showGridColumn: function(colName,show) {
		if(show) {
			if( $u.a.find(this._hiddenCols,colName) != -1) {
				this._hiddenCols.splice($u.a.find(this._hiddenCols,colName),1);
				this._showGridColumn(colName,show);
			}
		} else {
			if( $u.a.find(this._hiddenCols,colName) == -1) {
				this._hiddenCols.push(colName);
				this._showGridColumn(colName,show);
			}		
		}
	},
	
	_showGridColumn: function(colName,show) {
			
		var ele = 0;
		var sdis = $if(show, '','none');

		for(var i = 1; i <= this._rowsInGrid; i++) {
			ele = $(this.gridId + '.TD.R' + i + '.'+colName);
			if(ele) ele.style.display = sdis;
		}
		for(var i = 1; i <= this._newRowsInGrid; i++) {
			ele = $(this.gridId + '.TD.R-' + i + '.'+colName);
			if(ele) ele.style.display = sdis;
		}

		ele = $(this.gridId + '.COLUMNTITLES.TOP.'+colName);
		if(ele) ele.style.display = sdis;

		ele = $(this.gridId + '.COLUMNTITLES.BOTTOM.'+colName);
		if(ele) ele.style.display = sdis;

		ele = $(this.gridId + '.TD.R_QBE.'+colName);
		if(ele) ele.style.display = sdis;

		ele = $(this.gridId + '.TD.R_EMBSRC.'+colName);
		if(ele) ele.style.display = sdis;
		
			
	},
	
	_addRowsFromTemplate: function(numberOfRows,data) {
		var cele = 0;
		var pele = 0;
		var ele = $(this.gridId + '.GRID.ROWTEMPLATE');
		var dataIndex = 0;
		var funcData = '';
		this._rowsInGrid = this._rowsInGrid + 1 ;
		for(var i = this._rowsInGrid; i < this._rowsInGrid + numberOfRows; i++) {
			for(var prop in data[dataIndex]) {
				data[dataIndex][prop] = data[dataIndex][prop].replace(/\{grid\.rowNumber\}/ig,'' + this._rowsInGrid);
			}
			cele = ele.cloneNode(true);
			
			pele = $(this.gridId + '.R' + (i-1) );
			pele.parentNode.insertBefore(cele,pele.nextSibling);
			cele.id = this.gridId + '.R' + i ;
	
			if(cele.onclick){
				funcData = cele.onclick.toString().split('{ROW:INDEX}').join(''+i);
				//Firefox 'fixed' {ROW:INDEX}' and makes it into '{ROW: INDEX}'
				funcData = funcData.split('{ROW: INDEX}').join('' + i );
				funcData = funcData.split('{');
				funcData.shift();
				funcData = funcData.join('{');
				funcData = funcData.split('}');
				funcData.pop();
				funcData = funcData.join('}');
				cele.onclick = Function(funcData);
			}
			if(cele.ondblclick){
				funcData = cele.ondblclick.toString().split('{ROW:INDEX}').join(''+i);
				//Firefox 'fixed' {ROW:INDEX}' and makes it into '{ROW: INDEX}'
				funcData = funcData.split('{ROW: INDEX}').join('' + i );
				funcData = funcData.split('{');
				funcData.shift();
				funcData = funcData.join('{');
				funcData = funcData.split('}');
				funcData.pop();
				funcData = funcData.join('}');
				cele.ondblclick = Function(funcData);
			}
			this._parseControlTemplateRow(cele, data[dataIndex]);
			this._parseTemplateRow(cele,i);
			this._prepareRow(i);
			var ele = 0;
			
			if(this._reh._e.length != 0) {
				ele = $(this.gridId + '.TD.R' + i + '.__SYSTEM_ERRORCOLUMN');
				if(ele) ele.style.display = '';
				ele = $(this.gridId + '.TD.R' + i + '.__ROWEXPAND.__SYSTEM_ERRORCOLUMN');
				if(ele) ele.style.display = '';
				}
			
			dataIndex++;
		}
		this._rowsInGrid = this._rowsInGrid + (numberOfRows -1);
		this._reband();
	},
	
	_parseControlTemplateRow: function(ele,data) {
		var sele = 0;
		var tdele = 0;
		var thtml = '';
		for(var i = 0; i < ele.childNodes.length; i++) {
			sele = ele.childNodes[i];
			if(sele.tagName) {
				for(var j = 0; j < sele.childNodes.length; j++) {
					tdele = sele.childNodes[j];
					if(tdele.innerHTML) {
						if(tdele.tagName != '!') {
							thtml = tdele.innerHTML;
							for(var prop in data) {
								
								thtml = thtml.split('{' + prop + '}').join(data[prop]);				
								
							}
							tdele.innerHTML = thtml;
						}
					}
				}
			}
		}
	},
	
	_parseTemplateRow: function(ele,row) {
		for(var i = 0; i < ele.childNodes.length; i++) {
			if(typeof ele.childNodes[i].tagName != 'undefined') {
				if(ele.childNodes[i].id) ele.childNodes[i].id = ele.childNodes[i].id.split('{ROW:INDEX}').join(''+row);
				if(ele.childNodes[i].name) {
					ele.childNodes[i].name = ele.childNodes[i].name.split('{ROW:INDEX}').join(''+row);
				}
				if(ele.childNodes[i].onclick){
					var data = ele.childNodes[i].onclick.toString().split('{ROW:INDEX}').join(''+row);
				
					//Firefox 'fixed' {ROW:INDEX}' and makes it into '{ROW: INDEX}'
					data = data.split('{ROW: INDEX}').join('' + row );
					data = data.split('{');
					data.shift();
					data = data.join('{');
					data = data.split('}');
					data.pop();
					data = data.join('}');
					if(data.constructor == Array) data = data.join('');
					ele.childNodes[i].onclick = Function(data);
				}
				if(ele.childNodes[i].childNodes.length > 0) this._parseTemplateRow(ele.childNodes[i],row);		
			}
		}
	},
	
	
	_reband: function(){
		
		if(!this.banding.enabled) return false;
		var obj = new Object();
		var tdObj = new Object();
		var curOffset = 0;
		var curRows = this.banding.oddRowCount;
		var curClass = this.banding.oddRowClassName;
		var curType = 'o';
		for(var i=1;i<=(this._rowsInGrid + this._newRowsInGrid) ;i++){
			if(i <= this._rowsInGrid) obj = $(this.gridId+'.R'+i);
			else obj = $(this.gridId+'.R-'+(i - this._rowsInGrid));
			if(obj.style.display != 'none'){
				curOffset = curOffset+1;
				if(curOffset > curRows){
					if(curType == 'o'){
						curOffset = 1;
						curRows = this.banding.evenRowCount;
						curClass = this.banding.evenRowClassName;
						curType = 'e';
					} else{
						curOffset = 1;
						curRows = this.banding.oddRowCount;
						curClass = this.banding.oddRowClassName;
						curType = 'o';
					}
				}
				tdObj = obj.getElementsByTagName('td');
				for(var j=0;j<tdObj.length;j++) {
					if(tdObj[j].className.indexOf(curClass) == -1 && (tdObj[j].className.indexOf(this.banding.oddRowClassName) != -1 || tdObj[j].className.indexOf(this.banding.evenRowClassName) != -1)) {
						if(curType == 'o') $rcn(tdObj[j],this.banding.evenRowClassName);
						else $rcn(tdObj[j],this.banding.oddRowClassName);
						$acn(tdObj[j],curClass);
					}
				}
			}
		}
	},

	
	_gridQBEExecute: function(qbeType) {
	
		if(!this._executeEvent('canQBESearch',{qbeType: qbeType})) return false;
		var columnNum = this._colNumFromName(this._gridColNames,this._gridQBEColumn);
		var data = $(this.gridId +'.STATEINFO').value;
		var qbeValue = $gvs(this.gridId + '.QBE.V.' + $u.s.rTrim(this._gridQBEColumn,'[]'));
		data = data+'&'+A5.ajax.buildURLParam('_gridQBEValue',qbeValue);
		
		if(typeof this._qbeQueryMenu == 'undefined') {
			qbeValue = $gvs(this.gridId + '.QBE.EXCLUDEMATCHES');
			this.gridColumnInfo[columnNum].qbe.exclude = qbeValue;
		} else {
			qbeValue = this._qbeQueryMenu.getValue('ExcludeMatchingRecords');
			this.gridColumnInfo[columnNum].qbe.exclude = qbeValue;
		}
		if(typeof qbeValue == 'boolean') qbeValue = $if(qbeValue,'on','off');
		
		data = data+'&'+A5.ajax.buildURLParam('_gridQBEExcludeMatches',''+qbeValue);
		
		
		if(typeof this._qbeQueryMenu == 'undefined') {
			qbeValue = $gvs(this.gridId + '.QBE.ANDOR');
		} else {
			qbeValue = this._qbeQueryMenu.getValue('AndOr');
		}
		data = data+'&'+A5.ajax.buildURLParam('_gridQBEAndOr',qbeValue);
		this.gridColumnInfo[columnNum].qbe.andOr = qbeValue;
		this.gridColumnInfo[columnNum].qbe.operator = qbeType;
		
		data = data + '&__FormAction=QBE_Grid&__FormID=' + this.gridId+'&_gridQBEColumn='+this._gridQBEColumn + '&_gridQBEType='+qbeType;
		data = $u.s.tran(data,'\n','%0D%0A');
		data = data + '&__dvWindow=' + this._detailViewWindowState;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'QBESearch'})
		A5.ajax.callback(this.ajaxURL,data);
	},
	
	
	
	_gridQBEMenu: function(e,classInst) {
		if(typeof classInst._qbeQueryMenu == 'undefined') {
			var ele = $(classInst.gridId + '.QBE.MENU');
			ele.style.display = '';
			$po(ele,this,'dropdown');
			$e.add(document.body,'click',classInst._gridQBEMenuClear,classInst,true);
			classInst._gridQBEColumn = $u.s.word(this.id,-1,'.');

			var columnNum = classInst._colNumFromName(classInst._gridColNames,classInst._gridQBEColumn);
			$svs(classInst.gridId + '.QBE.EXCLUDEMATCHES',classInst.gridColumnInfo[columnNum].qbe.exclude);
			$svs(classInst.gridId + '.QBE.ANDOR',classInst.gridColumnInfo[columnNum].qbe.andOr);
			//take operator name (greater than or equal to) and remove spaces and then make uppercase, so it matches the menu item id.
			var searchVal = classInst.gridColumnInfo[columnNum].qbe.operator.replace(/ /g,'').toUpperCase();
			if(searchVal=='') searchVal = 'NOFILTER';
			var eles = ele.getElementsByTagName('img');
			for(var i=0;i<eles.length;i++){
				if($u.s.word(eles[i].id,3,'.') == 'CHECKICON') {
					if($u.s.word(eles[i].id,-1,'.') == searchVal) eles[i].style.visibility = '';
					else eles[i].style.visibility = 'hidden';
				}
			}

			var searchArray = classInst._qbeMenu[classInst.gridColumnInfo[columnNum].dataType];
			if(typeof searchArray == 'undefined') searchArray = classInst._qbeMenu.c;
			searchArray.push('NOFILTER');


			eles = ele.getElementsByTagName('li');
			for(var i=0;i<eles.length;i++){
				if($u.s.word(eles[i].id,3,'.') == 'ITEM') {
					if($u.a.find(searchArray,$u.s.word(eles[i].id,-1,'.')) != -1) eles[i].style.display = '';
					else eles[i].style.display = 'none';
				}
			}
		} else {
			classInst._gridQBEColumn = $u.s.word(this.id,-1,'.');
			var columnNum = classInst._colNumFromName(classInst._gridColNames,classInst._gridQBEColumn);
			classInst._qbeQueryMenu.setValue('ExcludeMatchingRecords',classInst.gridColumnInfo[columnNum].qbe.exclude);
			classInst._qbeQueryMenu.setValue('AndOr',classInst.gridColumnInfo[columnNum].qbe.andOr);
			var qbeval = classInst.gridColumnInfo[columnNum].qbe.operator;
			if(qbeval == '') qbeval = 'No filter';
			classInst._qbeQueryMenu.setValue('QBEValue',qbeval);
			
			var searchArray = classInst._qbeMenu[classInst.gridColumnInfo[columnNum].dataType];
			if(typeof searchArray == 'undefined') searchArray = classInst._qbeMenu.c;
			searchArray.push('NOFILTER');
			
			//number of items in the menu, not including the exclude and and/or items
			var item = 0;
			for(var i = 2; i < 17; i++) {
				item = classInst._qbeQueryMenu._data[i];
				if($u.a.find(searchArray,item.name.replace(/ /g,'').toUpperCase()) != -1) $(item._id).style.display = 'block';
				else $(item._id).style.display = 'none';
				
			}
			
			classInst._qbeQueryMenu.show('dropdown',this);

			
		}
		$e.stopEvent(e);
		return false;
		
	},
	
	_gridQBEMenuClear: function() {
		var ele = $(this.gridId + '.QBE.MENU');
		if(ele) {
			ele.style.display = 'none';
			$e.remove(document.body,'click',this._gridQBEMenuClear);
		}
	},
	
	_gridQBEClearColumnInfo: function() {
		for(i=1;i<=this.gridColumnInfo.length;i++) {
			if(this.gridColumnInfo[i-1].qbe) {
				this.gridColumnInfo[i-1].qbe.operator = '';
				this.gridColumnInfo[i-1].qbe.exclude = '';
				this.gridColumnInfo[i-1].qbe.andOr = 'AND';
			}
		}
	
	},
	
	gridQBERowVisible: function(isVisible) {
		ele = $(this.gridId + '.QBE_ROW');
		if(isVisible == true) {
			if(!this._executeEvent('canQBEShow',{})) return false;
			ele.style.display = '';
			this._executeEvent('afterQBEShow',{})
		} else {
			if(!this._executeEvent('canQBEHide',{})) return false;
			ele.style.display = 'none';
			this._executeEvent('afterQBEHide',{})
		}
		
		var data = $(this.gridId +'.STATEINFO').value;
		var arr = new Array();
		arr = data.split('&');
		var indx = $u.a.find(arr,'__si.QBEState',false,false);
		var QBEState = '__si.QBEState=' + isVisible
		if(indx == -1) {
			if(data == '') data = QBEState;
			else data = data + '&' + QBEState;
		} else {
			arr[indx] = QBEState;
			data = arr.join('&');
		}
		$(this.gridId +'.STATEINFO').value = data;
	
	},
	
	gridQBERowToggle: function() {
		ele = $(this.gridId + '.QBE_ROW');
		if(ele.style.display == 'none') this.gridQBERowVisible(true);
		else this.gridQBERowVisible(false);
	},
	
	
	loadJavascript: function(txt) {
		var sEle = document.getElementsByTagName('script');
		var cancelAdd = false;
		for(var i=0; i < sEle.length; i++) {
			if(sEle[i].text == txt) { 
				cancelAdd = true;
				break;
			}
		}
		
		if(cancelAdd == false) {
			var e = document.createElement('script');
			e.text = txt;
			document.getElementsByTagName('head')[0].appendChild(e);
		}
	},
	
	loadJavascriptFile: function(filename) {
		var onLoaded = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		var sEle = document.getElementsByTagName('script');
		var cancelAdd = false;
		for(var i=0; i < sEle.length; i++) {
			if(sEle[i].src == filename) { 
				cancelAdd = true;
				break;
			}
		}
		if(cancelAdd == false) {
			var e = document.createElement('script');
			e.src = filename;
			e.onload = function() {
				if(typeof jQuery != 'undefined') jQuery.noConflict();
				if(onLoaded.constructor == Function) onLoaded();
			};
			
			e.onreadystatechange = function() {
				if(this.readyState == 'complete' || this.readyState == 'loaded') {
					if(typeof jQuery != 'undefined') jQuery.noConflict();
					if(onLoaded.constructor == Function) onLoaded();
				}
			};
			document.getElementsByTagName('head')[0].appendChild(e);
			
		}
	},
	
	loadMetaTag: function(name,txt) {
			var e = document.createElement('meta');
			e.name = name;
			e.content = txt;
			document.getElementsByTagName('head')[0].appendChild(e);
	},
	
	loadCSSFile: function(filename) {
			var forceLoad = typeof arguments[1] != 'undefined' ? arguments[1] : false;
			var sEle = document.getElementsByTagName('link');
			var cancelAdd = false;
			if(forceLoad == false) {
				for(var i=0; i < sEle.length; i++) {
					if(sEle[i].href.indexOf(filename) > 0) { 
						cancelAdd = true;
						break;
					}
				}
			}
			if(cancelAdd == false) {
				var e = document.createElement('link');
				e.href = filename;
				e.rel = 'stylesheet';
				e.type = 'text/css';
				document.getElementsByTagName('head')[0].appendChild(e);
			}
	},
	
	loadXbasic: function(txt) {
			var versionNum = typeof arguments[1] != 'undefined' ? arguments[1] : '';
			
			if(this._embeddedMode == false) return false;
			var sEle = document.getElementsByTagName('script');
			var cancelAdd = false;
			for(var i=0; i < sEle.length; i++) {
				if(typeof sEle[i].language != 'undefined') {
					if(sEle[i].language.toLowerCase() == 'xbasic' + versionNum) {
						if(sEle[i].text.toLowerCase()  == txt.toLowerCase()) { 
							cancelAdd = true;
							break;
						}
					}
				}
			}
			if(cancelAdd == false) {
				var e = document.createElement('script');
				e.text = txt;
				e.language = 'Xbasic' + versionNum;
				document.getElementsByTagName('head')[0].appendChild(e);
			}
	},
	
	
	
	
	a5AjaxGridMozFixRowPost: function(rowId) {
			var ele = $(rowId);
			if(ele.style.height == ele.offsetHeight+'px') ele.style.height = '';
			var eles = ele.getElementsByTagName('input');
			for(var i=0;i<eles.length;i++){
				if(eles[i].style.height == eles[i].offsetHeight+'px') eles[i].style.height = '';
			}
			eles = ele.getElementsByTagName('select');
			for(var i=0;i<eles.length;i++){
				if(eles[i].style.height == eles[i].offsetHeight+'px') eles[i].style.height = '';
			}
			eles = ele.getElementsByTagName('textarea');
			for(var i=0;i<eles.length;i++){
				if(eles[i].style.height == eles[i].offsetHeight+'px') eles[i].style.height = '';
			}
	},
	
	
	createWindow: function(name,settings) {
		if(!this.getWindow(name)) {
			if(typeof settings == 'string') {
				var parts = settings.split('-');
				settings = new Object();
				$u.o.assign(settings , this._defaultWindowSettings[parts.shift()]);
				for(var i=0;i<parts.length;i++){
					if(parts[i] == 'url'){
						settings.body.content.type = 'url';
						settings.body.content.url = 'about:blank';
					} else if(parts[i] == 'resizable'){
						settings.resize = 'both';
					}
				}
			}
			if(typeof arguments[2] == 'object') $u.o.assign(settings,arguments[2]);
			this._genericWindow[name] = new A5.Window(settings);
		}
		return this._genericWindow[name];
	},
	
	getWindow: function(name) {
		if(typeof this._genericWindow[name] != 'undefined' ) return this._genericWindow[name];
		return false;
	},
	
	setVariables: function(vars) {
		if($u.compare(this._vars,vars) == false ) {
			$u.o.assign(this._vars,vars);
			$e.execute(this.gridId + '.STATEINFO','change');
		}
	},
	
	
	/*Keywatch Events*/
	
	_keyOpenLookupWindow: function() {
		if(typeof this._floatingLookupWindow[this._focusControl] != 'undefined') {
			this.openLookup('G',this._focusRow,this._focusControl);
		}
		return true;
	},
	
	
	
	
	_keyPageUp: function(){
		clearTimeout(this._keyPageNavigateTO);
		var classInst = this;
		this._keyPageNavigateTO = setTimeout(function() {
			classInst.pageNavigate('prev');
			delete classInst;
		},200);
		return true;
	},
	
	_keyPageDown: function(){
		clearTimeout(this._keyPageNavigateTO);
		var classInst = this;
		this._keyPageNavigateTO = setTimeout(function() {
			classInst.pageNavigate('next');
			delete classInst;
		},200);
		return true;
	},

	_keyPrevRow: function(){
		if(this._editModeRows[this._focusRow-1] || this._focusRow < 0){
			if($n(this.gridId+'.V.R'+(this._focusRow)+'.'+this._focusControl)[0].tagName.toLowerCase() != 'input') return false;
		} 
		if(this._focusRow == 1){
			if(this.pageNumber != 1) {
				clearTimeout(this._keyPageNavigateTO);
				var classInst = this;
				this._keyPageNavigateTO = setTimeout(function() {
					classInst.pageNavigate('prev');
					delete classInst;
				},200);
			}
		} else if(this._focusRow < 0) {
			if(this._focusRow == -1) {
				if(!this._editModeRows[this._rowsInGrid-1]){
					this._focusRowClick.call($(this.gridId+'.R'+(this._rowsInGrid)),null,this);
					$f(this.gridId+'.FOCUSCATCHER');
				} else $f(this.gridId+'.V.R'+(this._rowsInGrid)+'.'+this._focusControl);
			} else {
				$f(this.gridId+'.V.R'+(this._focusRow+1)+'.'+this._focusControl);
			}
		} else{
			if(!this._editModeRows[this._focusRow-2]){
				this._focusRowClick.call($(this.gridId+'.R'+(this._focusRow-1)),null,this);
				$f(this.gridId+'.FOCUSCATCHER');
			} else $f(this.gridId+'.V.R'+(this._focusRow-1)+'.'+this._focusControl);
			//this.setSelectedRow(this._focusRow - 1,true);
		}
		return true;
	},
	_keyNextRow: function(e){
		if(this._editModeRows[this._focusRow-1] || this._focusRow < 0 ){
			if($n(this.gridId+'.V.R'+(this._focusRow)+'.'+this._focusControl)[0].tagName.toLowerCase() != 'input') return false;
		}
		if(this._focusRow == this._rowsInGrid){
			if(this._newRowsInGrid == 0) {
				if(this.pageNumber < this.pagesInGrid) {
					clearTimeout(this._keyPageNavigateTO);
					var classInst = this;
					this._keyPageNavigateTO = setTimeout(function() {
						classInst.pageNavigate('next');
						delete classInst;
					},200);
				}
			} else $f(this.gridId+'.V.R-1.'+this._focusControl);
		} else if(this._focusRow < 0) {
			if(Math.abs(this._focusRow) == this._newRowsInGrid) {
				if(this.pageNumber < this.pagesInGrid) 	{
					clearTimeout(this._keyPageNavigateTO);
					var classInst = this;
					this._keyPageNavigateTO = setTimeout(function() {
						classInst.pageNavigate('next');
						delete classInst;
					},200);
				}
			} else $f(this.gridId+'.V.R'+(this._focusRow-1)+'.'+this._focusControl);
		} else{
			if(!this._editModeRows[this._focusRow]){
				this._focusRowClick.call($(this.gridId+'.R'+(this._focusRow+1)),null,this);
				$f(this.gridId+'.FOCUSCATCHER');
			} else $f(this.gridId+'.V.R'+(this._focusRow+1)+'.'+this._focusControl);
			//this.setSelectedRow(this._focusRow + 1,true);
		}
		return true;
	},
	
	helpWindow: function(txt,title) {
		
		var windowName = '_HelpWindow';
		var currWindow = this.getWindow(windowName);
		var windowHeight = typeof arguments[3] != 'undefined' ? arguments[3]: '3in';
		var windowWidth = typeof arguments[2] != 'undefined' ? arguments[2]: '4in';
		var windowType = typeof arguments[4] != 'undefined' ? arguments[4]: 'modal-resizable';
		var relativeTo = typeof arguments[5] != 'undefined' ? arguments[5]: '';
		var flagDropdown = false;
		
		
		if(windowType.split('-')[0] == 'dropdown') {
			flagDropdown = true;
			var rEle = $(relativeTo);
		}
		if(!currWindow) {
			currWindow = this.createWindow(windowName,windowType,
			{
			
			body: {
				content: {
					type: 'blank',
					elementId: '~'
				}
			},
			
			height: windowHeight,
			width: windowWidth,
			title: {
				html: 'Help Window',
				location: 'top',
				show: true
			},
			disableMove: false
		}
			);		
		}
		var windowDiv = currWindow.getWindowId('body');
		$(windowDiv).innerHTML = txt;
		currWindow.setTitle(title);
		currWindow.setSize(windowWidth,windowHeight);
		if(!flagDropdown) {
			currWindow.show(); 
		} else {
			currWindow.show('dropdown',rEle);
		}
	},
	
	showGridHelp: function(id) {
		var data = '__helpId=' + id;
		this.ajaxCallback('G','1','__a5ShowGridHelp','',data);
	},
	
	showFieldHelp: function(part,fieldName) {
		var rowNum = typeof arguments[2] != 'undefined' ? arguments[2] : this._selectedRow;
		if(part=='G') {
			var colNum = this._colNumFromName(this._gridColNames,fieldName);
			if(colNum > -1) {
				if(this.gridColumnInfo[colNum].hlp != '') {
					var data = '__part=G&__field=' + this.gridColumnInfo[colNum].name + '&__helpId=' + this.gridColumnInfo[colNum].hlp;
					this.ajaxCallback('G',rowNum + ':all','__a5ShowHelp','',data);
				}
			}
		} else {
			var colNum = this._colNumFromName(this._detailViewColNames,fieldName);
			if(colNum > -1) {
				if(this.detailViewColumnInfo[colNum].hlp != '') {
					var data = '__part='+part+'&__field=' + this.detailViewColumnInfo[colNum].name + '&__helpId=' + this.detailViewColumnInfo[colNum].hlp;
					this.ajaxCallback('D','1:all','__a5ShowHelp','',data);
				}
			}
		}
	},

	_keyF1: function(){
		if(this._focusControl != '') {
			this.showFieldHelp('G',this._focusControl);
		}
		return true;
	},
		
	_dvKeyF1: function(){
		if(this._dvFocusControl != '') {
			this.showFieldHelp('G',this._dvFocusControl);
		}
		return true;
	},
	
		
	_keySave: function(){
		if(this.rowEditMode != '' && ((this._focusRow > 0 && this._dirtyRows[this._focusRow-1]) || (this._focusRow < 0 && this._dirtyNewRows[Math.abs(this._focusRow)-1]))) {
			this.submitGridPartRow(this._focusRow);
		}
	},
	
	_keySaveAll: function(){
		if(this.rowEditMode != '' && this._isDirty) {
			this.submitGridPart();
		}
	},
	
	_keyEnter: function(){
		if(this._focusRow > 0 && !this._editModeRows[this._focusRow-1] && (this.rowEditMode == 'rod'  || this.rowEditMode == 'rod-s')) {
			if(this._focusControl != '') this.editField(this._focusRow,this._focusControl);
			else this.editRow([this._focusRow])
		}
	},
	
	_keyDeleteRecord: function(){
		if(this.rowEditMode != '') {
			this.deleteRow(this._focusRow);
		}
		return true;
		
	},
	_keyEscape: function(){
		if(this.rowEditMode != '' && ((this._focusRow > 0 && this._dirtyRows[this._focusRow-1]) || (this._focusRow < 0 && this._dirtyNewRows[Math.abs(this._focusRow)-1]))) {
			this._resetRow(this._focusRow);
		}
	},
	
	_dvKeyDeleteRecord: function(){
		if(this.detailViewEditMode != '' ) {
			this.deleteDetailViewRecord();
		}
		return true;
	},
	
	_dvKeySave: function() {
		if(this.detailViewEditMode != '' && this._detailViewIsDirty) {
			this.submitDetailView();
		}
	},
	
	_dvKeySaveAndEnter: function() {
		if(this.detailViewEditMode != '' && this._detailViewIsDirty) {
			this.submitDetailView(true);
		}
	},
	
	_dvKeyOpenLookupWindow: function() {
		if(typeof this._floatingLookupWindow[this._dvFocusControl] != 'undefined') {
			this.openLookup('DV',1,this._dvFocusControl);
		}
		return true;
	},
	
	
	_dvKeyEscape: function() {
		if(this.detailViewEditMode != '' && this._detailViewIsDirty) this.resetDetailView();
		
	},
	
	getStateInfo: function() {
		stateData = $u.o.toParams(this.stateInfo,'__si2');
		return stateData;
	},
	
	setStateInfo: function(obj) {
			$u.o.assign(this.stateInfo,obj);
	},
		

	_submitLow: function(action,formID,url){
		var optionalData = typeof arguments[3] != 'undefined' ? arguments[3] : '';
		var flagSubmitData = typeof arguments[4] != 'undefined' ? arguments[4] : false;
		if (typeof arguments[5] == 'undefined') stateID = formID + '.STATEINFO';
		else var stateID = arguments[5];
		var nameSpace = typeof arguments[6] != 'undefined' ? arguments[6] : '';
		var removeEvents = typeof arguments[7] != 'undefined' ? arguments[7] : true;
		
		
		var data = '';
		var stateInfo = $(stateID).value ? $(stateID).value : '' ;
		var stateInfoArray = stateInfo.split('&');
		var finalStateInfoArray = new Array();
		// prepare if needed
		if($(formID) && $ga(formID,'A5DataRegion') != 'A5DataRegion') a5_AJAX_FormPrepare(formID);
		if (action=='submit:dirty') {
			//submit all 'old' values and only edited fields as the 'new' values.
			data = a5_AJAX_Form_RegionHarvest(formID,false,true,nameSpace,removeEvents);
			data = $u.s.rTrim(data,' &') + '&' + '__FormID='+formID +'&__FormAction=submit';
		} else if (action=='submit:all' || action=='submit') {
			//submit all 'old' values and all 'new' values
			data = a5_AJAX_Form_RegionHarvest(formID,true,true,nameSpace,removeEvents);
			data = $u.s.rTrim(data,' &') + '&' + '__FormID='+formID +'&__FormAction=submit';		
		} else if (action=='submit:new' || flagSubmitData) {
			//submit all 'old' values and all 'new' values
			data = a5_AJAX_Form_RegionHarvest(formID,true,false,nameSpace,removeEvents);
			var actionName = $if(action=='submit:new','submit',action);
			data = $u.s.rTrim(data,' &') + '&' + '__FormID='+formID +'&__FormAction='+actionName;		
		} else data = '__FormAction=' +action +'&' +  '__FormID=' + formID;
		var URLInfo = document.URL;
		URLInfo=URLInfo.split('?').slice(1).join('?');
		URLInfo=URLInfo.replace(/\%22/g,'"');
		URLInfo=URLInfo.replace(/\%3C/g,'<');
		URLInfo=URLInfo.replace(/\%3E/g,'>');
		URLInfo=URLInfo.replace(/\%20/g,' ');
		URLInfo = URLInfo.split('&');
		var tempArg = '';
		for (var i=0;i<URLInfo.length;i++) {
			tempArg = URLInfo[i].split('=');
			URLInfo[i] = tempArg[0] + '=' + urlencode(tempArg.slice(1).join('='));
		}
		URLInfo = URLInfo.join('&');
		if(URLInfo != '') URLInfo = URLInfo+'&';
		if(stateInfo != '') stateInfo = stateInfo+'&';
		var stateInfo2 = this.getStateInfo();
		if(stateInfo2 != '') stateInfo = stateInfo2 + '&' + stateInfo;
		
		if(optionalData != '') optionalData = optionalData+'&';
		data = URLInfo + stateInfo+optionalData + data;
		if(data != ''){
			data = data + '&__Ajax=true';
		} else{
			data = '__Ajax=true';
		}
		data = $u.s.tran(data,'\n','%0D%0A');
		data = A5.ajax.addParamRequiredData(data);
		new $a.simple(url,{data: data, handleGeneric: true, method: 'post'});
	}	
	
}







function $f(ele){
	var ele = $n(ele);
	
	var select = typeof arguments[1] != 'undefined' ? arguments[1] : false;
	
	if(ele[0]){
		var tag = ele[0].tagName.toLowerCase();
		if(tag != 'input' && tag != 'select' && tag != 'textarea') {
			var ele2 = ele[0].getElementsByTagName('input');
			if(ele2.length == 0 ) return false;
			ele = ele2;
			tag = 'input';	
		} 
		var type = ele[0].type.toLowerCase();
		if(tag == 'input' && type == 'radio'){
			for(var i=0;i<ele.length;i++){
				if(ele[i].checked == true){
					var pele = ele[i];
					var cancelFocus = false;
					while(pele.tagName.toLowerCase() != 'body') {
						if(pele.style.display == 'none' || pele.style.visibility == 'hidden' )  {
							cancelFocus = true;
							break;
						}
						pele = pele.parentNode;
					}
					if(!cancelFocus) ele[i].focus();
					return false;
				}
			}
		}
		var pele = ele[0];
		var cancelFocus = false;
		if(tag == 'input' && type == 'hidden') cancelFocus = true;
		while(pele.tagName.toLowerCase() != 'body') {
			if(pele.style.display == 'none' || pele.style.visibility == 'hidden' )  {
				cancelFocus = true;
				break;
			}
			pele = pele.parentNode;
		}
		if(!cancelFocus) {
			ele[0].focus();
			if(select && ele[0].select) ele[0].select();
		}

	}
}




/*Generic Run Grid and Run Report Functions
*/

A5.component =  new Object();

A5.ajax.guid = function() {
	return (A5.ajax._s4()+A5.ajax._s4()+"-"+A5.ajax._s4()+"-"+A5.ajax._s4()+"-"+A5.ajax._s4()+"-"+A5.ajax._s4()+A5.ajax._s4()+A5.ajax._s4());
}

A5.ajax._s4 = function() {
   return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}

A5.component.runGenericComponent = function(go) {
	var arr = new Array();
	var pagePrefix = '';
	if(typeof go._applicationRoot == 'undefined') go._applicationRoot = '';
	pagePrefix = go._applicationRoot
	
	if(go.type == 'dialog2') {
		if(typeof go.dialog2Div == 'undefined') go.dialog2Div = '';
		if(typeof go.dialog2Name == 'undefined') go.dialog2Name = '';
		if(typeof go.alias == 'undefined') go.alias = go.dialog2Name;
		arr.push('__dialogDiv=' + go.dialog2Div);
		arr.push(A5.ajax.buildURLParam('__dialogFilename',go.dialog2Name));
		var page = '__a5RunDialog.a5w';
		$(go.dialog2Div).innerHTML = go.workingMessage;
		//special mode - edit grid row using dialog
		if(typeof go.specialDialogMode != 'undefined') {
			if(go.specialDialogMode == 'openDialogShowMappedControls') {
				arr.push(A5.ajax.buildURLParam('__controlMap','' + go.controlMap));
				arr.push(A5.ajax.buildURLParam('__controlSourceData','' + go.controlSourceData));
				arr.push(A5.ajax.buildURLParam('__parentComponentType','' + go.parentComponentType));
				if(go.parentComponentType == 'O') arr.push(A5.ajax.buildURLParam('__parentDialogId','' + go.parentDialogId));
				arr.push(A5.ajax.buildURLParam('__commitParent','' + go.commitParentOnDialogClose));
			}
			if(go.specialDialogMode == 'populateDialog') {
				arr.push(A5.ajax.buildURLParam('__getPKFrom','' + go.getPKFrom));
				arr.push(A5.ajax.buildURLParam('__PKValue','' + go.pkValue));
			}
			arr.push(A5.ajax.buildURLParam('__dialogSpecialMode',go.specialDialogMode + ':' + go.recordPrimaryKey));
			arr.push(A5.ajax.buildURLParam('__parentGridAlias',go._thisGridAlias));
			arr.push(A5.ajax.buildURLParam('__parentRow','' + go.sourceGridRowNumber));
			arr.push(A5.ajax.buildURLParam('__closeDialogAfterSubmit','' + go.closeDialogAfterSubmit));
			if(typeof go.windowName == 'undefined') go.windowName = '____none____';
			arr.push(A5.ajax.buildURLParam('__windowName','' + go.windowName));
			
		}
		
		
	} else {
		if(typeof go.customComponentDiv == 'undefined') go.customComponentDiv = '';
		if(typeof go.customComponentName == 'undefined') go.customComponentName = '';
		if(typeof go.alias == 'undefined') go.alias = go.customComponentName;	
		arr.push('__customComponentDiv=' + go.customComponentDiv);
		arr.push(A5.ajax.buildURLParam('__customComponentFilename',go.customComponentName));
		var page = '__a5RunCustomComponent.a5w';
		$(go.customComponentDiv).innerHTML = go.workingMessage;
	}
	
	page = pagePrefix + page;
	
	if(go.localArguments == undefined) go.localArguments = '';
	if(go.parameterBucket == undefined) go.parameterBucket = '';
	if(go.argumentValueBucket == undefined) go.argumentValueBucket = '';
	if(go.overrideSettings == undefined) go.overrideSettings = '';
	
	if(typeof go.placeholderValues == 'undefined') go.placeholderValues = '';
	if(typeof go.argumentBinding == 'undefined') go.argumentBinding = '';
	if(typeof go.a5_default_path == 'undefined') go.a5_default_path = '';
	if(typeof go.arguments == 'undefined') go.arguments = '';
	if(go.workingMessage == undefined) go.workingMessage = '<img src="CSS/A5System/Images/wait.gif" /> Working...';

	arr.push(A5.ajax.buildURLParam('__placeholderValues',go.placeholderValues));
	arr.push(A5.ajax.buildURLParam('__argumentBinding',go.argumentBinding));
	arr.push(A5.ajax.buildURLParam('__componentType',go.type));
	
	arr.push(A5.ajax.buildURLParam('__overrideSettings',go.overrideSettings));
	arr.push(A5.ajax.buildURLParam('__arguments',go.arguments));
	arr.push(A5.ajax.buildURLParam('__localArguments',go.localArguments));
	arr.push(A5.ajax.buildURLParam('__parameterBucket',go.parameterBucket));
	arr.push(A5.ajax.buildURLParam('__argumentValueBucket',go.argumentValueBucket));
	
	arr.push(A5.ajax.buildURLParam('__applicationRoot',go._applicationRoot));
	
	arr.push('__path=' + go.a5_default_path);
	arr.push('__guid=' + A5.ajax.guid() );
	arr.push('__alias=' + go.alias);
	arr.push('__initialLoadIsAjax=true');
		
	var params = arr.join('&');
	params = $u.s.tran(params,'\n','%0D%0A');
	
	var fakeData = params
	
	var pageVars = String(window.location);
	pageVars = pageVars.split('?');
	pageVars.shift();
	pageVars=pageVars.join('?');
	var data = pageVars;
	data = data + '&' + fakeData + '&__unsaved=no';
	go.guid = "NotNeeded"
	data = A5.ajax.addParamRequiredData(data);
	
	new $a.simple(page,{data:data, method:'post', handleGeneric:true});
}


A5.component.runGrid = function(go) {

	if(typeof go.gridDiv == 'undefined') go.gridDiv = '';
	if(typeof go.gridName == 'undefined') go.gridName = '';
	if(typeof go.alias == 'undefined') go.alias = go.gridName;
	if(typeof go.a5_default_path == 'undefined') go.a5_default_path = '';
	
	
	if(go.gridDiv == '') {
		alert('Fatal Error. DIV to display Grid Component was not defined.');
		return false;
		}
	
	if(go.gridName == '') {
		go.gridName = $(go.gridDiv).innerHTML = 'Fatal error: Grid to display was not specified.';
		return false;
		}
	
	if(go.alias == '') {
		$(go.reportDiv).innerHTML = 'Fatal error: Grid alias was not specified.';
		return false;
		}

	if(go.workingMessage == undefined) go.workingMessage = '<img src="CSS/A5System/Images/wait.gif" /> Working...';
	
	if(go.flagTimer == undefined) go.flagTimer = 'F';
	if(go.flagQueryEcho == undefined) go.flagQueryEcho = 'F';
	if(go.flagDebugMode == undefined) go.flagDebugMode = 'F';
	
	if(go.userFilter == undefined) go.userFilter = '';
	if(go.baseFilter == undefined) go.baseFilter = '';
	if(go.userOrder == undefined) go.userOrder = '';
	
	if(go.linkDefinition == undefined) go.linkDefinition = '';
	if(go.arguments == undefined) go.arguments = '';
	if(go.localArguments == undefined) go.localArguments = '';
	if(go.parameterBucket == undefined) go.parameterBucket = '';
	if(go.argumentValueBucket == undefined) go.argumentValueBucket = '';
	
	if(go.placeHolderValues == undefined) go.placeHolderValues = '';
	if(go.overrideSettings == undefined) go.overrideSettings = '';
	
	if(go._thisGridAlias == undefined) go._thisGridAlias = '';
	if(go.linkedContentSectionName == undefined) go.linkedContentSectionName = '';

	
	var flags = go.flagTimer + go.flagQueryEcho + go.flagDebugMode;
	
	var arr = new Array();
	arr.push('__vp__fn=GR');
	arr.push('__vp__div=' + go.gridDiv);
	arr.push(A5.ajax.buildURLParam('__vp__gridName',go.gridName));
	arr.push('__vp__path=' + go.a5_default_path);
	arr.push('__vp__guid=' + A5.ajax.guid() );
	arr.push('__vp__alias=' + go.alias);
	arr.push('__vp__flags=' + flags);
	
	arr.push(A5.ajax.buildURLParam('__vp__userFilter',go.userFilter));
	arr.push(A5.ajax.buildURLParam('__vp__userOrder',go.userOrder));
	arr.push(A5.ajax.buildURLParam('__vp__baseFilter',go.baseFilter));
	arr.push(A5.ajax.buildURLParam('__vp__override',go.overrideSettings));
	arr.push(A5.ajax.buildURLParam('__vp__linkDefinition',go.linkDefinition));
	arr.push(A5.ajax.buildURLParam('__vp__arguments',go.arguments));
	arr.push(A5.ajax.buildURLParam('__vp__localArguments',go.localArguments));
	arr.push(A5.ajax.buildURLParam('__vp__placeHolderValues',go.placeHolderValues));
	arr.push(A5.ajax.buildURLParam('__vp__parameterBucket',go.parameterBucket));
	arr.push(A5.ajax.buildURLParam('__vp__argumentValueBucket',go.argumentValueBucket));
	arr.push(A5.ajax.buildURLParam('__vp___thisGridAlias',go._thisGridAlias));
	arr.push(A5.ajax.buildURLParam('__vp___LCSName',go.linkedContentSectionName));
	
	//Lookups
	if(go.isLookupGrid == undefined) go.isLookupGride = false;
	if(go.isLookupGrid) {
		arr.push(A5.ajax.buildURLParam('__vp__isLookupGrid','true'));
		arr.push(A5.ajax.buildURLParam('__vp__lookupFieldName',go.lookupFieldName));
		arr.push(A5.ajax.buildURLParam('__vp__lookupFieldSection',go.lookupFieldSection));
		arr.push(A5.ajax.buildURLParam('__vp__lookupFieldName',go.lookupFieldName));
		arr.push(A5.ajax.buildURLParam('__vp__lookupReturnFields',go.lookupReturnFields));
		arr.push(A5.ajax.buildURLParam('__vp__lookupGridLinkLabel',go.lookupGridLinkLabel));
		arr.push(A5.ajax.buildURLParam('__vp__lookupGridLinkLabelStyle',go.lookupGridLinkLabelStyle));
		arr.push(A5.ajax.buildURLParam('__vp__lookupParentAlias',go._parentAlias));
		
	}
	
	
	
	var params = arr.join('&');
	params = $u.s.tran(params,'\n','%0D%0A');
	
	var fakeData = params
	
	var page = '&' + params + '._a5_ajax';
	
	var pageVars = String(window.location);
	pageVars = pageVars.split('?');
	pageVars.shift();
	pageVars=pageVars.join('?');

	
	//var data = '';
	var data = pageVars;
	
	data = data + '&' + fakeData;
	var page = '_dummyPage._a5_ajax';
	//tell the virtual page what the page type is - gr
	go.guid = "NotNeeded"
	//var page = '&__guid=' + go.guid +  '&__fn=gr' +  '._a5_ajax';
	var page = '&__fn=gr' +  '._a5_ajax';
	
	$(go.gridDiv).innerHTML = go.workingMessage;
	data = A5.ajax.addParamRequiredData(data);
	
	new $a.simple(page,{data:data, method:'post', handleGeneric:true});
}



A5.component.runReport = function(ro) {
	var flagDownload = false;
	if(typeof ro.download != 'undefined') {
		if(ro.download == 'Y' || ro.download == 'X') flagDownload = true;
	}

	if(!flagDownload) {
		if(typeof ro.reportIFrame == 'undefined' && typeof ro.reportDiv == 'undefined') {
			alert('Fatal Error. DIV or IFRAME to display report was not defined.');
			return false;
		}	
	} else {
		ro.reportIFrame = '';
	}
	
	


	var __mode = '';
	if(typeof ro.reportIFrame != 'undefined') __mode = 'iframe';
	else __mode = 'div';

	if(typeof ro.workingMessage == 'undefined') {
		ro.workingMessage = 'Generating report. Please wait.....';
	}

	if(typeof ro.reportName == 'undefined') {
		$(ro.reportIFrame).innerHTML = 'Fatal error: Report to print was not specified.';
		return false;
	}


	if(ro.filter == undefined) ro.filter = '';
	if(ro.order == undefined) ro.order = '';
	if(ro.sqlFilter == undefined) ro.sqlFilter = '';
	if(ro.sqlOrder == undefined) ro.sqlOrder = '';
	if(ro.arguments == undefined) ro.arguments = '';
	if(ro.localArguments == undefined) ro.localArguments = '';
	if(ro.parameterBucket == undefined) ro.parameterBucket = '';
	if(ro.argumentValueBucket == undefined) ro.argumentValueBucket = '';
	if(ro.gridId == undefined) ro.gridId = '';
	if(ro.download == undefined) ro.download = 'N';
	if(ro.clientSideFilename == undefined) ro.clientSideFilename = '';
	if(ro.xbasicFunction == undefined) ro.xbasicFunction = '';
	if(ro.reportMessagesDivId == undefined) ro.reportMessagesDivId = '';
	if(ro.width == undefined) ro.width = '9in';
	if(ro.height == undefined) ro.height = '11.5in';
	if(ro.displayMode == undefined) ro.displayMode = '';
	if(ro.pdfoptions == undefined) ro.pdfoptions = '';
	if(ro.saveAs == undefined) ro.saveAs = 'pdf';
	if(ro.reportType == undefined) ro.reportType = 'report';
	if(ro.pdfOpenParameters == undefined) ro.pdfOpenParameters = '';
	
	
	if(ro._gridCurrentFilter == undefined) ro._gridCurrentFilter = '';
	if(ro._gridCurrentOrder == undefined) ro._gridCurrentOrder = '';
	if(ro._gridCurrentArguments == undefined) ro._gridCurrentArguments = '';
	if(ro._gridCurrentDBType == undefined) ro._gridCurrentDBType = '';
	
	var data = new Array();
	data.push(A5.ajax.buildURLParam('reportName',ro.reportName));
	if(__mode == 'iframe') {
			data.push(A5.ajax.buildURLParam('reportIFrame',ro.reportIFrame));
			$(ro.reportIFrame).src = A5.ajax.addURLRequiredData('__workingMessage.a5w?'+A5.ajax.buildURLParam('message',ro.workingMessage)+'&icon=CSS/A5System/images/wait.gif');
	}
	else data.push(A5.ajax.buildURLParam('reportDiv',ro.reportDiv));
	
	
	data.push(A5.ajax.buildURLParam('filter',ro.filter));
	data.push(A5.ajax.buildURLParam('order',ro.order));
	data.push(A5.ajax.buildURLParam('sqlFilter',ro.sqlFilter));
	data.push(A5.ajax.buildURLParam('sqlOrder',ro.sqlOrder));
	data.push(A5.ajax.buildURLParam('arguments',ro.arguments));
	data.push(A5.ajax.buildURLParam('localArguments',ro.localArguments));
	data.push(A5.ajax.buildURLParam('parameterBucket',ro.parameterBucket));
	data.push(A5.ajax.buildURLParam('argumentValueBucket',ro.argumentValueBucket));	
	data.push(A5.ajax.buildURLParam('pdfoptions',ro.pdfoptions));

	data.push(A5.ajax.buildURLParam('width',ro.width));
	data.push(A5.ajax.buildURLParam('height',ro.height));
	data.push(A5.ajax.buildURLParam('displayMode',ro.displayMode));
	data.push(A5.ajax.buildURLParam('saveAs',ro.saveAs));
	data.push(A5.ajax.buildURLParam('reportType',ro.reportType));
	data.push(A5.ajax.buildURLParam('_pdfOpenParameters',ro.pdfOpenParameters));
	

	data.push(A5.ajax.buildURLParam('_gridCurrentFilter',ro._gridCurrentFilter));
	data.push(A5.ajax.buildURLParam('_gridCurrentOrder',ro._gridCurrentOrder));
	data.push(A5.ajax.buildURLParam('_gridCurrentArguments',ro._gridCurrentArguments));
	data.push(A5.ajax.buildURLParam('_gridCurrentDBType',ro._gridCurrentDBType));
	
	data.push(A5.ajax.buildURLParam('_gridId',ro.gridId));
	data.push(A5.ajax.buildURLParam('_download',ro.download));
	data.push(A5.ajax.buildURLParam('_clientSideFilename',ro.clientSideFilename));

	data.push(A5.ajax.buildURLParam('_xbasicFunction',ro.xbasicFunction));
	data.push(A5.ajax.buildURLParam('_reportMessagesDivId',ro.reportMessagesDivId));

	var dataPageVars = ''
	if(typeof ro.pageVars != 'undefined') {
		dataPageVars = ro.pageVars.join('&');
		dataPageVars = '&' + dataPageVars
	}
	
	var URLpageVars = String(window.location);
	URLpageVars = URLpageVars.split('?');
	URLpageVars.shift();
	URLpageVars=URLpageVars.join('?');
	if(URLpageVars != '') URLpageVars =  '&' + URLpageVars;
	
	
	data = data.join('&');
	data = data + dataPageVars + URLpageVars;
	data = $u.s.tran(data,'\n','%0D%0A');

	data = A5.ajax.addParamRequiredData(data);
	new $a.simple('__a5RunReport.a5w',{data: data, method: 'post', handle: A5.component._handleReportResponse});
}



A5.component._handleReportResponse = function(xmlObj){
	eval(xmlObj.responseText);
	if(typeof a5reportInfo != 'undefined') {
		if(a5reportInfo.reportFileName) {
			setTimeout(Function('$(\''+a5reportInfo.reportIFrame+'\').src = \''+A5.ajax.addURLRequiredData(a5reportInfo.reportFileName)+'\';'),250);
		}
	}
}




A5.form.populateSelect = function(eleId,currValue,data,clearExistingEntries) {
	//call old function if clearExistingEntries is a string, not a boolean
	if(typeof clearExistingEntries == 'string') {
		a5_AJAX_Form_populateSelect(eleId,currValue,data,clearExistingEntries);
		return false;
	}
	var ele = $(eleId);
	var currIndex = 0;
	if(clearExistingEntries) {
		if(ele.options.length > 0) {
			for(var i = ele.options.length -1; i >= 0; i--) ele.options[i] = null;
			ele.options[0] = null;
		}
	} else currIndex = ele.options.length;
	for(var i =0; i < data.length; i++) {
		if(data[i].constructor == Array) {
			if(data[i].length > 1) {
				ele.options[currIndex] = new Option(data[i][0],data[i][1]);	
			} else {
				ele.options[currIndex] = new Option(data[i][0],data[i][0]);
			}
		} else {
			ele.options[currIndex] = new Option(data[i],data[i]);
		}
		currIndex++;
	}
	var optionFound = false;
	if(ele.options.length > 0) {
		for(var i = 0; i < ele.options.length; i++) {
			if(ele.options[i].value == currValue) {
				optionFound = true;
				ele.options.selectedIndex = i;
				break;
			}
		}
		if(optionFound == false) {
			ele.options[ele.options.length] = new Option(currValue,currValue);
			ele.options.selectedIndex = ele.options.length -1;
		}
	}
}


A5.PageWindows = {

	_defaultWindowSettings: {
		'dropdown': {
			type: 'popup',
			title: {html: 'Null',show: false},
			body:  {content: {type: 'blank'}}
		},
		'modal': {
			type: 'modal', autoPosition: 'in-view',
			title: {html: 'Customer Grid', 
				tools: {items: [{action: 'close',name: 'Close',image: 'images/$$window.button.close.png.a5image'}],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		},
		'modeless': {
			type: 'modeless', autoPosition: 'in-view',
			title: {html: 'Customer Grid', 
				tools: {items: [{action: 'close',name: 'Close',image: 'images/$$window.button.close.png.a5image'}],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		}
	},
	
	createWindow: function(name,settings) {
		if(!this.getWindow(name)) {
			if(typeof settings == 'string') {
				var parts = settings.split('-');
				settings = this._defaultWindowSettings[parts.shift()];
				for(var i=0;i<parts.length;i++){
					if(parts[i] == 'url'){
						settings.body.content.type = 'url';
						settings.body.content.url = 'about:blank';
					} else if(parts[i] == 'resizable'){
						settings.resize = 'both';
					}
				}
			}
			if(typeof arguments[2] == 'object') $u.o.assign(settings,arguments[2]);
			this._genericWindow[name] = new A5.Window(settings);
		}
		return this._genericWindow[name];
	},
	
	getWindow: function(name) {
		if(typeof this._genericWindow[name] != 'undefined' ) return this._genericWindow[name];
		return false;
	},
	
	_genericWindow: []
	
}

function closeParentA5Window(ele) {
	var currWindow = A5.windows.getFromElement(ele);
	if(currWindow) currWindow.hide();
}

function closeLastOpenedA5Window() {
	var currWindow = A5.windows.getTop();
	if(currWindow) currWindow.hide();
}

function randId() {

	var d = new Date();
	str = d.getDate()+''+d.getHours()+''+d.getMinutes()+''+d.getSeconds();
	return str;

}

function getTabbedUI() {
var curWin = window;
while(window.top != curWin) {
	curWin = curWin.parent;
	if(curWin.tbiObj) {
		return curWin.tbiObj;
	}
	
}
if(typeof tbiObj != 'undefined') return tbiObj;
return false;
}



//Animation library
A5.anim = {
	run: function(ele,settings){
		A5.anim.stop(ele);
		$u.o.assign(settings,{
			channel: [],
			steps: 10,
			delay: 25,
			onBefore: 0,
			onAfter: 0
		},true);
		if(settings.channel.constructor != Array) settings.channel = [settings.channel];
		for(var i=0;i<settings.channel.length;i++){
			$u.o.assign(settings.channel[i],{
				property: '',
				start: 0,
				end: 1,
				unit: '',
				power: .5,
				clear: false
			},true);
			if(settings.channel[i].property == 'font-size' && settings.channel[i].unit == '') settings.channel[i].unit = 'pt';
			else if(settings.channel[i].unit == '') settings.channel[i].unit = 'px';
			settings.channel[i]._type = 'style';
			if($u.s.word(settings.channel[i].property,-1,'-') == 'color'){
				// convert colors to array
				settings.channel[i]._type = 'style:color';
				settings.channel[i].start = A5.anim._colorToNumber(settings.channel[i].start);
				settings.channel[i].end = A5.anim._colorToNumber(settings.channel[i].end);
			} else if(settings.channel[i].property == 'opacity'){
				settings.channel[i]._type = 'style:opacity';
				ele.style.zoom = '1';
			}
			settings.channel[i].property = settings.channel[i].property.split('-');
			for(j=1;j<settings.channel[i].property.length;j++) settings.channel[i].property[j] = $u.s.changeCase(settings.channel[i].property[j],'fu');
			settings.channel[i].property = settings.channel[i].property.join('');
		}
		
		var curStep = 0;
		if(settings.onBefore.constructor == Function) settings.onBefore.call(ele);
		if(settings.onAfter.constructor == Function) $e.add(ele,'a5AnimateComplete',settings.onAfter,null,false,ele.id+ele.name+'A5ANIMATE');
		ele._a5anim = setInterval(function(){ 
			for(var i=0;i<settings.channel.length;i++){
				if(settings.channel[i]._type == 'style:color' || typeof settings.channel[i].start == 'number'){
					if(settings.channel[i]._type == 'style:color'){
						var color = new Array();
						color.push(Math.ceil(A5.anim._ease(settings.channel[i].start[0],settings.channel[i].end[0],settings.steps,curStep,settings.channel[i].power)));
						color.push(Math.ceil(A5.anim._ease(settings.channel[i].start[1],settings.channel[i].end[1],settings.steps,curStep,settings.channel[i].power)));
						color.push(Math.ceil(A5.anim._ease(settings.channel[i].start[2],settings.channel[i].end[2],settings.steps,curStep,settings.channel[i].power)));
						ele.style[settings.channel[i].property] = '#'+$u.s.pad(color[0].toString(16),2,'0')+$u.s.pad(color[1].toString(16),2,'0')+$u.s.pad(color[2].toString(16),2,'0');;
						delete color;
					} else if(settings.channel[i]._type == 'style:opacity'){
						var opacity = A5.anim._ease(settings.channel[i].start,settings.channel[i].end,settings.steps,curStep,settings.channel[i].power);
						ele.style.opacity = opacity;
						ele.style.filter = 'alpha(opacity = '+Math.ceil(opacity*100)+')';
					} else ele.style[settings.channel[i].property] = A5.anim._ease(settings.channel[i].start,settings.channel[i].end,settings.steps,curStep,settings.channel[i].power)+settings.channel[i].unit;
				} else{
					if(curStep == settings.steps){
						ele.style[settings.channel[i].property] = settings.channel[i].end;
					}
				}
			}
			curStep++;
			if(curStep > settings.steps) A5.anim.stop(ele);
		},settings.delay);
	},
	stop: function(ele){
		if(ele._a5anim){
			clearInterval(ele._a5anim);
			$e.execute(ele,'a5AnimateComplete');
			$e.removeGroup(ele.id+ele.name+'A5ANIMATE');
		}
	},
	toggle: function(ele){
		A5.anim.stop(ele);
		var type = typeof arguments[1] != 'undefined' ? arguments[1].toString().toLowerCase() : 'fade';
		var dir = typeof arguments[2] != 'undefined' ? arguments[2].toString().toLowerCase() : 'toggle';
		var delay = typeof arguments[3] != 'undefined' ? arguments[3] : 500;
		var steps = Math.round(delay/25);
		var hasFade = type.search('fade') != -1 ? true : false;
		var hasDrop = type.search('drop') != -1 ? true : false;
		var hasSlide = type.search('slide') != -1 ? true : false;
		if(!hasFade && !hasDrop && !hasSlide) return false;
		if(dir == 'toggle'){
			dir = 'hide';
			if(ele.style.display == 'none') dir = 'show';
		}
		if(dir == 'show'){
			if(ele.style.display != 'none') return false;
			ele.style.display = '';
			var chnls = new Array();
			var oldStyle = {};
			if(hasFade){
				oldStyle = {opacity: '', filter: '', zoom: ''};
				if(ele.style.opacity) oldStyle.opacity = ele.style.opacity;
				if(ele.style.filter) oldStyle.filter = ele.style.filter;
				if(ele.style.zoom) oldStyle.zoom = ele.style.zoom;
				ele.style.opacity = '0';
				ele.style.filter = 'alpha(opacity=0)';
				if(ele.style.zoom == '') ele.style.zoom = '1';
				chnls.push({property: 'opacity', start: 0, end: 1})
			}
			if(hasDrop){
				var targHeight = ele.offsetHeight;
				oldStyle.overflow = ele.style.overflow;
				oldStyle.height = ele.style.height;
				ele.style.height = '0px';
				ele.style.overflow = 'hidden';
				chnls.push({property: 'height', start: 0, end: targHeight, unit: 'px'})
			}
			if(hasSlide){
				var targWidth = ele.offsetWidth;
				if(!oldStyle.overflow) oldStyle.overflow = ele.style.overflow;
				if(!hasDrop && ele.style.height == ''){
					oldStyle.height = '';
					ele.style.height = ele.offsetHeight+'px';
				}
				oldStyle.width = ele.style.width;
				ele.style.width = '0px';
				ele.style.overflow = 'hidden';
				chnls.push({property: 'width', start: 0, end: targWidth, unit: 'px'})
			}
			A5.anim.run(ele,{
				onAfter: Function('$ss(this,'+$u.o.toJSON(oldStyle)+');'),
				channel: chnls,
				'steps': steps
			});
		} else if(dir == 'hide'){
			if(ele.style.display == 'none') return false;
			var chnls = new Array();
			var oldStyle = {};
			if(hasFade){
				oldStyle = {opacity: '', filter: '', zoom: ''};
				if(ele.style.opacity) oldStyle.opacity = ele.style.opacity;
				if(ele.style.filter) oldStyle.filter = ele.style.filter;
				if(ele.style.zoom) oldStyle.zoom = ele.style.zoom;
				ele.style.opacity = '1';
				ele.style.filter = 'alpha(opacity=100)';
				if(ele.style.zoom == '') ele.style.zoom = '1';
				chnls.push({property: 'opacity', start: 1, end: 0})
			}
			if(hasDrop){
				var targHeight = ele.offsetHeight;
				oldStyle.overflow = ele.style.overflow;
				oldStyle.height = ele.style.height;
				ele.style.overflow = 'hidden';
				chnls.push({property: 'height', start: targHeight, end: 0, unit: 'px'})
			}
			if(hasSlide){
				var targWidth = ele.offsetWidth;
				if(!oldStyle.overflow) oldStyle.overflow = ele.style.overflow;
				if(!hasDrop && ele.style.height == ''){
					oldStyle.height = '';
					ele.style.height = ele.offsetHeight+'px';
				}
				oldStyle.width = ele.style.width;
				ele.style.width = '0px';
				ele.style.overflow = 'hidden';
				chnls.push({property: 'width', start: targWidth, end: 0, unit: 'px'})
			}
			A5.anim.run(ele,{
				onAfter: Function('$ss(this,'+$u.o.toJSON(oldStyle)+'); this.style.display = \'none\';'),
				channel: chnls,
				'steps': steps
			});
		}
	},
	_ease: function(start,end,steps,curStep,power){
		var delta = end-start;
		var result = start+(Math.pow(((1/steps)*curStep),power)*delta);
		return result;
	},
	_colorToNumber: function(color){
		if(color.constructor == Array()) return color;
		color = color.toString();
		var rColor = new Array();
		if(color.substr(0,4) == 'rgb('){
			rColor.push($u.s.toNum($u.s.word(color,1,',')));
			rColor.push($u.s.toNum($u.s.word(color,2,',')));
			rColor.push($u.s.toNum($u.s.word(color,3,',')));
		} else{
			// replace named colors:
			var sc = ['aliceblue','antiquewhite','aqua','aquamarine','azure','beige','bisque','black','blanchedalmond','blue','blueviolet','brown','burlywood','cadetblue','chartreuse','chocolate','coral','cornflowerblue','cornsilk','crimson','cyan','darkblue','darkcyan','darkgoldenrod','darkgray','darkgreen','darkkhaki','darkmagenta','darkolivegreen','darkorange','darkorchid','darkred','darksalmon','darkseagreen','darkslateblue','darkslategray','darkturquoise','darkviolet','deeppink','deepskyblue','dimgray','dodgerblue','firebrick','floralwhite','forestgreen','fuchsia','gainsboro','ghostwhite','gold','goldenrod','gray','green','greenyellow','honeydew','hotpink','indianred','indigo','ivory','khaki','lavender','lavenderblush','lawngreen','lemonchiffon','lightblue','lightcoral','lightcyan','lightgoldenrodyellow','lightgrey','lightgreen','lightpink','lightsalmon','lightseagreen','lightskyblue','lightslategray','lightsteelblue','lightyellow','lime','limegreen','linen','magenta','maroon','mediumaquamarine','mediumblue','mediumorchid','mediumpurple','mediumseagreen','mediumslateblue','mediumspringgreen','mediumturquoise','mediumvioletred','midnightblue','mintcream','mistyrose','moccasin','navajowhite','navy','oldlace','olive','olivedrab','orange','orangered','orchid','palegoldenrod','palegreen','paleturquoise','palevioletred','papayawhip','peachpuff','peru','pink','plum','powderblue','purple','red','rosybrown','royalblue','saddlebrown','salmon','sandybrown','seagreen','seashell','sienna','silver','skyblue','slateblue','slategray','snow','springgreen','steelblue','tan','teal','thistle','tomato','turquoise','violet','wheat','white','whitesmoke','yellow','yellowgreen'];
			var rc = ['#F0F8FF','#FAEBD7','#00FFFF','#7FFFD4','#F0FFFF','#F5F5DC','#FFE4C4','#000000','#FFEBCD','#0000FF','#8A2BE2','#A52A2A','#DEB887','#5F9EA0','#7FFF00','#D2691E','#FF7F50','#6495ED','#FFF8DC','#DC143C','#00FFFF','#00008B','#008B8B','#B8860B','#A9A9A9','#006400','#BDB76B','#8B008B','#556B2F','#FF8C00','#9932CC','#8B0000','#E9967A','#8FBC8F','#483D8B','#2F4F4F','#00CED1','#9400D3','#FF1493','#00BFFF','#696969','#1E90FF','#B22222','#FFFAF0','#228B22','#FF00FF','#DCDCDC','#F8F8FF','#FFD700','#DAA520','#808080','#008000','#ADFF2F','#F0FFF0','#FF69B4','#CD5C5C','#4B0082','#FFFFF0','#F0E68C','#E6E6FA','#FFF0F5','#7CFC00','#FFFACD','#ADD8E6','#F08080','#E0FFFF','#FAFAD2','#D3D3D3','#90EE90','#FFB6C1','#FFA07A','#20B2AA','#87CEFA','#778899','#B0C4DE','#FFFFE0','#00FF00','#32CD32','#FAF0E6','#FF00FF','#800000','#66CDAA','#0000CD','#BA55D3','#9370D8','#3CB371','#7B68EE','#00FA9A','#48D1CC','#C71585','#191970','#F5FFFA','#FFE4E1','#FFE4B5','#FFDEAD','#000080','#FDF5E6','#808000','#6B8E23','#FFA500','#FF4500','#DA70D6','#EEE8AA','#98FB98','#AFEEEE','#D87093','#FFEFD5','#FFDAB9','#CD853F','#FFC0CB','#DDA0DD','#B0E0E6','#800080','#FF0000','#BC8F8F','#4169E1','#8B4513','#FA8072','#F4A460','#2E8B57','#FFF5EE','#A0522D','#C0C0C0','#87CEEB','#6A5ACD','#708090','#FFFAFA','#00FF7F','#4682B4','#D2B48C','#008080','#D8BFD8','#FF6347','#40E0D0','#EE82EE','#F5DEB3','#FFFFFF','#F5F5F5','#FFFF00','#9ACD32'];
			color = $u.s.lTrim($u.s.tran(color.toLowerCase(),sc,rc),'#');
			if(color.length == 3){
				rColor.push(parseInt('0x'+$u.s.replicate(color.substr(0,1),2)));
				rColor.push(parseInt('0x'+$u.s.replicate(color.substr(1,1),2)));
				rColor.push(parseInt('0x'+$u.s.replicate(color.substr(2,1),2)));
			} else{
				rColor.push(parseInt('0x'+color.substr(0,2)));
				rColor.push(parseInt('0x'+color.substr(2,2)));
				rColor.push(parseInt('0x'+color.substr(4,2)));
			}
		}
		return rColor;
	}
}


A5.CustomComponentHelper = Class.create();
A5.CustomComponentHelper.prototype = {
	initialize: function(settings){
		$u.o.assign(settings,{
			ajaxURL: ''
		},true);
		$u.o.assign(this,settings,true);
		this.stateInfo = {};
		
		
		
		
		this._defaultWindowSettings = new Object();
		
		
		this._defaultWindowSettings['dropdown'] = {
			type: 'popup',
			theme: this.styleName,
			title: {html: 'Null',show: false},
			body:  {content: {type: 'blank'}}
		};		
		
		this._genericWindow = new Object();
		
		this._kw = new AUI.KeyWatcher([
			{key: 'F1', handle: this._keyF1}
			],this);		
		
		var closeButton = {action: 'close',name: 'Close',image: 'images/$$window.button.close.png.a5image'};
		if(typeof A5.themes != 'undefined') {
			if(typeof A5.themes._t[this.styleName] != 'undefined') closeButton = A5.themes._t[this.styleName].window.base._defaultTools.close;
		}

		this._defaultWindowSettings['modal'] = {
			type: 'modal', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Customer Grid', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		this._defaultWindowSettings['modeless'] = {
			type: 'modeless', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Customer Grid', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};		
	},
	
	
	setStateInfo: function(obj) {
		$u.o.assign(this.stateInfo,obj);
	},

	getStateInfo: function() {
		stateData = $u.o.toParams(this.stateInfo,'_state');
		return stateData;
	},
	

	ajaxCallback: function(part,rowNum,xbasicFunction) {
		//part and rowNum are meaningless but are in the prototype so that the same syntax is used
		//as Grid and Dialog2 component
		if(!this._executeEvent('canAjaxCallback',{xbasicFunctionName: xbasicFunction, ajaxEvent: 'AjaxCallback'})) return false;
	
		var callbackURL = typeof arguments[3] != 'undefined' ? arguments[3] : '';	
		var otherData = typeof arguments[4] != 'undefined' ? arguments[4] : '';
		var data = this.getStateInfo();
		data = '_XbasicFunction='+xbasicFunction+'&__FormAction=GenericAjaxCallback&'+data;
		if(callbackURL == '') callbackURL = this.ajaxURL;
		if(otherData!='') data=data + '&' + otherData;
		A5.ajax.callback(callbackURL,data);
		return false;
	},
	
	
	closeContainerWindow: function(ele) {
		//if grid is opened in a window, closes the container window
	    var cw = A5.windows.getFromElement(ele);
	    if(cw) cw.hide();
	},
	
	
	loadJavascript: function(txt) {
		var sEle = document.getElementsByTagName('script');
		var cancelAdd = false;
		for(var i=0; i < sEle.length; i++) {
			if(sEle[i].text == txt) { 
				cancelAdd = true;
				break;
			}
		}
		
		if(cancelAdd == false) {
			var e = document.createElement('script');
			e.text = txt;
			document.getElementsByTagName('head')[0].appendChild(e);
		}
	},
	
	loadJavascriptFile: function(filename) {
		var onLoaded = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		var sEle = document.getElementsByTagName('script');
		var cancelAdd = false;
		for(var i=0; i < sEle.length; i++) {
			if(sEle[i].src == filename) { 
				cancelAdd = true;
				break;
			}
		}
		if(cancelAdd == false) {
			var e = document.createElement('script');
			e.src = filename;
			e.onload = function() {
				if(typeof jQuery != 'undefined') jQuery.noConflict();
				if(onLoaded.constructor == Function) onLoaded();
			};
			
			e.onreadystatechange = function() {
				if(this.readyState == 'complete' || this.readyState == 'loaded') {
					if(typeof jQuery != 'undefined') jQuery.noConflict();
					if(onLoaded.constructor == Function) onLoaded();
				}
			};
			document.getElementsByTagName('head')[0].appendChild(e);
			
		}
	},
	
	
	loadCSSFile: function(filename) {
			var sEle = document.getElementsByTagName('link');
			var cancelAdd = false;
			for(var i=0; i < sEle.length; i++) {
				if(sEle[i].href.indexOf(filename) > 0) { 
					cancelAdd = true;
					break;
				}
			}
			if(cancelAdd == false) {
				var e = document.createElement('link');
				e.href = filename;
				e.rel = 'stylesheet';
				e.type = 'text/css';
				document.getElementsByTagName('head')[0].appendChild(e);
			}
	},
	
	loadXbasic: function(txt) {
			var versionNum = typeof arguments[1] != 'undefined' ? arguments[1] : '';
			if(this._embeddedMode == false) return false;
			var sEle = document.getElementsByTagName('script');
			var cancelAdd = false;
			for(var i=0; i < sEle.length; i++) {
				if(typeof sEle[i].language != 'undefined') {
					if(sEle[i].language.toLowerCase() == 'xbasic' + versionNum) {
						if(sEle[i].text.toLowerCase()  == txt.toLowerCase()) { 
							cancelAdd = true;
							break;
						}
					}
				}
			}
			if(cancelAdd == false) {
				var e = document.createElement('script');
				e.text = txt;
				e.language = 'Xbasic' + versionNum;
				document.getElementsByTagName('head')[0].appendChild(e);
			}
	},
	
	loadMetaTag: function(name,txt) {
			var e = document.createElement('meta');
			e.name = name;
			e.content = txt;
			document.getElementsByTagName('head')[0].appendChild(e);
	},
	
	createWindow: function(name,settings) {
			if(!this.getWindow(name)) {
				if(typeof settings == 'string') {
					var parts = settings.split('-');
					settings = new Object();
					$u.o.assign(settings , this._defaultWindowSettings[parts.shift()]);
					for(var i=0;i<parts.length;i++){
						if(parts[i] == 'url'){
							settings.body.content.type = 'url';
							settings.body.content.url = 'about:blank';
						} else if(parts[i] == 'resizable'){
							settings.resize = 'both';
						}
					}
				}
				if(typeof arguments[2] == 'object') $u.o.assign(settings,arguments[2]);
				this._genericWindow[name] = new A5.Window(settings);
			}
			return this._genericWindow[name];
		},
		
	getWindow: function(name) {
		if(typeof this._genericWindow[name] != 'undefined' ) return this._genericWindow[name];
		return false;
	},
	
	_executeEvent: function(eventName) {
		var result = true;
		var targs = new Array();
		for(var i = 1; i < arguments.length; i++) targs.push(arguments[i]);
		var tresult = false;
		if(typeof this[eventName] != 'undefined'  ) {

			if(this[eventName].constructor == Function) {
				tresult = this[eventName].apply(this,targs);
				if(typeof tresult == 'boolean') result = tresult;
			}
		}
		if(typeof this['_' +eventName] != 'undefined' ) {
			if(this['_'+eventName].constructor == Function) {
				tresult = this['_'+eventName].apply(this,targs);
				if(typeof tresult == 'boolean') result = result && tresult;
			}
			
		}
		return result;
	}
	
}


A5.DialogComponentHelper = Class.create();
A5.DialogComponentHelper.prototype = {
	initialize: function(dialogId,settings){
		this.dialogId = dialogId;
		$u.o.assign(settings,{
			ajaxURL: '',
			columnInfo: {},
			fieldHelpers: {},
			dialogWatches: {},
			fieldErrors: {
				type: '',
				className: '',
				inputClassName: '',
				icon: '',
				global: {
					contId: '',
					hoverClassName: '',
					hoverInputClassName: ''
				}
			}
			
		},true);
		$u.o.assign(this,settings,true);
		this._dirtyRows = [false];
		this._isDirty = false;
		this._focusControl = '';
		this._focusRow = 1;
		this._blurTO = 0;
		//error handlers
		this.fieldErrors.global.contId = this.dialogId + '.GLOBALERRORS';
		this._eh = new A5.ErrorHandler(this.fieldErrors);
		var tempFE = {type: 'tip'};
		$u.o.assign(tempFE,this.fieldErrors,true);
		this._rseh = new A5.ErrorHandler(tempFE);
		this.stateInfo = {};
		this.rowStateInfo = [];
		this._defaultWindowSettings = new Object();
		this._defaultWindowSettings['dropdown'] = {
			type: 'popup',
			theme: this.styleName,
			title: {html: 'Null',show: false},
			body:  {content: {type: 'blank'}}
		};		
		
		this._genericWindow = new Object();
		
		this._kw = new AUI.KeyWatcher([
			{key: 'F1', handle: this._keyF1}
			],this);		
		
		
		var closeButton = {action: 'close',name: 'Close',image: 'images/$$window.button.close.png.a5image'};
		if(typeof A5.themes != 'undefined') {
			if(typeof A5.themes._t[this.styleName] != 'undefined') closeButton = A5.themes._t[this.styleName].window.base._defaultTools.close;
		}
		
		this._defaultWindowSettings['modal'] = {
			type: 'modal', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Customer Grid', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		this._defaultWindowSettings['modeless'] = {
			type: 'modeless', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Customer Grid', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};		
		
		this._prepared = false;
		
	},

	_destroy: function() {
		var ele = 0;
		for(var winName in this._genericWindow){
			ele = $(this._genericWindow[winName].getWindowId('body'));
			if(ele.tagName.toLowerCase() == 'div') ele.innerHTML = '';
		}
	},


	_dynamicMask: function(fnName) {
		if(window[this.format.maskFunctionName]) 
		{
			var classInst = window[this.format.maskComponentObject];
			var e = {};
			e.rowNumber = 1;
			e.part = 'O';
			return window[this.format.maskFunctionName].call(classInst,e);		
		}
		return '';
	},


	prepare: function() {
		this._prepareRow(1);
		this._prepared = true;
	},
	
	_prepareRow: function(rowNum) {
		$e.removeGroup(this.dialogId + '.DIALOG');
		
		var rele = $(this.dialogId + '.R' + rowNum);
		var eles = 0;
		
		this.rowStateInfo[rowNum-1] = {summary: {}};
		for(var columnName in this.columnInfo) {
			if(this.columnInfo[columnName].calculateSummary) {
				this._summarize(columnName,rowNum);
			}
			if(typeof this.columnInfo[columnName].repeatingSection != 'undefined') {
				this.repeatingSections[this.columnInfo[columnName].repeatingSection]._ci[columnName] = this.columnInfo[columnName];	
			} else {
				if(this.columnInfo[columnName].isArray) eles = $n('V.R' + rowNum + '.' + columnName+'[]');
				else eles = $n('V.R' + rowNum + '.' + columnName);
				eles = $cetp(eles,rele);
				if(eles) {
					$e.add(eles,'keyup',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
					$e.add(eles,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
					$e.add(eles,'blur',this._setControlBlur,this,false,this.dialogId + '.DIALOG');
					$e.add(eles,'focus',this._setControlFocus,this,false,this.dialogId + '.DIALOG');
					if(eles[0].tagName.toLowerCase() == 'input') {
						if(eles[0].type == 'radio' || eles[0].type == 'checkbox') {
							$e.add(eles,'click',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
						}
					}
					if(this.fieldHelpers[columnName]) {
						this.fieldHelpers[columnName].bind(eles[0]);
					}
				}
			}
		}
		
		for(var dialogWatch in this.dialogWatches) {
			if(typeof this.dialogWatches[dialogWatch].repeatingSection != 'undefined') {
				this.repeatingSections[this.dialogWatches[dialogWatch].repeatingSection]._w[dialogWatch] = this.dialogWatches[dialogWatch];
			}
		}

		for(var repeatingSection in this.repeatingSections) {
			for( var i = 1; i <= this.repeatingSections[repeatingSection].rows; i++) {
				this._prepareRepeatingSectionRow(repeatingSection,i,rowNum);
			}
			this._prepareRepeatingSection(repeatingSection,rowNum);
		}
		
		if(rele) {
			for(var dialogWatch in this.dialogWatches) {
				if(typeof this.dialogWatches[dialogWatch].repeatingSection == 'undefined') {
					var watchIds = new Array();
					var eleTagName = '';
					var eles = 0;
					var tempEle = 0;
					for(var i = 0;i<this.dialogWatches[dialogWatch].watch.length; i++){
					//	if(this.dialogWatches[dialogWatch].watch[i] == this.dialogId + '.STATEINFO') watchIds.push(this.dialogId + '.STATEINFO');
					//	else {
							tempEle = $(this.dialogId + '.V.R' + rowNum + '.' + this.dialogWatches[dialogWatch].watch[i]);
							eleTagName = '';
							if(tempEle) eleTagName = tempEle.tagName.toLowerCase();
							if(eleTagName != 'input' && eleTagName != 'select' && eleTagName != 'textarea'){
								eles = $n('V.R' + rowNum + '.' + this.dialogWatches[dialogWatch].watch[i]);
								eles = $cetp(eles,$(this.dialogId + '.R' + rowNum));
								for(var j=0;j<eles.length;j++) watchIds.push(eles[j].id);
							} else watchIds.push(this.dialogId + '.V.R' + rowNum + '.' + this.dialogWatches[dialogWatch].watch[i]);
					//	}
					}			
					A5.Watch.add(this.dialogId+'.R' + rowNum + '.'+dialogWatch,watchIds,{
						data: {rowNumber: rowNum},
						onChange: this.dialogWatches[dialogWatch].onChange
					});
				}
			}
		}
		
	},
	
	_prepareRepeatingSection: function(sectionName,rowNum) {
		var rele = $(this.dialogId + '.R' + rowNum);
		var ele = 0;
		var eleL = 0;
		
		var rsTemp = this.repeatingSections[sectionName];
		var instNum = 0;
		
		var rsTemp = this.repeatingSections[sectionName];
		for(var i = 0; i < rsTemp._r[rowNum-1].i.length ; i ++ ) {
			if(!rsTemp._r[rowNum-1].i[i].deleted) {
				instNum = i + 1;
				break;
			}
		}

		var rsEle = $(this.dialogId+'.V.R'+rowNum + '.' + sectionName + '.I' + instNum +'.CONTENT');
		var rslEle = $(this.dialogId+'.V.R'+rowNum + '.' + sectionName + '.TITLES');
		var rslIndex = 0;
		if(rslEle && rsEle) {
			var rslIndx = 0;
			for(var i=0;i<rsEle.childNodes.length;i++){
				if(typeof rsEle.childNodes[i].tagName != 'undefined'){
					if(rsEle.childNodes[i].tagName.toUpperCase() == 'DIV'){
						while(rslIndx < rslEle.childNodes.length){
							if(typeof rslEle.childNodes[rslIndx].tagName != 'undefined'){
								if(rslEle.childNodes[rslIndx].tagName.toUpperCase() == 'DIV') break;
							}
							rslIndx++;
						}
						if( !(rsEle.childNodes[i].innerHTML == '&nbsp;' && rsEle.childNodes[i].style.width == '')) {
							rslEle.childNodes[rslIndx].style.width = rsEle.childNodes[i].offsetWidth+'px';
						}
						rslIndx++;
					}
				}
			}
		}
	
		this._getRepeatingSectionLogicalRowNumber(sectionName);
	},
	
	_getRepeatingSectionLogicalRowNumber: function(sectionName) {
		var rowNum = 1;
		if(typeof this.repeatingSections == 'undefined') return false;
		if(typeof this.repeatingSectionInfo == 'undefined') return false;
		var rsInfo = this.repeatingSectionInfo[sectionName];
		if(rsInfo.showRowCount == false) return false;
		var rsTemp = this.repeatingSections[sectionName];
		//var instNum = rsTemp.activeRow;
		var logRow = 0;
		var ele = '';
		for(var i = 1; i <= rsTemp.rows; i++) {
			ele = $(this.dialogId + '.' + sectionName + '.RSROWNUMBER_A5INSTANCE' + i );
			if(rsTemp._r[rowNum-1].i[i-1].deleted == false) {
				logRow++;
				if(ele) ele.innerHTML = logRow;
			}
		}
	},
	
	_prepareRepeatingSectionRow: function(sectionName,instNum, rowNum) {
		var rele = $(this.dialogId + '.R' + rowNum);
		var eles = 0;
		var rsTemp = this.repeatingSections[sectionName];
		rsTemp._r[rowNum-1].i[instNum-1] = {deleted: false, dirty: false, error: false};
		for(var columnName in rsTemp._ci) {
			if(rsTemp._ci[columnName].isArray) eles = $n('V.R' + rowNum + '.' + columnName +'_A5INSTANCE' + instNum + '[]');
			else eles = $n('V.R' + rowNum + '.' + columnName +'_A5INSTANCE' + instNum);
			eles = $cetp(eles,rele);
			if(eles) {
				$e.add(eles,'keyup',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
				$e.add(eles,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
				$e.add(eles,'blur',this._setControlBlur,this,false,this.dialogId + '.DIALOG');
				$e.add(eles,'focus',this._setControlFocus,this,false,this.dialogId + '.DIALOG');
				
				if(eles[0].tagName.toLowerCase() == 'input') {
					if(eles[0].type == 'radio' || eles[0].type == 'checkbox') {
						$e.add(eles,'click',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
					}
				}
				if(this.fieldHelpers[columnName]) {
					this.fieldHelpers[columnName].bind(eles[0]);
				}
			}
		}	
		var rsiEle = $(this.dialogId + '.V.R' + rowNum + '.' + sectionName + '.I' + instNum );
		$e.add(rsiEle,'mousedown',this._rsiOnClick,this,false,this.dialogId+'.DIALOG');
		
		var flagHighlightOnHover  = this.repeatingSectionInfo[sectionName].highlightOnHover;
		var flagHighlightOnSelect = this.repeatingSectionInfo[sectionName].highlightOnSelect;
		
		if(this.defaultRepeatingSection){
			if(this.defaultRepeatingSection.rowHoverClassName != '' && flagHighlightOnHover){
				$e.add(rsiEle,'mouseover',function(e,classInst){ $acn($(this.id+'.CONTENT').parentNode,classInst.defaultRepeatingSection.rowHoverClassName);},this,false,this.dialogId+'.DIALOG');
				$e.add(rsiEle,'mouseout',function(e,classInst){ $rcn($(this.id+'.CONTENT').parentNode,classInst.defaultRepeatingSection.rowHoverClassName);},this,false,this.dialogId+'.DIALOG');
			}
		}
		
		var rseEle = $(this.dialogId + '.V.R' + rowNum + '.' + sectionName + '.I' + instNum +'.ERROR' );
		if(rseEle) {
			$e.add(rseEle,'mouseover',this._repeapeatingSectionRowErrorShow,this,false,this.dialogId + '.DIALOG');
			$e.add(rseEle,'mouseout',this._repeapeatingSectionRowErrorHide,this,false,this.dialogId + '.DIALOG');
			
		}
		for(var dialogWatch in rsTemp._w) {
			var watchIds = new Array();
			var eleTagName = '';
			var eles = 0;
			var tempEle = 0;

			for(var i = 0;i<rsTemp._w[dialogWatch].watch.length; i++){
				tempEle = $(this.dialogId + '.V.R' + rowNum + '.' + rsTemp._w[dialogWatch].watch[i].replace(':A5INSTANCE','_A5INSTANCE'+instNum));
				eleTagName = '';
				if(tempEle) eleTagName = tempEle.tagName.toLowerCase();
				if(eleTagName != 'input' && eleTagName != 'select' && eleTagName != 'textarea'){
					eles = $n('V.R' + rowNum + '.' + rsTemp._w[dialogWatch].watch[i].replace(':A5INSTANCE','_A5INSTANCE'+instNum));
					eles = $cetp(eles,$(this.dialogId + '.R' + rowNum));
					for(var j=0;j<eles.length;j++) watchIds.push(eles[j].id);
				} else watchIds.push(this.dialogId + '.V.R' + rowNum + '.' + rsTemp._w[dialogWatch].watch[i].replace(':A5INSTANCE','_A5INSTANCE'+instNum));
			}			
			A5.Watch.add(this.dialogId+'.R' + rowNum + '.'+dialogWatch+'.I'+instNum,watchIds,{
				data: {rowNumber: rowNum, instNumber: instNum},
				onChange: rsTemp._w[dialogWatch].onChange
			});
		}
		
		var buttons = this.repeatingSectionInfo[sectionName].buttons;
		if(typeof buttons != 'undefined') {
			for(var i = 0; i < buttons.length; i++) {
				this._buttons[buttons[i]].bind(this.dialogId+'.V.R' + rowNum + '.' + buttons[i] + '_A5INSTANCE' + instNum);
			}
		}
	},
	
	
	_populateSourceComponent: function() {
		var go = {};
		go.controlMap = this.stateInfo.__controlMap;
		if(typeof go.controlMap == 'undefined') {
			alert('Method only appropriate if Dialog was opened using the \'Open Dialog to edit current record\' method');
			return false;
		};
		go.sourceGridRowNumber = this.stateInfo._parentGridRow;
		go.parentControlType = this.stateInfo.__parentComponentType;
		go.parentAlias = this.stateInfo.__parentAlias;
		go.submitParent = this.stateInfo._submitParent;
		go.windowName = this.stateInfo.__windowname;
		go.closeAfterSubmit = this.stateInfo.__closeDialogAfterSubmit;
		go.controlSourceData = this.harvest();
		
		var a = go.controlMap.split(',');
		var itemP = '';
		var item = '';
		var itemA = [];
		var arr = [];
		//arr - source - grid/dialog source control name, target - targetDialog controlName
		//create an array from the control Map with .source and .target properties
		for(var i = 0; i < a.length; i++){
			item = a[i];
			itemA = item.split('>');
			itemP = {};
			itemP.source = itemA[0];
			itemP.target = itemA[1];
			arr.push(itemP);
	    }
		
		var objName = '';
		var p2 = 'G';
		var r2 = '1';
		if(go.parentControlType == 'G' || go.parentControlType == 'D') {
			objName = go.parentAlias + '_GridObj';
			if(go.parentControlType == 'G') r2 = go.sourceGridRowNumber;
		}
		if(go.parentControlType == 'O') {
			objName = go.parentAlias + '_DlgObj';
			r2 = '1';	
			p2 = 'O';
		}

		//create an array from the source data values
	    var arrSD = go.controlSourceData.split('&');
	    var y = '';
	    var arr2 = [];
	    var arr3 = [];
	    var data = '';
	    var cn = '';
	    // arr2 - source - gridProperty
	    var rowNum = '1';
	    var sliceLen = 4;
	    for(var i = 0; i < arrSD.length; i++) {
	        y = arrSD[i];
	        if(y.slice(0,sliceLen) == 'V.R' + rowNum) {
	            arr3 = y.split('=');
	            data = arr3.slice(1,99999).join('=');
	            //get controlname from string like V.R4.FIRSNAME
	            cn = arr3[0].split('.')[2];
	            itemP = {};
	            itemP.source = cn;
	            itemP.data = data;
	            arr2.push(itemP);
	        }
	    }	
		
		//lookup the source Data value for each entry in the controlMap.
		var sn = '';
		var idx = '';
		var vali = '';
		var _d = {};
		
		for(var i = 0; i < arr.length; i++) {
			sn = arr[i].target;
			sn = sn.toUpperCase();
			idx = this._findArrayProp(arr2,'source',sn);
			if(idx >= 0 ) {
				vali = arr2[idx].data;
				if(p2 == 'G') window[objName].setValue(go.parentControlType,arr[i].source,r2,vali);
				else window[objName].setValue(arr[i].source,vali);
				
			} else {
				if(p2 == 'G') window[objName].setValue(go.parentControlType,arr[i].source,r2,vali);
				else window[objName].setValue(arr[i].source,'');
			}
	    }
	  
	    if(go.closeAfterSubmit) {
	    	var currWindow = window[objName].getWindow(go.windowName);
	    	currWindow.hide();
	    }
	    

		if(go.submitParent == 'Y') {
			if(go.parentControlType == 'G') window[objName].submitGridPartRow(r2);
			if(go.parentControlType == 'D') window[objName].submitDetailView();
			if(go.parentControlType == 'O') window[objName].submit();
		}
	
	
	},
	
	_synchronizeDialogData: function(go) {
	
		var rowNum = go.sourceGridRowNumber;
		
		var osi = {};
		osi._parentGridRow = rowNum;
		this.setStateInfo(osi);
		
	    var a = go.controlMap.split(',');
	    var itemP = '';
	    var item = '';
	    var itemA = [];
	    var arr = [];
	    //arr - source - grid/dialog source control name, target - targetDialog controlName
	    //create an array from the control Map with .source and .target properties
	    for(var i = 0; i < a.length; i++){
	        item = a[i];
	        itemA = item.split('>');
	        itemP = {};
	        itemP.source = itemA[0];
	        itemP.target = itemA[1];
	        arr.push(itemP);
	    }
	    
	   
		//create an array from the source data values
	    var arrSD = go.controlSourceData.split('&');
	    var y = '';
	    var arr2 = [];
	    var arr3 = [];
	    var data = '';
	    var cn = '';
	    // arr2 - source - gridProperty
	    var rn = $u.s.toNum(rowNum);
	    var sliceLen = 4;
	    if(rn >= 10) sliceLen = 5;
	    if(rn >= 100) sliceLen = 6;
	    if(rn >= 1000) sliceLen = 7;
	    if(rn < 0) sliceLen = 5;
	    
	  
	    for(var i = 0; i < arrSD.length; i++) {
	        y = arrSD[i];
	        if(y.slice(0,sliceLen) == 'V.R' + rowNum) {
	            arr3 = y.split('=');
	            data = unescape(arr3.slice(1,99999).join('='));
	            //get controlname from string like V.R4.FIRSNAME
	            cn = arr3[0].split('.')[2];
	            itemP = {};
	            itemP.source = cn;
	            itemP.data = data;
	            arr2.push(itemP);
	        }
	    }
		
		//lookup the source Data value for each entry in the controlMap.
		var sn = '';
		var idx = '';
		var vali = '';
		var _d = {};
	    for(var i = 0; i < arr.length; i++) {
	    	sn = arr[i].source;
	    	idx = this._findArrayProp(arr2,'source',sn);
	    	if(idx >= 0 ) {
	    		vali = arr2[idx].data;
		    	_d[arr[i].target] = vali;
		    } else {
		    	_d[arr[i].target] = '';
		    }
	    }
	    this.populate(_d);
	    this.prepare();
	},
	
	
	_findArrayProp: function(array,propName,value) {
		for(var i = 0; i < array.length; i++) {
		    if(array[i][propName].toLowerCase() == value.toLowerCase()) {
	               return i;
	            }
		}
	    return -1;
	},
	
		
	_fireWatches: function(rowNum) {
		for(var dialogWatch in this.dialogWatches) {
			if(typeof this.dialogWatches[dialogWatch].repeatingSection != 'undefined') {
				for(var i = 0; i < this.repeatingSections[this.dialogWatches[dialogWatch].repeatingSection].rows; i++) {
					A5.Watch.fire(this.dialogId+'.R' + rowNum + '.'+dialogWatch + '.I' +(i+1));	
				}
				
			} else {
				A5.Watch.fire(this.dialogId+'.R' + rowNum + '.'+dialogWatch);
			}
		}
	},
	
	_repeapeatingSectionRowErrorShow: function(e,classInst) {
		var id = this.id;
		id = id.split('.');
		var rowNum = $u.s.toNum(id[2]);
		var instNum = $u.s.toNum(id[4]);
		var sectionName = id[3];
		var rsTemp = classInst.repeatingSections[sectionName];
		clearTimeout(rsTemp._r[rowNum-1].reto);
		if(rsTemp._r[rowNum-1].i[instNum-1].error) {
			//alert(rsTemp._r[rowNum-1].i[instNum-1].errorText);
			id.pop();
			id.pop();
			var errorDivId = id.join('.') +'.ERRORDIV';
			var ele = $(errorDivId);
			if(ele == false) {
				ele = document.createElement('div');
				ele.id = errorDivId;
				ele.className = classInst.fieldErrors.className;
				ele.style.position = 'absolute';
				$e.add(ele,'mouseover',classInst._repeapeatingSectionRowErrorHideCancel,classInst);
				$e.add(ele,'mouseout',classInst._repeapeatingSectionRowErrorHide,classInst);
				document.body.appendChild(ele);
			}

			if(rsTemp._r[rowNum-1].i[instNum-1].errorText.constructor == Array) {
				var html = [];
				html.push(rsTemp._r[rowNum-1].i[instNum-1].errorText[0]);
				html.push('&nbsp;<a onclick="if(this.nextSibling.style.display==\'none\'){this.nextSibling.style.display=\'block\'; this.innerHTML = \'Less...\'; } else {this.nextSibling.style.display=\'none\'; this.innerHTML = \'More...\'; }; return false;" style="text-decoration: underline; cursor: pointer;">More...</a>');
				html.push('<div style="display:none;">');
				html.push(rsTemp._r[rowNum-1].i[instNum-1].errorText[1]);
				html.push('</div>');
				ele.innerHTML = html.join('');
			} else {
				ele.innerHTML = rsTemp._r[rowNum-1].i[instNum-1].errorText;
			}
			ele.style.display = '';
			$po(ele,this,'dropdown');
			
		}
		
	},
	
	_repeapeatingSectionRowErrorHideCancel: function(e,classInst) {
		var id = this.id;
		id = id.split('.');
		var rowNum = $u.s.toNum(id[2]);
		var sectionName = id[3];
		var rsTemp = classInst.repeatingSections[sectionName];
		clearTimeout(rsTemp._r[rowNum-1].reto);
	},
	
	_repeapeatingSectionRowErrorHide: function(e,classInst) {
		var id = this.id;
		id = id.split('.');
		var rowNum = $u.s.toNum(id[2]);
		var sectionName = id[3];
		var rsTemp = classInst.repeatingSections[sectionName];
		rsTemp._r[rowNum-1].reto = setTimeout(function() {classInst._repeatingSectionRowErrorHideComplete(sectionName); } , 500);
	},
	
	_repeatingSectionRowErrorHideComplete: function(sectionName) {
		var errorDivId = this.dialogId + '.V.R1.' + sectionName + '.ERRORDIV';
		var ele = $(errorDivId);
		if(ele) {
			ele.style.display = 'none';
		}
	},
	
	activateControlContainer: function(name) {
		name = name.toUpperCase();
		
		if(!this._controlContainers[name]) return false;
		var obj = this._controlContainers[name];
		var containerName = '';
		for(var i = 0; i < obj.length; i++) {
			containerName = this.dialogId + '.V.R1.' + obj[i].tab + 'Obj';
			window[containerName].select(''+obj[i].pane);
		}
	},
	
	closeContainerWindow: function(ele) {
		//if dialog is opened in a window, closes the container window
	    var cw = A5.windows.getFromElement(ele);
	    if(cw) cw.hide();
	},
	
	setFocus: function(name) {
		this.activateControlContainer(name.toUpperCase());
		var ele = $(this.dialogId + '.V.R1.' + name.toUpperCase());
		if(ele) {
			ele.focus();
		}
	},

	_setControlFocus: function(e,classInst) {
		var oldFocus = '';
		var oldRS = '';
		var oldRSrow = '';
		if(typeof classInst._focusControl != 'undefined') oldFocus = classInst._focusControl;
		if(typeof classInst._focusRepeatingSection != 'undefined') oldRS = classInst._focusRepeatingSection;
		if(typeof classInst._focusRepeatingSectionRow != 'undefined') oldRSrow = classInst._focusRepeatingSectionRow;
		clearTimeout(classInst._blurTO);
		classInst._kw.on();
		this._focusRow = Number(this.name.split('.')[1].substr(1));
		var colName = this.name.split('.')[2];
		colName = colName.split('_A5INSTANCE');
		var instNum = colName[1];
		if(typeof instNum == 'undefined') instNum = '0';
		
		if(instNum > 0) {
			var rsName = classInst._findRepeatingSection(colName[0]);
			if(rsName != oldRS) {
				//alert('repeating section changed: ' + rsName);
				classInst._executeEvent('onRptSectionFocus',{sectionName: rsName});
				classInst._focusRepeatingSection = rsName;
				//alert('row in repeating section changed: ' + instNum);
				classInst._executeEvent('onRptSectionRowChange',{sectionName: rsName, rowNumber: instNum, previousRowNumber: -1});
				classInst._focusRepeatingSectionRow = instNum;
				oldRSrow = instNum;
			}
			
			if(instNum != oldRSrow) {
				//alert('row changed: ' + instNum);
				classInst._executeEvent('onRptSectionRowChange',{sectionName: rsName, rowNumber: instNum, previousRowNumber: oldRSrow});
				classInst._focusRepeatingSectionRow = instNum;
			}

		} else {
			classInst._focusRepeatingSection = '';
			classInst._focusRepeatingSectionRow = '';
		}
		
		colName = colName.join(':');
		colName = colName.split('[');
		colName = colName[0];
		classInst._focusControl = colName;
		if(colName != oldFocus) {
			classInst._executeEvent('onControlFocus',{controlName: colName});
		}
	},
		
	_setControlBlur: function(e,classInst) {
		classInst._blurTO = setTimeout(function() {classInst._completeControlBlur(); classInst = null; } ,100);
		var rowNum = Number(this.name.split('.')[1].substr(1));
		var colName = this.name.split('.')[2];
		colName = colName.split('_A5INSTANCE');
		var instNum = colName[1];
		if(typeof instNum == 'undefined') instNum = '0';
		colName = colName.join(':');
		colName = colName.split('[');
		colName = colName[0];

		//classInst.clientSideValidateField(colName,rowNum,instNum);
		//if you make a selection from an edit-combo, the validation was firing when you clicked in the edit-combo
		var classInst2 = classInst;
		setTimeout(function() {classInst2.clientSideValidateField(colName,rowNum,instNum); delete classInst2; },400);
		
	},

	_completeControlBlur: function() {
		this._kw.off();
	},
		
	_setControlDirty: function(e,classInst) {
		var rowNum = Number(this.name.split('.')[1].substr(1));
		var colName = this.name.split('.')[2];
		colName = colName.split('_A5INSTANCE');
		var instNum = colName[1];
		if(typeof instNum == 'undefined') instNum = '0';

		colName = colName.join(':');
		colName = colName.split('[');
		colName = colName[0];
		classInst.setControlDirty(colName,true,rowNum,true);
		if( this.tagName.toLowerCase() == 'select' || (this.tagName.toLowerCase() == 'input' && (this.type == 'radio' || this.type == 'checkbox') )) {
			classInst.clientSideValidateField(colName,rowNum,instNum);
		}
	},
	
	
	setControlDirty: function(colName,state) {
		var cntrlInfoObj = this._getControlInfo(colName);
		var rowNum = typeof arguments[2] != 'undefined' ? arguments[2] : 1;
		var setRowState = typeof arguments[3] != 'undefined' ? arguments[3] : false;
		var eles = $cetp($n('V.R' + rowNum + '.' + cntrlInfoObj.controlName),$(this.dialogId+'.R'+rowNum));
		if(state) {
			if(cntrlInfoObj.calculateSummary) this._summarize(cntrlInfoObj.name,rowNum);
			//needs to be changed
			if(!$u.compare($gvs(eles),this.originalValues[rowNum-1][cntrlInfoObj.fullName])) {
				$sa(eles,'A5IsDirty','true');
				if(setRowState) {
					this._setRowState(rowNum,true);
				}
			}
		} else {
			if($ga(eles[0],'A5IsDirty') == 'true') {
				$sa(eles,'A5IsDirty','false');
				if(setRowState) {
					this._setRowState(rowNum,false);
				}
			}
		}
	},
	
	getControlDirty: function(colName) {
		
		var cntrlInfoObj = this._getControlInfo(colName);
		var rowNum = typeof arguments[1] != 'undefined' ? arguments[1] : 1;
		var eles = $cetp($n('V.R' + rowNum + '.' + cntrlInfoObj.controlName),$(this.dialogId+'.R'+rowNum));
		if(eles) {
			var flagDirty = $ga(eles[0],'A5IsDirty');
			if($ga(eles[0],'A5IsDirty') == 'true') return true;
			else return false;
		} else {
			return false;
		}
	},
	
	_setRepeatingSectionRowDirty: function(name,rowNum) {
		var controlName = this._getControlsInRepeatingSection(name)[0];
		var data = this.getValue(controlName + ':' + rowNum);
		this.setValue(controlName + ':' + rowNum,'foo');
		this.setValue(controlName + ':' + rowNum,data);
	},
	
	
	_repeatingSectionRowIsDirty: function(name,rowNum) {
			var isDirty = false;
			var controls = this._getControlsInRepeatingSection(name);
			for(var i=1;i<= controls.length;i++) {
				if(this.getControlDirty(controls[i-1] + ':' + rowNum)) {
					isDirty = true;
					return isDirty;
				}
			}
			return isDirty;
	},
	
	_getControlsInRepeatingSection: function(name) {
		return this.repeatingSectionInfo[name].controls;
	},
	

	_setRowState: function(rowNum,isDirty) {
		var stateChange = false;
		if(this._dirtyRows[rowNum-1] != isDirty) {
			stateChange = true;
			this._dirtyRows[rowNum-1] = isDirty;
		}
		
		if(stateChange) {
			if(isDirty){
				if($u.a.find(this._dirtyRows,true) != -1 && !this._isDirty) {
					this._isDirty = true;
				}
			} else{
				if($u.a.find(this._dirtyRows,true) == -1 && this._isDirty) {
					this._isDirty = false;
				}
			}
			if(this._prepared)	this._fireWatches(rowNum);
			this._executeEvent('onStateChange',{isDirty: this._isDirty});
		}
	},	
	

	_keyF1: function(){
		//alert(this._focusControl);
		
		if(this._focusControl != '') {
			var instNum = this._focusControl.split(':')[1];
			if(typeof instNum == 'undefined') instNum = '';
			else instNum = Number(instNum);
			if(instNum > 0) instNum = '_A5INSTANCE' + instNum;
			this.showFieldHelp(this._focusControl,instNum);
		}
		return true;
	},
	
	harvest: function() {
		var data = this._harvestRow(1);
		return data;
	},
	
	getData: function() {
		//just an alias for _harvestRow()
		return this._harvestRow(1);
	},
	
	populateControlsFromTable: function(primaryKey) {
	
		var pkData = '';
		if(primaryKey.constructor == Array) pkData = primaryKey.join('|||');
		else pkData = primaryKey;
		var showDebugInfo = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		var data = '_showDebug=' + showDebugInfo + '&_primaryKey=' + pkData;
		var xbasicFunction = 'system:populateControlsFromTable';
		this.ajaxCallback('G',1,xbasicFunction,'',data);
	},
		
	
	_harvestRow: function(row) {
		var data = new Array();
		var dirtyColumns = new Array();
		var rs = 0;
		var colnameSuffix = '';
		for(var colName in this.columnInfo) {
			if(this.columnInfo[colName].isArray) colnameSuffix = '[]';
			else colnameSuffix = '';
			if(typeof this.columnInfo[colName].repeatingSection != 'undefined') {
				rs = this.repeatingSections[this.columnInfo[colName].repeatingSection];
				for(var i = 1; i <= rs.rows; i++) {
					data.push(A5.ajax.buildURLParam('V.R' + row + '.' + colName+'_A5INSTANCE' + i+colnameSuffix, this.getValue(colName+':'+i,row) ));				
					data.push(A5.ajax.buildURLParam('old.V.R' + row + '.' + colName+'_A5INSTANCE' + i+colnameSuffix, this.originalValues[row-1][colName+':'+i] ));
					if(this.getControlDirty(colName+':'+i,row)) {
						dirtyColumns.push(colName+'_A5INSTANCE'+i);
					}
				}
			} else {

				data.push(A5.ajax.buildURLParam('V.R' + row + '.' + colName+colnameSuffix, this.getValue(colName,row) ));				
				data.push(A5.ajax.buildURLParam('old.V.R' + row + '.' + colName+colnameSuffix, this.originalValues[row-1][colName] ));
				if(this.getControlDirty(colName,row)) {
					dirtyColumns.push(colName);
				}
			}
		}
		data.push(A5.ajax.buildURLParam('dirtyColumns.R' + row, dirtyColumns.join('\n') ));
		//talk to eavan: alert(data.join('&'));
		
		return data.join('&');
	},
	
	populate: function(data) {
		var row = typeof arguments[1] != 'undefined' ? arguments[1] : 1;
		//if clean is true, then after you set the data the row is now clean
		var clean = typeof arguments[2] != 'undefined' ? arguments[2] : true;
		if(clean) {
			//$u.o.assign(this.originalValues[row-1],data);
			var cntrlInfoObj = '';
			var prop2 = '';
			for(var prop in data) {
				prop2 = prop.split('_A5INSTANCE').join(':');
				prop2 = prop2.toUpperCase();
				this.setValue(prop2,data[prop],false,row);
				this.originalValues[row-1][prop2] = data[prop];
				cntrlInfoObj = this._getControlInfo(prop2);
				$sa($cetp($n('V.R'+row + '.' + cntrlInfoObj.controlName),$(this.dialogId+'.R' + row)),'A5IsDirty','false');
			}
			this._setRowState(row,false);			
		} else {
			for(var prop in data) {
				this.setValue(prop,data[prop],true,row);
			}
		}
	},
	

	getValue: function(name) {
		name = name.toUpperCase();
		var cntrlInfoObj = this._getControlInfo(name);
		name = cntrlInfoObj.name;
		var row = typeof arguments[1] != 'undefined' ? arguments[1] : 1;
		if(this.columnInfo[name]) {
			var colType = this.columnInfo[name].type.split(',')[0];
			var dataType = this.columnInfo[name].dataType;
			if(this._dirtyRows[row-1]) {
				if(colType != 'label'  && colType != 'link'  && colType != 'img' ){
					var val = $gvs('V.R' + row + '.' + cntrlInfoObj.controlName, $(this.dialogId + '.R' + row));
					if(val == $ga('V.R' + row + '.' + cntrlInfoObj.controlName, 'A5WatermarkText', $(this.dialogId + '.R' + row))[0]) val = '';
					if(typeof dataType != 'undefined') {
						if(dataType == 'L') val = $u.s.toBool(val);
					}
					return val;
				}				
			}
			if(colType == 'link') return this.originalValues[row -1][cntrlInfoObj.fullName][0];
			else return this.originalValues[row -1][cntrlInfoObj.fullName];			
		} else {
			var val = $gvs(this.dialogId + '.V.R' + row + '.' + name);
			if(val == $ga(this.dialogId + '.V.R' + row + '.' + name, 'A5WatermarkText')) val = '';
			return val;			
		}
	
	},


	setValue: function(name, value) {
		var ele = false;
		name = name.toUpperCase();
		var cntrlInfoObj = this._getControlInfo(name);
		name = cntrlInfoObj.name;
		var honorChange = typeof arguments[2] == 'boolean' ? arguments[2] : true;
		var row = typeof arguments[3] != 'undefined' ? arguments[3] : 1;
		if(this.columnInfo[name]) {
			if(this.columnInfo[name].dataType == 'L') value = $u.s.toBool(''+value);
			colType = this.columnInfo[name].type.split(',')[0];
			if(typeof this.fieldHelpers[name] != 'undefined'){
				this.fieldHelpers[name].setValue(value,this.dialogId+'.V.R'+row+'.'+cntrlInfoObj.controlName);
				ele = $(this.dialogId+'.V.R'+row+'.'+cntrlInfoObj.controlName);
			} else if(colType == 'label'  || colType == 'link'  || colType == 'img'){
				$svs(this.dialogId+'.V.R'+row+'.'+cntrlInfoObj.controlName,value);
				ele = $(this.dialogId+'.V.R'+row+'.'+cntrlInfoObj.controlName);
			} else if(colType == 'popup-rte'){
				$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,$(this.dialogId+'.R'+row));
				$(this.dialogId+'.V.R'+row+'.'+cntrlInfoObj.controlName+'.DISPLAY').innerHTML = value;
			} else if(colType == 'rte'){
				$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,$(this.dialogId+'.R'+row));
				if(typeof window[this.dialogId+'_'+cntrlInfoObj.controlName+'_RTEObj']._rteObj != 'undefined') {
					window[this.dialogId+'_'+cntrlInfoObj.controlName+'_RTEObj']._rteObj.setHTML(value);				
				} else {
					window[this.dialogId+'_'+cntrlInfoObj.controlName+'_RTEObj'].setHTML(value);				
				}
			} else{
				$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,$(this.dialogId+'.R'+row));
			}
		} else {
			$svs('V.R'+row+'.'+name,value,$(this.dialogId+'.R'+row));
		}
		if(!ele && honorChange){
			ele = $n('V.R'+row+'.'+cntrlInfoObj.controlName);
			ele = $cetp(ele,$(this.dialogId+'.R'+row));
			if(ele){
				for(var i=0;i<ele.length;i++) $e.execute(ele[i],'change');
			}
		} else if(honorChange) {
			$e.execute(ele,'change');
		}
	},
	
	openLookup: function(fieldName,objEle) {
		window[this.dialogId +'_LOOKUPGRID_'+fieldName].call(this,objEle);
	},
	
	fillinLookupValues: function(data, fieldName, part, lookupGridId) {
		var currWindow = this.getWindow(this.dialogId + '.LOOKUP.' + fieldName);
		if(currWindow) currWindow.hide();
		var rowNum = 1;
		var fieldsTofillin = this.lookups[fieldName].fieldsToFillin;
		var prop = '';
		for(var i = 0; i < data.length; i++) {
			prop = fieldsTofillin[i];
			this.setValue(prop,data[i],true,rowNum);
		}
		if(this.lookups[fieldName].resetAfterFillin) {
			window[lookupGridId+'_GridObj'].showAll();
		}
		this._executeEvent('afterLookupGridFillinValues',{});
	},
	
	setRepeatingSectionRowError: function(sectionName,instNum,errorText) {
		var rowNum = 1;
		var rsTemp = this.repeatingSections[sectionName];
		rsTemp._r[rowNum-1].i[instNum-1].error = true;
		rsTemp._r[rowNum-1].i[instNum-1].errorText = errorText;
		this._showHideRowErrorIcons(sectionName);
		var ele = $(this.dialogId + '.V.R'+rowNum+'.'+sectionName+'.I'+instNum+'.CONTENT').parentNode;
		if(this.defaultRepeatingSection){
			if(this.defaultRepeatingSection.rowErrorClassName != ''){
				$acn(ele,this.defaultRepeatingSection.rowErrorClassName)
			}
		}
	},
	
	clearRepeatingSectionRowError: function(sectionName,instNum) {
		var rowNum = 1;
		var rsTemp = this.repeatingSections[sectionName];
		rsTemp._r[rowNum-1].i[instNum-1].error = false;
		this._showHideRowErrorIcons(sectionName);
		var ele = $(this.dialogId + '.V.R'+rowNum+'.'+sectionName+'.I'+instNum+'.CONTENT').parentNode;
		if(this.defaultRepeatingSection){
			if(this.defaultRepeatingSection.rowErrorClassName != ''){
				$rcn(ele,this.defaultRepeatingSection.rowErrorClassName)
			}
		}
	},
	
	_showHideRowErrorIcons: function(sectionName) {
		var rowNum = 1;
		var rsTemp = this.repeatingSections[sectionName];
		var hasError = false;
		for(var i = 0; i < rsTemp._r[rowNum-1].i.length; i++) {
			if(rsTemp._r[rowNum-1].i[i].error) {
				hasError = true;
				break;
			}
		}
		if(hasError) {
			var ele = $(this.dialogId + '.V.R' + rowNum + '.' + sectionName + '.TITLES.ERROR')
			if(ele) ele.style.display = '';
			for(var i = 1; i <= rsTemp._r[rowNum-1].i.length; i++) {
				var ele = $(this.dialogId + '.V.R' + rowNum + '.' + sectionName + '.I' + i + '.ERROR')
				if(ele) {
					ele.style.display = '';
					var eles = ele.getElementsByTagName('img');
					if(rsTemp._r[rowNum-1].i[i-1].error) {
						eles[0].style.visibility = '';
					} else {
						eles[0].style.visibility = 'hidden';
					}
					
				}
			}
		} else {
			var ele = $(this.dialogId + '.V.R' + rowNum + '.' + sectionName + '.TITLES.ERROR')
			if(ele) ele.style.display = 'none';
			for(var i = 1; i <= rsTemp._r[rowNum-1].i.length; i++) {
				var ele = $(this.dialogId + '.V.R' + rowNum + '.' + sectionName + '.I' + i + '.ERROR')
				if(ele) ele.style.display = 'none';
			}
			
		}
		
	
	},
	
	
	setErrors: function(errors) {
		var clientSide = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		for(var i = 0; i < errors.length; i++) {
			var colName = errors[i].id.split('.')[3];
			colName = colName.split('_A5INSTANCE');
			colName = colName.join(':');
			colName = colName.split('[');
			colName = colName[0];
			this.activateControlContainer(colName);
			if(errors[i].id.search('_A5INSTANCE') != -1) {
				this._rseh.set(errors[i].id,errors[i].message);
				for(var j = 0; j < this._rseh._e.length; j++) {
					if(this._rseh._e[j].id == errors[i].id) {
						this._rseh._e[j].clientSide = clientSide;
						break;
					}
				}
			} else {
				this._eh.set(errors[i].id,errors[i].message);
				for(var j = 0; j < this._eh._e.length; j++) {
					if(this._eh._e[j].id == errors[i].id) {
						this._eh._e[j].clientSide = clientSide;
						break;
					}
				}
				
			}
		}
	},

	clearErrors: function() {
		if(typeof arguments[0] != 'undefined') {
			var errorsToClear = new Array();
			var rsErrorsToClear = new Array();
			for(var i = 0; i < arguments[0].length; i++) {
				if(typeof arguments[0][i] == 'number') {
					for(var j = 0; j < this._eh._e.length; j++) {
						if(this._eh._e[j].id.indexOf('.R'+arguments[0][i]+'.') > -1) {
							errorsToClear.push(this._eh._e[j].id);
						}
					}
				} else {
					
					if(arguments[0][i].search('_A5INSTANCE') != -1) rsErrorsToClear.push(arguments[0][i]);
					else errorsToClear.push(arguments[0][i]);
				}
				
			}
			if(errorsToClear.length > 0 ) this._eh.clear(errorsToClear);
			if(rsErrorsToClear.length > 0 ) this._rseh.clear(rsErrorsToClear);
		} else {
			this._eh.clear();
			this._rseh.clear();
		}
		
		if($(this.dialogId + '.GLOBALERRORS')) $(this.dialogId + '.GLOBALERRORS').style.display = 'none';
	},
	
	clientSideValidateField: function(colName,rowNum,instNum) {
		
		var cntrlInfoObj = this._getControlInfo(colName);
		colName = cntrlInfoObj.name;
		if(typeof this.columnInfo[colName] != 'undefined') {
			if(typeof this.columnInfo[colName].validate != 'undefined') {
				var curValue = this.getValue(cntrlInfoObj.fullName);
				var result = this.columnInfo[colName].validate.call(this,curValue,colName,rowNum,instNum);
				if(typeof result == 'string') {
					this.setErrors([{id: this.dialogId + '.V.R' + rowNum + '.' + cntrlInfoObj.controlId, message: result}],true);
				} else {
					this.clearErrors([this.dialogId + '.V.R' + rowNum + '.' + cntrlInfoObj.controlId]);
				}
			}
		}
	},
	
	validate: function() {
		//1st arg: function to call if no errors, 2nd arg: function to call if errors, 3rd arg: tabId - only validate fields on current pane of tab Id
		var data = '';
		if(typeof arguments[0] == 'function') {
			this.__afterValidateSuccess = arguments[0];
			data='__hasAfterValidateSucess=true';
		} else {
			data = '__hasAfterValidateSucess=false';
		}
		
		if(typeof arguments[1] == 'function') {
			this.__afterValidateFailure = arguments[1];
			data=data+'&__hasAfterValidateFailure=true';
		} else {
			data=data+'&__hasAfterValidateFailure=false';
		}
		
		var tabObj = typeof arguments[2] != 'undefined' ? arguments[2] : '';
		var xbasicFunction = 'system:validateData';
		if(tabObj != '') {
			data = data +'&__currentTabOjbectId=' + tabObj;
			data = data+'&__currentPaneId=' + this.genieObjectNavigate(tabObj,'currentPaneId');
			xbasicFunction = 'system:validateFieldsOnPane'
		}
		this.ajaxCallback('G',1,xbasicFunction,'',data);
	},
	
	validateField: function(colName,rowNum,instNum) {
		var repeatingSectionName = '';
		if(instNum >0) {
			repeatingSectionName = this.columnInfo[colName].repeatingSection;
		}
		this.ajaxCallback('G',1,'system:validateField','','_fieldToValidate='+colName + '&_instNum=' + instNum +'&_repeatingSectionName='+repeatingSectionName);
	},
	
	submit: function() {
		var flagCheck = !this.submitIfHasClientSideErrors;
		
		//if there are any errors caught by clientside validation, the form does NOT submit.
		if(flagCheck){
			for(var i = 0; i < this._eh._e.length; i++) {
				if(this._eh._e[i].clientSide) return false;
			}
		}
	
		for(var i = 0; i < this._rseh._e.length; i++) {
					if(this._rseh._e[i].clientSide) return false;
		}
		
		if(!this._executeEvent('canSubmitDialog',{ajaxEvent: 'SubmitDialog'})) return false;
		this.ajaxCallback('G',1,'system:submitDialog');
	},
	
	
	
	resetForm: function() {
		var prompt = typeof arguments[0] != 'undefined' ? arguments[0] : true;
		if(prompt) {
			var classInst = this;

			var msg = classInst.resetFormMessage;
			var image = classInst.resetFormIcon;
			msg = '<div style="padding: 10px;" ><img src="'+image+'" style="margin-right: 5px; float: left;"/>'+msg+'					<br style="clear: both;" /></div>'					
					
			
			
			A5.msgBox.show(classInst.resetFormTitle,msg,'yn',function(button) {
				if(button == 'yes'){
					classInst.resetForm(false);    
			    } else if(button == 'no'){
			       //do nothing
    			}
    			delete classInst;
			} );
			return false;
		}
		this.populate(this.originalValues[0]);
		this.clearErrors();
	},
	
	setRepeatingSectionActiveRow: function(sectionName,instNumber) {
		var rowNum = 1;
		var oldInstNumber = this.repeatingSections[sectionName].activeRow;
		
		var flagHighlightOnHover  = this.repeatingSectionInfo[sectionName].highlightOnHover;
		var flagHighlightOnSelect = this.repeatingSectionInfo[sectionName].highlightOnSelect;
		
		if(oldInstNumber == instNumber) return false;
		var ele = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + instNumber +'.ICON');
		if(ele) {
			ele.style.visibility = '';
			if(this.defaultRepeatingSection){
				if(this.defaultRepeatingSection.rowSelectedClassName != '' && flagHighlightOnSelect){
					$acn($(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + instNumber +'.CONTENT').parentNode,this.defaultRepeatingSection.rowSelectedClassName);
				}
			}
			
			if(oldInstNumber != 0) {
				var eleOld = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + oldInstNumber+'.ICON' );
				eleOld.style.visibility = 'hidden';
				if(this.defaultRepeatingSection){
					if(this.defaultRepeatingSection.rowSelectedClassName != ''  && flagHighlightOnSelect){
						$rcn($(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + oldInstNumber +'.CONTENT').parentNode,this.defaultRepeatingSection.rowSelectedClassName);
					}
				}
			}
		}
		this.repeatingSections[sectionName].activeRow = instNumber;
	},
	
	_findRepeatingSection: function(controlName) {
		var rsi = this.repeatingSectionInfo;
		if(typeof rsi == 'undefined') return false;
		for(var sn in rsi) {
			var ctrls = rsi[sn].controls;
			for(var i = 1; i <= ctrls.length; i++) {
				if(ctrls[i-1] == controlName.toUpperCase()) return sn;
			}
		}
		return '';	
	},
	
	harvestRepeatingSectionColumn: function(controlName) {
		var delim = typeof arguments[1] != 'undefined' ? arguments[1] : ',';
		var sectionName = this._findRepeatingSection(controlName);
		if(sectionName == '') return false;
		controlName = controlName.toUpperCase();
		var rs = this.repeatingSections[sectionName];
		var rowNum = 1;
		var rows = rs.rows
		var dataArr = [];
		var ele = '';
		for(var instNum = 1; instNum <= rows; instNum ++) {
			if(rs._r[rowNum-1].i[instNum-1].deleted == false) {
				dataArr.push(this.getValue(controlName + ':' + instNum));
			}
		}
		var data = dataArr.join(delim);
		return data;
	},
	
	addRepeatingSectionRow: function(sectionName) {
		
		var flagNavToNewRow = typeof arguments[1] != 'undefined' ? arguments[1] : true;
		if(!this._executeEvent('canRptSectionRowAdd',{sectionName: sectionName})) return false;
		var flagIsDirty = this._isDirty
		var rowNum = 1;
		var rs = this.repeatingSections[sectionName];
		var pEle = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName);
		if($(this.dialogId + '.V.R'+rowNum+'.' + sectionName+'.CONTENT')) pEle = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName+'.CONTENT');
		var cEle = document.createElement('div');
		var dEle = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I[instanceNumber]');
		var iHTML = dEle.innerHTML;
		
		var instNum = rs.rows + 1;
		if(typeof iHTML == 'undefined') return false;
		iHTML = iHTML.split('[instanceNumber]').join('' + instNum);
		
		cEle.innerHTML = iHTML;
		cEle.id = this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + instNum;
		//pEle.appendChild(cEle);
		
		pEle.insertBefore(cEle,$(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + rs.rows).nextSibling);
		this._prepareRepeatingSectionRow(sectionName,instNum, rowNum);
		rs.rows = instNum;
		var tempData = {};
		for(colName in rs._ci) {
			tempData[colName + ':' + instNum] = this.defaultValues[colName];
			this.originalValues[rowNum-1][colName + ':' + instNum] = this.defaultValues[colName];
		}
		this.populate(tempData,rowNum,false);
		this.setRepeatingSectionActiveRow(sectionName,instNum);
		this._repeatingSectionFix(sectionName, rowNum);
		this._isDirty = flagIsDirty;
		this._fireWatches(rowNum);
		
		var scrollContainerEle = $(this.dialogId + '.V.R' + rowNum + '.' + sectionName + '.CONTENT');
		if(scrollContainerEle) {
			if(scrollContainerEle.style.overflow == 'auto' && flagNavToNewRow) cEle.scrollIntoView();	
		}

			
		this._executeEvent('afterRptSectionRowAdd',{sectionName: sectionName, rowNumber: instNum});
		
		this._getRepeatingSectionLogicalRowNumber(sectionName);
		

	},
	
	_repeatingSectionRowHasKey: function(sectionName,instNum) {
		//returns true if a row in a repeating section has a key value	
		if(typeof this.stateInfo == 'undefined') return false;
		if(typeof this.stateInfo.keys == 'undefined') return false;
		var aliases = this.repeatingSectionInfo[sectionName].boundAliases[0];
		if(typeof aliases == 'undefined') return false;
		var key = aliases + '_row' + instNum;
		if(typeof this.stateInfo.keys[key] == 'undefined') return false;
		return true;

	},
	
	
	_cleanRepeatingSections: function() {
		for(var sN in this.repeatingSections) {
			for(var i = 0; i < this.repeatingSections[sN]._r.length; i++) {
				for(var j = 0; j < this.repeatingSections[sN]._r[i].i.length; j++) {
					this.repeatingSections[sN]._r[i].i[j].dirty = false;
					
				}
			}
		}

	},

	
	
	deleteRepeatingSectionRow: function(sectionName) {
		
		var flagSilent = typeof arguments[2] != 'undefined' ? arguments[2] : false;
		var rs = this.repeatingSections[sectionName];
		var rowNum = 1;
		var instNum = typeof arguments[1] != 'undefined' ? arguments[1] : -1;
		if(instNum < 1) instNum = rs.activeRow;
		if(!this._executeEvent('canRptSectionRowDelete',{sectionName: sectionName, rowNumber: instNum})) return false;

		if(instNum > 0){
			var flagDirty = this._repeatingSectionRowIsDirty(sectionName,instNum);
			var flagRowHasKey = this._repeatingSectionRowHasKey(sectionName,instNum);
			if(flagRowHasKey) flagDirty = true;
			var flagOKToDelete = true;
			if(flagSilent == false && flagDirty == true) {
				//var flagConfirm = confirm('Delete this row?');
				var classInst = this;
				var msg = classInst.repeatingSectionInfo[sectionName].prompt;
				var image = classInst.repeatingSectionInfo[sectionName].icon;

				msg = '<div style="padding: 10px;" ><img src="'+image+'" style="margin-right: 5px; float: left;"/>'+msg+'					<br style="clear: both;" /></div>'					

				var title = classInst.repeatingSectionInfo[sectionName].title;
				A5.msgBox.show(title,msg,'yn',function(button) {
					if(button == 'yes'){
						classInst._deleteRepeatingSectionRowLow(sectionName,instNum);
						classInst._repeatingSectionFix(sectionName, rowNum);
					} else if(button == 'no'){
					   //do nothing
					}
					delete classInst;
					} );
				return false;

				//if(flagConfirm == false) flagOKToDelete =  false; 
			}

			if(flagOKToDelete) {
				this._deleteRepeatingSectionRowLow(sectionName,instNum);
				this._executeEvent('afterRptSectionRowDelete',{sectionName: sectionName, rowNumber: instNum});
			}

		}
		this._repeatingSectionFix(sectionName, rowNum);
		
		this._getRepeatingSectionLogicalRowNumber(sectionName);
	},
	
	
	_deleteRepeatingSectionRowLow: function(sectionName,instNum) {
		var flagDirty = this._repeatingSectionRowIsDirty(sectionName,instNum);
		//this._setRepeatingSectionRowDirty(sectionName,instNum);
		var rowNum = 1;
		this._setRowState(rowNum,true);
		var rs = this.repeatingSections[sectionName];
		var iEle = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + instNum);
		iEle.style.display = 'none';
		rs._r[rowNum-1].i[instNum-1].deleted = true;
		rs._r[rowNum-1].i[instNum-1].dirty = true;
		var nextInstNum = this._repeatingSectionNextRow(sectionName,instNum);
		if(nextInstNum > 0) this.setRepeatingSectionActiveRow(sectionName,nextInstNum);
		this._repeatingSectionFix(sectionName, rowNum);
	},
	
	_setRepeatingSectionRowCount: function(sectionName,rows) {
		var flagNavToNewRow = typeof arguments[2] != 'undefined' ? arguments[2] : true;
		var flagSetToNull = typeof arguments[3] != 'undefined' ? arguments[3] : true;
		var rowNum = 1;
		var iEle = 0;
		if(typeof this.repeatingSections == 'undefined') return false;
		var rs = this.repeatingSections[sectionName];
		var totalRows = rs.rows;
		//undelete all rows and set all controls to null
		for(var i = 1; i <= totalRows; i++) {
			if(rs._r[rowNum-1].i[i-1].deleted == true) this.undeleteRepeatingSectionRow(sectionName,i);
			else {
				iEle = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + i);
				if(iEle) iEle.style.display = '';
			}
			//set values in row that you undelete to null
			if(flagSetToNull) this._setRepeatingRowValuesToNull(sectionName,i);
		} 
		if(rows > totalRows) {
			var rowsToAdd = rows - totalRows
			for(var i = 1; i <= rowsToAdd; i++) {
				this.addRepeatingSectionRow(sectionName,flagNavToNewRow);
			}
		}
		if(totalRows > rows) {
			var rowsToDelete = totalRows - rows;
			var rn = 0;
			var iEle = 0;			
			for(var i = 1; i <= rowsToDelete; i++) {
				rn = (totalRows-i) + 1;	
				iEle = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName + '.I' + rn);
				if(iEle) iEle.style.display = 'none';
				rs._r[rowNum-1].i[rn-1].deleted = true;
			}
		}
		
	
		if(flagNavToNewRow) this.setRepeatingSectionActiveRow(sectionName,1);
		},
	
	
	_setRepeatingRowValuesToNull: function(sectionName,instNum) {
		var obj = this.repeatingSectionInfo[sectionName];
		var row = 1;
		for(var i = 1; i <= obj.controls.length; i++) {
			this.originalValues[0][obj.controls[i-1]+':' + instNum] = '';
			this.setValue(obj.controls[i-1] +':' + instNum,'',false);
			$sa($cetp($n('V.R'+row + '.' + obj.controls[i-1]),$(this.dialogId+'.R' + row)),'A5IsDirty','false');
		}
	},
	
	
	
	undeleteRepeatingSectionRow: function(sectionName,instNum) {
		var rs = this.repeatingSections[sectionName];
		var rowNum = 1;
		rs._r[rowNum-1].i[instNum-1].deleted = false;
		var eleName = this.dialogId + '.V.R'+rowNum+'.'+sectionName+'.I'+instNum;
		var ele = $(eleName);
		if(ele) {
			ele.style.display = '';
			this.setRepeatingSectionActiveRow(sectionName,instNum);
		}
	},
	
	
	_repeatingSectionNextRow: function(sectionName,instNum) {
		var rowNum = 1;
		var rs = this.repeatingSections[sectionName];
		var instData = rs._r[rowNum-1].i;
		for(var i = instNum + 1; i <= rs.rows; i++) {
			if(instData[i-1].deleted == false) return i;
		}

		for(var i = instNum - 1; i >= 1; i--) {
			if(instData[i-1].deleted == false) return i;
		}
		
		return -1;
		
	},
	
	_repeatingSectionFix: function(sectionName, rowNum) {
		var rs = this.repeatingSections[sectionName];
		for(var i = 0; i < rs._r[rowNum-1].i.length; i++) {
			if(rs._r[rowNum-1].i[i].deleted == false) {
				var ele = $(this.dialogId + '.V.R' + rowNum + '.' +sectionName + '.I' + (i+1) + '.DIVIDER');
				if(ele) ele.style.display = 'none';
				break;
			}
		}
	},
	
	
	
	genieObjectNavigate: function(id,target) {
		
		var rowNum = typeof arguments[2] != 'undefined' ? arguments[2] : 1;
		target = target.toLowerCase();
		var name = this.dialogId + '.V.R1.' + id + 'Obj';
		var ele = window[name];
		if(!ele) return false;
		var elePanes = '';
		if(typeof ele.panes != 'undefined')  {
			elePanes = ele.panes;
		} else if(typeof ele.bands != 'undefined') {
			elePanes = ele.bands;
		} else {
			return false;
		}
		
		var currentId = -1;
		if(typeof ele._curTabIndx != 'undefined') currentId = ele._curTabIndx;
		else currentId = ele._curBandIndx;
		
		if(target == 'currentpaneid') {
			return currentId;
		} else {
			var visiblePanes = [];
			for(var i = 0; i < elePanes.length; i++) {
				if(elePanes[i].show) visiblePanes.push(i);
			}
			var nextPane = 0;
			var lastPane = visiblePanes[visiblePanes.length-1];
			var currentPaneNumber = ($u.a.find(visiblePanes,currentId))
			if(target == 'next') nextPane = visiblePanes[currentPaneNumber + 1];
			if(target == 'prev') nextPane = visiblePanes[currentPaneNumber - 1];
			if(target == 'first') nextPane = visiblePanes[0];
			if(target == 'last') nextPane = visiblePanes[lastPane];
			if(typeof nextPane != 'undefined') {
				ele.select(nextPane);
				this._variablesChanged(['dialog.tabObject.' + id],rowNum);	
			}
		}
		
		this.genieButtonStates(id);
	},
	
	genieButtonStates: function(id) {
		var dialog = {};
		this._getTabObjectInfo(dialog,id);
		
		var elePrev = $(this.dialogId + '.' + id + '.PREVIOUS');
		var eleNext = $(this.dialogId + '.' + id + '.NEXT');
		var eleSubmit = $(this.dialogId + '.' + id + '.SUBMIT');
		if(elePrev) {
			if(dialog.tabObject[id].isOnFirstPane) elePrev.style.display = 'none';
			else elePrev.style.display = '';
		}
		if(eleNext) {
			if(dialog.tabObject[id].isOnLastPane) eleNext.style.display = 'none';
			else eleNext.style.display = '';
		}
		if(eleSubmit) {
			if(dialog.tabObject[id].isOnLastPane) eleSubmit.style.display = '';
			else eleSubmit.style.display = 'none';
		}
	},
	
	
	cascadingDropdown: function(rowNumber, value,childControls,part,thisControl) {
		//all dropdowns in a dialog have call cascadingDropdown(). But if they don't have dependent controls, it is a no-op.
		var arr = this._cascadingControls;
		var controlName = thisControl;
		controlName = controlName.split('.')
		controlName = controlName[ (controlName.length -1)];
		if($u.a.find(arr,controlName) == -1 ) return false;;
		part = 'O';
		var data = '';
		data = data + '__dropdownValue=' + urlencode(value);
		data = data + '&__childControls=' + urlencode(childControls);
		data = data + '&__thisControl=' + urlencode(controlName);
		data = data + '&__part=' + urlencode(part);
		//when a grid was being run as a lookup grid, __part was getting overwritten with the wrong value
		data = data + '&__part2=' + urlencode(part);
		data = data + '&_rowNumber=' + urlencode(rowNumber);
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'cascadingDropdown'})
		
		this.ajaxCallback('G',1,'system:cascadingDropdown','',data);
		return false;
	
	},
	
	_getControlInfo: function(colName){
		var tColName = colName.split(':');
		var tObj = {name: tColName[0], controlName: tColName[0], controlId: tColName[0], fullName: tColName[0], calculateSummary: false};
		if(this.columnInfo[tColName[0]]){
			if(typeof this.columnInfo[tColName[0]].repeatingSection != 'undefined'){
				var tRSInstNum = 0;
				var rsObj = this.repeatingSections[this.columnInfo[tColName[0]].repeatingSection];
				if(tColName.length > 1) tRSInstNum = $u.s.toNum(''+tColName[1]);
				if(tRSInstNum <=0) tRSInstNum = rsObj.activeRow;
				if(tRSInstNum > rsObj.rows) tRSInstNum = rsObj.rows;
				tObj.controlName = tObj.name+'_A5INSTANCE'+tRSInstNum;
				tObj.fullName = tObj.name + ':' + tRSInstNum;
			}
			tObj.controlId = tObj.controlName;
			if(this.columnInfo[tObj.name].isArray) tObj.controlName = tObj.controlName + '[]';
			if(this.columnInfo[tObj.name].calculateSummary) tObj.calculateSummary = this.columnInfo[tObj.name].calculateSummary;
		}
		return tObj;
	},
	
	_summarize: function(name,rowNum){
		name = name.toUpperCase();
		var cntrlInfoObj = this._getControlInfo(name);
		name = cntrlInfoObj.name;
		var sectionName = this.columnInfo[name].repeatingSection;
		var rs = this.repeatingSections[sectionName];
		var values = [];
		for(var i=1;i<=rs.rows;i++){
			if(rs._r[rowNum-1].i.length == 0) values.push(this.getValue(name+'_A5INSTANCE'+i,rowNum));
			else {
				if(!rs._r[rowNum-1].i[i-1].deleted) values.push(this.getValue(name+'_A5INSTANCE'+i,rowNum));
			}
		}
		if(this.columnInfo[name].dataType == 'N'){
			var sum = {count: values.length, total: 0, average: 0, first: 0, last: 0, minimum: 0, maximum: 0, standardDeviation: 0, variance: 0};
			if(sum.count > 0){
				for(var i=0;i<values.length;i++){
					values[i] = $u.s.toNum(values[i]);
					sum.total += values[i];
				}
				sum.average = sum.total/sum.count;
				sum.first = values[0];
				sum.last = values[values.length-1];
				values.sort(function(a,b){return a - b});
				sum.minimum = values[0];
				sum.maximum = values[values.length-1];
				
				// variance/standard deviation
				var sdVal = 0;
				var sdtVal = 0
				for(var i=0;i<values.length;i++){
					sdtVal = values[i]-sum.average;
					sdtVal = sdtVal*sdtVal;
					sdVal += sdtVal;
				}
				sum.variance = sdVal/sum.count;
				sum.standardDeviation = Math.sqrt(sdVal/sum.count);
			}
		} else{
			// Add date/logical handling at some point
			var sum = {count: values.length, first: '', last: '', minimum: '', maximum: ''};
			if(sum.count > 0){
				sum.first = values[0];
				sum.last = values[values.length-1];
				values.sort();
				sum.minimum = values[0];
				sum.maximum = values[values.length-1];
			}
		}
		this.rowStateInfo[rowNum-1].summary[name] = {};
		$u.o.assign(this.rowStateInfo[rowNum-1].summary[name],sum);
		this._variablesChanged(['summary.' + name],rowNum);	
	},	
	
	_variablesChanged: function(variables,rowNum) {
		for(var dialogWatch in this.dialogWatches) {			
			for(var i = 0; i < variables.length; i++) {
				if($u.a.find(this.dialogWatches[dialogWatch].variables,variables[i]) != -1) {
					A5.Watch.fire(this.dialogId + '.R' + rowNum + '.' + dialogWatch);
					break;
				}
			}
		}
	},
	
	setStateInfo: function(obj) {
		$u.o.assign(this.stateInfo,obj);
	},
	
	getStateInfo: function() {
		stateData = $u.o.toParams(this.stateInfo,'_state');
		return stateData;
	},
	
	refreshCaptcha: function(name) {
		var rowNum = 1;
		var data = '_captchaName=' + name + '&_rowNum=' + rowNum
		this.ajaxCallback('G',1,'system:refreshCaptcha','',data);
	},
	
	newRecord: function() {
		var data = '_newRecord=yes';
		delete this.stateInfo.keys;
		this.ajaxCallback('G',1,'system:newRecord','',data);
	},
	
	ajaxCallback: function(part,rowNum,xbasicFunction) {
		if(!this._executeEvent('canAjaxCallback',{xbasicFunctionName: xbasicFunction, ajaxEvent: 'AjaxCallback'})) return false;
		part = part.toUpperCase().substring(0,1);
		var callbackURL = typeof arguments[3] != 'undefined' ? arguments[3] : '';	
		var otherData = typeof arguments[4] != 'undefined' ? arguments[4] : '';
		
		//
		//rowNum can be 1, 2, 3, etc. or 1:none, 3:all etc
		//we want tempRowNum to be 1, 2, none, all so we can pass that into _getData(), and currentRowNum to be the actual current row number
		//if you pass in say 3, then tempRowNum and currentRowNum are both 3
		//but if you pass in 3:all, then tempRowNum = 'all' and currentRowNum = 3
		if(isNaN(rowNum)) {
			if(rowNum.toLowerCase() == 'all' || rowNum.toLowerCase() == 'all:all' ) {
				var tempRowNum = 'all';
				var currentRowNum = this._selectedRow;

			} else if (rowNum.toLowerCase() == 'none' || rowNum.toLowerCase() == 'none:none' ) {
				var tempRowNum = 'none';
				var currentRowNum = this._selectedRow;
			} else {
				if(rowNum.indexOf(':') == -1 ) {
				    var tempRowNum = 'all';
				    var currentRowNum = this._selectedRow;
				} else {
				    var rowNumC = new String(rowNum);
				    var currentRowNum = rowNumC.split(':')[0];
				var	tempRowNum = rowNumC.split(':')[1];
				};
			}
		} else {
			var tempRowNum = rowNum;
			var currentRowNum = rowNum;
		}		
		//
		
		//var data = this._getData(part,rowNum);
		var data = this.harvest();
		data = data + '&_part=' + part;
		data = '&' + data;
	
		//get repeating section active rows
		var rs = {};
		var rsPname = '';
		
		for(var repeatingSection in this.repeatingSections) {
			rsPname = '_repeatingSections.' + repeatingSection;
			rs = this.repeatingSections[repeatingSection];
			data = data + '&' +rsPname + '.activeRow=' + rs.activeRow;
			
			
			
			var rsDeletedInst = [];
			var rsDirtyInst = [];
			for(var i = 1; i <=rs.rows; i++)  {
				if(rs._r[currentRowNum-1].i[i-1].deleted) rsDeletedInst.push(i);
				if(rs._r[currentRowNum-1].i[i-1].dirty) rsDirtyInst.push(i);
			}
			data = data + '&' + rsPname + '.deletedRows='+rsDeletedInst.join(',');
			data = data + '&' + rsPname + '.dirtyRows='+rsDirtyInst.join(',');
			
		}
	
		if(callbackURL == '') {
			data = '_XbasicFunction='+xbasicFunction+'&_currentRow='+currentRowNum+'&__FormAction=GenericAjaxCallback&__FormID=' + this.gridId+data;
			callbackURL = this.ajaxURL;
		} else {
			data = '_Action='+xbasicFunction+'&_currentRow='+currentRowNum+'&__FormAction=GenericAjaxCallback&__FormID=' + this.gridId+data;
		}
		if(otherData!='') data=data + '&' + otherData;
		data = data + '&' + this.getStateInfo();
		A5.ajax.callback(callbackURL,data);
		return false;
	},
	
	_getRepeatingSectionInfo: function() {
		var currentRowNum = 1;
		//get repeating section active rows
		var data = '';
		var rs = {};
		var rsPname = '';

		for(var repeatingSection in this.repeatingSections) {
			rsPname = '_repeatingSections.' + repeatingSection;
			rs = this.repeatingSections[repeatingSection];
			data = data + '&' +rsPname + '.activeRow=' + rs.activeRow;
			var rsDeletedInst = [];
			var rsDirtyInst = [];
			for(var i = 1; i <=rs.rows; i++)  {
				if(rs._r[currentRowNum-1].i[i-1].deleted) rsDeletedInst.push(i);
				if(rs._r[currentRowNum-1].i[i-1].dirty) rsDirtyInst.push(i);
			}
			data = data + '&' + rsPname + '.deletedRows='+rsDeletedInst.join(',');
			data = data + '&' + rsPname + '.dirtyRows='+rsDirtyInst.join(',');
		}
		return data;
	
	},
	
	_getDialogVariables: function(dialog,summary,data) {
		//will need to fill in dialog. state varibles for use in client side calc fields.
		
		dialog.isDirty = this._isDirty;
		//dialog.state is not yet implemented - don't know what this means. header could be in view and a row in a Repeating Section could be enter
		
		$u.o.assign(summary,this.rowStateInfo[data.rowNumber-1].summary);
		if(this._tabObjects.length > 0) {
			for(var i in this._tabObjects) {
			    this._getTabObjectInfo(dialog,this._tabObjects[i]);
			}
		}
	},
	
	_getTabObjectInfo: function(dialog,tabId) {
		
		var name = this.dialogId + '.V.R1.' + tabId + 'Obj';
		var ele = window[name];
		if(!ele) return false;
		var currentId = -1;
		if(typeof ele._curTabIndx != 'undefined' ) currentId = ele._curTabIndx;
		else currentId = ele._curBandIndx;
		
		var elePanes = '';
		if(typeof ele.panes != 'undefined')  {
			elePanes = ele.panes;
		} else if(typeof ele.bands != 'undefined') {
			elePanes = ele.bands;
		} else {
			return false;
		}
		
		var visiblePanes = [];
		for(var i = 0; i < elePanes.length; i++) {
			if(elePanes[i].show) visiblePanes.push(i);
		}
		var paneCount = visiblePanes.length;
		var lastPane = visiblePanes[visiblePanes.length-1];
		var isOnFirstPane = false;
		var isOnLastPane = false;
		if(currentId == 0) isOnFirstPane = true;
		if(currentId == lastPane) isOnLastPane = true;
		if(typeof dialog.tabObject == 'undefined') dialog.tabObject = {};
		var currentPaneNumber = ($u.a.find(visiblePanes,currentId)) + 1;
		var js = '';
		dialog.tabObject[tabId] = {
			'isOnFirstPane' : isOnFirstPane, 
			'isOnLastPane' : isOnLastPane,
			'currentPane' : currentPaneNumber,
			'paneCount' : paneCount
			};
		
	},
	
	_tabPaneChange: function(id) {
		var dialog = {};
		this._getTabObjectInfo(dialog,id);
		this._variablesChanged(['dialog.tabObject.' + id ],1);
		var d = dialog.tabObject[id];
		this.genieButtonStates(id);
		this._executeEvent('onTabPaneChanged',{'isOnFirstPane': d.isOnFirstPane, 'isOnLastPane' : d.isOnLastPane, 'currentPane' : d.currentPane, 'paneCount': d.paneCount});
		
		var eleCurrent = '';
		var eleCount = ''
		eleCurrent = $(this.dialogId + '.' + id + '.PROGRESS.CURRENT');
		eleCount = $(this.dialogId + '.' + id + '.PROGRESS.STEPCOUNT');
		if(eleCurrent) eleCurrent.innerHTML = d.currentPane;
		if(eleCount) eleCount.innerHTML = d.paneCount;
		
		var eleBarChart = $(this.dialogId + '.' + id + '.PROGRESS.BARCHART');
		if(eleBarChart) {
			var chartWidthC = eleBarChart.style.width;
			var chartWidth = parseFloat(chartWidthC);
			var units = chartWidthC.replace(''+chartWidth,'');
			var barWidth = chartWidth * ( d.currentPane/d.paneCount);
			var eleBar = $(this.dialogId + '.' + id + '.PROGRESS.BARCHART.INNER');
			eleBar.style.width = '' + barWidth + units;
			
		}
	
		
	},
	
	loadJavascript: function(txt) {
		var sEle = document.getElementsByTagName('script');
		var cancelAdd = false;
		for(var i=0; i < sEle.length; i++) {
			if(sEle[i].text == txt) { 
				cancelAdd = true;
				break;
			}
		}
		
		if(cancelAdd == false) {
			var e = document.createElement('script');
			e.text = txt;
			document.getElementsByTagName('head')[0].appendChild(e);
		}
	},
	
	
	loadMetaTag: function(name,txt) {
		var e = document.createElement('meta');
		e.name = name;
		e.content = txt;
		document.getElementsByTagName('head')[0].appendChild(e);
	},
		
	
	
	loadJavascriptFile: function(filename) {
		var onLoaded = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		var sEle = document.getElementsByTagName('script');
		var cancelAdd = false;
		for(var i=0; i < sEle.length; i++) {
			if(sEle[i].src == filename) { 
				cancelAdd = true;
				break;
			}
		}
		if(cancelAdd == false) {
			var e = document.createElement('script');
			e.src = filename;
			e.onload = function() {
				if(typeof jQuery != 'undefined') jQuery.noConflict();
				if(onLoaded.constructor == Function) onLoaded();
			};

			e.onreadystatechange = function() {
				if(this.readyState == 'complete' || this.readyState == 'loaded') {
					if(typeof jQuery != 'undefined') jQuery.noConflict();
					if(onLoaded.constructor == Function) onLoaded();
				}
			};
			document.getElementsByTagName('head')[0].appendChild(e);

		}
	},
	
	
	loadCSSFile: function(filename) {
			var forceLoad = typeof arguments[1] != 'undefined' ? arguments[1] : false;
			var sEle = document.getElementsByTagName('link');
			var cancelAdd = false;
			if(forceLoad == false) {
				for(var i=0; i < sEle.length; i++) {
					if(sEle[i].href.indexOf(filename) > 0) { 
						cancelAdd = true;
						break;
					}
				}
			}
			if(cancelAdd == false) {
				var e = document.createElement('link');
				e.href = filename;
				e.rel = 'stylesheet';
				e.type = 'text/css';
				document.getElementsByTagName('head')[0].appendChild(e);
			}
	},	
	
	loadXbasic: function(txt) {
		var versionNum = typeof arguments[1] != 'undefined' ? arguments[1] : '';
		if(this._embeddedMode == false) return false;
		var sEle = document.getElementsByTagName('script');
		var cancelAdd = false;
		for(var i=0; i < sEle.length; i++) {
			if(typeof sEle[i].language != 'undefined') {
				if(sEle[i].language.toLowerCase() == 'xbasic' + versionNum) {
					if(sEle[i].text.toLowerCase()  == txt.toLowerCase()) { 
						cancelAdd = true;
						break;
					}
				}
			}
		}
		if(cancelAdd == false) {
			var e = document.createElement('script');
			e.text = txt;
			e.language = 'Xbasic' + versionNum;
			document.getElementsByTagName('head')[0].appendChild(e);
		}
	},
	
	helpWindow: function(txt,title) {
			
		var windowName = '_HelpWindow';
		var currWindow = this.getWindow(windowName);
		var windowHeight = typeof arguments[3] != 'undefined' ? arguments[3]: '3in';
		var windowWidth = typeof arguments[2] != 'undefined' ? arguments[2]: '4in';
		var windowType = typeof arguments[4] != 'undefined' ? arguments[4]: 'modal-resizable';
		var relativeTo = typeof arguments[5] != 'undefined' ? arguments[5]: '';
		var flagDropdown = false;


		if(windowType.split('-')[0] == 'dropdown') {
			flagDropdown = true;
			var rEle = $(relativeTo);
		}
		if(!currWindow) {
			currWindow = this.createWindow(windowName,windowType,
			{

			body: {
				content: {
					type: 'blank',
					elementId: '~'
				}
			},
			height: windowHeight,
			width: windowWidth,
			title: {
				html: 'Help Window',
				location: 'top',
				show: true
			},
			disableMove: false
		}
			);		
		}
		var windowDiv = currWindow.getWindowId('body');
		$(windowDiv).innerHTML = txt;
		currWindow.setTitle(title);
		if(!flagDropdown) {
			currWindow.show(); 
		} else {
			currWindow.show('dropdown',rEle);
		}
	},
		
	showDialogHelp: function(id) {
		var data = '__helpId=' + id;
		this.ajaxCallback('G','1','__a5ShowDialogHelp','',data);
	},

	showFieldHelp: function(fieldName,instNum) {
		fieldName = fieldName.split(':')[0];
		//alert(fieldName +'\n' + instNum);
		var helpId = this.columnInfo[fieldName].hlp;
		if(typeof helpId == 'undefined' || helpId == '') return false;
		var data = '__fieldname=' + fieldName + '&__helpId=' + helpId + '&__instNum=' + instNum;
		this.ajaxCallback('G',1,'system:showFieldHelp','',data);
	},

	openChildGrid: function(go) {
		A5.component.runGrid(go);
	},

	createWindow: function(name,settings) {
		if(!this.getWindow(name)) {
			if(typeof settings == 'string') {
				var parts = settings.split('-');
				settings = new Object();
				$u.o.assign(settings , this._defaultWindowSettings[parts.shift()]);
				for(var i=0;i<parts.length;i++){
					if(parts[i] == 'url'){
						settings.body.content.type = 'url';
						settings.body.content.url = 'about:blank';
					} else if(parts[i] == 'resizable'){
						settings.resize = 'both';
					}
				}
			}
			if(typeof arguments[2] == 'object') $u.o.assign(settings,arguments[2]);
			this._genericWindow[name] = new A5.Window(settings);
		}
		return this._genericWindow[name];
	},
	
	getWindow: function(name) {
		if(typeof this._genericWindow[name] != 'undefined' ) return this._genericWindow[name];
		return false;
	},
	
	_executeEvent: function(eventName) {
		var result = true;
		var targs = new Array();
		for(var i = 1; i < arguments.length; i++) targs.push(arguments[i]);
		var tresult = false;
		if(typeof this[eventName] != 'undefined'  ) {

			if(this[eventName].constructor == Function) {
				tresult = this[eventName].apply(this,targs);
				if(typeof tresult == 'boolean') result = tresult;
			}
		}
		if(typeof this['_' +eventName] != 'undefined' ) {
			if(this['_'+eventName].constructor == Function) {
				tresult = this['_'+eventName].apply(this,targs);
				if(typeof tresult == 'boolean') result = result && tresult;
			}
			
		}
		return result;
	},
	
	_rsiOnClick: function(e,classInst) {
		var idArr = this.id.split('.');
		var sectionName = idArr[3];
		var instNum = $u.s.toNum(idArr[4]);
		var rowNum = $u.s.toNum(idArr[2]);
		classInst.setRepeatingSectionActiveRow(sectionName,instNum,rowNum);
	}
	
	
	
}

			
				
//This is a temporary location - move to core
function A5ValidateNumber(data){
	

	var re = /[^0-9]/;
	while(data.charAt(data.length-1).match(re)){
		data= data.substring(0,data.length-1);
		if(data.length == 0) break;
	}
	while(data.charAt(0).match(re)){
		data= data.substring(1,data.length);
		if(data.length == 0) break;
	}	
	
	var tsChar = typeof arguments[1] != 'undefined' ? arguments[1] : $u.comma;
	var decChar = typeof arguments[2] != 'undefined' ? arguments[2] : $u.decimal;
	var decLen = typeof arguments[3] != 'undefined' ? arguments[3] : 0;
	var reDecChar = decChar == '.' ? '\.' : decChar;
	var reTSChar = tsChar == '.' ? '\.' : tsChar;
	if(decChar == '') decLen = 0;
	var numRE = RegExp('.*[^0-9].*');
	var eList = {
		iv: 'Value is not a valid number.',
		tg: 'Groupings must only occur on the thousands (i.e. 12,456,789).',
		dp: 'There must be '+decLen+' decimal places.',
		md: 'You must use a "'+decChar+'" for the decimal places.'
	}
	// integer
	if(decLen == 0){
		// no thousands seperator
		if(tsChar == '' && RegExp('.*[^0-9\-].*').test(data)) return eList.iv;
		else{
			if(RegExp('.*[^0-9\-'+reTSChar+'].*').test(data)) return eList.iv;
			else {
				var tsData = data.split(tsChar);
				if(tsData.length > 1){
					for(var i=tsData.length-1;i>0;i--){
						if(tsData[i].length != 3) return eList.tg;
						if(numRE.test(tsData[i])) return eList.iv;
					}
					if($u.s.lTrim(tsData[0],'-').length > 3) return eList.tg;
					if(numRE.test($u.s.lTrim(tsData[0],'-'))) return eList.iv;
				}
			}
		}
	} else{
		var dsData = data.split(decChar);
		// no thousands seperator
		if(tsChar == ''){
			if(decLen == -1 && dsData.length > 2) return eList.md;
			else if(decLen != -1 && dsData.length != 2) return eList.md;
			else if(decLen != -1 && dsData[1].length != decLen) return eList.dp;
			else if(RegExp('.*[^0-9\-'+reDecChar+'].*').test(data)) return eList.iv;
		} else{
			if(decLen == -1 && dsData.length > 2) return eList.md;
			else if(decLen != -1 && dsData.length != 2) return eList.md;
			else if(decLen != -1 && dsData[1].length != decLen) return eList.dp;
			else if(dsData.length == 2 && numRE.test(dsData[1])) return eList.iv;
			else {
				if(RegExp('.*[^0-9\-'+reTSChar+'].*').test(dsData[0])) return eList.iv;
				else {
					var tsData = dsData[0].split(tsChar);
					if(tsData.length > 1){
						for(var i=tsData.length-1;i>0;i--){
							if(tsData[i].length != 3) return eList.tg;
							if(numRE.test(tsData[i])) return eList.iv;
						}
						if($u.s.lTrim(tsData[0],'-').length > 3) return eList.tg;
						if(numRE.test($u.s.lTrim(tsData[0],'-'))) return eList.iv;
					}
				}
			}
		}
	}
	return '';
}


	
/*
Copyright (c) 2001, 2008
Alpha Software, Inc.

This JavaScript library is licensed exclusively for use with Alpha Five, 
Alpha Five Application Server and Alpha Five Run Engine. It is specifically 
not licensed for use on a server that does not have installed on it, a 
licensed copy of the Alpha Five Application Server.
*/



function a5_layout_cont_bands(a5_layout_cont_curID,a5_layout_cont_style){if(document.getElementById(a5_layout_cont_curID).style.display=='none'){if(document.all){document.getElementById(a5_layout_cont_curID).style.display='block';}
else{document.getElementById(a5_layout_cont_curID).style.display='table-row-group';}
document.getElementById(a5_layout_cont_curID+'_IMG').src='css//'+a5_layout_cont_style+'//AscOn.png';}
else{document.getElementById(a5_layout_cont_curID).style.display='none';document.getElementById(a5_layout_cont_curID+'_IMG').src='css//'+a5_layout_cont_style+'//DescOn.png';}}
function a5_layout_cont_singlebands(a5_layout_cont_curID,a5_layout_cont_prevID,a5_layout_cont_style){if(a5_layout_cont_curID!=a5_layout_cont_prevID){if(document.all){document.getElementById(a5_layout_cont_curID).style.display='block';}
else{document.getElementById(a5_layout_cont_curID).style.display='table-row-group';}
document.getElementById(a5_layout_cont_curID+'_IMG').src='css//'+a5_layout_cont_style+'//RowMarkerOn.png';if(a5_layout_cont_prevID!=''){document.getElementById(a5_layout_cont_prevID).style.display='none';document.getElementById(a5_layout_cont_prevID+'_IMG').src='css//'+a5_layout_cont_style+'//RowMarkerOff.png';}}
return a5_layout_cont_curID;}
function a5_layout_cont_singlebands_onload(a5_layout_cont_curID,a5_layout_cont_style){document.getElementById(a5_layout_cont_curID).style.display='none';document.getElementById(a5_layout_cont_curID+'_IMG').src='css//'+a5_layout_cont_style+'//RowMarkerOff.png';}
function a5_layout_cont_tabs(a5_layout_cont_curID,a5_layout_cont_prevID,a5_layout_cont_style){if(a5_layout_cont_curID!=a5_layout_cont_prevID){if(document.all){document.getElementById(a5_layout_cont_curID).style.display='block';}
else{document.getElementById(a5_layout_cont_curID).style.display='table';}
document.getElementById(a5_layout_cont_curID+'_IMG').src='css//'+a5_layout_cont_style+'//RowMarkerOn.png';if(a5_layout_cont_prevID!=''){document.getElementById(a5_layout_cont_prevID).style.display='none';document.getElementById(a5_layout_cont_prevID+'_IMG').src='css//'+a5_layout_cont_style+'//RowMarkerOff.png';}}
return a5_layout_cont_curID;}
function a5_layout_cont_genie(a5_layout_cont_curID,a5_layout_cont_prevID){if(a5_layout_cont_curID!=a5_layout_cont_prevID){if(document.all){document.getElementById(a5_layout_cont_curID).style.display='block';}
else{document.getElementById(a5_layout_cont_curID).style.display='table';}
if(a5_layout_cont_prevID!=''){document.getElementById(a5_layout_cont_prevID).style.display='none';}
var ele=document.getElementById(a5_layout_cont_curID)
var selectedPosX=0;var selectedPosY=0;while(ele!=null){selectedPosX+=ele.offsetLeft;selectedPosY+=ele.offsetTop;ele=ele.offsetParent;}
window.scrollTo(selectedPosX,selectedPosY);}}

