function prot(field) {
	var thisone = field.name;
	var breakit = thisone.split('-');
	var number = document.FF_CCAuthForm.elements["qty-"+breakit[1]].value;
	total = "$" + (number * 170) + ".00";
	document.FF_CCAuthForm.elements["total-"+breakit[1]].value = total;
}

function addnewRow(){
	var nextRowNum = getNextRowNum();
	var rowStr = getNextRowString(nextRowNum);
	$("#FF_FormFields").append(rowStr);
	var theNextRowDiv = "#nextRow_"+nextRowNum;
	$(theNextRowDiv).fadeIn("normal");	
}

function deleteRow(theRow){
	var theDivId = "#nextRow_"+theRow;
	$(theDivId).remove();
	var totalRows2 = parseFloat(document.FF_CCAuthForm.totalRows.value);
	//totalRows2 = totalRows2 - 1;
	//document.FF_CCAuthForm.totalRows.value = totalRows2;
	getTotalAmount();
}

function getNextRowNum(){
	var theVal = parseFloat(document.FF_CCAuthForm.totalRows.value);
	theVal++;
	document.FF_CCAuthForm.totalRows.value = theVal;
	return(theVal);
}

/*function getNextRowString(theNextRow){
	var formFieldLine1 = "<div id='nextRow_"+theNextRow+"' class='newRow'><a href=\"#\" onclick='deleteRow("+theNextRow+")'>Delete Row</a><input type='text' name='shieldSize_"+theNextRow+"' id='shieldSize_"+theNextRow+"' class='inputField1' />";
	var formFieldLine2 = "<input type='text' name='jobNum_"+theNextRow+"' id='jobNum_"+theNextRow+"' class='inputField2'/>";
	var formFieldLine3 = "<input type='text' name='quant_"+theNextRow+"' id='quant_"+theNextRow+"' class='inputField2'  onblur='doSecCalc(this);' />";
	var formFieldLine4 = "<input type='text' name='unitP_"+theNextRow+"' id='unitP_"+theNextRow+"' class='inputField2'  onblur='doSecCalc(this);' />";
	var formFieldLine5 = "<input type='text' name='subtotal_"+theNextRow+"' id='subtotal_"+theNextRow+"' class='inputField3' readonly />";
	var formFieldLine6 = "<div class='clearLeft'></div></div>";
	var newRowString = formFieldLine1 + "\n" + formFieldLine2 + "\n" + formFieldLine3 + "\n" + formFieldLine4 + "\n" + formFieldLine5 + "\n" + formFieldLine6;
	return(newRowString);
}*/

function getNextRowString(theNextRow){
	var formFieldLine1 = "<div id='nextRow_"+theNextRow+"'><table border=\"0\" cellspacing=\"2\" cellpadding=\"1\"class=\"cuRfq\" style=\"line-height: 14px; width: 580px;\"><tr>";
	var formFieldLine2 = "<td style=\"width: 180px;\"><select  onchange=\"pps("+theNextRow+");\" name=\"shieldSize_"+theNextRow+"\" id=\"shieldSize_"+theNextRow+"\" style=\"width: 175px;\"><option value=\"\">[Please Select]</option><optgroup label=\"Height: 0.250 Inches\"><option value=\".5 x .5 x .25\">0.5 x .5 x .25</option><option value=\".5 x .75 x .25\">0.5 x .75 x .25</option><option value=\".5 x 1.0 x .25\">0.5 x 1.0 x .25</option><option value=\".75 x .75 x .25\">0.75 x .75 x .25</option><option value=\".75 x 1.125 x .25\">0.75 x 1.125 x .25</option><option value=\".75 x 1.5 x .25\">0.75 x 1.5 x .25</option><option value=\"1.0 x 1.0 x .25\">1.0 x 1.0 x .25</option><option value=\"1.0 x 1.5 x .25\">1.0 x 1.5 x .25</option><option value=\"1.0 x 2.0 x .25\">1.0 x 2.0 x .25</option><option value=\"1.5 x 1.5 x .25\">1.5 x 1.5 x .25</option><option value=\"1.5 x 2.25 x .25\">1.5 x 2.25 x .25</option><option value=\"1.5 x 3.0 x .25\">1.5 x 3.0 x .25</option><option value=\"2.0 x 2.0 x .25\">2.0 x 2.0 x .25</option><option value=\"2.0 x 3.0 x .25\">2.0 x 3.0 x .25</option><option value=\"2.0 x 4.0 x .25\">2.0 x 4.0 x .25</option><option value=\"2.5 x 2.5 x .25\">2.5 x 2.5 x .25</option><option value=\"2.5 x 3.75 x .25\">2.5 x 3.75 x .25</option><option value=\"2.5 x 5.0 x .25\">2.5 x 5.0 x .25</option></optgroup><optgroup label=\"Height: 0.500 Inches\"><option value=\".5 x .5 x .5\">0.5 x .5 x .5</option><option value=\".5 x .75 x .5\">0.5 x .75 x .5</option><option value=\".5 x 1.0 x .5\">0.5 x 1.0 x .5</option><option value=\".75 x .75 x .5\">0.75 x .75 x .5</option><option value=\".75 x 1.125 x .5\">0.75 x 1.125 x .5</option><option value=\".75 x 1.5 x .5\">0.75 x 1.5 x .5</option><option value=\"1.0 x 1.0 x .5\">1.0 x 1.0 x .5</option><option value=\"1.0 x 1.5 x .5\">1.0 x 1.5 x .5</option><option value=\"1.0 x 2.0 x .5\">1.0 x 2.0 x .5</option><option value=\"1.5 x 1.5 x .5\">1.5 x 1.5 x .5</option><option value=\"1.5 x 2.25 x .5\">1.5 x 2.25 x .5</option><option value=\"1.5 x 3.0 x  .5\">1.5 x 3.0 x .5</option><option value=\"2.0 x 2.0 x .5\">2.0 x 2.0 x .5</option><option value=\"2.0 x 3.0 x .5\">2.0 x 3.0 x .5</option><option value=\"2.0 x 4.0 x .5\">2.0 x 4.0 x .5</option><option value=\"2.5 x 2.5 x .5\">2.5 x 2.5 x .5</option><option value=\"2.5 x 3.75 x .5\">2.5 x 3.75 x .5</option><option value=\"2.5 x 5.0 x .5\">2.5 x 5.0 x .5</option></optgroup><optgroup label=\"Height: 0.750 Inches\"><option value=\".5 x .5 x .75\">0.5 x .5 x .75</option><option value=\".5 x .75 x .75\">0.5 x .75 x .75</option><option value=\".5 x 1.0 x .75\">0.5 x 1.0 x .75</option><option value=\".75 x .75 x .75\">0.75 x .75 x .75</option><option value=\".75 x 1.125 x .75\">0.75 x 1.125 x .75</option><option value=\".75 x 1.5 x .75\">0.75 x 1.5 x .75</option><option value=\"1.0 x 1.0 x .75\">1.0 x 1.0 x .75</option><option value=\"1.0 x 1.5 x .75\">1.0 x 1.5 x .75</option><option value=\"1.0 x 2.0 x .75\">1.0 x 2.0 x .75</option><option value=\"1.5 x 1.5 x .75\">1.5 x 1.5 x .75</option><option value=\"1.5 x 2.25 x .75\">1.5 x 2.25 x .75</option><option value=\"1.5 x 3.0 x .75\">1.5 x 3.0 x .75</option><option value=\"2.0 x 2.0 x .75\">2.0 x 2.0 x .75</option><option value=\"2.0 x 3.0 x .75\">2.0 x 3.0 x .75</option><option value=\"2.0 x 4.0 x .75\">2.0 x 4.0 x .75</option><option value=\"2.5 x 2.5 x .75\">2.5 x 2.5 x .75</option><option value=\"2.5 x 3.75 x .75\">2.5 x 3.75 x .75</option><option value=\"2.5 x 5.0 x .75\">2.5 x 5.0 x .75</option></optgroup></select></td>";
	var formFieldLine3 = '<td style="width: 80px;"><input type="text" name="pps_'+theNextRow+'" id="pps_'+theNextRow+'" class="inputField2" style="width: 75px;" readonly /></td>';
	var formFieldLine4 = '<td style="width: 80px;"><input type="text" name="numSheets_'+theNextRow+'" id="numSheets_'+theNextRow+'" class="inputField2" onblur="doSecCalc(this); getTotalAmount();" style="width: 75px;" value="" /></td>';
	var formFieldLine5 = '<td style="width: 65px;"><b>$65.00</b></td>';
	var formFieldLine6 = '<td style="width: 75px;"><input type="text" name="subtotal_'+theNextRow+'" id="subtotal_'+theNextRow+'" class="inputField3" readonly style="width: 70px;" value="$150.00" /></td>';
	var formFieldLine7 = '<td style="width: 60px;"><input type="button" onclick="deleteRow('+theNextRow+')" value="Delete" style="width: 45px;"></td>';
	var formFieldLine8 = "</tr></table></div>";
	var newRowString = formFieldLine1 + "\n" + formFieldLine2 + "\n" + formFieldLine3 + "\n" + formFieldLine4 + "\n" + formFieldLine5 + "\n" + formFieldLine6 + "\n" + formFieldLine7 + "\n" + formFieldLine8;
	return(newRowString);
}


function doSecCalc(formFld){
	var theCurrFldName = formFld.name;
	var theStrArray = theCurrFldName.split('_');
	var theCurrIndex = theStrArray[1];
	var theQuant = document.FF_CCAuthForm.elements["numSheets_"+theStrArray[1]].value;
	//if (theQuant = 1) {
	//	alert ("You must select at least 2 sheets");
	//	document.FF_CCAuthForm.elements["numSheets_"+theStrArray[1]].value = "2";
	//	var theQuant = document.FF_CCAuthForm.elements["numSheets_"+theStrArray[1]].value;
	//	getTotalAmount();
	//}
	var theUnitP = 75.00;
	//var theUnitP = document.FF_CCAuthForm.elements["unitP_"+theStrArray[1]].value;
		if((theQuant == "") || (theUnitP == "")){
			document.FF_CCAuthForm.elements["subtotal_"+theStrArray[1]].value = "$0.00";
		}else{
			var theQuantVal= parseFloat(theQuant);
			var theUnitVal = parseFloat(theUnitP);
			var theTotalVal = theQuantVal * theUnitVal;
			var theTotalAmount = Math.round(theTotalVal*100)/100;
			var subToFld = "subtotal_"+theStrArray[1];
			document.FF_CCAuthForm.elements[subToFld].value = "$"+theTotalAmount;
			//document.FF_CCAuthForm.elements["numSheets_"+theStrArray[1]].focus();
			//checkForFinalChar(subToFld);
		}
}	

function getTotalAmount(){
	var totalRows = parseFloat(document.FF_CCAuthForm.totalRows.value);
	var theTotalAmt = 0;
	for(i=0;i<=totalRows;i++){
		var theCurrField = "subtotal_"+i;
		if (typeof document.FF_CCAuthForm.elements[theCurrField] != 'undefined') {
			var theCurrStr = document.FF_CCAuthForm.elements[theCurrField].value;
			var theCurrAmt = parseFloat(theCurrStr.substring(1,theCurrStr.length));
			theTotalAmt = theTotalAmt + theCurrAmt;
		}
	}
	var theSubTotalAmount = Math.round(theTotalAmt*100)/100;
	
	document.FF_CCAuthForm.completeTotal.value = "$"+theSubTotalAmount+".00";
	var theFinalFld = "completeTotal";
	//checkForFinalChar(theFinalFld);
}

function checkForFinalChar(thFld){
	var theCurrVal = document.FF_CCAuthForm.elements[thFld].value;
	var theStrArray = theCurrVal.split('.');
	var theChange = theStrArray[1];
	alert (theChange);
	if(theChange.length = 1){
		theCurrVal = theCurrVal+"0";
		document.FF_CCAuthForm.elements[thFld].value = theCurrVal;
	}
}

function pps(num) {
	var pps_string = document.FF_CCAuthForm.elements["shieldSize_"+num].value
	if (pps_string == ".5 x .5 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "176";}
	if (pps_string == ".5 x .75 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "120";}
	if (pps_string == ".5 x 1.0 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "112";}
	if (pps_string == ".75 x .75 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "104";}
	if (pps_string == ".75 x 1.125 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "80";}
	if (pps_string == ".75 x 1.5 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "64";}
	if (pps_string == "1.0 x 1.0 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "77";}
	if (pps_string == "1.0 x 1.5 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "55";}
	if (pps_string == "1.0 x 2.0 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "44";}
	if (pps_string == "1.5 x 1.5 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "40";}
	if (pps_string == "1.5 x 2.25 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "32";}
	if (pps_string == "1.5 x 3.0 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "24";}
	if (pps_string == "2.0 x 2.0 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "24";}
	if (pps_string == "2.0 x 3.0 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "18";}
	if (pps_string == "2.0 x 4.0 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "12";}
	if (pps_string == "2.5 x 2.5 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "15";}
	if (pps_string == "2.5 x 3.75 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "12";}
	if (pps_string == "2.5 x 5.0 x .25") {document.FF_CCAuthForm.elements["pps_"+num].value = "10";}
	if (pps_string == ".5 x .5 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "70";}
	if (pps_string == ".5 x .75 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "84";}
	if (pps_string == ".5 x 1.0 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "50";}
	if (pps_string == ".75 x .75 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "54";}
	if (pps_string == ".75 x 1.125 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "45";}
	if (pps_string == ".75 x 1.5 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "36";}
	if (pps_string == "1.0 x 1.0 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "50";}
	if (pps_string == "1.0 x 1.5 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "32";}
	if (pps_string == "1.0 x 2.0 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "25";}
	if (pps_string == "1.5 x 1.5 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "24";}
	if (pps_string == "1.5 x 2.25 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "18";}
	if (pps_string == "1.5 x 3.0 x  .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "16";}
	if (pps_string == "2.0 x 2.0 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "15";}
	if (pps_string == "2.0 x 3.0 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "12";}
	if (pps_string == "2.0 x 4.0 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "12";}
	if (pps_string == "2.5 x 2.5 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "12";}
	if (pps_string == "2.5 x 3.75 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "8";}
	if (pps_string == "2.5 x 5.0 x .5") {document.FF_CCAuthForm.elements["pps_"+num].value = "6";}
	if (pps_string == ".5 x .5 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "60";}
	if (pps_string == ".5 x .75 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "50";}
	if (pps_string == ".5 x 1.0 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "48";}
	if (pps_string == ".75 x .75 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "45";}
	if (pps_string == ".75 x 1.125 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "32";}
	if (pps_string == ".75 x 1.5 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "30";}
	if (pps_string == "1.0 x 1.0 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "36";}
	if (pps_string == "1.0 x 1.5 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "18";}
	if (pps_string == "1.0 x 2.0 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "18";}
	if (pps_string == "1.5 x 1.5 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "18";}
	if (pps_string == "1.5 x 2.25 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "15";}
	if (pps_string == "1.5 x 3.0 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "12";}
	if (pps_string == "2.0 x 2.0 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "12";}
	if (pps_string == "2.0 x 3.0 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "12";}
	if (pps_string == "2.0 x 4.0 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "8";}
	if (pps_string == "2.5 x 2.5 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "8";}
	if (pps_string == "2.5 x 3.75 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "8";}
	if (pps_string == "2.5 x 5.0 x .75") {document.FF_CCAuthForm.elements["pps_"+num].value = "4";}
}