function PaperStock()
{
	this.papers = new Array();
}

function paperstock_addPaper(paperType, iWidth, iHeight, paperPrice)
{
	this.papers[this.papers.length] = new Paper(paperType, iWidth, iHeight);
	this.papers[this.papers.length-1].price = paperPrice;
}

function paperstock_getElementAt(index)
{
	return this.papers[index];
}

function paperstock_getPaper(paperType, iWidth, iHeight, orientation)
{
	var paper = null;

	if(paperType == Paper.TYPE_CANVAS)
	{
	    paper = new Paper(Paper.TYPE_CANVAS, iWidth, iHeight);
	    paper.price = this.getPrice(paper);
	}
	else
	{
	    for(var i = 0; i < this.papers.length; i++)
	    {
		if(this.papers[i].type == paperType)
		{
		    var size = new Dimension(this.papers[i].width, this.papers[i].height);

		    if(size.contains(iWidth, iHeight, orientation))
		    {
			paper = new Paper(paperType, iWidth, iHeight);
			paper.width = this.papers[i].width;
			paper.height = this.papers[i].height;
			paper.price = this.papers[i].price;
			break;
		    }
		}
	    }
	}

	return paper;
}

function paperstock_getPrice(paper)
{
	var price = 0;

	if(paper.type == Paper.TYPE_CANVAS)
	{
		price = paper.getImageArea() * PaperStock.PRICE_CANVAS;
	}
	else
	{
		for(var i = 0; i < this.papers.length; i++)
		{
			if(this.papers[i].type == paper.type)
			{
				if(this.papers[i].width == paper.width &&
					this.papers[i].height == paper.height)
				{
					price = this.papers[i].price;
					break;
				}
			}
		}
	}

	return price;
}

function paperstock_toString()
{
	return this.papers.toString();
}

PaperStock.PRICE_CANVAS = 115;
PaperStock.prototype.add = paperstock_addPaper;
PaperStock.prototype.getElementAt = paperstock_getElementAt;
PaperStock.prototype.getPaper = paperstock_getPaper;
PaperStock.prototype.getPrice = paperstock_getPrice;
PaperStock.prototype.toString = paperstock_toString;
