

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.93 GHz and 95 W
case 1: 
if ((1*document.form1.EightGbMemory.value)==1) {
max=164;
idle=116;
} 
else if ((1*document.form1.EightGbMemory.value)==3) {
max=179;
idle=121;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=202;
idle=128;
}
else if ((1*document.form1.FourGbMemory.value)==1) {
max=163;
idle=115;
} 
else if ((1*document.form1.FourGbMemory.value)==3) {
max=178;
idle=120;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=201;
idle=127;
}
else if ((1*document.form1.TwoGbMemory.value)==1) {
max=162;
idle=116;
} 
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=171;
idle=118;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=184;
idle=121;
}
break;

// Xeon X5550, 2.66 GHz and 95 W
case 2: 
if ((1*document.form1.EightGbMemory.value)==1) {
max=164;
idle=118;
} 
else if ((1*document.form1.EightGbMemory.value)==3) {
max=179;
idle=123;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=201;
idle=130;
}
else if ((1*document.form1.FourGbMemory.value)==1) {
max=163;
idle=117;
} 
else if ((1*document.form1.FourGbMemory.value)==3) {
max=178;
idle=122;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=200;
idle=129;
}
else if ((1*document.form1.TwoGbMemory.value)==1) {
max=166;
idle=119;
} 
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=173;
idle=120;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=183;
idle=122;
}
break;

// Xeon E5540, 2.53 GHz and 80 W
case 3: 
if ((1*document.form1.EightGbMemory.value)==1) {
max=159;
idle=112;
} 
else if ((1*document.form1.EightGbMemory.value)==3) {
max=174;
idle=117;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=196;
idle=124;
}
else if ((1*document.form1.FourGbMemory.value)==1) {
max=158;
idle=111;
} 
else if ((1*document.form1.FourGbMemory.value)==3) {
max=173;
idle=116;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=195;
idle=123;
}
else if ((1*document.form1.TwoGbMemory.value)==1) {
max=159;
idle=112;
} 
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=167;
idle=114;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=178;
idle=116;
}
break;

// Xeon L5520, 2.4 GHz and 60 W
case 4: 
if ((1*document.form1.EightGbMemory.value)==1) {
max=143;
idle=112;
} 
else if ((1*document.form1.EightGbMemory.value)==3) {
max=158;
idle=117;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=180;
idle=124;
}
else if ((1*document.form1.FourGbMemory.value)==1) {
max=142;
idle=111;
} 
else if ((1*document.form1.FourGbMemory.value)==3) {
max=157;
idle=116;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=179;
idle=123;
}
else if ((1*document.form1.TwoGbMemory.value)==1) {
max=143;
idle=112;
} 
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=151;
idle=114;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=162;
idle=116;
}
break;

// Xeon E5504, 2.0 GHz and 80 W
case 5: 
if ((1*document.form1.EightGbMemory.value)==1) {
max=141;
idle=108;
} 
else if ((1*document.form1.EightGbMemory.value)==3) {
max=156;
idle=113;
}
else if ((1*document.form1.EightGbMemory.value)==6) {
max=178;
idle=120;
}
else if ((1*document.form1.FourGbMemory.value)==1) {
max=140;
idle=107;
} 
else if ((1*document.form1.FourGbMemory.value)==3) {
max=155;
idle=112;
}
else if ((1*document.form1.FourGbMemory.value)==6) {
max=177;
idle=119;
}
else if ((1*document.form1.TwoGbMemory.value)==1) {
max=141;
idle=108;
} 
else if ((1*document.form1.TwoGbMemory.value)==3) {
max=149;
idle=110;
}
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=160;
idle=112;
}
break;



}

var system_idle=idle;
var system_max=max;

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

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

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

var flash_idle=(2*document.form1.flash.value);
var flash_max=(3*document.form1.flash.value);


var total_idle=(system_idle+pci_idle+hdd_idle+ssd_idle+flash_idle-10);
var total_max=(system_max+pci_max+hdd_max+ssd_max+flash_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.93 GHz and 95 W
case 1: 
if ((1*document.form1.EightGbMemory.value)==2) {
max=261;
idle=156;
} 
else if ((1*document.form1.EightGbMemory.value)==6) {
max=276;
idle=165;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=287;
idle=172;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=298;
idle=179;
}
else if ((1*document.form1.FourGbMemory.value)==2) {
max=260;
idle=155;
} 
else if ((1*document.form1.FourGbMemory.value)==6) {
max=275;
idle=164;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=286;
idle=171;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=297;
idle=178;
}
else if ((1*document.form1.TwoGbMemory.value)==2) {
max=220;
idle=149;
} 
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=241;
idle=156;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=257;
idle=161;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=273;
idle=166;
}
break;

// Xeon X5550, 2.66 GHz and 95 W
case 2: 
if ((1*document.form1.EightGbMemory.value)==2) {
max=237;
idle=155;
} 
else if ((1*document.form1.EightGbMemory.value)==6) {
max=262;
idle=166;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=281;
idle=174;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=300;
idle=182;
}
else if ((1*document.form1.FourGbMemory.value)==2) {
max=236;
idle=154;
} 
else if ((1*document.form1.FourGbMemory.value)==6) {
max=261;
idle=165;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=280;
idle=173;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=299;
idle=181;
}
else if ((1*document.form1.TwoGbMemory.value)==2) {
max=254;
idle=158;
} 
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=261;
idle=162;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=266;
idle=165;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=271;
idle=168;
}
break;

// Xeon E5540, 2.53 GHz and 80 W
case 3: 
if ((1*document.form1.EightGbMemory.value)==2) {
max=216;
idle=145;
} 
else if ((1*document.form1.EightGbMemory.value)==6) {
max=236;
idle=155;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=251;
idle=162;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=266;
idle=170;
}
else if ((1*document.form1.FourGbMemory.value)==2) {
max=215;
idle=144;
} 
else if ((1*document.form1.FourGbMemory.value)==6) {
max=235;
idle=154;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=250;
idle=161;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=265;
idle=169;
}
else if ((1*document.form1.TwoGbMemory.value)==2) {
max=204;
idle=142;
} 
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=218;
idle=147;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=229;
idle=151;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=239;
idle=155;
}
break;

// Xeon L5520, 2.4 GHz and 60 W
case 4: 
if ((1*document.form1.EightGbMemory.value)==2) {
max=205;
idle=146;
} 
else if ((1*document.form1.EightGbMemory.value)==6) {
max=225;
idle=156;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=240;
idle=163;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=255;
idle=171;
}
else if ((1*document.form1.FourGbMemory.value)==2) {
max=204;
idle=145;
} 
else if ((1*document.form1.FourGbMemory.value)==6) {
max=224;
idle=155;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=239;
idle=162;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=254;
idle=170;
}
else if ((1*document.form1.TwoGbMemory.value)==2) {
max=193;
idle=143;
} 
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=207;
idle=148;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=218;
idle=152;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=228;
idle=156;
}
break;

// Xeon E5504, 2.0 GHz and 80 W
case 5: 
if ((1*document.form1.EightGbMemory.value)==2) {
max=189;
idle=140;
} 
else if ((1*document.form1.EightGbMemory.value)==6) {
max=209;
idle=150;
}
else if ((1*document.form1.EightGbMemory.value)==9) {
max=224;
idle=157;
}
else if ((1*document.form1.EightGbMemory.value)==12) {
max=239;
idle=165;
}
else if ((1*document.form1.FourGbMemory.value)==2) {
max=188;
idle=139;
} 
else if ((1*document.form1.FourGbMemory.value)==6) {
max=208;
idle=149;
}
else if ((1*document.form1.FourGbMemory.value)==9) {
max=223;
idle=156;
}
else if ((1*document.form1.FourGbMemory.value)==12) {
max=238;
idle=164;
}
else if ((1*document.form1.TwoGbMemory.value)==2) {
max=177;
idle=137;
} 
else if ((1*document.form1.TwoGbMemory.value)==6) {
max=191;
idle=142;
}
else if ((1*document.form1.TwoGbMemory.value)==9) {
max=202;
idle=146;
}
else if ((1*document.form1.TwoGbMemory.value)==12) {
max=212;
idle=150;
}
break;

}

var system_idle=idle;
var system_max=max;

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

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

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

var flash_idle=(2*document.form1.flash.value);
var flash_max=(3*document.form1.flash.value);


var total_idle=(system_idle+pci_idle+hdd_idle+ssd_idle+flash_idle-10);
var total_max=(system_max+pci_max+hdd_max+ssd_max+flash_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('1 DIMM','1');
  eightGBBox.options[eightGBBox.options.length] = new Option('3 DIMMs','3');  
  eightGBBox.options[eightGBBox.options.length] = new Option('6 DIMMs','6');

  fourGBBox.options[fourGBBox.options.length] = new Option('None','0');
  fourGBBox.options[fourGBBox.options.length] = new Option('1 DIMM','1');
  fourGBBox.options[fourGBBox.options.length] = new Option('3 DIMMs','3');  
  fourGBBox.options[fourGBBox.options.length] = new Option('6 DIMMs','6');

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

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

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.FourGbMemory.value == "0")&&(document.form1.TwoGbMemory.value == "0")&&(document.form1.EightGbMemory.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();
}

