<!--

//////////  Rocker and Chair JavaScript //////////////

//////////////////////  popUp   ////////////////////
 
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,location=0,scrollbars=1,statusbar=0,menubar=0,resizable=0,width=650,height=400,left = 100,top = 100');");
    return;
} // close popUP
// End popUp 



//////////////////////   isDigit       ////////////////////
// isDigit determine if an individual character is numeric,  called by isFloat

function isDigit(test)
{
//DEBUG STATEMENT FOLLOWS	   
// window.alert("isDigit started with " + test);
//DEBUG STATEMENT ABOVE
    if (test.match(/[0-9]/))
        {
//DEBUG STATEMENT FOLLOWS	
// window.alert("Character is a Digit");
//DEBUG STATEMENT ABOVE
                        return true;
                }
    else
                {
//DEBUG STATEMENT FOLLOWS			
// window.alert("Character is NOT a Digit");
//DEBUG STATEMENT ABOVE
                        return false;
                }
    return true;
} // close isDigit


//////////////////////   isEmpty ////////////////////
// Check whether string s is empty. Called by isFloat
// If empty ... returns True
// If not empty ... returns False

function isEmpty(s)
{   
//DEBUG STATEMENT FOLLOWS	   
// window.alert("isEmpty started with: " + s);		
//DEBUG STATEMENT ABOVE
if ((s == null) || (s.length == 0))
	{
//DEBUG STATEMENT FOLLOWS	
		// window.alert("Dimension is empty");
		return false;
	}
//DEBUG STATEMENT FOLLOWS		
// window.alert("Dimension is NOT empty");

    return true;
} // close isEmpty

//////////////////////   isFloat    ////////////////////


// isFloat (STRING s , Dimension Label)
// 
// True if string s is an unsigned floating point (real) number. 
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isInteger, then call isFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function isFloat(s)
{
//		document.TestForm.number.value = s;
	   var i;
	   var seenDecimalPoint = false;
//DEBUG STATEMENT FOLLOWS	   
// window.alert("isFloat started with: " + s);		
//DEBUG STATEMENT ABOVE	   
  if (isEmpty(s)) 
    	{
//DEBUG STATEMENT FOLLOWS	
	//		window.alert("Dimension is blank");
			return false;
		}
		
  if (s == ".") 		
		{
//DEBUG STATEMENT FOLLOWS	
		 window.alert("Dimension is only a decimal point");
		 return false;
		 }
   // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

		// Be sure only 1 period
       if ((c == ".") && !seenDecimalPoint) 
			{
			seenDecimalPoint = true;
			}
       else 
			{
//DEBUG STATEMENT FOLLOWS	   
// window.alert("i: " + i + " c: " + c);		
//DEBUG STATEMENT ABOVE	
			if (!isDigit(c))
				{
				 alert("Dimension contains invalid character '" + c + "'");
					 return false;
				 }
			}
    return true;
} // close isFloat
// All characters are numbers.
//	window.alert("Dimension is Valid");
    return true;
}


//////////////////////   getPrice    ////////////////////


function getPrice (s)
{
    // start looking at character position 1 for the vertical bar | 
    // (i.e. second character, since fabric code must exist)
    var i = 1;

    // look for bar
	var bar_at = s.indexOf('|');

// DEBUG STATEMENT BELOW	
//	window.alert("values are s: " + s + "  bar_at: " + bar_at);
// DEBUG STATEMENT ABOVE

			var fabric_code = s.substring(0,bar_at)
			var fabric_price = s.substring(bar_at+1,s.length);

// DEBUG STATEMENT BELOW
//	window.alert("values are fabric_code: " + fabric_code + " (price: " + price + "  )<BR>");
// DEBUG STATEMENT ABOVE	

document.TestForm.fabric_code.value = fabric_code;
document.TestForm.fabric_price.value = fabric_price;

}

//////////////////////   clearMessage  ////////////////////
//  Clears Additional Shipping Message when Clear all fields is clicked
function clearMessage ()
{
document.TestForm.shipMsg.src = "images/BlankImage.gif";
}

//////////////////////   calcPrice for RC-501, 601  ////////////////////

function calcPrice ()
{
var	additionalShipping = "no";		
document.TestForm.shipMsg.src = "images/BlankImage.gif";

var inA = eval(document.TestForm.A.value);
var inB = eval(document.TestForm.B.value);

var numbCushions = eval(document.TestForm.qty.value);
var inThickness = eval(document.TestForm.Thickness.value);

// Calc Labor for RC-501, 601

if (document.TestForm.ties.value =="no")
	{
	var sumLabor = 49.00;
	var style = "RC-501 without Ties";
	}
if (document.TestForm.ties.value == "yes")
	{
		var sumLabor = 55.00;
		var style = "RC-601 with Ties";
	}
// DEBUG STATEMENT BELOW
// window.alert("sumLabor: " + sumLabor + " ties: " + document.TestForm.ties.value + " A: " + inA + " B: " + inB);
// DEBUG STATEMENT ABOVE

var sumLabor = (sumLabor * numbCushions)
document.TestForm.sumLabor.value = sumLabor;
document.TestForm.style.value = style;

// Calc Foam for RC-501, 601
var sumLenTimesWidth_1 = inA * inB * (inThickness+1);
var sumLenTimesWidth_2 = sumLenTimesWidth_1 / 144;
// FOAM factor below changed from 1.04 to 1.26 on 1/10/03
// FOAM factor below changed from 1.26 to 1.50 on 4/18/03
// FOAM factor below changed from 1.50 to 1.68 on 9/14/04
// FOAM factor below changed from 1.68 to 1.90 on 1/17/05
// FOAM factor below changed from 1.90 to 2.10 on 5/05/05
// FOAM factor below changed from 2.10 to 3.15 on 11/01/05
var sumFoam = sumLenTimesWidth_2 * 3.15;
var sumFoam = Math.round(sumFoam * 100);
var sumFoam = ((sumFoam /100) * numbCushions);
// DEBUG STATEMENT BELOW
// window.alert("sumFoam: " + sumFoam + " sumLenTimesWidth_1: " + sumLenTimesWidth_1 + " sumLenTimesWidth_2: " + sumLenTimesWidth_2);
// DEBUG STATEMENT ABOVE
document.TestForm.sumFoam.value = sumFoam;

// Calc Fabric for RC-501, 601
if (isFloat(document.TestForm.fabric_price.value)) {return;}

// FABRIC factor below changed from 0.075 to 0.08 on 04/13/07
var sumFabric = eval(inB  * numbCushions  * document.TestForm.fabric_price.value * .08);
var sumFabric = Math.round(sumFabric * 100);
var sumFabric = (sumFabric /100);
// DEBUG STATEMENT BELOW
// window.alert("sumFabric: " + sumFabric);
// DEBUG STATEMENT ABOVE
document.TestForm.sumFabric.value = sumFabric;

// Calc Shipping for RC-501, 601
// Shipping below changed from 20 to 25 4/13/07
var sumShipping = 25  * numbCushions;

// factor changed from 10 to 14 on 4/18/03		
// factor changed from 14 to 6 (2 * thickness) + Factor of 10 on 4/13/07	
var linearDimension = (inA * 2) + (inThickness * 2) + 10 + inB;
if ((linearDimension >= 130) && (sumFabric > 0)) 
	{
		var sumShipping = sumShipping + 55;
		if (linearDimension > 165) 
			{
			additionalShipping = "yes";
			}	
	}	

// DEBUG STATEMENT BELOW
// window.alert("sumShipping: " + sumShipping + " linearDimension: " + linearDimension);
// DEBUG STATEMENT ABOVE
document.TestForm.sumShipping.value = sumShipping;
document.TestForm.additionalShipping.value = additionalShipping;
document.TestForm.linearDimension.value = linearDimension;


// Calc Total Price for ALL RC-501, 601 Cushions 
var price = eval(sumLabor + sumFoam + sumFabric + sumShipping);
var price = Math.round(price * 100);
var priceTotal = price /100;
// DEBUG STATEMENT BELOW
// window.alert("price: " + price);
// DEBUG STATEMENT ABOVE

document.TestForm.price_total.value = priceTotal;

document.TestForm.shipMsg.src = "images/BlankImage.gif";

if (additionalShipping == "yes")
	{
		document.TestForm.shipMsg.src = "images/addShipImage.gif";
	}
return true;
} // close Calc Price

//////////////////////   Validate for RC-501, 601 Cushion  ////////////////////

function Validate ()
{

var inA = eval(document.TestForm.A.value);
if ((inA == null) || (inA.length == 0))
	{
		window.alert("Dimension A is empty");
		document.TestForm.A.focus();
		return false;
	}

var inB = eval(document.TestForm.B.value);
if ((inB == null) || (inB.length == 0))
	{
		window.alert("Dimension B is empty");
		document.TestForm.B.focus();
		return false;
	}
		
var inC = eval(document.TestForm.C.value);
	if ((inC == null) || (inC.length == 0))
		{window.alert("Dimension C is empty");
		document.TestForm.C.focus();
		return false;}
		
		
var f_price = eval(document.TestForm.fabric_price.value);
if ((f_price == null) || (f_price.length == 0))
	{
		window.alert("Fabric Not Selected");
		document.TestForm.D3.focus();
		return false;
	}
var numbCushions = eval(document.TestForm.qty.value);
if ((numbCushions == 0))
	{
		window.alert("Specify Number of Cushions of this Size Wanted?");
		document.TestForm.qty.focus();
		return false;
	}
// calcPrice();	
return true;
} // close Validate

-->


