function addToCart(el, pid)
{
	$.ajax({
		type: "GET",
		url: "/shop/cart.php",
		data: "ajax=true&func=add&product_id="+pid+"&quantity=1",
		success: function(msg) {
			if(msg != "false")
			{
				if(msg == "true")
				{	
					$(el).replaceWith("Added to cart");
					updateShopMenu();
				}
				else
				{
					alert("Unable to add this item to your cart, because:\n" + msg);
				}
			}
		}
	});
}

function updateShopMenu()
{
	$div = $('#shop_cp_contain');

	$.ajax({
		url: "/shop/display_shop_menu.php",
		cache: false,
		success: function(html)
		{
			$div.replaceWith(html);
		}
	});
}

function changeToModPrice(prodid, qty, url)
{
	el = $('select.pmodifiers');
	ids = "";
	prodPrice = $('tr.price_row');

	el.each(function() {
		if($(this).val() != "" && $(this).val() != undefined)
			ids = ids + $(this).val() + ",";
	});

        $.ajax({
                type: "GET",
                url: url+"/shop/products.php",
                data: "func=getModPrice&maids="+ids+"&prodid="+prodid+"&qty="+qty,
                success: function(data) {
                	if($.cookie("currency")) {
				var price = 0;
				price = (data / 1.0) * $.cookie("exchange_rate");
				price = $.cookie("currency_symbol") + price.toFixed(2);
                		html = '<tr class="selected_price_row"><td><b>Selected Price:</b></td><td><span style="background:#e1e1e1;padding:1px;">' + price + '</span></td></tr>';
                	} else {
                		html = '<tr class="selected_price_row"><td><b>Selected Price:</b></td><td><span style="background:#e1e1e1;padding:1px;">$' + data + '</span></td></tr>';
			}

			if($('tr.selected_price_row').length)
				$('tr.selected_price_row').remove();
			
			prodPrice.after(html);
                }
        });
}
