﻿

// Called from Products.aspx and Testimonials.aspx page
function ShowTesimonials(val) {

    var results = "";

    for (var i = 0; i < val.length; i++) {
        var firstname = val[i].FirstName;
        var lastname = val[i].LastName;
        var city = val[i].City;
        var state = val[i].State;
        var country = val[i].Country;
        var injury = val[i].Injury;
        var description = val[i].Description;
        var occupation = val[i].Occupation;
        var age = val[i].Age;

        var displayName = "";
        if (firstname == "") {
            displayName = lastname;
        }
        else if (lastname == "") {
            displayName = firstname;
        }
        else {
            displayName = firstname + " " + lastname.substring(0, 1) + ".";
        }



        var location = "";
        if (city != "" && city != null) {
            if (state != "" && state != null) {
                location = "<br /><span class='inputTableCellTextBold'>Location:</span> " + city + ", " + state;
            }
            else {
                location = "<br /><span class='inputTableCellTextBold'>Location:</span> " + city;
            }
        }
        else if (state != "" && state != null) {
            location = "<br /><span class='inputTableCellTextBold'>Location:</span> " + state;
        }

        var country = "";

        if (country != "" && country != null) {
            country = "<br /><span class='inputTableCellTextBold'>Country:</span> " + country;
        }


        var displayAge = "";
        if (age != "" && age != "0") {
            displayAge = "<br /><span class='inputTableCellTextBold'>Age:</span> " + age;
        }


        results += "<br /><span class='inputTableCellTextBold'>Name:</span> " + displayName;
        results += location;
        results += country;
        if (injury != "" && injury != null) results += "<br /><span class='inputTableCellTextBold'>Injury:</span> " + injury;
        if (description != "" && description != null) results += "<br /><span class='inputTableCellTextBold'>Description:</span> " + description;
        if (occupation != "" && occupation != null) results += "<br /><span class='inputTableCellTextBold'>Occupation:</span> " + occupation;
        results += displayAge;

        var dt = val[i].SetupDate;
        results += "<br /><span class='inputTableCellTextBold'>Submitted</span>: " + FormatDatePart(dt);
        results += "<br /><hr />";

    }
    document.getElementById("divResponse").innerHTML = results;


    //document.getElementById(prefix + "pan_results").style.display = "";
    //document.getElementById(prefix + "pan_main").style.display = "none";

    if (document.getElementById("divNumResponses")) {
        document.getElementById("divNumResponses").innerHTML = val.length + (val.length == 1 ? " result found." : " results found.");
    }

    if (document.getElementById(prefix + "tb_search")) {
        document.getElementById(prefix + "tb_search").focus();
    }
}

