/*
* Changes
* ID            Date            User        Description
*               May  4, 2012    Alan        File Creaded
* 26025561      May 15, 2012    Alan        No validation for additional info fields inside collapsed headings
* 28757475      May 30, 2012    Alan        Don't validate for TermsUserAgreementText
*/


// ARR May/4/2012 Added fieldName parameter to include in alert message
function limitWordCount(elmt, limit) {
    //28757475. ARR May/28/2012 For ISettings TermsUserAgreementText field allow more than 4000 characters; Limit = 20,000
    if (elmt.id.indexOf("MainContent_UI.TermsUserAgreementText") != -1)
        limit = 20000;
    var result = elmt.value.match(/\n/g);
    var enters = result ? result.length : 0;
    var crLength = 0;                                                                       // Exceded CR length.
    if (elmt.value.length + enters > limit) {
        var ripStr = elmt.value.substring(limit);                                           // Get a string with the characters to delete
        var crs = ripStr ? ripStr.match(/\n/g) : null;                                      // look for CR (Carriage return) in exceded characters
        crLength = crs ? crs.length : 0;                                                    // Get length of CR in exceded characters
        elmt.value = elmt.value.substring(0, limit - enters + crLength);
        alert("The field cannot contain more than " + limit + " characters.");
        elmt.trigger('blur');					// AX-24898.24919.2 .blur();
    }
}

/*
// ARR May/15/2012 Id. 26025561. Set Div id to child controls (Function used by YesNoWithChildrenControl.cs, CheckListControl.cs, HeaderWithChildrenControl.cs)
function childSetParentId(id) {
    $("#" + id).find('*').each(function () {
        $(this).attr("showHideDivId", id);
    });
}

// ARR May/16/2012 Id. 26025561. Set for all Child Yes  Div id to child controls (Function used by YesNoWithChildrenControl.cs)
function childSetAsValidate(id) {
    $("#" + id).find('*').each(function () {
        $(this).removeClass("ignore").addClass("validate");
    });
}

// ARR May/16/2012 Id. 26025561. Set Div id to child controls (Function used by YesNoWithChildrenControl.cs)
function childSetAsIgnore(id) {
    $("#" + id).find('*').each(function () {
        $(this).removeClass("validate").addClass("ignore");
    });
}
*/

