function HpConstants(){}
HpConstants.JSF=':';
HpConstants.MESSAGES='messages';
HpConstants.SERVICE_SUCCESS='enterprise.SUCCESS';
HpConstants.control='control';
HpConstants.config='config';
HpConstants.init='init';
HpConstants.localize='localize';
HpConstants.localizer='localizer';
HpConstants.text='text';
HpConstants.integer='integer';
HpConstants.decimal= 'decimal';
HpConstants.currency='currency';
HpConstants.rate= 'rate';
HpConstants.minlength= 'minlength';
HpConstants.maxlength= 'maxlength';
HpConstants.minimum= 'minimum';
HpConstants.maximum= 'maximum';
HpConstants.step='step';
HpConstants.format='format';
HpConstants.notrim='notrim';
HpConstants.plain= 'plain';
HpConstants.required='required';
HpConstants.readonly='readonly';
HpConstants.pagebreakbefore='pagebreakbefore';
HpConstants.pagebreakafter='pagebreakafter';
HpConstants.info='info';
HpConstants.warn='warn';
HpConstants.error='error';
HpConstants.success='success';
HpConstants.active='active';
HpConstants.passive='passive';
HpConstants.hide='hide';
HpConstants.light='light';
HpConstants.select='select';
HpConstants.highlight='highlight';
function HpResource(){}
HpResource.decimalSeparator='.';
HpResource.groupingSeparator=',';
HpResource.minlength='Minimum charaters';
HpResource.maxlength='Maximum characters';
HpResource.minimum='Minimum';
HpResource.maximum='Maximum';
HpResource.step='Allowed step size:';
HpResource.errorAJAX='Action failed!';
HpResource.errorCurrency='Not a valid number or more than two decimal places!';
HpResource.errorDecimal='Not a valid number!';
HpResource.errorInteger='Only integers allowed!';
HpResource.errorRate='Not a valid number or more than four decimal places!';
HpResource.errorRequired='Input data are missing!';
HpResource.errorTrim='No leading or trailing spaces!';
function HpEvent(event)
{
this.type=null;
this.target=null;
this.relatedTarget=null;
this.keyCode=null;
this.charCode=null;
this.clientX=null;
this.clientY=null;
this.offsetX=null;
this.offsetY=null;
if(event==null)
event=window.event;
this.type=event.type;
if(event.srcElement==null)
this.target=event.target;
else
this.target=event.srcElement;
if(event.type=='mouseover')
{
if((event.relatedTarget==null) && (event.fromElement!=null))
this.relatedTarget=event.fromElement;
else
this.relatedTarget=event.relatedTarget;
}
else if(event.type=='mouseout')
{
if((event.relatedTarget==null) && (event.toElement!=null))
this.relatedTarget=event.toElement;
else
this.relatedTarget=event.relatedTarget;
}
this.keyCode=event.keyCode;
if(event.charCode)
this.charCode=event.charCode;
else
this.charCode=event.keyCode;
this.clientX=event.clientX;
this.clientY=event.clientY;
if(event.offsetX)
{
this.offsetX=event.offsetX;
this.offsetY=event.offsetY;
}
else
{
this.offsetX=event.layerX;
this.offsetY=event.layerY;
}
}
HpEvent.addEvent=function(a,b,c,d){if(HpCore.runtime==true){HpEvent.setRuntimeEvent(a,b,c);return true;}if(a.addEventListener){a.addEventListener(b,c,d);return true;}else if(a.attachEvent){var e=a.attachEvent('on'+b,c);return e;}else {a['on'+b]=c;}}
HpEvent.setRuntimeEvent=function(a,b,c){if(b=='abort') a.onabort=c;else if(b=='blur') a.onblur=c;else if(b=='change') a.onchange=c;else if(b=='click') a.onclick=c;else if(b=='dblclick') a.ondblclick=c;else if(b=='error') a.onerror=c;else if(b=='focus') a.onfocus=c;else if(b=='keydown') a.onkeydown=c;else if(b=='keypress') a.onkeypress=c;else if(b=='keyup') a.onkeyup=c;else if(b=='load') a.onload=c;else if(b=='mousedown') a.onmousedown=c;else if(b=='mousemove') a.onmousemove=c;else if(b=='mouseout') a.onmouseout=c;else if(b=='mouseover') a.onmouseover=c;else if(b=='mouseup') a.onmouseup=c;else if(b=='reset') a.onreset=c;else if(b=='resize') a.onresize=c;else if(b=='select') a.onselect=c;else if(b=='submit') a.onsubmit=c;else if(b=='unload') a.onunload=c;else throw 'Unhandeled event b in HpEvent.setRuntimeEvent! '+b;}
function HpCore(){}
HpCore.browser=null;
HpCore.messages=null;
HpCore.runtime=false;
HpCore.actions=new Array();
HpCore.locale='en';
HpCore.locales=new Array('en','de');
HpCore.initAutomatic=true;
HpCore.initBefore=new Array();
HpCore.initStartElement=new Array();
HpCore.initEndElement=new Array();
HpCore.initAfter=new Array();
HpEvent.addEvent(window,'load',initHpCore,false);
function initHpCore()
{
var i=0;
var temp=null;
HpCore.determineBrowser();
temp=document.getElementById(HpConstants.MESSAGES);
if(temp!=null)
{
HpCore.messages=new HpScrollBox(null,temp,true);
HpCore.messages.scroller.setButtonHeight(15);
}
for(i=0;i<HpCore.initBefore.length;i++)
HpCore.initBefore[i]();
if(HpCore.initAutomatic==true)
HpAction.registerAutomatic(new Array(),document);
for(i=0;i<HpCore.initAfter.length;i++)
HpCore.initAfter[i]();
HpCore.initBefore=null;
HpCore.initStartElement=null;
HpCore.initEndElement=null;
HpCore.initAfter=null;
HpCore.runtime=true;
}
HpCore.addInitBefore=function(a){HpCore.initBefore[HpCore.initBefore.length]=a;}
HpCore.addInitStartElement=function(a){HpCore.initStartElement[HpCore.initStartElement.length]=a;}
HpCore.addInitEndElement=function(a){HpCore.initEndElement[HpCore.initEndElement.length]=a;}
HpCore.addInitAfter=function(a){HpCore.initAfter[HpCore.initAfter.length]=a;}
HpCore.determineBrowser=function(){var a=null;if(navigator.userAgent==null) return;a=navigator.userAgent.toLowerCase();if(a.indexOf("msie")!=-1){HpCore.browser='EXPLORER';return;}if(a.indexOf("firefox")!=-1){HpCore.browser='FIREFOX';return;}if(a.indexOf("opera")!=-1){HpCore.browser='OPERA';return;}}
function HpDom(){}
HpDom.searchClass=function(a,b){var c=0;var d='';if((a.className==null)||(a.className.length<=0)) return null;c=a.className.indexOf(b);if((c<0)||((c>0)&&(a.className.charAt(c-1)!=' '))) return null;for(;(c<a.className.length)&&(a.className.charAt(c)!=' ');c++) d=d+a.className.charAt(c);return d;}
HpDom.containsClass=function(a,b){if(HpDom.getClassIndex(a,b)>=0) return true;else return false;}
HpDom.getClassIndex=function(a,b){var c=0;if(a.className==null) return -1;if(a.className==b) return 0;c=a.className.indexOf(b+' ');if(c==0) return 0;c=a.className.indexOf(' '+b+' ');if(c>=0) return c+1;c=a.className.indexOf(' '+b);if((c>=0)&&(c==a.className.length-1-b.length)) return c+1;return -1;}
HpDom.getClasses=function(a){return a.className;}
HpDom.setClasses=function(a,b){a.className=b;}
HpDom.addClass=function(a,b){if(b==null) return;if(HpDom.containsClass(a,b)==false){if(a.className.length==0) a.className=b;else a.className=a.className+' '+b;}}
HpDom.addClasses=function(a,b){var c=0;var d=null;if(b==null) return;d=HpUtil.compressSpace(b).split(' ');for(c=0;c<d.length;c++) HpDom.addClass(a,d[c]);}
HpDom.removeClass=function(a,b){var c=0;if(b==null) return;c=HpDom.getClassIndex(a,b);if(c>=0) a.className=a.className.substring(0,c)+a.className.substring(c+b.length,a.className.length);}
HpDom.removeClasses=function(a,b){var c=0;var d=null;if(b==null) return;d=HpUtil.compressSpace(b).split(' ');for(c=0;c<d.length;c++) HpDom.removeClass(a,d[c]);}
HpDom.getElementsByClass=function(a,b){var c=0;var d=null;var e=new Array();if(HpDom.containsClass(a,b)==true) e[e.length]=a;for(c=0;c<a.childNodes.length;c++){d=HpDom.getElementsByClass(a.childNodes[c],b);HpUtil.append(e,d);}return e;}
HpDom.removeChilds=function(a){var b=a.childNodes.length;while(a.hasChildNodes()) a.removeChild(a.firstChild);return b;}
HpDom.getChild=function(a,b){var c=0;for(c=0;c<a.childNodes.length;c++){if(a.childNodes[c].nodeName.toLowerCase()==b.toLowerCase()) return a.childNodes[c];}return null;}
HpDom.listChild=function(a,b,c){var d=0;var e=0;var f=null;var g=new Array();var h=null;if(b!=null) h=b.split(',');for(d=0;d<a.childNodes.length;d++){f=a.childNodes[d];if((f==null)||(f.nodeType!=1)) continue;if(b==null){g[g.length]=f;}else {if(f.nodeName!=null){for(e=0;e<h.length;e++){if(f.nodeName.toLowerCase()==h[e].toLowerCase()) g[g.length]=f;}}}if((c==true)&&(f.hasChildNodes()==true)) HpUtil.appendArray(g,HpDom.listChild(f,b,c));}return g;}
HpDom.isParent=function(a,b){var c=0;while(b.parentNode!=null){if(b.parentNode==a) return true;b=b.parentNode;}return false;}
HpDom.findParent=function(a,b){if(a.parentNode==null) return null;if(a.parentNode.nodeName.toLowerCase()==b.toLowerCase()) return a.parentNode;return HpDom.findParent(a.parentNode,b);}
HpDom.findPrevious=function(a,b){while(a!=null){a=a.previousSibling;if(a==null) return null;if(a.nodeName.toLowerCase()==b) return a;}return null;}
HpDom.findNext=function(a,b){while(a!=null){a=a.nextSibling;if(a==null) return null;if(a.nodeName.toLowerCase()==b) return a;}return null;}
HpDom.getText=function(a){if(HpDom.isField(a)==true) return a.value;else if(a.nodeType==1){if(a.hasChildNodes()) return a.firstChild.nodeValue;else return null;}else if(a.nodeType==3) return a.nodeValue;}
HpDom.setText=function(a,b){if(HpDom.isField(a)==true) a.value=b;else if(a.nodeType==1){if(a.hasChildNodes()) a.firstChild.nodeValue=b;else a.appendChild(document.createTextNode(b));}else if(a.nodeType==3) a.nodeValue=b;}
HpDom.unselect=function(a){var b=HpDom.getText(a);HpDom.setText(a,'');HpDom.setText(a,b);}
HpDom.isField=function(a){var b=null;if(a.nodeName==null) return false;b=a.nodeName.toLowerCase();if((b=='input')||(b=='select')||(b=='textarea')) return true;else return false;}
HpDom.isInput=function(a){return HpDom.checkNodeName(a,'input');}
HpDom.isCheckBox=function(a){if((HpDom.isInput(a)==true)&&(a.type=='checkbox')) return true;else return false;}
HpDom.isSelect=function(a){return HpDom.checkNodeName(a,'select');}
HpDom.isTextArea=function(a){return HpDom.checkNodeName(a,'textarea');}
HpDom.checkNodeName=function(a,b){if((a.nodeName!=null)&&(a.nodeName.toLowerCase()==b)) return true;else return false;}
HpDom.clearElement=function(a){if(HpDom.isSelect(a)==true) HpDom.removeChilds(a);else if(HpDom.isField(a)==true) HpDom.setText(a,'');else HpDom.removeChilds(a);}
HpDom.addOption=function(a,b,c,d,e){HpDom.setOption(a,a.length,b,c,d,e);}
HpDom.setOption=function(a,b,c,d,e,f){a[b]=new Option(c,d,e,f);}
HpDom.removeOption=function(a,b){a[b]=null;}
HpDom.removeOptionByValue=function(a,b){var c=0;for(c=a.options.length-1;c>=0;c--){if(a.options[c].value==b) a[c]=null;}}
HpDom.getAttribute=function(a,b){return a.getAttributeNode(b);}
HpDom.setAttribute=function(a,b,c){var d=null;try{d=document.createAttribute(b);d.nodeValue=c;a.setAttributeNode(d);}catch(e){a.setAttribute(b,c);}return a.getAttributeNode(b);}
HpDom.removeAttribute=function(a,b){a.removeAttribute(b,0);}
HpDom.cloneXML=function(a){var b=0;var c=null;var d=null;var e=null;var f=null;if(a.nodeType==1){c=document.createElement(a.nodeName);for(b=0;b<a.attributes.length;b++){d=a.attributes[b].nodeName;e=a.attributes[b].nodeValue;if(d.substring(0,2)=='on') HpAction.registerAll(c,d.substring(2),null,new Function('event',e),null,null);else HpDom.setAttribute(c,d,e);}for(b=0;b<a.childNodes.length;b++) c.appendChild(HpDom.cloneXML(a.childNodes[b]));}else if(a.nodeType==3){c=document.createTextNode(HpUtil.filter(a.nodeValue));}else {throw 'Unhandeled a type in HpDom.cloneXML!';}return c;}
function HpNumber(){}
HpNumber.round=function(a,b){var c=Math.pow(10,b);var d=Math.round(Math.abs(a)*c);if(a>=0.0) return d/c;else return d/c*-1;}
HpNumber.checkInteger=function(a){return HpNumber.checkNumber(a,0);}
HpNumber.checkDecimal=function(a){return HpNumber.checkNumber(a,-1);}
HpNumber.checkCurrency=function(a){return HpNumber.checkNumber(a,2);}
HpNumber.checkRate=function(a){return HpNumber.checkNumber(a,4);}
HpNumber.checkNumber=function(a,b){return HpNumber.check(a,b,HpResource.decimalSeparator,HpResource.groupingSeparator);}
HpNumber.parseInteger=function(a){return HpNumber.parseNumber(a,0);}
HpNumber.parseDecimal=function(a){return HpNumber.parseNumber(a,-1);}
HpNumber.parseCurrency=function(a){return HpNumber.parseNumber(a,2);}
HpNumber.parseRate=function(a){return HpNumber.parseNumber(a,4);}
HpNumber.parseNumber=function(a,b){return HpNumber.parse(a,b,HpResource.decimalSeparator,HpResource.groupingSeparator);}
HpNumber.formatInteger=function(a){return HpNumber.formatNumber(a,0) }
HpNumber.formatDecimal=function(a){return HpNumber.formatNumber(a,-1) }
HpNumber.formatCurrency=function(a){return HpNumber.formatNumber(a,2) }
HpNumber.formatRate=function(a){return HpNumber.formatNumber(a,4) }
HpNumber.formatNumber=function(a,b){return HpNumber.format(a,b,HpResource.decimalSeparator,HpResource.groupingSeparator) }
HpNumber.check=function(a,b,c,d){var e=null;var f=-1;if(a.length<=0) return false;for(i=0;i<a.length;i++){e=a.charAt(i);if((e>='0')&&(e<='9')) continue;if(e==d){if((f!=-1)&&(i>f)) return false;continue;}if(e==c){if(b==0) return false;if((b!=-1)&&(i<a.length-b-1)) return false;if(f!=-1) return false;f=i;continue;}if(((e=='+')||(e=='-'))&&(i==0)) continue;return false;}return true;}
HpNumber.parse=function(a,b,c,d){var e=0;var f=null;var g='';var h='';if(e<a.length){f=a.charAt(e);if((f=='+')||(f=='-')){e++;h=f;}}if(e<a.length){f=a.charAt(e);if(f==c) g=h+'0';else g=h;}for(;e<a.length;e++){f=a.charAt(e);if(f==d) continue;else if(f==c) g=g+'.';else if((f>='0')&&(f<='9')) g=g+f;}if(g.length==0) return null;if(b>=0) return HpNumber.round(parseFloat(g),b);return parseFloat(g);}
HpNumber.extract=function(a){var b=0;var c=null;var d='';var e=false;var f=false;if(a==null) return null;for(b=0;b<a.length;b++){c=a.charAt(b);if((d.length==0)&&((c=='-')||(c=='+'))){d=d+c;}else if((c>='0')&&(c<='9')){f=true;d=d+c;}else if((f==true)&&(e==false)&&(c=='.')){e=true;d=d+c;}}if(f==false) return null;else return parseFloat(d);}
HpNumber.format=function(a,b,c,d){var e=0;var f=null;var g=0;var h='';var i='';var j=-1;if(b>=0) i=HpNumber.round(a,b).toFixed(b);else i=a.toString();j=i.indexOf('.');for(e=i.length-1;e>=0;e--){f=i.charAt(e);if((f=='-')||(f=='+')){h=f+h;break;}if(f=='.'){h=c+h;continue;}if((j==-1)||(j>e)) g++;if(g==4){g=1;h=d+h;}h=f+h;}return h;}
function HpStyle(){}
HpStyle.getPropertyOfRule=function(a,b){var c=0;var d=null;var e=null;b=HpUtil.trim(b).toLowerCase();d=a.style.cssText.split(';');for(c=d.length-1;c>=0;c--){e=HpPair.parse(d[c],':',true,true);if((e!=null)&&(e.key==b)) return e;}return null;}
HpStyle.setPropertyOfRule=function(a,b,c){var d='';var e=null;var f=null;b=HpUtil.trim(b).toLowerCase();c=HpUtil.trim(c).toLowerCase();f=HpStyle.listPropertiesOfRule(a);for(i=f.length-1;i>=0;i--){if(f[i].key==b){e=f[i];d=d+b+':'+c+';';}else d=d+f[i].format(':') +';';}if(e==null) d=d+b+':'+c+';';a.style.cssText=d;return e;}
HpStyle.removePropertyOfRule=function(a,b){var c=0;var d='';var e=null;var f=null;b=HpUtil.trim(b).toLowerCase();f=HpStyle.listPropertiesOfRule(a);for(c=f.length-1;c>=0;c--){if(f[c].key==b) e=f[c];else d=d+f[c].format(':')+';';}a.style.cssText=d;return e;}
HpStyle.listPropertiesOfRule=function(a){var b=0;var c=null;var d=null;var e=new Array();c=a.style.cssText.split(';');for(b=c.length-1;b>=0;b--){d=HpPair.parse(c[b],':',true,true);if(d!=null) e[e.length]=d;}return e;}
HpStyle.getRuleOfDocument=function(a,b){var c=0;var d=null;for(c=document.styleSheets.length-1;c>=0;c--){if((a==null)||(HpStyle.isSheetForMedia(document.styleSheets[c],a)==true)){d=HpStyle.getRuleOfSheet(document.styleSheets[c],b);if(d!=null) return d;}}return null;}
HpStyle.getRuleOfSheet=function(a,b){return HpStyle.getRuleOfList(HpStyle.listRulesOfSheet(a),b);}
HpStyle.getRuleOfList=function(a,b){var c=0;var d=0;var e=null;b=HpUtil.trim(b).toLowerCase();for(c=a.length-1;c>=0;c--){e=a[c].selectorText.toLowerCase().split(',');for(d=e.length-1;d>=0;d--){if(HpUtil.trim(e[d])==b) return a[c];}}return null;}
HpStyle.listRulesOfDocument=function(a){var b=0;var c=new Array();for(b=document.styleSheets.length-1;b>=0;b--){if((a==null)||(HpStyle.isSheetForMedia(document.styleSheets[b],a)==true)) HpUtil.append(c,HpStyle.listRulesOfSheet(document.styleSheets[b]));}return c;}
HpStyle.listRulesOfSheet=function(a){var b=0;var c=null;var d=new Array();if(a.cssRules) c=a.cssRules;else if(a.rules) c=a.rules;for(b=c.length-1;b>=0;b--) d[d.length]=c[b];return d;}
HpStyle.isSheetForMedia=function(a,b){var c=0;var d=null;b=HpUtil.trim(b).toLowerCase();if(a.media.mediaText) d=a.media.mediaText.toLowerCase().split(',');else d=a.media.toLowerCase().split(',');for(c=0;c<d.length;c++){if(HpUtil.trim(d[c])==b) return true;}return false;}
function HpUtil(){}
HpUtil.appendArray=function(a,b){var c=0;for(c=0;c<b.length;c++) a[a.length]=b[c];}
HpUtil.getInnerWidth=function(){if(self.innerWidth) return self.innerWidth;if(document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;if(document.body) return document.body.clientWidth;return 0;}
HpUtil.getInnerHeight=function(){if(self.innerHeight) return self.innerHeight;if(document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;if(document.body) return document.body.clientHeight;return 0;}
HpUtil.filter=function(a){var b=null;var c='';var d=false;var e=null;for(b=0;b<a.length;b++){e=a.charAt(b);if((e==' ')||(e=='\n')||(e=='\t')){if(d==true) c=c+' ';d=false;}else {c=c+e;d=true;}}return c;}
HpUtil.compressSpace=function(a){var b=0;var c=0;var d='';var e=null;a=HpUtil.trim(a);for(b=0;b<a.length;b++){e=a.charAt(b);if(e==' ') c++;else c=0;if(c<=1) d=d+e;}return d;}
HpUtil.trim=function(a){return HpUtil.trimRight(HpUtil.trimLeft(a));}
HpUtil.trimLeft=function(a){var b=0;for(b=0;b<a.length;b++){if(a.charAt(b)!=' ') break;}return a.substring(b);}
HpUtil.trimRight=function(a){var b=0;for(b=a.length-1;b>=0;b--){if(a.charAt(b)!=' ') break;}return a.substring(0,b+1);}
HpUtil.append=function(a,b){for(var c=0;c<b.length;c++) a[a.length]=b[c];}
HpUtil.getIndex=function(a,b){for(var c=0;c<a.length;c++){if(a[c]==b) return c;}return -1;}
HpUtil.isNaviKey=function(a){if(a.keyCode==null) return false;if(a.keyCode==9) return true;if((a.keyCode>=37)&&(a.keyCode<=40)) return true;return false;}
HpUtil.isArrowKey=function(a){if(a.keyCode==null) return false;if((a.keyCode>=37)&&(a.keyCode<=40)) return true;return false;}
HpUtil.isEmpty=function(a){if(a==null) return true;if(a.length<=0) return true;return false;}
HpUtil.isNotEmpty=function(a){if(a==null) return false;if(a.length<=0) return false;return true;}
function HpElement(){}
HpElement.separator=',';
HpElement.renderText=function(a,b,c,d){var e=null;if(b==null) return null;if((b.length<=0)&&(c==true)) return null;e=HpDom.getText(a);if((e==null)||(e.length<=0)){HpDom.setText(a,b);return a;}if(c==true){if(d==null) HpDom.setText(a,e+b);else HpDom.setText(a,e+d+b);return a;}if(b!=e) HpDom.setText(a,b);return a;}
function HpInput(){}
HpInput.separator=',';
HpInput.renderText=function(a,b,c,d){return HpElement.renderText(a,b,c,d);}
function HpSelect(){}
HpSelect.renderText=function(a,b,c,d){if(b==null) return null;if(d<0){HpDom.addOption(a,b,c,false,true);return a;}HpDom.setOption(a,d,b,c,false,true);return a;}
function HpTextArea(){}
HpTextArea.separator='\n';
HpTextArea.renderText=function(a,b,c,d){return HpElement.renderText(a,b,c,d);}
function HpDiv(parent,element)
{
this.parent=parent;
this.element=element;
this.top=null;
this.left=null;
this.width=null;
this.height=null;
this.visible=true;
if(element==null)
return;
this.visible=(HpDom.containsClass(element,HpConstants.hide)==false);
if(this.visible==true)
{
this.top=element.offsetTop;
this.left=element.offsetLeft;
this.width=element.offsetWidth;
this.height=element.offsetHeight;
}
else
{
this.setVisible(true);
this.top=element.offsetTop;
this.left=element.offsetLeft;
this.width=element.offsetWidth;
this.height=element.offsetHeight;
this.setVisible(false);
}
}
HpDiv.prototype.removeChilds=function(){var a=true;if(this.visible==false){a=false;this.setVisible(true);}this.element.style.width='';this.element.style.height='';HpDom.removeChilds(this.element);this.setWidth (this.element.offsetWidth);this.setHeight(this.element.offsetHeight);if(a==false) this.setVisible(false);}
HpDiv.prototype.appendChild=function(a){var b=true;if(this.visible==false){b=false;this.setVisible(true);}this.element.style.width='';this.element.style.height='';this.element.appendChild(a);this.setWidth (this.element.offsetWidth);this.setHeight(this.element.offsetHeight);if(b==false) this.setVisible(false);}
HpDiv.prototype.setVisible=function(a){this.visible=a;if(a==true) HpDom.removeClass(this.element,HpConstants.hide);else HpDom.addClass(this.element,HpConstants.hide);}
HpDiv.prototype.setTop=function(a){this.top=a;this.element.style.top=a+'px';}
HpDiv.prototype.setLeft=function(a){this.left=a;this.element.style.left=a+'px';}
HpDiv.prototype.setWidth=function(a){this.width=a;this.element.style.width=a+'px';}
HpDiv.prototype.setHeight=function(a){this.height=a;this.element.style.height=a+'px';}
HpBox.prototype=new HpDiv();
HpBox.prototype.constructor=HpBox;
function HpBox(parent,element,auto)
{
var temp=null;
var visibleState=true;
this.content=null;
this.close=null;
this.indent=null;
this.full=null;
this.auto=auto;
this.minimumHeight=26;
this.maximumHeight=72;
if(element==null)
return;
if(HpDom.containsClass(element,HpConstants.hide)==true)
{
HpDom.removeClass(element,HpConstants.hide);
visibleState=false;
}
HpDiv.call(this,parent,element);
temp=HpDom.getChild(element,'ul');
if(temp==null)
{
temp=document.createElement('ul');
this.element.appendChild(temp);
}
this.content=new HpDiv(this,temp);
temp=document.createElement('div');
this.element.appendChild(temp);
HpDom.addClass(temp,'close');
this.close=new HpDiv(this,temp);
HpDom.setText(temp,'X');
temp=document.createElement('div');
this.element.appendChild(temp);
HpDom.addClass(temp,'indent');
this.indent=new HpDiv(this,temp);
HpDom.setText(temp,'▲');
temp=document.createElement('div');
this.element.appendChild(temp);
HpDom.addClass(temp,'full');
this.full=new HpDiv(this,temp);
HpDom.setText(temp,'▼');
HpBox.prototype.resize.call(this);
HpAction.registerRender(this.close.element,'click',HpBox.renderClose,this);
HpAction.registerRender(this.indent.element,'click',HpBox.renderIndent,this);
HpAction.registerRender(this.full.element,'click',HpBox.renderFull,this);
if(visibleState==false)
this.setVisible(false);
}
HpBox.prototype.resize=function(){if(this.auto==true){if(this.content.height>=this.maximumHeight){if(this.height!=this.maximumHeight) this.setHeight(this.maximumHeight);}else if(this.content.height<=this.minimumHeight){if(this.height!=this.minimumHeight) this.setHeight(this.minimumHeight);}else {this.setHeight(this.content.height);}}this.close.setLeft (this.width-this.close.width-5);this.indent.setLeft(this.close.left-this.indent.width-1);this.full.setLeft (this.indent.left);if(this.height>=this.content.height){this.indent.setVisible(false);this.full.setVisible(false);}else if(this.height>=this.maximumHeight){this.indent.setVisible(true);this.full.setVisible(false);}else {this.indent.setVisible(false);this.full.setVisible(true);}}
HpBox.prototype.setWidth=function(a){HpDiv.prototype.setWidth.call(this,a);this.resize();}
HpBox.prototype.removeItems=function(){var a=true;if(this.visible==false){a=false;this.setVisible(true);}HpDiv.prototype.removeChilds.call(this.content);this.resize();if(a==false) this.setVisible(false);}
HpBox.prototype.addItem=function(a){var b=null;var c=true;if(this.visible==false){c=false;this.setVisible(true);}b=document.createElement('li');b.appendChild(document.createTextNode(a));HpDiv.prototype.appendChild.call(this.content,b);this.resize();if(c==false) this.setVisible(false);return b;}
HpBox.renderClose=function(a){a.targets[0].setVisible(false);}
HpBox.renderIndent=function(a){var b=a.targets[0];b.indent.setVisible(false);b.full.setVisible(true);b.setHeight(b.minimumHeight);}
HpBox.renderFull=function(a){var b=a.targets[0];b.indent.setVisible(true);b.full.setVisible(false);if(b.content.height>=b.maximumHeight) b.setHeight(b.maximumHeight);else b.setHeight(b.content.height);}
HpScrollBox.prototype=new HpBox();
HpScrollBox.prototype.constructor=HpScrollBox;
function HpScrollBox(parent,element,auto)
{
var temp=null;
this.scroller=null;
var visibleState=true;
if(element==null)
return;
if(HpDom.containsClass(element,HpConstants.hide)==true)
{
HpDom.removeClass(element,HpConstants.hide);
visibleState=false;
}
HpBox.call(this,parent,element,auto);
temp=document.createElement('div');
this.element.appendChild(temp);
this.scroller=new HpScroller(this,temp,true);
this.scroller.onMouseUp=HpScrollBox.onScrollerMouseUp;
this.scroller.onButtonMouseMove=HpScrollBox.onScrollerButtonMouseMove;
HpScrollBox.prototype.resize.call(this);
if(visibleState==false)
this.setVisible(false);
}
HpScrollBox.prototype.setWidth=function(a){HpBox.prototype.setWidth.call(this,a);}
HpScrollBox.prototype.resize=function(){HpScrollBox.scroll(this,this.scroller.position);HpBox.prototype.resize.call(this);if(this.content.height>this.maximumHeight){this.scroller.setVisible(true);this.scroller.setLeft (this.width-this.scroller.width-6);this.scroller.setHeight (this.maximumHeight-this.scroller.top-5);this.scroller.setPositions(0,this.content.height-this.maximumHeight);}else {this.scroller.setVisible(false);}}
HpScrollBox.onScrollerMouseUp=function(a){HpScrollBox.scroll(a.targets[0],a.targets[2]);}
HpScrollBox.onScrollerButtonMouseMove=function(a){HpScrollBox.scroll(a.targets[0],a.targets[2]*-1);}
HpScrollBox.scroll=function(a,b){a.content.setTop(a.scroller.scroll(b));}
function HpCursor(parent)
{
var temp=null;
this.parent=parent;
this.topLine=null;
this.leftLine=null;
this.rightLine=null;
this.bottomLine=null;
this.top=0;
this.left=0;
this.width=0;
this.height=0;
this.visible=true;
this.setVisible=function(a){this.visible=a;if(a==true){this.topLine.setVisible(true);this.leftLine.setVisible(true);this.rightLine.setVisible(true);this.bottomLine.setVisible(true);}else {this.topLine.setVisible(false);this.leftLine.setVisible(false);this.rightLine.setVisible(false);this.bottomLine.setVisible(false);}}
this.setTop=function(a){this.top=a;this.topLine.setTop (a);this.leftLine.setTop (a);this.rightLine.setTop (a);this.bottomLine.setTop(a+this.leftLine.height-1);}
this.setLeft=function(a){this.left=a;this.topLine.setLeft (a);this.leftLine.setLeft (a);this.rightLine.setLeft (a+this.topLine.width-1);this.bottomLine.setLeft(a);}
this.setWidth=function(a){this.width=a;this.topLine.setWidth (a);this.rightLine.setLeft (this.topLine.left+a-1);this.bottomLine.setWidth(a);}
this.setHeight=function(a){this.height=a;this.leftLine.setHeight (a);this.rightLine.setHeight(a);this.bottomLine.setTop (this.topLine.top+a-1);}
temp=document.createElement('div');
this.parent.element.appendChild(temp);
HpDom.addClass(temp,'cursor');
this.topLine=new HpDiv(this,temp);
this.topLine.setHeight(1);
temp=document.createElement('div');
this.parent.element.appendChild(temp);
HpDom.addClass(temp,'cursor');
this.leftLine=new HpDiv(this,temp);
this.leftLine.setWidth(1);
temp=document.createElement('div');
this.parent.element.appendChild(temp);
HpDom.addClass(temp,'cursor');
this.rightLine=new HpDiv(this,temp);
this.rightLine.setWidth(1);
temp=document.createElement('div');
this.parent.element.appendChild(temp);
HpDom.addClass(temp,'cursor');
this.bottomLine=new HpDiv(this,temp);
this.bottomLine.setHeight(1);
}
HpScroller.prototype=new HpDiv();
HpScroller.prototype.constructor=HpScroller;
function HpScroller(parent,element,vertical)
{
var visibleState=true;
this.vertical=vertical;
this.onMouseUp=null;
this.onButtonMouseStart=null;
this.onButtonMouseMove=null;
this.onButtonMouseStop=null;
this.button=null;
this.process=false;/* true if currently scrolling will be executed */
this.range=0;
this.factor=1;/* scroll factor between range-size and scoller-size */
this.position=0;
this.positionStart=0;
this.positionEnd=0;
this.lastPosition=0;
this.lastClientPosition=0;
this.setPositions=function(a,b){this.position=a;this.positionStart=a;this.range=b;this.positionEnd=a-b;this.calculateFactor();}
this.setButtonWidth=function(a){this.button.setWidth(a);this.calculateFactor();}
this.setButtonHeight=function(a){this.button.setHeight(a);this.calculateFactor();}
this.calculateFactor=function(){if(this.vertical==true) this.factor=this.range/(this.height-this.button.height-2);else this.factor=this.range/(this.width-this.button.width-2);}
this.scroll=function(a){this.position=this.position-a;if(this.position>this.positionStart) this.position=this.positionStart;else if(this.position<this.positionEnd) this.position=this.positionEnd;if(this.vertical==true) this.button.setTop (HpNumber.round(((this.positionStart-this.position)/this.factor),0));else this.button.setLeft(HpNumber.round(((this.positionStart-this.position)/this.factor),0));return this.position;}
if(element==null)
return;
if(HpDom.containsClass(element,HpConstants.hide)==true)
{
HpDom.removeClass(element,HpConstants.hide);
visibleState=false;
}
if(vertical==true)
HpDom.addClass(element,'verticalScroller');
else
HpDom.addClass(element,'horizontalScroller');
HpDiv.call(this,parent,element);
this.element.appendChild(document.createElement('div'));
this.button=new HpDiv(this,this.element.firstChild);
this.button.setTop (0);
this.button.setLeft(0);
if(vertical==true)
this.button.setHeight(39);
else
this.button.setWidth (50);
HpAction.registerRender(this.element,'mouseup',HpScroller.mouseUp,[this.parent,this]);
HpAction.registerRender(this.button.element,'mousedown',HpScroller.buttonMouseStart,[this.parent,this]);
HpAction.registerRender(this.button.element,'mousemove',HpScroller.buttonMouseMove,[this.parent,this]);
HpAction.registerRender(this.button.element,'mouseup',HpScroller.buttonMouseStop,[this.parent,this]);
HpAction.registerRender(this.button.element,'mouseout',HpScroller.buttonMouseStop,[this.parent,this]);
if(visibleState==false)
this.setVisible(false);
}
HpScroller.prototype.setWidth=function(a){HpDiv.prototype.setWidth.call(this,a);if(this.vertical==true) this.button.setWidth(a-2);this.calculateFactor();}
HpScroller.prototype.setHeight=function(a){HpDiv.prototype.setHeight.call(this,a);if(this.vertical==false) this.button.setHeight(a-2);this.calculateFactor();}
HpScroller.mouseUp=function(a){var b=null;var c=null;c=a.targets[1];if(c.process==true) return;c.process=true;if(c.vertical==true) b=a.event.offsetY-c.button.top-HpNumber.round((c.button.height/2),0);else b=a.event.offsetX-c.button.left-HpNumber.round((c.button.width/2),0);b=HpNumber.round((b*c.factor),0);a.targets[2]=b;if(c.onMouseUp!=null) c.onMouseUp(a);c.process=false;}
HpScroller.buttonMouseStart=function(a){var b=null;b=a.targets[1];b.process=true;if(b.vertical==true){b.lastPostion=b.button.top;b.lastClientPosition=a.event.clientY;}else {b.lastPostion=b.button.left;b.lastClientPosition=a.event.clientX;}if(b.onButtonMouseStart!=null) b.onButtonMouseStart(a);}
HpScroller.buttonMouseMove=function(a){var b=0;var c=null;c=a.targets[1];if(c.process==false) return;if(c.vertical==true) b=c.button.top-(c.lastPostion+(a.event.clientY-c.lastClientPosition));else b=c.button.left-(c.lastPostion+(a.event.clientX-c.lastClientPosition));b=HpNumber.round((b*c.factor),0);a.targets[2]=b;if(c.onButtonMouseMove!=null) c.onButtonMouseMove(a);}
HpScroller.buttonMouseStop=function(a){var b=null;b=a.targets[1];if(b.onButtonMouseStop!=null) b.onButtonMouseStop(a);b.process=false;}
HpCell.prototype=new HpDiv();
HpCell.prototype.constructor=HpCell;
function HpCell(parent,index,element)
{
var visibleState=true;
this.index=index;
this.name=HpDom.getClasses(element).split(' ')[0];
this.highlight=false;
this.active=false;
this.select=false;
this.action=HpDom.containsClass(element,'action');
this.getTotalIndex=function(){var a=0;var b=0;var c=this.parent.parent;for(a=0;a<c.zones.length;a++){if(c.zones[a]==this.parent) break;b=b+c.zones[a].cells.length;}return this.index+b;}
this.setHighlight=function(a){this.highlight=a;if(a==true) HpDom.addClass(this.element,HpConstants.highlight);else HpDom.removeClass(this.element,HpConstants.highlight);}
this.setActive=function(a){this.active=a;if(a==true) HpDom.addClass(this.element,HpConstants.active);else HpDom.removeClass(this.element,HpConstants.active);}
this.setSelect=function(a){this.select=a;if(a==true) HpDom.addClass(this.element,HpConstants.select);else HpDom.removeClass(this.element,HpConstants.select);}
if(element==null)
return;
if(HpDom.containsClass(element,HpConstants.hide)==true)
{
HpDom.removeClass(element,HpConstants.hide);
visibleState=false;
}
HpDiv.call(this,parent,element);
if(visibleState==false)
this.setVisible(false);
}
HpZone.prototype=new HpDiv();
HpZone.prototype.constructor=HpZone;
function HpZone(parent,index,element)
{
var i=0;
var list=null;
var visibleState=true;
this.index=index;
this.cells=new Array();
this.scroll=HpDom.containsClass(element,'scroll');
if(element==null)
return;
if(HpDom.containsClass(element,HpConstants.hide)==true)
{
HpDom.removeClass(element,HpConstants.hide);
visibleState=false;
}
HpDiv.call(this,parent,element);
list=HpDom.listChild(element,'div',false);
for(i=0;i<list.length;i++)
this.cells[this.cells.length]=new HpCell(this,i,list[i]);
if(visibleState==false)
this.setVisible(false);
}
HpRow.prototype=new HpDiv();
HpRow.prototype.constructor=HpRow;
function HpRow(parent,index,element)
{
var i=0;
var zone=null;
var list=null;
var visibleState=true;
this.index=index;
this.zones=new Array();
this.cells=new Array();
if(element==null)
return;
if(HpDom.containsClass(element,HpConstants.hide)==true)
{
HpDom.removeClass(element,HpConstants.hide);
visibleState=false;
}
HpDiv.call(this,parent,element);
list=HpDom.listChild(element,'div',false);
for(i=0;i<list.length;i++)
{
zone=new HpZone(this,i,list[i])
this.zones[this.zones.length]=zone;
HpUtil.appendArray(this.cells,zone.cells);
}
if(visibleState==false)
this.setVisible(false);
}
HpSection.prototype=new HpDiv();
HpSection.prototype.constructor=HpSection;
function HpSection(parent,index,element)
{
var i=0;
var list=null;
var visibleState=true;
this.index=index;
this.rows=new Array();
if(element==null)
return;
if(HpDom.containsClass(element,HpConstants.hide)==true)
{
HpDom.removeClass(element,HpConstants.hide);
visibleState=false;
}
HpDiv.call(this,parent,element);
list=HpDom.listChild(element,'div',false);
for(i=0;i<list.length;i++)
this.rows[this.rows.length]=new HpRow(this,i,list[i]);
if(visibleState==false)
this.setVisible(false);
}
HpPreview.prototype=new HpDiv();
HpPreview.prototype.constructor=HpPreview;
function HpPreview(parent,element)
{
var temp=null;
var visibleState=true;
this.view=null;
this.head=null;
this.body=null;
this.foot=null;
this.horizontalLine=null;
this.verticalLine=null;
this.factorX=0;
this.factorY=0;
this.onPreviewCell=null;
this.clearSectionCells=function(a){var b=0;for(b=0;b<a.rows.length;b++) this.clearRowCells(a.rows[b]);}
this.clearRowCells=function(a){var b=0;for(b=0;b<a.cells.length;b++) HpDom.removeChilds(a.cells[b].element);}
this.prepare=function(){var a=0;var b=0;var c=null;var d=0;d=this.parent.printRows-this.head.rows.length;if(this.foot!=null) d=d-this.foot.rows.length;if(this.onPreviewCell!=null){for(a=0;a<this.head.rows.length;a++){c=this.head.rows[a];for(b=0;b<c.cells.length;b++) this.onPreviewCell(c.cells[b]);}}if(this.onPreviewCell==null){for(a=0;a<this.body.rows.length;a++){c=this.body.rows[a];if(a<d) c.setVisible(true);else c.setVisible(false);}}else {for(a=0;a<this.body.rows.length;a++){c=this.body.rows[a];if(a<d){c.setVisible(true);for(b=0;b<c.cells.length;b++) this.onPreviewCell(c.cells[b]);}else c.setVisible(false);}}if(this.onPreviewCell!=null){for(a=0;a<this.foot.rows.length;a++){c=this.foot.rows[a];for(b=0;b<c.cells.length;b++) this.onPreviewCell(c.cells[b]);}}}
this.resize=function(a,b,c,d,e,f,g,h){var i=0;var j=0;var k=0;var l=null;var m=0;var n=0;var o=0;this.setTop (a);this.setLeft (b);this.setWidth (c);this.setHeight(d);if(d<150) j=10;else j=20;this.view.setTop (j);this.view.setLeft (j);this.view.setWidth (c-(j*2)-4);this.view.setHeight(d-(j*2)-4);o=this.view.width/this.view.height;if(g==true) n=e/f;else n=f/e;if(o>n) this.view.setWidth (HpNumber.round(this.view.height*n,0));else if(o<n) this.view.setHeight(HpNumber.round(this.view.width/n,0));if(g==true) this.factorY=this.view.height/f;else this.factorY=this.view.height/e;j=this.parent.head.rows[0].height*this.factorY;m=Math.floor(j);k=j-m;this.view.setHeight(this.view.height-Math.floor(h*k));this.view.setWidth (HpNumber.round(this.view.height*n,0));if(g==true) this.factorX=this.view.width/e;else this.factorX=this.view.width/f;k=0;j=0;for(i=0;i<this.head.rows[0].cells.length;i++){l=this.head.rows[0].cells[i];if(l.visible==false) continue;j=l.width*this.factorX;k=k+(j-HpNumber.round(j,0));}this.view.setWidth(this.view.width-Math.floor(k));this.view.setLeft (Math.floor(this.width/2)-(this.view.width/2));this.horizontalLine.setTop (this.view.top+this.view.height+2);this.horizontalLine.setLeft (this.view.left);this.horizontalLine.setWidth (this.view.width+4);this.horizontalLine.setHeight(0);this.verticalLine.setTop (this.view.top);this.verticalLine.setLeft (this.view.left+this.view.width+2);this.verticalLine.setWidth (0);this.verticalLine.setHeight(this.view.height+4);this.resizeSection(this.head,m);this.body.setTop(this.head.height);this.resizeSection(this.body,m);if(this.foot!=null){this.foot.setTop(this.body.top+this.body.height);this.resizeSection(this.foot,m);}}
this.resizeSection=function(a,b){var c=0;var d=0;var e=null;for(c=0;c<a.rows.length;c++){e=a.rows[c];e.setTop(d);e.setHeight(b);this.resizeRow(e);if(e.visible==true) d=d+e.height;}a.setWidth(e.width);a.setHeight(d);}
this.resizeRow=function(a){var b=0;var c=0;var d=null;for(b=0;b<a.zones.length;b++){d=a.zones[b];d.setLeft(c);this.resizeZone(d);c=c+d.width;}a.setWidth(c);}
this.resizeZone=function(a){var b=0;var c=0;var d=0;for(b=0;b<a.cells.length;b++){d=a.cells[b];d.setLeft (c);d.setWidth (HpNumber.round((this.parent.head.rows[0].zones[a.index].cells[b].width*this.factorX),0));d.setHeight(a.parent.height-1);if(d.visible==true) c=c+d.width;}a.setWidth(c);}
if(element==null)
return;
if(HpDom.containsClass(element,HpConstants.hide)==true)
{
HpDom.removeClass(element,HpConstants.hide);
visibleState=false;
}
HpDom.addClass(element,'preview');
HpDiv.call(this,parent,element);
temp=document.createElement('div');
this.element.appendChild(temp);
HpDom.addClass(temp,'view');
this.view=new HpDiv(this,temp);
temp=document.createElement('div');
this.element.appendChild(temp);
HpDom.addClass(temp,'horizontalLine');
this.horizontalLine=new HpDiv(this,temp);
temp=document.createElement('div');
this.element.appendChild(temp);
HpDom.addClass(temp,'verticalLine');
this.verticalLine=new HpDiv(this,temp);
temp=parent.head.element.cloneNode(true);
this.view.element.appendChild(temp);
this.head=new HpSection(this.view,0,temp);
this.clearSectionCells(this.head);
temp=parent.body.element.cloneNode(true);
this.view.element.appendChild(temp);
this.body=new HpSection(this.view,1,temp);
this.clearSectionCells(this.body);
if(parent.foot!=null)
{
temp=parent.foot.element.cloneNode(true);
this.view.element.appendChild(temp);
this.foot=new HpSection(this.view,2,temp);
this.clearSectionCells(this.foot);
}
this.prepare();
if(visibleState==false)
this.setVisible(false);
}
function HpGrid(element,form)
{
var i=0;
var temp=null;
var list=null;
this.element=element;/* html element */
this.form=form;/* form element for submitting */
temp=element.id.split(HpConstants.JSF);
this.id=temp[temp.length-1];/* grid id without JSF prefix */
this.edit=false;
this.horizontalScrollIndex=0;/* index of the zone which can be scrolled */
this.prints=new Array();
this.preview=null;
this.printPixelShort=657;
this.printPixelLong=987;
this.previewFactorX=0;
this.previewFactorY=0;
this.cell=null;/* current selected body cell */
this.head=null;
this.body=null;
this.foot=null;
this.control=null;/* contains buttons,pagetabcontrols,... */
this.config=null;/* configuration information (hided) */
this.focuser=null;
this.cursor=new HpCursor(this);
this.target=null;/* event target cell could be different to cell (head-clicking) */
this.matrix=null;/* last cell range */
this.verticalScroller=null;
this.horizontalScroller=null;
this.components=new HpPairList();
this.filler=new Array();/* used when vertical scroller is visible */
this.printRows=47;
this.printPortrait=true;
this.cellCursor=false;
this.columnCursor=false;
this.headHighlight=true;
this.onRenderCursor=null;
this.onResetCursor=null;
this.onStartEdit=null;
this.onStopEdit=null;
this.onMouseDown=null;
this.onMouseUp=null;
this.onRenderPrintCell=null;
this.top=parseInt(element.style.top);
this.left=parseInt(element.style.left);
this.width=parseInt(element.style.width);
this.height=parseInt(element.style.height);
this.maxWidth=0;
this.maxHeight=0;
this.addComponent=function(a,b){HpDom.addClass(b,HpConstants.hide);b.style.zIndex=800;this.element.appendChild(b);this.components.addNew(a,b);}
this.focus=function(){try{this.focuser.firstChild.focus();}catch(e){}}
this.setCell=function(a){var b=a.parent.parent.parent;if(b==this.body) this.cell=a;else if(b==this.head) this.cell=this.body.rows[0].cells[a.getTotalIndex()];else if((this.foot!=null)&&(b==this.foot)) this.cell=this.body.rows[0].cells[a.getTotalIndex()];HpDom.setText(this.horizontalScroller.button.element,(this.cell.parent.parent.index+1) +':'+ (this.cell.getTotalIndex()+1));}
this.setTop=function(a){this.top=a;this.element.style.top=a+'px';}
this.setLeft=function(a){this.left=a;this.element.style.left=a+'px';}
this.getTopHeight=function(){var a=0;if(this.head!=null) a=a+this.head.height;return a;}
this.getBottomHeight=function(){var a=0;if(this.foot!=null) a=a+this.foot.height;if(this.control!=null) a=a+this.control.height;return a;}
this.getBodyVisibleHeight=function(){return this.height-this.getTopHeight()-this.getBottomHeight();}
this.getBodyOverflowHeight=function(){return this.body.height-this.getBodyVisibleHeight();}
this.initSubmit=function(){var a=0;var b=null;var c=new Array();var d=this.element.getElementsByTagName('span');for(a=0;a<d.length;a++){if(d[a].id!=null){b=document.createElement('input');b.type='text';b.id=d[a].id;b.name=d[a].id;b.value=HpDom.getText(d[a]);HpDom.addClass(b,HpConstants.hide);if(this.form!=null) this.form.appendChild(b);c[c.length]=b;}}return c;}
this.determineSection=function(a){if(a==null) return null;if(a==this.body.element) return this.body;if(a==this.head.element) return this.head;if((this.foot!=null)&&(a==this.foot.element)) return this.foot;if(a==this.control.element) return this.control;return null;}
this.determineRow=function(a){var b=0;var c=null;c=this.determineSection(a.parentNode);for(b=0;b<c.rows.length;b++){if(c.rows[b].element==a) return c.rows[b];}return null;}
this.determineZone=function(a){var b=0;var c=null;c=this.determineRow(a.parentNode);for(b=0;b<c.zones.length;b++){if(c.zones[b].element==a) return c.zones[b];}return null;}
this.determineCell=function(a){var b=0;var c=null;c=this.determineZone(a.parentNode);for(b=0;b<c.cells.length;b++){if(c.cells[b].element==a) return c.cells[b];}return null;}
this.setCursor=function(a,b){this.cellCursor=a;this.columnCursor=b;if((a==true)||(b==true)) this.cursor.setVisible(true);else this.cursor.setVisible(false);this.renderCursor();}
this.renderCursor=function(){var a=null;if(this.preview.visible==true) return;if((this.columnCursor==true)&&(((this.target!=null)&&(this.target.parent.parent.parent==this.head))||(this.cellCursor==false))){this.cell.setSelect(true);this.cursor.setTop (0);this.cursor.setLeft (this.cell.parent.left+this.cell.left);this.cursor.setWidth (this.cell.width);this.cursor.setHeight(this.control.top);if(this.onRenderCursor!=null){a=this.onRenderCursor(this);if(a!=null) HpDom.addClass(a,HpConstants.select);}if((this.cell.parent.scroll==true)&&((this.cursor.left<this.horizontalScroller.positionStart)||((this.cursor.left+this.cursor.width)>this.horizontalScroller.positionStart+(this.head.rows[0].zones[this.horizontalScrollIndex].width-this.horizontalScroller.range)))) this.cursor.setVisible(false);else this.cursor.setVisible(true);}else if(this.cellCursor==true){this.cell.setSelect(true);this.cursor.setTop (this.body.top+this.cell.parent.parent.top-1);this.cursor.setLeft (this.cell.parent.left+this.cell.left);this.cursor.setWidth (this.cell.width);this.cursor.setHeight(this.cell.parent.parent.height+1);if(this.onRenderCursor!=null){a=this.onRenderCursor(this);if(a!=null) HpDom.addClass(a,HpConstants.select);}if((this.cursor.top<(this.body.top-1))||(this.cursor.top>this.getBodyVisibleHeight())) this.cursor.setVisible(false);else if((this.cell.parent.scroll==true)&&((this.cursor.left<this.horizontalScroller.positionStart)||((this.cursor.left+this.cursor.width)>this.horizontalScroller.positionStart+(this.head.rows[0].zones[this.horizontalScrollIndex].width-this.horizontalScroller.range)))) this.cursor.setVisible(false);else this.cursor.setVisible(true);}this.focus();}
this.resetCursor=function(){var a=null;this.cell.setSelect(false);if(this.onResetCursor!=null){a=this.onResetCursor(this);if(a!=null) HpDom.removeClass(a,HpConstants.select);}}
this.naviLeft=function(){var a=null;var b=this.cell.getTotalIndex()-1;var c=this.cell.parent.parent.index;for(;b>=0;b--){a=this.body.rows[c].cells[b];if(a.action==true) break;if(a.visible==false) continue;this.resetCursor();this.setCell(a);if((this.cell.parent.scroll==true)&&((this.cell.parent.left+this.cell.left)<this.horizontalScroller.positionStart)) HpGrid.scrollHorizontal(this,(this.cell.width*-1));else this.renderCursor();break;}}
this.naviUp=function(){var a=this.cell.getTotalIndex();var b=this.cell.parent.parent.index;if(b>0){this.resetCursor();this.setCell(this.body.rows[b-1].cells[a]);if(this.cell.parent.parent.top<0) HpGrid.scrollVertical(this,(this.cell.parent.parent.height*-1));else this.renderCursor();}}
this.naviRight=function(){var a=null;var b=this.cell.getTotalIndex()+1;var c=this.cell.parent.parent.index;for(;b<this.body.rows[c].cells.length;b++){a=this.body.rows[c].cells[b];if(a.action==true) break;if(a.visible==false) continue;this.resetCursor();this.setCell(a);if((this.cell.parent.scroll==true)&&((this.horizontalScroller.position+this.cell.left+this.cell.width)>(this.horizontalScroller.positionStart+(this.head.rows[0].zones[this.horizontalScrollIndex].width-this.horizontalScroller.range)))) HpGrid.scrollHorizontal(this,this.cell.width);else this.renderCursor();break;}}
this.naviDown=function(){var a=this.cell.getTotalIndex();var b=this.cell.parent.parent.index;if(b<this.body.rows.length-1){this.resetCursor();this.setCell(this.body.rows[b+1].cells[a]);if((this.cell.parent.parent.top+this.cell.parent.parent.height)>=(this.height-this.getBottomHeight())) HpGrid.scrollVertical(this,this.cell.parent.parent.height);else this.renderCursor();}}
this.resize=function(a,b){var c=0;var d=null;var e=null;var f=0;var g=0;var h=0;var i=0;var j=0;var k=0;var l=0;f=a;g=b;this.maxWidth=a;this.maxHeight=b;for(c=0;c<this.head.rows[0].zones.length;c++){e=this.head.rows[0].zones[c];h=h+e.width;if(e.scroll==true) this.horizontalScrollIndex=e.index;}if(h<f) f=h;d=this.getTopHeight()+this.body.height+this.getBottomHeight();if(g>d) g=d;this.height=g;this.element.style.height=g+'px';if(this.getBodyOverflowHeight()>0){this.verticalScroller.setVisible(true);if((f+this.verticalScroller.width+2)<=this.maxWidth) f=f+this.verticalScroller.width+2;l=f-this.verticalScroller.width-2;}else {this.verticalScroller.setVisible(false);l=f;}this.width=f;this.element.style.width=f+'px';this.resizeSection(this.head,l);this.resizeSection(this.body,l);if(this.foot!=null){this.foot.setTop (this.height-this.getBottomHeight());this.resizeSection(this.foot,l);}this.control.setTop(this.height-this.control.height);this.resizeSection(this.control,f);this.control.rows[0].zones[0].setWidth(f);this.control.rows[0].zones[0].cells[1].setLeft(f-this.control.rows[0].zones[0].cells[1].width);if(this.verticalScroller.visible==true){this.verticalScroller.setTop (this.getTopHeight());this.verticalScroller.setLeft (l);this.verticalScroller.setHeight (this.getBodyVisibleHeight()-2);this.verticalScroller.setPositions(0,this.getBodyOverflowHeight());for(c=0;c<this.filler.length;c++) this.element.removeChild(this.filler[c].element);this.filler.length=0;for(c=0;c<this.head.rows.length;c++){d=this.head.rows[c].element.cloneNode(false);this.element.appendChild(d);d=new HpDiv(this,d);this.filler[this.filler.length]=d;HpDom.addClass(d.element,'fillerHead');d.setTop (this.head.top+d.top);d.setLeft(this.verticalScroller.left);}if(this.foot!=null){for(c=0;c<this.foot.rows.length;c++){d=this.foot.rows[c].element.cloneNode(false);this.element.appendChild(d);d=new HpDiv(this,d);this.filler[this.filler.length]=d;HpDom.addClass(d.element,'fillerFoot');d.setTop (this.foot.top+d.top);d.setLeft(this.verticalScroller.left);}}}for(c=0;c<this.head.rows[0].zones.length;c++){e=this.head.rows[0].zones[c];if(e.scroll==true) j=e.width;else i=i+e.width;}k=j-(this.width-i);if(this.verticalScroller.visible==true) k=k+this.verticalScroller.width;if(k<=0){this.horizontalScroller.setVisible(false);}else {this.horizontalScroller.setVisible (true);this.horizontalScroller.setTop (this.control.top+1);this.horizontalScroller.setLeft (HpNumber.round(this.width/2,0)-HpNumber.round(this.horizontalScroller.width/2,0));}this.horizontalScroller.setPositions(this.head.rows[0].zones[this.horizontalScrollIndex].left,k);this.focuser.style.top=(this.control.top+this.control.height-1)+'px';HpGrid.scrollVertical (this,0);HpGrid.scrollHorizontal(this,0);this.resizePreview();}
this.resizeSection=function(a,b){var c=0;var d=null;var e=null;var f=null;a.setWidth(b);if(a.rows.length<=0) return;d=a.rows[0];if(d.zones.length==2){if(d.zones[0].scroll==true) e=b-d.zones[1].width;else if(d.zones[1].scroll==true) e=d.zones[0].width;}else if(d.zones.length==3){if(d.zones[0].scroll==true){e=b-d.zones[1].width-d.zones[2].width;f=b-d.zones[2].width;}else if(d.zones[1].scroll==true){e=d.zones[0].width;f=b-d.zones[2].width;}else if(d.zones[2].scroll==true){e=d.zones[0].width;f=d.zones[0].width+d.zones[1].width;}}for(c=0;c<a.rows.length;c++){d=a.rows[c];d.setWidth(b);if(d.zones.length==1) continue;d.zones[1].setLeft(e);if(d.zones.length==3) d.zones[2].setLeft(f);}}
this.resizePreview=function(){var a=0;a=this.head.rows.length+this.body.rows.length;if(this.foot!=null) a=a+this.foot.rows.length;if(a>this.printRows) a=this.printRows;this.preview.resize(this.body.top,this.body.left,this.width,this.control.top-this.body.top, this.printPixelShort,this.printPixelLong,this.printPortrait,a);}
this.render=function(a){this.renderSection(this.head,this.preview.head,a);this.renderSection(this.body,this.preview.body,a);if(this.foot!=null) this.renderSection(this.foot,this.preview.foot,a);}
this.renderSection=function(a,b,c){var d=0;for(d=0;d<a.rows.length;d++) this.renderRow(a.rows[d],b.rows[d],c);b.setWidth(b.rows[0].width);}
this.renderRow=function(a,b,c){var d=0;var e=0;var f=null;for(d=0;d<a.zones.length;d++){f=b.zones[d];f.setLeft(e);this.renderZone(a.zones[d],f,c);e=e+f.width;}b.setWidth(e);}
this.renderZone=function(a,b,c){var d=0;var e=0;var f=0;var g=null;var h=null;var i=false;for(d=0;d<a.cells.length;d++){g=a.cells[d];h=b.cells[d];g.setLeft(e);h.setLeft(f);i=this.head.rows[0].zones[a.index].cells[d].highlight;if(i==true){g.setVisible(c);h.setVisible(c);}if((c==true)||(i==false)){e=e+g.width;f=f+h.width;}}a.setWidth(e);b.setWidth(f);}
this.renderPrint=function(){var a=0;var b=0;var c=0;var d=0;var e=null;var f=null;var g=null;var h=null;var i=null;var j=null;var k=0;for(a=0;a<this.prints.length;a++) this.element.parentNode.removeChild(this.prints[a].element);this.prints.length=0;k=this.printRows-this.head.rows.length;if(this.foot!=null) k=k-this.foot.rows.length;for(a=0;a<this.body.rows.length;a=a+k){i=this.element.cloneNode(false);this.element.parentNode.insertBefore(i,this.element);j=new HpDiv(null,i);this.prints[this.prints.length]=j;if(a!=0) HpDom.addClass(j.element,HpConstants.pagebreakbefore);i=this.head.element.cloneNode(true);j.element.appendChild(i);f=new HpSection(j,0,i);this.renderPrintSection(f,0);c=0;i=this.body.element.cloneNode(false);j.element.appendChild(i);HpDom.removeClass(i,HpConstants.hide);g=new HpSection(j,1,i);for(b=a;(b<this.body.rows.length)&&(b<(a+k));b++){i=this.body.rows[b].element.cloneNode(true);g.element.appendChild(i);e=new HpRow(g,g.rows.length,i);d=this.renderPrintRow(e,c);c=c+e.height;}g.setTop (f.height);g.setWidth (f.width);g.setHeight(c);if(this.foot!=null){i=this.foot.element.cloneNode(true);j.element.appendChild(i);HpDom.removeClass(i,HpConstants.hide);h=new HpSection(j,2,i);this.renderPrintSection(h,g.top+g.height);}j.setWidth(g.width);if(this.foot==null) j.setHeight(g.top+g.height);else j.setHeight(h.top+h.height);HpDom.addClass(j.element,'print');}}
this.renderPrintSection=function(a,b){var c=0;var d=null;HpDom.removeClass(a.element,HpConstants.hide);for(c=0;c<a.rows.length;c++){d=a.rows[c];this.renderPrintRow(d,d.top);}a.setTop (b);a.setWidth(d.width);}
this.renderPrintRow=function(a,b){var c=0;var d=0;var e=null;for(c=0;c<a.zones.length;c++){e=a.zones[c];e.setLeft(d);this.renderPrintZone(e);d=d+e.width;}a.setTop (b);a.setWidth(d);}
this.renderPrintZone=function(a){var b=0;if(this.onRenderPrintCell==null) return;for(b=0;b<a.cells.length;b++) this.onRenderPrintCell(a.cells[b]);}
list=HpDom.listChild(this.element,'div',false);
for(i=0;i<list.length;i++)
{
if(HpDom.containsClass(list[i],'head'))
this.head=new HpSection(this,i,list[i]);
else if(HpDom.containsClass(list[i],'body'))
this.body=new HpSection(this,i,list[i]);
else if(HpDom.containsClass(list[i],'foot'))
this.foot=new HpSection(this,i,list[i]);
else if(HpDom.containsClass(list[i],'control'))
this.control=new HpSection(this,i,list[i]);
else if(HpDom.containsClass(list[i],'config'))
this.config=list[i];
}
this.maxWidth=HpNumber.parseInteger(HpDom.getText(HpDom.getElementsByClass(this.config,'maxWidth')[0]));
this.maxHeight=HpNumber.parseInteger(HpDom.getText(HpDom.getElementsByClass(this.config,'maxHeight')[0]));
temp=document.createElement('div');
this.element.appendChild(temp);
this.verticalScroller=new HpScroller(this,temp,true);
this.verticalScroller.setWidth(16);
this.verticalScroller.onMouseUp=HpGrid.onVerticalScrollerMouseUp;
this.verticalScroller.onButtonMouseStart=HpGrid.stopEdit;
this.verticalScroller.onButtonMouseMove=HpGrid.onVerticalScrollerButtonMouseMove;
this.verticalScroller.onButtonMouseStop=HpGrid.onVerticalScrollerButtonMouseStop;
temp=document.createElement('div');
this.element.appendChild(temp);
this.horizontalScroller=new HpScroller(this,temp,false);
this.horizontalScroller.setWidth (200);
this.horizontalScroller.setHeight(16);
this.horizontalScroller.onMouseUp=HpGrid.onHorizontalScrollerMouseUp;
this.horizontalScroller.onButtonMouseStart=HpGrid.stopEdit;
this.horizontalScroller.onButtonMouseMove=HpGrid.onHorizontalScrollerButtonMouseMove;
this.focuser=document.createElement('div');
this.focuser.id=this.element.id+'-focuser';
HpDom.addClass(this.focuser,'focuser');
this.focuser.style.left='0px';
this.focuser.style.width='1px';
this.focuser.style.height='1px';
this.element.appendChild(this.focuser);
temp=document.createElement('textarea');
temp.tabIndex=0;
this.focuser.appendChild(temp);
this.cursor.setVisible(false);
for(i=0;i<this.body.rows[0].cells.length;i++)
{
temp=this.body.rows[0].cells[i];
if(temp.action==false)
{
this.setCell(temp);
break;
}
}
HpGrid.calculatePrintRows(this);
temp=document.createElement('div');
this.element.appendChild(temp);
this.preview=new HpPreview(this,temp);
this.preview.setVisible(false);
temp=HpAction.registerRender(this.element,'keypress',HpGrid.renderKeyPress,this);
if(HpCore.browser=='EXPLORER')
HpAction.registerRender(this.element,'keydown',HpGrid.renderKeyArrow,this);
else
temp.addRender(HpGrid.renderKeyArrow);
HpAction.registerRender(this.body.element,'mousedown',HpGrid.renderMouseDown,this);
HpAction.registerRender(this.head.element,'mousedown',HpGrid.renderMouseDown,this);
HpAction.registerRender(this.body.element,'mouseup',HpGrid.renderMouseUp,this);
HpAction.registerRender(this.head.element,'mouseup',HpGrid.renderMouseUp,this);
HpAction.registerRender(HpDom.getElementsByClass(this.control.element,'listImage')[0],'click',HpGrid.renderListView,this);
HpAction.registerRender(HpDom.getElementsByClass(this.control.element,'printImage')[0],'click',HpGrid.renderPrintView,this);
HpAction.registerRender(HpDom.getElementsByClass(this.control.element,'printPortrait')[0],'click',HpGrid.renderPrintOrientation,this);
HpAction.registerRender(HpDom.getElementsByClass(this.control.element,'printLandscape')[0],'click',HpGrid.renderPrintOrientation,this);
HpAction.registerRender(HpDom.getElementsByClass(this.control.element,'printInput')[0],'keyup',HpGrid.renderPrintInput,this);
HpAction.registerRender(HpDom.getElementsByClass(this.control.element,'showCols')[0],'click',HpGrid.renderShowCols,this);
HpAction.registerRender(HpDom.getElementsByClass(this.control.element,'hideCols')[0],'click',HpGrid.renderHideCols,this);
this.resize(this.maxWidth,this.maxHeight);
this.renderCursor();
this.focus();
}
HpGrid.startEdit=function(a){var b=null;var c=null;var d=null;b=a.targets[0];if(b.edit==true) return;b.edit=true;if(b.onStartEdit==null) return null;d=b.onStartEdit(a);if(d==null) return null;b.cell.element.appendChild(d.key);HpDom.removeClass(d.key,HpConstants.hide);if(HpDom.isCheckBox(d.key)){c=HpDom.getText(d.value);if(c=='X') d.key.checked=true;else d.key.checked=false;}else {if(a.event.keyCode==13){c=HpDom.getText(d.value);if(c==null) HpDom.setText(d.key,'');else HpDom.setText(d.key,c);}else HpDom.setText(d.key,'');}HpDom.setText(d.value,'');d.key.focus();d.key.focus();return d.key;}
HpGrid.stopEdit=function(a){var b=null;var c=null;b=a.targets[0];b.focus();if(b.edit==false) return;b.edit=false;if(b.onStopEdit==null) return null;c=b.onStopEdit(a);if(c==null) return null;if(HpDom.isCheckBox(c.key)){if(c.key.checked==true) HpDom.setText(c.value,'X');else HpDom.setText(c.value,'');}else HpDom.setText(c.value,HpDom.getText(c.key));b.element.appendChild(c.key);HpDom.addClass(c.key,HpConstants.hide);}
HpGrid.determineCellNode=function(a){var b=a;while(b.parentNode!=null){if(HpDom.containsClass(b.parentNode,'zone')==true) return b;b=b.parentNode;}return null;}
HpGrid.renderMouseDown=function(a){var b=null;var c=null;var d=null;d=a.targets[0];b=HpGrid.determineCellNode(a.event.target);if(b==null) return;c=d.determineCell(b);if(c.action==true) return;HpGrid.stopEdit(a);d.resetCursor();d.target=c;d.setCell(c);d.renderCursor();if(d.onMouseDown!=null) d.onMouseDown(a);return true;}
HpGrid.renderMouseUp=function(a){var b=0;var c=0;var d=null;var e=null;var f=null;var g=null;var h=0;var i=0;var j=0;var k=0;e=a.targets[0];e.matrix=null;f=e.target;d=HpGrid.determineCellNode(a.event.target);e.target=e.determineCell(d);if((e.headHighlight==true)&&(f!=null)&&(f.parent.parent.parent==e.head)){e.matrix=new Array();g=(f.highlight==false);i=f.getTotalIndex();h=e.target.getTotalIndex();if(i>h){b=i;i=h;h=b;}k=f.parent.parent.index;j=e.target.parent.parent.index;if(k>j){b=k;k=j;j=b;}for(b=k;b<=j;b++){e.matrix[b-k]=new Array();for(c=i;c<=h;c++){e.matrix[b-k][c-i]=e.head.rows[b].cells[c];e.head.rows[b].cells[c].setHighlight(g);}}}if(e.onMouseUp!=null) e.onMouseUp(a);e.focus();return true;}
HpGrid.renderKeyPress=function(a){var b=null;var c=null;var d=null;var e=null;var f=null;d=a.targets[0];e=a.event.keyCode;if(a.event.target!=d.focuser.firstChild){b=HpGrid.determineCellNode(a.event.target);if(b!=null) c=d.determineCell(b);if((c!=null)&&(c.parent.parent.parent==d.control)) return;}if((e>=37)&&(e<=40)) return;if(e==9) return;if(e==13){if(d.edit==false) HpGrid.startEdit(a);else HpGrid.stopEdit(a);return;}if(d.edit==false){f=HpGrid.startEdit(a);if(f==null) return;if(HpDom.isCheckBox(f)==false){if(HpCore.browser=='FIREFOX') HpDom.setText(f,String.fromCharCode(a.event.charCode));else f.select();}}}
HpGrid.renderKeyArrow=function(a){var b=null;var c=null;var d=null;var e=null;d=a.targets[0];e=a.event.keyCode;if(a.event.target!=d.focuser.firstChild){b=HpGrid.determineCellNode(a.event.target);if(b!=null) c=d.determineCell(b);if((c!=null)&&(c.parent.parent.parent==d.control)) return;}if(e==37){HpGrid.stopEdit(a);d.naviLeft();return;}if(e==38){HpGrid.stopEdit(a);d.naviUp();return;}if(e==39){HpGrid.stopEdit(a);d.naviRight();return;}if(e==40){HpGrid.stopEdit(a);d.naviDown();return;}}
HpGrid.renderListView=function(a){var b=0;var c=null;var d=null;var e=null;var f=null;var g=null;var h=null;var i=null;c=a.targets[0];d=HpDom.getElementsByClass(c.control.element,'pageBack')[0];e=HpDom.getElementsByClass(c.control.element,'pageNext')[0];f=HpDom.getElementsByClass(c.control.element,'printImage')[0];g=HpDom.getElementsByClass(c.control.element,'printInput')[0];h=HpDom.getElementsByClass(c.control.element,'printPortrait')[0];i=HpDom.getElementsByClass(c.control.element,'printLandscape')[0];c.body.setVisible(true);if(c.foot!=null) c.foot.setVisible(true);c.cursor.setVisible(true);c.preview.setVisible(false);HpDom.removeClass(f,HpConstants.hide);if(d!=null) HpDom.removeClass(d,HpConstants.hide);if(e!=null) HpDom.removeClass(e,HpConstants.hide);HpDom.addClass(a.source,HpConstants.hide);HpDom.addClass(g,HpConstants.hide);HpDom.addClass(h,HpConstants.hide);HpDom.addClass(i,HpConstants.hide);for(b=0;b<c.prints.length;b++) c.element.parentNode.removeChild(c.prints[b].element);c.prints.length=0;c.focus();}
HpGrid.renderPrintView=function(a){var b=null;var c=null;var d=null;var e=null;var f=null;b=a.targets[0];c=HpDom.getElementsByClass(b.control.element,'pageBack')[0];d=HpDom.getElementsByClass(b.control.element,'pageNext')[0];e=HpDom.getElementsByClass(b.control.element,'listImage')[0];f=HpDom.getElementsByClass(b.control.element,'printInput')[0];HpGrid.stopEdit(a);b.renderPrint();b.body.setVisible(false);if(b.foot!=null) b.foot.setVisible(false);b.cursor.setVisible(false);b.preview.setVisible(true);HpDom.addClass(a.source,HpConstants.hide);if(c!=null) HpDom.addClass(c,HpConstants.hide);if(d!=null) HpDom.addClass(d,HpConstants.hide);HpDom.removeClass(e,HpConstants.hide);HpDom.removeClass(f,HpConstants.hide);HpGrid.renderPrintOrientationIcon(b);HpDom.setText(f,b.printRows);f.focus();}
HpGrid.renderPrintInput=function(a){var b=null;var c=null;var d=0;var e=null;if((HpUtil.isArrowKey(a.event)==true)||(a.event.keyCode==8)||(a.event.keyCode==46)) return;b=a.targets[0];d=b.head.rows.length+1;if(b.foot!=null) d=d+b.foot.rows.length;c=new HpInteger(true,false,null,null,d,null,null).execute(a.source,a.event,null);if(c.state==false) return;e=HpNumber.parseInteger(HpDom.getText(a.source));if(e!=b.printRows){b.printRows=e;b.preview.prepare();b.resizePreview();b.renderPrint();}}
HpGrid.renderPrintOrientation=function(a){var b=null;b=a.targets[0];if(b.printPortrait==true) b.printPortrait=false;else b.printPortrait=true;HpGrid.renderPrintOrientationIcon(b);b.resizePreview();b.renderPrint();}
HpGrid.renderPrintOrientationIcon=function(a){var b=null;var c=null;b=HpDom.getElementsByClass(a.control.element,'printPortrait')[0];c=HpDom.getElementsByClass(a.control.element,'printLandscape')[0];if(a.printPortrait==true){HpDom.removeClass(b,HpConstants.hide);HpDom.addClass (c,HpConstants.hide);}else {HpDom.addClass (b,HpConstants.hide);HpDom.removeClass(c,HpConstants.hide);}}
HpGrid.calculatePrintRows=function(a){if(a.printPortrait==true) a.printRows=Math.floor(a.printPixelLong/a.head.rows[0].height);else a.printRows=Math.floor(a.printPixelShort/a.head.rows[0].height);}
HpGrid.renderShowCols=function(a){var b=null;b=a.targets[0];b.render(true);b.resize(b.maxWidth,b.maxHeight);if(b.preview.visible==true) b.renderPrint();b.focus();}
HpGrid.renderHideCols=function(a){var b=0;var c=null;var d=null;var e=0;var f=0;d=a.targets[0];d.render(false);d.resetCursor();if(d.cell.visible==false){e=d.cell.parent.parent.index;f=d.cell.getTotalIndex();for(b=f+1;(c==null)&&(b<d.body.rows[e].cells.length);b++){if(d.body.rows[e].cells[b].visible==true) c=d.body.rows[e].cells[b];}for(b=f-1;(c==null)&&(b>=0);b--){if(d.body.rows[e].cells[b].visible==true) c=d.body.rows[e].cells[b];}if(c!=null) d.setCell(c);}d.renderCursor();d.resize(d.maxWidth,d.maxHeight);if(d.preview.visible==true) d.renderPrint();d.focus();}
HpGrid.onHorizontalScrollerMouseUp=function(a){HpGrid.stopEdit(a);HpGrid.scrollHorizontal(a.targets[0],a.targets[2]);}
HpGrid.onHorizontalScrollerButtonMouseMove=function(a){HpGrid.scrollHorizontal(a.targets[0],a.targets[2]*-1);}
HpGrid.scrollHorizontal=function(a,b){var c=0;var d=0;if(a.horizontalScroller.visible==false) return;d=a.horizontalScroller.scroll(b);for(c=0;c<a.head.rows.length;c++) a.head.rows[c].zones[a.horizontalScrollIndex].setLeft(d);for(c=0;c<a.body.rows.length;c++) a.body.rows[c].zones[a.horizontalScrollIndex].setLeft(d);if(a.foot!=null){for(c=0;c<a.foot.rows.length;c++) a.foot.rows[c].zones[a.horizontalScrollIndex].setLeft(d);}a.renderCursor();}
HpGrid.onVerticalScrollerMouseUp=function(a){var b=a.targets[2];b=b+HpGrid.calculateScrollDifference(b,a.targets[0].body.rows[0].height);HpGrid.stopEdit(a);HpGrid.scrollVertical(a.targets[0],b);}
HpGrid.onVerticalScrollerButtonMouseMove=function(a){HpGrid.scrollVertical(a.targets[0],a.targets[2]*-1);}
HpGrid.onVerticalScrollerButtonMouseStop=function(a){var b=0;var c=null;c=a.targets[0];b=c.body.rows[0].top%c.body.rows[0].height;b=HpGrid.calculateScrollDifference(b,c.body.rows[0].height);HpGrid.scrollVertical(c,b*-1);}
HpGrid.scrollVertical=function(a,b){var c=0;var d=0;var e=0;if(a.verticalScroller.visible==false) return;e=a.verticalScroller.scroll(b);d=a.body.rows[0].height;for(c=0;c<a.body.rows.length;c++) a.body.rows[c].setTop((c*d)+e);a.renderCursor();}
HpGrid.calculateScrollDifference=function(a,b){var c=0;c=Math.abs(a)%b;if(c>=HpNumber.round((b/2),0)){if(a>=0) return Math.abs(b-c);else return Math.abs(b-c)*-1;}else {if(a>=0) return c*-1;else return c;}}
HpAttribute.TAG_ATTRIBUTE='Attribute';
HpAttribute.TAG_ID='Id';
HpAttribute.TAG_NAME='Name';
HpAttribute.TAG_VALUE='Value';
function HpAttribute(element,name,value)
{
this.element=element;
this.name=name;
this.value=value;
}
HpAttribute.create=function(a){var b=new HpAttribute(null,null,null);b.element=document.getElementById(HpDom.getText(HpDom.getChild(a,HpAttribute.TAG_ID)));b.name=HpDom.getText(HpDom.getChild(a,HpAttribute.TAG_NAME));b.value=HpDom.getText(HpDom.getChild(a,HpAttribute.TAG_VALUE));return b;}
function HpAttributeList()
{
var list=new Array();
this.size=function(){return list.length;}
this.item=function(a){return list[a];}
this.get=function(a,b){var c=0;for(c=0;c<list.length;c++){if((list[c].element==a)&&(list[c].name==b)) return list[c].value;}return null;}
this.getItem=function(a,b){var c=0;for(c=0;c<list.length;c++){if((list[c].element==a)&&(list[c].name==b)) return list[c];}return null;}
this.indexOf=function(a,b){var c=0;for(c=0;c<list.length;c++){if((list[c].element==a)&&(list[c].name==b)) return c;}return -1;}
this.contains=function(a,b){if(this.indexOf(a,b)>=0) return true;else return false;}
this.add=function(a){if(a instanceof HpAttribute) list[list.length]=a;else throw 'No instance of HpAttribute!';}
this.addNew=function(a,b,c){var d=new HpAttribute(a,b,c);list[list.length]=d;return d;}
this.addList=function(a){for(i=0;i<a.size();i++) this.add(a.item(i));}
this.put=function(a,b,c){var d=this.getItem(a,b);if(d==null) return this.addNew(a,b,c);d.element=a;d.name=b;d.value=c;return d;}
this.remove=function(a){var b=0;var c=null;for(b=0;b<list.length;b++){if(c!=null) list[b-1]=list[b];if((c==null)&&(b==a)) c=list[b];}if(c!=null) list.length=list.length-1;return c;}
this.clear=function(){list.length=0;}
this.filter=function(a,b){var c=0;var d=new HpAttributeList();for(c=0;c<list.length;c++){if((a!=null)&&(a!=list[c].element)) continue;if((b!=null)&&(b!=list[c].name)) continue;d.add(list[c]);}return d;}
this.formatFallBack=function(a,b,c){var d=0;var e='';var f='';for(d=0;d<list.length;d++){if((a==null)&&(list[d].element!=null)) continue;if((a!=null)&&(list[d].element!=null)&&(a!=list[d].element)) continue;if((b!=null)&&(list[d].name!=null)&&(b!=list[d].name)) continue;if(list[d].element==null){if(e.length<=0) e=list[d].value;else e=e +c+ list[d].value;}else {if(f.length<=0) f=list[d].value;else f=f +c+ list[d].value;}}if(f.length>0) return f;else return e;}
}
HpAttributeList.create=function(a){var b=0;var c=null;var d=new HpAttributeList();c=HpDom.listChild(a,HpAttribute.TAG_ATTRIBUTE,false);for(b=0;b<c.length;b++) d.add(HpAttribute.create(c[b]));return d;}
function HpPair(key,value)
{
this.key=key;
this.value=value;
this.format=function(a){if((this.key==null)&&(this.value==null)) return '';if(this.key==null) return a+this.value;if(this.value==null) return this.key+a;return this.key+a+this.value;}
}
HpPair.parse=function(a,b,c,d){var e=0;var f=null;if((a==null)||(a.length<=0)) return null;e=a.indexOf(b);if(e==0) return null;else if(e<0) f=new HpPair(a,null);else if(e==a.length-1) f=new HpPair(a.substring(0,e),null);else f=new HpPair(a.substring(0,e),a.substring(e+1,a.length));if(c==true){f.key=HpUtil.trim(f.key);if(f.value!=null) f.value=HpUtil.trim(f.value);if((f.key==null)||(f.key.length<=0)) return null;if((f.value!=null)&&(f.value.length<=0)) f.value=null;}if(d==true){f.key=f.key.toLowerCase();if(f.value!=null) f.value=f.value.toLowerCase();}return f;}
function HpPairList()
{
var list=new Array();
this.size=function(){return list.length;}
this.item=function(a){return list[a];}
this.get=function(a){var b=0;for(b=0;b<list.length;b++){if(list[b].key==a) return list[b].value;}return null;}
this.getItem=function(a){var b=0;for(b=0;b<list.length;b++){if(list[b].key==a) return list[b];}return null;}
this.indexOf=function(a){var b=0;for(b=0;b<list.length;b++){if(list[b].key==a) return b;}return -1;}
this.containsKey=function(a){if(this.indexOf(a)>=0) return true;else return false;}
this.add=function(a){if(a instanceof HpPair) list[list.length]=a;else throw 'No instance of HpPair!';}
this.addNew=function(a,b){var c=new HpPair(a,b);list[list.length]=c;return c;}
this.put=function(a,b){var c=this.getItem(a);if(c==null) return this.addNew(a,b);c.key=a;c.value=b;return c;}
this.remove=function(a){var b=0;var c=null;for(b=0;b<list.length;b++){if(c!=null) list[b-1]=list[b];if((c==null)&&(list[b].key==a)) c=list[b];}if(c!=null) list.length=list.length-1;return c;}
this.clear=function(){list.length=0;}
this.format=function(a,b){var c='';for(i=0;i<list.length;i++){c=c+list[i].format(b);if(i<list.length-1) c=c+a;}return c;}
}
function HpUrl()
{
this.address=null;
this.params=new HpPairList();
this.format=function(){if((this.address==null)&&(this.params.size()<=0)) return '';if(this.address==null) return HpUrl.formatParams(this.params);if(this.params.size()<=0) return HpUrl.formatAddress(this.address);return HpUrl.formatAddress(this.address)+'?'+HpUrl.formatParams(this.params);}
}
HpUrl.formatAddress=function(a){if((a==null)||(a.length<=0)) return '';else return encodeURI(a);}
HpUrl.formatParams=function(a){var b=0;var c='';var d=null;for(b=0;b<a.size();b++){d=a.item(b);c=c+encodeURIComponent(d.key) +'='+ encodeURIComponent(d.value);if(b<a.size()-1) c=c+'&';}return c;}
HpUrl.parse=function(a){var b=0;var c=new HpUrl();if((a==null)||(a.length<=0)||(a=='?')) return c;b=a.indexOf('?');if(b<0) c.address=decodeURI(a);else if(b==a.length-1) c.address=decodeURI(a.substring(0,b));else if(b>0){c.address=decodeURI(a.substring(0,b));c.params=HpUrl.parseParams(a.substring(b+1,a.length));}else c.params=HpUrl.parseParams(a.substring(1,a.length));return c;}
HpUrl.parseParams=function(a){var b=0;var c=null;var d=new HpPairList();if((a==null)||(a.length<=0)) return d;c=a.split('&');for(b=0;b<c.length;b++){pair=HpPair.parse(decodeURIComponent(c[b]),'=',false,false);if(pair!=null) d.add(pair);}return d;}
function HpCurrency(required,format,minLength,maxLength,minimum,maximum,step)
{
this.required=required;
this.format=format;
this.minLength=minLength;
this.maxLength=maxLength;
this.minimum=minimum;
this.maximum=maximum;
this.step=step;
this.execute=function(a,b,c){var d=new HpAction(a,b);d.addInit (HpCurrency.init);d.addRender(HpCurrency.render);d.controls.put(HpConstants.config,this);if(c==null) d.addTarget(a);else d.addTarget(c);HpCurrency.config(d);d.execute();return d;}
}
HpCurrency.executeKeyUp=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpCurrency.init);e.addRender(HpCurrency.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpCurrency.config(e);d.format=false;d.minLength=null;d.minimum=null;d.step=null;e.execute();return e;}
HpCurrency.executeBlur=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpCurrency.init);e.addRender(HpCurrency.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpCurrency.config(e);e.execute();return e;}
HpCurrency.register=function(a,b,c,d,e){var f=null;var g=new HpPairList();if(b==null) b=HpCurrency.init;if(d==null) d=HpCurrency.render;if(e==null) e=a;f=HpAction.registerAll(a,'keyup',b,c,d,e);config=HpCurrency.config(f);config.format=false;config.minLength=null;config.minimum=null;config.step=null;g.addNew(f.type,f);f=HpAction.registerAll(a,'blur',b,c,d,e);config=HpCurrency.config(f);g.addNew(f.type,f);return g;}
HpCurrency.config=function(a){var b=null;var c=null;if(a.controls.containsKey(HpConstants.config)==false){c=new HpCurrency();c.required=HpDom.containsClass(a.source,HpConstants.required);c.format=(HpDom.containsClass(a.source,HpConstants.plain)==false);b=HpDom.searchClass(a.source,HpConstants.minlength);if(b!=null) c.minLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maxlength);if(b!=null) c.maxLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.minimum);if(b!=null) c.minimum=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maximum);if(b!=null) c.maximum=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.step);if(b!=null) c.step=HpNumber.extract(b);a.controls.put(HpConstants.config,c);}a.styles.addNew(null,HpConstants.error,HpConstants.error);a.styles.addNew(null,HpConstants.success,HpConstants.success);return c;}
HpCurrency.init=function(a){var b=null;var c=null;if(a.state==false) return;b=HpDom.getText(a.source);config=a.controls.get(HpConstants.config);if(b.length<=0){if(config.required==true){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.errorRequired);}return;}a.state=HpNumber.checkCurrency(b);if(a.state==false){a.messages.addNew(null,HpConstants.error,HpResource.errorCurrency);return;}HpInit.initLength(a,b,config.minLength,config.maxLength);if(a.state==false) return;HpInit.initRange(a,HpNumber.parseCurrency(b),config.minimum,config.maximum,config.step);if(a.state==false) return;}
HpCurrency.render=function(a){var b=0;var c=null;var d=null;var e=null;if(HpUtil.isNaviKey(a.event)==true) return true;c=HpDom.getText(a.source);d=a.controls.get(HpConstants.config);if((a.state==true)&&(d.format==true)&&(c.length>0)) e=HpNumber.formatCurrency(HpNumber.parseCurrency(c));else e=c;for(b=0;b<a.targets.length;b++){HpRender.renderInit(a.targets[b],a.styles);HpRender.renderText(a.targets[b],e,false);HpRender.renderState(a.targets[b],a.state,a.styles);HpRender.messageRender(a);}return true;}
function HpDecimal(required,format,minLength,maxLength,minimum,maximum,step)
{
this.required=required;
this.format=format;
this.minLength=minLength;
this.maxLength=maxLength;
this.minimum=minimum;
this.maximum=maximum;
this.step=step;
this.execute=function(a,b,c){var d=new HpAction(a,b);d.addInit (HpDecimal.init);d.addRender(HpDecimal.render);d.controls.put(HpConstants.config,this);if(c==null) d.addTarget(a);else d.addTarget(c);HpDecimal.config(d);d.execute();return d;}
}
HpDecimal.executeKeyUp=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpDecimal.init);e.addRender(HpDecimal.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpDecimal.config(e);d.format=false;d.minLength=null;d.minimum=null;d.step=null;e.execute();return e;}
HpDecimal.executeBlur=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpDecimal.init);e.addRender(HpDecimal.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpDecimal.config(e);e.execute();return e;}
HpDecimal.register=function(a,b,c,d,e){var f=null;var g=new HpPairList();if(b==null) b=HpDecimal.init;if(d==null) d=HpDecimal.render;if(e==null) e=a;f=HpAction.registerAll(a,'keyup',b,c,d,e);config=HpDecimal.config(f);config.format=false;config.minLength=null;config.minimum=null;config.step=null;g.addNew(f.type,f);f=HpAction.registerAll(a,'blur',b,c,d,e);config=HpDecimal.config(f);g.addNew(f.type,f);return g;}
HpDecimal.config=function(a){var b=null;var c=null;if(a.controls.containsKey(HpConstants.config)==false){c=new HpDecimal();c.required=HpDom.containsClass(a.source,HpConstants.required);c.format=(HpDom.containsClass(a.source,HpConstants.plain)==false);b=HpDom.searchClass(a.source,HpConstants.minlength);if(b!=null) c.minLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maxlength);if(b!=null) c.maxLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.minimum);if(b!=null) c.minimum=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maximum);if(b!=null) c.maximum=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.step);if(b!=null) c.step=HpNumber.extract(b);a.controls.put(HpConstants.config,c);}a.styles.addNew(null,HpConstants.error,HpConstants.error);a.styles.addNew(null,HpConstants.success,HpConstants.success);return c;}
HpDecimal.init=function(a){var b=null;var c=null;if(a.state==false) return;b=HpDom.getText(a.source);config=a.controls.get(HpConstants.config);if(b.length<=0){if(config.required==true){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.errorRequired);}return;}a.state=HpNumber.checkDecimal(b);if(a.state==false){a.messages.addNew(null,HpConstants.error,HpResource.errorDecimal);return;}HpInit.initLength(a,b,config.minLength,config.maxLength);if(a.state==false) return;HpInit.initRange(a,HpNumber.parseDecimal(b),config.minimum,config.maximum,config.step);if(a.state==false) return;}
HpDecimal.render=function(a){var b=0;var c=null;var d=null;var e=null;if(HpUtil.isNaviKey(a.event)==true) return true;c=HpDom.getText(a.source);d=a.controls.get(HpConstants.config);if((a.state==true)&&(d.format==true)&&(c.length>0)) e=HpNumber.formatDecimal(HpNumber.parseDecimal(c));else e=c;for(b=0;b<a.targets.length;b++){HpRender.renderInit(a.targets[b],a.styles);HpRender.renderText(a.targets[b],e,false);HpRender.renderState(a.targets[b],a.state,a.styles);HpRender.messageRender(a);}return true;}
function HpEntry(){}
HpEntry.wrapper='div';
HpEntry.renderText=function(a,b,c,d,e){var f=null;var g=null;if(b==null) return null;if(c<0){if(d==null) g=document.createElement(HpEntry.wrapper);else g=document.createElement(d);g.appendChild(document.createTextNode(b));HpDom.setAttribute(g,'class','');if((e!=null)&&(e!=true)&&(e!=false)) HpDom.setAttribute(g,'id',e);a.appendChild(g);return g;}f=HpDom.listChild(a,null,false);if(d==null) d=f[c].nodeName;g=document.createElement(d);g.appendChild(document.createTextNode(b));HpDom.setAttribute(g,'class','');if((e!=null)&&(e!=false)){if(e==true) HpDom.setAttribute(g,'id',f[c].id);else HpDom.setAttribute(g,'id',e);}a.replaceChild(g,f[c]);return g;}
function HpInteger(required,format,minLength,maxLength,minimum,maximum,step)
{
this.required=required;
this.format=format;
this.minLength=minLength;
this.maxLength=maxLength;
this.minimum=minimum;
this.maximum=maximum;
this.step=step;
this.execute=function(a,b,c){var d=new HpAction(a,b);d.addInit (HpInteger.init);d.addRender(HpInteger.render);d.controls.put(HpConstants.config,this);if(c==null) d.addTarget(a);else d.addTarget(c);HpInteger.config(d);d.execute();return d;}
}
HpInteger.executeKeyUp=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpInteger.init);e.addRender(HpInteger.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpInteger.config(e);d.format=false;d.minLength=null;d.minimum=null;d.step=null;e.execute();return e;}
HpInteger.executeBlur=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpInteger.init);e.addRender(HpInteger.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpInteger.config(e);e.execute();return e;}
HpInteger.register=function(a,b,c,d,e){var f=null;var g=new HpPairList();if(b==null) b=HpInteger.init;if(d==null) d=HpInteger.render;if(e==null) e=a;f=HpAction.registerAll(a,'keyup',b,c,d,e);config=HpInteger.config(f);config.format=false;config.minLength=null;config.minimum=null;config.step=null;g.addNew(f.type,f);f=HpAction.registerAll(a,'blur',b,c,d,e);config=HpInteger.config(f);g.addNew(f.type,f);return g;}
HpInteger.config=function(a){var b=null;var c=null;if(a.controls.containsKey(HpConstants.config)==false){c=new HpInteger();c.required=HpDom.containsClass(a.source,HpConstants.required);c.format=(HpDom.containsClass(a.source,HpConstants.plain)==false);b=HpDom.searchClass(a.source,HpConstants.minlength);if(b!=null) c.minLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maxlength);if(b!=null) c.maxLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.minimum);if(b!=null) c.minimum=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maximum);if(b!=null) c.maximum=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.step);if(b!=null) c.step=HpNumber.extract(b);a.controls.put(HpConstants.config,c);}a.styles.addNew(null,HpConstants.error,HpConstants.error);a.styles.addNew(null,HpConstants.success,HpConstants.success);return c;}
HpInteger.init=function(a){var b=null;var c=null;if(a.state==false) return;b=HpDom.getText(a.source);config=a.controls.get(HpConstants.config);if(b.length<=0){if(config.required==true){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.errorRequired);}return;}a.state=HpNumber.checkInteger(b);if(a.state==false){a.messages.addNew(null,HpConstants.error,HpResource.errorInteger);return;}HpInit.initLength(a,b,config.minLength,config.maxLength);if(a.state==false) return;HpInit.initRange(a,HpNumber.parseInteger(b),config.minimum,config.maximum,config.step);if(a.state==false) return;}
HpInteger.render=function(a){var b=0;var c=null;var d=null;var e=null;if(HpUtil.isNaviKey(a.event)==true) return true;c=HpDom.getText(a.source);d=a.controls.get(HpConstants.config);if((a.state==true)&&(d.format==true)&&(c.length>0)) e=HpNumber.formatInteger(HpNumber.parseInteger(c));else e=c;for(b=0;b<a.targets.length;b++){HpRender.renderInit(a.targets[b],a.styles);HpRender.renderText(a.targets[b],e,false);HpRender.renderState(a.targets[b],a.state,a.styles);HpRender.messageRender(a);}return true;}
function HpLocale(){}
HpLocale.register=function(a,b,c,d,e){var f=null;var g=new HpPairList();if(d==null) d=HpLocale.render;f=HpAction.registerAll(a,'click',b,c,d,e);g.addNew('click',f);HpLocale.config(f);return g;}
HpLocale.config=function(a){a.targets=null;}
HpLocale.render=function(a){var b=0;var c=0;var d=null;var e=null;for(b=0;b<HpCore.locales.length;b++){if(HpDom.containsClass(a.source,HpCore.locales[b])==true) e=HpCore.locales[b];}for(b=0;b<HpCore.locales.length;b++){if(a.targets==null) d=HpDom.getElementsByClass(document,HpCore.locales[b]);else d=a.targets;for(c=0;c<d.length;c++){if(HpDom.containsClass(d[c],HpConstants.localizer)==true) continue;if(HpCore.locales[b]==e) HpDom.removeClasses(d[c],HpConstants.localize);else HpDom.addClasses(d[c],HpConstants.localize);}}return true;}
function HpRate(required,format,minLength,maxLength,minimum,maximum,step)
{
this.required=required;
this.format=format;
this.minLength=minLength;
this.maxLength=maxLength;
this.minimum=minimum;
this.maximum=maximum;
this.step=step;
this.execute=function(a,b,c){var d=new HpAction(a,b);d.addInit (HpRate.init);d.addRender(HpRate.render);d.controls.put(HpConstants.config,this);if(c==null) d.addTarget(a);else d.addTarget(c);HpRate.config(d);d.execute();return d;}
}
HpRate.executeKeyUp=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpRate.init);e.addRender(HpRate.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpRate.config(e);d.format=false;d.minLength=null;d.minimum=null;d.step=null;e.execute();return e;}
HpRate.executeBlur=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpRate.init);e.addRender(HpRate.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpRate.config(e);e.execute();return e;}
HpRate.register=function(a,b,c,d,e){var f=null;var g=new HpPairList();if(b==null) b=HpRate.init;if(d==null) d=HpRate.render;if(e==null) e=a;f=HpAction.registerAll(a,'keyup',b,c,d,e);config=HpRate.config(f);config.format=false;config.minLength=null;config.minimum=null;config.step=null;g.addNew(f.type,f);f=HpAction.registerAll(a,'blur',b,c,d,e);config=HpRate.config(f);g.addNew(f.type,f);return g;}
HpRate.config=function(a){var b=null;var c=null;if(a.controls.containsKey(HpConstants.config)==false){c=new HpRate();c.required=HpDom.containsClass(a.source,HpConstants.required);c.format=(HpDom.containsClass(a.source,HpConstants.plain)==false);b=HpDom.searchClass(a.source,HpConstants.minlength);if(b!=null) c.minLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maxlength);if(b!=null) c.maxLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.minimum);if(b!=null) c.minimum=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maximum);if(b!=null) c.maximum=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.step);if(b!=null) c.step=HpNumber.extract(b);a.controls.put(HpConstants.config,c);}a.styles.addNew(null,HpConstants.error,HpConstants.error);a.styles.addNew(null,HpConstants.success,HpConstants.success);return c;}
HpRate.init=function(a){var b=null;var c=null;if(a.state==false) return;b=HpDom.getText(a.source);config=a.controls.get(HpConstants.config);if(b.length<=0){if(config.required==true){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.errorRequired);}return;}a.state=HpNumber.checkRate(b);if(a.state==false){a.messages.addNew(null,HpConstants.error,HpResource.errorRate);return;}HpInit.initLength(a,b,config.minLength,config.maxLength);if(a.state==false) return;HpInit.initRange(a,HpNumber.parseRate(b),config.minimum,config.maximum,config.step);if(a.state==false) return;}
HpRate.render=function(a){var b=0;var c=null;var d=null;var e=null;if(HpUtil.isNaviKey(a.event)==true) return true;c=HpDom.getText(a.source);d=a.controls.get(HpConstants.config);if((a.state==true)&&(d.format==true)&&(c.length>0)) e=HpNumber.formatRate(HpNumber.parseRate(c));else e=c;for(b=0;b<a.targets.length;b++){HpRender.renderInit(a.targets[b],a.styles);HpRender.renderText(a.targets[b],e,false);HpRender.renderState(a.targets[b],a.state,a.styles);HpRender.messageRender(a);}return true;}
function HpText(required,trim,minLength,maxLength)
{
this.required=required;
this.trim=trim;
this.minLength=minLength;
this.maxLength=maxLength;
this.execute=function(a,b,c){var d=new HpAction(a,b);d.addInit (HpText.init);d.addRender(HpText.render);d.controls.put(HpConstants.config,this);if(c==null) d.addTarget(a);else d.addTarget(c);HpText.config(d);d.execute();return d;}
}
HpText.executeKeyUp=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpText.init);e.addRender(HpText.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpText.config(e);d.trim=false;d.minLength=null;e.execute();return e;}
HpText.executeBlur=function(a,b,c){var d=null;var e=new HpAction(a,b);e.addInit (HpText.init);e.addRender(HpText.render);if(c==null) e.addTarget(a);else e.addTarget(c);d=HpText.config(e);e.execute();return e;}
HpText.register=function(a,b,c,d,e){var f=null;var g=new HpPairList();if(b==null) b=HpText.init;if(d==null) d=HpText.render;if(e==null) e=a;f=HpAction.registerAll(a,'keyup',b,c,d,e);config=HpText.config(f);config.trim=false;config.minLength=null;g.addNew(f.type,f);f=HpAction.registerAll(a,'blur',b,c,d,e);config=HpText.config(f);g.addNew(f.type,f);return g;}
HpText.config=function(a){var b=null;var c=null;if(a.controls.containsKey(HpConstants.config)==false){c=new HpText();c.required=HpDom.containsClass(a.source,HpConstants.required);c.trim=(HpDom.containsClass(a.source,HpConstants.notrim)==false);b=HpDom.searchClass(a.source,HpConstants.minlength);if(b!=null) c.minLength=HpNumber.extract(b);b=HpDom.searchClass(a.source,HpConstants.maxlength);if(b!=null) c.maxLength=HpNumber.extract(b);a.controls.put(HpConstants.config,c);}a.styles.addNew(null,HpConstants.error,HpConstants.error);a.styles.addNew(null,HpConstants.success,HpConstants.success);return c;}
HpText.init=function(a){var b=null;if(a.state==false) return;b=HpDom.getText(a.source);config=a.controls.get(HpConstants.config);if(b.length<=0){if(config.required==true){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.errorRequired);}return;}if((config.trim==true)&&((b.charAt(0)==' ')||(b.charAt(b.length-1)==' '))){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.errorTrim);return;}HpInit.initLength(a,b,config.minLength,config.maxLength);if(a.state==false) return;}
HpText.render=function(a){var b=0;var c=null;if(HpUtil.isNaviKey(a.event)==true) return true;for(b=0;b<a.targets.length;b++){HpRender.renderInit(a.targets[b],a.styles);HpRender.renderState(a.targets[b],a.state,a.styles);HpRender.messageRender(a);}return true;}
function HpAction(source,event)
{
this.source=null;
this.type=null;
this.init=new Array();
this.action=new Array();
this.render=new Array();
this.targets=new Array();
this.controls=new HpPairList();
this.styles=new HpAttributeList();
this.messages=new HpAttributeList();
this.state=true;
this.event=null;
this.ajax=null;
this.source=source;
if(event!=null)
{
this.type=event.type;
this.event=new HpEvent(event);
}
this.addInit=function(a){this.init[this.init.length]=a;}
this.addAction=function(a){this.action[this.action.length]=a;}
this.addRender=function(a){this.render[this.render.length]=a;}
this.addTarget=function(a){this.targets[this.targets.length]=a;}
this.setAJAX=function(a){this.ajax=new HpAJAX(this,a);}
this.execute=function(){var a=0;this.messages.clear();this.state=true;for(a=0;a<this.init.length;a++) this.init[a](this);for(a=0;a<this.action.length;a++) this.action[a](this);if(this.ajax==null){for(a=0;a<this.render.length;a++) this.render[a](this);}return this.state;}
}
HpAction.get=function(a,b){var c=HpAction.indexOf(a,b);if(c>=0) return HpCore.actions[c];else return null;}
HpAction.indexOf=function(a,b){var c=0;for(c=0;c<HpCore.actions.length;c++){if((HpCore.actions[c].source==a)&&(HpCore.actions[c].type==b)) return c;}return -1;}
HpAction.execute=function(a){var b=-1;var c=new HpEvent(a);var d=c.target;while((d!=null)&&(b<0)){b=HpAction.indexOf(d,c.type);d=d.parentNode;}if(b<0) return false;HpCore.actions[b].event=c;return HpCore.actions[b].execute();}
HpAction.register=function(a){HpCore.actions[HpCore.actions.length]=a;HpEvent.addEvent(a.source,a.type,HpAction.execute,false);}
HpAction.registerAll=function(a,b,c,d,e,f){var g=new HpAction();g.source=a;g.type=b;if(c!=null){if(c instanceof Array) g.init=c;else g.init[0]=c;}if(d!=null){if(d instanceof Array) g.action=d;else g.action[0]=d;}if(e!=null){if(e instanceof Array) g.render=e;else g.render[0]=e;}if(f!=null){if(f instanceof Array) g.targets=f;else g.targets[0]=f;}HpAction.register(g);return g;}
HpAction.registerRender=function(a,b,c,d){return HpAction.registerAll(a,b,null,null,c,d) }
HpAction.registerAutomatic=function(a,b){var c=0;var d=null;var e=null;a[a.length]=b;if(b.nodeType==1){if(HpDom.isInput(b)==true){if(HpDom.containsClass(b,HpConstants.integer)==true) e=HpInteger.register(b);else if(HpDom.containsClass(b,HpConstants.decimal)==true) e=HpDecimal.register(b);else if(HpDom.containsClass(b,HpConstants.currency)==true) e=HpCurrency.register(b);else if(HpDom.containsClass(b,HpConstants.rate)==true) e=HpRate.register(b);else e=HpText.register(b);}else if(HpDom.isTextArea(b)==true) e=HpText.register(b);else if(HpDom.containsClass(b,HpConstants.localizer)==true) e=HpLocale.register(b);if(e==null) e=new HpPairList();for(c=0;c<HpCore.initStartElement.length;c++) HpCore.initStartElement[c](a,b,e);}for(c=0;c<b.childNodes.length;c++) HpAction.registerAutomatic(a,b.childNodes[c]);if(b.nodeType==1){for(c=0;c<HpCore.initEndElement.length;c++) HpCore.initEndElement[c](a,b,e);}a[a.length-1]=null;a.length=a.length-1;}
HpAJAX.TAG_MESSAGES='Messages';
HpAJAX.TAG_SERVICE_STATE='ServiceState';
HpAJAX.ACTIVEX=['MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
function HpAJAX(action,url)
{
this.action=action;
this.url=HpUrl.parse(url);
this.data=new HpPairList();
this.request=null;
this.response=null;
this.sendGet=function(){HpAJAX.send(this.action,this.url,null);}
this.sendPost=function(){HpAJAX.send(this.action,this.url,this.data);}
}
HpAJAX.send=function(a,b,c){var d=0;try{a.state=false;a.ajax.response=null;a.ajax.request=HpAJAX.createXMLHttpRequest();b.params.put('de.hp.ajax',(new Date()).getTime());if(c==null){a.ajax.request.open('GET',b.format(),true);a.ajax.request.onreadystatechange=process;a.ajax.request.send(null);}else {a.ajax.request.open('POST',b.format(),true);a.ajax.request.onreadystatechange=process;a.ajax.request.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8');a.ajax.request.send(HpUrl.formatParams(c));}}catch(e){a.messages.addNew(null,HpConstants.error,'[Send] ' +HpResource.errorAJAX);for(d=0;d<a.render.length;d++){a.render[d](a);}}function process(){if(a.ajax.request.readyState==4){try{if(a.ajax.request.status==200) HpAJAX.response(a);else throw '[Status] '+HpResource.errorAJAX;}catch(e){a.messages.addNew(null,HpConstants.error,'[Process] '+HpResource.errorAJAX);}finally {for(d=0;d<a.render.length;d++){a.render[d](a);}}}}}
HpAJAX.createXMLHttpRequest=function(){var a=0;var b=null;try{b=new XMLHttpRequest();}catch(e){}if(b!=null) return b;for(a=0;a<HpAJAX.ACTIVEX.length;a++){try{b=new ActiveXObject(HpAJAX.ACTIVEX[a]);}catch(e){}if(b!=null){HpAJAX.ACTIVEX=[HpAJAX.ACTIVEX[a]];return b;}}throw HpResource.errorAJAX+' [Request]';}
HpAJAX.response=function(a){var b=null;var c=null;if((a.ajax.request==null)||(a.ajax.request.responseXML==null)){a.messages.addNew(null,HpConstants.error,'[Response] '+HpResource.errorAJAX);throw HpResource.errorAJAX;}a.ajax.response=HpDom.getChild(a.ajax.request.responseXML,'JSAction');if(a.ajax.response==null){a.messages.addNew(null,HpConstants.error,'[Root] '+HpResource.errorAJAX);throw HpResource.errorAJAX;}b=HpDom.getChild(a.ajax.response,HpAJAX.TAG_SERVICE_STATE);if(b==null){a.messages.addNew(null,HpConstants.error,'[State] '+HpResource.errorAJAX);throw HpResource.errorAJAX;}c=HpAJAX.listMessage(a.ajax.response);if(c!=null) a.messages.addList(c);if(HpAJAX.getServiceState(a.ajax.response)==HpConstants.SERVICE_SUCCESS){a.state=true;}else {a.state=false;a.messages.addNew(null,HpConstants.error,'[Service] '+HpResource.errorAJAX);}}
HpAJAX.getServiceState=function(a){return HpDom.getText(HpDom.getChild(a,HpAJAX.TAG_SERVICE_STATE));}
HpAJAX.listMessage=function(a){var b=HpDom.getChild(a,HpAJAX.TAG_MESSAGES);if(b==null) return null;else return HpAttributeList.create(b);}
function HpInit(){}
HpInit.initLength=function(a,b,c,d){if((c!=null)&&(b.length<c)){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.minlength +' '+ c);return;}if((d!=null)&&(b.length>d)){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.maxlength +' '+ d);return;}}
HpInit.initRange=function(a,b,c,d,e){var f=null;if((c!=null)&&(b<c)){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.minimum +' '+ HpNumber.formatDecimal(c));return;}if((d!=null)&&(b>d)){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.maximum +' '+ HpNumber.formatDecimal(d));return;}if(e!=null){if(c==null) f=b%e;else f=(b-c)%e;if(f!=0){a.state=false;a.messages.addNew(null,HpConstants.error,HpResource.step +' '+ HpNumber.formatDecimal(e));}return;}}
function HpRender(){}
HpRender.messageRender=function(a){var b=null;var c=null;var d=null;var e=null;var f=new HpPairList();if(HpCore.messages==null) return true;HpCore.messages.removeItems();HpDom.removeClass(HpCore.messages.element,HpConstants.error);HpDom.removeClass(HpCore.messages.element,HpConstants.warn);HpDom.removeClass(HpCore.messages.element,HpConstants.info);HpCore.messages.setVisible(false);for(i=0;i<a.messages.size();i++){if(a.messages.item(i).element==null){if(HpCore.messages.visible==false) HpCore.messages.setVisible(true);c=HpCore.messages.content.element;b=HpCore.messages.addItem(a.messages.item(i).value);}else {c=a.messages.item(i).element;if(f.containsKey(c)==false){HpDom.clearElement(c);f.addNew(c,null);}b=HpRender.renderEntry(c,a.messages.item(i).value);}d=a.messages.item(i).name;HpRender.renderStyle(b,d,null);if(c==HpCore.messages.content.element){if(e==null) e=d;else if(e==HpConstants.info) e=d;else if((e==HpConstants.warn)&&(d==HpConstants.error)) e=d;}}if(e!=null) HpDom.setClasses(HpCore.messages.element,e);return true;}
HpRender.stateRender=function(a){var b=0;var c=null;c=a.controls.get(HpConstants.text);for(b=0;b<a.targets.length;b++){HpRender.renderInit (a.targets[b],a.styles);HpRender.renderText (a.targets[b],c,false);HpRender.renderState(a.targets[b],a.state,a.styles);}return true;}
HpRender.renderEntry=function(a,b){if(HpDom.isInput(a)==true) return HpInput.renderText(a,b,true,HpInput.separator);if(HpDom.isTextArea(a)==true) return HpTextArea.renderText(a,b,true,HpTextArea.separator);if(HpDom.isSelect(a)==true) return HpSelect.renderText(a,b,b,-1);if(HpDom.checkNodeName(a,'ul')==true) return HpEntry.renderText(a,b,-1,'li',null);return HpEntry.renderText(a,b,-1,HpEntry.wrapper,null);}
HpRender.renderText=function(a,b,c){if(HpDom.isInput(a)==true) return HpInput.renderText(a,b,c,HpInput.separator);if(HpDom.isTextArea(a)==true) return HpTextArea.renderText(a,b,c,HpTextArea.separator);if(HpDom.isSelect(a)==true){if(c==true) return HpSelect.renderText(a,b,b,-1);else return HpSelect.renderText(a,b,b,0);}return HpElement.renderText(a,b,c,HpElement.separator);}
HpRender.renderInit=function(a,b){if((b.contains(a,HpConstants.init)==true)||(b.contains(null,HpConstants.init)==true)) HpDom.setClasses(a,b.formatFallBack(a,HpConstants.init,' '));}
HpRender.renderState=function(a,b,c){var d=c.formatFallBack(a,HpConstants.error,' ');var e=c.formatFallBack(a,HpConstants.success,' ');if(b==true){HpDom.removeClasses(a,d);HpDom.addClasses (a,e);}else {HpDom.removeClasses(a,e);HpDom.addClasses (a,d);}return a;}
HpRender.renderStyle=function(a,b,c){if(b instanceof HpAttributeList) HpDom.addClasses(a,b.formatFallBack(a,c,' '));else HpDom.addClasses(a,b);return a;}
HpRender.display=function(a){var b=document.getElementById(a);if(HpDom.containsClass(b,HpConstants.hide)==false) HpDom.addClass(b,HpConstants.hide);else HpDom.removeClass(b,HpConstants.hide);}
