<!--

function checkSubmitForm() {
// Checks all the fields on the form before submitting the form to be validated
    var frm= document.forms[getNetuiTagName("workflow")];
    
    for(i=0; i<frm.elements.length; i++) {
        if (frm.elements[i].type == "text" || frm.elements[i].type == "password") {
            frm.elements[i].value = removeSpaces(frm.elements[i].value);
        }
    }
    frm.submit();
}

function trimFormFields(frm) {
    
    for(i=0; i<frm.elements.length; i++) {
        if (frm.elements[i].type == "text" || frm.elements[i].type == "password") {
            frm.elements[i].value = removeSpaces(frm.elements[i].value);
        }
    }

}

function removeSpaces(str) {
// Removes leading and trailing spaces from input string
    var temp = str;
    var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
    if (obj.test(temp)) { 
        temp = temp.replace(obj,'$2');
    }
    return temp;
}
    

function setFocus(formID,fieldID) {
// Sets the focus to the form in the field defined by the input tagIds
    formName=getNetuiTagName(formID, this);
    fieldName=getNetuiTagName(fieldID, this);
    document.forms[formName].elements[fieldName].focus();
}

function replaceAllChar(string, text, by) {
   // Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replaceAllChar(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
-->
