/*
 * Clase Tienda
 * 
 * Version: 	$Revision: 1.0 $
 * Author:  Antonio Hernández Ritoré 
 */
 
function Tienda(){
// 	Definicion de atributos
	this.stock = null;
	this.carro = null;
	this.ofertas = null;
	
	this.carroOf0 = null;
	this.carroOf1 = null;
	this.carroOf2 = null;
	
	this.cliente = null;

	this.colores = null;
	this.designs = null;
	
	this.artact = null;
	this.linact = -1;
		
//	Definicion de metodos
	this.enviarPedido = enviarPedido;
	this.mostrarArticulo = mostrarArticulo;
	this.buscarArticulo = buscarArticulo;
	this.buscarColor = buscarColor;
	this.buscarDesignImg = buscarDesignImg;
	this.mostrarLinea = mostrarLinea;
	this.borrarLinea = borrarLinea;
}


function mostrarArticulo(ref){
/*
	this.linact = -1;
	this.artact = tienda.buscarArticulo(ref);
	top.cuerpo.document.location = "mostrarart.html";
	*/
	openWindowHTML('fueraservicio.html', 200, 150);
}

function buscarArticulo(ref){
	for(var i=0;i<this.stock.length;i++){
		if(this.stock[i].referencia==ref)
			return this.stock[i];
	}
	return null;	
}

function mostrarLinea(i, ofid){
	this.linact = i;
	if(ofid==null){
		this.artact = tienda.buscarArticulo(this.carro[i].referencia);
	}else if(ofid==0){
		this.artact = tienda.buscarArticulo(this.carroOf0[i].referencia);
	}else if(ofid==1){
		this.artact = tienda.buscarArticulo(this.carroOf1[i].referencia);
	}else if(ofid==2){
		this.artact = tienda.buscarArticulo(this.carroOf2[i].referencia);
	}
	top.cuerpo.document.location = "mostrarart.html";
}

function buscarColor(rgb){
	for(var i=0;i<this.colores.length;i++){
		if(this.colores[i][0]==rgb)
			return this.colores[i][1];
	}
	return "";	
}

function buscarDesignImg(desc){
	for(var i=0;i<this.designs.length;i++){
		if(this.designs[i][0]==desc)
			return this.designs[i][1];
	}
	return "";	
}

function borrarLinea(ind, ofid){

	if(ofid==null){
		c = this.carro;
	}else if(ofid==0){
		c = this.carroOf0;
	}else if(ofid==1){
		c = this.carroOf1;
	}else if(ofid==2){
		c = this.carroOf2;
	}

	if(c && ind>=0 && ind<c.length){
		for(i=ind;i<c.length-1;i++)
			c[i]=c[i+1];
		c.length=c.length-1;
	}
}

function enviarPedido(){
}