<!--
function toDollarsAndCents(n) 
{
	var s = "" + Math.round(n * 100) / 100
	var i = s.indexOf('.')
	if (i < 0) return s + ".00"
	var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3)
	if (i + 2 == s.length) t += "0"
	return t
}


function stone(stoneName, stonePrice, stonePrice2)
{
	this.stoneName		= 	stoneName;
	this.stonePrice		= 	stonePrice;
	this.stonePrice2 	= 	stonePrice2;
}

function addStone(stoneName, stonePrice, stonePrice2)
{
	myStone[myStone.length] = new stone(stoneName, stonePrice, stonePrice2);
	myStone.length++;
}

function edgeDetails(edgeName, edgePrice)
{
	this.edgeName	= 	edgeName;
	this.edgePrice	= 	edgePrice;
}

function addEdge(edgeName, edgePrice)
{
	myEdges[myEdges.length] = new edgeDetails(edgeName, edgePrice);
	myEdges.length++;
}

function cutouts(cutoutName, cutoutPrice)
{
	this.cutoutName		= 	cutoutName;
	this.cutoutPrice	= 	cutoutPrice;
}

function addCutout(cutoutName, cutoutPrice)
{
	myCutouts[myCutouts.length] = new cutouts(cutoutName, cutoutPrice);
	myCutouts.length++;
}


function initStuff()
{
	stoneObj	= document.theForm.stone;
	edgeObj		= document.theForm.edge;
	cutoutObj	= document.theForm.cutout;

	for(i=0;i<stoneObj.length;i++)
	{
		for(count=0;count<myStone.length;count++)
		{
			stoneObj[i].options[count] = new Option(myStone[count].stoneName);
			stoneObj[i].options[count].value = count;
			stoneObj[i].options[count].text = myStone[count].stoneName;
		}
	}


	for(i=0;i<edgeObj.length;i++)
	{
		for(count=0;count<myEdges.length;count++)
		{
			edgeObj[i].options[count] = new Option(myEdges[count].edgeName);
			edgeObj[i].options[count].value = count;
			edgeObj[i].options[count].text = myEdges[count].edgeName;
		}
	}


	for(i=0;i<cutoutObj.length;i++)
	{
		for(count=0;count<myCutouts.length;count++)
		{
			cutoutObj[i].options[count] = new Option(myCutouts[count].cutoutName);
			cutoutObj[i].options[count].value = count;
			cutoutObj[i].options[count].text = myCutouts[count].cutoutName;
		}
	}

}

function changeStone(stoneIndex)
{
	stoneObj = document.theForm.stone[stoneIndex];
	stoneCount = document.theForm.stoneCount[stoneIndex];
	stonePrice = document.theForm.stonePrice[stoneIndex];
	if(isNaN(stoneCount.value)) stoneCount.value = 0
	
	if(stoneCount.value >= 30)
	{
		stonePrice.value = toDollarsAndCents(stoneCount.value * myStone[stoneObj.value].stonePrice2);
	}
	else
	{
		stonePrice.value = toDollarsAndCents(stoneCount.value * myStone[stoneObj.value].stonePrice);
	}
	updateTotals();
}

function changeEdge(edgeIndex)
{
	edgeObj = document.theForm.edge[edgeIndex];
	edgeCount = document.theForm.edgeCount[edgeIndex];
	edgePrice = document.theForm.edgePrice[edgeIndex];
	if(isNaN(edgeCount.value)) edgeCount.value = 0
	edgePrice.value = toDollarsAndCents(edgeCount.value * myEdges[edgeObj.value].edgePrice);
	updateTotals();
}

function changeCutout(cutoutIndex)
{
	cutoutObj = document.theForm.cutout[cutoutIndex];
	cutoutCount = document.theForm.cutoutCount[cutoutIndex];
	cutoutPrice = document.theForm.cutoutPrice[cutoutIndex];
	if(isNaN(cutoutCount.value)) cutoutCount.value = 0
	cutoutPrice.value = toDollarsAndCents(cutoutCount.value * myCutouts[cutoutObj.value].cutoutPrice);
	updateTotals();
}

function updateTotals()
{
	var totalVal = 0;
	stonePrice = document.theForm.stonePrice;
	edgePrice = document.theForm.edgePrice;
	cutoutPrice = document.theForm.cutoutPrice;
	
	for(counter=0;counter<stonePrice.length;counter++)
	{
		if(isNaN(stonePrice[counter].value)) stonePrice[counter].value = 0.00;
		totalVal += (1 * stonePrice[counter].value);
	}

	for(counter=0;counter<edgePrice.length;counter++)
	{
		if(isNaN(edgePrice[counter].value)) edgePrice[counter].value = 0.00;
		totalVal += (1 * edgePrice[counter].value);
	}
	for(counter=0;counter<cutoutPrice.length;counter++)
	{
		if(isNaN(cutoutPrice[counter].value)) cutoutPrice[counter].value = 0.00;
		totalVal += (1 * cutoutPrice[counter].value);
	}

	document.theForm.total.value = toDollarsAndCents(totalVal);
	
}


function sendData()
{
	var outData = "\n";
	
	stoneObj = document.theForm.stone;
	edgeObj = document.theForm.edge;
	cutoutObj = document.theForm.cutout;
	
	stoneCount = document.theForm.stoneCount;
	edgeCount = document.theForm.edgeCount;
	cutoutCount = document.theForm.cutoutCount;
	
	stonePrice = document.theForm.stonePrice;
	edgePrice = document.theForm.edgePrice;
	cutoutPrice = document.theForm.cutoutPrice;
	
	for(counter=0;counter<stonePrice.length;counter++)
	{
		outData += "'Stone" + counter + "','" + stoneObj[counter].options[stoneObj[counter].value].text + "'," + stoneCount[counter].value + "," + stonePrice[counter].value + "\n";
	}
	for(counter=0;counter<edgePrice.length;counter++)
	{
		outData += "'edge" + counter + "','" + edgeObj[counter].options[edgeObj[counter].value].text + "'," + edgeCount[counter].value + "," + edgePrice[counter].value + "\n";
	}
	for(counter=0;counter<cutoutPrice.length;counter++)
	{
		outData += "'cutout" + counter + "','" + cutoutObj[counter].options[cutoutObj[counter].value].text + "'," + cutoutCount[counter].value + "," + cutoutPrice[counter].value + "\n";
	}

	outData += "\nTotal Estimate=" + document.theForm.total.value + "\n\n";

	outData += "Contact Info:\n";
	outData += "Name=" + document.theForm.Name.value + "\n";
	outData += "Company=" +	document.theForm.Company.value + "\n";
	outData += "Address=" + document.theForm.Address.value + "\n";
	outData += "cityStateZip=" + document.theForm.cityStateZip.value + "\n";
	outData += "Telephone=" + document.theForm.Telephone.value + "\n";
	outData += "Fax=" + document.theForm.Fax.value + "\n";
	outData += "Email=" + document.theForm.Email.value + "\n";

	document.submitForm.requestData.value = outData;
	
	return false;
}
-->
