function calculate_redeem(){

	id=document.form1.state.selectedIndex;
	abr=document.form1.state.options[id].value;
	
price=new Array();
price['CA']=new Array();
	price['CA'][1]=5;
	price['CA'][2]=10;
	price['CA'][3]=0;
price['OR']=new Array();
	price['OR'][1]=5;
	price['OR'][2]=0;
	price['OR'][3]=0;
price['IA']=new Array();
	price['IA'][1]=5;
	price['IA'][2]=0;
	price['IA'][3]=0;
price['MI']=new Array();
	price['MI'][1]=10;
	price['MI'][2]=0;
	price['MI'][3]=0;
price['NY']=new Array();
	price['NY'][1]=5;
	price['NY'][2]=0;
	price['NY'][3]=0;
price['DE']=new Array();
	price['DE'][1]=5;
	price['DE'][2]=0;
	price['DE'][3]=0;
price['CT']=new Array();
	price['CT'][1]=5;
	price['CT'][2]=0;
	price['CT'][3]=0;
price['MA']=new Array();
	price['MA'][1]=5;
	price['MA'][2]=0;
	price['MA'][3]=0;
price['VT']=new Array();
	price['VT'][1]=5;
	price['VT'][2]=0;
	price['VT'][3]=0;
price['ME']=new Array();
    price['ME'][1]=5;
	price['ME'][2]=0;
	price['ME'][3]=15;
price['HI']=new Array();
	price['HI'][1]=5;
	price['HI'][2]=0;
	price['HI'][3]=0;

	nrcans=document.form1.cans.value;
	nrbottles=document.form1.bottles.value;
	nrCAbottles=document.form1.CAbottles.value;
	nrMEbottles=document.form1.MEbottles.value;
	cans=0;	
	if( nrcans=="" || isNaN(nrcans)){
		cans=0;
	}else{
		cans=parseInt(nrcans, 10);
	}
	bottles=0;
	if(nrbottles=="" || isNaN(nrbottles)){
		bottles=0;
	}else{
		bottles=parseInt(nrbottles, 10);
	}
	CAbottles=0
	if(nrCAbottles=="" || isNaN(nrCAbottles)){
		CAbottles=0;
	}else{
		CAbottles=parseInt(nrCAbottles, 10);
	}
	MEbottles=0;
	if( nrMEbottles=="" || isNaN(nrMEbottles)){
		MEbottles=0;
	}else{
		MEbottles=parseInt(nrMEbottles, 10);
	}

	total=(price[abr][1]*(cans+bottles)*52)+(price[abr][2]*CAbottles*12)+(price[abr][3]*MEbottles*12);
	total=total/100
	
	total=total+"";
	textid=document.getElementById('dollar');
	tvs=document.getElementById('tv');
	gass=document.getElementById('gas');
	textarray=total.split(".");
	if(textarray.length==2){

		if (textarray[1].length == 0){total=total+".00";}
		if (textarray[1].length == 1){total=total+"0";}
	}else{
		total=total+".00";
	}

	
	x = total.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	//return x1 + x2;



	textid.value=x1+x2;
	tvs.innerHTML=cans*52*3;
	gass.innerHTML=cans*52*.02;

}

function reset_price(){
	textid=document.getElementById('dollar');
	textid.innerHTML="0.00";
}

function show_hide(){

	id=document.form1.state.selectedIndex;
	abr=document.form1.state.options[id].value;

	div_ca=document.getElementById("CA");
	div_me=document.getElementById("ME");

	if(abr=="CA"){
		div_ca.style.display="block";	
		div_me.style.display="none";
	}else{
		if(abr=="ME"){
			div_ca.style.display="none";	
			div_me.style.display="block";
		}else{
			div_ca.style.display="none";	
			div_me.style.display="none";
		}
	}
	
	

}
