<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @abstract Generating Country Option List and Country Wise State Option List
 * @author   Mohammad Sajjad Hossain
 * @link www.sajjadhossin.com
 * @version 1.0
 */

if(! function_exists('get_states'))
{
    function get_states()
    {
        return array(   "AL" => "Alabama",
                        "AK" => "Alaska",
                        "AZ" => "Arizona",
                        "AR" => "Arkansas",
                        "CA" => "California",
                        "CO" => "Colorado",
                        "CT" => "Connecticut",
						"DC" => "District of Columbia",
                        "DE" => "Delaware",
                        "FL" => "Florida",
                        "GA" => "Georgia",
                        "HI" => "Hawaii",
                        "ID" => "Idaho",
                        "IL" => "Illinois",
                        "IN" => "Indiana",
                        "IA" => "Iowa",
                        "KS" => "Kansas",
                        "KY" => "Kentucky",
                        "LA" => "Louisiana",
                        "ME" => "Maine",
                        "MD" => "Maryland",
                        "MA" => "Massachusetts",
                        "MI" => "Michigan",
                        "MN" => "Minnesota",
                        "MS" => "Mississippi",
                        "MO" => "Missouri",
                        "MT" => "Montana",
                        "NE" => "Nebraska",
                        "NV" => "Nevada",
                        "NH" => "New Hampshire",
                        "NJ" => "New Jersey",
                        "NM" => "New Mexico",
                        "NY" => "New York",
                        "NC" => "North Carolina",
                        "ND" => "North Dakota",
                        "OH" => "Ohio",
                        "OK" => "Oklahoma",
                        "OR" => "Oregon",
                        "PA" => "Pennsylvania",
                        "RI" => "Rhode Island",
                        "SC" => "South Carolina",
                        "SD" => "South Dakota",
                        "TN" => "Tennessee",
                        "TX" => "Texas",
                        "UT" => "Utah",
                        "VT" => "Vermont",
                        "VA" => "Virginia",
                        "WA" => "Washington",
                        "WV" => "West Virginia",
                        "WI" => "Wisconsin",
                        "WY" => "Wyoming");
    }
}

if(!function_exists('get_military_states'))
{
    function get_military_states()
    {
        return array(   "AP" => "Armed Forces Pacific",
                        "AA" => "Armed Forces Americas",
                        "AE" => "Armed Forces Europe",
                        " " => " ",
                        " " => "US Military Bases:",
                        "AL" => "Alabama",
                        "AK" => "Alaska",
                        "AZ" => "Arizona",
                        "AR" => "Arkansas",
                        "CA" => "California",
                        "CO" => "Colorado",
                        "CT" => "Connecticut",
                        "DE" => "Delaware",
                        "DC" => "District of Columbia",
                        "FL" => "Florida",
                        "GA" => "Georgia",
                        "HI" => "Hawaii",
                        "ID" => "Idaho",
                        "IL" => "Illinois",
                        "IN" => "Indiana",
                        "IA" => "Iowa",
                        "KS" => "Kansas",
                        "KY" => "Kentucky",
                        "LA" => "Louisiana",
                        "ME" => "Maine",
                        "MD" => "Maryland",
                        "MA" => "Massachusetts",
                        "MI" => "Michigan",
                        "MN" => "Minnesota",
                        "MS" => "Mississippi",
                        "MO" => "Missouri",
                        "MT" => "Montana",
                        "NE" => "Nebraska",
                        "NV" => "Nevada",
                        "NH" => "New Hampshire",
                        "NJ" => "New Jersey",
                        "NM" => "New Mexico",
                        "NY" => "New York",
                        "NC" => "North Carolina",
                        "ND" => "North Dakota",
                        "OH" => "Ohio",
                        "OK" => "Oklahoma",
                        "OR" => "Oregon",
                        "PA" => "Pennsylvania",
                        "RI" => "Rhode Island",
                        "SC" => "South Carolina",
                        "SD" => "South Dakota",
                        "TN" => "Tennessee",
                        "TX" => "Texas",
                        "UT" => "Utah",
                        "VT" => "Vermont",
                        "VA" => "Virginia",
                        "WA" => "Washington",
                        "WV" => "West Virginia",
                        "WI" => "Wisconsin",
                        "WY" => "Wyoming");
    }
}

if(!function_exists('get_countries'))
{
    function get_countries()
    {
        return array(   "US" => "United States",
                        "GB" => "United Kingdom",
                        "CA" => "Canada",
                        "AU" => "Australia",
                        "AL" => "Albania",
                        "DZ" => "Algeria",
                        "AS" => "American Samoa",
                        "AD" => "Andorra",
                        "AO" => "Angola",
                        "AI" => "Anguilla",
                        "AQ" => "Antarctica",
                        "AG" => "Antigua And Barbuda",
                        "AR" => "Argentina",
                        "AM" => "Armenia",
                        "AW" => "Aruba",
                        "AU" => "Australia",
                        "AT" => "Austria",
                        "AZ" => "Azerbaijan",
                        "BS" => "Bahamas",
                        "BH" => "Bahrain",
                        "BD" => "Bangladesh",
                        "BB" => "Barbados",
                        "BY" => "Belarus",
                        "BE" => "Belgium",
                        "BZ" => "Belize",
                        "BJ" => "Benin",
                        "BM" => "Bermuda",
                        "BT" => "Bhutan",
                        "BO" => "Bolivia",
                        "BA" => "Bosnia And Herzegovina",
                        "BW" => "Botswana",
                        "BV" => "Bouvet Island",
                        "BR" => "Brazil",
                        "IO" => "British Indian Ocean Territory",
                        "BN" => "Brunei Darussalam",
                        "BG" => "Bulgaria",
                        "BF" => "Burkina Faso",
                        "BI" => "Burundi",
                        "KH" => "Cambodia",
                        "CM" => "Cameroon",
                        "CV" => "Cape Verde",
                        "KY" => "Cayman Islands",
                        "CF" => "Central African Republic",
                        "CI" => "Channel Islands",
                        "TD" => "Chad",
                        "CL" => "Chile",
                        "CN" => "China",
                        "CX" => "Christmas Island",
                        "CC" => "Cocos (Keeling) Islands",
                        "CO" => "Colombia",
                        "KM" => "Comoros",
                        "CG" => "Congo",
                        "CD" => "Congo, The Dem. Rep. Of The",
                        "CK" => "Cook Islands",
                        "CR" => "Costa Rica",
                        "CI" => "Cote D'ivoire",
                        "HR" => "Croatia",
                        "CY" => "Cyprus",
                        "CZ" => "Czech Republic",
                        "DK" => "Denmark",
                        "DJ" => "Djibouti",
                        "DM" => "Dominica",
                        "DO" => "Dominican Republic",
                        "TP" => "East Timor",
                        "EC" => "Ecuador",
                        "EG" => "Egypt",
                        "SV" => "El Salvador",
                        "GQ" => "Equatorial Guinea",
                        "ER" => "Eritrea",
                        "EE" => "Estonia",
                        "ET" => "Ethiopia",
                        "FK" => "Falkland Islands (Malvinas)",
                        "FO" => "Faroe Islands",
                        "FJ" => "Fiji",
                        "FI" => "Finland",
                        "FR" => "France",
                        "GF" => "French Guiana",
                        "PF" => "French Polynesia",
                        "TF" => "French Southern Territories",
                        "GA" => "Gabon",
                        "GM" => "Gambia",
                        "GE" => "Georgia",
                        "DE" => "Germany",
                        "GH" => "Ghana",
                        "GI" => "Gibraltar",
                        "GR" => "Greece",
                        "GL" => "Greenland",
                        "GD" => "Grenada",
                        "GP" => "Guadeloupe",
                        "GU" => "Guam",
                        "GT" => "Guatemala",
                        "GN" => "Guinea",
                        "GW" => "Guinea-Bissau",
                        "GY" => "Guyana",
                        "HT" => "Haiti",
                        "HM" => "Heard Island And Mcdonald Islands",
                        "VA" => "Holy See (Vatican City State)",
                        "HN" => "Honduras",
                        "HK" => "Hong Kong",
                        "HU" => "Hungary",
                        "IS" => "Iceland",
                        "IN" => "India",
                        "ID" => "Indonesia",
                        "IE" => "Ireland",
                        "IL" => "Israel",
                        "IT" => "Italy",
                        "IR" => "Iran",
                        "IQ" => "Iraq",
                        "JM" => "Jamaica",
                        "JP" => "Japan",
                        "JO" => "Jordan",
                        "KZ" => "Kazakstan",
                        "KE" => "Kenya",
                        "KI" => "Kiribati",
                        "KW" => "Kuwait",
                        "KG" => "Kyrgyzstan",
                        "LA" => "Lao People's Democratic Republic",
                        "LV" => "Latvia",
                        "LB" => "Lebanon",
                        "LS" => "Lesotho",
                        "LY" => "Libya",
                        "LI" => "Liechtenstein",
                        "LT" => "Lithuania",
                        "LU" => "Luxembourg",
                        "MO" => "Macau",
                        "MK" => "Macedonia",
                        "MG" => "Madagascar",
                        "MW" => "Malawi",
                        "MY" => "Malaysia",
                        "MV" => "Maldives",
                        "ML" => "Mali",
                        "MT" => "Malta",
                        "MH" => "Marshall Islands",
                        "MQ" => "Martinique",
                        "MR" => "Mauritania",
                        "MU" => "Mauritius",
                        "YT" => "Mayotte",
                        "MX" => "Mexico",
                        "FM" => "Micronesia, Federated States Of",
                        "MD" => "Moldova, Republic Of",
                        "MC" => "Monaco",
                        "MN" => "Mongolia",
                        "MS" => "Montserrat",
                        "MA" => "Morocco",
                        "MZ" => "Mozambique",
                        "NA" => "Namibia",
                        "NR" => "Nauru",
                        "NP" => "Nepal",
                        "NL" =>  "Netherlands",
                        "AN" => "Netherlands Antilles",
                        "NC" => "New Caledonia",
                        "NZ" => "New Zealand",
                        "NI" => "Nicaragua",
                        "NE" => "Niger",
                        "NG" => "Nigeria",
                        "NU" => "Niue",
                        "NF" => "Norfolk Island",
						'KP' => 'North Korea',
                        "MP" => "Northern Mariana Islands",
                        "NO" => "Norway",
                        "OM" => "Oman",
                        "PK" => "Pakistan",
                        "PW" => "Palau",
                        "PS" => "Palestinian Territory, Occupied",
                        "PA" => "Panama",
                        "PG" => "Papua New Guinea",
                        "PY" => "Paraguay",
                        "PE" => "Peru",
                        "PH" => "Philippines",
                        "PN" => "Pitcairn",
                        "PL" => "Poland",
                        "PT" => "Portugal",
                        "PR" => "Puerto Rico",
                        "QA" => "Qatar",
                        "RE" => "Reunion",
                        "RO" => "Romania",
                        "RU" => "Russian Federation",
                        "RW" => "Rwanda",
                        "SH" => "Saint Helena",
                        "KN" => "Saint Kitts And Nevis",
                        "LC" => "Saint Lucia",
                        "PM" => "Saint Pierre And Miquelon",
                        "VC" => "Saint Vincent And The Grenadines",
                        "WS" => "Samoa",
                        "SM" => "San Marino",
                        "ST" => "Sao Tome And Principe",
                        "SA" => "Saudi Arabia",
                        "SN" => "Senegal",
                        "SC" => "Seychelles",
                        "SG" => "Singapore",
                        "SK" => "Slovakia",
                        "SI" => "Slovenia",
                        "SB" => "Solomon Islands",
                        "SO" => "Somalia",
                        "ZA" => "South Africa",
                        "GS" => "South Georgia",
						'KR' => 'South Korea',
                        "ES" => "Spain",
                        "LK" => "Sri Lanka",
                        "SR" => "Suriname",
                        "SJ" => "Svalbard And Jan Mayen",
                        "SZ" => "Swaziland",
                        "SE" => "Sweden",
                        "CH" => "Switzerland",
                        "SY" => "Syrian Arab Republic",
                        "TW" => "Taiwan",
                        "TJ" => "Tajikistan",
                        "TZ" => "Tanzania, United Republic Of",
                        "TH" => "Thailand",
                        "TG" => "Togo",
                        "TK" => "Tokelau",
                        "TO" => "Tonga",
                        "TT" => "Trinidad And Tobago",
                        "TN" => "Tunisia",
                        "TR" => "Turkey",
                        "TM" => "Turkmenistan",
                        "TC" => "Turks And Caicos Islands",
                        "TV" => "Tuvalu",
                        "UG" => "Uganda",
                        "UA" => "Ukraine",
                        "AE" => "United Arab Emirates",
                        "UM" => "United States Minor Outlying Islands",
                        "UY" => "Uruguay",
                        "UZ" => "Uzbekistan",
                        "VU" => "Vanuatu",
                        "VE" => "Venezuela",
                        "VN" => "Viet Nam",
                        "VG" => "Virgin Islands, British",
                        "VI" => "Virgin Islands, U.S.",
                        "WF" => "Wallis And Futuna",
                        "EH" => "Western Sahara",
                        "YE" => "Yemen",
                        "YU" => "Yugoslavia",
                        "ZM" => "Zambia",
                        "ZW" => "Zimbabwe");
    }
}

if(!function_exists('get_country_select'))
{
    function get_country_select($name, $id='', $attribute='')
    {
        $ctl = '<select name="' . $name . '" id="' .($id ? $id : $name). '" ' . $attribute . ' >';
        $ctl .= '<option value=" ">Select a country</option>';
        $countries = get_countries();

        foreach($countries as $abbr => $country)
        {
            $ctl .= '<option value="' . $abbr . '">' . $country . ' &nbsp;</option>';
        }
        $ctl .= '</select>';
        
        return $ctl;
    }
}

if(!function_exists('get_country_full_name'))
{
    function get_country_full_name($abbr)
    {
        $countries = get_countries();

        return isset($countries[$abbr]) ? $countries[$abbr] : '';
    }
}

if(!function_exists('get_state_select'))
{
    function get_state_select($name, $id='', $attribute='')
    {
        $ctl = '<select name="' . $name . '" id="' .($id ? $id : $name). '" ' . $attribute . ' >';
        $ctl .= '<option value=" ">Select a state</option>';
        $states = get_states();

        foreach($states as $abbr => $state)
        {
            $ctl .= '<option value="' . $abbr . '">' . $state . ' &nbsp;</option>';
        }
        $ctl .= '</select>';
        return $ctl;
    }
}

if(!function_exists('get_military_state_select'))
{
    function get_military_state_select($name, $id='', $attribute='')
    {
        $ctl = '<select name="' . $name . '" id="' .($id ? $id : $name). '" ' . $attribute . ' >';
        $ctl .= '<option value=" ">Select a state</option>';
        $states = get_military_states();

        foreach($states as $abbr => $state)
        {
            $ctl .= '<option value="' . $abbr . '">' . $state . ' &nbsp;</option>';
        }
        $ctl .= '</select>';
        return $ctl;
    }
}

if(!function_exists('get_state_full_name'))
{
    function get_state_full_name($abbr)
    {
        $states = get_states();

        return isset($states[$abbr]) ? $states[$abbr] : '';
    }
}

if(!function_exists('get_military_state_full_name'))
{
    function get_military_state_full_name($abbr)
    {
        $states = get_military_states();

        return isset($states[$abbr]) ? $states[$abbr] : '';
    }
}
?>