
/////////////////////////////////////////////////////////////////////////
/////////// Calculates Total Wattage for System Configuration///////////
///////////////////////////////////////////////////////////////////////



function ServerModule(model) {

var a=model;

var max1=0;
var idle1=0;

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

switch (a) {
case 0: max1=0; idle1=0; break;
// Case of Quad Core Intel Xeon X5460 Processor(3.16 Ghz / 120W)
case 1: 
max1=238;
idle1=177;
break;
// Case of Quad Core Intel Xeon X5450 Processor(3.0 Ghz / 80W)
case 2: 
max1=212;
idle1=161;
break;
// Case of Quad Core Intel Xeon E5440 Processor (2.83 Ghz / 80W)
case 3: 
max1=212;
idle1=161;
break;
// Case of Quad Core Intel Xeon E410 Processor (2.33 Ghz / 80W)
case 4: 
max1=212;
idle1=161;
break;
// Case of Dual Core Intel Xeon 5260 Processor (3.33 Ghz / 80W)
case 5: 
max1=212;
idle1=161;
break;
// Case of Quad Core Intel Xeon L5420 Processor (2.5 Ghz / 50W)
case 6: 
max1=122;
idle1=107;
break;
// Case of Quad Core Intel Xeon X5470 Processor (3.33 GHz)
case 7: 
max1=238;
idle1=177;
break;
// Case of Quad-Core Intel Xeon L5430 Processor (2.66 GHz)
case 8: 
max1=122;
idle1=107;
}


// Calculates Total HDD Wattage
var hdd_idle=(10*document.form1.sas.value);
var hdd_max=(12*document.form1.sas.value);

// Calculates Total Memory Usage
var memory_idle=((7*document.form1.OneGbMemory.value)+(10*document.form1.TwoGbMemory.value)+(10*document.form1.FourGbMemory.value));
var memory_max=((8*document.form1.OneGbMemory.value)+(11*document.form1.TwoGbMemory.value)+(11*document.form1.FourGbMemory.value));

// Calculates Total Optical Drive Wattage
var dvd_idle=(3*document.form1.DVD.value);
var dvd_max=(8*document.form1.DVD.value);

// Calculates Total SSD Wattage
var ssd_idle=(.1*document.form1.ssd.value);
var ssd_max=(2.4*document.form1.ssd.value);

// Calculates Total PCI-E Wattage
var pci_idle=(12*document.form1.pci.value);
var pci_max=(20*document.form1.pci.value);


var total_idle=idle1+ssd_idle+hdd_idle+memory_idle+dvd_idle+pci_idle-22;
var total_max=max1+hdd_max+ssd_max+memory_max+dvd_max+pci_max-32;

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

document.form1.tot2_idle.value=Math.round(total_idle);
document.form1.tot2_power.value=Math.round(tot);
document.form1.btu_power.value=Math.round((((document.form1.tot2_idle.value*3600)/1055.056)*100)/100);
document.form1.btu_power2.value=Math.round((((document.form1.tot2_power.value*3600)/1055.056)*100)/100);

}


function ServerModule2(model2) {

var a=model2;

var max1=0;
var idle1=0;

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


switch (a) {
case 0: max1=0; idle1=0; break;
// Case of Quad Core Intel Xeon X5460 Processor(3.16 Ghz / 120W)
case 1: 
max1=317;
idle1=199;
break;
// Case of Quad Core Intel Xeon E5450 Processor (3.0 Ghz / 80W)
case 2: 
max1=265;
idle1=180;
break;
// Case of Quad Core Intel Xeon E5440 Processor (2.83 Ghz / 80W)
case 3: 
max1=265;
idle1=180;
break;
// Case of Quad Core Intel Xeon E410 Processor (2.33 Ghz / 80W)
case 4: 
max1=265;
idle1=180;
break;
// Case of Dual Core Intel Xeon 5260 Processor (3.33 Ghz / 80W)
case 5: 
max1=265;
idle1=180;
break;
// Case of Quad Core Intel Xeon L5420 Processor (2.5 Ghz / 50W)
case 6: 
max1=159;
idle1=121;
break;
// Case of Quad Core Intel Xeon X5470 Processor (3.33 GHz)
case 7: 
max1=317;
idle1=199;
break;
// Case of Quad-Core Intel Xeon L5430 Processor (2.66 GHz)
case 8: 
max1=159;
idle1=121;
break;
}


// Calculates Total HDD Wattage
var hdd_idle=(10*document.form1.sas.value);
var hdd_max=(12*document.form1.sas.value);

// Calculates Total Memory Usage
var memory_idle=((7*document.form1.OneGbMemory.value)+(10*document.form1.TwoGbMemory.value)+(10*document.form1.FourGbMemory.value));
var memory_max=((8*document.form1.OneGbMemory.value)+(11*document.form1.TwoGbMemory.value)+(11*document.form1.FourGbMemory.value));

// Calculates Total Optical Drive Wattage
var dvd_idle=(3*document.form1.DVD.value);
var dvd_max=(8*document.form1.DVD.value);

// Calculates Total SSD Wattage
var ssd_idle=(.1*document.form1.ssd.value);
var ssd_max=(2.4*document.form1.ssd.value);

// Calculates Total PCI-E Wattage
var pci_idle=(12*document.form1.pci.value);
var pci_max=(20*document.form1.pci.value);


var total_idle=idle1+ssd_idle+hdd_idle+memory_idle+dvd_idle+pci_idle-22;
var total_max=max1+ssd_max+hdd_max+memory_max+dvd_max+pci_max-32;

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

document.form1.tot2_idle.value=Math.round(total_idle);
document.form1.tot2_power.value=Math.round(tot);


document.form1.btu_power.value=Math.round((((document.form1.tot2_idle.value*3600)/1055.056)*100)/100);
document.form1.btu_power2.value=Math.round((((document.form1.tot2_power.value*3600)/1055.056)*100)/100);

}



function systot() {
var a=(1*document.form1.Processor.value);
var b=(1*document.form1.Quantity.value);

if (b == 1) {
ServerModule(a);
}
else if (b == 2) {
ServerModule2(a);
}
}


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


function setOptions(chosen) {
var selbox = document.form1.pci
 
selbox.options.length = 0;

if (chosen == "0") {
  selbox.options[selbox.options.length] = new Option('None','0');
  selbox.options[selbox.options.length] = new Option('1 PCIe Card','1');
  selbox.options[selbox.options.length] = new Option('2 PCIe Cards','2');
  selbox.options[selbox.options.length] = new Option('3 PCIe Cards','3');
}
if (chosen == "1") {
  selbox.options[selbox.options.length] = new Option('1 PCIe Card','1');
  selbox.options[selbox.options.length] = new Option('2 PCIe Cards','2');
  selbox.options[selbox.options.length] = new Option('3 PCIe Cards','3');
}
}


function PrintMenu() {
var a=((1*document.form1.sas.value));
if (a==0) {
setOptions('0');
}
if (a>0) {
setOptions('1');
}
}



function FinalCheck() {
//Checks to make sure user cannot proceed (Mozilla) if memory exceeds 16
if (((1*document.form1.FourGbMemory.value)+(1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value))>16) {
stop
}
//Checks to make sure user cannot proceed (Mozilla) if no memory is selected
else if (((1*document.form1.OneGbMemory.value)+(1*document.form1.TwoGbMemory.value)+(1*document.form1.FourGbMemory.value))==0) {
stop
}
else {
proceed();
}
}


function CheckForm () { 

	//Initialise variables
	var errorMsg = "";


	//Check for DIMM quantity
	if ((document.form1.FourGbMemory.value == "0")&&(document.form1.TwoGbMemory.value == "0")&&(document.form1.OneGbMemory.value == "0")){
		errorMsg += "\n\tDIMMs \t\t- Enter # of DIMMs 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;
	}
	
	FinalCheck();
}



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

