var d;
var base;

var qb1=0 ;
var qb2=0 ;
var qb3=0 ;
var qb4=0 ;
var qb5=0 ;
var qb6=0 ;
var qb7=0 ;
var qb8=0 ;
var qb82=0 ;
var qb9=0 ;
var qb10=0 ;

var priceB1 = 0;
var priceB2 = 0;
var priceB3 = 0;
var priceB4 = 0;
var priceB5 = 0;
var priceB6 = 0;
var priceB7 = 0;
var priceB8 = 0;
var priceB82 = 0;
var priceB9 = 0;
var priceB10 = 0;

var total1 = 0;
var total2 = 0;
var total3 = 0;
var total4 = 0;
var total5 = 0;
var total6 = 0;
var total7 = 0;
var total8 = 0;
var total82 = 0;
var total9 = 0;
var total10 = 0;
var Total;

///////////////////////////////

function doCalc(theItem){

	//switchDescription(theItem);

	d = document.theForm;

	qbottle1=0;
	qbottle2=0;
	qbottle3=0;
	qbottle4=0;
	qbottle5=0;
	qbottle6=0;
	qbottle7=0;
	qbottle8=0;
	qbottle82=0;
	qbottle9=0;
	qbottle10=0;
	Bottles =0;
	
	runningTotal = 0;
	PriceBottle1 = 0;
	PriceBottle2 = 0;
	PriceBottle3 = 0;
	PriceBottle4 = 0;
	PriceBottle5 = 0;
	PriceBottle6 = 0;
	PriceBottle7 = 0;
	PriceBottle8 = 0;
	PriceBottle82 = 0;
	PriceBottle9 = 0;
	PriceBottle10 = 0;

	PriceTotal1 = 0;
	PriceTotal2 = 0;
	PriceTotal3 = 0;
	PriceTotal4 = 0;
	PriceTotal5 = 0;
	PriceTotal6 = 0;
	PriceTotal7 = 0;
	PriceTotal8 = 0;
	PriceTotal82 = 0;
	PriceTotal9 = 0;
	PriceTotal10 = 0;
	Total=0;
	
	qbottle1 = parseInt(eval(d.qb1.value))
    qbottle2 = parseInt(eval(d.qb2.value))
	qbottle3 = parseInt(eval(d.qb3.value))
    qbottle4 = parseInt(eval(d.qb4.value))
	qbottle5 = parseInt(eval(d.qb5.value))
	qbottle6 = parseInt(eval(d.qb6.value))
	qbottle7 = parseInt(eval(d.qb7.value))
	qbottle8 = parseInt(eval(d.qb8.value))
	qbottle82 = parseInt(eval(d.qb82.value))
	qbottle9 = parseInt(eval(d.qb9.value))
	qbottle10 = parseInt(eval(d.qb10.value))

//   Calculation Total number of bottles 
	 Bottles += qbottle1;
	 Bottles += qbottle2;
	 Bottles += qbottle3;
	 Bottles += qbottle4;
     Bottles += qbottle5;
	 Bottles += qbottle6;
	 Bottles += qbottle7;
	 Bottles += qbottle8;
	 Bottles += qbottle82;
	 Bottles += qbottle9;
	 Bottles += qbottle10;

	 if (Bottles<12)
	 {	var bottle1 = 12.00;
		var bottle2 = 28.00;
		var bottle3 = 21.00;
		var bottle4 = 16.00;
		var bottle5 = 18.00;
		var bottle6 = 24.00;
		var bottle7 = 8.00;
		var bottle8 = 13.00;
		var bottle82 = 13.00;
		var bottle9 = 18.00;
		var bottle10 = 13.00;
	 } 
	 else 
	 {	var bottle1 = 10.00;
		var bottle2 = 24.00;
		var bottle3 = 18.00;
		var bottle4 = 14.00;
		var bottle5 = 15.00;
		var bottle6 = 20.00;
		var bottle7 = 7.00;
		var bottle8 = 11.00;
		var bottle82 = 11.00;
		var bottle9 = 13.00;
		var bottle10 = 11.00;
	 } 
	
	//Calculation for bottle 1 
	PriceBottle1 += bottle1 * qbottle1; 
	d.priceB1.value ="$"+ PriceBottle1;	 
	//alert(Bottles);
	//alert(bottle1);
	//alert(d.priceB1.value);
	
	//Calculation for bottle 2 
	PriceBottle2 += bottle2 * qbottle2;  
	d.priceB2.value ="$"+ PriceBottle2;


	//Calculation for bottle 3 
	PriceBottle3 += bottle3 * qbottle3; 
	d.priceB3.value ="$"+ PriceBottle3;

	//Calculation for bottle 4 
	PriceBottle4 += bottle4 * qbottle4;  
	d.priceB4.value ="$"+ PriceBottle4;

	//Calculation for bottle 5 
	PriceBottle5 += bottle5 * qbottle5; 
	d.priceB5.value ="$"+ PriceBottle5;

	//Calculation for bottle 6 
	PriceBottle6 += bottle6 * qbottle6; 
	d.priceB6.value ="$"+ PriceBottle6;

	//Calculation for bottle 7 
	PriceBottle7 += bottle7 * qbottle7; 
	d.priceB7.value ="$"+ PriceBottle7;

    //Calculation for bottle 8 
	PriceBottle8 += bottle8 * qbottle8; 
	d.priceB8.value ="$"+ PriceBottle8; 

	//Calculation for bottle 82 
	PriceBottle82 += bottle82 * qbottle82; 
	d.priceB82.value ="$"+ PriceBottle82; 
	
	//Calculation for bottle 9 
	PriceBottle9 += bottle9 * qbottle9; 
	d.priceB9.value ="$"+ PriceBottle9;
	
	//Calculation for bottle 10 
	PriceBottle10 += bottle10 * qbottle10; 
	d.priceB10.value ="$"+ PriceBottle10;

//alert(Bottles);

	 Total += PriceBottle1 ;
	 Total += PriceBottle2 ;
	 Total += PriceBottle3 ;
	 Total += PriceBottle4 ;
	 Total += PriceBottle5 ;
	 Total += PriceBottle6 ;
	 Total += PriceBottle7 ;
	 Total += PriceBottle8 ;
	 Total += PriceBottle82 ;
	 Total += PriceBottle9 ;
	 Total += PriceBottle10 ;

	  if ((Bottles)>11)
	 { //alert(Bottles);
	  //alert(Total);
	 Total = Math.floor((Total*0.90)*100) ;
	 Total = Total/100 ;
	 }

	d.total1.value=  Total; 
	//d.total2.value=  "$"+  Total;  
	//d.total3.value=  "$"+  Total; 
	//d.total4.value=  "$"+  Total; 
	//d.total5.value=  "$"+  Total; 
	}

function init(){
	d = document.theForm;
	
}

function switchDescription(selectedItem){
	// first set all to hidden
	descs = new Array('qb1Div','qb2Div','qb3Div','qb4Div','qb5Div','qb6Div','qb7Div');
	for(x=0; x < 7; x++){
		if(document.getElementById){
			document.all[descs[x]].style.visibility = "hidden";
		}
		else{
			str = "document.layers.";
			str += descs[x];
			str += ".visibility = 'hidden'";
			eval(str);
		}
	}
	if(document.getElementById){
		document.all[selectedItem].style.visibility = "visible";
	}
	else{
		str = "document.layers.";
		str += selectedItem;
		str += ".visibility = 'visible'";
		eval(str);
	}
}
