		  
function calcProgram(form,submit_it) {
// By making the first element 0, this associates the list precisely with the select list.
// To maintain all you need to do is change this array.
var blcu_prog = new Array(0,515,1215,1830,1700,2800,3400,515,775,615,705,1215,1830,1700,2800,3400,615);
var bsu_prog = new Array(0,2340,2340);
var tj_prog = new Array(0,1200,2400,1200,2400);
var sel = document.getElementById('pblcu'); // The list
var sel2 = document.getElementById('pbsu'); // The list
var sel3 = document.getElementById('ptju'); // The list
var ind = sel.selectedIndex; // What's selected
var ind2 = sel2.selectedIndex; // What's selected
var ind3 = sel3.selectedIndex; // What's selected
var prog_total = document.getElementById('prog_total');
if (ind != 0) {
  prog_total.value = blcu_prog[sel[ind].value]; // the correlating value from the array
  if (ind == 1) {
    document.accomm_form.blcu_duration.value = 4;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 2) {
    document.accomm_form.blcu_duration.value = 12;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 3) {
    document.accomm_form.blcu_duration.value = 12;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 4) {
    document.accomm_form.blcu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 5) {
    document.accomm_form.blcu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 6) {
    document.accomm_form.blcu_duration.value = 40;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 7) {
    document.accomm_form.blcu_duration.value = 4;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 8) {
    document.accomm_form.blcu_duration.value = 4;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 9) {
    document.accomm_form.blcu_duration.value = 5;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 10) {
    document.accomm_form.blcu_duration.value = 6;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 11) {
    document.accomm_form.blcu_duration.value = 12;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 12) {
    document.accomm_form.blcu_duration.value = 12;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 13) {
    document.accomm_form.blcu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 14) {
    document.accomm_form.blcu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 15) {
    document.accomm_form.blcu_duration.value = 40;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind == 16) {
    document.accomm_form.blcu_duration.value = 5;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  }  
} 
if (ind2 != 0) {
    prog_total.value = bsu_prog[sel2[ind2].value]; 
	if (ind2 == 1) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind2 == 2) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind2 == 3) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind2 == 4) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind2 == 5) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind2 == 6) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind2 == 7) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind2 == 8) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind2 == 9) {
    document.accomm_form.bsu_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  }
} 
if (ind3 != 0) {
    prog_total.value = tj_prog[sel3[ind3].value];
	if (ind3 == 1) {
    document.accomm_form.tj_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind3 == 2) {
    document.accomm_form.tj_duration.value = 40;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind3 == 3) {
    document.accomm_form.tj_duration.value = 20;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  } else 
  if ( ind3 == 4) {
    document.accomm_form.tj_duration.value = 40;
	calcAccomm(document.accomm_form);
	calcSubtotal();
  }   
}
if (ind == 0) {
    document.accomm_form.blcu_duration.value = 0;
	document.accomm_form.ablcu.selectedIndex = 0;  
}
if (ind2 == 0) {
    document.accomm_form.bsu_duration.value = 0;  
	document.accomm_form.absu.selectedIndex = 0; 
}if (ind3 == 0) {
    document.accomm_form.tj_duration.value = 0;  
	document.accomm_form.atju.selectedIndex = 0; 
}
if ( (ind == 0) && (ind2 == 0) && (ind3 == 0) ) {  
	prog_total.value = 0;
	document.accomm_form.acc_total.value = 0;
	document.accomm_form.ablcu.selectedIndex = 0;
	document.totals_form.uni_total.value = 0;
	document.totals_form.overall_total.value = 0;
}


if (submit_it) { form.submit(); }
}

function clearForm() {
  document.prog_form.pblcu.selectedIndex  = 0;
  document.prog_form.pbsu.selectedIndex  = 0;
  document.prog_form.ptju.selectedIndex  = 0;
  document.prog_form.prog_total.value = 0;
  return true;
}

function calcAccomm(form,submit_it) {
// By making the first element 0, this associates the list precisely with the select list.
// To maintain all you need to do is change this array.
var blcu_acc = new Array(0,26,14,29,60,30,0); // Prices for dorm single, dorm double, conference center, xijiao, hejia, self-arranged
var bsu_acc = new Array(0,9,6,0); // Prices for dorm single, dorm double (BSU)
var tj_acc = new Array(0,12,6,0); // Price for dorm single (Tongji)
var sel4 = document.getElementById('ablcu'); // The list
var sel5 = document.getElementById('absu'); // The list
var sel6 = document.getElementById('atju'); // The list
var blcu_duration = document.getElementById('blcu_duration');
var ind4 = sel4.selectedIndex; // What's selected
var ind5 = sel5.selectedIndex; // What's selected
var ind6 = sel6.selectedIndex; // What's selected
var acc_total = document.getElementById('acc_total');
var accomm1
var accomm2
var accomm3
if (ind4 == 0) {  
	acc_total.value = 0;
}
if (ind5 == 0) {
	acc_total.value = 0;
}
if (ind6 == 0) {
	acc_total.value = 0;  
}
if (ind4 != 0) {
  



 if ( (ind4 == 3) || (ind4 == 1) ) { // if 'Conference Center' or 'BLCU Dorm Single' is selected
  
  if (blcu_duration.value == 4) {   // equivalent to 28 days
    acc_total.value = blcu_acc[sel4[ind4].value] * 28; 
  } else
  if (blcu_duration.value == 5) {   // equivalent to 35 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(16 * 5);
    acc_total.value = 20 * 35; 
  } else
  if (blcu_duration.value == 6) {   // equivalent to 42 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(16 * 12);
    acc_total.value = 20 * 42;
  } else
  if (blcu_duration.value == 12) {  // equivalent to 84 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(16 * 54);
    acc_total.value = 18.5 * 90; // the correlating value from the array
  } else
  if (blcu_duration.value == 20) {   // equivalent to 140 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(16 * 60);
	//accomm3 = parseInt(15 * 50);
    acc_total.value = 17 * 140; 
  } else
  if (blcu_duration.value == 40) {   // equivalent to 280 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(15 * 60);
	//accomm3 = parseInt(15 * 50);
    acc_total.value = 2 * (17 * 140); 
  }   
 
}
 
  
  else // any other BLCU accomm is selected i.e. He Jia Hotel or Xi Jiao Hotel


  if (ind4 == 2) { // if 'BLCU Dorm Double' is selected
  
  if (blcu_duration.value == 4) {   // equivalent to 28 days
    acc_total.value = blcu_acc[sel4[ind4].value] * 28; 
  } else
  if (blcu_duration.value == 5) {   // equivalent to 35 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(16 * 5);
    acc_total.value = 12 * 35; 
  } else
  if (blcu_duration.value == 6) {   // equivalent to 42 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(16 * 12);
    acc_total.value = 11 * 42;
  } else
  if (blcu_duration.value == 12) {  // equivalent to 84 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(16 * 54);
    acc_total.value = 10 * 90; // the correlating value from the array
  } else
  if (blcu_duration.value == 20) {   // equivalent to 140 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(16 * 60);
	//accomm3 = parseInt(15 * 50);
    acc_total.value = 9.5 * 140; 
  } else
  if (blcu_duration.value == 40) {   // equivalent to 280 days
    //accomm1 = parseInt(blcu_acc[sel4[ind4].value] * 30);
	//accomm2 = parseInt(15 * 60);
	//accomm3 = parseInt(15 * 50);
    acc_total.value = 2 * (9.5 * 140); 
  }   
 }


else {
    acc_total.value = blcu_acc[sel4[ind4].value] * document.accomm_form.blcu_duration.value * 7;
  }
  
}

if (ind5 != 0) {
   acc_total.value = bsu_acc[sel5[ind5].value] * document.accomm_form.bsu_duration.value * 7;
}

if (ind6 != 0) {
   acc_total.value = tj_acc[sel6[ind6].value] * document.accomm_form.tj_duration.value * 7;
}

calcSubtotal();

if (submit_it) { form.submit(); }

}

function calcSubtotal() {
var progCost
var accommCost
var subtotal
var serviceCost

progCost = parseInt(document.prog_form.prog_total.value);
accommCost = parseInt(document.accomm_form.acc_total.value);
document.totals_form.uni_total.value = progCost + accommCost;

subtotal = parseInt(document.totals_form.uni_total.value);
serviceCost = parseInt(document.totals_form.chinaunipath_total.value);
document.totals_form.overall_total.value = subtotal + serviceCost;
}


function calcService(form,submit_it) {
// By making the first element 0, this associates the list precisely with the select list.
// To maintain all you need to do is change this array.
var bj_service = new Array(0,750,500,350);
var sh_service = new Array(0,550,400);
var sel7 = document.getElementById('bjservices'); // The list
var sel8 = document.getElementById('shservices'); // The list
var ind7 = sel7.selectedIndex; // What's selected
var ind8 = sel8.selectedIndex; // What's selected
var service_total = document.getElementById('service_total');
if (ind7 != 0) {
  service_total.value = bj_service[sel7[ind7].value]; // the correlating value from the array
}
if (ind8 != 0) {
  service_total.value = sh_service[sel8[ind8].value]; 
}
if ( (ind7 == 0) && (ind8 == 0) ) {  
	service_total.value = 0;
}

document.totals_form.chinaunipath_total.value = service_total.value;

calcSubtotal();

if (submit_it) { form.submit(); }
}


function startOver() {
  document.prog_form.pblcu.selectedIndex  = 0;
  document.prog_form.pbsu.selectedIndex  = 0;
  document.prog_form.ptju.selectedIndex  = 0;
  document.prog_form.prog_total.value = 0;
  
  document.accomm_form.ablcu.selectedIndex  = 0;
  document.accomm_form.absu.selectedIndex  = 0;
  document.accomm_form.atju.selectedIndex  = 0;
  document.accomm_form.acc_total.value = 0;
  document.accomm_form.blcu_duration.value  = 0;
  document.accomm_form.bsu_duration.value  = 0;
  document.accomm_form.tj_duration.value  = 0;
  
  document.service_form.bjservices.selectedIndex  = 0;
  document.service_form.shservices.selectedIndex  = 0;
  document.service_form.service_total.value = 0;
  
  scroll(0,0);
  
  return true;
}