$(document).ready(function () {
	Shadowbox.init();
	
	if ($('#cart').get(0)) {
		$('tr.updatebtn').css('display','none');
	}
	
	
	$('.cycle').each(function(i) {
		var imagenes = $('img',this);
		$(this).empty();
		$(this).append(imagenes);
		if ($('.pagina-carta').get(0)) {
			$(this).css('height', '192px');
		}
	});
	$('.cycle').cycle();
	
});

function remove_item(id) {
	document.getElementById('updates_'+id).value = 0;
	document.getElementById('cart').submit();
}

var totalLinea = 0;
function updateItem(id, price)
{
	tmp = $('#item-' + id + ' .line_price').html();
	partes = tmp.split(' ');
	if (partes.length < 2)
		partes = tmp.split('&nbsp;');
	
	priceformat = $('#item-' + id + ' .price').html()
	escoma = (priceformat.indexOf(',') > 0);
	
	total = (parseInt($('#updates_' + id).val()) * price);
	if (total != NaN)
	{
		totalstr = total.toFixed(2) + ' ' + partes[1];
		if (escoma){
			totalstr = totalstr.replace(".",',');
		}
		
		$('#item-' + id + ' .line_price').attr('title', total);
		$('#item-' + id + ' .line_price').html(totalstr);
		
		totalLinea = 0;
		$('#cart .line_price').each (function() {
			totalLinea += parseFloat($(this).attr('title'));
		});
		totalstr = totalLinea.toFixed(2) + ' ' + partes[1];
		if (escoma){
			totalstr = totalstr.replace(".",',');
		}
		$('#cart td.subtotal').html(totalstr);
		
		var fm = $('form#cart');
		$.ajax({
			   type: "POST",
			   url: fm.action,
			   data: fm.serialize(),
			   dataType: 'html',
			   success: function(msg){
				   				   }			 
			});
	}
	
}


function mejorsinspam(usuario,dominio) 
{
	var cadena = "mailto:" + usuario + "@" + dominio;
	window.location = cadena;
}
function mostrar_email (usuario,dominio)
{
		var obj = document.getElementById('email');
		if (obj && obj.innerHTML)
			obj.innerHTML = usuario + '@' + dominio;
}
