function FocusControlSite(_1,_2,_3){alert(_1);_2.focus();if(_3){_2.select();}_2.className="inputerror";}function UnHighlightSite(_4){if(_4.className=="inputerror"){_4.className="inputnormal";}}function Trim(_5){return LTrim(RTrim(_5));}function LTrim(_6){return _6.replace(/^\s+/,"");}function RTrim(_7){return _7.replace(/\s+$/,"");}var m_csErrorString="";var m_nFormatErrorID=0;function UpdatePage(){if(m_nFormatErrorID!=0){return;}var _8=document.getElementById("mainform").elements;for(lControl=0;lControl<_8.length;lControl++){objCurrentControl=_8[lControl];if(!objCurrentControl.getAttribute("Calculation")){continue;}objCurrentControl.onchange();Format(objCurrentControl);if(m_nFormatErrorID!=0){return;}}}function Format(_9){if(m_nFormatErrorID!=0&&m_nFormatErrorID!=_9.id){return;}var _a=false;var _b=_9.getAttribute("FormatType");if(_b=="Money"){_a=FormatCurrency(_9);}else{if(_b=="Percent"){_a=FormatPercent(_9);}else{if(_b=="Number"){_a=ValidateNumber(_9);}else{_a=true;}}}if(!_a){m_nFormatErrorID=_9.id;FocusControlSite(m_csErrorString,_9,true);}else{if(_a&&_9.FormatType!="Text"){m_nFormatErrorID=0;UnHighlightSite(_9);}}}function FormatCurrency(_c){var _d=_c.value;_d=_d.toString().replace(/\$|\,/g,"");numStr=new String(_d);if((numStr.indexOf("(")>=0)&&(numStr.indexOf(")")>=0)){pos=false;}else{pos=true;}_d=_d.toString().replace(/\(|\)/g,"");if(isNaN(_d)){m_csErrorString="The characters you entered is not a valid currency amount.";return false;}sign=(_d==(_d=Math.abs(_d)));sign=sign&&pos;_d=Math.floor(_d*100+0.50000000001);cents=_d%100;_d=Math.floor(_d/100).toString();if(cents<10){cents="0"+cents;}for(var i=0;i<Math.floor((_d.length-(1+i))/3);i++){_d=_d.substring(0,_d.length-(4*i+3))+","+_d.substring(_d.length-(4*i+3));}_d+="."+cents;if(!sign){_c.value="($"+_d+")";}else{_c.value="$"+_d;}return true;}function FormatPercent(_f){var num=_f.value;num=num.toString().replace(/%/g,"");if(isNaN(num)){m_csErrorString="The characters you entered is not a valid percentage amount.";return false;}num=Trim(num);if(num.length==0){_f.value="0%";return true;}num=MyRounder(num,2);num+="%";_f.value=num;return true;}function MyRounder(x,d){return (Math.round(x*10*d)/(10*d));}function ValidateNumber(_13){var num=_13.value;if(isNaN(num)){m_csErrorString="The characters you entered is not a valid number amount.";return false;}_13.value=num;return true;}function MakeNumber(_15){_15=_15.toString().replace(/\$|\,/g,"");numStr=new String(_15);if((numStr.indexOf("(")>=0)&&(numStr.indexOf(")")>=0)){pos=false;}else{pos=true;}_15=_15.toString().replace(/\(|\)/g,"");if(_15.length==0){return 0;}sign=(_15==(_15=Math.abs(_15)));sign=sign&&pos;var _16=Math.round(_15*100)/100;if(!sign){_16=_16*-1;}return _16;}function MakePercent(_17){_17=_17.replace(/%/g,"");return _17/100;}function roundNumber(num,dec){var _1a=Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);return _1a;}