function hideScart(){
	$("#kScart ul").fadeOut(800);
}

$(document).ready(function(){

	$("#billing").live("click",function(){
		if( !$(this).is(":checked")) {
			$("#addressForm").attr("action","shop-billing.html");
		}
		else {
			$("#addressForm").attr("action","shop-confirm.html");
		}
	})
	

	$("a.kToScart").live('click', function(){
		
		if( $('#option').val() ){
			var opt = $('#option').val();
		}
		else {
			var opt = ''; 
		}
		
		$.ajax({
			type: "POST",
			url: '/kameleo2/kInt.php?action=add2Scart',
			data: 'product=' + $(this).attr("href") + '&option=' + opt,
			success: function( d ){
				
				$("#kScart").html( d );	
				$("#kScart ul").show();
				
				setTimeout("hideScart()", '3000');
				
			}		
		});
		return false;

	})
	$("a.kShopDelete").live('click', function(){
		var $this = $(this)
		$.ajax({
			type: "POST",
			url: '/kameleo2/kInt.php?action=delFromScart',
			data: 'product=' + $(this).attr("href") ,
			success: function( d ){
				$this.parents("tr:eq(0)").remove()
								
				$("#kTot b").html( d );
			}		
		});
		return false;

	})
	
	$("#kShopScart select").live('change', function(){
		var $this = $(this)
		$.ajax({
			type: "POST",
			url: '/kameleo2/kInt.php?action=updateScart',
			data: 'product=' + $this.parent().find(".prid").val() + '&qt=' + $(this).val(),
			success: function( d ){
				var t = d.split("/");
				$this.parent().parent().find('.tot').html( t[0] );
				$("#kTot b").html( t[1] );
			}		
		});
		return false;

	})
	
	$.ajax({
		type: "POST",
		url: '/kameleo2/kInt.php?action=getMyScart',
		success: function( d ){
			$("#kScart").html( d );	
		}		
	});

})
