var tab_bloc_menu = new Array();
var current_bloc_menu = '1';
function show_hide_bloc_langue( couche ) {
	alterner_couche(tab_bloc_menu, 'bloc_menu', current_bloc_menu );
	alterner_couche(tab_bloc_menu, 'bloc_menu', couche );
	current_bloc_langue = couche;

	if ((obj = MM_findObj('bloc_menu'))) {
		obj.value = couche;
	}
}

function alterner_couche(tab, name, couche ) {
//alert(name+couche);
	if (!(layer = MM_findObj(name + couche))) {
		//alert('false pour '+name + couche);
		return;
	}
	if (layer.style.display == 'none'){
		//alert(name+couche+" aparait")
		layer.style.display = 'block';
	} else {
		//alert(name+couche+" disparait")
		layer.style.display = 'none';
	}
}

function popup_close(popup_name) {
	document.getElementById(popup_name).style.display = 'none';
	document.getElementById('masque').style.display = 'none';
}

function popup_open(popup_name) {
	document.getElementById(popup_name).style.display = 'inline';
	document.getElementById('masque').style.display = 'inline';
	if (document.height == undefined) {
		/* ie */
		document.getElementById(popup_name).style.marginLeft = parseInt((document.body.clientWidth/2)-(document.getElementById(popup_name).width/2))+'px';
	}else{
		/* firefox */
		document.getElementById(popup_name).style.marginLeft = parseInt((document.width/2)-(document.getElementById(popup_name).width/2))+'px';
	}
}

function header_actif(lg, id) {
	document.getElementById(id).src='/languages/'+lg+'/media/img/menu_'+id+'_actif.gif'
}
function header_inactif(lg, id) {
	document.getElementById(id).src='/languages/'+lg+'/media/img/menu_'+id+'.gif'
}

	var i_diapo = 0;
	var tab_diapo_img = new Array("illustration_direct_japon_mini.jpg","illustration_assistance_technique_mini.jpg","illustration_ateliers_creations_mini.jpg","illustration_partenaires_mini.jpg");
	var tab_diapo_href = new Array("/ecole_grand_chocolat/direct_japon","/ecole_grand_chocolat/assistance_technique","/ecole_grand_chocolat/ateliers_creations","ecole_grand_chocolat/nos_partenaires");
	function cpt_rbs(Time_Left){
		if(Time_Left <= 0)
		{
			i_diapo++;
			if (i_diapo > 3){
				i_diapo = 0;
			}
			
			document.getElementById('titre_diapo_'+i_diapo).style.display= 'inline';
			document.getElementById('texte_diapo_'+i_diapo).style.display= 'inline';
			document.getElementById('num_diapo'+i_diapo).style.color='white';
			document.getElementById('partenaire_diapo').src='/shared/img_pro/'+tab_diapo_img[i_diapo];
			if (document.getElementById('titre_diapo_'+(i_diapo-1))) {
				document.getElementById('num_diapo'+(i_diapo-1)).style.color='#301b1b';
				document.getElementById('titre_diapo_'+(i_diapo-1)).style.display= 'none';
				document.getElementById('texte_diapo_'+(i_diapo-1)).style.display= 'none';
			}else{
				document.getElementById('titre_diapo_'+(3)).style.display= 'none';
				document.getElementById('texte_diapo_'+(3)).style.display= 'none';
				document.getElementById('num_diapo'+(3)).style.color='#301b1b';
			}
			/*
			document.getElementById('partenaire_diapo').src='/shared/img_pro/'+tab_diapo_img[i_diapo];
			document.getElementById('num_diapo'+i_diapo).style.color='white';
			document.getElementById('texte_diapo').innerHTML=tab_diapo_texte[i_diapo];
			document.getElementById('titre_diapo').innerHTML=tab_diapo_titre[i_diapo];
			document.getElementById('titre_diapo').href=tab_diapo_href[i_diapo];
			if (document.getElementById('num_diapo'+(i_diapo-1)))
				document.getElementById('num_diapo'+(i_diapo-1)).style.color='#301b1b';
			else
				document.getElementById('num_diapo'+(3)).style.color='#301b1b';
			if (document.getElementById('num_diapo'+(i_diapo+1)))
				document.getElementById('num_diapo'+(i_diapo+1)).style.color='#301b1b';
			else
				document.getElementById('num_diapo'+(1)).style.color='#301b1b';
			*/
			Time_Left = 4;
		}
	 	setTimeout('cpt_rbs('+(Time_Left-1)+')', 1000);
	}

	function diapo_go(i) {
		document.getElementById('num_diapo'+(i_diapo)).style.color='#301b1b';
		document.getElementById('titre_diapo_'+(i_diapo)).style.display= 'none';
		document.getElementById('texte_diapo_'+(i_diapo)).style.display= 'none';
		i_diapo = i;
		document.getElementById('titre_diapo_'+i_diapo).style.display= 'inline';
		document.getElementById('texte_diapo_'+i_diapo).style.display= 'inline';
		document.getElementById('num_diapo'+i_diapo).style.color='white';
		document.getElementById('partenaire_diapo').src='/shared/img_pro/'+tab_diapo_img[i_diapo];
		if (document.getElementById('titre_diapo_'+(i_diapo-1))) {
			document.getElementById('num_diapo'+(i_diapo-1)).style.color='#301b1b';
			document.getElementById('titre_diapo_'+(i_diapo-1)).style.display= 'none';
			document.getElementById('texte_diapo_'+(i_diapo-1)).style.display= 'none';
		}else{
			document.getElementById('titre_diapo_'+(3)).style.display= 'none';
			document.getElementById('texte_diapo_'+(3)).style.display= 'none';
			document.getElementById('num_diapo'+(3)).style.color='#301b1b';
		}
		/*
		document.getElementById('num_diapo'+(i_diapo)).style.color='#301b1b';
		i_diapo = i;
			document.getElementById('partenaire_diapo').src='/shared/img_pro/'+tab_diapo_img[i_diapo];
			document.getElementById('texte_diapo').innerHTML=tab_diapo_texte[i_diapo];
			document.getElementById('titre_diapo').innerHTML=tab_diapo_titre[i_diapo];
			document.getElementById('titre_diapo').href=tab_diapo_href[i_diapo];
			document.getElementById('num_diapo'+i_diapo).style.color='white';
			if (document.getElementById('num_diapo'+(i_diapo-1)))
				document.getElementById('num_diapo'+(i_diapo-1)).style.color='#301b1b';
			else
				document.getElementById('num_diapo'+(3)).style.color='#301b1b';
			if (document.getElementById('num_diapo'+(i_diapo+1)))
				document.getElementById('num_diapo'+(i_diapo+1)).style.color='#301b1b';
			else
				document.getElementById('num_diapo'+(1)).style.color='#301b1b';
		*/
	}


	function table_link(link){
		document.location.href = link;
	}

	function table_link_partenaires(){
		document.location.href = tab_diapo_href[i_diapo];
	}
	
	
function valide_prereservation() {
	var obj = document.f_form.Commandes_proMessage;
	var myOption = -1;

	for (i=document.f_form.elements["data[Commandes_pro][civilite]"].length-1; i > -1; i--) {
    if (document.f_form.elements["data[Commandes_pro][civilite]"][i].checked) {
      myOption = i; i = -1;
    }
  }

	if ( myOption == -1 ) {
		obj.value = "Veuillez saisir votre civilit&eacute;";
	}
  	else if ( document.f_form.elements["data[Commandes_pro][nom]"].value == '' ) {
		obj.value = "Veuillez saisir un nom";
		document.f_form.elements["data[Commandes_pro][nom]"].focus();
	}
	else if ( document.f_form.elements["data[Commandes_pro][prenom]"].value == '' ) {
		obj.value = "Veuillez saisir un prenom";
		document.f_form.elements["data[Commandes_pro][prenom]"].focus();
	}
	else if ( document.f_form.elements["data[Commandes_pro][raison_sociale]"].value == '' ) {
		obj.value = "Veuillez saisir une raison sociale";
		document.f_form.elements["data[Commandes_pro][raison_sociale]"].focus();
	}
	/*
	else if ( document.f_form.elements["data[Commandes_pro][numero_client]"].value == '' || isNaN(document.f_form.elements["data[Commandes_pro][numero_client]"].value) ) {
		obj.value = "Veuillez saisir un numero de client valide";
		document.f_form.elements["data[Commandes_pro][numero_client]"].focus();
	}
	*/
  	else if ( document.f_form.elements["data[Commandes_pro][adresse]"].value == '' ) {
		obj.value = "Veuillez saisir une adresse";
		document.f_form.elements["data[Commandes_pro][adresse]"].focus();
	}
	/*
  	else if ( document.f_form.elements["data[Commandes_pro][type_client]"][0].checked == false && document.f_form.elements["data[Commandes_pro][type_client]"][1].checked == false ) {
		obj.value = "Veuillez saisir type de client";
	}
	*/
	else if ( document.f_form.elements["data[Commandes_pro][zip]"].value == '' || isNaN(document.f_form.elements["data[Commandes_pro][zip]"].value) ) {
		obj.value = "Veuillez saisir un code postal";
		document.f_form.elements["data[Commandes_pro][zip]"].focus();
	}
	else if ( document.f_form.elements["data[Commandes_pro][tel]"].value == '' || isNaN(document.f_form.elements["data[Commandes_pro][tel]"].value) ) {
		obj.value = "Veuillez saisir un num&eacute;ro de t&eacute;l&eacute;phone valide";
		document.f_form.elements["data[Commandes_pro][tel]"].focus();
	}
	else if ( document.f_form.elements["data[Commandes_pro][ville]"].value == '' ) {
		obj.value = "Veuillez saisir une ville";
		document.f_form.elements["data[Commandes_pro][ville]"].focus();
	}
	else if ( document.f_form.elements["data[Commandes_pro][pays]"].value == '' ) {
		obj.value = "Veuillez saisir une pays";
		document.f_form.elements["data[Commandes_pro][pays]"].focus();
	}
	else if ( document.f_form.elements["data[Commandes_pro][email]"].value == '' ) {
		obj.value = "Veuillez saisir un email";
		document.f_form.elements["data[Commandes_pro][email]"].focus();
	}
	else if ( document.f_form.elements["data[Commandes_pro][email]"].value != '' ){
		var reg_mail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-z]{2,3}$/;
		if (!(reg_mail.exec(document.f_form.elements["data[Commandes_pro][email]"].value)!=null)){
			obj.value = "Veuillez saisir un email valide";
			document.f_form.elements["data[Commandes_pro][email]"].focus();
			return false;
	}
    document.getElementById('boutonAnnulerReservation').style.display = 'none';
    document.getElementById('boutonValiderReservation').style.display = 'none';
    document.getElementById('boutonFermerReservation').style.display = 'none';
		
    obj.value = "R&eacute;servation effectu&eacute;e"; 
    popup_open('popup_valid_reservation');
    //document.f_form.submit();
		return true;
	}
	return false;
}

