geocoder = new GClientGeocoder();
function verifyAndSubmit(action, form , alertMsg){
    try{
        if(form.addressLine1.value == '' || form.city.value == '' || form.postalCode.value == ''){
            _sv2(action,form,'actionForm','Submit');
            return false;
        }
        var state = '';
        if(form.selectedCountryId.value == 'CA' || form.selectedCountryId.value == 'US'){
            state = ', ' + form.state.value;
        }
        var postalCodeDisplay = (form.postalCode.value.toLowerCase() != 'a1a1a1')?', ' + form.postalCode.value:''; 
        var address = form.addressLine1.value + ',' + form.city.value + state + ', ' + getCountryDisplayEn(form.selectedCountryId.value) + postalCodeDisplay;
        

        geocoder.getLatLng(address, function(point){
        if (point) {
            _sv2(action,form,'actionForm','Submit','lat',point.lat(),'lng',point.lng());
        }else if(confirm(alertMsg)){
            _sv2(action,form,'actionForm','Submit','lat','-200.0','lng','-200.0');
        }
                                        });
        
    }catch(err){alert(err);}
}

function setDefaultCoordinates(id){
    var defaultLng = document.UserAddressViewForm.defaultLng.value;
    var defaultLat = document.UserAddressViewForm.defaultLat.value;
    
    geocoder.getLatLng(country, function(point){
                                                document.UserAddressViewForm.defaultLng.value = point.lng().toFixed(5);
                                                document.UserAddressViewForm.defaultLat.value = point.lat().toFixed(5);
                                                //alert(point.lng().toFixed(5) + ' ' + point.lat().toFixed(5));
                                              });
} 

function load(latIn,lngIn, zoomLevel) {
      
      var lat = 0;
      var lng = 0;
      var zoom_level = 4;
	if(latIn != undefined && lngIn != undefined && latIn != -200 && lngIn != -200){
	    zoom_level = (zoomLevel)?zoomLevel:14;
	    lat = latIn;
	    lng = lngIn;
	}
	if (GBrowserIsCompatible()) {

	    var map_div = document.getElementById('map');
	    var map = new GMap2(map_div);

            map.removeMapType(G_HYBRID_MAP);
            map.removeMapType(G_SATELLITE_MAP);
            

	    map.addControl(new GSmallMapControl());
	    map.addControl(new GMapTypeControl());
	    var center = new GLatLng(lat,lng);
	    map.setCenter(center, zoom_level);
	    

	    var marker = new GMarker(center, {draggable: true});  
	    map.addOverlay(marker);
	    
	    GEvent.addListener(marker, "dragend", function() {
	    var point = marker.getPoint();
	    map.panTo(point);
	    //document.getElementById("lat").innerHTML = point.lat().toFixed(5);
	    //document.getElementById("lng").innerHTML = point.lng().toFixed(5);
		});


//	 GEvent.addListener(map, "moveend", function() {
//		  map.clearOverlays();
//		  var center = map.getCenter();
//		  var marker = new GMarker(center, {draggable: true});
//		  map.addOverlay(marker);



	 GEvent.addListener(marker, "dragend", function() {
     var point =marker.getPoint();
	     map.panTo(point);
 	     changeLocationOnMap(point.lat().toFixed(5),point.lng().toFixed(5));
       });
 

      }
    }

function showAddress(address,lat,lng) {
    if(lat != undefined && lng != undefined && lat != -200 && lng != -200){
        setAddressToDisplay('addresDisplayFound');
        load(lat,lng);
        return false;
    }
	var map_div = document.getElementById('map');
	   var map = new GMap2(map_div);
       map.addControl(new GSmallMapControl());
       map.addControl(new GMapTypeControl());
        map.removeMapType(G_HYBRID_MAP);
        map.removeMapType(G_SATELLITE_MAP);

       if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
                setAddressToDisplay('addresDisplayNotFound');
		changeLocationOnMap('-200','-200');
		apost('mngAddrssAjax.do?actionForm=UpdatePoint','no_replacement',document.UserAddressViewForm,'lat',-200,'lng',-200,'_eval0','');
                var addressId = document.getElementById('addressToDisplay').value;
                var country = document.getElementById('country_'+addressId).value;
                var countryDefaultLat = getCountryLat(country);
                var countryDefaultLng = getCountryLng(country);
                var zoom = getCountryZoomLevel(country);
                //alert();
		load(countryDefaultLat, countryDefaultLng,zoom);
            } else {
                setAddressToDisplay('addresDisplayFound');
		apost('mngAddrssAjax.do?actionForm=UpdatePoint','no_replacement',document.UserAddressViewForm,'lat',point.lat().toFixed(5),'lng',point.lng().toFixed(5),'_eval0','');
		document.getElementById('addressToDisplayCrntLng').value = point.lng().toFixed(5);
		document.getElementById('addressToDisplayCrntLat').value = point.lat().toFixed(5);
		var addressId = document.getElementById('addressToDisplay').value;
		document.getElementById('lat_'+addressId).value = point.lat().toFixed(5);
		document.getElementById('lng_'+addressId).value = point.lng().toFixed(5);
		document.getElementById('overwriteCoordinates').innerHTML = '';
		 map.clearOverlays()
			map.setCenter(point, 14);
		var marker = new GMarker(point, {draggable: true});  
		 map.addOverlay(marker);

		GEvent.addListener(marker, "dragend", function() {
	     var pt = marker.getPoint();
	     map.panTo(pt);
        });

//	 GEvent.addListener(map, "moveend", function() {
//		  map.clearOverlays();
//		  var center = map.getCenter();
//		  var marker = new GMarker(center, {draggable: true});
//		  map.addOverlay(marker);


	 GEvent.addListener(marker, "dragend", function() {
     var pt = marker.getPoint();
	    map.panTo(pt);
changeLocationOnMap(pt.lat().toFixed(5),pt.lng().toFixed(5));
        });
 
//        });

            }
          }
        );
      }
    }

function changeLocationOnMap(lat,lng){
//alert('changeLocationOnMap('+lat+','+lng+')');
    document.getElementById('addressToDisplayCrntLng').value = lng;
    document.getElementById('addressToDisplayCrntLat').value = lat;
    
    if(lat == -200 && lng == -200){

	var addressId = document.getElementById('addressToDisplay').value;
	document.getElementById('lat_'+addressId).value = lat;
	document.getElementById('lng_'+addressId).value = lng;
	var country = document.getElementById('country_'+addressId).value;
        lat = getCountryLat(country);
        lng = getCountryLng(country);
    }
    var language = document.getElementById('lngg').value;
    var methodCall = 'applyChangedLocationPoint('+lat+','+lng+')';
    document.getElementById('overwriteCoordinates').innerHTML='<a href="javascript:void(0)" onclick="'+methodCall+'"><img border=\"0\" src=\"img/buttons/apply_coordinates_'+language+'.gif\" onmouseover=\"this.src=\'img/buttons/apply_coordinates_over_'+language+'.gif\'\" onmouseout=\"this.src=\'img/buttons/apply_coordinates_'+language+'.gif\'\"/></a>';
}
function applyChangedLocationPoint(lat,lng){
try{
    var addressId = document.getElementById('addressToDisplay').value;
    document.getElementById('lat_'+addressId).value = lat;
    document.getElementById('lng_'+addressId).value = lng;
    document.getElementById('overwriteCoordinates').innerHTML='';

    document.getElementById('addressToDisplayCrntLng').value = lng;
    document.getElementById('addressToDisplayCrntLat').value = lat;
    try{
        //alert('2222222');
	setAddressToDisplay('addresDisplayFound');
    }catch(err){
	alert('applyChangedLocationPoint ' + err);
    }
    apost('mngAddrssAjax.do?actionForm=UpdatePoint','no_replacement',document.UserAddressViewForm,'lat',lat,'lng',lng,'_eval0','');
    load(lat,lng);
    }catch(err){
	alert('applyChangedLocationPoint ' + err);
    }
}

function setAddressToDisplay(ident){
    var divElement = document.getElementById('address_to_display');
    if(ident == 'addresDisplayFound'){
        divElement.innerHTML = '<font class=\'static_fields\'>&nbsp;<br>&nbsp;</font>';
	//divElement.innerHTML = document.getElementById('addressDtl1').value+ '<font class=\'bold\'><font class=\'dynamic_fields\'>' +addressDtl+'</font></font>'+document.getElementById('addressDtl2').value;
    }else if(ident == 'addresDisplayNotFound'){
        
	divElement.innerHTML = document.getElementById('addressNotFoundStr').value;
    }else if(ident == 'addresId'){
        divElement.innerHTML = '<font class=\'static_fields\'>&nbsp;<br>&nbsp;</font>';
	//var addressDisplayStr = document.getElementById('display_'+addressDtl).value;
        //divElement.innerHTML = document.getElementById('addressDtl1').value+ ' <font class="static_fields">'+addressDisplayStr + '<br> &nbsp</font>';
    }
}


    function setPrimaryAddress(action, form, addressId){
	apost(action, 'address_list_short', form ,'_eval0','');  
	document.UserAddressViewForm.primaryAddressId.value=addressId;
	document.UserAddressViewForm.addressToDisplay.value=addressId;
        ///alert('333333333');
	setAddressToDisplay('addresDisplayFound');
	showAddress(getAddressDisplay(addressId),getAddressLat(addressId),getAddressLng(addressId));
	
    }
    
    
    
    function getAddressDisplay(addressId){
    	return document.getElementById('display_'+addressId).value;
    }
    function getAddressLat(addressId){
    	return document.getElementById('lat_'+addressId).value;
    }
    function getAddressLng(addressId){
        return document.getElementById('lng_'+addressId).value;
    }




    var country = new Array();
    country[0] = 'Afghanistan';
    country[1] = 'Albania';
    country[2] = 'Algeria';
    country[3] = 'American Samoa';
    country[4] = 'Andorra';
    country[5] = 'Angola';
country[6] = 'Anguilla';
country[7] = 'Antarctica';
country[8] = 'Antigua and Barbuda';
country[9] = 'Argentina';
country[10] = 'Armenia';
country[11] = 'Aruba';
country[12] = 'Australia';
country[13] = 'Austria';
country[14] = 'Azerbaijan';
country[15] = 'Bahamas';
country[16] = 'Bahrain';
country[17] = 'Bangladesh';
country[18] = 'Barbados';
country[19] = 'Belarus';
country[20] = 'Belgium';
country[21] = 'Belize';
country[22] = 'Benin';
country[23] = 'Bermuda';
country[24] = 'Bhutan';
country[25] = 'Bolivia';
country[26] = 'Bosnia and Herzegovina';
country[27] = 'Botswana';
country[28] = 'Bouvet Island';
country[29] = 'Brazil';
country[30] = 'British Indian Ocean Territory';
country[31] = 'British Virgin Islands';
country[32] = 'Brunei';
country[33] = 'Burkina Faso';
country[34] = 'Burundi';
country[35] = 'Cambodia';
country[36] = 'Cameroon';
country[37] = 'Canada';
country[38] = 'Cape Verde';
country[39] = 'Cayman Islands';
country[40] = 'Central African Republic';
country[41] = 'Chad';
country[42] = 'Chile';
country[43] = 'China';
country[44] = 'Christmas Island';
country[45] = 'Cocos Islands';
country[46] = 'Colombia';
country[47] = 'Comoros';
country[48] = 'Congo';
country[49] = 'Cook Islands';
country[50] = 'Costa Rica';
country[51] = 'Croatia';
country[52] = 'Cuba';
country[53] = 'Cyprus';
country[54] = 'Czech Republic';
country[55] = 'C?te d\'Ivoire';
country[56] = 'Denmark';
country[57] = 'Djibouti';
country[58] = 'Dominica';
country[59] = 'Dominican Republic';
country[60] = 'Ecuador';
country[61] = 'Egypt';
country[62] = 'El Salvador';
country[63] = 'Equatorial Guinea';
country[64] = 'Eritrea';
country[65] = 'Estonia';
country[66] = 'Ethiopia';
country[67] = 'Falkland Islands';
country[68] = 'Faroe Islands';
country[69] = 'Fiji';
country[70] = 'Finland';
country[71] = 'France';
country[72] = 'French Guiana';
country[73] = 'French Polynesia';
country[74] = 'French Southern Territories';
country[75] = 'Gabon';
country[76] = 'Gambia';
country[77] = 'Georgia';
country[78] = 'Germany';
country[79] = 'Ghana';
country[80] = 'Gibraltar';
country[81] = 'Greece';
country[82] = 'Greenland';
country[83] = 'Grenada';
country[84] = 'Guadeloupe';
country[85] = 'Guam';
country[86] = 'Guatemala';
country[87] = 'Guinea';
country[88] = 'Guinea-Bissau';
country[89] = 'Guyana';
country[90] = 'Haiti';
country[91] = 'Heard Island And McDonald Islands';
country[92] = 'Honduras';
country[93] = 'Hong Kong';
country[94] = 'Hungary';
country[95] = 'Iceland';
country[96] = 'India';
country[97] = 'Indonesia';
country[98] = 'Iran';
country[99] = 'Iraq';
country[100] = 'Ireland';
country[101] = 'Israel';
country[102] = 'Italy';
country[103] = 'Jamaica';
country[104] = 'Japan';
country[105] = 'Jordan';
country[106] = 'Kazakhstan';
country[107] = 'Kenya';
country[108] = 'Kiribati';
country[109] = 'Kuwait';
country[110] = 'Kyrgyzstan';
country[111] = 'Laos';
country[112] = 'Latvia';
country[113] = 'Lebanon';
country[114] = 'Lesotho';
country[115] = 'Liberia';
country[116] = 'Libya';
country[117] = 'Liechtenstein';
country[118] = 'Lithuania';
country[119] = 'Luxembourg';
country[120] = 'Macao';
country[121] = 'Macedonia';
country[122] = 'Madagascar';
country[123] = 'Malawi';
country[124] = 'Malaysia';
country[125] = 'Maldives';
country[126] = 'Mali';
country[127] = 'Malta';
country[128] = 'Marshall Islands';
country[129] = 'Martinique';
country[130] = 'Mauritania';
country[131] = 'Mauritius';
country[132] = 'Mayotte';
country[133] = 'Mexico';
country[134] = 'Micronesia';
country[135] = 'Moldova';
country[136] = 'Monaco';
country[137] = 'Mongolia';
country[138] = 'Montenegro';
country[139] = 'Montserrat';
country[140] = 'Morocco';
country[141] = 'Mozambique';
country[142] = 'Myanmar';
country[143] = 'Namibia';
country[144] = 'Nauru';
country[145] = 'Nepal';
country[146] = 'Netherlands';
country[147] = 'Netherlands Antilles';
country[148] = 'New Caledonia';
country[149] = 'New Zealand';
country[150] = 'Nicaragua';
country[151] = 'Niger';
country[152] = 'Nigeria';
country[153] = 'Niue';
country[154] = 'Norfolk Island';
country[155] = 'North Korea';
country[156] = 'Northern Mariana Islands';
country[157] = 'Norway';
country[158] = 'Oman';
country[159] = 'Pakistan';
country[160] = 'Palau';
country[161] = 'Palestine';
country[162] = 'Panama';
country[163] = 'Papua New Guinea';
country[164] = 'Paraguay';
country[165] = 'Peru';
country[166] = 'Philippines';
country[167] = 'Pitcairn';
country[168] = 'Poland';
country[169] = 'Portugal';
country[170] = 'Puerto Rico';
country[171] = 'Qatar';
country[172] = 'Reunion';
country[173] = 'Romania';
country[174] = 'Russia';
country[175] = 'Rwanda';
country[176] = 'Saint Helena';
country[177] = 'Saint Kitts And Nevis';
country[178] = 'Saint Lucia';
country[179] = 'Saint Pierre And Miquelon';
country[180] = 'Saint Vincent And The Grenadines';
country[181] = 'Samoa';
country[182] = 'San Marino';
country[183] = 'Sao Tome And Principe';
country[184] = 'Saudi Arabia';
country[185] = 'Senegal';
country[186] = 'Serbia';
country[187] = 'Serbia and Montenegro';
country[188] = 'Seychelles';
country[189] = 'Sierra Leone';
country[190] = 'Singapore';
country[191] = 'Slovakia';
country[192] = 'Slovenia';
country[193] = 'Solomon Islands';
country[194] = 'Somalia';
country[195] = 'South Africa';
country[196] = 'South Georgia And The South Sandwich Islands';
country[197] = 'South Korea';
country[198] = 'Spain';
country[199] = 'Sri Lanka';
country[200] = 'Sudan';
country[201] = 'Suriname';
country[202] = 'Svalbard And Jan Mayen';
country[203] = 'Swaziland';
country[204] = 'Sweden';
country[205] = 'Switzerland';
country[206] = 'Syria';
country[207] = 'Taiwan';
country[208] = 'Tajikistan';
country[209] = 'Tanzania';
country[210] = 'Thailand';
country[211] = 'The Democratic Republic Of Congo';
country[212] = 'Timor-Leste';
country[213] = 'Togo';
country[214] = 'Tokelau';
country[215] = 'Tonga';
country[216] = 'Trinidad and Tobago';
country[217] = 'Tunisia';
country[218] = 'Turkey';
country[219] = 'Turkmenistan';
country[220] = 'Turks And Caicos Islands';
country[221] = 'Tuvalu';
country[222] = 'U.S. Virgin Islands';
country[223] = 'Uganda';
country[224] = 'Ukraine';
country[225] = 'United Arab Emirates';
country[226] = 'United Kingdom';
country[227] = 'United States';
country[228] = 'United States Minor Outlying Islands';
country[229] = 'Uruguay';
country[230] = 'Uzbekistan';
country[231] = 'Vanuatu';
country[232] = 'Vatican';
country[233] = 'Venezuela';
country[234] = 'Vietnam';
country[235] = 'Wallis And Futuna';
country[236] = 'Western Sahara';
country[237] = 'Yemen';
country[238] = 'Zambia';
country[239] = 'Zimbabwe';
country[240] = '?land Islands';
country[241] = 'Bulgaria';

var country_code = new Array();
country_code[0]='AF';
country_code[1]='AL';
country_code[2]='DZ';
country_code[3]='AS';
country_code[4]='AD';
country_code[5]='AO';
country_code[6]='AI';
country_code[7]='XX';
country_code[8]='AG';
country_code[9]='AR';
country_code[10]='AM';
country_code[11]='AW';
country_code[12]='AU';
country_code[13]='AT';
country_code[14]='AZ';
country_code[15]='BS';
country_code[16]='BH';
country_code[17]='BD';
country_code[18]='BB';
country_code[19]='BY';
country_code[20]='BE';
country_code[21]='BZ';
country_code[22]='BJ';
country_code[23]='BM';
country_code[24]='BT';
country_code[25]='BO';
country_code[26]='BA';
country_code[27]='BW';
country_code[28]='BV';
country_code[29]='BR';
country_code[30]='IO';
country_code[31]='VG';
country_code[32]='BN';
country_code[33]='BF';
country_code[34]='BI';
country_code[35]='KH';
country_code[36]='CM';
country_code[37]='CA';
country_code[38]='CV';
country_code[39]='KY';
country_code[40]='CF';
country_code[41]='TD';
country_code[42]='CL';
country_code[43]='CN';
country_code[44]='CX';
country_code[45]='CC';
country_code[46]='CO';
country_code[47]='KM';
country_code[48]='CG';
country_code[49]='CK';
country_code[50]='CR';
country_code[51]='HR';
country_code[52]='CU';
country_code[53]='CY';
country_code[54]='CZ';
country_code[55]='CI';
country_code[56]='DK';
country_code[57]='DJ';
country_code[58]='DM';
country_code[59]='DO';
country_code[60]='EC';
country_code[61]='EG';
country_code[62]='SV';
country_code[63]='GQ';
country_code[64]='ER';
country_code[65]='EE';
country_code[66]='ET';
country_code[67]='FK';
country_code[68]='FO';
country_code[69]='FJ';
country_code[70]='FI';
country_code[71]='FR';
country_code[72]='GF';
country_code[73]='PF';
country_code[74]='TF';
country_code[75]='GA';
country_code[76]='GM';
country_code[77]='GE';
country_code[78]='DE';
country_code[79]='GH';
country_code[80]='GI';
country_code[81]='GR';
country_code[82]='GL';
country_code[83]='GD';
country_code[84]='GP';
country_code[85]='GU';
country_code[86]='GT';
country_code[87]='GN';
country_code[88]='GW';
country_code[89]='GY';
country_code[90]='HT';
country_code[91]='HM';
country_code[92]='HN';
country_code[93]='HK';
country_code[94]='HU';
country_code[95]='IS';
country_code[96]='IN';
country_code[97]='ID';
country_code[98]='IR';
country_code[99]='IQ';
country_code[100]='IE';
country_code[101]='IL';
country_code[102]='IT';
country_code[103]='JM';
country_code[104]='JP';
country_code[105]='JO';
country_code[106]='KZ';
country_code[107]='KE';
country_code[108]='KI';
country_code[109]='KW';
country_code[110]='KG';
country_code[111]='LA';
country_code[112]='LV';
country_code[113]='LB';
country_code[114]='LS';
country_code[115]='LR';
country_code[116]='LY';
country_code[117]='LI';
country_code[118]='LT';
country_code[119]='LU';
country_code[120]='MO';
country_code[121]='MK';
country_code[122]='MG';
country_code[123]='MW';
country_code[124]='MY';
country_code[125]='MV';
country_code[126]='ML';
country_code[127]='MT';
country_code[128]='MH';
country_code[129]='MQ';
country_code[130]='MR';
country_code[131]='MU';
country_code[132]='YT';
country_code[133]='MX';
country_code[134]='FM';
country_code[135]='MD';
country_code[136]='MC';
country_code[137]='MN';
country_code[138]='ME';
country_code[139]='MS';
country_code[140]='MA';
country_code[141]='MZ';
country_code[142]='MM';
country_code[143]='NA';
country_code[144]='NR';
country_code[145]='NP';
country_code[146]='NL';
country_code[147]='AN';
country_code[148]='NC';
country_code[149]='NZ';
country_code[150]='NI';
country_code[151]='NE';
country_code[152]='NG';
country_code[153]='XX';
country_code[154]='NF';
country_code[155]='KP';
country_code[156]='MP';
country_code[157]='NO';
country_code[158]='OM';
country_code[159]='PK';
country_code[160]='PW';
country_code[161]='XX';
country_code[162]='PA';
country_code[163]='PG';
country_code[164]='PY';
country_code[165]='PE';
country_code[166]='PH';
country_code[167]='PN';
country_code[168]='PL';
country_code[169]='PT';
country_code[170]='PR';
country_code[171]='QA';
country_code[172]='RE';
country_code[173]='RO';
country_code[174]='RU';
country_code[175]='RW';
country_code[176]='SH';
country_code[177]='KN';
country_code[178]='LC';
country_code[179]='PM';
country_code[180]='VC';
country_code[181]='WS';
country_code[182]='SM';
country_code[183]='ST';
country_code[184]='SA';
country_code[185]='SN';
country_code[186]='RS';
country_code[187]='XX';
country_code[188]='SC';
country_code[189]='SL';
country_code[190]='SG';
country_code[191]='SK';
country_code[192]='SI';
country_code[193]='SB';
country_code[194]='SO';
country_code[195]='ZA';
country_code[196]='GS';
country_code[197]='KR';
country_code[198]='ES';
country_code[199]='LK';
country_code[200]='SD';
country_code[201]='SR';
country_code[202]='XX';
country_code[203]='SZ';
country_code[204]='SE';
country_code[205]='CH';
country_code[206]='SY';
country_code[207]='TW';
country_code[208]='TJ';
country_code[209]='TZ';
country_code[210]='TH';
country_code[211]='CD';
country_code[212]='TL';
country_code[213]='TG';
country_code[214]='TK';
country_code[215]='TO';
country_code[216]='TT';
country_code[217]='TN';
country_code[218]='TR';
country_code[219]='TM';
country_code[220]='TC';
country_code[221]='TV';
country_code[222]='XX';
country_code[223]='UG';
country_code[224]='UA';
country_code[225]='AE';
country_code[226]='GB';
country_code[227]='US';
country_code[228]='XX';
country_code[229]='UY';
country_code[230]='UZ';
country_code[231]='VU';
country_code[232]='VA';
country_code[233]='VE';
country_code[234]='VN';
country_code[235]='WF';
country_code[236]='EH';
country_code[237]='YE';
country_code[238]='ZM';
country_code[239]='ZW';
country_code[240]='XX';
country_code[241]='BG';



var country_lat = new Array();
country_lat[0] = 33.93911;
country_lat[1] = 41.15333;
country_lat[2] = 28.03389;
country_lat[3] = -14.27097;
country_lat[4] = 42.54624;
country_lat[5] = -11.20269;
country_lat[6] = 18.22055;
country_lat[7] = -75.25097;
country_lat[8] = 17.06082;
country_lat[9] = -38.41610;
country_lat[10] = 40.06910;
country_lat[11] = 12.52111;
country_lat[12] = -25.27440;
country_lat[13] = 47.51623;
country_lat[14] = 40.14310;
country_lat[15] = 25.03428;
country_lat[16] = 26.07652;
country_lat[17] = 23.68499;
country_lat[18] = 13.19389;
country_lat[19] = 53.70981;
country_lat[20] = 50.50389;
country_lat[21] = 17.18988;
country_lat[22] = 9.30769;
country_lat[23] = 32.32138;
country_lat[24] = 27.51416;
country_lat[25] = -16.29015;
country_lat[26] = 43.91589;
country_lat[27] = -22.32847;
country_lat[28] = -54.42320;
country_lat[29] = -14.23500;
country_lat[30] = -6.34319;
country_lat[31] = 18.42069;
country_lat[32] = 4.53528;
country_lat[33] = 12.23833;
country_lat[34] = -3.37306;
country_lat[35] = 12.56568;
country_lat[36] = 7.36972;
country_lat[37] = 56.13037;
country_lat[38] = 16.00208;
country_lat[39] = 19.51347;
country_lat[40] = 6.61111;
country_lat[41] = 15.45417;
country_lat[42] = -35.67515;
country_lat[43] = 35.86166;
country_lat[44] = -10.44753;
country_lat[45] = -12.16898;
country_lat[46] = 4.57087;
country_lat[47] = -11.87500;
country_lat[48] = -0.22802;
country_lat[49] = -21.23674;
country_lat[50] = 9.74892;
country_lat[51] = 45.80583;
country_lat[52] = 21.52176;
country_lat[53] = 35.12641;
country_lat[54] = 49.81749;
country_lat[55] = 7.53999;
country_lat[56] = 56.26392;
country_lat[57] = 11.82514;
country_lat[58] = 15.41500;
country_lat[59] = 18.73569;
country_lat[60] = -1.83124;
country_lat[61] = 26.82055;
country_lat[62] = 13.79419;
country_lat[63] = 1.65080;
country_lat[64] = 15.17938;
country_lat[65] = 58.59527;
country_lat[66] = 9.14500;
country_lat[67] = -51.79625;
country_lat[68] = 61.89263;
country_lat[69] = -16.57819;
country_lat[70] = 61.92411;
country_lat[71] = 46.22764;
country_lat[72] = 3.93389;
country_lat[73] = -17.67974;
country_lat[74] = -49.44996;
country_lat[75] = -0.80369;
country_lat[76] = 13.44318;
country_lat[77] = 41.70573;
country_lat[78] = 51.16569;
country_lat[79] = 7.94653;
country_lat[80] = 36.13774;
country_lat[81] = 39.07421;
country_lat[82] = 71.70694;
country_lat[83] = 12.26278;
country_lat[84] = 16.99597;
country_lat[85] = 13.44430;
country_lat[86] = 15.78347;
country_lat[87] = 9.94559;
country_lat[88] = 11.80375;
country_lat[89] = 4.86042;
country_lat[90] = 18.97119;
country_lat[91] = -53.08181;
country_lat[92] = 15.20000;
country_lat[93] = 22.39643;
country_lat[94] = 47.16249;
country_lat[95] = 64.96305;
country_lat[96] = 20.59368;
country_lat[97] = -0.78927;
country_lat[98] = 32.42791;
country_lat[99] = 33.22319;
country_lat[100] = 53.41291;
country_lat[101] = 31.04605;
country_lat[102] = 41.87194;
country_lat[103] = 18.10958;
country_lat[104] = 36.20482;
country_lat[105] = 30.58516;
country_lat[106] = 48.01957;
country_lat[107] = -0.02356;
country_lat[108] = -3.37042;
country_lat[109] = 29.31166;
country_lat[110] = 41.20438;
country_lat[111] = 19.85627;
country_lat[112] = 56.87964;
country_lat[113] = 34.01624;
country_lat[114] = -29.60999;
country_lat[115] = 6.42805;
country_lat[116] = 26.33510;
country_lat[117] = 47.16600;
country_lat[118] = 55.16944;
country_lat[119] = 49.81527;
country_lat[120] = 22.19874;
country_lat[121] = 41.60863;
country_lat[122] = -18.76695;
country_lat[123] = -13.25431;
country_lat[124] = 4.21048;
country_lat[125] = 3.20278;
country_lat[126] = 17.57069;
country_lat[127] = 35.93750;
country_lat[128] = 7.13147;
country_lat[129] = 14.64153;
country_lat[130] = 21.00789;
country_lat[131] = -20.34840;
country_lat[132] = -12.82750;
country_lat[133] = 23.63450;
country_lat[134] = 7.42555;
country_lat[135] = 47.41163;
country_lat[136] = 43.75030;
country_lat[137] = 46.86250;
country_lat[138] = 42.70868;
country_lat[139] = 16.74250;
country_lat[140] = 31.79170;
country_lat[141] = -18.66569;
country_lat[142] = 21.91397;
country_lat[143] = -22.95764;
country_lat[144] = -0.52278;
country_lat[145] = 28.39486;
country_lat[146] = 52.13263;
country_lat[147] = 12.22608;
country_lat[148] = -20.90431;
country_lat[149] = -40.90056;
country_lat[150] = 12.86542;
country_lat[151] = 17.60779;
country_lat[152] = 8.67528;
country_lat[153] = -169.86723;
country_lat[154] = -29.04084;
country_lat[155] = 40.33985;
country_lat[156] = 17.33083;
country_lat[157] = 60.47202;
country_lat[158] = 21.51258;
country_lat[159] = 30.37532;
country_lat[160] = 6.51083;
country_lat[161] = 31.75763;
country_lat[162] = 8.53798;
country_lat[163] = -6.31499;
country_lat[164] = -23.44250;
country_lat[165] = -9.18997;
country_lat[166] = 12.87972;
country_lat[167] = -24.70361;
country_lat[168] = 51.91944;
country_lat[169] = 39.39987;
country_lat[170] = 18.22083;
country_lat[171] = 25.35483;
country_lat[172] = -21.11514;
country_lat[173] = 45.94316;
country_lat[174] = 57.27904;
country_lat[175] = -1.94028;
country_lat[176] = -10.03070;
country_lat[177] = 17.35782;
country_lat[178] = 13.90944;
country_lat[179] = 46.94194;
country_lat[180] = 12.98431;
country_lat[181] = -13.75903;
country_lat[182] = 43.94236;
country_lat[183] = 0.18636;
country_lat[184] = 23.88594;
country_lat[185] = 14.49740;
country_lat[186] = 44.01652;
country_lat[187] = -1.28683;
country_lat[188] = -4.67957;
country_lat[189] = 8.46055;
country_lat[190] = 1.35208;
country_lat[191] = 48.66903;
country_lat[192] = 46.15124;
country_lat[193] = -9.64571;
country_lat[194] = 5.15215;
country_lat[195] = -30.55948;
country_lat[196] = -54.42958;
country_lat[197] = 35.90776;
country_lat[198] = 40.46367;
country_lat[199] = 7.87305;
country_lat[200] = 12.86281;
country_lat[201] = 3.91931;
country_lat[202] = 0;
country_lat[203] = -26.52250;
country_lat[204] = 60.12816;
country_lat[205] = 46.81819;
country_lat[206] = 34.80208;
country_lat[207] = 23.69781;
country_lat[208] = 38.86103;
country_lat[209] = -6.36903;
country_lat[210] = 15.87003;
country_lat[211] = -2.85526;
country_lat[212] = -8.87422;
country_lat[213] = 8.61954;
country_lat[214] = -8.96736;
country_lat[215] = -21.17899;
country_lat[216] = 10.69180;
country_lat[217] = 33.88692;
country_lat[218] = 38.96375;
country_lat[219] = 38.96972;
country_lat[220] = 21.69402;
country_lat[221] = -7.10954;
country_lat[222] = 18.33576;
country_lat[223] = 1.37333;
country_lat[224] = 48.37943;
country_lat[225] = 23.42408;
country_lat[226] = 55.37805;
country_lat[227] = 37.09024;
country_lat[228] = 0;
country_lat[229] = -32.52278;
country_lat[230] = 41.37749;
country_lat[231] = -15.37671;
country_lat[232] = 41.90292;
country_lat[233] = 6.42375;
country_lat[234] = 14.05832;
country_lat[235] = -13.76875;
country_lat[236] = 24.21553;
country_lat[237] = 15.55273;
country_lat[238] = -13.13390;
country_lat[239] = -19.01544;
country_lat[240] = 60.17700;
country_lat[241] = 42.73388;


var country_lng = new Array();
country_lng[0] = 67.70995;
country_lng[1] = 20.16833;
country_lng[2] = 1.65963;
country_lng[3] = -170.13222;
country_lng[4] = 1.60155;
country_lng[5] = 17.87389;
country_lng[6] = -63.06862;
country_lng[7] = -0.07139;
country_lng[8] = -61.79643;
country_lng[9] = -63.61667;
country_lng[10] = 45.03819;
country_lng[11] = -69.96834;
country_lng[12] = 133.77514;
country_lng[13] = 14.55007;
country_lng[14] = 47.57693;
country_lng[15] = -77.39628;
country_lng[16] = 50.53711;
country_lng[17] = 90.35633;
country_lng[18] = -59.54320;
country_lng[19] = 27.95339;
country_lng[20] = 4.46994;
country_lng[21] = -88.49765;
country_lng[22] = 2.31583;
country_lng[23] = -64.75737;
country_lng[24] = 90.43360;
country_lng[25] = -63.58865;
country_lng[26] = 17.67908;
country_lng[27] = 24.68487;
country_lng[28] = 3.41319;
country_lng[29] = -51.92528;
country_lng[30] = 71.87652;
country_lng[31] = -64.63997;
country_lng[32] = 114.72767;
country_lng[33] = -1.56159;
country_lng[34] = 29.91889;
country_lng[35] = 104.99096;
country_lng[36] = 12.35472;
country_lng[37] = -106.34677;
country_lng[38] = -24.01320;
country_lng[39] = -80.56696;
country_lng[40] = 20.93944;
country_lng[41] = 18.73221;
country_lng[42] = -71.54297;
country_lng[43] = 104.19540;
country_lng[44] = 105.69045;
country_lng[45] = 96.83108;
country_lng[46] = -74.29733;
country_lng[47] = 43.87222;
country_lng[48] = 15.82766;
country_lng[49] = -159.77767;
country_lng[50] = -83.75343;
country_lng[51] = 15.98511;
country_lng[52] = -77.78117;
country_lng[53] = 33.42986;
country_lng[54] = 15.47296;
country_lng[55] = -5.54708;
country_lng[56] = 9.50178;
country_lng[57] = 42.59027;
country_lng[58] = -61.37098;
country_lng[59] = -70.16265;
country_lng[60] = -78.18341;
country_lng[61] = 30.80250;
country_lng[62] = -88.89653;
country_lng[63] = 10.26789;
country_lng[64] = 39.78233;
country_lng[65] = 25.01361;
country_lng[66] = 40.48967;
country_lng[67] = -59.52361;
country_lng[68] = -6.91181;
country_lng[69] = 179.41441;
country_lng[70] = 25.74815;
country_lng[71] = 2.21375;
country_lng[72] = -53.12578;
country_lng[73] = -149.40684;
country_lng[74] = 70.02498;
country_lng[75] = 11.60944;
country_lng[76] = -15.31014;
country_lng[77] = 44.76929;
country_lng[78] = 10.45153;
country_lng[79] = -1.02319;
country_lng[80] = -5.34537;
country_lng[81] = 21.82431;
country_lng[82] = -42.60430;
country_lng[83] = -61.60417;
country_lng[84] = -62.06764;
country_lng[85] = 144.79373;
country_lng[86] = -90.23076;
country_lng[87] = -9.69665;
country_lng[88] = -15.18041;
country_lng[89] = -58.93018;
country_lng[90] = -72.28521;
country_lng[91] = 73.50416;
country_lng[92] = -86.24191;
country_lng[93] = 114.10950;
country_lng[94] = 19.50330;
country_lng[95] = -19.02084;
country_lng[96] = 78.96288;
country_lng[97] = 113.92133;
country_lng[98] = 53.68805;
country_lng[99] = 43.67929;
country_lng[100] = -8.24389;
country_lng[101] = 34.85161;
country_lng[102] = 12.56738;
country_lng[103] = -77.29751;
country_lng[104] = 138.25292;
country_lng[105] = 36.23841;
country_lng[106] = 66.92368;
country_lng[107] = 37.90619;
country_lng[108] = -168.73404;
country_lng[109] = 47.48177;
country_lng[110] = 74.76610;
country_lng[111] = 102.49550;
country_lng[112] = 24.60319;
country_lng[113] = 35.90332;
country_lng[114] = 28.23361;
country_lng[115] = -9.42950;
country_lng[116] = 17.22833;
country_lng[117] = 9.55537;
country_lng[118] = 23.88127;
country_lng[119] = 6.12958;
country_lng[120] = 113.54387;
country_lng[121] = 21.74527;
country_lng[122] = 46.86911;
country_lng[123] = 34.30152;
country_lng[124] = 101.97577;
country_lng[125] = 73.22068;
country_lng[126] = -3.99617;
country_lng[127] = 14.37542;
country_lng[128] = 171.18448;
country_lng[129] = -61.02417;
country_lng[130] = -10.94083;
country_lng[131] = 57.55215;
country_lng[132] = 45.16624;
country_lng[133] = -102.55278;
country_lng[134] = 150.55081;
country_lng[135] = 28.36989;
country_lng[136] = 7.41284;
country_lng[137] = 103.84666;
country_lng[138] = 19.37439;
country_lng[139] = -62.18737;
country_lng[140] = -7.09262;
country_lng[141] = 35.52956;
country_lng[142] = 95.95622;
country_lng[143] = 18.49041;
country_lng[144] = 166.93150;
country_lng[145] = 84.12401;
country_lng[146] = 5.29127;
country_lng[147] = -69.06009;
country_lng[148] = 165.61804;
country_lng[149] = 174.88597;
country_lng[150] = -85.20723;
country_lng[151] = 8.08167;
country_lng[152] = 9.08200;
country_lng[153] = -19.05445;
country_lng[154] = 167.95471;
country_lng[155] = 127.51009;
country_lng[156] = 145.38469;
country_lng[157] = 8.46895;
country_lng[158] = 55.92325;
country_lng[159] = 69.34512;
country_lng[160] = 133.43359;
country_lng[161] = -95.64786;
country_lng[162] = -80.78213;
country_lng[163] = 143.95555;
country_lng[164] = -58.44383;
country_lng[165] = -75.01515;
country_lng[166] = 121.77402;
country_lng[167] = -127.43931;
country_lng[168] = 19.14514;
country_lng[169] = -8.22445;
country_lng[170] = -66.59015;
country_lng[171] = 51.18388;
country_lng[172] = 55.53638;
country_lng[173] = 24.96676;
country_lng[174] = 44.38477;
country_lng[175] = 29.87389;
country_lng[176] = -24.14347;
country_lng[177] = -62.78300;
country_lng[178] = -60.97889;
country_lng[179] = -56.27111;
country_lng[180] = -61.28723;
country_lng[181] = -172.10463;
country_lng[182] = 12.45778;
country_lng[183] = 6.61308;
country_lng[184] = 45.07916;
country_lng[185] = -14.45236;
country_lng[186] = 21.00586;
country_lng[187] = 36.80674;
country_lng[188] = 55.49198;
country_lng[189] = -11.77989;
country_lng[190] = 103.81984;
country_lng[191] = 19.69902;
country_lng[192] = 14.99546;
country_lng[193] = 160.15619;
country_lng[194] = 46.19962;
country_lng[195] = 22.93751;
country_lng[196] = -36.58791;
country_lng[197] = 127.76692;
country_lng[198] = -3.74922;
country_lng[199] = 80.77180;
country_lng[200] = 30.21764;
country_lng[201] = -56.02778;
country_lng[202] = 0;
country_lng[203] = 31.46587;
country_lng[204] = 18.64350;
country_lng[205] = 8.22751;
country_lng[206] = 38.99681;
country_lng[207] = 120.96052;
country_lng[208] = 71.27609;
country_lng[209] = 34.88882;
country_lng[210] = 100.99254;
country_lng[211] = 24.56543;
country_lng[212] = 125.72754;
country_lng[213] = 0.82478;
country_lng[214] = -171.85588;
country_lng[215] = -175.19824;
country_lng[216] = -61.22250;
country_lng[217] = 9.53750;
country_lng[218] = 35.24332;
country_lng[219] = 59.55628;
country_lng[220] = -71.79793;
country_lng[221] = 177.64933;
country_lng[222] = -64.89633;
country_lng[223] = 32.29028;
country_lng[224] = 31.16558;
country_lng[225] = 53.84782;
country_lng[226] = -3.43597;
country_lng[227] = -95.71289;
country_lng[228] = 0;
country_lng[229] = -55.76584;
country_lng[230] = 64.58526;
country_lng[231] = 166.95916;
country_lng[232] = 12.45339;
country_lng[233] = -66.58973;
country_lng[234] = 108.27720;
country_lng[235] = -177.15610;
country_lng[236] = -12.88583;
country_lng[237] = 48.51639;
country_lng[238] = 27.84933;
country_lng[239] = 29.15486;
country_lng[240] = 19.91500;
country_lng[241] = 25.48583;


function getCountryDisplayEn(countryCode){
for(var i = 0; i < country_code.length; i++){
        if(country_code[i] == countryCode){
            return country[i];
        }
    }

return country[4];
}

function getCountryLat(countryCode){
    var index = 0;
    for(var i = 0; i < country.length; i++){
        if(country_code[i] == countryCode){
            index = i;
        }
    }
    return country_lat[index];
}

function getCountryLng(countryCode){
    var index = 0;
    for(var i = 0; i < country.length; i++){
        if(country_code[i] == countryCode){
            index = i;
        }
    }
    return country_lng[index];
}

var country_zoom = new Array();

country_zoom[4]=8;
country_zoom[6]=9;
country_zoom[8]=9;
country_zoom[11]=10;
country_zoom[12]=4;
country_zoom[13]=7;
country_zoom[14]=7;
country_zoom[15]=7;
country_zoom[16]=9;
country_zoom[17]=7;
country_zoom[18]=9;
country_zoom[29]=4;
country_zoom[37]=4;
country_zoom[43]=4;
country_zoom[53]=8;
country_zoom[79]=6;
country_zoom[80]=11;
country_zoom[82]=3;
country_zoom[117]=10;
country_zoom[119]=9;
country_zoom[127]=10;
country_zoom[174]=4;
country_zoom[182]=12;
country_zoom[186]=7;
country_zoom[227]=4;


function getCountryZoomLevel(countryCode){
    for(var i = 0; i < country.length; i++){
        if(country_code[i] == countryCode && country_zoom[i]){
            return country_zoom[i];
        }
    }
    return 5;
}

function manageStatesAndProvinces(country,action,form){
        if(country=='US' || country=='CA'){
            apost(action,'countries',form,'size','600,260','actionForm','manageCountries','keepWizardOpened','yes');
        }else{
            document.getElementById('states_combo').innerHTML='';
        }
    }
