
//------------------------------------------------------------------------------------


function show_cartbutton() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("cartbutton").style.visibility = "visible";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.cartbutton.style.visibility = "visible";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.cartbutton.visibility = "visible";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//------------------------------------------------------------------------------------

function hide_cartbutton() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("cartbutton").style.visibility = "hidden";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.cartbutton.style.visibility = "hidden";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.cartbutton.visibility = "hidden";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//------------------------------------------------------------------------------------

function show_remainder() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("remainder").style.visibility = "visible";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.remainder.style.visibility = "visible";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.remainder.visibility = "visible";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//------------------------------------------------------------------------------------

function hide_remainder() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("remainder").style.visibility = "hidden";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.remainder.style.visibility = "hidden";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.remainder.visibility = "hidden";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//------------------------------------------------------------------------------------

function show_not0_msg() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("not0_msg").style.visibility = "visible";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.not0_msg.style.visibility = "visible";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.not0_msg.visibility = "visible";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//------------------------------------------------------------------------------------

function hide_not0_msg() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("not0_msg").style.visibility = "hidden";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.not0_msg.style.visibility = "hidden";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.not0_msg.visibility = "hidden";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//------------------------------------------------------------------------------------

function show_under0_msg() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("under0_msg").style.visibility = "visible";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.under0_msg.style.visibility = "visible";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.under0_msg.visibility = "visible";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//------------------------------------------------------------------------------------

function hide_under0_msg() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("under0_msg").style.visibility = "hidden";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.under0_msg.style.visibility = "hidden";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.under0_msg.visibility = "hidden";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//------------------------------------------------------------------------------------

function reset(){		// Resets all fields and values in the form
	// Hide all cut fields
	hide_not0_msg();
	hide_cartbutton();
	hide_under0_msg()
	tape=0;
	
	window.document.all.cut1.style.visibility="hidden";
	window.document.all.cut2.style.visibility="hidden";
	window.document.all.cut3.style.visibility="hidden";
	window.document.all.cut4.style.visibility="hidden";
	window.document.all.cut5.style.visibility="hidden";
	window.document.all.cut6.style.visibility="hidden";
	window.document.all.cut7.style.visibility="hidden";
	window.document.all.cut8.style.visibility="hidden";

	// Reset all cut values to 0
	document.cuts.cut1[0].selected = true;
	document.cuts.cut1.value = 0;
	document.cuts.cut2.value = 0;
	document.cuts.cut3.value = 0;
	document.cuts.cut4.value = 0;
	document.cuts.cut5.value = 0;
	document.cuts.cut6.value = 0;
	document.cuts.cut7.value = 0;
	document.cuts.cut8.value = 0;
	document.cuts.inches_left.value=48;

	// Uncheck all tapes
	window.document.all.form_type.tapes[0].checked = false;
	window.document.all.form_type.tapes[1].checked = false;
	window.document.all.form_type.tapes[2].checked = false;	
	window.document.all.form_type.tapes[3].checked = false;	
	window.document.all.form_type.tapes[4].checked = false;	
	window.document.all.form_type.tapes[5].checked = false;	
	window.document.all.form_type.tapes[6].checked = false;	

	roll=("Please select a type of tape.");
	document.desc.info.value=roll; 			// WRITE COMPOSITE TO VISIBLE FIELD	
}

//------------------------------------------------------------------------------------

function tapetype(){
//alert("starting tapetype function");

//var tape=0;

if(window.document.all.form_type.tapes[0].checked == true){ 
tape=window.document.form_type.tapes[0].value; price=99.5;}


else if(window.document.all.form_type.tapes[1].checked == true){ 
tape=window.document.form_type.tapes[1].value; price=99.5}


else if(window.document.all.form_type.tapes[2].checked == true){ 
tape=window.document.form_type.tapes[2].value; price=115}


else if(window.document.all.form_type.tapes[3].checked == true){ 
tape=window.document.form_type.tapes[3].value; price=125}


else if(window.document.all.form_type.tapes[4].checked == true){ 
tape=window.document.form_type.tapes[4].value; price=115}


else if(window.document.all.form_type.tapes[5].checked == true){ 
tape=window.document.form_type.tapes[5].value; price=125}


else if(window.document.all.form_type.tapes[6].checked == true){ 
tape=window.document.form_type.tapes[6].value; price=115}


if(tape != 0) { window.document.all.cut1.style.visibility="visible" };	

//alert(price);
calcSIZE();
}

//------------------------------------------------------------------------------------

function calcSIZE() {
//alert("Starting Calcsize");  			// IS IT RUNNING?

// Set Local Variables that need to be reinitialized each time a form field changes
	var tempnum 	= (0 * 1);
	var leftover 	= (1 * 1);
	var v 		= new Array(9);
	var w 		= new Array(9);
	var y 		= (1 * 1);
	var z 		= (1 * 1);
	var total 	= (0 * 1);
	var max		= (9 * 1);
	var n		= "";

//alert("established variables");

// LOAD CUT VALUES INTO ARRAY
	v[0]=0;
	v[1]=(window.document.cuts.cut1.value * 1);
	v[2]=(window.document.cuts.cut2.value * 1);
	v[3]=(window.document.cuts.cut3.value * 1);
	v[4]=(window.document.cuts.cut4.value * 1);
	v[5]=(window.document.cuts.cut5.value * 1);
	v[6]=(window.document.cuts.cut6.value * 1);
	v[7]=(window.document.cuts.cut7.value * 1);
	v[8]=(window.document.cuts.cut8.value * 1);

//alert("loaded arrays");

// CONVERT 0 VALUES TO NULLS FOR DESCRIPTION BOX
	if (v[1] == 0) {w[1] = "48"}; else {w[1] = v[1]};
	if (v[2] == 0) {w[2] = ""}; else {w[2] = v[2]};
	if (v[3] == 0) {w[3] = ""}; else {w[3] = v[3]};
	if (v[4] == 0) {w[4] = ""}; else {w[4] = v[4]};
	if (v[5] == 0) {w[5] = ""}; else {w[5] = v[6]};
	if (v[6] == 0) {w[6] = ""}; else {w[6] = v[6]};
	if (v[7] == 0) {w[7] = ""}; else {w[7] = v[7]};
	if (v[8] == 0) {w[8] = ""}; else {w[8] = v[8]};

//alert("converted arrays");

// Write Info to Screen and Hidden Fields -------------------------------
	roll=("RTape Conform " + tape + "RLA cut in inches as follows: "+w[1]+" "+w[2]+" "+w[3]+" "+w[4]+" "+w[5]+" "+w[6]+" "+w[7]+" "+w[8]+" "); 		// CREATE COMPOSITE TEXT from input values 

	document.sizer.op1.value=roll; 			// WRITE COMPOSITE TO HIDDEN FIELD USED BY CART
	document.sizer.op44.value=tape; 		// WRITE TAPE TYPE TO HIDDEN FIELD USED BY CART
	document.sizer.op33.value=price; 		// WRITE PRICE TO HIDDEN FIELD USED BY CART
	document.desc.info.value=roll; 			// WRITE COMPOSITE TO VISIBLE FIELD
//alert(tape +" "+ price + " " + roll);

//TOTAL CUT VALUES
	for (y=1; y<9; y++){
	total = total + v[y];
	}

//alert("y = "+y+" total = "+total);

// Calculate Remainder of Log
	leftover=(48 - total);
	document.cuts.inches_left.value=leftover;

// Determine whether to show cartbutton or not
	if (leftover == 0 ) {
	show_cartbutton();
	hide_not0_msg();
	hide_under0_msg();
	}
	else if (leftover < 0 ) {
	hide_cartbutton();
	hide_not0_msg();
	show_under0_msg();
	}
	else // (leftover < 48 && leftover > 0) 
	{
	hide_cartbutton();
	hide_under0_msg();
	show_not0_msg();
	}

// IF A SELECTION HAS A VALUE, MAKE THE FIELD TO THE RIGHT VISIBLE

	if(total < 48 && v[1] > 0) { window.document.all.cut2.style.visibility="visible" };	
	if(total < 48 && v[2] > 0) { window.document.all.cut3.style.visibility="visible" };
	if(total < 48 && v[3] > 0) { window.document.all.cut4.style.visibility="visible" }; 
	if(total < 48 && v[4] > 0) { window.document.all.cut5.style.visibility="visible" };
	if(total < 48 && v[5] > 0) { window.document.all.cut6.style.visibility="visible" };
	if(total < 48 && v[6] > 0) { window.document.all.cut7.style.visibility="visible" };
	if(total < 48 && v[7] > 0) { window.document.all.cut8.style.visibility="visible" };
}


// END OF SCRIPT ------------------------------