
function CSACalc()
{
	this.weeklyPickupPrices;
	this.discountPickupPrices;
	this.pickupLocation;
	this.mimimumAmount;
	this.form = document.csaForm;
	this.shareType;
	this.chargeForSeasonal;
}

/**
 * Calculates the CSA prices
 *
 * @param {Boolean} weekly  Whether or not this is a weekly or seasonal share
 */
CSACalc.prototype.calculate = function( weekly )
{

	this.form.amt.value = 0;
	answer = 0;

    for (var i=0; i<this.form.share.length; i++)
    {
	    if (this.form.share[i].checked)
	    {
			 answer += this.form.share[i].value-0;

			 for (var j = 0; j < this.form.locations.length; j++)
			 {
				 if (this.form.locations[j].checked && (this.form.locations[j].value == this.pickupLocations[j]))
				 {
					  if (weekly)
					  {
							answer += this.weeklyPickupPrices[j]*6-0;
							this.shareType = '6 Week';
					  }
					  else
					  {
					  		answer += this.discountPickupPrices[j]-0;
							this.shareType = 'Seasonal';
					  }

					  this.form.pickupLocation.value = this.form.locations[j].value;
					  this.form.shareType.value = this.shareType;
				 }
		  	}
	    }
    }
    this.mimimumAmount = this.form.minAmt.value = this.form.amt.value = answer;
}

CSACalc.prototype.trackChange = function()
{
	this.form.minAmt.value = this.form.amt.value;
}

