$(document).ready( function() {
	
	$('.add-to-cart').click( toCart);
	$('.btcartd').click( function() { removeCart($(this).attr('rel')) });
	
});

function toCart()
{
	var id = $(this).attr('rel');
	$.post( '/order/?ajax=x1', { op:'toCart', id:id }, function(a) { $('#cart').html(a.cart); alert(a.result); }, "json" );
}

function removeCart(id)
{
	if( !confirm('Удалить из корзины')) return false;
	$.post( '/order/?ajax=x1', { op:'removeCart', id:id }, function(a) { location.reload(); } );
}

function fF()
{
	if( $(this).val() == $(this).attr('rel')) $(this).val('');
}

function fB()
{
	if( $(this).val().length == 0) $(this).val($(this).attr('rel'));
}


var pos = new Array(20);
var ss=1;
while (ss<=20)
{
pos[ss]=1;
ss++;
}
function open_img(id, img_id, hi, ps, old)
{
	
	if (pos[ps] == 0)
	{
	
	
	
	$(id)
	.animate( {opacity: "0"}, 0 )
	.animate( {height: hi}, 400 )
	.animate( {opacity: "1"}, 400 );
	document.getElementById(img_id).src='/img/'+img_id+'.jpg';
	
	pos[ps] = 1;
	
	return;
	}

	if (pos[ps] == 1)
	{
	
	$(id)
	.animate( {opacity: "0"}, 0 )
	.animate( {height: old}, 400 )
	.animate( {opacity: "1"}, 400 );
	
	document.getElementById(img_id).src='/img/1pixel.gif';
	pos[ps] = 0;
	return;
	}
	
}


function open_table(id, hi, ps)
{
	
	if (pos[ps] == 0)
	{
	
	
	
	$(id)
	.animate( {opacity: "0"}, 0 )
	.animate( {height: hi}, 400 )
	.animate( {opacity: "1"}, 400 );
	
	
	pos[ps] = 1;
	
	return;
	}

	if (pos[ps] == 1)
	{
	id2 = id.replace(/#/i, '');
	document.getElementById(id2).style.display="none";
	
	pos[ps] = 0;
	return;
	}
	
}
