<!-- 
//////////  Fabric Only 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
// 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 true;
	}
//DEBUG STATEMENT FOLLOWS		
// window.alert("Dimension is NOT empty");
return false;
}

//////////////////////   isInteger    ////////////////////
function isInteger (s)

{   var i;
	var defaultEmptyOK = false
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // 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);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

//////////////////////   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 points");
		 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))
				{
				 window.alert("Dimension contains invalid character '" + c + "'");
				 return false;
				 }
			}
    }
// All characters are numbers.
//	window.alert("Dimension is Valid");
    return true;
}


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

function getPrice (inSelection)
{

    // 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 = inSelection.indexOf('|');

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

			var FabricCode = inSelection.substring(0,bar)
			var FabricPrice = inSelection.substring(bar+1,inSelection.length);

// DEBUG STATEMENT BELOW
// window.alert("1st FabricCode: " + FabricCode + " 1st FabricPrice: " + FabricPrice + "  )");
// DEBUG STATEMENT ABOVE	

document.TestForm.FirstFabricCode.value = FabricCode;
document.TestForm.FirstFabricPrice.value = FabricPrice;

}

//////////////////////   getPriceSecond    ////////////////////

function getPriceSecond (inSelection)
{

    // 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 = inSelection.indexOf('|');

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

			var FabricCode = inSelection.substring(0,bar)
			var FabricPrice = inSelection.substring(bar+1,inSelection.length);

// DEBUG STATEMENT BELOW
// window.alert("2nd FabricCode: " + FabricCode + " 2nd FabricPrice: " + FabricPrice + "  )");
// DEBUG STATEMENT ABOVE	

document.TestForm.SecondFabricCode.value = FabricCode;
document.TestForm.SecondFabricPrice.value = FabricPrice;

}


//////////////////////   calcPrice for Fabric Only  ////////////////////

function calcPrice ()
{
	var FabricSum = 0;
// Calc Price & Shipping for 1st Fabric Only
if (isEmpty(document.TestForm.FirstFabricLength.value))
	{var fflen = 0;}
else { 
// DEBUG STATEMENT BELOW
//	window.alert(document.TestForm.FirstFabricLength.value);
	var fflen = eval(document.TestForm.FirstFabricLength.value);
	if (fflen < 2 )
		{
		window.alert("First Length must be for minimum of 2 yards");
		return;
		}
	}		
// Calc Fabric Cost for 1st Fabric Only Choice
	var FabricCost = eval(fflen * document.TestForm.FirstFabricPrice.value);
	
// DEBUG STATEMENT BELOW
// window.alert("1st FabricCost: " + FabricCost);
// DEBUG STATEMENT ABOVE

		var FabricCost = Math.round(FabricCost * 100);
		var FirstFabricCost = eval(FabricCost /100);

		
// DEBUG STATEMENT BELOW
// window.alert("1st FabricCost: " + FirstFabricCost + " Length: " + fflen + " - " + document.TestForm.FirstFabricLength.value + "Price: " + document.TestForm.FirstFabricPrice.value);
// DEBUG STATEMENT ABOVE

		document.TestForm.FirstFabricCost.value = FirstFabricCost;
	
// Calc Price & Shipping for 2nd Fabric Only
if (isEmpty(document.TestForm.SecondFabricLength.value))
	{var sflen = 0;}
else{ 
// DEBUG STATEMENT BELOW
//	window.alert(document.TestForm.SecondFabricLength.value);
	var sflen = eval(document.TestForm.SecondFabricLength.value);
	if (sflen < 2)
		{
		window.alert("Second Length must be for minimum of 2 yards");
		return;
		}
	}
//alc Fabric Cost for 1st Fabric Only Choice
		var FabricCost = eval(sflen * document.TestForm.SecondFabricPrice.value);

// DEBUG STATEMENT BELOW
// window.alert("FabricCost: " + FabricCost);
// DEBUG STATEMENT ABOVE

		var FabricCost = Math.round(FabricCost * 100);
		var SecondFabricCost = eval(FabricCost /100);

		
// DEBUG STATEMENT BELOW
// window.alert("2nd FabricCost: " + SecondFabricCost);
// DEBUG STATEMENT ABOVE

		document.TestForm.SecondFabricCost.value = SecondFabricCost;

document.TestForm.sumLabor.value = 0;
document.TestForm.sumFoam.value = 0;

// Calc Shipping for Fabric Only

var lengthTotal = eval(fflen + sflen);

document.TestForm.FabricOnlyLengthTotal.value = lengthTotal;

if (lengthTotal == 0) return;

// DEBUG STATEMENT BELOW
// window.alert("lengthTotal: " + lengthTotal + " 1stLen: " + fflen + " - " + document.TestForm.FirstFabricLength.value + " 2ndLen: "  + sflen + " - " + document.TestForm.SecondFabricLength.value);
// DEBUG STATEMENT ABOVE

var sumShipping = 0;
var	additionalShipping = "no";	

if (lengthTotal <= 7) {var sumShipping = 15.;}
else {
	if (lengthTotal <= 13) {var sumShipping = 20.;}
	else {
		if (lengthTotal <= 20) {var sumShipping = 25.;}
		else {
			if (lengthTotal <= 30) {var sumShipping = 30.;}
			else {
				if (lengthTotal >= 31) 
				{var sumShipping = 30.; var	additionalShipping = "yes";	}
				}
			}
		}
	}



var linearDimension = 0;
	

document.TestForm.additionalShipping.value = additionalShipping;
document.TestForm.linearDimension.value = "NA";

// DEBUG STATEMENT BELOW
// window.alert("sumShipping: " + sumShipping + " linearDimension: " + linearDimension);
// DEBUG STATEMENT ABOVE

// Calc Total Price for Fabric Only
var sumFabric = eval(FirstFabricCost + SecondFabricCost);
var priceTotal = eval(sumShipping + sumFabric);
document.TestForm.sumShipping.value = sumShipping;
document.TestForm.sumFabric.value = sumFabric;
document.TestForm.price_total.value = priceTotal;

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

if (additionalShipping == "yes")
	{
	document.TestForm.shipMsg.src = "images/addShipImage.gif";
	}

}
// calcPrice();	

//////////////////////   Validate for Fabric Only ////////////////////

function Validate ()
{
var FirstFabricL = eval(document.TestForm.FirstFabricLength.value);
var SecondFabricL = eval(document.TestForm.SecondFabricLength.value);
var FirstFabricP = eval(document.TestForm.FirstFabricPrice.value);
var SecondFabricP = eval(document.TestForm.SecondFabricPrice.value);

//DEBUG STATEMENT
//window.alert("One: " + FirstFabricL  + " : " + SecondFabricL  + " : " + FirstFabricP  + " : " + SecondFabricP +  " : " +  Fabric1L + " : " +  Fabric2L );

var Fabric2L = "OK";
var Fabric1L = "OK";
if ((FirstFabricL == null) || (FirstFabricL == 0))
	{Fabric1L = "NO";}
if ((SecondFabricL == null) || (SecondFabricL == 0))
	{Fabric2L = "NO";}
	
//DEBUG STATEMENT
//window.alert("Lengths: " + Fabric1L + " : " + Fabric2L);

var Fabric2P = "OK";
var Fabric1P = "OK";
if ((FirstFabricP == null) || (FirstFabricP == 0))
	{Fabric1P = "NO";}
if ((SecondFabricP == null) || (SecondFabricP == 0))
	{Fabric2P = "NO";}
	
//DEBUG STATEMENT
//window.alert("Prices: " + Fabric1P + " : " + Fabric2P);	
	
//DEBUG STATEMENT
//window.alert("Lengths: " + Fabric1L + " : " + Fabric2L);

//DEBUG STATEMENT
//window.alert("Price Tests Next : " + " : " + Fabric1L  + " : " + Fabric1P + " : " + Fabric2L + " : " + Fabric2P);
if ((Fabric1L == "OK") && (Fabric1P == "NO"))	
	{window.alert("No Fabric Specified");
	document.TestForm.D3_First.focus();
	return false;}	

if ((Fabric2L == "OK") && (Fabric2P == "NO"))	
	{window.alert("No Fabric Specified");
	document.TestForm.D3_Second.focus();
	return false;}	
		
//if ((Fabric2L =="OK") && (SecondFabricL < 2))
//	{window.alert("2 Yard Minimum Required");
//	document.TestForm.SecondFabricLength.focus();
//	return false;}		
		

//DEBUG STATEMENT
//window.alert("Length Tests Next : " + Fabric1L  + " : " + Fabric1P + " : " + Fabric2L + " : " + Fabric2P);
if (Fabric1P == "OK") 
	{if (Fabric1L == "NO")
	{window.alert("No Length Specified");
	document.TestForm.FirstFabricLength.focus();
	return false;}	
	}
	
if ((Fabric2P == "OK") && (Fabric2L == "NO"))	
	{window.alert("No Length Specified");
	document.TestForm.SecondFabricLength.focus();
	return false;}	
				
if ((Fabric1L == "NO") && (Fabric2L == "NO") && (Fabric1P == "NO") && (Fabric2P == "NO")    )
	{window.alert("Nothing Specified");
	document.TestForm.D3_First.focus();
	return false;}
	
//DEBUG STATEMENT
//window.alert("Returning No Errors: " + Fabric1L  + " : " + Fabric1P + " : " + Fabric2L + " : " + Fabric2P);
return true;

} // close Validate

-->

