function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      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 imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src='" + img.src + "', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
window.attachEvent("onload", correctPNG);


/*
* Le code suivant va apprendre la balise blink à IE
*/
if ( document.all )
{
 function blink_show()
 {
  blink_tags  = document.all.tags("blink");
  blink_count = blink_tags.length;
  for ( i = 0; i < blink_count; i++ )
  {
   blink_tags[i].style.visibility = "visible";
  }

  window.setTimeout( "blink_hide()", 700 );
 }

 function blink_hide()
 {
  blink_tags  = document.all.tags("blink");
  blink_count = blink_tags.length;
  for ( i = 0; i < blink_count; i++ )
  {
   blink_tags[i].style.visibility = "hidden";
  }

  window.setTimeout( "blink_show()", 250 );
 }

 window.onload = blink_show;
}

function imageMax(chemin)
{
	html = '<html> <head> <title>ImageMax</title> </head> <body onBlur="top.close()"><IMG src="'+chemin+'" BORDER=0 NAME=ImageMax onLoad="window.resizeTo(document.ImageMax.width+20, document.ImageMax.height+70)">	</body></html>';
	popupImage = window.open('','_blank','toolbar=0, location=0, directories=0, menuBar=0, scrollbars=0, resizable=1');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close();
}

function Ouvrir_Spplus()
{
	// Largeur et hauteur préconisées de la fenêtre SPPLUS
	var PopupSpplus_largeur	= 750;
	var PopupSpplus_hauteur	= 560;
	
	// Position haut et gauche de la fenêtre SPPLUS pour affichage centré dans l'écran
	var PopupSpplus_top	=((screen.height-PopupSpplus_hauteur)/2);
	var PopupSpplus_left	=((screen.width-PopupSpplus_largeur)/2);
	
	// Ouverture du popup SPLUS avec barre état uniquement et focus sur la fenêtre
	var win = window.open('', "SPPLUS","status=yes,top="+PopupSpplus_top+",left="+PopupSpplus_left+",width="+PopupSpplus_largeur+",height="+PopupSpplus_hauteur);
	win.focus();
}

function Lien() {
	document.getElementById("formulairex").submit();
}

function Lien2() {
	document.getElementById("action").value = "affichage_coordonnees";
	document.getElementById("formulairex").submit();
}

function Lien3() {
	document.getElementById("action").value = "affichage_contact";
	document.getElementById("formulairex").submit();
}

function Ajout()
{
	document.getElementById("ajout").value = 1;
	//window.alert(document.getElementById("ajout").value+document.getElementById("do").value+document.getElementById("action").value);
	document.getElementById("formulairex2").submit();
}

function incrementer(indice)
{
	document.getElementById("idduproduit").value = document.getElementById("id_du_produit["+indice+"]").value;
	document.getElementById("modification_quantite").value = 1;
	document.getElementById("formulairex2").submit();
}

function decrementer(indice)
{
	document.getElementById("idduproduit").value = document.getElementById("id_du_produit["+indice+"]").value;
	document.getElementById("modification_quantite").value = 2;
	document.getElementById("formulairex2").submit();
}

function supprimer(indice)
{
	document.getElementById("idduproduit").value = document.getElementById("id_du_produit["+indice+"]").value;
	document.getElementById("modification_quantite").value = 3;
	document.getElementById("formulairex2").submit();
}

function check(liv_dif)
{
		if (document.getElementById("mot_de_passe").value == "")
		{
			window.alert("Veuillez saisir votre mot de passe");
			exit;
		}

		if (document.getElementById("mot_de_passe_bis").value == "")
		{
			window.alert("Veuillez confirmer votre mot de passe");
			exit;
		}
		else if ((document.getElementById("mot_de_passe_bis").value != "") && (document.getElementById("mot_de_passe_bis").value != document.getElementById("mot_de_passe").value))
		{
			window.alert("Confirmation du mot de passe incorrecte");
			exit;
		}
		if (document.getElementById("nom_facturation").value == "")
		{
			window.alert("Veuillez saisir votre nom de facturation");
			exit;
		}
		if (document.getElementById("prenom_facturation").value == "")
		{
			window.alert("Veuillez saisir votre prenom de facturation");
			exit;
		}
		if (document.getElementById("adresse_facturation").value == "")
		{
			window.alert("Veuillez saisir votre adresse de facturation");
			exit;
		}
		if (document.getElementById("code_postal_facturation").value == "")
		{
			window.alert("Veuillez saisir votre code postal de facturation");
			exit;
		}
		if (document.getElementById("ville_facturation").value == "")
		{
			window.alert("Veuillez saisir votre ville de facturation");
			exit;
		}
		if (document.getElementById("email_facturation").value != "")
		{
			indexAroba = document.getElementById("email_facturation").value.indexOf('@');
			indexPoint = document.getElementById("email_facturation").value.indexOf('.');
			if ((indexAroba < 0) || (indexPoint < 0))
			{
				window.alert("L'adresse mail de facturation est incorrecte");
				exit;
			}
		}
		else
		{
			window.alert("Veuillez saisir votre adresse mail de facturation");
			exit;
		}
		if (document.getElementById("confirmation_email_facturation").value == "")
		{
			window.alert("Veuillez confirmer votre email de facturation");
			exit;
		}
		else if ((document.getElementById("confirmation_email_facturation").value != "") && (document.getElementById("confirmation_email_facturation").value != document.getElementById("email_facturation").value))
		{
			window.alert("Confirmation de l'email de facturation incorrecte");
			exit;
		}
		

		if(liv_dif)
		{
			if (document.getElementById("nom_livraison").value == "")
			{
				window.alert("Veuillez saisir votre nom de livraison");
				exit;
			}
			if (document.getElementById("prenom_livraison").value == "")
			{
				window.alert("Veuillez saisir votre prenom de livraison");
				exit;
			}
			if (document.getElementById("adresse_livraison").value == "")
			{
				window.alert("Veuillez saisir votre adresse de livraison");
				exit;
			}
			if (document.getElementById("code_postal_livraison").value == "")
			{
				window.alert("Veuillez saisir votre code postal de livraison");
				exit;
			}
			if (document.getElementById("ville_livraison").value == "")
			{
				window.alert("Veuillez saisir votre ville de livraison");
				exit;
			}
			/*if (document.getElementById("email_livraison").value != "")
			{
				indexAroba = document.getElementById("email_facturation").value.indexOf('@');
				indexPoint = document.getElementById("email_facturation").value.indexOf('.');
				if ((indexAroba < 0) || (indexPoint < 0))
				{
					window.alert("L'adresse mail de livraison est incorrecte");
					exit;
				}
			}
			else
			{
				window.alert("Veuillez saisir votre adresse mail de livraison");
				exit;
			}*/
		}

		document.getElementById("validation").value = 1;
		document.getElementById("formulaire").submit();

}

function cgvtest(liv_dif)
{			

		if (!document.getElementById("cgv").checked)
		{
			window.alert("Veuillez accepter les conditions générales de vente.");
			exit;
		}
		
		/*if(checkemail(document.getElementById("email_facturation")))
		{
				exit;
		}
		else
		{*/
      check(liv_dif);
		//}

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function OuvrirFenetre(url,nom,details) 
{ 
	window.open(url,nom,details);
}

function validercontact() {
	if (document.getElementById('nom').value=='') { alert("Renseignez le nom !"); return; }
	if (document.getElementById('prenom').value=='') { alert("Renseignez le prénom !"); return; }
	if (document.getElementById('email').value=='') { alert("Renseignez l'email !"); return; }
	if (document.getElementById('confirmation_email').value=='') { alert("Renseignez la confirmation de l'email !"); return; }
	if (document.getElementById('zonetexte').value=='') { alert("Renseignez le message!"); return; }
	document.getElementById('frm').submit();
}

function valider() {
	document.getElementById("validation").value = 1;
	document.getElementById('frm').submit();
}

function adresseDiff() {
	document.getElementById("livraison_differente").value = 1;
	document.forms['formulaire'].action = "coordonnees.php";
	document.getElementById("formulaire").submit();
}

function adresseDiffTris() {
	document.forms['formulaire'].action = "compte.php";
	document.getElementById("formulaire").submit();
}

function adresseDiffBis() {
	document.getElementById("livraison_differente").value = 1;
	document.forms['formulaire'].action = "compte.php";
	document.getElementById("formulaire").submit();
}

function lien(url)
{
	window.open(url);
}

function gethttp()
{
    try { http = new XMLHttpRequest(); }
    catch(e) { try { http = new ActiveXObject("Microsoft.XMLHTTP"); }
    catch (e) { http= false ; }}
    return http;
}

function checkemail(a,b)
{
  if(a.value != '')
  {
	  //window.alert(b.value);
		http=gethttp();
		http.open("POST","/verification_doublon.php/",false);
		http.setRequestHeader("Method","POST /commande/dhtml_update/ HTTP/1.1");
		http.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		http.send("email="+a.value);
		checkitemail(a,b);
		started=0;
	}
}


function checkitemail(a,b)
{	
	etat=http.readyState;
    if (http.status == 200 && etat==4)
    {
        response = http.responseText;
        if (response != "error") 
        {
          window.alert('adresse email déjà enregistrée. Veuillez en saisir une autre.');
          if(response == 'email')
          {
            a.value='';
            b.value='';
          }
          else 
          {
            a.value=response;
            b.value=response;
          }
        }
    }
    //else
    //{
    //  window.alert("ok");
    //}
}
//]]>