/* Start of Data Array */
	   var countrycode = new Array();

	   var have_local_codes = new Array();

	   have_local_codes['AU'] = 'true';

	   var havestate = new Array();
		 havestate['AU'] = 'true';
		 havestate['JP'] = 'true';
		 havestate['NZ'] = 'true';
		 havestate['US'] = 'true';
		 havestate['NULL'] = 'true';
        countrycode['AF'] = 93;

        countrycode['AL'] = 355;

        countrycode['DZ'] = 213;

        countrycode['AS'] = 684;

        countrycode['AD'] = 376;

        countrycode['AO'] = 244;

        countrycode['AI'] = 1;

        countrycode['AQ'] = 672;

        countrycode['AG'] = 672;

        countrycode['AR'] = 54;

        countrycode['AM'] = 374;

        countrycode['AW'] = 297;

        countrycode['AU'] = 61;

        countrycode['AT'] = 43;

        countrycode['AZ'] = 994;

        countrycode['BS'] = 242;

        countrycode['BH'] = 973;

        countrycode['BD'] = 880;

        countrycode['BB'] = 246;

        countrycode['BY'] = 375;
        countrycode['NULL'] = '';
        countrycode['BE'] = 32;

        countrycode['BZ'] = 501;

        countrycode['BJ'] = 229;

        countrycode['BM'] = 441;

        countrycode['BT'] = 975;

        countrycode['BO'] = 591;

        countrycode['BA'] = 387;

        countrycode['BW'] = 267;

        countrycode['BV'] = 267;

        countrycode['BR'] = 55;

        countrycode['IO'] = 246;

        countrycode['BN'] = 246;

        countrycode['BG'] = 359;

        countrycode['BF'] = 226;

        countrycode['BI'] = 257;

        countrycode['KH'] = 855;

        countrycode['CM'] = 237;

        countrycode['CA'] = 1;

        countrycode['CV'] = 238;

        countrycode['KY'] = 809;

        countrycode['CF'] = 236;

        countrycode['TD'] = 235;

        countrycode['CL'] = 56;

        countrycode['CN'] = 86;

        countrycode['CX'] = 61;

        countrycode['CC'] = 61;

        countrycode['CO'] = 57;

        countrycode['KM'] = 269;

        countrycode['CG'] = 242;

        countrycode['CD'] = 243;

        countrycode['CK'] = 682;

        countrycode['CR'] = 506;

        countrycode['CI'] = 225;

        countrycode['HR'] = 385;

        countrycode['CU'] = 53;

        countrycode['CY'] = 357;

        countrycode['CZ'] = 420;

        countrycode['DK'] = 45;

        countrycode['DJ'] = 253;

        countrycode['DM'] = 1;

        countrycode['DO'] = 809;

        countrycode['TP'] = 670;

        countrycode['EC'] = 593;

        countrycode['EG'] = 20;

        countrycode['SV'] = 503;

        countrycode['GQ'] = 240;

        countrycode['ER'] = 291;

        countrycode['EE'] = 372;

        countrycode['ET'] = 251;

        countrycode['FK'] = 500;

        countrycode['FO'] = 298;

        countrycode['FJ'] = 679;

        countrycode['FI'] = 358;

        countrycode['FR'] = 33;

        countrycode['GF'] = 594;

        countrycode['PF'] = 689;

        countrycode['TF'] = 33;

        countrycode['GA'] = 241;

        countrycode['GM'] = 220;

        countrycode['GE'] = 995;

        countrycode['DE'] = 49;

        countrycode['GH'] = 233;

        countrycode['GI'] = 350;

        countrycode['GR'] = 30;

        countrycode['GL'] = 299;

        countrycode['GD'] = 809;

        countrycode['GP'] = 590;

        countrycode['GU'] = 671;

        countrycode['GT'] = 502;

        countrycode['GN'] = 224;

        countrycode['GW'] = 245;

        countrycode['GY'] = 592;

        countrycode['HT'] = 509;

        countrycode['HM'] = 61;

        countrycode['VA'] = 39;

        countrycode['HN'] = 504;

        countrycode['HK'] = 852;

        countrycode['HU'] = 36;

        countrycode['IS'] = 354;

        countrycode['IN'] = 91;

        countrycode['ID'] = 62;

        countrycode['IR'] = 98;

        countrycode['IQ'] = 964;

        countrycode['IE'] = 353;

        countrycode['IL'] = 972;

        countrycode['IT'] = 39;

        countrycode['JM'] = 1;

        countrycode['JP'] = 81;

        countrycode['JO'] = 962;

        countrycode['KZ'] = 7;

        countrycode['KE'] = 254;

        countrycode['KI'] = 686;

        countrycode['KP'] = 850;

        countrycode['KR'] = 82;

        countrycode['KW'] = 965;

        countrycode['KG'] = 996;

        countrycode['LA'] = 856;

        countrycode['LV'] = 371;

        countrycode['LB'] = 961;

        countrycode['LS'] = 266;

        countrycode['LR'] = 231;

        countrycode['LY'] = 218;

        countrycode['LI'] = 41;

        countrycode['LT'] = 370;

        countrycode['LU'] = 352;

        countrycode['MO'] = 853;

        countrycode['MK'] = 389;

        countrycode['MG'] = 261;

        countrycode['MW'] = 265;

        countrycode['MY'] = 60;

        countrycode['MV'] = 960;

        countrycode['ML'] = 223;

        countrycode['MT'] = 356;

        countrycode['MH'] = 692;

        countrycode['MQ'] = 596;

        countrycode['MR'] = 222;

        countrycode['MU'] = 230;

        countrycode['YT'] = 269;

        countrycode['MX'] = 52;

        countrycode['FM'] = 691;

        countrycode['MD'] = 373;

        countrycode['MC'] = 377;

        countrycode['MN'] = 976;

        countrycode['MS'] = 809;

        countrycode['MA'] = 212;

        countrycode['MZ'] = 258;

        countrycode['MM'] = 95;

        countrycode['NA'] = 264;

        countrycode['NR'] = 674;

        countrycode['NP'] = 977;

        countrycode['NL'] = 31;

        countrycode['AN'] = 599;

        countrycode['NC'] = 687;

        countrycode['NZ'] = 64;

        countrycode['NI'] = 505;

        countrycode['NE'] = 227;

        countrycode['NG'] = 234;

        countrycode['NU'] = 683;

        countrycode['NF'] = 672;

        countrycode['MP'] = 670;

        countrycode['NO'] = 47;

        countrycode['OM'] = 968;

        countrycode['PK'] = 92;

        countrycode['PW'] = 680;

        countrycode['PS'] = 970;

        countrycode['PA'] = 507;

        countrycode['PG'] = 675;

        countrycode['PY'] = 595;

        countrycode['PE'] = 51;

        countrycode['PH'] = 63;

        countrycode['PN'] = 872;

        countrycode['PL'] = 48;

        countrycode['PT'] = 351;

        countrycode['PR'] = 1;

        countrycode['QA'] = 974;

        countrycode['RE'] = 262;

        countrycode['RO'] = 40;

        countrycode['RU'] = 7;

        countrycode['RW'] = 250;

        countrycode['SH'] = 290;

        countrycode['KN'] = 1;

        countrycode['LC'] = 1;

        countrycode['PM'] = 508;

        countrycode['VC'] = 1;

        countrycode['WS'] = 685;

        countrycode['SM'] = 378;

        countrycode['ST'] = 239;

        countrycode['SA'] = 966;

        countrycode['SN'] = 221;

        countrycode['CS'] = 381;

        countrycode['SC'] = 248;

        countrycode['SL'] = 232;

        countrycode['SG'] = 65;

        countrycode['SK'] = 421;

        countrycode['SI'] = 386;

        countrycode['SB'] = 677;

        countrycode['SO'] = 252;

        countrycode['ZA'] = 27;

        countrycode['GS'] = 995;

        countrycode['ES'] = 34;

        countrycode['LK'] = 94;

        countrycode['SD'] = 249;

        countrycode['SR'] = 597;

        countrycode['SJ'] = 79;

        countrycode['SZ'] = 268;

        countrycode['SE'] = 46;

        countrycode['CH'] = 41;

        countrycode['SY'] = 963;

        countrycode['TW'] = 886;

        countrycode['TJ'] = 7;

        countrycode['TZ'] = 255;

        countrycode['TH'] = 66;

        countrycode['TG'] = 228;

        countrycode['TK'] = 690;

        countrycode['TO'] = 676;

        countrycode['TT'] = 868;

        countrycode['TN'] = 216;

        countrycode['TR'] = 90;

        countrycode['TM'] = 993;

        countrycode['TC'] = 1;

        countrycode['TV'] = 688;

        countrycode['UG'] = 256;

        countrycode['UA'] = 380;

        countrycode['AE'] = 971;

        countrycode['GB'] = 44;
        countrycode['UK'] = 44;
        countrycode['US'] = 1;

        countrycode['UM'] = 1;

        countrycode['UY'] = 598;

        countrycode['UZ'] = 7;

        countrycode['VU'] = 678;

        countrycode['VE'] = 58;

        countrycode['VN'] = 84;

        countrycode['VG'] = 1;

        countrycode['VI'] = 1;

        countrycode['WF'] = 681;

        countrycode['EH'] = 212;

        countrycode['YE'] = 969;

        countrycode['ZM'] = 260;

        countrycode['ZW'] = 263;

        var statearrayAU = new Array();

		var statearrayNULL = new Array();

		var phonearrayAU = new Array();

		var statearrayJP = new Array();

        var statearrayNZ = new Array();

        var statearrayUS = new Array();

        statearrayAU['ACT'] = 'Australian Capital Territory';
        phonearrayAU['ACT'] = "02";

        statearrayAU['NSW'] = 'New South Wales';
        phonearrayAU['NSW'] = "02";

        statearrayAU['NT'] = 'Northern Territory';
        phonearrayAU['NT'] = '08';

        statearrayAU['QLD'] = 'Queensland';
        phonearrayAU['QLD'] = '07';

        statearrayAU['SA'] = 'South Australia';
        phonearrayAU['SA'] = '08';

        statearrayAU['TAS'] = 'Tasmania';
        phonearrayAU['TAS'] = '03';

        statearrayAU['VIC'] = 'Victoria';
        phonearrayAU['VIC'] = '03';

        statearrayAU['WA'] = 'Western Australia';
        phonearrayAU['WA'] = '08';

        statearrayJP['Hokkaido'] = 'Hokkaido';

        statearrayJP['Aomori'] = 'Aomori';

        statearrayJP['Iwate'] = 'Iwate';

        statearrayJP['Miyagi'] = 'Miyagi';

        statearrayJP['Akita'] = 'Akita';

        statearrayJP['Yamagata'] = 'Yamagata';

        statearrayJP['Tokyo'] = 'Tokyo';

        statearrayJP['Kanagawa'] = 'Kanagawa';

        statearrayJP['Niigata'] = 'Niigata';

        statearrayJP['Toyama'] = 'Toyama';

        statearrayJP['Ishikawa'] = 'Ishikawa';

        statearrayJP['Fukui'] = 'Fukui';

        statearrayJP['Shiga'] = 'Shiga';

        statearrayJP['Kyoto'] = 'Kyoto';

        statearrayJP['Osaka'] = 'Osaka';

        statearrayJP['Hyogo'] = 'Hyogo';

        statearrayJP['Nara'] = 'Nara';

        statearrayJP['Wakayama'] = 'Wakayama';

        statearrayJP['Kagawa'] = 'Kagawa';

        statearrayJP['Ehime'] = 'Ehime';

        statearrayJP['Kouchi'] = 'Kouchi';

        statearrayJP['Fukuoka'] = 'Fukuoka';

        statearrayJP['Saga'] = 'Saga';

        statearrayJP['Nagasaki'] = 'Nagasaki';

        statearrayJP['Fukushima'] = 'Fukushima';

        statearrayJP['Ibaraki'] = 'Ibaraki';

        statearrayJP['Tochigi'] = 'Tochigi';

        statearrayJP['Gumma'] = 'Gumma';

        statearrayJP['Saitama'] = 'Saitama';

        statearrayJP['Chiba'] = 'Chiba';

        statearrayJP['Yamanashi'] = 'Yamanashi';

        statearrayJP['Nagano'] = 'Nagano';

        statearrayJP['Gifu'] = 'Gifu';

        statearrayJP['Shizuoka'] = 'Shizuoka';

        statearrayJP['Aichi'] = 'Aichi';

        statearrayJP['Mie'] = 'Mie';

        statearrayJP['Tottori'] = 'Tottori';

        statearrayJP['Shimane'] = 'Shimane';

        statearrayJP['Hiroshima'] = 'Hiroshima';
		
        statearrayJP['Okayama'] = 'Okayama';

        statearrayJP['Yamaguchi'] = 'Yamaguchi';

        statearrayJP['Tokushima'] = 'Tokushima';

        statearrayJP['Kumamoto'] = 'Kumamoto';

        statearrayJP['Oita'] = 'Oita';

        statearrayJP['Miyazaki'] = 'Miyazaki';

        statearrayJP['Kagoshima'] = 'Kagoshima';

        statearrayJP['Okinawa'] = 'Okinawa ';

        statearrayNZ['Northland'] = 'Northland';

        statearrayNZ['Auckland'] = 'Auckland';

        statearrayNZ['Waikato'] = 'Waikato';

        statearrayNZ['Bay of Plenty'] = 'Bay of Plenty';

        statearrayNZ['Gisborne'] = 'Gisborne';

        statearrayNZ['Hawkes Bay'] = 'Hawkes Bay';

        statearrayNZ['Taranaki'] = 'Taranaki';

        statearrayNZ['Manawatu-Wanganui'] = 'Manawatu-Wanganui';

        statearrayNZ['Wellington'] = 'Wellington';

        statearrayNZ['Tasman'] = 'Tasman';

        statearrayNZ['Marlborough'] = 'Marlborough';

        statearrayNZ['Nelson'] = 'Nelson';

        statearrayNZ['West Coast'] = 'West Coast';

        statearrayNZ['Otago'] = 'Otago';

        statearrayNZ['Canterbury'] = 'Canterbury';

        statearrayNZ['Southland'] = 'Southland';

        statearrayNZ['Chatham Islands'] = 'Chatham Islands';

        statearrayUS['AL'] = 'Alabama';

        statearrayUS['AK'] = 'Alaska';

        statearrayUS['AZ'] = 'Arizona';

        statearrayUS['AR'] = 'Arkansas';

        statearrayUS['CA'] = 'California';

        statearrayUS['CO'] = 'Colorado';

        statearrayUS['CT'] = 'Connecticut';

        statearrayUS['DC'] = 'D.C.';

        statearrayUS['DE'] = 'Delaware';

        statearrayUS['FL'] = 'Florida';

        statearrayUS['GA'] = 'Georgia';

        statearrayUS['HI'] = 'Hawaii';

        statearrayUS['ID'] = 'Idaho';

        statearrayUS['IL'] = 'Illinois';

        statearrayUS['IN'] = 'Indiana';

        statearrayUS['IA'] = 'Iowa';

        statearrayUS['KS'] = 'Kansas';

        statearrayUS['KY'] = 'Kentucky';

        statearrayUS['LA'] = 'Louisiana';

        statearrayUS['ME'] = 'Maine';

        statearrayUS['MD'] = 'Maryland';

        statearrayUS['MA'] = 'Massachusetts';

        statearrayUS['MI'] = 'Michigan';

        statearrayUS['MN'] = 'Minnesota';

        statearrayUS['MS'] = 'Mississippi';

        statearrayUS['MO'] = 'Missouri';

        statearrayUS['MT'] = 'Montana';

        statearrayUS['NE'] = 'Nebraska';

        statearrayUS['NV'] = 'Nevada';

        statearrayUS['NH'] = 'New Hampshire';

        statearrayUS['NJ'] = 'New Jersey';

        statearrayUS['NM'] = 'New Mexico';

        statearrayUS['NY'] = 'New York';

        statearrayUS['NC'] = 'North Carolina';

        statearrayUS['ND'] = 'North Dakota';

        statearrayUS['OH'] = 'Ohio';

        statearrayUS['OK'] = 'Oklahoma';

        statearrayUS['OR'] = 'Oregon';

        statearrayUS['PA'] = 'Pennsylvania';

        statearrayUS['RI'] = 'Rhode Island';

        statearrayUS['SC'] = 'South Carolina';

        statearrayUS['SD'] = 'South Dakota';

        statearrayUS['TN'] = 'Tennessee';

        statearrayUS['TX'] = 'Texas';

        statearrayUS['UT'] = 'Utah';

        statearrayUS['VT'] = 'Vermont';

        statearrayUS['VA'] = 'Virginia';

        statearrayUS['WA'] = 'Washington';

        statearrayUS['WV'] = 'West Virginia';

        statearrayUS['WI'] = 'Wisconsin';

        statearrayUS['WY'] = 'Wyoming';

        statearrayNULL['NULL'] = ' ';

		function setOther(string) {
		    document.getElementById("countryn").value = document.getElementById("countryn").value + string;
		    finalPhone();
		}

		function setCountry(string) {
		    if (countrycode[string]) {
		        document.getElementById("country_code").value = countrycode[string];
		    }
		    setState(string);
		    finalPhone();
		}

		function setState(string) {
		    if (havestate[string]) {
		        var strTex = "<select name=\"state\" id=\"state_name\" style=\"width: 150px;\" onchange=\"setStateCode(this.value);\">";
		        strTex = strTex + "<option value=\"\">Please Select</option>";
		        var sarray = window["statearray" + string];
		        for (var i in sarray) {
					if (typeof sarray[i] != 'function') {
						strTex = strTex + "<option value=\"" + i + "\">" + sarray[i] + "</option>";
					}
				}
		        strTex = strTex + "</select><span class=\"red\"> *</span>";
		        //strTex = strTex + "</select> <font color=\"#FF0000\">*</font>";
		        document.getElementById("state_div").innerHTML = strTex;
		    } else {
		        document.getElementById("state_div").innerHTML = "<input type=\"text\" name=\"state\" id=\"state_name\" style=\"width: 150px;\" maxlength=\"40\"><span class=\"red\"> *</span>";
		    }
		    finalPhone();
		}

		function setStateCode(state){
			var country = document.getElementById('country_name').value;
			if(country != '' && state != '' && have_local_codes[country]){
				var state_code = window["phonearray" + country][state];
				document.getElementById("phone_number").value = state_code + ' ';
			}
		}

		function finalPhone() {
		    var country = document.getElementById("country_code").value.replace(/\D/g, "");
		    var phone = document.getElementById("phone_number").value.replace(/\D/g, "");
		}