var TubeDiameter = 0.0



function formatNum(expr,decplaces)

{ 

var str = (Math.round(parseFloat(expr) * Math.pow(10,decplaces))).toString( )

while (str.length <= decplaces)

{

str = "0" + str

}

var decpoint = str.length - decplaces

return str.substring(0,decpoint) + "." +str.substring(decpoint,str.length)

}

 

function mainc(form, callingField)

{

	if ( form.formtype.value == "all" ) 

	{

               	calcGsht(form)

	calcRod(form)

	}

	if ( form.formtype.value == "all" ) 

	{

	if(form.rodtotalprice.value != "" && form.sheettotalprice.value != "" )

	{

		form.grandtotal.value = parseFloat(form.rodtotalprice.value) + parseFloat(form.sheettotalprice.value)

		form.grandtotal.value = formatNum(form.grandtotal.value,2)

	} else if(form.rodtotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.rodtotalprice.value,2) 

	} else if(form.sheettotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.sheettotalprice.value,2) 

	}	

    } else {

	if( form.sheettotalprice.value != "" )

	{

		form.grandtotal.value =  formatNum(form.sheettotalprice.value,2)

	} else if(form.sheettotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.sheettotalprice.value,2) 

	}



}

}





function mains(form, callingField)

{

	if ( form.formtype.value == "sheet" ) 

	{

	calcGsht(form)

	}

	if ( form.formtype.value == "sheet" ) 

	{

	if( form.sheettotalprice.value != "" )

	{

		form.grandtotal.value =  formatNum(form.sheettotalprice.value,2)

	} else if(form.sheettotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.sheettotalprice.value,2) 

	}



}

}



function mainr(form, callingField)

{

	if ( form.formtype.value == "rod" ) 

	{

	calcRod(form)

	}

	if ( form.formtype.value == "rod" ) 

	{

	if( form.rodtotalprice.value != "" )

	{

		form.grandtotal.value =  formatNum(form.rodtotalprice.value,2)

	} else if(form.rodtotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.rodtotalprice.value,2) 

	}



}

}



function mainr1(form, callingField)

{

	if ( form.formtype.value == "rod1" ) 

	{

	calcRod(form)

	}

	if ( form.formtype.value == "rod1" ) 

	{

	if( form.rodtotalprice.value != "" )

	{

		form.grandtotal.value =  formatNum(form.rodtotalprice.value,2)

	} else if(form.rodtotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.rodtotalprice.value,2) 

	}



}

}





function maint(form, callingField)

{

	if ( form.formtype.value == "tube" ) 

	{

	calcTube(form)

	}

	

	if ( form.formtype.value == "tube" ) 

	{

		if( form.TotalPrice.value != "" )

		{

		form.grandtotal.value =  formatNum(form.TotalPrice.value,2)

		} else 

		if(form.TotalPrice.value != "")

		{

		form.grandtotal.value = formatNum(form.TotalPrice.value,2) 

		}

	}else

		if ( form.formtype.value == "tubing" ) 

		{

		TubeDiameter = form.TubePerFt.value

		calcTubing(form)

		}

		if ( form.formtype.value == "tubing" ) 

		{

			if( form.TotalPrice.value != "" )

			{

			form.grandtotal.value =  formatNum(form.TotalPrice.value,2)

			} else 

			if(form.TotalPrice.value != "")

			{

			form.grandtotal.value = formatNum(form.TotalPrice.value,2) 

			}

		}else

			if ( form.formtype.value == "tube1" ) 

			{

			calcTube1(form)

			}

			if ( form.formtype.value == "tube1" ) 

			{

				if( form.TotalPrice.value != "" )

				{

				form.grandtotal.value =  formatNum(form.TotalPrice.value,2)

				}else 

				if(form.TotalPrice.value != "")

					{

					form.grandtotal.value = formatNum(form.TotalPrice.value,2) 

					}

				}else

				if ( form.formtype.value == "tube3" ) 

				{

				calcTube3(form)

				}

				if ( form.formtype.value == "tube3" ) 

				{

					if( form.TotalPrice.value != "" )

					{

					form.grandtotal.value =  formatNum(form.TotalPrice.value,2)

					} else 	

					if(form.TotalPrice.value != "")

					{

					form.grandtotal.value = formatNum(form.TotalPrice.value,2) 

					}

				}else

				if ( form.formtype.value == "tube4" ) 

				{

				calcTube4(form)

				}

				if ( form.formtype.value == "tube4" ) 

				{

					if( form.TotalPrice.value != "" )

					{

					form.grandtotal.value =  formatNum(form.TotalPrice.value,2)

					} else 	

					if(form.TotalPrice.value != "")

					{

					form.grandtotal.value = formatNum(form.TotalPrice.value,2) 

					}



				

			}

		}



function main4(form, callingField)

{

	

		if (form.shape.selectedIndex == "0" || form.sheetqty.value == "" || 

    		form.shtwidthlength.selectedIndex == "0"  || 

    		form.sheetthickness.selectedIndex == "0")

    {

	} else  {

       

        	var sheetqty = form.sheetqty.value

        	var sheetthickness=form.sheetthickness.options[form.sheetthickness.selectedIndex].value

        	var sheetcolor=form.sheetcolor.options[form.sheetcolor.selectedIndex].value

        	var sheetsize=form.shtwidthlength.options[form.shtwidthlength.selectedIndex].value

        	var persqft=sheetthickness

        	var persheet=sheetthickness*sheetsize

        	var sheettotal= persheet*sheetqty

  		calcSheetDiscount(form, sheettotal, persqft, persheet)

        	// alert("just completed calcDiscount")

               }



	{

	if (form.rodshape.selectedIndex == "0" || form.rodqty.value == "" || 

    		form.RodDiameter.selectedIndex == "0" || 

    		form.RodLength.selectedIndex == "0")

    {

	} else {



        	var rodqty = form.rodqty.value

        	var RodDiameter=form.RodDiameter.options[form.RodDiameter.selectedIndex].value

        	var RodColor=form.RodColor.options[form.RodColor.selectedIndex].value

        	var RodLength=form.RodLength.value

        	var PerRod=RodDiameter

        	var PerFt=RodDiameter*RodLength

        	var RodTotal= PerFt * rodqty

  		calcRodDiscount(form, RodTotal, PerFt, PerRod)

               }

               }   

	{

	if(form.sheettotalprice.value != "" && form.rodtotalprice.value != "" )

	{

		form.grandtotal.value = parseFloat(form.sheettotalprice.value) +                                                                                                                                                                                                                                                 parseFloat(form.rodtotalprice.value)

	}

	 else if(form.sheettotalprice.value != "")

		form.grandtotal.value =  formatNum(form.sheettotalprice.value,2)

	

	else if(form.rodtotalprice.value != "")

		form.grandtotal.value = formatNum(form.rodtotalprice.value,2) 



	 else if(form.sheettotalprice.value != ""&& form.rodtotalprice.value != "" )

	               	form.grandtotal.value = formatNum(form.grandtotal.value,2)



	}

}









	





function calcGsht(form)

{



	if (form.shape.selectedIndex == "0" || form.sheetqty.value == "" || 

    		form.shtwidthlength.selectedIndex == "0"  || 

    		form.sheetthickness.selectedIndex == "0")

	{

        

	} else {

       

        	var sheetqty = form.sheetqty.value

        	var sheetthickness=form.sheetthickness.options[form.sheetthickness.selectedIndex].value

        	var sheetcolor=form.sheetcolor.options[form.sheetcolor.selectedIndex].value

        	var sheetsize=form.shtwidthlength.options[form.shtwidthlength.selectedIndex].value

        	var persqft=sheetthickness

        	var persheet=sheetthickness*sheetsize

        	var sheettotal= persheet*sheetqty

  		calcSheetDiscount(form, sheettotal, persqft, persheet)

        	// alert("just completed calcDiscount")

        }

}  







  

          

function calcRod(form)

{

	if (form.rodshape.selectedIndex == "0" || form.rodqty.value == "" || 

    		form.RodDiameter.selectedIndex == "0" || 

    		form.RodLength.selectedIndex == "0")



	{

	

	} else {



        	var rodqty = form.rodqty.value

        	var RodDiameter=form.RodDiameter.options[form.RodDiameter.selectedIndex].value

        	var RodColor=form.RodColor.options[form.RodColor.selectedIndex].value

        	var RodLength=form.RodLength.value

        	var PerRod=RodDiameter

        	var PerFt=RodDiameter*RodLength

        	var RodTotal= PerFt * rodqty

  		calcRodDiscount(form, RodTotal, PerFt, PerRod)

        }

}   



function calcTube1(form)

{

        	var TubeTotal = 0.0

        	var TubeDiscount = 0.0

	var TotalPrice = 0.0

	var TubeQty = form.TubeQty.value

	var TubePerFt = form.TubePerFt.value	

        	var TubeTotal = TubePerFt * TubeQty

  	calcTubeDiscount(form, TubeTotal)



}





function calcTube3(form)

{

        	var TubeTotal = 0.0

        	var TubeDiscount = 0.0

	var TotalPrice = 0.0

	var TubeQty = form.TubeQty.value

	var TubePerFt = form.TubePerFt.value	

        	var TubeTotal = TubePerFt * TubeQty

  	calcTubeDiscount(form, TubeTotal)



}



function calcTube4(form)

{

        	var TubeTotal = 0.0

        	var TubeDiscount = 0.0

	var TotalPrice = 0.0

	var TubeQty = form.TubeQty.value

	var TubePerFt = form.TubeDiameter.options[form.TubeDiameter.selectedIndex].value

	var TubeLength = form.TubeLength.value * 1

	var tubeitem = TubeLength * TubePerFt 	

        	var TubeTotal = tubeitem * TubeQty

  	calcTubeDiscount(form, TubeTotal)

	form.tubeitem.value = formatNum(tubeitem,2)

	form.TubePerFt.value = formatNum(TubePerFt,2)

}





function calcTube(form)

{

        	var TubeTotal = 0.0

        	var TubeDiscount = 0.0

	var TotalPrice = 0.0

	var TubeQty = form.TubeQty.value

	var TubePerFt = form.TubeDiameter.options[form.TubeDiameter.selectedIndex].value	

        	form.TubePerFt.value = form.TubeDiameter.options[form.TubeDiameter.selectedIndex].value

        	var TubeTotal = TubePerFt * TubeQty

  	calcTubeDiscount(form, TubeTotal)



}

 



function calcTubing(form)

{

        	var TubeTotal = 0.0

        	var TubeDiscount = 0.0

	var TotalPrice = 0.0

	var TubeQty = form.TubeQty.value

	var TubePerFt = TubeDiameter	

        	form.TubePerFt.value = TubeDiameter

        	var TubeTotal = TubePerFt * TubeQty

  	calcTubeDiscount(form, TubeTotal)



}

  



function calcTubeDiscount(form, TubeTotal)

{



/* 	

 *      This is the discount schedule that is used to

 *	calculate the discount for the quantity of goods

 *	selected for tube plastic. 

 */

	var TubeDiscount = 0.0

	var TotalPrice = 0.0	

	

	if ( TubeTotal > 1499.995)

	{

		TubeDiscount = TubeTotal * .375



	} else if ( TubeTotal > 999.995 )

	{

		TubeDiscount = TubeTotal * .35



	} else if ( TubeTotal > 749.995)

	{

		TubeDiscount = TubeTotal * .333



	} else if ( TubeTotal > 574 )

	{

		TubeDiscount = TubeTotal * .30

	} else if ( TubeTotal > 400 )

	{

		TubeDiscount = TubeTotal * .25

	} else if ( TubeTotal > 274.995 )

	{

		TubeDiscount = TubeTotal * .20

	} else if ( TubeTotal > 125.995 )

	{

		TubeDiscount = TubeTotal * .10

	} 



        TotalPrice = (TubeTotal - TubeDiscount) 	

        form.TubeDiscount.value=formatNum(TubeDiscount,2)

        form.TotalPrice.value=formatNum(TotalPrice,2)

        form.TubeTotal.value=formatNum(TubeTotal,2)





         return 

}









           

function calcRodDiscount(form, RodTotal, PerFt, PerRod)

{



/* 	

 *      This is the discount schedule that is used to

 *	calculate the discount for the quantity of goods

 *	selected for rod plastic. 

 */

	

	var RodDiscount = 0.0

        form.RodPerFt.value=PerRod

        form.roditem.value=formatNum(PerFt,2)

        form.RodTotal.value=formatNum(RodTotal,2)



	if ( RodTotal > 1499.995)

	{

		// alert(RodTotal)

		RodDiscount = RodTotal * .375

	  	RodTotal = RodTotal * .625

		// PerFt= PerFt * .625

		// PerRod= PerRod * .625

	} else if ( RodTotal > 999.995 )

	{

		RodDiscount = RodTotal * .35

	  	RodTotal = RodTotal * .65

		// PerFt= PerFt * .65

		// PerRod= PerRod * .65

	} else if ( RodTotal > 749.995)

	{

		RodDiscount = RodTotal * .333

	  	RodTotal = RodTotal * .666

		// PerFt= PerFt * .666

		// PerRod= PerRod * .666

	} else if ( RodTotal > 574 )

	{

		RodDiscount = RodTotal * .30

	  	RodTotal = RodTotal * .70

		// PerFt= PerFt * .70

		// PerRod = PerRod * .70

	} else if ( RodTotal > 400 )

	{

		RodDiscount = RodTotal * .25

	  	RodTotal = RodTotal * .75

		// PerFt= PerFt * .75

		// PerRod = PerRod * .75

	} else if ( RodTotal > 274.995 )

	{

		RodDiscount = RodTotal * .20

	  	RodTotal = RodTotal * .80

		// PerFt= PerFt * .80

		// PerRod= PerRod * .80

	} else if ( RodTotal > 125.995 )

	{

		RodDiscount = RodTotal * .10

	  	RodTotal = RodTotal * .90

		// PerFt= PerFt * .90

		// PerRod= PerRod * .90

	} 

	

        form.roddiscount.value=formatNum(RodDiscount,2)

        form.rodtotalprice.value=formatNum(RodTotal,2)

	





        return 

}







function calcSheetDiscount(form, sheettotal, persqft, persheet)

{



/* 	

 *      This is the discount schedule that is used to

 *	calculate the discount for the quantity of goods

 *	selected for sheet plastic. 

 */



        form.ShtTotal.value=formatNum(sheettotal,2)

        form.ShtPerFt.value=formatNum(persqft,2)

        form.sheetitem.value=formatNum(persheet,2)

	var SheetDiscount = 0.0



	if ( sheettotal > 1499.995)

	{

		// alert("Doing a discount")

		SheetDiscount = sheettotal * .375

	  	sheettotal = sheettotal * .625

		// persqft= persqft * .625

		// persheet= persheet * .625

	} else if ( sheettotal > 999.995 )

	{

		// alert("Doing a discount")

		SheetDiscount = sheettotal * .35

	  	sheettotal = sheettotal * .65

		// persqft= persqft * .65

		// persheet= persheet * .65

	} else if ( sheettotal > 749.995)

	{

		// alert("Doing a discount")

		SheetDiscount = sheettotal * .333

	  	sheettotal = sheettotal * .666

		// persqft= persqft * .666

		// persheet= persheet * .666

	} else if ( sheettotal > 574 )

	{

		// alert("Doing a discount")

		SheetDiscount = sheettotal * .30

	  	sheettotal = sheettotal * .70

		// persqft= persqft * .70

		// persheet = persheet * .70

	} else if ( sheettotal > 400 )

	{

		// alert("Doing a discount")

		SheetDiscount = sheettotal * .25 

	  	sheettotal = sheettotal * .75

		// persqft= persqft * .75

		// persheet = persheet * .75

	} else if ( sheettotal > 274.995 )

	{

		// alert("Doing a discount")

		SheetDiscount = sheettotal * .20 

	  	sheettotal = sheettotal * .80

		// persqft= persqft * .80

		// persheet= persheet * .80

	} else if ( sheettotal > 125.995 )

	{

		// alert("Doing a discount")

		SheetDiscount = sheettotal * .10

	  	sheettotal = sheettotal * .90

		// persqft= persqft * .90

		// persheet= persheet * .90

	} 

	

        form.sheetdiscount.value=formatNum(SheetDiscount,2)

        form.sheettotalprice.value=formatNum(sheettotal,2)

	





        return 

}



function clearRod(form, callingfield)

{

 

/*

 * This function clears the Rod section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 

	form.grandtotal.value="" 

	form.rodtotalprice.value = "" 

	form.roddiscount.value = ""



        	form.RodPerFt.value=""

        	form.roditem.value=""

        	form.RodTotal.value=""

       	form.rodqty.value = "1" 

	form.RodDiameter.selectedIndex = "0" 

        	form.RodColor.selectedIndex = "0" 

 	form.RodLength.value = ""

	form.rodshape.selectedIndex = "0" 



}



function clearRod1(form, callingfield)

{

 

/*

 * This function clears the Rod section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 

	form.grandtotal.value="" 

	form.rodtotalprice.value = "" 

	form.roddiscount.value = ""



        	form.RodPerFt.value=""

        	form.roditem.value="1"

        	form.RodTotal.value=""

       	form.rodqty.value = "1" 

	form.RodDiameter.selectedIndex = "0" 

        	form.RodColor.selectedIndex = "0" 

	form.rodshape.selectedIndex = "0" 



}



function clearTube(form, callingfield)

{

 

/*

 * This function clears the Tube section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 

	form.grandtotal.value="" 

	form.TotalPrice.value = "" 

	form.TubeDiscount.value = ""



        	form.TubePerFt.value=""

        	form.TubeTotal.value=""

       	form.TubeQty.value = "1" 

	form.TubeDiameter.selectedIndex = "0" 

	form.formula.selectedIndex = "0" 

	form.TubeColor.selectedIndex = "0" 

}



function clearTubing2(form, callingfield)

{

 

/*

 * This function clears the Tube section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 

	form.grandtotal.value="" 

	form.TotalPrice.value = "" 

	form.TubeDiscount.value = ""

	form.formula.selectedIndex = "0"	

        	form.TubePerFt.value=""

        	form.TubeTotal.value=""

       	form.TubeQty.value = "1" 

	form.insidediameter.selectedIndex = "0" 

	form.outsidediameter.selectedIndex = "0"

	form.wallthickness.selectedIndex = "0"

}



function clearTubing1(form, callingfield)

{

 

/*

 * This function clears the Tube section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 

	form.grandtotal.value="" 

	form.TotalPrice.value = "" 

	form.TubeDiscount.value = ""

	form.formula.selectedIndex = "0"	

        	form.TubePerFt.value=""

        	form.TubeTotal.value=""

       	form.TubeQty.value = "1" 

	form.TubeDiameter.selectedIndex = "0" 

	form.TubeColor.selectedIndex = "0"

}



function clearTubing3(form, callingfield)

{

 

/*

 * This function clears the Tube section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 

	form.grandtotal.value="" 

	form.TotalPrice.value = "" 

	form.TubeDiscount.value = ""

	form.formula.selectedIndex = "0"	

        	form.TubePerFt.value=""

        	form.TubeTotal.value=""

       	form.TubeQty.value = "1" 

	form.TubeDiameter.selectedIndex = "0" 



}



function clearTubing4(form, callingfield)

{

 

/*

 * This function clears the Tube section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 

	form.grandtotal.value="" 

	form.TotalPrice.value = "" 

	form.TubeDiscount.value = ""

	form.formula.selectedIndex = "0"	

        	form.TubePerFt.value=""

        	form.TubeTotal.value=""

       	form.TubeQty.value = "1" 

	form.TubeDiameter.selectedIndex = "0" 

	form.tubeitem.value = ""

}





function clearRod(form, callingfield)

{

 

/*

 * This function clears the Rod section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 



        	form.RodPerFt.value=""

        	form.roditem.value=""   

        	form.RodTotal.value=""

        	form.rodtotalprice.value=""

	form.roddiscount.value = ""

	if(callingfield == "shape")

	{

        	form.qty.value = "1" 

	}

	form.RodDiameter.selectedIndex = "" 

    form.RodLength.value = ""

    form.RodColor.selectedIndex = "" 

 	form.rodshape.selectedIndex = ""

 	form.grandtotal.value="" 



}



function clearSheet(form, callingfield)

{

 

/*

 * This function clears the Sheet section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 



                form.customwidth.value="0"

	form.customlength.value="0"





	form.tolerance.selectedIndex="0"

	form.circle.selectedIndex="0"

	form.shape.customwidth="0"

	form.shape.customheight="0"

	form.shape.selectedIndex="0"

	form.sheettotalprice.value="" 

	form.sheetdiscount.value= ""

                form.ShtTotal.value=""

                form.ShtPerFt.value=""

                form.sheetitem.value=""

	form.sheetthickness.selectedIndex="0"

       	form.sheetqty.value= "1" 

	form.shtwidthlength.selectedIndex="0"

                form.sheetcolor.selectedIndex="0"

                form.grandtotal.value="" 

}



function clearTubing(form, callingfield)

{

 

/*

 * This function clears the Tubing section so you don't get any strange data left around

 * when the user changes something else on the page.

 *

 */ 



       	form.qty.selectedIndex="0" 

	form.formula.selectedIndex= "0"

                form.insidediameter.selectedIndex="0"

                form.outsidediameter.selectedIndex="0"

                form.wallthickness.selectedIndex="0"

	form.per100ft.value= "" 

	form.tubetotal.value=""

          

                

}



function createDescription(form) {



var tmp_sheetsize = "";

var sheet_string = "";

var rod_string = "";



/*

  *  Create the Sheet String Description

  *

  */



if(form.shtwidthlength.selectedIndex=="2" ) {

	

	tmp_sheetsize = form.customwidth.value + "in x " + form.customlength.value + "in ";

	sheet_string = form.shape.options[form.shape.selectedIndex].text + ", "

	                      + " " + tmp_sheetsize + ", "   

	                      + form.sheetthickness.options[form.sheetthickness.selectedIndex].text

	                      +", "+ form.tolerance.options[form.tolerance.selectedIndex].text 

	                      +", "+ form.sheetcolor.options[form.sheetcolor.selectedIndex].text; 

	if(form.circle.options[form.circle.selectedIndex].text == "Yes" ) {

	      sheet_string = sheet_string + ", R-Blanks";

	}

	

} else {



     tmp_sheetsize = form.shtwidthlength.options[form.shtwidthlength.selectedIndex].text;

     sheet_string = form.shape.options[form.shape.selectedIndex].text + ","

	+ "  " + tmp_sheetsize + ", "   

	+ form.sheetthickness.options[form.sheetthickness.selectedIndex].text

	 +", "+ form.sheetcolor.options[form.sheetcolor.selectedIndex].text; 

}



if ( form.formtype.value == "all" ) {



     if (form.inch.value == "Y"){

	rod_string = form.rodshape.options[form.rodshape.selectedIndex].text + ", "

		+ form.RodLength.value + " in, " 

		+ form.RodDiameter.options[form.RodDiameter.selectedIndex].text

		+ ", " + form.RodColor.options[form.RodColor.selectedIndex].text;

	}else{

	rod_string = form.rodshape.options[form.rodshape.selectedIndex].text + ", "

		+ form.RodLength.value + " ft, " 

		+ form.RodDiameter.options[form.RodDiameter.selectedIndex].text

		+ ", " + form.RodColor.options[form.RodColor.selectedIndex].text;

	}



form.roddescription.value=rod_string;

} 

// alert(rod_string);

form.sheetdescription.value=sheet_string;





}





function createDescriptionr(form) {



var tmp_sheetsize = "";

var sheet_string = "";

var rod_string = "";



/*

  *  Create the Rod String Description

  *

  */



if ( form.formtype.value == "rod" ) {

	rod_string = form.rodshape.options[form.rodshape.selectedIndex].text + ", "

		+ form.RodLength.value + " ft, " 

		+ form.RodDiameter.options[form.RodDiameter.selectedIndex].text

		+ ", " + form.RodColor.options[form.RodColor.selectedIndex].text;

form.roddescription.value=rod_string;

} 

// alert(rod_string);

form.sheetdescription.value=sheet_string;



}



function createDescriptionr1(form) {



var tmp_sheetsize = "";

var sheet_string = "";

var rod_string = "";



/*

  *  Create the Rod String Description

  *

  */



if ( form.formtype.value == "rod1" ) {

	rod_string = form.rodshape.options[form.rodshape.selectedIndex].text + ", "

		+ form.RodDiameter.options[form.RodDiameter.selectedIndex].text

		+ ", " + form.RodColor.options[form.RodColor.selectedIndex].text;

form.roddescription.value=rod_string;

} 

// alert(rod_string);

form.sheetdescription.value=sheet_string;



}





function createDescriptiont(form) {





var tmp_sheetsize = "";

var sheet_string = "";

var tube_string = "";



/*

  *  Create the Tube String Description

  *

  */



if ( form.formtype.value == "tube" ) {

	tube_string = form.formula.options[form.formula.selectedIndex].text + ", "

		+ form.TubeDiameter.options[form.TubeDiameter.selectedIndex].text

		+ ", " + form.TubeColor.options[form.TubeColor.selectedIndex].text;



} 



if ( form.formtype.value == "tubing" ) {

	tube_string = form.formula.options[form.formula.selectedIndex].text + ", "

	+ "I.D. "	+ form.insidediameter.options[form.insidediameter.selectedIndex].text +", " 

	+ "O.D." + form.outsidediameter.options[form.outsidediameter.selectedIndex].text + ", "

	+ "Wall" + form.wallthickness.options[form.wallthickness.selectedIndex].text; 

} 





if ( form.formtype.value == "tube1" ) {

	tube_string = form.formula.options[form.formula.selectedIndex].text + ", "

	+ "Outside Diameter " + form.TubeDiameter.options[form.TubeDiameter.selectedIndex].text +", " 

	+ "Wall Thickness" + form.TubeColor.options[form.TubeColor.selectedIndex].text; 

} 





if ( form.formtype.value == "tube3" ) {

	tube_string = form.formula.options[form.formula.selectedIndex].text + ", "

	+ "Tube Diameter " + form.TubeDiameter.options[form.TubeDiameter.selectedIndex].text; 

} 





if ( form.formtype.value == "tube4" ) {

	tube_string = form.formula.options[form.formula.selectedIndex].text + ", "

	+ "O.D. / I.D. " + form.TubeDiameter.options[form.TubeDiameter.selectedIndex].text; 

	form.TubePerFt.value = form.tubeitem.value;

} 





// alert(tube_string);

form.tubedescription.value=tube_string;





}







function createDescriptiont2(form) {





var tmp_sheetsize = "";

var sheet_string = "";

var rod_string = "";



/*

  *  Create the Tubing String Description

  *

  */



if ( form.formtype.value == "rod" ) {

	rod_string = form.rodshape.options[form.rodshape.selectedIndex].text + ", "

		+ form.RodLength.value + " ft, " 

		+ form.RodDiameter.options[form.RodDiameter.selectedIndex].text

		+ ", " + form.RodColor.options[form.RodColor.selectedIndex].text;

form.roddescription.value=rod_string;

} 

// alert(rod_string);

form.sheetdescription.value=sheet_string;





}











/*

 *

 * The following include the standard Polymer Plastics JavaScript functions

 * which calculate the price and discounts. 

 *

 */





function customSheet(form, callingfield)

{

/* 

 *

 * The customSheet function calculates the price of before discount for any

 * custom piece of material, then calls the discountSheet function who updates

 * the page. 

 * 

 *  Variables used in the function are:

 *

 *              form.customwidth.value 

 *              form.customlength.value 

 *              form.tolerance.value

 *              form.circle.value

 *              form.sheetthickness.options[form.sheetthickness.selectedIndex].value

 *      	form.sheetqty.value = "1" 

 *

 * 

 *      var sheetcolor=form.sheetcolor.options[form.sheetcolor.selectedIndex].value

 *      var sheetsize=form.shtwidthlength.options[form.shtwidthlength.selectedIndex].value

 *      var persqft=sheetthickness

 *      var persheet=sheetthickness*sheetsize

 *      var sheettotal= persheet*sheetqty

 *	calcSheetDiscount(form, sheettotal, persqft, persheet)

 *      

 */

	if (form.shape.selectedIndex == "0" || form.sheetqty.value == "" || 

    		form.shtwidthlength.selectedIndex == "0"  || 

    		form.shtwidthlength.selectedIndex == "1"  || 

    		form.sheetthickness.selectedIndex == "0")

	{

        

	} else {



 		var sheetthickness=form.sheetthickness.options[form.sheetthickness.selectedIndex].value

        	var persqft=sheetthickness

		var sheetwidth=formatNum(form.customwidth.value,2)

		var sheetlength=formatNum(form.customlength.value,2)

        	var sheetsize=(sheetwidth/12)*(sheetlength/12)	

	

		var persheet=sheetthickness*sheetsize



		var persheet= persheet*2

	

		var sheettotal=0.00

		sheettotal = persheet*form.sheetqty.value 

	

		var tolerancecharge=0.000

		tolerancecharge=form.tolerance.options[form.tolerance.selectedIndex].value

	

		var circlecharge=form.circle.value*10.00

		var quantitycharge = 0.0

		var quantitycirclecharge

	

		// alert(persheet + " ," + sheetthickness + " ," + tolerancecharge +  " ," + sheetlength)

	

       	/* 	Figure out which should be considered length, make sure customer didn't screw

        	* 	it up, and change them if needed. 

		*/

		if(sheetlength < sheetwidth)

		{

			var tmp_store = sheetlength

			sheetwidth = sheetlength

			sheetlength = tmp_store

		}

		

		/* 

	 	*

	 	* 	Base charge amount that gets set according to the

	 	*      Quantity of material and the Tolerance cuts needed.

	 	*

	 	*/  

	

	  	if(form.sheetqty.value < 10 )

	  	{

			if(tolerancecharge == "15.00")

			{

				quantitycharge = form.sheetqty.value * 1.00

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.75

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.75

	

			}

			quantitycirclecharge=form.sheetqty.value*1.25

	

		} else if(form.sheetqty.value < 50)

		{	

			if(tolerancecharge == "15.00")

			{

				quantitycharge=form.sheetqty.value*.75

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.50

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.30

	

			}

			quantitycirclecharge=form.sheetqty.value*.75

	

		} else if(form.sheetqty.value < 99)

		{	

			if(tolerancecharge == "15.00")

			{

				quantitycharge=form.sheetqty.value*.50

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.40

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.25

	

			}

			quantitycirclecharge=form.sheetqty.value*.60

	

		} else if(form.sheetqty.value < 300)

		{	

			if(tolerancecharge == "15.00")

			{

				quantitycharge=form.sheetqty.value*.40

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.30

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.20

	

			}

			quantitycirclecharge=form.sheetqty.value*.50

		

		} else if(form.sheetqty.value < 600)

		{	

			if(tolerancecharge == "15.00")

			{

				quantitycharge=form.sheetqty.value*.30

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.25

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.17

	

			}

			quantitycirclecharge=form.sheetqty.value*.35

		

		} else if(form.sheetqty.value > 599)

		{	

			if(tolerancecharge == "15.00")

			{

				quantitycharge=form.sheetqty.value*.25

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.20

	

			} else if(tolerancecharge == "10.00")

			{

				quantitycharge=form.sheetqty.value*.15

	

			}

			quantitycirclecharge=form.sheetqty.value*.30

		}	

	

		// alert("Quantity Circle Charge = " + quantitycirclecharge)	



		/* 

	 	*	Multiply the quantity charge by the thickness of the material 

	 	*	multiplier, which is basically 1,2,3,4,5,6.

	 	*/

	

		if(sheetthickness < .3751)

		{

			quantitycharge = quantitycharge*1

		} else if(sheetthickness < .7501)

		{

			quantitycharge = quantitycharge*2

		} else if(sheetthickness < 1.1251)

		{

			quantitycharge = quantitycharge*3

		} else if(sheetthickness < 1.51)

		{

			quantitycharge = quantitycharge*4

		} else if(sheetthickness < 2.001)

		{

			quantitycharge = quantitycharge*5

		} else if(sheetthickness < 3.001)

		{

			quantitycharge = quantitycharge*6

		}

	

		/* 

	 	*	Multiply the quantity charge by the Length of the material 

	 	*	multiplier, which is basically ,2,3,4,5,6.

	 	*/

	

	

		if(sheetlength < 12.1)

		{

			quantitycharge = quantitycharge*1

		} else if(sheetlength < 36.1)

		{

			quantitycharge = quantitycharge*2

		} else if(sheetlength < 48.1)

		{

			quantitycharge = quantitycharge*3

		} else if(sheetlength < 59.1)

		{

			quantitycharge = quantitycharge*4

		} else if(sheetlength > 59)

		{

			quantitycharge = quantitycharge*5

		}

	

		/*

	 	* Check to determine if Width Strip Charge applies, if

	 	* so mulitiply quantitycharge by Stip factor. 

	 	*/

	

		if(sheetwidth < 1.5 && tolerancecharge == "15.00")

		{

			quantitycharge = quantitycharge*2

		}

		// alert("Quantity Charge = " + quantitycharge)

		// alert("Tolerance Charge  = " + tolerancecharge)

	

		var chargetotal = 0.00

		var tmp_hold = 0.00

		

		tmp_hold = parseFloat(tolerancecharge)

	

		// alert("TMP HOLD  = " + tmp_hold)

	

		chargetotal = chargetotal + tmp_hold 

		chargetotal = chargetotal + circlecharge

		// alert("Form Circle Value = " + form.circle.selectedIndex)

		chargetotal = chargetotal + (quantitycirclecharge * form.circle.selectedIndex) 

		chargetotal = chargetotal + quantitycharge 	

	

		// alert("Charge Total  = " + chargetotal)

		// alert("Sheet  Total  = " + sheettotal)

		// alert("Per SQ FT     = " + persqft)

		

		persheet = persheet + (chargetotal/form.sheetqty.value)

 		sheettotal = sheettotal + chargetotal

	

		persqft = persheet / formatNum(sheetsize,2)

	

		// persqft = parseFloat(persqft) + (parseFloat(chargetotal)/parseFloat(sheetsize))

	

		// alert("Per SQ FT     = " + persqft)

	

			

		calcSheetDiscount(form, sheettotal, persqft, persheet)

	

	}

	return	



}

function getCookie(name) {

    var dc = document.cookie;

    var prefix = name + "=";

    var begin = dc.indexOf("; " + prefix);

    if (begin == -1) {

        begin = dc.indexOf(prefix);

        if (begin != 0) return null;

    } else

      begin +=2;

    var end = document.cookie.indexOf(";", begin);

    if (end == -1)

        end = dc.length;

    return unescape(dc.substring(begin + prefix.length, end ) );

}





function main(form, callingField)

{

	if(callingField == "customwidth" || callingField == "customheight" )

	{

    		(form.shtwidthlength.options[2].selected) = true

	}

	

	if( form.shtwidthlength.selectedIndex=="2" )

	{

		if( form.customwidth.value != "0" && form.customlength.value != "0") 

		{

			if(form.circle.selectedIndex == "1")

			{

				if( form.customwidth.value != form.customlength.value)

				{

					alert("Width Inches and Length Inches fields must be equal for Round Blanks")

				} else {

					customSheet(form, callingField)

					if ( form.formtype.value == "all" ) {

               				    calcRod(form)

					}

				}

			} else {

				customSheet(form, callingField)



				if ( form.formtype.value == "all" ) {

               				calcRod(form)

				}

			}

		} else {



			if ( form.formtype.value == "all" ) {

				calcRod(form)

			}

		}

	} else {

		calcGsht(form)

		if ( form.formtype.value == "all" ) {

               		calcRod(form)

		}

	}





      if ( form.formtype.value == "all" ) {



	if(form.rodtotalprice.value != "" && form.sheettotalprice.value != "" )

	{

		form.grandtotal.value = parseFloat(form.rodtotalprice.value) + parseFloat(form.sheettotalprice.value)

		form.grandtotal.value = formatNum(form.grandtotal.value,2)

	} else if(form.rodtotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.rodtotalprice.value,2) 

	} else if(form.sheettotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.sheettotalprice.value,2) 



	}	



    } else {



	if( form.sheettotalprice.value != "" )

	{

		form.grandtotal.value =  formatNum(form.sheettotalprice.value,2)

	} else if(form.sheettotalprice.value != "")

	{

		form.grandtotal.value = formatNum(form.sheettotalprice.value,2) 

	}



    }

















}

function resetpage(form, callingField)

{

	if ( form.formtype.value == "all" ) {



	clearRod(form, callingField)

    }

	clearSheet(form, callingField)



   

  

}







function resetpager(form, callingField)

{

	if ( form.formtype.value == "rod" ) {

	clearRod(form, callingField)

	}

	else

	if ( form.formtype.value == "rod1" ) {

	clearRod1(form, callingField)

	}



}



function resetpaget(form, callingField)

{

	if ( form.formtype.value == "tube" ) {

	clearTube(form, callingField)

	} 

	else 

	if ( form.formtype.value == "tubing" ) {

	clearTubing2(form, callingField)

	}

	else 

	if ( form.formtype.value == "tube1" ) {

	clearTubing1(form, callingField)

	}

	else 

	if ( form.formtype.value == "tube3" ) {

	clearTubing3(form, callingField)

	}

	else 

	if ( form.formtype.value == "tube4" ) {

	clearTubing4(form, callingField)

	}





}





function submitOrder(form, callingField) {



    /* 

     *

     *  This code sets up the cookie so that a order number

     *  can be tracked for a customer. The order number is the

     *  acts as the reference to the cart. 

     *

     */ 



     var exp = new Date()

     var makeNumber = exp.getTime() + 10 

     check_cookie = getCookie("ppc_order_number")



     // var oneYearFromNow = exp.getTime() + (365 * 24 * 60 * 60 * 1000)

     // exp.setTime(makeNumber)

     // document.cookie = "ppc_order_number=" + makeNumber

     // document.cookie = "ppc_order_number=3434;expires=" + exp.toGMTString() 

     // alert("What the heck is check_cookie anyway = " + check_cookie);



     if(check_cookie == null )

       {

	   var exp = new Date()

	   var oneMonthFromNow = exp.getTime() + (365 + 24 + 60 * 60 * 1000)

	   exp.setTime(oneMonthFromNow)



           document.cookie = "ppc_order_number=" + makeNumber + 

	     " ;expires=" + exp.toGMTString() + " ; path=/"

           form.cookiefield.value = getCookie("ppc_order_number")

      //   alert("Horay: Set the cookie value, =  " + form.cookiefield.value )



       } else {

            form.cookiefield.value = check_cookie

      //    alert("Cool we found it, but set it anyway to = " + form.cookiefield.value )



       }



     if(callingField == "viewcart") { 

        // This will cause the order to be dropped. 

	// alert("Got a call from ViewCart");



	if ( form.formtype.value == "all" ) {

		form.RodTotal.value = "0" ;

	}

	form.ShtTotal.value = "0" ;

     } else {

	createDescription(form) 

     }

	



    form.submit()

}





function submitOrderr(form, callingField) {



    /* 

     *

     *  This code sets up the cookie so that a order number

     *  can be tracked for a customer. The order number is the

     *  acts as the reference to the cart. 

     *

     */ 



     var exp = new Date()

     var makeNumber = exp.getTime() + 10 

     check_cookie = getCookie("ppc_order_number")



     // var oneYearFromNow = exp.getTime() + (365 * 24 * 60 * 60 * 1000)

     // exp.setTime(makeNumber)

     // document.cookie = "ppc_order_number=" + makeNumber

     // document.cookie = "ppc_order_number=3434;expires=" + exp.toGMTString() 

     // alert("What the heck is check_cookie anyway = " + check_cookie);



     if(check_cookie == null )

       {

	   var exp = new Date()

	   var oneMonthFromNow = exp.getTime() + (365 + 24 + 60 * 60 * 1000)

	   exp.setTime(oneMonthFromNow)



           document.cookie = "ppc_order_number=" + makeNumber + 

	     " ;expires=" + exp.toGMTString() + " ; path=/"

           form.cookiefield.value = getCookie("ppc_order_number")

      //   alert("Horay: Set the cookie value, =  " + form.cookiefield.value )



       } else {

            form.cookiefield.value = check_cookie

      //    alert("Cool we found it, but set it anyway to = " + form.cookiefield.value )



       }



    if(callingField == "viewcart") { 

        // This will cause the order to be dropped. 

	// alert("Got a call from ViewCart");



	if ( form.formtype.value == "rod" ) {

		form.RodTotal.value = "0" ;

	}

	form.RodTotal.value = "0" ;

     } else {

	createDescriptionr(form) 

     }

	

    form.submit()

}



function submitOrderr1(form, callingField) {



    /* 

     *

     *  This code sets up the cookie so that a order number

     *  can be tracked for a customer. The order number is the

     *  acts as the reference to the cart. 

     *

     */ 



     var exp = new Date()

     var makeNumber = exp.getTime() + 10 

     check_cookie = getCookie("ppc_order_number")



     // var oneYearFromNow = exp.getTime() + (365 * 24 * 60 * 60 * 1000)

     // exp.setTime(makeNumber)

     // document.cookie = "ppc_order_number=" + makeNumber

     // document.cookie = "ppc_order_number=3434;expires=" + exp.toGMTString() 

     // alert("What the heck is check_cookie anyway = " + check_cookie);



     if(check_cookie == null )

       {

	   var exp = new Date()

	   var oneMonthFromNow = exp.getTime() + (365 + 24 + 60 * 60 * 1000)

	   exp.setTime(oneMonthFromNow)



           document.cookie = "ppc_order_number=" + makeNumber + 

	     " ;expires=" + exp.toGMTString() + " ; path=/"

           form.cookiefield.value = getCookie("ppc_order_number")

      //   alert("Horay: Set the cookie value, =  " + form.cookiefield.value )



       } else {

            form.cookiefield.value = check_cookie

      //    alert("Cool we found it, but set it anyway to = " + form.cookiefield.value )



       }



    if(callingField == "viewcart") { 

        // This will cause the order to be dropped. 

	// alert("Got a call from ViewCart");



	if ( form.formtype.value == "rod1" ) {

		form.RodTotal.value = "0" ;

	}

	form.RodTotal.value = "0" ;

     } else {

	createDescriptionr1(form) 

     }

	

    form.submit()

}



function submitOrdert(form, callingField) {



    /* 

     *

     *  This code sets up the cookie so that a order number

     *  can be tracked for a customer. The order number is the

     *  acts as the reference to the cart. 

     *

     */ 



     var exp = new Date()

     var makeNumber = exp.getTime() + 10 

     check_cookie = getCookie("ppc_order_number")



     // var oneYearFromNow = exp.getTime() + (365 * 24 * 60 * 60 * 1000)

     // exp.setTime(makeNumber)

     // document.cookie = "ppc_order_number=" + makeNumber

     // document.cookie = "ppc_order_number=3434;expires=" + exp.toGMTString() 

     // alert("What the heck is check_cookie anyway = " + check_cookie);



     if(check_cookie == null )

       {

	   var exp = new Date()

	   var oneMonthFromNow = exp.getTime() + (365 + 24 + 60 * 60 * 1000)

	   exp.setTime(oneMonthFromNow)



           document.cookie = "ppc_order_number=" + makeNumber + 

	     " ;expires=" + exp.toGMTString() + " ; path=/"

           form.cookiefield.value = getCookie("ppc_order_number")

      //   alert("Horay: Set the cookie value, =  " + form.cookiefield.value )



       } else {

            form.cookiefield.value = check_cookie

      //    alert("Cool we found it, but set it anyway to = " + form.cookiefield.value )



       }



    if(callingField == "viewcart") { 

        // This will cause the order to be dropped. 

	// alert("Got a call from ViewCart");



	if ( form.formtype.value == "tube" ) {

		form.TubeTotal.value = "0" ;

	}

	form.TubeTotal.value = "0" ;

     } else {

	createDescriptiont(form) 

     }



    form.submit()

}


