var Sum = 140; // The Initial amount  //
var Amt = 0;
var Index = 0;

SumArray = new Array(140); // The prices of products that are selected by default when the page opens //
SelectedIndexes = new Array(0); // The selected Indexes of all Radio Buttons //

IndexValues = new Array();
// The following arrays contain the Code of the products //
IndexValues[0] = new Array('BOX1', 'BOX2'); 

PricesArray = new Array();
// The following arrays contain the Prices of all the products //
PricesArray[0] = new Array(140,180);

function CreateModelNumber(RadioIndex, SelectedIndex)
{
	Sum = Sum - SumArray[RadioIndex];

	Amt = PricesArray[RadioIndex][SelectedIndex];

	SumArray[RadioIndex] = Amt;
	Sum += Amt;

	Q = document.form1.qty.selectedIndex+1;
	Amt = Sum*Q;

	SelectedIndexes[RadioIndex] = SelectedIndex;

	Code = IndexValues[RadioIndex][SelectedIndexes];

	if(SelectedIndex == 0) { Sum = 140; Amt = Sum*Q; }
	else if(SelectedIndex == 1) { Sum = 180; Amt = Sum*Q; }
	document.getElementById('ModelNumber').innerHTML = Code; // Write the generated Code to the Table at the end of the page //
	document.getElementById('BasicPrice').innerHTML = Sum; // Write the Sum to the Table at the end of the page //
	document.getElementById('OrderQuantity').innerHTML = Q; // Write the Quantity to the Table at the end of the page //
	document.getElementById('OrderTotal').innerHTML = Amt; // Write the Entended Price to the Table at the end of the page //

	document.getElementById('ModelConfig').value = Code; // Set the value of hidden field 'ModelConfig' to the generated Code //

	document.forms.form1.PricePerModel.value = Sum; // Set the value of hidden field 'PricePerModel' to Price Per Model //
	document.forms.form1.hdnQuantity.value = Q; // Set the value of hidden field 'hdnQuantity' to the Quantity //
}

function calculateTotal() // This function is called when the Quantity is changed //
{
	Q = document.form1.qty.selectedIndex+1;
	Amt = Sum*Q;
	
	document.getElementById('BasicPrice').innerHTML = Sum;
	document.getElementById('OrderQuantity').innerHTML = Q;
	document.getElementById('OrderTotal').innerHTML = Amt;

	document.forms.form1.PricePerModel.value = Sum;
	document.forms.form1.hdnQuantity.value = Q;
}

window.onload = function()
{
	Code = 'BOX1';

	document.getElementById('ModelNumber').innerHTML = Code;

	document.getElementById('ModelConfig').value = Code;
	document.forms.form1.PricePerModel.value = 140;
	document.forms.form1.hdnQuantity.value = 1;
}