function loadingOn()
{
	$(".loading").fadeIn();
}

function loadingOff()
{
	$(".loading").fadeOut();
}

function updateQ(linia,producto,acabado,talla)
{
	loadingOn();
	$.ajax({
		type: "POST",
		url: "/en/shopping-cart/update-product",
		data: "producto="+producto+"&acabado="+acabado+"&talla="+talla+"&unidades="+$("#unidades"+linia).val(),
		success: function(total){
			$("#shopping-cart-line"+linia+" .total-linia").html(total);
			updateTotales();
			loadingOff();
		}
	});
}

function updateTotales()
{
	$.ajax({
		type: "POST",
		url: "/en/sistema/get-totales",
		data: "nodata=true",
		success: function(info){
			aux=info.split("@");
			$("#header-totales-unidades").html(aux[0]);			
			$("#header-totales-precio").html(aux[1]);			
			$("#total-cesta-precio").html(aux[1]);			
			$("#gastos-envio-estimados-precio").html(aux[2]);			
		}
	});
}

function deleteProduct(linia,producto,acabado,talla)
{
	loadingOn();
	$.ajax({
		type: "POST",
		url: "/en/shopping-cart/del-product",
		data: "producto="+producto+"&acabado="+acabado+"&talla="+talla,
		success: function(product_count){
			if(product_count==0)
			{
				document.location=document.location;
			}
			updateTotales();
			loadingOff();
		}
	});

	$('#shopping-cart-line'+linia).fadeOut("slow");
}

function useInvoiceData()
{
	if($("#usar_datos_facturacion").is(":checked")) 
	{
		$("#datos_envio_container").hide();
	}
	else
	{
		$("#datos_envio_container").fadeIn("slow");
	}
}

function changeUserMode()
{
	if($("#new_user1").is(":checked")) 
	{
		$("#cuenta_usuario_bloque").fadeIn("slow");
		$("#full_data_bloque").fadeIn("slow");
		$("#login_bloque").hide();
		$("#mode").val("register");
	}
	else
	{
		$("#login_bloque").fadeIn("slow");
		$("#cuenta_usuario_bloque").hide();
		$("#full_data_bloque").hide();
		$("#mode").val("login");
	}
}
