//QUAND ON CLIQUES SUR LE MENU PRINCIPAL
	function apercu(acc) {	   
	    var xhr;
	    if (window.XMLHttpRequest) {
			xhr = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			xhr = new ActiveXObject('Microsoft.XMLHTTP');
		} else {
	        alert('JavaScript : votre navigateur ne supporte pas les objets XMLHttpRequest...');
	        return;
	    }
	    xhr.open('POST','requete_chemise2.php',true);
	    xhr.onreadystatechange = function() {
			if(acc!='validation2') {
		        if (xhr.readyState == 4) {
		            if (document.getElementById) document.getElementById('liste').innerHTML = xhr.responseText;
		        } else {
					document.getElementById('liste').innerHTML = "<div style='margin-top:100px;text-align:center;'><img src='../style/wait.gif' /><br /><p>Chargement</p></div>";					
				}
			} else {
				if (xhr.readyState == 4) {
		           	window.location='../panier-ls-chemise.php';
		        } else {
					document.getElementById('bloc_validation').innerHTML = "<div style='margin-top:100px;text-align:center;'><img src='../style/wait.gif' /><br /><p>Chargement</p></div>";
					document.getElementById('menu_tissus').innerHTML = "";
				}
			}
	    }
					
	    xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		var data = 'acc='+escape(acc);
	    xhr.send(data);
    }

//POUR APPELER LES TISSUS
	function apercu2(valeur) {	   
	    var xhr;
	    if (window.XMLHttpRequest) {
			xhr = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			xhr = new ActiveXObject('Microsoft.XMLHTTP');
		} else {
	        alert('JavaScript : votre navigateur ne supporte pas les objets XMLHttpRequest...');
	        return;
	    }
	    xhr.open('POST','requete_tissu2.php',true);
	    xhr.onreadystatechange = function() {
	        if (xhr.readyState == 4) {
	            if (document.getElementById) document.getElementById('liste_interne').innerHTML = xhr.responseText;
	        } else {
				document.getElementById('liste_interne').innerHTML = "<div style='margin-top:100px;text-align:center;'><img src='../style/wait.gif' /><br /><p>Chargement</p></div>";
			}
	    }
	    xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		
	    var data = 'choix='+escape(valeur);
	    xhr.send(data);
    }


//GESTION DU MODULE
	function zoom1() {
		etat1 = document.getElementById('f_zoom1').value;
		document.getElementById('f_zoom2').value = '0';
		if(etat1=='1') {
			changerVue('face');document.getElementById('f_zoom1').value='0';
		} else {
			changerVue('dos');document.getElementById('f_zoom1').value='1';
		}
	}
	function zoom2() {
		etat2 = document.getElementById('f_zoom2').value;
		document.getElementById('f_zoom1').value = '0';
		if(etat2=='1') {
			changerVue('face');document.getElementById('f_zoom2').value='0';
		} else {
			changerVue('col');document.getElementById('f_zoom2').value='1';
		}
	}

//ENREGISTRER EN SESSION LES CHOIX
	function enregistrement(nom,valeur) {	   
	    if(flashDisponible){
			var xhr;
		    if (window.XMLHttpRequest) {
				xhr = new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				xhr = new ActiveXObject('Microsoft.XMLHTTP');
			}		
		    xhr.open('POST','enregistrement2.php',true);
			xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		    var data = nom+'='+escape(valeur);
		    xhr.send(data);
		}
    }

//INSCRIRE DANS LE FORMULAIRE	
	function formulaire(cat,nom) {
		if(flashDisponible) {
			document.getElementById(cat).value = nom;
		}
	}

//QUAND ON CLIQUE SUR LE MENU
	var btn_menu = new Array('tissu','col','poignet','dos','bas','gorge','epaulette','poche','bouton','couture','monogramme','broderie');
	function menu_on(calque) {
		etat = calque.style.color;		
		if(etat!='#942800' && etat!='rgb(148, 40, 0)') calque.style.color = '#000000';
	}
	function menu_of(calque) {
		etat = calque.style.color;
		if(etat=='#000000' || etat=='rgb(0, 0, 0)') calque.style.color = '#666';
	}
	
	function change_menu(calque) {
		for(i=0;i<12;i++) {
			document.getElementById('btn_'+btn_menu[i]).style.color = '#666';
		}
		document.getElementById('btn_'+btn_menu[calque]).style.color = '#942800';
		h = 22*calque;
		document.getElementById('menu_construction').style.backgroundPosition = '0px '+h+'px';
		apercu(btn_menu[calque]);
		
		if(calque==3) {
			changerVue('dos');
		} else if(calque==1 || calque==9) {
			changerVue('col');
		} else {
			changerVue('face');
		}
	}

// APPARITION DU MENU TISSU
	function appar_menu() {
		document.getElementById('menu_tissus').style.display = 'block';
		document.getElementById('plusdoptions').style.backgroundPosition = '0 -32px';
		document.getElementById('plusdoptions').style.color = '#333';
	}
	function dispar_menu() {
		document.getElementById('menu_tissus').style.display = 'none';
		document.getElementById('plusdoptions').style.backgroundPosition = '0 0';
		document.getElementById('plusdoptions').style.color = '#fff';
	}
//MENU DE RECHERCHE DES TISSUS
	tab_coul = new Array('blanc','gris','noir','bleu','marron','vert','rouge','rose','violet','parme','orange','jaune');
	tab_etat = new Array(0,0,0,0,0,0,0,0,0,0,0,0);
	function rec_tissu(choix,type) {		
		
		if(type=='cat') {
			for(i=0;i<7;i++) {document.getElementById('ica_'+i).style.fontWeight = '100';}
			document.getElementById('ica_'+choix).style.fontWeight = '900';
			for(i=0;i<12;i++) {document.getElementById('ic_'+i).style.borderColor = '#ffffff';}
		} else {			
			for(i=0;i<12;i++) {document.getElementById('ic_'+i).style.borderColor = '#ffffff';tab_etat[i] = 0;}
			document.getElementById('ic_'+choix).style.borderColor = '#942800';
			document.getElementById('rec_cat').style.backgroundPosition = '0 1500px';
			tab_etat[choix] = 1;
			choix = tab_coul[choix];
		}
		dispar_menu();
		apercu2(choix);
	}
//INDICATION COULEURS
	function indic_couleur(coul) {		
		etat = tab_etat[coul];
		if(etat==0) {
			document.getElementById('ic_'+coul).style.borderColor = '#999999';
		}
		document.getElementById('indic_couleur').innerHTML = tab_coul[coul];
		document.getElementById('indic_couleur').style.display = 'block';
	}
	function indic_couleur_stop(coul) {	
		etat = tab_etat[coul];
		if(etat==0) {
			document.getElementById('ic_'+coul).style.borderColor = '#ffffff';
		}
		document.getElementById('indic_couleur').style.display = 'none';
	}