$(document).ready(function(){
	
	$("#basskess").click(function(){
	if (jQuery(this).attr("good_count") == 1)
		add_to_basket(jQuery(this).attr("good_id"),jQuery(this).offset().left-30+"px",jQuery(this).offset().top-100+"px", 1);
	else
		add_to_basket(jQuery(this).attr("good_id"),jQuery(this).offset().left-30+"px",jQuery(this).offset().top-100+"px", document.getElementById('qwinput').value);
	});
	$(".basskess2").click(function(){
		add_to_basket(jQuery(this).attr("good_id"),jQuery(this).offset().left-30+"px",jQuery(this).offset().top-100+"px", 1);
	});

});	


function add_to_basket(arg,arg1,arg2,ccount)
{
	
	$("#ajax_in").html("");
	$("#real_psevdo").html("");
	$("#ajax").css("left",arg1);
	$("#ajax").css("top",arg2);
	$("#ajax").slideDown("fast");


	var TID = CPHttpRequest.InitThread();
	CPHttpRequest.SetAction(TID, ShowResult);
	CPHttpRequest.Send(TID, '/addtobasket.php', {'ID':arg, 'CCOUNT':ccount, 'mode':'ajax', 'backs':window.location.href});
	return false;
	
}

function HideResult() {
	
	$("#ajax").slideUp();
	$("#ajax_in").html("");
	$("#real_psevdo").html("");
	
}


function ShowResult(data) {
		$("#basket_span").html(data);
		$("#real_psevdo").html($("#psevdo_basket").html());
		$("#ajax_in").html(data);
		setTimeout("HideResult()",2000);
}	


/*

$(document).ready(function(){
	$("#basskess").click(function(){
		add_to_basket(jQuery(this).attr("good_count"),jQuery(this).attr("good_id"),jQuery(this).offset().left+8+"px",jQuery(this).offset().top-25+"px");
	});

	
	
});

	
function add_to_basket(arg0,arg,arg1,arg2)
{
	$("#ajax").css("left",arg1);
	$("#ajax").css("top",arg2);
	$("#ajax").css("display","block");


	var TID = CPHttpRequest.InitThread();
	CPHttpRequest.SetAction(TID, ShowResult);
	if (arg0=="-1")
	{
		CPHttpRequest.Send(TID, '/addtobasket.php', {'COUNT':document.getElementById('qwinput').value,'ID':arg, 'mode':'ajax', 'backs':window.location.href});
	} else {
		CPHttpRequest.Send(TID, '/addtobasket.php', {'COUNT':1,'ID':arg, 'mode':'ajax', 'backs':window.location.href});
	}		
	return false;
}
	
function ShowResult(data) {
	var obContainer = document.getElementById('basket_span');
	if (obContainer)
		obContainer.innerHTML = data;
	$("#ajax").css("display","none");
}	
*/

function chmode(arg)
{
	var TID = CPHttpRequest.InitThread();
	CPHttpRequest.SetAction(TID, ShowResultR);
	CPHttpRequest.Send(TID, '/change_sort.php', {'mode':'ajax', 'ID':arg});
	return false;
}

function ShowResultR(data) {window.location.href = window.location.href;}