﻿

// Data & function(s) for ISO 3166-1 country names and codes


// Get HTML for a list of Select options of ISO 3166-1 country names and codes.
// eg "<option value="GB">United Kingdom</option>
//     <option value="US" SELECTED>United States</option>"
// Parameters: strSelectedValue is a value that will be marked as "SELECTED" 
//             if it is found in the options list
function getTitleOptionsListHtml(strSelectedValue) {
    var strTitleOptionsList = '<option value="">Please select...</option>\n';
    for (var i = 0; i < titles.length; i++) {  
        strTitleOptionsList += '<option value="' + titles[i].code + '"'
        if (strSelectedValue == titles[i].code) {
            strTitleOptionsList += " SELECTED"
        }
        strTitleOptionsList += ">" + titles[i].name + "</option>\n";
    }
    return strTitleOptionsList;
}


// Get the country name for a given code.
function getTitleName(strTitleCode) {
    for (var i = 0; i < titles.length; i++) {  
        if (strTitleCode == titles[i].code) {
            return titles[i].name;
        }
    }
    return "";
}


// ISO 3166-1 country names and codes from http://opencountrycodes.appspot.com/javascript		
titles = [
    {code: "Mr", name: "Mr"},
    {code: "Mrs", name: "Mrs"},
    {code: "Ms", name: "Ms"},
    {code: "Miss", name: "Miss"},
    {code: "Dr", name: "Dr"}
    //{code: "Other", name: "Other"}
];
