/* Actions for product-buttons in webshop_standard.php */
$('document').ready( function () {
	$('input[@type=submit].button').focus( function () { $(this).blur(); });

	$('input[@type=submit].button').click( function () {
		var fdata = $('#productForm input, #productForm select').serialize();

		$('#cart').html('<div style="padding: 10px 0px 0px 40px; color: red;">Uppdaterar...</div>');
		$('div.confirm-overlay').show();
		$('div.confirm-alert').show();

		$.post('xmlhttp/cartaction.php', fdata, function (data) {

			if (data != '' && ! isNaN(data)) {
				$.get('xmlhttp/cart.php', { sel: data, ajax: 1 }, function (html) {
					$('#cart').html(html);
				});
			} else {
				if (data) alert(data);
				$('#cart').load('xmlhttp/cart.php');
			}
		});

		return false;
	});
	
	
	$('input[@type=submit].button-clean').click( function () {
		var fdata = 'action=cleancart';
		
		$.post('xmlhttp/cartaction.php', fdata, function (data) {
			location.href = 'kassa.php';
		});

		return false;
	});
	
	
	

	$('.types').change( function () {

		propID = $(this).val();
		price = $('#prod_price').val();
		productID = $('#prodId').val();

		$.get('xmlhttp/changePrice.php',{ propID: propID, price: price, productID: productID }, function (data) {
			$('.price h3').html(data+':-');
		});

	});
});
