// Calculates Total Wattage for System Configuration
function systot() {
 
// Calculates CPU Total
var cpu_max=((1*document.form1.processor.value)*(1*document.form1.cpu.value));

var cpu_idle=0;

if ((1*document.form1.processor.value) == 80) {
    cpu_idle=(cpu_max*50)/100;
} else {
	cpu_idle=(cpu_max*30)/100;
}

var procSelInd = document.form1.processor.selectedIndex;
var procSelTxt = document.form1.processor.options[procSelInd].text;
if (procSelTxt == '2389') {
	cpu_max=cpu_max + (cpu_max*0.03);
    cpu_idle=cpu_idle + (cpu_idle*0.03);
}

// Calculates DIMM Total
var dimm_idle=(((1*document.form1.dimm8GB.value)*1)+((1*document.form1.dimm2GB.value)*2)+((1*document.form1.dimm4GB.value)*3));
var dimm_max=(((1*document.form1.dimm8GB.value)*2)+((1*document.form1.dimm2GB.value)*4)+((1*document.form1.dimm4GB.value)*6));

// Calculates HDD Total
var hdd=(((1*document.form1.hdd.value)*8));

// Calculates PCI Total
var pci=((1*document.form1.pci.value)*15);

// Calculates DVD-ROM Total
var dvd_idle=((1*document.form1.dvd.value)*3);
var dvd_max=((1*document.form1.dvd.value)*8);

// Calculates Fans & Blowers Total
var fan=(1*50);

var workload=(((1*document.form1.workload.value))/100);

var total_max=cpu_max+dimm_max+hdd+pci+dvd_max+fan;
var total_idle=cpu_idle+dimm_idle+hdd+pci+dvd_idle+fan;

var tot=Math.round((100*((total_idle+((total_max-total_idle)*workload))))/100);

document.form1.sys_tot.value=Math.round(tot);
document.form1.idle_tot.value=Math.round(total_idle);
document.form1.btu_power.value=Math.round((((document.form1.sys_tot.value*3600)/1055.056)*100)/100);
document.form1.btu_power2.value=Math.round((((document.form1.idle_tot.value*3600)/1055.056)*100)/100);
}


// Calls ALL Functions
function proceed() {
systot();
}


function CheckForm () { 

	//Initialise variables
	var errorMsg = "";

	//Check for CPU quantity
	if ((document.form1.cpu.value == "0")){
		errorMsg += "\n\tCPUs \t\t- Enter # of CPUs desired";	
	}

	//Check for DIMM quantity
	if ((document.form1.dimm8GB.value == "0")&&(document.form1.dimm2GB.value == "0")&&(document.form1.dimm4GB.value == "0")){
		errorMsg += "\n\tDIMMs \t\t- Enter # of DIMMs desired";	
	}

	//If there is a problem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Your request has not been processed because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	proceed();
}

// Tests to ensure that at least 4 DIMMS are selected
function parameterchecksone() {
CheckForm();
}
