// FormatX pricing calculations
function pricePoint(quant, cost)
{
    this.quant = quant;
    this.cost = cost;
}
function getPrice(theTable, theQuant, maxCost)
{
    if (theTable == null || theQuant == null) return null;
    var minCost = null;
    for(var i = 0; i < theTable.length; i++){
	var pp = theTable[i];
	if (theQuant >= pp.quant){
	    var thisCost = 1 * pp.cost * theQuant;
	    if (minCost == null || thisCost < minCost)
		minCost = thisCost;
	}
    }
    if (minCost != null && maxCost != null && minCost > maxCost)
	return maxCost;
    else
	return minCost;
}
var formatXPrice = new Array(14);
formatXPrice[0] = new pricePoint(1, 29.90);
formatXPrice[1] = new pricePoint(5, 21.80);
formatXPrice[2] = new pricePoint(10, 20.90);
formatXPrice[3] = new pricePoint(20, 17.95);
formatXPrice[4] = new pricePoint(30, 16.97);
formatXPrice[5] = new pricePoint(50, 14.98);
formatXPrice[6] = new pricePoint(75, 13.20);
formatXPrice[7] = new pricePoint(100, 10.90);
formatXPrice[8] = new pricePoint(200, 7.95);
formatXPrice[9] = new pricePoint(300, 6.63);
formatXPrice[10] = new pricePoint(500, 5.18);
formatXPrice[11] = new pricePoint(750, 4.39);
formatXPrice[12] = new pricePoint(1000, 3.79);
formatXPrice[13] = new pricePoint(2000, 2.60);

var formatXPlusPrice = new Array(14);
formatXPlusPrice[0] = new pricePoint(1, 49.90);
formatXPlusPrice[1] = new pricePoint(5, 37.80);
formatXPlusPrice[2] = new pricePoint(10, 34.90);
formatXPlusPrice[3] = new pricePoint(20, 31.45);
formatXPlusPrice[4] = new pricePoint(30, 28.63);
formatXPlusPrice[5] = new pricePoint(50, 24.98);
formatXPlusPrice[6] = new pricePoint(75, 21.72);
formatXPlusPrice[7] = new pricePoint(100, 18.79);
formatXPlusPrice[8] = new pricePoint(200, 13.70);
formatXPlusPrice[9] = new pricePoint(300, 11.30);
formatXPlusPrice[10] = new pricePoint(500, 8.78);
formatXPlusPrice[11] = new pricePoint(750, 7.32);
formatXPlusPrice[12] = new pricePoint(1000, 6.29);
formatXPlusPrice[13] = new pricePoint(2000, 4.35);

function calculateFormatXPrice(quant)
{
    return getPrice(formatXPrice, quant, 6900.00)
}
function calculateFormatXPlusPrice(quant)
{
    return getPrice(formatXPlusPrice, quant, 9900.00)
}
