if(!document.getElementById){
  if(document.all){
    document.getElementById=function(){
if(typeof document.all[arguments[0]]!="undefined"){return document.all[arguments[0]]}else{return null}
    }
  }else if(document.layers){
    document.getElementById=function(){
if(typeof document[arguments[0]]!="undefined"){return document[arguments[0]]}else{return null}
    }
  }
}
function aff_tva(){
	mondoc=document.info_utilisateur;
	valeur=mondoc.pays.options[mondoc.pays.options.selectedIndex].value;
	valeur=valeur.charAt(2);
	if(valeur==0){
		document.getElementById('tva_1').className="Invisible";
		document.getElementById('tva_3').className="Invisible";
		document.getElementById('tva_intra').className="Invisible";
		mondoc.tva_intra.value="";
	}else{
		document.getElementById('tva_1').className="";
		document.getElementById('tva_3').className="";
		document.getElementById('tva_intra').className="champ";
	}
}
function aff_tva_fact(){
	mondoc2=document.info_facturation;
	valeur=mondoc2.pays_fact.options[mondoc2.pays_fact.options.selectedIndex].value;
	valeur=valeur.charAt(0);
	if(valeur==0){
		document.getElementById('tva_fact1').className="Invisible";
		document.getElementById('tva_fact3').className="Invisible";
		document.getElementById('tva_intra_fact').className="Invisible";
		mondoc2.tva_intra_fact.value="";
	}else{
		document.getElementById('tva_fact1').className="";
		document.getElementById('tva_fact3').className="";
		document.getElementById('tva_intra_fact').className="champ";
	}
}
function suppVin(id_vin,id_commande,langue){
	var ok=confirm('Supprimer ce vin?');
	if(ok){
		window.location="../gestion/suppression_vin.php?id_inscription_vin="+id_vin+"&id_commande="+id_commande+"&langue="+langue;
	}
}
function EauDeVie(valeur){
	mondoc=document.re_tech;
	if(valeur==1){
		mondoc.vin_aromatique[1].checked=true;
		mondoc.vin_sous_voile[1].checked=true;
		mondoc.vdn[1].checked=true;
	}
}
function Affiche_tr(check,valeur){
	mondoc=document.re_tech;
	mtab_tr=Array('tab_tr');
	mtab_eff=Array('tab_eff');
	if(valeur=="tranquille"){
		if(check){
			document.getElementById('col_tr').className="";
			mondoc.type_eff.checked=false;
			for(i=0;i<mtab_tr.length;i++){
				Affiche(mtab_tr[i],'','aff');
				Affiche(mtab_eff[i],'','cache');
			}
			for(i=3;i<mondoc.couleur_type.length;i++){
				if(mondoc.couleur_type[i].checked){
					mondoc.couleur_type[i-3].checked=true;
				}
			}
			for(i=12;i<mondoc.sucre_type.length;i++){
				if(mondoc.sucre_type[i].checked){
					mondoc.sucre_type[i-12].checked=true;
				}
			}
		}else{
			Affiche(mtab_tr[0],'','cache');
			document.getElementById('col_tr').className="champ-rouge";
			for(i=0;i<mondoc.couleur_type.length-3;i++){
				mondoc.couleur_type[i].checked=false;
			}
			for(i=0;i<mondoc.sucre_type.length-12;i++){
				mondoc.sucre_type[i].checked=false;
			}
		}
	}else if(valeur=="effervescent"){
		if(check){
			document.getElementById('col_tr').className="";
			mondoc.type_tr.checked=false;
			for(i=0;i<mtab_eff.length;i++){
				Affiche(mtab_eff[i],'','aff');
				Affiche(mtab_tr[i],'','cache');
			}
			for(i=0;i<mondoc.couleur_type.length-3;i++){
				if(mondoc.couleur_type[i].checked){
					mondoc.couleur_type[i+3].checked=true;
				}
			}
			for(i=0;i<mondoc.sucre_type.length-12;i++){
				if(mondoc.sucre_type[i].checked){
					mondoc.sucre_type[i+12].checked=true;
				}
			}
		}else{
			
			Affiche(mtab_eff[0],'','cache');
			document.getElementById('col_tr').className="champ-rouge";
			for(i=3;i<mondoc.couleur_type.length;i++){
				mondoc.couleur_type[i].checked=false;
			}
			for(i=12;i<mondoc.sucre_type.length;i++){
				mondoc.sucre_type[i].checked=false;
			}
		}
	}
}

function meme_adresse(obj){
	var info=document.info_utilisateur;
	var facturation=document.info_facturation;
	if(obj.checked==false){
		facturation.raison_sociale_fact.value="";
		facturation.adresse_fact.value="";
		facturation.adresse2_fact.value="";
		facturation.email_fact.value="";
		facturation.cp_fact.value="";
		facturation.ville_fact.value="";
		facturation.tva_intra_fact.value="";
		facturation.pays_fact.options.selectedIndex=0;
		aff_tva_fact(facturation.pays_fact.options[0].value.charAt(0));
		facturation.autre_pays.value="";
	}else{		
		facturation.raison_sociale_fact.value=info.raison_sociale.value;
		facturation.adresse_fact.value=info.adresse.value;
		facturation.adresse2_fact.value=info.adresse2.value;
		/*
		facturation.nom_fact.value=info.nom.value;
		if(info.civilite[0].checked==true){
			facturation.civilite_fact[0].checked=true;
		}else if(info.civilite[1].checked==true){
			facturation.civilite_fact[1].checked=true;
		}else if(info.civilite[2].checked==true){
			facturation.civilite_fact[2].checked=true;
		}
		*/
		facturation.email_fact.value=info.email.value;
		facturation.cp_fact.value=info.cp.value;
		facturation.ville_fact.value=info.ville.value;
		facturation.tva_intra_fact.value=info.tva_intra.value;
		//pays
		var passe=0;
		for(j=0;j<facturation.pays_fact.options.length;j++){
			//alert(facturation.pays_fact.options[j].text+"--"+info.pays.options[info.pays.options.selectedIndex].text);
			if(facturation.pays_fact.options[j].text==info.pays.options[info.pays.options.selectedIndex].text){
				facturation.pays_fact.options.selectedIndex=j;
				aff_tva_fact(facturation.pays_fact.options[j].value.charAt(0));
				var passe=1;
			}
		}
		if(passe==0){
			facturation.autre_pays.value=info.pays.options[info.pays.options.selectedIndex].text;
		}
	}
}
function Verif_re_tech(){
	var prb=0;
	var mondoc=document.re_tech;
	if(mondoc.type_eff.checked==false && mondoc.type_tr.checked==false){
		document.getElementById('col_tr').className="champ-rouge";
		prb=1;
	}else{
		document.getElementById('col_tr').className="";
	}
	if(mondoc.sucres_residuels.value==""){
		mondoc.sucres_residuels.className="champ-rouge";
		prb=1;
	}else{
		mondoc.sucres_residuels.className="champ";
	}
	if(mondoc.alcool_acquis.value==""){
		mondoc.alcool_acquis.className="champ-rouge";
		prb=1;
	}else{
		mondoc.alcool_acquis.className="champ";
	}
	if(prb!=1){
		document.re_tech.submit();
	}
}
function Verif_contact(){
	var prb=0;
	if(document.contact.nom.value==""){
		document.contact.nom.className="champ-rouge";
		prb=1;
	}else{
		document.contact.nom.className="champ";
	}
	if(document.contact.prenom.value==""){
		document.contact.prenom.className="champ-rouge";
		prb=1;
	}else{
		document.contact.prenom.className="champ";
	}
	if(document.contact.email.value==""){
		document.contact.email.className="champ-rouge";
		prb=1;
	}else{
		document.contact.email.className="champ";
	}
	if(document.contact.sujet.value==""){
		document.contact.sujet.className="champ-rouge";
		prb=1;
	}else{
		document.contact.sujet.className="champ";
	}
	if(document.contact.message.value==""){
		document.contact.message.className="champ-rouge";
		prb=1;
	}else{
		document.contact.message.className="champ";
	}
	if(prb!=1){
		document.contact.submit();
	}
}
function Verif_distributeur(){
	var prb=0;
	var mondoc=document.dist;
	if(mondoc.prix_vin.value==""){
		mondoc.prix_vin.className="champ-rouge";
		prb=1;
	}else{
		mondoc.prix_vin.className="champ";
	}
	var oki=false;
	if(document.dist.acc1.checked==true){
		oki=true;
	}
	if(document.dist.acc2.checked==true){
		oki=true;
	}
	if(document.dist.acc3.checked==true){
		oki=true;
	}
	if(document.dist.acc4.checked==true){
		oki=true;
	}
	if(document.dist.acc5.checked==true){
		oki=true;
	}
	if(document.dist.acc6.checked==true){
		oki=true;
	}
	if(document.dist.acc7.checked==true){
		oki=true;
	}
	if(document.dist.acc8.checked==true){
		oki=true;
	}
	if(document.dist.acc9.checked==true){
		oki=true;
	}
	if(oki==false){
		
		document.getElementById('tab_accords').className="champ-rouge";
		prb=1;
	
		prb=1;
	}else{
		document.getElementById('tab_accords').className="";
	}
	/*if(mondoc.raison_sociale.value==""){
		mondoc.raison_sociale.className="champ-rouge";
		prb=1;
	}else{
		mondoc.raison_sociale.className="champ";
	}
	if(mondoc.tel.value==""){
		mondoc.tel.className="champ-rouge";
		prb=1;
	}else{
		mondoc.tel.className="champ";
	}
	if(mondoc.adresse.value==""){
		mondoc.adresse.className="champ-rouge";
		prb=1;
	}else{
		mondoc.adresse.className="champ";
	}
	if(mondoc.cp.value==""){
		mondoc.cp.className="champ-rouge";
		prb=1;
	}else{
		mondoc.cp.className="champ";
	}
	if(mondoc.ville.value==""){
		mondoc.ville.className="champ-rouge";
		prb=1;
	}else{
		mondoc.ville.className="champ";
	}
	if(mondoc.id_distributeur_fk.value=="" && mondoc.raison_sociale.value==""){
		mondoc.id_distributeur_fk.className="champ-rouge";
		mondoc.raison_sociale.className="champ-rouge";
		prb=1;
	}else{
		mondoc.id_distributeur_fk.className="champ";
		mondoc.raison_sociale.className="champ";
	}
	*/
	
	if(prb!=1){
		mondoc.submit();
	}
}
function Verif_utilisateur(){
	var prb=0;
	//alert('vérification des champs');
	var mondoc=document.info_utilisateur;
	if(mondoc.nom.value==""){
		mondoc.nom.className="champ-rouge";
		prb=1;
	}else{
		mondoc.nom.className="champ";
	}
	if(mondoc.raison_sociale.value==""){
		mondoc.raison_sociale.className="champ-rouge";
		prb=1;
	}else{
		mondoc.raison_sociale.className="champ";
	}
	if(mondoc.email.value.indexOf("@") == "-1" || mondoc.email.value.indexOf(".") == "-1" || mondoc.email.value == ""){
		mondoc.email.className="champ-rouge";
		prb=1;
	}else{
		mondoc.email.className="champ";
	}
	if(mondoc.adresse.value==""){
		mondoc.adresse.className="champ-rouge";
		prb=1;
	}else{
		mondoc.adresse.className="champ";
	}
	if(mondoc.cp.value==""){
		mondoc.cp.className="champ-rouge";
		prb=1;
	}else{
		mondoc.cp.className="champ";
	}
	if(mondoc.ville.value==""){
		mondoc.ville.className="champ-rouge";
		prb=1;
	}else{
		mondoc.ville.className="champ";
	}
	if(mondoc.pays.value=="" && mondoc.autre_pays.value==""){
		mondoc.pays.className="champ-rouge";
		mondoc.autre_pays.className="champ-rouge";
		prb=1;
	}else{
		mondoc.pays.className="champ";
		mondoc.autre_pays.className="champ";
	}
	if(mondoc.pays.value.charAt(0)==0 && mondoc.pays.value.charAt(2)==1 && mondoc.autre_pays.value=="" && mondoc.tva_intra.value==""){
		mondoc.tva_intra.className="champ-rouge";
		prb=1;
	}else if(mondoc.pays.value.charAt(0)==0 && mondoc.pays.value.charAt(2)==1){
		mondoc.tva_intra.className="champ";
	}else{
		mondoc.tva_intra.className="Invisible";
	}
	if(mondoc.tel.value==""){
		mondoc.tel.className="champ-rouge";
		prb=1;
	}else{
		mondoc.tel.className="champ";
	}
	if(mondoc.civilite_oe[0].checked!=true && mondoc.civilite_oe[1].checked!=true && mondoc.civilite_oe[2].checked!=true){
		mondoc.civilite_oe[0].checked!=true;
	}
	if(mondoc.oenologue.value==""){
		mondoc.oenologue.className="champ-rouge";
		prb=1;
	}else{
		mondoc.oenologue.className="champ";
	}
	
	if(prb!=1){
		//alert(prb);
		document.info_utilisateur.submit();
	}
}
function Verif_facturation(){
	var prb=0;
	var mondoc=document.info_facturation;
	if(mondoc.raison_sociale_fact.value==""){
		mondoc.raison_sociale_fact.className="champ-rouge";
		prb=1;
	}else{
		mondoc.raison_sociale_fact.className="champ";
	}
	if(mondoc.email_fact.value==""){
		mondoc.email_fact.className="champ-rouge";
		prb=1;
	}else{
		mondoc.email_fact.className="champ";
	}
	if(mondoc.adresse_fact.value==""){
		mondoc.adresse_fact.className="champ-rouge";
		prb=1;
	}else{
		mondoc.adresse_fact.className="champ";
	}
	if(mondoc.cp_fact.value==""){
		mondoc.cp_fact.className="champ-rouge";
		prb=1;
	}else{
		mondoc.cp_fact.className="champ";
	}
	if(mondoc.ville_fact.value==""){
		mondoc.ville_fact.className="champ-rouge";
		prb=1;
	}else{
		mondoc.ville_fact.className="champ";
	}
	if(mondoc.pays_fact.value=="" && mondoc.autre_pays.value==""){
		mondoc.pays_fact.className="champ-rouge";
		mondoc.autre_pays.className="champ-rouge";
		prb=1;
	}else{
		mondoc.pays_fact.className="champ";
		mondoc.autre_pays.className="champ";
	}
	mondoc2=document.info_facturation;
	valeur=mondoc2.pays_fact.options[mondoc2.pays_fact.options.selectedIndex].value;
	valeur=valeur.charAt(0);
	if(valeur==1 && mondoc.autre_pays.value=="" && mondoc.tva_intra_fact.value==""){
		mondoc.tva_intra_fact.className="champ-rouge";
		prb=1;
	}else{
		mondoc.tva_intra_fact.className="champ";
	}
	if(prb!=1){
		mondoc.submit();
	}
}
function Verif_identification(){
	var prb=0;
	var mondoc=document.info_produit;
	if(mondoc.pays.value=="" && mondoc.autre_pays.value==""){
		mondoc.pays.className="champ-rouge";
		mondoc.autre_pays.className="champ-rouge";
		prb=1;
	}else{
		mondoc.pays.className="champ";
		mondoc.autre_pays.className="champ";
	}
	if(mondoc.appellation.value=="" && mondoc.autre_appellation.value==""){
		mondoc.appellation.className="champ-rouge";
		mondoc.autre_appellation.className="champ-rouge";
		prb=1;
	}else{
		mondoc.appellation.className="champ";
		mondoc.autre_appellation.className="champ";
	}
	if(mondoc.region.value=="" && mondoc.autre_region.value==""){
		mondoc.region.className="champ-rouge";
		mondoc.autre_region.className="champ-rouge";
		prb=1;
	}else{
		mondoc.region.className="champ";
		mondoc.autre_region.className="champ";
	}
	if(mondoc.nom_du_vin.value==""){
		mondoc.nom_du_vin.className="champ-rouge";
		prb=1;
	}else{
		mondoc.nom_du_vin.className="champ";
	}
	
	valeur=mondoc.millesime.options[mondoc.millesime.options.selectedIndex].value;
	if(valeur==""){
		mondoc.millesime.className="champ-rouge";
		prb=1;
	}else{
		mondoc.millesime.className="champ";
	}
	
	if(mondoc.numero_lot.value==""){
		mondoc.numero_lot.className="champ-rouge";
		prb=1;
	}else{
		mondoc.numero_lot.className="champ";
	}
	if(mondoc.stock.value==""){
		mondoc.stock.className="champ-rouge";
		prb=1;
	}else{
		mondoc.stock.className="champ";
	}
	if(mondoc.couleur[0].checked==false && mondoc.couleur[1].checked==false && mondoc.couleur[2].checked==false){
		document.getElementById('couleur_vin').className="champ-rouge";
		
		//mondoc.couleur[0].className="champ-rouge";
		//alert("Veillez choisir la couleur");
		prb=1;
	}else{
		document.getElementById('couleur_vin').className="";
	}
	//gestion du cas de l'Alsace
	//si dans appellation grand cru
	if(mondoc.region.value=="Alsace" && mondoc.appellation.options[mondoc.appellation.selectedIndex].text.indexOf("grand-cru",0)!=-1 && mondoc.cepage.value=="" && mondoc.autre_cepage.value==""){
		mondoc.cepage.className="champ-rouge";
		mondoc.autre_cepage.className="champ-rouge";
		alert(mondoc.cepage.value);
		prb=1;
	}else{
		mondoc.cepage.className="champ";
		mondoc.autre_cepage.className="champ";
	}
	//parcours des donnnees reg
	//document.info_produit.donnee_reg=Array();
	for (i=0; i<mondoc.elements.length; i++){ 
        meschecks = mondoc.elements[i]; 
        if (meschecks.checked){ 
			
			if((meschecks.value=="Grand cru|" || meschecks.value=="grand cru|" || meschecks.value=="Premier cru|" || meschecks.value=="premier cru|") && mondoc.region.value=="Bourgogne" && mondoc.id_nom_du_cru_fk.value=="" && mondoc.autre_nom_du_cru.value==""){
				mondoc.id_nom_du_cru_fk.className="champ-rouge";
				mondoc.autre_nom_du_cru.className="champ-rouge";
			}else{
				mondoc.id_nom_du_cru_fk.className="champ";
				mondoc.autre_nom_du_cru.className="champ";
			}
        } 
 	}  
	if(prb!=1){
		mondoc.submit();
	}
}
function Cas_particulier(){
	mondoc=document.info_produit;
	if(mondoc.region.value=="Bourgogne"){
		var passe=0;
		for (i=0; i<mondoc.elements.length; i++){ 
			meschecks = mondoc.elements[i]; 
			if (meschecks.checked){ 
				if(meschecks.value=="Premier cru|" || meschecks.value=="Grand cru|" || meschecks.value=="premier cru|" || meschecks.value=="grand cru|"){
					Affiche('id_nom_du_cru','','aff');
					passe=1;
				}
			}
		}
		if(passe==0){
			Affiche('id_nom_du_cru','','cache');
			mondoc.id_nom_du_cru_fk.selectedIndex=0;
			mondoc.autre_nom_du_cru.value="";
		}
	}
	if(mondoc.region.value=="Alsace" && mondoc.appellation.options[mondoc.appellation.selectedIndex].text.indexOf("grand-cru",0)!=-1){
		Affiche('id_cepage','','aff');
	}else if(mondoc.region.value=="Alsace"){
		Affiche('id_cepage','','cache');
	}
}
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}else if (document.documentElement && document.documentElement.clientHeight) {
		windowHeight = document.documentElement.clientHeight;
	}else if (document.body && document.body.clientHeight) {
		windowHeight = document.body.clientHeight;
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contenuTableau= document.getElementById('tableau');
			var tailleContenu=document.getElementById('tableau').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			var reste=windowHeight - (tailleContenu);
			if (reste >= 0){
				//contenuPage.style.height=(tailleContenu+reste-158-footerHeight) +'px';
				contenuTableau.style.height=(tailleContenu+reste-158-footerHeight) +'px';
				var tailleContenu  = document.getElementById('contenu').offsetHeight;
				//footerElement.style.top=(tailleContenu+reste)+'px';
				//footerElement.style.position = 'relative';
				//footerElement.style.top = (windowHeight - (tailleContenu)) + 'px';
			}else{
				//footerElement.style.paddingTop=0 +'px';
				//footerElement.style.position = 'static';
			}
		}
	}
}
function Cache(id,classe){
	object=window.document.getElementById(id);
	if(object.className=='Invisible'){
		object.className=classe;
	}else{
		object.className='Invisible';
	}
}
function Affiche(id,classe,action){
	if(action=='cache'){
		object=window.document.getElementById(id);
		object.className='Invisible';
	}else if(action=='aff'){
		object=window.document.getElementById(id);
		object.className=classe;
	}
}
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher. 
   { 
   for(var i=0; i<document.images.length; i++) 
      { 
     var img = document.images[i] 
     var imgName = img.src.toUpperCase() 
     if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
        { 
       var imgClass = (img.className) ? "class='" + img.className + "' " : ""   
       var strNewHTML = "<span " + imgClass 
       + " style=;" 
        + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
       + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
       img.outerHTML = strNewHTML 
       i = i-1 
        } 
      } 
   }  
window.onload = function() {
	setFooter();	
}
window.onresize = function() {
	setFooter(); 
}