<?PHP
/**
* @name MOOJ Proforms 
* @version 1.0
* @package proforms
* @copyright Copyright (C) 2008-2011 Mad4Media. All rights reserved.
* @author Dipl. Inf.(FH) Fahrettin Kutyol
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.mad4media.de Mad4Media Software Development - Softwareentwicklung
* Please note that some Javascript files are not under GNU/GPL License.
* These files are under the mad4media license
* They may edited and used infinitely but may not repuplished or redistributed.  
* For more information read the header notice of the js files.
**/

defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

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

define("_M4J_COUNTRY_ONLY_NAMES", 1);
define("_M4J_COUNTRY_ONLY_ISO", 2);
define("_M4J_COUNTRY_NAME_AND_ISO", 3);

function m4jCountryDropDownArray($format = _M4J_COUNTRY_ONLY_NAMES){
	$array = array();
	foreach($GLOBALS["m4jCountries"] as $country){
		switch ($format){	
			default: 
			case _M4J_COUNTRY_ONLY_NAMES: 
				array_push($array, array("val" => $country["name"], "text"=> $country["name"]  ) );
				break;
				
			case _M4J_COUNTRY_ONLY_ISO: 
				array_push($array, array("val" => $country["code"], "text"=> $country["code"]  ) );				
				break;
				
			case _M4J_COUNTRY_NAME_AND_ISO: 
				array_push($array, array("val" => $country["code"], "text"=> $country["name"]  ) );
				break;
		}
	}
	return $array;
}

?>
