$(document).ready(function()
{
	$("a.evEshop").click(function()
	{
		id = parseInt($(this).attr("href").substr(1));
		if (!isNaN(id))
		{
			$(this).attr("alt", "selected");
			$("#eshop").load("updatebasket.php?item=" + id, null, pointToAction);
			$("#eshop_bg").animate({opacity: 1.0}, 100 );
			$("#eshop_bg").animate({opacity: 0.4}, 100 );
			$("#eshop_bg").animate({opacity: 1.0}, 100 );
			$("#eshop_bg").animate({opacity: 0.4}, 100 );
			$(this).blur();
			$(this).hide(600);
			return false;
		}
	});

	$("a.evEshop")
	.filter(function ()
	{
		return $(this).attr("alt") == "selected";
	})
	.each(function()
	{
		$(this).hide(800);
	});
	
	$("#eshop").hover(
		function ()
		{
			$("#eshop").css("background-color", "gray");	
		},
		function ()
		{
			$("#eshop").css("background-color", "transparent");
		}
	);
});

function emptyBasket()
{
	$("#eshop").load("updatebasket.php");
	$("a.evEshop")
	.filter(function ()
	{
		return $(this).attr("alt") == "selected";
	})
	.each(function()
	{
		$(this).show(800);
		$(this).attr("alt", "");
	});
	
}

function login()
{
	logged = 1;
	pointToBasket();
}

function pointToAction()
{
	if (logged)
		pointToBasket();
	else
		pointToLogin();
}

function pointToLogin()
{
	$("#idBasket").unbind('click');
	$("#idBasket").attr('href', '/account.php?modal=true&keepThis=true&TB_iframe=true&height=200&width=300');
	$("#idBasket").attr('class', 'thickbox');
	$("#idBasket").click(function()
	{
		var t = this.title || this.name || null;
		var a = this.href || this.alt;
		var g = this.rel || false;
		
		tb_show(t, a, g);
		this.blur();
		return false;
	});
}

function pointToBasket()
{
	$("#idBasket").unbind('click');
	$("#idBasket").attr('href', '/basket.php?modal=true&keepThis=true&TB_iframe=true&height=450&width=600');
	$("#idBasket").click(function()
	{
		var t = this.title || this.name || null;
		var a = this.href || this.alt;
		var g = this.rel || false;

		tb_show(t, a, g);
		this.blur();
		return false;
	});
}
