

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=234;
idle=147;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=256;
idle=155;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=278;
idle=164;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=234;
idle=147;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=256;
idle=155;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=278;
idle=164;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=225;
idle=144;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=246;
idle=151;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=268;
idle=158;
}
break;

// Xeon X5560, 2.80GHz
case 2: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=234;
idle=147;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=256;
idle=155;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=278;
idle=164;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=234;
idle=147;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=256;
idle=155;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=278;
idle=164;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=225;
idle=144;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=246;
idle=151;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=268;
idle=158;
}
break;

// Xeon E5540, 2.53GHz
case 3: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=238;
idle=153;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=242;
idle=159;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=276;
idle=165;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=238;
idle=153;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=242;
idle=159;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=276;
idle=165;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=228;
idle=148;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=232;
idle=153;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=267;
idle=158;
}
break;

// Xeon E5520, 2.53GHz
case 4: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=238;
idle=153;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=242;
idle=159;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=276;
idle=165;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=238;
idle=153;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=242;
idle=159;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=276;
idle=165;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=228;
idle=148;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=232;
idle=153;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=267;
idle=158;
}
break;

// Xeon L5520, 2.26GHz
case 5: 
if ((1*document.form1.EightGbMemory.value)==3) {
max=212;
idle=149;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=231;
idle=157;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=251;
idle=165;
}
else if ((1*document.form1.FourGbMemory.value)==3) {
max=212;
idle=149;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=231;
idle=157;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=251;
idle=165;
}
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=204;
idle=148;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=222;
idle=152;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=240;
idle=157;
}
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 dvd_idle=(3*document.form1.dvd.value);
var dvd_max=(8*document.form1.dvd.value);

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

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

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


var total_idle=(system_idle+dvd_idle+hdd_idle+ssd_idle+pci_idle-10);
var total_max=(system_max+dvd_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=360;
idle=197;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=404;
idle=214;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=430;
idle=227;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=360;
idle=197;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=404;
idle=214;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=430;
idle=227;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=350;
idle=193;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=393;
idle=207;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=407;
idle=210;
}
break;

// Xeon X5560, 2.80GHz
case 2: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=360;
idle=197;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=404;
idle=214;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=430;
idle=227;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=360;
idle=197;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=404;
idle=214;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=430;
idle=227;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=350;
idle=193;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=393;
idle=207;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=407;
idle=210;
}
break;

// Xeon E5540, 2.53GHz
case 3: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=321;
idle=198;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=359;
idle=210;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=387;
idle=222;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=321;
idle=198;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=359;
idle=210;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=387;
idle=222;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=311;
idle=192;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=350;
idle=202;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=370;
idle=208;
}
break;

// Xeon E5520, 2.53GHz
case 4: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=321;
idle=198;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=359;
idle=210;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=387;
idle=222;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=321;
idle=198;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=359;
idle=210;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=387;
idle=222;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=311;
idle=192;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=350;
idle=202;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=370;
idle=208;
}
break;

// Xeon L5520, 2.26GHz
case 5: 
if ((1*document.form1.EightGbMemory.value)==6) {
max=299;
idle=194;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=338;
idle=210;
}
else if ((1*document.form1.EightGbMemory.value)==18) {
max=363;
idle=219;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=299;
idle=194;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=338;
idle=210;
}
else if ((1*document.form1.FourGbMemory.value)==18) {
max=363;
idle=219;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=290;
idle=189;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=326;
idle=198;
}
else if ((1*document.form1.TwoGbMemory.value)==18) {
max=345;
idle=203;
}
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 dvd_idle=(3*document.form1.dvd.value);
var dvd_max=(8*document.form1.dvd.value);

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

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

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


var total_idle=(system_idle+dvd_idle+hdd_idle+ssd_idle+pci_idle-10);
var total_max=(system_max+dvd_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();
}

