

// Calculates Total Power of Selected DIMMs
function memtot() {
var a=(((1*document.form1.textfield2.value)*4.5)+((1*document.form1.textfield3.value)*5)+((1*document.form1.textfield4.value)*6));
document.form1.mem_tot.value=a;
}

// Calculates Total Power for CPUs
function cputot() {
var a=(1*document.form1.textfield0.value);
var b=(a*118);
document.form1.cpu_tot.value=b;
}

// Calculates Total Power for HDDs
function hddtot() {
var a=(1*document.form1.textfield5.value);
var b=(a*8);
document.form1.hdd_tot.value=b;
}

// Calculates Total Power for PCI Cards
function pcitot() {
var a=(1*document.form1.textfield6.value);
var b=(a*5);
document.form1.pci_tot.value=b;
}

// Calculates Total Power for PSUs
function psutot() {
var a=(1*document.form1.textfield7.value);
var b=(a*19);
document.form1.psu_tot.value=b;
}

// Calculates Total Power for Fixed Components
function fixtot() {
var a=75+20;
document.form1.fixed_tot.value=a;
}

// Calculates Total Wattage for System Configuration
function systot2() {
var a=((1*document.form1.mem_tot.value)+(1*document.form1.cpu_tot.value)+(1*document.form1.hdd_tot.value)+(1*document.form1.pci_tot.value)+(1*document.form1.psu_tot.value)+(1*document.form1.fixed_tot.value));
document.form1.tot_power.value=a;
}

// Calculates Total Wattage for System Configuration [Temporary]
function systot() {
var a=(((1*document.form1.textfield2.value)*4.5)+((1*document.form1.textfield3.value)*5)+((1*document.form1.textfield4.value)*6));
var b=((1*document.form1.textfield0.value)*118);
var c=((1*document.form1.textfield5.value)*8);
var d=((1*document.form1.textfield6.value)*5);
var e=((1*document.form1.textfield7.value)*19);
var f=(75+20);
document.form1.tot_power.value=((1*a)+(1*b)+(1*c)+(1*d)+(1*e)+(1*f));
}

// Calculates Total BTU for System Configuration
function btutot() {
systot();
var a=(1*document.form1.tot_power.value);
var b=((a*3600)/1055.056);
document.form1.btu_power.value=(Math.round(b*100)/100);
}

// Calculates Total BTU for System Configuration
function actot() {
btutot();
var a=(1*document.form1.btu_power.value);
var b=(a/12000);
document.form1.ac_tot.value=(Math.round(b*100)/100);
}

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


function CheckForm () { 

	//Initialise variables
	var errorMsg = "";

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

	//Check for DIMM quantity
	if ((document.form1.textfield2.value == "0")&&(document.form1.textfield3.value == "0")&&(document.form1.textfield4.value == "0")){
		errorMsg += "\n\tDIMMs \t\t- Enter # of DIMMs desired";	
	}
	
	//Check for HDD quantity
	if (document.form1.textfield5.value == "0"){
		errorMsg += "\n\tHard Disk Drives \t- Enter # of HDDs desired";	
	}

	//Check for PSU quantity
	if (document.form1.textfield7.value == "0"){
		errorMsg += "\n\tPower Supplies \t- Enter # of PSUs desired";	
	}

	//If there is aproblem 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();
}

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

// Custom Package Selection Configurations
function defaultselection() {
if (1*document.form1.defaultvalue.value==1) {
document.form1.textfield0.value=1;
document.form1.textfield2.value=2;
document.form1.textfield3.value=0;
document.form1.textfield4.value=0;
document.form1.textfield5.value=1;
document.form1.textfield6.value=0;
document.form1.textfield7.value=1;
}
else if (1*document.form1.defaultvalue.value==2) {
document.form1.textfield0.value=2;
document.form1.textfield2.value=4;
document.form1.textfield3.value=0;
document.form1.textfield4.value=0;
document.form1.textfield5.value=1;
document.form1.textfield6.value=0;
document.form1.textfield7.value=2;
}
else if (1*document.form1.defaultvalue.value==3) {
document.form1.textfield0.value=2;
document.form1.textfield2.value=0;
document.form1.textfield3.value=4;
document.form1.textfield4.value=0;
document.form1.textfield5.value=1;
document.form1.textfield6.value=0;
document.form1.textfield7.value=2;
}
else if (1*document.form1.defaultvalue.value==4) {
document.form1.textfield0.value=2;
document.form1.textfield2.value=0;
document.form1.textfield3.value=4;
document.form1.textfield4.value=0;
document.form1.textfield5.value=2;
document.form1.textfield6.value=0;
document.form1.textfield7.value=2;
}
else if (1*document.form1.defaultvalue.value==5) {
document.form1.textfield0.value=2;
document.form1.textfield2.value=0;
document.form1.textfield3.value=0;
document.form1.textfield4.value=4;
document.form1.textfield5.value=2;
document.form1.textfield6.value=0;
document.form1.textfield7.value=2;
}
}