 function matchRegularExpression(valeur, regularExpression)
{
	var resultat = valeur.match(regularExpression);
	if(resultat!=null && resultat.length==1) 
		return true;
	else 
		return false;
}
 
 function isNum(n)
 {
 	var regExpNumeric=/^[0-9]+$/g;
 	return matchRegularExpression(n, regExpNumeric);
 }
 
 function isAlphaNum(n)
 {
 	var regExpAlphaNumeric =/^[0-9a-zA-Z]+$/g;
 	return matchRegularExpression(n, regExpAlphaNumeric);
 }
 
 function isTVA(tva, iso)
 {
 	tva = tva.replace(/\s/g,"");
 	tva = tva.substring(2, tva.length);
 	var l = tva.length;
 	switch (iso)
 	{
 		case 'IE':
 		case 'HU':
 		case 'MT':
 		case 'SI':
 			return (l==8) && isAlphaNum(tva);
 		case 'DK':
 		case 'FI':
 		case 'LU':
 			return (l==8) && isNum(tva);
 		case 'CZ':
 			return (l>=8) && (l<=10) && isAlphaNum(tva);
 		case 'ES':
 		case 'CY':
 		case 'EE':
 			return (l==9) && isAlphaNum(tva);
 		case 'DE':
 		case 'EL':
 		case 'GR':
 		case 'PT':
 		case 'BE':
 			return (l==9) && isNum(tva);
 		case 'SK':
 			return ((l==9) || (l==10)) && isAlphaNum(tva);
 		case 'LT':
 			return ((l==9) || (l==12)) && isAlphaNum(tva);
 		case 'GB':
 			return ((l==9) && isNum(tva))
 					|| ((l==4) && (tva.charAt(1)=='9') && (isNum(tva)))
 					|| ((l==5) && isNum(tva.substr(2,3)));
 		case 'AT':
 			return (l==9) && (tva.charAt(0)=='U') && isNum(tva.substr(1,l-1));
 		case 'PL':
 			return (l==10) && isAlphaNum(tva);
 		case 'LV':
 			return (l==11) && isAlphaNum(tva);
 		case 'IT':
 		case 'FR':
 			return (l==11) && isNum(tva);
 		case 'NL':
 			return (l==11) && isNum(tva.substr(8,2));
 		case 'SE':
 			return (l==12) && isNum(tva);
 		default:
 			return true;
 	}
 }
 
 function fReturnISOCode(NomPays) {
	switch (NomPays)
	{
		case 'IRLANDE':
			return 'IE'
		case 'HONGRIE':
			return 'HU';
		case 'MALTE':
			return 'MT';
		case 'SLOVENIE':
			return 'SI';
		case 'DANEMARK':
			return 'DK';
		case 'FINLANDE':
			return 'FI';
		case 'LUXEMBOURG':
			return 'LU';
		case 'REPUBLIQUE TCHEQUE':
			return 'CZ';
		case 'ESPAGNE':
			return 'ES';
		case 'CHYPRE':
			return 'CY';
		case 'ESTONIE':
			return 'EE';
		case 'ALLEMAGNE':
			return 'DE';
		case 'GRECE':
			return 'GR';
		case 'PORTUGAL':
			return 'PT';
		case 'BELGIQUE':
			return 'BE';
		case 'SLOVAQUIE':
			return 'SK';
		case 'LITUANIE':
			return 'LT';
		case 'GRANDE BRETAGNE':
			return 'GB';
		case 'AUTRICHE':
			return 'AT';
		case 'POLOGNE':
			return 'PL';
		case 'LETTONIE':
			return 'LV';
		case 'ITALIE':
			return 'IT';
		case 'FRANCE':
			return 'FR';
		case 'PAYS BAS':
			return 'NL';
		case 'SUEDE':
			return 'SE';
		default:
			return 'NONE';
	}
 }
