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 qb9=0 ;
var qb10=0 ;
var qb11=0 ;
var qb12=0 ;
var qb13=0 ;
var qb14=0 ;
var qb15=0 ;
var qb16=0 ;
var qb17=0 ;


var bottle1 = 23.00;  //2007 GRENACHE
var bottle2 = 21.00;  //2008 VIOGNIER
var bottle3 = 21.00;  //2006 SANGIOVESE
var bottle4 = 22.00;  //2006 MISTERO
var bottle5 = 24.00;  //2006 CABERNET FRANC
var bottle6 = 25.00;  //2005 CABERNET SAUVIGNON
var bottle7 = 21.00;  //2004 SYRAH
var bottle8 = 27.00;  //2007 MOURVEDRE
var bottle9 = 29.00;  //2007 PETITE SYRAH 
var bottle10 = 35.00;  //2006 RESERVE SYRAH 
var bottle11 = 23.00;  //2007 MALBEC
var bottle12 = 22.00;  //2008 Trois Demoiselle
var bottle13 = 42.00;  //2006 IL NONNO 
var bottle14 = 42.00;  //2006 La BÊTE NOIRE 
var bottle15 = 46.00;  //2006 LE GRAND-PÈRE
var bottle16 = 34.00;  //2007 DESSERT SYRAH
var bottle17 = 32.00;  //2009 CONTESSA SYLVANA 

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 priceB9 = 0;
var priceB10 = 0;
var priceB11 = 0;
var priceB12 = 0;
var priceB13 = 0;
var priceB14 = 0;
var priceB15 = 0;
var priceB16 = 0;
var priceB17 = 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 total9 = 0;
var total10 = 0;
var total11 = 0;
var total12 = 0;
var total13 = 0;
var total14 = 0;
var total15 = 0;
var total16 = 0;
var total17 = 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;
	qbottle9=0;
	qbottle10=0;
	qbottle11=0;
	qbottle12=0;
	qbottle13=0;
	qbottle14=0;
	qbottle15=0;
	qbottle16=0;
	qbottle17=0;
	Bottles =0;
	
	runningTotal = 0;
	PriceBottle1 = 0;
	PriceBottle2 = 0;
	PriceBottle3 = 0;
	PriceBottle4 = 0;
	PriceBottle5 = 0;
	PriceBottle6 = 0;
	PriceBottle7 = 0;
	PriceBottle8 = 0;
	PriceBottle9 = 0;
	PriceBottle10 = 0;
	PriceBottle11 = 0;
	PriceBottle12 = 0;
	PriceBottle13 = 0;
	PriceBottle14 = 0;
	PriceBottle15 = 0;
	PriceBottle16 = 0;
	PriceBottle17 = 0;

	PriceTotal1 = 0;
	PriceTotal2 = 0;
	PriceTotal3 = 0;
	PriceTotal4 = 0;
	PriceTotal5 = 0;
	PriceTotal6 = 0;
	PriceTotal7 = 0;
	PriceTotal8 = 0;
	PriceTotal9 = 0;
	PriceTotal10 = 0;
	PriceTotal11 = 0;
	PriceTotal12 = 0;
	PriceTotal13 = 0;
	PriceTotal14 = 0;
	PriceTotal15 = 0;
	PriceTotal16 = 0;
	PriceTotal17 = 0;
	Total=0;
	
	qbottle1 = parseInt(eval(d.qb1.value))
	PriceBottle1 += bottle1 * qbottle1; 
	//PriceBottle1 += case1 * parseInt(eval(d.qc1.value)); 
	d.priceB1.value ="$"+ PriceBottle1;
	 
	qbottle2 = parseInt(eval(d.qb2.value))
	PriceBottle2 += bottle2 * qbottle2; 
	//PriceBottle2 += case2 * parseInt(eval(d.qc2.value)); 
	d.priceB2.value ="$"+ PriceBottle2;
	//d.total2.value=  "$"+  PriceBottle2; 

	qbottle3 = parseInt(eval(d.qb3.value))
	PriceBottle3 += bottle3 * qbottle3; 
	//PriceBottle3 += case3 * parseInt(eval(d.qc3.value)); 
	d.priceB3.value ="$"+ PriceBottle3;

	qbottle4 = parseInt(eval(d.qb4.value))
	PriceBottle4 += bottle4 * qbottle4; 
	//PriceBottle4 += case3 * parseInt(eval(d.qc4.value)); 
	d.priceB4.value ="$"+ PriceBottle4;

	qbottle5 = parseInt(eval(d.qb5.value))
	PriceBottle5 += bottle5 * qbottle5; 
	//PriceBottle5 += case3 * parseInt(eval(d.qc5.value)); 
	d.priceB5.value ="$"+ PriceBottle5;

	qbottle6 = parseInt(eval(d.qb6.value))
	PriceBottle6 += bottle6 * qbottle6; 
	d.priceB6.value ="$"+ PriceBottle6;

	qbottle7 = parseInt(eval(d.qb7.value))
	PriceBottle7 += bottle7 * qbottle7; 
	d.priceB7.value ="$"+ PriceBottle7;

	qbottle8 = parseInt(eval(d.qb8.value))
	PriceBottle8 += bottle8 * qbottle8; 
	d.priceB8.value ="$"+ PriceBottle8;

	qbottle9 = parseInt(eval(d.qb9.value))
	PriceBottle9 += bottle9 * qbottle9; 
	d.priceB9.value ="$"+ PriceBottle9;

	qbottle10 = parseInt(eval(d.qb10.value))
	PriceBottle10 += bottle10 * qbottle10; 
	d.priceB10.value ="$"+ PriceBottle10;

	qbottle11 = parseInt(eval(d.qb11.value))
	PriceBottle11 += bottle11 * qbottle11; 
	d.priceB11.value ="$"+ PriceBottle11;

	qbottle12 = parseInt(eval(d.qb12.value))
	PriceBottle12 += bottle12 * qbottle12; 
	d.priceB12.value ="$"+ PriceBottle12;

	qbottle13 = parseInt(eval(d.qb13.value))
	PriceBottle13 += bottle13 * qbottle13; 
	d.priceB13.value ="$"+ PriceBottle13;

	qbottle14 = parseInt(eval(d.qb14.value))
	PriceBottle14 += bottle14 * qbottle14; 
	d.priceB14.value ="$"+ PriceBottle14;

	qbottle15 = parseInt(eval(d.qb15.value))
	PriceBottle15 += bottle15 * qbottle15; 
	d.priceB15.value ="$"+ PriceBottle15;

	qbottle16 = parseInt(eval(d.qb16.value))
	PriceBottle16 += bottle16 * qbottle16; 
	d.priceB16.value ="$"+ PriceBottle16;

	qbottle17 = parseInt(eval(d.qb17.value))
	PriceBottle17 += bottle17 * qbottle17; 
	d.priceB17.value ="$"+ PriceBottle17;


     Bottles += qbottle1;
	 Bottles += qbottle2;
	 Bottles += qbottle3;
	 Bottles += qbottle4;
     Bottles += qbottle5;
	 Bottles += qbottle6;
	 Bottles += qbottle7;
	 Bottles += qbottle8;
	 Bottles += qbottle9;
	 Bottles += qbottle10;
	 Bottles += qbottle11;
	 Bottles += qbottle12;
	 Bottles += qbottle13;
	 Bottles += qbottle14;
	 Bottles += qbottle15;
	 Bottles += qbottle16;
	 Bottles += qbottle17;

	
	 //alert(Bottles);

	 Total += PriceBottle1 ;
	 Total += PriceBottle2 ;
	 Total += PriceBottle3 ;
	 Total += PriceBottle4 ;
	 Total += PriceBottle5 ;
	 Total += PriceBottle6 ;
	 Total += PriceBottle7 ;
	 Total += PriceBottle8 ;
	 Total += PriceBottle9 ;
	 Total += PriceBottle10 ;
	 Total += PriceBottle11 ;
	 Total += PriceBottle12 ;
	 Total += PriceBottle13 ;
	 Total += PriceBottle14 ;
	 Total += PriceBottle15 ;
	 Total += PriceBottle16 ;
	 Total += PriceBottle17 ;
	  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);
	}
}

