/*
THIS SOFTWARE IS A PRODUCT OF RE SOFTWARE (SINGAPORE). ISSUED UNDER 
THE LICENSED POLICY WRITTEN IN THE TERMS AND CONDITIONS. ANY ILLEGAL 
DISTRIBUTION OF THIS SOFTWARE EITHER ACCIDENTAL OR DELIBERATE WILL 
BE SUBJECTED TO THE MAXIMUM PENALTY UNDER LAW. 

IF YOU ARE UNSURE OF THE TERMS AND CONDITIONS OR THE AGREED USAGE 
AGREEMENT, YOU ARE REQUIRED TO TERMINATE THE USAGE OF THIS SOFTWARE 
AND CONTACT RE SOFTWARE REPRESENTATIVE(S) IMMEDIATELY. 
*/
function RES_FRM(_1){
this.sID=_1;
this.asVars=new Array();
this.arVRule=new Array();
this.asVText=new Array();
this.avDefVal=new Array();
this.asLabel=new Array();
this.asToolTip=new Array();
this.asType=new Array();
this.aiMaxSize=new Array();
this.abPriKey=new Array();
this.iColCnt=0;
}
function RES_FRM_addField(_2,_3,_4,_5,_6,_7,_8,_9,_a){
this.asVars[this.iColCnt]=_2;
this.arVRule[this.iColCnt]=_3;
this.asVText[this.iColCnt]=_4;
this.avDefVal[this.iColCnt]=_5;
this.asLabel[this.iColCnt]=_6;
this.asToolTip[this.iColCnt]=_7;
this.asType[this.iColCnt]=_8;
this.aiMaxSize[this.iColCnt]=_9;
this.abPriKey[this.iColCnt]=_a;
this.iColCnt++;
}
function RES_FRM_init(){
var _b,oNew;
for(var i=0,oInp=null,aoLab=null;i<this.iColCnt;i++){
aoLab=document.getElementsByTagName("label");
for(var j=0;j<aoLab.length;j++){
var _e=aoLab[j];
if(_e.getAttribute("for")==this.asVars[i]){
dojo.event.connect(_e,"onmouseover",this,"evtMouseOver");
dojo.event.connect(_e,"onmouseout",this,"evtMouseOut");
_e.setAttribute("title",this.asToolTip[i]);
_b=_e.firstChild;
oNew=document.createTextNode(this.asLabel[i]);
if(_b==undefined){
_e.appendChild(oNew);
}else{
_e.replaceChild(oNew,_b);
}
break;
}
}
oInp=document.getElementById(this.asVars[i]);
if(oInp==undefined){
continue;
}
switch(this.asType[i]){
case "text":
if(this.abPriKey[i]){
oInp.setAttribute("readOnly",true);
}
oInp.setAttribute("maxLength",this.aiMaxSize[i]);
oInp.setAttribute("value",this.avDefVal[i]);
break;
case "textarea":
_b=oInp.firstChild;
oNew=document.createTextNode(this.avDefVal[i]);
if(_b==undefined){
oInp.appendChild(oNew);
}else{
oInp.replaceChild(oNew,_b);
}
break;
case "select":
var _f=oInp.childNodes;
for(var k in _f){
var _11=_f[k];
if(_11.value==this.avDefVal[i]){
_11.selected=true;
break;
}else{
try{
_11.selected=false;
}
catch(e){
}
}
}
break;
case "checkbox":
case "radio":
case "hidden":
case "password":
case "file":
default:
}
}
}
function RES_FRM_validate(){
var _12,bProceed=true;
for(var i in this.asVars){
if(this.abPriKey[i]||this.asType[i]=="file"){
continue;
}
switch(this.asType[i]){
case "select":
case "radio":
break;
default:
_12=document.getElementById(this.asVars[i]);
if(!this._validateField(_12)){
bProceed=false;
}
break;
}
}
if(!this._validateLogic()){
bProceed=false;
}
if(!bProceed){
alert("Invalid inputs detected, please correct them before submission.");
}
return bProceed;
}
function RES_FRM__validateField(_14){
var _15=_14.id;
var _16=_14.value;
var _17=true;
var i,j;
var _19;
j=Array_search(_15,this.asVars);
var _1a=this.arVRule[j];
if(!_1a.test(trim(_16))){
_19=this.asVText[j];
_14.setAttribute("title",_19);
setAttribClass(_14,"error");
_17=false;
}else{
_14.removeAttribute("title");
unsetAttribClass(_14);
_17=true;
}
return _17;
}
function RES_FRM_validateImage(_1b){
var _1c=/(.+)[\/\\]([^\/\\]+)$/;
var _1d=/(.+)\.([\w\d]+)$/;
var _1e=_1b.getAttribute("id");
var sFN=_1b.value.replace(_1c,"$2");
var sFX=sFN.replace(_1d,"$2").toLowerCase();
switch(sFX){
case "jpg":
case "jpeg":
case "png":
case "gif":
break;
default:
alert("Invalid filetype selected for upload.\nOnly JPG/PNG/GIF images allowed!");
_1b.value="";
break;
}
}
function RES_FRM_evtMouseOver(_21){
var _22=getEventCaller(_21);
var _23=_22.parentNode;
var _24=_22.nextSibling;
var _25=document.createElement("SPAN");
var _26=document.createTextNode(_22.getAttribute("title"));
setAttribClass(_25,"tooltip");
_25.appendChild(_26);
if(_24==null){
_23.appendChild(_25);
}else{
_23.insertBefore(_25,_24);
}
}
function RES_FRM_evtMouseOut(_27){
var _28=getEventCaller(_27);
var _29=_28.parentNode;
var _2a=_28.nextSibling;
_29.removeChild(_2a);
}
function RES_FRM__validateLogic(){
return true;
}
RES_FRM.prototype.addField=RES_FRM_addField;
RES_FRM.prototype.init=RES_FRM_init;
RES_FRM.prototype.validate=RES_FRM_validate;
RES_FRM.prototype._validateField=RES_FRM__validateField;
RES_FRM.prototype._validateLogic=RES_FRM__validateLogic;
RES_FRM.prototype.validateImage=RES_FRM_validateImage;
RES_FRM.prototype.evtMouseOver=RES_FRM_evtMouseOver;
RES_FRM.prototype.evtMouseOut=RES_FRM_evtMouseOut;

