	
/*
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){if(pEle.constructor==Function)obj=pEle(obj);else 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){if(pEle.constructor==Function)obj=pEle(obj);else 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){if(pEle.constructor==Function)obj=pEle(obj);else 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){if(val==null)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){if(pEle.constructor==Function)obj=pEle(obj);else 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(typeof val[0]!='undefined')ele.src=val[0];if(typeof val[1]!='undefined')ele.title=val[1];}else ele.src=val;}else if(tag=='a'){if(val.constructor==Array){if(typeof val[0]!='undefined'){if(honorHTML)ele.innerHTML=val[0];else ele.innerHTML=val[0].replace(/\n/g,'\n<br/>');}
if(typeof val[1]!='undefined')ele.href=''+val[1];if(typeof val[2]!='undefined')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){if(pEle.constructor==Function)obj=pEle(obj);else 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){if(pEle.constructor==Function)obj=pEle(obj);else 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){if(pEle.constructor==Function)obj=pEle(obj);else 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){if(pEle.constructor==Function)obj=pEle(obj);else 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){if(pEle.constructor==Function)obj=pEle(obj);else 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 $gpt(obj){var ignoreNonPos=typeof arguments[1]!='undefined'?arguments[1]:false;var tPos=0;if(ignoreNonPos){pEle=obj.parentNode;if(pEle.tagName.toLowerCase()!='html'&&pEle.tagName.toLowerCase()!='body'){while(pEle.tagName.toLowerCase()!='body'){if(pEle.style.position=='absolute'||pEle.style.position=='relative')tPos+=pEle.offsetTop;pEle=pEle.parentNode;}}}else{var b=obj.getBoundingClientRect();var tS=Math.max(document.body.scrollTop,document.documentElement.scrollTop);tPos=b.top+tS;}
return tPos;}
function $gpl(obj){var ignoreNonPos=typeof arguments[1]!='undefined'?arguments[1]:false;var lPos=0;if(ignoreNonPos){pEle=obj.parentNode;if(pEle.tagName.toLowerCase()!='html'&&pEle.tagName.toLowerCase()!='body'){while(pEle.tagName.toLowerCase()!='body'){if(pEle.style.position=='absolute'||pEle.style.position=='relative')lPos+=pEle.offsetLeft;pEle=pEle.parentNode;}}}else{var b=obj.getBoundingClientRect();var lS=Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);lPos=b.left+lS;}
return lPos;}
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'&&obj[prop]!=null){if(!objD[prop]){if(obj[prop].constructor==Array)objD[prop]=[];else objD[prop]={};}
$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'&&obj[prop]!=null){if(!objD[prop]||typeof objD[prop]!='object'){if(obj[prop].constructor==Array)objD[prop]=[];else objD[prop]={};}
$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]||'';var encode=typeof arguments[2]!='undefined'?arguments[2]:true;if(encode)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+'[]',encode));}else{propArr.push(prefix+'[]='+$u.o.toParams(obj[i],'',encode));}}else{if(typeof obj[i]=='object'){propArr.push($u.o.toParams(obj[i],prefixArrIt+'[]',encode));}else{propArr.push(prefixArrIt+'[]='+$u.o.toParams(obj[i],'',encode));}}}
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;if(encode)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,encode));}else{propArr.push(prefix+propStr+'='+$u.o.toParams(obj[prop],'',encode));}}else{if(typeof obj[prop]=='object'){propArr.push($u.o.toParams(obj[prop],prefixArrIt+prop,encode));}else{propArr.push(prefixArrIt+propStr+'='+$u.o.toParams(obj[prop],'',encode));}}
propCount++}
return propArr.join('&');}}else{if(type=='number')return String(obj);else if(type=='boolean')return obj?'.t.':'.f.';else if(encode)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,"");else return''+obj;}}},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:[],_ae:{},_aeg:{i:0,a:[],dhTO:0,sT:0,sX:0,sY:0,iX:[],iY:[],maxX:0,maxY:0,minX:0,minY:0,lClick:0},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;}else if(evntType.substr(0,8)=='abstract'&&!$e.abstractEvents.disabled){if(ele.id=='')ele.id=A5.u.getUniqueId();if(!$e._ae[ele.id]){$e._ae[ele.id]={ele:ele,dt:false,ut:false,mt:false,d:[],u:[],m:[],g:[]};}
var subType=evntType.substr(8);var supportMouse=!(navigator.userAgent.match(/(iPad|iPhone|iPod)/i)?true:false);var supportTouch=(navigator.userAgent.match(/android/i)||!!('createTouch'in document));if(subType=='down'){if($ga(ele,'A5AbstEvntD')!='true'){if(supportTouch)$e.add(ele,'touchstart',$e._aetDown);if(supportMouse)$e.add(ele,'mousedown',$e._aemDown);$sa(ele,'A5AbstEvntD','true');for(var i=$e._ae[ele.id].d.length-1;i>=0;i--){if($e._ae[ele.id].d[i]){delete $e._ae[ele.id].d[i][0];delete $e._ae[ele.id].d[i][1];delete $e._ae[ele.id].d[i];}}
$e._ae[ele.id].d=[];}
$e._ae[ele.id].d.push([evntFunc,wFunc,evntScope,scopeOverride,groupName]);}else if(subType=='up'){if($ga(ele,'A5AbstEvntU')!='true'){if(supportTouch)$e.add(ele,'touchend',$e._aetUp);if(supportMouse)$e.add(ele,'mouseup',$e._aemUp);$sa(ele,'A5AbstEvntU','true');for(var i=$e._ae[ele.id].u.length-1;i>=0;i--){if($e._ae[ele.id].u[i]){delete $e._ae[ele.id].u[i][0];delete $e._ae[ele.id].u[i][1];delete $e._ae[ele.id].u[i];}}
$e._ae[ele.id].u=[];}
$e._ae[ele.id].u.push([evntFunc,wFunc,evntScope,scopeOverride,groupName]);}else if(subType=='move'){if($ga(ele,'A5AbstEvntM')!='true'){if(supportTouch)$e.add(ele,'touchmove',$e._aetMove);if(supportMouse)$e.add(ele,'mousemove',$e._aemMove);$sa(ele,'A5AbstEvntM','true');for(var i=$e._ae[ele.id].m.length-1;i>=0;i--){if($e._ae[ele.id].m[i]){delete $e._ae[ele.id].m[i][0];delete $e._ae[ele.id].m[i][1];delete $e._ae[ele.id].m[i];}}
$e._ae[ele.id].m=[];}
$e._ae[ele.id].m.push([evntFunc,wFunc,evntScope,scopeOverride,groupName]);}else{if($ga(ele,'A5AbstEvntG')!='true'){$e.add(ele,'abstractdown',$e._aegStart);$sa(ele,'A5AbstEvntG','true');for(var i=$e._ae[ele.id].g.length-1;i>=0;i--){if($e._ae[ele.id].g[i]){delete $e._ae[ele.id].g[i][0];delete $e._ae[ele.id].g[i][1];delete $e._ae[ele.id].g[i];}}
$e._ae[ele.id].g=[];if($ga(document.documentElement,'A5AbstEvntG')!='true'){$e.add(document.documentElement,'abstractmove',$e._aegMove);$e.add(document.documentElement,'abstractup',$e._aegEnd);$sa(document.documentElement,'A5AbstEvntG','true');}}
$e._ae[ele.id].g.push([evntType,evntFunc,wFunc,evntScope,scopeOverride,groupName]);$e._aeg.i++;}
return true;}
if($e.abstractEvents.disabled){if(evntType.substr(0,8)=='abstract'){if(evntType=='abstractdown')evntType='mousedown';else if(evntType=='abstractup')evntType='mouseup';else if(evntType=='abstractmove')evntType='mousemove';else if(evntType=='abstractclick')evntType='click';else if(evntType=='abstractdblclick')evntType='dblclick';}}
$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(evntType.substr(0,8)=='abstract'){if($e._ae[ele.id]){var subType=evntType.substr(8);if(subType=='down'){var evnts=$e._ae[ele.id].d;for(var i=evnts.length-1;i>=0;i--){if(evnts[i]){if(evnts[i][0]==evntFunc){delete evnts[i][0];delete evnts[i][1];delete evnts[i];evnts.splice(i,1);}}}
if($ga(ele,'A5AbstEvntD')=='true'&&evnts.length==0){$e.remove(ele,'touchstart',$e._aetDown);$e.remove(ele,'mousedown',$e._aemDown);$sa(ele,'A5AbstEvntD','');}}else if(subType=='up'){var evnts=$e._ae[ele.id].u;for(var i=evnts.length-1;i>=0;i--){if(evnts[i]){if(evnts[i][0]==evntFunc){delete evnts[i][0];delete evnts[i][1];delete evnts[i];evnts.splice(i,1);}}}
if($ga(ele,'A5AbstEvntU')=='true'&&evnts.length==0){$e.remove(ele,'touchend',$e._aetUp);$e.remove(ele,'mouseup',$e._aemUp);$sa(ele,'A5AbstEvntU','');}}else if(subType=='move'){var evnts=$e._ae[ele.id].m;for(var i=evnts.length-1;i>=0;i--){if(evnts[i]){if(evnts[i][0]==evntFunc){delete evnts[i][0];delete evnts[i][1];delete evnts[i];evnts.splice(i,1);}}}
if($ga(ele,'A5AbstEvntM')=='true'&&evnts.length==0){$e.remove(ele,'touchmove',$e._aetMove);$e.remove(ele,'mousemove',$e._aemMove);$sa(ele,'A5AbstEvntM','');}}else{var evnts=$e._ae[ele.id].g;for(var i=evnts.length-1;i>=0;i--){if(evnts[i]){if(evnts[i][0]==evntFunc){delete evnts[i][1];delete evnts[i][2];delete evnts[i];evnts.splice(i,1);$e._aeg.i--;}}}
if($ga(ele,'A5AbstEvntG')=='true'&&evnts.length==0){$e.remove(ele,'abstractdown',$e._aegStart);$sa(ele,'A5AbstEvntG','');}}
return true;}}
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){if(eObj[0])$e.remove(eObj[0],eObj[1],eObj[2],i);else{delete eObj[0];delete eObj[3];delete eObj[2];delete $e._e[i];}}}}
var evnts=0;var hadRemEvnts=false;for(var eleId in $e._ae){evnts=$e._ae[eleId].d;for(var i=evnts.length-1;i>=0;i--){if(evnts[i][5]==gName){delete evnts[i][0];delete evnts[i][1];delete evnts[i];evnts.splice(i,1);hadRemEvnts=true;}}
if(evnts.length==0&&hadRemEvnts){var ele=$(eleId);$e.remove(ele,'touchstart',$e._aetDown);$e.remove(ele,'mousedown',$e._aemDown);$sa(ele,'A5AbstEvntd','');}
hadRemEvnts=false;evnts=$e._ae[eleId].u;for(var i=evnts.length-1;i>=0;i--){if(evnts[i][5]==gName){delete evnts[i][0];delete evnts[i][1];delete evnts[i];evnts.splice(i,1);hadRemEvnts=true;}}
if(evnts.length==0&&hadRemEvnts){var ele=$(eleId);$e.remove(ele,'touchend',$e._aetUp);$e.remove(ele,'mouseup',$e._aemUp);$sa(ele,'A5AbstEvntU','');}
hadRemEvnts=false;evnts=$e._ae[eleId].m;for(var i=evnts.length-1;i>=0;i--){if(evnts[i][5]==gName){delete evnts[i][0];delete evnts[i][1];delete evnts[i];evnts.splice(i,1);hadRemEvnts=true;}}
if(evnts.length==0&&hadRemEvnts){var ele=$(eleId);$e.remove(ele,'touchmove',$e._aetMove);$e.remove(ele,'mousemove',$e._aemMove);$sa(ele,'A5AbstEvntM','');}
hadRemEvnts=false;evnts=$e._ae[eleId].g;for(var i=evnts.length-1;i>=0;i--){if(evnts[i][5]==gName){delete evnts[i][0];delete evnts[i][1];delete evnts[i];evnts.splice(i,1);hadRemEvnts=true;}}
if(evnts.length==0&&hadRemEvnts){var ele=$(eleId);$e.remove(ele,'abstractdown',$e._aegStart);$sa(ele,'A5AbstEvntG','');}}
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;var e={};if(evntType.substr(0,8)=='abstract'){if($e._ae[ele.id]){var subType=evntType.substr(8);if(subType=='down'){var evnts=$e._ae[ele.id].d;for(var i=0;i<evnts.length;i++)evnts[i][1](e);}else if(subType=='up'){var evnts=$e._ae[ele.id].u;for(var i=0;i<evnts.length;i++)evnts[i][1](e);}else if(subType=='move'){var evnts=$e._ae[ele.id].m;for(var i=0;i<evnts.length;i++)evnts[i][1](e);}else{var evnts=$e._ae[ele.id].g;for(var i=0;i<evnts.length;i++){if(evnts[i][0]==evntType)evnts[i][2](e);}}}
return;}
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](e);}}}},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;},getTouches:function(e){if(e.originalEvent){if(e.originalEvent.touches&&e.originalEvent.touches.length)return e.originalEvent.touches;else if(e.originalEvent.changedTouches&&e.originalEvent.changedTouches.length)return e.originalEvent.changedTouches;}else{if(e.touches||e.changedTouches){if(e.touches.length)return e.touches;else if(e.changedTouches.length)return e.changedTouches;}}
return null;},getCoors:function(e){var coors={};var tempT=$e.getTouches(e);if(tempT){if(tempT.length){coors.clientX=tempT[0].clientX;coors.clientY=tempT[0].clientY;return coors;}}
coors.clientX=e.clientX;coors.clientY=e.clientY;return coors;},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($e._e[i][0])$e.remove($e._e[i][0],$e._e[i][1],$e._e[i][2],i);}}},_aetDown:function(e){$e._ae[this.id].dt=new Date().getTime();$e._aeDown(this,e);},_aemDown:function(e){if($e._ae[this.id]){if($e._ae[this.id].dt){if(new Date().getTime()-$e._ae[this.id].dt<1000){$e._ae[this.id].dt=false;return;}}}
$e._aeDown(this,e);},_aeDown:function(ele,e){var evnts=$e._ae[ele.id].d;for(var i=0;i<evnts.length;i++)evnts[i][1](e);},_aetUp:function(e){$e._ae[this.id].ut=new Date().getTime();$e._aeUp(this,e);},_aemUp:function(e){if($e._ae[this.id]){if($e._ae[this.id].ut){if(new Date().getTime()-$e._ae[this.id].ut<1000){$e._ae[this.id].ut=false;return;}}}
$e._aeUp(this,e);},_aeUp:function(ele,e){var evnts=$e._ae[ele.id].u;for(var i=0;i<evnts.length;i++)evnts[i][1](e);},_aetMove:function(e){$e._ae[this.id].mt=new Date().getTime();$e._aeMove(this,e);},_aemMove:function(e){if($e._ae[this.id]){if($e._ae[this.id].mt){if(new Date().getTime()-$e._ae[this.id].mt<1000){$e._ae[this.id].mt=false;return;}}}
$e._aeMove(this,e);},_aeMove:function(ele,e){var evnts=$e._ae[ele.id].m;for(var i=0;i<evnts.length;i++)evnts[i][1](e);},_aegStart:function(e){if(!e.type)return;$e._aeg.a.push(this.id);if($e._aeg.a.length==1){var coor=$e.getCoors(e);$e._aeg.sT=new Date().getTime();$e._aeg.sX=coor.clientX;$e._aeg.sY=coor.clientY;$e._aeg.maxX=coor.clientX;$e._aeg.maxY=coor.clientY;$e._aeg.minX=coor.clientX;$e._aeg.minY=coor.clientY;$e._aeg.dhTO=setTimeout($e._aegHold,$e.abstractEvents.downHold.duration);}},_aegMove:function(e){if(!$e._aeg.a)return;var coor=$e.getCoors(e);$e._aeg.maxX=Math.max($e._aeg.maxX,coor.clientX);$e._aeg.maxY=Math.max($e._aeg.maxY,coor.clientY);$e._aeg.minX=Math.min($e._aeg.minX,coor.clientX);$e._aeg.minY=Math.min($e._aeg.minY,coor.clientY);},_aegEnd:function(e){if($e._aeg.a.length==0)return true;clearTimeout($e._aeg.dhTO);var tn=new Date().getTime();var isClick=false;var isDblClick=false;var isSwipe=false;var dX=Math.max($e._aeg.sX-$e._aeg.minX,$e._aeg.maxX-$e._aeg.sX);var dY=Math.max($e._aeg.sY-$e._aeg.minY,$e._aeg.maxY-$e._aeg.sY);var dist=Math.sqrt((dX*dX)+(dY*dY));if(dist<=$e.abstractEvents.click.wiggle){isClick=true;if((tn-$e._aeg.lClick)<=$e.abstractEvents.dblClick.duration)isDblClick=true;$e._aeg.lClick=tn;}
if(dist/(tn-$e._aeg.sT)>=$e.abstractEvents.swipe.velocity){isSwipe=true;var hDir='left';var vDir='up';if($e._aeg.sX-$e._aeg.minX<$e._aeg.maxX-$e._aeg.sX)hDir='right';if($e._aeg.sY-$e._aeg.minY<$e._aeg.maxY-$e._aeg.sY)vDir='down';if(dX>=dY){e.swipeDirection=hDir;}else{e.swipeDirection=vDir;}}
var tA=$u.a.dedup($e._aeg.a.join('\n').split('\n'));$e._aeg.a=[];$e._aeg.sT=0;$e._aeg.sX=0;$e._aeg.sY=0;$e._aeg.maxX=5000;$e._aeg.maxY=5000;$e._aeg.minX=-5000;$e._aeg.minY=-5000;for(var j=0;j<tA.length;j++){var evnts=$e._ae[tA[j]].g;for(var i=0;i<evnts.length;i++){var subType=evnts[i][0].substr(8);if(subType=='click'){if(isClick)evnts[i][2](e);}else if(subType=='dblclick'){if(isDblClick)evnts[i][2](e);}else if(subType=='swipe'){if(isSwipe)evnts[i][2](e);}}}},_aegHold:function(){var e={type:'abstractdownhold'};for(var j=0;j<$e._aeg.a.length;j++){if($e._ae[$e._aeg.a[j]]){if($e._ae[$e._aeg.a[j]].g){var evnts=$e._ae[$e._aeg.a[j]].g;for(var i=0;i<evnts.length;i++){if(evnts[i][0].substr(8)=='downhold')evnts[i][2](e);}}}}},onLoaded:0,abstractEvents:{disabled:false,click:{wiggle:5},dblClick:{duration:600},downHold:{duration:600},swipe:{velocity:.75}}}
$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);}}
var data=this.data.split('&');var dataI=0;var prop='';var obj={};for(var i=0;i<data.length;i++){dataI=data[i].split('=');prop=dataI.shift();dataI=dataI.join('=');if(prop.substr(prop.length-2)=='[]'){prop=prop.substr(0,prop.length-2);if(typeof obj[prop]=='undefined')obj[prop]=[];obj[prop].push(dataI);}else obj[prop]=dataI;}
this.data=$u.o.toParams(obj,'',false);this.fill=$(options.fill)||null;this.url=url;this._secondChance=true;$a.lastCallback=new Date().getTime();this.initCallback=$a.lastCallback;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);if($a._def[''+this.initCallback])setTimeout(Function('$a._def[\''+this.initCallback+'\'](); delete $a._def[\''+this.initCallback+'\'];'),20);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){$a.lastCallback=new Date().getTime();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.XMLHttpRequest)return new XMLHttpRequest();else if(window.ActiveXObject)return new ActiveXObject('Microsoft.XMLHTTP');else return false;}}
$a._def={};$a.lastCallback=new Date().getTime();$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-3)+'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-3)+'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.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.add(new Option(curValue,curValue),0);curObj.options.selectedIndex=0;}}}
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()!='submit'&&eles[j].type!='reset'&&eles[j].type!='button'&&eles[j].type!='image'&&eles[j].type!='file'){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.id=baseId+'.LABEL';buttonNode.tabIndex=1;buttonNode.href="#";$e.add(buttonNode,'mouseup',this._clickNode,this);buttonNode.className=this._gDef(data[i].labelClassName,this.node.labelClassName);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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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])}
var oldValue=curValue;this.value=curValue;if(this.inputId!='')$(this.inputId).value=curValue.join('\n');if(oldValue.join('\n')!=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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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,A5.d.evnts.click,this._selectBand,this);$e.add(ele,'click',function(e){$e.preventDefault(e);return false;});$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,A5.d.evnts.click,this._selectBand,this);$e.add(ele,'click',function(e){$e.preventDefault(e);return false;});$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,A5.d.evnts.click,this._selectTab,this);$e.add(ele,'click',function(e){$e.preventDefault(e);return false;});$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,A5.d.evnts.click,this._selectTab,this);$e.add(ele,'click',function(e){$e.preventDefault(e);return false;});$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.add(new Option(currValue,currValue),0);ele.options.selectedIndex=0;}}}
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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" />','')+$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:{},defaultContainer:'',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'||A5.windows._w[prop].type=='modal-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,{container:A5.windows.defaultContainer,type:'',theme:'',override:'base',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:''},pointer:{show:false,location:'auto',size:10,upClassName:'',leftClassName:'',downClassName:'',rightClassName:''},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);A5.overrides.assign(this,'window',this.override);if(this.type==''){this.type='modeless';}else this.type=this.type.toLowerCase();if(this.type!='modal'&&this.type!='popup'&&this.type!='modal-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;var css=$gs(HTMLDlgMainEle);if(css.search('box-sizing:')==-1)$ss(HTMLDlgMainEle,css+' box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');HTMLDlgEle=document.createElement('div');HTMLDlgEle.id=this._windowId+'.POINTER';$ss(HTMLDlgEle,'display: none; position: absolute;');HTMLDlgMainEle.appendChild(HTMLDlgEle);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,A5.d.evnts.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,A5.d.evnts.down,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);HTMLDlgTmplEle.style.position='relative';if(this.body.content.type=='url'){HTMLDlgTmplEle.style.padding='0px';HTMLDlgTmplEle.style.width='100%';if(!document.all)HTMLDlgTmplEle.style.marginBottom='-2px';}
var css=$gs(HTMLDlgTmplEle);if(css.search('box-sizing:')==-1)$ss(HTMLDlgTmplEle,css+' box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');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.lastChild.style.display='none';else ele.lastChild.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).lastChild.style.display='';else $(this.resizeElementId).lastChild.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;$e.execute(ele,'a5resize');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.lastChild.style.display='none';else ele.lastChild.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.lastChild.style.display='';else ele.lastChild.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(eleB,'a5resize');$e.execute(ele,'resizeComplete');}});}}
$e.add(HTMLDlgMainEle,'mousedown',function(e){$e.stopPropagation(e);});$e.add(HTMLDlgMainEle,'mousedown',function(){A5.windows._hidePopups(this._windowCurIndx);if(!(this.type=='modal'||this.type=='modal-popup'))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(this.container!='')$(this.container).appendChild(HTMLDlgMainEle);else 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.lastChild.childNodes.length;i++){if(typeof ele.lastChild.childNodes[i].tagName!='undefined'){if(ele.lastChild.childNodes[i].id!=this.dragElementId+'.TITLE')ele.lastChild.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.lastChild.childNodes.length;i++){if(typeof ele.lastChild.childNodes[i].tagName!='undefined')ele.lastChild.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._initCSSAnim=false;this._dock='';this._canCSSAnim=true;this._oldTop=HTMLDlgMainEle.style.top;if(document.all)this._canCSSAnim=false;if(A5.flags.isFireFox)this._cssAnim={tProp:'-moz-transform',tDOMProp:'MozTransform',prop:'MozTransition'};else if(A5.flags.isOpera)this._cssAnim={tProp:'-o-transform',tDOMProp:'OTransform',prop:'OTransition'};else if(A5.flags.isIE)this._cssAnim={tProp:'-ms-transform',tDOMProp:'MsTransform',prop:''};else this._cssAnim={tProp:'-webkit-transform',tDOMProp:'WebkitTransform',prop:'WebkitTransition'};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);wEle.style.top=this._oldTop;if(this.activeClassName!='')$acn(wEle,this.activeClassName);this._moveToFront();var pRegex=/^[0-9]+%$/;if(this.animation.disabled){if(document.all&&navigator.appName!='Opera')wEle.style.display='';else wEle.style.visibility='';if(pRegex.test(this.width)||pRegex.test(this.height))this._stretch();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);}}else{wEle.style.display='';wEle.style.visibility='hidden';if(pRegex.test(this.width)||pRegex.test(this.height))this._stretch();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);}
var animType=this.animation.show.type;if(animType.substr(0,3)=='css'&&this._canCSSAnim){var anim='';var dur=this.animation.show.duration;if(typeof dur!='number')dur=500;if(animType.substr(0,9)=='css-slide'){if(animType=='css-slide'){if(this._dock=='b')animType='css-slide-bottom';else if(this._dock=='l')animType='css-slide-left';else if(this._dock=='r')animType='css-slide-right';else animType='css-slide-top';}
var loc=AUI.u.getVPScroll();var vpSize=AUI.u.getVPSize();loc.x=wEle.offsetLeft-loc.x;loc.y=wEle.offsetTop-loc.y;if(animType=='css-slide-bottom')wEle.style[this._cssAnim.tDOMProp]='translate3d(0px,'+((vpSize.height-loc.y)+wEle.offsetHeight)+'px,0px)';else if(animType=='css-slide-left')wEle.style[this._cssAnim.tDOMProp]='translate3d(-'+(loc.x+wEle.offsetWidth)+'px,0px,0px)';else if(animType=='css-slide-right')wEle.style[this._cssAnim.tDOMProp]='translate3d('+((vpSize.width-loc.x)+wEle.offsetWidth)+'px,0px,0px)';else wEle.style[this._cssAnim.tDOMProp]='translate3d(0px,-'+(loc.y+wEle.offsetHeight)+'px,0px)';anim=['var wEle = $(\''+this._windowId+'\');','wEle.style.display = \'\';','wEle.style[\''+this._cssAnim.prop+'\'] = \''+this._cssAnim.tProp+' '+dur+'ms ease-in-out\';','wEle.style[\''+this._cssAnim.tDOMProp+'\'] = \'translate3d(0px,0px,0px)\';'].join('\n');}
setTimeout(Function(anim),1);if(!this._initCSSAnim){if(A5.flags.isFireFox)$e.add(wEle,'transitionend',function(e){this.style['MozTransition']='';if($ga(this,'A5WINDOWHIDE')=='true'){this.style.display='none';this.style['MozTransform']='';$sa(this,'A5WINDOWHIDE','');}});else if(A5.flags.isOpera)$e.add(wEle,'oTransitionEnd',function(e){this.style['OTransition']='';if($ga(this,'A5WINDOWHIDE')=='true'){this.style.display='none';this.style['OTransform']='';$sa(this,'A5WINDOWHIDE','');}});else $e.add(wEle,'webkitTransitionEnd',function(e){this.style['WebkitTransition']='';if($ga(this,'A5WINDOWHIDE')=='true'){this.style.display='none';this.style['WebkitTransform']='';$sa(this,'A5WINDOWHIDE','');}});this._initCSSAnim=true;}}
$sa(wEle,'A5WINDOWHIDE','');wEle.style.visibility='';wEle.style.display='none';if(animType.substr(0,3)!='css')A5.u.element.show(wEle,this.animation.show);else wEle.style.display='';}
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.type=='modal-popup'){this._lockIndex=AUI.LockUI.page(this.lockUIClassName,this._zIndex);$e.add('AUILockUIPage','mousedown',A5.windows._hidePopups);}
if(this.type=='popup'||this.type=='modal-popup'){var classInst=this;setTimeout(function(){$e.add(document.documentElement,'mousedown',classInst._popupHide,classInst,true);delete classInst;},1000);}
A5.windows._hidePopups(this._windowCurIndx);this.hidden=false;if(this.onShow.constructor==Function)this.onShow.call(this);}else this.focus();this._initShow=true;},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'||this.type=='modal-popup')AUI.LockUI.pageFree();if(this.type=='popup'||this.type=='modal-popup')$e.remove(document.documentElement,'mousedown',this._popupHide);var wEle=$(this._windowId);this._oldTop=wEle.style.top;wEle.style.top='-5000px';if(this.animation.disabled){if(document.all&&navigator.appName!='Opera')wEle.style.display='none';else wEle.style.visibility='hidden';}else{var animType=this.animation.hide.type;if(animType.substr(0,3)=='css'&&this._canCSSAnim){var anim='';var dur=this.animation.hide.duration;if(typeof dur!='number')dur=500;if(animType.substr(0,9)=='css-slide'){if(animType=='css-slide'){if(this._dock=='b')animType='css-slide-bottom';else if(this._dock=='l')animType='css-slide-left';else if(this._dock=='r')animType='css-slide-right';else animType='css-slide-top';}
var loc=AUI.u.getVPScroll();var vpSize=AUI.u.getVPSize();loc.x=wEle.offsetLeft-loc.x;loc.y=wEle.offsetTop-loc.y;wEle.style[this._cssAnim.tDOMProp]='translate3d(0px,0px,0px)';anim=['var wEle = $(\''+this._windowId+'\');','wEle.style.display = \'\';','wEle.style[\''+this._cssAnim.prop+'\'] = \''+this._cssAnim.tProp+' '+dur+'ms ease-in-out\';'];var trans='';if(animType=='css-slide-bottom')trans='translate3d(0px,'+((vpSize.height-loc.y)+wEle.offsetHeight)+'px,0px)';else if(animType=='css-slide-left')trans='translate3d(-'+(loc.x+wEle.offsetWidth)+'px,0px,0px)';else if(animType=='css-slide-right')trans='translate3d('+((vpSize.width-loc.x)+wEle.offsetWidth)+'px,0px,0px)';else trans='translate3d(0px,-'+(loc.y+wEle.offsetHeight)+'px,0px)';anim.push('wEle.style[\''+this._cssAnim.tDOMProp+'\'] = \''+trans+'\';');anim=anim.join('\n');}
$sa(wEle,'A5WINDOWHIDE','true');setTimeout(Function(anim),1);if(!this._initCSSAnim){if(A5.flags.isFireFox)$e.add(wEle,'transitionend',function(e){this.style['MozTransition']='';if($ga(this,'A5WINDOWHIDE')=='true'){this.style.display='none';this.style['MozTransform']='';$sa(this,'A5WINDOWHIDE','');}});else if(A5.flags.isOpera)$e.add(wEle,'oTransitionEnd',function(e){this.style['OTransition']='';if($ga(this,'A5WINDOWHIDE')=='true'){this.style.display='none';this.style['OTransform']='';$sa(this,'A5WINDOWHIDE','');}});else $e.add(wEle,'webkitTransitionEnd',function(e){this.style['WebkitTransition']='';if($ga(this,'A5WINDOWHIDE')=='true'){this.style.display='none';this.style['WebkitTransform']='';$sa(this,'A5WINDOWHIDE','');}});this._initCSSAnim=true;}}else if(animType.substr(0,3)!='css')A5.u.element.hide(wEle,this.animation.hide);else wEle.style.display='none';}
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){var wEle=$(this._windowId);var bEle=$(this._windowId+'.BODY');this._restoreScroll=this._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('100%','100%');AUI.Drag.disable(this._windowId);AUI.Resize.disable(this._windowId);this.focus();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();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,A5.d.evnts.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,A5.d.evnts.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,A5.d.evnts.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(!A5.flags.isMobile&&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,A5.d.evnts.down,Function('this.src = \''+toolObj.imagePressed+'\';'));$e.add(HTMLBEle,A5.d.evnts.up,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,A5.d.evnts.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,A5.d.evnts.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,A5.d.evnts.click,this._windowAction);}
tEle.innerHTML='&nbsp;';this._tools=new Array();},setPosition:function(val1,val2){if(this._dock!=''){this.setMoveDisabled(this.disableMove);$e.remove(window,'resize',this._keepDocked);$e.remove(window,'scroll',this._keepDocked);this._dock='';}
var setPointerHandled=false;var wEle=$(this._windowId);if(val1.toLowerCase()=='center'){var vpSize=this._getVPSize();var vpScroll=this._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=this._getVPScroll();var vpSize=this._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(),$if(this.pointer.show,this.pointer.size,0));if(this.pointer.show)this._setPointer(val1,wEle,pEle);setPointerHandled=true;}}else if(val1.toLowerCase()=='dock'){this._dock=val2.toLowerCase().substr(0,1);AUI.Drag.disable(this._windowId);$e.add(window,'resize',this._keepDocked,this,true);$e.add(window,'scroll',this._keepDocked,this,true);var vpSize=this._getVPSize();var vpScroll=this._getVPScroll();if(this._dock=='t'){wEle.style.top=vpScroll.y+'px';wEle.style.left=Math.max(Math.round(((vpSize.width)/2)-(wEle.offsetWidth/2)+vpScroll.x),0)+'px';}else if(this._dock=='b'){wEle.style.top=((vpSize.height+vpScroll.y)-wEle.offsetHeight)+'px';wEle.style.left=Math.max(Math.round(((vpSize.width)/2)-(wEle.offsetWidth/2)+vpScroll.x),0)+'px';}else if(this._dock=='l'){wEle.style.top=Math.max(Math.round(((vpSize.height)/2)-(wEle.offsetHeight/2)+vpScroll.y),0)+'px';wEle.style.left=vpScroll.x+'px';}else if(this._dock=='r'){wEle.style.top=Math.max(Math.round(((vpSize.height)/2)-(wEle.offsetHeight/2)+vpScroll.y),0)+'px';wEle.style.left=((vpSize.width+vpScroll.x)-wEle.offsetWidth)+'px';}}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(!setPointerHandled&&this.pointer.show)this._setPointer(val1,wEle,false);if(this.onMove.constructor==Function)this.onMove();this._oldTop=wEle.style.top;},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');var pRegex=/^[0-9]+%$/;if(pRegex.test(this.width)||pRegex.test(this.height)){$e.add(window,'resize',this._stretch,this,true);this._stretch();this._hasStretch=true;}else if(this._hasStretch){$e.remove(window,'resize',this._stretch);this._hasStretch=false;}
if(!pRegex.test(this.width))bcEle.style.width=this.width;if(!pRegex.test(this.height))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';}
$e.execute(bEle,'a5resize');},_keepDocked:function(){var wEle=$(this._windowId);var vpSize=this._getVPSize();var vpScroll=this._getVPScroll();if(this._dock=='t'){wEle.style.top=vpScroll.y+'px';wEle.style.left=Math.max(Math.round(((vpSize.width)/2)-(wEle.offsetWidth/2)+vpScroll.x),0)+'px';}else if(this._dock=='b'){wEle.style.top=((vpSize.height+vpScroll.y)-wEle.offsetHeight)+'px';wEle.style.left=Math.max(Math.round(((vpSize.width)/2)-(wEle.offsetWidth/2)+vpScroll.x),0)+'px';}else if(this._dock=='l'){wEle.style.top=Math.max(Math.round(((vpSize.height)/2)-(wEle.offsetHeight/2)+vpScroll.y),0)+'px';wEle.style.left=vpScroll.x+'px';}else if(this._dock=='r'){wEle.style.top=Math.max(Math.round(((vpSize.height)/2)-(wEle.offsetHeight/2)+vpScroll.y),0)+'px';wEle.style.left=((vpSize.width+vpScroll.x)-wEle.offsetWidth)+'px';}},_stretch:function(){var pRegex=/^[0-9]+%$/;var cs=this._getVPSize();var wEle=$(this._windowId);var bEle=$(this._windowId+'.BODY');var bcEle=bEle.parentNode;if(pRegex.test(this.width)){var w=cs.width-(wEle.offsetWidth-bEle.offsetWidth);w=(w/100)*$u.s.toNum(this.width);bcEle.style.width=w+'px';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';}}
if(pRegex.test(this.height)){var h=cs.height-(wEle.offsetHeight-bEle.offsetHeight);h=(h/100)*$u.s.toNum(this.height);bEle.style.height=h+'px';}
$e.execute(bEle,'a5resize');},_setPointer:function(val,wEle,pEle){var pntEle=$(this._windowId+'.POINTER');pntEle.style.top='';pntEle.style.left='';var loc='up';var pEleOffset=0;var wEleOffset=0;if(this.pointer.location=='up'||this.pointer.location=='down'||this.pointer.location=='left'||this.pointer.location=='right'){loc=this.pointer.location;}else if(val.toLowerCase()=='dropdown'||val.toLowerCase()=='dropdown-right'){if($gpt(wEle)>$gpt(pEle))loc='up';else loc='down';}else if(val.toLowerCase()=='flyout'||val.toLowerCase()=='flyout-bottom'){if($gpl(wEle)>$gpl(pEle))loc='left';else loc='right';}
if(loc=='up'||loc=='down'){if(loc=='up'){pntEle.className=this.pointer.upClassName;pntEle.style.display='';}else{pntEle.className=this.pointer.downClassName;pntEle.style.display='';}
pntEle.style.left='50%';if(pEle){var wEleOffset=$gpl(wEle);var pEleOffset=$gpl(pEle);var wEleOffsetMax=wEleOffset+wEle.offsetWidth-this.pointer.size;var pEleOffsetMax=pEleOffset+pEle.offsetWidth-this.pointer.size;wEleOffset+=this.pointer.size;pEleOffset+=this.pointer.size;var tOffsetStart=Math.min(Math.max(wEleOffset,pEleOffset),wEleOffsetMax);var tOffsetEnd=Math.max(Math.min(wEleOffsetMax,pEleOffsetMax),wEleOffset);var tOffset=(tOffsetStart-wEleOffset)+this.pointer.size+Math.round((tOffsetEnd-tOffsetStart)/2);pntEle.style.left=tOffset+'px';}}else if(loc=='left'||loc=='right'){if(loc=='left'){pntEle.className=this.pointer.leftClassName;pntEle.style.display='';}else{pntEle.className=this.pointer.rightClassName;pntEle.style.display='';}
pntEle.style.top='50%';if(pEle){var wEleOffset=$gpt(wEle);var pEleOffset=$gpt(pEle);var wEleOffsetMax=wEleOffset+wEle.offsetHeight-this.pointer.size;var pEleOffsetMax=pEleOffset+pEle.offsetHeight-this.pointer.size;wEleOffset+=this.pointer.size;pEleOffset+=this.pointer.size;var tOffsetStart=Math.min(Math.max(wEleOffset,pEleOffset),wEleOffsetMax);var tOffsetEnd=Math.max(Math.min(wEleOffsetMax,pEleOffsetMax),wEleOffset);var tOffset=(tOffsetStart-wEleOffset)+this.pointer.size+Math.round((tOffsetEnd-tOffsetStart)/2);pntEle.style.top=tOffset+'px';}}else pntEle.style.display='none';},_getVPSize:function(){if(this.container=='')return AUI.u.getVPSize();else{var cEle=$(this.container);return{width:cEle.offsetWidth,height:cEle.offsetHeight};}},_getVPScroll:function(){if(this.container=='')return AUI.u.getVPScroll();else{var cEle=$(this.container);return{x:cEle.scrollLeft,y:cEle.scrollTop};}},_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'||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;this._window.setToolDisplay('close',true);$(this._window.getWindowId('buttons')).style.textAlign=this.buttonAlign;var showButtons=true;var buttons=[];if(type.constructor==Array){for(var i=0;i<type.length;i++){buttons.push({action:Function('this._msgBoxAction = \''+type[i].value+'\'; this.hide();'),className:this.buttonClassName,width:this.buttonWidth});$u.o.assign(buttons[i],type[i]);}}else{type=type.toLowerCase();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{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:'',buttonAlign:'',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,{override:'base',location:'top',className:'',separator:{className:'',show:false},tab:{className:'',selectedClassName:'',disabledClassName:'',closeClassName:'',closeIcon:'',closeHoverIcon:'',closeIconStyle:0},scrollButtons:{overlay:false,fullHeight:false,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);A5.overrides.assign(this,'tabBand',this.override);this.location=this.location.toLowerCase();if(this.location!='bottom')this.location='top';var ele=$(ctrlId);this._ele=ele;this.ctrlId=ele.id;ele.innerHTML='';ele.className=this.className;ele.style.overflow='hidden';ele.style.position='relative';if(A5.flags.supportsTouch||A5.u.drag.simulateTouch){$e.add(ele,'a5dragscrolldischange',this._dragScrollDisChange,this);$e.add(ele,'a5dragscrollend',this._dragScrollEnd,this,true);A5.u.drag.add(ele,'custom',{overlay:this.scrollButtons.overlay,axis:'x',tolerance:5,onStart:function(d,c,e){d.tEle=$(this.id+'.TABTABLE');d.pEle=$(this.id+'.PTOOLBAR');d.nEle=$(this.id+'.NTOOLBAR');d.tabOffset=$u.s.toNum(d.tEle.style.left);d.tabMinLeft=(d.tEle.offsetWidth-(this.offsetWidth-$if(!c.overlay,d.pEle.offsetWidth+d.nEle.offsetWidth+4,4)))*-1;d.tabDis=0;if(d.tabOffset<=d.tabMinLeft)d.tabDis=1;else if(d.tabOffset==0)d.tabDis=-1;$e.stopEvent(e);},onMove:function(d){var val=Math.min(Math.max(d.tabOffset+d.moveX,d.tabMinLeft),0);if(val==d.tabMinLeft&&d.tabDis!=1){d.tabDis=1;$sa(this,'a5dragscrolldisable','n');$e.execute(this,'a5dragscrolldischange');}else if(val==0&&d.tabDis!=-1){d.tabDis=-1;$sa(this,'a5dragscrolldisable','p');$e.execute(this,'a5dragscrolldischange');}else if(d.tabDis!=0&&val<0&&val>d.tabMinLeft){d.tabDis=0;$sa(this,'a5dragscrolldisable','');$e.execute(this,'a5dragscrolldischange');}
d.tEle.style.left=val+'px';},onEnd:function(d,e){$e.stopEvent(e);$e.execute(this,'a5dragscrollend');}});}
var tblEle=document.createElement('table');tblEle.id=this.ctrlId+'.TABTABLE';this._tblEle=tblEle;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';this._ptbEle=ptbEle;ptbEle.style.position='absolute';ptbEle.style.left='0px';if(this.scrollButtons.fullHeight)ptbEle.style.height='100%';if(this.location=='bottom')ptbEle.style.top='0px';else ptbEle.style.bottom='0px';var ntbEle=document.createElement('div');ntbEle.id=this.ctrlId+'.NTOOLBAR';this._ntbEle=ntbEle;ntbEle.style.position='absolute';ntbEle.style.right='0px';if(this.scrollButtons.fullHeight)ntbEle.style.height='100%';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';this._pbEle=pbEle;pbEle.className=this.scrollButtons.prevClassName;pbEle.innerHTML='<img id="'+this.ctrlId+'.PREVIMG" src="'+this.scrollButtons.prevImage+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" style="border: none;" /> ';pbEle.style.display='none';ptbEle.appendChild(pbEle);$e.add(pbEle,A5.d.evnts.click,this._scrollPrev,this,true);$e.add(pbEle,A5.d.evnts.dblClick,this._scrollPrev,this,true);var nbEle=document.createElement('a');nbEle.id=this.ctrlId+'.NEXT';this._nbEle=nbEle;nbEle.className=this.scrollButtons.nextClassName;nbEle.innerHTML='<img id="'+this.ctrlId+'.NEXTIMG" src="'+this.scrollButtons.nextImage+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" style="border: none;" /> ';nbEle.style.display='none';ntbEle.appendChild(nbEle);$e.add(nbEle,A5.d.evnts.click,this._scrollNext,this,true);$e.add(nbEle,A5.d.evnts.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._ele;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));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);var cStyle=this._gDef(tObj.closeIconStyle,this.tab.closeIconStyle);if(typeof cStyle=='string'||typeof cStyle=='object')$ss(iEle,cStyle);iEle.style.verticalAlign='top';iEle.style.borderStyle='none';tEle.appendChild(iEle);$acn(tEle,this._gDef(tObj.closeClassName,this.tab.closeClassName));if(!A5.flags.isMobile){$e.add(iEle,'mouseover',this._closeMOver,this);$e.add(iEle,'mouseout',this._closeMOut,this);}
$e.add(iEle,A5.d.evnts.click,this._close,this);}
var tblEle=this._tblEle;var cellIndx=tblEle.rows[0].cells.length;tblEle.rows[0].insertCell(cellIndx);tblEle.rows[0].cells[cellIndx].appendChild(tEle);$e.add(tEle,A5.d.evnts.click,this._click,this);$e.add(tEle,'click',function(e){$e.preventDefault(e);return false;});$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,A5.d.evnts.click,this._click);$e.remove(tEle,'contextmenu',this._rClick);if(tEle.lastChild.tagName){if(tEle.lastChild.tagName.toLowerCase()=='img'){if(!A5.flags.isMobile){$e.remove(tEle.lastChild,'mouseover',this._closeMOver);$e.remove(tEle.lastChild,'mouseout',this._closeMOut);}
$e.remove(tEle.lastChild,A5.d.evnts.click,this._close);}}
delete tEle;if(tIndx<this._scrollTab)this._scrollTab--;this._tblEle.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'){var tEle=this._getTab(this._curTabIndx);if(this._items[this._curTabIndx].disabled)tEle.className=this._gDef(this._items[this._curTabIndx].disabledClassName,this.tab.disabledClassName);else tEle.className=this._gDef(this._items[this._curTabIndx].className,this.tab.className);if(this._items[this._curTabIndx].close)$acn(tEle,this._gDef(this._items[this._curTabIndx].closeClassName,this.tab.closeClassName));}
this._curTabIndx=tIndx;this.value=this._items[this._curTabIndx].value;var tEle=this._getTab(this._curTabIndx)
tEle.className=this._gDef(this._items[this._curTabIndx].selectedClassName,this.tab.selectedClassName);if(this._items[this._curTabIndx].close)$acn(tEle,this._gDef(this._items[this._curTabIndx].closeClassName,this.tab.closeClassName));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._ele;var tblEle=this._tblEle;var pbEle=this._pbEle;var nbEle=this._nbEle;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._ptbEle;var ntbEle=this._ntbEle;if((tblEle.offsetWidth-this._scrollOffset)<(tbEle.offsetWidth-$if(this.scrollButtons.overlay,0,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._ele;var tblEle=this._tblEle;var ptbEle=this._ptbEle;var ntbEle=this._ntbEle;var tEle=tblEle.rows[0].cells[tIndx];if((tEle.offsetLeft+tEle.offsetWidth-this._scrollOffset)>(tbEle.offsetWidth-$if(this.scrollButtons.overlay,0,ptbEle.offsetWidth+ntbEle.offsetWidth))||(tblEle.offsetWidth-this._scrollOffset)<(tbEle.offsetWidth-$if(this.scrollButtons.overlay,0,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-$if(this.scrollButtons.overlay,0,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._tblEle.rows[0].cells[tIndx].firstChild.firstChild.innerHTML='&nbsp;'+html+'&nbsp;';},_scrollReset:function(){if(this._scrollTab==-1)return false;var tbEle=this._ele;var tblEle=this._tblEle;var ptbEle=this._ptbEle;var ntbEle=this._ntbEle;var tEle=tblEle.rows[0].cells[this._scrollTab];if(tblEle.offsetWidth-this._scrollOffset<(tbEle.offsetWidth-$if(this.scrollButtons.overlay,0,ptbEle.offsetWidth+ntbEle.offsetWidth))){this._scrollRJ=true;this._scrollTab=this._lastTabIndx;this._scrollOffset=tEle.offsetLeft+tEle.offsetWidth+4;this._scrollOffset=this._scrollOffset-(tbEle.offsetWidth-$if(this.scrollButtons.overlay,0,ptbEle.offsetWidth+ntbEle.offsetWidth));this._scrollAnimate(true);}else{if(this._scrollRJ){this._scrollOffset=tEle.offsetLeft+tEle.offsetWidth+4;this._scrollOffset=this._scrollOffset-(tbEle.offsetWidth-$if(this.scrollButtons.overlay,0,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._ele;var tblEle=this._tblEle;var ptbEle=this._ptbEle;var ntbEle=this._ntbEle;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-$if(this.scrollButtons.overlay,0,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._ele;var tblEle=this._tblEle;var ptbEle=this._ptbEle;var ntbEle=this._ntbEle;var nextTab=this._getNextAvailableTab(this._scrollTab);if(!this._scrollRJ){if((tblEle.offsetWidth-this._scrollOffset-tblEle.rows[0].cells[this._scrollTab].offsetWidth)<(tbEle.offsetWidth-$if(this.scrollButtons.overlay,0,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-$if(this.scrollButtons.overlay,0,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._tblEle;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._pbEle.className=this.scrollButtons.prevClassName;this._pbEle.firstChild.src=this.scrollButtons.prevImage;}else{this._pbEle.className=this._gDef(this.scrollButtons.prevDisabledClassName,this.scrollButtons.prevClassName);this._pbEle.firstChild.src=this._gDef(this.scrollButtons.prevDisabledImage,this.scrollButtons.prevImage);}}else{if(state){this._nbEle.className=this.scrollButtons.nextClassName;this._nbEle.firstChild.src=this.scrollButtons.nextImage;}else{this._nbEle.className=this._gDef(this.scrollButtons.nextDisabledClassName,this.scrollButtons.nextClassName);this._nbEle.firstChild.src=this._gDef(this.scrollButtons.nextDisabledImage,this.scrollButtons.nextImage);}}},_dragScrollDisChange:function(e,classInst){if(classInst._canScroll){var val=$ga(this,'a5dragscrolldisable');if(val=='n'){classInst._setScrollDisabled('n',false);classInst._canScrollNext=false;}else if(val=='p'){classInst._setScrollDisabled('p',false);classInst._canScrollPrev=false;}else{classInst._setScrollDisabled('n',true);classInst._setScrollDisabled('p',true);classInst._canScrollNext=true;classInst._canScrollPrev=true;}}},_dragScrollEnd:function(){var tblEle=this._tblEle;this._scrollOffset=Math.abs($u.s.toNum(tblEle.style.left));for(var i=0;i<tblEle.rows[0].cells.length;i++){if(tblEle.rows[0].cells[i].offsetLeft>=this._scrollOffset){this._scrollTab=i;break;}}},_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._tblEle.rows[0].cells[val];var tEle=cEle.firstChild;return tEle;}
return false;},_getTabIndex:function(val){if(typeof val=='number'){if(val>-1&&val<this._items.length)return val;else return-1;}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';ele.style.left='-200%';}}}}
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='';ele.style.left='0px';}
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);}else if(pSettings.type=='htmlReport'){var data=this._panes[indx].data;$u.o.assign(data,{reportDiv:this._panes[indx]._id+'.CONTENT'});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]);if(typeof document.documentElement.style.opacity!='undefined'||!(document.all&&navigator.appName!='Opera')){var name=this._panes[indx].name.toUpperCase();if(item.paneType=='grid'&&window[name+'_GridObj']){window[name+'_GridObj']._destroy();eval('delete '+name+'_GridObj');}else if(item.paneType=='dialog2'&&window[name+'_DlgObj']){window[name+'_DlgObj']._destroy();eval(name+'_DlgObj = false; try{delete '+name+'_DlgObj;}catch(err){}');}else if(item.paneType=='customComponent'&&window[name+'_CustObj']){window[name+'_CustObj']._destroy();eval('delete '+name+'_CustObj');}}}
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);}else if(pSettings.type=='htmlReport'){var data=this._tbObj._panes[i].data;$u.o.assign(data,{reportDiv:this._tbObj._panes[i]._id+'.CONTENT'});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';cEle.style.left='-200%';}
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'||pSettings.type=='htmlReport'){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=='htmlReport'){var data=pSettings.data;$u.o.assign(data,{reportDiv:pSettings._id+'.CONTENT'});A5.component.runReport(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});var tARef=pSettings.autoRefresh;pSettings.autoRefresh=false;this._tbObj.select(pSettings._id);pSettings.autoRefresh=tARef;this._tbObj._panes.autoRefresh=tARef;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={override:'base',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,onRightClick:0,onNodeSelect:0,onNodeClick:0,onNodeExpand:0,onBeforeNodeExpand:0,onNodeCollapse:0,onNodeDraw: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);A5.overrides.assign(this,'tree',this.override);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,A5.d.evnts.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,A5.d.evnts.up,this._clickToggleBranch);$e.add(iNode,A5.d.evnts.up,this._clickToggleBranch,this,false,this.contId+'.EVENTS');if(!A5.flags.isMobile&&(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(){var oldValue=this.value;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'){if(dataNode.location.length>1){var loc=[];for(var i=0;i<dataNode.location.length-1;i++){loc.push(dataNode.location[i]);tDataNode=this.getDataNode(loc);if(!tDataNode.expanded)this._toggleBranch(tDataNode);}}
selClassName=this._gDef(dataNode.selectedClassName,this.node.selectedClassName);if(selClassName!='')$acn($(this.contId+'.'+dataNode.location.join('.')).firstChild,selClassName);this.selection[this.selection.length]=dataNode;}}
var curValue=[];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');$e.execute(this.inputId,'change');}
if(oldValue.join('\n')!=curValue.join('\n')){if(typeof dataNode=='object'){if(dataNode.onSelect.constructor==Function)dataNode.onSelect(dataNode);}else if(this.onNodeSelect.constructor==Function)this.onNodeSelect(dataNode);}},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.id=baseId+'.LABEL';buttonNode.tabIndex=-1;buttonNode.href="#";$e.add(buttonNode,A5.d.evnts.up,this._clickNode,this,false,this.contId+'.EVENTS');$e.add(buttonNode,'click',function(e){$e.preventDefault(e);return false;},null,false,this.contId+'.EVENTS');if(!A5.flags.isMobile){$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.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(!A5.flags.isMobile&&(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,A5.d.evnts.up,this._clickToggleBranch,this,false,this.contId+'.EVENTS');divNode.appendChild(tempNode);if(curIcon!=''){buttonNode.innerHTML='<img id="'+baseId+'.LABELICON" src="'+curIcon+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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.onBeforeExpand.constructor==Function)dataNode.onBeforeExpand(dataNode);else if(this.onBeforeNodeExpand.constructor==Function)this.onBeforeNodeExpand(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 oldValue=this.value;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');$e.execute(this.inputId,'change');}
if(oldValue.join('\n')!=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,A5.d.evnts.up,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,A5.d.evnts.up,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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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,onBeforeExpand: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:'',override:'base',inputId:'',focusClassName:'',multiple:false,loopNavigate:false,loopNavigateNullSelection:true,allowNullSelection:true,defaultValues:false,calculateValue:0,scroll:{},layout:'',layouts:{},columnLayout:{header:{show:true,className:'',item:{className:'',hoverClassName:'',order:{ascendingImage:'',descendingImage:'',className:'',style:0}}},data:{item:{className:'',style:''}}},content:{header:{show:true,html:'',className:'',style:0},footer:{show:true,html:'',className:'',style:0}},item:{className:'',hoverClassName:'',selectedClassName:'',style:0,titleClassName:'',separatorClassName:'',template:''},animation:{swap:{flow:'ltr',duration:600}},filter:false,order:false,onFocus:0,onBlur:0,onRightClick:0,onSelect:0,onClick:0,onDblClick:0,onListDraw:0,onBeforeListDraw:0,onItemDraw:0,onBeforeItemDraw: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);A5.overrides.assign(this,'listBox',this.override);if(typeof this.item.template!='undefined'){if(this.layout=='')this.layout='*default';this.layouts['*default']={type:'template',template:this.item.template};}
if(typeof this.item.calculateValue!='undefined')this.calculateValue=this.item.calculateValue;if(this._template!=''&&this.calculateValue.constructor!=Function){this.calculateValue=function(data){if(data.constructor==Object){var val=new Array();for(prop in data)val.push(data[prop]);return val.join('\n');}else if(data.constructor==Array){return data.join('\n');}else return data;}}
var contEle=$(this.contId);if(contEle.style.position!='absolute')contEle.style.position='relative';$ss(contEle,$gs(contEle)+'; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');$sa(contEle,'A5StoredStylePadding',contEle.style.padding);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 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,A5.d.evnts.click,this._focus,this,true);$e.add(contEle,'contextmenu',this._rClick,this,true);contEle.parentNode.insertBefore(HTMLFocusCatcher,contEle);this._data=[].concat(data);this._clOrderCol=-1;this._clOrderCols=[];this._clOrderDir=0;this._clfWidth=-1;this._clfFlex=false;this._clf=false;this._clfCSC={i:false,dir:0};this._ioStyle=false;this._curL='';this._curLObj={}
this._isInit=true;this.refresh();this._isInit=false;},setLayout:function(layout){this.layout=layout
this.refresh();},setColumnOrderImage:function(indx,dir){if(dir==0)indx=false;if(this._clf){if(typeof this._clfCSC.i=='number')$(this.contId+'.CHEADER.'+this._clfCSC.i+'.IMG').style.display='none';this._clfCSC={i:indx,d:dir};if(typeof this._clfCSC.i=='number'){var iEle=$(this.contId+'.CHEADER.'+this._clfCSC.i+'.IMG');iEle.style.display='';if(this._clfCSC.d<0)iEle.src=this.columnLayout.header.item.order.descendingImage;else iEle.src=this.columnLayout.header.item.order.ascendingImage;}}else this._clfCSC={i:indx,d:dir};},setDisplay:function(part,val){if(part=='column-header'){this.columnLayout.header.show=val;this.refresh();}else if(part=='content-header'){var ele=$(this.contId+'.CONTENT.HEADER');if(val)ele.style.display='';else ele.style.display='none';}else if(part=='content-footer'){var ele=$(this.contId+'.CONTENT.FOOTER');if(val)ele.style.display='';else ele.style.display='none';}},refresh:function(){var keepVal=typeof arguments[0]!='undefined'?arguments[0]:true;var lEle=$(this.contId);this._oldWidth=lEle.offsetWidth;this._clfWidth=-1;this._clf=false;this._ioStyle=false;var lObj=this.layouts[this.layout];$u.o.assign(lObj,this._lDefaults,true);if(this._isInit){lEle.innerHTML='';chEle=document.createElement('div');chEle.id=this.contId+'.CHEADER';chEle.className=this.columnLayout.header.className;$ss(chEle,'overflow: hidden; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');chgEle=document.createElement('div');chgEle.id=this.contId+'.CHEADER.GROUP';chEle.appendChild(chgEle);lEle.appendChild(chEle);var cwEle=document.createElement('div');cwEle.id=this.contId+'.CONTENTWRAPPER';$ss(cwEle,'position: relative; -webkit-transform: translate3d(0px,0px,0px); box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');lEle.appendChild(cwEle);var cdhEle=document.createElement('div');cdhEle.id=this.contId+'.CONTENT.HEADER';cdhEle.className=this.content.header.className;if(typeof this.content.header.style=='object'||typeof this.content.header.style=='string')$ss(cdhEle,this.content.header.style);cdhEle.style['WebkitTransform']='translate3d(0px,0px,0px)';cwEle.appendChild(cdhEle);var cEle=document.createElement('div');cEle.id=this.contId+'.CONTENT';cEle.style['WebkitTransform']='translate3d(0px,0px,0px)';cwEle.appendChild(cEle);var cdfEle=document.createElement('div');cdfEle.id=this.contId+'.CONTENT.FOOTER';cdfEle.className=this.content.footer.className;if(typeof this.content.footer.style=='object'||typeof this.content.footer.style=='string')$ss(cdfEle,this.content.footer.style);cdfEle.style.clear='both';cdfEle.style['WebkitTransform']='translate3d(0px,0px,0px)';cwEle.appendChild(cdfEle);if(A5.flags.isFireFox)$e.add(cwEle,'transitionend',Function('var cEle = $(\''+this.contId+'.CONTENTTEMP\'); if(cEle){ this.style[\'MozTransition\'] = \'\'; $(\''+this.contId+'\').removeChild(cEle);}'));else if(A5.flags.isOpera)$e.add(cwEle,'oTransitionEnd',Function('var cEle = $(\''+this.contId+'.CONTENTTEMP\'); if(cEle){ this.style[\'OTransition\'] = \'\'; $(\''+this.contId+'\').removeChild(cEle);}'));else if(A5.flags.isWebKit)$e.add(cwEle,'webkitTransitionEnd',Function('var cEle = $(\''+this.contId+'.CONTENTTEMP\'); if(cEle){ this.style[\'WebkitTransition\'] = \'\'; $(\''+this.contId+'\').removeChild(cEle);}'));var cfEle=document.createElement('div');cfEle.style.clear='both';cwEle.appendChild(cfEle);var sObj1={theme:'',axis:'both'};var sObj2={theme:'',axis:'both'};$u.o.assign(sObj1,this.scroll);$u.o.assign(sObj2,this.scroll);sObj1.disabled=true;sObj2.disabled=true;if(sObj1.theme==''){sObj1.theme=this.theme;sObj2.theme=this.theme;}
A5.u.drag.add(lEle,'scroll',sObj1);A5.u.drag.add(cwEle,'scroll',sObj2);}else{var chEle=$(this.contId+'.CHEADER');var chgEle=$(this.contId+'.CHEADER.GROUP');var cwEle=$(this.contId+'.CONTENTWRAPPER');var cdhEle=$(this.contId+'.CONTENT.HEADER');var cdfEle=$(this.contId+'.CONTENT.FOOTER');var cEle=$(this.contId+'.CONTENT');}
cEle.style.whiteSpace='';chEle.style.display='none';if(this.content.header.show){cdhEle.style.display='';if(this._isInit)cdhEle.innerHTML=this.content.header.html;}else cdhEle.style.display='none';if(this.content.footer.show){cdfEle.style.display='';if(this._isInit)cdfEle.innerHTML=this.content.footer.html;}else cdfEle.style.display='none';var os={left:0,top:0};if(this._curL=='template-horizontal'&&lObj.type!='template-horizontal'){cwEle.style.whiteSpace='';cdhEle.style.display='';cEle.style.display='';cdfEle.style.display='';}
if(lObj.type=='template'||lObj.type=='template-flow'||lObj.type=='template-horizontal'){os=A5.u.element.getScroll(lEle);if(this._curL=='column'||this._isInit){$e.remove(lEle,'a5resize',this._resize);A5.u.drag.setDisabled(cwEle,'scroll',true);$e.remove(cwEle,'scroll',Function('$(\''+this.contId+'.CHEADER\').scrollLeft = this.scrollLeft;'));cwEle.style.height='';cwEle.style.overflow='';if($ga(lEle,'A5CustomScroll'))lEle.style.overflow='hidden';else lEle.style.overflow='auto';lEle.style.padding=$ga(lEle,'A5StoredStylePadding');A5.u.drag.setDisabled(lEle,'scroll',false);}
if(typeof lObj.template=='object')lObj.template=lObj.template.join('');this._template=lObj.template;if(lObj.type=='template-flow'){this._ioStyle={cssFloat:'left',width:lObj.item.width};}else if(lObj.type=='template-horizontal'){this._ioStyle={display:'inline-block',width:lObj.item.width};if(this._curL!='template-horizontal'){cwEle.style.whiteSpace='nowrap';cdhEle.style.display='inline-block';cEle.style.display='inline-block';cdfEle.style.display='inline-block';}}}else if(lObj.type=='column'){os=A5.u.element.getScroll(cwEle);if(this._curL!='column'||this._isInit){A5.u.drag.setDisabled(lEle,'scroll',true);A5.u.drag.setDisabled(cwEle,'scroll',false);$e.add(cwEle,'scroll',Function('$(\''+this.contId+'.CHEADER\').scrollLeft = A5.u.element.getScroll(this).left;'));$e.add(lEle,'a5resize',this._resize,this,true);lEle.style.overflow='hidden';lEle.style.padding='0px';cwEle.style.height='100px';if($ga(cwEle,'A5CustomScroll'))cwEle.style.overflow='hidden';else cwEle.style.overflow='auto';cEle.innerHTML='';cEle.style.display='';}
this._clf=true;this._clOrderCols=[];if(this.columnLayout.header.show)chEle.style.display='';chgEle.innerHTML='';chgEle.style.width='';var cObj=0;var tHTML=[];var chiEle=0;lObj._fTotal=0;lObj._wTotal=0;for(var i=0;i<lObj.columns.length;i++){cObj=lObj.columns[i];$u.o.assign(cObj,this._cDefaults,true);if(cObj.width.substr(0,5)=='flex('){cObj._w='0px';cObj._f=$u.s.toNum(cObj.width);lObj._fTotal+=cObj._f;}else{cObj._w=cObj.width;cObj._f=0;lObj._wTotal+=A5.u.convertUnits(cObj.width,'px');}}
if(lObj._fTotal!=0){cEle.innerHTML='<div class="'+this.item.className+'" style="visibility: hidden; height: '+(cEle.offsetHeight+300)+'px;"><div>&nbsp;</div></div>';var tWidth=cEle.firstChild.firstChild.offsetWidth;if(tWidth>lObj._wTotal){var rWidth=tWidth-lObj._wTotal;for(var i=0;i<lObj.columns.length;i++){cObj=lObj.columns[i];if(cObj._f!=0)cObj._w=Math.round((rWidth*(cObj._f/lObj._fTotal))-.49)+'px';}}
cEle.innerHTML='';}
for(var i=0;i<lObj.columns.length;i++){cObj=lObj.columns[i];tHTML.push('<div class="'+this._gDef(cObj.data.className,this.columnLayout.data.item.className)+'" style="'+this._gDef(cObj.data.style,this.columnLayout.data.item.style)+'; width: '+cObj._w+'; overflow: hidden; text-overflow: ellipsis; white-space: pre; float: left; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;">'+cObj.data.template+'</div>');if(this.columnLayout.header.show){chiEle=document.createElement('div');chiEle.id=this.contId+'.CHEADER.'+i;chiEle.innerHTML=cObj.header.html;chiEle.className=this._gDef(cObj.header.className,this.columnLayout.header.item.className);if(!A5.flags.isMobile){$e.add(chiEle,'mouseover',Function('$acn(this,\''+this._gDef(cObj.header.hoverClassName,this.columnLayout.header.item.hoverClassName)+'\');'));$e.add(chiEle,'mouseout',Function('$rcn(this,\''+this._gDef(cObj.header.hoverClassName,this.columnLayout.header.item.hoverClassName)+'\');'));}
this._clOrderCols.push(cObj.order);if(cObj.order||cObj.header.onClick.constructor==Function)$e.add(chiEle,A5.d.evnts.click,this._colClick,this);if(cObj.header.onRightClick.constructor==Function)$e.add(chiEle,'contextmenu',this._colRClick,this);$e.add(chiEle,A5.d.evnts.down,function(e){$e.stopEvent($e.getEvent(e));return false;});$ss(chiEle,this._gDef(cObj.header.style,this.columnLayout.header.item.style)+'; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; float: left; box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');chiEle.style.width=cObj._w;ctiEle=document.createElement('img');ctiEle.id=this.contId+'.CHEADER.'+i+'.IMG';ctiEle.src=this.columnLayout.header.item.order.ascendingImage;ctiEle.className=this.columnLayout.header.item.order.className;if(typeof this.columnLayout.header.item.order.style=='string'||typeof this.columnLayout.header.item.order.style=='object')$ss(ctiEle,this.columnLayout.header.item.order.style);ctiEle.style.display='none';chiEle.appendChild(ctiEle);chgEle.appendChild(chiEle);}
this._clfWidth+=A5.u.convertUnits(cObj._w,'px');}
this._clfWidth+=1;this._clfFlex=lObj._fTotal!=0?true:false;chgEle.style.width=(this._clfWidth+cEle.offsetWidth)+'px';chgEle.style.height='1px';tHTML.push('<br style="clear: both;" />');this._template=tHTML.join('');}
this._curL=lObj.type;this._curLObj=lObj;this.populate(this._data,keepVal);cdhEle.style.width='';cdfEle.style.width='';if(this._curL=='column'){if(lEle.style.height!=''){var contentHeight=lEle.clientHeight;if(chEle)contentHeight-=chEle.offsetHeight;cwEle.style.height=contentHeight+'px';}
if(!this._clfFlex){cdhEle.style.width=this._clfWidth+'px';cdfEle.style.width=this._clfWidth+'px';}
A5.u.element.setScroll(cwEle,os.left,os.top);}else{A5.u.element.setScroll(lEle,os.left,os.top);}},populate:function(data){var keepVal=typeof arguments[1]!='undefined'?arguments[1]:false;if(keepVal)var oldVals=[].concat(this.value);var anim=typeof arguments[2]!='undefined'?arguments[2]:false;if(anim)this._swapList(anim);this._data=[];this._dataMap=[];this._data=this._data.concat(data);$e.removeGroup(this.contId+'.EVENTS');$(this.contId+'.CONTENT').innerHTML='';this._values=new Array();var tData=[].concat(this._data);for(var i=0;i<tData.length;i++){if(typeof tData[i]=='object')tData[i]['*key']=i;}
if(this.fitler||this.order){var tData2=[];for(var i=0;i<tData.length;i++){strData=this._getStrData(tData[i]);if(strData!='-'&&strData!='*title'&&strData!='*static')tData2.push(tData[i]);}
tData=tData2;}
if(this.filter){var tData2=[];if(this.filter.constructor==Object){for(var i=0;i<tData.length;i++){for(var fCol in this.filter){if(this.filter[fCol](tData[i][fCol])){tData2.push(tData[i]);break;}}}}else{for(var i=0;i<tData.length;i++){if(this.filter(tData[i]))tData2.push(tData[i]);}}
tData=tData2;}
if(this._clf){if(this._clOrderCol>-1)$(this.contId+'.CHEADER.'+this._clOrderCol+'.IMG').style.display='none';this._clOrderDir=0;if(typeof this._clfCSC.i=='number'){var iEle=$(this.contId+'.CHEADER.'+this._clfCSC.i+'.IMG');iEle.style.display='';if(this._clfCSC.d<0)iEle.src=this.columnLayout.header.item.order.descendingImage;else iEle.src=this.columnLayout.header.item.order.ascendingImage;}}
if(this.order){if(this.order.constructor==Function)tData.sort(this.order);else{var ofPrefix='var v1 = arguments[0]; var v2 = arguments[1]; var result = 0;';var ofBody='result = v1-v2;';var ofSuffix='return result;';if(this.order.constructor==Object){var tColName='';for(var tCol in this.order){tCol=tCol.split(':');tColName=tCol[0];ofPrefix='var v1 = arguments[0].'+tColName+'; var v2 = arguments[1].'+tColName+'; var result = 0;';if(typeof tData[0][tColName]=='string'){ofPrefix=ofPrefix+'v1 = v1.replace(/(<([^>]+)>)/ig,\'\');v2 = v2.replace(/(<([^>]+)>)/ig,\'\');';if(tCol.length>1){if(tCol[1]=='number'){ofPrefix=ofPrefix+' v1 = $u.s.toNum(v1); v2 = $u.s.toNum(v2);';}else if(tCol[1]=='date'){ofPrefix=ofPrefix+' var tDate = new Date(); var tFrm = tDate._parseFormat(\''+tCol[2]+'\'); tDate.fromFormat(v1,tFrm); v1 = new Date(tDate); tDate.fromFormat(v2,tFrm); v2 = new Date(tDate);';}else if(tCol[1]=='boolean'){ofPrefix=ofPrefix+' v1 = $u.s.toBool(v1); v2 = $u.s.toBool(v2);';ofBody='if(v1<v2) result = -1; if(v1>v2) result = 1;';}}else ofBody='if(v1.toLowerCase()<v2.toLowerCase()) result = -1; if(v1.toLowerCase()>v2.toLowerCase()) result = 1;';}else if(typeof tData[0][tColName]=='boolean')ofBody='if(v1<v2) result = -1; if(v1>v2) result = 1;';tCol=tCol.join(':');if(this.order[tCol]<0)ofSuffix='return result*-1;';break;}
if(this._clf){this._clOrderCol=$u.a.find(this._clOrderCols,tCol);if(this._clOrderCol>-1){this._clOrderDir=this.order[tCol];var iEle=$(this.contId+'.CHEADER.'+this._clOrderCol+'.IMG');iEle.style.display='';if(this._clOrderDir<0)iEle.src=this.columnLayout.header.item.order.descendingImage;else iEle.src=this.columnLayout.header.item.order.ascendingImage;}}}else{if(typeof tData[0]=='string')ofBody='if(v1.toLowerCase()<v2.toLowerCase()) result = -1; if(v1.toLowerCase()>v2.toLowerCase()) result = 1;';else if(typeof tData[0]=='boolean')ofBody='if(v1<v2) result = -1; if(v1>v2) result = 1;';if(this.order<0)ofSuffix='return result*-1;';}
tData.sort(Function(ofPrefix+ofBody+ofSuffix));}}
this._renderData(tData,0);if(!this.allowNullSelection&&data.length!=0&&!(keepVal&&oldVals.length!=0))this._selectItem(0);if(keepVal)this.setValue(oldVals,false);},appendRows:function(data){var indx=this._data.length;this._data=this._data.concat(data);if(this.fitler||this.order)this.populate(this._data,true);else{for(var i=indx;i<this._data.length;i++){if(typeof this._data=='object')this._data[i]['*key']=i;}
this._renderData([].concat(this._data),indx);}},removeRows:function(rows){for(var i=0;i<rows.length;i++){if(typeof rows[i]!='number')rows[i]=this._getIndex(rows[i]);rows[i]=this._dataMap[rows[i]];}
rows.sort(function(a,b){return b-a});for(var i=0;i<rows.length;i++)this._data.splice(rows[i],1);this.populate(this._data,true);},insertRows:function(indx,data){if(typeof indx!='number')indx=this._getIndex(indx);indx=this._dataMap[indx];if(typeof indx=='undefined')this.appendRows(data);else{var tData=[indx,0].concat(data);this._data.splice.apply(this._data,tData);this.populate(this._data,true);}},updateRow:function(indx,rowData){if(typeof indx!='number')indx=this._getIndex(indx);dIndx=indx;indx=this._dataMap[indx];if(typeof rowData=='object')$u.o.assign(this._data[indx],rowData);else this._data[indx]=rowData;if(this.fitler||this.order)this.populate(this._data,true);else{var tData={};$u.o.assign(tData,this._data[indx]);if(this._template==''){if(this._hasOBIDEvnt)this.onBeforeItemDraw.call(this,tData,dIndx);var html=tData.toString();var value=tData.toString();}else{var html=this._template;if(this._hasOBIDEvnt)this.onBeforeItemDraw.call(this,tData,dIndx);for(var prop in tData)html=html.split('{'+prop+'}').join(tData[prop]);html=html.split('{*row}').join(indx);html=html.split('{*dataRow}').join(dIndx);html=html.split('{*dataRowOneBased}').join(dIndx+1);var value=this.calculateValue(tData,indx);}
var ele=$(this.contId+'.'+dIndx);ele.innerHTML=html;this._values[dIndx]=value;if(this._hasOIDEvnt)this.onItemDraw.call(this,ele,tData,dIndx);}},setFilter:function(filter){if(this._data.length==0)return false;if(filter.constructor==Object){this.filter={};for(var fCol in filter){if(filter[fCol].constructor==Function)this.filter[fCol]=filter[fCol];else if(filter[fCol].constructor==RegExp)this.filter[fCol]=Function('return ('+filter[fCol].toString()+').test(arguments[0]);');}}else if(filter.constructor==Function)this.filter=filter;else if(filter.constructor==RegExp)this.filter=Function('return ('+filter.toString()+').test(arguments[0]);');else this.filter=false;this.populate(this._data,true);},setOrder:function(order){if(this._data.length==0)return false;this.order=order;this.populate(this._data,true);},setValue:function(val){var executeSelect=typeof arguments[1]!='undefined'?arguments[1]:true;if(val.constructor==Array){if(val.join('\n')==this.value.join('\n'))executeSelect=false;if(val.length==0){if(this.allowNullSelection){this._deselectAll();if(this.onSelect.constructor==Function&&executeSelect)this.onSelect();}}else{if(this.multiple){this._deselectAll()
for(var i=0;i<val.length;i++)this._selectItem(this._getIndex(val[i]),true,executeSelect);}else{this._selectItem(this._getIndex(val.pop()),false,executeSelect);}}}else{if(val==this.value[0])executeSelect=false;if(String(val)==''){if(this.allowNullSelection){this._deselectAll();if(this.onSelect.constructor==Function&&executeSelect)this.onSelect();}}else this._selectItem(this._getIndex(val),false,executeSelect);}
if(this.inputId!=''){$(this.inputId).value=this.value.join('\n');$e.execute(this.inputId,'change');}},scrollToItem:function(val){val=this._getIndex(val);var eleId=this.contId+'.'+val;if($(eleId)){var ele=$(eleId);if(this._curL=='column')var cEle=$(this.contId+'.CONTENTWRAPPER');else var cEle=$(this.contId);var cs=A5.u.element.getScroll(cEle);var nCSX=false;var nCSY=false;if(this._curL=='template-horizontal'){if(cs.left>(ele.offsetLeft-2))nCSX=(ele.offsetLeft-2);else if((cs.left+cEle.offsetWidth)<(ele.offsetLeft+ele.offsetWidth-2))nCSX=(ele.offsetLeft+ele.offsetWidth+2-cEle.offsetWidth);}
if(cs.top>(ele.offsetTop-2))nCSY=(ele.offsetTop-2);else if((cs.top+cEle.offsetHeight)<(ele.offsetTop+ele.offsetHeight-2))nCSY=(ele.offsetTop+ele.offsetHeight+2-cEle.offsetHeight);if(nCSX!=false||nCSY!=false)A5.u.element.setScroll(cEle,nCSX,nCSY);}},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;},_renderData:function(data,startIndx){this._rData=data;this._hasOBIDEvnt=this.onBeforeItemDraw.constructor==Function;this._hasOIDEvnt=this.onItemDraw.constructor==Function;if(this.onBeforeListDraw.constructor==Function)this.onBeforeListDraw.call(this,data,startIndx);var lEle=$(this.contId+'.CONTENT');var strData='';var tIndx=this._dataMap.length;if(this._template==''){for(var i=startIndx;i<data.length;i++){strData=this._getStrData(data[i]);if(strData=='-'||strData=='*title'||strData=='*static')this._renderSep(data[i],lEle);else{this._dataMap.push(data[i]['*key']);this._renderSimpleItem(data[i],tIndx,i,lEle);tIndx++;}}}else{var applytDefVals=typeof this.defaultValues=='object'?true:false;for(var i=startIndx;i<data.length;i++){strData=this._getStrData(data[i]);if(strData=='-'||strData=='*title'||strData=='*static')this._renderSep(data[i],lEle);else{if(applytDefVals)$u.o.assign(data[i],this.defaultValues,true);this._dataMap.push(data[i]['*key']);this._renderItem(data[i],tIndx,i,lEle);tIndx++;}}}
if(this.onListDraw.constructor==Function)this.onListDraw.call(this,data,startIndx);},_renderItem:function(iData,indx,itemIndx,lEle){var tHTML=this._template;if(this._hasOBIDEvnt){var tData={};$u.o.assign(tData,iData);this.onBeforeItemDraw.call(this,tData,indx);for(var prop in tData)tHTML=tHTML.split('{'+prop+'}').join(tData[prop]);}else{for(var prop in iData)tHTML=tHTML.split('{'+prop+'}').join(iData[prop]);}
tHTML=tHTML.split('{*row}').join(itemIndx);tHTML=tHTML.split('{*dataRow}').join(indx);tHTML=tHTML.split('{*dataRowOneBased}').join(indx+1);this._renderItemLow(tHTML,this.calculateValue(iData,indx),indx,lEle,iData);},_renderSimpleItem:function(iData,indx,itemIndx,lEle){if(this._hasOBIDEvnt)this.onBeforeItemDraw.call(this,iData,indx);this._renderItemLow(iData.toString(),iData.toString(),indx,lEle,iData);},_renderItemLow:function(html,value,indx,lEle,iData){var ele=document.createElement('div');ele.id=this.contId+'.'+indx;ele.innerHTML=html;ele.href='#';ele.tabIndex=-1;ele.className=this._gDef(this._curLObj.item.className,this.item.className);if(typeof this.item.style=='object'||typeof this.item.style=='string'||typeof this._curLObj.item.style=='object'||typeof this._curLObj.item.style=='string')$ss(ele,this._gDef(this._curLObj.item.style,this.item.style));if(this._ioStyle)$ss(ele,this._ioStyle);if(this._clfWidth>0)ele.style.width=this._clfWidth+'px';this._values.push(value);$sa(ele,'A5ListIndex',''+indx);$e.add(ele,A5.d.evnts.click,this._onClick,this,false,this.contId+'.EVENTS');$e.add(ele,A5.d.evnts.dblClick,this._onDblClick,this,false,this.contId+'.EVENTS');if(!A5.flags.isMobile){$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,lEle){if(sep=='-'){var ele=document.createElement('hr');ele.className=this._gDef(this._curLObj.item.separatorClassName,this.item.separatorClassName);}else if(sep['*title']){var ele=document.createElement('div');ele.className=this._gDef(this._curLObj.item.titleClassName,this.item.titleClassName);ele.innerHTML=sep['*title'];}else if(sep['*static']){var ele=document.createElement('div');ele.className=this._gDef(this._curLObj.item.className,this.item.className);ele.innerHTML=sep['*static'];}
if(this._curL=='column'&&!this._clfFlex)ele.style.width=this._clfWidth+'px';ele.style.clear='both';lEle.appendChild(ele);},_getStrData:function(data){if(typeof data=='string')return data;else if(typeof data=='object'){if(typeof data['*title']!='undefined')return'*title';else if(typeof data['*static']!='undefined')return'*static';}
return'';},_selectItem:function(indx){var multiOverride=typeof arguments[1]!='undefined'?arguments[1]:false;var executeSelect=typeof arguments[2]!='undefined'?arguments[2]:true;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._gDef(this._curLObj.item.selectedClassName,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._gDef(this._curLObj.item.selectedClassName,this.item.selectedClassName));this.scrollToItem(indx);if(this.inputId!=''){$(this.inputId).value=this.value.join('\n');$e.execute(this.inputId,'change');}
if(this.onSelect.constructor==Function&&executeSelect)this.onSelect();}else if(this.inputId!=''){$(this.inputId).value=this.value.join('\n');$e.execute(this.inputId,'change');}},_deselectAll:function(){for(var i=0;i<this.selection.length;i++)$rcn(this.contId+'.'+this.selection[i],this._gDef(this._curLObj.item.selectedClassName,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!=''||classInst._curLObj.item.hoverClassName!='')$acn(this,classInst._gDef(classInst._curLObj.item.hoverClassName,classInst.item.hoverClassName));},_mOut:function(e,classInst){if(classInst.item.hoverClassName!=''||classInst._curLObj.item.hoverClassName!='')$rcn(this,classInst._gDef(classInst._curLObj.item.hoverClassName,classInst.item.hoverClassName));},_colClick:function(e,classInst){var col=Number(this.id.split('.').pop());var cObj=classInst.layouts[classInst.layout].columns[col];if(cObj.header.onClick.constructor==Function)cObj.header.onClick.call(classInst);if(cObj.order){var colName=classInst._clOrderCols[col];for(var i=0;i<classInst._clOrderCols.length;i++){if(classInst._clOrderCols[i]==colName){col=i;break;}}
var order={};order[colName]=1;if(classInst._clOrderCol==col){if(classInst._clOrderDir==1)order[colName]=-1;else order=false;}
classInst.setOrder(order);if(!order)classInst._clOrderCol=-1;}
$e.stopEvent(e);return false;},_colRClick:function(e,classInst){var col=Number(this.id.split('.').pop());var func=classInst.layouts[classInst.layout].columns[col].header.onRightClick;if(func.constructor==Function){func.call(classInst);$e.stopEvent(e);return false;}},_resize:function(){var lEle=$(this.contId);if(lEle.style.height!=''){var chEle=$(this.contId+'.CHEADER');var cwEle=$(this.contId+'.CONTENTWRAPPER');var contentHeight=lEle.clientHeight;if(chEle)contentHeight-=chEle.offsetHeight;cwEle.style.height=contentHeight+'px';if(this.layouts[this.layout]._fTotal!=0){if(this._oldWidth!=lEle.offsetWidth)this.refresh();}}},_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,A5.d.evnts.up,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,A5.d.evnts.up,this._blur);if(this.onBlur.constructor==Function)this.onBlur();},_swapList:function(anim){if(A5.flags.isIE)return true;var ele=$(this.contId);var chEle=$(this.contId+'.CHEADER');var cwEle=$(this.contId+'.CONTENTWRAPPER');if($(this.contId+'.CONTENTWRAPPERTEMP'))ele.removeChild($(this.contId+'.CONTENTWRAPPERTEMP'));var tcwEle=cwEle.cloneNode(true);tcwEle.id=this.contId+'.CONTENTWRAPPERTEMP';$ss(tcwEle,{position:'absolute',width:ele.clientWidth+'px',top:$if(chEle,chEle.offsetHeight+'px','0px')});var propAnimDOM='WebkitTransition';var propDOM='WebkitTransform';var propCSS='-webkit-transform';if(A5.flags.isFireFox){propAnimDOM='MozTransition';propDOM='MozTransform';propCSS='-moz-transform';}else if(A5.flags.isOpera){propAnimDOM='OTransition';propDOM='OTransform';propCSS='-o-transform';}
ele.appendChild(tcwEle);tcwEle.scrollTop=cwEle.scrollTop;tcwEle.scrollLeft=cwEle.scrollLeft;var dur=this.animation.swap.duration;if(typeof anim=='object'){dur=anim.duration;anim=anim.type;}
if(anim=='prev'){if(this.animation.swap.flow=='rtl')anim='slide-right';else anim='slide-left';}else if(anim=='next'){if(this.animation.swap.flow=='rtl')anim='slide-left';else anim='slide-right';}
var animNum=1;if(anim=='slide-left')animNum=-1;cwEle.style[propDOM]='translateX('+animNum+'00%)';setTimeout(Function('var cwEle = $(\''+this.contId+'.CONTENTWRAPPER\'); var tcwEle = $(\''+this.contId+'.CONTENTWRAPPERTEMP\'); cwEle.style[\''+propAnimDOM+'\'] = \''+propCSS+' '+dur+'ms ease-in-out\'; cwEle.style[\''+propDOM+'\'] = \'translateX(0%)\'; tcwEle.style[\''+propDOM+'\'] = \'translateX('+(animNum*-1)+'00%)\'; tcwEle.style[\''+propAnimDOM+'\'] = \''+propCSS+' '+dur+'ms ease-in-out\';'),0);},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!=''&&arguments[i]!=false&&arguments[i]!=null)return arguments[i];return'';},_cDefaults:{header:{html:'',className:'',hoverClassName:'',style:0,onClick:0,onRightClick:0},data:{template:'',className:'',style:''},order:false,width:'flex(1)'},_lDefaults:{type:'template',coulmns:[],template:'',item:{width:'3in',className:'',hoverClassName:'',selectedClassName:'',style:false,titleClassName:'',separatorClassName:''}}}
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();if(dRange.parentElement()==ele)range.setEndPoint('EndToStart',dRange);startPos=range.text.replace(/\r/g,'').length;var 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){this.override='base';if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'edit');$u.o.assign(this,settings);A5.overrides.assign(this,'edit',this.override);this._editPrepare();},create:function(s){var HTMLBEle=document.createElement('input');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;$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);if(!this.decouple)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;if(mask.length!=0){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);oldStyle=oldStyle.split('display:').join('x-display:');oldStyle=oldStyle.split('visibility:').join('x-visibility:');$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&&pMask.mask.length!=0){$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&&pMask.mask.length!=0){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(typeof this._multi=='undefined')this._multi=this._editParseMultiVal();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 ele=$(eleId);if(this.decouple)var sel={start:ele.value.length,end:ele.value.length,length:0};else var sel=A5.edit.getSelection(ele);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=String(this._editNumberIn(data.vals[i].val,this.format._number)).split('.').join(this.format._number.decimal);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(typeof this._multi=='undefined')this._multi=this._editParseMultiVal();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:'',override:'base',content:{type:'',url:'',data:''},minimum:1,delay:100,selectionRequired:false,container:{className:'',hoverClassName:'',focusClassName:'',pressedClassName:'',style:0,editClassName:'',separatorClassName:'',button:{html:'',className:'',hoverClassName:'',pressedClassName:''}},listbox:{theme:''},window:{theme:'',type:'popup',location:'dropdown'},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);A5.overrides.assign(this,'editSuggest',this.override);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,{header:{},tbar:{},bbar:{},footer:{},title:{show:false},body:{content:{type:'blank'},style:{padding:'0px',overflow:'auto'}},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.calculateValue.constructor!=Function)this._listbox.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;var eleId=ele.id;var cEle=$(eleId+'.CONTAINER');if(cEle){var bIndx=0;var cbEle=0;while($(eleId+'.CUSTOMBUTTON.'+bIndx)){cbEle=$(eleId+'.CUSTOMBUTTON.'+bIndx);$e.add(cbEle,A5.d.evnts.down,Function('$acn(this,\''+this.container.button.pressedClassName+'\')'));if(!A5.flags.isMobile){$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,A5.d.evnts.up,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,A5.d.evnts.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);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!='')$acn(cEle,classInst.container.focusClassName);},_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);var cEle=$(classInst._targetId+'.CONTAINER');if(cEle&&classInst.container.focusClassName!=''&&classInst._listbox._window.hidden)$rcn(cEle,classInst.container.focusClassName);},_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(keyCode==27){this._listbox._window.hide();}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.setValue('');}
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.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();var cEle=$(this._targetId+'.CONTAINER');if(this.window.location.constructor==Array){if(!this._listbox._window.hidden)this._listbox._window.setPosition.apply(this._listbox._window,this.window.location);else this._listbox._window.show.apply(this._listbox._window,this.window.location);}else{if(!this._listbox._window.hidden)this._listbox._window.setPosition(this.window.location,$if(cEle,cEle,this._targetId));else this._listbox._window.show(this.window.location,$if(cEle,cEle,this._targetId));}}else{this._listbox._window.hide();}}});A5.EditButtonGroup=Class.create(A5.Edit,{initialize:function(settings){$u.o.assign(this,{theme:'',override:'base',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);A5.overrides.assign(this,'editButtonGroup',this.override);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+'.CUSTOMBUTTON.0';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(!A5.flags.isMobile&&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,A5.d.evnts.down,this._bmDown,this);if(!A5.flags.isMobile){$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,A5.d.evnts.up,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:'',override:'base',decouple:false,listbox:{theme:''},window:{theme:'',type:'popup',location:'dropdown'},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'}},autoShow:false,autoPosition:false,_container:{focusClassName:this.container.focusClassName,pressedClassName:this.container.pressedClassName,button:{pressedClassName:this.container.button.pressedClassName}},_selectionRequired:this.selectionRequired,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);}
if(!this._makeSelection&&this._selectionRequired)$e.execute($(this._targetId),'a5selectionclear');this._makeSelection=false;}});$u.o.assign(this.listbox,{loopNavigate:true,onClick:function(){if(!this.decouple)$(this._targetId).focus();setTimeout(Function('$e.execute($(\''+this._targetId+'\'),\'a5listselection\');'),1);}});A5.overrides.assign(this,'editCombo',this.override);var win=new A5.Window(this.window);this._listbox=new A5.ListBox(win.getWindowId('body'),[],this.listbox);this._listbox._window=win;this._listbox.decouple=this.decouple;if(this._listbox.calculateValue.constructor!=Function)this._listbox.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.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(!A5.flags.isMobile&&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,A5.d.evnts.click,this._bOnClick,this);if(!A5.flags.isMobile&&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,A5.d.evnts.down,Function('$acn(this,\''+this.container.button.pressedClassName+'\')'));if(!A5.flags.isMobile){$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,A5.d.evnts.up,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,A5.d.evnts.up,this._mUp,this);$e.add(ele,'a5listselection',this._listSelection,this);$e.add(ele,'a5selectionclear',this._srClear,this);if(this.selectionRequired&&this.selectionRequiredFilterMode!='progressive')ele.readOnly=true;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&&classInst._listbox._window.hidden)classInst._srClear({},classInst);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;if(classInst.decouple)classInst._oldIPoint=0;else{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.decouple)return;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){if(this.decouple)return;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);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=[].concat(data);this._populateList(dArr);}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.calculateValue(data[i])).substr(0,curValLen).toLowerCase()){dArr[dArr.length]=data[i];}}
this._populateList(dArr);}},_keyPress:function(e,classInst){if(classInst.decouple)return;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.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);if(classInst.decouple)classInst._editClearWatermark(ele);else 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();},_srClear:function(e,classInst){var val=$gvs(classInst._targetId);if(val!=classInst._initValue&&val!='')$svs(classInst._targetId,classInst._initValue);},_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');var showWin=false;if(dArr.length>0){showWin=true;this._listbox.populate(dArr);var data=this._editValSplit($(this._targetId),true);this._listbox.setValue(data.vals[data.selIndx].val);}else if(getFullList){showWin=true;this._listbox.populate([]);}
if(showWin){if(this.window.location.constructor==Array){if(!this._listbox._window.hidden)this._listbox._window.setPosition.apply(this._listbox._window,this.window.location);else this._listbox._window.show.apply(this._listbox._window,this.window.location);}else{if(!this._listbox._window.hidden)this._listbox._window.setPosition(this.window.location,$if(cEle,cEle,this._targetId));else this._listbox._window.show(this.window.location,$if(cEle,cEle,this._targetId));}}else this._listbox._window.hide();}});A5.EditTree=Class.create(A5.Edit,{initialize:function(data,settings){$u.o.assign(this,{override:'base',decouple:false,tree:{theme:''},window:{theme:'',type:'popup',location:'dropdown'},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);A5.overrides.assign(this,'editTree',this.override);this.setData(data);$u.o.assign(this.window,{title:{show:false},body:{content:{type:'blank'},style:{padding:'0px',overflow:'auto'}},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,decouple:this.decouple,onNodeClick:function(data){if(!data.children){var ele=$(this._targetId)
if(!this.decouple)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(!A5.flags.isMobile&&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,A5.d.evnts.click,this._bOnClick,this);if(!A5.flags.isMobile&&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,A5.d.evnts.down,Function('$acn(this,\''+this.container.button.pressedClassName+'\')'));if(!A5.flags.isMobile){$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,A5.d.evnts.up,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,A5.d.evnts.up,this._mUp,this);$e.add(ele,'a5treeselection',this._treeSelection,this);if(this.selectionRequired)ele.readOnly=true;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;if(classInst.decouple)classInst._oldIPoint=0;else{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){if(classInst.decouple)return;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){if(this.decouple)return;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.decouple)return;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);var cEle=$(this._targetId+'.CONTAINER');if(this.window.location.constructor==Array){if(!this._tree._window.hidden)this._tree._window.setPosition.apply(this._tree._window,this.window.location);else this._tree._window.show.apply(this._tree._window,this.window.location);}else{if(!this._tree._window.hidden)this._tree._window.setPosition(this.window.location,$if(cEle,cEle,this._targetId));else this._tree._window.show(this.window.location,$if(cEle,cEle,this._targetId));}
this._tree.setValue(data.vals[data.selIndx].val);},_treeSelection:function(e,classInst){if(classInst._tree.value.length!=0){var ele=$(classInst._targetId);if(classInst.decouple)classInst._editClearWatermark(ele);else 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,{override:'base',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);A5.overrides.assign(this,'button',this.override);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);if(A5.flags.supportsMouse){$e.remove(ele,'mouseover',this._mOver);$e.remove(ele,'mouseout',this._mOut);}
$e.remove(ele,A5.d.evnts.down,this._mDown);$e.remove(ele,A5.d.evnts.up,this._mUp);$e.remove(ele,A5.d.evnts.click,this._mClick);if(A5.flags.supportsMouse){$e.add(ele,'mouseover',this._mOver,this);$e.add(ele,'mouseout',this._mOut,this);}
$e.add(ele,A5.d.evnts.down,this._mDown,this);$e.add(ele,A5.d.evnts.up,this._mUp,this);$e.add(ele,A5.d.evnts.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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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,{override:'base',type:'two-state',keepPressed:true,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);A5.overrides.assign(this,'buttonToggle',this.override);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'||typeof val=='string')){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!=''&&this.keepPressed)$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(classInst.pressedClassName!='')$rcn(this,classInst.pressedClassName);if($ga(this,'A5ButtonState')=='true'||classInst.type=='multi-state'){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!=''&&classInst.keepPressed)$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,{override:'base',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:'',animation:{show:{type:'',duration:500},hide:{type:'',duration:500}},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);A5.overrides.assign(this,'buttonDropdown',this.override);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);if(A5.flags.supportsMouse){$e.remove(ele,'mouseover',this._mOver);$e.remove(ele,'mouseout',this._mOut);}
$e.remove(ele,A5.d.evnts.move,this._mMove);$e.remove(ele,A5.d.evnts.down,this._mDown);$e.remove(ele,A5.d.evnts.up,this._mUp);$e.remove(ele,A5.d.evnts.click,this._mClick);if(A5.flags.supportsMouse){$e.add(ele,'mouseover',this._mOver,this);$e.add(ele,'mouseout',this._mOut,this);}
$e.add(ele,A5.d.evnts.move,this._mMove,this);$e.add(ele,A5.d.evnts.down,this._mDown,this);$e.add(ele,A5.d.evnts.up,this._mUp,this);$e.add(ele,A5.d.evnts.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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" />';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.ButtonList=Class.create();A5.ButtonList.prototype={initialize:function(contId,btns,settings){this.contId=contId;$u.o.assign(this,{override:'base',inputId:'',multiple:false,button:{keepPressed:true,style:0,className:'',firstClassName:'',lastClassName:'',middleClassName:'',hoverClassName:'',pressedClassName:'',disabledClassName:'',iconStyle:0,iconClassName:'',layout:'icon text'},onSelect:0,onClick:0,_hasIcon:false});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'buttonList');$u.o.assign(this,settings);A5.overrides.assign(this,'buttonList',this.override);if(this.button.layout.search('icon')!=-1)this._hasIcon=true;this.selection=[];this.value=[];this.populate(btns);},setValue:function(val){var indx=-1;this.selection=[];if(val.constructor==Array){for(var i=0;i<val.length;i++){indx=this._valToIndx(val[i]);if(indx!=-1)this.selection.push(indx);}}else{indx=this._valToIndx(val);if(indx!=-1)this.selection=[indx];}
this._setState($(this.contId));if(this.inputId!=''){$(this.inputId).value=this.value.join('\n');$e.execute(this.inputId,'change');}
if(this.onSelect.constructor==Function)this.onSelect();},setDisabled:function(val,dis){var indx=this._valToIndx(val);if(indx>=0&&indx<this._btns.length){var cEle=$(this.contId);var eles=cEle.getElementsByTagName('button');eles[indx].disabled=dis;this._setState(cEle);}},setDisplay:function(val,dis){var indx=this._valToIndx(val);if(indx>=0&&indx<this._btns.length){var cEle=$(this.contId);var eles=cEle.getElementsByTagName('button');if(dis)eles[indx].style.display='';else eles[indx].style.display='none';this._setState(cEle);}},populate:function(btns){$(this.contId).innerHTML='';this._btns=[];this.appendButtons(btns);},appendButtons:function(btns){var cEle=$(this.contId);for(var i=0;i<btns.length;i++){var btn=document.createElement('button');btn.id=A5.u.getUniqueId();btn.className=this.button.className;if(typeof this.button.style=='object'||typeof this.button.style=='string')$ss(btn,this.button.style);cEle.appendChild(btn);this._setContent(btn,btns[i]);this._btns.push(btns[i]);}
this._setState(cEle);},insertButtons:function(val,btns){var indx=this._valToIndx(val);if(indx>=0&&indx<this._btns.length){var cEle=$(this.contId);var eles=cEle.getElementsByTagName('button');var nEle=eles[indx];for(var i=0;i<btns.length;i++){var btn=document.createElement('button');btn.id=A5.u.getUniqueId();btn.className=this.button.className;if(typeof this.button.style=='object'||typeof this.button.style=='string')$ss(btn,this.button.style);cEle.insertBefore(btn,nEle);this._setContent(btn,btns[i]);nEle=btn.nextSibling;this._btns.splice(indx+i,0,btns[i]);}
for(var i=0;i<this.selection.length;i++){if(this.selection[i]>=indx)this.selection[i]+=btns.length;}
this._setState(cEle);}},removeButton:function(val){var cEle=$(this.contId);var indx=this._valToIndx(val);var eles=cEle.getElementsByTagName('button');if(indx!=-1){cEle.removeChild(eles[indx]);this._btns.splice(indx,1);for(var i=0;i<this.selection.length;i++){if(this.selection[i]>=indx)this.selection[i]--;}
this._setState(cEle);}},updateButton:function(val,btn){var cEle=$(this.contId);var indx=this._valToIndx(val);var eles=cEle.getElementsByTagName('button');if(indx!=-1){this._setContent(eles[indx],btn,true);this._setState(cEle);}},_valToIndx:function(val){if(typeof val=='number')return val;for(var i=0;i<this._btns.length;i++){if(this._btns[i].value==val)return i;}
return-1;},_setState:function(cEle){var eles=cEle.getElementsByTagName('button');this.value=[];A5.u.element.cssGroup(eles,this.button);for(var i=0;i<eles.length;i++){if(eles[i].disabled)$acn(eles[i],this.button.disabledClassName);if($u.a.find(this.selection,i)!=-1){$sa(eles[i],'A5ButtonState','true');if(this.button.keepPressed)$acn(eles[i],this.button.pressedClassName);else $rcn(eles[i],this.button.pressedClassName);this.value.push(this._btns[i].value);}else{$sa(eles[i],'A5ButtonState','');$rcn(eles[i],this.button.pressedClassName);}
var iEle=$(eles[i].id+'.ICON');if(iEle){if(eles[i].disabled&&this._btns[i].disabledIcon!=''){iEle.src=this._btns[i].disabledIcon;}else if($ga(eles[i],'A5ButtonState')=='true'&&this._btns[i].pressedIcon!=''){iEle.src=this._btns[i].pressedIcon;}else{iEle.src=this._btns[i].icon;}}
$sa(eles[i],'A5ButtonIndex',''+i);}},_setContent:function(ele,bc){var update=arguments[2];$u.o.assign(bc,this._bDef,true);if(bc.value=='')bc.value=bc.html;if(bc.icon!=''&&this.button.layout.search('icon')!=-1)bc.hasIcon=true;var iHTML=bc.hasIcon?'<img id="'+ele.id+'.ICON" src="'+bc.icon+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" class="'+this.button.iconClassName+'" style="vertical-align: middle; border: none;" />':'';var fHTML='';if(this.button.layout=='icon')fHTML=iHTML;else if(this.button.layout=='text')fHTML=bc.html;else if(this.button.layout=='icon text')fHTML=iHTML+' '+bc.html;else if(this.button.layout=='text icon')fHTML=bc.html+' '+iHTML;else if(this.button.layout=='icon/text')fHTML=iHTML+'<br />'+bc.html;else if(this.button.layout=='text/icon')fHTML=bc.html+'<br />'+iHTML;ele.innerHTML=fHTML;ele.title=bc.tip;$sa(ele,'A5ButtonIcon',bc.icon);$sa(ele,'A5ButtonIconHover',bc.hoverIcon);$sa(ele,'A5ButtonIconPressed',bc.pressedIcon);$sa(ele,'A5ButtonIconDisabled',bc.disabledIcon);var iEle=$(ele.id+'.ICON');if(typeof this.button.iconStyle=='object'||typeof this.button.iconStyle=='string')$ss(iEle,this.button.iconStyle);if(!update){if(A5.flags.supportsMouse){$e.add(ele,'mouseover',Function('$acn(this,\''+this.button.hoverClassName+'\');var iEle = $(this.id+\'.ICON\'); if(iEle){ if(this.disabled && $ga(this,\'A5ButtonIconDisabled\') != \'\'){ iEle.src = $ga(this,\'A5ButtonIconDisabled\'); } else if($ga(this,\'A5ButtonState\') == \'true\' && $ga(this,\'A5ButtonIconPressed\') != \'\'){ iEle.src = $ga(this,\'A5ButtonIconPressed\'); } else if($ga(this,\'A5ButtonIconHover\') != \'\'){ iEle.src = $ga(this,\'A5ButtonIconHover\'); }}'));$e.add(ele,'mouseout',Function('$rcn(this,\''+this.button.hoverClassName+'\'); if($ga(this,\'A5ButtonState\') != \'true\') $rcn(this,\''+this.button.pressedClassName+'\');var iEle = $(this.id+\'.ICON\'); if(iEle){ if(this.disabled && $ga(this,\'A5ButtonIconDisabled\') != \'\'){ iEle.src = $ga(this,\'A5ButtonIconDisabled\');} else if($ga(this,\'A5ButtonState\') == \'true\' && $ga(this,\'A5ButtonIconPressed\') != \'\'){ iEle.src = $ga(this,\'A5ButtonIconPressed\');} else{ iEle.src = $ga(this,\'A5ButtonIcon\');}}'));}
$e.add(ele,'abstractdown',Function('$acn(this,\''+this.button.pressedClassName+'\');var iEle = $(this.id+\'.ICON\'); if(iEle){ if(this.disabled && $ga(this,\'A5ButtonIconDisabled\') != \'\'){ iEle.src = $ga(this,\'A5ButtonIconDisabled\');} else if($ga(this,\'A5ButtonState\') == \'true\' && $ga(this,\'A5ButtonIconPressed\') != \'\'){ iEle.src = $ga(this,\'A5ButtonIconPressed\');} else{ iEle.src = $ga(this,\'A5ButtonIcon\');}}'));$e.add(ele,'abstractclick',this._onClick,this);}},_onClick:function(e,classInst){var indx=Number($ga(this,'A5ButtonIndex'));if(classInst.multiple){var curSelIndx=$u.a.find(classInst.selection,indx);if(curSelIndx==-1)classInst.selection.push(indx);else classInst.selection.splice(curSelIndx,1);classInst._setState(this.parentNode);}else{classInst.selection=[indx];classInst._setState(this.parentNode);}
if(classInst.inputId!=''){$(classInst.inputId).value=classInst.value.join('\n');$e.execute(classInst.inputId,'change');}
if(classInst.onClick.constructor==Function)classInst.onClick();if(classInst.onSelect.constructor==Function)classInst.onSelect();},_bDef:{value:'',html:'',icon:'',hoverIcon:'',pressedIcon:'',disabledIcon:'',tip:''}}
A5.Menubar=Class.create({initialize:function(contId,data,settings){if(!$(contId))return false;this.contId=contId;$u.o.assign(this,{theme:'',override:'base',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);A5.overrides.assign(this,'menubar',this.override);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('div');ele.className=this._gDef(this.data[i].className,this.item.className);var html=this.data[i].html;if(this.data[i].icon!='')html='<img src="'+this.data[i].icon+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" /> '+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,A5.d.evnts.down,this._iMDown,this);$e.add(ele,A5.d.evnts.up,this._iMUp,this);$e.add(ele,A5.d.evnts.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&&!classInst.data[indx].disabled){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&&!classInst.data[indx].disabled){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,{override:'base',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:''},pointer:{show:false,location:'auto',size:10,upClassName:'',leftClassName:'',downClassName:'',rightClassName:''},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);A5.overrides.assign(this,'menu',this.override);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);var setPointerHandled=false
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(),$if(this.pointer.show,this.pointer.size,0));if(this.pointer.show)this._setPointer(val1,mEle,pEle);setPointerHandled=true;}}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;}
if(!setPointerHandled&&this.pointer.show)this._setPointer(val1,mEle,false);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,'mousedown',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,'mousedown',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,'mousedown',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;var pointerHTML='';if(level==0)pointerHTML='<div id="'+this._menuId+'.POINTER" style="display: none; position: absolute;"></div>';if(micShow){mEle.innerHTML='<div class="'+this.iconColumn.className+'"><div class="'+this.innerClassName+'"></div></div>'+pointerHTML;var mcEle=mEle.firstChild.firstChild;}else{mEle.innerHTML='<div class="'+this.innerClassName+'"></div>'+pointerHTML;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,A5.d.evnts.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('div');ele.className=this._gDef(item.className,this.item.className);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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" style="border: none;" align="top" />','<img id="'+item._id+'.ICON" src="'+this.item.radioImage+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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)+0.49);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('div');aEle.className=className;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,A5.d.evnts.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 if(rows==1)break;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,A5.d.evnts.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;},_setPointer:function(val,mEle,pEle){var pntEle=$(this._menuId+'.POINTER');pntEle.style.top='';pntEle.style.left='';var loc='up';var pEleOffset=0;var mEleOffset=0;if(this.pointer.location=='up'||this.pointer.location=='down'||this.pointer.location=='left'||this.pointer.location=='right'){loc=this.pointer.location;}else if(val.toLowerCase()=='dropdown'||val.toLowerCase()=='dropdown-right'){if($gpt(mEle)>$gpt(pEle))loc='up';else loc='down';}else if(val.toLowerCase()=='flyout'||val.toLowerCase()=='flyout-bottom'){if($gpl(mEle)>$gpl(pEle))loc='left';else loc='right';}
if(loc=='up'||loc=='down'){if(loc=='up'){pntEle.className=this.pointer.upClassName;pntEle.style.display='';}else{pntEle.className=this.pointer.downClassName;pntEle.style.display='';}
pntEle.style.left='50%';if(pEle){var mEleOffset=$gpl(mEle);var pEleOffset=$gpl(pEle);var mEleOffsetMax=mEleOffset+mEle.offsetWidth-this.pointer.size;var pEleOffsetMax=pEleOffset+pEle.offsetWidth-this.pointer.size;mEleOffset+=this.pointer.size;pEleOffset+=this.pointer.size;var tOffsetStart=Math.min(Math.max(mEleOffset,pEleOffset),mEleOffsetMax);var tOffsetEnd=Math.max(Math.min(mEleOffsetMax,pEleOffsetMax),mEleOffset);var tOffset=(tOffsetStart-mEleOffset)+this.pointer.size+Math.round((tOffsetEnd-tOffsetStart)/2);pntEle.style.left=tOffset+'px';}}else if(loc=='left'||loc=='right'){if(loc=='left'){pntEle.className=this.pointer.leftClassName;pntEle.style.display='';}else{pntEle.className=this.pointer.rightClassName;pntEle.style.display='';}
pntEle.style.top='50%';if(pEle){var mEleOffset=$gpt(mEle);var pEleOffset=$gpt(pEle);var mEleOffsetMax=mEleOffset+mEle.offsetHeight-this.pointer.size;var pEleOffsetMax=pEleOffset+pEle.offsetHeight-this.pointer.size;mEleOffset+=this.pointer.size;pEleOffset+=this.pointer.size;var tOffsetStart=Math.min(Math.max(mEleOffset,pEleOffset),mEleOffsetMax);var tOffsetEnd=Math.max(Math.min(mEleOffsetMax,pEleOffsetMax),mEleOffset);var tOffset=(tOffsetStart-mEleOffset)+this.pointer.size+Math.round((tOffsetEnd-tOffsetStart)/2);pntEle.style.top=tOffset+'px';}}else pntEle.style.display='none';},_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:'',edit:{className:'',container:{className:''}},icon:'',global:{contId:'',hoverClassName:'',hoverInputClassName:''}},true);$u.o.assign(this,settings);if(typeof this.inputClassName!='undefined')this.edit.className=this.inputClassName;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';this._editPrep(this._e[i].id,false);}}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);this._editPrep(this._e[i].id,false);$(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';this._editPrep(this._e[i].id,false);}}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);this._editPrep(this._e[i].id,false);}}else{for(var i=0;i<this._e.length;i++){$(this._e[i].id+'.ERRORDIV').style.display='none';this._editPrep(this._e[i].id,false);}}
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);this._editPrep(iEle,true);}else{var ele=document.createElement('span');ele.id=errorId+'.ERRORSPAN';ele.innerHTML=errorMsg;ele.className=this.className;var iEle=$(errorId);if(iEle.tagName){this._editPrep(iEle,true,ele);}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);this._editPrep(iEle,true);}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);this._editPrep(iEle,true);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);this._editPrep(iEle,true);}else{var iconEle=document.createElement('img');iconEle.src=this.icon;iconEle.id=errorId+'.ERRORTIPICON'
$ss(iconEle,'vertical-align: middle; margin-left: 2px;');var ele=$(errorId+'.ERRORTIPICONDIV');if(!ele){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){this._editPrep(iEle,true,iconEle);}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);this._editPrep(iEle,true);$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);this._editPrep(iEle,true);}else{var ele=document.createElement('div');ele.id=errorId+'.ERRORDIV';ele.innerHTML=errorMsg;ele.className=this.className;var iEle=$(errorId);if(iEle.tagName){this._editPrep(iEle,true,ele);}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';this._editPrep(this._e[indx].id,false);}else if(this.type=='tip'){$e.remove($(this._e[indx].id),'mouseover',this._mover);$e.remove($(this._e[indx].id),'mouseout',this._mout);this._editPrep(this._e[indx].id,false);$(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';this._editPrep(this._e[indx].id,false);}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);this._editPrep(this._e[indx].id,false);}else{$(this._e[indx].id+'.ERRORDIV').style.display='none';this._editPrep(this._e[indx].id,false);}
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();},_editPrep:function(ele,val){ele=$(ele);var eleToAdd=typeof arguments[2]!='undefined'?arguments[2]:false;var tagName=ele.tagName;if(typeof tagName!='string')return false;tagName=tagName.toLowerCase();var tagType=ele.type;if(typeof tagType=='string')tagType=tagType.toLowerCase();if($(ele.id+'.CONTAINER')&&tagName=='input'&&tagType!='checkbox'&&tagType!='radio'){if(val)$acn(ele.id+'.CONTAINER',this.edit.container.className);else $rcn(ele.id+'.CONTAINER',this.edit.container.className);if(eleToAdd)$(ele.id+'.CONTAINER').parentNode.insertBefore(eleToAdd,$(ele.id+'.CONTAINER').nextSibling);}else{if(val){if(tagType!='checkbox'&&tagType!='radio')$acn(ele,this.edit.className);}else $rcn(ele,this.edit.className);if(eleToAdd)ele.parentNode.insertBefore(eleToAdd,ele.nextSibling);}},_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,{override:'base',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);A5.overrides.assign(this,'datePicker',this.override);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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" align="top" /></div>','   <div id="{BASEID}.DATEPICKER.NEXTBUTTON" style="float: right;"><img src="'+this.navigator.header.nextIcon+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" align="top" /></div>','   <div id="{BASEID}.DATEPICKER.MONTHYEARBUTTONS"><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH" class="'+this.navigator.header.item.className+'"></a> <a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.0" class="'+this.navigator.panel.item.className+'">'+this.months[0]+'</a></td>','      <td style="width:34%"><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.1" class="'+this.navigator.panel.item.className+'">'+this.months[1]+'</a></td>','      <td style="width:33%"><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.2" class="'+this.navigator.panel.item.className+'">'+this.months[2]+'</a></td>','     </tr>','     <tr>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.3" class="'+this.navigator.panel.item.className+'">'+this.months[3]+'</a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.4" class="'+this.navigator.panel.item.className+'">'+this.months[4]+'</a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.5" class="'+this.navigator.panel.item.className+'">'+this.months[5]+'</a></td>','     </tr>','     <tr>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.6" class="'+this.navigator.panel.item.className+'">'+this.months[6]+'</a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.7" class="'+this.navigator.panel.item.className+'">'+this.months[7]+'</a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.8" class="'+this.navigator.panel.item.className+'">'+this.months[8]+'</a></td>','     </tr>','     <tr>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.9" class="'+this.navigator.panel.item.className+'">'+this.months[9]+'</a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.MONTH.10" class="'+this.navigator.panel.item.className+'">'+this.months[10]+'</a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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;" />','      </td>','     </tr>','     <tr>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.PREVDEC" class="'+this.navigator.panel.item.className+'">&laquo;</a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.0" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.1" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.2" class="'+this.navigator.panel.item.className+'"></a></td>','     </tr>','     <tr>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.3" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.4" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.5" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.6" class="'+this.navigator.panel.item.className+'"></a></td>','     </tr>','     <tr>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.7" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.8" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" tabindex="-1" id="{BASEID}.DATEPICKER.YEAR.9" class="'+this.navigator.panel.item.className+'"></a></td>','      <td><a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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,A5.d.evnts.click,this._todayButton,this,true);$e.add(ele,'click',function(e){$e.preventDefault(e);return false;});if(!A5.flags.isMobile){$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,A5.d.evnts.click,this._dClick,this);$e.add(eles,'click',function(e){$e.preventDefault(e);return false;});if(!A5.flags.isMobile){$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');if(!A5.flags.isMobile){$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');if(!A5.flags.isMobile){$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',A5.d.evnts.click,this._monthPane,this,true);$e.add(this.contId+'.DATEPICKER.MONTH','click',function(e){$e.preventDefault(e);return false;});$e.add(this.contId+'.DATEPICKER.YEAR',A5.d.evnts.click,this._yearPane,this,true);$e.add(this.contId+'.DATEPICKER.YEAR','click',function(e){$e.preventDefault(e);return false;});if(!A5.flags.isMobile){$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',A5.d.evnts.click,this._prevButton,this,true);$e.add(this.contId+'.DATEPICKER.PREVBUTTON','click',function(e){$e.preventDefault(e);return false;});$e.add(this.contId+'.DATEPICKER.NEXTBUTTON',A5.d.evnts.click,this._nextButton,this,true);$e.add(this.contId+'.DATEPICKER.NEXTBUTTON','click',function(e){$e.preventDefault(e);return false;});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',A5.d.evnts.click,this._inputYear,this);$e.add(this.contId+'.DATEPICKER.YEAR.INPUTCOMMIT','click',function(e){$e.preventDefault(e);return false;});$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'],A5.d.evnts.click,this._monthClick,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',function(e){$e.preventDefault(e);return false;});$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'],A5.d.evnts.click,this._yearClick,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',function(e){$e.preventDefault(e);return false;});$e.add(this.contId+'.DATEPICKER.YEAR.PREVDEC',A5.d.evnts.click,this._prevDecade,this);$e.add(this.contId+'.DATEPICKER.YEAR.PREVDEC','click',function(e){$e.preventDefault(e);return false;});$e.add(this.contId+'.DATEPICKER.YEAR.NEXTDEC',A5.d.evnts.click,this._nextDecade,this);$e.add(this.contId+'.DATEPICKER.YEAR.NEXTDEC','click',function(e){$e.preventDefault(e);return false;});this.refresh();}}
A5.TimePicker=Class.create();A5.TimePicker.prototype={initialize:function(contId,settings){this.contId=contId;$u.o.assign(this,{override:'base',inputId:'',format:'h:0m am',switchYear:50,time:0,hours:0,minutes:0,seconds:0,className:'',style:0,edit:{className:'',buttonClassName:'',buttonImage:'',menu:{hourColumns:12,minuteColumns:10,secondColumns:10}},meridianClassName:'',mouseWheelEdit:true,selectionRequired:false,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);A5.overrides.assign(this,'timePicker',this.override);$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',columns:this.edit.menu.hourColumns,name:'hours',variable:'hours',data:this._getHours()},{type:'radio-group',columns:this.edit.menu.minuteColumns,name:'minutes',variable:'minutes',data:this._getMinutes()},{type:'radio-group',columns:this.edit.menu.secondColumns,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(){debugger
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();var roAttr='';if(this.selectionRequired)roAttr=' readonly="readonly"';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"'+roAttr+' /></td>','  <td>:</td>','  <td><input id="'+this.contId+'.M" class="'+this.edit.className+'" size="2" maxlength="2"'+roAttr+' /></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><div id="'+this.contId+'.A" class="'+this.meridianClassName+'">AM</div></td>');html=html.concat([' </tr>',' <tr>','  <td><div tabindex="-1" id="'+this.contId+'.H.DD" class="'+this.edit.buttonClassName+'" style="font: 0pt arial;"><img src="'+this.edit.buttonImage+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" style="border: none;" /></div></td>','  <td style="font-size: 0px;"></td>','  <td><div tabindex="-1" id="'+this.contId+'.M.DD" class="'+this.edit.buttonClassName+'" style="font: 0pt arial;"><img src="'+this.edit.buttonImage+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" style="border: none;" /></div></td>']);if(this._parsedFormat.secondsMode!='none'){html=html.concat(['  <td></td>','  <td><div tabindex="-1" id="'+this.contId+'.S.DD" class="'+this.edit.buttonClassName+'" style="font: 0pt arial;"><img src="'+this.edit.buttonImage+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" style="border: none;" /></div></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'],A5.d.evnts.click,this._ddShow,this);if(this._parsedFormat.hasMeridian)$e.add(this.contId+'.A',A5.d.evnts.click,this._mClick,this);this.refresh();}}
A5.DateTimePicker=Class.create();A5.DateTimePicker.prototype={initialize:function(contId,settings){this.contId=contId;$u.o.assign(this,{override:'base',inputId:'',format:'MM/dd/yyyy h:0m am',switchYear:50,date:0,combinedContainer:{layout:'time/date',className:''},datePicker:{disabledDates:{}},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);A5.overrides.assign(this,'dateTimePicker',this.override);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);},refresh:function(){$u.o.assign(this._dp.disabledDates,this.datePicker.disabledDates);this._dp.refresh();},_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:'',override:'base',decouple:false,dateTime:{theme:''},window:{theme:'',type:'popup',location:'dropdown',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);A5.overrides.assign(this,'editDateTime',this.override);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;}}}}
this._hasTCommit=hasTCommit;this._hasBCommit=hasBCommit;$u.o.assign(this.window,{decouple:this.decouple,title:{show:false},body:{content:{type:'blank'}},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,{decouple:this.decouple,onChange:function(){var ele=$(this._targetId)
if(!this.decouple)ele.focus();$e.execute(ele,'a5datetimeselection');}});this._editPrepare();this._value='';this._oldIPoint=0;},_createDropdown:function(){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(this._hasTCommit)this._dateTime._window.setDisplay('title',true);if(this._hasBCommit)this._dateTime._window.setDisplay('buttons',true);this._dateTime.onChange=0;}else{if(this._hasTCommit)this._dateTime._window.setDisplay('title',false);if(this._hasBCommit)this._dateTime._window.setDisplay('buttons',false);}
this._dateTime._window.addAction('commit',function(){var ele=$(this._targetId);if(!this.decouple)ele.focus();$e.execute(ele,'a5datetimeselection');});},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(!A5.flags.isMobile&&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,A5.d.evnts.click,this._bOnClick,this);if(!A5.flags.isMobile&&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,A5.d.evnts.down,Function('$acn(this,\''+this.container.button.pressedClassName+'\')'));if(!A5.flags.isMobile){$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,A5.d.evnts.up,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,A5.d.evnts.up,this._mUp,this);$e.add(ele,'a5datetimeselection',this._dtSelection,this);if(this.selectionRequired)ele.readOnly=true;this._editBind(ele);$sa(ele,'A5ControlBound','true');},_focus:function(e,classInst){if(!classInst._dateTime)classInst._createDropdown();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){if(!classInst._dateTime)classInst._createDropdown();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){if(!classInst._dateTime)classInst._createDropdown();$e.stopEvent(e);var tEleId=$ga(this,'A5TargetInput');var ele=$(tEleId);if(ele.disabled)return false;if(classInst.decouple)classInst._oldIPoint=0;else{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){if(this.decouple)return;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.decouple)return;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){if(!this._dateTime)this._createDropdown();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();var cEle=$(this._targetId+'.CONTAINER');if(this.window.location.constructor==Array){if(!this._dateTime._window.hidden)this._dateTime._window.setPosition.apply(this._dateTime._window,this.window.location);else this._dateTime._window.show.apply(this._dateTime._window,this.window.location);}else{if(!this._dateTime._window.hidden)this._dateTime._window.setPosition(this.window.location,$if(cEle,cEle,this._targetId));else this._dateTime._window.show(this.window.location,$if(cEle,cEle,this._targetId));}},_dtSelection:function(e,classInst){if(classInst._dateTime.date.getDate!=0){var ele=$(classInst._targetId);if(classInst.decouple)classInst._editClearWatermark(ele);else 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;if(this.decouple)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:'',override:'base',style:0,className:'',globalProperties:{}});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'toolbar');$u.o.assign(this,settings);A5.overrides.assign(this,'toolbar',this.override);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)||$ga(ctrlId,'A5ISHTMLEDITOR')=='true')return false;this.ctrlId=ctrlId;this._htmlEdId='A5HTMLEDITOR'+this._htmlEdIndx[0];this._htmlEdIndx[0]++;$u.o.assign(settings,{theme:'',override:'base',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);A5.overrides.assign(this,'htmlEditor',this.override);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]=='link'){var url=prompt('Link URL','');if(url!=null)this._edInsertHTML('a',url,{href:url});}else{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);$sa(tEle,'A5ISHTMLEDITOR','true');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);$e.add(this._iEle.contentWindow,'contextmenu',function(e){$e.stopEvent(e);return false;});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);$e.add(this._eDoc,'contextmenu',function(e){$e.stopEvent(e);return false;});}
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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" />','')+$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'&&this._edSelBookmark!=''){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(''));}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!=String(this._eDoc.body.innerHTML)){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');}}),new A5.Button({theme:this.theme+':toolbar',tip:'Insert Link',layout:'icon',icon:this.icons.insertLink,onClick:function(classInst){A5.commandHandler.action(classInst.htmlEdId,'insert:link');}})];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:'',override:'base',className:'',window:{theme:'',type:'modeless',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-(($gpt(bEle)-$gpt(bEle.parentNode))*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});A5.overrides.assign(this,'popupHTMLEditor',this.override);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){$e.stopPropagation(e);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){$e.stopPropagation(e);classInst.edit($ga(this,'A5TargetID'));},this);$sa(ele,'A5ControlBound','true');}}
A5.Slider=Class.create();A5.Slider.prototype={initialize:function(contId,settings){this.contId=contId;$u.o.assign(this,{theme:'',override:'base',inputId:'',separator:'..',type:'',direction:'',min:0,max:100,step:1,className:'',innerClassName:'',handle:{show:true,className:'',hoverClassName:'',selectedClassName:'',minClassName:'',maxClassName:''},range:{show:true,className:'',hoverClassName:'',selectedClassName:''},value:0,onChange:0,onSlide:0});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'slider');$u.o.assign(this,settings);A5.overrides.assign(this,'slider',this.override);this._coor={};this._sliderSize=0;this._sliderUnitPrePx=0;this._val1=0;this._val2=0;this._tVal1=0;this._tVal2=0;this._rEle=0;this._hEle1=0;this._hEle2=0;this._cHandle='';this._cfHandle='';this._dPlace=0;this._dragFlag=false;this._initRender();},setValue:function(val){if(this.type=='range'){if(typeof val=='string')val=val.split(this.separator);if(val.constructor==Array){this._val1=$u.s.toNum(''+val[0]);this._val2=$u.s.toNum(''+val[1]);}else this._val1=$u.s.toNum(''+val);}else this._val1=$u.s.toNum(''+val);this._val1=Math.max(Math.min(this._val1,this.max),this.min);this._val2=Math.max(Math.min(this._val2,this.max),this.min);this._cfHandle='';this._refresh();},refresh:function(){this.setValue(this.value);},_sClick:function(e){if(this._dragFlag)return true;var vps=AUI.u.getVPScroll();var coor=this._getCoors(e);var sEle=$(this.contId+'.SLIDER');var clickLoc=(coor.clientX+vps.x)-$gpl(sEle);var sliderSize=sEle.offsetWidth;var sliderUnitPrePx=(this.max-this.min)/sliderSize;var val=(Math.round((sliderUnitPrePx*clickLoc)/this.step)*this.step)+this.min;var dPlace=0;if(Math.round(this.step)!=this.step)dPlace=Math.pow(10,String(this.step).split('.')[1].length);if(dPlace>0)val=Math.round(val*dPlace)/dPlace;var cfHandle='min-value';if(this.type=='range'){if(val>this._val2){this._val2=val;cfHandle='max-value';}else if(val<this._val1)this._val1=val;else if(Math.abs(val-this._val1)>Math.abs(val-this._val2)){this._val2=val;cfHandle='max-value';}else this._val1=val;}else{this._val1=val;cfHandle='value';}
this._cfHandle=cfHandle;this._refresh();},_dragStart:function(e,classInst){$e.stopEvent(e);classInst._coor=classInst._getCoors(e);classInst._sliderSize=$(classInst.contId+'.SLIDER').offsetWidth;classInst._sliderUnitPrePx=(classInst.max-classInst.min)/classInst._sliderSize;classInst._dPlace=0;if(Math.round(classInst.step)!=classInst.step)classInst._dPlace=Math.pow(10,String(classInst.step).split('.')[1].length);if(A5.flags.isMobile){$e.add(document,'touchmove',classInst._dragMove,classInst);$e.add(document,'touchend',classInst._dragEnd,classInst);}else{$e.add(document,'mousemove',classInst._dragMove,classInst);$e.add(document,'mouseup',classInst._dragEnd,classInst);}
classInst._cHandle=this.id.split('.').pop();if(classInst._cHandle=='SLIDERHANDLE1'&&classInst.type=='range')classInst._cfHandle='min-value';else if(classInst._cHandle=='SLIDERHANDLE2')classInst._cfHandle='max-value';else if(classInst._cHandle=='SLIDERHANDLE1')classInst._cfHandle='value';else classInst._cfHandle='range';if(classInst._cfHandle=='range'&&classInst.range.selectedClassName!=''){$acn(this,classInst.range.selectedClassName);if(classInst.handle.selectedClassName!=''){$acn(classInst.contId+'.SLIDERHANDLE1',classInst.handle.selectedClassName);$acn(classInst.contId+'.SLIDERHANDLE2',classInst.handle.selectedClassName);}}else if(classInst.handle.selectedClassName!='')$acn(this,classInst.handle.selectedClassName);return false;},_dragMove:function(e,classInst){$e.stopEvent(e);classInst._dragFlag=true;var coor=classInst._getCoors(e);var dif=coor.clientX-classInst._coor.clientX;var val1=classInst._val1;var val2=classInst._val2;if(classInst._cHandle=='SLIDERHANDLE1'){val1=val1+(Math.round((dif*classInst._sliderUnitPrePx)/classInst.step)*classInst.step);if(classInst.type=='range')val1=Math.min(val1,val2);}else if(classInst._cHandle=='SLIDERHANDLE2'){var val2=val2+(Math.round((dif*classInst._sliderUnitPrePx)/classInst.step)*classInst.step);val2=Math.max(val2,val1);val2=Math.min(val2,classInst.max);}else if(classInst._cHandle=='SLIDERRANGE'){var valDif=(Math.round((dif*classInst._sliderUnitPrePx)/classInst.step)*classInst.step);var handled=false;if(valDif<0){if((val1+valDif)-classInst.min<0){val2=classInst.min+(val2-val1);val1=classInst.min;handled=true;}}else{if(classInst.max-(val2+valDif)<0){val1=classInst.max-(val2-val1);val2=classInst.max;handled=true;}}
if(!handled){val1=val1+valDif;val2=val2+valDif;}}
val1=Math.max(val1,classInst.min);val1=Math.min(val1,classInst.max);if(classInst._dPlace>0){val1=Math.round(val1*classInst._dPlace)/classInst._dPlace;val2=Math.round(val2*classInst._dPlace)/classInst._dPlace;}
classInst._hEle1.style.left=((100/(classInst.max-classInst.min))*(val1-classInst.min))+'%';classInst._hEle2.style.left=((100/(classInst.max-classInst.min))*(val2-classInst.min))+'%';if(classInst.type=='range'){classInst._rEle.style.left=classInst._hEle1.style.left;classInst._rEle.style.width=((100/(classInst.max-classInst.min))*(val2-val1))+'%';if(classInst.onSlide.constructor==Function)classInst.onSlide.call(classInst,{value:[val1,val2],handle:classInst._cfHandle});}else{classInst._rEle.style.width=((100/(classInst.max-classInst.min))*(val1-classInst.min))+'%';if(classInst.onSlide.constructor==Function)classInst.onSlide.call(classInst,{value:val1,handle:classInst._cfHandle});}
classInst._tVal1=val1;classInst._tVal2=val2;return false;},_dragEnd:function(e,classInst){$e.stopEvent(e);if(A5.flags.isMobile){$e.remove(document,'touchmove',classInst._dragMove);$e.remove(document,'touchend',classInst._dragEnd);}else{$e.remove(document,'mousemove',classInst._dragMove);$e.remove(document,'mouseup',classInst._dragEnd);}
if(classInst._cfHandle=='range'&&classInst.range.selectedClassName!=''){$rcn(classInst.contId+'.SLIDERRANGE',classInst.range.selectedClassName);if(classInst.handle.selectedClassName!=''){$rcn(classInst.contId+'.SLIDERHANDLE1',classInst.handle.selectedClassName);$rcn(classInst.contId+'.SLIDERHANDLE2',classInst.handle.selectedClassName);}}else if(classInst.handle.selectedClassName!='')$rcn(classInst.contId+'.'+classInst._cHandle,classInst.handle.selectedClassName);if(!classInst._dragFlag)return false;classInst._val1=classInst._tVal1;classInst._val2=classInst._tVal2;classInst._refresh();setTimeout(function(){classInst._dragFlag=false;delete classInst;},0);return false;},_getCoors:function(e){var coors={};var tempT=this._getTouches(e);if(tempT){if(tempT.length){coors.clientX=tempT[0].clientX;coors.clientY=tempT[0].clientY;return coors;}}
coors.clientX=e.clientX;coors.clientY=e.clientY;return coors;},_getTouches:function(e){if(e.originalEvent){if(e.originalEvent.touches&&e.originalEvent.touches.length)return e.originalEvent.touches;else if(e.originalEvent.changedTouches&&e.originalEvent.changedTouches.length)return e.originalEvent.changedTouches;}else{if(e.touches||e.changedTouches){if(e.touches.length)return e.touches;else if(e.changedTouches.length)return e.changedTouches;}}
return null;},_refresh:function(){var oldVal=String(this.value);this._hEle1.style.left=((100/(this.max-this.min))*(this._val1-this.min))+'%';this._hEle2.style.left=((100/(this.max-this.min))*(this._val2-this.min))+'%';if(this.type=='range'){this._rEle.style.left=this._hEle1.style.left;this._rEle.style.width=((100/(this.max-this.min))*(this._val2-this._val1))+'%';this.value=[this._val1,this._val2];if(this.inputId.constructor==Array){$svs(this.inputId[0],this.value[0]);$svs(this.inputId[1],this.value[1]);$e.execute(this.inputId[0],'change');$e.execute(this.inputId[1],'change');}else{$svs(this.inputId,this.value.join(this.separator));$e.execute(this.inputId,'change');}}else{this._rEle.style.width=((100/(this.max-this.min))*(this._val1-this.min))+'%';this.value=this._val1;$svs(this.inputId,this.value);$e.execute(this.inputId,'change');}
if(this.onChange.constructor==Function&&oldVal!=String(this.value))this.onChange.call(this,{value:this.value,handle:this._cfHandle});},_initRender:function(){var ele=$(this.contId);if(this.className!='')$acn(ele,this.className);var sEle=document.createElement('div');sEle.id=this.contId+'.SLIDER';sEle.className=this.innerClassName;sEle.style.position='relative';$e.add(sEle,A5.d.evnts.click,this._sClick,this,true);$e.add(sEle,'selectstart',function(e){$e.stopEvent($e.getEvent(e));return false;});$e.add(sEle,'dragstart',function(e){$e.stopEvent($e.getEvent(e));return false;});ele.appendChild(sEle);var rEle=document.createElement('div');rEle.id=this.contId+'.SLIDERRANGE';rEle.className=this.range.className;rEle.style.position='absolute';if(!this.range.show)rEle.style.display='none';if(A5.flags.isMobile)$e.add(rEle,'touchstart',this._dragStart,this);else{$e.add(rEle,'mousedown',this._dragStart,this);if(!A5.flags.isMobile&&this.range.hoverClassName!=''){$e.add(rEle,'mouseover',Function('if(!arguments[1]._dragFlag) $acn(this,\''+this.range.hoverClassName+'\');'),this);$e.add(rEle,'mouseout',Function('$rcn(this,\''+this.range.hoverClassName+'\');'));}}
sEle.appendChild(rEle);var hEle1=document.createElement('div');hEle1.id=this.contId+'.SLIDERHANDLE1';hEle1.className=this.handle.className+$if(this.type=='range',' '+this.handle.minClassName,'');hEle1.style.position='absolute';if(!this.handle.show)hEle1.style.display='none';if(A5.flags.isMobile)$e.add(hEle1,'touchstart',this._dragStart,this);else{$e.add(hEle1,'mousedown',this._dragStart,this);if(!A5.flags.isMobile&&this.handle.hoverClassName!=''){$e.add(hEle1,'mouseover',Function('if(!arguments[1]._dragFlag) $acn(this,\''+this.handle.hoverClassName+'\');'),this);$e.add(hEle1,'mouseout',Function('$rcn(this,\''+this.handle.hoverClassName+'\');'));}}
sEle.appendChild(hEle1);var hEle2=document.createElement('div');hEle2.id=this.contId+'.SLIDERHANDLE2';hEle2.className=this.handle.className+' '+this.handle.maxClassName;hEle2.style.position='absolute';if(!this.handle.show||this.type!='range')hEle2.style.display='none';if(A5.flags.isMobile)$e.add(hEle2,'touchstart',this._dragStart,this);else{$e.add(hEle2,'mousedown',this._dragStart,this);if(!A5.flags.isMobile&&this.handle.hoverClassName!=''){$e.add(hEle2,'mouseover',Function('if(!arguments[1]._dragFlag) $acn(this,\''+this.handle.hoverClassName+'\');'),this);$e.add(hEle2,'mouseout',Function('$rcn(this,\''+this.handle.hoverClassName+'\');'));}}
sEle.appendChild(hEle2);this._rEle=rEle;this._hEle1=hEle1;this._hEle2=hEle2;this.setValue(this.value);}};A5.Switch=Class.create({initialize:function(contId,settings){this.contId=contId;$u.o.assign(this,{theme:'',override:'base',value:false,inputId:'',flow:'ltr',className:'',onClassName:'',offClassName:'',innerClassName:'',rightClassName:'',leftClassName:'',buttonClassName:'',text:{on:'',off:''},values:{on:true,off:false},onSelect:0});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'switch');$u.o.assign(this,settings);A5.overrides.assign(this,'switch',this.override);this._render();this._init=false;this._value=false;this.setValue(this.value);this._init=true;},setValue:function(val){if(typeof val=='boolean')val=val?this.values.on:this.values.off;var oldValue=this._value;this.value=val;var ele=$(this.contId);var loc='left';if(this.value==this.values.on){$acn(ele,this.onClassName);$rcn(ele,this.offClassName);if(this.flow=='ltr')loc='right';this._value=true;}else{$acn(ele,this.offClassName);$rcn(ele,this.onClassName);if(this.flow=='rtl')loc='right';this._value=false;}
if(loc=='left'){ele.firstChild.firstChild.style.left='-100%';ele.firstChild.lastChild.style.left='0%';ele.firstChild.childNodes[1].style.left='0%';}else{ele.firstChild.firstChild.style.left='0%';ele.firstChild.lastChild.style.left='100%';ele.firstChild.childNodes[1].style.left='100%';}
$sa(ele,'A5SwitchLoc',loc);if(this.inputId!=''){$svs(this.inputId,this.value);$e.execute(this.inputId,'change');}
if(this.onSelect.constructor==Function&&this._init&&oldValue!=this._value)this.onSelect.call(this);},_switch:function(e,classInst){var val=false;if($ga(this,'A5SwitchLoc')=='left'){if(classInst.flow=='rtl')val=true;}else{if(classInst.flow=='ltr')val=true;}
classInst.setValue(val);},_toggle:function(e,classInst){classInst.setValue(!classInst._value);},_render:function(){var ele=$(this.contId);ele.style.overflow='hidden';$acn(ele,this.className);var iEle=document.createElement('div');iEle.style.position='relative';iEle.className=this.innerClassName;var lEle=document.createElement('div');$ss(lEle,'position: absolute; z-index: 1; width: 100%; left: -100%;');lEle.className=this.leftClassName;if(this.flow=='ltr')lEle.innerHTML=this.text.on;else lEle.innerHTML=this.text.off;iEle.appendChild(lEle);var bEle=document.createElement('div');$ss(bEle,'position: absolute; z-index: 2; left: 0%;');bEle.className=this.buttonClassName;bEle.innerHTML='&nbsp;';iEle.appendChild(bEle);var rEle=document.createElement('div');$ss(rEle,'position: absolute; z-index: 1; width: 100%; left: 0%;');rEle.className=this.rightClassName;if(this.flow=='rtl')rEle.innerHTML=this.text.on;else rEle.innerHTML=this.text.off;iEle.appendChild(rEle);ele.appendChild(iEle);$e.add(ele,'a5switch',this._switch,this);$e.add(ele,'abstractclick',this._toggle,this);A5.u.drag.add(ele,'custom',{axis:'x',onMove:function(d){var p=(d.customMoveX/this.offsetWidth)*100;if($ga(this,'A5SwitchLoc')=='right')p=((this.offsetWidth+d.customMoveX)/this.offsetWidth)*100;p=Math.max(Math.min(p,100),0);this.firstChild.firstChild.style.left=(p-100)+'%';this.firstChild.lastChild.style.left=p+'%';this.firstChild.childNodes[1].style.left=p+'%';},onEnd:function(d){var p=(d.customMoveX/this.offsetWidth)*100;if($ga(this,'A5SwitchLoc')=='right')p=((this.offsetWidth+d.customMoveX)/this.offsetWidth)*100;p=Math.max(Math.min(p,100),0);if(p<50)$sa(this,'A5SwitchLoc','left');else $sa(this,'A5SwitchLoc','right');$e.execute(this,'a5switch');}});}});A5.map={initState:-1,initQueue:[],init:function(){A5.map.initState=1;for(var i=0;i<A5.map.initQueue.length;i++){A5.map._m[A5.map.initQueue[i]]._genMap();}},_fn:'http://maps.googleapis.com/maps/api/js?sensor=true&libraries=geometry&callback=A5.map.init',_m:{},_mrk:{},_mrkC:{},_ovr:{},_d:{}}
A5.Map=Class.create({initialize:function(contId,settings){this.contId=contId;$u.o.assign(this,{override:'base',type:'',ui:{draggable:true,panControl:null,zoomControl:null,zoomOnDlbClick:true,streetViewControl:null,mapTypeControl:null,scale:null,overviewMap:null},route:{draggable:false,avoid:{highways:null,tolls:null},travelMode:'driving',units:'default',optimizeOrder:false,directionsPanel:false},draw:{polygon:{startIcon:{url:'',width:false,height:false,anchor:{x:false,y:false}}}},onClick:false,onDblClick:false,onRightClick:false,onZoomChange:false,onInitialize:false});$u.o.assign(this,settings);A5.overrides.assign(this,'map',this.override);this._dmc=[];this._mrk={};this._ovr={};this._mode={clickable:true};if(A5.map.initState==1)this._genMap();else{if(A5.map.initState==-1){A5.map.initState=0;var sEle=document.createElement('script');sEle.src=A5.map._fn;document.getElementsByTagName('head')[0].appendChild(sEle);}
A5.map.initQueue.push(this.contId);}
A5.map._m[this.contId]=this;},refresh:function(){if(this._delayMethod('refresh',arguments))return false;google.maps.event.trigger(this.map,'resize');this.map.setZoom(this.map.getZoom());},setValue:function(){this.setCenter.apply(this,arguments)},setZoom:function(zoom){if(this._delayMethod('setZoom',arguments))return false;this.map.setZoom(zoom);},setCenter:function(loc){if(this._delayMethod('setCenter',arguments))return false;var pan=typeof arguments[1]!='undefnined'?arguments[1]:false;if(typeof loc=='string'){if(typeof this._gc=='undefined')this._gc=new google.maps.Geocoder();this._gc.geocode({'address':loc},Function('if(arguments[1] == google.maps.GeocoderStatus.OK) A5.map._m[\''+this.contId+'\'].map.'+$if(pan,'panTo','setCenter')+'(arguments[0][0].geometry.location);'));}else{var ll=new google.maps.LatLng(loc[0],loc[1],true);if(pan)this.map.panTo(ll);else this.map.setCenter(ll);}},view:function(){if(this._delayMethod('view',arguments))return false;var pan=false;var arg=[];for(var i=0;i<arguments.length;i++)arg.push(arguments[i]);if(typeof arg[arg.length-1]=='boolean')pan=arg.pop();if(arg.length==1){if(arg[0].constructor==Array){if(typeof arg[0][0]!='number'){arg=arg[0];arg.push(pan);this.view.apply(this,arg);return true;}}
this.setCenter(arg[0],pan);}else{var latMax=arg[0][0];var latMin=arg[0][0];var lngMax=arg[0][1];var lngMin=arg[0][1];for(var i=1;i<arg.length;i++){latMax=Math.max(latMax,arg[i][0]);latMin=Math.min(latMin,arg[i][0]);lngMax=Math.max(lngMax,arg[i][1]);lngMin=Math.min(lngMin,arg[i][1]);}
var llb=new google.maps.LatLngBounds(new google.maps.LatLng(latMax,lngMin,true),new google.maps.LatLng(latMin,lngMax,true));if(pan)this.map.panToBounds(llb);else this.map.fitBounds(llb);}},viewMarkers:function(){if(this._delayMethod('viewMarkers',arguments))return false;var locs=[];var pos=0;var arg=arguments;if(arg.length==1){if(arg[0].constructor==Array)arg=arg[0];}
for(var i=0;i<arg.length;i++){if(typeof this._mrk[arguments[i]]!='undefined'){pos=A5.map._mrk[this.contId+':'+arguments[i]].getPosition();locs.push([pos.lat(),pos.lng()]);}}
if(locs.length==1)this.setCenter(locs[0]);else if(locs.length>0)this.view.apply(this,locs);},viewMarkerGroups:function(){if(this._delayMethod('viewMarkerGroups',arguments))return false;var locs=[];var pos=0;var arg=arguments;if(arg.length==1){if(arg[0].constructor==Array)arg=arg[0];}
for(var prop in this._mrk){if($u.a.find(arg,this._mrk[prop].group)!=-1){pos=A5.map._mrk[this.contId+':'+prop].getPosition();locs.push([pos.lat(),pos.lng()]);}}
if(locs.length==1)this.setCenter(locs[0]);else if(locs.length>0)this.view.apply(this,locs);},addMarker:function(name,loc,settings){if(this._delayMethod('addMarker',arguments))return false;var s={group:'',icon:{url:'',width:false,height:false,anchor:{x:false,y:false}},title:'',detail:{has:false,data:''},overlay:{has:false,data:10,fill:{color:null,opacity:null},stroke:{color:null,width:null,opacity:null}},draggable:false,animation:false,emphasize:false,onClick:false,onDblClick:false,onDrag:false,onDragEnd:false,onDragStart:false,onMouseDown:false,onMouseOut:false,onMouseOver:false,onMouseUp:false,onRightClick:false,onAddComplete:false,onRemove:false};$u.o.assign(s,settings);if(typeof this._mrk[name]!='undefined')this.removeMarker(name);this._mrk[name]=s;if(typeof loc=='string'){if(typeof this._gc=='undefined')this._gc=new google.maps.Geocoder();this._gc.geocode({'address':loc},Function('if(arguments[1] == google.maps.GeocoderStatus.OK){ A5.map._m[\''+this.contId+'\']._mrk[\''+name+'\'].position = arguments[0][0].geometry.location; A5.map._m[\''+this.contId+'\']._addMarker(\''+name+'\');}'));}else{this._mrk[name].position=new google.maps.LatLng(loc[0],loc[1],true);this._addMarker(name);}},removeMarker:function(name){if(this._delayMethod('removeMarker',arguments))return false;if(typeof this._mrk[name]!='undefined'){if(this._mrk[name].onRemove)s.onRemove.call(this,this._mrk[name],A5.map._mrk[this.contId+':'+name]);if(this._mrk[name].overlay.has){A5.map._mrkC[this.contId+':'+name].setMap(null);delete A5.map._mrkC[this.contId+':'+name];}
A5.map._mrk[this.contId+':'+name].setMap(null);delete A5.map._mrk[this.contId+':'+name];delete this._mrk[name];}},setMarkerDisplay:function(name,val){if(this._delayMethod('setMarkerDisplay',arguments))return false;if(typeof this._mrk[name]!='undefined')A5.map._mrk[this.contId+':'+name].setVisible(val);},emphasizeMarker:function(name,dur){if(this._delayMethod('emphasizeMarker',arguments))return false;if(typeof this._mrk[name]!='undefined'){A5.map._mrk[this.contId+':'+name].setAnimation(google.maps.Animation.BOUNCE);if(typeof dur=='number')setTimeout(Function('A5.map._m[\''+this.contId+'\'].deemphasizeMarker(\''+name+'\')'),dur);}},deemphasizeMarker:function(name){if(this._delayMethod('deemphasizeMarker',arguments))return false;if(typeof this._mrk[name]!='undefined')A5.map._mrk[this.contId+':'+name].setAnimation(null);},removeMarkerGroup:function(group){if(this._delayMethod('removeMarkerGroup',arguments))return false;for(var prop in this._mrk){if(this._mrk[prop].group==group)this.removeMarker(prop);}},setMarkerGroupDisplay:function(group,val){if(this._delayMethod('setMarkerGroupDisplay',arguments))return false;for(var prop in this._mrk){if(this._mrk[prop].group==group)A5.map._mrk[this.contId+':'+prop].setVisible(val);}},emphasizeMarkerGroup:function(group,dur){if(this._delayMethod('emphasizeMarkerGroup',arguments))return false;for(var prop in this._mrk){if(this._mrk[prop].group==group)A5.map._mrk[this.contId+':'+prop].setAnimation(google.maps.Animation.BOUNCE);}
if(typeof dur=='number')setTimeout(Function('A5.map._m[\''+this.contId+'\'].deemphasizeMarkerGroup(\''+group+'\')'),dur);},deemphasizeMarkerGroup:function(group){if(this._delayMethod('deemphasizeMarkerGroup',arguments))return false;for(var prop in this._mrk){if(this._mrk[prop].group==group)A5.map._mrk[this.contId+':'+prop].setAnimation(null);}},getMarkerPositions:function(){if(this._delayMethod('getMarkerPositions',arguments))return false;var latLng={};var pos=0;var allMrks=arguments.length==0;var arg=arguments;if(arg.length==1){if(arg[0].constructor==Array)arg=arg[0];}
for(var prop in this._mrk){if(allMrks||$u.a.find(arg,prop)!=-1){pos=A5.map._mrk[this.contId+':'+prop].getPosition();latLng[prop]=[pos.lat(),pos.lng()];}}
return latLng;},getMarkerGroupPositions:function(){if(this._delayMethod('getMarkerGroupPositions',arguments))return false;var latLng={};var pos=0;var arg=arguments;if(arg.length==1&&arg[0].constructor==Array)arg=arg[0];for(var prop in this._mrk){if($u.a.find(arg,this._mrk[prop].group)!=-1){pos=A5.map._mrk[this.contId+':'+prop].getPosition();latLng[prop]=[pos.lat(),pos.lng()];}}
return latLng;},showMarkerDetail:function(mrk){if(this._delayMethod('showMarkerDetail',arguments))return false;if(typeof this._mrk[mrk]!='undefined'){var dData=this._mrk[mrk].detail.data;if(typeof dData=='string')this._showDetailLow(mrk,dData);else if(dData.constructor==Function)this._showDetailLow(mrk,dData());else if(dData.constructor==Object){var data='';if(typeof dData.data!='undefined')data=dData.data;new $a.simple(dData.url,{method:'get','data':data,handle:Function('if(arguments[0].responseText) A5.map._m[\''+this.contId+'\']._showDetailsLow(\''+mrk+'\',arguments[0].responseText);')})}}},plotRoute:function(){if(this._delayMethod('plotRoute',arguments))return false;this._dirSetup();var arg=[];if(arguments.length==1)arg=arguments[0];else{for(var i=0;i<arguments.length;i++)arg.push(arguments[i]);}
this._r=[].concat(arg);var s=arg.shift();if(s.constructor==Array)s=new google.maps.LatLng(s[0],s[1]);var e=arg.pop();if(e.constructor==Array)e=new google.maps.LatLng(e[0],e[1]);var wp=[];var cwp=0;if(arg.length>0){for(var i=0;i<arg.length;i++){cwp=arg[i];if(cwp.constructor==Array)cwp=new google.maps.LatLng(cwp[0],cwp[1]);wp.push({location:cwp});}}
var tm=google.maps.DirectionsTravelMode.DRIVING;var uSys=null;if(this.route.travelMode.toUpperCase()=='WALKING')tm=google.maps.DirectionsTravelMode.WALKING;if(this.route.units.toUpperCase()=='IMPERIAL')uSys=google.maps.UnitSystem.IMPERIAL;else if(this.route.units.toUpperCase()=='METRIC')uSys=google.maps.UnitSystem.METRIC;this._dirS.route({origin:s,destination:e,waypoints:wp,unitSystem:uSys,travelMode:tm,avoidHighways:this.route.avoid.highways,avoidTolls:this.route.avoid.tolls,optimizeWaypoints:this.route.optimizeOrder},Function('if(arguments[1] == google.maps.DirectionsStatus.OK) A5.map._m[\''+this.contId+'\']._dirR.setDirections(arguments[0]);'));},clearRoute:function(){if(typeof this._dirR!='undefined')this._dirR.setDirections({routes:[]});this._r=[];},getRoute:function(){var r={start:false,end:false,waypoints:{original:[],plotted:[],order:[]}};if(this._r==[])return r;var d=this._dirR.getDirections();r.start=this._r[0];r.end=this._r[this._r.length-1];for(var i=1;i<this._r.length-1;i++){r.waypoints.original.push(this._r[i]);}
r.waypoints.order=d.routes[0].waypoint_order;for(var i=0;i<r.waypoints.order.length;i++){r.waypoints.plotted.push(r.waypoints.original[r.waypoints.order[i]]);}
return r;},addOverlay:function(name,type,data,settings){if(this._delayMethod('addOverlay',arguments))return false;var s={type:type,data:data,group:'',fill:{color:null,opacity:null},stroke:{color:null,width:null,opacity:null},onClick:false,onDblClick:false,onMouseDown:false,onMouseOut:false,onMouseOver:false,onMouseUp:false,onRightClick:false,onAddComplete:false,onRemove:false};$u.o.assign(s,settings);if(typeof this._ovr[name]!='undefined')this.removeOverlay(name);this._ovr[name]=s;if(type=='circle'){if(typeof data[0]=='string'){if(typeof this._gc=='undefined')this._gc=new google.maps.Geocoder();this._gc.geocode({'address':data[0]},Function('if(arguments[1] == google.maps.GeocoderStatus.OK){ A5.map._m[\''+this.contId+'\']._ovr[\''+name+'\'].data[0] = arguments[0][0].geometry.location; A5.map._m[\''+this.contId+'\']._addOverlay(\''+name+'\');}'));}else{this._ovr[name].data[0]=new google.maps.LatLng(data[0][0],data[0][1],true);this._addOverlay(name);}}else if(type=='polygon'){this._addOverlay(name);}},getOverlayData:function(){if(this._delayMethod('getOverlayData',arguments))return false;var data={};var ovr=0;var pos=0;var path=0;var allOvrs=arguments.length==0;var arg=arguments;if(arg.length==1){if(arg[0].constructor==Array)arg=arg[0];}
for(var prop in this._ovr){if(allOvrs||$u.a.find(arg,prop)!=-1)this._getOvrData(prop,data);}
return data;},getOverlayGroupData:function(){if(this._delayMethod('getOverlayGroupData',arguments))return false;var data={};var arg=arguments;if(arg.length==1&&arg[0].constructor==Array)arg=arg[0];for(var prop in this._ovr){if($u.a.find(arg,this._ovr[prop].group)!=-1)this._getOvrData(prop,data);}
return data;},_getOvrData:function(prop,data){var ovr=A5.map._ovr[this.contId+':'+prop];var pos=0;var path=0;if(this._ovr[prop].type=='polygon'){data[prop]={type:'polygon',data:[]};path=ovr.getPath();for(var i=0;i<path.length;i++)data[prop].data.push([path.getAt(i).lat(),path.getAt(i).lng()]);}else{data[prop]={type:'circle',data:[]};pos=ovr.getCenter();data[prop].data.push([pos.lat(),pos.lng()]);data[prop].data.push(ovr.getRadius());}},removeOverlay:function(name){if(this._delayMethod('removeOverlay',arguments))return false;if(typeof this._ovr[name]!='undefined'){if(this._ovr[name].onRemove)s.onRemove.call(this,this._ovr[name],A5.map._ovr[this.contId+':'+name]);A5.map._ovr[this.contId+':'+name].setMap(null);delete A5.map._ovr[this.contId+':'+name];delete this._ovr[name];}},removeOverlayGroup:function(group){if(this._delayMethod('removeOverlayGroup',arguments))return false;for(var prop in this._ovr){if(this._ovr[prop].group==group)this.removeOverlay(prop);}},setMode:function(type){if(this._mode.type=='edit'){if(this._mode.eo!=''){var oc=A5.map._ovr[this.contId+':'+this._mode.eo];if(oc)oc.setOptions({editable:false});}}
if(this._mode.l)google.maps.event.removeListener(this._mode.l);if(this._mode.type=='draw'){if(this._mode.subType=='overlay-polygon'&&this._mrk['__A5DRAWPOLYSTART']){this.removeOverlay(this._mode.name);this.removeMarker('__A5DRAWPOLYSTART');}else if(this._mode.subType=='overlay-circle'&&this._mode.p.length==1){this.removeOverlay(this._mode.name);}}
if(type=='draw'){this._mode.type=type;this._mode.subType=arguments[1];if(this._mode.subType=='route'){this._mode.s=typeof arguments[2]!='undefined'?arguments[2]:{};$u.o.assign(this._mode.s,{maximum:false},true);this._mode.cf=typeof arguments[3]!='undefined'?arguments[3]:false;this._dirSetup();this._dirR.setOptions({preserveViewport:true});}else{this._mode.name=arguments[2];this._mode.s=typeof arguments[3]!='undefined'?arguments[3]:{};this._mode.cf=typeof arguments[4]!='undefined'?arguments[4]:false;}
if(this._mode.l)google.maps.event.removeListener(this._mode.l);this._mode.l=google.maps.event.addListener(this.map,'click',Function('A5.map._m[\''+this.contId+'\']._draw(arguments[0]);'));this._mode.p=[];this.map.setOptions({draggableCursor:'crosshair'});this._setOvrClickable(false);}else if(type=='erase'){this._mode.type=type;this._mode.subType=arguments[1];this._mode.cf=typeof arguments[2]!='undefined'?arguments[2]:false;this.map.setOptions({draggableCursor:'crosshair'});this._setOvrClickable(true);}else if(type=='edit'){this._mode.type=type;this._mode.subType=arguments[1];this._mode.cf=typeof arguments[2]!='undefined'?arguments[2]:false;this.map.setOptions({draggableCursor:'crosshair'});this._setOvrClickable(true);}else{this._mode.type='default';this._mode.subType='';if(this._mode.l)google.maps.event.removeListener(this._mode.l);if(this._mode.lc)google.maps.event.removeListener(this._mode.lc);this._mode.p=[];this.map.setOptions({draggableCursor:''});if(this._dirR)this._dirR.setOptions({preserveViewport:false});this._setOvrClickable(true);}},_addMarker:function(name){var s=this._mrk[name];var icon=null;if(s.icon.url!=''){var iAnchor=null;var iSize=null;if(s.icon.anchor.x&&s.icon.anchor.y)iAnchor=new google.maps.Point(s.icon.anchor.x,s.icon.anchor.y);if(s.icon.width&&s.icon.height)iSize=new google.maps.Size(s.icon.width,s.icon.height);icon=new google.maps.MarkerImage(s.icon.url,iSize,null,iAnchor);}
var anim=null;if(s.animation=='drop'||s.animation==true)anim=google.maps.Animation.DROP;else if(s.animation=='bounce')anim=google.maps.Animation.BOUNCE;var gs={draggable:s.draggable,icon:icon,title:s.title,position:s.position,map:this.map,animation:anim}
A5.map._mrk[this.contId+':'+name]=new google.maps.Marker(gs);if(s.detail.has)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'click',Function('A5.map._m[\''+this.contId+'\'].showMarkerDetail(\''+name+'\');'));if(s.overlay.has){var val=this._cRad(s.overlay.data);A5.map._mrkC[this.contId+':'+name]=new google.maps.Circle({map:this.map,center:s.position,radius:val,fillColor:s.overlay.fill.color,fillOpacity:s.overlay.fill.opacity,strokeColor:s.overlay.stroke.color,strokeOpacity:s.overlay.stroke.opacity,strokeWeight:s.overlay.stroke.width});if(s.draggable)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'drag',Function('A5.map._mrkC[\''+this.contId+':'+name+'\'].setCenter(arguments[0].latLng)'));}
google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'click',Function('var mObj = A5.map._m[\''+this.contId+'\']; if(mObj._mode.type == \'erase\' && mObj._mode.subType == \'marker\'){ mObj._erase(\''+name+'\');} else if(mObj._mrk[\''+name+'\'].onClick){mObj._mrk[\''+name+'\'].onClick();}'));if(s.onDblClick)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'dblclick',s.onDblClick);if(s.onDrag)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'drag',s.onDrag);if(s.onDragEnd)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'dragend',s.onDragEnd);if(s.onDragStart)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'dragstart',s.onDragStart);if(s.onMouseDown)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'mousedown',s.onMouseDown);if(s.onMouseOut)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'mouseout',s.onMouseOut);if(s.onMouseOver)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'mouseover',s.onMouseOver);if(s.onMouseUp)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'mouseup',s.onMouseUp);if(s.onRightClick)google.maps.event.addListener(A5.map._mrk[this.contId+':'+name],'rightclick',s.onRightClick);if(typeof s.emphasize=='number')this.emphasizeMarker(name,s.emphasize);if(s.onAddComplete)s.onAddComplete.call(this,s,A5.map._mrk[this.contId+':'+name]);},_addOverlay:function(name){var s=this._ovr[name];if(s.type=='circle'){var val=this._cRad(s.data[1]);A5.map._ovr[this.contId+':'+name]=new google.maps.Circle({map:this.map,center:s.data[0],radius:val,fillColor:s.fill.color,fillOpacity:s.fill.opacity,strokeColor:s.stroke.color,strokeOpacity:s.stroke.opacity,strokeWeight:s.stroke.width,clickable:this._mode.clickable});}else if(s.type=='polygon'){var p=[];for(var i=0;i<s.data.length;i++)p.push(new google.maps.LatLng(s.data[i][0],s.data[i][1],true));A5.map._ovr[this.contId+':'+name]=new google.maps.Polygon({map:this.map,paths:p,fillColor:s.fill.color,fillOpacity:s.fill.opacity,strokeColor:s.stroke.color,strokeOpacity:s.stroke.opacity,strokeWeight:s.stroke.width,clickable:this._mode.clickable});}
google.maps.event.addListener(A5.map._ovr[this.contId+':'+name],'click',Function('var mObj = A5.map._m[\''+this.contId+'\']; if(mObj._mode.type == \'erase\' && mObj._mode.subType == \'overlay\'){ mObj._erase(\''+name+'\');} else if(mObj._mode.type == \'edit\' && mObj._mode.subType == \'overlay\'){ mObj._edit(\''+name+'\');} else if(mObj._ovr[\''+name+'\'].onClick){mObj._ovr[\''+name+'\'].onClick.apply(this,arguments);}'));if(s.onDblClick)google.maps.event.addListener(A5.map._ovr[this.contId+':'+name],'dblclick',s.onDblClick);if(s.onMouseDown)google.maps.event.addListener(A5.map._ovr[this.contId+':'+name],'mousedown',s.onMouseDown);if(s.onMouseOut)google.maps.event.addListener(A5.map._ovr[this.contId+':'+name],'mouseout',s.onMouseOut);if(s.onMouseOver)google.maps.event.addListener(A5.map._ovr[this.contId+':'+name],'mouseover',s.onMouseOver);if(s.onMouseUp)google.maps.event.addListener(A5.map._ovr[this.contId+':'+name],'mouseup',s.onMouseUp);if(s.onRightClick)google.maps.event.addListener(A5.map._ovr[this.contId+':'+name],'rightclick',s.onRightClick);if(s.onAddComplete)s.onAddComplete.call(this,s,A5.map._ovr[this.contId+':'+name]);},_draw:function(data){if(this._mode.subType=='marker'){this.addMarker(this._mode.name,[data.latLng.lat(),data.latLng.lng()],this._mode.s);if(this._mode.cf.constructor==Function){var result=this._mode.cf.call(this,data);if(typeof result=='string'){this._mode.name=result;return true;}}
this.setMode('default');}else if(this._mode.subType=='overlay-circle'){this._mode.p.push(data.latLng);if(this._mode.p.length==1){var d=[[this._mode.p[0].lat(),this._mode.p[0].lng()],1];this.addOverlay(this._mode.name,'circle',d,this._mode.s);this._mode.lc=google.maps.event.addListener(this.map,'mousemove',Function('var co = A5.map._ovr[\''+this.contId+':'+this._mode.name+'\']; co.setRadius(google.maps.geometry.spherical.computeDistanceBetween(co.getCenter(),arguments[0].latLng));'));}else if(this._mode.p.length==2){if(this._mode.lc)google.maps.event.removeListener(this._mode.lc);var d=[[this._mode.p[0].lat(),this._mode.p[0].lng()],google.maps.geometry.spherical.computeDistanceBetween(this._mode.p[0],this._mode.p[1])];this.addOverlay(this._mode.name,'circle',d,this._mode.s);if(this._mode.cf.constructor==Function){var result=this._mode.cf.call(this,d);if(typeof result=='string'){this._mode.p=[];this._mode.name=result;return true;}}
this.setMode('default');}}else if(this._mode.subType=='overlay-polygon'){this._mode.p.push([data.latLng.lat(),data.latLng.lng()]);if(this._mode.p.length==1){this.addMarker('__A5DRAWPOLYSTART',this._mode.p[0],{onClick:Function('A5.map._m[\''+this.contId+'\']._drawPolyFin()'),icon:this.draw.polygon.startIcon});}else{this.addOverlay(this._mode.name,'polygon',this._mode.p,this._mode.s);}}else if(this._mode.subType=='route'){if(this._mode.p.length<this._mode.s.maximum||this._mode.s.maximum==false){this._mode.p.push([data.latLng.lat(),data.latLng.lng()]);if(this._mode.p.length>1){this.plotRoute([].concat(this._mode.p));if(this._mode.cf.constructor==Function)this._mode.cf.call(this,this._mode.p);}}}},_drawPolyFin:function(){this.removeMarker('__A5DRAWPOLYSTART');if(this._mode.cf.constructor==Function){var result=this._mode.cf.call(this,this._mode.p);if(typeof result=='string'){this._mode.p=[];this._mode.name=result;return true;}}
this.setMode('default');},_erase:function(name){var rem=true;if(this._mode.subType=='marker'){if(this._mode.cf)rem=this._mode.cf.call(this,name,this._mrk[name]);if(rem)this.removeMarker(name);}else{if(this._mode.cf)rem=this._mode.cf.call(this,name,this._ovr[name]);if(rem)this.removeOverlay(name);}},_edit:function(name){if(this._mode.cf){if(!this._mode.cf.call(this,name,this._ovr[name]))return false;}
if(this._mode.eo!=''){var oc=A5.map._ovr[this.contId+':'+this._mode.eo];if(oc)oc.setOptions({editable:false});}
A5.map._ovr[this.contId+':'+name].setOptions({editable:true});this._mode.eo=name;},_setOvrClickable:function(val){this._mode.clickable=val;for(var prop in this._ovr)A5.map._ovr[this.contId+':'+prop].setOptions({clickable:val});},_cRad:function(data){var rad=String(data);var val=$u.s.toNum(rad);if(rad.substr(rad.length-5).toLowerCase()=='sq km')val=Math.sqrt((val*1000000)/Math.PI);else if(rad.substr(rad.length-5).toLowerCase()=='sq mi')val=Math.sqrt((val*2589846.49)/Math.PI);else if(rad.substr(rad.length-5).toLowerCase()=='sq ft')val=Math.sqrt((val*0.09290304)/Math.PI);else if(rad.substr(rad.length-4).toLowerCase()=='sq m')val=Math.sqrt(val/Math.PI);else if(rad.substr(rad.length-2).toLowerCase()=='km')val=val*1000;else if(rad.substr(rad.length-2).toLowerCase()=='mi')val=val*1609.3;else if(rad.substr(rad.length-2).toLowerCase()=='ft')val=val*0.3048;return val;},_dirSetup:function(){if(typeof this._dirS=='undefined'){this._dirS=new google.maps.DirectionsService();var pEle=null;if($(this.route.directionsPanel))pEle=$(this.route.directionsPanel);this._dirR=new google.maps.DirectionsRenderer({draggable:this.route.draggable,panel:pEle});this._dirR.setMap(this.map);}},_showDetailLow:function(mrk,data){if(typeof A5.map._d[this.contId]=='undefined')A5.map._d[this.contId]=new google.maps.InfoWindow({content:''});A5.map._d[this.contId].setContent(data);A5.map._d[this.contId].open(this.map,A5.map._mrk[this.contId+':'+mrk]);},_zChange:function(){var zNew=this.map.getZoom();this.onZoomChange.call(this,{zoom:zNew,oldZoom:this._zOld});this._zOld=zNew;},_genMap:function(){var mapType=google.maps.MapTypeId.ROADMAP;if(this.type.toUpperCase()=='HYBRID')mapType=google.maps.MapTypeId.HYBRID;else if(this.type.toUpperCase()=='ROADMAP')mapType=google.maps.MapTypeId.ROADMAP;else if(this.type.toUpperCase()=='SATELLITE')mapType=google.maps.MapTypeId.SATELLITE;else if(this.type.toUpperCase()=='TERRAIN')mapType=google.maps.MapTypeId.TERRAIN;var ops={center:new google.maps.LatLng(42.40,-71.05),zoom:11,mapTypeControl:this.ui.mapTypeControl,overviewMapControl:this.ui.overviewMap,panControl:this.ui.panControl,scaleControl:this.ui.scale,streetViewControl:this.ui.streetViewControl,zoomControl:this.ui.zoomControl,mapTypeId:mapType,draggable:this.ui.draggable,disableDoubleClickZoom:!this.ui.zoomOnDlbClick};this.map=new google.maps.Map(document.getElementById(this.contId),ops);if(this.onClick)google.maps.event.addListener(this.map,'click',this.onClick);if(this.onDblClick)google.maps.event.addListener(this.map,'dblclick',this.onDblClick);if(this.onRightClick)google.maps.event.addListener(this.map,'rightclick',this.onRightClick);if(this.onZoomChange)google.maps.event.addListener(this.map,'zoom_changed',Function('A5.map._m[\''+this.contId+'\']._zChange();'));for(var i=0;i<this._dmc.length;i++)this[this._dmc[i].method].apply(this,this._dmc[i].args);this._dmc=[];this._zOld=this.map.getZoom();if(this.onInitialize){var ll=this.map.getCenter();this.onInitialize.call(this,{zoom:this.map.getZoom(),center:[ll.lat(),ll.lng()]})}},_delayMethod:function(m,args){if(this.map)return false;var data={method:m,args:[]};for(var i=0;i<args.length;i++)data.args.push(args[i]);this._dmc.push(data);return 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;}}}}}
if(typeof A5.overrides=='undefined'){A5.overrides={_o:{},add:function(cType,sObj){if(typeof this._o[cType]=='undefined')this._o[cType]={};$u.o.assign(this._o[cType],sObj);},assign:function(classInst,cType,oType){if(typeof this._o[cType]!='undefined'){var oObj=this._o[cType];if(typeof oObj[oType]!='undefined'){if(typeof oObj[oType]!='undefined')$u.o.assign(classInst,oObj[oType]);}}}}}
A5.u={_uIdIndx:0,getUniqueId:function(){A5.u._uIdIndx++;return'A5UID'+A5.u._uIdIndx;},convertUnits:function(size,uIn,uOut){if(typeof size=='string'&&typeof uOut=='undefined'){size=$u.s.aTrim(size);uOut=uIn;uIn=size.substr(size.length-2,2);size=$u.s.toNum(size);}
if(size==0)return 0;if(uOut==uIn)return size;if(typeof this._units=='undefined'){var ele=document.createElement('div');$ss(ele,'width: 1cm; height: 1in; padding: 0px; border: none; margin: 0px; position: absolute; left: -2in; top: -2in');document.body.insertBefore(ele,document.body.firstChild);this._units={'px':1};this._units['in']=ele.offsetHeight;this._units['pt']=this._units['in']/72;this._units['pc']=this._units['pt']*12;this._units['cm']=ele.offsetWidth;this._units['mm']=this._units['cm']/10;}
var fIn=this._units[uIn];var fOut=this._units[uOut];var result=(size*fIn)/fOut;if(typeof result!='number')result=0;return result;},css:{},element:{cssGroup:function(eles,settings){$u.o.assign(settings,{firstClassName:false,lastClassName:false,middleClassName:false},true);for(var i=0;i<eles.length;i++){if(settings.firstClassName)$rcn(eles[i],settings.firstClassName);if(settings.lastClassName)$rcn(eles[i],settings.lastClassName);if(settings.middleClassName)$acn(eles[i],settings.middleClassName);}
for(var i=0;i<eles.length;i++){if(eles[i].style.display!='none'){if(settings.firstClassName)$acn(eles[i],settings.firstClassName);if(settings.middleClassName)$rcn(eles[i],settings.middleClassName);break;}}
for(var i=eles.length-1;i>=0;i--){if(eles[i].style.display!='none'){if(settings.lastClassName)$acn(eles[i],settings.lastClassName);if(settings.middleClassName)$rcn(eles[i],settings.middleClassName);break;}}},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(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(ele.style.display!='none')$sa(ele,'A5StyleDisplay',ele.style.display);if(jQuery(ele).queue().length!=0)jQuery(ele).stop(true,true);else if(ele.style.display=='none'&&!anim.force)return false;if(anim.force){var dVal=$ga(ele,'A5StyleDisplay');if(typeof dVal=='string')ele.style.display=dVal;else ele.style.display='';}
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{if(ele.style.display=='none')return false;$sa(ele,'A5StyleDisplay',ele.style.display);ele.style.display='none';if(func)func();}},show:function(ele,anim){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)jQuery(ele).stop(true,true);else if(ele.style.display!='none'&&!anim.force)return false;if(anim.force)ele.style.display='none';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{if(ele.style.display!='none')return false;var dVal=$ga(ele,'A5StyleDisplay');if(typeof dVal=='string')ele.style.display=dVal;else ele.style.display='';if(func)func();}},setScroll:function(ele,x,y,s){ele=$(ele);var cScrl=$ga(ele,'A5CustomScroll');var tEle=false;if(typeof x=='object'||typeof x=='string'){var tEle=$(x);s=y;x=false;y=false;}
if(typeof s!='object')s={};$u.o.assign(s,{fireEvent:false,mode:'into-view'},true);if(tEle){var cs=A5.u.element.getScroll(ele);var pEle=tEle.parentNode;var oT=tEle.offsetTop;var oL=tEle.offsetLeft;if(ele.style.position!='absolute'&&ele.style.position!='relative'){oT-=ele.offsetTop;oL-=ele.offsetLeft;}
while(pEle!=ele){if(pEle.style.position=='absolute'||pEle.style.position=='relative'){oT+=pEle.offsetTop;oL+=pEle.offsetLeft;}
pEle=pEle.parentNode;}
if(s.mode=='top')y=oT;else if(s.mode=='bottom')y=(oT+tEle.offsetHeight-ele.offsetHeight);else{if(cs.left>oL||ele.offsetWidth<tEle.offsetWidth)x=oL;else if((cs.left+ele.offsetWidth)<(oL+tEle.offsetWidth))x=(oL+tEle.offsetWidth-ele.offsetWidth);if(cs.top>oT||ele.offsetHeight<tEle.offsetHeight)y=oT;else if((cs.top+ele.offsetHeight)<(oT+tEle.offsetHeight))y=(oT+tEle.offsetHeight-ele.offsetHeight);}}
if(typeof cScrl=='string'&&cScrl!=''){cScrl=cScrl.split(',');var cSX=Number(cScrl[0]);var cSY=Number(cScrl[1]);if(typeof x=='number')cSX=x;if(typeof y=='number')cSY=y;var sW=ele.scrollWidth+cSX;var sH=ele.firstChild.offsetHeight;if(cSX<0)cSX=0;else if(cSX>sW)cSX=sW;if(cSY<0)cSY=0;else if(cSY>sH)cSY=sH;$sa(ele,'A5CustomScroll',cSX+','+cSY);ele.firstChild.style[A5.u.css.properties.transitionDOM]='';ele.firstChild.style[A5.u.css.properties.transformDOM]=A5.u.drag._getTrans((cSX*-1),(cSY*-1));var sIBEle=$(ele.id+'.SCROLLINDICATOR.X');if(sIBEle){sIBEle.style[A5.u.css.properties.transitionDOM]='';sIBEle.style.display='none';}
sIBEle=$(ele.id+'.SCROLLINDICATOR.Y');if(sIBEle){sIBEle.style[A5.u.css.properties.transitionDOM]='';sIBEle.style.display='none';}}else{if(typeof x=='number')ele.scrollLeft=x;if(typeof y=='number')ele.scrollTop=y;}
if(s.fireEvent)$e.execute(ele,'scroll');},getScroll:function(ele){var cScrl=$ga(ele,'A5CustomScroll');if(cScrl){cScrl=cScrl.split(',');var cSX=Number(cScrl[0]);var cSY=Number(cScrl[1]);if(A5.u.drag._st[ele.id]){var swcs={};swcs[A5.u.css.properties.transformDOM]='';if(typeof window.getComputedStyle!='undefined')swcs=window.getComputedStyle(ele.firstChild);else if(ele.currentStyle)swcs=ele.firstChild.currentStyle;var transform={e:0,f:0};if(A5.flags.isFireFox||A5.flags.isOpera){var mRE=/matrix\(\s*-?\d+(?:\.\d+)?\s*,\s*-?\d+(?:\.\d+)?\s*,\s*-?\d+(?:\.\d+)?\s*,\s*-?\d+(?:\.\d+)?\s*\,\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)/;var mREM=swcs[A5.u.css.properties.transformDOM].match(mRE);if(mREM){transform.e=mREM[1];transform.f=mREM[2];}}else if(A5.flags.isIE){transform=new MSCSSMatrix(swcs[A5.u.css.properties.transformDOM]);}else{transform=new WebKitCSSMatrix(swcs[A5.u.css.properties.transformDOM]);}
cSX=Math.round(transform.e)*-1;cSY=Math.round(transform.f)*-1;}
return{top:cSY,left:cSX};}
return{top:ele.scrollTop,left:ele.scrollLeft};}}}
A5.PanelCard=Class.create({initialize:function(settings){this.contId='';this._initLow.apply(this,arguments);this._ieCludge=false;if(document.all&&!document.createElement('canvas').getContext)this._ieCludge=true;this._canAnim=true;if(document.all&&navigator.appName!='Opera')this._canAnim=false;if(A5.flags.isFireFox)this._anim={tProp:'-moz-transform',tDOMProp:'MozTransform',prop:'MozTransition'};else if(A5.flags.isOpera)this._anim={tProp:'-o-transform',tDOMProp:'OTransform',prop:'OTransition'};else if(A5.flags.isIE)this._anim={tProp:'-ms-transform',tDOMProp:'MsTransform',prop:''};else this._anim={tProp:'-webkit-transform',tDOMProp:'WebkitTransform',prop:'WebkitTransition'};},_initLow:function(settings){$u.o.assign(this,{theme:'',override:'base',className:'',header:{show:false,scroll:false,html:'',className:'',style:0},body:{scroll:{axis:'both'},content:{type:'',src:'',data:''},className:'',style:0},overlay:{show:false,html:''},footer:{show:false,scroll:false,html:'',className:'',style:0},onSize:0,_sizing:'',_beforeBody:0,_afterBody:0,_onSetSize:0,_panelType:'panelCard',_name:'',_title:'',_w:0,_h:0});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'panelCard');$u.o.assign(this,settings);A5.overrides.assign(this,'panelCard',this.override);},create:function(){if(typeof arguments[0]!='undefined'){this.contId=arguments[0];if($(this.contId))var ele=$(this.contId);else{var ele=document.createElement('div');ele.id=this.contId;}}else{this.contId=A5.u.getUniqueId();var ele=document.createElement('div');ele.id=this.contId;}
ele.className=this.className;ele.style.position='relative';var hEle=document.createElement('div');hEle.id=this.contId+'.HEADER';hEle.className=this.header.className;if(typeof this.header.style=='string'||typeof this.header.style=='object')$ss(hEle,this.header.style);hEle.innerHTML=this._parseHTML(this.header.html);if(hEle.style.overflow=='')hEle.style.overflow='hidden';if(!this.header.show)hEle.style.display='none';hEle.style.position='relative';if(this.header.scroll){hEle.style.overflow='auto';if(typeof this.header.scroll=='object'){if(typeof this.header.scroll.theme=='undefined')this.header.scroll.theme=this.theme;A5.u.drag.add(hEle,'scroll',this.header.scroll);}else A5.u.drag.add(hEle,'scroll',{axis:both,theme:this.theme});}
ele.appendChild(hEle);if(this._beforeBody.constructor==Function)this._beforeBody(ele,bEle);if(this._panelType=='panelCard'){if(this.body.content.type=='url'){var bEle=document.createElement('iframe');bEle.id=this.contId+'.BODY';if(typeof this.body.style=='string'||typeof this.body.style=='object')$ss(bEle,this.body.style);bEle.frameBorder='0';bEle.border='0';bEle.style.padding='0px';bEle.style.width='100%';if(!document.all)bEle.style.marginBottom='-5px';var cURL='';var cData='';if(this.body.content.src.constructor==Function)cURL=this.body.content.src.call(this);else cURL=this.body.content.src;if(this.body.content.data.constructor==Function)cData=this.body.content.data.call(this);else cData=this.body.content.data;if(cData!='')cURL+=cData;bEle.src=cURL;}else{var bEle=document.createElement('div');bEle.id=this.contId+'.BODY';var html='';if(this.body.content.type=='html'){if(this.body.content.src.constructor==Function)html=this.body.content.src.call(this);else html=this.body.content.src;}else if(this.body.content.type=='callback'){var cURL='';var cData='';if(this.body.content.src.constructor==Function)cURL=this.body.content.src.call(this);else cURL=this.body.content.src;if(this.body.content.data.constructor==Function)cData=this.body.content.data.call(this);else cData=this.body.content.src;new $a.simple(cURL,{data:cData,handleGeneric:true,method:'get'});}
bEle.innerHTML=this._parseHTML(html);if(typeof this.body.style=='string'||typeof this.body.style=='object')$ss(bEle,this.body.style);bEle.style.position='relative';if(this.body.scroll){bEle.style.overflow='auto';if(typeof this.body.scroll=='object'){if(typeof this.body.scroll.theme=='undefined')this.body.scroll.theme=this.theme;A5.u.drag.add(bEle,'scroll',this.body.scroll);}else A5.u.drag.add(bEle,'scroll',{axis:both,theme:this.theme});}}}else{var bEle=document.createElement('div');bEle.id=this.contId+'.BODY';if(typeof this.body.style=='string'||typeof this.body.style=='object')$ss(bEle,this.body.style);bEle.style.overflow='hidden';bEle.style.position='relative';if(this._panelType=='panelLayout'){bEle.innerHTML='<div id="'+this.contId+'.BODYINNER" style="position: absolute; left: 0px; top: 0px;"><div id="'+this.contId+'.DOCKOVERLAY" class="'+this.dock.flowLock.className+'" style="position: absolute; left: 0px; top: 0px; display: none; z-index: 4;"></div></div>';$e.add(this.contId+'.DOCKOVERLAY',A5.d.evnts.click,function(e,classInst){classInst.hideDock();},this);}}
bEle.className=this.body.className;ele.appendChild(bEle);var fEle=document.createElement('div');fEle.id=this.contId+'.FOOTER';fEle.className=this.footer.className;if(typeof this.footer.style=='string'||typeof this.footer.style=='object')$ss(fEle,this.footer.style);fEle.innerHTML=this._parseHTML(this.footer.html);if(fEle.style.overflow=='')fEle.style.overflow='hidden';if(!this.footer.show)fEle.style.display='none';fEle.style.position='relative';if(this.footer.scroll){fEle.style.overflow='auto';if(typeof this.footer.scroll=='object'){if(typeof this.footer.scroll.theme=='undefined')this.footer.scroll.theme=this.theme;A5.u.drag.add(fEle,'scroll',this.footer.scroll);}else A5.u.drag.add(fEle,'scroll',{axis:both,theme:this.theme});}
ele.appendChild(fEle);var oEle=document.createElement('div');oEle.id=this.contId+'.OVERLAY';oEle.innerHTML=this._parseHTML(this.overlay.html);if(!this.overlay.show)oEle.style.display='none';ele.appendChild(oEle);if(this._afterBody.constructor==Function)this._afterBody(ele,bEle,hEle,fEle);if(A5.flags.supportsTouch){$e.add(ele,'touchmove',function(e){var tempT=$e.getTouches(e);var pDef=true;if(tempT){if(tempT.length){if(tempT.length>1)pDef=false;}}
if(pDef)$e.preventDefault(e);});}
var css=$gs(ele);if(!this._ieCludge&&css.search('box-sizing:')==-1)$ss(ele,css+' box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');css=$gs(bEle);if(!this._ieCludge&&css.search('box-sizing:')==-1)$ss(bEle,css+' box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');return ele;},bindSize:function(type){if($(this.contId))var ele=$(this.contId);else return false;if(type=='self'){$e.add(ele,'a5resize',this._sizeEle,this);this._sizeEle.call(ele,{},this);}else if(type=='parent'){$e.add(ele.parentNode,'a5resize',this._sizeEle,this);this._sizeEle.call(ele.parentNode,{},this);}else if(type=='window'){document.body.style.margin='0px';document.body.style.padding='0px';if(!A5.flags.isMobile)$e.add(window,'resize',this._sizeWindow,this,true);else $e.add(window,'orientationchange',this._sizeWindow,this,true);document.body.style.overflow='hidden';this._sizeWindowComplete();}
this._sizing=type;},setSize:function(w,h){var lazy=arguments[2]?arguments[2]:false;var fireSizeEvnt=arguments[3]?arguments[3]:true;if(lazy&&this._w==w&&this._h==h)return false;var ele=$(this.contId);var bEle=$(this.contId+'.BODY');var css=$gs(ele);var dif=0;if(this._ieCludge)dif=A5.u.convertUnits($u.s.toNum(ele.currentStyle['padding-right']),$u.s.aTrim(ele.currentStyle['padding-right'],' 1234567890.'),'px')+A5.u.convertUnits($u.s.toNum(ele.currentStyle['padding-left']),$u.s.aTrim(ele.currentStyle['padding-left'],' 1234567890.'),'px')+A5.u.convertUnits($u.s.toNum(ele.currentStyle['border-right-width']),$u.s.aTrim(ele.currentStyle['border-right-width'],' 1234567890.'),'px')+A5.u.convertUnits($u.s.toNum(ele.currentStyle['border-left-width']),$u.s.aTrim(ele.currentStyle['border-left-width'],' 1234567890.'),'px');else if(css.search('box-sizing:')==-1)$ss(ele,css+' box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');if(w>=0){var marginL=ele.style.marginLeft;var marginR=ele.style.marginRight;if(marginL=='')marginL=ele.style.margin;if(marginR=='')marginR=ele.style.margin;dif+=marginL==''?0:A5.u.convertUnits($u.s.toNum(marginL),$u.s.aTrim(marginL,' 1234567890.'),'px');dif+=marginR==''?0:A5.u.convertUnits($u.s.toNum(marginR),$u.s.aTrim(marginR,' 1234567890.'),'px');ele.style.width=(w-dif)+'px';this._w=w;}
if(h>=0){css=$gs(bEle);dif=0;if(this._ieCludge)dif=A5.u.convertUnits($u.s.toNum(bEle.currentStyle['padding-top']),$u.s.aTrim(bEle.currentStyle['padding-top'],' 1234567890.'),'px')+A5.u.convertUnits($u.s.toNum(bEle.currentStyle['padding-bottom']),$u.s.aTrim(bEle.currentStyle['padding-bottom'],' 1234567890.'),'px')+A5.u.convertUnits($u.s.toNum(bEle.currentStyle['border-top-width']),$u.s.aTrim(bEle.currentStyle['border-top-width'],' 1234567890.'),'px')+A5.u.convertUnits($u.s.toNum(bEle.currentStyle['border-bottom-width']),$u.s.aTrim(bEle.currentStyle['border-bottom-width'],' 1234567890.'),'px')
else if(css.search('box-sizing:')==-1)$ss(bEle,css+' box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box;');var marginT=ele.style.marginTop;var marginB=ele.style.marginBottom;if(marginT=='')marginT=ele.style.margin;if(marginB=='')marginB=ele.style.margin;dif+=marginT==''?0:A5.u.convertUnits($u.s.toNum(marginT),$u.s.aTrim(marginT,' 1234567890.'),'px');dif+=marginB==''?0:A5.u.convertUnits($u.s.toNum(marginB),$u.s.aTrim(marginB,' 1234567890.'),'px');bEle.style.height=(h-(ele.offsetHeight-bEle.offsetHeight)-dif)+'px';this._h=h;}
$e.execute(bEle,'a5resize');if(this._onSetSize.constructor==Function)this._onSetSize.call(this);if(this.onSize.constructor==Function&&fireSizeEvnt)this.onSize.call(this,{width:this._w,height:this._h});},setDisplay:function(part,show){part=part.toLowerCase();if(part=='header'||part=='footer'||part=='overlay'){if(this[part].show!=show){this[part].show=show;var ele=$(this.getPanelId(part));if(show)ele.style.display='';else ele.style.display='none';this.setSize(this._w,this._h,false,false);}}},getPanelId:function(part){part=typeof arguments[0]!='undefined'?arguments[0].toString():'';part=part.toLowerCase();var eleId=this.contId;if(part=='header')eleId=eleId+'.HEADER';else if(part=='body')eleId=eleId+'.BODY';else if(part=='footer')eleId=eleId+'.FOOTER';else if(part=='overlay')eleId=eleId+'.OVERLAY';return eleId;},_sizeEle:function(e,classInst){classInst.setSize(this.offsetWidth,this.offsetHeight,true);},_sizeWindow:function(e){var classInst=this;clearTimeout(this._swTO);this._swTO=setTimeout(function(){classInst._sizeWindowComplete();delete classInst},50);},_sizeWindowComplete:function(){var viewportwidth;var viewportheight;if(typeof window.innerWidth!='undefined'){viewportwidth=window.innerWidth,viewportheight=window.innerHeight}else if(typeof document.documentElement!='undefined'&&typeof document.documentElement.clientWidth!='undefined'&&document.documentElement.clientWidth!=0){viewportwidth=document.documentElement.clientWidth,viewportheight=document.documentElement.clientHeight}else{viewportwidth=document.getElementsByTagName('body')[0].clientWidth,viewportheight=document.getElementsByTagName('body')[0].clientHeight}
this.setSize(viewportwidth,viewportheight,true);},_parseHTML:function(html){html=html.split('{panel.id}').join(this.contId);html=html.split('{panel.name}').join(this._name);html=html.split('{panel.title}').join(this._title);return html;},_getPanelEleById:function(id,p){var eles=0;var isPanelCard=false;if(typeof p.tagName!='undefined'){var pId=p.id;var ele=p;}else{var pId=p.src.contId;var ele=p._ele;if(p.src._panelType=='panelCard')isPanelCard=true;}
id=id.split('{panel.id}').join(pId);if(arguments[2]||isPanelCard){eles=ele.getElementsByTagName('*');for(var i=0;i<eles.length;i++){if(eles[i].id==id)return eles[i];}}else{eles=ele.firstChild.getElementsByTagName('*');for(var i=0;i<eles.length;i++){if(eles[i].id==id)return eles[i];}
eles=ele.lastChild.previousSibling.getElementsByTagName('*');for(var i=0;i<eles.length;i++){if(eles[i].id==id)return eles[i];}}
return false;},_gDef:function(){for(var i=0;i<arguments.length;i++)if(arguments[i]!=''&&arguments[i]!=false&&arguments[i]!=null)return arguments[i];return'';}});A5.PanelNavigator=Class.create(A5.PanelCard,{_initLow:function(panels,settings){this.panels=panels;$u.o.assign(this,{type:'',flow:'ltr',theme:'',override:'base',loopNavigate:false,className:'',header:{show:false,html:'',className:'',style:0},body:{className:'',style:0},overlay:{show:false,html:''},footer:{show:false,html:'',className:'',style:0},indicator:{show:false,location:'bottom',className:'',panelClassName:'',panelSelectedClassName:''},controls:{prev:{has:false,id:'{panel.id}.CTRL.PREV',settings:{layout:'text',html:'Back'}},next:{has:false,id:'{panel.id}.CTRL.NEXT',settings:{layout:'text',html:'Next'}},back:{has:false,id:'{panel.id}.CTRL.BACK',settings:{layout:'text',html:'Back'}},forward:{has:false,id:'{panel.id}.CTRL.FORWARD',settings:{layout:'text',html:'Forward'}},panels:[]},animation:{type:'slide',duration:400},state:{activePanel:'',hasPrevPanel:false,prevPanelIndex:0,prevPanel:'',hasNextPanel:false,nextPanelIndex:0,nextPanel:'',history:[],historyIndex:-1,hasHistoryBack:false,historyBack:'',hasHistoryForward:false,historyForward:''},onSize:0,onPanelActivate:0,_isHistoryNav:false,_sizing:'',_panelIndx:-1,_beforeBody:0,_panelType:'panelNavigator',_name:'',_title:''});if(settings.type=='tabband'){$u.o.assign(settings,{location:'top',tabband:{location:'',theme:''}},true);if(settings.tabband.location=='')settings.tabband.location=settings.location;if(settings.tabband.theme==''){if(settings.tabband.location=='bottom')settings.tabband.theme=settings.theme+':bottom';else settings.tabband.theme=settings.theme;}}else if(settings.type=='carousel'){$u.o.assign(settings,{swipe:{allow:true,velocity:.5}},true);}
if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'panelNavigator');$u.o.assign(this,settings);A5.overrides.assign(this,'panelNavigator',this.override);},getPanel:function(panel){var panelArr=panel.split(':');var pObj={};var pScope=this;var panelIndx=-1;while(panelArr.length>0){panelIndx=pScope._getPanelIndx(panelArr.shift());if(panelIndx!=-1){pObj=pScope.panels[panelIndx];pScope=pObj.src;}else return false;}
return pObj;},setActivePanel:function(panel){if(window.event){if(window.event.type=='touchend'||window.event.type=='touchstart'){$e.preventDefault(window.event);}}
if(panel=='')return false;var panelArr=panel.split(':');panel=panelArr.shift();var panelIndx=this._getPanelIndx(panel);if(panelIndx==-1||this.panels.length==0)return false;var percent=typeof arguments[1]!='undefined'?arguments[1]:0;var doAnim=true;if(typeof percent=='boolean'){doAnim=percent;percent=0;}else if(typeof arguments[2]!='undefined')doAnim=arguments[2];var bEle=$(this.contId+'.BODY');this.panels[panelIndx].src.setSize(bEle.clientWidth,bEle.clientHeight,true);if(panelArr.length!=0&&(this.panels[panelIndx].src._panelType=='panelNavigator'||this.panels[panelIndx].src._panelType=='panelLayout'))this.panels[panelIndx].src.setActivePanel(panelArr.join(':'),$if(panelIndx==this._panelIndx&&doAnim,true,false));if(panelIndx==this._panelIndx){var state=false;for(var i=0;i<this.controls.panels.length;i++){if(this.controls.panels[i]._b){state=false;if(this.controls.panels[i].panel==this.state.activePanel)state=true;this.controls.panels[i]._b.setValue(state);}}
return false;}
var ele=$(this.contId+'.PANEL.'+panelIndx);var oEle=$(this.contId+'.PANEL.'+this._panelIndx);var animDir=panelIndx-this._panelIndx;var animType=this.animation.type;if(animType=='slide'){if(this.flow=='ttb'||this.flow=='btt'){if(this.flow=='btt')animDir=animDir*-1;if(animDir>0)animType='slide-up';else animType='slide-down';}else{if(this.flow=='rtl')animDir=animDir*-1;if(animDir>0)animType='slide-left';else animType='slide-right';}}
if(!this._isHistoryNav){this.state.historyIndex++;this.state.history.splice(this.state.historyIndex);this.state.history.push(panel);}
this._panelIndx=panelIndx;this._setPanelState();if(this.type=='tabband'){if(this._tbSet)this._tabband.select(panel);}else if(this.type=='carousel')this._setPanelInfo(bEle);if(this.onPanelActivate.constructor==Function)this.onPanelActivate();this._transEle(ele,oEle,animType,percent,doAnim);if(this.controls.prev.has){if(this.state.hasPrevPanel)this.controls.prev._b.setDisplay(true);else this.controls.prev._b.setDisplay(false);}
if(this.controls.next.has){if(this.state.hasNextPanel)this.controls.next._b.setDisplay(true);else this.controls.next._b.setDisplay(false);}
if(this.controls.back.has){if(this.state.hasHistoryBack)this.controls.back._b.setDisplay(true);else this.controls.back._b.setDisplay(false);}
if(this.controls.forward.has){if(this.state.hasHistoryForward)this.controls.forward._b.setDisplay(true);else this.controls.forward._b.setDisplay(false);}
var state=false;for(var i=0;i<this.controls.panels.length;i++){if(this.controls.panels[i]._b){state=false;if(this.controls.panels[i].panel==this.state.activePanel)state=true;this.controls.panels[i]._b.setValue(state)}}},firstPanel:function(){if(this._panelIndx>0)this.setActivePanel(this.panels[0].name);},prevPanel:function(){if(this.state.hasPrevPanel)this.setActivePanel(this.state.prevPanel);},nextPanel:function(){if(this.state.hasNextPanel)this.setActivePanel(this.state.nextPanel);},lastPanel:function(){if(this._panelIndx<this.panels.length-1)this.setActivePanel(this.panels[this.panels.length-1].name);},historyFirst:function(){if(this.state.historyIndex<=0)return false;this.state.historyIndex=0;this._isHistoryNav=true;this.setActivePanel(this.state.history[this.state.historyIndex]);this._isHistoryNav=false;},historyBack:function(){if(this.state.historyIndex<=0)return false;this.state.historyIndex--;this._isHistoryNav=true;this.setActivePanel(this.state.history[this.state.historyIndex]);this._isHistoryNav=false;},historyForward:function(){if(this.state.historyIndex>this.state.history.length-2)return false;this.state.historyIndex++;this._isHistoryNav=true;this.setActivePanel(this.state.history[this.state.historyIndex]);this._isHistoryNav=false;},historyLast:function(){if(this.state.historyIndex>this.state.history.length-2)return false;this.state.historyIndex=this.state.history.length-1;this._isHistoryNav=true;this.setActivePanel(this.state.history[this.state.historyIndex]);this._isHistoryNav=false;},_afterBody:function(ele,bEle,hEle,fEle){var tEle=0;var p={};for(var i=0;i<this.panels.length;i++){p=this.panels[i];$u.o.assign(p,this._pDefaults,true);p.src._name=p.name;p.src._title=p.title;tEle=p.src.create(this.contId+'.PANEL.'+i);tEle.style.position='absolute';tEle.style.top='';if(i!=0){tEle.style.top='-5000px';tEle.style.left='-5000px';}
this._transClearEvnt(tEle);bEle.appendChild(tEle);p._ele=tEle;var ctrlEle=false;if(p.controls.prev.has){ctrlEle=this._getPanelEleById(p.controls.prev.id,p);if(ctrlEle){p.controls.prev._b=new A5.Button(p.controls.prev.settings);p.controls.prev._b.bind(ctrlEle);$e.add(ctrlEle,A5.d.evnts.click,this.prevPanel,this,true);}}
if(p.controls.next.has){ctrlEle=this._getPanelEleById(p.controls.next.id,p);if(ctrlEle){p.controls.next._b=new A5.Button(p.controls.next.settings);p.controls.next._b.bind(ctrlEle);$e.add(ctrlEle,A5.d.evnts.click,this.nextPanel,this,true);}}}
if(this.indicator.show){var iEle=document.createElement('div');iEle.id=this.contId+'.INDICATOR';iEle.className=this.indicator.className;$e.add(iEle,A5.d.evnts.click,this._indClick,this);var loc=this.indicator.location.toLowerCase();if(loc[0]=='#')this._indLoc='element';else{if(loc=='auto'){if(this.flow=='ttb'||this.flow=='btt')loc='right';else loc='bottom';}
this._indLoc=loc;$ss(iEle,'position: absolute; '+loc+': 0px; z-index: 4; text-align: center;');}
var ipEle=0;for(var i=0;i<this.panels.length;i++){ipEle=document.createElement('div');if(i==0)ipEle.className=this._gDef(this.panels[i].indicator.className,this.indicator.panelClassName)+' '+this._gDef(this.panels[i].indicator.selectedClassName,this.indicator.panelSelectedClassName);else ipEle.className=this._gDef(this.panels[i].indicator.className,this.indicator.panelClassName);iEle.appendChild(ipEle);if(loc=='left'||loc=='right')iEle.appendChild(document.createElement('br'));}
if(this._indLoc=='element'){var icEle=this._getPanelEleById(loc.substr(1),ele);icEle.appendChild(iEle);}else{bEle.appendChild(iEle);if(this._indLoc=='left'||this._indLoc=='right'){iEle.style.marginTop='-'+(iEle.offsetHeight/2)+'px';iEle.style.top='50%';}else{iEle.style.marginLeft='-'+(iEle.offsetWidth/2)+'px';iEle.style.left='50%';}}}
this._panelIndx=0;if(this.panels.length==0)this._panelIndx=-1;else{this.state.history=[this.panels[this._panelIndx].name];this.state.historyIndex=0;}
this._setPanelState();bEle.style.padding='0px';if(this.type=='tabband'){var tbEle=document.createElement('div');tbEle.id=this.contId+'.TABBAND';$e.add(tbEle,'a5setactivepanel',this._tbChange,this);if(this.location=='bottom')ele.insertBefore(tbEle,fEle);else ele.insertBefore(tbEle,bEle);this._tabband=new A5.TabBand(tbEle,[],this.tabband);this._tabband.onChange=function(d){$sa(this._ele,'A5NEWNAVPANEL',d.value);$e.execute(this._ele,'a5setactivepanel');};this._tbSet=true;for(var i=0;i<this.panels.length;i++){this._tabband.add({html:this.panels[i].title,value:this.panels[i].name});}
this._tabband.select(this.state.activePanel);}else if(this.type=='carousel'){this._setPanelInfo(bEle);var a='x';if(this.flow=='ttb'||this.flow=='btt')a='y';var endFunc='$sa(this,\'A5PanelNavSwipe\',\'none\');\n$e.execute(this,\'a5carouselend\');';if(this.swipe.allow){var endFunc=['var d = arguments[0];','vX = $u.n.round((d.startX-d.x)/Math.round(d.endT-d.startT),2);','vY = $u.n.round((d.startY-d.y)/Math.round(d.endT-d.startT),2);','var swipe = \'none\';','if(Math.max(Math.abs(vX),Math.abs(vY)) > '+this.swipe.velocity+'){',' if(Math.abs(vX) > Math.abs(vY)){','  if(vX > 0) swipe = \'left\';','  else swipe = \'right\';',' } else{','  if(vX > 0) swipe = \'up\';','  else swipe = \'down\';',' }','}','$sa(this,\'A5PanelNavSwipe\',swipe);','$e.execute(this,\'a5carouselend\');'].join('\n');}
A5.u.drag.add(bEle,'custom',{axis:a,stopPropagation:true,_canAnim:this._canAnim,_anim:this._anim,tolerance:15,onStart:function(d,i){var data=$ga(this,'A5PanelNavData').split(',');var pEle=$(data[1]);var nEle=$(data[2]);d._d={ele:$(data[0]),sp:'left',ap:'top',w:this.offsetWidth,h:this.offsetHeight};if(data[3]=='ttb'||data[3]=='btt'){d._d.sp='top';d._d.ap='left';if(data[3]=='btt'){d._d.bEle=nEle;d._d.aEle=pEle;}else{d._d.bEle=pEle;d._d.aEle=nEle;}}else if(data[3]=='rtl'){d._d.bEle=nEle;d._d.aEle=pEle;}else{d._d.bEle=pEle;d._d.aEle=nEle;}
if(i._canAnim){if(d._d.bEle!=false){d._d.bEle.style.top='0px';d._d.bEle.style.left='0px';}
if(d._d.aEle!=false){d._d.aEle.style.top='0px';d._d.aEle.style.left='0px';}
if(d._d.sp=='left'){if(d._d.bEle!=false)d._d.bEle.style[i._anim.tDOMProp]='translate(-100%,0px)';if(d._d.aEle!=false)d._d.aEle.style[i._anim.tDOMProp]='translate(100%,0px)';}else{if(d._d.bEle!=false)d._d.bEle.style[i._anim.tDOMProp]='translate(0px,-100%)';if(d._d.aEle!=false)d._d.aEle.style[i._anim.tDOMProp]='translate(0px,100%)';}}else{if(d._d.bEle!=false){d._d.bEle.style[d._d.sp]='-100%';d._d.bEle.style[d._d.ap]='0px';}
if(d._d.aEle!=false){d._d.aEle.style[d._d.sp]='100%';d._d.aEle.style[d._d.ap]='0px';}}
$e.execute(this,'a5carouselstart');},onMove:function(d,i,e){if(d._d.sp=='left'||d._d.sp=='right'){var s=d._d.w;var val=d.customMoveX;}else{var s=d._d.h;var val=d.customMoveY;}
val=Math.max(Math.min(val,s),s*-1);if(i._canAnim){if(d._d.sp=='left'){if(d._d.ele!=false)d._d.ele.style[i._anim.tDOMProp]='translate('+val+'px,0px)';if(d._d.bEle!=false)d._d.bEle.style[i._anim.tDOMProp]='translate('+(val-s)+'px,0px)';if(d._d.aEle!=false)d._d.aEle.style[i._anim.tDOMProp]='translate('+(s+val)+'px,0px)';}else{if(d._d.ele!=false)d._d.ele.style[i._anim.tDOMProp]='translate(0px,'+val+'px)';if(d._d.bEle!=false)d._d.bEle.style[i._anim.tDOMProp]='translate(0px,'+(val-s)+'px)';if(d._d.aEle!=false)d._d.aEle.style[i._anim.tDOMProp]='translate(0px,'+(s+val)+'px)';}}else{if(d._d.ele!=false)d._d.ele.style[d._d.sp]=val+'px';if(d._d.bEle!=false)d._d.bEle.style[d._d.sp]=(val-s)+'px';if(d._d.aEle!=false)d._d.aEle.style[d._d.sp]=(s+val)+'px';}},onEnd:Function(endFunc)});$e.add(bEle,'a5carouselstart',this._cStart,this,true);$e.add(bEle,'a5carouselend',this._cEnd,this,true);}
var ctrlEle=false;if(this.controls.prev.has){ctrlEle=this._getPanelEleById(this.controls.prev.id,ele,true);if(ctrlEle){this.controls.prev._b=new A5.Button(this.controls.prev.settings);this.controls.prev._b.bind(ctrlEle);if(this.panels.length==0||!this.loopNavigate)ctrlEle.style.display='none';$e.add(ctrlEle,A5.d.evnts.click,this.prevPanel,this,true);}}
if(this.controls.next.has){ctrlEle=this._getPanelEleById(this.controls.next.id,ele,true);if(ctrlEle){this.controls.next._b=new A5.Button(this.controls.next.settings);this.controls.next._b.bind(ctrlEle);if(this.panels.length==0)ctrlEle.style.display='none';$e.add(ctrlEle,A5.d.evnts.click,this.nextPanel,this,true);}}
if(this.controls.back.has){ctrlEle=this._getPanelEleById(this.controls.back.id,ele,true);if(ctrlEle){this.controls.back._b=new A5.Button(this.controls.back.settings);this.controls.back._b.bind(ctrlEle);ctrlEle.style.display='none';$e.add(ctrlEle,A5.d.evnts.click,this.historyBack,this,true);}}
if(this.controls.forward.has){ctrlEle=this._getPanelEleById(this.controls.forward.id,ele,true);if(ctrlEle){this.controls.forward._b=new A5.Button(this.controls.forward.settings);this.controls.forward._b.bind(ctrlEle);ctrlEle.style.display='none';$e.add(ctrlEle,A5.d.evnts.click,this.historyForward,this,true);}}
for(var i=0;i<this.controls.panels.length;i++){ctrlEle=this._getPanelEleById(this.controls.panels[i].id,ele,true);if(ctrlEle){this.controls.panels[i]._b=new A5.ButtonToggle(this.controls.panels[i].settings);this.controls.panels[i]._b.bind(ctrlEle);if(this.controls.panels[i].panel==this.state.activePanel)this.controls.panels[i]._b.setValue(true,ctrlEle);$e.add(ctrlEle,A5.d.evnts.click,this._activatePanel,this);$sa(ctrlEle,'A5LinkedPanel',this.controls.panels[i].panel);}}},_activatePanel:function(e,classInst){panel=$ga(this,'A5LinkedPanel');classInst.setActivePanel(panel);},_onSetSize:function(){var bEle=$(this.contId+'.BODY');if(this._panelIndx!=-1)this.panels[this._panelIndx].src.setSize(bEle.clientWidth,bEle.clientHeight,true);if(this.type=='tabband'){this._tabband.refresh();}
if(this._indLoc!='element'){var iEle=$(this.contId+'.INDICATOR');if(iEle){if(this._indLoc=='left'||this._indLoc=='right')iEle.style.marginTop='-'+(iEle.offsetHeight/2)+'px';else iEle.style.marginLeft='-'+(iEle.offsetWidth/2)+'px';}}},_getPanelIndx:function(panel){if(typeof panel=='number')return panel;for(var i=0;i<this.panels.length;i++){if(this.panels[i].name==panel){return i;}}
return-1},_tbChange:function(e,classInst){classInst._tbSet=false;classInst.setActivePanel($ga(this,'A5NEWNAVPANEL'));classInst._tbSet=true;},_indClick:function(e,classInst){if(this.offsetHeight>this.offsetWidth)var pos=(e.clientY-$gpt(this))-(this.offsetHeight/2);else var pos=(e.clientX-$gpl(this))-(this.offsetWidth/2);if(pos>0)classInst.nextPanel();else classInst.prevPanel();},_cStart:function(){var bEle=$(this.contId+'.BODY');if(this.state.hasPrevPanel)this.panels[this.state.prevPanelIndex].src.setSize(bEle.clientWidth,bEle.clientHeight,true);if(this.state.hasNextPanel)this.panels[this.state.nextPanelIndex].src.setSize(bEle.clientWidth,bEle.clientHeight,true);},_cEnd:function(){var bEle=$(this.contId+'.BODY');var data=$ga(bEle,'A5PanelNavData').split(',');var swipe=$ga(bEle,'A5PanelNavSwipe');var ele=$(data[0]);var pEle=$(data[1]);var nEle=$(data[2]);if(this.flow=='ttb'||this.flow=='btt'){var pOffset=$gpt(ele.parentNode);var offset=$gpt(ele)-pOffset;var size=bEle.offsetHeight;var aEle=false;if(pEle){if(Math.abs($gpt(pEle)-pOffset)<size)aEle=pEle;}
if(nEle){if(Math.abs($gpt(nEle)-pOffset)<size)aEle=nEle;}
if(this.flow=='ttb'){var pDir='bottom';var nDir='top';}else{var pDir='top';var nDir='bottom';}}else{var pOffset=$gpl(ele.parentNode);var offset=$gpl(ele)-pOffset;var size=bEle.offsetWidth;if(pEle){if(Math.abs($gpl(pEle)-pOffset)<size)aEle=pEle;}
if(nEle){if(Math.abs($gpl(nEle)-pOffset)<size)aEle=nEle;}
if(this.flow=='rtl'){pDir='left';nDir='right';}else{var pDir='right';var nDir='left';}}
var percent=(1/size)*Math.abs(offset);if(swipe==pDir&&this.state.hasPrevPanel){this.setActivePanel(this.state.prevPanel,percent);}else if(swipe==nDir&&this.state.hasNextPanel){this.setActivePanel(this.state.nextPanel,percent);}else if(Math.abs(offset)>15){if(percent>.5&&aEle){percent=(1-percent);this.setActivePanel(this.panels[Number(aEle.id.split('.').pop())].name,percent);}else{var animDir=offset;var animType='';if(this.flow=='ttb'||this.flow=='btt'){if(this.flow=='btt')animDir=animDir*-1;if(animDir>0)animType='slide-up';else animType='slide-down';}else{if(this.flow=='rtl')animDir=animDir*-1;if(animDir>0)animType='slide-left';else animType='slide-right';}
this._transEle(ele,aEle,animType,percent);}}},_setPanelInfo:function(bEle){var data=[];data.push(this.contId+'.PANEL.'+this._panelIndx);if(this.state.hasPrevPanel)data.push(this.contId+'.PANEL.'+this.state.prevPanelIndex);else data.push('');if(this.state.hasNextPanel)data.push(this.contId+'.PANEL.'+this.state.nextPanelIndex);else data.push('');data.push(this.flow);$sa(bEle,'A5PanelNavData',data.join(','));},_setPanelState:function(){var s=this.state;s.activePanel='';s.hasPrevPanel=false;s.prevPanel='';s.prevPanelIndex=-1;s.hasNextPanel=false;s.nextPanel='';s.nextPanelIndex=-1;if(this.panels.length!=0){s.activePanel=this.panels[this._panelIndx].name;if(this._panelIndx>0){s.hasPrevPanel=true;s.prevPanelIndex=this._panelIndx-1;s.prevPanel=this.panels[s.prevPanelIndex].name;}else if(this.loopNavigate){s.hasPrevPanel=true;s.prevPanelIndex=this.panels.length-1;s.prevPanel=this.panels[s.prevPanelIndex].name;}
if(this._panelIndx<=this.panels.length-2){s.hasNextPanel=true;s.nextPanelIndex=this._panelIndx+1;s.nextPanel=this.panels[s.nextPanelIndex].name;}else if(this.loopNavigate){s.hasNextPanel=true;s.nextPanelIndex=0;s.nextPanel=this.panels[s.nextPanelIndex].name;}}
if(s.historyIndex>0){s.hasHistoryBack=true;s.historyBack=s.history[s.historyIndex-1];}else{s.hasHistoryBack=false;s.historyBack='';}
if(s.historyIndex<s.history.length-1){s.hasHistoryForward=true;s.historyForward=s.history[s.historyIndex+1];}else{s.hasHistoryForward=false;s.historyForward='';}
var iEle=$(this.contId+'.INDICATOR');if(iEle){var ipEles=iEle.getElementsByTagName('div');for(var i=0;i<ipEles.length;i++)ipEles[i].className=this._gDef(this.panels[i].indicator.className,this.indicator.panelClassName);if(this.panels.length!=0)ipEles[this._panelIndx].className=this._gDef(this.panels[this._panelIndx].indicator.className,this.indicator.panelClassName)+' '+this._gDef(this.panels[this._panelIndx].indicator.selectedClassName,this.indicator.panelSelectedClassName);}},_transEle:function(ele,oEle,type){var percent=typeof arguments[3]!='undefined'?arguments[3]:0;var doAnim=typeof arguments[4]!='undefined'?arguments[4]:true;if(percent==1)return false;var nVal='';var oVal='';var cssProp=this._anim.tProp;var cssDOMProp=this._anim.tDOMProp;var cssAnimProp=this._anim.prop;if(this._canAnim){if(type=='slide-left'){if(percent==0)ele.style[cssDOMProp]=this._transGetCSSVal('100%','0px');ele.style.top='1px';ele.style.left='1px';nVal=this._transGetCSSVal('0px','0px');oVal=this._transGetCSSVal('-100%','0px');}else if(type=='slide-right'){if(percent==0)ele.style[cssDOMProp]=this._transGetCSSVal('-100%','0px');ele.style.top='1px';ele.style.left='1px';nVal=this._transGetCSSVal('0px','0px');oVal=this._transGetCSSVal('100%','0px');}else if(type=='slide-up'){if(percent==0)ele.style[cssDOMProp]=this._transGetCSSVal('0px','100%');ele.style.top='1px';ele.style.left='1px';nVal=this._transGetCSSVal('0px','0px');oVal=this._transGetCSSVal('0px','-100%');}else if(type=='slide-down'){if(percent==0)ele.style[cssDOMProp]=this._transGetCSSVal('0px','-100%');ele.style.top='1px';ele.style.left='1px';nVal=this._transGetCSSVal('0px','0px');oVal=this._transGetCSSVal('0px','100%');}else if(type=='fade'){cssProp='opacity';cssDOMProp='opacity';ele.style.opacity='0';ele.style.top='1px';ele.style.left='1px';nVal='1';oVal='0';}
ele.style[cssAnimProp]='';$sa(ele,'A5PanelNavIsActive','true');if(oEle){oEle.style[cssAnimProp]='';$sa(oEle,'A5PanelNavIsActive','false');}
var dur=this.animation.duration;var tween='ease-in-out';if(percent!=0){dur=Math.round(dur*percent);tween='ease-out';}
aArr=[];aArr.push('var ele = $(\''+ele.id+'\');');aArr.push('ele.style.top = \'0px\';');aArr.push('ele.style.left = \'0px\';');if(doAnim)aArr.push('ele.style[\''+cssAnimProp+'\'] = \''+cssProp+' '+dur+'ms '+tween+'\';');aArr.push('ele.style[\''+cssDOMProp+'\'] = \''+nVal+'\';');if(oEle){aArr.push('var oEle = $(\''+oEle.id+'\');');if(doAnim)aArr.push('oEle.style[\''+cssAnimProp+'\'] = \''+cssProp+' '+dur+'ms '+tween+'\';');aArr.push('oEle.style[\''+cssDOMProp+'\'] = \''+oVal+'\';');}
setTimeout(Function(aArr.join('\n')),0);}else{if(oEle)oEle.style.top='-5000px';ele.style.top='0px';ele.style.left='0px';}},_transClearEvnt:function(ele){if(A5.flags.isFireFox)$e.add(ele,'transitionend',function(e){if(e.target.id!=this.id)return true;this.style['MozTransition']='';this.style.top=$if($ga(ele,'A5PanelNavIsActive')=='true','0px','-5000px');this.style.left='0px';});else if(A5.flags.isOpera)$e.add(ele,'oTransitionEnd',function(e){if(e.target.id!=this.id)return true;this.style['OTransition']='';this.style.top=$if($ga(ele,'A5PanelNavIsActive')=='true','0px','-5000px');this.style.left='0px';});else $e.add(ele,'webkitTransitionEnd',function(e){if(e.target.id!=this.id)return true;this.style['WebkitTransition']='';this.style.top=$if($ga(ele,'A5PanelNavIsActive')=='true','0px','-5000px');this.style.left='0px';});},_transGetCSSVal:function(x,y){if(A5.flags.isOpera)return'translate('+x+','+y+')';else return'translate3d('+x+','+y+',0px)';},_pDefaults:{name:'',title:'',show:true,indicator:{className:'',selectedClassName:''},controls:{prev:{has:false,id:'{panel.id}.CTRL.PREV',settings:{layout:'text',html:'Back'}},next:{has:false,id:'{panel.id}.CTRL.NEXT',settings:{layout:'text',html:'Next'}}}}});A5.PanelLayout=Class.create(A5.PanelCard,{_initLow:function(panels,settings){this.panels=panels;$u.o.assign(this,{theme:'',override:'base',flow:'ltr',className:'',header:{show:false,html:'',className:'',style:0},body:{className:'',style:0},overlay:{show:false,html:''},footer:{show:false,html:'',className:'',style:0},dock:{method:'overlay',panel:{beforeClassName:'',afterClassName:''},flowLock:{has:true,className:''}},controls:{prev:{has:false,id:'{panel.id}.CTRL.PREV',settings:{layout:'text',html:'Back'}},next:{has:false,id:'{panel.id}.CTRL.NEXT',settings:{layout:'text',html:'Next'}},dock:[]},animation:{duration:400},state:{activePanel:'',firstPanel:'',lastPanel:'',flowCollapsed:'',hasPrevPanel:false,prevPanel:'',hasNextPanel:false,nextPanel:'',hasDockPanel:false,beforeDockPanels:[],afterDockPanels:[],dockPanelShown:false,currentDockPanel:''},onSize:0,onLayoutRefresh:0,onDockPanelShow:0,onDockPanelHide:0,onPanelActivate:0,_sizing:'',_flowSize:0,_altSize:0,_fpCollapsed:false,_fpActive:0,_fpFirst:0,_fpLast:0,_fpCollapseTrg:[],_beforeBody:0,_curDock:-1,_prevDock:-1,_panelType:'panelLayout',_name:'',_title:''});if(typeof settings.theme!='undefined')A5.themes.assign(this,settings.theme,'panelLayout');$u.o.assign(this,settings);A5.overrides.assign(this,'panelLayout',this.override);},refresh:function(){this._layoutRefresh(false);},getPanel:function(panel){var panelArr=panel.split(':');var pObj={};var pScope=this;var panelIndx=-1;while(panelArr.length>0){panelIndx=pScope._getPanelIndx(panelArr.shift());if(panelIndx!=-1){pObj=pScope.panels[panelIndx];pScope=pObj.src;}else return false;}
return pObj;},setActivePanel:function(panel){if(window.event){if(window.event.type=='touchend'||window.event.type=='touchstart'){$e.preventDefault(window.event);}}
if(panel=='')return false;var panelArr=panel.split(':');panel=panelArr.shift();var panelIndx=this._getPanelIndx(panel);var fpCollapseIndx=0
for(var i=this._fpCollapseTrg.length-1;i>=0;i--){fpCollapseIndx=this._getPanelIndx(this._fpCollapseTrg[i]);if(fpCollapseIndx>panelIndx){this._fpCollapseTrg.pop();if(this.panels[fpCollapseIndx].controls.flowCollapse.has)this.panels[fpCollapseIndx].controls.flowCollapse._b.setValue(0);}else break;}
if(this._fpCollapseTrg.length==0)this.state.flowCollapsed=false;if(panelIndx>-1){var p=this.panels[panelIndx];clearTimeout(p._hideTimeout);var pPrev=false;if(this._prevDock>-1)pPrev=this.panels[this._prevDock];if(p.isDocked){if(this._curDock!=panelIndx){var doEle=$(this.contId+'.DOCKOVERLAY');if(this.dock.flowLock.has)doEle.style.display='';var tEle=p._ele;if(this.flow!='rtl')tEle.style.left='';else tEle.style.right='';var aArr=[];var lAfter=p.dock.search('after')!=-1
if(this.dock.method=='underlay'){var cEle=$(this.contId+'.BODY').firstChild;var sPos=0;if(pPrev){if(this._prevDock==this._curDock&&lAfter==(pPrev.dock.search('after')!=-1)){this._transEle(pPrev._ele,aArr,pPrev._size*-1,p._size*-1,lAfter,null,null,arguments[1]);sPos=pPrev._size;}
pPrev._ele.style.zIndex=1;}
this._transEle(tEle,aArr,sPos*-1,p._size*-1,lAfter,null,null,arguments[1]);this._transEle(cEle,aArr,sPos,p._size,lAfter,true,null,arguments[1]);tEle.style.zIndex=2;}else{this._transEle(tEle,aArr,p._size*-1,0,lAfter,null,null,arguments[1]);if(pPrev){if(this._prevDock==this._curDock)this._transEle(pPrev._ele,aArr,0,pPrev._size*-1,pPrev.dock.search('after')!=-1,null,null,arguments[1]);pPrev._ele.style.zIndex=4;}
tEle.style.zIndex=5;}
if(this.flow=='ttb'||this.flow=='btt')p.src.setSize(this._altSize,p._size,true);else p.src.setSize(p._size,this._altSize,true);setTimeout(Function(aArr.join('\n')),0);this._curDock=panelIndx;this._prevDock=panelIndx;this.state.dockPanelShown=true;this.state.currentDockPanel=panel;var state=false;for(var i=0;i<this.controls.dock.length;i++){if(this.controls.dock[i]._b){state=false;if(this.controls.dock[i].panel==this.state.currentDockPanel)state=true;this.controls.dock[i]._b.setValue(state)}}
if(this.onDockPanelShow.constructor==Function)this.onDockPanelShow();}}else{this.hideDock();if(p._hidden){p.show=true;this._fpActive=panelIndx;this._layoutRefresh(true);}}}
if(panelArr.length!=0&&(this.panels[panelIndx].src._panelType=='panelNavigator'||this.panels[panelIndx].src._panelType=='panelLayout'))this.panels[panelIndx].src.setActivePanel(panelArr.join(':'),false);if(this.onPanelActivate.constructor==Function)this.onPanelActivate();},firstPanel:function(){for(var i=0;i<this.panels.length;i++){p=this.panels[i];if(p.show&&p.dock!='collapse-before'&&p.dock!='collapse-after'&&p.dock!='auto-collapse-before'&&p.dock!='auto-collapse-after'){this.setActivePanel(p.name);break;}}},prevPanel:function(){if(this.state.hasPrevPanel)this.setActivePanel(this.state.prevPanel);},nextPanel:function(){if(this.state.hasNextPanel)this.setActivePanel(this.state.nextPanel);},lastPanel:function(){for(var i=this.panels.length-1;i>=0;i--){p=this.panels[i];if(p.show&&p.dock!='collapse-before'&&p.dock!='collapse-after'&&p.dock!='auto-collapse-before'&&p.dock!='auto-collapse-after'){this.setActivePanel(p.name);break;}}},hideDock:function(){if(this._curDock==-1)return false;var panelIndx=this._curDock;this._curDock=-1;var doEle=$(this.contId+'.DOCKOVERLAY');doEle.style.display='none';var tEle=this.panels[panelIndx]._ele;var aArr=[];var lAfter=this.panels[panelIndx].dock.search('after')!=-1
if(this.dock.method=='underlay'){var cEle=$(this.contId+'.BODY').firstChild;this._transEle(tEle,aArr,this.panels[panelIndx]._size*-1,0,lAfter);this._transEle(cEle,aArr,this.panels[panelIndx]._size,0,lAfter,true);}else{this._transEle(tEle,aArr,0,this.panels[panelIndx]._size*-1,lAfter);}
setTimeout(Function(aArr.join('\n')),0);this.state.dockPanelShown=false;this.state.currentDockPanel='';for(var i=0;i<this.controls.dock.length;i++){if(this.controls.dock[i]._b)this.controls.dock[i]._b.setValue(false)}
if(this.onDockPanelHide.constructor==Function)this.onDockPanelHide();},collapseFlow:function(panel){var panelIndx=this._getPanelIndx(panel);if(panelIndx!=-1){if(this.state.flowCollapsed){if(this._fpCollapseTrg[this._fpCollapseTrg.length-1]==panelIndx)return false;}
this._fpCollapseTrg.push(panelIndx);this._fpActive=panelIndx;this.state.flowCollapsed=true;if(this.panels[panelIndx].controls.flowCollapse.has)this.panels[panelIndx].controls.flowCollapse._b.setValue(1);this._layoutRefresh(true);}},expandFlow:function(){var fpCollapseIndx=0;if(arguments[0]){for(var i=0;i<this._fpCollapseTrg.length;i++){fpCollapseIndx=this._getPanelIndx(this._fpCollapseTrg[i]);if(this.panels[fpCollapseIndx].controls.flowCollapse.has)this.panels[fpCollapseIndx].controls.flowCollapse._b.setValue(0);}
this._fpCollapseTrg=[];}else{fpCollapseIndx=this._fpCollapseTrg.pop();fpCollapseIndx=this._getPanelIndx(fpCollapseIndx);if(this.panels[fpCollapseIndx].controls.flowCollapse.has)this.panels[fpCollapseIndx].controls.flowCollapse._b.setValue(0);}
if(this._fpCollapseTrg.length==0)this.state.flowCollapsed=false;this._layoutRefresh(true);},_afterBody:function(ele,bEle){var cEle=bEle.firstChild;this._transClearEvnt(cEle);$e.add(cEle,'a5transpost',this._transPost,this);if(this.flow=='btt'||this.flow=='rtl'){for(var i=this.panels.length-1;i>-1;i--)this._createPanel(cEle,i);}else{for(var i=0;i<this.panels.length;i++)this._createPanel(cEle,i);}
bEle.style.padding='0px';var ctrlEle=false;if(this.controls.prev.has){ctrlEle=this._getPanelEleById(this.controls.prev.id,ele,true);if(ctrlEle){this.controls.prev._b=new A5.Button(this.controls.prev.settings);this.controls.prev._b.bind(ctrlEle);$e.add(ctrlEle,A5.d.evnts.click,this.prevPanel,this,true);}}
if(this.controls.next.has){ctrlEle=this._getPanelEleById(this.controls.next.id,ele,true);if(ctrlEle){this.controls.next._b=new A5.Button(this.controls.next.settings);this.controls.next._b.bind(ctrlEle);$e.add(ctrlEle,A5.d.evnts.click,this.nextPanel,this,true);}}
for(var i=0;i<this.controls.dock.length;i++){ctrlEle=this._getPanelEleById(this.controls.dock[i].id,ele,true);if(ctrlEle){this.controls.dock[i]._b=new A5.ButtonToggle(this.controls.dock[i].settings);this.controls.dock[i]._b.bind(ctrlEle);$e.add(ctrlEle,A5.d.evnts.click,this._showDock,this);$sa(ctrlEle,'A5LinkedPanel',this.controls.dock[i].panel);}}},_createPanel:function(cEle,i){var p=this.panels[i];$u.o.assign(p,this._pDefaults,true);p.src._name=p.name;p.src._title=p.title;this.panels[i]._flex=-1;var curPanelSize=this.panels[i].size;if(curPanelSize.substr(0,5)=='flex('){this.panels[i]._flex=$u.s.toNum(curPanelSize.substr(5));curPanelSize=this.panels[i].minSize;}
if(typeof curPanelSize!='number')curPanelSize=A5.u.convertUnits(curPanelSize,'px');this.panels[i]._size=curPanelSize;var tEle=p.src.create(this.contId+'.PANEL.'+i);tEle.style.position='absolute';if(this.flow!='btt')tEle.style.top='0px';else tEle.style.bottom='0px';if(this.flow!='rtl')tEle.style.left='0px';else tEle.style.right='0px';tEle.style.zIndex=3;$sa(tEle,'A5PanelIndex',''+i);$e.add(tEle,'a5transpost',this._transPost,this);this._transClearEvnt(tEle);cEle.appendChild(tEle);p._ele=tEle;var ctrlEle=false;if(p.controls.prev.has){ctrlEle=this._getPanelEleById(p.controls.prev.id,p);if(ctrlEle){p.controls.prev._b=new A5.Button(p.controls.prev.settings);p.controls.prev._b.bind(ctrlEle);$e.add(ctrlEle,A5.d.evnts.click,this.prevPanel,this,true);}}
if(p.controls.next.has){ctrlEle=this._getPanelEleById(p.controls.next.id,p);if(ctrlEle){p.controls.next._b=new A5.Button(p.controls.next.settings);p.controls.next._b.bind(ctrlEle);$e.add(ctrlEle,A5.d.evnts.click,this.nextPanel,this,true);}}
if(p.controls.flowCollapse.has){ctrlEle=this._getPanelEleById(p.controls.flowCollapse.id,p);if(ctrlEle){var s=[];s.push(p.controls.flowCollapse.states.collapse);s.push(p.controls.flowCollapse.states.expand);p.controls.flowCollapse.settings.type='multi-state';$u.o.assign(p.controls.flowCollapse.settings,p.controls.flowCollapse.states.collapse);p.controls.flowCollapse._b=new A5.ButtonToggle(p.controls.flowCollapse.settings,s);p.controls.flowCollapse._b.bind(ctrlEle);$sa(ctrlEle,'A5LinkedPanel',p.name);$e.add(ctrlEle,A5.d.evnts.click,this._toggleFlowCollapse,this);}}},_layoutRefresh:function(anim){var p=0;this._transEle($(this.contId+'.BODY').firstChild,false,0,0);var flowSize=this._flowSize;var altSize=this._altSize;var curMinTotalSizeWDock=0
for(var i=0;i<this.panels.length;i++){p=this.panels[i];if(p.show&&p.dock!='collapse-before'&&p.dock!='collapse-after')curMinTotalSizeWDock+=p._size;}
var newFPFirst=-1;var newFPLast=0;var newFPTotalFixedWidth=0;var newFPTotalFlexVal=0;var newFPHasFlex=false;var curFPCollapse=-1;if(this._fpCollapseTrg.length!=0)curFPCollapse=this._fpCollapseTrg[this._fpCollapseTrg.length-1];var curPanelSize=0;var curTotalSize=0;var flagCD=curMinTotalSizeWDock>flowSize;var curFPCollapseCanExpand=false;for(var i=this._fpActive;i<this.panels.length;i++){p=this.panels[i];if(p.show&&p.dock!='collapse-before'&&p.dock!='collapse-after'&&!(flagCD&&(p.dock=='auto-collapse-before'||p.dock=='auto-collapse-after'))){if(newFPFirst==-1)newFPFirst=i;curPanelSize=p._size;if(curTotalSize+curPanelSize<=flowSize||newFPFirst==i){newFPLast=i;if(p._flex==-1)newFPTotalFixedWidth+=curPanelSize;else newFPTotalFlexVal+=p._flex;curTotalSize+=curPanelSize;}else break;}}
if(newFPFirst>0&&curTotalSize<flowSize){for(var i=newFPFirst-1;i>=0;i--){p=this.panels[i];if(p.show&&p.dock!='collapse-before'&&p.dock!='collapse-after'&&!(flagCD&&(p.dock=='auto-collapse-before'||p.dock=='auto-collapse-after'))){curPanelSize=p._size;if(i<curFPCollapse){if(curTotalSize+curPanelSize<=flowSize)curFPCollapseCanExpand=true;break;}
if(curTotalSize+curPanelSize<=flowSize){newFPFirst=i;if(p._flex==-1)newFPTotalFixedWidth+=curPanelSize;else newFPTotalFlexVal+=p._flex;curTotalSize+=curPanelSize;}else break;}}}
if(curTotalSize!=newFPTotalFixedWidth)newFPHasFlex=true;var oldFPFirst=this._fpFirst;var oldFPLast=this._fpLast;this._fpFirst=newFPFirst;this._fpLast=newFPLast;var totalFlexWidth=flowSize-newFPTotalFixedWidth;var curOffset=0;var tEle=0;var aArr=[];this.state.firstPanel=this.panels[newFPFirst].name;this.state.lastPanel=this.panels[newFPLast].name;this.state.activePanel=this._fpActive<newFPFirst?this.state.firstPanel:this.panels[this._fpActive].name;this.state.hasPrevPanel=false;this.state.prevPanel='';this.state.hasNextPanel=false;this.state.nextPanel='';this.state.hasDockPanel=false;this.state.beforeDockPanels=[];this.state.afterDockPanels=[];var lateSize=false;for(var i=0;i<this.panels.length;i++){p=this.panels[i];tEle=p._ele;if(p.show&&i>=newFPFirst&&i<=newFPLast&&p.dock!='collapse-before'&&p.dock!='collapse-after'&&!(flagCD&&(p.dock=='auto-collapse-before'||p.dock=='auto-collapse-after'))){if(this.flow!='rtl')tEle.style.left='0px';else tEle.style.right='0px';curPanelSize=p._size;if(p._flex!=-1)curPanelSize=Math.round((totalFlexWidth/newFPTotalFlexVal)*p._flex);if(i==newFPLast)curPanelSize=flowSize-curOffset;lateSize=p._curSize>curPanelSize&&anim;if(anim){if(!p._hidden)this._transEle(tEle,aArr,p._curOffset,curOffset,false,false,lateSize);else if(i>oldFPLast)this._transEle(tEle,aArr,flowSize,curOffset,false,false,lateSize);else this._transEle(tEle,false,0,curOffset,false);}else this._transEle(tEle,false,0,curOffset,false);if(!lateSize){if(this.flow=='ttb'||this.flow=='btt')p.src.setSize(altSize,curPanelSize,true);else p.src.setSize(curPanelSize,altSize,true);}else if(p._altSize!=altSize){if(this.flow=='ttb'||this.flow=='btt')p.src.setSize(altSize,p._curSize,true);else p.src.setSize(p._curSize,altSize,true);}
tEle.style.zIndex=3;p.isDocked=false;p._hidden=false;p._curOffset=curOffset;p._curSize=curPanelSize;p._altSize=altSize;curOffset+=curPanelSize;if(p.dock.search('collapse')!=-1){if(p.dock.search('after')!=-1&&this.dock.panel.afterClassName!='')$rcn(tEle,this.dock.panel.afterClassName);else if(this.dock.panel.beforeClassName!='')$rcn(tEle,this.dock.panel.beforeClassName);}
if(this._curDock==i)this._curDock=-1;if(p.controls.prev.has){if(this.state.hasPrevPanel&&i==newFPFirst)p.controls.prev._b.setDisplay(true);else p.controls.prev._b.setDisplay(false);}
if(p.controls.next.has)p.controls.next._b.setDisplay(false);if(p.controls.flowCollapse.has){if(this.state.hasPrevPanel)p.controls.flowCollapse._b.setDisplay(false);else p.controls.flowCollapse._b.setDisplay(true);}}else{if(!p._hidden){if(i>newFPLast)this._transEle(tEle,aArr,p._curOffset,flowSize,false);else{tEle.style.zIndex=1;p._hideTimeout=setTimeout(Function('$(\''+tEle.id+'\').style.'+$if(this.flow!='rtl','left','right')+' = \'-5000px\';'),this.animation.duration+100);}}else{if(i>newFPLast)this._transEle(tEle,false,flowSize,flowSize,false);else if(tEle.style.left!='-5000px'&&tEle.style.right!='-5000px'){p._hideTimeout=setTimeout(Function('$(\''+tEle.id+'\').style.'+$if(this.flow!='rtl','left','right')+' = \'-5000px\';'),this.animation.duration+100);}
tEle.style.zIndex=1;}
if(p.dock.search('collapse')!=-1){p.isDocked=true;this.state.hasDockPanel=true;if(p.dock.search('after')!=-1){this.state.afterDockPanels.push(p.name);if(this.dock.panel.afterClassName!='')$acn(tEle,this.dock.panel.afterClassName);}else{this.state.beforeDockPanels.push(p.name);if(this.dock.panel.beforeClassName!='')$acn(tEle,this.dock.panel.beforeClassName);}}else if(i<newFPFirst&&(i>=curFPCollapse||!curFPCollapseCanExpand)&&p.show){this.state.hasPrevPanel=true;this.state.prevPanel=p.name;}else if(i>newFPLast&&p.show&&!this.state.nextPanel){this.state.hasNextPanel=true;this.state.nextPanel=p.name;}
p._hidden=true;if(this._curDock==i){if(p.isDocked){clearTimeout(p._hideTimeout);var lAfter=p.dock.search('after')!=-1;if(this.dock.method=='underlay'){var cEle=$(this.contId+'.BODY').firstChild;var sPos=0;this._transEle(tEle,false,sPos*-1,p._size*-1,lAfter);this._transEle(cEle,false,sPos,p._size,lAfter,true);tEle.style.zIndex=2;}else{this._transEle(tEle,false,p._size*-1,0,lAfter);tEle.style.zIndex=5;}}else{this._curDock=-1;var doEle=$(this.contId+'.DOCKOVERLAY');if(this.dock.flowLock.has)doEle.style.display='none';}}}}
if(anim)setTimeout(Function(aArr.join('\n')),0);if(this.controls.prev.has){if(this.state.hasPrevPanel)this.controls.prev._b.setDisplay(true);else this.controls.prev._b.setDisplay(false);}
p=this.panels[newFPLast];if(p.controls.next.has&&this.state.hasNextPanel)p.controls.next._b.setDisplay(true);if(this.controls.next.has){if(this.state.hasNextPanel)this.controls.next._b.setDisplay(true);else this.controls.next._b.setDisplay(false);}
var d=0;var state=false;for(var i=0;i<this.controls.dock.length;i++){d=this.controls.dock[i];state=false;if(d._b){if(d.panel=='*generic'){if(this.state.hasDockPanel)state=true;}else if(d.panel=='*before'){if(this.state.beforeDockPanels.length>0)state=true;}else if(d.panel=='*after'){if(this.state.afterDockPanels.length>0)state=true;}else if(this.panels[this._getPanelIndx(d.panel)].isDocked)state=true;d._b.setDisplay(state);}}
if(this.onLayoutRefresh.constructor==Function)this.onLayoutRefresh();},_onSetSize:function(){var bEle=$(this.contId+'.BODY');var cEle=bEle.firstChild;var doEle=$(this.contId+'.DOCKOVERLAY');var cWidth=bEle.clientWidth;var cHeight=bEle.clientHeight;this._flowSize=cWidth;this._altSize=cHeight;if(this.flow=='ttb'||this.flow=='btt'){this._flowSize=cHeight;this._altSize=cWidth;}
cEle.style.width=cWidth+'px';cEle.style.height=cHeight+'px';doEle.style.width=cWidth+'px';doEle.style.height=cHeight+'px';this._layoutRefresh(false);},_showDock:function(e,classInst){panel=$ga(this,'A5LinkedPanel');var panelIndx=classInst._getPanelIndx(panel);if(panelIndx>-1){if($ga(this,'A5ButtonState')!='true')classInst.hideDock();else classInst.setActivePanel(panel);}else{var menuItems=[];var genSingleDock=(classInst.state.beforeDockPanels.length+classInst.state.afterDockPanels.length==1&&panel=='*generic');var p=0;if(panel=='*before'||panel=='*generic'){if((classInst.state.beforeDockPanels.length==1&&panel=='*after')||genSingleDock){classInst.setActivePanel(classInst.state.beforeDockPanels[0]);return true;}
for(var i=0;i<classInst.state.beforeDockPanels.length;i++){p=classInst.panels[classInst._getPanelIndx(classInst.state.beforeDockPanels[i])];menuItems.push({html:p.name,value:p.name});}}
if(panel=='*after'||panel=='*generic'){if((classInst.state.afterDockPanels.length==1&&panel=='*after')||genSingleDock){classInst.setActivePanel(classInst.state.afterDockPanels[0]);return true;}
for(var i=0;i<classInst.state.afterDockPanels.length;i++){p=classInst.panels[classInst._getPanelIndx(classInst.state.afterDockPanels[i])];menuItems.push({html:p.name,value:p.name});}}
if(!classInst._dMenu)classInst._dMenu=new A5.Menu([],{theme:classInst.theme,iconColumn:{show:false},onClick:function(item){pl1Obj.setActivePanel(item.value);}});classInst._dMenu.populate(menuItems);classInst._dMenu.show('dropdown',this);}},_toggleFlowCollapse:function(e,classInst){var panel=$ga(this,'A5LinkedPanel');if(classInst.state.flowCollapsed){if(classInst._fpCollapseTrg[classInst._fpCollapseTrg.length-1]==classInst._getPanelIndx(panel))classInst.expandFlow();else classInst.collapseFlow(panel);}else classInst.collapseFlow(panel);},_getPanelIndx:function(panel){if(typeof panel=='number')return panel;panel=panel.toLowerCase();for(var i=0;i<this.panels.length;i++){if(this.panels[i].name.toLowerCase()==panel)return i;}
return-1;},_transEle:function(ele,aArr,sVal,eVal,after,alwaysTL,lateSize){var doAnim=typeof arguments[7]=='boolean'?arguments[7]:true;var mLoc=this._locVals[this.flow.substr(0,1)];var aLoc=this._locVals[this.flow.substr(2,1)];if(after){var tLoc=mLoc;mLoc=aLoc;aLoc=tLoc;}
if(alwaysTL){if(mLoc=='bottom'||mLoc=='right'){var tLoc=mLoc;mLoc=aLoc;aLoc=tLoc;sVal=sVal*-1;eVal=eVal*-1;}}
if(ele.style[mLoc]==''){ele.style[mLoc]='0px';ele.style[aLoc]='';}
var cssProp=mLoc;var cssDOMProp=mLoc;var cssAnimProp='';if(this._canAnim){if(mLoc=='left'){sVal='translate3d('+sVal+'px,0px,0px)';eVal='translate3d('+eVal+'px,0px,0px)';}else if(mLoc=='right'){sVal='translate3d('+(sVal*-1)+'px,0px,0px)';eVal='translate3d('+(eVal*-1)+'px,0px,0px)';}else if(mLoc=='top'){sVal='translate3d(0px,'+sVal+'px,0px)';eVal='translate3d(0px,'+eVal+'px,0px)';}else if(mLoc=='bottom'){sVal='translate3d(0px,'+(sVal*-1)+'px,0px)';eVal='translate3d(0px,'+(eVal*-1)+'px,0px)';}
cssProp=this._anim.tProp;cssDOMProp=this._anim.tDOMProp;cssAnimProp=this._anim.prop;if(A5.flags.isOpera){sVal='translate('+$u.s.word($u.s.word(sVal,2,'('),1,',0px)')+')';eVal='translate('+$u.s.word($u.s.word(eVal,2,'('),1,',0px)')+')';}}else{sVal=sVal+'px';eVal=eVal+'px';}
if(aArr.constructor==Array){ele.style[cssDOMProp]=sVal;aArr.push('var tEle = $(\''+ele.id+'\');');aArr.push('tEle.style[\''+cssDOMProp+'\'] = \''+eVal+'\';');if(doAnim)aArr.push('tEle.style[\''+cssAnimProp+'\'] = \''+cssProp+' '+this.animation.duration+'ms ease-in-out\';');}else{ele.style[cssDOMProp]=eVal;}
if(lateSize||ele.id==this.contId+'.BODYINNER')$sa(ele,'A5PanelTransPost','true');else $sa(ele,'A5PanelTransPost','false');},_transClearEvnt:function(ele){if(A5.flags.isFireFox)$e.add(ele,'transitionend',Function('if(arguments[0].target.id != this.id) return true; this.style[\'MozTransition\'] = \'\'; if($ga(this,\'A5PanelTransPost\') == \'true\'){ $e.execute(this,\'a5transpost\');}'));else if(A5.flags.isOpera)$e.add(ele,'oTransitionEnd',Function('if(arguments[0].target.id != this.id) return true; this.style[\'OTransition\'] = \'\'; if($ga(this,\'A5PanelTransPost\') == \'true\'){ $e.execute(this,\'a5transpost\');}'));else $e.add(ele,'webkitTransitionEnd',Function('if(arguments[0].target.id != this.id) return true; this.style[\'WebkitTransition\'] = \'\'; if($ga(this,\'A5PanelTransPost\') == \'true\'){ $e.execute(this,\'a5transpost\');}'));},_transPost:function(e,classInst){var panelIndx=Number(''+$ga(this,'A5PanelIndex'));if(!isNaN(panelIndx)){var curPanelSize=classInst.panels[panelIndx]._curSize;var altSize=classInst._altSize;if(this.flow=='ttb'||this.flow=='btt')classInst.panels[panelIndx].src.setSize(altSize,curPanelSize,true);else classInst.panels[panelIndx].src.setSize(curPanelSize,altSize,true);}},_pDefaults:{name:'',title:'',size:'flex(1)',minSize:0,dock:'',show:true,controls:{prev:{has:false,id:'{panel.id}.CTRL.PREV',settings:{layout:'text',html:'Back'}},next:{has:false,id:'{panel.id}.CTRL.NEXT',settings:{layout:'text',html:'Next'}},flowCollapse:{has:false,id:'{panel.id}.CTRL.FLOWCOLLAPSE',settings:{layout:'text'},states:{collapse:{html:'&laquo;'},expand:{html:'&raquo;'}}}},isDocked:false,_curOffset:0,_curSize:0,_altSize:0,_hidden:true},_locVals:{'l':'left','r':'right','b':'bottom','t':'top'}});A5.u.drag={simulateTouch:false,defaults:{custom:{tolerance:5},scroll:{theme:'',onPull:0,onPullRelease:0,onPullEnd:0,momentum:{allow:true,duration:1000},bounce:{allow:true},indicator:{show:true,h:{className:'',barClassName:''},v:{className:'',barClassName:''}}}},_w:{},_st:{},_i:{_a:false},_getTrans:function(x,y){if(A5.flags.isOpera)return'translate('+x+'px,'+y+'px)';else return'translate3d('+x+'px,'+y+'px,0px)';},_start:function(e){var d=A5.u.drag;var i=d._i;if(i._a)return true;i._a=true;i.startT=new Date().getTime();i.endT=false;var c=$e.getCoors(e);i.x=c.clientX;i.y=c.clientY;i.startX=i.x;i.startY=i.y;i.moveX=0;i.moveY=0;i.customMoveX=0;i.customMoveY=0;i.maxX=0;i.minX=0;i.maxY=0;i.minY=0;i.hasMomentum=false;i._s=false;i._cX=false;i._cY=false;i._cB=false;d._awe={};var stopEvent=false;var ele=this;var eId='';while(ele.tagName.toUpperCase()!='BODY'){eId=ele.id;if(eId!=''){if(typeof d._w[eId]!='undefined'){d._awe[eId]=ele;if(d._w[eId].p){stopEvent=true;break;}
if(d._w[eId].s&&!d._w[eId].s.disabled&&!i._s){var ss=d._w[eId].s;var cScrl=$ga(ele,'A5CustomScroll');var cSX=0;var cSY=0;if(cScrl){cScrl=cScrl.split(',');cSX=Number(cScrl[0]);cSY=Number(cScrl[1]);}
if(typeof ss._p=='undefined'){ss._p={t:0,b:0};var swcs={paddingTop:'',paddingBottom:''};if(typeof window.getComputedStyle!='undefined')swcs=window.getComputedStyle(ele);else if(ele.currentStyle)swcs=ele.currentStyle;if(swcs.paddingTop!='')ss._p.t=A5.u.convertUnits(swcs.paddingTop,'px');if(swcs.paddingBottom!='')ss._p.b=A5.u.convertUnits(swcs.paddingBottom,'px');ss._p.y=ss._p.t+ss._p.b;}
var sW=ele.scrollWidth+cSX;var sH=ele.firstChild.offsetHeight+ss._p.y;if(d._st[eId]){var swcs={};swcs[A5.u.css.properties.transformDOM]='';if(typeof window.getComputedStyle!='undefined')swcs=window.getComputedStyle(ele.firstChild);else if(ele.currentStyle)swcs=ele.firstChild.currentStyle;var transform={e:0,f:0};if(A5.flags.isFireFox||A5.flags.isOpera){var mRE=/matrix\(\s*-?\d+(?:\.\d+)?\s*,\s*-?\d+(?:\.\d+)?\s*,\s*-?\d+(?:\.\d+)?\s*,\s*-?\d+(?:\.\d+)?\s*\,\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)/;var mREM=swcs[A5.u.css.properties.transformDOM].match(mRE);if(mREM){transform.e=mREM[1];transform.f=mREM[2];}}else if(A5.flags.isIE){transform=new MSCSSMatrix(swcs[A5.u.css.properties.transformDOM]);}else{transform=new WebKitCSSMatrix(swcs[A5.u.css.properties.transformDOM]);}
cSX=Math.round(transform.e)*-1;cSY=Math.round(transform.f)*-1;clearInterval(d._st[eId].inter);delete d._st[eId];ele.firstChild.style[A5.u.css.properties.transitionDOM]='';ele.firstChild.style[A5.u.css.properties.transformDOM]=d._getTrans((cSX*-1),(cSY*-1));}
i._s={id:eId,iX:false,iY:false,x:false,y:false,vX:cSX,vY:cSY,cX:cSX,cY:cSY,sW:sW,sH:sH,mX:sW-ele.clientWidth,mY:sH-ele.clientHeight,oP:ss.onPull.constructor==Function,oPE:ss.onPullEnd.constructor==Function,oPF:ss.onPull,oPEF:ss.onPullEnd,b:ss.bounce.allow,pX:ele.offsetWidth/2,pY:ele.offsetHeight/2,pXP:0,pYP:0,oW:ele.offsetWidth,oH:ele.offsetHeight,xIBEle:false,yIBEle:false};if((ss.axis=='x'||ss.axis=='both')&&!i._cX&&ele.clientWidth<i._s.sW){i._s.x=true;if(ss.indicator.show){var sIEle=$(ele.id+'.SCROLLINDICATOR.X');if(!sIEle){sIEle=document.createElement('div');sIEle.id=ele.id+'.SCROLLINDICATOR.X';sIEle.className=ss.indicator.h.className;sIEle.style.left='0px';sIEle.style.bottom='0px';ele.appendChild(sIEle);$ss(sIEle,'position: absolute; overflow: hidden; bottom: 0px; left: 0px;');sIEle.innerHTML='<div class="'+ss.indicator.h.barClassName+'" style="position: absolute; top: 0px; left: 0px; font: 0px; width: 5px; height: 5px;"></div>';}
sIEle.style.display='';sIEle.style.width=ele.offsetWidth+'px';sIEle.style.display='none';var sIBEle=sIEle.firstChild;sIBEle.style.left=((i._s.vX/i._s.sW)*100)+'%';sIBEle.style.width=((ele.clientWidth/i._s.sW)*100)+'%';sIBEle.style.minWidth='10px';sIBEle.style[A5.u.css.properties.transitionDOM]='';i._s.xIBEle=sIBEle;}}
if((ss.axis=='y'||ss.axis=='both')&&!i._cY&&ele.clientHeight<i._s.sH){i._s.y=true;if(ss.indicator.show){var sIEle=$(ele.id+'.SCROLLINDICATOR.Y');if(!sIEle){sIEle=document.createElement('div');sIEle.id=ele.id+'.SCROLLINDICATOR.Y';sIEle.className=ss.indicator.v.className;ele.appendChild(sIEle);$ss(sIEle,'position: absolute; overflow: hidden; top: 0px; right: 0px;');sIEle.innerHTML='<div class="'+ss.indicator.v.barClassName+'" style="position: absolute; top: 0px; left: 0px; font: 0px; width: 5px; height: 5px;"></div>';}
sIEle.style.display='';sIEle.style.height=ele.offsetHeight+'px';sIEle.style.display='none';var sIBEle=sIEle.firstChild;sIBEle.style.top=((i._s.vY/i._s.sH)*100)+'%';sIBEle.style.height=((ele.clientHeight/i._s.sH)*100)+'%';sIBEle.style.minHeight='10px';sIBEle.style[A5.u.css.properties.transitionDOM]='';i._s.yIBEle=sIBEle;}}
if(ss.stopPropagation){if(!i._cX&&i._s.x)i._cX=true;if(!i._cY&&i._s.y)i._cY=true;}}
if(d._w[eId].c&&!d._w[eId].c.disabled){if(d._w[eId].c.axis=='x'&&!i._cX)i._cX={id:eId,l:false,a:false};else if(d._w[eId].c.axis=='y'&&!i._cY)i._cY={id:eId,l:false,a:false};else{if(!i._cX)i._cX={id:eId,l:false,a:false};if(!i._cY)i._cY={id:eId,l:false,a:false};}
if(i._cX!=false&&i._cY!=false)break;}}}
ele=ele.parentNode;}
if(i._cX==true)i._cX=false;if(i._cY==true)i._cY=false;if(!i._cX)i._cX={id:false,a:false,l:false};if(!i._cY)i._cY={id:false,a:false,l:false};if(i._cX.id&&i._cY.id){if(i._cX.id==i._cY.id)i._cB=true;}
if(i._s||i._cX.id||i._cY.id){if(e.type=='touchstart')i.eType='touch';else i.eType='mouse';if(i.eType=='touch'){$e.add(document.body,'touchmove',d._move);$e.add(document.body,'touchend',d._end);}else{$e.add(document.documentElement,'mousemove',d._move);$e.add(document.documentElement,'mouseup',d._end);}}else{i._a=false;if(stopEvent)$e.stopEvent(e);else $e.preventDefault(e);}},_move:function(e){$e.preventDefault(e);var d=A5.u.drag;var i=d._i;var c=$e.getCoors(e);if(Math.abs(i.x-c.clientX)>3||Math.abs(i.y-c.clientY)>3)i.hasMomentum=true;else i.hasMomentum=false;i.x=c.clientX;i.y=c.clientY;i.moveX=i.x-i.startX;i.moveY=i.y-i.startY;i.customMoveX=i.moveX;i.customMoveY=i.moveY;i.maxX=Math.max(i.moveX,i.maxX);i.minX=Math.min(i.moveX,i.minX);i.maxY=Math.max(i.moveY,i.maxY);i.minY=Math.min(i.moveY,i.minY);var useCX=true;var useCY=true;if(i._s){useCX=false;useCY=false;var oldPXP=i._s.pXP;var oldPYP=i._s.pYP;if(i._s.x){if(!i._s.iX){if(i._s.xIBEle&&i.moveX!=0){i._s.xIBEle.parentNode.style.display='';i._s.iX=true;}}
var sX=i._s.vX-i.moveX;if(sX<0||sX>i._s.mX){var oX=0;if(sX<0)oX=sX*-1;else if(sX>i._s.mX)oX=(sX-i._s.mX)*-1;if(i._cX.id){useCX=true;i.customMoveX=oX;}else{i._s.cX=sX;i._s.pXP=oX;}}else{i._s.cX=sX;i._s.pXP=0;i.customMoveX=0;if(i._cX.a){if(d._w[i._cX.id].c.onEnd&&!(i._cB&&i._cY.a))d._w[i._cX.id].c.onEnd.call(d._awe[i._cX.id],i,d._w[i._cX.id].c,e);i._cX.a=false;i._cY.l=false;}}
if(i._s.xIBEle)i._s.xIBEle.style.left=((i._s.cX/i._s.sW)*100)+'%';}else{if(i._s.y&&i._cX.id){if(Math.max(Math.abs(i.minY),i.maxY)<d._w[i._cX.id].c.tolerance)useCX=true;}else useCX=true;}
if(i._s.y){if(!i._s.iY){if(i._s.yIBEle&&i.moveY!=0){i._s.yIBEle.parentNode.style.display='';i._s.iY=true;}}
var sY=i._s.vY-i.moveY;if(sY<0||sY>i._s.mY){var oY=0;if(sY<0)oY=sY*-1;else if(sY>i._s.mY)oY=(sY-i._s.mY)*-1;if(i._cY.id){useCY=true;i.customMoveY=oY;}else{i._s.cY=sY;i._s.pYP=oY;}}else{i._s.cY=sY;i._s.pYP=0;i.customMoveY=0;if(i._cY.a){if(d._w[i._cY.id].c.onEnd&&!(i._cB&&i._cX.a))d._w[i._cY.id].c.onEnd.call(d._awe[i._cY.id],i,d._w[i._cY.id].c,e);i._cY.a=false;i._cX.l=false;}}
if(i._s.yIBEle)i._s.yIBEle.style.top=((i._s.cY/i._s.sH)*100)+'%';}else{if(i._s.x&&i._cY.id){if(Math.max(Math.abs(i.minX),i.maxX)<d._w[i._cY.id].c.tolerance)useCY=true;}else useCY=true;}
if(i._s.oP&&(i._s.pXP!=0||i._s.pYP!=0)){i._s.oPF.call(d._awe[i._s.id],i,d._w[i._s.id].s,i._s.pXP*-1,i._s.pYP*-1,e);}
if(i._s.oPE&&((i._s.pXP==0&&oldPXP!=0)||(i._s.pYP==0&&oldPYP!=0))){i._s.oPEF.call(d._awe[i._s.id],i,d._w[i._s.id].s,i._s.pXP*-1,i._s.pYP*-1,e);}
d._awe[i._s.id].firstChild.style[A5.u.css.properties.transformDOM]=d._getTrans((i._s.cX*-1),(i._s.cY*-1));$sa(d._awe[i._s.id],'A5CustomScroll',i._s.cX+','+i._s.cY);d._scrlEvnt(d._awe[i._s.id]);}
if(i._cB&&useCX&&useCY){if(i._cX.a&&i._cY.a){if(d._w[i._cX.id].c.onMove)d._w[i._cX.id].c.onMove.call(d._awe[i._cX.id],i,d._w[i._cX.id].c,e);}else if(Math.max(Math.abs(i.customMoveX),Math.abs(i.customMoveY))>d._w[i._cX.id].c.tolerance){if(d._w[i._cX.id].c.onStart)d._w[i._cX.id].c.onStart.call(d._awe[i._cX.id],i,d._w[i._cX.id].c,e);i._cX.a=true;i._cY.a=true;}}else{if(i._cX.id&&useCX&&!i._cX.l){if(i._cX.a){if(d._w[i._cX.id].c.onMove)d._w[i._cX.id].c.onMove.call(d._awe[i._cX.id],i,d._w[i._cX.id].c,e);}else if(Math.abs(i.customMoveX)>d._w[i._cX.id].c.tolerance){if(d._w[i._cX.id].c.onStart)d._w[i._cX.id].c.onStart.call(d._awe[i._cX.id],i,d._w[i._cX.id].c,e);i._cX.a=true;if(d._w[i._cX.id].c.stopPropagation)i._cY.l=true;}}
if(i._cY.id&&useCY&&!i._cY.l){if(i._cY.a){if(d._w[i._cY.id].c.onMove)d._w[i._cY.id].c.onMove.call(d._awe[i._cY.id],i,d._w[i._cY.id].c,e);}else if(Math.abs(i.customMoveY)>d._w[i._cY.id].c.tolerance){if(d._w[i._cY.id].c.onStart)d._w[i._cY.id].c.onStart.call(d._awe[i._cY.id],i,d._w[i._cY.id].c,e);i._cY.a=true;if(d._w[i._cY.id].c.stopPropagation)i._cX.l=true;}}}},_end:function(e){var d=A5.u.drag;var i=d._i;i._a=false;i.endT=new Date().getTime();if(i._cB&&i._cX.a&&i._cY.a){if(d._w[i._cX.id].c.onEnd)d._w[i._cX.id].c.onEnd.call(d._awe[i._cX.id],i,d._w[i._cX.id].c,e);}else if(i._cX.a){if(d._w[i._cX.id].c.onEnd)d._w[i._cX.id].c.onEnd.call(d._awe[i._cX.id],i,d._w[i._cX.id].c,e);}else if(i._cY.a){if(d._w[i._cY.id].c.onEnd)d._w[i._cY.id].c.onEnd.call(d._awe[i._cY.id],i,d._w[i._cY.id].c,e);}
if(i._s){if(d._w[i._s.id].s.onPullRelease.constructor==Function&&(i._s.pXP!=0||i._s.pYP!=0)){d._w[i._s.id].s.onPullRelease.call(d._awe[i._s.id],i,d._w[i._s.id].s,i._s.pXP*-1,i._s.pYP*-1,e);}
var ele=$(i._s.id);if(i.hasMomentum||i._s.pXP!=0||i._s.pYP!=0){var dT=i.endT-i.startT;var vX=(i._s.vX-i._s.cX)/dT;var vY=(i._s.vY-i._s.cY)/dT;var tX=i._s.x?i._s.cX-(vX*(d._w[i._s.id].s.momentum.duration/2)):i._s.cX;var tY=i._s.y?i._s.cY-(vY*(d._w[i._s.id].s.momentum.duration/2)):i._s.cY;tX=Math.round(Math.max(Math.min(tX,i._s.mX),0));tY=Math.round(Math.max(Math.min(tY,i._s.mY),0));ele.firstChild.style[A5.u.css.properties.transitionDOM]=A5.u.css.properties.transform+' '+d._w[i._s.id].s.momentum.duration+'ms ease';ele.firstChild.style[A5.u.css.properties.transformDOM]=d._getTrans((tX*-1),(tY*-1));d._st[ele.id]={w:i._s.sW,h:i._s.sH,inter:setInterval(Function('A5.u.drag._scrlEvnt($(\''+ele.id+'\'))'),50)};i._s.cX=tX;i._s.cY=tY;if(i._s.xIBEle){i._s.xIBEle.style[A5.u.css.properties.transitionDOM]='left '+d._w[i._s.id].s.momentum.duration+'ms ease';i._s.xIBEle.style.left=((i._s.cX/i._s.sW)*100)+'%';}
if(i._s.yIBEle){i._s.yIBEle.style[A5.u.css.properties.transitionDOM]='top '+d._w[i._s.id].s.momentum.duration+'ms ease';i._s.yIBEle.style.top=((i._s.cY/i._s.sH)*100)+'%';}}else{if(i._s.xIBEle)i._s.xIBEle.parentNode.style.display='none';if(i._s.yIBEle)i._s.yIBEle.parentNode.style.display='none';}
$sa(ele,'A5CustomScroll',i._s.cX+','+i._s.cY);}
this._awe={};if(i.eType=='touch'){$e.remove(document.body,'touchmove',A5.u.drag._move);$e.remove(document.body,'touchend',A5.u.drag._end);}else{$e.remove(document.documentElement,'mousemove',A5.u.drag._move);$e.remove(document.documentElement,'mouseup',A5.u.drag._end);}},_scrlTranEnd:function(e,classInst){if(classInst._st[this.parentNode.id]){clearInterval(classInst._st[this.parentNode.id].inter);delete classInst._st[this.parentNode.id];}
this.style[A5.u.css.properties.transitionDOM]='';var sIEle=$(this.parentNode.id+'.SCROLLINDICATOR.X')
if(sIEle)sIEle.style.display='none';var sIEle=$(this.parentNode.id+'.SCROLLINDICATOR.Y')
if(sIEle)sIEle.style.display='none';classInst._scrlEvnt(this.parentNode);},_scrlEvnt:function(ele){var evt=document.createEvent('UIEvent');evt.initEvent('scroll',true,true);ele.dispatchEvent(evt);},add:function(ele,t,s){var ieV=-1;if(/MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(navigator.userAgent)!=null)ieV=parseFloat(RegExp.$1);if(!A5.flags.supportsTouch&&t=='scroll'&&!(this.simulateTouch&&(ieV>10||ieV<0)))return false;ele=this._gEle(ele);this._add(ele);if(t=='scroll'){var fcEle=ele.firstChild;var fcId='';if(fcEle){if(typeof fcEle.tagName!='undefined')fcId=fcEle.id;}
if(fcId!=ele.id+'.SCROLLWRAPPER'){var swEle=document.createElement('div');swEle.id=ele.id+'.SCROLLWRAPPER';$e.add(swEle,A5.u.css.properties.transitionEndEvent,this._scrlTranEnd,this);for(var i=ele.childNodes.length-1;i>=0;i--){swEle.insertBefore(ele.childNodes[i],swEle.firstChild);}
ele.appendChild(swEle);}
var ts={};$u.o.assign(ts,this.defaults.scroll);if(typeof s.theme!='undefined')A5.themes.assign(ts,s.theme,'scroll');$u.o.assign(s,ts,true);if(typeof s.axis=='undefined')s.axis='both';if(typeof s.stopPropagation=='undefined')s.stopPropagation=false;this._w[ele.id].s=s;if(ele.style.position!='absolute')ele.style.position='relative';$sa(ele,'A5CustomScroll','0,0');if(!A5.flags.supportsTouch&&this.simulateTouch){ele.style.overflow='hidden';ele.style.overflowX='hidden';ele.style.overflowY='hidden';}}else if(t=='custom'){$u.o.assign(s,{axis:'both',tolerance:this.defaults.custom.tolerance,onStart:false,onMove:false,onEnd:false,disabled:false,stopPropagation:false},true);this._w[ele.id].c=s;}else if(t=='prevent')this._w[ele.id].p=true;},remove:function(ele,t){ele=$(ele);if(!this._w[ele.id])this._w[ele.id]={};if(t=='scroll')this._w[ele.id].s=false;else if(t=='custom')this._w[ele.id].c=false;else if(t=='prevent')this._w[ele.id].p=false;this._rem(ele);},setDisabled:function(ele,t,val){ele=$(ele);if(this._w[ele.id]){if(t=='scroll'&&this._w[ele.id].s){this._w[ele.id].s.disabled=val;ele.firstChild.style[A5.u.css.properties.transformDOM]=A5.u.drag._getTrans(0,0);}else if(this._w[ele.id].c)this._w[ele.id].c.disabled=val;}},_gEle:function(ele){ele=$(ele);ele.unselectable=true
$ss(ele,$gs(ele)+'; -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none;');if(ele.id=='')ele.id=A5.u.getUniqueId();return ele;},_add:function(ele){if(!this._w[ele.id]){this._w[ele.id]={c:false,s:false,p:false,i:{}};$e.add(ele,'abstractdown',this._start);$e.add(ele,'selectstart',function(e){$e.stopEvent($e.getEvent(e));return false;});$e.add(ele,'dragstart',function(e){$e.stopEvent($e.getEvent(e));return false;});}},_rem:function(ele){if(!this._w[ele.id].c&&!this._w[ele.id].s){$e.remove(ele,'abstractdown',this._start);$e.remove(ele,'selectstart',function(e){$e.stopEvent($e.getEvent(e));return false;});$e.remove(ele,'dragstart',function(e){$e.stopEvent($e.getEvent(e));return false;});delete this._w[ele.id];}}}
A5.flags={}
A5.flags.supportsTouch=navigator.userAgent.match(/android/i)||!!('createTouch'in document)
A5.flags.supportsMouse=!(navigator.userAgent.match(/(iPad|iPhone|iPod)/i)?true:false);if(navigator.userAgent.match(/ipad/i)||navigator.userAgent.match(/playbook/i)||navigator.userAgent.match(/xoom/i)||navigator.userAgent.match(/kindle/i)||navigator.userAgent.match(/hp-tablet/i)||navigator.userAgent.match(/gt-p1000/i)||navigator.userAgent.match(/tablet/i))A5.flags.isTablet=true;else A5.flags.isTablet=false;if(navigator.userAgent.match(/safari/i))A5.flags.isSafari=navigator.userAgent.match(/chrome/i)?false:true;else A5.flags.isSafari=false;A5.flags.isMobile=navigator.userAgent.match(/mobile/i)?true:false;A5.flags.isWebKit=navigator.userAgent.match(/webkit/i)?true:false;A5.flags.isOpera=navigator.userAgent.match(/opera/i)?true:false;A5.flags.isFireFox=navigator.userAgent.match(/firefox/i)?true:false;A5.flags.isIE=navigator.userAgent.match(/msie/i)?true:false;A5.flags.isWindows=navigator.userAgent.match(/windows/i)?true:false;A5.flags.isIPhone=navigator.userAgent.match(/iphone/i)?true:false;A5.flags.isIPad=navigator.userAgent.match(/ipad/i)?true:false;A5.flags.isXoom=navigator.userAgent.match(/xoom/i)?true:false;A5.flags.isKindle=navigator.userAgent.match(/kindle/i)?true:false;A5.flags.isPlaybook=navigator.userAgent.match(/playbook/i)?true:false;A5.flags.isGalaxy=navigator.userAgent.match(/gt-p1000/i)?true:false;A5.flags.isTouchPad=navigator.userAgent.match(/hp-tablet/i)?true:false;A5.flags.isNotWebKit=!A5.flags.isWebKit;A5.flags.useBasicScroller=!A5.flags.isWebKit;A5.flags.isPortraitMode=window.orientation==0?true:false;A5.d={evnts:{down:'mousedown',up:'mouseup',move:'mousemove',click:'click',dblClick:'dblclick'}}
if(A5.flags.supportsTouch){A5.d={evnts:{down:'abstractdown',up:'abstractup',move:'abstractmove',click:'abstractclick',dblClick:'abstractdblclick'}}}
if(A5.flags.isFireFox)A5.u.css.properties={transform:'-moz-transform',transformDOM:'MozTransform',transitionDOM:'MozTransition',transitionEndEvent:'transitionend'};else if(A5.flags.isOpera)A5.u.css.properties={transform:'-o-transform',transformDOM:'OTransform',transitionDOM:'OTransition',transitionEndEvent:'oTransitionEnd'};else if(A5.flags.isIE)A5.u.css.properties={transform:'-ms-transform',transformDOM:'MsTransform',transitionDOM:'MsTransition',transitionEndEvent:'transitionend'};else A5.u.css.properties={transform:'-webkit-transform',transformDOM:'WebkitTransform',transitionDOM:'WebkitTransition',transitionEndEvent:'webkitTransitionEnd'};

	
/*
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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" onclick="prev_year('+object_name+','+month_type+','+day_type+'); return false"><img src="'+path+style+'/PrevYear.png?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" alt="Previous Year" border="0"></a>'+'<a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" onclick="prev_month('+object_name+','+month_type+','+day_type+'); return false"><img src="'+path+style+'/PrevMonth.png?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" alt="Previous Month" border="0"></a>'+'</td>\n'+'<td align="center" nowrap>'+month_year_html+'</td>\n'+'<td align="center" nowrap>'+'<a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" onclick="next_month('+object_name+','+month_type+','+day_type+'); return false"><img src="'+path+style+'/NextMonth.png?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" alt="Next Month" border="0"></a>'+'<a href="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" onclick="next_year('+object_name+','+month_type+','+day_type+'); return false"><img src="'+path+style+'/NextYear.png?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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="?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd#" 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._buttons = [];
		
		this._menus = [];
		this._menuData = [];
		
		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._focusControl2 = '';
		this._dvFocustControl = '';
		this._dvFocustControl2 = '';
		this._focusRowTO = 0;
		this._helpTO = 0;
		this._detailViewRow = 0;
		this._detailViewIsDirty = false;
		this._disabledBySecurity = [];
		this._disabledBySecurityDV = [];
		
		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: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		this._defaultWindowSettings['modalpopup'] = {
			type: 'modal-popup', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		
		this._defaultWindowSettings['modeless'] = {
			type: 'modeless', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		
		this._defaultWindowSettings['modelesspopup'] = {
			type: 'popup', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Window', 
				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._functions = {};
		
		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') {
			if(this._rowsInGrid > 0) {
				alert('Primary key for Grid was not defined.');
			}
			return '';
		}
		if(rowNum < 0) 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 '';
	},
	
	getSessionVariable: function(varname) {
		varname = varname.toUpperCase();
		return this._vars.SESSION[varname];
	},

	getPageVariable: function(varname) {
		varname = varname.toUpperCase();
		return this._vars.PAGEVARIABLE[varname];
	},

	_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);
		}
		var count = 0;
		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 if(this.checkBoxSelector == 'multiplePage') {
		    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;
	},
	
	fadeOutMessage: function(id,message) {
		var duration = typeof arguments[2] != 'undefined' ? arguments[2] : 2000;
		var flagStyle = typeof arguments[3] != 'undefined' ? arguments[3] : true;
		A5.fadeOutMessage(id,message,duration,flagStyle,this.styleName);
	},

	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('');
	},

	_clearHiddenRowData: function(rowNum) {	
		var ele = '';
		ele = $(this.gridId + '._HIDDENA5DATA.R' + rowNum);
		if(ele) ele.value = '';
	},

	clearRowErrors: function() {
		var rowsToClear = new Array();
		if(typeof arguments[0] != 'undefined') {
			for(var i = 0; i < arguments[0].length; i++) {
				this._clearHiddenRowData(arguments[0][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);
	
	},
	
	blur: function() {
		$(this.gridId + '.FOCUSCATCHER').blur();
		this._kw.off();
	},
	

	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) {
		var flagSnaking = false;
		if(id.replace(/\s/g,'') == '') id = 'NULLVALUE';
		var gobj = this._rowsInGroupHeader1[id];
		if(typeof gobj == 'string') flagSnaking = true;
		var rEle = '';
		var mode2 = '';
		var rid = ''
		
		if(!flagSnaking) rid = gobj[0];
		else rid = gobj.split('|')[1];
		
		if(mode == 'hide') mode2 = 'none';
		if(mode == 'show') mode2 = '';
		if(mode == 'toggle') {
			if(!flagSnaking) rEle = $(this.gridId + '.R' + rid);
			else rEle = $(this.gridId +'.SNAKING.' + rid);
			if(rEle) mode = rEle.style.display;
			if(mode == '') mode2 = 'none';
			else mode2 = '';
		
		}
		var isDeleted = '';
		var eleCloseIcon = $(this.gridId + '.GHCLOSE.' + rid);
		var eleOpenIcon = $(this.gridId + '.GHOPEN.' + rid);
		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';
		
		}
		if(!flagSnaking) {
			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;
				}
			}
		} else {
			rEle = $(this.gridId +'.SNAKING.' + rid);
			if(rEle) 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 flagSnaking = false;
		var gobj = this._rowsInGroupHeader1;
		for(var ii in gobj) {
			if(typeof gobj[ii] == 'string') {
				flagSnaking = true;
				break;
			}
		}
		var rEle = '';
		if(flagSnaking) {
			var id = '';
			for(var ii in gobj) {
				id = gobj[ii].split('|')[1];
				rEle = $(this.gridId + '.SNAKING.' + id);
				if(rEle) rEle.style.display = 'none';
				var eleCloseIcon = $(this.gridId + '.GHCLOSE.' + id);
				var eleOpenIcon = $(this.gridId + '.GHOPEN.' + id);
				if(eleCloseIcon) eleCloseIcon.style.display = 'none';
				if(eleOpenIcon) eleOpenIcon.style.display = '';
			}
			return false;
		}
		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;
	},

		argumentValue: function(name) {
			var args = this._gridArguments;
			if(typeof args == 'undefined') return '';
			var arr = args.split('\n');
			var arr2 = '';
			argName = '';
			argVal = '';
			for(var i = 1; i <= arr.length; i++) {
				arr2 = arr[i-1].split('|');
				argName = arr2[arr2.length-1];
				if(argName.toLowerCase() == name.toLowerCase() ) {
					argVal = arr[i-1].split('|||')[0];
					break;
				}
			}
		return argVal;
	},

	getParentObject: function() {
		if(this.parentGridAlias !='') {
			if(typeof window[this.parentGridAlias+'_GridObj'] != 'undefined') return window[this.parentGridAlias+'_GridObj'];
			if(typeof window[this.parentGridAlias+'_DlgObj'] != 'undefined') return window[this.parentGridAlias+'_DlgObj'];
			return false;
		} 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();
		//commented out becuause causes unselect row to fail when opening a detail view
		//if($(this.gridId + '.R' + rowNum) == false) return false;
		
		//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 != '') {
				if($(this.gridId+'.R'+this._selectedRow)) this._removeRowClassName($(this.gridId+'.R'+this._selectedRow),this.rowSelectedClassName);
			}
			if(this.hasRowSelectorIcon) {
				if(this._selectedRow < 0) {
					if(this.newRowSelectorIconOff != '') {
						if($(this.gridId+'.R'+this._selectedRow)) $(this.gridId + '.R' + this._selectedRow + '.__ROWSELECTOR').src = this.newRowSelectorIconOff;
					} else {
						if($(this.gridId+'.R'+this._selectedRow))  $(this.gridId + '.R' + this._selectedRow + '.__ROWSELECTOR').style.visibility = 'hidden';
					}

				} else {
					if(this.rowSelectorIconOff != '') $(this.gridId + '.R' + this._selectedRow + '.__ROWSELECTOR').src = this.rowSelectorIconOff;
					else {
						if($(this.gridId + '.R' + this._selectedRow + '.__ROWSELECTOR')) $(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 == '') {
						if(ele.style) ele.style.visibility = '';	
					}
				} else {
					ele.src = this.rowSelectorIconOn;
					if(this.rowSelectorIconOff == '') {
						if(ele.style) ele.style.visibility = '';	
					}
				}
			}
		} else if(this._selectedRow > this._rowsInGrid)  {
			this._selectedRow = 0;
		}
		if(flagResynchLinkedContent) this._internalRefreshLinkedContent();
		this._executeEvent('onRowSelect', {rowNumber: this._selectedRow});
		
	},
	
	_addRowClassName: function(ele,rowClassName) {
		if(!ele) return false;
		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) {
		if(!ele) return false;
		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;
	
	},
	
	computeSearchFromMetaData: function(data) {
		
		if(!this._executeEvent('canSearchSubmit',{})) return false;
		if(!this._confirmAction()) return false;
		this.ajaxCallback('G','none','__a5systemComputeSearchFromMetaData','',data);
	
	},
	
	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;
		
		var ele = ''
		for(var i = 0; i < this._newRowsInGrid; i++) {
			ele = this.gridId + '.R-' + (i+1);
			$(ele).style.display = '';
		}
		
		this._executeEvent('onNewRowsShow',{});
	},

	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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" />'
		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 == 'S') return 'edit';
		
		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) {
				var key_i = '';
				for(var i = 0;i < key.length; i++) {
					key_i = key[i];
					
					if(this._embeddedMode) {
						//
						if(key_i == '') key_i = '__nullvalue__';
					}
					//alert(this._embeddedMode + ' - ' + key_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?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" /> 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;
				//need to send back stateInfo which has the gridCacheId in it  
				var stateInfo2 = window[this.gridId + '_LOOKUP_'+fieldName+'_GridObj'].getStateInfo();
				if(stateInfo2 != '') data = data + '&' + stateInfo2;
				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'));
		
		
		if(go.isLookupGrid == undefined) go.isLookupGrid = false;
		if(go.isLookupGrid) {
			arr.push(A5.ajax.buildURLParam('__vp__isLookupGrid','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.showWindowParameters != 'undefined' && typeof go.windowPositionArg1 == 'undefined') {
				var params = go.showWindowParameters.split('\'');
				go.windowPositionArg1 = params[1];
				go.windowPositionArg2 = params[3];
			}
			
			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(typeof go.showWindowParameters == 'undefined') go.showWindowParameters = '';
		

		
		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?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" /> 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'));
		arr.push(A5.ajax.buildURLParam('__vp___showWindowParameters',go.showWindowParameters));
		
		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';
		
		page = '__a5runGrid.a5w';
		data = data + '&__preprocessInternal=true';
		
		$(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) {
		//alert('parentGridId: ' + parentGridId);
		//alert(part);
		//alert(rowNum);
		//debugger;
		if(!this._executeEvent('canLookupGridSelectRow',{})) return false;

		if(part!='O') {	
			var lookupWindowId = parentGridId + '.GRID.LOOKUPWINDOW.' + fieldName;
			if(part=='DV') {
				lookupWindowId = parentGridId + '.DV.LOOKUPWINDOW.' + fieldName;
			}
			var eleW = $(lookupWindowId);
			if(eleW) eleW.style.display = 'none';
			
		};
		var data = new Array();
		var missingFld = new Array();
		var currField = '';
		for(var i=0;i < this.lookupGridFieldsToReturn.length; i++) {
			currField = this.lookupGridFieldsToReturn[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]);
					currField = '';
					break;
				}
			}
			if(currField != '') missingFld.push(currField);
		}
		
		if(missingFld.length != 0) {
			alert('Error: Lookup grid does not contain all of the mapped fillin fields. The following fields are in the Lookup Map, but are not in the Lookup Grid\n' + missingFld.join(', '));
			return false;
		}
		
		
		
		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) {
		clearTimeout(this._focusRowTO);
		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]);
		
		var executeAfterDetailViewEvent = false;
		
		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);	
					executeAfterDetailViewEvent = true;
				}
			} else {
				//this._populateDetailView(rowNumber, data, this._detailViewColNames,false,[],1,false);
				this._populateDetailView(rowNumber, data, this._detailViewColNames,false,[],0,false);
				executeAfterDetailViewEvent = true;
			}
			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?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" />Working...';
				}
			}
		}
		if(executeAfterDetailViewEvent) this._executeEvent('afterDetailViewOpen',{rowNumber: rowNumber});
		//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?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" />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);
	},




	_resetDVFocus: function() {
		if(typeof this._dvFocusControl2	!= 'undefined') {
			var ele = $(this.gridId + '.D.V.R1.' + this._dvFocusControl2);
			if(ele) {
				try
				{
					if(typeof ele.focus != 'undefined') ele.focus();
					if(typeof ele.select != 'undefined') ele.select();
				}
				catch(err) {}
			}
		}
	},


	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 = '';
			var eImg = '';
			for(var i=0;i<this.detailViewColumnInfo.length;i++) {
				if(this.detailViewColumnInfo[i].type == 'img,label') {
					eImg = $(this.gridId + '.D.V.R1.' + this.detailViewColumnInfo[i].name) ;
					if(eImg) eImg.value = '';
				}
				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._detailViewState == 'enter') return false;
		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';
			}
		var ele = '';
		ele = $(this.gridId + 'D._HIDDENA5DATA.R1');
		if(ele) ele.value = '';
	},
	
	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;
				}
			}
		}
	},
	

	closeCurrentTabbedUIPane: function() {
		if(typeof tbiObj != 'undefined') {
			var idx = tbiObj._tbObj._curTabIndx;
			tbiObj._tbObj.remove(idx);
		}
	},		
	
	
	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});
		$(this.gridId+'.FOCUSCATCHER').focus();
		return true;
	},
	
	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;
		field = field.toUpperCase();
		
		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;
	},

	
	_rowExpandLow: 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) {
		var trEle = $(this.gridId+'.R' + rowNum + '.__ROWEXPAND_TR');
		if(trEle == false) return false;
		var flagFireCanRowCollapse = false;
		
		if($ga(trEle,'A5RowExpanded') == 'true') {
			flagFireCanRowCollapse = true;
		}
	
		if(flagFireCanRowCollapse) {
			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;
		if(flagFireCanRowCollapse) {
			this._executeEvent('afterRowCollapse',{rowNumber: rowNum});
		}
		
		$sa(trEle,'A5RowExpanded','false');
	},
	
	rowExpand: function(rowNum) {
		this.rowExpandToggle(rowNum,true);
	},
	
	rowExpandToggle: function(rowNum) {
		var forceExpand = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		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' || forceExpand) {
			if(!this._executeEvent('canRowExpand',{rowNumber: rowNum, isDirty: rowIsDirty})) return false;
			if($ga(trEle,'A5RowExpanded') == 'true') {
				this._rowExpandLow(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._rowExpandLow(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();
			if(typeof this._originalValues[rowNum-1] != 'undefined') {
				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 stateInfo2 = this.getStateInfo();
				if(stateInfo2 != '') data = data + '&' + stateInfo2;

				
				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;
				
				var stateInfo = $(this.gridId +'.STATEINFO').value;
				if(stateInfo!='') data=data +'&' + stateInfo;
				var stateInfo2 = this.getStateInfo();
				if(stateInfo2 != '') data = data + '&' + stateInfo2;
				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;
		
		var stateInfo2 = this.getStateInfo();
		if(stateInfo2 != '') data = data + '&' + stateInfo2;
				
		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;
		
		var browserData = $u.o.toJSON(A5.flags);
		data = data + '&' + A5.ajax.buildURLParam('__a5browserflags',browserData);
		
		
		A5.ajax.callback(callbackURL,data);
		return false;
	},	
	
	isDirty: function() {
		if(this._detailViewIsDirty) return true;
		if(this._isDirty) return true;
		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++) {
							if(typeof this._newDVValues != 'undefined') {
								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
								if(typeof this._newValues != 'undefined') {
									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
							if(typeof this._newValues != 'undefined') {
								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];
				var flagPretendDirty = false;
				if(this._detailViewRow < 0) {
					if(typeof this._newDVValues == 'undefined') flagPretendDirty = true;
				} else {
					if(typeof this._originalDVValues == 'undefined') flagPretendDirty = true;
				}
				if(this._detailViewIsDirty || flagPretendDirty) {
					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') {
			if(row == 0) return '';
			
			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.constructor != Array) {
						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;
			ele = $n('S.'+name);
			if(ele == false) {
				ele = $n('S.'+name + '[]');
			}
			
			ele = $cetp(ele,$(this.gridId+'.SEARCH_PART.FORM'));
			$svs(ele,value,$(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),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(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),rObj[i] ));
							}

						//} else if(eles[j].type.toLowerCase() == 'text' || eles[j].type == 'hidden' || eles[j].type == 'password'  || eles[j].type == ''){
						} else if(eles[j].type.toLowerCase() != 'submit' && eles[j].type != 'reset' && eles[j].type != 'button'  && eles[j].type != 'image' && eles[j].type != 'file'){
							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[colNum].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[colNum].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]);
				}
				ele = $cetp(ele,$(this.gridId + '.R' + rowNum)); 
				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]);
				ele = $cetp(ele,$(this.gridId + '.R' + rowNum));
				$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[colNum].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;
		var val = '';
		var oVal = '';
		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[colNum].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.constructor == Array || typeof ele.tagName != 'undefined') {
						if(ele.tagName) {
							val = ele.getAttribute('A5OriginalValue').split('||A5ARRAYSEP||');
						} else {
							//protect against error if field is a label
							var oVal = ele[0].getAttribute('A5OriginalValue');
							val = '';
							if(oVal) val = oVal.split('||A5ARRAYSEP||');
							//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) {
			
			var ele = '';
			ele = $(this.gridId + '._HIDDENA5DATA.R' + rowNum);
			if(ele) ele.value = '';
		
			this._populateRow(rowNum,this._newValues,this._gridColNames);
			var ele = '';
			var ctl = this.gridColumnInfo;
			for(var i = 0; i < ctl.length; i++) {
				if(ctl[i].type.substr(0,3) == 'img') {
					ele = $(this.gridId + '.V.R' + rowNum + '.' + ctl[i].name + '_HIDDENA5FN');
					if(ele) ele.value = '';
				}
			}
			
		} 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);
		}
		ele = $(ele);
		if(ele) {
			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';
		}
		$e.removeGroup(this.gridId+'.DETAILVIEW_PART.FORMEvents2');
		
		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.FORMEvents2');
		$e.add(eles,'blur',this._setDVControlBlur,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents2');
		
		for(var i = 0; i < eles.length; i++) {
			if($u.a.find(this._disabledBySecurityDV,eles[i].name.split('.').pop()) != -1 ) eles[i].disabled = true;
		}
		
		eles = rele.getElementsByTagName('select');
		$e.add(eles,'focus',this._setDVControlFocus,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents2');
		$e.add(eles,'blur',this._setDVControlBlur,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents2');
		
		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($u.a.find(this._disabledBySecurityDV,eles[i].name.split('.').pop()) != -1 ) eles[i].disabled = true;
		}
		
		eles = rele.getElementsByTagName('textarea');
		$e.add(eles,'focus',this._setDVControlFocus,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents2');
		$e.add(eles,'blur',this._setDVControlBlur,this,false,this.gridId+'.DETAILVIEW_PART.FORMEvents2');
		
		for(var i = 0; i < eles.length; i++) {
			if($u.a.find(this._disabledBySecurityDV,eles[i].name.split('.').pop()) != -1 ) eles[i].disabled = true;
		}

		
		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';
				} 
			}
		}
		
		
		
	},
	
	runAction: function(name) {
		var actObj = this._actions;
		if(typeof actObj == 'undefined') return false;
		var js = actObj[name];
		if(typeof js == 'undefined') return false;
		if(js != '') eval(js);
			
		
	},

	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] || $u.a.find(this._disabledBySecurity,eles[i].name.split('.').pop()) != -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]  || $u.a.find(this._disabledBySecurity,eles[i].name.split('.').pop()) != -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]  || $u.a.find(this._disabledBySecurity,eles[i].name.split('.').pop()) != -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');
					if($u.a.find(this._disabledBySecurity,eles[i].name.split('.').pop()) != -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($u.a.find(this._disabledBySecurity,eles[i].name.split('.').pop()) != -1 ) eles[i].disabled = true;
			}


			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');
			for(var i = 0; i < eles.length; i++) {
				if($u.a.find(this._disabledBySecurity,eles[i].name.split('.').pop()) != -1 ) eles[i].disabled = true;
			}
			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 name2 = ele.name.split('.');
		if(typeof name2[1] == 'undefined') return 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';
			if(ele) {
				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';
			if(typeof window[containerName]._curBandIndx != 'undefined') {
				//in an accordion
				if(window[containerName]._curBandIndx != -1) {
					if(window[containerName]._curBandIndx +1 == obj[i].pane) {
						//you are already on the band. so bail. otherwise it will toggle the band
						return false;
					}
				}
			}
			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._focusControl2 = classInst._focusControl;
					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 name2 = this.name.split('.');
			if(typeof name2[1] == 'undefined' ) { return false; };
			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];
				classInst._dvFocusControl2 = classInst._dvFocusControl;
			}
		}

	},
	
	_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);
		}
	},
	
	
	
	_refreshGridIfClean: function() {
		var grid = {};
		grid.hasDetailView = $if(this._detailViewColNames.length > 0, true,false);
		if(grid.hasDetailView==false) {
			grid.isDirty = this._isDirty;
		} else {
			grid.isDirty = this._detailViewIsDirty;
		}
		if(grid.isDirty == true) return false;
		var result = this._executeEvent('beforeAutoRefresh',{})
		if(result == true) this.refresh();
	},
	
	autoRefreshStop: function() {
		this._autoRefreshInterval = 0;
	},
	
	
	autoRefreshStart: function(interval) {
			this._autoRefreshInterval = interval;
			setTimeout('if( typeof ' + this.gridId + '_GridObj != \'undefined\')' + this.gridId + '_GridObj._autoRefreshLow();',interval);
	},
	
	_autoRefreshLow: function() {
		var d = 0;
		var ele = $(this.gridId + '.STATEINFO');
		if(!ele) {
			this._autoRefreshInterval = 0;
			return false;
		}
		if(typeof this._autoRefreshInterval == 'undefined') return false;
		d = this._autoRefreshInterval;
		if(d == 0) return false;
		this._refreshGridIfClean();
		setTimeout('if( typeof ' + this.gridId + '_GridObj != \'undefined\')' + this.gridId + '_GridObj._autoRefreshLow()',d);
	},
	
	_showGridErrorColumn: function(show) {
		//to support legacy grids before v10.5 that use a different method of show/hide on error column 
		
		//if fixed scrolling with fixed column sizes are turned on, and the grid is editable, the row error column must always be shown or grid is messed up
		var flagAlwaysShown = false;
		if(typeof this._rowErrorColumnAlwaysVisible != 'undefined') flagAlwaysShown = this._rowErrorColumnAlwaysVisible;
		if(flagAlwaysShown) show = true;
		
		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;
		
		
		ele = $(this.gridId + '.SUMM.' + colName);
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName + '.TOTAL'); 
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName + '.AVG');
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName  + '.MIN');
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName + '.MAX');
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName + '.STDDEV');
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName + '.VAR');
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName + '.FIRST');
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName + '.LAST');
		if(ele) ele.style.display = sdis;
		
		ele = $(this.gridId + '.SUMM.' + colName + '.COUNT');
		if(ele) ele.style.display = sdis;
		
		
			
	},
	
	_addRowsFromTemplate: function(numberOfRows,data) {
		var cele = 0;
		var pele = 0;
		var ele = $(this.gridId + '.GRID.ROWTEMPLATE');
		if(typeof ele != 'object') return false;
		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;
	
	},
	
	_findControlNumber: function(part,name) {
		var arr = '';
		if(part == 'G') arr = this.gridColumnInfo;
		else alert('fix for dv');
		var i2 = -1;
		for(var i = 0; i < arr.length; i++) {
			if(arr[i].name == name) {
				i2 = i;
				break;
			}
		}
		return i2;
	},
	
	_setOriginalValues: function(part,rowNum,obj) {
		//this is not currently used
		var id = -1;
		var arr = '';
		if(part == 'G') arr = this._originalValues;
		else alert('fix for dv');
		for(var key in obj){
			id = this._findControlNumber(part,key);	
		    arr[rowNum-1][id] = obj[key];
		   }
	},
	
	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);
	},
	
	_runJSOnLoad: function() {
		var e = A5.eleByClass('__A5Component_jsRunOnLoad');
		for(var i = 1; i <= e.length; i++) {
			eval(e[i-1].value);
			e[i-1].value = '';
		}
	},
		

	_submitLow: function(action,formID,url){
	
		var ele = $(this.gridId + '.STATEINFO');
		if(!ele) {
			return false;
		}
	
		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.fadeOutMessage = function(id,message,duration,flagStyle,style) {
	var msg = '';
	if(flagStyle) {
		msg = '<div class="'+style+'Win"><div class="'+style+'WinInner '+style+'WinTitle">'+message+'</div></div>';
	} else {
		msg = message;
	}
	var ele = $(id);
	if(!ele) return false;
	ele.innerHTML  = msg;
	ele.style.display = '';
	A5.u.element.hide(ele,{type: 'fade',duration: duration} );
}
A5.component.runGenericComponent = function(go) {
	var arr = new Array();
	var pagePrefix = '';
	if(typeof go._applicationRoot == 'undefined') go._applicationRoot = '';
	pagePrefix = go._applicationRoot
	
	if(typeof go._parentComponentHasPanels == 'undefined') go._parentComponentHasPanels = false;
	arr.push(A5.ajax.buildURLParam('__parentComponentHasPanels','' + go._parentComponentHasPanels));
			
	
	
	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;
		if(typeof go._thisGridAlias == 'undefined') go._thisGridAlias = '';
		arr.push('__dialogDiv=' + go.dialog2Div);
		arr.push(A5.ajax.buildURLParam('__dialogFilename',go.dialog2Name));
		arr.push(A5.ajax.buildURLParam('__parentComponentAlias',go._thisGridAlias));
		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._thisGridAlias == 'undefined') go._thisGridAlias = '';
		arr.push(A5.ajax.buildURLParam('__parentComponentAlias',go._thisGridAlias));
	
	
		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?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" /> 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;
		}
		
	//solves problem of html editor in detail view not working when running in a tabbed UI if the tab is set to autorefresh.		
	//if(typeof window[go.alias.toUpperCase() + '_GridObj'] != 'undefined') {
	//go.__useCachedGrid will only be defined if go was generated from a button in a grid or dialog. will not be defined in tabbed UI.
	if(typeof go.__useCachedGrid == 'undefined') {
		if(typeof window[go.alias.toUpperCase() + '_GridObj'] == 'object') {
			if( $(window[go.alias.toUpperCase() + '_GridObj'].gridId +'.FOCUSCATCHER') )  {
				window[go.alias.toUpperCase() + '_GridObj'].refresh();
				return true;
			}
		}
	}
			

	if(go.workingMessage == undefined) go.workingMessage = '<img src="CSS/A5System/Images/wait.gif?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" /> 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 = '';
	
	if(typeof go.showWindowParameters == 'undefined') go.showWindowParameters = '';


	
	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));
	arr.push(A5.ajax.buildURLParam('__vp___showWindowParameters',go.showWindowParameters));
	
	
	//Lookups
	if(go.isLookupGrid == undefined) go.isLookupGrid = 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';
	
	page = '__a5runGrid.a5w';
	
	
	$(go.gridDiv).innerHTML = go.workingMessage;
	data = A5.ajax.addParamRequiredData(data);
	
	data = data + '&__preprocessInternal=true';
	
	
	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(typeof ro.htmlReporting == 'object') {
		ro.htmlReporting = $u.o.toJSON(ro.htmlReporting);
	} else ro.htmlReporting = '';
	if(ro.hostComponentType == undefined) ro.hostComponentType = 'Grid';
	if(ro.filter == undefined) ro.filter = '';
	if(ro.filter_incremental == undefined) ro.filter_incremental = '';
	if(ro.order == undefined) ro.order = '';
	if(ro.sqlFilter == undefined) ro.sqlFilter = '';
	if(ro.sqlFilter_incremental == undefined) ro.sqlFilter_incremental = '';
	if(ro.sqlOrder == undefined) ro.sqlOrder = '';
	if(ro.arguments == undefined) ro.arguments = '';
	if(ro.arguments_incremental == undefined) ro.arguments_incremental = '';
	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.afterExecuteJavascript == undefined) ro.afterExecuteJavascript  = '';
	if(ro.__dtfmt == undefined) ro.__dtfmt = 'mm/dd/yy';
	
	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('_htmlReporting',ro.htmlReporting));
	data.push(A5.ajax.buildURLParam('filter',ro.filter));
	data.push(A5.ajax.buildURLParam('filter_incremental',ro.filter_incremental));
	data.push(A5.ajax.buildURLParam('order',ro.order));
	data.push(A5.ajax.buildURLParam('sqlFilter',ro.sqlFilter));
	data.push(A5.ajax.buildURLParam('sqlFilter_incremental',ro.sqlFilter_incremental));
	data.push(A5.ajax.buildURLParam('sqlOrder',ro.sqlOrder));
	data.push(A5.ajax.buildURLParam('arguments',ro.arguments));
	data.push(A5.ajax.buildURLParam('arguments_incremental',ro.arguments_incremental));
	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('pdfoptions',ro.pdfoptions));
	data.push(A5.ajax.buildURLParam('_hostComponent',ro.hostComponentType));
	data.push(A5.ajax.buildURLParam('__dtfmt',ro.__dtfmt));

	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));
	data.push(A5.ajax.buildURLParam('_afterExecuteJavascript',ro.afterExecuteJavascript));
	
	
	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);
	
	var initialView = 'pdf';
	if(typeof ro.htmlReporting.initialView != 'undefined')  initialView = ro.htmlReporting.initialView.toLowerCase();
	if(initialView == 'pdf') {
		new $a.simple('__a5RunReport.a5w',{data: data, method: 'post', handle: A5.component._handleReportResponse});
	} else {
		new $a.simple('__a5RunReport.a5w',{data: data, method: 'post'});
	}
}



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);
		}
		if(typeof a5reportInfo.afterExecuteJavascript != 'undefined') {
			if(a5reportInfo.afterExecuteJavascript != '') eval(a5reportInfo.afterExecuteJavascript);
		}
	}
}




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 = {
	styleName: '',
	_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) {
	
		/*
		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;
		}
		*/
	
		if(!this.getWindow(name)) {
			if(typeof settings == 'string') {
				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;
				}
				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';
					}
				}
				settings.theme = this.styleName;
				settings.title.tools.items = [closeButton];
			}
			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;
}

A5.eleByClass = function(cName) {
	if ( !document.getElementsByClassName ) {
		var elArray = [];
		var tmp = document.getElementsByTagName('*');
		var regex = new RegExp("(^|\s)" + cName + "(\s|$)");
		for(var i = 0; i < tmp.length; i++) {
			if(regex.test(tmp[i].className)) {
				elArray.push(tmp[i]);
			}
		}
		return elArray;
	} else {
		return document.getElementsByClassName(cName);
	}
}

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.executeThisThenThat = function() {
	var args = [];
	for(var i = 0; i < arguments.length; i++) args.push(arguments[i]);
	var thisCode = args.shift();
	var lc = $a.lastCallback;
	if(typeof thisCode == 'string') eval(thisCode);
	else thisCode();
	if(args.length == 1) {
		var thatCode = args[0];
		if(lc == $a.lastCallback) {
			if(typeof thatCode == 'string') eval(thatCode);
			else thatCode();
		} else {
			$a._def['' + $a.lastCallback] = typeof thatCode == 'string' ? Function(thatCode) : thatCode;
		}
	} else {
		if(lc == $a.lastCallback) {
			A5.executeThisThenThat.apply(this,args);	
		} else {
			$a._def['' + $a.lastCallback] = function() {
				A5.executeThisThenThat.apply(this,args);
				delete args;
			}
		}
	}
}


A5.u.element.visibilityHide =function(ele) {
	ele.style.visibility = 'hidden';
}

A5.u.element.visibilityShow =function(ele) {
	ele.style.visibility = '';
}

A5.u.element.visibilityToggle =function(ele) {
	if(ele.style.visibility == 'hidden') ele.style.visibility = '';
	else ele.style.visibility = 'hidden';
}

A5._buttonAddTheme = function(ele,theme) {
	var settings = {};
	A5.themes.assign(settings,theme,'button');
	
	if(A5.flags.supportsMouse && settings.hoverClassName != '') {
		
		$e.add(ele,'mouseover',Function('$acn(this,\''+settings.hoverClassName+'\')') );
		$e.add(ele,'mouseout',Function('$rcn(this,\''+settings.hoverClassName+'\')') );
	}
	if(settings.pressedClassName != '') {
		$e.add(ele,A5.d.evnts.down,Function('$acn(this,\''+settings.pressedClassName+'\')') );
		$e.add(ele,A5.d.evnts.up,Function('$rcn(this,\''+settings.pressedClassName+'\')') );
	}
}
A5._btn = function(ele,mode,style) {

	if(typeof A5._btnHighlight != 'undefined') {
		if(A5._btnHighlight == false) return true;
	}
	//allows button hightlight effects to be disabled for mobile
	if(mode == 'onmouseover') $acn(ele, style + 'ButtonHover');
	if(mode == 'onmousedown') $acn(ele, style + 'ButtonPressed');
	if(mode == 'onmouseup') $rcn(ele, style + 'ButtonPressed');
	if(mode == 'onmouseout') {
		$rcn(ele, style + 'ButtonPressed');
		$rcn(ele, style + 'ButtonHover');
	}
}


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._functions = {};
		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: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		this._defaultWindowSettings['modeless'] = {
			type: 'modeless', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};		
		
		
		
		this._defaultWindowSettings['modalpopup'] = {
			type: 'modal-popup', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
				};

		this._defaultWindowSettings['modelesspopup'] = {
			type: 'popup', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Window', 
				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;
		
		var browserData = $u.o.toJSON(A5.flags);
		data = data + '&' + A5.ajax.buildURLParam('__a5browserflags',browserData);
		
		
		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);
			
		}
	},
	
	getParentObject: function() {
			if(this.parentComponentAlias !='') {
				if(typeof window[this.parentComponentAlias+'_GridObj'] != 'undefined') return window[this.parentComponentAlias+'_GridObj'];
				if(typeof window[this.parentComponentAlias+'_DlgObj'] != 'undefined') return window[this.parentComponentAlias+'_DlgObj'];
				return false
			} else return false;
	},
	
	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);
	},
	
	
	_destroy: function() {
		var ele = 0;
		for(var winName in this._genericWindow){
			ele = $(this._genericWindow[winName].getWindowId('body'));
			if(ele.tagName.toLowerCase() == 'div') ele.innerHTML = '';
		}
	},
	
	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._isDataDirty = false;
		this._focusControl = '';
		this._focusRow = 1;
		this._blurTO = 0;
		this._functionToConstrainElements = Function('var eles = arguments[0]; var dlgId = \''+this.dialogId+'.\'; var dlgIdLen = dlgId.length; var eles2 = []; for(var i = 0;i < eles.length; i++){ if(eles[i].id.substr(0,dlgIdLen) == dlgId) eles2.push(eles[i]);}; if(eles2.length == 0) return false; return eles2;');
		this._controls = {};
		//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._listViewData = [];
		this._listViewSettings = [];
		this._buttonListData = [];
		this._treeData = [];
		this._treeSettings = [];
		this._mapSettings = [];
		this._menus = [];
		this._menuData = [];
		this._defaultWindowSettings = new Object();
		this._defaultWindowSettings['dropdown'] = {
			type: 'popup',
			theme: this.styleName,
			title: {html: 'Null',show: false},
			body:  {content: {type: 'blank'}}
		};		
		this._controlInst = new Object();
		this._genericWindow = new Object();
		this._vars = {SESSION : {}, PAGEVARIABLE : {}};
		
		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: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};
		
		this._defaultWindowSettings['modalpopup'] = {
					type: 'modal-popup', autoPosition: 'in-view',
					theme: this.styleName,
					title: {html: 'Window', 
						tools: {items: [closeButton],
							dummy: false
						}},
					body: {content: {type: 'blank'}}
		};
		
		
		this._defaultWindowSettings['modeless'] = {
			type: 'modeless', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};		
		
		this._defaultWindowSettings['modelesspopup'] = {
			type: 'popup', autoPosition: 'in-view',
			theme: this.styleName,
			title: {html: 'Window', 
				tools: {items: [closeButton],
					dummy: false
				}},
			body: {content: {type: 'blank'}}
		};		
		
		this._prepared = false;
		this._functions = {};
		
	},

	_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._executeEvent('beforePrepare',{});
		this._prepareRow(1);
		this._prepared = true;
		this._executeEvent('afterPrepare',{});
	},
	
	_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,false);
			}
			if(this.columnInfo[columnName].type == 'control') {
				if(typeof this.columnInfo[columnName].repeatingSection != 'undefined') {
					this.repeatingSections[this.columnInfo[columnName].repeatingSection]._ci[columnName] = this.columnInfo[columnName];	
				} else {
					if(typeof this._controlInst['R'+rowNum + '.' + columnName] == 'undefined') {
						var controlDat = this._controls[columnName];

						if(controlDat.type == 'list') {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName , onSelect: function(){if(typeof this._onSelect != 'undefined') this._onSelect(); setTimeout(Function('$e.execute(\''+this.inputId+'\', \'change\');'),0) }  };
							if(typeof controlDat.settings.onSelect != 'undefined') controlDat.settings._onSelect = controlDat.settings.onSelect;
							$u.o.assign(sObj,controlDat.settings,true);
							sObj._state = {};
							sObj._state.page = 1;
							if(typeof sObj.containerId == 'undefined') sObj.containerId = this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL';
							this._controlInst['R' + rowNum + '.' + columnName] = new A5.ListBox(sObj.containerId, controlDat.data, sObj);
							$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
						} else if(controlDat.type == 'dateTimePicker') {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName};
							$u.o.assign(sObj,controlDat.settings,true);
							this._controlInst['R' + rowNum + '.' + columnName] = new A5.DateTimePicker(this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL', sObj);
							//ensure that the calendar works after as second prepare()
							this._controlInst['R' + rowNum + '.' + columnName].setValue(this.originalValues[rowNum-1][columnName]);
							$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
						} else if(controlDat.type == 'slider') {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName};
							$u.o.assign(sObj,controlDat.settings,true);
							//when the dialog was opened in a window, the slider would show up multiple times. unlike other controls - the slider is not destructive
							$(this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL').innerHTML = '';
							this._controlInst['R' + rowNum + '.' + columnName] = new A5.Slider(this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL', sObj);
							$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');


						} else if(controlDat.type == 'switch') {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName};
							$u.o.assign(sObj,controlDat.settings,true);
							$(this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL').innerHTML = '';
							this._controlInst['R' + rowNum + '.' + columnName] = new A5.Switch(this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL', sObj);
							$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');						
						} else if(controlDat.type == 'buttonList') {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName};
							$u.o.assign(sObj,controlDat.settings,true);
							this._controlInst['R' + rowNum + '.' + columnName] = new A5.ButtonList(this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL', controlDat.data, sObj);
							$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
						} else if(controlDat.type == 'tree') {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName};
							$u.o.assign(sObj,controlDat.settings,true);
							this._controlInst['R' + rowNum + '.' + columnName] = new A5.Tree(this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL', controlDat.data, sObj);
							$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
						} else if(controlDat.type == 'map') {
							var cId = this.dialogId + '.V.R' + rowNum + '.' + columnName + '.CONTROL';
							if(typeof controlDat.containerId != 'undefined') cId = controlDat.containerId;
							if($(cId).innerHTML == '') {
								this._controlInst['R' + rowNum + '.' + columnName] = new A5.Map(cId, controlDat.settings);
							}
						} else if(controlDat.type == 'custom' ) {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName, rowNumber: rowNum};
							$u.o.assign(sObj,controlDat.settings,true);
							this._controlInst['R' + rowNum + '.' + columnName] = sObj;
						}
						if(controlDat.onInitialize) controlDat.onInitialize.call(this._controlInst['R' + rowNum + '.' + columnName],rowNum);
					}
				}
			} else {
				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);
					eles = this._functionToConstrainElements(eles);
					if(eles) {
						var tagName = eles[0].tagName.toLowerCase();
						//keyup event on non typeable controls cause problems
						if((tagName == 'input' && eles[0].type != 'radio' && eles[0].type != 'checkbox'  ) || tagName == 'textarea') $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(tagName == '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]);
							
							if(this.fieldHelpers[columnName].onBind) this.fieldHelpers[columnName].onBind(rowNum)
						}
					}
				}
			}
		}
		
		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]);
								if(eles.length == 0) eles = $n('V.R' + rowNum + '.' + this.dialogWatches[dialogWatch].watch[i]+'[]');
								//eles = $cetp(eles,$(this.dialogId + '.R' + rowNum));
								eles = this._functionToConstrainElements(eles);
								
								
								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) {
		var rowNum = typeof arguments[1] != 'undefined' ? arguments[1] : 1;
		var rele = $(this.dialogId + '.R' + rowNum);
		var ele = 0;
		var eleL = 0;
		
		var rsTemp = this.repeatingSections[sectionName];
		if(typeof rsTemp == 'undefined') return false;
		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'){
						//sr 4/7/12 orphan controls are in a hidden div
						if(rsEle.childNodes[i].style.display != 'none') {
							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);
	},

	populateDropdownBox: function(columnName,data,clearExisting) {
		var curData = '';
		var ele = this._getControlLow(columnName);
		if(ele) {
			curData = this.getValue(columnName);
			A5.form.populateSelect(ele,curData,data,clearExisting);
		}
	},

	_getControlLow: function(columnName) {
		var ele =  $(this.dialogId + '.V.R1.' + columnName);
		if(!ele) {
			var rsName = this._findRepeatingSection(columnName);
			var instNum = this.repeatingSections[rsName].activeRow;
			ele = $(this.dialogId + '.V.R1.' + columnName + '_A5INSTANCE' + instNum);
		}
		return ele;
	},
	
	
	showContainerWindow: function(ele,containerName) {
		
		this._functions['_showContainerWindow_' + containerName.toUpperCase()](ele);
	},
		
	
	populateDropdownBoxRepeatingSection: function(columnName,data,clearExisting) {
		var sectionName = this._findRepeatingSection(columnName);
		var rs = this.repeatingSections[sectionName];
		if(typeof rs == 'undefined') return false;
		var rows = rs.rows;
		var columnName_i = '';
		for(var i = 1; i <= rows; i++) {
			columnName_i = columnName + '_A5INSTANCE' + i;
			this.populateDropdownBox(columnName_i,data,clearExisting);
		}
		columnName_i = columnName + '_A5INSTANCE[instanceNumber]';
		this.populateDropdownBox(columnName_i,data,clearExisting);
	},
	
	refreshDropdownBoxChoices: function(controlName) {
		var dynamicFilter = typeof arguments[1] != 'undefined' ? arguments[1] : '';
		var dynamicFilterArgs = typeof arguments[2] != 'undefined' ? arguments[2] : '';
		var dynamicFilter = typeof arguments[1] != 'undefined' ? arguments[1] : '';
		var selectedValue = typeof arguments[3] != 'undefined' ? arguments[3] : '__none__';
		//if the control is in a RS
		var currentRSRowOnly = typeof arguments[4] != 'undefined' ? arguments[4] : false;
		var data = new Array();
		data.push(A5.ajax.buildURLParam('_controlName',controlName));
		data.push(A5.ajax.buildURLParam('_dynamicFilter',dynamicFilter));
		data.push(A5.ajax.buildURLParam('_dynamicFilterArgs',dynamicFilterArgs));
		data.push(A5.ajax.buildURLParam('_selectedValue',selectedValue));
		data.push(A5.ajax.buildURLParam('_currentRSRowOnly',currentRSRowOnly));
		data = data.join('&');
		var xbasicFunction = 'system:refreshDropddownBox';
		this.ajaxCallback('G',1,xbasicFunction,'',data);
	},
	
	_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];
		if(typeof rsTemp == 'undefined') return false;
		//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) {
		this._executeEvent('beforeRptSectionRowPrepare',{sectionName: sectionName, rowNumber: instNum});
		var rele = $(this.dialogId + '.R' + rowNum);
		var eles = 0;
		var rsTemp = this.repeatingSections[sectionName];
		if(typeof rsTemp == 'undefined') return false;
		rsTemp._r[rowNum-1].i[instNum-1] = {deleted: false, dirty: false, error: false};
		for(var columnName in rsTemp._ci) {
			if(rsTemp._ci[columnName].type == 'control') {
				if(typeof this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] == 'undefined') {
					var controlDat = this._controls[columnName];
					if(controlDat.type == 'list') {
						var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum, onSelect: function(){setTimeout(Function('$e.execute(\''+this.inputId+'\', \'change\');'),0) }};
						$u.o.assign(sObj,controlDat.settings,true);
						var tData = [];
						$u.o.assign(tData,controlDat.data);
						sObj._state = {};
						sObj._state.page = 1;
						this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] = new A5.ListBox(this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum + '.CONTROL', tData, sObj);
						$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
					} else if(controlDat.type == 'dateTimePicker') {
						var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum};
						$u.o.assign(sObj,controlDat.settings,true);
						this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] = new A5.DateTimePicker(this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum + '.CONTROL', sObj);

						//ensure that the calendar works after as second prepare()
						this._controlInst['R' + rowNum + '.' + columnName+ '_A5INSTANCE' + instNum].setValue(this.originalValues[rowNum-1][columnName +':' + instNum]);

						$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');

					} else if(controlDat.type == 'slider') {
						var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum};
						$u.o.assign(sObj,controlDat.settings,true);
						//see comment for single instance
						$(this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum + '.CONTROL').innerHTML = '';
						this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] = new A5.Slider(this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum + '.CONTROL', sObj);
						$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');

					} else if(controlDat.type == 'switch') {
						var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum};
						$u.o.assign(sObj,controlDat.settings,true);
						//see comment for single instance
						$(this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum + '.CONTROL').innerHTML = '';
						this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] = new A5.Switch(this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum + '.CONTROL', sObj);
						$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');					



					} else if(controlDat.type == 'buttonList') {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum};
							$u.o.assign(sObj,controlDat.settings,true);
							var tData = [];
							$u.o.assign(tData,controlDat.data);
							this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] = new A5.ButtonList(this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum + '.CONTROL', tData, sObj);
							$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');



					} else if(controlDat.type == 'tree') {
							var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum};
							$u.o.assign(sObj,controlDat.settings,true);
							var tData = [];
							$u.o.assign(tData,controlDat.data);
							this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] = new A5.Tree(this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum + '.CONTROL', tData, sObj);
							$e.add(sObj.inputId,'change',this._setControlDirty,this,false,this.dialogId + '.DIALOG');
					} else if(controlDat.type == 'map') {
						if($(this.dialogId + '.V.R' + rowNum + '.' + columnName  + '_A5INSTANCE' + instNum + '.CONTROL').innerHTML == '') {
							this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] = new A5.Map(this.dialogId + '.V.R' + rowNum + '.' + columnName  + '_A5INSTANCE' + instNum + '.CONTROL', controlDat.settings);
						}
					} else if(controlDat.type == 'custom' ) {
						var sObj = {inputId: this.dialogId + '.V.R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum, rowNumber: rowNum, instanceNumber: instNum};
						$u.o.assign(sObj,controlDat.settings,true);
						this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum] = sObj;
					}
					if(controlDat.onInitialize) controlDat.onInitialize.call(this._controlInst['R' + rowNum + '.' + columnName + '_A5INSTANCE' + instNum],rowNum,instNum);
				}
			} else {
				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);
				eles = this._functionToConstrainElements(eles);
				
				
				if(eles) {
				
					var tagName = eles[0].tagName.toLowerCase();
					//keyup event on non typeable controls cause problems
					if((tagName == 'input' && eles[0].type != 'radio' && eles[0].type != 'checkbox'  ) || tagName == 'textarea') $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(tagName == '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]);
						if(this.fieldHelpers[columnName].onBind) this.fieldHelpers[columnName].onBind(rowNum,instNum)
					}
				}
			}
		}	
		
		var rsInfo = this.repeatingSectionInfo[sectionName];
		if(typeof rsInfo['abstractJavascript']	!= 'undefined') rsInfo['abstractJavascript'](instNum);
		
		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._repeatingSectionRowErrorShow,this,false,this.dialogId + '.DIALOG');
			$e.add(rseEle,'mouseout',this._repeatingSectionRowErrorHide,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));
					if(eles.length == 0) eles = $n('V.R' + rowNum + '.' + rsTemp._w[dialogWatch].watch[i].replace(':A5INSTANCE','_A5INSTANCE'+instNum ) +'[]');
					//eles = $cetp(eles,$(this.dialogId + '.R' + rowNum));
					eles = this._functionToConstrainElements(eles);
					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);
			}
		}
		
		
		if(typeof rsTemp._r[rowNum-1].hc != 'undefined') {
			for(var controlName in rsTemp._r[rowNum-1].hc) {
				this._hideRSColumnLow(controlName,instNum,rsTemp._r[rowNum-1].hc[controlName]);
			}
		}
		this._executeEvent('afterRptSectionRowPrepare',{sectionName: sectionName, rowNumber: 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;
	            
	           
	            data = data.replace('%26amp;','&');
	            data = data.replace('%3D','=');
	            data = data.replace('%26gt;','>');
	            data = data.replace('%26lt;','<');
	            
	            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;
				vali = decodeURIComponent(vali);
				if(p2 == 'G') {
					if(go.parentControlType == 'G') window[objName].setValue(go.parentControlType,arr[i].source,r2,vali);
					else window[objName].setValue(go.parentControlType,arr[i].source,vali);
				}
				else window[objName].setValue(arr[i].source,vali);
				
			} else {
				if(p2 == 'G') {
					if(go.parentControlType == 'G') window[objName].setValue(go.parentControlType,arr[i].source,r2,vali);
					else window[objName].setValue(go.parentControlType,arr[i].source,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();
	    var obj = {};
	    obj.specialDialogMode = 'none';
	    this._executeEvent('onSynchronizeDialog',{synchronizeType: obj.specialDialogMode, obj: obj});
	    
	},
	
	
	_findArrayProp: function(array,propName,value) {
		for(var i = 0; i < array.length; i++) {
		    if(array[i][propName].toLowerCase() == value.toLowerCase()) {
	               return i;
	            }
		}
	    return -1;
	},
	
	getParentObject: function() {
		if(this.parentComponentAlias !='') {
			if(typeof window[this.parentComponentAlias+'_GridObj'] != 'undefined') return window[this.parentComponentAlias+'_GridObj'];
			if(typeof window[this.parentComponentAlias+'_DlgObj'] != 'undefined') return window[this.parentComponentAlias+'_DlgObj'];
			return false
		} else return false;
	},
	
	buttonClick: function(id) {
		id = id.toUpperCase();
		var instNum = typeof arguments[1] != 'undefined' ? arguments[1] : -1;
		var eleId = this.dialogId + '.V.R1.' + id;
		if(instNum > 0) eleId = eleId + '_A5INSTANCE' + instNum;
		var ele = $(eleId);
		if(ele) {
			$e.execute(ele,'abstractclick');
			ele.click();
		}
	},
	
	
	getOrientation: function() { 
		var ele = $('MOBILESIMULATORDEVICEPICKER');
		if(ele) { 
			var ele2 = $(this.dialogId + '.R1.BODY');
			if(ele2.clientWidth >= ele2.clientHeight) return 'landscape';
			else return 'portrait';
		}
		
		if( window.innerWidth >= window.innerHeight) {
			return 'landscape';
		} else {
			return 'portrait';
		}
	},
	
	
	refreshClientSideComputations: function() {
		this._fireWatches(1);	
	},
		
	_fireWatches: function(rowNum) {
		for(var columnName in this.columnInfo) {
			if(this.columnInfo[columnName].calculateSummary) {
				this._summarize(columnName,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);
			}
			
			if(typeof this.dialogWatches[dialogWatch].updateColumn != 'undefined') {
				if(this.dialogWatches[dialogWatch].updateColumn != '') {
					var ci = this.columnInfo[this.dialogWatches[dialogWatch].updateColumn]
					if(typeof ci != 'undefined') {
						if(ci.calculateSummary) {
						this._summarize(this.dialogWatches[dialogWatch].updateColumn,rowNum);
						}		
					}
				}
			}
			
		}
	},
	
	_repeatingSectionRowErrorShow: 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._repeatingSectionRowErrorHideCancel,classInst);
				$e.add(ele,'mouseout',classInst._repeatingSectionRowErrorHide,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');
			
		}
		
	},
	
	_repeatingSectionRowErrorHideCancel: 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);
	},
	
	_repeatingSectionRowErrorHide: 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';
			if(typeof window[containerName]._curBandIndx != 'undefined') {
				//in an accordion
				if(window[containerName]._curBandIndx != -1) {
					if(window[containerName]._curBandIndx +1 == obj[i].pane) {
						//you are already on the pane. so bail. otherwise it will toggle the pane
						return false;
					}
				}
			}
			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();
	},
	
	_resetDialogToBlank: function() {
		var data = {};
		$u.o.assign(data,this.defaultValues);
		delete data.A5REPEATINGSECTIONDATA;
		this.populate(data);
		for(var rs in this.repeatingSections) {
			for(var i = 0; i < this.repeatingSections[rs].rows; i++) {
				this._setRepeatingRowValuesToNull(rs,i+1);
			}
		}	
	},
	
	closeCurrentTabbedUIPane: function() {
		if(typeof tbiObj != 'undefined') {
			var idx = tbiObj._tbObj._curTabIndx;
			tbiObj._tbObj.remove(idx);
		}
	},
	


	synchronizeDialog: function(obj) {
	
		if(typeof this._hasOnSynchronizeEvent != 'undefined') {
			if(this._hasOnSynchronizeEvent) {
				var jdata = $u.o.toJSON(obj);
				var data = new Array();
				data.push(A5.ajax.buildURLParam('_jdata',jdata));
				data = data.join('&');
				var xbasicFunction = 'system:onSynchronizeDialogServerEvent';
				this.ajaxCallback('G',1,xbasicFunction,'',data);
				}
		}
		
		
		if(typeof obj.specialDialogMode == 'undefined') {
			this._resetDialogToBlank();
			
			this._executeEvent('onSynchronizeDialog',{synchronizeType: obj.specialDialogMode, obj: obj});
			return false;
		}
		if(obj.specialDialogMode == 'editGridRow') {
			//reset dialog to default
			this._resetDialogToBlank();
			this.populateControlsFromTable(obj.recordPrimaryKey);
			this.stateInfo._parentGridRow = obj.__parentRowNum;
		}

		if(obj.specialDialogMode == 'newGridRow') {
			this._resetDialogToBlank();
			this.newRecord();
		}

		if(obj.specialDialogMode == 'populateDialog') {
			if(obj.getPKFrom.toLowerCase() == 'specifynow') {
				this._resetDialogToBlank();
				this.populateControlsFromTable(obj.pkValue);

			} else {
				this._resetDialogToBlank();
				this.populateControlsFromTable('__sessionvariable__:' +obj.pkValue);
			}
		}

		//since the window show happens after the synchronizeDialog() we have to use a setTimeout() to fix RS headings		
		var classInst = this;
		setTimeout(function() {classInst._fixAllRepeatingSectionHeaders(); delete classInst; },100);
		
		this._executeEvent('onSynchronizeDialog',{synchronizeType: obj.specialDialogMode, obj: obj});
		
	},
	
	_fixAllRepeatingSectionHeaders: function() {
		for(var rs in this.repeatingSections) {
			this._prepareRepeatingSection(rs,1);
		}
	},
	 

	deleteRecord: function() {

		var options = typeof arguments[0] != 'undefined' ? arguments[0] : {};
		if(typeof options.confirmation != 'undefined') {
			if(options.confirmation == false) {
				this._deleteRecordNoConfirmation(options);
				return true;
			}
		}
		var classInst = this;
		var msg = classInst.deleteRecordDialogMessage;
		var image = classInst.resetFormIcon;
		msg = '<div style="padding: 10px;" ><img src="'+image+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" style="margin-right: 5px; float: left;"/>'+msg+'					<br style="clear: both;" /></div>'					
		A5.msgBox.show(classInst.deleteRecordDialogTitle,msg,'yn',function(button) {
			if(button == 'yes'){
				classInst._deleteRecordNoConfirmation(options);    
		    } else if(button == 'no'){
		       //do nothing
			}
			delete classInst;
			} );
		return false;
	},
	 
	 
	
	_deleteRecordNoConfirmation: function() {
		var options = typeof arguments[0] != 'undefined' ? arguments[0] : {};
		var pkl = this._primaryKeyList;
		if(!pkl) {
				alert('Error - You have not loaded primary keys for the Dialog. Therefore, you cannot delete this record.');
				return false;
			}
		if(pkl.length == 0) return false;
		
		var currentRecord = 0;
		if(typeof this._currentRecordNumber != 'undefined') {
			currentRecord = this._currentRecordNumber;
		}
		
		var flagAdjustCurrentRecord = false;
		if(currentRecord == pkl.length) flagAdjustCurrentRecord = true;
		
		var nextRecordToShow = 0;
		if(currentRecord < pkl.length) {
			nextRecordToShow = currentRecord + 1;
		} else {
			nextRecordToShow = currentRecord - 1;
		}
		
		
		var pkToShow = '';
		var flagShowNewRecord = true;
		if(nextRecordToShow >0) {
			pkToShow = pkl[nextRecordToShow-1].k;
			flagShowNewRecord = false;
		}
		
		if(typeof options.nextRecordToShow != 'undefined') {
			if(options.nextRecordToShow.toLowerCase() == 'newrecord') flagShowNewRecord = true;
		}
		
		
		var data = '_flagAdjustCurrentRecord=' +flagAdjustCurrentRecord +  '&_flagShowNewRecord=' + flagShowNewRecord +  '&_currentRecordNumber=' + currentRecord + '&_primaryKeyToShow=' + pkToShow + '&_options=' + $u.o.toJSON(options);
		var xbasicFunction = 'system:deleteRecord';
		this.ajaxCallback('G',1,xbasicFunction,'',data);
	
	},
	
	
	navigateRecord: function(direction) {
		var flagSetSliderPosition = typeof arguments[1] != 'undefined' ? arguments[1] : true;
		var flag = '';
		flag = this._executeEvent('canRecordNavigate',{isDirty: this._isDirty, isDataDirty:  this._isDataDirty, target: direction});
		if (flag == false) {
			this._setSliderPosition(this._currentRecordNumber,false);
			if(typeof this._primaryKeyListNavigator != 'undefined') this._primaryKeyListNavigator.setValue(this._currentRecordNumber -1,false); //don't navigate to target record
			return false;
		}
		/*
		//it is up to the developer to decide how to handle this in the canRecordNavigate event
		if(this._isDataDirty) {
			alert('Please save changes before navigating.');
			this._setSliderPosition(this._currentRecordNumber,false);
			if(typeof this._primaryKeyListNavigator != 'undefined') this._primaryKeyListNavigator.setValue(this._currentRecordNumber -1,false); //don't navigate to target record
			return false;
		}
		*/
		 
		var pkl = this._primaryKeyList;
		if(!pkl) {
			alert('Error - You have not loaded primary keys for the Dialog. Therefore, you cannot navigate records.');
			return false;
		}
		if(pkl.length == 0) return false;
		
		if(typeof pkl == 'undefined') return false;
		if(!isNaN(direction)) {
				targetRecord = direction;
		} else {
			direction = direction.toLowerCase();
			var currentRecord = 0;
			if(typeof this._currentRecordNumber != 'undefined') {
				currentRecord = this._currentRecordNumber;
			}
			var targetRecord = 0;
			if(direction == 'next') targetRecord = currentRecord + 1;
			if(direction == 'previous') targetRecord = currentRecord - 1;
			if(direction == 'first') targetRecord = 1;
			if(direction == 'last') targetRecord = pkl.length;
			if(targetRecord == 0) targetRecord = 1;
			if(targetRecord > pkl.length) targetRecord = pkl.length
		}
		
		this.populateControlsFromTable(pkl[targetRecord-1].k,false);
		this._currentRecordNumber = targetRecord;
		if(flagSetSliderPosition) {
			this._setSliderPosition(targetRecord,false);
		}
		if(typeof this._primaryKeyListNavigator != 'undefined') this._primaryKeyListNavigator.setValue(targetRecord -1,false); //don't navigate to target record
		
		this._executeEvent('afterRecordNavigate',{target: direction});
		
	},
	
	
	setFocus: function(name) {
		var instNum = typeof arguments[1] != 'undefined' ? arguments[1] : 0;
		this.activateControlContainer(name.toUpperCase());
		var ele = $(this.dialogId + '.V.R1.' + name.toUpperCase());
		if(instNum > 0) {
			//_repeatingSectionLogicalToPhysicalRow
			var rsName = this._findRepeatingSection(name);
			var instNum2 = this._repeatingSectionLogicalToPhysicalRow(rsName,instNum);
			ele = $(this.dialogId + '.V.R1.' + name.toUpperCase()+'_A5INSTANCE' + instNum2);
		}
		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;
				
				classInst.setRepeatingSectionActiveRow(rsName,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));
		var eles = this._functionToConstrainElements($n('V.R' + rowNum + '.' + cntrlInfoObj.controlName));
		
		
		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(this._isDataDirty == false) {
					if($u.a.find(this._dataBoundControls,cntrlInfoObj.name) != -1) {
						this._isDataDirty = true;
						this._variablesChanged(['dialog.isDataDirty'],rowNum);
						this._executeEvent('onDataStateChange',{isDirty: true, isDataDirty: this._isDataDirty});
						//the previous command was not causing the submit button to show if an unbound field had been previously edited
						this.refreshClientSideComputations();
					}
				}
				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));
		var eles = this._functionToConstrainElements($n('V.R' + rowNum + '.' + cntrlInfoObj.controlName));
		
		
		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;
	},

	
	_repeatingSectionRowIsEmpty: function(name,rowNum) {
			var isEmpty = true;
			var controls = this._getControlsInRepeatingSection(name);
			for(var i=1;i<= controls.length;i++) {
				if(this.getValue(controls[i-1] + ':' + rowNum) != '' ) {
					isEmpty = false;
					return isEmpty;
				}
			}
			return isEmpty;
	},
	
	
	_repeatingSectionRowIsDeleted: function(id,i) {
		return this.repeatingSections[id]._r[0].i[i-1].deleted;
	},


	_repeatingSectionLogicalToPhysicalRow: function(name,logicalRow) {
		var rs = this.repeatingSections[name]._r[0].i;
		var pr = -1;
		var lr = 0 ;
		for(var i = 1; i <= rs.length; i++) {
			if(!rs[i-1].deleted) {
				lr = lr+1;	
				if(lr == logicalRow) {
					pr = i;
					break;
				}
			}
		}
		return pr;
	},
	
	_getControlsInRepeatingSection: function(name) {
		return this.repeatingSectionInfo[name].controls;
	},
	

	_setRowState: function(rowNum,isDirty) {
		var dataDirty = this._isDataDirty;
		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;
					this._isDataDirty = false;
				}
			}
			
			if(this._prepared)	this._fireWatches(rowNum);
			this._executeEvent('onStateChange',{isDirty: this._isDirty, isDataDirty: this._isDataDirty});
			if(isDirty == false && dataDirty) this._executeEvent('onDataStateChange',{isDirty: false, isDataDirty: false});
		}
	},	
	

	_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 onCallbackComplete = typeof arguments[2] != 'undefined' ? arguments[2] : '';
		var debugDiv = typeof arguments[3] != 'undefined' ? arguments[3] : '';
		var errorDiv = typeof arguments[4] != 'undefined' ? arguments[4] : '';
		var data = '_showDebug=' + showDebugInfo + '&_primaryKey=' + pkData + '&_debugInfoDiv=' + debugDiv + '&_errorDiv=' + errorDiv;
		data = data + '&' + A5.ajax.buildURLParam('_onCallbackComplete',onCallbackComplete);
		var xbasicFunction = 'system:populateControlsFromTable';
		
		this.ajaxCallback('G',1,xbasicFunction,'',data);
	},
	
	

	getPrimaryKeyList: function(filter,order,maxKeys) {
		var arr = [];
		arr.push(A5.ajax.buildURLParam('__filter',filter));
		arr.push(A5.ajax.buildURLParam('__order',order));
		arr.push(A5.ajax.buildURLParam('__maxkeys',maxKeys));
		var data = arr.join('&');
		var xbasicFunction = 'system:getPrimaryKeyList';
		this.ajaxCallback('G',1,xbasicFunction,'',data);
	},
	
	refreshPrimaryKeyList: function() {
		var xbasicFunction = 'system:refreshKeys';
		var data = '';
		this.ajaxCallback('G',1,xbasicFunction,'',data);
	},
	
	getRepeatingSectionVisibleRows: function(sectionName) {
		var rs = this.repeatingSections[sectionName];
		if(typeof rs == 'undefined') return false;
		var rows = rs.rows;
		var a = [];
		var ele = '';
		for(var i = 1; i <= rows; i++) {
			ele = $(this.dialogId + '.V.R1.' + sectionName + '.I' + i);
			if(ele) {
				if(ele.style.display == '') a.push(i);
			}
		}
		return a.join(',');
	},
	
	_harvestRow: function(row) {
		var data = new Array();
		var dirtyColumns = new Array();
		var rs = 0;
		var vardata_i = '';
		var varolddata_i = '';
		var eleFU = '';
		var colName2 = '';
		
		var colnameSuffix = '';
		for(var colName in this.columnInfo) {
			colName2 = colName
			if(this.columnInfo[colName].isArray) colnameSuffix = '[]';
			else colnameSuffix = '';
			if(typeof this.columnInfo[colName].repeatingSection != 'undefined') {
				rs = this.repeatingSections[this.columnInfo[colName].repeatingSection];
				if(typeof rs == 'undefined') return false;
				for(var i = 1; i <= rs.rows; i++) {
					vardata_i = this.getValue(colName+':'+i,row);
					varolddata_i = this.originalValues[row-1][colName+':'+i];
					if(this.columnInfo[colName].type == 'img,img') {
						//don't submit binary data
						if (vardata_i.substring(0,11) == 'data:image/') vardata_i = '';
						if (varolddata_i.substring(0,11) == 'data:image/') varolddata_i = '';
					}
					
					if(this.columnInfo[colName].type == 'fileUpload,fileUpload') {
						
						var eleFU = $(this.dialogId + '.V.R1.' + colName + '_A5INSTANCE' + i);
						if(eleFU) vardata_i = eleFU.value;
						varoldata_i = '';
						colName2 = colName+ '_A5FILEUPLOAD' ;
						if(vardata_i != '') dirtyColumns.push(colName2+ '_A5INSTANCE' + i);
					}
					
					
					data.push(A5.ajax.buildURLParam('V.R' + row + '.' + colName2+'_A5INSTANCE' + i+colnameSuffix, vardata_i ));				
					data.push(A5.ajax.buildURLParam('old.V.R' + row + '.' + colName2+'_A5INSTANCE' + i+colnameSuffix, varolddata_i ));
					if(this.getControlDirty(colName+':'+i,row)) {
						dirtyColumns.push(colName+'_A5INSTANCE'+i);
					}
					if(this.columnInfo[colName].type == 'img,img') {
						var eleId = this.dialogId + '.V.R1.' + colName + '_HIDDENA5FN' +'_A5INSTANCE' + i +colnameSuffix;
						var ele = $(eleId);
						var valImg = $gvs(ele);
						data.push(A5.ajax.buildURLParam('V.R' + row + '.' + colName+'_HIDDENA5FN'+'_A5INSTANCE'+ i +colnameSuffix, valImg ));				
						data.push(A5.ajax.buildURLParam('old.V.R' + row + '.' + colName+'_HIDDENA5FN'+'_A5INSTANCE'+ i +colnameSuffix, '' ));		
						if(valImg != '') {
							dirtyColumns.push(colName+ '_HIDDENA5FN' +'_A5INSTANCE' + i +colnameSuffix);
						}
					}
				}
			} else {
			
				vardata_i = this.getValue(colName,row);
				varolddata_i = this.originalValues[row-1][colName];
				colName2 = colName
				
				if(this.columnInfo[colName].type == 'img,img') {
				//don't submit binary data
					if (vardata_i.substring(0,11) == 'data:image/') vardata_i = '';
					if (varolddata_i.substring(0,11) == 'data:image/') varolddata_i = '';
				}
				
				if(this.columnInfo[colName].type == 'fileUpload,fileUpload') {
					var eleFU = $(this.dialogId + '.V.R1.' + colName);
					if(eleFU) vardata_i = eleFU.value;
					varoldata_i = '';
					colName2 = colName+ '_A5FILEUPLOAD';
					if(vardata_i != '') dirtyColumns.push(colName2);
				}

				data.push(A5.ajax.buildURLParam('V.R' + row + '.' + colName2+colnameSuffix, vardata_i ));				
				data.push(A5.ajax.buildURLParam('old.V.R' + row + '.' + colName2+colnameSuffix, varolddata_i ));
				if(this.columnInfo[colName].type == 'img,img') {
					var eleId = this.dialogId + '.V.R1.' + colName + '_HIDDENA5FN';
					var ele = $(eleId);
					var valImg = $gvs(ele);
					data.push(A5.ajax.buildURLParam('V.R' + row + '.' + colName+'_HIDDENA5FN'+colnameSuffix, valImg ));				
					data.push(A5.ajax.buildURLParam('old.V.R' + row + '.' + colName+'_HIDDENA5FN'+colnameSuffix, '' ));		
					if(valImg != '') {
						dirtyColumns.push(colName+ '_HIDDENA5FN');
					}
				}
				
				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('&');
	},
	
	setVariables: function(vars) {
		if($u.compare(this._vars,vars) == false ) {
			$u.o.assign(this._vars,vars);
		}
	},
	
	getSessionVariable: function(varname) {
		varname = varname.toUpperCase();
		return this._vars.SESSION[varname];
	},
	
	getPageVariable: function(varname) {
		varname = varname.toUpperCase();
		return this._vars.PAGEVARIABLE[varname];
	},

	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;
		var honorChange = typeof arguments[3] != 'undefined' ? arguments[3] : true;
		if(clean) {
			//$u.o.assign(this.originalValues[row-1],data);
			var cntrlInfoObj = '';
			var prop2 = '';
			var tempData = '';
			for(var prop in data) {
				prop2 = prop.split('_A5INSTANCE').join(':');
				prop2 = prop2.toUpperCase();
				tempData = data[prop];
				if(tempData == null) tempData = '';
				this.setValue(prop2,tempData,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');
				$sa(this._functionToConstrainElements($n('V.R'+row + '.' + cntrlInfoObj.controlName)),'A5IsDirty','false');
			}
			this._setRowState(row,false);			
		} else {
			for(var prop in data) {
				this.setValue(prop,data[prop],honorChange,row);
			}
		}
	},
	 
	 
	getControl: function(name ) {
		name = name.toUpperCase();
		var cntrlInfoObj = this._getControlInfo(name);
		name = cntrlInfoObj.name;
		var row = typeof arguments[1] != 'undefined' ? arguments[1] : 1;		
		if(cntrlInfoObj.instNum != -1) {
			if(typeof this._controlInst['R' + row + '.' + name + '_A5INSTANCE' + cntrlInfoObj.instNum] != 'undefined') return this._controlInst['R' + row + '.' + name + '_A5INSTANCE' + cntrlInfoObj.instNum];
		} else {
			if(typeof this._controlInst['R' + row + '.' + name] != 'undefined') return this._controlInst['R' + row + '.' + name ];
		}
		return false;
	
	},
	


	getValue: function(name) {
		
		if(name.split('::')[0].toLowerCase() == 'list' && typeof name.split('::')[1] != 'undefined')  {
			//get value from a list. format for name is: //list::l1::lastname (list::listname::fieldname). listname can be list1:3 (3rd instance)
			var listId = name.split('::')[1];
			var field = name.split('::')[2];
			return this._listGetValue(listId,field);
		}
		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 flagForceReadControl = this.columnInfo[name].isCalc;
			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 = '';

					var val = $gvs('V.R' + row + '.' + cntrlInfoObj.controlName, this._functionToConstrainElements );
					if(val == $ga('V.R' + row + '.' + cntrlInfoObj.controlName, 'A5WatermarkText', this._functionToConstrainElements)[0]) val = '';

					if(typeof dataType != 'undefined') {
						if(dataType == 'L') val = $u.s.toBool(val);
					}
					
					if(this.columnInfo[name].isArray && typeof val == 'string') val = val.split('\n');
					
					return val;
				}				
			}
			if(colType == 'label') return $gvs(this.dialogId + '.V.R' + row + '.' + cntrlInfoObj.controlName);
			if(colType == 'link') return this.originalValues[row -1][cntrlInfoObj.fullName][0];
			else {
				if(flagForceReadControl) {
					var val = $gvs(this.dialogId + '.V.R' + row + '.' + cntrlInfoObj.controlName);
					if(typeof dataType != 'undefined') {
						if(dataType == 'L') val = $u.s.toBool(val);
					}
					return val
					
				} 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;			
		}
	
	},

	setValueFrom: function(target,source) {
		if(target.constructor == Array) {
			var count = target.length;
			var count2 = source.length;
			var t2 = '';
			var s2 = '';
			for(var i = 1; i <= count; i++) {
				t2 = target[i-1];
				s2 = source[i-1];
				if(typeof s2 != 'undefined') this.setValue(t2,this.getValue(s2));
			}
			
		} else {
			this.setValue(target,this.getValue(source));
		}
	},

	setValue: function(name, value) {
		var ele = false;
		name = name.toUpperCase();
		var cntrlInfoObj = this._getControlInfo(name);
		name = cntrlInfoObj.name;
		
		if(typeof cntrlInfoObj.type == 'undefined') {
			var ele = $(this.dialogId + '.V.R1.' + name);
			if(ele) {
				if(ele.tagName == 'DIV' || ele.tagName == 'A' || ele.tagName == 'BUTTON') return ele.innerHTML = value;
			}
		}

		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 == 'control'){		
				//$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,$(this.dialogId+'.R'+row));
				$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,this._functionToConstrainElements);
				
				
				if(this._controlInst['R' + row + '.' + cntrlInfoObj.controlName ]) {
					this._controlInst['R' + row + '.' + cntrlInfoObj.controlName ].setValue(value);
				}
			} 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));
				$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,this._functionToConstrainElements);
				$(this.dialogId+'.V.R'+row+'.'+cntrlInfoObj.controlName+'.DISPLAY').innerHTML = value;
			} else if(colType == 'logicalRadio') {
				if(value) value = 'True';
				else value = 'False';
				$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,this._functionToConstrainElements);
			} else if(colType == 'rte'){
				//$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,$(this.dialogId+'.R'+row));
				$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,this._functionToConstrainElements);
				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));
				
				$svs('V.R'+row+'.'+cntrlInfoObj.controlName,value,this._functionToConstrainElements);
			}
		} else {
			//$svs('V.R'+row+'.'+name,value,$(this.dialogId+'.R'+row));
			$svs('V.R'+row+'.'+name,value,this._functionToConstrainElements);
		}
		if(!ele && honorChange){
			ele = $n('V.R'+row+'.'+cntrlInfoObj.controlName);
			//ele = $cetp(ele,$(this.dialogId+'.R'+row));
			ele = this._functionToConstrainElements(ele);
			if(ele){
				//if a checkbox for example, has 10 boxes - don't fire onChange 10 times!
				//for(var i=0;i<ele.length;i++) $e.execute(ele[i],'change');
				$e.execute(ele[0],'change');
			}
		} else if(honorChange) {
			$e.execute(ele,'change');
		}
	},
	
	
	fadeOutMessage: function(id,message) {
		var duration = typeof arguments[2] != 'undefined' ? arguments[2] : 2000;
		var flagStyle = typeof arguments[3] != 'undefined' ? arguments[3] : true;
		A5.fadeOutMessage(id,message,duration,flagStyle,this.styleName);
	},
	
	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 w2 = this.getWindow(this._currentOpenLookupWindowName);
		if(w2) w2.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];
		if(typeof rsTemp == 'undefined') return false;
		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];
		if(typeof rsTemp == 'undefined') return false;
		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];
		if(typeof rsTemp == 'undefined') return false;
		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;
					}
				}
				
			}
		}
	},
	
	showGlobalErrors: function(location,msg) {
		var eleId = '';
		if(location.toLowerCase() == '<default>' || location == '') eleId = this.dialogId + '.GLOBALERRORS';
		else eleId = this.dialogId + '.V.R1.' + location.toUpperCase();
		
		var ele = $(eleId);
		if(!ele) {
			alert('Global Error\n\n' + msg);
			return false;
		}
		this._globalErrorId = ele;
		ele.style.display = '';
		ele.innerHTML = '<span style="color:red;">' + msg + '</span>';
	},
	
	showDebuggingInfo: function(location,msg) {
		var eleId = '';
		if(location.toLowerCase() == '<default>' || location == '') eleId = this.dialogId + '.DEBUGUPDATECOMMANDS';
		else eleId = this.dialogId + '.V.R1.' + location.toUpperCase();
		var ele = $(eleId);
		if(!ele) return false;
		ele.style.display = '';
		ele.innerHTML = msg;
	},

	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';
		
		var ele2  = this._globalErrorId;
		if(ele2) ele2.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);
	},
	
	validateContainer: function(containerId) {
		var onSuccess = typeof arguments[1] != 'undefined' ? arguments[1] : 'none';
		var onFailure = typeof arguments[2] != 'undefined' ? arguments[2] : 'none';
		var onSuccessSS = typeof arguments[3] != 'undefined' ? arguments[3] : 'none';
	
	},
	
	runAction: function(name) {
		var actObj = this._actions;
		if(typeof actObj == 'undefined') return false;
		var js = actObj[name];
		if(typeof js == 'undefined') return false;
		if(js != '') eval(js);
		
	
	},
	
	submit: function() {
		var submitType = typeof arguments[0] != 'undefined' ? arguments[0] : 'none';
		var submitData = typeof arguments[1] != 'undefined' ? arguments[1] : '';
		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){
			
				var d = this._rseh._e[i].id.split('.').pop().split('_A5INSTANCE');
				var rsName = this._findRepeatingSection(d[0]);
				if(!this.repeatingSections[rsName]._r[0].i[Number(d[1])-1].deleted) {
					return false;
				}
			}
		}
		if(!this._executeEvent('canSubmitDialog',{ajaxEvent: 'SubmitDialog'})) return false;
		var data = '__submitType=' + submitType;
		if(submitData != '') data = data + '&' + submitData;
		this.ajaxCallback('G',1,'system:submitDialog','',data);
	},
	
	
	
	resetForm: function() {
		var prompt = typeof arguments[0] != 'undefined' ? arguments[0] : true;
		if(prompt) {
			if(!this._executeEvent('canResetForm',{})) return false;
			var classInst = this;

			var msg = classInst.resetFormMessage;
			var image = classInst.resetFormIcon;
			msg = '<div style="padding: 10px;" ><img src="'+image+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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();
		this._executeEvent('afterResetForm',{});
	},
	
	
	_confirmAction: function() {
		var msg = this.dirtyFormMessage;
		var image = this.dirtyFormIcon;
		msg = '<div style="padding: 10px;" ><img src="'+image+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" style="margin-right: 5px; float: left;"/>'+msg+'					<br style="clear: both;" /></div>'					
		A5.msgBox.show(this.dirtyFormTitle,msg,'O',function() {} );
	},

	
	getRepeatingSectionActiveRow: function(sectionName) {
		var flagLogicalRow = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		var rs = this.repeatingSections[sectionName];
		if(typeof rs == 'undefined') return false;
		if(flagLogicalRow) {
			var lrn = 0;
			for(var i = 1; i <= rs.rows; i++) {
				if(rs._r[0].i[i-1].deleted == false) {
					lrn++;
					if(i == rs.activeRow) break;
				}
			}
			return lrn;
		} else {
			return rs.activeRow;
		}
	},
	
	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;
		this._executeEvent('onRptSectionRowChange',{sectionName: sectionName, rowNumber: instNumber, previousRowNumber: oldInstNumber});		
		
		
	},
	
	_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 '';	
	},
	
	getInstanceNumber: function(controlName) {
		var rs = this._findRepeatingSection(controlName.toUpperCase());
		if(rs == '') return '';
		var rsi = this.repeatingSections[rs];
		return rsi.activeRow;
	},
	
	harvestRepeatingSectionColumn: function(controlName) {
		var delim = typeof arguments[1] != 'undefined' ? arguments[1] : ',';
		var mode =  typeof arguments[2] != 'undefined' ? arguments[2] : '';
		var sectionName = this._findRepeatingSection(controlName);
		if(sectionName == '') return false;
		controlName = controlName.toUpperCase();
		var rs = this.repeatingSections[sectionName];
		if(typeof rs == 'undefined') return false;
		var rowNum = 1;
		var rows = rs.rows
		var dataArr = [];
		var ele = '';
		var ele2 = '';
		var ele3 = '';
		if(mode != '') {
			if(typeof rs._r[rowNum-1].hc == 'undefined') rs._r[rowNum-1].hc = {};
			rs._r[rowNum-1].hc[controlName] = mode;
		}
		for(var instNum = 1; instNum <= rows; instNum ++) {
			if(mode == '') {
				if(rs._r[rowNum-1].i[instNum-1].deleted == false) {
					dataArr.push(this.getValue(controlName + ':' + instNum));
				}
			} else {
				this._hideRSColumnLow(controlName,instNum,mode);
			}
		}
		var data = dataArr.join(delim);
		return data;
	},
	
	
	_hideRSColumnLow: function(controlName,instNum,mode) {
	
		ele = $(this.dialogId + '.V.R1.' + controlName + '_A5INSTANCE' + instNum);
		tEle = $(this.dialogId + '.V.R1.' + controlName + '.RSTITLE');
		cEle = false;
		ctEle = false;
		while(ele.tagName.toLowerCase() != 'body') {
			if(ele.className.toLowerCase() == 'a5container') { 
				cEle = ele;
				break;
			}
			ele = ele.parentNode;
		}
		if(tEle) {
			while(tEle.tagName.toLowerCase() != 'body') {
				if(tEle.className.toLowerCase() == 'a5container') { 
					ctEle = tEle;
					break;
				}
				tEle = tEle.parentNode;
			}
		}
		
		var brEle = false;
		var brtEle = false;
		if(cEle) {
			brEle = cEle.nextSibling;
		}
		if(ctEle) {
			brtEle = ctEle.nextSibling;
		}

		if(mode == 'hide') {
			if(cEle) cEle.style.display = 'none';
			if(ctEle) ctEle.style.display = 'none';

			if(brEle) brEle.style.display = 'none';
			if(brtEle) brtEle.style.display = 'none';			
			
		}

		if(mode == 'show') {
			if(cEle) cEle.style.display = '';
			if(ctEle) ctEle.style.display = '';
			
			if(brEle) brEle.style.display = '';
			if(brtEle) brtEle.style.display = '';			
			
		}

		if(mode == 'visibility_hide') {
			if(cEle) cEle.style.visibility = 'hidden';
			if(ctEle) ctEle.style.visibility = 'hidden';
			
			if(brEle) brEle.style.visibility = 'hidden';
			if(brtEle) brtEle.style.visibility = 'hidden';			

			
		}				
		if(mode == 'visibility_show') {
			if(cEle) cEle.style.visibility = 'visible';
			if(ctEle) ctEle.style.visibility = 'visible';

			if(brEle) brEle.style.visibility = '';
			if(brtEle) brtEle.style.visibility = '';					
			
		}			
		
	},
	
	hideRepeatingSectionColumn: function(controlName) {
		var mode =  typeof arguments[1] != 'undefined' ? arguments[1] : 'hide';
		this.harvestRepeatingSectionColumn(controlName,'',mode);
	},
	
	
	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];
		if(typeof rs == 'undefined') return false;
		var pEle = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName);
		if(rs.usedRows < rs.rows) {
			var instNum = rs.usedRows + 1;
			rs.usedRows = instNum;
			var ele = $(this.dialogId + '.V.R' + rowNum + '.' + sectionName + '.I' + instNum);
			ele.style.display = '';
			//new record row was not scrolling into view
			if($(this.dialogId + '.V.R'+rowNum+'.' + sectionName+'.CONTENT')) pEle = $(this.dialogId + '.V.R'+rowNum+'.' + sectionName+'.CONTENT');
		} else {
			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;
			rs.usedRows = instNum;
		}
		//if the new row you just added is already in the dom, make sure it is not set to deleted
		rs._r[0].i[instNum-1].deleted = false;
		
		var tempData = {};
		for(colName in rs._ci) {
			if(typeof this.defaultValues.A5REPEATINGSECTIONDATA != 'undefined') {
				tempData[colName + ':' + instNum] = this.defaultValues.A5REPEATINGSECTIONDATA[colName];
				this.originalValues[rowNum-1][colName + ':' + instNum] = this.defaultValues.A5REPEATINGSECTIONDATA[colName];
			} else { 
				tempData[colName + ':' + instNum] = this.defaultValues[colName];
				this.originalValues[rowNum-1][colName + ':' + instNum] = this.defaultValues[colName];
			}
		}
		this.populate(tempData,rowNum,false,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) {
				pEle.scrollTop = pEle.scrollHeight;	
			}
		}
		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];
		if(typeof rs == 'undefined') return false;
		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+'?A5WSessionId=b0259207a0504e5faa0d3a16c33b60dd" 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);
						//want the submit button to go enabled after deleting a row that has a key (i.e databound row)
						classInst._isDataDirty = true;
						classInst._variablesChanged(['dialog.isDataDirty'],rowNum);
						classInst.refreshClientSideComputations();
						classInst._executeEvent('afterRptSectionRowDelete',{sectionName: sectionName, rowNumber: 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];
		if(typeof rs == 'undefined') return false;
		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);
		this._getRepeatingSectionLogicalRowNumber(sectionName);
	},
	
	_getRepeatingSectionRowCount: function(sectionName) {
		var rs = this.repeatingSections[sectionName];
		if(typeof rs == 'undefined') return false;
		var count = 0;
		var rowNum = 1;
		for(var i = 1; i <= rs.rows; i++) {
			if(rs._r[rowNum-1].i[i-1].deleted != true) count++;
		}	
		return count;
	},
	
	_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];
		if(typeof rs == 'undefined') return false;
		rs.usedRows = rows;
		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) {
				if(flagSetToNull) this.undeleteRepeatingSectionRow(sectionName,i);
			} else {
				if(flagSetToNull) {
					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(!flagSetToNull) {
			//if not setting existing data to null, deleted rows are not restored, therefore
			//the actual row count might still be short
			var actualRows = this._getRepeatingSectionRowCount(sectionName);
			var rowsStillToAdd = rows - actualRows;
			if(rowsStillToAdd > 0 ) {
				for(var i = 1; i <= rowsStillToAdd; i++) {
					this.addRepeatingSectionRow(sectionName,flagNavToNewRow);
					//alert('target row count: ' + rows + ' actual ' + actualRows);
				}
			}
		}
		
		
		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');
			$sa(this._functionToConstrainElements($n('V.R'+row + '.' + obj.controls[i-1])),'A5IsDirty','false');
			
		}
	},
	
	undeleteRepeatingSectionRow: function(sectionName,instNum) {
		var rs = this.repeatingSections[sectionName];
		if(typeof rs == 'undefined') return false;
		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];
		if(typeof rs == 'undefined') return false;
		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];
		if(typeof rs == 'undefined') return false;
		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;
			}
		}
		//force summary calculations to recompute
		this.refreshClientSideComputations();
	},
	
	
	
	accordionPanes: function(id,action) {
		//action is 'open' or 'close' - opens or closes all panes on an accordion
		action = action.toUpperCase()[0];
		var test = true;
		if(action == 'O') test = false;
		var ele = window[this.dialogId + '.V.R1.' + id + 'Obj'];
		var count = ele.bands.length;
		for(var i = 1; i <= count; i++) {
			if(ele.bands[i-1].expanded == test) {
				ele.select(i-1,true);
			}
		}
	},
	
	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;
		var instNum = 0;
		controlName = controlName.split('_A5INSTANCE');
		if(controlName[1]!= '') instNum = controlName[1];
		controlName = controlName[0];
		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);
		data = data + '&_instanceNumber=' + instNum;
		this._executeEvent('beforeAjaxCallback',{ajaxEvent: 'cascadingDropdown'})
		
		this.ajaxCallback('G',1,'system:cascadingDropdown','',data);
		return false;
	
	},
	
	_getControlInfo: function(colName){
		var tColName = '';
		if(colName.search(':') != -1 ) 	tColName = colName.split(':');
		else tColName = colName.split('_A5INSTANCE');
		
		var tObj = {name: tColName[0], controlName: tColName[0], controlId: tColName[0], fullName: tColName[0], calculateSummary: false, instNum: -1};
		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.instNum = 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;
			if(this.columnInfo[tObj.name].type) tObj.type = this.columnInfo[tObj.name].type;
		}
		return tObj;
	},
	
	_summarize: function(name,rowNum){
		var flagVarChanged = typeof arguments[2] != 'undefined' ? arguments[2] : true;
		name = name.toUpperCase();
		var cntrlInfoObj = this._getControlInfo(name);
		name = cntrlInfoObj.name;
		var sectionName = this.columnInfo[name].repeatingSection;
		var rs = this.repeatingSections[sectionName];
		if(typeof rs == 'undefined') return false;
		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);
		if(flagVarChanged) this._variablesChanged(['summary.' + name],rowNum);	
	},	
	
	_variablesChanged: function(variables,rowNum) {
		for(var dialogWatch in this.dialogWatches) {	
			if(this.dialogWatches[dialogWatch].variables) {
				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 ops = typeof arguments[0] != 'undefined' ? arguments[0] : {};
		var flag = '';
		flag = this._executeEvent('canRecordNavigate',{isDirty: this._isDirty, isDataDirty:  this._isDataDirty, target: 'newRecord'});
		if (flag == false) {
			this._setSliderPosition(this._currentRecordNumber,false);
			if(typeof this._primaryKeyListNavigator != 'undefined') this._primaryKeyListNavigator.setValue(this._currentRecordNumber -1,false); //don't navigate to target record
			return false;
		}
	
		var data = '_newRecord=yes&_newRecordOptions='  + $u.o.toJSON(ops);
		delete this.stateInfo.keys;
		this.ajaxCallback('G',1,'system:newRecord','',data);
		this._executeEvent('afterRecordNavigate',{target: 'newRecord'});
		
		for(var repeatingSection in this.repeatingSections) {
			this.setRepeatingSectionActiveRow(repeatingSection,1);
		}
	},
	
	saveDataInRepository: function(key) {
		var data = '_repositoryKey=' + key;
		this.ajaxCallback('G',1,'system:saveDataInRepository','',data);
	},
	
	loadDataFromRepository: function(key) {
		var flagDelete = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		var data = '_repositoryKey=' + key + '&_delete=' + flagDelete;
		this.ajaxCallback('G',1,'system:loadDataFromRepository','',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] : '';
		if(rowNum == '') rowNum = 1;
		if(typeof rowNum == 'undefined') rowNum = 1;
		
		//
		//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();
		var browserData = $u.o.toJSON(A5.flags);
		data = data + '&' + A5.ajax.buildURLParam('__a5browserflags',browserData);
		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];
			if(typeof rs == 'undefined') return false;
			data = data + '&' +rsPname + '.activeRow=' + rs.activeRow;
			data = data + '&' + rsPname + '.visibleRows=' + this.getRepeatingSectionVisibleRows(repeatingSection);
			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];
			if(typeof rs == 'undefined') return false;
			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(',');
			data = data + '&' + rsPname + '.visibleRows='+this.getRepeatingSectionVisibleRows(repeatingSection);
		}
		return data;
	},
	
	_getDialogVariables: function(dialog,summary,data) {
		
		
		dialog.orientation = this.getOrientation();
		
		//will need to fill in dialog. state varibles for use in client side calc fields.
		dialog.isDirty = this._isDirty;
		dialog.isDataDirty = this._isDataDirty;
		//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
		
		
		dialog.isNewRecord = true;
		var primaryAlias = this._primaryTableAlias;
		if(primaryAlias != '') {
			if(typeof this.stateInfo.keys != 'undefined') {
				if(typeof this.stateInfo.keys[primaryAlias] != 'undefined') dialog.isNewRecord = false;
			}
		}
		
		dialog.firstRecord = false;
		dialog.lastRecord = false;
		if(typeof pkl != 'undefined') {
			if(typeof this._currentRecordNumber != 'undefined') {
				var pkl = this._primaryKeyList;
				dialog.firstRecord = false;
				dialog.lastRecord = false;
				if(this._currentRecordNumber == 1) {
					dialog.firstRecord = true;
					dialog.lastRecord = false;
				} else if(this._currentRecordNumber == pkl.length) {
					dialog.firstRecord = false;
					dialog.lastRecord = true;
				} 
			}
		}
		
		dialog.activePanelId = this.panelGetActive();
		dialog.activePanelName = '';
		if(dialog.activePanelId != '') dialog.activePanelName =  window[this.dialogId + '_PanelObj']._displayNames[dialog.activePanelId];
		
		$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
			};
		
	},
	
	selectTabPane: function(id,numberOrId) {
		try {
			if(typeof numberOrId == 'string') {
				numberOrId = this._tabPaneNumberFromId(id,numberOrId);
				if(numberOrId == 0) return false;
			}
	  		window[this.dialogId + '.V.R1.' + id + 'Obj'].select('' + numberOrId);
		  }
		catch(err)
		  {
		  }
	},
	
	_tabPaneNumberFromId: function(tabId,paneId) {
		var ele = $(this.dialogId +'.V.R1.'+tabId+'.PANES');
		var paneId2 = '';
		var idx = '';
		var ids = [];
		var paneNumber = 0;
		for(var i = 0; i < ele.childNodes.length; i++) {
		    if(typeof ele.childNodes[i].tagName != 'undefined') {
		        paneId2 = $ga(ele.childNodes[i],'a5paneid');
		        if(paneId2 != '' && paneId2 != null) {
		        	paneNumber++;
		        	if(paneId2 == paneId) return paneNumber;
		        }
		    }
		}
		return paneNumber;
	},
	
	_tabInfo: function(tabId) {
		
		var paneCount = 0;
		var visiblePane = 0;
		var nextPane = 0;
		var prevPane = 0;
		var status = false;
		var interval = 0;
		var tobj = window[this.dialogId + '.V.R1.' + tabId + 'Obj'];
		paneCount = tobj.panes.length;
		visiblePane = tobj._curTabIndx+1;
		if(visiblePane == paneCount) nextPane = 1;
		else nextPane = visiblePane+1;
		
		prevPane = visiblePane -1;
		if(prevPane == 0) prevPane = paneCount;
		
		
		var tobj = this._tabTimers;
		if(typeof tobj != 'undefined') {
			var tobjx = tobj[tabId];
			if(typeof tobjx != 'undefined') {
				interval = tobjx.interval;
				status = tobjx.status;
			}		
		}
		
		
		return { 'paneCount' : paneCount, 'currentPane' : visiblePane, 'nextPane' : nextPane, 'previousPane' : prevPane, 'status' : status, 'interval' : interval};
	
	},
	
	
	tabTimerGoto: function(tabId,target) {
		target = target.toLowerCase();
		target = target[0];
		var t2 = '';
		var tInfo = this._tabInfo(tabId);
		t2 = target;
		if(target == 'f') t2 = 1;
		if(target == 'l') t2 = tInfo.paneCount;
		if(target == 'n') t2 = tInfo.nextPane;
		if(target == 'p') t2 = tInfo.previousPane;
		this.selectTabPane(tabId,t2);
		
		var tobj = this._tabTimers;
		if(typeof tobj == 'undefined') return false;
		var tobjx = tobj[tabId];
		if(typeof tobjx == 'undefined') return false;
		if(tobjx.status == 'on') {
			this.tabTimerStop(tabId);
			this.tabTimerStart(tabId);
		}
		
	},

	
	_tabTimerStartStop: function(tabId,mode) {
		var tobj = this._tabTimers;
		if(typeof tobj == 'undefined') return false;
		var tobjx = tobj[tabId];
		if(typeof tobjx == 'undefined') return false;
		var interval = tobjx.interval;
		var tabInfo = this._tabInfo(tabId);
		if(mode == 'start') {
			tobjx.status = 'on';
			tobjx._i = setInterval(Function(this.dialogId + '_DlgObj.tabTimerGoto(\''+tabId+'\',\'n\');'),interval*1000);
		} else if (mode == 'stop') {
			tobjx.status = 'off';
			clearInterval(tobjx._i);
		}		
	},

	
	tabTimerStop: function(tabId) {
		this._tabTimerStartStop(tabId,'stop');
	},
	
	tabTimerStart: function(tabId) {
		this._tabTimerStartStop(tabId,'start');
	},
		
	
	_tabPaneChange: function(id) {
		var dialog = {};
		this._getTabObjectInfo(dialog,id);
		this._variablesChanged(['dialog.tabObject.' + id ],1);
		if(typeof dialog.tabObject == 'undefined') return false;
		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;
			
		}
	
		
	},

	duplicateRepeatingSectionRow: function(id) {
		var activeRow = this.repeatingSections[id].activeRow;
		var rows = this.repeatingSections[id].rows;
		//find a row that is empty
		var targetRow = -1;
		var flagDeleted = '';
		var flagEmpty = '';
		for(var i = 1; i <= rows; i++) {
			flagEmpty = this._repeatingSectionRowIsEmpty(id,i);
			if(flagEmpty) {
				flagDeleted = this.repeatingSections[id]._r[0].i[i-1].deleted;
				if(flagDeleted == false) {
					targetRow = i;
					break;
				}
			}
		}
		if(targetRow == -1) {
			this.addRepeatingSectionRow(id);
			targetRow = this.repeatingSections[id].activeRow;
		}
		this._copyRepeatingSectionRowLow(id,activeRow,targetRow);
	},
	
	
	copyRepeatingSectionRow: function(id,sourceRow,targetRow) {
		var promptIfDirty = typeof arguments[3] != 'undefined' ? arguments[3] : true;
		if(targetRow == -1) targetRow = this.repeatingSections[id].activeRow;
		
		if(targetRow == sourceRow) return false;
		
		if(promptIfDirty) {
			var flagTargetIsDirty = this._repeatingSectionRowIsDirty(id,targetRow);
			var msg = 'Overwrite existing data in row?';
			if(typeof this._rsOverwriteRowMsg != 'undefined') msg = this._rsOverwriteRowMsg;
			if(flagTargetIsDirty) {
				var flagConfirm = confirm(msg);
				if(flagConfirm == false) return false;
			}
		}		
		this._copyRepeatingSectionRowLow(id,sourceRow,targetRow);
	},
	
	_showHideFrame: function(id,action) {
		if(typeof this.framesInfo == 'undefined') return false;
		var frameInfo = this.framesInfo[id];
		if(typeof frameInfo == 'undefined') return false;
		var rs = frameInfo.repeatingSections;
		var onOpen = frameInfo.onOpen;
		var onClose = frameInfo.onClose;
		
		//alert(frameInfo.repeatingSections + ' -- ' + onOpen + ' - ' + onClose);
		//onOpen, onClose
		if(action=='show') {
			for(var i = 1; i <= rs.length; i++) {
				this._prepareRepeatingSection(rs[i-1],1);
			}
			if(onOpen != '') {
				if(typeof window[onOpen] != 'undefined') window[onOpen]();
			}
		} else {
			if(onClose != '') {
				if(typeof window[onClose] != 'undefined') window[onClose]();
			}
		
		
		}
	},
	
	_copyRepeatingSectionRowLow: function(id,sourceRow,targetRow) {
		if(targetRow == -1) targetRow = this.repeatingSections[id].activeRow;
		if(sourceRow == targetRow) return false;
		var rsInfo = this.repeatingSectionInfo[id].controls;
		var sourceVal = '';
		for(var i = 0; i < rsInfo.length; i++) {
			sourceVal = this.getValue(rsInfo[i] + ':' + sourceRow);
			this.setValue(rsInfo[i] + ':' + targetRow,sourceVal);
		}
	},
	
	moveUpRepeatingSectionRow: function(id) {
		var row1 = this.repeatingSections[id].activeRow;
		if(row1 == 1) return false;
		
		var row2 = row1;
		var flagLoop = true;
		while (flagLoop)
		  {
		 	row2 = row2 - 1;
		 	if(this._repeatingSectionRowIsDeleted(id,row2) == false) {
		 		flagLoop = false;
		 		break;
		 	}
		 	if(row2 <= 1) {
		 		flagLoop = false;
		 		break;
		 	}
		  }
		  
		if(row2 == row1 || row2 < 1 || this._repeatingSectionRowIsDeleted(id,row2 )  ) return false;
		
		this.swapRepeatingSectionRows(id,row1,row2);
		this.setRepeatingSectionActiveRow(id,row2);
		
	},
	
	moveDownRepeatingSectionRow: function(id) {
		var row1 = this.repeatingSections[id].activeRow;
		var rows = this.repeatingSections[id].rows;
		if(row1 == rows) return false;
		var row2 = row1;
		var flagLoop = true;
		while (flagLoop)
		  {
		 	row2 = row2 + 1;
		 	if(this._repeatingSectionRowIsDeleted(id,row2) == false) {
		 		flagLoop = false;
		 		break;
		 	}
		 	if(row2 <= 1) {
		 		flagLoop = false;
		 		break;
		 	}
		  }
		  
		if(row2 == row1 || row2 < 1 || this._repeatingSectionRowIsDeleted(id,row2 )  ) return false;
		this.swapRepeatingSectionRows(id,row1,row2);
		this.setRepeatingSectionActiveRow(id,row2);
	},
		
	_harvestRepeatingSection: function(id) {
		id = id.toUpperCase();
		var rows = this.repeatingSections[id].rows;
		var _a = [];
		var rsInfo = this.repeatingSectionInfo[id].controls;
		if(typeof rsInfo == 'undefined') return false;
		for(var r = 1; r <= rows; r++) {
			var o = {};
			for(var i = 0; i < rsInfo.length; i++) {
				o[rsInfo[i]] = this.getValue(rsInfo[i] + ':' + r);
			}
			o.__deleted = this._repeatingSectionRowIsDeleted(id,r);
			o.__rowNumber = r;
			_a.push(o);
		}
		
		//alert($u.o.toJSON(_a));
		return _a;
	},
	
	sortRepeatingSection: function(id,colName,direction) {
		
		id = id.toUpperCase();
		colName = colName.toUpperCase();
		direction = direction.toLowerCase();
		direction = direction[0];
		var arr = this._harvestRepeatingSection(id);
		if(arr == false) return false;
		var colType = this.columnInfo[colName].dataType;
	    arr.sort( function(a,b) {
	        var result = 0;
	        var val1 = a[colName];
	        var val2 = b[colName];
	        if(colType == 'N') {
	        	val1 = $u.s.toNum(val1);
	        	val2 = $u.s.toNum(val2);
	        }
	        
	        if(colType == 'L') {
	        	val1 = $u.s.toBool(val1);
	        	val2 = $u.s.toBool(val2);
	        }
	        
	        if(colType == 'D' || colType == 'T'  ) {
	        	val1 = Date.parse(val1);
	        	val2 = Date.parse(val2);
	        }
	        
	        if(typeof val1 == 'string') {
	            if(val1.toLowerCase() > val2.toLowerCase()) result =  1;
	            else if(val1.toLowerCase() < val2.toLowerCase()) result =  -1;
	        }  else {
	            result = val1 - val2;           
	        }
	        if(val1 > val2) result =  1;
	        else if(val1 < val2) result =  -1;
	        if(direction == 'd') result = result * -1;
	        return result;
	        }
	     )

	    var rows = this.repeatingSections[id].rows;
	    var rowNum = 1;
	    var rs = this.repeatingSections[id];
	    if(typeof rs == 'undefined') return false;
	    for(var i = 1; i <= rows; i++) {
	    	this.undeleteRepeatingSectionRow(id,i);
			this._setRepeatingRowValuesToNull(id,i);
		} 
	    
	    var _d = {};
	    var arrI = '';
	    var _pk = [];
	   
	   	var arrTemp = [];
	   	
	   
	   var aliases = this.repeatingSectionInfo[id].boundAliases;
	   
	    for(var i = 0; i < arr.length; i++) {
	    	arrI = arr[i];
	    	for(var key in arrI) {
	    		_d[key + ':' + (i+1)] = arr[i][key];
	    	}
	    	if(arrI['__deleted']) {
	    		this._deleteRepeatingSectionRowLow(id,i+1);
	    	}
	    	var pko = {};
	    	pko.newRow = i+1;
	    	pko.oldRow = arrI['__rowNumber'];
	    	arrTemp.push('New: '+ pko.newRow + ' Old: ' + pko.oldRow);
	    	_pk.push(pko);
	    }
   
	    this.populate(_d);
	    //after sorting rows, need to adjust the keys
		var tempkey = '';
	    for(r = 0; r < _pk.length; r++) {
	    	_pk[r].key = {};
	    	for(var a = 0; a <  aliases.length; a++) {
	    		tempkey = this.getKey(aliases[a],(r+1));
	    		_pk[r].key[aliases[a]] = tempkey;
	    	}
		}
		var keyval = '';
		
		
		for(r = 0; r < _pk.length; r++) {
			for(var a = 0; a < aliases.length;a++) {
				keyval = _pk[_pk[r].oldRow-1].key[aliases[a]];
				if(keyval == false) keyval = '__undefinedkey__';
				this.setKey(aliases[a],keyval,(r+1));
			}
		}
	},
	
	getKey: function(aliasName) {
		var row = typeof arguments[1] != 'undefined' ? arguments[1] : -1;
		var keyObj = typeof arguments[2] != 'undefined' ? arguments[2] : this.stateInfo.keys;
		if(typeof keyObj == 'undefined') return false;
		if(row > 0 ) {
			var k = aliasName.toUpperCase() + '_row' + row;
		} else {
			var k = aliasName.toUpperCase();
		}
		if(typeof keyObj[k] != 'undefined') return keyObj[k]._key;
		else return false;
	},
	
	setKey: function(aliasName,value) {
		var row = typeof arguments[2] != 'undefined' ? arguments[2] : -1;
		if(row > 0) {
			var k = aliasName.toUpperCase() + '_row' + row;
		} else {
			var k = aliasName.toUpperCase();
		}
		if(typeof this.stateInfo.keys == 'undefined') this.stateInfo.keys = {};
		if(typeof this.stateInfo.keys[k] == 'undefined') this.stateInfo.keys[k] = {};
		if(value == '__undefinedkey__') delete this.stateInfo.keys[k];
		else this.stateInfo.keys[k]._key = value;
	
	},
	

	
	
	
	_swapKeys: function(aliasName,row1,row2) {
		
		if(typeof this.stateInfo == 'undefined') return false;
		if(typeof this.stateInfo.keys == 'undefined') return false;
		var k1 = aliasName.toUpperCase() + '_row' + row1;
		var k2 = aliasName.toUpperCase() + '_row' + row2;
		var key1 = '__undefinedkey__';
		var key2 = '__undefinedkey__';
		
		if(typeof this.stateInfo.keys[k1] != 'undefined') key1 = this.stateInfo.keys[k1]._key;
		if(typeof this.stateInfo.keys[k2] != 'undefined') key2 = this.stateInfo.keys[k2]._key;;
		if(key2 == '__undefinedkey__') {
			delete this.stateInfo.keys[k1];
		} else {
			if(typeof this.stateInfo.keys[k1] == 'undefined') this.stateInfo.keys[k1] = {};
			this.stateInfo.keys[k1]._key = key2;	
		}
		if(key1 == '__undefinedkey__') {
			delete this.stateInfo.keys[k2];
		} else {
			if(typeof this.stateInfo.keys[k2] == 'undefined') this.stateInfo.keys[k2] = {};
			this.stateInfo.keys[k2]._key = key1;	
		}
	},
	
	_swapKeysRS: function(id,row1,row2) {
		var aliases = this.repeatingSectionInfo[id].boundAliases;
		for(var a in aliases) {
			this._swapKeys(aliases[a],row1,row2)
		}
	},
	
	swapRepeatingSectionRows: function(id,row1,row2) {
		var rsInfo = this.repeatingSectionInfo[id].controls;
		if(typeof rsInfo == 'undefined') return false;
		var v1 = '';
		var v2 = '';
		var _d = {};
		//alert(row1 + '\n' + row2);
		for(var i = 0; i < rsInfo.length; i++) {
			v1 = this.getValue(rsInfo[i] + ':' + row1);
			v2 = this.getValue(rsInfo[i] + ':' + row2);
			
			_d[rsInfo[i] +':' + row1] = v2;
			_d[rsInfo[i] +':' + row2] = v1;
			
			//alert(v1 + '\n' + v2);
			/*
			var flagFireChange = true;  //if you don't fire the change then moving a row up 2 times failes.
			this.setValue(rsInfo[i] + ':' + row1,v2,flagFireChange);
			this.setValue(rsInfo[i] + ':' + row2,v1,flagFireChange);
			*/
			
			
		}
		//1 row number, false - don't set controls clean, true - don't fire change event
		this.populate(_d,1,false,true);
		//alert($u.o.toJSON(_d));
			
		//this._prepareRepeatingSection(id,1);
		//this.prepare();
		this._swapKeysRS(id,row1,row2);
		
	},
	
	_sortPrimaryKeyList: function() {
	
		var r = this._primaryKeyListNavigator.selection[0];
		var k = this._primaryKeyList[r].k;
		var obj = this._primaryKeyList;
		if(typeof obj[0].d1 != 'undefined') {
			obj.sort(function(a,b) {
				if (a.d1 < b.d1) return -1;
				if (a.d1 > b.d1) return 1;
				return 0;
				}
			);
		} else {
			obj.sort(function(a,b) {
				if (a.k < b.k) return -1;
				if (a.k > b.k) return 1;
				return 0;
				}
			);
		}
		
		this._primaryKeyListNavigator.populate(this._primaryKeyList);
		var r2 = -1;
		for(var i = 0; i < this._primaryKeyList.length; i++) {
			if(this._primaryKeyList[i].k == k) {
				r2 = i;
				break;
		    }
		}
		if(r2 > -1) this._primaryKeyListNavigator.setValue(r2,false);
	},
	
	_primaryKeyListSetKey: function(key) {
		var arr = this._primaryKeyListNavigator._data;
		var idx = -1;
		for(var i = 1; i <= arr.length; i++) {
		    if(''+arr[i-1].k == '' + key) {
		        idx = i;
		        break;
	    	}
		}
		if(idx != -1) {
			this._primaryKeyListNavigator.setValue(idx-1);
		}
	},

	_updatePrimaryKeyList: function(obj,mode) {
		
		
		if(mode == 'update') {
			if(typeof this._primaryKeyListNavigator != 'undefined') {
				var r = this._primaryKeyListNavigator.selection[0];
				this._primaryKeyList[r] = obj;
				this._primaryKeyListNavigator.updateRow(r,obj);
			} else if (typeof this.__navigationSliderObject != 'undefined') {
				var r = this.__navigationSliderObject.value -1;
				this._primaryKeyList[r] = obj;
			}
		} else if(mode == 'enter') {
			if(typeof this._primaryKeyList != 'undefined') {
				var r = this._primaryKeyList.length;
				this._primaryKeyList[r] = obj;
				if(typeof this._primaryKeyListNavigator != 'undefined') {
					this._primaryKeyListNavigator.appendRows([obj]);
					this._primaryKeyListNavigator.setValue(r,false);
				}
			}
			this._currentRecordNumber = this._currentRecordNumber + 1;
		} else if(mode == 'delete') {
			var r = obj.recordNumber;
			this._primaryKeyList.splice(obj.recordNumber-1,1);
			r = r -1; 
			
			if(typeof this._primaryKeyListNavigator != 'undefined') {
				this._primaryKeyListNavigator.populate(this._primaryKeyList);
				var r2 = r;
				if(r == this._primaryKeyList.length) {
					r2 = r2 -1;
				}
				this._primaryKeyListNavigator.setValue(r2,false);
				r = r2;
				//don't do this here. the ajax response has already done it.
				//this._currentRecordNumber = this._currentRecordNumber -1;
			}
			
			
			
		}
		
		if(this.__navigationSliderObject) {
			if(typeof this._primaryKeyList != 'undefined') {
				var count = this._primaryKeyList.length;
				if($(this.__sliderDynMsgId)) {
					if(typeof r != 'undefined') {
						var data = {value: r+1};
						$(this.__sliderDynMsgId).innerHTML = eval(this.__sliderMessageTemplate);
					}
				}
				if(mode == 'enter') {
					this.__navigationSliderObject.setValue(count-1);
					this.__navigationSliderObject.max = count;
				}
			}
		}
		
	
	},
	
	_navigationListViewInit: function(id,obj,ops) {
		id = id.toUpperCase();
		var html = ops.htmlTemplate;
		var listViewObjId = ops.listViewObjectId;
		$(id).innerHTML = html;
		var initData = ops.initialData;
		this._primaryKeyListNavigator = new A5.ListBox(listViewObjId,initData,obj);
	},
	

	_navigationSliderInit: function(id,obj,ops) {
		
		var d = {};
		d.range = false;
		d.min = 1;
		d.max = 5;
		d.step = 1;
		d.value = 1;
		d.change = '';
		d.slide = '';
		$u.o.assign(d,obj);
		id = id.toUpperCase();
		if(!$(id)) return false;
		var idS = id + '_SLIDERCONTROL';
		var html = ops.sliderTemplate;
		$(id).innerHTML = html;
		//var idSjq = $u.s.tran(idS,'.','\\.');
		//jQuery('#' + idSjq).slider(d);
		
		d.onChange = d.change;
		d.onSlide = d.slide;
		d.theme = this.styleName;
		d.range = {show: true};
		this.__navigationSliderObject = new A5.Slider(idS,d);
		
		
		this.__sliderId = idS;
		//this.__sliderIdJS = idSjq;
		this.__sliderKeyColumnName = ops.keyColumnName;
		this.__sliderOnChange = ops.sliderOnChangeFunction;
		this.__sliderOnSlide = ops.sliderOnSlideFunction;
		this.__sliderMessageTemplate = ops.sliderMessage;
		this.__sliderDynMsgId = ops.sliderDynamicMsgId;
		
	},
	
	_hideSliderMsg2: function(e,id) {
		var ele = $(id + '.SLIDERMESSAGECONTAINER');
		var ele2 = $(id + '.CONTROL');
		var relEle = (e.relatedTarget) ? e.relatedTarget : e.toElement;
		if(relEle){
			while(relEle != ele2 && relEle.tagName.toLowerCase() != 'body' && relEle.tagName.toLowerCase() != 'html' ) relEle = relEle.parentNode
			if(relEle == ele2) return;
		}
		A5.u.element.hide(ele,{ type: 'fade'});
	},
	
	_paintSliderMessage: function(e,id,msg) {
		id = id.toUpperCase();
		var ctrl = this.getControl(id);
		var e2 = '';
		if(typeof e == 'object')  e2 = e;
		else e2 = ctrl;
		//if e was not passed in as an object then read value from the control itself
		if(typeof e2.value[0] != 'undefined') {
			var value = e2.value[0];
			var value1 = e2.value[0];
			var value2 = e2.value[1];
		} else {
			var value = e2.value;
			var value1 = value;
			var value2 = value;
		}
		
		
		var max = ctrl.max
		var min = ctrl.min
		var ele = $(this.dialogId + '.V.R1.' + id + '.SLIDERMESSAGECONTAINER');
		
		var msgTxt = '';
		if(msg.split(':')[0].toLowerCase() == '\'js') { 
			var fnName = msg.split(':')[1];
			fnName = fnName.split('\'')[0];
			if(typeof window[fnName] != 'undefined') {
				var e = {value: value, value1: value1, value2: value2, min: min, max: max};
				msgTxt = window[fnName].call(this,e);
			} else {
				msgTxt = 'Function not found: ' + fnName;
			}
		} else {
			msgTxt = eval(msg);
		}
		ele.innerHTML = msgTxt;
	},
	
	_hideSliderMsg: function(e) {
		var flagHideSlider = this.__hideSlider;
		if(flagHideSlider == false) return false;
		var sliderContainer = this.__idSliderMessageOuterContainer;
		var sliderMessage  = this.__idSliderMessageContainer;
		var ele = $(sliderContainer);
		if(!ele) return false;
		var relEle = (e.relatedTarget) ? e.relatedTarget : e.toElement;
		if(relEle){
			while(relEle != ele && relEle.tagName.toLowerCase() != 'body' && relEle.tagName.toLowerCase() != 'html' ) relEle = relEle.parentNode
			if(relEle == ele) return;
		}
		
		A5.u.element.hide($(sliderMessage),{ type: 'fade'});
	
	},

	_navigationSliderSetMax: function(id,max) {
		id = id.toUpperCase();
		var idS = id + '_SLIDERCONTROL';
		if(!$(idS)) return false;
		if(max == 0) $(this.__sliderId).style.visibility = 'hidden';
		else $(this.__sliderId).style.visibility = '';
		//var idSjq = $u.s.tran(idS,'.','\\.');
		//jQuery('#' + idSjq).slider('option','max',max);
		this.__navigationSliderObject.max = max;
		this.__navigationSliderObject.refresh();
	
	},
	
	_setSliderPosition: function(recno) {
		var flagNavigateToRecord = typeof arguments[1] != 'undefined' ? arguments[1] : true;
		if(typeof this.__sliderId == 'undefined') return false;
		this.__sliderNavigateToRecord = flagNavigateToRecord;
		//jQuery('#' + this.__sliderIdJS).slider('option','value',recno);
		this.__navigationSliderObject.setValue(recno);
		this.__sliderNavigateToRecord = true;
		var count = this._primaryKeyList.length;
		var kc = this.__sliderKeyColumnName;
		var data = {};
		data.value = recno;
		if($(this.__sliderDynMsgId)) $(this.__sliderDynMsgId).innerHTML = eval(this.__sliderMessageTemplate);

	},
	
	
	_sliderOnChange: function (data) {
		//e,data
		//alert('_sliderOnChange');
		var kc = this.__sliderKeyColumnName;
		var count = this._primaryKeyList.length;
		$(this.__sliderDynMsgId).innerHTML = eval(this.__sliderMessageTemplate);
		var currentKey = this._primaryKeyList[data.value-1][kc];
		if(typeof window[this.__sliderOnChange] != 'undefined') window[this.__sliderOnChange](currentKey,data.value,count);
		var flagNavigate = true;
		if(typeof this.__sliderNavigateToRecord != 'undefined') flagNavigate = this.__sliderNavigateToRecord;
		if(flagNavigate) this.navigateRecord(data.value,false); //do not call _setSliderPosition()
		if(typeof this._listNavigator != 'undefined') {
			this._listNavigator.setValue(data.value-1, false); //do not fire onSelect
		}
	},
	
	
	_sliderOnSlide: function (data) {
		//e,data
		var count = this._primaryKeyList.length;
		var kc = this.__sliderKeyColumnName;
		$(this.__sliderDynMsgId).innerHTML = eval(this.__sliderMessageTemplate);
		var currentKey = this._primaryKeyList[data.value-1][kc];
		if(typeof window[this.__sliderOnSlide] != 'undefined') window[this.__sliderOnSlide](currentKey,data.value,count);

	
	},
	
	_runEmbeddedReport: function(data) {
		this.ajaxCallback('G',1,'system:ComputeFilterThenRunReport','',data);
	},
	

	
	refreshDataSeries: function(seriesArray) {
		if(seriesArray.constructor != Array) var seriesArray = [seriesArray];
		var jsFunctionResult = this._executeJavascriptForDataSeries(seriesArray);
		var callbackData = '';
		var arr = [];
		arr.push(A5.ajax.buildURLParam('__seriesNames',seriesArray.join(',')));
		arr.push(A5.ajax.buildURLParam('__javascriptFunctionResults',jsFunctionResult));
		callbackData = arr.join('&');
		this.ajaxCallback('G',1,'system:RefreshDataSeries','',callbackData);
	},
	
	exportChart: function(obj) {
		if(typeof this._chartControlsInfo == 'undefined') return false;
		obj._chartControlsInfo = this._chartControlsInfo;
		var data = $u.o.toJSON(obj);
		var arr = [];
		arr.push(A5.ajax.buildURLParam('_exportChartInfo',data));
		var callbackData = arr.join('&');
		this.ajaxCallback('G',1,'system:exportChart','',callbackData);
	},
	
	_harvestLists: function() {
			var c = this._controlInst;
			var cInfo = this._controls;
			var id = '';
			var name = ''
			var ci = '';
			var datai = '';
			var obj = '';
			var instNum = '';
			for(var l in c){
				id = l.split('.')[1];
				name = l.split('.')[1].split('_A5INSTANCE')[0];
				instNum = l.split('.')[1].split('_A5INSTANCE')[1];
				ci = cInfo[name];
				
				if(ci.type == 'list') {
					obj = this.getControl(id);
					datai = obj._data[obj._dataMap[obj.selection[0]]];
					alert('full name:' + l + '\n - id: ' + id +  '\n - name:  ' + name + '\n - type : ' + ci.type + '\n -instnum: ' + instNum + '\n\n - data_i: ' + $u.o.toJSON(datai));
				}
			}
	//currentRow = listObj._dataMap[currentRow]; //translates logical to physical row
	//			if(typeof currentRow == 'undefined') return false;
				
	//			var currentRowData = listObj._data[currentRow];
	//	DLG1_DlgObj._controls['L2'] =  { type: 'list',  data: DLG1_DlgObj._listViewData['L2'], settings: DLG1_DlgObj._listViewSettings['L2'] }
		
		},
		
	_listGetValue: function(listId,field) {
		//listId can be LIST1:3 or LIST1_A5INSTANCE3
		
		var obj = this.getControl(listId);
		if(obj == false) {
			alert('List not found: ' + listId); return '';
		}
		//do not convert field to uppercase or you will break it
		if(field == '__PRIMARYKEY') field = '__primaryKey';
		if(field == 'KEY_TABLE_1') field = 'key_table_1';
		//var val = obj._rData[obj._dataMap[obj.selection[0]]][field];
		if(field.toUpperCase() == '<ROWNUMBER>') {
			return obj.selection[0] + 1;
		}

		//make lookup case insensitive by makeing a new json object with upper case keys		
		var arr = obj._rData[obj.selection[0]];
		
		var d2 = {};
		var key2 = '';
		for(var n in arr) {
			key2 = n.toUpperCase();
			d2[key2] = arr[n];
		}
		var val = d2[field.toUpperCase()];		
		return val;
	},
	
	computeSearchFromMetaDataAndFilterList: function(listId,syntax,data,jsonOptions) {
	
		var arr = [];
		arr.push(A5.ajax.buildURLParam('__listId',listId));
		arr.push(A5.ajax.buildURLParam('__options',syntax));
		arr.push(A5.ajax.buildURLParam('__searchData',data));
		var listState = this.getControl(listId)._state;
		arr.push(A5.ajax.buildURLParam('__listState',$u.o.toJSON(listState)));
		callbackData = arr.join('&');
		this.ajaxCallback('G',1,'system:ComputeSearchAndFilterList','',callbackData);
	},
	
	_filterList: function(listId,filterExpn,orderExpn,filterParameters) {
	
		filterExpn = $if(filterExpn==undefined,'Null',filterExpn);
		orderExpn = $if(orderExpn==undefined,'Null',orderExpn);
		filterParameters = $if(filterParameters==undefined,'Null',filterParameters);
	
		var callbackData = '';
		var arr = [];
		arr.push(A5.ajax.buildURLParam('__listId',listId));
		arr.push(A5.ajax.buildURLParam('__filter',filterExpn));
		arr.push(A5.ajax.buildURLParam('__order',orderExpn));
		arr.push(A5.ajax.buildURLParam('__filterParameters',filterParameters));
		callbackData = arr.join('&');
		this.ajaxCallback('G',1,'system:FilterList','',callbackData);
	
	},
	
	
	_initialListRender: function(listId) {
	
		var obj = this.getControl(listId.toUpperCase());
		if(typeof obj._hasBeenRendered == 'undefined') {
			obj._hasBeenRendered = true;
		}
		
		if(typeof obj._hasBeenRendered == 'undefined') {
			obj._hasBeenRendered = true;
			this._refreshListData(listId);
		} else {
			if(obj._hasBeenRendered == false) {
				obj._hasBeenRendered = true;
				this._refreshListData(listId);
			}
		}
	},
	
	_refreshListData:  function(listId) {
	
		var obj = typeof arguments[1] != 'undefined' ? arguments[1] : {};
		listId = listId.toUpperCase();
		var listInfo = this._listControlsInfo[listId];
		var jsFuncName = '';
		var dataSeries = ''
		if(typeof listInfo != 'undefined') {
			if(typeof listInfo.javascriptFunction != 'undefined') jsFuncName = listInfo.javascriptFunction;
			if(typeof listInfo.seriesName != 'undefined') dataSeries = listInfo.seriesName;
			if(dataSeries != '') {
				var seriesInfo = this._dataSeries;
				if(typeof seriesInfo) seriesInfo = seriesInfo[dataSeries];
				jsFuncName = seriesInfo['javascriptFunction'];
			}
		}
		var jsFunctionResult = '';
		if(jsFuncName != '') {
			var seriesArray = [];
			seriesArray.push(dataSeries)
			jsFunctionResult = this._executeJavascriptForDataSeries(seriesArray);
		}
		var callbackData = '';
		var arr = [];
		arr.push(A5.ajax.buildURLParam('__listId',listId));
		//use singular for var name
		arr.push(A5.ajax.buildURLParam('__javascriptFunctionResults',jsFunctionResult));
		arr.push(A5.ajax.buildURLParam('__options',$u.o.toJSON(obj)));
		callbackData = arr.join('&');
		this.ajaxCallback('G',1,'system:RefreshList','',callbackData);
		
		},
	
	
	_listRefreshCascadingLists: function(listId) {
		var obj = {};
		obj.keepFocusOnCurrentSelection = true;
		obj.setFocusToValue = '';
		obj.refreshDependentLists = true;
		obj.onlyRefreshDependentLists = true;
		this._refreshListData(listId,obj);
		},
	
	
	
	_listRemoveSelectedRows: function(listId) {
		var lObj = this.getControl(listId);
		var row = lObj.selection;
		if(typeof row == 'undefined') return false;
		row.sort();
		//lObj.removeRows(row);
		lObj.removeRows(lObj.value);
		//get last value in array
		row = row.pop();
		if((row+1) > lObj._rData.length) row --;
		lObj.setValue(row);
	},
		
	
	_listRemoveAllRows: function(listId) {
		var lObj = this.getControl(listId);
		lObj.populate([]);
	},
	
	
	
	
	_listShiftPositionSelectedRows: function(listId,target) {
		var lObj = this .getControl(listId);
		var a = lObj._rData;
		var lo = a.length;
		var rows =  [].concat(lObj.selection);
		rows.sort();
		
		var lastRow = rows[rows.length -1];
		var firstRow = rows[0];
		var nextRow = parseInt(lastRow) + 1;
		var prevRow = parseInt(firstRow) - 1;
		
		target = target.toLowerCase()[0];
		var old_index = -1;
		var new_index = -1;
		var newRows = rows;
		if(target == 'd') {
			old_index = nextRow;
			if(nextRow > a.length -1) return false;
			new_index = firstRow;
			for(i in newRows) { 
				newRows[i] = parseInt(newRows[i]) + 1
			}
		}
		if(target == 'u') {
			old_index = parseInt(firstRow) -1;
			if(old_index < 0) return false;
			new_index = parseInt(lastRow);
			for(i in newRows) { 
				newRows[i] = parseInt(newRows[i]) - 1
			}
		}
		if(target == 't') {
			for(var i = 1; i <= firstRow ; i++) {
				this._listShiftPositionSelectedRows(listId,'up');
			}
			return true;
		}
		if(target == 'b') { 
			var count = (a.length -1) - parseInt(lastRow);
			for(var i = 0; i < count; i++) {
				this._listShiftPositionSelectedRows(listId,'down');
			}
			return true;
		}
		A5ArrayMove(a,old_index,new_index);
		//a.move(old_index,new_index);
		lObj.populate(a);
		lObj.setValue(newRows);
	},
	
	

	_listMoveAllRows: function(listSource,listTarget) {
		var lSrc = this.getControl(listSource);
		var lTar = this.getControl(listTarget);
		//get array of data to move
		var rows = [];
		for(var i = 0; i < lSrc._rData.length; i++) { 
			rows.push(lSrc._rData[i]);
		}
		
		
		
		var flagAppend = false; 
		var row = 0;
		//if there is no data in the list, or the last record is selected, do an append
		if(lTar._rData.length == 0) { 
			flagAppend = true;
		} else {
			var row = [].concat(lTar.selection);
			row.sort();
			//get last value in array
			row = row.pop();
			row++;
			if(row >= lTar._rData.length) flagAppend = true; 
		}
			
		if(flagAppend) {
			lTar.appendRows(rows);
		} else { 
			lTar.insertRows(row,rows);		
		}
		lTar.setValue(row + (rows.length -1));
		
		//lTar.insertRows(0,rows);
		this._listRemoveAllRows(listSource);
		//lTar.setValue(0);
	},
	
	_listMoveCurrentSelection: function(listSource,listTarget) {
		var lSrc = this.getControl(listSource);
		var lTar = this.getControl(listTarget);
		if(lSrc._rData.length == 0) { 
			return false; 
		}
		var rowTar = '';
		if(lTar._rData.length == 0) { 
			rowTar = 0;
		} else {
			rowTar = [].concat(lTar.selection);
			rowTar.sort();
			rowTar = rowTar.pop();
			rowTar = rowTar + 1;
		}
		//get array of data to move
		var rows = [];
		for(var i = 0; i < lSrc.selection.length; i++) { 
			rows.push(lSrc._rData[lSrc.selection[i]]);
		}
		if(rowTar >= lTar._rData.length) {
			lTar.appendRows(rows);
			var newTarget = lTar._rData.length -1;
			lTar.setValue(newTarget);
		} else {
			lTar.insertRows(rowTar,rows);
			lTar.setValue(rowTar);
		}
		this._listRemoveSelectedRows(listSource);
	},
	
	
	
	_listNavigateRecord: function(listId,direction) {
		
		var listObj = this.getControl(listId);
		if(typeof listObj == 'undefined') return false;
		var pageSize = listObj._state.pageSize;
		var currRow = listObj.selection[0];
		if(typeof currRow == 'undefined') currRow = 0;
		var targetRow = -1;
		var d = direction[0].toLowerCase();
		if(d == 'n') {
			targetRow = (currRow+1) + 1;
			if(targetRow > pageSize) this._listNavigate(listId,'next-byrecord');
			listObj.setValue(targetRow -1);
		}
	
		if(d == 'p') {
			targetRow = (currRow+1) -1;
			if(targetRow < 1) this._listNavigate(listId,'previous-byrecord');
			listObj.setValue(targetRow -1);
		}
	
		if(d == 'f') {
			this._listNavigate(listId,'first-byrecord');
		}


		if(d == 'l') {
			this._listNavigate(listId,'last-byrecord');
		}
		
	
	},
	
	_listNavigate: function(listId,direction) {
		var obj = {};
		obj.cmd = 'navigate';
		var result = this._list_executeEvent(listId,'beforePageNavigate',{'direction' : direction[0]});
		if(!result) return false;
		obj.direction = direction;
		this._listMethod(listId,obj);
	},
	
	_listNavigateToPage: function(listId,pageNumber) {
			var obj = {};
			obj.cmd = 'navigate';
			var result = this._list_executeEvent(listId,'beforePageNavigate',{'direction' : 'pageNumber', 'pageNumber': pageNumber});
			if(!result) return false;
			obj.direction = 'pageNumber';
			obj.pageNumber = pageNumber;
			this._listMethod(listId,obj);
	},
	
	_listRefreshRow: function(listId) {
		var obj = {};
		obj.cmd = 'refreshRow';
		var result = this._list_executeEvent(listId,'beforeRefreshRow',{});
		if(!result) return false;
		this._listMethod(listId,obj);
	},
	
	_listRefreshRecordsByKey: function(listId,keys) {
		var options = typeof arguments[2] != 'undefined' ? arguments[2] : {};
		
		if(keys.constructor != Array) keys = [keys];
		var obj = {};
		obj.cmd = 'refreshRowByKey';
		obj.keys = keys;
		obj.additionalOptions = options;
		var result = this._list_executeEvent(listId,'beforeRefreshRow',{keys : keys});
		if(!result) return false;
		this._listMethod(listId,obj);
	},
	
	
	_listFetchMore: function(listId) {
		var obj = {};
		obj.cmd = 'fetchMore';
		this._listMethod(listId,obj);
	},
	
	_listFetchRecordsByKey: function(listId,keys) {
		if(keys.constructor != Array) keys = [keys];
		this._listMethod(listId,{cmd : 'fetchExplicit', keys: keys} );
	},
	
	
	_list_executeEvent: function(listId,eventName) {
		listId = listId.toUpperCase();
		var result = true;
		var s = this._listViewSettings[listId];
		if(typeof s == 'undefined') return result;
		var e = s.systemEvents;
		if(typeof e == 'undefined') return result;
		var obj = this.getControl(listId);
		var targs = new Array();
		for(var i = 2; i < arguments.length; i++) targs.push(arguments[i]);
	
		var tresult = false;
		if(typeof e[eventName] != 'undefined'  ) {
			if(e[eventName].constructor == Function) {
				tresult = e[eventName].apply(obj,targs);
				if(typeof tresult == 'boolean') result = tresult;
			}
		}
		if(typeof e['_' +eventName] != 'undefined' ) {
			if(e['_'+eventName].constructor == Function) {
				tresult = e['_'+eventName].apply(obj,targs);
				if(typeof tresult == 'boolean') result = result && tresult;
			}
		}
			return result;
	},
	
	
	
	_listMethod: function(listId, obj) {
		//('"+ut(variablename)+"',{cmd: 'fetchMore'});"
		//alert(obj.cmd);
	
		listId = listId.toUpperCase();
		var listObj = this.getControl(listId);
		if(typeof listObj == 'undefined') return false;
		var arr = [];
		if(obj.cmd == 'fetchMore') {
			if(typeof listObj._lockedForFetch != 'undefined') {
				if(listObj._lockedForFetch) return false;
			}
			if(typeof listObj._flagAllDataHasBeenFetched != 'undefined') {
				if(listObj._flagAllDataHasBeenFetched) return false;
			}
			var result = this._list_executeEvent(listId,'beforeFetchMore',{});
			if(!result) return false;
			listObj._lockedForFetch = true;
		}
		
		if(obj.cmd == 'refreshRow') {
			var listData = listObj._data;
			if(typeof listData == 'undefined') return false;
			var currentRow = listObj.selection[0];
			obj.currentRowNumber = currentRow;
			currentRow = listObj._dataMap[currentRow]; //translates logical to physical row
			if(typeof currentRow == 'undefined') return false;
			
			var currentRowData = listObj._data[currentRow];
			arr.push(A5.ajax.buildURLParam('_currentRowData',$u.o.toJSON(currentRowData)));
		}
		
		arr.push(A5.ajax.buildURLParam('_listId',listId));
		arr.push(A5.ajax.buildURLParam('_cmdObj',$u.o.toJSON(obj)));
		
		arr.push(A5.ajax.buildURLParam('_listState',$u.o.toJSON(listObj._state)));
		var data = arr.join('&');
		this.ajaxCallback('G',1,'system:listCommand','',data);
	},
	
	_refreshChart: function(chartId) {
		chartId = chartId.toUpperCase();
		var chartInfo = this._chartControlsInfo[chartId];
		if(typeof chartInfo == 'undefined') return false;
		var seriesArray = chartInfo.dataSeries;
		var jsFunctionResult = this._executeJavascriptForDataSeries(seriesArray);
		var callbackData = '';
		var arr = [];
		arr.push(A5.ajax.buildURLParam('__chartId',chartId));
		arr.push(A5.ajax.buildURLParam('__seriesNames',chartInfo.dataSeries.join(',')));
		arr.push(A5.ajax.buildURLParam('__javascriptFunctionResults', jsFunctionResult ));
		callbackData = arr.join('&');
		this.ajaxCallback('G',1,'system:RefreshChart','',callbackData);
	},

	_executeJavascriptForDataSeries: function(seriesArray) {
	//if a custom data series has a javascript function, execute code
		var seriesName = '';
		var fnResult = [];
		var seriesInfo = '';
		var jsFuncName = '';
		for(var sn = 0; sn < seriesArray.length; sn++){
			seriesName = seriesArray[sn].toUpperCase();
			seriesInfo = this._dataSeries[seriesName];
			jsFuncName = '';
			if(typeof seriesInfo != 'undefined') {
				if(typeof seriesInfo.javascriptFunction != 'undefined') {
					jsFuncName = seriesInfo.javascriptFunction;
					if(jsFuncName != '') {
						if(typeof window[jsFuncName] == 'function') {
							var fnResult_i = window[jsFuncName].call(this);
							if(typeof fnResult_i == 'undefined') {alert('Javascript did not return valid series'); return false;}
							if(fnResult_i.constructor == Array ||  fnResult_i.constructor == Object) fnResult_i = $u.o.toJSON(fnResult_i);
							var tempObj = {};
							tempObj.seriesName = seriesName;
							tempObj.javascriptFunctionResult = fnResult_i;
							fnResult.push( $u.o.toJSON(tempObj) );
						}
					}
				}
			}
		}
		return fnResult.join('\n');	
	},
	
	panelGetActive: function() {
		var pObj = window[this.dialogId + '_PanelObj'];
		if(typeof pObj == 'undefined') return '';
		
		if(pObj._panelType == 'panelCard') {
			return '';
		} else {
			var address = [];
			while(pObj._panelType != 'panelCard') {
				address.push(pObj.state.activePanel);
				pObj = pObj.getPanel(address[address.length-1]).src;
			}
			//alert(address);
			return address[address.length -1];
		}
	},
	
	panelGetId: function(panelName,part) {
		part = part.toLowerCase();
		if(part != 'header' && part != 'footer') part = 'body';
		if(panelName == '') return '';
		return this.panelGet(panelName).getPanelId(part);
	},
	
	
	panelGet: function(panelName) {

		//if flagRoot = true, return the root
		var flagRoot = typeof arguments[1] != 'undefined' ? arguments[1] : false;
		var path = this._panelResolvePath(panelName);
		
		//var path =  window[this.dialogId + '_PanelObj']._panelPath[panelName];
		if(typeof path == 'undefined') {
			if(flagRoot) return {src: window[this.dialogId + '_PanelObj']};
			else return window[this.dialogId + '_PanelObj'];
			
		} else {
			path = path.toUpperCase();
			if(flagRoot)	return window[this.dialogId + '_PanelObj'].getPanel(path);
			else return window[this.dialogId + '_PanelObj'].getPanel(path).src;
		}
	},
	
	panelSetActive: function(panelName) {
		/*
		var containerPanel = typeof arguments[1] != 'undefined' ? arguments[1] : '';
		var path = '';
		if(containerPanel == '') {
			path =  window[this.dialogId + '_PanelObj']._panelPath[panelName];
		} else {
			path =  window[this.dialogId + '_PanelObj']._panelPath[containerPanel];				
			path = path + ':' + panelName;
		}
		*/
		var path = this._panelResolvePath(panelName);
		window[this.dialogId + '_PanelObj'].setActivePanel(path);
	},
	
	panelNavigate: function(panelName,direction) {
		
		var panel = this.panelGet(panelName);
		direction = direction.toUpperCase()[0];
		if(direction == 'F') alert('first option not implemented yet');
		else if(direction == 'P') panel.prevPanel();
		else if(direction == 'N') panel.nextPanel();
		else if(direction == 'L') alert('last option not implemented yet');
	},
	
	
	_panelResolvePath: function(panelName) {
		var path = '';
		if(panelName.search('>') == -1) {
			path =  window[this.dialogId + '_PanelObj']._panelPath[panelName];
		} else {
			panelName = panelName.split('>');

			path =  window[this.dialogId + '_PanelObj']._panelPath[panelName[0]];	
			if(typeof path == 'undefined') path = panelName[1];
			else path = path + ':' + panelName[1];
		}
		return path;
	},
	
	
	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);
		}
	},
	
	_runJSOnLoad: function() {
		var e = A5.eleByClass('__A5Component_jsRunOnLoad');
		for(var i = 1; i <= e.length; i++) {
			eval(e[i-1].value);
			e[i-1].value = '';
		}
	},
	
	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);
	}
	
	
	
}

//convert an array of arrays into an array of json objects
function A5DataArrayToObject(cols,data){
	var nData = [];
	var tData = {};
	for(var i=0;i<data.length;i++){
		tData = {};
		if(data[i].constructor == Object) {
			nData.push(data[i]);
		} else {
			for(var j=0;j<cols.length;j++){
				tData[cols[j]] = data[i][j];
			}
			nData.push(tData);
		}
	}
	return nData;
}
			


				
//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 == '') {
			if(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 '';
}


function A5ArrayMove(arrayName, old_index, new_index) {
    if (new_index >= arrayName.length) {
        var k = new_index - arrayName.length;
        while ((k--) + 1) {
            arrayName.push(undefined);
        }
    }
    arrayName.splice(new_index, 0, arrayName.splice(old_index, 1)[0]);
};


	
/*
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);}}
