if (typeof(Number)!='undefined'&&typeof(Number.prototype)!='undefined'){
  if (typeof(Number.prototype.toFixed)=='undefined'){

    function Number_toFixed(d) {
      var n = this;
      d = d || 2;
      var f = Math.pow(10, d);
      n = Math.round(n * f) / f;
      n += Math.pow(10, - (d + 1));
      n += '';
      return d == 0 ? n.substring(0, n.indexOf('.')) :
        n.substring(0, n.indexOf('.') + d + 1);
    }
    Number.prototype.toFixed = Number_toFixed;
  }
}


function prodOne() { 

if (window.document.orderForm.prod1.checked == true) {
	window.document.orderForm.prod1quantity.focus();
		}
if (window.document.orderForm.prod1.checked == false) {
	window.document.orderForm.prod1quantity.value = '';
	window.document.orderForm.prod1quantity.blur();
	calcPrices();
		}		
}

function prodTwo() { 

if (window.document.orderForm.prod2.checked == true) {
	window.document.orderForm.prod2quantity.focus();
		}
if (window.document.orderForm.prod2.checked == false) {
	window.document.orderForm.prod2quantity.value = '';
	window.document.orderForm.prod2quantity.blur();
	calcPrices();
		}		
}

function prodThree() { 

if (window.document.orderForm.prod3.checked == true) {
	window.document.orderForm.prod3quantity.focus();
		}
if (window.document.orderForm.prod3.checked == false) {
	window.document.orderForm.prod3quantity.value = '';
	window.document.orderForm.prod3quantity.blur();
	calcPrices();
		}		
}


function calcPrices() { 

////////// Product 1 ////////////

if (window.document.orderForm.prod1quantity.value == '')		{
		x_prod1price = 60.00;
		window.document.orderForm.prod1price.value = '' ;		
		}

if (window.document.orderForm.prod1quantity.value == 1)		{
		x_prod1price = 60.00;
		window.document.orderForm.prod1price.value = '$' + x_prod1price;		
		}
		
if ((window.document.orderForm.prod1quantity.value > 1)	&& (window.document.orderForm.prod1quantity.value < 6)) {
		x_prod1price = 57.00;
		window.document.orderForm.prod1price.value = '$' + x_prod1price;		
		}
		
if ((window.document.orderForm.prod1quantity.value > 5)	&& (window.document.orderForm.prod1quantity.value < 11)) {
		x_prod1price = 54.00;
		window.document.orderForm.prod1price.value = '$' + x_prod1price;		
		}	
		
if ((window.document.orderForm.prod1quantity.value > 10)	&& (window.document.orderForm.prod1quantity.value < 26)) {
		x_prod1price = 51.00;
		window.document.orderForm.prod1price.value = '$' + x_prod1price;		
		}	
		
if ((window.document.orderForm.prod1quantity.value > 25)	&& (window.document.orderForm.prod1quantity.value < 51)) {
		x_prod1price = 48.00;
		window.document.orderForm.prod1price.value = '$' + x_prod1price;		
		}
		
if ((window.document.orderForm.prod1quantity.value > 50)	&& (window.document.orderForm.prod1quantity.value < 101)) {
		x_prod1price = 45.00;
		window.document.orderForm.prod1price.value = '$' + x_prod1price;		
		}
		
if (window.document.orderForm.prod1quantity.value > 100)		{
		x_prod1price = 40.00;
		window.document.orderForm.prod1price.value = '$' + x_prod1price;		
		}		

x_prod1total = (window.document.orderForm.prod1quantity.value) * x_prod1price;
window.document.orderForm.prod1total.value = '$' + x_prod1total.toFixed(2);

if ((window.document.orderForm.prod1quantity.value == '') || (window.document.orderForm.prod1quantity.value == 0))	{
		x_prod1price = '';
		window.document.orderForm.prod1price.value = '';
		window.document.orderForm.prod1total.value = ''		
		}

////////// Product 2 ////////////		

x_prod2total2 = 0;
x_prod2total3 = 0;
prod2quantity = 0;

if	((window.document.orderForm.prod2quantity.value == '') || (window.document.orderForm.prod2quantity.value == '0')) 	{
	window.document.orderForm.prod2price.value = '';
	window.document.orderForm.prod2total2.value = '';
	}

if	(window.document.orderForm.prod2quantity.value != '')	{

if (window.document.orderForm.prod2quantity.value < 11)  {
		x_prod2price = 13.50;
		window.document.orderForm.prod2price.value = '$' + x_prod2price.toFixed(2);		
		}
		
if ((window.document.orderForm.prod2quantity.value > 10) && (window.document.orderForm.prod2quantity.value < 21)) {
		x_prod2price = 12.85;
		window.document.orderForm.prod2price.value = '$' + x_prod2price.toFixed(2);			
		}
		
if ((window.document.orderForm.prod2quantity.value > 20) && (window.document.orderForm.prod2quantity.value < 51)) {
		x_prod2price = 11.50;
		window.document.orderForm.prod2price.value = '$' + x_prod2price.toFixed(2);			
		}	

if ((window.document.orderForm.prod2quantity.value > 50) && (window.document.orderForm.prod2quantity.value < 101)) {
		x_prod2price = 10.50;
		window.document.orderForm.prod2price.value = '$' + x_prod2price.toFixed(2);		
		}	

if ((window.document.orderForm.prod2quantity.value > 100) && (window.document.orderForm.prod2quantity.value < 251)) {
		x_prod2price = 9.50;
		window.document.orderForm.prod2price.value = '$' + x_prod2price.toFixed(2);		
		}
		
if ((window.document.orderForm.prod2quantity.value > 250) && (window.document.orderForm.prod2quantity.value < 501)) {
		x_prod2price = 8.50;
		window.document.orderForm.prod2price.value = '$' + x_prod2price.toFixed(2);		
		}	

if (window.document.orderForm.prod2quantity.value > 500) {
		x_prod2price = 7.50;
		window.document.orderForm.prod2price.value = '$' + x_prod2price.toFixed(2);		
		}
		
	x_prod2total2 = (window.document.orderForm.prod2quantity.value) * x_prod2price;
	window.document.orderForm.prod2total2.value = '$' +  x_prod2total2.toFixed(2);
}

if (window.document.orderForm.product2Basic.checked == true) {
		x_prod2total1 = 475.00;
		window.document.orderForm.prod2total1.value = '$' + x_prod2total1.toFixed(2);


x_prod2total3 = (x_prod2total1 + x_prod2total2);
window.document.orderForm.prod2total3.value = '$' + x_prod2total3.toFixed(2);
}

if (window.document.orderForm.product2Basic.checked == false) {
		x_prod2total1 = 0.00;
		window.document.orderForm.prod2total1.value = '' ;
		x_prod2total3 = (x_prod2total1 + x_prod2total2);
		window.document.orderForm.prod2total3.value = '$' + x_prod2total3.toFixed(2);
		if (window.document.orderForm.prod2total3.value == '$0.00')
			{window.document.orderForm.prod2total3.value = '';}
		}


////////// Product 3 ////////////	

x_prod3total2 = 0;
x_prod3total3 = 0;
prod3quantity = 0;

if	((window.document.orderForm.prod3quantity.value == '') || (window.document.orderForm.prod3quantity.value == '0')) 	{
	window.document.orderForm.prod3price.value = '';
	window.document.orderForm.prod3total2.value = '';
	}

if	(window.document.orderForm.prod3quantity.value != '')	{

if (window.document.orderForm.prod3quantity.value < 21)  {
		x_prod3price = 23.75;
		window.document.orderForm.prod3price.value = '$' + x_prod3price.toFixed(2);		
		}
		
if ((window.document.orderForm.prod3quantity.value > 20) && (window.document.orderForm.prod3quantity.value < 51)) {
		x_prod3price = 21.25;
		window.document.orderForm.prod3price.value = '$' + x_prod3price.toFixed(2);		
		}	

if ((window.document.orderForm.prod3quantity.value > 50) && (window.document.orderForm.prod3quantity.value < 101)) {
		x_prod3price = 19.25;
		window.document.orderForm.prod3price.value = '$' + x_prod3price.toFixed(2);		
		}	

if ((window.document.orderForm.prod3quantity.value > 100) && (window.document.orderForm.prod3quantity.value < 251)) {
		x_prod3price = 18.50;
		window.document.orderForm.prod3price.value = '$' + x_prod3price.toFixed(2);		
		}
		
if ((window.document.orderForm.prod3quantity.value > 250) && (window.document.orderForm.prod3quantity.value < 501)) {
		x_prod3price = 17.50;
		window.document.orderForm.prod3price.value = '$' + x_prod3price.toFixed(2);		
		}	

if (window.document.orderForm.prod3quantity.value > 500) {
		x_prod3price = 15.75;
		window.document.orderForm.prod3price.value = '$' + x_prod3price.toFixed(2);		
		}
		
	x_prod3total2 = (window.document.orderForm.prod3quantity.value) * x_prod3price;
	window.document.orderForm.prod3total2.value = '$' +  x_prod3total2.toFixed(2);

}
		
if (window.document.orderForm.product3Basic.checked == true) {
		x_prod3total1 = 795.00;
		window.document.orderForm.prod3total1.value = '$' +  x_prod3total1.toFixed(2);

		x_prod3total3 = x_prod3total1 + x_prod3total2;
		window.document.orderForm.prod3total3.value = '$' + x_prod3total3.toFixed(2);
}

if (window.document.orderForm.product3Basic.checked == false) {
		x_prod3total1 = 0.00;
		window.document.orderForm.prod3total1.value = '' ;
		x_prod3total3 = x_prod3total1 + x_prod3total2;
		window.document.orderForm.prod3total3.value = '$' + x_prod3total3.toFixed(2);
		if (window.document.orderForm.prod3total3.value == '$0.00')
			{window.document.orderForm.prod3total3.value = '';}
		}



////////// Product 4 ////////////		

x_prod4total = 0;

if (window.document.orderForm.product4.checked == true) {
		x_prod4total = 125.00;
		window.document.orderForm.prod4total.value = '$' + x_prod4total.toFixed(2);
		} 
		
if (window.document.orderForm.product4.checked == false) {
		x_prod4total = 0.00;
		window.document.orderForm.prod4total.value = '';
		} 
		

grandTotal = x_prod1total + x_prod2total3 + x_prod3total3 + x_prod4total;
window.document.orderForm.prodSubtotal.value = grandTotal;
window.document.orderForm.grandTotal.value = '$' + grandTotal.toFixed(2);

}

