<?php
	/*
	** File: makeCountrySelector
	** Description: Prints a select for countries.
	** Version: $Revision: 1.10 $
	** Created: 7/20/99
	** Author: Shannon -jj Behrens
	** Email: jj@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/12/15 17:23:27 $
	**
	** Log : $Log: makeCountrySelector,v $
	** Log : Revision 1.10  1999/12/15 17:23:27  leon
	** Log : Added functionality from Mari Bester to translate displayed StateProv
	** Log : and Country address fields from codes into names.
	** Log :
	** Log : Revision 1.9  1999/11/15 18:59:56  leon
	** Log : Made US the default country.
	** Log :
	** Log : Revision 1.8  1999/10/19 22:30:02  jj
	** Log : Countries are now alphabetized by the full country name rather than by the
	** Log : abbreviation (this is code donated by Isaac).
	** Log :
	** Log : Revision 1.7  1999/10/11 23:04:03  leon
	** Log : Removed all require()'s, added block to stop double include()'s
	** Log :
	** Log : Require wasn't giving any performance advantage because it was always
	** Log : being called with a variable.  Futhermore, using return inside a
	** Log : require()'d file does not work in PHP4.
	** Log :
	** Log : Revision 1.6  1999/10/04 20:36:38  jj
	** Log : Made sure our country list was iso 3166 compliant.  In an act of provinciality, I put the US at the top of the list.
	** Log :
	** Log : Revision 1.5  1999/09/22 22:15:32  leon
	** Log : Added complete list of countries with DHL codes
	** Log :
	** Log : Revision 1.4  1999/09/10 00:14:33  jj
	** Log : Wrapped everything in basically an ifndef.
	** Log :
	** Log : Revision 1.3  1999/09/09 22:44:03  jj
	** Log : Wrapped this script in an "if" statement to avoid redeclarations.
	** Log :
	** Log : Revision 1.2  1999/08/18 22:32:06  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.1  1999/07/28 21:18:36  leon
	** Log : New include modules based on code donation from a live project
	** Log :
	**
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	*/

	/*
	** Ensure that module isn't included twice
	*/

	$included_flag = 'INCLUDE_' . basename(__FILE__);
	
	if(defined($included_flag))
		//if this module has been included already, then the
		//constant will be defined.  Note the unusual use of
		//the return statement here.  Control will return to
		//the file that included it.
		return;
	
	define($included_flag, TRUE);	


	/*
	** Country names and ISO country codes
	**
	** This array is used for converting the codes
	** back to names in some of the functions below,
	** and it's also used by makeCountrySelector.
	*/
	$Countries = array(
		"AF" => "Afghanistan",
		"AS" => "American Samoa",
		"AL" => "Albania",
		"DZ" => "Algeria",		
		"AD" => "Andorra",
		"AO" => "Angola",		
		"AI" => "Anguilla",		
		"AG" => "Antigua and Barbuda",
		"AQ" => "Antarctica",
		"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",		
		"CA" => "Canada",
		"CV" => "Cape Verde",		
		"KY" => "Cayman Islands",
		"CF" => "Central African Republic",		
		"TD" => "Chad",
		"CL" => "Chile",
		"CN" => "China",
		"CX" => "Christmas Island",
		"CC" => "Cocos (Keeling) Islands",
		"CO" => "Colombia",		
		"KM" => "Comoros",		
		"CG" => "Congo",
		"CK" => "Cook Islands",
		"CR" => "Costa Rica",
		"CI" => "Cote D'Ivoire (Ivory Coast)",
		"HR" => "Croatia (Hrvatska)",
		"CU" => "Cuba",		
		"CY" => "Cyprus",		
		"CZ" => "Czech Republic",
		"CS" => "Czechoslovakia (former)",
		"DK" => "Denmark",
		"DJ" => "Djibouti",
		"DM" => "Dominica",
		"DO" => "Dominican Republic",
		"TP" => "East Timor",		
		"EC" => "Ecuador",
		"EG" => "Egypt",
		"SV" => "El Salvador",		
		"ER" => "Eritrea",
		"EE" => "Estonia",		
		"ET" => "Ethiopia",
		"GQ" => "Equatorial Guinea",
		"FK" => "Falkland Islands (Malvinas)",
		"FO" => "Faroe Islands",
		"FJ" => "Fiji",				
		"FI" => "Finland",
		"FR" => "France",
		"FX" => "France, Metropolitan",
		"GF" => "French Guiana",			
		"PF" => "French Polynesia",
		"TF" => "French Southern Territories",			
		"GA" => "Gabon",
		"GM" => "Gambia",		
		"DE" => "Germany",		
		"GE" => "Georgia",
		"GH" => "Ghana",
		"GI" => "Gibraltar",
		"GB" => "Great Britain (UK)",
		"GR" => "Greece",
		"GL" => "Greenland",
		"GD" => "Grenada",
		"GP" => "Guadeloupe",
		"GU" => "Guam",
		"GT" => "Guatemala",
		"GN" => "Guinea",
		"GW" => "Guinea-Bissau",
		"GY" => "Guyana",
		"HT" => "Haiti",		
		"HM" => "Heard and McDonald Islands",		
		"HN" => "Honduras",
		"HU" => "Hungary",
		"HK" => "Hong Kong",		
		"IS" => "Iceland",
		"IN" => "India",		
		"ID" => "Indonesia",
		"IR" => "Iran",		
		"IQ" => "Iraq",
		"IE" => "Ireland",
		"IL" => "Israel",		
		"IT" => "Italy",
		"JM" => "Jamaica",
		"JP" => "Japan",		
		"JO" => "Jordan",
		"KZ" => "Kazakhstan",
		"KE" => "Kenya",
		"KI" => "Kiribati",
		"KP" => "Korea (North)",
		"KR" => "Korea (South)",
		"KW" => "Kuwait",		
		"KG" => "Kyrgyzstan",
		"LA" => "Laos",		
		"LV" => "Latvia",
		"LB" => "Lebanon",
		"LS" => "Lesotho",
		"LR" => "Liberia",
		"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",
		"MD" => "Moldova",		
		"MC" => "Monaco",
		"MN" => "Mongolia",
		"MS" => "Montserrat",
		"MA" => "Morocco",
		"MZ" => "Mozambique",
		"MM" => "Myanmar",
		"NA" => "Namibia",
		"NR" => "Nauru",
		"NP" => "Nepal",
		"NL" => "Netherlands",
		"AN" => "Netherlands Antilles",
		"NT" => "Neutral Zone",
		"NC" => "New Caledonia",
		"NZ" => "New Zealand (Aotearoa)",
		"MP" => "Northern Mariana Islands",		
		"NI" => "Nicaragua",
		"NU" => "Niue",
		"NE" => "Niger",
		"NG" => "Nigeria",
		"NF" => "Norfolk Island",
		"NO" => "Norway",
		"OM" => "Oman",
		"PK" => "Pakistan",
		"PW" => "Palau",		
		"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",
		"KN" => "Saint Kitts and Nevis",				
		"LC" => "Saint Lucia",		
		"VC" => "Saint Vincent and the Grenadines",
		"WS" => "Samoa",		
		"SM" => "San Marino",
		"ST" => "Sao Tome and Principe",
		"SA" => "Saudi Arabia",
		"SN" => "Senegal",
		"SC" => "Seychelles",
		"SL" => "Sierra Leone",		
		"SG" => "Singapore",
		"SK" => "Slovak Republic",		
		"SI" => "Slovenia",		
		"Sb" => "Solomon Islands",
		"SO" => "Somalia",
		"ZA" => "South Africa",
		"GS" => "S. Georgia and S. Sandwich Isls.",		
		"ES" => "Spain",
		"LK" => "Sri Lanka",
		"PM" => "St. Pierre and Miquelon",		
		"SH" => "St. Helena",
		"SD" => "Sudan",
        "SR" => "Suriname",
		"SJ" => "Svalbard and Jan Mayen Islands",		
		"SZ" => "Swaziland",
		"SE" => "Sweden",
		"CH" => "Switzerland",
		"SY" => "Syria",
		"TW" => "Taiwan",
		"TJ" => "Tajikistan",
		"TZ" => "Tanzania",
		"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",		
		"UK" => "United Kingdom",
        "US" => "United States",
		"UY" => "Uruguay",		
		"UM" => "US Minor Outlying Islands",
		"SU" => "USSR (former)",		
		"UZ" => "Uzbekistan",
		"VU" => "Vanuatu",
		"VA" => "Vatican City State (Holy See)",
		"VE" => "Venezuela",
		"VG" => "Virgin Islands (British)",
		"VI" => "Virgin Islands (U.S.)",
		"VN" => "Viet Nam",
		"WF" => "Wallis and Futuna Islands",
		"EH" => "Western Sahara",
		"YE" => "Yemen",
		"YU" => "Yugoslavia",
		"ZR" => "Zaire",
		"ZM" => "Zambia",
		"ZW" => "Zimbabwe"	
	);


	/*
	** Function: makeCountrySelector
	** Input:  STRING name, STRING selected
	** Output: BOOLEAN
	** Description:  Prints a complete selector for choosing
	** a country.  You may name the selector and optionally
	** specify the country to be selected.
	*/
	function makeCountrySelector($name, $selected="US")
	{
		global $Countries;

		print("<SELECT NAME=\"$name\" SIZE=\"1\">\n");
		print("<OPTION VALUE=\"\">Please Select</OPTION>\n");

		for(reset($Countries); $key = key($Countries); next($Countries))
		{
			print("<OPTION VALUE=\"$key\"");
			if($key == $selected)
			{
				print(" SELECTED");
			}
			print(">$Countries[$key]</OPTION>\n");
		}

		print("</SELECT>\n");
		
		return(TRUE);	
	}


	/*
	** Function: getCountryName
	** Input:  STRING CountryCode
	** Output: STRING
	** Description:  Returns the name of a country
	** given its code.
	**
	** Contributed by Mari Bester [Mari@dchip.com]
	*/
	function getCountryName($CountryCode)
	{
		global $Countries;
		return($Countries[$CountryCode]);
	}		
?>
