function addToCart(product, sid) {

	//pop up
	$.post("/store/ajax/store.php", { action: 'addproduct', product: product, sid: sid },
	function(data) {
		tb_show('', '/store/ajax/display.php?product='+product+'&height=200&width=475', '');
		updateCount(sid);
	});
	
}

function updateCount(sid) {
	
	$.post("/store/ajax/store.php", { action: 'updatecount', sid: sid },
	function(data){
		$('#cartnotice').html(data);
		//alert(data);
	});	
	
}

function updateQty(product, qty, sid, input) {
	
	//update session
	$.post("/store/ajax/store.php", { action: 'updateqty', product: product, qty: qty, sid: sid },
	function(data) {
		resparray = data.split('T');
		dqty = resparray[0];
		dprice = resparray[1];
		
		$('#carttable tr#prod_'+product+' .total').html(dprice);
		
		if($(input).val() != dqty) {
			$(input).val(dqty);	
			//post notice
			$(".errornotice").hide();
			$('<div class="errornotice" style="font-size: 10px; font-weight: bold; color: red;">Note: We only have '+dqty+' of this item left in stock. Your quantity has been reduced.</div>').insertAfter(input);
			setTimeout('$(".errornotice").fadeOut("fast");', 5000);
		}		
	});	
	
	//update subtotal
	$.post("/store/ajax/store.php", { action: 'grabsubtotal', sid: sid },
	function(data) {
		$('#carttable #subtotal').html(data);
	});	
	
}

function shipOptions() {
	
	tb_show('', '/store/ajax/shipping.php?height=220&width=475', '');
	
}

function pickShip(product) {
	
	//ajax routine
	$.post("/store/ajax/setshipping.php", { key: product },
	function(data) {
		//close dindow
		tb_remove();
		window.location.href = '/store/checkout/payment';
	});
	
}
