/////////////////////////////////////////////////////////////
// Copyright 1999,2000 Amaris Software Entwicklungsges. mbH
// waShop.js
// Javascript-Bibliothek für Shopfunktionen
/////////////////////////////////////////////////////////////

function waOrder()
{ this.price				= new Array();	
	this.location			= new Array();	
	this.quantity			= new Array();	
	this.detail				= new Array();	
	this.quantitysum 	= 0;
	this.pricesum			= 0;
}

function waShop()
{	this.user					= new Array();	
	this.order				= new waOrder;
	this.basketIn			= waBasketIn;
	this.basketRecalc	= waBasketRecalc;
	this.basketClear	= waBasketClear;
}

function waBasketIn(larticle, lprize, llocation, ldetail)
{	for (element in this.order.price)
	{ if (element == larticle)
		{	if (this.order.quantity[element] != 0)
			{	this.order.quantity[element] ++;
				this.order.quantitysum ++;
				this.order.pricesum += lprize
				return;
			}
		}
	}
	this.order.price[larticle]=lprize;
	this.order.location[larticle]=llocation;
	this.order.quantity[larticle]=1;
	this.order.quantitysum ++;
	this.order.pricesum += lprize

	if (arguments.length > 3)
		{ this.order.detail[larticle]=ldetail; }
	else
		{ this.order.detail[larticle]=""; }
}

function waBasketRecalc(larticle,lquantity)
{ for (element in this.order.price)
	{ if (element == larticle)
		{	this.order.quantitysum += -this.order.quantity[larticle]+lquantity;
			this.order.pricesum += (-this.order.quantity[larticle]+lquantity)*this.order.price[larticle];
			this.order.quantity[larticle] = lquantity; 
		}
	}
}

function waBasketClear()
{	this.order.price				= Array();
	this.order.location 		= Array();
	this.order.quantity			= Array();
	this.order.detail				= Array();
	this.order.quantitysum	= 0;
	this.order.pricesum			= 0;
}
