/*
Function: price_quote(qfrm)
Purpose: To produce a quick quote price for a banner, excluding artwork, setup and shipping fees.

Author: Robert Traulsen
Email: bob@ConcessionSolutions.com

Date: December 13, 2005

*/

function price_quoteban(qfrm){
var price_per;
var cost;
var w;
var h;

w = 0;
h = 0;

// Verify user entered data as digits plus a '.' in sizes ('w' and 'h') whole number only for quantity 'q'

if ((isNaN(qfrm.q.value)) || (qfrm.q.value == "0")) // If invalid digits, return user to quantity entry box
{
	alert("You have entered an invalid number.  Please use only the digits 0-9 in the Quantity.");
	qfrm.q.select();
	qfrm.q.focus();
	return false;
}

if (isNaN(qfrm.wf.value)) // If invalid digits, return user to width entry box
{
	alert("You have entered an invalid number.  Please use only the digits 0-9 and a '.' for Width feet.");
	qfrm.wf.select();
	qfrm.wf.focus();
	return false;
}

if (isNaN(qfrm.wi.value)) // If invalid digits, return user to width entry box
{
	alert("You have entered an invalid number.  Please use only the digits 0-9 and a '.' for Width inches.");
	qfrm.wi.select();
	qfrm.wi.focus();
	return false;
}

if ((qfrm.wi.value == "0") && (qfrm.wf.value == "0"))
{
	alert("You have not entered a valid number.  Please enter a value for Width feet and/or inches.");
	qfrm.wf.select();
	qfrm.wf.focus();
	return false;
} else {
	w = (parseFloat(qfrm.wf.value) * 12) + parseFloat(qfrm.wi.value);
}

if (isNaN(qfrm.hf.value)) // If invalid digits, return user to Height entry box
{
	alert("You have entered an invalid number.  Please use only the digits 0-9 and a '.' for Height feet.");
	qfrm.hf.select();
	qfrm.hf.focus();
	return false;
}

if (isNaN(qfrm.hi.value)) // If invalid digits, return user to Height entry box
{
	alert("You have entered an invalid number.  Please use only the digits 0-9 and a '.' for Height inches.");
	qfrm.hi.select();
	qfrm.hi.focus();
	return false;
}

if ((qfrm.hi.value == "0") && (qfrm.hf.value == "0"))
{
	alert("You have not entered a valid number.  Please enter a value for Height feet and/or inches.");
	qfrm.hf.select();
	qfrm.hf.focus();
	return false;
} else {
	h = (parseFloat(qfrm.hf.value) * 12) + parseFloat(qfrm.hi.value);
}

intQty = parseInt(qfrm.q.value);

// Determine cost per square foot based on quantity ordered

if (intQty == 1){
	price_per = 6;
}

if ((intQty >=2) && (intQty <=4)){
	price_per = 5;
}

if ((intQty >=5) && (intQty <=10)){
	price_per = 4.5;
}

if ((intQty >=11) && (intQty <=20)){
	price_per = 4;
}

if (intQty >= 21) {
		qfrm.c.value = "Call";
		qfrm.tc.value = "Call";
		qfrm.c.focus();
		return false;
}

/* calculate the price:
			multiply width x height in inches, 
			convert to square feet, 
			multiply by price and 
			multiply by quantity

*/

cost = (((w * h)/144)*price_per);

num = cost;
num2 = cost * intQty;
// below is borrowed from the: The JavaScript Source!! http://javascript.internet.com 

num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	num = Math.floor(num * 100 + 0.50000000001);
	cents = num % 100;
	num = Math.floor(num / 100).toString();
	if(cents < 10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
		num = num.substring(0,num.length - (4 * i + 3)) + ',' + num.substring(num.length-(4 * i + 3));
	qfrm.c.value =  ('$' + num + '.' + cents);
	
	num2 = num2.toString().replace(/\$|\,/g,'');
	if(isNaN(num2))
		num2 = "0";
	num2 = Math.floor(num2 * 100 + 0.50000000001);
	cents = num2 % 100;
	num2 = Math.floor(num2 / 100).toString();
	if(cents < 10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num2.length - (1 + i)) / 3); i++)
		num2 = num2.substring(0,num2.length - (4 * i + 3)) + ',' + num2.substring(num2.length-(4 * i + 3));
	qfrm.tc.value =  ('$' + num2 + '.' + cents);

return false;

} // End of function price_quote(qfrm)