/* horloge panier */


function incremente_horloge()
{
	if (min==0  && sec==1)
	{

		stop_horloge();
		alert('Votre panier est vide');
		window.location='/panier.php';
	}
	if (sec<=60)
	{
		sec--;
		document.getElementById('secondes').innerHTML=sec;
		//document.temps.sec.value=sec;
		mlsec=59;
	}

	if (sec==0)
	{
		min--;
		document.getElementById('minutes').innerHTML=min;
		//document.temps.min.value=min;
		sec=60;
	}
}

function start_horloge()
{

	if (encours==1)
	{
		clearInterval(interv);
		encours=0;
	}

	else
	{
		interv=setInterval("incremente_horloge()",1000);
		encours=1;
	}

}

function stop_horloge()
{
	clearInterval(interv);
	sec=0;
	min=0;
	heure=0;
	document.getElementById('minutes').innerHTML='0';
	document.getElementById('secondes').innerHTML='0';
	encours=0;
}

function init()
{
	encours=1;
	interv=setInterval("incremente_horloge()",1000);
}

/* fin horloge */

function menu_taille(idproduit,idrows,idcols)
{
	/* tableua des quantites globales max */

	var mysel = document.getElementById('qte'+idrows+'-'+idcols);
	var nouvel_element;
	var compteur=option_quantite[idproduit];
	/* on vide  les quantités précédentes*/
	for (j=mysel.options.length-1;j>=0;j--)		{	mysel.options[j]=null;	}
	/* on rempli si l'iproduit est supérieur à 0*/
	if (option_quantite[idproduit]>0)
	{
		nouvel_element = new Option('Quantité','0');
		mysel.options[mysel.length] = nouvel_element;
		for (compteur=1;compteur<=option_quantite[idproduit];compteur++)
		{
			nouvel_element = new Option(compteur,compteur);
			mysel.options[mysel.length] = nouvel_element;
		}
		mysel.style.visibility='visible';
		mysel.style.display='block';
	}
	/* sinon on cache le menu déroulant*/
	else if (option_quantite[idproduit]<0)
	{
		nouvel_element = new Option('Le maximum a été atteint','-1');
		mysel.options[mysel.length] = nouvel_element;
		mysel.style.visibility='visible';
		mysel.style.display='block';
	}
	else
	{
		mysel.style.visibility='hidden';
		mysel.style.display='non';
	}
}


function Trim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;

}

function change(id,klasse) {
	document.getElementById(id).className = klasse;
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage()
{ //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function cart_updt(nb,debug)
{
	if (nb==1)
	{
		document.getElementById('nb_prod_basket').innerHTML='<table><tr><td valign="bottom" width="30"><img src="/images/haut/panier/panier.gif" border="0"></td><td valign="bottom" nowrap><a href="/panier.php" style="font-family:arial;font-weight:bold;font-size:11px;color:#4d84ba;">Vous avez '+nb+' produit dans votre panier</a></td></tr></table>';
	}
	else if (nb>1)
	{
		document.getElementById('nb_prod_basket').innerHTML='<table><tr><td valign="bottom"  width="30"><img src="/images/haut/panier/panier.gif" border="0"></td><td valign="bottom" nowrap><a href="/panier.php" style="font-family:arial;font-weight:bold;font-size:11px;color:#4d84ba;">Vous avez '+nb+' produits dans votre panier</a></td></tr></table>';
	}
	else if (nb==0)
	{
		document.getElementById('nb_prod_basket').innerHTML='<table><tr><td valign="bottom"  width="30"><img src="/images/haut/panier/panier_vide.gif" border="0"></td><td valign="bottom" nowrap style="font-family:arial;font-weight:bold;font-size:11px;color:#4d84ba;">Votre panier est vide</td></tr></table>';

	}

	if (debug==1)
	{
		alert('Quantité supplémentaire indisponible');
	}
}
/* fonction qui cache le div ajout au panier*/
function div_del()
{
	document.getElementById('confirmation_ajout').innerHTML='';
	document.getElementById('confirmation_ajout').style.visibility='hidden';
	document.getElementById('confirmation_ajout').style.display='none';
	//window.location=document.location;
}
/* fonction qui confirme ajout au panier et propose de continuer visite ou aller panier */
function confirmation_ajout(idproduit,quantite,idproduit_group,idrows)
{
	if (document.getElementById('confirmation_ajout'))
	{
		document.getElementById('confirmation_ajout').style.visibility='visible';
		document.getElementById('confirmation_ajout').style.display='block';
		position=(window.screen.availWidth)/2;
		var  c = getAnchorPosition('imageetiquet-'+idproduit_group+'-'+idrows);
		document.getElementById('confirmation_ajout').style.left = eval(position-150)+'px';
		document.getElementById('confirmation_ajout').style.top = eval(c.y+150)+'px';
		document.getElementById('confirmation_ajout').innerHTML='<table width="300" height="170 " border="0" cellpadding="0" cellspacing="0" background="/images/produit/ajout-panier.gif" style="background-repeat:no-repeat"><tr>   <td width="103" height="21">&nbsp;</td><td width="179">&nbsp;</td><td width="18">&nbsp;</td></tr><tr><td height="116">&nbsp;</td><td class="navpetit">Le produit a bien &eacute;t&eacute; ajout&eacute; &agrave; votre panier<br /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr>  <td align="right"><A onclick="div_del(\'confirmation_ajout\');"><img src="/images/produit/continuer.gif" width="144" height="20" border="0"/></a></td></tr>  <tr><td align="right"><a href="panier.php"><img src="/images/produit/valid_commande.gif" width="144" height="20" border="0"/></a></td></tr></table></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>';
		//document.getElementById('confirmation_ajout-'+idproduit_group+'-'+idrows).innerHTML='okokokok';
	}
}

/*fonction qui affiche que la quantite max achetable est depassee */
function max_confirmation_ajout(idproduit,quantite,idproduit_group,idrows)
{
	if (document.getElementById('confirmation_ajout'))
	{
		document.getElementById('confirmation_ajout').style.visibility='visible';
		document.getElementById('confirmation_ajout').style.display='block';
		position=(window.screen.availWidth)/2;;
		var  c = getAnchorPosition('imageetiquet-'+idproduit_group+'-'+idrows);
		document.getElementById('confirmation_ajout').style.left = eval(position-150)+'px';
		document.getElementById('confirmation_ajout').style.top = eval(c.y+150)+'px';
		document.getElementById('confirmation_ajout').innerHTML='<table width="300" height="170 " border="0" cellpadding="0" cellspacing="0" background="/images/produit/ajout-panier.gif" style="background-repeat:no-repeat"><tr>   <td width="103" height="21">&nbsp;</td><td width="179">&nbsp;</td><td width="18">&nbsp;</td></tr><tr><td height="116">&nbsp;</td><td class="navpetit"><font color="red"><b>Vous avez d&eacute;pass&eacute; la quantit&eacute; limite pour ce produit<br>Vous ne pouvez plus ajouter ce produit &agrave; votre panier</b></font><br /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr>  <td align="right"><A onclick="div_del(\'confirmation_ajout\');"><img src="/images/produit/continuer.gif" width="144" height="20" border="0"/></a></td></tr><tr><td align="right"><a href="panier.php"><img src="/images/produit/valid_commande.gif" width="144" height="20" border="0"/></a></td></tr></table></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>';
	}
}

/*fcontion qui dit attention plus de produit */
function non_confirmation_ajout(idproduit,quantite,idproduit_group,idrows)
{
	if (document.getElementById('confirmation_ajout'))
	{
		document.getElementById('confirmation_ajout').style.visibility='visible';
		document.getElementById('confirmation_ajout').style.display='block';
		position=(window.screen.availWidth)/2;;
		var  c = getAnchorPosition('imageetiquet-'+idproduit_group+'-'+idrows);
		document.getElementById('confirmation_ajout').style.left = eval(position-150)+'px';
		document.getElementById('confirmation_ajout').style.top = eval(c.y+150)+'px';
		document.getElementById('confirmation_ajout').innerHTML='<table width="300" height="170 " border="0" cellpadding="0" cellspacing="0" background="/images/produit/ajout-panier.gif" style="background-repeat:no-repeat"><tr>   <td width="103" height="21">&nbsp;</td><td width="179">&nbsp;</td><td width="18">&nbsp;</td></tr><tr><td height="116">&nbsp;</td><td class="navpetit"><font color="red"><b>Ce produit est d&eacute;j&agrave &eacute;puise vous ne pouvez pas l\'ajouter &agrave; votre panier</b></font><br /> <table width="100%" border="0" cellpadding="2" cellspacing="2"> <tr>  <td align="right"><A onclick="div_del(\'confirmation_ajout\');"><img src="/images/produit/continuer.gif" width="144" height="20" border="0"/></a></td></tr><tr><td align="right"><a href="panier.php"><img src="/images/produit/valid_commande.gif" width="144" height="20" border="0"/></a></td></tr></table></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>';
	}
}
/* met en rupture le fond */
/*
   function rupture(idproduit_group,idrows)
   {

   if (document.getElementById('imageetiquet-'+idproduit_group+'-'+idrows))
   {
   document.getElementById('imageetiquet-'+idproduit_group+'-'+idrows).src="images/produit/haut_etiquette_rupt.jpg";
   }
   }*/

/* fonction qui ajouter le produit au panier */
/**
 *
 * @access public
 * @return void
 **/


function fetch_unix_timestamp() {
	minn=0;
	max=100000000000;
    // http://kevin.vanzonneveld.net
    // +   original by: Leslie Hoare
    // *     example 1: rand(1, 1);
    // *     returns 1: 1
 
    if( max ) {
		
        return Math.floor(Math.random() * (max - minn + 1)) + minn;
    } else {
			
        return Math.floor(Math.random() * (minn + 1));
		
    }
}

function cart_add(idproduit,qte,panier,idproduit_group,idrows)
{




	   if (idproduit>0)
	   {
	   var div = document.getElementById('container');

	   var handleSuccess = function(o)
	   {
	   if(o.responseText !== undefined)
	   {


	   var result='';
	   result=o.responseText;
	   var result_array=result.split('\n');
	   var i=0;
	   while (result_array[i].length>0)
	   {
		   var ligne_split=result_array[i].split('~');
		   if (ligne_split[0]=='TOTAL')
		   {
		   cart_updt(ligne_split[1],'');
		   }
		   if (ligne_split[0]=='AJOUTOK')
		   {
		   confirmation_ajout(ligne_split[1],ligne_split[2],idproduit_group,idrows);
		   }
		   if (ligne_split[0]=='MAX')
		   {
		   max_confirmation_ajout(ligne_split[1],ligne_split[2],idproduit_group,idrows);
		   }
		   if (ligne_split[0]=='ERREUR')
		   {
		   non_confirmation_ajout(ligne_split[1],ligne_split[2],idproduit_group,idrows);
		   }
		   if (panier==1)
		   {
			   if (ligne_split[0]=='LIGNE')
			   {
				   cart_display(ligne_split[1],ligne_split[2],ligne_split[3],ligne_split[4],ligne_split[5],ligne_split[6],ligne_split[7],ligne_split[8],ligne_split[9],ligne_split[10],ligne_split[11],ligne_split[12],ligne_split[13],ligne_split[14],ligne_split[15],ligne_split[16],ligne_split[17]);
			   }
			   if (ligne_split[0]=='FIN')
			   {
				   cart_display_final(ligne_split[1],ligne_split[2],ligne_split[3],ligne_split[4],ligne_split[5])
			   }
			   if (ligne_split[0]=='DATE_EXP')
			   {
				   document.getElementById('date_exp').innerHTML='<b>'+ligne_split[1]+'</b>';
			   }

		   }




		   i++;
	   }
	   }
	   }
	   var handleFailure = function(o)
	   {
		   if(o.responseText !== undefined)
		   {
		   }
	   }

	   if (qte<=0)
	   {
		   qte=1;
	   }
	   var callback =
	   {
success:handleSuccess,
	failure: handleFailure,
	argument: { idproduit:"idprod", quantite:"qte" }
	   };
	   var sUrl = 'ajax/basket.php?idprod='+idproduit+'&mode=add&quantite='+qte+'&time='+fetch_unix_timestamp()+'';
	   var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);

	   }

	   if (panier==1)
	   {
		//   cart_voir();
		   //setTimeout("window.location='panier.php'",100);
		   //window.location='panier.php';
	   }
}

/* fonction qui supprime un produit du panier */
function cart_del(idproduit,qte,panier)
{

	panier=1;
	if (idproduit>0)
	{
		var div = document.getElementById('container');

		var handleSuccess = function(o)
		{
			if(o.responseText !== undefined)
			{

				var result;
				result=o.responseText;
				var result_array=result.split('\n');
				var i=0;
				while (result_array[i].length>0)
				{
					var ligne_split=result_array[i].split('~');


						if ( idproduit==ligne_split[1] )
						{
						/*
							alert(ligne_split[9])dd;
							document.getElementById('show_cart_nom'+ligne_split[1]).innerHTML=' ';
							document.getElementById('show_cart_img'+ligne_split[1]).innerHTML=' ';
							document.getElementById('show_cart_qte'+ligne_split[1]).innerHTML=' ';
							document.getElementById('show_cart_del'+ligne_split[1]).innerHTML=' ';
							document.getElementById('show_cart_tot'+ligne_split[1]).innerHTML=' ';

					*/
					}


						if (ligne_split[0]=='LIGNE')
						{
							cart_display(ligne_split[1],ligne_split[2],ligne_split[3],ligne_split[4],ligne_split[5],ligne_split[6],ligne_split[7],ligne_split[8],ligne_split[9],ligne_split[10],ligne_split[11],ligne_split[12],ligne_split[13],ligne_split[14],ligne_split[15],ligne_split[16],ligne_split[17]);
						}
						if (ligne_split[0]=='FIN')
						{
							cart_display_final(ligne_split[1],ligne_split[2],ligne_split[3],ligne_split[4],ligne_split[5])
						}
						if (ligne_split[0]=='DATE_EXP')
						{

							document.getElementById('date_exp').innerHTML='<b>'+ligne_split[1]+'</b>';
						}

						//if (ligne_split[9]-qte<0 && ligne_split[0]=='LIGNE' &&  idproduit==ligne_split[1])
						{
						window.location='panier.php';
						}





					i++;
				}
			}
		}
		var handleFailure = function(o)
		{
			if(o.responseText !== undefined)
			{
			}
		}

		if (qte<=0)
		{
			qte=1;
		}
		var callback =
		{
success:handleSuccess,
	failure: handleFailure,
	argument: { idproduit:"idprod", quantite:"qte" }
		};
		var sUrl = 'ajax/basket.php?idprod='+idproduit+'&mode=del&quantite='+qte+'&time='+fetch_unix_timestamp()+'';
		var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);

	}
	//cart_voir();
	//	window.location='panier.php';
}
function cart_expiration(minute,time)
{





	if (time>1)
	{
		document.getElementById('expiration').innerHTML=', il expire dans '+minute+' minutes '+time+' secondes';
	}
	if (time==1)
	{
		document.getElementById('expiration').innerHTML=', il expire dans '+minute+' minute '+time+' secondes';
	}
}




/* visualisation du panier dans son intégralité dans panier.php*/
function cart_voir(type)
{



	var div = document.getElementById('container');

	var handleSuccess = function(o){
		if(o.responseText !== undefined){


			var result;
			result=o.responseText;
			var result_array=result.split('\n');
			var i=0;
			while (result_array[i].length>0)
			{
				var ligne_split=result_array[i].split('~');
				var ligne_split=result_array[i].split('~');
				if (ligne_split[0]=='BONDHA' && ligne_split[1]>0 )
				{
					document.getElementById('bon_d_ha').innerHTML='<b>'+ligne_split[1]+'&euro;</b>';
					document.getElementById('bon_d_ha_reduction').innerHTML='Réduction de : ';
				}
				else if (ligne_split[0]=='BONDHA')
				{
					document.getElementById('bon_d_ha').innerHTML='';
					document.getElementById('bon_d_ha_reduction').innerHTML='';
				}
				if (ligne_split[0]=='TOTAL')
				{
					cart_updt(ligne_split[1],'');
				}

				if (ligne_split[0]=='EXPIRATION')
				{
					//	cart_expiration(ligne_split[1],ligne_split[2]);
				}

				if (ligne_split[0]=='TYPEENVOI')
				{
					if (ligne_split[1]==1)
					{
						if (document.getElementById('coursier'))
						{
							document.getElementById('coursier').innerHTML=' <input type="radio" value="1" name="coursier" onclick="cart_voir(1)" checked >';
						}
					}
					else if (ligne_split[1]==2)
					{
						if (document.getElementById('colissimo'))
						{
							document.getElementById('colissimo').innerHTML=' <input type="radio" value="2" name="coursier" onclick="cart_voir(2)" checked >';
						}
					}
				}
				if (ligne_split[0]=='LIGNE')
				{
					cart_display(ligne_split[1],ligne_split[2],ligne_split[3],ligne_split[4],ligne_split[5],ligne_split[6],ligne_split[7],ligne_split[8],ligne_split[9],ligne_split[10],ligne_split[11],ligne_split[12],ligne_split[13],ligne_split[14],ligne_split[15],ligne_split[16],ligne_split[17]);
				}
				if (ligne_split[0]=='FIN')
				{
					cart_display_final(ligne_split[1],ligne_split[2],ligne_split[3],ligne_split[4],ligne_split[5])
				}
				if (ligne_split[0]=='DATE_EXP')
				{
					document.getElementById('date_exp').innerHTML='<b>'+ligne_split[1]+'</b>';
				}
				i++;
			}
		}
	}
	var handleFailure = function(o)
	{
		if(o.responseText !== undefined)
		{
		}
	}


	var callback =
	{
success:handleSuccess,
	failure: handleFailure,
	argument: { idproduit:"idprod", quantite:"qte" }
	};
	var sUrl = 'ajax/basket.php?time='+fetch_unix_timestamp()+'';
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);




}

/* fonction qui affiche les produit en html*/
function  cart_display(id,type,marque,nom,nomcols,cols,nomrows,rows,quantit,prix,poids,fragile,grand,reste,remise,remise_texte)
{

	if (quantit>0)
	{


		/* mlle */
		var txt_mlle;
		if (remise>0)
		{
			txt_mlle=remise_texte;
		}
		else
		{
			txt_mlle='';
		}

		document.getElementById('show_cart_nom'+id).innerHTML=''+type+' '+marque+' '+nom+' '+nomrows+' '+rows+'<br><small><i> - '+nomcols+' '+cols+'</i></small><br><b><font color="red">'+txt_mlle+'</font></b>';


		if (reste>0)
		{
			document.getElementById('show_cart_qte'+id).innerHTML='<table align=center width=100 ><tr><td  style="vertical-align:middle;font-family:arial;font-size:11px;font-weight:bold;padding-left:5px;padding-right:5px;background-color:#E6E6E6;" align="right" width=30>'+quantit+'</td><td><table><tr><td  align="left"  style="vertical-align:middle;font-family:arial;font-size:11px;font-weight:bold;padding-left:5px;padding-right:5px;background-color:#E6E6E6;" height="15"><input type="button" value="+" style="width:30px;"  onClick=\"cart_add('+id+',1,1);\" ></td></tr><tr><td align="left"  style="vertical-align:middle;text-align:center;font-family:arial;font-size:11px;font-weight:bold;padding-left:5px;padding-right:5px;background-color:#E6E6E6;"  height="15"><input name="button2" type="button" style="width:30px;" onClick=\"cart_del('+id+',1,1);\" value="-"></td></tr></table></td></tr></table>';
		}
		else
		{
			document.getElementById('show_cart_qte'+id).innerHTML='<table align=center width=100 ><tr><td  style="vertical-align:middle;font-family:arial;font-size:11px;font-weight:bold;padding-left:5px;padding-right:5px;background-color:#E6E6E6;" align="right" width=30>'+quantit+'</td><td><table><tr><td  align="left"  style="vertical-align:middle;font-family:arial;font-size:11px;font-weight:bold;padding-left:5px;padding-right:5px;background-color:#E6E6E6;" height="15"><input type="button" value="+" style="width:30px;;visibility:hidden"  onClick=\"cart_add('+id+',1,1);\"  ></td></tr><tr><td align="left"  style="vertical-align:middle;text-align:center;font-family:arial;font-size:11px;font-weight:bold;padding-left:5px;padding-right:5px;background-color:#E6E6E6;"  height="15"><input name="button2" type="button" style="width:30px;" onClick=\"cart_del('+id+',1,1);\" value="-"></td></tr></table></td></tr></table>';
		}




		if (remise>0)
		{
			var new_prix=prix-remise;
			document.getElementById('show_cart_tot'+id).innerHTML='Prix remisé: '+new_prix+'&euro;<br><font size="1">Ancien prix:&nbsp;'+prix+'&euro;</font>';
		}

		else
		{
			document.getElementById('show_cart_tot'+id).innerHTML=''+prix+'&euro;';
		}
		document.getElementById('show_cart_del'+id).innerHTML='<span style="vertical-align:middle;text-align:center;font-family:arial;font-size:11px;font-weight:bold;padding-left:5px;padding-right:5px;background-color:#E6E6E6;"><input name="button22" type="button" style="width:30px;" onClick=\"cart_del('+id+','+quantit+',1);\";" value="-"></span>';
	}
}
/*fonction qui calcule le prix final */
function cart_display_final(total_sub,total_weight,price_shipping,total,total_colissimo)
{
	if (total_sub>0)
	{
		document.getElementById('show_cart_sub_total').innerHTML=''+total_sub+'';
		document.getElementById('show_cart_total_shipping').innerHTML=''+price_shipping+'';
		<!--document.getElementById('show_cart_total_shipping_2').innerHTML=''+total_colissimo+'';-->
			document.getElementById('show_cart_total').innerHTML=''+total+'';
	}
	else if (total_sub==0)
	{
		document.getElementById('cacher_panier').innerHTML='';
		<!--document.getElementById('paiement_cb').innerHTML='';-->
			document.getElementById('cacher_contenu').innerHTML='<table width="100%"><tr><td colspan=2><br><b>Votre panier est vide </b></td>  </tr><tr><td colspan=2 align=right><input type="button" border="0" value="Retour à la liste des ventes" onClick="javascript:document.location.href=\'index.php\';" style="background-color:#F5F0E3;font-family:arial;font-size:11px;width:150px;"></td></tr></table>';
	}
}
/* fonction qui update les BON d'achat */
function ticket_fonction_nb(selectf)
{
	var BA=selectf.options[selectf.selectedIndex].value;
	/*

	   AjaxRequest.get(
	   {
	   'url':'ajax/basket.php'
	   ,'parameters':{ 'idprod':'' }
	   ,'BA':''+BA+''
	   ,'majticket':'ok'
	   ,'onSuccess':function(req)
	   {
	   var result;
	   result=req.responseText;
	   var result_array=result.split('\n');
	   var i=0;
	   cart_voir();
	   }
	   });*/

	var handleSuccess = function(o)
	{
		if(o.responseText !== undefined)
		{

			var result;
			result=o.responseText;

			var result_array=result.split('\n');
			var i=0;
			cart_voir();

		}
	}
	var handleFailure = function(o)
	{
		if(o.responseText !== undefined)
		{

		}
	}


	var callback =
	{
success:handleSuccess,
	failure: handleFailure,
	argument: { idproduit:"idprod", quantite:"qte" }
	};
	var sUrl = 'ajax/basket.php?BA='+BA+'&time='+fetch_unix_timestamp()+'';
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);

}
/* code postal */
function code_postal()
{
	var cp=document.getElementById('codepostal').value;
	var pays=document.getElementById('pays').value;
	if ((cp.length>=5 && pays==1) || (cp.length>=4 && pays==2))
	{
		var handleSuccess = function(o)
		{
			if(o.responseText !== undefined)
			{

				var result;
				result=o.responseText;
				var result_array=result.split('\n');
				var i=0;
				var j=0;
				var content_html;
				var longeur_menu=document.ajout.cp.length;
				for (j=document.forms['ajout'].cp.options.length-1;j>=0;j--)
				{
					document.forms['ajout'].cp.options[j]=null;
				}
				for (i=0;  i<=result_array[i].length-1;i++)
				{
					var ligne_split=result_array[i].split('~');
					if (ligne_split[0]=='VILLE')
					{
						var nouvel_element;
						nouvel_element = new Option(ligne_split[1],ligne_split[1],false,false);
						document.ajout.cp.options[document.ajout.cp.length] = nouvel_element;
						var test_ville=1;
					}
				}
				if (test_ville!=1)
				{
					document.getElementById('ville_connue').innerHTML='Code postal inconnu merci de remplir la ville';
					noticediv=document.getElementById('select_ville');
					noticediv2=document.getElementById('input_ville');
					noticediv.style.visibility='hidden';
					noticediv.style.display='none';
					noticediv2.style.visibility='visible';
					noticediv2.style.display='block';
				}
				else
				{
					var nouvel_element2;
					nouvel_element2 = new Option('Autres...','-10',false,false);
					document.ajout.cp.options[document.ajout.cp.length] = nouvel_element2;
					document.getElementById('ville_connue').innerHTML='';
					noticediv2=document.getElementById('input_ville');
					noticediv=document.getElementById('select_ville');
					noticediv.style.visibility='visible';
					noticediv.style.display='block';
					noticediv2.style.visibility='hidden';
					noticediv2.style.display='none';
				}
			}
		}
		var handleFailure = function(o)
		{
			if(o.responseText !== undefined)
			{
			}
		}


		var callback =
		{
success:handleSuccess,
	failure: handleFailure,
	argument: { idproduit:"idprod", quantite:"qte" }
		};
		var sUrl = 'ajax/cp.php?cp='+cp+'&pays='+pays+'&time='+fetch_unix_timestamp()+'';
		var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
	}

}
/* fcontion qui affiche le code postal */
function affiche_cp(sel)
{
	var value_cp=sel.options[sel.selectedIndex].value;
	if (value_cp=='-10')
	{
		document.getElementById('ville_connue').innerHTML='Merci de remplir votre ville';
		noticediv2.style.visibility='visible';
		noticediv2.style.display='block';
	}
	else
	{
		document.getElementById('ville_connue').innerHTML='';
		noticediv2.style.visibility='hidden';
		noticediv2.style.display='none';
	}

}
/* fonction pour swapper le descriptif et prix dans détail produit */
function descriptif_detail(id)
{
	var idproduit=id.options[id.selectedIndex].value;
	var div_desc= document.getElementById('descriptif-'+idproduit) ;
	var prix_desc= document.getElementById('prix_produit-'+idproduit);
	if (document.getElementById('prix_public-'+idproduit)!=undefined)
	{
		var prix_public= document.getElementById('prix_public-'+idproduit);
	}
	var prix_mlle= document.getElementById('prix-mlle-'+idproduit);


	if(document.getElementById('apartir') && idproduit>0)
	{
		document.getElementById('apartir').innerHTML='<br>';
	}
	else if(document.getElementById('apartir'))
	{
		document.getElementById('apartir').innerHTML='à partir de:';
	}




	if (document.getElementById('prix-mlle-'+idproduit))
	{
		if (document.getElementById('prix_mlle'))
		{
			document.getElementById('prix_mlle').innerHTML=prix_mlle.innerHTML;
		}

	}


	if (document.getElementById('descriptif-'+idproduit) && document.getElementById('prix_produit-'+idproduit))
	{
		document.getElementById('descriptif').innerHTML=div_desc.innerHTML;
		document.getElementById('prix_produit').innerHTML=prix_desc.innerHTML;
		if (document.getElementById('prix_public')!=undefined)
		{
			document.getElementById('prix_public').innerHTML=prix_public.innerHTML;

		}


	}
}
/* fonction qui swappe le prix produit dans un listing */
function listing_prix(id,idproduit,idproduit_group,idrows)
{
	var idproduit=id.options[id.selectedIndex].value;
	var idproduit=id.options[id.selectedIndex].value;
	var prix_desc= document.getElementById('prix_produit-'+idproduit);
	if ( document.getElementById('prix_public-'+idproduit)!=undefined)
	{
		var prix_public= document.getElementById('prix_public-'+idproduit);
	}
	var prix_mlle= document.getElementById('prix-mlle-'+idproduit);

	if(document.getElementById('apartir-'+idproduit_group+'-'+idrows))
	{
		document.getElementById('apartir-'+idproduit_group+'-'+idrows).innerHTML='<br>';
	}
	if(document.getElementById('prix_mlle-'+idproduit_group+'-'+idrows))
	{
		document.getElementById('prix_mlle-'+idproduit_group+'-'+idrows).innerHTML=prix_mlle.innerHTML;
	}




	var idsplit=idproduit.split('-');
	/*raz*/
	/*
	   if (document.getElementById('prix_public-'+idproduit)!=undefined && document.getElementById('prix_produit-'+idproduit)!=undefined && idsplit[0]>0 && idsplit[1]>0 )
	   {
	//		document.getElementById('prix_produit-'+idproduit_group+'-'+idrows).innerHTML= document.getElementById('prix_produit-'+idproduit+'-0').innerHTML;
	//		document.getElementById('prix_public-'+idproduit_group+'-'+idrows).innerHTML= document.getElementById('prix_public-'+idproduit+'-0').innerHTML;
	//		document.getElementById('apartir-'+idproduit_group+'-'+idrows).innerHTML=document.getElementById('apartir-'+idproduit+'-0').innerHTML;
	}
	if (document.getElementById('prix_public-'+idproduit_group+'-'+idrows)!=undefined )
	{
	document.getElementById('prix_public-'+idproduit_group+'-'+idrows).innerHTML=prix_public.innerHTML;
	}
	if ( document.getElementById('prix_produit-'+idproduit_group+'-'+idrows)!=undefined)
	{
	//		  document.getElementById('prix_produit-'+idproduit_group+'-'+idrows).innerHTML=prix_desc.innerHTML;
	}
	 */
}
/* fonction pour le zoom des produit */
var CpathIMG;
function zoomIMG(pathIMG)
{
	CpathIMG=pathIMG;
	document.getElementById('zoom').src = "http://images2.bazarchic.com/i/2/"+pathIMG+".jpg";
	var test=1;
}
function popUpZoom()
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('http://images2.bazarchic.com/i/1/'+CpathIMG+'.jpg', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600,left = 750,top = 550');");
}
function popUp(URL)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=500,left = 750,top = 550');");
}
function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}


