function basketUp() {
	$("#basketBox").animate({bottom: "0"}, 300, function(){
		$("#up").css({display: 'none'});
		$("#up2").css({visibility: 'hidden'});
		$("#down").css({display: 'block'});
		$("#down2").css({visibility: 'visible'});
	});

//	alert(document.getElementById('basketBox').style.bottom);
}

function basketDown() {
	$("#basketBox").animate({bottom :"-156px"}, 300, function(){
		$("#up").css({display: 'block'});
		$("#up2").css({visibility: 'visible'});
		$("#down").css({display: 'none'});
		$("#down2").css({visibility: 'hidden'});
	});
}

function toBasket(id) {
    num = document.getElementById('count').value;

	$.ajax({
        url: '/'+_arg+'/system/store/add/'+id+'/'+num,
        dataType: 'script',
        success: function(){
            updateBasket(type, id);					
        }
	});
}

function delBasket(id) {
	$.ajax({
		url: '/'+_arg+'/system/store/removebasket/'+id,
        dataType: 'script',
		success: function(){
            updateBasket(type, id);		
		}
	});
}

function updateBasket(type, id) {

    basketUp();

    if (type == 'add'){
        width = parseInt($("#basket_container").css('width')) + 157;
        contentheight = width; 
        $("#basket_container").css('width', width + 'px');
        $.ajax({
            url: '/'+_arg+'/system/store/getitem/'+id,
            success: function(msg){
                $("#basket_container").prepend(msg);
                $("#basketItem_"+id).fadeIn(300);
            }
        });
	}

	if (type == 'remove') {
		$("#basketItem_"+id).fadeOut(300, function(){ 
			$("#basketItem_"+id).remove();
            width = parseInt($("#basket_container").css('width'));
            width = (width > 157) ? (width - 157) : 0;
            contentheight = width; 
            $("#basket_container").css('width', width + 'px');
		});
	}

	$.ajax({
		url: '/'+_arg+'/system/store/getinfo/',
        dataType: 'script',
		success: function() {
			$("#binfo-count").text(count);
			$("#binfo-price").text(price);
		}
	});


}

function movedown(){
	if (window.moveupvar)
		clearTimeout(moveupvar);
	if (parseInt(crossobj.style.left)>=940+contentheight*(-1))
		crossobj.style.left=parseInt(crossobj.style.left)-speed+"px";
	    movedownvar=setTimeout("movedown()",20);
}

function moveup(){
	if (window.movedownvar)
		clearTimeout(movedownvar);
	if (parseInt(crossobj.style.left)<0)
		crossobj.style.left=parseInt(crossobj.style.left)+speed+"px";
	    moveupvar=setTimeout("moveup()",20);
}

function stopscroll(){
	if (window.moveupvar)
		clearTimeout(moveupvar);
	if (window.movedownvar)
		clearTimeout(movedownvar);
}

function movetop(){
	stopscroll();
	crossobj.style.left=0+"px";
}

function getcontent_height(){
    contentheight=crossobj.offsetWidth;
	window.onload=getcontent_height;
}