/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$.expr[':'].icontains = function(a, i, m) {
    return $(a).text().toUpperCase()
        .indexOf(m[3].toUpperCase()) >= 0;
};

var CREDITOR_ADDRESS_LIST_FOR_DF = {};

function AIAccountsForHTML() {

    //if(item_count>0)
    var html = '';
    var item_count = 1;
    var account_html_by_key = {};
    $(".crPrint").each(function(i, el) {

        var header = $.trim($(this).find('.sub_header').first().text());

        var trans = '<p ><span class="bg-yellow">' + header + '</span>';
        var exp = '<p ><span class="bg-yellow">' + header + '</span>';
        var equ = '<p ><span class="bg-yellow">' + header + '</span>';

        var inconsistancy = '<span class="glyphicon glyphicon-remove " title="Inconsistency" style="color:red;font-size:14px;margin-top:5px"></span>';
        var advice = '<span class="glyphicon glyphicon-plus advice-text" title="Inconsistency" style="font-size:14px;margin-top:5px;"></span>';
        var table = $(this).find('.rpt_content_table').first();
        var html = '';
        var quest = '&nbsp;&nbsp;<span class="glyphicon glyphicon-question-sign acct-quest" title="QUESTIONABLE REPORTED" style="color:red;font-size:16px;"></span>';

        var m = '<span style="color:red" title="Missing">M</span>';
        var u = '<span  style="color:red;" title="Unproven">-U</span>';
        var inc = '<span  style="color:red;" title="Inconsistency">-I</span>';

        if (table)
            table.find('tr').each(function(i, el) {
                if (i == 0) return true;
                var tds = $(this).find('td');
                var td0 = $.trim(tds.eq(0).text());
                var text1 = $.trim(tds.eq(1).text());
                var text2 = $.trim(tds.eq(2).text());
                var text3 = $.trim(tds.eq(3).text());

                if (td0 == 'Account #:' || td0 == 'Account Type:' || td0 == 'Account Type - Detail:') {
                    if (td0 == 'Account #:') {
                        if (text1 != '') tds.eq(1).html(text1.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                        if (text2 != '') tds.eq(2).html(text2.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                        if (text3 != '') tds.eq(3).html(text3.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                    }
                    trans += '<p ><span class="bg-yellow">' + td0 + '</span> &nbsp;&nbsp;&nbsp;<span class="bg-tra">' + text1 + '</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + text2 + '</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ">' + text3 + '</span> </p>';
                    // if account # then add questionable sign


                } else if (td0 == 'Account Status:') {
                    tds.eq(0).html(advice + '&nbsp;&nbsp;&nbsp;<span >' + td0 + '&nbsp; </span><span class="span-cl-green">KEEP OPEN</span>');
                } else if (td0 == 'Monthly Payment:') {
                    tds.eq(0).html(advice + '&nbsp;&nbsp;&nbsp;<span >' + td0 + '&nbsp; </span><span class="span-cl-green">STAY CURRENT</span>');
                } else if (td0 == 'Balance:') {
                    tds.eq(0).html(advice + '&nbsp;&nbsp;&nbsp;<span >' + td0 + '&nbsp; </span><span class="span-cl-green" title="KEEP AT NO GREATER THAN 30% of reported credit limit but BEST IF AT OR BELOW 10% of the reported credit limit!">KEEP AT 10%</span>');
                } else if (td0 == 'High Credit:') {
                    tds.eq(0).html(advice + '&nbsp;&nbsp;&nbsp;<span >' + td0 + '&nbsp; </span><span class="span-cl-green" title="NEVER GO OVER 50% at any time">NEVER GO OVER 50%</span>');
                } else if (td0 == 'Past Due:') {
                    tds.eq(0).html(advice + '&nbsp;&nbsp;&nbsp;<span >' + td0 + '&nbsp; </span><span class="span-cl-green" title="OBVIOUSLY PAY BILLS IN FULL ON TIME ALWAYS, DO NOT MISS , OR BE LATE OR HAVE INCOMPLETE PAYMENT IN ACCOUNT HISTORY">DON\'T BE LATE</span>');
                }


                if (td0 != 'Account #:') {


                    if (text1 == '' || text1 == '-') tds.eq(1).html(text1 + m);
                    else {
                        if (text1 != text2 && text2 != '') {
                            tds.eq(1).html(text1 + inc);
                        } else {
                            tds.eq(1).html(text1 + u);
                        }

                    }

                    if (text2 == '' || text2 == '-') tds.eq(2).html(text2 + m);
                    else {
                        if (text2 != text3 && text3 != '') {
                            tds.eq(2).html(text2 + inc);
                        } else {
                            tds.eq(2).html(text2 + u);
                        }

                    }
                    if (text3 == '' || text3 == '-') tds.eq(3).html(text3 + m);
                    else {
                        if (text3 != text1 && text1 != '') {
                            tds.eq(3).html(text3 + inc);
                        } else {
                            tds.eq(3).html(text3 + u);
                        }

                    }
                }
            })
        $(this).find('.hstry-header').first().append('<p class="span-cl-green">OBVIOUSLY PAY BILLS IN FULL ON TIME ALWAYS, DO NOT MISS , OR BE LATE OR HAVE INCOMPLETE PAYMENT IN ACCOUNT HISTORY</p>')


        var address = getContactAdd(item_count, header);
        trans += '<p ><span class="bg-yellow">Address: </span> &nbsp;&nbsp;&nbsp;<span class="bg-tra">' + address + '</span>';

        var negative = true;

        var dtype;
        var template;
        var verbiage = '';
        var template_df;

        if ($(this).is(':icontains("Collection/Chargeoff")') || $(this).is(':icontains("Chargeoff")') || $(this).is(':icontains("Writtenoff")')) {
            dtype = 7;
            template = 'COFF-Ew1L4D1-bureau_4';
            template_df = 'COFF-Ew1L3D1-df-creditor_3';
        } else if ($(this).is(':icontains("Medical")')) {
            if ($(this).find(".hstry-120 ").length > 0 || $(this).find(".hstry-150 ").length > 0 || $(this).find(".hstry-180 ").length > 0) {
                dtype = 6;
                template = 'MCOL-Ew1L7D1-bureau_7';
                template_df = 'MCOL-Ew1L8D1-df-creditor_8';
            } else {
                $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                negative = false;
                dtype = 10;
                template = 'AUDIT-Ew1L1D1-audit_40';
            }
        } else if ($(this).is(':icontains("Collection")')) {
            if ($(this).find(".hstry-120 ").length > 0 || $(this).find(".hstry-150 ").length > 0 || $(this).find(".hstry-180 ").length > 0) {
                dtype = 5;
                template = 'NMCOL-Ew1L5D1-bureau_5';
                template_df = 'NMCOL-Ew1L6D1-df-creditor_6';
            } else {
                $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                negative = false;
                dtype = 10;
                template = 'AUDIT-Ew1L1D1-audit_40';
            }
        } else if ($(this).is(':icontains("Student")') || $(this).is(':icontains("Student loan")') || $(this).is(':icontains("subsidized")') || $(this).is(':icontains("unsubsidized")') ||
            $(this).is(':icontains("SAllIE MAE")')) {
            var count = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) + ($(this).find(".hstry-90 ").length) + ($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
            if (count > 3) {
                dtype = 4;
                template = 'SL3-Ew1L11D1-bureau_11';
                template_df = 'SL3-Ew1L12D1-df-creditors_12';
            } else if (late_counts > 1 && late_counts <= 3) {
                dtype = 4;
                template = 'SL12-Ew1L9D1-bureau_9';
                template_df = 'SL12-Ew1L10D1-df-creditor_10';
            } else {
                $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                negative = false;
                dtype = 10;
                template = 'AUDIT-Ew1L1D1-audit_40';
            }
        }
        // check for non student loan deogatory (3+ lates) and deliquency (1 or 2 lates)
        // else if( $(this).is(':icontains("LATE")') || $(this).is(':icontains("PAST DUE")')){
        //     var count = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) +($(this).find(".hstry-90 ").length) +($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
        //     if(count>3 ) setCBValues(item_count,address,3,'NLP3-Ew1LPRD1-bureau_17',html);
        //     else if(count>0<3) setCBValues(item_count,address,3,'NLP12-Ew1L1D1-bureau_1',html);
        // }
        else {
            var late_counts = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) + ($(this).find(".hstry-90 ").length) + ($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
            if (late_counts > 3) {
                dtype = 3;
                template = 'NLP3-Ew1LPRD1-bureau_17';
                template_df = 'NLP3-Ew1LPRx1D1-df-creditor_17';
            } else if (late_counts > 1 && late_counts <= 3) {
                dtype = 3;
                template = 'NLP12-Ew1L1D1-bureau_1';
                template_df = 'NLP12-Ew1L1D1-df-creditor_1';
            } else {
                $('.check-aa', '#main-content-' + item_count).prop('checked', true); //check audit analysis checkbox in destination
                negative = false;
                dtype = 10;
                template = 'AUDIT-Ew1L1D1-audit_40';
            }

        }
        if (negative) {
            $('.span-cl-green', '#main-content-' + item_count).remove();
            $('.advice-text', '#main-content-' + item_count).remove();
            $(this).find('.span-cl-green').remove();
            $(this).find('.advice-text').remove();
            var ph_table = $(this).find('.addr_hsrty').first();
            var tdlength = ph_table.find(" tr:first > td").length;

            verbiage = '<p >My state and the applicable federal regulations and standards for proper lawful reporting requires that any injurious claim of delinquency and or derogatoriness be factual and physically verified as being fully True, ACCURATE, COMPLETE, TIMELY, of a known ownership of responsibility, and else wise undeniably VALIDATED and further mandates that all such allegations are reported in a perfect and certifiable compliant manner such as in relation to the mandatorily perfect correct and complete certificated Metro 2 Format reporting standard(s). Being that the noted allegation(s) of delinquencies and derogatoriness\'s are reported as one or more fallible conditions of being "missing or incomplete", inconsistent, questionable, and or else wise UNPROVEN reporting. Inability to validate and certify compliant reporting is grounds to demand eradication of claims, and this is my REBUTTAL to  ANY AND ALL NEGATIVE ACCUSATIONS and my rightful DEMAND TO REMOVE such claims from REPORTING!</p>';

            var tds0, tds1, tds2;
            var m = '<span style="color:red" title="Missing">M</span>';
            var u = '<span  class="cl-diff" title="Unproven">-U</span>';
            var inc = '<span  class="cl-diff" title="Inconsistency">-I</span>';
            ph_table.find('tr').each(function(i, el) {
                if (i == 0 || i == 1) return true;
                else if (i == 2) tds0 = $(this).find('td');
                else if (i == 3) tds1 = $(this).find('td');
                else if (i == 4) tds2 = $(this).find('td');
            })
            tds0.each(function(i, el) {
                if (i == 0) {
                    tds0.eq(i).removeClass("rowAlt");
                    tds1.eq(i).removeClass("rowAlt");
                    tds2.eq(i).removeClass("rowAlt");
                    return true;
                }
                var text1 = $.trim(tds0.eq(i).text());
                var text2 = $.trim(tds1.eq(i).text());
                var text3 = $.trim(tds2.eq(i).text());

                if (text1 == '') tds0.eq(i).html(m);
                else if (text1 != 'OK') {
                    if (text1 != text2) {
                        if (text2 == 'OK' && text3 == 'OK') tds0.eq(i).html(text1 + u);
                        else if (text2 == '' && text3 == '') tds0.eq(i).html(text1 + u);
                        else tds0.eq(i).html(text1 + inc);
                    } else {
                        tds0.eq(i).html(text1 + u);
                    }

                }

                if (text2 == '') tds1.eq(i).html(m);
                else if (text2 != 'OK') {
                    if (text2 != text3) {
                        if (text1 == 'OK' && text3 == 'OK') tds1.eq(i).html(text2 + u);
                        else if (text1 == '' && text3 == '') tds1.eq(i).html(text2 + u);
                        else tds1.eq(i).html(text2 + inc);
                    } else {
                        tds1.eq(i).html(text1 + u);
                    }

                }
                if (text3 == '') tds2.eq(i).html(m);
                else if (text3 != 'OK') {
                    if (text3 != text1) {
                        if (text1 == 'OK' && text2 == 'OK') tds2.eq(i).html(text3 + u);
                        else if (text1 == '' && text2 == '') tds2.eq(i).html(text3 + u);
                        else tds2.eq(i).html(text3 + inc);
                    } else {
                        tds2.eq(i).html(text1 + u);
                    }

                }
            })


        } else {
            $('.acct-quest', '#main-content-' + item_count).remove();


            //$('.bg-yellow','#main-content-'+item_count).remove();
        }
        var img = '<div  style="width:100%;" class="acct-cb-img"><table class="table rpt_content_table rpt_content_header rpt_table4column ng-scope" >' + $(this).html() + '</table></div>';

        var br = '<p class="cb-br" >*****************************************************************************************************</p>';
        html = trans + img + verbiage + br; // merge all three beauroes

        verbiage = getVerbiage();
        var df_content_indicator = "";
        html = trans + img + verbiage + br + df_content_indicator; // merge all three beauroes



        if (html) {
            account_html_by_key[header] = html;
            $('#credit-report-content-modal .modal-body .content-data').append(html);
        }
        //$('#summernote-'+item_count).summernote('code',html); // insert content in text area.

    });

    return account_html_by_key;
}


var contact_addresses = {
    "BRCLYSBANKDE": "BARCLAYS",
    "CCB/CENTURY": "COMENITYCAPITALBANK",
    "CAP1/BSTBY": "CAP1",
    "CREDITONEBANK": "CREDIT ONE",
    "CHRYSLERCAP": "CHRYSLER CAPITAL",
    "DISCOVERBA": "DISCOVER"
};
var creditor_aler_msg = '';
var wave_html = '';


function setIQReportFormatLikeEpic() {
    AIpersonalInfo();
    AIpublicInfo();
    AIInquiry();
    //AIAccountsForHTML();
}
//var account_html_by_key = {};
function getCreditReportContent(elem, type = true) {
    $('.sub_header select').remove();
    $('select.banks, select.review_type, select.inq-address-dropdown').remove();
    $('select[name=source_type]').remove();
    var source_type = $('select[name=report_type]').val();
    if ($(elem).prop('checked')) {

        if (!$(elem).attr('name')) return false;

        var divlen = $(elem).attr('name').replace('auto_generate_image_', '');
        var enhance_val = $('input[name=enhance_check_' + divlen + ']:checked').val();
        if (enhance_val == 4) {
            return false;
        }
        if (!isVelocityQuickStartChecked(divlen) && type) {
            alert("Please select at least one item from velocity");
            $(elem).prop('checked', false);
            return false;
        }
        var account_html_by_key = {}

        var is_personal_info = isEnhanceCheckedByValue(divlen, 'negative_item_');
        var is_inquiry = isEnhanceCheckedByValue(divlen, 'negative_inq_item_');
        var is_multiple_negativ_attack = isEnhanceCheckedByValue(divlen, 'item_bank_');
        var is_public_attack = isEnhanceCheckedByValue(divlen, 'public_negative_item_');

        if (source_type == 3) {
            if (is_personal_info) {
                //account_html_by_key = SmartCreditAIpersonalInfo()
                account_html_by_key = PERSONAL_INFO_FROM_CREDIT_REPORT;
            } else if (is_inquiry) {
                //account_html_by_key = SmartCreditAIInquiry();
                account_html_by_key = INQUIRY_INFO_FROM_CREDIT_REPORT
            } else if (is_multiple_negativ_attack) {

                // account_html_by_key = SmartCreditAIAccounts();
                account_html_by_key = CREDIT_REPORT_KEY_ADDRESS_LIST;

            } else if (is_public_attack) {
                account_html_by_key = SmartCreditAIpublicInfo();

            }
        } else {
            if (is_personal_info) {
                //account_html_by_key = AIpersonalInfo();
                account_html_by_key = PERSONAL_INFO_FROM_CREDIT_REPORT;

            }

            if (is_inquiry) {
                //account_html_by_key = AIInquiry();
                account_html_by_key = INQUIRY_INFO_FROM_CREDIT_REPORT
            }

            if (is_multiple_negativ_attack) {
                //account_html_by_key = AIAccounts();
                account_html_by_key = CREDIT_REPORT_KEY_ADDRESS_LIST
                    //account_html_by_key =  AIAccountsForHTML();
            }

            if (is_public_attack) {
                account_html_by_key = AIpublicInfo();
            }
        }

        getEpicBankInfoFromHTML(elem, account_html_by_key);
        removeUnwantedEpicVariable(divlen);
    }
}


function removeUnwantedEpicVariable(divlen) {
    var tag_names_array = [
        'negative_item_',
        'negative_inq_item_',
        'item_bank_',
        'public_negative_item_'
    ];
    for (var i in tag_names_array) {
        var tag_name = tag_names_array[i];
        var enhance_checkbox = $('input[name="' + tag_name + divlen + '[]"]:checked');
        if (enhance_checkbox.length == 0) {
            if (tag_name == 'negative_item_') {
                $('input[name=epic_personal_info_' + divlen + ']').remove();
            }

            if (tag_name == 'negative_inq_item_') {
                $('input[name=epic_inquiry_section_html_' + divlen + ']').remove();
            }

            if (tag_name == 'item_bank_') {
                $('input[name=epic_every_section_html_' + divlen + ']').remove();
            }

            if (tag_name == 'public_negative_item_') {
                $('input[name=epic_public_section_html_' + divlen + ']').remove();
            }
        }
    }


}

function isVelocityQuickStartChecked(divlen) {

    var result = false;

    if (isCreditContentChecked('negative_inq_item_', divlen)) {
        result = true;
    } else if (isCreditContentChecked('public_negative_item_', divlen)) {
        result = true;
    } else if (isCreditContentChecked('item_bank_', divlen)) {
        result = true;
    } else if (isCreditContentChecked('negative_item_', divlen)) {
        result = true;
    }


    return result;
}

function isCreditContentChecked(tag_name, divlen) {
    var result = false;
    $('input[name="' + tag_name + divlen + '[]"]').each(function() {
        if ($(this).prop('checked')) {
            result = true;
            return false;
        }
    });

    return result;
}

function isEnhanceCheckedByValue(divlen, tag_name) {
    var result = false;
    var enhance_checkbox = $('input[name="' + tag_name + divlen + '[]"]');

    if (enhance_checkbox.length == 0) {
        return false;
    }

    enhance_checkbox.each(function() {

        if ($(this).prop('checked')) {
            result = true;
            return false;
        }
    });

    return result;

}

function array_key_contains(key, address_assoc) {
    var result;
    if (address_assoc) {
        for (var name in address_assoc) {
            if (key && name) {
                if (name.includes(key)) {
                    return name;
                }
            }
            //if(key == "CELTIC/CONT"){console.log('1',name);}
        }
    }

    return result;
}

function getContactAdd(i, add) {

    add = add.replace('BNK', 'BANK');
    var alert_html = '';
    var address_assoc = getDF();
    var address = address_assoc[add];

    if (typeof address === 'undefined') {
        if (/\s/.test(add)) {
            add = add.replace(/  +/g, ' ');
            var myStringArray = add.split(" ");
            alert_html = ',' + (i + 1);
            myStringArray.forEach(function(entry) {
                if (typeof address === 'undefined')
                    address = address_assoc[array_key_contains(entry, address_assoc)];
                else return;

            });
        } else if (add.indexOf('/') !== -1) {

            var myStringArray = add.split("/");
            alert_html = ',' + (i + 1);
            myStringArray.forEach(function(entry) {
                if (typeof address === 'undefined')
                    address = address_assoc[array_key_contains(entry, address_assoc)];
                else return;

            });
        }
    }

    if (typeof address === 'undefined') {
        var add2 = contact_addresses[add];
        alert_html = ',' + (i + 1);
        address = address_assoc[add2];
    }


    if (typeof address === 'undefined') {
        address = 'AS REPORTED, the item  <strong>' + add + '</strong> does NOT have an exactly matching Data Furnisher/Creditor Contract address location.';
    }

    return address;
}

function AIAccounts(divlen = 0) {
    var item_count = 1;
    var negative_keys_html = getNegativeKeys();
    $('.credit-report .cl-diff').remove();
    //if(item_count>0)
    var html = '';
    //$('#credit-report-content-modal .modal-body .content-data').html('')
    var account_html_by_key = {};
    $(".credit-report .crPrint").each(function(i, el) {

        var header = $.trim($(this).find('.sub_header').first().clone() //clone the element
            .children() //select all the children
            .remove() //remove all the children
            .end() //again go back to selected element
            .text());

        if (!header) {
            var tmp_header = $.trim($(this).find('.sub_header').children('ng.ng-binding').first().clone() //clone the element
                .children() //select all the children
                .remove() //remove all the children
                .end() //again go back to selected element
                .text());
            if (tmp_header) {
                header = tmp_header;
            }
        }

        var trans_header = header;
        if (BANK_LIST_INDEX_LESS_ASSOC[header]) {
            trans_header = BANK_LIST_INDEX_LESS_ASSOC[header]
        }

        var trans = '<p ><span class="bg-yellow">' + trans_header + '</span>';
        var exp = '<p ><span class="bg-yellow">' + trans_header + '</span>';
        var equ = '<p ><span class="bg-yellow">' + trans_header + '</span>';

        var inconsistancy = '<span class="glyphicon glyphicon-remove " title="Inconsistency" style="color:red;font-size:14px;margin-top:5px"></span>';
        //var advice = '<span class="glyphicon glyphicon-plus advice-text" title="Inconsistency" style="font-size:14px;margin-top:5px;"></span>';
        var advice = '';
        var table = $(this).find('.rpt_content_table').first();
        var html = '';
        var quest = '&nbsp;&nbsp;<span class="glyphicon glyphicon-question-sign acct-quest" title="QUESTIONABLE REPORTED" style="color:red;font-size:16px;"></span>';

        var m = '<span style="color:red" title="Missing">M</span>';
        var u = '<span  style="color:red;" title="Unproven">-U</span>';
        var inc = '<span  style="color:red;" title="Inconsistency">-I</span>';

        if (table)
            table.find('tr').each(function(i, el) {
                if (i == 0) return true;
                var tds = $(this).find('td');
                var td0 = $.trim(tds.eq(0).text());
                var text1 = $.trim(tds.eq(1).text());
                var text2 = $.trim(tds.eq(2).text());
                var text3 = $.trim(tds.eq(3).text());

                text1 = text1.replace('M', '');
                text1 = text1.replace('-U', '');
                text1 = text1.replace('-I', '');

                text2 = text2.replace('M', '');
                text2 = text2.replace('-U', '');
                text2 = text2.replace('-I', '');

                text3 = text3.replace('M', '');
                text3 = text3.replace('-U', '');
                text3 = text3.replace('-I', '');

                if (td0 == 'Account #:' || td0 == 'Account Type:' || td0 == 'Account Type - Detail:') {
                    if (td0 == 'Account #:') {
                        if (text1 != '') tds.eq(1).html(text1.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                        if (text2 != '') tds.eq(2).html(text2.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                        if (text3 != '') tds.eq(3).html(text3.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                    }
                    trans += '<p ><span class="bg-yellow">' + td0 + '</span> &nbsp;&nbsp;&nbsp;<span class="bg-tra">' + text1 + '</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + text2 + '</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ">' + text3 + '</span> </p>';
                    // if account # then add questionable sign


                } else if (td0 == 'Account Status:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green"></span>');
                } else if (td0 == 'Monthly Payment:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green"></span>');
                } else if (td0 == 'Balance:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green" ></span>');
                } else if (td0 == 'High Credit:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green" ></span>');
                } else if (td0 == 'Past Due:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green" ></span>');
                }


                if (td0 != 'Account #:') {


                    if (text1 == '' || text1 == '-') tds.eq(1).html(text1 + m);
                    else {
                        if (text1 != text2 && text2 != '') {
                            tds.eq(1).html(text1 + inc);
                        } else {
                            tds.eq(1).html(text1 + u);
                        }

                    }

                    if (text2 == '' || text2 == '-') tds.eq(2).html(text2 + m);
                    else {
                        text2 = text2.replace('M', '');
                        text2 = text2.replace('-U', '');
                        text2 = text2.replace('-I', '');

                        if (text2 != text3 && text3 != '') {

                            tds.eq(2).html(text2 + inc);
                        } else {
                            tds.eq(2).html(text2 + u);
                        }

                    }
                    if (text3 == '' || text3 == '-') tds.eq(3).html(text3 + m);
                    else {
                        text3 = text3.replace('M', '');
                        text3 = text3.replace('-U', '');
                        text3 = text3.replace('-I', '');

                        if (text3 != text1 && text1 != '') {
                            tds.eq(3).html(text3 + inc);
                        } else {
                            tds.eq(3).html(text3 + u);
                        }

                    }
                }
            })
            //$(this).find('.hstry-header').first().find('p.span-cl-green').remove();
            //$(this).find('.hstry-header').first().append('<p class="span-cl-green">OBVIOUSLY PAY BILLS IN FULL ON TIME ALWAYS, DO NOT MISS , OR BE LATE OR HAVE INCOMPLETE PAYMENT IN ACCOUNT HISTORY</p>')


        var address = getContactAdd(item_count, header);
        trans += '<p ><span class="bg-yellow">Address: </span> &nbsp;&nbsp;&nbsp;<span class="bg-tra">' + address + '</span>';

        var negative = true;

        var dtype;
        var template;
        var verbiage = '';
        var template_df;

        if ($(this).is(':contains("Collection/Chargeoff")') || $(this).is(':contains("Chargeoff")') || $(this).is(':contains("Writtenoff")')) {
            dtype = 7;
            template = 'COFF-Ew1L4D1-bureau_4';
            template_df = 'COFF-Ew1L3D1-df-creditor_3';
        } else if ($(this).is(':contains("Medical")')) {
            if ($(this).find(".hstry-120 ").length > 0 || $(this).find(".hstry-150 ").length > 0 || $(this).find(".hstry-180 ").length > 0) {
                dtype = 6;
                template = 'MCOL-Ew1L7D1-bureau_7';
                template_df = 'MCOL-Ew1L8D1-df-creditor_8';
            } else {
                $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                negative = false;
                dtype = 10;
                template = 'AUDIT-Ew1L1D1-audit_40';
            }
        } else if ($(this).is(':contains("Collection")')) {
            if ($(this).find(".hstry-120 ").length > 0 || $(this).find(".hstry-150 ").length > 0 || $(this).find(".hstry-180 ").length > 0) {
                dtype = 5;
                template = 'NMCOL-Ew1L5D1-bureau_5';
                template_df = 'NMCOL-Ew1L6D1-df-creditor_6';
            } else {
                $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                negative = false;
                dtype = 10;
                template = 'AUDIT-Ew1L1D1-audit_40';
            }
        } else if ($(this).is(':contains("Student")') || $(this).is(':contains("Student loan")') || $(this).is(':contains("subsidized")') || $(this).is(':contains("unsubsidized")') ||
            $(this).is(':contains("SAllIE MAE")')) {
            var count = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) + ($(this).find(".hstry-90 ").length) + ($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
            if (count > 3) {
                dtype = 4;
                template = 'SL3-Ew1L11D1-bureau_11';
                template_df = 'SL3-Ew1L12D1-df-creditors_12';
            } else if (late_counts > 1 && late_counts <= 3) {
                dtype = 4;
                template = 'SL12-Ew1L9D1-bureau_9';
                template_df = 'SL12-Ew1L10D1-df-creditor_10';
            } else {
                $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                negative = false;
                dtype = 10;
                template = 'AUDIT-Ew1L1D1-audit_40';
            }
        }
        // check for non student loan deogatory (3+ lates) and deliquency (1 or 2 lates)
        // else if( $(this).is(':contains("LATE")') || $(this).is(':contains("PAST DUE")')){
        //     var count = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) +($(this).find(".hstry-90 ").length) +($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
        //     if(count>3 ) setCBValues(item_count,address,3,'NLP3-Ew1LPRD1-bureau_17',html);
        //     else if(count>0<3) setCBValues(item_count,address,3,'NLP12-Ew1L1D1-bureau_1',html);
        // }
        else {
            var late_counts = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) + ($(this).find(".hstry-90 ").length) + ($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
            if (late_counts > 3) {
                dtype = 3;
                template = 'NLP3-Ew1LPRD1-bureau_17';
                template_df = 'NLP3-Ew1LPRx1D1-df-creditor_17';
            } else if (late_counts > 1 && late_counts <= 3) {
                dtype = 3;
                template = 'NLP12-Ew1L1D1-bureau_1';
                template_df = 'NLP12-Ew1L1D1-df-creditor_1';
            } else {
                $('.check-aa', '#main-content-' + item_count).prop('checked', true); //check audit analysis checkbox in destination
                negative = false;
                dtype = 10;
                template = 'AUDIT-Ew1L1D1-audit_40';
            }

        }
        if (negative) {
            $('.span-cl-green', '#main-content-' + item_count).remove();
            $('.advice-text', '#main-content-' + item_count).remove();
            $(this).find('.span-cl-green').remove();
            $(this).find('.advice-text').remove();
            var ph_table = $(this).find('.addr_hsrty').first();
            var tdlength = ph_table.find(" tr:first > td").length;

            verbiage = '<p >My state and the applicable federal regulations and standards for proper lawful reporting requires that any injurious claim of delinquency and or derogatoriness be factual and physically verified as being fully True, ACCURATE, COMPLETE, TIMELY, of a known ownership of responsibility, and else wise undeniably VALIDATED and further mandates that all such allegations are reported in a perfect and certifiable compliant manner such as in relation to the mandatorily perfect correct and complete certificated Metro 2 Format reporting standard(s). Being that the noted allegation(s) of delinquencies and derogatoriness\'s are reported as one or more fallible conditions of being "missing or incomplete", inconsistent, questionable, and or else wise UNPROVEN reporting. Inability to validate and certify compliant reporting is grounds to demand eradication of claims, and this is my REBUTTAL to  ANY AND ALL NEGATIVE ACCUSATIONS and my rightful DEMAND TO REMOVE such claims from REPORTING!</p>';

            var tds0, tds1, tds2;
            var m = '<span style="color:red" title="Missing">M</span>';
            var u = '<span  class="cl-diff" title="Unproven">-U</span>';
            var inc = '<span  class="cl-diff" title="Inconsistency">-I</span>';
            ph_table.find('tr').each(function(i, el) {
                if (i == 0 || i == 1) return true;
                else if (i == 2) tds0 = $(this).find('td');
                else if (i == 3) tds1 = $(this).find('td');
                else if (i == 4) tds2 = $(this).find('td');
            })
            tds0.each(function(i, el) {
                if (i == 0) {
                    tds0.eq(i).removeClass("rowAlt");
                    tds1.eq(i).removeClass("rowAlt");
                    tds2.eq(i).removeClass("rowAlt");
                    return true;
                }
                var text1 = $.trim(tds0.eq(i).text());
                var text2 = $.trim(tds1.eq(i).text());
                var text3 = $.trim(tds2.eq(i).text());

                text1 = text1.replace('M', '');
                text1 = text1.replace('-U', '');
                text1 = text1.replace('-I', '');

                text2 = text2.replace('M', '');
                text2 = text2.replace('-U', '');
                text2 = text2.replace('-I', '');

                text3 = text3.replace('M', '');
                text3 = text3.replace('-U', '');
                text3 = text3.replace('-I', '');

                if (text1 == '') tds0.eq(i).html(m);
                else if (text1 != 'OK') {
                    if (text1 != text2) {
                        if (text2 == 'OK' && text3 == 'OK') tds0.eq(i).html(text1 + u);
                        else if (text2 == '' && text3 == '') tds0.eq(i).html(text1 + u);
                        else tds0.eq(i).html(text1 + inc);
                    } else {
                        tds0.eq(i).html(text1 + u);
                    }

                }

                if (text2 == '') tds1.eq(i).html(m);
                else if (text2 != 'OK') {
                    if (text2 != text3) {
                        if (text1 == 'OK' && text3 == 'OK') tds1.eq(i).html(text2 + u);
                        else if (text1 == '' && text3 == '') tds1.eq(i).html(text2 + u);
                        else tds1.eq(i).html(text2 + inc);
                    } else {
                        tds1.eq(i).html(text1 + u);
                    }

                }
                if (text3 == '') tds2.eq(i).html(m);
                else if (text3 != 'OK') {
                    if (text3 != text1) {
                        if (text1 == 'OK' && text2 == 'OK') tds2.eq(i).html(text3 + u);
                        else if (text1 == '' && text2 == '') tds2.eq(i).html(text3 + u);
                        else tds2.eq(i).html(text3 + inc);
                    } else {
                        tds2.eq(i).html(text1 + u);
                    }

                }
            })


        } else {
            $('.acct-quest', '#main-content-' + item_count).remove();
            //$('.bg-yellow','#main-content-'+item_count).remove();
        }

        var full_table_grab = $(this).html();
        full_table_grab = full_table_grab.replace(header, trans_header);

        var img = '<div  style="width:100%;" class="acct-cb-img"><table class="table rpt_content_table rpt_content_header rpt_table4column ng-scope" >' + full_table_grab + '</table></div>';

        var br = '<p class="cb-br" >*****************************************************************************************************</p>';

        verbiage = getVerbiage();
        var df_content_indicator = "";
        html = trans + img + verbiage + br + df_content_indicator; // merge all three beauroes

        if (divlen > 0) {
            $('input[name="dest_check_' + divlen + '[]"]:checked').each(function(i, value) {
                if ($(this).prop('checked') && $(this).val() == 11) {
                    //html += negative_keys_html;
                    return false;
                }
            });
        }

        if (html) {
            account_html_by_key[header] = html
            $('#credit-report-content-modal .modal-body .content-data').append(html);
        }

    });
    //console.log('account_html_by_key',account_html_by_key)
    return account_html_by_key;
}

function getNegativeKeys() {
    var negative_keys = '<p > <strong class="clr-red">? </strong>&nbsp;&nbsp;= <span class="bg-light-red">Data Point is QUESTIONABLE in its reporting</span>' +
        '<br> <strong class="clr-red">I </strong>&nbsp;&nbsp;= <span class="bg-light-red">Data Point is INCONSISTENTLY reported across displayed bureaus, an infraction of the 5th point of Metro 2 Five points of compliance!</span>' +
        '<br> <strong class="clr-red"> M </strong>&nbsp;&nbsp;= <span class="bg-light-red">Data Point is MISSING and or is DEFICIENTLY reported as compared to what is most likely information that SHOULD OF BEEN adequately reported!</span>' +
        '<br> <strong class="clr-red"> U </strong>&nbsp;&nbsp;= <span class="bg-light-red">Data Point is else wise UNPROVEN , as reported! Undocumented claims can NOT be assumed valid nor compliantly reported!</span></p>'
    return negative_keys;
}





 /* ------creditor contacts start -------- */

 function getSmartCreditCreditorDropDown() {
    var addressObj = {};
    var all_crditors_contacts_smart_credit = creditorContactsSmartCredit();
    if (all_crditors_contacts_smart_credit) {
        $.each(all_crditors_contacts_smart_credit, function(index, value) {
            var bank_name = $.trim(value.bank_name);
            var address = value.address.replace(/ +(?= )/g, '');
            if (bank_name && address) {
                addressObj[bank_name] = bank_name + " : " + address;
                CREDITOR_ADDRESS_LIST_FOR_DF[bank_name] = address;
            }
        })
    }

    return addressObj;

}

// function creditorContactsSmartCredit() {
//     var contactInfo = [];
//     var creditor_tbl = $("td").filter(function() {
//         var current_text = $(this).text().replace(/<(?:.|\n)*?>/gm, '');
//         current_text = current_text.replace(/\r?\n|\r/g, '');
//         current_text = $.trim(current_text);
        
//         return current_text == "Creditor Contacts" && $(this).attr('style');
//     }).parents('table[border = 1]').first().next('table').next('table');
    
//     creditor_tbl.find('tr').each(function(i, el) {
//         var key_tds = $(this).find('td').children('table').each(function() {
//             var tds = $(this).find('tr td');
//             var obj = {};
//             var bank_name = getTextValueFromTdByColumn(tds, 1);
            
//             var address = "";
//             var phone = "";
//             if (getTextValueFromTdByColumn(tds, 2)) {
//                 address = getTextValueFromTdByColumn(tds, 2);
//             }

//             if (getTextValueFromTdByColumn(tds, 3)) {
//                 phone = getTextValueFromTdByColumn(tds, 3);
//             }

//             if (bank_name) {
//                 obj = {
//                     'bank_name': bank_name,
//                     'address': address,
//                     'phone': phone
//                 }
//                 contactInfo.push(obj);
//             }
//         });
//     });
//     return contactInfo;
// }


function creditorAddressAssocForIQ() {
    var addressObj = {};
    var table = $("#CreditorContacts .rpt_content_table");
    table.find('tr').each(function(i, el) {
        var $tds = $(this).find('td');
        var key = $tds.eq(0).text();
        var key = $tds.eq(0).text();
        if (key != "") {
            var name = $tds.eq(0).text().replace(/<(?:.|\n)*?>/gm, '');
            name = name.replace(/\r?\n|\r/g, '');
            name = name.replace('_', '');
            name = name.replace('-', '');
            name = name.replace(/\s+/g, " ");
            name = name.trim();


            var address = $tds.eq(1).text().replace(/<(?:.|\n)*?>/gm, '');
            address = address.replace(/\r?\n|\r/g, '');
            address = address.replace('_', '');
            address = address.replace('-', '');
            address = address.replace(/\s+/g, " ");
            address = address.trim();

            if (name && address) {
                addressObj[name] = name + " : " + address;
                CREDITOR_ADDRESS_LIST_FOR_DF[name] = address;
            }
        }
    });

    return addressObj;
}

 /* ------creditor contacts End -------- */

// get creditor contacts from report and make select box.
function getDF() {
    var source_type = $('select[name=report_type]').val();

    //console.log('imran');
    //    var addressObj = {};
    //    if (source_type == 3) {
    //        //addressObj = getSmartCreditCreditorDropDown();
    //        addressObj = CREDIT_REPORT_ADDRESS_LIST;
    //    } else {
    //        
    //    }

    return CREDIT_REPORT_ADDRESS_LIST;

}



function SmartCreditAIAccounts() {
    var item_count = 1;
    var bankInfo = [];
    var account_html_by_key = {};
    var verbiage = '';

    $('.credit-report .crWhiteTradelineHeader b').each(function(i, el1) {
        var bank_table_html = $(this).parents('tr').first().html();
        var bank = $.trim($(this)
            .clone() //clone the element
            .children() //select all the children
            .remove() //remove all the children
            .end() //again go back to selected element
            .text());

        var endDropdownClass = 'smart-cerdit-subAccount-history-' + i;

        if (bank) {

            var header = bank;
            var trans_header = header;

            if (BANK_LIST_INDEX_LESS_ASSOC[header]) {
                trans_header = BANK_LIST_INDEX_LESS_ASSOC[header]
            }


            var trans = '<p ><span class="bg-yellow">' + trans_header + '</span>';
            var exp = '<p ><span class="bg-yellow">' + trans_header + '</span>';
            var equ = '<p ><span class="bg-yellow">' + trans_header + '</span>';

            var inconsistancy = '<span class="glyphicon glyphicon-remove " title="Inconsistency" style="color:red;font-size:14px;margin-top:5px"></span>';
            //var advice = '<span class="glyphicon glyphicon-plus advice-text" title="Inconsistency" style="font-size:14px;margin-top:5px;"></span>';
            var advice = '';
            var table = $(this).parent().parents('table').first().next('table').find('table.crLightTableBackground');
            var html = '';
            var quest = '&nbsp;&nbsp;<span class="glyphicon glyphicon-question-sign acct-quest" title="QUESTIONABLE REPORTED" style="color:red;font-size:16px;"></span>';

            var m = '<span style="color:red" title="Missing">M</span>';
            var u = '<span  style="color:red;" title="Unproven">-U</span>';
            var inc = '<span  style="color:red;" title="Inconsistency">-I</span>';


            var transType = 3;
            var equfType = 3;
            var expType = 3;
            var creditorObj = getSmartCreditAddressPhoneByBankName(bank);
            var current_bankInfo = [];
            var current_table = $(this).parent().parents('table').first().next('table').find('table.crLightTableBackground');
            table.find('tr').each(function(j, el2) {
                var obj = {};
                var tds = $(this).find('td');
                var key_tds = $(this).find('td b');
                var title = $.trim(key_tds.eq(0)
                    .clone() //clone the element
                    .children() //select all the children
                    .remove() //remove all the children
                    .end() //again go back to selected element
                    .text());
                var experian = getTextValueFromTdByColumn(tds, 2);
                var equifax = getTextValueFromTdByColumn(tds, 3);
                var mytrans = getTextValueFromTdByColumn(tds, 1);
                var text1 = "";
                var text2 = "";
                var text3 = "";
                var td0 = title;

                if (experian && experian != 'Experian') {

                    text2 = tds.eq(2).text().replace(/<(?:.|\n)*?>/gm, '');
                    text2 = text2.replace(/\r?\n|\r/g, '');
                    text2 = replaceAll(text2, '_', '');
                    text2 = replaceAll(text2, '-', '');
                    text2 = text2.replace(/\s+/g, " ");
                    text2 = $.trim(text2);
                    text2 = text2.replace('updatenegativepositive', '');
                } else if (experian && experian == 'Experian') {
                    return;
                    if (tds.eq(2).children('select').val()) {
                        expType = tds.eq(2).children('select').val();
                    }
                }

                if (equifax && equifax != 'Equifax') {

                    text3 = tds.eq(3).text().replace(/<(?:.|\n)*?>/gm, '');
                    text3 = text3.replace(/\r?\n|\r/g, '');
                    text3 = replaceAll(text3, '_', '');
                    text3 = replaceAll(text3, '-', '');
                    text3 = text3.replace(/\s+/g, " ");
                    text3 = $.trim(text3);
                    text3 = text3.replace('updatenegativepositive', '');
                } else if (equifax && equifax == 'Equifax') {
                    return;
                    if (tds.eq(3).children('select').val()) {
                        equfType = tds.eq(3).children('select').val();
                    }
                }

                if (mytrans && mytrans != 'TransUnion') {

                    text1 = tds.eq(1).text().replace(/<(?:.|\n)*?>/gm, '');
                    text1 = text1.replace(/\r?\n|\r/g, '');
                    text1 = replaceAll(text1, '_', '');
                    text1 = replaceAll(text1, '-', '');
                    text1 = text1.replace(/\s+/g, " ");
                    text1 = $.trim(text1);
                    text1 = text1.replace('updatenegativepositive', '');
                } else if (mytrans && mytrans == 'TransUnion') {
                    return;
                    if (tds.eq(1).children('select').val()) {
                        transType = tds.eq(1).children('select').val();
                    }
                }
                if (title) {
                    //                    obj = {
                    //                        'TransUnion': {account: text1, 'key_name': title},
                    //                        'Experian': {account: text2, 'key_name': title},
                    //                        'Equifax': {account: text3, 'key_name': title},
                    //                    }

                    current_bankInfo.push(obj);
                }

                text1 = text1.replace('M', '');
                text1 = text1.replace('-U', '');
                text1 = text1.replace('-I', '');

                text2 = text2.replace('M', '');
                text2 = text2.replace('-U', '');
                text2 = text2.replace('-I', '');

                text3 = text3.replace('M', '');
                text3 = text3.replace('-U', '');
                text3 = text3.replace('-I', '');

                if (td0 == 'Account #:' || td0 == 'Account Type:' || td0 == 'Account Type - Detail:') {
                    if (td0 == 'Account #:') {
                        if (text1 != '')
                            tds.eq(1).html(text1.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                        if (text2 != '')
                            tds.eq(2).html(text2.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                        if (text3 != '')
                            tds.eq(3).html(text3.replace(/\*/g, '<span class="bg-yellow acct-quest">*</span>') + quest);
                    }
                    trans += '<p ><span class="bg-yellow">' + td0 + '</span> &nbsp;&nbsp;&nbsp;<span class="bg-tra">' + text1 + '</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + text2 + '</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ">' + text3 + '</span> </p>';
                } else if (td0 == 'Account Status:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green"></span>');
                } else if (td0 == 'Monthly Payment:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green"></span>');
                } else if (td0 == 'Balance:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green" title=""></span>');
                } else if (td0 == 'High Credit:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green" title=""></span>');
                } else if (td0 == 'Past Due:') {
                    tds.eq(0).html(advice + '<span >' + td0 + '&nbsp; </span><span class="span-cl-green" title=""></span>');
                }

                if (td0 != 'Account #:') {
                    if ((text1 == '' || text1 == '-'))
                        tds.eq(1).html(text1 + m);
                    else {
                        if (text1 != text2 && text2 != '') {
                            tds.eq(1).html(text1 + inc);
                        } else {
                            tds.eq(1).html(text1 + u);
                        }
                    }

                    if (text2 == '' || text2 == '-')
                        tds.eq(2).html(text2 + m);
                    else {
                        if (text2 != text3 && text3 != '') {
                            tds.eq(2).html(text2 + inc);
                        } else {
                            tds.eq(2).html(text2 + u);
                        }
                    }
                    if (text3 == '' || text3 == '-')
                        tds.eq(3).html(text3 + m);
                    else {
                        if (text3 != text1 && text1 != '') {
                            tds.eq(3).html(text3 + inc);
                        } else {
                            tds.eq(3).html(text3 + u);
                        }
                    }
                }

            });
            var newaddress = "";
            var phone = "";
            if (creditorObj.hasOwnProperty('address') && creditorObj.address) {
                newaddress = creditorObj.address
            }

            if (creditorObj.hasOwnProperty('phone') && creditorObj.phone && creditorObj.phone != "BYM-AIL-ONLY") {
                phone = creditorObj.phone
            }
            var type = {
                    'TransUnion': transType,
                    'Experian': expType,
                    'Equifax': equfType,
                }
                //$(this).find('.hstry-header').first().find('p.span-cl-green').remove();
                //$(this).find('.hstry-header').first().append('<p class="span-cl-green">OBVIOUSLY PAY BILLS IN FULL ON TIME ALWAYS, DO NOT MISS , OR BE LATE OR HAVE INCOMPLETE PAYMENT IN ACCOUNT HISTORY</p>')
            var address = getContactAdd(item_count, trans_header);
            trans += '<p ><span class="bg-yellow">Address: </span> &nbsp;&nbsp;&nbsp;<span class="bg-tra">' + newaddress + '</span>';
            var negative = true;

            var dtype;
            var template;

            var template_df;

            var parent_table = $(this).parents('table').first();
            var parent_next_tbl = parent_table.next('table');

            var has_chargeoff = false;
            var has_medical = false;
            var has_collection = false;
            var has_student = false;

            parent_next_tbl.find('td').each(function() {
                if ($(this).is(':contains("Collection/Chargeoff")') ||
                    $(this).is(':contains("Chargeoff")') ||
                    $(this).is(':contains("Writtenoff")')) {

                    has_chargeoff = true;
                    return false;

                } else if ($(this).is(':contains("Medical")')) {

                    has_medical = true;
                    return false;

                } else if ($(this).is(':contains("Collection")')) {

                    has_collection = true;
                    return false;

                } else if ($(this).is(':contains("Student")') ||
                    $(this).is(':contains("Student loan")') ||
                    $(this).is(':contains("subsidized")') ||
                    $(this).is(':contains("unsubsidized")') ||
                    $(this).is(':contains("SAllIE MAE")')) {

                    has_student = true;
                    return false;
                }
            });

            if (has_chargeoff) {
                dtype = 7;
                template = 'COFF-Ew1L4D1-bureau_4';
                template_df = 'COFF-Ew1L3D1-df-creditor_3';
            } else if (has_medical) {
                if ($(this).find(".hstry-120 ").length > 0 || $(this).find(".hstry-150 ").length > 0 || $(this).find(".hstry-180 ").length > 0) {
                    dtype = 6;
                    template = 'MCOL-Ew1L7D1-bureau_7';
                    template_df = 'MCOL-Ew1L8D1-df-creditor_8';
                } else {
                    $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                    negative = false;
                    dtype = 10;
                    template = 'AUDIT-Ew1L1D1-audit_40';
                }
            } else if (has_collection) {
                if ($(this).find(".hstry-120 ").length > 0 || $(this).find(".hstry-150 ").length > 0 || $(this).find(".hstry-180 ").length > 0) {
                    dtype = 5;
                    template = 'NMCOL-Ew1L5D1-bureau_5';
                    template_df = 'NMCOL-Ew1L6D1-df-creditor_6';
                } else {
                    $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                    negative = false;
                    dtype = 10;
                    template = 'AUDIT-Ew1L1D1-audit_40';
                }
            } else if (has_student) {
                var count = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) + ($(this).find(".hstry-90 ").length) + ($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
                if (count > 3) {
                    dtype = 4;
                    template = 'SL3-Ew1L11D1-bureau_11';
                    template_df = 'SL3-Ew1L12D1-df-creditors_12';
                } else if (late_counts > 1 && late_counts <= 3) {
                    dtype = 4;
                    template = 'SL12-Ew1L9D1-bureau_9';
                    template_df = 'SL12-Ew1L10D1-df-creditor_10';
                } else {
                    $('.check-aa', '#main-content-' + item_count).prop('checked', true);
                    negative = false;
                    dtype = 10;
                    template = 'AUDIT-Ew1L1D1-audit_40';
                }
            }
            // check for non student loan deogatory (3+ lates) and deliquency (1 or 2 lates)
            // else if( $(this).is(':contains("LATE")') || $(this).is(':contains("PAST DUE")')){
            //     var count = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) +($(this).find(".hstry-90 ").length) +($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
            //     if(count>3 ) setCBValues(item_count,address,3,'NLP3-Ew1LPRD1-bureau_17',html);
            //     else if(count>0<3) setCBValues(item_count,address,3,'NLP12-Ew1L1D1-bureau_1',html);
            // }
            else {
                var late_counts = ($(this).find(".hstry-120 ").length) + ($(this).find(".hstry-150 ").length) + ($(this).find(".hstry-180 ").length) + ($(this).find(".hstry-other ").length) + ($(this).find(".hstry-90 ").length) + ($(this).find(".hstry-60 ").length) + ($(this).find(".hstry-30 ").length);
                if (late_counts > 3) {
                    dtype = 3;
                    template = 'NLP3-Ew1LPRD1-bureau_17';
                    template_df = 'NLP3-Ew1LPRx1D1-df-creditor_17';
                } else if (late_counts > 1 && late_counts <= 3) {
                    dtype = 3;
                    template = 'NLP12-Ew1L1D1-bureau_1';
                    template_df = 'NLP12-Ew1L1D1-df-creditor_1';
                } else {
                    $('.check-aa', '#main-content-' + item_count).prop('checked', true); //check audit analysis checkbox in destination
                    negative = false;
                    dtype = 10;
                    template = 'AUDIT-Ew1L1D1-audit_40';
                }

            }


            if (negative) {
                $('.span-cl-green', '#main-content-' + item_count).remove();
                $('.advice-text', '#main-content-' + item_count).remove();
                $(this).find('.span-cl-green').remove();
                $(this).find('.advice-text').remove();
                var ph_table = $(this).find('.addr_hsrty').first();
                var tdlength = ph_table.find(" tr:first > td").length;

                // verbiage = '<p >My state and the applicable federal regulations and standards for proper lawful reporting requires that any injurious claim of delinquency and or derogatoriness be factual and physically verified as being fully True, ACCURATE, COMPLETE, TIMELY, of a known ownership of responsibility, and else wise undeniably VALIDATED and further mandates that all such allegations are reported in a perfect and certifiable compliant manner such as in relation to the mandatorily perfect correct and complete certificated Metro 2 Format reporting standard(s). Being that the noted allegation(s) of delinquencies and derogatoriness\'s are reported as one or more fallible conditions of being "missing or incomplete", inconsistent, questionable, and or else wise UNPROVEN reporting. Inability to validate and certify compliant reporting is grounds to demand eradication of claims, and this is my REBUTTAL to  ANY AND ALL NEGATIVE ACCUSATIONS and my rightful DEMAND TO REMOVE such claims from REPORTING!</p>';

                var tds0, tds1, tds2;
                var m = '<span style="color:red" title="Missing">M</span>';
                var u = '<span  class="cl-diff" title="Unproven">-U</span>';
                var inc = '<span  class="cl-diff" title="Inconsistency">-I</span>';
                ph_table.find('tr').each(function(i, el) {
                    if (i == 0 || i == 1)
                        return true;
                    else if (i == 2)
                        tds0 = $(this).find('td');
                    else if (i == 3)
                        tds1 = $(this).find('td');
                    else if (i == 4)
                        tds2 = $(this).find('td');
                })

                if (tds0)
                    tds0.each(function(i, el) {
                        if (i == 0) {
                            tds0.eq(i).removeClass("rowAlt");
                            tds1.eq(i).removeClass("rowAlt");
                            tds2.eq(i).removeClass("rowAlt");
                            return true;
                        }
                        var text1 = $.trim(tds0.eq(i).text());
                        var text2 = $.trim(tds1.eq(i).text());
                        var text3 = $.trim(tds2.eq(i).text());

                        if (text1 == '')
                            tds0.eq(i).html(m);
                        else if (text1 != 'OK') {
                            if (text1 != text2) {
                                if (text2 == 'OK' && text3 == 'OK')
                                    tds0.eq(i).html(text1 + u);
                                else if (text2 == '' && text3 == '')
                                    tds0.eq(i).html(text1 + u);
                                else
                                    tds0.eq(i).html(text1 + inc);
                            } else {
                                tds0.eq(i).html(text1 + u);
                            }

                        }

                        if (text2 == '')
                            tds1.eq(i).html(m);
                        else if (text2 != 'OK') {
                            if (text2 != text3) {
                                if (text1 == 'OK' && text3 == 'OK')
                                    tds1.eq(i).html(text2 + u);
                                else if (text1 == '' && text3 == '')
                                    tds1.eq(i).html(text2 + u);
                                else
                                    tds1.eq(i).html(text2 + inc);
                            } else {
                                tds1.eq(i).html(text1 + u);
                            }

                        }
                        if (text3 == '')
                            tds2.eq(i).html(m);
                        else if (text3 != 'OK') {
                            if (text3 != text1) {
                                if (text1 == 'OK' && text2 == 'OK')
                                    tds2.eq(i).html(text3 + u);
                                else if (text1 == '' && text2 == '')
                                    tds2.eq(i).html(text3 + u);
                                else
                                    tds2.eq(i).html(text3 + inc);
                            } else {
                                tds2.eq(i).html(text1 + u);
                            }

                        }
                    })


            } else {
                $('.acct-quest', '#main-content-' + item_count).remove();


                //$('.bg-yellow','#main-content-'+item_count).remove();
            }
            var full_table_grab = $(this).parents('table').first().parents('tr').first().html();
            full_table_grab = full_table_grab.replace(header, trans_header);

            var img = '<div  style="width:100%;" class="acct-cb-img"><table class="table rpt_content_table rpt_content_header rpt_table4column ng-scope" >' + full_table_grab + '</table></div>';

            var br = '<p class="cb-br" >*****************************************************************************************************</p>';
            verbiage = getVerbiage();
            html = trans + img + verbiage + br; // merge all three beauroes
            //console.log('header', header);
            if (html) {
                account_html_by_key[header] = html;
                $('#credit-report-content-modal .modal-body .content-data').append(html);
            }

        }
    });

    return account_html_by_key;
}


function getVerbiage() {
    var verbiage = `<p 
    style="margin-top:10px;width:100%;word-break: break-word;">
    <span style="background-color: yellow">
    My state and the applicable federal regulations 
    and standards for proper lawful reporting 
    requires that any injurious claim of delinquency 
    and or derogatoriness be factual and physically 
    verified as being fully True, ACCURATE, COMPLETE, 
     TIMELY, of a known ownership of responsibility, 
    and else wise undeniably VALIDATED and further 
    mandates that all such allegations are reported in a perfect and 
    certifiable compliant manner such as in relation to the mandatorily 
    perfect correct and complete certificated Metro 2 Format reporting 
    standard(s). Being that the noted allegation(s) of 
    delinquencies and derogatoriness\'s are reported as one or more 
    fallible conditions of being "missing or incomplete", 
    inconsistent, questionable, and or else wise UNPROVEN reporting. 
    Inability to validate and certify compliant reporting is grounds to 
    demand eradication of claims, and this is my REBUTTAL to  ANY AND ALL 
    NEGATIVE ACCUSATIONS and my rightful DEMAND TO REMOVE such claims from 
    REPORTING!
    </span>
    </p>`;

    return verbiage;
}

function getSmartCreditAddressPhoneByBankName(bank_name) {
    var obj = "";
    var creditorInfo = creditorContactsSmartCredit();
    for (var i in creditorInfo) {
        if (creditorInfo[i].bank_name == bank_name) {
            obj = creditorInfo[i];
            break;
        }
    }

    return obj;
}

function getTextValueFromTdByColumn(tds, col) {
    var text = $.trim(tds.eq(col)
        .clone() //clone the element
        .children() //select all the children
        .remove() //remove all the children
        .end() //again go back to selected element
        .text());
    text = text.replace(/\r?\n|\r/g, '');
    if (text) {
        return text;
    } else {
        return null;
    }
}


function setSequenceNumberForAccount(data) {
    var tables = $(".credit-report .crPrint");

    var banObj = [];
    var bankArray = [];
    var temp_array = [];
    var bankList = [];


    var all_crditors_contacts_IQ = getAllCreditorContactsByName()
    tables.find('tr').each(function(i1, el) {
        var $tds = $(this).find('td');
        var bank_name = "";
        var firstTd = $tds.eq(0).children('ng-include').children('.sub_header');
        bank_name = firstTd.clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '');
        bank_name = bank_name.replace(/\r?\n|\r/g, '');
        bank_name = bank_name.replace('_', '');
        bank_name = bank_name.replace('-', '');
        bank_name = bank_name.replace(/\s+/g, " ");
        bank_name = bank_name.trim();
        bank_name = bank_name.replace('updatenegativepositive', '');
        bank_name = $.trim(bank_name);
        if (bank_name != "") {
            bankList.push(bank_name);
        }
    });

    $('.credit-report .sub_header').each(function(i, el) {


        var current_acc_info = findAccountInfoFromTable($(this).next('table.rpt_content_table'));
        var $tds = $(this).find('td');
        var bank_name = "";

        //var firstTd = $tds.eq(0).children('ng-include').children('.sub_header');
        bank_name = $(this).clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '');
        var nested_bank = $.trim($(this).children('ng.ng-binding').clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, ''));

        bank_name = bank_name.replace(/\r?\n|\r/g, '');
        bank_name = bank_name.replace('_', '');
        bank_name = bank_name.replace('-', '');
        bank_name = bank_name.replace(/\s+/g, " ");
        bank_name = bank_name.trim();
        bank_name = bank_name.replace('updatenegativepositive', '');
        bank_name = $.trim(bank_name);

        // console.log('current_acc',current_acc_info,bank_name,nested_bank)

        if ((bank_name != "" || nested_bank) && bank_name != "Bankruptcy" && bank_name != "Risk Factors") {

            var currentClass = 'current_bank_' + i;

            var current_elem = null;
            if (!$(this).hasClass('publicrecordinfo')) {
                current_elem = $(this);

            }

            if (!bank_name && nested_bank) {
                bank_name = nested_bank;
            }

            temp_array.push(bank_name);
            var bank_name_with_count_value = bank_name + getKeyIndex(bank_name, temp_array, bankList);
            //            if(bank_name_with_count_value){
            //                 $(this).text(bank_name_with_count_value);
            //            }
            var key_name_new = "";
            var bank_name_with_count_value1 = bank_name_with_count_value;

            if (bank_name_with_count_value1) {
                $(this).text(bank_name_with_count_value1);
            }



            var obj = { 'index': i, 'bank_name': bank_name_with_count_value1 };

            $(this).nextAll('table').first().find('th').eq(0).attr('id', 'bank_address_text_' + i).css({ 'color': 'black' }).text(all_crditors_contacts_IQ[bank_name]);
            // my change code


            $(this).nextAll('table').first().find('th.headerTUC').children('select').attr('id', 'selectiq_tuc_' + i);
            $(this).nextAll('table').first().find('th.headerTUC').children('select').attr('class', 'banks review_type ' + currentClass);
            $(this).nextAll('table').first().find('th.headerEXP').children('select').attr('id', 'selectiq_exp_' + i);
            $(this).nextAll('table').first().find('th.headerEXP').children('select').attr('class', 'banks review_type ' + currentClass);
            $(this).nextAll('table').first().find('th.headerEQF').children('select').attr('id', 'selectiq_eqf_' + i);
            $(this).nextAll('table').first().find('th.headerEQF').children('select').attr('class', 'banks review_type ' + currentClass);

        }
    });



    //alert(isFirstReport);




}


function getKeyIndex(value, tmp_array, total_array) {

    var result = "";
    var exist_in_temp = 0;
    var total_exist = count_array_values(total_array, value);

    if (tmp_array == "" || total_array == "" || total_exist < 2) {
        return "";
    } else {

        exist_in_temp = count_array_values(tmp_array, value);
    }

    return "-" + exist_in_temp;

}

function count_array_values(my_array, match) {
    var count = 0;

    $.each(my_array, function(i, value) {
        if (value == match) {
            count++;
        }
    })


    return count;
}


function getEpicBankInfoFromHTML(elem, account_html_by_key) {
    if (!elem) {
        return false;
    }


    var divlen = $(elem).attr('name').replace('auto_generate_image_', '');

    var count = 0;
    if ($(elem).prop('checked')) {
        var html = '';
        var report_type = $('select[name=report_type]').val();
        var is_personal_info = isEnhanceCheckedByValue(divlen, 'negative_item_');
        var is_inquiry = isEnhanceCheckedByValue(divlen, 'negative_inq_item_');
        var is_multiple_negativ_attack = isEnhanceCheckedByValue(divlen, 'item_bank_');
        var is_public_attack = isEnhanceCheckedByValue(divlen, 'public_negative_item_');

        if (is_personal_info) {
            $('input[name="negative_item_' + divlen + '[]"]').each(function() {
                if ($(this).prop('checked')) {
                    var current_bank = $(this).data('view');
                    current_bank = $.trim(current_bank);

                    if (account_html_by_key[current_bank]) {
                        html += account_html_by_key[current_bank];
                    }
                    count++;
                }
            });

            if (count == 0) {
                $(elem).prop('checked', false);
                alert('Please select at least one personal information.');
            }

            if (html) {
                $('#inputformId').append("<input type='hidden' name='epic_personal_info_" + divlen + "' value=''/>");
                $('input[name="epic_personal_info_' + divlen + '"]').val(html);
            }

        }

        if (is_inquiry) {
            if (itemDataSetForEpic('negative_inq_item_', "epic_inquiry_section_html_", divlen, account_html_by_key, "Please select at least one inquiry item.", "inquiry")) {
                $(elem).prop('checked', false);
            }
        }

        if (is_multiple_negativ_attack) {
            if (itemDataSetForEpic('item_bank_', "epic_every_section_html_", divlen, account_html_by_key, "Please select at least one inquiry item.", "inquiry")) {
                $(elem).prop('checked', false);
            }
            //            $('input[name="item_bank_'+divlen+'[]"]').each(function(){
            //                if($(this).prop('checked')){
            //                    var current_bank = $(this).data('view');
            //                    current_bank = $.trim(current_bank);
            //                    if(account_html_by_key[current_bank]){
            //                        html += account_html_by_key[current_bank];
            //                    }
            //
            //                    count++;
            //                }
            //            });
            //        
            //            if(count == 0){
            //                $(elem).prop('checked',false);
            //                alert('Please select at least one negative item.');
            //            }
            //            
            //            if(html){
            //                $('#inputformId').append("<input type='hidden' name='epic_every_section_html_"+divlen+"' value=''/>");
            //                $('input[name="epic_every_section_html_'+divlen+'"]').val(html);
            //            }

        }

        if (is_public_attack) {
            //console.log('dddddd',account_html_by_key);
            if (itemDataSetForEpic('public_negative_item_', "epic_public_section_html_", divlen, account_html_by_key, "Please select at least one public item.", "public")) {
                $(elem).prop('checked', false);
            }
        }

    }
}



function itemDataSetForEpic(selected_input, new_variable_name, divlen, account_html_by_key, error_message = "", type = "") {
    var count = 0;
    var html = "";
    var result = false;
    //console.log('account_html_by_key111',account_html_by_key)
    //$('input[name="'+new_variable_name+divlen+'"]').remove();
    if (type == "public") {
        if (account_html_by_key) {
            html = account_html_by_key;
            count = 1;
        }
    } else {
        var inq_name_array = [];
        $('input[name="' + selected_input + divlen + '[]"]').each(function() {
            if ($(this).prop('checked')) {
                var current_bank = $(this).data('view');
                current_bank = $.trim(current_bank);
                if (type == "inquiry") {
                    current_bank = $.trim($(this).parent('li').text());
                }

                // if (BANK_LIST_INDEX_LESS_ASSOC[current_bank]) {
                //     current_bank = BANK_LIST_INDEX_LESS_ASSOC[current_bank];
                // }

                //console.log('current_bank', current_bank, account_html_by_key)

                if (account_html_by_key[current_bank]) {
                    html += account_html_by_key[current_bank];
                    inq_name_array.push(current_bank);
                }

                count++;
            }
        });
    }
    if (count == 0) {
        result = true;
        alert(error_message);
    }

    if (html) {
        $('input[name="' + new_variable_name + divlen + '"]').remove()
        $('#inputformId').append("<input type='hidden' name='" + new_variable_name + divlen + "' value=''/>");
        $('input[name="' + new_variable_name + divlen + '"]').val(html);

    }

    return result;
}


function setSmartCreaditAccountHistorySequenceNumber() {

    var account_history_tables = $('#AccountHistory:contains(Account History)').next('td');


    var temp_array = [];
    var bankList = [];
    $('.credit-report .crWhiteTradelineHeader b').each(function(k, elk) {
        var bank = $.trim($(this)
            .clone() //clone the element
            .children() //select all the children
            .remove() //remove all the children
            .end() //again go back to selected element
            .text().replace(/<(?:.|\n)*?>/gm, ''));
        bankList.push(bank);
    });
    //console.log('bankList',bankList);
    $('.credit-report .crWhiteTradelineHeader b').each(function(i, el1) {
        var bank = $.trim($(this)
            .clone() //clone the element
            .children() //select all the children
            .remove() //remove all the children
            .end() //again go back to selected element
            .text().replace(/<(?:.|\n)*?>/gm, ''));
        var temp_bank = bank;
        var endDropdownClass = 'smart-cerdit-subAccount-history-' + i;
        temp_array.push(bank);
        //my bank area
        //console.log('temp_bank',temp_bank)
        var bank = bank + getSmartCreditKeyIndex(bank, temp_array)
        var new_bank = temp_bank + getKeyIndex(temp_bank, temp_array, bankList);

        if (bank) {
            $(this).attr('data-bank', temp_bank)
            $(this).text(new_bank);
        }
    });




}


function getSmartCreditKeyIndex(value, tmp_array) {
    var total_array = [];
    $('.crWhiteTradelineHeader b').each(function(i, el1) {
        var bank = $.trim($(this)
            .clone()
            .children()
            .remove()
            .end()
            .text().replace(/<(?:.|\n)*?>/gm, ''));
        if (bank) {
            total_array.push(bank);
        }
    });
    var result = "";
    var exist_in_temp = 0;
    var total_exist = count_array_values(total_array, value);

    if (tmp_array == "" || total_array == "" || total_exist < 2) {
        return "";
    } else {

        exist_in_temp = count_array_values(tmp_array, value);
    }

    return "-" + exist_in_temp;

}

function AIpersonalInfo() {

    var account_html_by_key = {};
    var table = '';
    $(' .credit-report .rpt_fullReport_header').each(function() {
        var head = $.trim($(this).text());
        if (head == 'Personal Information') {
            table = $(this).next().next();
            return false; // exit each loop.
        }
    })

    $('.all-select').remove(); //remove all dropdowns inside public report of report
    var html = '';

    if (table)
        table.find('tr').each(function(i, el) {
            html = '';
            if (i == 0 || i == 1) return true; // skip first tr
            var tds = $(this).find('td');
            var td0 = $.trim(tds.eq(0).text());
            var text1 = $.trim(tds.eq(1).text());
            var text2 = $.trim(tds.eq(2).text());
            var text3 = $.trim(tds.eq(3).text());

            var trans = '<p ><span class="bg-yellow">' + td0 + '</span>&nbsp;&nbsp;&nbsp;<span class="bg-tra">' + text1 + '</span><span class="bg-exp">&nbsp;&nbsp;&nbsp;&nbsp;' + text2 + '</span><span class="bg-equ">&nbsp;&nbsp;&nbsp;&nbsp;' + text3 + '</span></p>';

            tds.eq(1).html('<span class="bg-yellow">' + text1 + '</span>');
            tds.eq(2).html('<span class="bg-yellow">' + text2 + '</span>');
            tds.eq(3).html('<span class="bg-yellow">' + text3 + '</span>');

            var img = '<div style="width:80%;" class="bg-white"><div class="rpt_fullReport_header">Personal Information</div><table class="rpt_content_table rpt_content_header rpt_table4column"><tbody><tr><th></th><th class="headerTUC">TransUnion</th><th class="headerEXP" ng-show="true">Experian</th><th class="headerEQF" ng-show="true">Equifax</th></tr>' + $(this).html() + '</tbody></table></div>';

            var name = "XXXXX";
            var p1 = '';
            var td2 = td0;
            if (td0 == 'Name:') {
                td2 = "FIRST & LAST NAME";
                name = CLIENT_INFO_FROM_DB['name'] //$('#name').val();
            } else if (td0 == 'Also Known As:') {
                td2 = "FIRST & LAST NAME";
                name = CLIENT_INFO_FROM_DB['name'] //$('#name').val();
            } else if (td0 == 'Former:') {
                td2 = "FIRST & LAST NAME";
                name = CLIENT_INFO_FROM_DB['name'] //$('#name').val();
            } else if (td0 == 'Date of Birth:') {
                name = $('#birth_date').val();
                //name = new Date(name);
                //name = name.toLocaleString('en-us', { month: 'long' }) + ' ' + name.getDate() + ' ' + name.getFullYear();
            } else if (td0 == 'Current Address(es):' || td0 == 'Previous Address(es):') {
                name = CLIENT_INFO_FROM_DB['address'];
                td2 = "Current Address";
            } else {
                td2 = td0;
            }
            p1 = td0 + '(s) of <span class="bg-tra">' + text1 + '</span>' + ' and ' + '<span class="bg-exp">' + text2 + '</span>  and <span class="bg-equ">' + text3 + '</span>';

            var verbiage = '<p class="bg-yellow2" style="font-size:14px;width:98%;" >REMOVE the display reported ' + p1 + ' as my REQUISITE REPORTED CURRENT CORRECT COMPLETE ' + td2 + ' is <span class="bg-tra">' + name + '</span>. I DO NOT AUTHORIZE you to retain nor report any not proven true correct valid and required reported personal identifier information that is not in exact agreement with my submitted FACTUALLY CORRECT CURRENT PERSONAL IDENTIFIERS as indicated.</p>';
            if (td0 == 'Employers:') {
                verbiage = '<p class="bg-yellow2" style="font-size:14px;width:98%;">Please remove the reported allegations of employer(s) of  <span class="bg-tra">' + text1 + '</span>' + ' and ' + '<span class="bg-exp">' + text2 + '</span>  and <span class="bg-equ">' + text3 + '</span> as there is not federal reporting requisites to report alleged employers.I DO NOT AUTHORIZE you to retain nor report any personal identifier data of which is not EACH of being VERIFIABLE, TRUE, CORRECT, COMPLETE, TIMELY, or elsewise documented VALIDATED, so do NOT!</p>';
            }

            var br = '<p class="cb-br" >*****************************************************************************************************</p>';
            html += trans + img + verbiage + br; // merge all three beauroes
            if (html) {
                account_html_by_key[td0.replace(":", "")] = html;
            }
        });

    return account_html_by_key;
}


function SmartCreditAIpersonalInfo() {

    var account_html_by_key = {};
    var table = $('#personalInfo:contains(Personal Information)').parents('table').next('table');
    var html = '';
    //console.log('table',table)
    if (table)
        table.find('tr').each(function(i, el) {
            html = '';
            if (i == 0 || i == 1)
                return;

            var tds = $(this).find('td');
            var $key_tds = $(this).find('td span b');
            var key = $key_tds.eq(0).clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '');
            var obj = {};
            var text1 = "";
            var text2 = "";
            var text3 = "";

            if (key != "") {

                var tq_eq_1 = tds.eq(1);
                text1 = tq_eq_1.clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '');
                if (tq_eq_1.has('span').length) {
                    text1 = tq_eq_1.children('span').text().replace(/<(?:.|\n)*?>/gm, '');
                }
                text1 = text1.replace(/\r?\n|\r/g, '');
                text1 = text1.replace('_', '');
                text1 = text1.replace('-', '');
                text1 = text1.replace(/\s+/g, " ");
                text1 = $.trim(text1);
                text1 = text1.replace('updatenegativepositive', '');

                var tq_eq_2 = tds.eq(2);

                text2 = tq_eq_2.clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '');
                if (tq_eq_2.has('span').length) {
                    text2 = tq_eq_2.children('span').text().replace(/<(?:.|\n)*?>/gm, '');
                }
                text2 = text2.replace(/\r?\n|\r/g, '');
                text2 = text2.replace('_', '');
                text2 = text2.replace('-', '');
                text2 = text2.replace(/\s+/g, " ");
                text2 = $.trim(text2);
                text2 = text2.replace('updatenegativepositive', '');

                var tq_eq_3 = tds.eq(3);
                text3 = tq_eq_3.clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '');
                if (tq_eq_3.has('span').length) {
                    text3 = tq_eq_3.children('span').text().replace(/<(?:.|\n)*?>/gm, '');
                }
                text3 = text3.replace(/\r?\n|\r/g, '');
                text3 = text3.replace('_', '');
                text3 = text3.replace('-', '');
                text3 = text3.replace(/\s+/g, " ");
                text3 = $.trim(text3);
                text3 = text3.replace('updatenegativepositive', '');

                var key_name = key.replace(/<(?:.|\n)*?>/gm, '');
                key_name = key.replace(/\r?\n|\r/g, '');
                key_name = key.replace(':', " ");
                key_name = key.replace(/\s+/g, " ");
                key_name = $.trim(key);
                var td0 = key_name;
                tds.eq(1).html('<span class="bg-yellow">' + text1 + '</span>');
                tds.eq(2).html('<span class="bg-yellow">' + text2 + '</span>');
                tds.eq(3).html('<span class="bg-yellow">' + text3 + '</span>');
                var trans = '<p style="display:block"><span class="crTableBackground">' + td0 + '</span>&nbsp;&nbsp;&nbsp;<span class="crTableBackground">' + text1 + '</span><span class="crTableBackground">&nbsp;&nbsp;&nbsp;&nbsp;' + text2 + '</span><span class="crTableBackground">&nbsp;&nbsp;&nbsp;&nbsp;' + text3 + '</span></p>';
                trans = "";


                var img = '<div style="width:80%;" class="bg-white"><div class="sectionHeader">Personal Information</div><table class="" width="560"><tbody><tr class="crTableHeader"><th></th><th class="tranunionHeaderColum">TransUnion</th><th class="experianHeaderColum" ng-show="true">Experian</th><th class="equifaxHeaderColum" ng-show="true">Equifax</th></tr>' + $(this).html() + '</tbody></table></div>';

                var name = "XXXXX";

                var p1 = '';
                var td2 = td0;
                if (td0 == 'CREDIT REPORT DATE:') {
                    name = CLIENT_INFO_FROM_DB['today_date'];
                    name = new Date(name);
                    name = name.toLocaleString('en-us', { month: 'long' }) + ' ' + name.getDate() + ' ' + name.getFullYear();
                } else if (td0 == 'NAME:') {
                    td2 = "FIRST & LAST NAME";
                    name = CLIENT_INFO_FROM_DB['name'];
                } else if (td0 == 'ALSO KNOWN AS:') {
                    td2 = "FIRST & LAST NAME";
                    name = CLIENT_INFO_FROM_DB['name'];
                } else if (td0 == 'FORMER:') {
                    td2 = "FIRST & LAST NAME";
                    name = CLIENT_INFO_FROM_DB['name'];
                } else if (td0 == 'DATE OF BIRTH:') {
                    name = $('#birth_date').val();
                    //name = new Date(name);
                    //name = name.toLocaleString('en-us', { month: 'long' }) + ' ' + name.getDate() + ' ' + name.getFullYear();
                } else if (td0 == 'CURRENT ADDRESS:' || td0 == 'PREVIOUS ADDRESS:' || td0 == 'PREVIOUSADDRESS:') {
                    name = CLIENT_INFO_FROM_DB['address'];
                    td2 = "Current Address";
                } else {
                    td2 = td0;
                }


                p1 = td0 + '(s) of <span class="crTableBackground">' + text1 + '</span>' + ' and ' + '<span class="crTableBackground">' + text2 + '</span>  and <span class="crTableBackground">' + text3 + '</span>';
                //p1 = "";
                var verbiage = '<p class="bg-yellow2" style="font-size:14px;width:98%;" >REMOVE the display reported ' + p1 + ' as my REQUISITE REPORTED CURRENT CORRECT COMPLETE ' + td2 + ' is <span class="bg-tra">' + name + '</span>. I DO NOT AUTHORIZE you to retain nor report any not proven true correct valid and required reported personal identifier information that is not in exact agreement with my submitted FACTUALLY CORRECT CURRENT PERSONAL IDENTIFIERS as indicated.</p>';
                if (td0 == 'EMPLOYER:') {
                    verbiage = '<p class="bg-yellow2" style="font-size:14px;width:98%;">Please remove the reported allegations of employer(s) of';

                    if (text1) {
                        verbiage += ' <span class="bg-tra">' + text1 + '</span>';
                    }

                    if (text2) {
                        verbiage += ' and ' + '<span class="bg-exp">' + text2 + '</span>'
                    }

                    if (text3) {
                        verbiage += ' and <span class="bg-equ">' + text3 + '</span>';
                    }

                    verbiage += ' as there is not federal reporting requisites to report alleged employers.I DO NOT AUTHORIZE you to retain nor report any personal identifier data of which is not EACH of being VERIFIABLE, TRUE, CORRECT, COMPLETE, TIMELY, or elsewise documented VALIDATED, so do NOT!</p>';
                }

                var br = '<p class="cb-br" >*****************************************************************************************************</p>';
                html = img + trans + verbiage + br; // merge all three beauroes

                if (html) {
                    account_html_by_key[td0.replace(":", "")] = html;
                }

            }

        });

    return account_html_by_key;
}


function AIInquiry() {

    var account_html_by_key = [];
    var table = $('#Inquiries').find('.rpt_content_table').first();
    $('.inquiries').remove();
    var item_count = 1;
    var inq_name_array = [];
    var key_array = [];
    table.find('tr').each(function(i, el) {

        if (i == 0) return true; // skip first tr
        //if(i>1) return true; // skip first tr
        //if(item_count>0) addContent();//add new content box if not first.
        var trans = '<p ><span class="bg-yellow">Inquiries</span></p>';
        var exp = '<p ><span class="bg-yellow">Inquiries</span></p>';
        var equ = '<p ><span class="bg-yellow">Inquiries</span></p>';

        var tds = $(this).find('td');
        var td0 = $.trim(tds.eq(0).text());
        var text1 = $.trim(tds.eq(1).text());
        var text2 = $.trim(tds.eq(2).text());
        var text3 = $.trim(tds.eq(3).text());

        var address = getContactAdd(item_count, td0);
        //var address = $('#select-df-'+item_count+' option:contains('+td0+')').val();

        trans += '<p><span class="bg-yellow">CREDITOR NAME</span>&nbsp;&nbsp;&nbsp;<span class="bg-tra">' + td0 + '</span> </p>';
        exp += '<p><span class="bg-yellow">CREDITOR NAME</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + td0 + '</span> </p>';
        equ += '<p><span class="bg-yellow">CREDITOR NAME</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ" >' + td0 + '</span> </p>';

        trans += '<p><span class="bg-yellow">INQUIRY DATE</span>&nbsp;&nbsp;&nbsp;<span class="bg-tra">' + text2 + '</span> </p>';
        exp += '<p><span class="bg-yellow">INQUIRY DATE</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + text2 + '</span> </p>';
        equ += '<p><span class="bg-yellow">INQUIRY DATE</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ" >' + text2 + '</span> </p>';

        trans += '<p><span class="bg-yellow"> CREDITOR ADDRESS</span>&nbsp;&nbsp;&nbsp;<span class="bg-tra">' + address + '</span> </p>';
        exp += '<p><span class="bg-yellow"> CREDITOR ADDRESS</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + address + '</span> </p>';
        equ += '<p><span class="bg-yellow"> CREDITOR ADDRESS</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ" >' + address + '</span> </p>';

        tds.eq(1).html('<span class="bg-yellow">' + text1 + '</span>');
        tds.eq(2).html('<span class="bg-yellow">' + text2 + '</span>');
        tds.eq(3).html('<span class="bg-yellow">' + text3 + '</span>');

        var img = '<div style="width:80%;" class="bg-white"><div class="rpt_fullReport_header">Inquiries</div><table class="help_text"><tbody><tr><td class="help_text_img"><img src="https://www.identityiq.com/images/tu/info_icon.gif"></td><td>Below are the names of people and/or organizations who have obtained a copy of your Credit Report. Inquiries such as these can remain on your credit file for up to two years.</td></tr></tbody></table><table class="rpt_content_table rpt_content_header rpt_table4column"><tbody><tr><th class="tbheader" width="30%">Creditor Name</th><th class="tbheader" width="30%">Type of Business</th><th class="tbheader" width="15%">Date of inquiry</th><th class="tbheader" width="15%"> Credit Bureau</th></tr>' + $(this).html() + '</tbody></table></div>';

        var verbiage = "<p >This INQUIRY to date has NOT been proven COMPLIANTLY REPORTED such as to posses factually demonstrated document PHYSICALLY VERIFIED PROOF of adequate lawful PERMISSIBLE PURPOSE achieved from accused and LEGALLY IDENTIFIED consumer and or from an entity otherwise with authority above and beyond said accused consumer's knowledge or refusal.COMPLIANCE OF REPORTING, even for true valid claims is a MINIMAL CRITERIA of reporting so ERADICATE this inquiry allegation HERE AND NOW. Additionally , remove from reporting any associated ALLEGED delinquencies and or derogatoriness , as there can not be ASSUMPTIONS of compliant reporting!</p>";
        var br = '<p class="cb-br" >*****************************************************************************************************</p>';
        //var html = trans +br + exp + br + equ + br +img  + verbiage + br ; // merge all three beauroes
        var html = trans + br + exp + br + equ + br + img + verbiage + br; // merge all three beauroes
        //console.log('account_html_by_key',td0);
        //console.log('account_html_by_key1111',img);
        if (html && !($.inArray(td0.replace(":", ""), inq_name_array) !== -1)) {

            inq_name_array.push(td0.replace(":", ""));

        }

        if (html && td0.replace(":", "")) {
            var obj = {};
            obj['name'] = td0.replace(":", "");
            obj['value'] = html;
            account_html_by_key.push(obj);

        }

    });
    var current_assoc = sameKeyValueAppend(account_html_by_key);

    return current_assoc;
}


function sameKeyValueAppend(account_html_by_key) {
    var output = [];
    var html = {};
    account_html_by_key.forEach(function(item) {
        var existing = output.filter(function(v, i) {
            return v.name == item.name;
        });
        if (existing.length) {
            var existingIndex = output.indexOf(existing[0]);
            output[existingIndex].value = output[existingIndex].value.concat(item.value);
        } else {
            if (typeof item.value == 'string')
                item.value = [item.value];
            output.push(item);
        }
    });

    if (output) {
        for (var i in output) {
            if (output[i].value) {
                var string = "";
                for (var j in output[i].value) {
                    string += output[i].value[j];
                }

                html[output[i].name] = string;
            }
        }
    }

    return html;
}

function getAllCreditorContactsByName() {
    var table = $("#CreditorContacts .rpt_content_table");
    var result = {};

    table.find('tr').each(function(i, el) {
        var $tds = $(this).find('td');
        var key = $tds.eq(0).text();
        var key = $tds.eq(0).text();
        if (key != "") {
            var name = $tds.eq(0).text().replace(/<(?:.|\n)*?>/gm, '');
            name = name.replace(/\r?\n|\r/g, '');
            name = name.replace('_', '');
            name = name.replace('-', '');
            name = name.replace(/\s+/g, " ");
            name = name.trim();


            var address = $tds.eq(1).text().replace(/<(?:.|\n)*?>/gm, '');
            address = address.replace(/\r?\n|\r/g, '');
            address = address.replace('_', '');
            address = address.replace('-', '');
            address = address.replace(/\s+/g, " ");
            address = address.trim();

            result[name] = address;
        }
    });

    return result;
}

function AIpublicInfo() {
    var item_count = 1;
    //if(item_count>0)
    var creditor_address = getAllCreditorContactsByName();
    var account_html_by_key = "";
    var html = "";
    $('#PublicInformation >ng >div').each(function() {
        if ($(this).hasClass('ng-hide')) return false;
        $('.publicrecord').remove();
        html = "";
        var header = $.trim($(this).find('.sub_header').first().text());
        if (header.length == 0) {
            header = $.trim($(this).text());
        }

        var trans = '<p ><span class="bg-yellow">' + header + ' </span>';
        var exp = '<p ><span class="bg-yellow">' + header + ' </span>';
        var equ = '<p ><span class="bg-yellow">' + header + ' </span>';

        var df_address = '';

        var table = $(this).find('.sub_header').first().next();
        if (table.length == 0) {
            table = $(this).first().next();
        }
        var public_key_name = "";
        table.find('tr').each(function(i, el) {
            var tds = $(this).find('td');
            var td0 = $.trim(tds.eq(0).text());
            var text1 = $.trim(tds.eq(1).text());
            var text2 = $.trim(tds.eq(2).text());
            var text3 = $.trim(tds.eq(3).text());

            public_key_name = td0.replace(":", "");

            if (td0 == 'Type:') {
                trans += '<span class="bg-tra">' + text1 + '</span> </p>';
                exp += '<span class="bg-exp">' + text2 + '</span> </p>';
                equ += '<span class="bg-equ" >' + text3 + '</span> </p>';
            } else if (td0 == 'Date Filed/Reported:') {
                trans += '<p ><span class="bg-yellow">' + td0 + ' </span> <span class="bg-tra">' + text1 + '</span> </p>';
                exp += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-exp">' + text2 + '</span> </p>';
                equ += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-equ">' + text3 + '</span> </p>';
            } else if (td0 == 'Reference#:') {
                trans += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-tra">' + text1 + '</span> </p>';
                exp += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-exp">' + text2 + '</span> </p>';
                equ += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-equ">' + text3 + '</span> </p>';
            } else if (td0 == 'Court:') {
                trans += '<p ><span class="bg-yellow">Account Name: </span> <span class="bg-tra">' + text1 + '</span> </p>';
                exp += '<p ><span class="bg-yellow">Account Name: </span><span class="bg-exp">' + text2 + '</span> </p>';
                equ += '<p ><span class="bg-yellow">Account Name: </span><span class="bg-equ">' + text3 + '</span> </p>';

                df_address = creditor_address[text1];
                if (typeof df_address == 'undefined') df_address = creditor_address[text2];
                if (typeof df_address == 'undefined') df_address = creditor_address[text3];

                if (typeof df_address === 'undefined') {
                    df_address = getContactAdd(item_count, text1);
                    if (typeof df_address == 'undefined') df_address = getContactAdd(item_count, text2);
                    if (typeof df_address == 'undefined') df_address = getContactAdd(item_count, text3);
                }

            }

            if (text1 == text2 && text2 == text3) {
                if (text1 == '-') {
                    tds.eq(1).html('<span class="bg-yellow">-</span>');
                    tds.eq(2).html('<span class="bg-yellow">-</span>');
                    tds.eq(3).html('<span class="bg-yellow">-</span>');
                }
            } else if (text1 == text2 && text2 != text3) {
                tds.eq(3).html('<span class="bg-yellow">' + text3 + '</span>');
            } else if (text1 != text2 && text2 == text3) {
                tds.eq(1).html('<span class="bg-yellow">' + text1 + '</span>');
            } else if (text1 == text3 && text2 != text3) {
                tds.eq(2).html('<span class="bg-yellow">' + text2 + '</span>');
            } else if (text1 != text3 && text2 != text3) {
                tds.eq(1).html('<span class="bg-yellow">' + text1 + '</span>');
                tds.eq(2).html('<span class="bg-yellow">' + text2 + '</span>');
                tds.eq(3).html('<span class="bg-yellow">' + text3 + '</span>');
            }


        })


        trans += '<p ><span class="bg-yellow">Address:</span><span class="bg-tra">' + df_address + '</span> </p>';
        exp += '<p ><span class="bg-yellow">Address:</span><span class="bg-exp">' + df_address + '</span> </p>';
        equ += '<p ><span class="bg-yellow">Address:</span><span class="bg-equ">' + df_address + '</span> </p>';

        var img = '<div style="width:80%;" class="bg-white"><table class="rpt_content_table rpt_content_header rpt_table4column">' + table.html() + '</table></div>';

        var br = '<p class="cb-br" >*****************************************************************************************************</p>';
        var html = trans + br + exp + br + equ + img;

        if (html) {
            account_html_by_key += html;
        }
    });

    return account_html_by_key;
}

function SmartCreditAIpublicInfo() {
    var item_count = 1;
    var account_html_by_key = "";
    var header = "";
    var infotbl = "";
    var pbInfo_label = $("td").filter(function() {
        var result = false;
        var current_text = $(this).clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '')
        current_text = current_text.replace(/\r?\n|\r/g, '');
        current_text = $.trim(current_text);
        if (current_text == "Public Information" && $(this).attr('style')) {
            return true;
        }
    });
    pbInfo_label.closest('table').attr('id', 'PublicInformation');
    var public_tbl = pbInfo_label.parent('tr').first().next('tr').children('td').children('table');

    public_tbl.each(function() {
        var public_bank = $(this).find('td.crGrantedTradelineHeader b').clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '');
        if (public_bank) {
            header = public_bank;
        }
    });



    $('.publicrecord').remove();

    var trans = '<p ><span class="bg-yellow">' + header + ' </span>';
    var exp = '<p ><span class="bg-yellow">' + header + ' </span>';
    var equ = '<p ><span class="bg-yellow">' + header + ' </span>';
    var df_address = '';
    var no_of_tbl = 3
    var table = public_tbl.eq(no_of_tbl);
    var prev_table = public_tbl.eq(no_of_tbl - 1);
    table.find('tr').each(function(i, el) {
        var tds = $(this).find('td.crLightTableBackground');
        var key_tds = $(this).find('td.crLightTableBackground b');
        var td0 = $.trim(key_tds.text());
        var text1 = $.trim(tds.eq(2).text());
        var text2 = $.trim(tds.eq(3).text());
        var text3 = $.trim(tds.eq(4).text());

        if (td0 == 'Type:') {
            trans += '<span class="bg-tra">' + text1 + '</span> </p>';
            exp += '<span class="bg-exp">' + text2 + '</span> </p>';
            equ += '<span class="bg-equ" >' + text3 + '</span> </p>';
        } else if (td0 == 'Date Filed/Reported:') {
            trans += '<p ><span class="bg-yellow">' + td0 + ' </span> <span class="bg-tra">' + text1 + '</span> </p>';
            exp += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-exp">' + text2 + '</span> </p>';
            equ += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-equ">' + text3 + '</span> </p>';
        } else if (td0 == 'Reference#:') {
            trans += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-tra">' + text1 + '</span> </p>';
            exp += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-exp">' + text2 + '</span> </p>';
            equ += '<p ><span class="bg-yellow">' + td0 + ' </span><span class="bg-equ">' + text3 + '</span> </p>';
        } else if (td0 == 'Court:') {
            trans += '<p ><span class="bg-yellow">Account Name: </span> <span class="bg-tra">' + text1 + '</span> </p>';
            exp += '<p ><span class="bg-yellow">Account Name: </span><span class="bg-exp">' + text2 + '</span> </p>';
            equ += '<p ><span class="bg-yellow">Account Name: </span><span class="bg-equ">' + text3 + '</span> </p>';

            df_address = getContactAdd(item_count, text1);
            if (!df_address) df_address = getContactAdd(item_count, text2);
            if (!df_address) df_address = getContactAdd(item_count, text3);

        }
        if (text1 == text2 && text2 == text3) {
            if (text1 == '-') {
                tds.eq(2).html('<span class="bg-yellow">-</span>');
                tds.eq(3).html('<span class="bg-yellow">-</span>');
                tds.eq(4).html('<span class="bg-yellow">-</span>');
            }
        } else if (text1 == text2 && text2 != text3) {
            tds.eq(4).html('<span class="bg-yellow">' + text3 + '</span>');
        } else if (text1 != text2 && text2 == text3) {
            tds.eq(2).html('<span class="bg-yellow">' + text1 + '</span>');
        } else if (text1 == text3 && text2 != text3) {
            tds.eq(3).html('<span class="bg-yellow">' + text2 + '</span>');
        } else if (text1 != text3 && text2 != text3) {
            tds.eq(2).html('<span class="bg-yellow">' + text1 + '</span>');
            tds.eq(3).html('<span class="bg-yellow">' + text2 + '</span>');
            tds.eq(4).html('<span class="bg-yellow">' + text3 + '</span>');
        }
    })

    trans += '<p ><span class="bg-yellow">Address:</span><span class="bg-tra">' + df_address + '</span></p>';
    exp += '<p ><span class="bg-yellow">Address:</span><span class="bg-exp">' + df_address + '</span></p>';
    equ += '<p ><span class="bg-yellow">Address:</span><span class="bg-equ">' + df_address + '</span></p>';
    var pb_th = '<tr><td class="crLightTableBackground" width=""></td>' +
        '<tr><td class="crLightTableBackground" width="2"></td>' +
        '<td class="crLightTableBackground" width="136">' +
        'TransUnion' +
        '</td>' +
        '<td class="crLightTableBackground" width="136">' +
        'Experian' +
        '</td>' +
        '<td class="crLightTableBackground" width="136">' +
        'Equifax' +
        '</td>' +
        '</tr>';

    var img = '<div style="width:80%;" class="bg-white">' +
        '<table class="rpt_content_table rpt_content_header rpt_table4column">' +
        prev_table.html() +
        '</table>' +
        '<table class="rpt_content_table rpt_content_header rpt_table4column">'

    +table.html() +
        '</table></div>';

    var br = '<p class="cb-br" >*****************************************************************************************************</p>';
    var html = trans + br + exp + br + equ + img;
    if (html) {
        account_html_by_key += html;
    }

    return account_html_by_key;
}


function SmartCreditAIInquiry() {
    var item_count = 1;
    var inq_tbl_label = $("td").filter(function() {
        var current_text = $(this).clone().children().remove().end().text().replace(/<(?:.|\n)*?>/gm, '')
        current_text = $.trim(current_text);
        return current_text == "Inquiries" && $(this).attr('style');
    });
    inq_tbl_label.closest('table').attr('id', 'Inquiries');
    var inquries_tbl = inq_tbl_label.parents('table[border = 1]').first().next('table').next('table');
    var account_html_by_key = {};
    inquries_tbl.find('tr').each(function(i, el) {

        //if(i==0) return true; // skip first tr
        //if(i>1) return true; // skip first tr
        //if(item_count>0) addContent();//add new content box if not first.

        var key_tds = $(this).find('td').children('table').each(function() {
            var mytds = $(this).find('tr td');
            var obj = {};
            var type = 3;
            var bank_name = getTextValueFromTdByColumn(mytds, 1);
            var date_of_inq = "";
            var creditor_bereau = "";
            if (getTextValueFromTdByColumn(mytds, 2)) {
                date_of_inq = getTextValueFromTdByColumn(mytds, 2);
            }

            if (getTextValueFromTdByColumn(mytds, 3)) {
                creditor_bereau = getTextValueFromTdByColumn(mytds, 3);
            }


            if (bank_name) {

                obj = {
                    'key_name': bank_name + "_" + date_of_inq,
                    'creditor_bereau': creditor_bereau,
                }

            }

            var trans = '<p ><span class="bg-yellow">Inquiries</span></p>';
            var exp = '<p ><span class="bg-yellow">Inquiries</span></p>';
            var equ = '<p ><span class="bg-yellow">Inquiries</span></p>';

            var tds = $(this).find('td');
            var td0 = bank_name;
            var text1 = $.trim(tds.eq(1).text());
            var text2 = date_of_inq;
            var text3 = $.trim(tds.eq(3).text());

            //        if(creditor_bereau == 'Equifax'){
            //            
            //        }else if(creditor_bereau == 'TransUnion'){
            //            
            //        }else if(creditor_bereau == 'Experian'){
            //            
            //        }
            var address = getContactAdd(item_count, td0);
            trans += '<p><span class="bg-yellow">CREDITOR NAME</span>&nbsp;&nbsp;&nbsp;<span class="bg-tra">' + td0 + '</span> </p>';
            exp += '<p><span class="bg-yellow">CREDITOR NAME</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + td0 + '</span> </p>';
            equ += '<p><span class="bg-yellow">CREDITOR NAME</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ" >' + td0 + '</span> </p>';

            trans += '<p><span class="bg-yellow">INQUIRY DATE</span>&nbsp;&nbsp;&nbsp;<span class="bg-tra">' + text2 + '</span> </p>';
            exp += '<p><span class="bg-yellow">INQUIRY DATE</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + text2 + '</span> </p>';
            equ += '<p><span class="bg-yellow">INQUIRY DATE</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ" >' + text2 + '</span> </p>';

            trans += '<p><span class="bg-yellow"> CREDITOR ADDRESS</span>&nbsp;&nbsp;&nbsp;<span class="bg-tra">' + address + '</span> </p>';
            exp += '<p><span class="bg-yellow"> CREDITOR ADDRESS</span>&nbsp;&nbsp;&nbsp;<span class="bg-exp">' + address + '</span> </p>';
            equ += '<p><span class="bg-yellow"> CREDITOR ADDRESS</span>&nbsp;&nbsp;&nbsp;<span class="bg-equ" >' + address + '</span> </p>';

            tds.eq(1).html('<span class="bg-yellow">' + text1 + '</span>');
            tds.eq(2).html('<span class="bg-yellow">' + text2 + '</span>');
            tds.eq(3).html('<span class="bg-yellow">' + text3 + '</span>');
            var tr_html = $(this).html();
            var inq_table_html = $(this).html();
            inq_table_html.replace('<td width="3" class="crLightTableBackground"> </td>', '');
            var img = '<div style="width:80%;" class="bg-white"><div class="rpt_fullReport_header">Inquiries</div><table class="help_text"><tbody><tr><td class="help_text_img"><img src="https://www.identityiq.com/images/tu/info_icon.gif"></td><td>Below are the names of people and/or organizations who have obtained a copy of your Credit Report. Inquiries such as these can remain on your credit file for up to two years.</td></tr></tbody></table><table class="smart-credit-inq-table rpt_content_table rpt_content_header rpt_table4column"><tbody><tr><th class="tbheader" width="30%">Creditor Name</th><th class="tbheader" width="15%">Date of inquiry</th><th class="tbheader" width="15%"> Credit Bureau</th></tr>' + inq_table_html + '</tbody></table></div>';

            var verbiage = "<p >This INQUIRY to date has NOT been proven COMPLIANTLY REPORTED such as to posses factually demonstrated document PHYSICALLY VERIFIED PROOF of adequate lawful PERMISSIBLE PURPOSE achieved from accused and LEGALLY IDENTIFIED consumer and or from an entity otherwise with authority above and beyond said accused consumer's knowledge or refusal.COMPLIANCE OF REPORTING, even for true valid claims is a MINIMAL CRITERIA of reporting so ERADICATE this inquiry allegation HERE AND NOW. Additionally , remove from reporting any associated ALLEGED delinquencies and or derogatoriness , as there can not be ASSUMPTIONS of compliant reporting!</p>";
            var br = '<p class="cb-br" >*****************************************************************************************************</p>';
            var html = trans + br + exp + br + equ + br + img + verbiage + br; // merge all three beauroes
            if (html) {
                account_html_by_key[bank_name] = html;
            }
        });

    })

    $('.smart-credit-inq-table').find('tr').each(function(i, el) {
        $(this).find('th').attr('width', '15%');
        var td_text = $.trim($(this).find('td').clone()
            .children() //select all the children
            .remove() //remove all the children
            .end() //again go back to selected element
            .text().replace(/<(?:.|\n)*?>/gm, ''));
        if (!td_text) {
            $(this).find('td').eq(0).remove();
        }
    });

    return account_html_by_key;
}