

// Modification fiche produit 
function change_opt(id)
{
	// Price 
	$('.loadgif').show(); 
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "v="+id+"&type=price",
		async:false,
		success: function (msg){
			$('.loadgif').hide();
			$('#price_tarif').html(msg);
		}
	});
	
	// photo
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "v="+id+"&type=photo",
		async:false,
		success: function (msg){
			$('.loadgif').hide();
			$('#pic_photo').html(msg);
			jQuery(".imgzoom").jqzoom({ zoomWidth: 316, zoomHeight: 440 });
		}
	});
	
	// vignettes
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "v="+id+"&type=vign",
		async:false,
		success: function (msg){
			$('.loadgif').hide();
			$('#blk_vgn').html(msg);
		}
	});
		
	// option
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "v="+id+"&type=opt",
		async:false,
		success: function (msg){
			$('.loadgif').hide();
			$('#opt_id').html(msg);
		}
	});
	
	//taille
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "v="+id+"&type=size",
		async:false,
		success: function (msg){
			$('#opt_size').html(msg);
		}
	});
}


function change_opt_pic(id)
{
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "pic="+id,
		async:false,
		success: function (fct){
			$('.loadgif').hide();
			$('#pic_photo').html(fct);
			jQuery(".imgzoom").jqzoom({ zoomWidth: 316, zoomHeight: 440 });
		}
	});
}

function addPromo()
{
	pin = document.getElementById('promocode').value;
	//alert(pin);
	
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "promo="+pin,
		async:false,
		success: function (fct){
			$('.loadgif').hide();
			$('#pxprm').html(fct);
		}
	});
	
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "promodiv="+pin,
		async:false,
		success: function (fct){
			$('.loadgif').hide();
			$('#promodiv').html(fct);
		}
	});
	
}


function getShipping(pst)
{	
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "pst="+pst,
		async:false,
		success: function (fct){
			$('.loadgif').hide();
			$('#cellspace').html(fct);
		}
	});
	
	//document.getElementById('error_post').style.diplay = "none";
}

// add product to cart
function add_product()
{
	var o = document.forms['form_article'].elements['opt_id'].value;
	var s = document.forms['form_article'].elements['opt_size'].value;
	var q = document.forms['form_article'].elements['opt_qte'].value;
	
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "cmd=d"+"&opt="+o+"&size="+s+"&qte="+q,
		async:false,
		success: function (fct){
			$('.loadgif').hide();
			$('#cart_prd').html(fct);
		}
	});
	
	$.ajax({
		type :"POST", url:"/ajax.php", data : "cmd=t", async:false,
		success: function (fct){ $('#nb_article').html(fct); }
	});
	
	return false;
}


// add product to cart
function modify_qty(opt, siz)
{
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "updt="+opt+"&id="+siz,
		async:false,
		success: function (fct){
			$('.loadgif').hide();
			$('#cart_').html(fct);
				// alert(fct);
				if (fct <= 1)
				{
					document.getElementById('tr_'+siz).style.display = 'none';
				}
				
				$.ajax({
					type :"POST", url:"/ajax.php", data : "updt=px&id="+siz+"&bn="+opt, async:false,
					success: function (fct){ $('#pxqty_'+siz).html(fct); }
				});
				
				$.ajax({
					type :"POST", url:"/ajax.php", data : "updt=ipt&id="+siz, async:false,
					success: function (fct){ $('#qty_'+siz).html(fct); }
				});
				
				$.ajax({
					type :"POST", url:"/ajax.php", data : "updt=ht", async:false,
					success: function (fct){
						$('#pxht').html(fct);
						$('#promprix').html(fct);
					}
				});
				
				$.ajax({
					type :"POST", url:"/ajax.php", data : "cmd=t", async:false,
					success: function (fct){ $('#nb_article').html(fct); }
				});
		}
	});
}

// add product to cart
function del_prd(opt)
{
	$.ajax({
		type :"POST", url:"/ajax.php",
		data : "del="+opt,
		async:false,
		success: function (fct){
			$('.loadgif').hide();
			$('#cart_prd').html(fct);
			
			$.ajax({
				type :"POST", url:"/ajax.php", data : "updt=ht", async:false,
				success: function (fct){ $('#pxht').html(fct); }
			});
			
			$.ajax({
				type :"POST", url:"/ajax.php", data : "cmd=t", async:false,
				success: function (fct){ $('#nb_article').html(fct); }
			});
			
			document.getElementById('tr_'+opt).style.display = 'none';
		}
	});
		
	return false;
}

function affliv()
{
	var com = document.getElementById('shipping_blk');
	if(com.style.display == "block")
	{
		com.style.display = "none";
	}
	else
	{
		com.style.display = "block";
	}
}

function closeblock(id)
{
	document.getElementById(id).style.display = 'none';
}



function condition_vt(val)
{
	var com = document.getElementById('vt');
	if (com.checked == false )
	{
		alert(val); 
		return false;
	}
}

