// Initialize Global Variables
	var width=(0 * 1);
	var banner="";			// calculated text for description

	var PCH=(0.50 * 1);		// PC ppsf hemmed
	var PCWT=(0.625 * 1);		// PC weight per sq yd (converted to feet below)

	var SOH=(0.63 * 1);		// SO ppsf hemmed
	var SOWT=(0.81 * 1);		// SO weight per sq yd (converted to feet below)

	var ERH=(0.75 * 1);		// ER ppsf hemmed
	var ERWT=(0.81 * 1);		// ER weight per sq yd (converted to feet below)

	var FABmsg="";			// Holder for Fabric Name 
	var ppsf=(0 * 1);		// Generic Price Per Square Foot
	var prefix="$";			// used in calc to display dollar sign

function show_cartbutton() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("cartbutton").style.visibility = "visible";
		 document.getElementById("cartmess").style.visibility = "visible";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.cartbutton.style.visibility = "visible";
		 window.document.all.cartmess.style.visibility = "visible";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.cartbutton.visibility = "visible";
		 window.document.cartmess.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";
	   	 document.getElementById("cartmess").style.visibility = "hidden";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.cartbutton.style.visibility = "hidden";
		 window.document.all.cartmess.style.visibility = "hidden";}

	//for Netscapt 4.0 or older browsers
	else if (document.layers)	
		{window.document.cartbutton.visibility = "hidden";
		 window.document.cartmess.visibility = "hidden";}
	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

//Functions to Show or Hide the Color DIV when Enamel Receptive is selected
function show_color() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("divcolor").style.visibility = "visible";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.divcolor.style.visibility = "visible";}

	//for Netscape 4.0 or older browsers
	else if (document.layers)	
		{window.document.divcolor.visibility = "visible";}

	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}

function hide_color() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)				
		{document.getElementById("divcolor").style.visibility = "hidden";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.divcolor.style.visibility = "hidden";}

	//for Netscape 4.0 or older browsers
	else if (document.layers)	
		{window.document.divcolor.visibility = "hidden";}
	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
	}


//SHOW WELDED DIV ---------------------------------------------------------
function show_welded() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)
		{document.getElementById("welded").style.visibility = "visible";
		 document.getElementById("hemmed").style.visibility = "hidden";
		 document.getElementById("divGROM_hem").style.visibility = "hidden";
		 document.getElementById("divGROM_weld").style.visibility = "visible";
		 document.getElementById("divMSG_weld").style.visibility = "visible";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.welded.style.visibility = "visible";
		 window.document.all.hemmed.style.visibility = "hidden";
		 window.document.all.divGROM_hem.style.visibility = "hidden";
		 window.document.all.divGROM_weld.style.visibility = "visible";
		 window.document.all.divMSG_weld.style.visibility = "visible";}
	
	//for Netscape 4.0 or older browsers
	else if (document.layers)	
		{window.document.welded.visibility = "visible";
		 window.document.hemmed.visibility = "hidden";
		 window.document.divGROM_hem.visibility = "hidden";
		 window.document.divGROM_weld.visibility = "visible";
		 window.document.divMSG_weld.visibility = "visible";}
	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
}

//SHOW HEMMED DIV ---------------------------------------------------------
function show_hemmed() {
	//for IE 5 & Netscape 6 Browsers
	if (document.getElementById)
		{document.getElementById("hemmed").style.visibility = "visible";
		 document.getElementById("welded").style.visibility = "hidden";
		 document.getElementById("divGROM_hem").style.visibility = "visible";
		 document.getElementById("divGROM_weld").style.visibility = "hidden";
		 document.getElementById("divMSG_weld").style.visibility = "hidden";}

	//for older IE browsers
	else if (window.document.all)				
		{window.document.all.hemmed.style.visibility = "visible";
		 window.document.all.welded.style.visibility = "hidden";
		 window.document.all.divGROM_hem.style.visibility = "visible";
		 window.document.all.divGROM_weld.style.visibility = "hidden";
		 window.document.all.divMSG_weld.style.visibility = "hidden";}
	
	//for Netscape 4.0 or older browsers
	else if (document.layers)	
		{window.document.hemmed.visibility = "visible";
		 window.document.welded.visibility = "hidden";
		 window.document.divGROM_hem.visibility = "visible";
		 window.document.divGROM_weld.visibility = "hidden";
		 window.document.divMSG_weld.visibility = "hidden";}
	else 
		{alert("Sorry, this doesnt work in your browser.");
		return;}
}

//MAIN CALC FUNCTION ---------------------------------------------------------
function calcPRICE() {
// Set Local Variables that need to be reinitialized each time a form field changes
	var fabric=document.pricer.material.value;
	var hemstyle=document.pricer.hem.value;
	var color=document.pricer.opt1.value;
	var widthA=document.pricer.opt2a.value;
	var widthB=document.pricer.opt2b.value;
	var quantity=document.pricer.op5.value;
	var grommets=document.pricer.grom.value;

//alert("mat = " + fabric + " " + hemstyle + " wA = " + widthA + " wB = " + widthB  + " " + grommets + " " + color + " " + quantity );

// Determine hem style and display the appropriate Width Field
	if ( hemstyle == "Welded Hem, " ) 
		{ show_welded();
		  width=widthB;
		  grommets="No grommets. "
		  cut=0;}		// no need to add to width for cut
	else { show_hemmed();
	       width=widthA;
	       cut=2;}			// add 2" for cut width

//alert("cut = " + cut);
// Set Base Price based on Material Selected
	if(fabric=="1")
		{ppsf = PCH; 
		 WT=PCWT;
		 FABmsg="10oz Printer's Choice Matte, ";
		 show_color();}
	else if(fabric=="2")
		{ppsf = SOH;
		 WT=SOWT;
		 FABmsg="13oz Show Off Glossy, ";
		 show_color();}
	else 	{ppsf = ERH; 
		 WT=ERWT;
	 	 FABmsg="13oz Enamel Receptive, ";
		 color="White, ";
		 hide_color();}

	if ( hemstyle == "Welded Hem, " ) 
		{ ppsf=ppsf+.05;}

//alert(ppsf + " " + FABmsg);

// Write Info to Screen and Hidden Fields -------------------------------
	// CREATE COMPOSITE TEXT from input values 
	banner=("Ready Roll, " + FABmsg + color + "with " + hemstyle + width + " IN x 72 FT, and " + grommets + "."); 
	document.pricer.op1.value=banner; 			// WRITE COMPOSITE TO HIDDEN FIELD USED BY CART
	document.desc.info.value=banner; 			// WRITE COMPOSITE TO VISIBLE FIELD

// Validate Fields and Hide Price Fields and Cart Button if Validation Fails
	if (width>0 && quantity>0)
		{testresult=true;}
	else{
		document.pricer.price.value=""; 
		document.pricer.op33.value="";
		hide_cartbutton();
		return false;}

// Calculate Area of banner
	var cut_width=((width * 1) + cut);
	var cut_length=(866 * 1);
	var sq_ft=((cut_width * cut_length) / 144);
	var sq_ftTotal=(sq_ft * quantity);

// Calculate Price
	calc = (ppsf * sq_ft)					// ADD IT ALL UP
	round=Math.round(calc*100);				// ROUND IT OFF TO 2 DECIMAL...
	tempnum=''+round/100+''					
	loc=tempnum.indexOf(".");				
	if (loc>0) {tempnum=tempnum+"00";tempnum=tempnum.substring(0,loc+3);}
	document.pricer.op33.value=tempnum;  			// WRITE PRICE TO HIDDEN FIELD - NO $
	document.pricer.price.value=prefix+tempnum;		// WRITE PRICE TO VISIBLE FORM FIELD 

// Calculate Weight
	calc = (WT * sq_ft / 9) + 2;				// CALCS WEIGHT BASED ON SQ YDS & ADDS 2LBS FOR BOX
	round=Math.round(calc*1);
	tempnum=''+round/1+''
	document.pricer.op11.value=tempnum;  			// WRITE WEIGHT TO HIDDEN FIELD

// Show Cart Button
	show_cartbutton();	
}

