
function fIsTelephoneValidChars(strCheck,strTypePhone,strAdditionalChars) {
	var strChar = "";
	if (typeof(strAdditionalChars) != 'undefined') {
		var strValid = "0123456789" + strAdditionalChars;
	} else {
		var strValid = "0123456789";
	}
	
	//checks if there are any characters in 'strCheck', that are not in 'strValid'	
	for (var intCount = 0; intCount < strCheck.length; intCount++) {
		strChar = strCheck.charAt(intCount);
		if (strValid.indexOf(strChar) == -1){
			alert("Invalid characters. Allowed characters: 0-9 and no spaces");
			return false;
		}
	}
	
	//checks if number is not too short
	if(strCheck.length < 10){
		alert("Please enter the full " + strTypePhone + " Number");
		return false;
	}

	//checks if number starts with zero
	if(strCheck.charAt(0) != "0"){
		alert("Please start the " + strTypePhone + " Number with the correct dialing code");
		return false;
	}

	return true;
}
		// =============================================================== //

function fIsCountryCodeValidChars(strCheck,strTypePhone,strDefaultCountryCode) {
	var strChar = "";
	var strValid = "0123456789+";

	//checks if there are any characters in 'strCheck', that are not in 'strValid'	
	for (var intCount = 0; intCount < strCheck.length; intCount++) {
		strChar = strCheck.charAt(intCount);
		if (strValid.indexOf(strChar) == -1){
			alert("Invalid characters. Allowed characters: +, 0-9 and no spaces");
			return false;
		}
	}

	//checks if CCode is not empty
	if(strCheck == "") {
		alert("Please enter the Country Calling Code for the " + strTypePhone + " Number or use the default of" + strDefaultCountryCode);
		return false;
	}

	//checks that the CCode starts with a +
	if(strCheck.charAt(0) != "+"){
		alert("Please start the Country Calling Code for " + strTypePhone + " Number with a '+' sign, for example " + strDefaultCountryCode);
		return false;
	}

	//checks if the CCode is not longer thatn 5 chars
	if(strCheck.length > 5){
		alert("The " + strTypePhone + " Number Country Code should not be more than 5 characters");
		return false;
	}
		
	//checks if CCode differs from the default CCode and confirms the change
	if(strCheck != strDefaultCountryCode) {
		if(confirm("Are you sure you want to change the " + strTypePhone + " Number Country Calling Code?")){
			return true ;
		}else{
			return false ;
		}
	}

	return true;
}
		
		// =============================================================== //

