function update_shopping_cart(positionfrom,positionto,address,update){
    var splat = new Array(2);
	splat=address.split("?");
	ajax_cart(positionfrom,positionto,splat[0],splat[1]+update);
}

function move(source,position){
	if($(position)){
		$(source).style.left='';$(source).style.top='';$(source).style.height='';$(source).style.width='';$(source).style.display='block';
		$(source).style.position='fixed';
		var fx = $(source).effects({duration:1500, wait:true , transition: Fx.Transitions.Back.easeIn});
		fx.start({
			'top': ($(position).offsetTop + $(source).offsetHeight + $(position).offsetHeight),
			'left': $(position).offsetLeft,
			'height': '1px',
			'width': '1px'
		});
		window.setTimeout(function(){$(source).style.display='none';},1500);
	}
}

function ajax_cart(positionfrom,positionto,url, data){
	var xmlHttp=null;
	try
	  {// Firefox, Opera 8.0+, Safari, IE7
	  xmlHttp=new XMLHttpRequest();
	  }
	catch(e)
	  {// Old IE
	  try
	    {
	    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  catch(e)
	    {
		    document.cart_quantity.submit();
			return;
	    }
	  }
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", data.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
	  if (xmlHttp.readyState==4)
	  {// 4 = "loaded"
	  if (xmlHttp.status==200)
	    {// 200 = "OK"
			move(positionfrom,positionto);
			window.setTimeout(function(){
				 var string="START "+xmlHttp.responseText+" END";
				 var ar = string.match(/<span id="ItemsInCart">(.*)<\/span>/);
				 $('ItemsInCart').innerHTML=RegExp.$1;
			},1500);
	    }
	  else
	    {
			document.cart_quantity.submit();
	    }
	  }
	}
	xmlHttp.send(data);
}

function showbox(selected_model){
  $('quantity_box').value=selected_model;
}

window.addEvent('domready', function() {
    spans=$$('.textbuttonup');
    $each(spans,function(el){
        var parent=el.getParent();
        parent.set('class','textbutton');
    });

});