

function ServerModule(model) {

var a=model;

var max=0;
var idle=0;

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

switch (a) {
case 0: max=0; idle=0; 
break;
// Xeon X5570, 2.93GHz
case 1: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=241;
idle=154;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=263;
idle=162;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=285;
idle=171;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=241;
idle=154;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=263;
idle=162;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=285;
idle=171;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=232;
idle=151;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=253;
idle=158;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=275;
idle=165;
}
break;

// Xeon X5560, 2.80GHz
case 2: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=241;
idle=154;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=263;
idle=162;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=285;
idle=171;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=241;
idle=154;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=263;
idle=162;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=285;
idle=171;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=232;
idle=151;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=253;
idle=158;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=275;
idle=165;
}
break;

// Xeon E5540, 2.53GHz
case 3: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=245;
idle=160;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=249;
idle=166;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=283;
idle=172;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=245;
idle=160;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=249;
idle=166;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=283;
idle=172;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=235;
idle=155;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=239;
idle=160;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=274;
idle=165;
}
break;

// Xeon E5520, 2.53GHz
case 4: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=245;
idle=160;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=249;
idle=166;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=283;
idle=172;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=245;
idle=160;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=249;
idle=166;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=283;
idle=172;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=235;
idle=155;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=239;
idle=160;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=274;
idle=165;
}
break;

// Xeon L5520, 2.26GHz
case 5: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=219;
idle=156;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=238;
idle=164;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=258;
idle=172;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=219;
idle=156;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=238;
idle=164;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=258;
idle=172;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=211;
idle=155;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=229;
idle=159;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=247;
idle=164;
}
break;

}

//If EightGbMemory is selected, add 2W per DIMM to the max!
var eightGBMem = (1*document.form1.EightGbMemory.value);
max= max + (eightGBMem*2);

var system_idle=idle;
var system_max=max;

var hdd_idle=(10*document.form1.hdd.value);
var hdd_max=(12*document.form1.hdd.value);

var pci_idle=(12*document.form1.pci.value);
var pci_max=(20*document.form1.pci.value);

var ssd_idle=(.1*document.form1.ssd.value);
var ssd_max=(2.4*document.form1.ssd.value);


var total_idle=(system_idle+hdd_idle+ssd_idle+pci_idle-10);
var total_max=(system_max+hdd_max+ssd_max+pci_max-12);

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);
}


function ServerModule2(model) {

var a=model;

var max=0;
var idle=0;

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

switch (a) {
case 0: max=0; idle=0; 
break;
// Xeon X5570, 2.93GHz
case 1: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=367;
idle=204;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=411;
idle=221;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=437;
idle=234;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=367;
idle=204;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=411;
idle=221;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=437;
idle=234;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=357;
idle=200;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=400;
idle=214;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=414;
idle=217;
}
break;

// Xeon X5560, 2.80GHz
case 2: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=367;
idle=204;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=411;
idle=221;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=437;
idle=234;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=367;
idle=204;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=411;
idle=221;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=437;
idle=234;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=357;
idle=200;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=400;
idle=214;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=414;
idle=217;
}
break;

// Xeon E5540, 2.53GHz
case 3: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=328;
idle=205;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=366;
idle=217;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=394;
idle=229;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=328;
idle=205;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=366;
idle=217;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=394;
idle=229;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=318;
idle=199;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=357;
idle=209;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=377;
idle=215;
}
break;

// Xeon E5520, 2.53GHz
case 4: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=328;
idle=205;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=366;
idle=217;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=394;
idle=229;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=328;
idle=205;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=366;
idle=217;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=394;
idle=229;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=318;
idle=199;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=357;
idle=209;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=377;
idle=215;
}
break;

// Xeon L5520, 2.26GHz
case 5: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=306;
idle=201;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=345;
idle=217;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=370;
idle=226;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=306;
idle=201;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=345;
idle=217;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=370;
idle=226;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=297;
idle=196;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=333;
idle=205;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=352;
idle=210;
}
break;

}

//If EightGbMemory is selected, add 2W per DIMM to the max!
var eightGBMem = (1*document.form1.EightGbMemory.value);
max= max + (eightGBMem*2);

var system_idle=idle;
var system_max=max;

var hdd_idle=(10*document.form1.hdd.value);
var hdd_max=(12*document.form1.hdd.value);

var pci_idle=(12*document.form1.pci.value);
var pci_max=(20*document.form1.pci.value);

var ssd_idle=(.1*document.form1.ssd.value);
var ssd_max=(2.4*document.form1.ssd.value);


var total_idle=(system_idle+hdd_idle+ssd_idle+pci_idle-10);
var total_max=(system_max+hdd_max+ssd_max+pci_max-12);

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);
}


 
function PrintMenu() {
	var cpuQty = document.form1.Quantity.value;

var eightGBBox = document.form1.EightGbMemory;
var fourGBBox = document.form1.FourGbMemory;
var twoGBBox = document.form1.TwoGbMemory;
 
eightGBBox.options.length = 0;
fourGBBox.options.length = 0;
twoGBBox.options.length = 0;

if (cpuQty == "1") {
  
  eightGBBox.options[eightGBBox.options.length] = new Option('None','0');
  eightGBBox.options[eightGBBox.options.length] = new Option('3 DIMMs','3');  
  eightGBBox.options[eightGBBox.options.length] = new Option('6 DIMMs','6');
  eightGBBox.options[eightGBBox.options.length] = new Option('9 DIMM','9');
  
  fourGBBox.options[fourGBBox.options.length] = new Option('None','0');
  fourGBBox.options[fourGBBox.options.length] = new Option('3 DIMMs','3');  
  fourGBBox.options[fourGBBox.options.length] = new Option('6 DIMMs','6');
  fourGBBox.options[fourGBBox.options.length] = new Option('9 DIMM','9');

  twoGBBox.options[twoGBBox.options.length] = new Option('None','0');
  twoGBBox.options[twoGBBox.options.length] = new Option('3 DIMMs','3');  
  twoGBBox.options[twoGBBox.options.length] = new Option('6 DIMMs','6');
  twoGBBox.options[twoGBBox.options.length] = new Option('9 DIMM','9');
}
else if (cpuQty == "2") {

  eightGBBox.options[eightGBBox.options.length] = new Option('None','0');
  eightGBBox.options[eightGBBox.options.length] = new Option('6 DIMMs','6');  
  eightGBBox.options[eightGBBox.options.length] = new Option('12 DIMMs','12');
  eightGBBox.options[eightGBBox.options.length] = new Option('18 DIMMs','18');  
  
  fourGBBox.options[fourGBBox.options.length] = new Option('None','0');
  fourGBBox.options[fourGBBox.options.length] = new Option('6 DIMMs','6');  
  fourGBBox.options[fourGBBox.options.length] = new Option('12 DIMMs','12');
  fourGBBox.options[fourGBBox.options.length] = new Option('18 DIMMs','18');  

  twoGBBox.options[twoGBBox.options.length] = new Option('None','0');
  twoGBBox.options[twoGBBox.options.length] = new Option('6 DIMMs','6');  
  twoGBBox.options[twoGBBox.options.length] = new Option('12 DIMMs','12');
  twoGBBox.options[twoGBBox.options.length] = new Option('18 DIMMs','18');   
}
}

function proceed() {
var a=1*document.form1.Quantity.value;
var b=1*document.form1.Processor.value;
if (a==1) {
ServerModule(b);
}
else if (a==2) {
ServerModule2(b);
}
}

function CheckForm () { 

	//Initialise variables
	var errorMsg = "";


	//Check for DIMM quantity
	if ((document.form1.EightGbMemory.value == "0")&&(document.form1.FourGbMemory.value == "0")&&(document.form1.TwoGbMemory.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;
	}
	
	proceed();
}



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

