/*
Function: mag_price_quote(qfrm)
Purpose: To produce a quick quote price for a FlexMagnet, excluding artwork, setup and shipping fees.

Author: Robert Traulsen
Email: bob@ConcessionSolutions.com

Date: December 14, 2005

*/

function price_quote(qfrm){
var price_per;
var cost;
var s;
var q;
var numa;
var numb;
var numc;
var numd;
var nq;

s = 0;
q = 0;

// Verify user entered data as digits plus a '.' in sizes ('w' and 'h') whole number only for quantity 'q'

if (qfrm.q.value == "0") // If user didn't select a quantity, return user to form
{
	alert("You have not selected a quantity.");
	return false;
}

if (qfrm.s.value == "0")
{
	alert("Please select a size.");
	return false;
}

if (qfrm.q.value == "0")
{
	alert("Please enter a quantity.");
	return false;
}
if (qfrm.q.value < 100)
{
	alert("The minimum quantity is 100.");
	return false;
}

// Width and Height appear to be valid so set w and h

s = parseFloat(qfrm.s.value);
q = parseFloat(qfrm.q.value);

// If there is a decimal in quantity, only use the whole number

intQty = parseInt(qfrm.q.value);


if ((intQty >= 100) && (intQty < 250)){
	if(s == "1"){
		price_per = .59;
	}
	if(s == "2"){
		price_per = .59;
	}
	if(s == "3"){
		price_per = .65;
	}
	if(s == "4"){
		price_per = .655;
	}
	if(s == "5"){
		price_per = .66;
	}
	if(s == "6"){
		price_per = .665;
	}
	if(s == "7"){
		price_per = .72;
	}
	if(s == "8"){
		price_per = .79;
	}
	if(s == "9"){
		price_per = 1.05;
	}
	if(s == "10"){
		price_per = 1.15;
	}
	if(s == "11"){
		price_per = 2.00;
	}
	if(s == "12"){
		price_per = .85;
	}
	if(s == "13"){
		price_per = .90;
	}
	if(s == "14"){
		price_per = 1.25;
	}
	if(s == "15"){
		price_per = .85;
	}
	if(s == "16"){
		price_per = 1.00;
	}
	if(s == "17"){
		price_per = .85;
	}
	color = .1;
	qfrm.nq.value = 250;
}
if ((intQty >= 250) && (intQty < 500)){
	if(s == "1"){
		price_per = .39;
	}
	if(s == "2"){
		price_per = .39;
	}
	if(s == "3"){
		price_per = .445;
	}
	if(s == "4"){
		price_per = .45;
	}
	if(s == "5"){
		price_per = .455;
	}
	if(s == "6"){
		price_per = .46;
	}
	if(s == "7"){
		price_per = .549;
	}
	if(s == "8"){
		price_per = .589;
	}
	if(s == "9"){
		price_per = .70;
	}
	if(s == "10"){
		price_per = .87;
	}
	if(s == "11"){
		price_per = 1.35;
	}
	if(s == "12"){
		price_per = .55;
	}
	if(s == "13"){
		price_per = .67;
	}
	if(s == "14"){
		price_per = .89;
	}
	if(s == "15"){
		price_per = .59;
	}
	if(s == "16"){
		price_per = .705;
	}
	if(s == "17"){
		price_per = .56;
	}
	color = .085;
	qfrm.nq.value = 500;
}
if ((intQty >= 500) && (intQty < 1000)){
	if(s == "1"){
		price_per = .27;
	}
	if(s == "2"){
		price_per = .27;
	}
	if(s == "3"){
		price_per = .31;
	}
	if(s == "4"){
		price_per = .315;
	}
	if(s == "5"){
		price_per = .32;
	}
	if(s == "6"){
		price_per = .325;
	}
	if(s == "7"){
		price_per = .379;
	}
	if(s == "8"){
		price_per = .399;
	}
	if(s == "9"){
		price_per = .51;
	}
	if(s == "10"){
		price_per = .575;
	}
	if(s == "11"){
		price_per = 1.00;
	}
	if(s == "12"){
		price_per = .38;
	}
	if(s == "13"){
		price_per = .455;
	}
	if(s == "14"){
		price_per = .58;
	}
	if(s == "15"){
		price_per = .40;
	}
	if(s == "16"){
		price_per = .54;
	}
	if(s == "17"){
		price_per = .42;
	}
	color = .05;
	qfrm.nq.value = "1,000";
}
if ((intQty >= 1000) && (intQty < 2500)){
	if(s == "1"){
		price_per = .185;
	}
	if(s == "2"){
		price_per = .185;
	}
	if(s == "3"){
		price_per = .205;
	}
	if(s == "4"){
		price_per = .21;
	}
	if(s == "5"){
		price_per = .215;
	}
	if(s == "6"){
		price_per = .22;
	}
	if(s == "7"){
		price_per = .269;
	}
	if(s == "8"){
		price_per = .285;
	}
	if(s == "9"){
		price_per = .38;
	}
	if(s == "10"){
		price_per = .46;
	}
	if(s == "11"){
		price_per = .97;
	}
	if(s == "12"){
		price_per = .265;
	}
	if(s == "13"){
		price_per = .35;
	}
	if(s == "14"){
		price_per = .44;
	}
	if(s == "15"){
		price_per = .29;
	}
	if(s == "16"){
		price_per = .43;
	}
	if(s == "17"){
		price_per = .279;
	}
	color = .03;
	qfrm.nq.value = "2,500";
}
if ((intQty >= 2500) && (intQty < 5000)){
	if(s == "1"){
		price_per = .158;
	}
	if(s == "2"){
		price_per = .158;
	}
	if(s == "3"){
		price_per = .175;
	}
	if(s == "4"){
		price_per = .18;
	}
	if(s == "5"){
		price_per = .185;
	}
	if(s == "6"){
		price_per = .19;
	}
	if(s == "7"){
		price_per = .235;
	}
	if(s == "8"){
		price_per = .25;
	}
	if(s == "9"){
		price_per = .355;
	}
	if(s == "10"){
		price_per = .425;
	}
	if(s == "11"){
		price_per = .98;
	}
	if(s == "12"){
		price_per = .225;
	}
	if(s == "13"){
		price_per = .317;
	}
	if(s == "14"){
		price_per = .41;
	}
	if(s == "15"){
		price_per = .27;
	}
	if(s == "16"){
		price_per = .385;
	}
	if(s == "17"){
		price_per = .24;
	}
	color = .025;
	qfrm.nq.value = "5,000";
}
if ((intQty >= 5000) && (intQty < 10000)){
	if(s == "1"){
		price_per = .14;
	}
	if(s == "2"){
		price_per = .14;
	}
	if(s == "3"){
		price_per = .15;
	}
	if(s == "4"){
		price_per = .153;
	}
	if(s == "5"){
		price_per = .158;
	}
	if(s == "6"){
		price_per = .165;
	}
	if(s == "7"){
		price_per = .208;
	}
	if(s == "8"){
		price_per = .23;
	}
	if(s == "9"){
		price_per = .32;
	}
	if(s == "10"){
		price_per = .395;
	}
	if(s == "11"){
		price_per = .98;
	}
	if(s == "12"){
		price_per = .203;
	}
	if(s == "13"){
		price_per = .285;
	}
	if(s == "14"){
		price_per = .38;
	}
	if(s == "15"){
		price_per = .249;
	}
	if(s == "16"){
		price_per = .35;
	}
	if(s == "17"){
		price_per = .203;
	}
	color = .02;
	qfrm.nq.value = "10,000";
}
if ((intQty >= 10000) && (intQty < 20000)){
	if(s == "1"){
		price_per = .132;
	}
	if(s == "2"){
		price_per = .132;
	}
	if(s == "3"){
		price_per = .14;
	}
	if(s == "4"){
		price_per = .142;
	}
	if(s == "5"){
		price_per = .147;
	}
	if(s == "6"){
		price_per = .155;
	}
	if(s == "7"){
		price_per = .188;
	}
	if(s == "8"){
		price_per = .20;
	}
	if(s == "9"){
		price_per = .305;
	}
	if(s == "10"){
		price_per = .38;
	}
	if(s == "11"){
		price_per = .97;
	}
	if(s == "12"){
		price_per = .185;
	}
	if(s == "13"){
		price_per = .26;
	}
	if(s == "14"){
		price_per = .35;
	}
	if(s == "15"){
		price_per = .25;
	}
	if(s == "16"){
		price_per = .32;
	}
	if(s == "17"){
		price_per = .195;
	}
	color = .015;
	qfrm.nq.value = "20,000";
}
if (intQty >= 20000){
	qfrm.ac.value = "call";
	qfrm.bc.value = "call";
	qfrm.cc.value = "call";
	qfrm.dc.value = "call";
	qfrm.atc.value = "call";
	qfrm.btc.value = "call";
	qfrm.ctc.value = "call";
	qfrm.dtc.value = "call";
	return false;
}



/* calculate the price:
			multiply width x height in inches, 
			multiply by price and 
			multiply by quantity

*/



cost = price_per;

num = cost;

// below is borrowed and modified 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));*/
	
	ac = num;
	bc = (num + color);
	dc = (num + (color * 2));
	
	ac = ac.toString().replace(/\$|\,/g,'');
	if(isNaN(ac))
		ac = "0";
	ac = Math.floor(ac * 1000 + 0.50000000001);
	acents = ac % 1000;
	ac = Math.floor(ac / 1000).toString();
	if(acents < 10)
		acents = "0" + acents;
	for (var i = 0; i < Math.floor((ac.length - (1 + i)) / 3); i++)
		ac = ac.substring(0,ac.length - (4 * i + 3)) + ',' + ac.substring(ac.length-(4 * i + 3));
		
	bc = bc.toString().replace(/\$|\,/g,'');
	if(isNaN(bc))
		bc = "0";
	bc = Math.floor(bc * 1000 + 0.50000000001);
	bcents = bc % 1000;
	bc = Math.floor(bc / 1000).toString();
	if(bcents < 10)
		bcents = "0" + bcents;
	for (var i = 0; i < Math.floor((bc.length - (1 + i)) / 3); i++)
		bc = bc.substring(0,bc.length - (4 * i + 3)) + ',' + bc.substring(bc.length-(4 * i + 3));
		
	dc = dc.toString().replace(/\$|\,/g,'');
	if(isNaN(dc))
		dc = "0";
	dc = Math.floor(dc * 1000 + 0.50000000001);
	dcents = dc % 1000;
	dc = Math.floor(dc / 1000).toString();
	if(dcents < 10)
		dcents = "0" + dcents;
	for (var i = 0; i < Math.floor((dc.length - (1 + i)) / 3); i++)
		dc = dc.substring(0,dc.length - (4 * i + 3)) + ',' + dc.substring(dc.length-(4 * i + 3));
	
	ac = ('$' + ac + '.' + acents);
	bc = ('$' + bc + '.' + bcents);
	dc = ('$' + dc + '.' + dcents);
	
	qfrm.ac.value = ac;
	qfrm.bc.value = bc;
	qfrm.dc.value = dc;	
	
	numa = num * intQty;
	numb = ((num + color) * intQty);
	numd = ((num + (color * 2)) * intQty);

	
	numa = numa.toString().replace(/\$|\,/g,'');
	if(isNaN(numa))
		numa = "0";
	numa = Math.floor(numa * 100 + 0.50000000001);
	acents = numa % 100;
	numa = Math.floor(numa / 100).toString();
	if(acents < 10)
		acents = "0" + acents;
	for (var i = 0; i < Math.floor((numa.length - (1 + i)) / 3); i++)
		numa = numa.substring(0,numa.length - (4 * i + 3)) + ',' + numa.substring(numa.length-(4 * i + 3));
		
	numb = numb.toString().replace(/\$|\,/g,'');
	if(isNaN(numb))
		numb = "0";
	numb = Math.floor(numb * 100 + 0.50000000001);
	bcents = numb % 100;
	numb = Math.floor(numb / 100).toString();
	if(bcents < 10)
		bcents = "0" + bcents;
	for (var i = 0; i < Math.floor((numb.length - (1 + i)) / 3); i++)
		numb = numb.substring(0,numb.length - (4 * i + 3)) + ',' + numb.substring(numb.length-(4 * i + 3));
		
	numd = numd.toString().replace(/\$|\,/g,'');
	if(isNaN(numd))
		numd = "0";
	numd = Math.floor(numd * 100 + 0.50000000001);
	dcents = numd % 100;
	numd = Math.floor(numd / 100).toString();
	if(dcents < 10)
		dcents = "0" + dcents;
	for (var i = 0; i < Math.floor((numd.length - (1 + i)) / 3); i++)
		numd = numd.substring(0,numd.length - (4 * i + 3)) + ',' + numd.substring(numd.length-(4 * i + 3));
		
	qfrm.atc.value =  ('$' + numa + '.' + acents);
	qfrm.btc.value =  ('$' + numb + '.' + bcents);
	qfrm.dtc.value =  ('$' + numd + '.' + dcents);

return false;

} // End of function price_quote(qfrm)