var user = {
		root:	"/",
		cart:	{
				items:		new Array(),
				addItem: 	function(id,quantity){
							//tem de passar pelo servidor, ou então tem de guardar na cookie
							//na cookie tem mais sentido, pelo servidor e ajax
							new Ajax.Request(
								user.root+"cart", 
								{
									method: 'post',
									parameters: "product_id="+id+"&quantity="+quantity,
									onSuccess: function(transport){
										window.location = window.location;
									}
								}
							);
							//alert("adicionar "+quantity+" de "+id);
						},
				addItems: 	function(json){
							new Ajax.Request(
								user.root+"cart", 
								{
									method: 'post',
									parameters: json,
									onSuccess: function(transport){
										window.location = window.location;
									}
								}
							);
						},
				increase: 	function(id,quantity){
							//tem de passar pelo servidor, ou então tem de guardar na cookie
							//na cookie tem mais sentido, pelo servidor e ajax
							new Ajax.Request(
								user.root+"cart", 
								{
									method: 'post',
									parameters: "product_id="+id+"&quantity="+quantity,
									onSuccess: function(transport){
										window.location = window.location;
									}
								}
							);
							//alert("adicionar "+quantity+" de "+id);
						},
				decrease: 	function(id,quantity){
							//tem de passar pelo servidor, ou então tem de guardar na cookie
							//na cookie tem mais sentido, pelo servidor e ajax
							new Ajax.Request(
								user.root+"cart", 
								{
									method: 'post',
									parameters: "product_id="+id+"&quantity=-"+quantity,
									onSuccess: function(transport){
										window.location = window.location;
									}
								}
							);
							//alert("adicionar "+quantity+" de "+id);
						},
				empty:		function(){
							new Ajax.Request(
								user.root+"cart/delete", 
								{
									method: 'get',
									onSuccess: function(transport){
										window.location = window.location;
									}
								}
							);

						},
				deleteItem:	function(id){
							new Ajax.Request(
								user.root+"cart/delete/"+id, 
								{
									method: 'get',
									onSuccess: function(transport){
										window.location = window.location;
									}
								}
							);	
						}

		},
		login:	function(ser){
				new Ajax.Request(
					user.root+"login", 
					{
						method: 	'post',
						parameters:	ser,
						onSuccess: 	function(transport){
							window.location = window.location;
						}
					}
				);
				
		},
		logout:	function(){
				new Ajax.Request(
					user.root+"logout", 
					{
						method: 	'get',
						onSuccess: 	function(transport){
							window.location = window.location;
						}
					}
				);
				
		}
};


