function textCounter(field, countfield, maxlimit) 
{
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

function setAreaAndCountry() {
	var area = document.getElementById("area");
	s = area.value;
	var countryCode = document.getElementById("countryCode");

	if(s == "CUR") {
		countryCode.value='+5999';
	} else if(s == "BON") {
		countryCode.value='+5997';
	} else if(s == "SUR") {
		countryCode.value='+597';
	} else if(s == "SEU") {
		countryCode.value='+5993';
	} else if(s == "SAB") {
		countryCode.value='+5994';
	} else if(s == "DSM") {
		countryCode.value='+5995';
	} else if(s == "FSM") {
		countryCode.value='+590690';
//	} else if(s == "SBA") {
//		countryCode.value='+590690';
	} else{ // if(s == "SKI")
		countryCode.value='+1869';
	}

}
 
function checkNumbers()
{

var mobile_number = document.sendhepa.phonenumber;

var island_code = document.sendhepa.area.value;

if(island_code == "CUR") {

	var countDigits = /^\d{7}$/;

	var checkFirstDigits = /^51|^52|^540|^56|^530|^531/;

	var island_name = 'Curacao';
	
} else if(island_code == "BON") {

	var countDigits = /^\d{6}$/;

	var checkFirstDigits = /^95|^96/;

	var island_name = 'Bonaire';
	
} else if(island_code == "SUR") {

	var countDigits = /^\d{7}$/;

	var checkFirstDigits = /^83|^84/;

	var island_name = 'Suriname';
	
} else if(island_code == "SEU") {

	var countDigits = /^\d{6}$/;

	var checkFirstDigits = /^181|^184|^185/;

	var island_name = 'St. Eustatius';
	
} else if(island_code == "SAB") {

	var countDigits = /^\d{6}$/;

	var checkFirstDigits = /^165|^166|^167/;

	var island_name = 'Saba';
	
} else if(island_code == "DSM") {

	var countDigits = /^\d{6}$/;

	var checkFirstDigits = /^86|^53|^54|^80|^81|^87|^88/;

	var island_name = 'Dutch St. Maarten'; 
	
} else if(island_code == "FSM") {

	var countDigits = /^\d{6}$/;

	var checkFirstDigits = /^87|^10/;

	var island_name = 'French St. Maarten'; 

} else if(island_code == "SBA") {

	var countDigits = /^\d{6}$/;

	var checkFirstDigits = /^10/;

	var island_name = 'St. Baths';
	
} else { // island_code == "SKI"

	var countDigits = /^\d{7}$/;

	var checkFirstDigits = /^556|^557|^558/;

	var island_name = 'St. Kitts Nevis';	
}

if (!countDigits.test(mobile_number.value) || !checkFirstDigits.test(mobile_number.value)){

	alert('That is not a valid number\nfor ' + island_name);
	mobile_number.className='error';
	mobile_number.focus();
	return false;
	
}else{

	mobile_number.className='';

}
return true;
}
