populateCountryDropdown = function(countrySignup, selected_country_id) {

var top_countries = [
["United States",5000],
["United Kingdom",5094],
["Canada",5001],
["Australia",5002],
["Sweden",5087],
["Denmark",5029],
["Norway",5063],
["France",5033],
["Belgium",5004],
["Italy",5047]
];

var alphabetical_countries = [
["Afghanistan",5010],
["Albania",5012],
["Algeria",5013],
["American Samoa",5112],
["Andorra",5113],
["Angola",5014],
["Anguilla",5114],
["Antarctica",8],
["Antigua",5015],
["Argentina",5011],
["Armenia",5017],
["Aruba",5018],
["Australia",5002],
["Austria",5003],
["Azerbaijan",5115],
["Bahamas",5019],
["Bahrain",5116],
["Bangladesh",5020],
["Barbados",5005],
["Belarus",5110],
["Belgium",5004],
["Belize",5117],
["Benin",5118],
["Bermuda",5008],
["Bhutan",5119],
["Bolivia",5109],
["Bosnia and Herzegowina",5009],
["Botswana",5120],
["Bouvet Island",29],
["Brazil",5006],
["British Indian Ocean Territory",31],
["Brunei Darussalam",5122],
["Bulgaria",5007],
["Burkina Faso",5123],
["Burundi",5125],
["Cambodia",5021],
["Cameroon",5126],
["Canada",5001],
["Cape Verde",5127],
["Cayman Islands",5022],
["Central African Republic",5128],
["Chad",5129],
["Chile",5023],
["China",5024],
["Christmas Island",5130],
["Cocos (Keeling) Islands",5131],
["Colombia",5025],
["Comoros",5132],
["Congo",5133],
["Cook Islands",5135],
["Costa Rica",5026],
["Cote D'Ivoire",52],
["Croatia",5027],
["Cyprus",5028],
["Czech Republic",5108],
["Denmark",5029],
["Djibouti",5138],
["Dominica",5139],
["Dominican Republic",5140],
["East Timor",61],
["Ecuador",5036],
["Egypt",5030],
["El Salvador",5141],
["Equatorial Guinea",5142],
["Eritrea",5143],
["Estonia",5031],
["Ethiopia",5144],
["Falkland Islands (Malvinas)",5145],
["Faroe Islands",5146],
["Fiji",5147],
["Finland",5032],
["France",5033],
["France, Metropolitan",74],
["French Guiana",5148],
["French Polynesia",5149],
["French Southern Territories",77],
["Gabon",5150],
["Gambia",5151],
["Georgia",5152],
["Germany",5034],
["Ghana",5101],
["Gibraltar",5153],
["Greece",5035],
["Greenland",5037],
["Grenada",5154],
["Guadeloupe",5155],
["Guam",5038],
["Guatemala",5156],
["Guinea",5158],
["Guinea-bissau",5159],
["Guyana",5160],
["Haiti",5161],
["Heard and Mc Donald Islands",94],
["Honduras",5162],
["Hong Kong",5039],
["Hungary",5040],
["Iceland",5041],
["India",5042],
["Indonesia",5043],
["Iraq",5163],
["Ireland",5044],
["Israel",5045],
["Italy",5047],
["Jamaica",5048],
["Japan",5049],
["Jordan",5050],
["Kazakhstan",5165],
["Kenya",5051],
["Kiribati",5166],
["Korea, Republic of",5052],
["Kuwait",5053],
["Kyrgyzstan",5168],
["Lao People's Democratic Republic",116],
["Latvia",5054],
["Lebanon",5056],
["Lesotho",5170],
["Liberia",5171],
["Libyan Arab Jamahiriya",121],
["Liechtenstein",5173],
["Lithuania",5055],
["Luxembourg",5174],
["Macau",5175],
["Macedonia, The Former Yugoslav Republic of",5176],
["Madagascar",5177],
["Malawi",5178],
["Malaysia",5057],
["Maldives",5060],
["Mali",5179],
["Malta",5058],
["Marshall Islands",5181],
["Martinique",5182],
["Mauritania",5183],
["Mauritius",5184],
["Mayotte",5185],
["Mexico",5059],
["Micronesia, Federated States of",5186],
["Moldova, Republic of",5187],
["Monaco",5188],
["Mongolia",5189],
["Montenegro", 5236],
["Montserrat",5190],
["Morocco",5107],
["Mozambique",5064],
["Namibia",5065],
["Nauru",5191],
["Nepal",5066],
["Netherlands",5061],
["Netherlands Antilles",5192],
["New Caledonia",5193],
["New Zealand",5062],
["Nicaragua",5194],
["Niger",5195],
["Nigeria",5102],
["Niue",5196],
["Norfolk Island",5197],
["Northern Mariana Islands",5198],
["Norway",5063],
["Oman",5067],
["Pakistan",5068],
["Palau",5199],
["Panama",5069],
["Papua New Guinea",5200],
["Paraguay",5070],
["Peru",5071],
["Philippines",5072],
["Pitcairn",169],
["Poland",5073],
["Portugal",5074],
["Puerto Rico",5075],
["Qatar",5076],
["Reunion",5201],
["Romania",5077],
["Russian Federation",5078],
["Rwanda",5202],
["Saint Kitts and Nevis",5204],
["Saint Lucia",5079],
["Saint Vincent and the Grenadines",5206],
["Samoa",5207],
["San Marino",5208],
["Sao Tome and Principe",5209],
["Saudi Arabia",5080],
["Senegal",5210],
["Serbia", 5235],
["Seychelles",5211],
["Sierra Leone",5212],
["Singapore",5081],
["Slovakia (Slovak Republic)",5105],
["Slovenia",5082],
["Solomon Islands",5213],
["Somalia",5214],
["South Africa",5083],
["South Georgia and the South Sandwich Islands",194],
["Spain",5084],
["Sri Lanka",5085],
["St. Helena",197],
["St. Pierre and Miquelon",198],
["Suriname",200],
["Svalbard and Jan Mayen Islands",5216],
["Swaziland",5217],
["Sweden",5087],
["Switzerland",5088],
["Taiwan",5089],
["Tajikistan",5220],
["Tanzania, United Republic of",5106],
["Thailand",5090],
["Togo",5221],
["Tokelau",5222],
["Tonga",5223],
["Trinidad and Tobago",5091],
["Tunisia",5224],
["Turkey",5092],
["Turkmenistan",5225],
["Turks and Caicos Islands",5226],
["Tuvalu",5227],
["Uganda",5228],
["Ukraine",5093],
["United Arab Emirates",5111],
["United Kingdom",5094],
["United States",5000],
["United States Minor Outlying Islands",224],
["Uruguay",5095],
["Uzbekistan",5229],
["Vanuatu",5230],
["Vatican City State (Holy See)",5231],
["Venezuela",5096],
["Viet Nam",5097],
["Virgin Islands (British)",231],
["Virgin Islands (U.S.)",5232],
["Wallis and Futuna Islands",5233],
["Western Sahara",234],
["Yemen",5234],
["Zaire",237],
["Zambia",5098],
["Zimbabwe",5099]
];

var found_selected = false;


var op = new Option("--Please Select--", "0", "", "");
countrySignup.options.add(op);

for(var i = 0; i < top_countries.length; i++)
{
    var country = top_countries[i];
    var op = new Option(country[0], ""+country[1], "", "");
    if(!found_selected && selected_country_id == country[1])
    {
        op.selected = true;
        found_selected = true;
    }
    countrySignup.options.add(op);
}

var optg = document.createElement('optgroup');
optg.label = 'All Countries';

for(var i = 0; i < alphabetical_countries.length; i++)
{
    var country = alphabetical_countries[i];
    var op = new Option(country[0], ""+country[1], "", "");
    op.innerHTML = country[0];

    if(!found_selected && selected_country_id == country[1])
    {
        op.selected = true;
        found_selected = true;
    }
    optg.appendChild(op);
}

countrySignup.appendChild(optg);

}

