//all JavaScript in this file is Copyright Pegasus Web Productions, LLC. reuse or reproduction of this script is strictly prohibited

<!-- Begin
function FabricSelected(ID,FH,FW,FP)
{
	var FabricRow = "HWRow" + ID;
	var txtPrice = "txtFabricPrice" + ID;
		
	for (var i = 0; i < document.frmFabric.Fabric.length; i++)  {
		var FabricRowLoop = "HWRow" + i;
		var txtSize = "txtSize" + i;
		document.getElementById(FabricRowLoop).style.visibility = "hidden";
		document.getElementById(txtSize).value = null;
		}
		
	document.getElementById(FabricRow).style.visibility = "visible";
	document.getElementById("txtFabricTotal").innerHTML = document.getElementById(txtPrice).innerHTML;
	document.getElementById("FabricTotal").value = document.getElementById(txtPrice).innerHTML;
	getFabricCost(ID,FH,FW,FP);
	getMyWayCost();
}
//  End -->

<!-- Begin
function getFabricCost(ID,FH,FW,FP)
{
	var answer = (FH * FW) * FP;
	var FormName = "frmFabric" + ID;
	//var txtTotal = "txtFabricTotal" + ID;
	var SelectedFabricID = "Fabric" + ID;
	var txtPrice = "txtFabricPrice" + ID;
	var txtSize = "txtSize" + ID;
	document.getElementById(txtPrice).innerHTML = answer.toFixed(2);
	document.getElementById("txtFabricTotal").value = answer.toFixed(2);
		//calculate and display final totals for fabric column
		document.getElementById("txtFabricTotal").innerHTML = answer.toFixed(2);
		document.getElementById("FabricTotal").value = answer.toFixed(2);
		document.getElementById(txtSize).value = FW + "w by " + FH + "h";
		document.getElementById("FabricToCart").value = document.getElementById(SelectedFabricID).value + "," + FW + "w" + " x " + FH + "h" + "," + answer.toFixed(2);
	//calculate the MyWay total
	getMyWayCost();
	return answer;
}
//  End -->

<!-- Begin
function getFlossCost(FQ,FP)
{
	var answer = FQ * FP;
	var runningTotal = 0;
	var runningQty = 0;
//alert(document.frmFloss.length);
for(var i=1; i <= document.getElementById("FlossLoopCounter").value; i++) {//
	var LoopFlossQuantity = "FlossQuantity" + i;
	var LoopFlossPrice = "txtFlossPrice" + i;
	runningTotal = runningTotal + (parseFloat(document.getElementById(LoopFlossQuantity).value) * parseFloat(document.getElementById(LoopFlossPrice).innerHTML));
	runningQty = runningQty + parseFloat(document.getElementById(LoopFlossQuantity).value);
    }
	document.getElementById("txtSkeinsTotal").innerHTML = runningTotal.toFixed(2);
	document.getElementById("txtSkeinsQty").innerHTML = runningQty;
	//prepare the floss for the cart FlossToCart
	getFlossCartReady();
	//calculate the MyWay total
	getMyWayCost();	
	return answer;
}
//  End -->

<!-- Begin
function getOtherCost(ID,Price)
{
	var DropDownName = "OtherQuantity" + ID;
	//var answer = document.getElementById(DropDownName).value * Price;
	document.getElementById("txtOtherTotal").value = 0;
	document.getElementById("OtherToCart").value = '';
	var Sub = 0;
	for (var i = 1; i <= document.getElementById("OtherLoopCounter").value; i++)  {
		var OtherQty = "OtherQuantity" + i;
		var OtherID = "OtherID" + i;
		var OtherPrice = "OtherPrice" + i;
		var Sub = Sub + (parseFloat(document.getElementById(OtherQty).value) * parseFloat(document.getElementById(OtherPrice).value));
		document.getElementById("OtherToCart").value = document.getElementById("OtherToCart").value + document.getElementById(OtherQty).value + "," + document.getElementById(OtherID).value + "," + document.getElementById(OtherPrice).value + "|";
	}
	document.getElementById("OtherToCart").value = document.getElementById("OtherToCart").value.slice(0, -1);
	document.getElementById("txtOtherTotal").innerHTML = Sub;
	//calculate the MyWay total
	getMyWayCost();
	//return answer;
}
//  End -->


<!-- Begin
function getMyWayCost()
{
	var MyWayCost = parseFloat(document.getElementById("txtSkeinsTotal").innerHTML) + parseFloat(document.getElementById("txtFabricTotal").innerHTML) + parseFloat(document.getElementById("txtOtherTotal").innerHTML);
	document.getElementById("txtMyWayTotal").innerHTML = MyWayCost.toFixed(2);
	document.getElementById("MyWayTotal").value = MyWayCost.toFixed(2);
	//getCartReady();
}
//  End -->



<!-- Begin
function getFlossCartReady()
{	
	//prepare the floss for the cart FlossToCart
	document.getElementById("FlossToCart").value = '';	
	for (var i = 1; i <= document.getElementById("FlossLoopCounter").value; i++)  {
		var Fqty = "FlossQuantity" + i;
		var Fid = "FlossID" + i;
		//if(i > 35){alert(Fqty + " " + Fid);}
		if(i == document.getElementById("FlossLoopCounter").value){
			document.getElementById("FlossToCart").value = document.getElementById("FlossToCart").value + document.getElementById(Fqty).value + "|" + document.getElementById(Fid).value;
			}
		else
			{
			document.getElementById("FlossToCart").value = document.getElementById("FlossToCart").value + document.getElementById(Fqty).value + "|" + document.getElementById(Fid).value + ",";
			}
		}
}
//  End -->
