	
	// Slash2 Webshop
	// (C) 2009, Slash2

	function refresh_page(){
		shop_ajax.setParser('mf_cart');
		shop_ajax.setCallback('fill_cart');
		shop_ajax.sendRequest();
	}

	function fill_cart(content, type) {
		document.getElementById('cart_product_container').innerHTML = content;

		$('#show_coupon_cats').click(function(){
			$(this).hide();
			$('#coupon_cats').slideToggle('slow');
		});
		$('#close_coupon_cats').click(function(){
			$('#coupon_cats').slideToggle('slow', function(){
				$('#show_coupon_cats').show();
			});
		});	

		fill_cart_top();

		$(".fancybox_link").fancybox({
				'frameWidth': 950,
				'frameHeight': 550,
				'hideOnContentClick': false
		});

	}
	
	function confirm_delete_from_cart(variant_id, question){
		var answer = confirm(question)
		if (answer){
			remove_from_cart(variant_id);
		}
	}

	function remove_from_cart(cart_variant) {
		
		shop_ajax.setParser('cart');
		shop_ajax.setVar('cart_action','remove');
		shop_ajax.setVar('cart_variant',cart_variant);
		shop_ajax.setCallback('refresh_page');
		shop_ajax.sendRequest();
	
	}
	
/* 	function update(variant_id, quantity) {
		
		shop_ajax.setParser('cart');
		shop_ajax.setVar('cart_action','update');
		shop_ajax.setVar('cart_variant', variant_id);
		shop_ajax.setVar('cart_qty', quantity);
		shop_ajax.setCallback('refresh_page');		
		shop_ajax.sendRequest();
	
	} */
	
	function update(variant_id, quantity) {
		
		shop_ajax.setParser('cart');
		shop_ajax.setVar('cart_action','update');
		shop_ajax.setVar('cart_variant', variant_id);
		shop_ajax.setVar('cart_qty', quantity);
		shop_ajax.setCallback('product_add_to_cart');		
		shop_ajax.sendRequest();
	
	}	
	
	function change_variant_amount(direction, variant_id, question){
	
		var old_amount = parseInt(document.getElementById('product_variant_amount_'+variant_id).value);
		
		if(direction == 'up'){
			update(variant_id, (old_amount + 1));
		} else {
			if(old_amount != 1){
				update(variant_id, (old_amount - 1));				
			} else {
				var answer = confirm(question)
				if (answer){
					remove_from_cart(variant_id);
				}
			}
		}
	}
	
	$(document).ready(function() {
		refresh_page();
	});	
	
