function Clase_Carrito(){
	   // productos
	   this.carrito = new Clase_Vector();
	   this.add = add;
	   this.getBeanImagen = getBeanImagen;
	   this.remove = remove;
	   this.getPedido = getPedido;
	   this.getSize = getSize;
	   this.isInCarrito = isInCarrito;
}
// Se recupera el numero inventario del producto i
function getBeanImagen(i){
	var obj = new Clase_ImagenesBean();
	obj = this.carrito.getIndexValue(i);
	return obj;
}

// Añade en la colección un nuevo producto
function add(titulo, precio, numeroInventario){
	var obj = new Clase_ImagenesBean();
	obj.setTitulo(titulo);
	obj.setPrecio(precio);
	obj.setNumeroInventario(numeroInventario);
	if (!this.isInCarrito(obj)){
		this.carrito.addIndexValue(obj);
		return true;
	}else{
		return false;
	}
}

function isInCarrito(obj1){
	var obj = new Clase_ImagenesBean();
	var titulo = obj1.getNumeroInventario();
	for (i=0;i<this.carrito.getNumberElements();i++){
		obj = this.getBeanImagen(i);
		if (obj.getNumeroInventario() == titulo){
			return true;
		}
	}
	return false;
}

// Añade en la colección un nuevo producto
function remove(numeroInventario){
	var obj = new Clase_ImagenesBean();
	for (i=0;i<this.carrito.getNumberElements();i++){
		obj = this.getBeanImagen(i);
		if (obj.getNumeroInventario() == numeroInventario){
			this.carrito.deleteIndex(i);
			return true;
		}
	}
}

// Devuelve como cadena el contenido del carrito
function getPedido(){
	var obj = new Clase_ImagenesBean();
	var cadena = "";
	for (i=0;i<this.carrito.getNumberElements();i++){
		obj = this.getBeanImagen(i);
		if (i==(this.carrito.getNumberElements()-1)){
			cadena+= obj.getNumeroInventario()+";"+obj.getPrecio()+";"+obj.getTitulo();
		}else{
			cadena+= obj.getNumeroInventario()+";"+obj.getPrecio()+";"+obj.getTitulo()+"%";
		}
	}
	return cadena;
}

function getSize(){
	return this.carrito.getNumberElements();
}