var aMobileSettings = new Array;
	aMobileSettings[0] = Array('14', '61', '10', '10', '04', '0', 'Australia');
	aMobileSettings[1] = Array('157', '64', '9', '11', '02', '0', 'New Zealand');
	aMobileSettings[2] = Array('229', '44', '11', '11', '07', '0', 'United Kingdom');
	aMobileSettings[3] = Array('230', '1', '10', '10', '', '', 'United States');
	aMobileSettings[4] = Array('39', '1', '10', '10', '', '', 'Canada');
	aMobileSettings[5] = Array('105', '353', '10', '10', '08', '0', 'Ireland');
	aMobileSettings[6] = Array('196', '65', '8', '8', '', '', 'Singapore');
	aMobileSettings[7] = Array('81', '49', '11', '12', '01', '0', 'Germany');
	aMobileSettings[8] = Array('74', '33', '10', '10', '06', '0', 'France');
	aMobileSettings[9] = Array('108', '39', '9', '9', '3', '', 'Italy');
	aMobileSettings[10] = Array('154', '31', '10', '10', '06', '0', 'Netherlands');
	aMobileSettings[11] = Array('203', '34', '9', '9', '6', '', 'Spain');
	aMobileSettings[12] = Array('181', '7', '10', '10', '', '8', 'Russian Federation');




		//' validate mobile number - INTERNATIONAL OR LOCAL - according to supplied rules for the country
		function isMobileNumber(theNumber, minLength, maxLength, theCountryCode, thePrefix, theTrunkDigit) {

			var pfLen = thePrefix.length; //' length of prefix	
			var re_lenStr = ""; //' regex test for length
			var re_trunkStr = ""; //' regex test for trunk-dialing or international codes
			var re_preStr = ""; //' regex test for prefix (sans trunk-dialing code)
			var trunkLen = theTrunkDigit.length; //' length of trunk-dialing code (dropped from prefix)
			
			// replace spaces in number for check
			var rExpSpace = / /gi; // global search for any space char
			theNumber = theNumber.replace(rExpSpace,"");
			var rExpBrackets = /\(|\)/gi;
			theNumber = theNumber.replace(rExpBrackets,"");
			
			if(theNumber.substring(0, 1)=="+"){ theNumber = theNumber.substring(1, theNumber.length); }

		//'	regex international or trunk-dialing prefix
			if( theTrunkDigit=="" ){ re_trunkStr = "("+ theCountryCode +"){0,1}" } //' NANP numbers don't have a "0" before local dialing
			else{ re_trunkStr = "(("+ theTrunkDigit +")|("+ theCountryCode +")){1}"; }

		//'	regex required prefix regex string (not for 
			if(thePrefix!=""){ //' the NANP has no set prefixes - uses local area codes
				if( theTrunkDigit=="" ){ re_preStr = "("+ thePrefix +"){1}" }
				else{ re_preStr = "("+ thePrefix.substring(theTrunkDigit.length, thePrefix.length) +"){1}" }
			}

		//'	regex length strings - may be min to max or single digit(min)	
			if( minLength!=maxLength && !isNaN(maxLength) ){ re_lenStr = (minLength - thePrefix) +","+ (maxLength - thePrefix); }
			else{ re_lenStr = (minLength - thePrefix.length); }
			
		//'	regex test using compiled string
			var reStr = "^"+ re_trunkStr + re_preStr +"[0-9]{"+ re_lenStr  +"}$"
			var re = new RegExp(reStr);
			return re.test(theNumber);	
			
		}

	//'	validate ANY international
		function isInternational(sNumber){
		//'	determine prefix
			var rtn_var = false;
			var countryCode; var minLen; var maxLen;
			var phonePrefix; var phoneTrunkDigit;	
		
		//'	remove plus
			if(sNumber.substring(0, 1)=="+"){ sNumber = sNumber.substring(1, sNumber.length); }
					
			for(var x=0; x<aMobileSettings.length; x++){
				countryCode = aMobileSettings[x][1] 	
				if(sNumber.substring(0, countryCode.length) == countryCode){ //' validate for the country found
					minLen = aMobileSettings[x][2]; //' minimum required length
					maxLen = aMobileSettings[x][3]; //' maximum required length
					phonePrefix = aMobileSettings[x][4]; //' required prefix for validation (eg "04")
					phoneTrunkDigit =  aMobileSettings[x][5]
					rtn_var = isMobileNumber(sNumber, minLen, maxLen, countryCode, phonePrefix, phoneTrunkDigit);
				}
			}	
			return rtn_var;	
		}

		//' Validate Mobile From any country
		function valid_mobile(sNumber, iCountry) {
			
		//'	set variables
			var isValidMobile = false; //' default to no
			var countryID = null;
			if(document.getElementById(iCountry).value=="null") {
				if(document.getElementById("merchantCountryID") != null)
				{
					countryID = parseInt(document.getElementById("merchantCountryID").value);
				}
			} else {
				countryID = parseInt(document.getElementById(iCountry).value); //' selected country ID
			}
			var pNumber = document.getElementById(sNumber).value; //' entered mobile phone number

			var country; //' country name
			var countryCode; //' intrenational dialing code
			var minLen = "10"; //' minimum length of complete (local) number
			var maxLen = ""; //' maximum length of complete (local) number
			var phonePrefix = "04"; //' standard mobile prefix for country/region
			var phoneTrunkDigit = "0"; //' trunk-dialing code (removed from required prefix for international dialing)
			
		//'	get country details from array	
			if(!isNaN(countryID)){	
				get_set: //' get the settings
				for(var x=0; x<aMobileSettings.length; x++){
					if(aMobileSettings[x][0] == countryID){ //' this country
						country = aMobileSettings[x][6]; //' string
						minLen = aMobileSettings[x][2]; //' minimum required length
						maxLen = aMobileSettings[x][3]; //' maximum required length
						phonePrefix = aMobileSettings[x][4]; //' required prefix for validation (eg "04")
						phoneTrunkDigit =  aMobileSettings[x][5]; //' remove any leading-digit for international calls (eg "0")
						countryCode = aMobileSettings[x][1] //' the international dialing code (eg "61")
						break get_set; //' end loop
					}
				}	
			//' validate according to the rules in database (from array)
				isValidMobile = isMobileNumber(pNumber, minLen, maxLen, countryCode, phonePrefix, phoneTrunkDigit);
			}
		
			if(isValidMobile || isInternational(pNumber)){
				return true
			}else{ 
				if(country == undefined) alert( pNumber + ' is not a valid mobile phone number for the selected country, and is not a recognised international number.'); 
				else alert( pNumber + ' is not a valid mobile phone number for '+ country +'.'); 
				document.getElementById(sNumber).focus();
				return false;	
			}
		}
		
		//' Validate Mobile From any country
		function valid_mobile_quiet(sNumber, iCountry) {
			
		//'	set variables
			var isValidMobile = false; //' default to no
			var countryID = null;
			if(document.getElementById(iCountry).value=="null") {
				if(document.getElementById("merchantCountryID") != null)
				{
					countryID = parseInt(document.getElementById("merchantCountryID").value);
				}
			} else {
				countryID = parseInt(document.getElementById(iCountry).value); //' selected country ID
			}
			var pNumber = document.getElementById(sNumber).value; //' entered mobile phone number

			var country; //' country name
			var countryCode; //' intrenational dialing code
			var minLen = "10"; //' minimum length of complete (local) number
			var maxLen = ""; //' maximum length of complete (local) number
			var phonePrefix = "04"; //' standard mobile prefix for country/region
			var phoneTrunkDigit = "0"; //' trunk-dialing code (removed from required prefix for international dialing)
			
		//'	get country details from array	
			if(!isNaN(countryID)){	
				get_set: //' get the settings
				for(var x=0; x<aMobileSettings.length; x++){
					if(aMobileSettings[x][0] == countryID){ //' this country
						country = aMobileSettings[x][6]; //' string
						minLen = aMobileSettings[x][2]; //' minimum required length
						maxLen = aMobileSettings[x][3]; //' maximum required length
						phonePrefix = aMobileSettings[x][4]; //' required prefix for validation (eg "04")
						phoneTrunkDigit =  aMobileSettings[x][5]; //' remove any leading-digit for international calls (eg "0")
						countryCode = aMobileSettings[x][1] //' the international dialing code (eg "61")
						break get_set; //' end loop
					}
				}	
			//' validate according to the rules in database (from array)
				isValidMobile = isMobileNumber(pNumber, minLen, maxLen, countryCode, phonePrefix, phoneTrunkDigit);
			}
		
			if(isValidMobile || isInternational(pNumber))
			{
				return true;
			}
			else
			{ 
				return false;	
			}
		}