var id;

// activated onclick, opens a new browser window with an image
function showLargeImage(path)
{
	window.open(path, 'image','width=685, height=645, menubar=0, resizable=0, scrollbars=0, location=0')
}

function addToCart(url, productId) 
{
	id = productId;
	Element.show($("indicator_" + id));
	var qty = $("qty_" + productId).value;
	var price = $("price_" + productId).value;
	new Ajax.Request(url + "in-cos/", {
		parameters: "productId=" + productId + "&qty=" + qty + "&price=" + price,
		onSuccess: addedToCart
	});
	return false;
} 
function addedToCart(resp, jsonObj) 
{
	// returns the response from the server as raw text
	var response = resp.responseText;
	Element.hide($("indicator_" + id));
	if (response == 1)
	{
		Effect.toggle($("msgOk_" + id), 'appear');
		setTimeout("Effect.toggle($('msgOk_' + id));", 1000);
	}
	else
	{
		Effect.toggle($("msgNotOk_" + id), 'appear');
		setTimeout("Effect.toggle($('msgNotOk_' + id));", 1000);
	}
}


function removeFromCart(url, productId) 
{
	id = productId;
	new Ajax.Request(url + "din-cos/", {
		parameters: "productId=" + productId,
		onSuccess: removedFromCart
	});
	return false;
}
function removedFromCart(resp, jsonObj) 
{
	// returns the response from the server as raw text
	var response = resp.responseText;
	if (response == 1)
		Effect.Fade("row_" + id);
}


function emptyCart(url) 
{
	new Ajax.Request(url + "goleste-cosul/", {
		onSuccess: emptiedCart
	});
	return false;
}
function emptiedCart(resp, jsonObj) 
{
	// returns the response from the server as raw text
	var response = resp.responseText;
	if (response == 1)
	{
		Effect.Fade("cart");
		Effect.Appear($("cartIsEmpty2"));
	}
}