function choixAgence(id,nom,isregion){
	if(isregion){

		if(id == 9){
			$('type_envoi').innerHTML = " au Directeur National des Ventes";
		}else{
			$('type_envoi').innerHTML = " au Directeur Commercial Régional";
		}

	$('nom_agence').innerHTML = "";
	$('form_id_agence').value = "";
	$('form_id_region').value = id;
	$('form_contact').style.display='block';
	$('pro').style.display='none';
	$('choix6').setStyle('display','block');
	$('selection').style.display='none';

	} else {
	  $('form_contact').style.display='block';
	  $('pro').style.display='block';
	  $('choix6').setStyle('display','none');
	  $('selection').style.display='block';
	  $('type_envoi').innerHTML = " à l’agence de : ";
	  $('nom_agence').innerHTML = nom;
	  $('form_id_agence').value = id;
	  $('form_id_region').value = "";
	}

  /*window.location.hash = "#form_contact";*/
  aller('form_contact');
}

function aller(elmt){

	var scroll = new Fx.Scroll(window, { wait: false, duration: 1500, transition: Fx.Transitions.Quad.easeInOut });
	scroll.toElement(elmt);
}

function descendre(){
	/*window.location.hash = "#flash";*/
	aller('flash');
}

function voirformulaire(){

  //val = document.getElementById('choix').value;

  /*window.location.hash = "#choix"+val;*/
  //aller('choix'+val);
  aller('type_envoi');
}


function controlForm(e){
	var e = new Event(e);
	var choix = $('choix');
	var val = null;

	contact = $('form_id_region').value;


	var pro = 0;
	if(choix)
		val = $('choix').value;
	else
		pro = 1;

    var texte = "";

    if((val && val < 5) || (pro == 1 && !contact)){
		if (val == 1 || (pro)){val = "";}
	  	if(!$("civilite"+val+"_0").checked & !$("civilite"+val+"_1").checked & !$("civilite"+val+"_2").checked){texte += "- choisissez votre civilite\n";}
		if($("nom"+val).value == "")		{texte += "- entrez votre nom\n"}
		if($("prenom"+val).value == "")		{texte += "- entrez votre prenom\n"}
		if($("Adresse"+val).value == "")	{texte += "- entrez votre adresse\n"}
		if($("cp"+val).value == "")			{texte += "- entrez votre code postal\n"}
		if($("ville"+val).value == "")			{texte += "- entrez votre ville\n"}
		if($("telephone"+val).value == "")	{texte += "- entrez votre téléphone\n"}

		if(pro == 1 && !contact)
		if($("societe").value == ""){texte += "- entrez votre société\n"}
	}

	if (val == 5){
	if(!$("civilite"+val+"_0").checked & !$("civilite"+val+"_1").checked & !$("civilite"+val+"_2").checked){texte += "- choisissez votre civilite\n";}
	if($("nom"+val).value == "")		{texte += "- entrez votre nom\n"}
	if($("prenom"+val).value == "")		{texte += "- entrez votre prenom\n"}
	if($("telephone"+val).value == "")	{texte += "- entrez votre téléphone\n"}
	if($("agence").value == "")			{texte += "- entrez votre agence\n"}
	}

	if(contact){
		val = 6;
		if(!$("civilite"+val+"_0").checked & !$("civilite"+val+"_1").checked & !$("civilite"+val+"_2").checked){texte += "- choisissez votre civilite\n";}
		if($("nom"+val).value == "")		{texte += "- entrez votre nom\n"}
		if($("prenom"+val).value == "")		{texte += "- entrez votre prenom\n"}
		if($("Adresse"+val).value == "")	{texte += "- entrez votre adresse\n"}
		if($("cp"+val).value == "")			{texte += "- entrez votre code postal\n"}
		if($("ville"+val).value == "")		{texte += "- entrez votre ville\n"}
		if($("telephone"+val).value == "")	{texte += "- entrez votre téléphone\n"}
		if($("societe"+val).value == "")	{texte += "- entrez le nom de votre société\n"}
		if($("fonction"+val).value == "")	{texte += "- entrez votre fonction\n"}
	}


	if(texte != ""){
		send = "Problèmes avec ces champs obligatoires : \n"+texte
		alert(send);
		e.stop();return false;
	}
}

window.addEvent('domready', function() {
	var form = $('form_contact');
    form.addEvent('submit', controlForm);
 });

