$(document).ready(function(){ 

	$("#basketItemsWrap li:first").hide();

	$(".addToBasketButton").live('click',function() {
		var productIDValSplitter 	= (this.id).split("_");
		var productIDVal 			= productIDValSplitter[1];
		
		if($(this).hasClass("additional")) {
			var count2 = $("#count2"+productIDVal).val();
		} else {
			var count2 = $("#count"+productIDVal).val();
		}
		
		var productChecking = 0;
		var productChecking = ( $('#productChecking').is(":checked") ? 1 : 0 );
		$.ajax({  
			type: "POST",  
			url: "/engine/add_to_basket.php",
			data: { productID: productIDVal, session: $("#sessid").val(),count: count2,checking: productChecking},
			success: function(theResponse) {
				eval(theResponse);
				$("#basketText").html(objectsCount);
				$("#basketInfo").html(contentToWrite);
				$(".window").html("<div style=\"text-align: center;\" id=\"windowLoader\"><img src=\""+siteurl+"templates/images/loader.gif\" /></div>");
				
				var maskHeight = $(document).height();
				var maskWidth = $(window).width();
				$('#mask').css({'width':maskWidth,'height':maskHeight});
				
				$('#mask').fadeIn(300);	
				$('#mask').fadeTo(200,0.5);	
				
				$(".window").width("400px");
				$(".window").height("220px");
				var winH = $(window).height();
				var winW = $(window).width();
				$(".window").css('top',  winH/2-$(".window").height()/2+$(window).scrollTop());
				$(".window").css('left', winW/2-$(".window").width()/2);
				$(".window").fadeIn(1000);
				$(".window").html('<a href="#" class="close"><img src="'+siteurl+'templates/images/closebox.gif"></a>'+windowContent);
			}  
		});
		return false;
	});
});

