// JavaScript Document

var pricearray = new Array();

pricearray[0] = new Array();		// saturday prices
pricearray[1] = new Array();		// friday prices
pricearray[2] = new Array();		// wednesday prices
pricearray[3] = new Array();		// sunday prices

pricearray[0][0] = 525.00;			// Prime prices
pricearray[0][1] = 342.00;			// Area A prices
pricearray[0][2] = 249.00;			// Area B prices
pricearray[0][3] = 147.00;			// Area C prices
pricearray[0][4] = 111.00;			// Area D prices
pricearray[0][5] = 54.00;			// Area E prices

pricearray[1][0] = 474.00;			// Prime prices
pricearray[1][1] = 342.00;			// Area A prices
pricearray[1][2] = 249.00;			// Area B prices
pricearray[1][3] = 147.00;			// Area C prices
pricearray[1][4] = 111.00;			// Area D prices
pricearray[1][5] = 54.00;	

pricearray[2][0] = 474.00;			// Prime prices
pricearray[2][1] = 342.00;			// Area A prices
pricearray[2][2] = 249.00;			// Area B prices
pricearray[2][3] = 147.00;			// Area C prices
pricearray[2][4] = 111.00;			// Area D prices
pricearray[2][5] = 54.00;	


pricearray[3][0] = 474.00;			// Prime prices
pricearray[3][1] = 342.00;			// Area A prices
pricearray[3][2] = 249.00;			// Area B prices
pricearray[3][3] = 147.00;			// Area C prices
pricearray[3][4] = 111.00;			// Area D prices
pricearray[3][5] = 54.00;	

var longcentersurcharge = 12;

function changetotals()
{
	var dayindex = -1;
	var dayindexlength = parseInt(document.frmbooking.optdayname.length);

	var i;
	for(i=0;i<dayindexlength;i++)
	{
		if(document.frmbooking.optdayname[i].checked)
		{
			dayindex = i;
			break;
		}
	}
	
	var pricelevelindex = -1;
	pricelevelindexlength = document.frmbooking.optpricelevel.length;
	
	for(i=0;i<pricelevelindexlength;i++)
	{
		if(document.frmbooking.optpricelevel[i].checked)
		{
			pricelevelindex = i;
			break;
		}
	}
	
	if(pricelevelindex == -1 || dayindex == -1)
	{
		return;	
	}
	
	var applicableprice;
	applicableprice = pricearray[dayindex][pricelevelindex];
	
	document.getElementById("txtpriceperseat").value = applicableprice;
	
	var numberofseats;
	numberofseats = parseInt(document.getElementById("txtnumberofseats").value);
	
	if(!numberofseats)
	{
		//alert("Please enter a valid number in Number Of Seats");
		return;
	}
	
	var grosstotal;
	grosstotal = applicableprice * numberofseats;
	document.getElementById("txtgrosstotal").value = roundafloat(grosstotal,2);
	
	var surchargetotal;
	surchargetotal = longcentersurcharge * numberofseats;
	document.getElementById("txtsurcharge").value = roundafloat(surchargetotal,2);
	
	var taxdeductiblegift;
	taxdeductiblegift = parseInt(document.getElementById("txttaxdeductiblegift").value);
	
	var endowment;
	endowment = parseInt(document.getElementById("txtendowment").value);
	
	var nettotal;
	nettotal = grosstotal + surchargetotal;
	
	if(taxdeductiblegift)
	{
		nettotal = nettotal + taxdeductiblegift;	
	}

	if(endowment)
	{
		nettotal = nettotal + endowment;
	}
	
	document.getElementById("txtnettotal").value = roundafloat(nettotal,2);
	
	return;
}

function getRadioButtonIndex(optionbutton,indexlength)
{
	var selectedbuttonindexvalue = -1;

	for(i=0;i<indexlength;i++)
	{
		if(optionbutton[i].checked)
		{
			selectedbuttonindexvalue = i;
		}
	}

	if(selectedbuttonindexvalue == -1)
	{
		return (false);
	}
	else
	{
		return (selectedbuttonindexvalue);
	}
}

function roundafloat(floatnumber,digitsafterdecimal)
{
	var logicnumber = Math.pow(10,digitsafterdecimal);
	
	var returnnumber = Math.round(floatnumber*logicnumber)/logicnumber;
	
	return (returnnumber);
}