// JavaScript Document

/*#######################################################*/
document.observe("dom:loaded", function() {
/*#######################################################*/	
		
		$('error_message').hide();

});


////////////////////////////////////  TEST FORMULAIRE ///////////////////////
function verifForm()
{
		
		$('error_message').hide();

	
	testOK		=	true;	

	if(longueurChamps('CodePostal')!=5){
		$('error_message').innerHTML = "Le&nbsp;code postal doit &ecirc;tre compos&eacute; de cinq chiffres.";
		$('error_message').show();
		testOK=false;
	}	

	if(natureChamps('CodePostal')==false){
		$('error_message').innerHTML = "Le&nbsp;code postal doit &ecirc;tre en chiffres";
		$('error_message').show();
		testOK=false;
	}
	

	if(!testChamps('CodePostal')){
		$('error_message').innerHTML = "Veuillez indiquer votre code postal.";
		$('error_message').show();
		testOK=false;
	}	
	
	if (!testOK){
		return false;
	}else{
		openAdresse('CodePostal');
		return false;
	}

}

function testChamps(idChamp)
{
	return $(idChamp).present();	
}

function longueurChamps(idChamp)
{
	return ($F(idChamp).length);
}

function natureChamps(idChamp)
{
		if(isNaN($F(idChamp)) || Math.round($F(idChamp)) != $F(idChamp)  )
		{		
			return false;
		}
}

function openAdresse(idChamp)
{
	window.location.href = "trouver-nos-agences.php?cp="+($F(idChamp));
	//var url = 'http://fc1.1bis.com/palatine/geocode.asp?cityTxt='+($F(idChamp));
	//window.open(url, "TrouverUneAgence", "toolbar=no, status=yes, scrollbars=yes, resizable=no, width=640, height=400");	
}



