var country_codes = Array();	
var domesticmode = true;
var internationalmode = false;	
var country_code_fields = Array();
var area_code_fields = Array();
var phone_a_fields = Array();
var phone_b_fields = Array();
var phone_verbose_names = Array();
var state_fields = Array();
var zip_fields = Array();
var country_fields = Array();
var last_country = '';
var last_country_id = '';
var last_autoset_country_code = '';
var country_code_sizes = new Array(0, 5);
var area_code_sizes = new Array(3, 5);
var phone_a_sizes = new Array(3, 15);
var phone_b_sizes = new Array(4, 0);
var state_sizes = new Array(2, 25);
var zip_sizes = new Array(10, 15);
var stored_domestic_states = new Array();
var stored_international_states = new Array();
var stored_international_country_codes = new Array();
var stored_international_country = '';
var stored_domestic_country = '';
var stored_phone_a = new Array();
var international_divs = new Array();
var domestic_divs = new Array();
var international_selects = new Array();

function clean_phone_highlights() {
	for (var c = 0; c< country_code_fields.length; c++) {
		document.getElementById(country_code_fields[c]).className = 'goodField';
		document.getElementById(area_code_fields[c]).className = 'goodField';
		document.getElementById(phone_a_fields[c]).className = 'goodField';
		document.getElementById(phone_b_fields[c]).className = 'goodField';
	}	
}
function check_phones()
{
	clean_phone_highlights();
	var field_names	= phone_verbose_names;
	var areacode_fields = area_code_fields;
	var phone_a = phone_a_fields;
	var phone_b = phone_b_fields;
	var countrycode_fields = country_code_fields;
	var message = '';
	var highlight = new Array();
			
	for (var i = 0; i<areacode_fields.length; i++) 
	{
		phone_length = 0;
		phone_length += document.getElementById(areacode_fields[i]).value.length; 
		phone_length += document.getElementById(phone_a[i]).value.length; 
		phone_length += document.getElementById(phone_b[i]).value.length; 
			
		if(phone_length > 0)
		{
			if(internationalmode)
			{
				if (!is_valid_country_code(document.getElementById(countrycode_fields[i]).value))
				{
					message += '- ' + field_names[i] + '\'s country code seems to be invalid\n\n'; 
					flag = true;
					highlight.push(countrycode_fields[i]);
				}		
			}
			/*check the areacodes*/
			if (!is_valid_area_code(document.getElementById(areacode_fields[i]).value))
			{
				message += '- ' + field_names[i] + '\'s area code seems to be invalid\n\n'; 
				flag = true;
				highlight.push(areacode_fields[i]);
			}	
			/* check the phone numbers */	 
			
			if (!is_valid_phone_a_code(document.getElementById(phone_a[i]).value) || 
				!is_valid_phone_b_code(document.getElementById(phone_b[i]).value)) 
			{ 
				message += '- ' + field_names[i] + ' seems to be invalid\n\n'; 
				flag = true;
				highlight.push(phone_a[i]);
				highlight.push(phone_b[i]);
			}
		}//end of if there is a phone number	
		else document.getElementById(country_code_fields[i]).value = '';			
	} /*end for loop*/
	for (var h = 0; h < highlight.length; h ++ ) {
		document.getElementById(highlight[h]).className = 'badField';
	}
	return message;
}
function is_valid_phone_a_code(test_string)
{
	test_string = international_data_clean(test_string);
	var ret = true;
	var max_length = phone_a_sizes[0];
	if(internationalmode) max_length = phone_a_sizes[1]; 		
	if(test_string.length < 3 || test_string.length > max_length || isNaN(test_string)) {
		ret = false;
	}
	return ret;
}
function is_valid_phone_b_code(test_string)
{
	test_string = international_data_clean(test_string);
	var ret = true;
	var max_length = phone_b_sizes[0];
	if(internationalmode) max_length = phone_b_sizes[1]; 
	var min_length = 4;
	if(max_length == 0) min_length = 0;
	if(test_string.length < 0 || test_string.length > max_length || isNaN(test_string)) {
		ret = false;
	}
	return ret;
}
function is_valid_country_code(test_string)
{	
	var ret = true;
	var max_length = country_code_sizes[0];
	if(internationalmode) max_length = country_code_sizes[1]; 
	if(test_string.length < 2 || test_string.length > max_length || isNaN(test_string)) {
		ret = false;
	}
	return ret;
}		
function is_valid_area_code(test_string)
{
	var ret = true;		
	var max_length = area_code_sizes[0];
	if(internationalmode) max_length = area_code_sizes[1]; 
	if(test_string.length < 3 || test_string.length > max_length || isNaN(test_string)) ret = false;
	return ret;
}
function is_valid_zip_code(test_string)
{		
	test_string = international_data_clean(test_string);
	var ret = true;
	var max_length = zip_sizes[0];
	if(internationalmode) {
		max_length = zip_sizes[1]; 
	}
	if(test_string.length < 3 || test_string.length > max_length || !alphanumeric(test_string)) {
		ret = false;
	}
	return ret;
}
function check_all_states()
{
	var invalid_states = new Array();
	for(var sc=0; sc<state_fields.length; sc++)
	{
		if(!is_valid_state(document.getElementById(state_fields[sc]).value))
		{
			invalid_states[invalid_states.length] = state_fields[sc];
		}
		else if (document.getElementById(state_fields[sc] + '_forcefail').value == 'Y')
		{
			invalid_states[invalid_states.length] = state_fields[sc];
		}
	}
	return invalid_states;
}
function is_valid_state(test_string)
{
	var ret = true;
	if (domesticmode && test_string.length < 2) ret = false;
	return ret;
}
function international_data_clean(unclean_string)
{
	var clean_string = unclean_string.replace('-', '');
	while(clean_string.length != unclean_string.length)
	{
		unclean_string = clean_string;
		clean_string = unclean_string.replace('-', '');
	}
	clean_string = unclean_string.replace(' ', '');
	while(clean_string.length != unclean_string.length)
	{
		unclean_string = clean_string;
		clean_string = unclean_string.replace(' ', '');
	}
	return clean_string;
}	

//DYNAMIC FORM SWITCHES
function international_reset_field_sizes(index, field_array, size_array)
{
	var old_value = '';
	for(var acc=0; acc<field_array.length; acc++)
	{
		document.getElementById(field_array[acc]).maxLength = size_array[index];
		document.getElementById(field_array[acc]).size = size_array[index];
		if(document.getElementById(field_array[acc]).value.length > size_array[index])
		{
			old_value = document.getElementById(field_array[acc]).value;
			old_value = old_value.substring(0, size_array[index]);
			document.getElementById(field_array[acc]).value = old_value;
		}
	}
}

function international_style_display(field_name_array, new_display)
{
	for(var fnc=0; fnc<field_name_array.length; fnc++)
	{
		document.getElementById(field_name_array[fnc]).style.display = new_display;
	}
}

function set_to_international()
{
	//variable initialization
	internationalmode = true;
	domesticmode = false;
	last_autoset_country_code = '';
	//form size changes
	international_reset_field_sizes(1, area_code_fields, area_code_sizes);
	international_reset_field_sizes(1, phone_a_fields, phone_a_sizes);
	international_reset_field_sizes(1, state_fields, state_sizes);
	international_reset_field_sizes(1, zip_fields, zip_sizes);
	
	international_style_display(domestic_divs, 'none');
	international_style_display(international_divs, 'block');		
	//clear the phone b values 
	var tmp;
	var tmp2;
	for(var fnc=0; fnc<phone_b_fields.length; fnc++)
	{
		tmp = document.getElementById(phone_a_fields[fnc]);
		tmp2 = document.getElementById(phone_b_fields[fnc]);
		if(tmp2.value.length > 0)
		{
			if(tmp.value.length > 0) tmp.value += '-'+tmp2.value;
			else tmp.value = tmp2.value;
		}
		tmp2.value = '';
	}
	//store the domestic states in case the user goes back		
	for (var sc=0; sc<state_fields.length; sc++)
	{	
		stored_domestic_states[sc] = document.getElementById(state_fields[sc]).value;
	}
	//remove all selections
	var junk = new Object();
	clear_all_selects_but_this(junk);
	//set all international country selections
	for(var cc=0; cc<country_fields.length; cc++)
	{
		var country_select = document.getElementById(country_fields[cc]+'_inter');
		for(var tcc=0; tcc<country_select.options.length; tcc++)
		{
			if(country_select.options[tcc].value == stored_international_country)
			{
				country_select.selectedIndex = tcc;
			}
		}
	}
	set_country(stored_international_country);		
	//clear the states in case we don't have defaults
	clear_states();
	//restore any international defaults we have
	for(var sc=0; sc<stored_international_states.length; sc++)
	{
		document.getElementById(state_fields[sc]).value = stored_international_states[sc];
		international_select_to_the_right(document.getElementById(state_fields[sc]));
		document.getElementById(state_fields[sc]).className = 'goodField';
	}
	//restore any phoneas we have
	for (var bc=0; bc<stored_phone_a.length; bc++)
	{
		document.getElementById(phone_a_fields[bc]).value = stored_phone_a[bc];
	}
	//restore any country codes we have
	for(var cc=0; cc<stored_international_country_codes.length; cc++)
	{
		document.getElementById(country_code_fields[cc]).value = stored_international_country_codes[cc];
	}
}	
function set_to_domestic()
{
	internationalmode = false;
	domesticmode = true;
	last_autoset_country_code = '';	
	
	//store the phone_as in case the user comes back
	for (var bc=0; bc<phone_a_fields.length; bc++)
	{
		stored_phone_a[bc] = document.getElementById(phone_a_fields[bc]).value;
	} 
	//store the country codes in case the user comes back
	for (var cc=0; cc<country_code_fields.length; cc++)
	{
		stored_international_country_codes[cc] = document.getElementById(country_code_fields[cc]).value;
	}		
	//store the international states in case the user comes back
	for (var sc=0; sc<state_fields.length; sc++)
	{
		stored_international_states[sc] = document.getElementById(state_fields[sc]).value;
	}
	
	var tmp;
	for(var fnc=0; fnc<phone_a_fields.length; fnc++)
	{
		tmp = international_data_clean(document.getElementById(phone_a_fields[fnc]).value);
		if(tmp.length > 0)
		{
			document.getElementById(phone_a_fields[fnc]).value = tmp.substr(0, 3);
			document.getElementById(phone_b_fields[fnc]).value = tmp.substr(3, 4);				
		}
	}		
	
	international_reset_field_sizes(0, area_code_fields, area_code_sizes);	
	international_reset_field_sizes(0, phone_a_fields, phone_a_sizes);	
	international_reset_field_sizes(0, state_fields, state_sizes);
	international_reset_field_sizes(0, zip_fields, zip_sizes);		
	international_style_display(domestic_divs, 'block');
	international_style_display(international_divs, 'none');		
	
	var junk = new Object();
	clear_all_selects_but_this(junk);	
	for(var cc=0; cc<country_fields.length; cc++)
	{
		var country_select = document.getElementById(country_fields[cc]+'_local');
		for(var tcc=0; tcc<country_select.options.length; tcc++)
		{
			if(country_select.options[tcc].value == stored_domestic_country)
			{
				country_select.selectedIndex = tcc;
			}
		}
	}		
	set_country(stored_domestic_country);	
	for(var pc=0; pc<country_code_fields.length; pc++) {
		document.getElementById(country_code_fields[pc]).value = '';
	}		
	//clear them all in case we don't have defaults in this, the world of domestic states
	clear_states();
	//restore any domestic defaults we have
	for(var sc=0; sc<stored_domestic_states.length; sc++)
	{
		document.getElementById(state_fields[sc]).value = stored_domestic_states[sc];			
		international_select_to_the_right(document.getElementById(state_fields[sc]));
		document.getElementById(state_fields[sc]).className = 'goodField';
	}
}	
function selected_international(selobj)
{
	var was_selected = selobj.options[selobj.selectedIndex].value;
	var ccs = country_code_fields;	
	var this_autoset_country_code = '';	
	for(var ccc=0; ccc<country_codes.length; ccc++)
	{
		if(country_codes[ccc][0] == was_selected)
		{
			this_autoset_country_code = country_codes[ccc][1];
			for(var pc=0; pc<ccs.length; pc++) {
				//we only reset the country code if the current value is equal to the last value 
				// set by country selection
				if(document.getElementById(ccs[pc]).value == last_autoset_country_code)
				{
					document.getElementById(ccs[pc]).value = this_autoset_country_code;
				}
			}
		}
	}	
	last_autoset_country_code = this_autoset_country_code;		
	set_country(was_selected);
	clear_all_selects_but_this(selobj);		
	clear_states();		
}

function selected_domestic(selobj)
{
	var was_selected = selobj.options[selobj.selectedIndex].value;		
	set_country(was_selected);
	clear_all_selects_but_this(selobj);		
	clear_states();		
}

//LOWEST LEVEL FUNCTIONALITY

function set_country(country_name)
{
	var this_country_id;
	for(var lcc=0; lcc<country_codes.length; lcc++)
	{
		if(country_codes[lcc][0] == country_name) this_country_id = country_codes[lcc][2];
	}
	for(var sc=0; sc<state_fields.length; sc++)
	{
		if(document.getElementById(state_fields[sc] + '_hidden_states_'+last_country_id)) 
		{
			document.getElementById(state_fields[sc] + '_hidden_states_'+last_country_id).style.display = 'none';
		}
		if(document.getElementById(state_fields[sc] + '_hidden_states_'+this_country_id)) 
		{
			document.getElementById(state_fields[sc] + '_hidden_states_'+this_country_id).style.display = 'block';
		}
	}
	for(var cc=0; cc<country_fields.length; cc++)
	{
		document.getElementById(country_fields[cc]).value = country_name;
	}
	last_country = country_name;
	if(domesticmode)
	{
		stored_domestic_country = last_country;
	}
	else if (internationalmode)
	{
		stored_international_country = last_country;
	}
	last_country_id = '';
	//because it isn't passed, we must find the country id, which there is a lookup array for
	for(var lcc=0; lcc<country_codes.length; lcc++)
	{
		if(country_codes[lcc][0] == last_country) last_country_id = country_codes[lcc][2];
	}
}

function clear_all_selects_but_this(selobj)
{	
	for(var csel=0; csel < international_selects.length; csel++) 
	{		
		if(selobj.id != international_selects[csel])
		{
			document.getElementById(international_selects[csel]).selectedIndex = 0;
		}
	}
}	

function clear_states()
{
	for(var pc=0; pc<state_fields.length; pc++) {
		document.getElementById(state_fields[pc]).value = '';
		document.getElementById(state_fields[pc]+'_forcefail').value = 'N'; 			
	}
}

function international_select_to_the_right(input_box)
{
	var forcefail = document.getElementById(input_box.id + '_forcefail');
	var sel_right_name = input_box.id+'_states_of_'+last_country_id;
	var select_to_right = document.getElementById(sel_right_name);
	var done = false;
	if(select_to_right)
	{			
		for(var src=0; src<select_to_right.options.length; src++)
		{
			if(!done && input_box.value.length == 1)
			{
				input_box.className = 'badCurrentField';
				last_has_focus_field = 'badField';
				forcefail.value = 'Y';
				if(!done && select_to_right.options[src].value.substr(0,1) == input_box.value.toUpperCase())
				{
					select_to_right.selectedIndex = src;
					done = true;
				}
			}
			else {
				if(!done && select_to_right.options[src].value == input_box.value.toUpperCase())
				{	
					input_box.className = 'currentField';
					last_has_focus_field = 'goodField';
					forcefail.value = 'N';
					select_to_right.selectedIndex = src;
					done = true;
				}					
			}
		}
		if(!done) {
			input_box.className = 'badCurrentField';
			last_has_focus_field = 'badField';
			forcefail.value = 'Y';
			//REMOVAL OF BAD DIGITS
			//if(input_box.value.length == 1) input_box.value = '';
			//else input_box.value = input_box.value.substr(0,1);
		}
		input_box.value = input_box.value.toUpperCase();
	}
	else {
		input_box.className = 'currentField';
		last_has_focus_field = 'goodField';
		forcefail.value = 'N';
	}
}

function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
	{
		var alphaa = numaric.charAt(j);
		var hh = alphaa.charCodeAt(0);
		if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		{
		}
		else	
		{
			return false;
		}
	}
	return true;
}
function upper_case_first_letter(field)
{
	var first_part = field.value.substr(0,1);
	var second_part = field.value.substr(1,100);	
	field.value = first_part.toUpperCase() + second_part;
}

function display_rest_of_add(new_setting)
{
	if(new_setting == 'dom')
	{
		if(!domesticmode) set_to_domestic();
	}
	else if (new_setting == 'inter')
	{
		if(!internationalmode) set_to_international(); 
	}
}

country_fields[country_fields.length] = 'Country';
	country_codes[0] = Array('Afghanistan',93, 1);
country_codes[1] = Array('Albania',355, 2);
country_codes[2] = Array('Algeria',213, 3);
country_codes[3] = Array('American Samoa',684, 4);
country_codes[4] = Array('Andorra',376, 5);
country_codes[5] = Array('Angola',244, 6);
country_codes[6] = Array('Anguilla',264, 7);
country_codes[7] = Array('Antarctica',672, 8);
country_codes[8] = Array('Antigua',268, 9);
country_codes[9] = Array('Argentina',54, 10);
country_codes[10] = Array('Armenia',374, 11);
country_codes[11] = Array('Aruba',297, 12);
country_codes[12] = Array('Ascension',247, 13);
country_codes[13] = Array('Australia',61, 14);
country_codes[14] = Array('Australian External Territories',672, 15);
country_codes[15] = Array('Austria',43, 16);
country_codes[16] = Array('Azerbaijan',994, 17);
country_codes[17] = Array('Bahamas',242, 18);
country_codes[18] = Array('Bahrain',973, 19);
country_codes[19] = Array('Bangladesh',880, 20);
country_codes[20] = Array('Barbados',246, 21);
country_codes[21] = Array('Barbuda',268, 22);
country_codes[22] = Array('Belarus',375, 23);
country_codes[23] = Array('Belgium',32, 24);
country_codes[24] = Array('Belize',501, 25);
country_codes[25] = Array('Benin',229, 26);
country_codes[26] = Array('Bermuda',441, 27);
country_codes[27] = Array('Bhutan',975, 28);
country_codes[28] = Array('Bolivia',591, 29);
country_codes[29] = Array('Bosnia &amp; Herzegovina',387, 30);
country_codes[30] = Array('Botswana',267, 31);
country_codes[31] = Array('Brazil',55, 32);
country_codes[32] = Array('British Virgin Islands',284, 33);
country_codes[33] = Array('Brunei Darussalam',673, 34);
country_codes[34] = Array('Bulgaria',359, 35);
country_codes[35] = Array('Burkina Faso',226, 36);
country_codes[36] = Array('Burundi',257, 37);
country_codes[37] = Array('Cambodia',855, 38);
country_codes[38] = Array('Cameroon',237, 39);
country_codes[39] = Array('Canada',1, 40);
country_codes[40] = Array('Cape Verde Islands',238, 41);
country_codes[41] = Array('Cayman Islands',345, 42);
country_codes[42] = Array('Central African Republic',236, 43);
country_codes[43] = Array('Chad',235, 44);
country_codes[44] = Array('Chatham Island (New Zealand)',64, 45);
country_codes[45] = Array('Chile',56, 46);
country_codes[46] = Array('China (PRC)',86, 47);
country_codes[47] = Array('Christmas Island',53, 48);
country_codes[48] = Array('Cocos-Keeling Islands',61, 49);
country_codes[49] = Array('Colombia',57, 50);
country_codes[50] = Array('Comoros',269, 51);
country_codes[51] = Array('Congo',242, 52);
country_codes[52] = Array('Congo, Dem. Rep. of  (former Zaire)',243, 53);
country_codes[53] = Array('Cook Islands',682, 54);
country_codes[54] = Array('Costa Rica',506, 55);
country_codes[55] = Array('Croatia',385, 56);
country_codes[56] = Array('Cuba',53, 57);
country_codes[57] = Array('Cuba (Guantanamo Bay)',5399, 58);
country_codes[58] = Array('Cura‡ao',599, 59);
country_codes[59] = Array('Cyprus',357, 60);
country_codes[60] = Array('Czech Republic',420, 61);
country_codes[61] = Array('Denmark',45, 62);
country_codes[62] = Array('Diego Garcia',246, 63);
country_codes[63] = Array('Djibouti',253, 64);
country_codes[64] = Array('Dominica',767, 65);
country_codes[65] = Array('Dominican Republic',809, 66);
country_codes[66] = Array('East Timor',670, 67);
country_codes[67] = Array('Easter Island',56, 68);
country_codes[68] = Array('Ecuador',593, 69);
country_codes[69] = Array('Egypt',20, 70);
country_codes[70] = Array('El Salvador',503, 71);
country_codes[71] = Array('Equatorial Guinea',240, 72);
country_codes[72] = Array('Eritrea',291, 73);
country_codes[73] = Array('Estonia',372, 74);
country_codes[74] = Array('Ethiopia',251, 75);
country_codes[75] = Array('Falkland Islands (Malvinas)',500, 76);
country_codes[76] = Array('Faroe Islands',298, 77);
country_codes[77] = Array('Fiji Islands',679, 78);
country_codes[78] = Array('Finland',358, 79);
country_codes[79] = Array('France',33, 80);
country_codes[80] = Array('French Antilles',596, 81);
country_codes[81] = Array('French Guiana',594, 82);
country_codes[82] = Array('French Polynesia',689, 83);
country_codes[83] = Array('Gabonese Republic',241, 84);
country_codes[84] = Array('Gambia',220, 85);
country_codes[85] = Array('Georgia',995, 86);
country_codes[86] = Array('Germany',49, 87);
country_codes[87] = Array('Ghana',233, 88);
country_codes[88] = Array('Gibraltar',350, 89);
country_codes[89] = Array('Greece',30, 90);
country_codes[90] = Array('Greenland',299, 91);
country_codes[91] = Array('Grenada',473, 92);
country_codes[92] = Array('Guadeloupe',590, 93);
country_codes[93] = Array('Guam',671, 94);
country_codes[94] = Array('Guantanamo Bay',5399, 95);
country_codes[95] = Array('Guatemala',502, 96);
country_codes[96] = Array('Guinea',224, 98);
country_codes[97] = Array('Guinea-Bissau',245, 97);
country_codes[98] = Array('Guyana',592, 99);
country_codes[99] = Array('Haiti',509, 100);
country_codes[100] = Array('Honduras',504, 101);
country_codes[101] = Array('Hong Kong',852, 102);
country_codes[102] = Array('Hungary',36, 103);
country_codes[103] = Array('Iceland',354, 104);
country_codes[104] = Array('India',91, 105);
country_codes[105] = Array('Indonesia',62, 106);
country_codes[106] = Array('Inmarsat (Atlantic Ocean - East)',871, 107);
country_codes[107] = Array('Inmarsat (Atlantic Ocean - West)',874, 108);
country_codes[108] = Array('Inmarsat (Indian Ocean)',873, 109);
country_codes[109] = Array('Inmarsat (Pacific Ocean)',872, 110);
country_codes[110] = Array('Inmarsat SNAC',870, 111);
country_codes[111] = Array('International Freephone Service',800, 112);
country_codes[112] = Array('International Shared Cost Service (ISCS)',808, 113);
country_codes[113] = Array('Iran',98, 114);
country_codes[114] = Array('Iraq',964, 115);
country_codes[115] = Array('Ireland',353, 116);
country_codes[116] = Array('Israel',972, 117);
country_codes[117] = Array('Italy',39, 118);
country_codes[118] = Array('Jamaica',876, 119);
country_codes[119] = Array('Japan',81, 120);
country_codes[120] = Array('Jordan',962, 121);
country_codes[121] = Array('Kazakhstan',7, 122);
country_codes[122] = Array('Kenya',254, 123);
country_codes[123] = Array('Kiribati',686, 124);
country_codes[124] = Array('Korea (North)',850, 125);
country_codes[125] = Array('Korea (South)',82, 126);
country_codes[126] = Array('Kuwait',965, 127);
country_codes[127] = Array('Kyrgyz Republic',996, 128);
country_codes[128] = Array('Laos',856, 129);
country_codes[129] = Array('Latvia',371, 130);
country_codes[130] = Array('Lebanon',961, 131);
country_codes[131] = Array('Lesotho',266, 132);
country_codes[132] = Array('Liberia',231, 133);
country_codes[133] = Array('Libya',218, 134);
country_codes[134] = Array('Liechtenstein',423, 135);
country_codes[135] = Array('Lithuania',370, 136);
country_codes[136] = Array('Luxembourg',352, 137);
country_codes[137] = Array('Macao',853, 138);
country_codes[138] = Array('Macedonia (Former Yugoslav Rep of.)',389, 139);
country_codes[139] = Array('Madagascar',261, 140);
country_codes[140] = Array('Malawi',265, 141);
country_codes[141] = Array('Malaysia',60, 142);
country_codes[142] = Array('Maldives',960, 143);
country_codes[143] = Array('Mali Republic',223, 144);
country_codes[144] = Array('Malta',356, 145);
country_codes[145] = Array('Marshall Islands',692, 146);
country_codes[146] = Array('Martinique',596, 147);
country_codes[147] = Array('Mauritania',222, 148);
country_codes[148] = Array('Mauritius',230, 149);
country_codes[149] = Array('Mayotte Island',269, 150);
country_codes[150] = Array('Mexico',52, 151);
country_codes[151] = Array('Micronesia, (Federal States of)',691, 152);
country_codes[152] = Array('Midway Island',808, 153);
country_codes[153] = Array('Moldova',373, 154);
country_codes[154] = Array('Monaco',377, 155);
country_codes[155] = Array('Mongolia',976, 156);
country_codes[156] = Array('Montserrat',664, 157);
country_codes[157] = Array('Morocco',212, 158);
country_codes[158] = Array('Mozambique',258, 159);
country_codes[159] = Array('Myanmar',95, 160);
country_codes[160] = Array('Namibia',264, 161);
country_codes[161] = Array('Nauru',674, 162);
country_codes[162] = Array('Nepal',977, 163);
country_codes[163] = Array('Netherlands',31, 164);
country_codes[164] = Array('Netherlands Antilles',599, 165);
country_codes[165] = Array('Nevis',869, 166);
country_codes[166] = Array('New Caledonia',687, 167);
country_codes[167] = Array('New Zealand',64, 168);
country_codes[168] = Array('Nicaragua',505, 169);
country_codes[169] = Array('Niger',227, 170);
country_codes[170] = Array('Nigeria',234, 171);
country_codes[171] = Array('Niue',683, 172);
country_codes[172] = Array('Norfolk Island',672, 173);
country_codes[173] = Array('Northern Marianas Islands (Saipan, Rota, &amp; Tinian)',670, 174);
country_codes[174] = Array('Norway',47, 175);
country_codes[175] = Array('Oman',968, 176);
country_codes[176] = Array('Pakistan',92, 177);
country_codes[177] = Array('Palau',680, 178);
country_codes[178] = Array('Palestinian Settlements',970, 179);
country_codes[179] = Array('Panama',507, 180);
country_codes[180] = Array('Papua New Guinea',675, 181);
country_codes[181] = Array('Paraguay',595, 182);
country_codes[182] = Array('Peru',51, 183);
country_codes[183] = Array('Philippines',63, 184);
country_codes[184] = Array('Poland',48, 185);
country_codes[185] = Array('Portugal',351, 186);
country_codes[186] = Array('Puerto Rico',787, 187);
country_codes[187] = Array('Qatar',974, 188);
country_codes[188] = Array('Romania',40, 190);
country_codes[189] = Array('Russia',7, 191);
country_codes[190] = Array('Rwandese Republic',250, 192);
country_codes[191] = Array('R‚union Island',262, 189);
country_codes[192] = Array('S?o Tom‚ and Principe',239, 199);
country_codes[193] = Array('San Marino',378, 198);
country_codes[194] = Array('Saudi Arabia',966, 200);
country_codes[195] = Array('Senegal',221, 201);
country_codes[196] = Array('Serbia and Montenegro',381, 202);
country_codes[197] = Array('Seychelles Republic',248, 203);
country_codes[198] = Array('Sierra Leone',232, 204);
country_codes[199] = Array('Singapore',65, 205);
country_codes[200] = Array('Slovak Republic',421, 206);
country_codes[201] = Array('Slovenia',386, 207);
country_codes[202] = Array('Solomon Islands',677, 208);
country_codes[203] = Array('Somali Democratic Republic',252, 209);
country_codes[204] = Array('South Africa',27, 210);
country_codes[205] = Array('Spain',34, 211);
country_codes[206] = Array('Sri Lanka',94, 212);
country_codes[207] = Array('St. Helena',290, 193);
country_codes[208] = Array('St. Kitts/Nevis',869, 194);
country_codes[209] = Array('St. Lucia',758, 195);
country_codes[210] = Array('St. Pierre &amp; Miquelon',508, 196);
country_codes[211] = Array('St. Vincent &amp; Grenadines',784, 197);
country_codes[212] = Array('Sudan',249, 213);
country_codes[213] = Array('Suriname',597, 214);
country_codes[214] = Array('Swaziland',268, 215);
country_codes[215] = Array('Sweden',46, 216);
country_codes[216] = Array('Switzerland',41, 217);
country_codes[217] = Array('Syria',963, 218);
country_codes[218] = Array('Taiwan',886, 219);
country_codes[219] = Array('Tajikistan',992, 220);
country_codes[220] = Array('Tanzania',255, 221);
country_codes[221] = Array('Thailand',66, 222);
country_codes[222] = Array('Togolese Republic',228, 223);
country_codes[223] = Array('Tokelau',690, 224);
country_codes[224] = Array('Tonga Islands',676, 225);
country_codes[225] = Array('Trinidad &amp; Tobago',868, 226);
country_codes[226] = Array('Tunisia',216, 227);
country_codes[227] = Array('Turkey',90, 228);
country_codes[228] = Array('Turkmenistan',993, 229);
country_codes[229] = Array('Turks and Caicos Islands',649, 230);
country_codes[230] = Array('Tuvalu',688, 231);
country_codes[231] = Array('Uganda',256, 232);
country_codes[232] = Array('Ukraine',380, 233);
country_codes[233] = Array('United Arab Emirates',971, 234);
country_codes[234] = Array('United Kingdom',44, 235);
last_country = 'United States of America';			
last_country_id = 236;
stored_domestic_country = 'United States of America';			
country_codes[235] = Array('United States of America',1, 236);
country_codes[236] = Array('Universal Personal Telecommunications (UPT)',878, 238);
country_codes[237] = Array('Uruguay',598, 239);
country_codes[238] = Array('US Virgin Islands',340, 237);
country_codes[239] = Array('Uzbekistan',998, 240);
country_codes[240] = Array('Vanuatu',678, 241);
country_codes[241] = Array('Vatican City',379, 242);
country_codes[242] = Array('Venezuela',58, 243);
country_codes[243] = Array('Vietnam',84, 244);
country_codes[244] = Array('Wake Island',808, 245);
country_codes[245] = Array('Wallis and Futuna Islands',681, 246);
country_codes[246] = Array('Western Samoa',685, 247);
country_codes[247] = Array('Yemen',967, 248);
country_codes[248] = Array('Zambia',260, 249);
country_codes[249] = Array('Zanzibar',255, 250);
country_codes[250] = Array('Zimbabwe',263, 251);

international_selects[international_selects.length] = 'Country_local';
international_selects[international_selects.length] = 'Country_inter';
international_divs[international_divs.length] = 'Country_inter_div';
domestic_divs[domestic_divs.length] = 'Country_local_div';
state_fields[state_fields.length] = 'State';
international_selects[international_selects.length] = 'State_states_of_40';
international_selects[international_selects.length] = 'State_states_of_236';
zip_fields[zip_fields.length] = 'Zip';
country_code_fields[country_code_fields.length] = 'CountryCodeOffice1';
area_code_fields[area_code_fields.length] = 'AreaCodeOffice1';
phone_a_fields[phone_a_fields.length] = 'PhoneOffice1a';
phone_b_fields[phone_b_fields.length] = 'PhoneOffice1b';
phone_verbose_names[phone_verbose_names.length] = 'Office Phone 1';
international_divs[international_divs.length] = 'PhoneOffice1';
domestic_divs[domestic_divs.length] = 'PhoneOffice1_phone_b_div';
