function checkNumericCp(val,minlength){
	if (val=='' || val.length < minlength || val.length>5 ){
		return false;
	}
	var s = '0123456789';
	for(i=0;i<val.length;i++){
		if (s.indexOf(val.charAt(i))==-1){
			return false;
		}
	}
	return true;
}

function checkCPlocaliser() {
	var rep = checkNumericCp($('cploc').getValue(),2); //var rep = checkCodePostal($('cploc').getValue(), '5');
	if (rep != true) {
		alert('Le code postal est incorrect. Veuillez entrer au moins deux chiffres');
		$('cploc').focus();
		return false;
	}
	return true;
}

// fonction gèrant la vérification des cp suivant le pays
function checkCodePostal(valCP, valPays) {
	switch (valPays) {
		// france
		case '5':
			var regex = /^(0[1-9]|[1-9][0-9])[0-9][0-9][0-9]$/;
			return regex.test(valCP);
			break;
		default: 
			return true;
			break;
	}
	return true;
}

function onBlocLocaliser(){
	if (checkCPlocaliser()){
		var fr = document.getElementById('formCP');
		if (fr){
			fr.submit();
		}
	}
}

