$(function(){
  
	 $("#item_count_minus").click(function(){
	 	
		var current_count = $("#item_count").val();
		var new_count = 0;
		if(!isNaN(current_count))
		{
			if(current_count > 0)
			{
				new_count = current_count - 1;
			}	
		}
		
		$("#item_count").val(new_count);
		
		return false;
	 });
	 
	 $("#item_count_plus").click(function(){
	 	
		var current_count = $("#item_count").val();
		var new_count = 0;
		if(!isNaN(parseInt(current_count)))
		{
	
			new_count = parseInt(current_count) + 1;
				
		}
		
		$("#item_count").val(new_count);
		
		return false;
	 });


	$("#basket_add").click(function(){
		
		//alert($(this).attr('pid'));
		
		var id = $(this).attr('pid');
		var buyer = new buyProduct( id, false, false);
		buyer.execute();
		if(ProductCheckForm != false){
		
			/*
			var main_height = $("#main").height();
			$("#basket_wrrap").css("display", "block");
			$("#basket_wrrap").height(main_height);
			
			var html_width = $("html").width();
			var dialog_left = (html_width - $("#basket_dialog").width())/2;
			
			var body_height = $("body").height();
			var dialog_top = (body_height - $("#basket_dialog").height())/2;
			
			var item_price = parseFloat($("#item_price").val());
			var item_count = parseInt($("#item_count").val());
			var price = item_price * item_count;
	
			$("#basket_dialog").css({display:"block", left: dialog_left, top: "200px"});		
			$("#basket_dialog_count").text(item_count);
			$("#basket_dialog_price").text(price+"zł");
			*/
			
		}

		return false;
		
	});
	
	$("#basket_addNow").click(function(){
	
		var id = $(this).attr('pid');
		//var buyer = new buyProduct( id, true, false);
		var buyer = new buyProduct( id, false, false);
		buyer.execute();	

		return false;
	
	});
	
	$("#basket_back").click(function(){
		$("#basket_wrrap").css("display", "none");
		return false;
	});
	$("#basket_goto").click(function(){

		location.href = '/koszyk';		
		return false;
	});
	
	
	$("#basket_dialog > h1 >a ").click(function(){
		$("#basket_wrrap").css("display", "none");
		
		//alert('test');
		
		return false;
	});
}); 