


// Calculates Total Wattage for System Configuration
function systot() {
//Calculates total memory power

var a1=(1*document.form1.OneGbMemory.value);
var a2=(1*document.form1.TwoGbMemory.value);
var a3=(1*document.form1.FourGbMemory.value);
var a83=(1*document.form1.EightGbMemory.value);
var a4=((1*document.form1.CPU_Utilization.value)/100);

var a5=a1*Math.round((2+(2*a4))*100)/100;
var a6=a2*Math.round((1+(2*a4))*100)/100;
var a7=a3*Math.round((1+(3*a4))*100)/100;
var a87=a83*Math.round((2+(3*a4))*100)/100;
var a=(1*a5)+(1*a6)+(1*a7)+(1*a87);

// Calculates total cpu power
var b1=(1*document.form1.CPU_Power.value);
if (b1==1) {
var b=Math.round((1*document.form1.CPU.value)*(20+(48*a4))*100)/100; 
}
else if (b1==2) {
var b=Math.round((1*document.form1.CPU.value)*(30+(65*a4))*100)/100;
}
else if (b1==3) {
var b=Math.round((1*document.form1.CPU.value)*(40+(80*a4))*100)/100;
}
else if (b1==4) {
var b=Math.round((1*document.form1.CPU.value)*(35+(70*a4))*100)/100;
}
else if (b1==5) {
var b=Math.round((1*document.form1.CPU.value)*(30+(43*a4))*100)/100;
}

// Calcullates hard drive power
var c=(9*document.form1.hdd.value);

// Calculates pci card power
var d=(16*document.form1.pci.value);

// Calculates power supply power
var e=(7.8*4);

// Calculates Fixed Numbers
// Calculate fans
var g=69;
//Calculates miscellaneous

var h=((((40*document.form1.CPU.value)/8)-25)*a4);
//different formula for 75W only
if (b1==5) {
	if ((1*document.form1.CPU.value == 6) || (1*document.form1.CPU.value == 8)) {
		h = -20;
	} else if ((1*document.form1.CPU.value == 4)) {
		h = -5 * a4;
	} else if ((1*document.form1.CPU.value == 2)) {
		h = 10+((((50*document.form1.CPU.value)/8)-10)*a4)
	}
}

var dc=Math.round((a+b+c+d+e+g+h)*10)/10;
var dc2=Math.round((dc/3800)*100)/100;
var j=(1*document.form1.textfield13.value);
var k=Math.round((1+(1-1/0.965)*(j-220)/110)*100)/100;

var ac_pre=Math.round(((((0.18008*(dc2*dc2*dc2))-(0.49518*(dc2*dc2))+(0.45273*(dc2))+0.75382)))*100)/100;

var ac=Math.round(((dc/ac_pre)*k)*100)/100;

document.form1.tot_power.value=Math.round(ac);
}

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

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


function finalcheck() {

//Checks to make sure user cannot proceed (Mozilla) if more than 16 dimms are selected [2 CPU]
if ((1*document.form1.CPU.value==2)&&(((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))>16)) {
stop																														 
}
//Checks to make sure user cannot proceed (Mozilla) if more than 8 dimms are selected [2 CPU - 120W]
else if (((document.form1.CPU.value == "2") && (document.form1.CPU_Power.value == "3")) && (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))>8)) {
stop
}
//Checks to make sure user cannot proceed (Mozilla) if more than 32 dimms are selected [4 CPU]
else if ((1*document.form1.CPU.value==4)&&(((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))>32)) {
stop																														 
}
//Checks to make sure user cannot proceed (Mozilla) if more than 16 dimms are selected [4 CPU - 120W]
else if (((document.form1.CPU.value == "4") && (document.form1.CPU_Power.value == "3")) && (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))>16)) {
stop
}
//Checks to make sure user cannot proceed (Mozilla) if more than 48 dimms are selected 6 CPU]
else if ((1*document.form1.CPU.value==6)&&(((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))>48)) {
stop																														 
}
//Checks to make sure user cannot proceed (Mozilla) if more than 24 dimms are selected [6 CPU - 120W]
else if (((document.form1.CPU.value == "6") && (document.form1.CPU_Power.value == "3")) && (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))>24)) {
stop
}
//Checks to make sure user cannot proceed (Mozilla) if more than 64 dimms are selected 8 CPU]
else if ((1*document.form1.CPU.value==8)&&(((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))>64)) {
stop																														 
}
//Checks to make sure user cannot proceed (Mozilla) if more than 32 dimms are selected [8 CPU - 120W]
else if (((document.form1.CPU.value == "8") && (document.form1.CPU_Power.value == "3")) && (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))>32)) {
stop
}
// Checks to make sure that CPU Utlization is not more than 100%
else if (1*document.form1.CPU_Utilization.value>100) {
stop
}
// Checks to make sure that at least 1 HDD is selected and no more than 4
else if ((1*document.form1.hdd.value<0)||(1*document.form1.hdd.value>4)) {
stop	
}
// Checks to make sure that no more than 8 PCI cards are selected
else if (1*document.form1.pci.value>8) {
stop	
}
else {
proceed();
}
}

function CheckForm () { 

	//Initialise variables
	var errorMsg = "";


	//Check for DIMM quantity
	if ((document.form1.CPU.value == "2") && (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))<4)) {
		errorMsg += "\n\tDIMMs \t\t- Minimum of 4 DIMMs for " + document.form1.CPU.value + " CPUs";	
	}

	//Check for DIMM quantity
	if ((document.form1.CPU.value == "4") && (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))<8)) {
		errorMsg += "\n\tDIMMs \t\t- Minimum of 8 DIMMs for " + document.form1.CPU.value + " CPUs";	
	}

	//Check for DIMM quantity
	if ((document.form1.CPU.value == "6") && (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))<12)) {
		errorMsg += "\n\tDIMMs \t\t- Minimum of 12 DIMMs for " + document.form1.CPU.value + " CPUs";	
	}

	//Check for DIMM quantity
	if ((document.form1.CPU.value == "8") && (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value)+(1*document.form1.EightGbMemory.value))<16)) {
		errorMsg += "\n\tDIMMs \t\t- Minimum of 16 DIMMs for " + document.form1.CPU.value + " CPUs";	
	}


	//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;
	}
	
	finalcheck();
}

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