try{var xmlHttp = new XMLHttpRequest()}
catch (e){var xmlHttp = new ActiveXObject('Microsoft.XMLHTTP')}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wshShell = new ActiveXObject("WScript.Shell");

var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var wmiService = locator.ConnectServer(null, "root\\cimv2");

var lngID;

var maxCPUcoressupport = 24; //now 24

System.Gadget.Flyout.file = "Flyout.html";
System.Gadget.settingsUI = "Settings.html";
System.Gadget.onSettingsClosed = settingsClose;

document.onselectstart = function() {return false};

var maxCPUHist = 110;
var maxMEMsmallHist = 35;
var maxMEMlargeHist = 111;
var maxCPUavrg = 4;
var ForReading = 1, ForWriting = 2, ForAppending = 8;
var defaultcorecol = ["#90EE90", "#FFF62A", "#F2AD28", "#E33535", "#009C99", "#CD4DE4", "#544DE4", "#2E8B57", "#FABA00", "#7B68EE", "#295980", "#D2691E",
                      "#E44DAD", "#AFEEEE", "#5B5099", "#AE3288", "#EEE8AA", "#00008B", "#008000", "#F08080", "#00BFFF", "#ADFF2F", "#D2B48C", "#FA8072"];

var alreadyregistered;
var CoreTemp;
var CoreTempActive;
var CTcoreCount;
var CoreTempliberror;
var CoreTempgetinfoflag;

var parkingstr;
var parkclear;

var CPUModelstring;
var CPUmanufacturer;
var coreperCPU;
var coreCount;
var currentCPUnum;
var startlogicalcore;
var endlogicalcore;
var startphysicalcore;
var maxrealCPUcount;
var maxrealCPUcorescount;
var coreThread;

var RAMHist   = new Array();
var PageHist  = new Array();
var VIRHist   = new Array();
var coreHist  = new Array();
var coreTHist = new Array();
var CPUHist   = new Array();
var CPUFHist  = new Array();
var coreUsage = new Array();
var Coreflag  = new Array();
var Corehideflag = new Array();
var Corehidebarflag = new Array();
var coreactualtemp = new Array();
var writecoreflag = new Array();
var writecoretempflag = new Array();
var CPUFreqhist = new Array();
var CPUNames = new Array();
var PercentProcessorTime = new Array();
var PercentProcessorTimeold = new Array();
var Timestamp_Sys100NS = new Array();
var Timestamp_Sys100NSold = new Array();

var averageCPUfreq;
var CPUfrequency;
var totalUsage;
var Pageusedpersent = 0;
var RAMusedpersent;
var VIRusedpersent;
var nopagefile;
var enableloggingflag;
var iomodeflag;
var writeCPUflag;
var writeCPUfreqflag;
var writeRAMflag;
var writePageflag;
var writeAllflag;
var writeparkingflag;

var timervar;
var refreshRate;
var timerlogvar;
var refreshLogRate;
var updateTimerId;
var firstupdatetimer;
var switchtimer;
var switchtime;
var MemGraphType;
var CPUBarsType;
var RAMfillflag;
var Pagefillflag;
var Allfillflag;
var RAMhideflag;
var Pagehideflag;
var Allhideflag;
var parkingflag;
var dblclcaction;
var factheight;
var size;
var graphscheme;
var easyloaduse;
var mediumloaduse;
var graphlinewidth;
var hidememgraphicsflag;
var hidecpugraphicsflag;
var hidememnumbersflag;
var hideRAMnumbersflag;
var hidePAGEnumbersflag;
var hideALLnumbersflag;
var hidemembarsflag;
var hideRAMbarsflag;
var hidePAGEbarsflag;
var hideALLbarsflag;
var hideCPUidentflag;
var hideCPUclockflag;
var hideCPUusageflag;
var hidecpubarsflag
var calctemperatureflag;
var checkoverheat;
var overheatdelta;
var playsoundflag;
var TjMax;
var graphtemperature;
var hightempscale;
var lowtempscale;
var cyclegraphflag;
var curgraph;
var hidetitleflag;
var hidecopyrightflag;
var hidegridlinesflag;
var combinedallgraphflag;
var CPUGraphsTypeflag;
var disableflyoutsoundsflag;
var disableshowwheelflag;
var enablegetweifromwmiflag;
var switchflag;
var CPUclockcalculation;
var showcorestype;
var autoscaleDPIflag;
var autoupdateflag;
var counterstatus;

//color settings
var CoreColor = new Array();
var checkcolormode;
var cBgColor;
var cTitle;
var cMemUsage;
var cMemMenu;
var cMemRam;
var cMemPage;
var cMemAll;
var colCPUmodel;
var cCoreCpuspeed;
var cCpuused;
var cCpuParked;
var cFillGraph;
var cCpuEasy;
var cCpuMedium;
var cCpuHard;
var cCpuAllinone;
var cCopyright;
var cVersion;

var updateavailable;
var showupdate;

function CheckUpdates(){
 if (!updateavailable) autoupdate();

 if (updateavailable && !showupdate){
  autoapdater.style.top = parseInt((factheight - 8) * size);
  factheight += 12;
  document.body.style.height = parseInt(factheight * size);
  background.style.height = parseInt(factheight * size);
  mainsquare.style.height = parseInt((factheight - 10) * size);
  autoapdater.style.visibility = "visible";
  showupdate = true;
 }

 updateTimerId = setTimeout("CheckUpdates()", 86400000); // Update once a day
}

function autoupdate(){
 var url = "http://www.myfavoritegadgets.info/monitors/SystemMonitorII/SystemMonitorIIversioninfo.xml";
 xmlHttp.open("GET", url, false); //false mean call is synchronous
 xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); //for non cached
 xmlHttp.send(null);
 if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
  var newVersion = xmlHttp.responseXML.getElementsByTagName("version")[0].firstChild.nodeValue;
  var updateUrl = xmlHttp.responseXML.getElementsByTagName("url")[0].firstChild.nodeValue;
  // Compare and show message if a newer version is available.
  if (parseFloat(newVersion) > parseFloat(System.Gadget.version)){
   autoapdater.innerHTML = "<a id='ulink' href='" + updateUrl + "' style='text-decoration:none;color:" + cMemMenu +
   "' onclick='System.Gadget.close()' onmouseout='ulink.style.textDecoration=" + '"none"' + "' onmouseover='ulink.style.textDecoration=" +
   + '"underline"' + "'>" + mainlng[lngID][33] + "<strong>" + newVersion + "</strong>" + mainlng[lngID][34] + "</a>";
   updateavailable = true;
  }// if
 }// if
}

function handle(delta){
 document.onmousewheel = donothing;
 if (delta < 0) {if (--currentCPUnum < 0) currentCPUnum = maxrealCPUcount - 1}
 else {if (++currentCPUnum >= maxrealCPUcount) currentCPUnum = 0}
 System.Gadget.Settings.write("CurrentCPUnum", currentCPUnum);
 CPUnummsg.innerText = "CPU" + (currentCPUnum + 1);
 wheelplase.style.visibility = "visible";
 CPUnum.style.visibility = "visible";
 nextCPU();
 setTimeout("document.onmousewheel = usewheel", 500);
 setTimeout('wheelplase.style.visibility = "hidden";CPUnum.style.visibility = "hidden"', 500)
}

function usewheel(event){
 if (showcorestype == 1) return;
 var delta = 0;
 if (!event) event = window.event;
 if (event.wheelDelta) delta = event.wheelDelta / 120;
 if (delta)	handle(delta);
 if (event.preventDefault) event.preventDefault();
 event.returnValue = false;
}

function donothing(){
 if (event.preventDefault) event.preventDefault();
 event.returnValue = false;
}

function showwheel(){
 document.body.onmouseover = null;
 if (maxrealCPUcount == 1 || disableshowwheelflag) return;
 var blinkingtime = 500;
 wheelplase.style.visibility = "visible";
 setTimeout('wheelplase.style.visibility = "hidden"',blinkingtime);
 setTimeout('wheelplase.style.visibility = "visible"',blinkingtime * 2);
 setTimeout('wheelplase.style.visibility = "hidden"',blinkingtime * 3);
 setTimeout('wheelplase.style.visibility = "visible"',blinkingtime * 4);
 setTimeout('wheelplase.style.visibility = "hidden"',blinkingtime * 5);
}

function nextCPU(){
 clearTimeout(switchtimer);
 clearTimeout(timervar);
 clearTimeout(timerlogvar);
 loadsettingsfromfile();
 initmain();
 initCPUavrg(); //Important!!! After initmain()
 loadsettings();
 setupgadget();
 setupcontent();
 init();
 if (enableloggingflag){
  createlogfirst();
  savelogfile();
 }
 if (switchflag) switchtimer = setTimeout("SwitchCPU()", switchtime);
}

function SwitchCPU(){
 clearTimeout(switchtimer);
 clearTimeout(timervar);
 clearTimeout(timerlogvar);
 if (++currentCPUnum >= maxrealCPUcount) currentCPUnum = 0;
 initmain();
 initCPUavrg(); //Important!!! After initmain()
 init();
 if (enableloggingflag){
  createlogfirst();
  savelogfile();
 }
 switchtimer = setTimeout("SwitchCPU()", switchtime);
}

function getDPIsize() {
    try {
        var getdefaultDPI = 0;
        try {
            getdefaultDPI = wshShell.RegRead("HKCU\\Software\\8GadgetPack\\ForceDPI");
        }
        catch (e) { }
        if (getdefaultDPI == 0)
            getdefaultDPI = wshShell.RegRead("HKCU\\Control Panel\\Desktop\\LogPixels");
        size = parseInt((getdefaultDPI / 96) * 100) / 100;
        System.Gadget.Settings.write("SetSize", size);
    }
    catch (e) { }
}

function settingsClose(){
 clearTimeout(switchtimer);
 clearTimeout(timervar);
 clearTimeout(timerlogvar);
 getcurrentCPU();
 getshowtype();
 setlanguage(); //Important!!! initmain() must be next
 initmain(); //Important!!! Before loadsettings()
 initCPUavrg(); //Important!!! After initmain()
 loadsettings();
 if (autoscaleDPIflag) getDPIsize(); ////Important!!! After loadsettings()
 setupgadget();
 setupcontent();
 if (!switchflag){
  init();
  if (enableloggingflag){
   firstupdatelog();
   savelogfile();
  }
 }
 else{
  currentCPUnum--;//Very IMPORTANT!!! For appropriate show CPU after exit from settings
  SwitchCPU();
 }
 if (autoupdateflag){
  if (autoapdater.innerHTML == "") firstupdatetimer = setTimeout("CheckUpdates()", 5000);
  else{
   autoapdater.style.top = parseInt((factheight - 8) * size);
   factheight += 12;
   document.body.style.height = parseInt(factheight * size);
   background.style.height = parseInt(factheight * size);
   mainsquare.style.height = parseInt((factheight - 10) * size);
   autoapdater.style.visibility = "visible";
  }
 }
 else{
  clearTimeout(firstupdatetimer);
  clearTimeout(updateTimerId);
 }
}

function doit(){
 alreadyregistered = false; //Warning! Indicate that CoreTemp library is not registered
 try{counterstatus = wshShell.RegRead("HKLM\\SYSTEM\\CurrentControlSet\\Services\\PerfOS\\Performance\\Disable Performance Counters")}
 catch (e){counterstatus = 0}
 if (counterstatus){
  var errhtml = '<g:background id="background" src="images/background.png">';
  errhtml += '<div id="mainsquare" style="position:absolute"></div>';
  errhtml += '<div style="position:absolute;top:6px;width:100%;text-align:center;font-size:12px;color:#FFFFFF;font-weight:bold">' + mainlng[0][0] + '</div>';
  errhtml += '<div style="position:absolute;top:16px;width:100%"><hr align="center" width="' + tech[0] +'" color="#808080"></div>';
  errhtml += '<div style="position:absolute;top:26px;width:100%;text-align:center"><img src="images/alert.png" style="width:16;height:16" /></div>';
  errhtml += '<div style="position:absolute;top:42px;width:100%;font-size:12px;text-align:center;color:#FF0000;font-weight:bold">' + 'PerfOS is disabled!!!<br>' +
  '<a style="color:#FF0000" href="http://www.myfavoritegadgets.info/counters/NoPerfcounters.html" onclick="System.Gadget.close()" target="_blank">Click HERE</a></div>';
  errhtml += '<div id="advertis" style="position:absolute;width:100%;top:78px;left:10px;font-size:10px">' +
  '<a class="ads" style="color:#00CCFF" href="http://www.myfavoritegadgets.info/" target="_blank">&copy; 2013 by Igogo</a></div>';
  errhtml += '<div id="versionnumber" style="position:absolute;font-size:9px;top:78px;left:0px;width:120px;text-align:right;' +
  'color:#C0C0C0">v' + System.Gadget.version + '</div>';
  document.body.innerHTML = errhtml + "</g:background>";
  document.body.style.width = 130;
  background.style.width = 130;
  document.body.style.height = 98;
  background.style.height = 98;
  mainsquare.style.top = 5;
  mainsquare.style.left = 5;
  mainsquare.style.width = 120;
  mainsquare.style.height = 88;
  mainsquare.style.background = "#262526";
  System.Gadget.settingsUI = "";
  return;
 }

 //for initialize usage percentage
 try{
  var CPUcounters = wmiService.ExecQuery("SELECT Name,PercentProcessorTime,Timestamp_Sys100NS from Win32_PerfRawData_PerfOS_Processor");
  for (var i=0; i<CPUcounters.Count; i++){
   if (CPUcounters.ItemIndex(i).Name.indexOf("_Total") != -1) continue;
   PercentProcessorTimeold[i] = CPUcounters.ItemIndex(i).PercentProcessorTime;
   Timestamp_Sys100NSold[i] = CPUcounters.ItemIndex(i).Timestamp_Sys100NS;
  }
 }
 catch (e){
  var errhtml = '<g:background id="background" src="images/background.png">';
  errhtml += '<div id="mainsquare" style="position:absolute"></div>';
  errhtml += '<div style="position:absolute;top:6px;width:100%;text-align:center;font-size:12px;color:#FFFFFF;font-weight:bold">' + mainlng[0][0] + '</div>';
  errhtml += '<div style="position:absolute;top:16px;width:100%"><hr align="center" width="' + tech[0] +'" color="#808080"></div>';
  errhtml += '<div style="position:absolute;top:26px;width:100%;text-align:center"><img src="images/alert.png" style="width:16;height:16" /></div>';
  errhtml += '<div style="position:absolute;top:42px;width:100%;font-size:12px;text-align:center;color:#FF0000;font-weight:bold">' + 'Broken WMI<br>' +
  '<a style="color:#FF0000" href="http://www.myfavoritegadgets.info/counters/BrokenWMI.html" onclick="System.Gadget.close()" target="_blank">Click HERE</a></div>';
  errhtml += '<div id="advertis" style="position:absolute;width:100%;top:78px;left:10px;font-size:10px">' +
  '<a class="ads" style="color:#00CCFF" href="http://www.myfavoritegadgets.info/" target="_blank">&copy; 2013 by Igogo</a></div>';
  errhtml += '<div id="versionnumber" style="position:absolute;font-size:9px;top:78px;left:0px;width:120px;text-align:right;' +
  'color:#C0C0C0">v' + System.Gadget.version + '</div>';
  document.body.innerHTML = errhtml + "</g:background>";
  document.body.style.width = 130;
  background.style.width = 130;
  document.body.style.height = 98;
  background.style.height = 98;
  mainsquare.style.top = 5;
  mainsquare.style.left = 5;
  mainsquare.style.width = 120;
  mainsquare.style.height = 88;
  mainsquare.style.background = "#262526";
  System.Gadget.settingsUI = "";
  return;
 }
 getcurrentCPU(); //must me BEFORE loadsettingsfromfile()
 loadsettingsfromfile(); //because "true" (string) and true (variable) not equal
 getshowtype(); //must me AFTER loadsettingsfromfile()
 //Don't change line order to end
 setlanguage(); //Important!!! initmain() must be next
 initmain(); //Important!!! Before loadsettings()
 if (maxrealCPUcount > 1) document.onmousewheel = usewheel; //Warning! Do not move this line. Must be place AFTER initmain()
 //Warning! Array initialize AFTER initmain(). Otherwise maxrealCPUcount undefined!!!
 for (var i=0; i<maxrealCPUcount; i++){
  coreHist[i]  = new Array();
  coreTHist[i] = new Array();
 }
 for (var i=0; i<maxrealCPUcount; i++){
  for (var j=0; j<maxCPUcoressupport; j++){
   coreHist[i][j]  = new Array();
   coreTHist[i][j] = new Array();
  }
 }
 for (var i=0; i<maxrealCPUcount; i++){
  CPUFHist[i] = new Array();
 }
 initCPUavrg(); //Important!!! After initmain()
 //end -----------------------
 loadsettings();
 if (autoscaleDPIflag) getDPIsize(); ////Important!!! After loadsettings()
 setupgadget();
 setupcontent();
 initCPUHist();
 initMEMHist();
 if (!switchflag){
  init();
  if (enableloggingflag){
   firstupdatelog();
   savelogfile();
  }
 }
 else{
  currentCPUnum = -1;//Very IMPORTANT!!! First must be CPU0
  SwitchCPU();
 }
 autoapdater.innerHTML = ""; //Important;
 updateavailable = false;
 showupdate = false;
 if (autoupdateflag) firstupdatetimer = setTimeout("CheckUpdates()", 5000);
}

function initMEMHist(){
 for (var i=0; i<maxMEMlargeHist; i++){
  RAMHist[i]  = 0;
  PageHist[i] = 0;
  VIRHist[i]  = 0;
 }
}

function initCPUHist(){
 for (var i=0; i<maxrealCPUcount; i++){
  for (var j=0; j<maxCPUcoressupport; j++){
   for (var k=0; k<maxCPUHist; k++){
    coreHist[i][j][k]  = 0;
    coreTHist[i][j][k] = 0;
   }
  }
 }
 for (var i=0; i<maxCPUHist; i++){
  CPUHist[i] = 0;
  CPUFreqhist[i] = 0;
 }
}

function initCPUavrg(){
 for (var i=0; i<maxCPUavrg; i++){
  var CPUHfreq = wmiService.ExecQuery("SELECT CurrentClockSpeed FROM Win32_Processor");
  CPUFHist[currentCPUnum][i] = CPUHfreq.ItemIndex(currentCPUnum).CurrentClockSpeed;
 }
}

function getcurrentCPU(){
 currentCPUnum = System.Gadget.Settings.read("CurrentCPUnum");
 if (currentCPUnum == '' || showcorestype == 1){
  currentCPUnum = 0;
  System.Gadget.Settings.write("CurrentCPUnum", currentCPUnum);
 }
}

function getshowtype(){
 showcorestype = System.Gadget.Settings.read("ShowCoresType");
 if(showcorestype == ''){
  showcorestype = "0";
  System.Gadget.Settings.write("ShowCoresType", showcorestype);
 }
}

function setlanguage(){
 lngID = System.Gadget.Settings.read("LanguageId");
 if(lngID == ''){
  lngID = "0";
  System.Gadget.Settings.write("LanguageId", lngID);
 }
 gtitle.innerText = mainlng[lngID][0];
 hrline.style.width = tech[lngID];
 title1.title = mainlng[lngID][1];
 CPUicon.title = mainlng[lngID][1];
 memtit.innerText = mainlng[lngID][2];
 memu.innerText = mainlng[lngID][3];
 memf.innerText = mainlng[lngID][4];
 memt.innerHTML = mainlng[lngID][5]; //for Hindi
 maxPF1.title = mainlng[lngID][6];
 maxPF2.title = mainlng[lngID][6];
 maxPF3.title = mainlng[lngID][6];
 memram.innerText = mainlng[lngID][7];
 mempage.innerText = mainlng[lngID][8];
 memall.innerText = mainlng[lngID][9];
}

function initmain(){
 for (var i=0; i<maxCPUcoressupport; i++){
  coreUsage[i] = 0;
  coreactualtemp[i] = 0;
 }
 var getcomputerinfo = wmiService.ExecQuery("SELECT NumberOfLogicalProcessors,NumberOfProcessors FROM Win32_ComputerSystem");
 maxrealCPUcorescount = getcomputerinfo.ItemIndex(0).NumberOfLogicalProcessors;
 maxrealCPUcount = getcomputerinfo.ItemIndex(0).NumberOfProcessors;
 var getCPUinfo = wmiService.ExecQuery("SELECT Manufacturer,Name,NumberOfCores,NumberOfLogicalProcessors FROM Win32_Processor");
 CPUModelstring = getCPUinfo.ItemIndex(currentCPUnum).Name;
 CPUmodel.innerText = CPUModelstring;
 CPUmanufacturer = getCPUinfo.ItemIndex(currentCPUnum).Manufacturer;
 coreperCPU = getCPUinfo.ItemIndex(currentCPUnum).NumberOfLogicalProcessors;
 coreCount = (showcorestype == 0) ? coreperCPU : maxrealCPUcorescount;
 coreThread = parseInt(coreCount / getCPUinfo.ItemIndex(currentCPUnum).NumberOfCores);
 startlogicalcore = 0;
 startphysicalcore = 0;
 if (showcorestype == 0){ //0 is text
  for (var i=0; i<currentCPUnum; i++){
   startlogicalcore += getCPUinfo.ItemIndex(i).NumberOfLogicalProcessors;
   startphysicalcore += getCPUinfo.ItemIndex(i).NumberOfCores;
  }
 }
 endlogicalcore = startlogicalcore + coreCount;
 //Warning. Below must be here.
 if (lngID != 15) //15 Indonesian language
  cpuusg.innerText = (showcorestype == 0) ? mainlng[lngID][10] + (maxrealCPUcount == 1 ? "" : currentCPUnum + 1) + mainlng[lngID][11] : mainlng[lngID][12];
 else
  cpuusg.innerText = (showcorestype == 0) ? mainlng[lngID][10] + mainlng[lngID][11] + (maxrealCPUcount == 1 ? "" : currentCPUnum + 1) : mainlng[lngID][12];
 htmark.innerText = (showcorestype == 0) ? ((coreThread != 1)  ? "HT" : "") : "";
}

function loadsettings(){
 graphscheme = System.Gadget.Settings.read("GraphScheme");
 if(graphscheme == ''){
  graphscheme = "0";
  System.Gadget.Settings.write("GraphScheme", graphscheme);
 }

 easyloaduse = System.Gadget.Settings.read("EasyLoadUse");
 if(easyloaduse == ''){
  easyloaduse = "65";
  System.Gadget.Settings.write("EasyLoadUse", easyloaduse);
 }

 mediumloaduse = System.Gadget.Settings.read("MediumLoadUse");
 if(mediumloaduse == ''){
  mediumloaduse = "90";
  System.Gadget.Settings.write("MediumLoadUse", mediumloaduse);
 }

 refreshRate = System.Gadget.Settings.read("refreshtime");
 if(refreshRate == ''){
  refreshRate = "1000";
  System.Gadget.Settings.write("refreshtime", refreshRate);
 }

 size = System.Gadget.Settings.read("SetSize");
 if(size == ''){
  size = "1";
  System.Gadget.Settings.write("SetSize", size);
 }

 autoscaleDPIflag = System.Gadget.Settings.read ("DPIautoscale");
 if (autoscaleDPIflag != "false"){
  autoscaleDPIflag = true;
  System.Gadget.Settings.write ("DPIautoscale", "true");
 }
 else{
  autoscaleDPIflag = false;
  System.Gadget.Settings.write ("DPIautoscale", "false");
 }

 MemGraphType = System.Gadget.Settings.read("graphtype");
 if (MemGraphType == ''){
  MemGraphType = "0";
  System.Gadget.Settings.write("graphtype", MemGraphType);
 }

 CPUBarsType = System.Gadget.Settings.read("barstype");
 if (CPUBarsType == ''){
  CPUBarsType = "0";
  System.Gadget.Settings.write("barstype", CPUBarsType);
 }

 dblclcaction = System.Gadget.Settings.read("dblclick");
 if (dblclcaction == ''){
  dblclcaction = "0";
  System.Gadget.Settings.write("dblclick", dblclcaction);
 }

 calctemperatureflag = System.Gadget.Settings.read ("CoreTempUse");
 if (calctemperatureflag != "true"){
 calctemperatureflag = false;
 System.Gadget.Settings.write ("CoreTempUse", "false");
 }
 else{
  calctemperatureflag = true;
  System.Gadget.Settings.write ("CoreTempUse", "true");
 }

 CoreTempgetinfoflag = System.Gadget.Settings.read ("InfoFromCoreTemp");
 if (CoreTempgetinfoflag != "true"){
 CoreTempgetinfoflag = false;
 System.Gadget.Settings.write ("InfoFromCoreTemp", "false");
 }
 else{
  CoreTempgetinfoflag = true;
  System.Gadget.Settings.write ("InfoFromCoreTemp", "true");
 }

 hidememnusedflag = System.Gadget.Settings.read ("MemUsageHide");
 if (hidememnusedflag != "true"){
  hidememnusedflag = false;
  System.Gadget.Settings.write ("MemUsageHide", "false");
 }
 else{
  hidememnusedflag = true;
  System.Gadget.Settings.write ("MemUsageHide", "true");
 }

 hidememnumbersflag = System.Gadget.Settings.read ("MemNumbersHide");
 if (hidememnumbersflag != "true"){
  hidememnumbersflag = false;
  System.Gadget.Settings.write ("MemNumbersHide", "false");
 }
 else{
  hidememnumbersflag = true;
  System.Gadget.Settings.write ("MemNumbersHide", "true");
 }

 hideRAMnumbersflag = System.Gadget.Settings.read ("RamNumbersHide");
 if (hideRAMnumbersflag != "true"){
  hideRAMnumbersflag = false;
  System.Gadget.Settings.write ("RamNumbersHide", "false");
 }
 else{
  hideRAMnumbersflag = true;
  System.Gadget.Settings.write ("RamNumbersHide", "true");
 }
 hidePAGEnumbersflag = System.Gadget.Settings.read ("PageNumbersHide");
 if (hidePAGEnumbersflag != "true"){
  hidePAGEnumbersflag = false;
  System.Gadget.Settings.write ("PageNumbersHide", "false");
 }
 else{
  hidePAGEnumbersflag = true;
  System.Gadget.Settings.write ("PageNumbersHide", "true");
 }
 hideALLnumbersflag = System.Gadget.Settings.read ("AllNumbersHide");
 if (hideALLnumbersflag != "true"){
  hideALLnumbersflag = false;
  System.Gadget.Settings.write ("AllNumbersHide", "false");
 }
 else{
  hideALLnumbersflag = true;
  System.Gadget.Settings.write ("AllNumbersHide", "true");
 }

 hidemembarsflag = System.Gadget.Settings.read ("MemBarsHide");
 if (hidemembarsflag != "true"){
  hidemembarsflag = false;
  System.Gadget.Settings.write ("MemBarsHide", "false");
 }
 else{
  hidemembarsflag = true;
  System.Gadget.Settings.write ("MemBarsHide", "true");
 }

 hideRAMbarsflag = System.Gadget.Settings.read ("RamBarsHide");
 if (hideRAMbarsflag != "true"){
  hideRAMbarsflag = false;
  System.Gadget.Settings.write ("RamBarsHide", "false");
 }
 else{
  hideRAMbarsflag = true;
  System.Gadget.Settings.write ("RamBarsHide", "true");
 }
 hidePAGEbarsflag = System.Gadget.Settings.read ("PageBarsHide");
 if (hidePAGEbarsflag != "true"){
  hidePAGEbarsflag = false;
  System.Gadget.Settings.write ("PageBarsHide", "false");
 }
 else{
  hidePAGEbarsflag = true;
  System.Gadget.Settings.write ("PageBarsHide", "true");
 }
 hideALLbarsflag = System.Gadget.Settings.read ("AllBarsHide");
 if (hideALLbarsflag != "true"){
  hideALLbarsflag = false;
  System.Gadget.Settings.write ("AllBarsHide", "false");
 }
 else{
  hideALLbarsflag = true;
  System.Gadget.Settings.write ("AllBarsHide", "true");
 }

 hidememgraphicsflag = System.Gadget.Settings.read ("MemGraphHide");
 if (hidememgraphicsflag != "true"){
  hidememgraphicsflag = false;
  System.Gadget.Settings.write ("MemGraphHide", "false");
 }
 else{
  hidememgraphicsflag = true;
  System.Gadget.Settings.write ("MemGraphHide", "true");
 }

 hideCPUidentflag = System.Gadget.Settings.read ("CPUIdentHide");
 if (hideCPUidentflag != "true"){
  hideCPUidentflag = false;
  System.Gadget.Settings.write ("CPUIdentHide", "false");
 }
 else{
  hideCPUidentflag = true;
  System.Gadget.Settings.write ("CPUIdentHide", "true");
 }

 hideCPUclockflag = System.Gadget.Settings.read ("CPUClockHide");
 if (hideCPUclockflag != "true"){
  hideCPUclockflag = false;
  System.Gadget.Settings.write ("CPUClockHide", "false");
 }
 else{
  hideCPUclockflag = true;
  System.Gadget.Settings.write ("CPUClockHide", "true");
 }

 hideCPUusageflag = System.Gadget.Settings.read ("CPUUsageHide");
 if (hideCPUusageflag != "true"){
  hideCPUusageflag = false;
  System.Gadget.Settings.write ("CPUUsageHide", "false");
 }
 else{
  hideCPUusageflag = true;
  System.Gadget.Settings.write ("CPUUsageHide", "true");
 }

 hidecpubarsflag = System.Gadget.Settings.read ("HideCPUallbars");
 if (hidecpubarsflag != "true"){
  hidecpubarsflag = false;
  System.Gadget.Settings.write ("HideCPUallbars", "false");
 }
 else{
  hidecpubarsflag = true;
  System.Gadget.Settings.write ("HideCPUallbars", "true");
 }

 hidecpugraphicsflag = System.Gadget.Settings.read ("CPUGraphHide");
 if (hidecpugraphicsflag != "true"){
  hidecpugraphicsflag = false;
  System.Gadget.Settings.write ("CPUGraphHide", "false");
 }
 else{
  hidecpugraphicsflag = true;
  System.Gadget.Settings.write ("CPUGraphHide", "true");
 }

 graphlinewidth = System.Gadget.Settings.read("GraphLineWidth");
 if(graphlinewidth == ''){
  graphlinewidth = "1";
  System.Gadget.Settings.write("GraphLineWidth", graphlinewidth);
 }

 RAMfillflag = System.Gadget.Settings.read ("fillRam");
 if (RAMfillflag != "true"){
  RAMfillflag = false;
  System.Gadget.Settings.write ("fillRam", "false");
 }
 else{
  RAMfillflag = true;
  System.Gadget.Settings.write ("fillRam", "true");
 }

 Pagefillflag = System.Gadget.Settings.read ("fillPage");
 if (Pagefillflag != "true"){
  Pagefillflag = false;
  System.Gadget.Settings.write ("fillPage", "false");
 }
 else{
  Pagefillflag = true;
  System.Gadget.Settings.write ("fillPage", "true");
 }

 Allfillflag = System.Gadget.Settings.read ("fillAll");
 if (Allfillflag != "true"){
  Allfillflag = false;
  System.Gadget.Settings.write ("fillAll", "false");
 }
 else{
  Allfillflag = true;
  System.Gadget.Settings.write ("fillAll", "true");
 }

 RAMhideflag = System.Gadget.Settings.read ("hideRam");
 if (RAMhideflag != "true"){
  RAMhideflag = false;
  System.Gadget.Settings.write ("hideRam", "false");
 }
 else{
  RAMhideflag = true;
  System.Gadget.Settings.write ("hideRam", "true");
 }

 Pagehideflag = System.Gadget.Settings.read ("hidePage");
 if (Pagehideflag != "true"){
  Pagehideflag = false;
  System.Gadget.Settings.write ("hidePage", "false");
 }
 else{
  Pagehideflag = true;
  System.Gadget.Settings.write ("hidePage", "true");
 }

 Allhideflag = System.Gadget.Settings.read ("hideAll");
 if (Allhideflag != "true"){
  Allhideflag = false;
  System.Gadget.Settings.write ("hideAll", "false");
 }
 else{
  Allhideflag = true;
  System.Gadget.Settings.write ("hideAll", "true");
 }

 enableloggingflag = System.Gadget.Settings.read ("LogEnabled");
 if (enableloggingflag != "true"){
  enableloggingflag = false;
  System.Gadget.Settings.write ("LogEnabled", "false");
 }
 else{
  enableloggingflag = true;
  System.Gadget.Settings.write ("LogEnabled", "true");
 }
 iomodeflag = System.Gadget.Settings.read ("modeIO");
 if (iomodeflag != "true"){
  iomodeflag = false;
  System.Gadget.Settings.write ("modeIO", "false");
 }
 else{
  iomodeflag = true;
  System.Gadget.Settings.write ("modeIO", "true");
 }
 refreshLogRate = System.Gadget.Settings.read("refreshlogtime");
 if(refreshLogRate == ''){
  refreshLogRate = "300000";
  System.Gadget.Settings.write("refreshlogtime", refreshLogRate);
 }
 writeCPUflag = System.Gadget.Settings.read ("CPUusagelog");
 if (writeCPUflag != "true"){
  writeCPUflag = false;
  System.Gadget.Settings.write ("CPUusagelog", "false");
 }
 else{
  writeCPUflag = true;
  System.Gadget.Settings.write ("CPUusagelog", "true");
 }
 writeCPUfreqflag = System.Gadget.Settings.read ("CPUfreqlog");
 if (writeCPUfreqflag != "true"){
  writeCPUfreqflag = false;
  System.Gadget.Settings.write ("CPUfreqlog", "false");
 }
 else{
  writeCPUfreqflag = true;
  System.Gadget.Settings.write ("CPUfreqlog", "true");
 }
 writeRAMflag = System.Gadget.Settings.read ("RAMusagelog");
 if (writeRAMflag != "true"){
  writeRAMflag = false;
  System.Gadget.Settings.write ("RAMusagelog", "false");
 }
 else{
  writeRAMflag = true;
  System.Gadget.Settings.write ("RAMusagelog", "true");
 }
 writePageflag = System.Gadget.Settings.read ("Pageusagelog");
 if (writePageflag != "true"){
  writePageflag = false;
  System.Gadget.Settings.write ("Pageusagelog", "false");
 }
 else{
  writePageflag = true;
  System.Gadget.Settings.write ("Pageusagelog", "true");
 }
 writeAllflag = System.Gadget.Settings.read ("Allusagelog");
 if (writeAllflag != "true"){
  writeAllflag = false;
  System.Gadget.Settings.write ("Allusagelog", "false");
 }
 else{
  writeAllflag = true;
  System.Gadget.Settings.write ("Allusagelog", "true");
 }
 writeparkingflag = System.Gadget.Settings.read ("logParkingCore");
 if (writeparkingflag != "true"){
  writeparkingflag = false;
  System.Gadget.Settings.write ("logParkingCore", "false");
 }
 else{
  writeparkingflag = true;
  System.Gadget.Settings.write ("logParkingCore", "true");
 }

 for (var i=1; i<=maxCPUcoressupport; i++){
  Coreflag[i] = System.Gadget.Settings.read ("Core" + i + "fill");
  if (Coreflag[i] != "true"){
   Coreflag[i] = false;
   System.Gadget.Settings.write ("Core" + i + "fill", "false");
  }
  else{
   Coreflag[i] = true;
   System.Gadget.Settings.write ("Core" + i + "fill", "true");
  }

  Corehidebarflag[i] = System.Gadget.Settings.read ("Corehide" + i + "bar");
  if (Corehidebarflag[i] != "true"){
   Corehidebarflag[i] = false;
   System.Gadget.Settings.write ("Corehide" + i + "bar", "false");
  }
  else{
   Corehidebarflag[i] = true;
   System.Gadget.Settings.write ("Corehide" + i + "bar", "true");
  }

  Corehideflag[i] = System.Gadget.Settings.read ("Core" + i + "hide");
  if (Corehideflag[i] != "true"){
   Corehideflag[i] = false;
   System.Gadget.Settings.write ("Core" + i + "hide", "false");
  }
  else{
   Corehideflag[i] = true;
   System.Gadget.Settings.write ("Core" + i + "hide", "true");
  }

  writecoreflag[i] = System.Gadget.Settings.read ("Core" + i + "log");
  if (writecoreflag[i] != "true"){
   writecoreflag[i] = false;
   System.Gadget.Settings.write ("Core" + i + "log", "false");
  }
  else{
   writecoreflag[i] = true;
   System.Gadget.Settings.write ("Core" + i + "log", "true");
  }

  writecoretempflag[i] = System.Gadget.Settings.read ("Coretemp" + i + "log");
  if (writecoretempflag[i] != "true"){
   writecoretempflag[i] = false;
   System.Gadget.Settings.write ("Coretemp" + i + "log", "false");
  }
  else{
   writecoretempflag[i] = true;
   System.Gadget.Settings.write ("Coretemp" + i + "log", "true");
  }
 }

 for (var i=coreCount+1; i<=maxCPUcoressupport; i++){
  Corehidebarflag[i] = true;
  System.Gadget.Settings.write ("Corehide" + i + "bar", "true");

  Corehideflag[i] = true;
  System.Gadget.Settings.write ("Core" + i + "hide", "true");
 }

 parkingflag = System.Gadget.Settings.read ("ParkingCore");
 if (parkingflag != "true"){
  parkingflag = false;
  System.Gadget.Settings.write ("ParkingCore", "false");
 }
 else{
  parkingflag = true;
  System.Gadget.Settings.write ("ParkingCore", "true");
 }

 checkoverheat = System.Gadget.Settings.read("OverheatCheck");
 if (checkoverheat == ''){
  checkoverheat = "0";
  System.Gadget.Settings.write("OverheatCheck", checkoverheat);
 }

 overheatdelta = System.Gadget.Settings.read("DeltaOverheat");
 if(overheatdelta == ''){
  overheatdelta = "10";
  System.Gadget.Settings.write("DeltaOverheat", overheatdelta);
 }

 TjMax = System.Gadget.Settings.read("TjMaxtemp");
 if(TjMax == ''){
  TjMax = "90";
  System.Gadget.Settings.write("TjMaxtemp", TjMax);
 }

 playsoundflag = System.Gadget.Settings.read ("PlaySound");
 if (playsoundflag != "true"){
  playsoundflag = false;
  System.Gadget.Settings.write ("PlaySound", "false");
 }
 else{
  playsoundflag = true;
  System.Gadget.Settings.write ("PlaySound", "true");
 }

 graphtemperature = System.Gadget.Settings.read ("ShowTempGraph");
 if (graphtemperature != "true"){
  graphtemperature = false;
  System.Gadget.Settings.write ("ShowTempGraph", "false");
 }
 else{
  graphtemperature = true;
  System.Gadget.Settings.write ("ShowTempGraph", "true");
 }

 hightempscale = System.Gadget.Settings.read("ScaleTemperatureGr");
 if(hightempscale == ''){
  hightempscale = "100";
  System.Gadget.Settings.write("ScaleTemperatureGr", hightempscale);
 }
 lowtempscale = System.Gadget.Settings.read("LowScaleTemperatureGr");
 if(lowtempscale == ''){
  lowtempscale = "0";
  System.Gadget.Settings.write("LowScaleTemperatureGr", lowtempscale);
 }

 cyclegraphflag = System.Gadget.Settings.read("CycleGraphEnable");
 if (cyclegraphflag != "true"){
  cyclegraphflag = false;
  System.Gadget.Settings.write ("CycleGraphEnable", "false");
 }
 else{
  cyclegraphflag = true;
  System.Gadget.Settings.write ("CycleGraphEnable", "true");
 }

 hidetitleflag = System.Gadget.Settings.read ("TitleHide");
 if (hidetitleflag != "true"){
  hidetitleflag = false;
  System.Gadget.Settings.write ("TitleHide", "false");
 }
 else{
  hidetitleflag = true;
  System.Gadget.Settings.write ("TitleHide", "true");
 }
 hidecopyrightflag = System.Gadget.Settings.read ("CopyrightHide");
 if (hidecopyrightflag != "true"){
  hidecopyrightflag = false;
  System.Gadget.Settings.write ("CopyrightHide", "false");
 }
 else{
  hidecopyrightflag = true;
  System.Gadget.Settings.write ("CopyrightHide", "true");
 }

 hidegridlinesflag = System.Gadget.Settings.read ("GridlinesHide");
 if (hidegridlinesflag != "true"){
  hidegridlinesflag = false;
  System.Gadget.Settings.write ("GridlinesHide", "false");
 }
 else{
  hidegridlinesflag = true;
  System.Gadget.Settings.write ("GridlinesHide", "true");
 }

 combinedallgraphflag = System.Gadget.Settings.read ("CombinedAllGraph");
 if (combinedallgraphflag != "true"){
  combinedallgraphflag = false;
  System.Gadget.Settings.write ("CombinedAllGraph", "false");
 }
 else{
  combinedallgraphflag = true;
  System.Gadget.Settings.write ("CombinedAllGraph", "true");
 }

 CPUGraphsTypeflag = System.Gadget.Settings.read ("CPUGraphsType");
 if (CPUGraphsTypeflag == ''){
  CPUGraphsTypeflag = "0";
  System.Gadget.Settings.write("CPUGraphsType", CPUGraphsTypeflag);
 }

 disableflyoutsoundsflag = System.Gadget.Settings.read ("DisableFlyoutSounds");
 if (disableflyoutsoundsflag != "true"){
  disableflyoutsoundsflag = false;
  System.Gadget.Settings.write ("DisableFlyoutSounds", "false");
 }
 else{
  disableflyoutsoundsflag = true;
  System.Gadget.Settings.write ("DisableFlyoutSounds", "true");
 }

 disableshowwheelflag = System.Gadget.Settings.read ("DisableShowWheel");
 if (disableshowwheelflag != "true"){
  disableshowwheelflag = false;
  System.Gadget.Settings.write ("DisableShowWheel", "false");
 }
 else{
  disableshowwheelflag = true;
  System.Gadget.Settings.write ("DisableShowWheel", "true");
 }

 enablegetweifromwmiflag = System.Gadget.Settings.read ("GetWEIfromWMIenable");
 if (enablegetweifromwmiflag != "true"){
  enablegetweifromwmiflag = false;
  System.Gadget.Settings.write ("GetWEIfromWMIenable", "false");
 }
 else{
  enablegetweifromwmiflag = true;
  System.Gadget.Settings.write ("GetWEIfromWMIenable", "true");
 }

 switchtime = System.Gadget.Settings.read("SwithchRate");
 if(switchtime == ''){
  switchtime = "10000";
  System.Gadget.Settings.write("SwithchRate", switchtime);
 }
 switchflag = System.Gadget.Settings.read ("Switch");
 if (switchflag != "true"){
  switchflag = false;
  System.Gadget.Settings.write ("Switch", "false");
 }
 else{
  switchflag = true;
  System.Gadget.Settings.write ("Switch", "true");
 }

 CPUclockcalculation = System.Gadget.Settings.read("CPUClockFormula");
 if(CPUclockcalculation == ''){
  CPUclockcalculation = "0";
  System.Gadget.Settings.write("CPUClockFormula", CPUclockcalculation);
 }

 autoupdateflag = System.Gadget.Settings.read ("AutoUpdate");
 if (autoupdateflag != "true"){
  autoupdateflag = false;
  System.Gadget.Settings.write ("AutoUpdate", "false");
 }
 else{
  autoupdateflag = true;
  System.Gadget.Settings.write ("AutoUpdate", "true");
 }

 //color settings
 checkcolormode = System.Gadget.Settings.read("ColorModeCheck");
 if (checkcolormode == ''){
  checkcolormode = "0";
  System.Gadget.Settings.write("ColorModeCheck", checkcolormode);
 }
 cBgColor = System.Gadget.Settings.read("colBgColor");
 if (cBgColor == ''){
  cBgColor = "#262526";
  System.Gadget.Settings.write("colBgColor", cBgColor);
 }

 cTitle = System.Gadget.Settings.read("colTitle");
 if (cTitle == ''){
  cTitle = "#FFFFFF";
  System.Gadget.Settings.write("colTitle", cTitle);
 }
 cMemUsage = System.Gadget.Settings.read("colMemUsage");
 if (cMemUsage == ''){
  cMemUsage = "#FFFFFF";
  System.Gadget.Settings.write("colMemUsage", cMemUsage);
 }
 cMemMenu = System.Gadget.Settings.read("colMemMenu");
 if (cMemMenu == ''){
  cMemMenu = "#FFCC00";
  System.Gadget.Settings.write("colMemMenu", cMemMenu);
 }
 cMemRam = System.Gadget.Settings.read("colMemRam");
 if (cMemRam == ''){
  cMemRam = "#87CEFA";
  System.Gadget.Settings.write("colMemRam", cMemRam);
 }
 cMemPage = System.Gadget.Settings.read("colMemPage");
 if (cMemPage == ''){
  cMemPage = "#6666CC";
  System.Gadget.Settings.write("colMemPage", cMemPage);
 }
 cMemAll = System.Gadget.Settings.read("colMemAll");
 if (cMemAll == ''){
  cMemAll = "#CCCCCC";
  System.Gadget.Settings.write("colMemAll", cMemAll);
 }
 cCPUmodel = System.Gadget.Settings.read("colCPUmodel");
 if (cCPUmodel == ''){
  cCPUmodel = "#C0C0C0";
  System.Gadget.Settings.write("colCPUmodel", cCPUmodel);
 }
 cCoreCpuspeed = System.Gadget.Settings.read("colCoreCpuspeed");
 if (cCoreCpuspeed == ''){
  cCoreCpuspeed = "#FFFFFF";
  System.Gadget.Settings.write("colCoreCpuspeed", cCoreCpuspeed);
 }
 cCpuused = System.Gadget.Settings.read("colCpuused");
 if (cCpuused == ''){
  cCpuused = "#FFFFFF";
  System.Gadget.Settings.write("colCpuused", cCpuused);
 }
 cCpuParked = System.Gadget.Settings.read("colCpuParked");
 if (cCpuParked == ''){
  cCpuParked = "#C0C0C0";
  System.Gadget.Settings.write("colCpuParked", cCpuParked);
 }

 for (var i=1; i<=maxCPUcoressupport; i++){
  CoreColor[i] = System.Gadget.Settings.read ("Core" + i + "col");
  if (CoreColor[i] == ''){
   CoreColor[i] = defaultcorecol[i-1];
   System.Gadget.Settings.write("Core" + i + "col", CoreColor[i]);
  }
 }

 cFillGraph = System.Gadget.Settings.read("colFillGraph");
 if (cFillGraph == ''){
  cFillGraph = "#000000";
  System.Gadget.Settings.write("colFillGraph", cFillGraph);
 }

 cCpuEasy = System.Gadget.Settings.read("colCpuEasy");
 if (cCpuEasy == ''){
  cCpuEasy = "#90EE90";
  System.Gadget.Settings.write("colCpuEasy", cCpuEasy);
 }
 cCpuMedium = System.Gadget.Settings.read("colCpuMedium");
 if (cCpuMedium == ''){
  cCpuMedium = "#FFF62A";
  System.Gadget.Settings.write("colCpuMedium", cCpuMedium);
 }
 cCpuHard = System.Gadget.Settings.read("colCpuHard");
 if (cCpuHard == ''){
  cCpuHard = "#E33535";
  System.Gadget.Settings.write("colCpuHard", cCpuHard);
 }
 cCpuAllinone = System.Gadget.Settings.read("colCpuAllinone");
 if (cCpuAllinone == ''){
  cCpuAllinone = "#FF8C00";
  System.Gadget.Settings.write("colCpuAllinone", cCpuAllinone);
 }

 cCopyright = System.Gadget.Settings.read("colCopyright");
 if (cCopyright == ''){
  cCopyright = "#00CCFF";
  System.Gadget.Settings.write("colCopyright", cCopyright);
 }
 cVersion = System.Gadget.Settings.read("colVersion");
 if (cVersion == ''){
  cVersion = "#C0C0C0";
  System.Gadget.Settings.write("colVersion", cVersion);
 }
 //color settings end

 for (var j=1; j<=coreCount; j++){
  document.getElementById("namCore" + j).innerText  = mainlng[lngID][13] + j;
  document.getElementById("namCore" + j + "p").innerHTML = '<span style="font-size:' + parseInt(9 * size) + 'px;font-weight:bold">&nbsp;</span>';
 }

 if (CPUBarsType != 0) document.getElementById("namCore1").innerText = mainlng[lngID][14];
 if (calctemperatureflag) tryregistercoretemplibrary();
 if (parkingflag) setupcoresparkingnamts();
}

function insert(arr,i){ 
 var j;
 var v = arr[i][0];
 var tmp = arr[i];
 for (j=i-1; j>=0; j--){
  if (checkstr(arr[j][0], v)) break;
  arr[j+1] = arr[j];
 }
 arr[j+1] = tmp;
}

function checkstr(el1, el2){
 var ml = el1.length>el2.length ? el1.length : el2.length;
 for (var i=0; i<ml; i++){
  if (el1.charAt(i)>el2.charAt(i)) return true;
 }
 return false;
}

function insertionSort(arr){
 var i = 1;
 while (i<arr.length){
  insert(arr, i);
  i++;
 }
}

function setupcoresparkingnamts(){
 var parkingnames = wmiService.ExecQuery("SELECT Name from Win32_PerfFormattedData_Counters_ProcessorInformation");
 var j = 0;
 try{
  for (var i=0; i<parkingnames.Count; i++){
   CPUNames[j] = new Array();
   if (parkingnames.ItemIndex(i).Name.indexOf("_Total") != -1) continue;
   CPUNames[j][0] = parkingnames.ItemIndex(i).Name;
   CPUNames[j][1] = i;
   j++;
  }
 }
 catch (e){CPUNames[j][1] = "n/a"}
 insertionSort(CPUNames);
 CPUNames.reverse();
}

function tryregistercoretemplibrary(){
 if (alreadyregistered) return;
 CoreTempliberror = false;
 CoreTempActive = false;
 CoreTemp = CreateObjectFromDLL();
 if (CoreTemp == null) CoreTempliberror = true;
 else alreadyregistered = true;
}

function trycoretemp(){
 if (CoreTempliberror){
  CPUmodel.innerText = "Load library error!";
  return;
 }
 try{
  CoreTemp.Refresh();
  CTcoreCount = CoreTemp.CoreCount;
 }
 catch (e){CTcoreCount = 0}
 if (CTcoreCount == 0 && CoreTempActive) CoreTempActive = false;
 else if (CTcoreCount > 0 && !CoreTempActive) CoreTempActive = true;
 if (!CoreTempActive){
  CPUmodel.innerText = mainlng[lngID][15];
  if (CoreTempgetinfoflag){
   cpuspeed.innerText = mainlng[lngID][30];
   CPUfrequency = 0;
  }
  for (var j=1; j<=coreCount; j++){
   document.getElementById("namCore" + j).innerText  = mainlng[lngID][13] + j;
  }
  return;
 }

 if (CoreTempgetinfoflag){
  try{
   var nameCPU = CoreTemp.CPUName;
   nameCPU = nameCPU.substr(0,23);
   CPUmodel.innerHTML = "<nobr>" + nameCPU + "</nobr><br>VID: " + (CoreTemp.VID ? CoreTemp.VID.toFixed(4): "N/A") +"V TjMax: " + 
   (CoreTemp.GetTjMax(currentCPUnum) ? CoreTemp.GetTjMax(currentCPUnum) + (CoreTemp.Fahrenheit ? "&deg;F" : "&deg;C") : "N/A");
   CPUfrequency = CoreTemp.CPUSpeed.toFixed(0);
   cpuspeed.innerText = CPUfrequency + mainlng[lngID][16] + "(" + CoreTemp.FSBSpeed.toFixed(1) + "x" + CoreTemp.Multiplier.toFixed(1) + ")";
  }
  catch (e){}
 }
 else CPUmodel.innerText = CPUModelstring;

 if (CTcoreCount == 0) return; //no cores found

 if (showcorestype == 0) CTcoreCount = startphysicalcore + parseInt(coreCount / coreThread);
 else{
  coreThread = parseInt(coreCount / CTcoreCount / maxrealCPUcount);
  CTcoreCount *= maxrealCPUcount;
 }

 var realindex = 0;
 for (var i=startphysicalcore; i<CTcoreCount; i++){
  try{
   for (var j=0; j<coreThread; j++){
    var temp = parseInt(CoreTemp.GetTemp(i));
    coreactualtemp[realindex] = temp;
    if (coreTHist[currentCPUnum][realindex].push(temp) > maxCPUHist) coreTHist[currentCPUnum][realindex].shift();
    if (CPUBarsType == 0){ //no all cores in one
     document.getElementById("namCore" + (realindex + 1)).innerHTML = !temp ? mainlng[lngID][13] + (realindex + 1) : "[" + temp + (CoreTemp.Fahrenheit ? "&deg;F" : "&deg;C") + "]";
    }
    realindex++;
   }// end for
  }
  catch (e){}
 }// end for

 switch (checkoverheat){
  case 1:
   var overheatyes = false;
   var minimum;
   minimum = coreactualtemp[0];
   for (var i=1; i<coreCount; i++){
    if (minimum > coreactualtemp[i]) minimum = coreactualtemp[i];
   }
   for (var i=0; i<coreCount; i++){
    if ((coreactualtemp[i] - minimum) >= overheatdelta){
     overheatyes = true;
     if (document.getElementById("barback" + (i+1)).style.visibility == "visible") document.getElementById("WarningCore" + (i+1)).style.visibility = "visible";
    }
    else document.getElementById("WarningCore" + (i+1)).style.visibility = "hidden";
   } 
   if (overheatyes){
    if (playsoundflag) System.Sound.playSound("media/redalert.wav");
   }
   break;
  case 2:
   var overheatCPUyes = false;
   for (var i=0; i<coreCount; i++){
    if (coreactualtemp[i] >= TjMax) overheatCPUyes = true;
   }
   if (overheatCPUyes){
    for (var i=1; i<=coreCount; i++){
     if (document.getElementById("barback" + i).style.visibility == "visible") document.getElementById("WarningCore" + i).style.visibility = "visible";
    }
    if (playsoundflag) System.Sound.playSound("media/redalert.wav");
   }
   else{
    for (var i=1; i<=coreCount; i++){
     document.getElementById("WarningCore" + i).style.visibility = "hidden";
    }
   }
   break;
 }
}

function loadsettingsfromfile(){
 var inifilename = System.Environment.getEnvironmentVariable("APPDATA") + "\\" + System.Gadget.name + "_CPU" + currentCPUnum +  "_Settings.ini";
 try{
  var inifile = fso.OpenTextFile(inifilename, ForReading);
   try{
    var tmp = inifile.ReadLine();
    tmp = inifile.ReadLine();
    tmp = inifile.ReadLine();
    if (tmp != ";purr purr meow meow") throw "old";

    lngID = inifile.ReadLine();
    System.Gadget.Settings.write("LanguageId", lngID);
    //color settings
    checkcolormode = inifile.ReadLine();
    System.Gadget.Settings.write("ColorModeCheck", checkcolormode);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sBgColorSelect", tmp);
    cBgColor = inifile.ReadLine();
    System.Gadget.Settings.write("colBgColor", cBgColor);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sTitColorSelect", tmp);
    cTitle = inifile.ReadLine();
    System.Gadget.Settings.write("colTitle", cTitle);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sMemColorSelect", tmp);
    cTitle = inifile.ReadLine();
    System.Gadget.Settings.write("colMemUsage", cTitle);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sMMemColorSelect", tmp);
    cMemMenu = inifile.ReadLine();
    System.Gadget.Settings.write("colMemMenu", cMemMenu);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sRamMemColorSelect", tmp);
    cMemRam = inifile.ReadLine();
    System.Gadget.Settings.write("colMemRam", cMemRam);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sPageMemColorSelect", tmp);
    cMemPage = inifile.ReadLine();
    System.Gadget.Settings.write("colMemPage", cMemPage);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sAllMemColorSelect", tmp);
    cMemAll = inifile.ReadLine();
    System.Gadget.Settings.write("colMemAll", cMemAll);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sCPUnameColorSelect", tmp);
    colCPUmodel = inifile.ReadLine();
    System.Gadget.Settings.write("colCPUmodel", colCPUmodel);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sCoreColorSelect", tmp);
    cCoreCpuspeed = inifile.ReadLine();
    System.Gadget.Settings.write("colCoreCpuspeed", cCoreCpuspeed);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sCPUusedColorSelect", tmp);
    cCpuused = inifile.ReadLine();
    System.Gadget.Settings.write("colCpuused", cCpuused);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sParkingColorSelect", tmp);
    cCpuParked = inifile.ReadLine();
    System.Gadget.Settings.write("colCpuParked", cCpuParked);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sGrBgColorSelect", tmp);
    cFillGraph = inifile.ReadLine();
    System.Gadget.Settings.write("colFillGraph", cFillGraph);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sVersnColorSelect", tmp);
    cVersion = inifile.ReadLine();
    System.Gadget.Settings.write("colVersion", cVersion);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sCopyColorSelect", tmp);
    cCopyright = inifile.ReadLine();
    System.Gadget.Settings.write("colCopyright", cCopyright);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sSingleColorSelect", tmp);
    cCpuAllinone = inifile.ReadLine();
    System.Gadget.Settings.write("colCpuAllinone", cCpuAllinone);
    for (var i=1; i<=maxCPUcoressupport; i++){
     tmp = inifile.ReadLine();
     System.Gadget.Settings.write("sCore" + i + "ColorSelect", tmp);
     CoreColor[i] = inifile.ReadLine();
     System.Gadget.Settings.write("Core" + i + "col", CoreColor[i]);
    }
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sEasyLoadColorSelect", tmp);
    cCpuEasy = inifile.ReadLine();
    System.Gadget.Settings.write("colCpuEasy", cCpuEasy);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sModerateLoadColorSelect", tmp);
    cCpuMedium = inifile.ReadLine();
    System.Gadget.Settings.write("colCpuMedium", cCpuMedium);
    tmp = inifile.ReadLine();
    System.Gadget.Settings.write("sHardLoadColorSelect", tmp);
    cCpuHard = inifile.ReadLine();
    System.Gadget.Settings.write("colCpuHard", cCpuHard);
    //color settings end

    graphscheme = inifile.ReadLine();
    System.Gadget.Settings.write("GraphScheme", graphscheme);
    easyloaduse = inifile.ReadLine();
    System.Gadget.Settings.write("EasyLoadUse", easyloaduse);
    mediumloaduse = inifile.ReadLine();
    System.Gadget.Settings.write("MediumLoadUse", mediumloaduse);
    refreshRate = inifile.ReadLine();
    System.Gadget.Settings.write("refreshtime", refreshRate);
    size = inifile.ReadLine();
    System.Gadget.Settings.write("SetSize", size);
    MemGraphType = inifile.ReadLine();
    System.Gadget.Settings.write("graphtype", MemGraphType);
    dblclcaction = inifile.ReadLine();
    System.Gadget.Settings.write("dblclick", dblclcaction);
    CPUBarsType = inifile.ReadLine();
    System.Gadget.Settings.write("barstype", CPUBarsType);

    hidememnusedflag = inifile.ReadLine();
    System.Gadget.Settings.write ("MemUsageHide", hidememnusedflag);

    hidememnumbersflag = inifile.ReadLine();
    System.Gadget.Settings.write ("MemNumbersHide", hidememnumbersflag);
    hideRAMnumbersflag = inifile.ReadLine();
    System.Gadget.Settings.write ("RamNumbersHide", hideRAMnumbersflag);
    hidePAGEnumbersflag = inifile.ReadLine();
    System.Gadget.Settings.write ("PageNumbersHide", hidePAGEnumbersflag);
    hideALLnumbersflag = inifile.ReadLine();
    System.Gadget.Settings.write ("AllNumbersHide", hideALLnumbersflag);

    hidemembarsflag = inifile.ReadLine();
    System.Gadget.Settings.write ("MemBarsHide", hidemembarsflag);
    hideRAMbarsflag = inifile.ReadLine();
    System.Gadget.Settings.write ("RamBarsHide", hideRAMbarsflag);
    hidePAGEbarsflag = inifile.ReadLine();
    System.Gadget.Settings.write ("PageBarsHide", hidePAGEbarsflag);
    hideALLbarsflag = inifile.ReadLine();
    System.Gadget.Settings.write ("AllBarsHide", hideALLbarsflag);

    hideCPUidentflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CPUIdentHide", hideCPUidentflag);
    hideCPUclockflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CPUClockHide", hideCPUclockflag);
    hideCPUusageflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CPUUsageHide", hideCPUusageflag);

    hidecpubarsflag = inifile.ReadLine();
    System.Gadget.Settings.write ("HideCPUallbars", hidecpubarsflag);

    hidecpugraphicsflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CPUGraphHide", hidecpugraphicsflag);

    hidememgraphicsflag = inifile.ReadLine();
    System.Gadget.Settings.write ("MemGraphHide", hidememgraphicsflag);

    RAMfillflag = inifile.ReadLine();
    System.Gadget.Settings.write ("fillRam", RAMfillflag);
    Pagefillflag = inifile.ReadLine();
    System.Gadget.Settings.write ("fillPage", Pagefillflag);
    Allfillflag = inifile.ReadLine();
    System.Gadget.Settings.write ("fillAll", Allfillflag);

    RAMhideflag = inifile.ReadLine();
    System.Gadget.Settings.write ("hideRam", RAMhideflag);
    Pagehideflag = inifile.ReadLine();
    System.Gadget.Settings.write ("hidePage", Pagehideflag);
    Allhideflag = inifile.ReadLine();
    System.Gadget.Settings.write ("hideAll", Allhideflag);

    for (var i=1; i<=maxCPUcoressupport; i++){
     Coreflag[i] = inifile.ReadLine();
     System.Gadget.Settings.write ("Core" + i + "fill", Coreflag[i]);
     Corehidebarflag[i] = inifile.ReadLine();
     System.Gadget.Settings.write ("Corehide" + i + "bar", Corehidebarflag[i]);
     Corehideflag[i] = inifile.ReadLine();
     System.Gadget.Settings.write ("Core" + i + "hide", Corehideflag[i]);
    }

    parkingflag = inifile.ReadLine();
    System.Gadget.Settings.write ("ParkingCore", parkingflag);

    calctemperatureflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CoreTempUse", calctemperatureflag);

    checkoverheat = inifile.ReadLine();
    System.Gadget.Settings.write("OverheatCheck", checkoverheat);

    overheatdelta = inifile.ReadLine();
    System.Gadget.Settings.write("DeltaOverheat", overheatdelta);

    TjMax = inifile.ReadLine();
    System.Gadget.Settings.write("TjMaxtemp", TjMax);

    playsoundflag = inifile.ReadLine();
    System.Gadget.Settings.write("PlaySound", playsoundflag);

    graphtemperature = inifile.ReadLine();
    System.Gadget.Settings.write("ShowTempGraph", graphtemperature);
    lowtempscale = inifile.ReadLine();
    System.Gadget.Settings.write("LowScaleTemperatureGr", lowtempscale);
    hightempscale = inifile.ReadLine();
    System.Gadget.Settings.write("ScaleTemperatureGr", hightempscale);

    cyclegraphflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CycleGraphEnable", cyclegraphflag);

    enableloggingflag = inifile.ReadLine();
    System.Gadget.Settings.write ("LogEnabled", enableloggingflag);
    iomodeflag = inifile.ReadLine();
    System.Gadget.Settings.write ("modeIO", iomodeflag);
    refreshLogRate = inifile.ReadLine();
    System.Gadget.Settings.write ("refreshlogtime", refreshLogRate);
    writeCPUflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CPUusagelog", writeCPUflag);
    writeCPUfreqflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CPUfreqlog", writeCPUfreqflag);
    writeRAMflag = inifile.ReadLine();
    System.Gadget.Settings.write ("RAMusagelog", writeRAMflag);
    writePageflag = inifile.ReadLine();
    System.Gadget.Settings.write ("Pageusagelog", writePageflag);
    writeAllflag = inifile.ReadLine();
    System.Gadget.Settings.write ("Allusagelog", writeAllflag);
    for (var i=1; i<=maxCPUcoressupport; i++){
     writecoreflag[i] = inifile.ReadLine();
     System.Gadget.Settings.write ("Core" + i + "log", writecoreflag[i]);
     writecoretempflag[i] = inifile.ReadLine();
     System.Gadget.Settings.write ("Coretemp" + i + "log", writecoretempflag[i]);
    }

    writeparkingflag = inifile.ReadLine();
    System.Gadget.Settings.write ("logParkingCore", writeparkingflag);

    hidetitleflag = inifile.ReadLine();
    System.Gadget.Settings.write ("TitleHide", hidetitleflag);
    hidecopyrightflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CopyrightHide", hidecopyrightflag);

    graphlinewidth = inifile.ReadLine();
    System.Gadget.Settings.write ("GraphLineWidth", graphlinewidth);

    hidegridlinesflag = inifile.ReadLine();
    System.Gadget.Settings.write ("GridlinesHide", hidegridlinesflag);

    combinedallgraphflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CombinedAllGraph", combinedallgraphflag);

    CoreTempgetinfoflag = inifile.ReadLine();
    System.Gadget.Settings.write ("InfoFromCoreTemp", CoreTempgetinfoflag);

    CPUGraphsTypeflag = inifile.ReadLine();
    System.Gadget.Settings.write ("CPUGraphsType", CPUGraphsTypeflag);

    autoupdateflag = inifile.ReadLine();
    System.Gadget.Settings.write ("AutoUpdate", autoupdateflag);

    disableflyoutsoundsflag = inifile.ReadLine();
    System.Gadget.Settings.write ("DisableFlyoutSounds", disableflyoutsoundsflag);

    enablegetweifromwmiflag = inifile.ReadLine();
    System.Gadget.Settings.write ("GetWEIfromWMIenable", enablegetweifromwmiflag);

    switchflag = inifile.ReadLine();
    System.Gadget.Settings.write ("Switch", switchflag);
    switchtime = inifile.ReadLine();
    System.Gadget.Settings.write ("SwithchRate", switchtime);

    CPUclockcalculation = inifile.ReadLine();
    System.Gadget.Settings.write ("CPUClockFormula", CPUclockcalculation);

    showcorestype = inifile.ReadLine();
    System.Gadget.Settings.write ("ShowCoresType", showcorestype);

    disableshowwheelflag = inifile.ReadLine();
    System.Gadget.Settings.write ("DisableShowWheel", disableshowwheelflag);

    autoscaleDPIflag = inifile.ReadLine();
    System.Gadget.Settings.write ("DPIautoscale", autoscaleDPIflag);
   }//end try 2

   catch (e){}

   finally {inifile.Close()}
 }//end try 1

 catch (e){}
}

function savelogfile(){
 updatelog();
 timerlogvar = setTimeout("savelogfile()",refreshLogRate);
}

function createlogfirst(){
 var inifilename = System.Environment.getEnvironmentVariable("APPDATA") + "\\" + System.Gadget.name + "_CPU" + currentCPUnum + "_log.txt";
 if (!fso.FileExists(inifilename)){
  try{
   var inifile = fso.OpenTextFile(inifilename, ForAppending, true, -1); //true for create file -1, for UNICODE
   try{
    inifile.WriteLine(";System Monitor II log file (c) 2010-2013 by Igor 'Igogo' Bushin http://www.myfavoritegadgets.info/");
    inifile.WriteLine(";===***=== CPU" + currentCPUnum + ": " + CPUModelstring + " ===***===");
   }//end try 2
   catch (e){}
  finally {inifile.Close()}
  }//end try 1
  catch (e){}
 }// end if 
}

function firstupdatelog(){
 var inifilename = System.Environment.getEnvironmentVariable("APPDATA") + "\\" + System.Gadget.name + "_CPU" + currentCPUnum + "_log.txt";
  if (!iomodeflag){
   try{
    var inifile = fso.OpenTextFile(inifilename, ForWriting, true, -1); //true for create file
    try{
     inifile.WriteLine(";System Monitor II log file (c) 2010-2013 by Igor 'Igogo' Bushin http://www.myfavoritegadgets.info/");
     inifile.WriteLine(";===***=== CPU" + currentCPUnum + ": " + CPUModelstring + " ===***===");
    }//end try 2
    catch (e){}
    finally {inifile.Close()}
   }//end try 1
   catch (e){}
  }
  else{
   try{
    if (!fso.FileExists(inifilename)){
     var inifile = fso.OpenTextFile(inifilename, ForAppending, true, -1); //true for create file -1, for UNICODE
     try {
      inifile.WriteLine(";System Monitor II log file (c) 2010-2013 by Igor 'Igogo' Bushin http://www.myfavoritegadgets.info/");
      inifile.WriteLine(";===***=== CPU" + currentCPUnum + ": " + CPUModelstring + " ===***===");
     }//end try 2
     catch (e){}
     finally {inifile.Close()}
    }// end if 
   }//end try 1
   catch (e){}
  }// else
}

function updatelog(){
 var inifilename = System.Environment.getEnvironmentVariable("APPDATA") + "\\" + System.Gadget.name + "_CPU" + currentCPUnum + "_log.txt";
 try{
  var inifile = fso.OpenTextFile(inifilename, ForAppending, true, -1); //true for create file -1, for UNICODE
  try{
   var str = "";
   var now = new Date();
   var day = (now.getDate()<10) ? "0" + now.getDate() : now.getDate();
   var mon = ((now.getMonth()+1)<10) ? "0" + (now.getMonth()+1) : (now.getMonth()+1);
   var hrs = (now.getHours()<10) ? "0" + now.getHours() : now.getHours();
   var min = (now.getMinutes()<10) ? "0" + now.getMinutes() : now.getMinutes();
   var sec = (now.getSeconds()<10) ? "0" + now.getSeconds() : now.getSeconds();
   str = day + "/" + mon + "/" + now.getFullYear() + " " + hrs + ":" + min + ":" + sec + " ";
   if (writeCPUflag) str += mainlng[lngID][17] + currentCPUnum + (writeCPUfreqflag ? (" " + CPUfrequency + " " + mainlng[lngID][16]) : "") + mainlng[lngID][18] + totalUsage + "%, ";
   else if (writeCPUfreqflag) str += CPUfrequency + " " + mainlng[lngID][16] + ", ";
   for (var j=0; j<coreCount; j++){
    if (writecoreflag[j+1]) str += mainlng[lngID][19] + (j+1) + mainlng[lngID][20] + coreUsage[j] + "%, ";
    if (writecoretempflag[j+1] && CoreTempActive && calctemperatureflag) str += "[" + coreactualtemp[j] + (CoreTemp.Fahrenheit ? "°F" : "°C") + "], ";
    if (writeparkingflag) str += document.getElementById("namCore" + (j+1) + "p").innerText == "P" ? mainlng[lngID][21] : "";
   }
   if (writeRAMflag) str += mainlng[lngID][22] + RAMusedpersent + "%, ";
   if (writePageflag){
    if (!nopagefile) str += mainlng[lngID][23] + Pageusedpersent + "%, ";
    else str += mainlng[lngID][24];
   }
   if (writeAllflag) str += mainlng[lngID][25] + VIRusedpersent + "%";
   if (str.charAt(str.length-2) == ",") str = str.substring(0,str.length-2);
   inifile.WriteLine(str);
  }//end try 2
  catch (e){}
  finally {inifile.Close()}
 }//end try 1
 catch (e){}
}

function init(){
 update();
 timervar = setTimeout("init()",refreshRate);
} 

function docyclegraph(){
 if (!cyclegraphflag) return;
 if (!curgraph){
  curgraph = 1;
  temperatureimg.style.visibility = "visible";
 }
 else{
  curgraph = 0;
  temperatureimg.style.visibility = "hidden";
 }
}

function fixedDigits(value){
 if (value >= 1000) return value.toFixed(0);
 else if (value >= 100) return value.toFixed(1);
 else if (value >= 10) return value.toFixed(2);
 else return value.toFixed(3);    
}

function formatBytes(bytes){
 if (bytes >= 10000) return fixedDigits(bytes / 1024) + mainlng[lngID][26];
 else return bytes + mainlng[lngID][27];
}

function update(){
//---------------- CPU frequency
 if (!CoreTempgetinfoflag){
  var CPUfreq = wmiService.ExecQuery("SELECT CurrentClockSpeed FROM Win32_Processor");
  var freqCPU = CPUfreq.ItemIndex(currentCPUnum).CurrentClockSpeed;
  if (CPUclockcalculation == "0"){
   if (CPUFHist[currentCPUnum].push(freqCPU) > maxCPUavrg) CPUFHist[currentCPUnum].shift();
   averageCPUfreq = 0;
   for (var i=0; i<maxCPUavrg; i++){
    averageCPUfreq += CPUFHist[currentCPUnum][i];
   }
   CPUfrequency = Math.floor(averageCPUfreq / maxCPUavrg);
  }
  else CPUfrequency = parseInt(freqCPU);
  cpuspeed.innerText = CPUfrequency + mainlng[lngID][16];
 }
//---------------- MEM
 var getmemory = wmiService.ExecQuery("SELECT TotalVirtualMemorySize,FreeVirtualMemory,FreePhysicalMemory,TotalVisibleMemorySize FROM Win32_OperatingSystem");
 var RAMall  = getmemory.ItemIndex(0).TotalVisibleMemorySize;
 var RAMfree = getmemory.ItemIndex(0).FreePhysicalMemory;
 var RAMused = RAMall - RAMfree;
 RAMusedpersent = Math.round(RAMused / RAMall * 100);

 var VIRall = getmemory.ItemIndex(0).TotalVirtualMemorySize;
 var VIRfree = getmemory.ItemIndex(0).FreeVirtualMemory;
 var VIRused = VIRall - VIRfree;
 VIRusedpersent = Math.round(VIRused / VIRall * 100); //don't move this

 RAMall  = Math.round(RAMall  / 1024);
 RAMfree = Math.round(RAMfree / 1024);
 RAMused = Math.round(RAMused / 1024);

 VIRall  = Math.round(VIRall  / 1024);
 VIRfree = Math.round(VIRfree / 1024);
 VIRused = Math.round(VIRused / 1024);

 ram1.innerText = formatBytes(RAMused) + mainlng[lngID][28];
 ram2.innerText = formatBytes(RAMfree) + mainlng[lngID][28];
 ram3.innerText = formatBytes(RAMall)  + mainlng[lngID][28];

 all1.innerText = formatBytes(VIRused) + mainlng[lngID][28];
 all2.innerText = formatBytes(VIRfree) + mainlng[lngID][28];
 all3.innerText = formatBytes(VIRall)  + mainlng[lngID][28];

 var Pageall = parseInt('0', 10);
 var getPageFile = wmiService.ExecQuery("SELECT AllocatedBaseSize,CurrentUsage,PeakUsage FROM Win32_PageFileUsage");
 try{
  for (var eItems = new Enumerator(getPageFile); eItems.atEnd() == false; eItems.moveNext()){
   Pageall += parseInt(eItems.item().AllocatedBaseSize, 10);
  }
  if (Pageall != 0) nopagefile = false;
  else nopagefile = true;
 }
 catch (e){nopagefile = true}

 if (!nopagefile){
  var Pageused = parseInt('0', 10);
  var maxPageused = parseInt('0', 10);
  for (var eItems = new Enumerator(getPageFile); eItems.atEnd() == false; eItems.moveNext()){
   Pageused += parseInt(eItems.item().CurrentUsage, 10);
   maxPageused += parseInt(eItems.item().PeakUsage, 10);
  }
  var Pagefree = Pageall - Pageused;
  Pageusedpersent = Math.round(Pageused / Pageall * 100);
  Pageall  = parseInt(Pageall);
  Pagefree = parseInt(Pagefree);
  Pageused = parseInt(Pageused);
  page1.innerText = formatBytes(Pageused) + mainlng[lngID][28];
  page2.innerText = formatBytes(Pagefree) + mainlng[lngID][28];
  page3.innerText = formatBytes(Pageall)  + mainlng[lngID][28];

  usgpage.innerText = Pageusedpersent + "%";

  var titlestr = mainlng[lngID][29] + formatBytes(maxPageused) + mainlng[lngID][28] + " (" + Math.round(maxPageused / Pageall * 100) + "%)";
  maxPF1.title = titlestr;
  maxPF2.title = titlestr;
  maxPF3.title = titlestr;
 }
 else{
  Pageusedpersent = 0;
  page1.innerHTML   = '<span style="width:' + parseInt(8 * size) + 'px;"></span>' + mainlng[lngID][30];
  page2.innerHTML   = '<span style="width:' + parseInt(8 * size) + 'px;"></span>' + mainlng[lngID][30];
  page3.innerHTML   = '<span style="width:' + parseInt(8 * size) + 'px;"></span>' + mainlng[lngID][30];
  usgpage.innerText = mainlng[lngID][30];
 }

 if (RAMusedpersent  < 0) RAMusedpersent = 0;
 if (VIRusedpersent  < 0) VIRusedpersent = 0;
 if (Pageusedpersent < 0) Pageusedpersent = 0;

 usgram.innerText = RAMusedpersent  + "%";
 usgall.innerText = VIRusedpersent  + "%";

 memused.innerText = Math.round((RAMusedpersent + VIRusedpersent) / 2) + "%";

 if (graphscheme != 0){
  if (RAMusedpersent < easyloaduse) barram.style.background = cCpuEasy; //green bar
  else if (mediumloaduse < RAMusedpersent) barram.style.background = cCpuHard; //red bar
  else barram.style.background = cCpuMedium; //yellow bar

  if (Pageusedpersent < easyloaduse) barpage.style.background = cCpuEasy; //green bar
  else if (mediumloaduse < Pageusedpersent) barpage.style.background = cCpuHard; //red bar
  else barpage.style.background = cCpuMedium; //yellow bar

  if (VIRusedpersent < easyloaduse) barall.style.background = cCpuEasy; //green bar
  else if (mediumloaduse < VIRusedpersent) barall.style.background = cCpuHard; //red bar
  else barall.style.background = cCpuMedium; //yellow bar
 }

 imgbarram.style.width  = parseInt(0.7 * size * RAMusedpersent);
 imgbarpage.style.width = parseInt(0.7 * size * Pageusedpersent);
 imgbarall.style.width  = parseInt(0.7 * size * VIRusedpersent);

 if (RAMHist.push(RAMusedpersent)   > maxMEMlargeHist) RAMHist.shift();
 if (PageHist.push(Pageusedpersent) > maxMEMlargeHist) PageHist.shift();
 if (VIRHist.push(VIRusedpersent)   > maxMEMlargeHist) VIRHist.shift();

 paintGraphMEM();
//---------------- CPU

 if (calctemperatureflag) trycoretemp();

 var j = 0;
 totalUsage = 0;
 var CPUcounters = wmiService.ExecQuery("SELECT PercentProcessorTime,Timestamp_Sys100NS from Win32_PerfRawData_PerfOS_Processor");
 for (var i=startlogicalcore; i<endlogicalcore; i++){
  PercentProcessorTime[i] = CPUcounters.ItemIndex(i).PercentProcessorTime;
  Timestamp_Sys100NS[i] = CPUcounters.ItemIndex(i).Timestamp_Sys100NS;
  coreUsage[j] = parseInt((1 - (PercentProcessorTime[i] - PercentProcessorTimeold[i])/(Timestamp_Sys100NS[i] - Timestamp_Sys100NSold[i])) * 100);
  if (coreUsage[j] < 0) coreUsage[j] = 0; //Warning! Don't remove this. Percentage can be negative value 
  totalUsage += coreUsage[j];
  PercentProcessorTimeold[i] = PercentProcessorTime[i];
  Timestamp_Sys100NSold[i] = Timestamp_Sys100NS[i];
  j++;
 }
 totalUsage = Math.round(totalUsage / coreCount);
 cpuused.innerText = totalUsage + "%";

 if (CPUHist.push(totalUsage) > maxCPUHist) CPUHist.shift();
 if (CPUFreqhist.push(CPUfrequency) > maxCPUHist) CPUFreqhist.shift();

 if (parkingflag == true && CPUBarsType == 0){
  var j = 1;
  try{
   var parking = wmiService.ExecQuery("SELECT ParkingStatus from Win32_PerfFormattedData_Counters_ProcessorInformation");
   for (var i=startlogicalcore; i<endlogicalcore; i++){
    document.getElementById("namCore" + j + "p").innerHTML = parking.ItemIndex(CPUNames[i][1]).ParkingStatus ? parkingstr : parkclear;
    j++;
   }
  }
  catch (e){}
 } //end if

 for (var j=0; j<coreCount; j++){
  document.getElementById("usgCore" + (j+1)).innerText = coreUsage[j] + "%";
  
  if (graphscheme != 0){
   if (coreUsage[j] < easyloaduse) document.getElementById("cbar" + (j+1)).style.background = cCpuEasy; //green bar
   else if (mediumloaduse < coreUsage[j]) document.getElementById("cbar" + (j+1)).style.background = cCpuHard; //red bar
   else document.getElementById("cbar" + (j+1)).style.background = cCpuMedium; //yellow bar
  }
  document.getElementById("imgbar" + (j+1)).style.width = parseInt(0.5 * size * coreUsage[j]);
  if (coreHist[currentCPUnum][j].push(coreUsage[j]) > maxCPUHist) coreHist[currentCPUnum][j].shift();
 }

 if (CPUBarsType != 0){
  if (graphscheme != 0){
   if (totalUsage < easyloaduse) document.getElementById("imgbar1").style.background = cCpuEasy; //green bar
   else if (mediumloaduse < totalUsage) document.getElementById("imgbar1").style.background = cCpuHard; //red bar
   else document.getElementById("imgbar1").style.background = cCpuMedium; //yellow bar
  }
  document.getElementById("usgCore1").innerText = totalUsage + "%";
  document.getElementById("imgbar1").style.width = parseInt(0.5 * size * totalUsage);
 }

 paintGraphCPU();
}

function paintGraphMEM(){
 var g1path = "";
 var g2path = "";
 var g3path = "";
 var g1 = 0;
 var g2 = 0;
 var g3 = 0;
 var i  = 1;
 var arrbegin = (MemGraphType == 0) ? maxMEMlargeHist - maxMEMsmallHist : 0;
 g1 = parseInt(RAMHist[arrbegin]);
 g2 = parseInt(PageHist[arrbegin]);
 g3 = parseInt(VIRHist[arrbegin]);
 g1path += "m 0," + (100 - g1);
 g2path += "m 0," + (100 - g2);
 g3path += "m 0," + (100 - g3);
 for (var j=arrbegin; j<maxMEMlargeHist; j++){
  g1 = parseInt(RAMHist[j]);
  g2 = parseInt(PageHist[j]);
  g3 = parseInt(VIRHist[j]);
  g1path += " l " + i + "," + (100 - g1);
  if (RAMfillflag) g1path += " m " + i + ",100 " + "l " + i + "," + (100 - g1);
  g2path += " l " + i + "," + (100 - g2);
  if (Pagefillflag) g2path += " m " + i + ",100 " + "l " + i + "," + (100 - g2);
  g3path += " l " + i + "," + (100 - g3);
  if (Allfillflag) g3path += " m " + i + ",100 " + "l " + i + "," + (100 - g3);
  i++;
 }// end for

 g1path += " e";
 g2path += " e";
 g3path += " e";

 if (!combinedallgraphflag){
  RAMgraph.path  = g1path;
  Pagegraph.path = g2path;
  VIRgraph.path  = g3path;
 }
 else{
  cRAMgraph.path  = g1path;
  cPagegraph.path = g2path;
  cVIRgraph.path  = g3path;
 }
}

function paintGraphCPU(){
 if (CPUGraphsTypeflag == 0){
  var cpath = new Array();
  var c     = new Array();
  for (var j=0; j<coreCount; j++){
   cpath[j] = "";
   c[j]     = 0;
   for (var i=0; i<maxCPUHist; i++){
    if (!cyclegraphflag){
     if (!graphtemperature) c[j] = parseInt(coreHist[currentCPUnum][j][i]);
     else{
      c[j] = parseInt((coreTHist[currentCPUnum][j][i] - lowtempscale) * (100 / (hightempscale - lowtempscale)));
      if (c[j] < 0) c[j] = 0;
      if (c[j] > 100) c[j] = 100;
     }
    }
    else{
     if (!curgraph) c[j] = parseInt(coreHist[currentCPUnum][j][i]);
     else{
      c[j] = parseInt((coreTHist[currentCPUnum][j][i] - lowtempscale) * (100 / (hightempscale - lowtempscale)));
      if (c[j] < 0) c[j] = 0;
      if (c[j] > 100) c[j] = 100;
     }
    }
    if (!i) cpath[j] += "m 0," + (100 - c[j]);
    cpath[j] += " l " + (i+1) + "," + (100 - c[j]);
    if (Coreflag[j+1]) cpath[j] += " m " + (i+1) + ",100 " + "l " + (i+1) + "," + (100 - c[j]);
   }// for i
   cpath[j] += " e";
   document.getElementById("core" + (j+1) + "graph").path = cpath[j];
  }// for j
 }//if
 else{
  var CPUpath = "";
  var c = 0;
  if (CPUGraphsTypeflag == 2){
   var max = getMaxFreq();
   if (max == 0) max = 1;
   freqscalenum.innerText = max != 1 ? max + " " + mainlng[lngID][16] : mainlng[lngID][30];
   for (var i=0; i<maxCPUHist; i++){
    c = 1 - 1.0 * CPUFreqhist[i] / max;
    if (c < 0) c = 0;
    if (c > 100) c = 100;
    if (!i) CPUpath += "m 0," + parseInt(100 * c);
    CPUpath += " l " + (i+1) + "," + parseInt(100 * c);
    if (Coreflag[1]) CPUpath += " m " + (i+1) + ",100 " + "l " + (i+1) + "," + parseInt(100 * c);
   }// end for
  }
  else{
   for (var i=0; i<maxCPUHist; i++){
    c = parseInt(CPUHist[i]);
    if (!i) CPUpath += "m 0," + (100 - c);
    CPUpath += " l " + (i+1) + "," + (100 - c);
    if (Coreflag[1]) CPUpath += " m " + (i+1) + ",100 " + "l " + (i+1) + "," + (100 - c);
   }// end for
  }
  CPUpath += " e";
  document.getElementById("core0graph").path = CPUpath;
 }
}

function getMaxFreq(){
 var max = 0;
 for (var i=0; i<maxCPUHist; i++){
  if (CPUFreqhist[i] > max) max = CPUFreqhist[i];
 }
 return max;
}

function setupcontent(){
 if (hidememgraphicsflag) return;
 if (MemGraphType == 0){
  memborderRAM.style.visibility = "visible";
  memborderPAGE.style.visibility = "visible";
  memborderAll.style.visibility = "visible";
  rect1.style.visibility = "visible";
  rect2.style.visibility = "visible";
  memborder.style.visibility  = "hidden";
  RAMgraph.style.left = parseInt(9 * size);
  Pagegraph.style.left = parseInt(47 * size);
  VIRgraph.style.left = parseInt(85 * size);
  RAMgraph.style.width = parseInt(35 * size);
  Pagegraph.style.width = parseInt(35 * size);
  VIRgraph.style.width = parseInt(35 * size);
  RAMgraph.coordsize = "35 100";
  Pagegraph.coordsize = "35 100";
  VIRgraph.coordsize = "35 100";
 }
 else{
  memborderRAM.style.visibility = "hidden";
  memborderPAGE.style.visibility = "hidden";
  memborderAll.style.visibility = "hidden";
  rect1.style.visibility = "hidden";
  rect2.style.visibility = "hidden";
  memborder.style.visibility  = "visible";
  RAMgraph.style.left = parseInt(9 * size);
  Pagegraph.style.left = parseInt(9 * size);
  VIRgraph.style.left = parseInt(9 * size);
  RAMgraph.style.width = parseInt(110 * size);
  Pagegraph.style.width = parseInt(110 * size);
  VIRgraph.style.width = parseInt(110 * size);
  RAMgraph.coordsize = "110 100";
  Pagegraph.coordsize = "110 100";
  VIRgraph.coordsize = "110 100";
 }
}

function hideunhidegraphs(){
 if (!RAMhideflag) RAMgraph.style.visibility = "visible";
 else RAMgraph.style.visibility = "hidden";
 if (!Pagehideflag) Pagegraph.style.visibility = "visible";
 else Pagegraph.style.visibility = "hidden";
 if (!Allhideflag) VIRgraph.style.visibility = "visible";
 else VIRgraph.style.visibility = "hidden";

 for (var i=1; i<=maxCPUcoressupport; i++){
  if (!Corehideflag[i]) document.getElementById("core" + i + "graph").style.visibility = "visible";
  else document.getElementById("core" + i + "graph").style.visibility = "hidden";
 }
}

function setupcombinedallgraph(){
 if (combinedallgraphflag){
  if (!RAMhideflag) cRAMgraph.style.visibility = "visible";
  else cRAMgraph.style.visibility = "hidden";
  if (!Pagehideflag) cPagegraph.style.visibility = "visible";
  else cPagegraph.style.visibility = "hidden";
  if (!Allhideflag) cVIRgraph.style.visibility = "visible";
  else cVIRgraph.style.visibility = "hidden";
 }
 else{
  cRAMgraph.style.visibility = "hidden";
  cPagegraph.style.visibility = "hidden";
  cVIRgraph.style.visibility = "hidden";
 }
}

function setupgadget(){
 var newtopcoord;
 var adstopcoord;
 var numhidden;

 if (coreCount >= 24){
  coreCount = 24;
  factheight = 493;
  newtopcoord = 439;
  adstopcoord = 473;
  numhidden = 24;
 }
 else
 if (coreCount == 16){
  factheight = 493-80;
  newtopcoord = 439-80;
  adstopcoord = 473-80;
  numhidden = 16;
 }
 else
 if (coreCount == 12){
  factheight = 493-120;
  newtopcoord = 439-120;
  adstopcoord = 473-120;
  numhidden = 12;
 }
 else
 if (coreCount == 8){
  factheight = 493-160;
  newtopcoord = 439-160;
  adstopcoord = 473-160;
  numhidden = 8;
 }
 else
 if (coreCount == 6){
  factheight = 493-180;
  newtopcoord = 439-180;
  adstopcoord = 473-180;
  numhidden = 6;
 }
 else
 if (coreCount == 5){
  factheight = 493-190;
  newtopcoord = 439-190;
  adstopcoord = 473-190;
  numhidden = 5;
 }
 else
 if (coreCount == 4){
  factheight = 493-200;
  newtopcoord = 439-200;
  adstopcoord = 473-200;
  numhidden = 4;
 }
 else
 if (coreCount == 3){
  factheight = 493-210;
  newtopcoord = 439-210;
  adstopcoord = 473-210;
  numhidden = 3;
 }
 else
 if (coreCount == 2){
  factheight = 493-220;
  newtopcoord = 439-220;
  adstopcoord = 473-220;
  numhidden = 2;
 }
 else{
  factheight = 493-230;
  newtopcoord = 439-230;
  adstopcoord = 473-230;
  numhidden = 1;
 }

 if (CPUBarsType != 0){
  factheight = 493-230;
  newtopcoord = 439-230;
  adstopcoord = 473-230;
  numhidden = 1;
 }

 for (var i=1; i<=coreCount; i++){
  document.getElementById("namCore" + i).style.visibility = "visible";
  document.getElementById("namCore" + i + "p").style.visibility = "visible";
  document.getElementById("usgCore" + i).style.visibility = "visible";
  document.getElementById("cbar" + i).style.visibility  = "visible";
  document.getElementById("barback" + i).style.visibility = "visible";
 }

 for (var i=maxCPUcoressupport; i>numhidden; i--){
  document.getElementById("namCore" + i).style.visibility = "hidden";
  document.getElementById("namCore" + i + "p").style.visibility = "hidden";
  document.getElementById("usgCore" + i).style.visibility = "hidden";
  document.getElementById("cbar" + i).style.visibility  = "hidden";
  document.getElementById("barback" + i).style.visibility = "hidden";
 }

 newtopcoord = parseInt(newtopcoord * size);
 adstopcoord = parseInt(adstopcoord * size);

 //background section
 //fixed bug with 100% width BEFORE set real width in background section
 document.body.style.width = parseInt(130 * size);
 background.style.width = parseInt(130 * size);

 core.innerText = CoreTempgetinfoflag ? mainlng[lngID][32] : mainlng[lngID][31]; //Important

 //setup parking strings
 parkingstr = '<span style="font-size:' + parseInt(9 * size) + 'px;color:' + cCpuParked + ';font-weight:bold">P</span>';
 parkclear  = '<span style="font-size:' + parseInt(9 * size) + 'px;font-weight:bold">&nbsp;</span>';

 //setup wheel picture
 wheelplase.style.top = parseInt(10 * size);
 wheelimg.style.width = parseInt(32 * size);
 wheelimg.style.height = parseInt(32 * size);

 //setup CPU number when wheel round
 CPUnum.style.top = parseInt(20 * size);
 CPUnum.style.fontSize = parseInt(12 * size);

 var picn;
 if (size <= 1.25) picn = 32;
 else if (size <= 1.75) picn = 48;
 else if (size <= 3.0) picn = 64;
 else picn = 128;
 if (CPUmanufacturer.indexOf("Intel") != -1) CPUiconsrc.src = "images/intel" + picn + ".png";
 else if (CPUmanufacturer.indexOf("AMD") != -1) CPUiconsrc.src = "images/amd" + picn + ".png";
 else CPUiconsrc.src = "images/via" + picn + ".png";

 //top section
 gtitle.style.top = parseInt(6 * size);
 gline.style.top = parseInt(16 * size);
 memtit.style.top = parseInt(26 * size);
 memscr.style.top = parseInt(26 * size);
 memused.style.top = parseInt(26 * size);
 memu.style.top = parseInt(40 * size);
 memf.style.top = parseInt(40 * size);
 memt.style.top = parseInt(40 * size);
 ram1.style.top = parseInt(50 * size);
 ram2.style.top = parseInt(50 * size);
 ram3.style.top = parseInt(50 * size);
 page1.style.top = parseInt(60 * size);
 page2.style.top = parseInt(60 * size);
 page3.style.top = parseInt(60 * size);
 all1.style.top = parseInt(70 * size);
 all2.style.top = parseInt(70 * size);
 all3.style.top = parseInt(70 * size);
 memram.style.top = parseInt(80 * size);
 usgram.style.top = parseInt(80 * size);
 mempage.style.top = parseInt(90 * size);
 usgpage.style.top = parseInt(90 * size);
 memall.style.top = parseInt(100 * size);
 usgall.style.top = parseInt(100 * size);
 barbackram.style.top = parseInt(85 * size);
 barram.style.top = parseInt(85 * size);
 barbackpage.style.top = parseInt(95 * size);
 barpage.style.top = parseInt(95 * size);
 barbackall.style.top = parseInt(105 * size);
 barall.style.top = parseInt(105 * size);
 memgraph.style.top = parseInt(114 * size);
 memlinesx.style.top = parseInt(116 * size);
 memlinesy.style.top = parseInt(116 * size);
 memborderRAM.style.top = parseInt(116 * size);
 memborderPAGE.style.top = parseInt(116 * size);
 memborderAll.style.top = parseInt(116 * size);
 memborder.style.top = parseInt(116 * size);
 RAMgraph.style.top = parseInt(116 * size);
 Pagegraph.style.top = parseInt(116 * size);
 VIRgraph.style.top = parseInt(116 * size);
 rect1.style.top = parseInt(116 * size);
 rect2.style.top = parseInt(116 * size);
 CPUmodel.style.top = parseInt(150 * size);
 core.style.top = parseInt(173 * size);
 cpuusg.style.top = parseInt(184 * size);
 CPUicon.style.top = parseInt(182 * size);
 cpuspeed.style.top = parseInt(173 * size);
 cpuused.style.top = parseInt(184 * size);

 cRAMgraph.style.top = newtopcoord;
 cPagegraph.style.top = newtopcoord;
 cVIRgraph.style.top = newtopcoord;
 CPUgraph.style.top = newtopcoord - parseInt(2 * size);
 freqscalebg.style.top = newtopcoord - parseInt(3 * size);
 freqscalenum.style.top = newtopcoord - parseInt(3 * size);
 CPUlinesx.style.top = newtopcoord;
 CPUlinesy.style.top = newtopcoord;
 CPUborder.style.top = newtopcoord;
 htmark.style.top = adstopcoord;
 advertis.style.top = adstopcoord;
 versionnumber.style.top = adstopcoord;

 for (var i=1; i<=maxCPUcoressupport; i++){
  //top section
  document.getElementById("namCore" + i).style.top = parseInt((185 + i * 10) * size);
  document.getElementById("namCore" + i + "p").style.top = parseInt((185 + i * 10) * size);
  document.getElementById("usgCore" + i).style.top = parseInt((185 + i * 10) * size);
  document.getElementById("barback" + i).style.top = parseInt((189 + i * 10) * size);
  document.getElementById("cbar" + i).style.top = parseInt((189 + i * 10) * size);
  document.getElementById("WarningCore" + i).style.top = parseInt((189 + i * 10) * size);
  document.getElementById("core" + i + "graph").style.top = newtopcoord;
  //left section
  document.getElementById("namCore" + i).style.left = parseInt(61 * size);
  document.getElementById("namCore" + i + "p").style.left = parseInt(91 * size);
  document.getElementById("barback" + i).style.left = parseInt(9 * size);
  document.getElementById("cbar" + i).style.left = parseInt(9 * size);
  document.getElementById("WarningCore" + i).style.left = parseInt(9 * size);
  document.getElementById("core" + i + "graph").style.left = parseInt(9 * size);
  //font-size section
  document.getElementById("namCore" + i).style.fontSize = parseInt(9 * size);
  document.getElementById("usgCore" + i).style.fontSize = parseInt(9 * size);
  //width section
  document.getElementById("usgCore" + i).style.width = parseInt(123 * size);
  document.getElementById("imgback" + i).style.width = parseInt(50 * size);
  document.getElementById("WarningImg" + i).style.width = parseInt(50 * size);
  document.getElementById("core" + i + "graph").style.width = parseInt(110 * size);
  document.getElementById("core" + i + "graph").strokeweight = graphlinewidth;
  //height section
  document.getElementById("barback" + i).style.height = parseInt(6 * size);
  document.getElementById("cbar" + i).style.height = parseInt(6 * size);
  document.getElementById("imgbar" + i).style.height = parseInt(6 * size);
  document.getElementById("WarningImg" + i).style.height = parseInt(6 * size);
  document.getElementById("core" + i + "graph").style.height = parseInt(30 * size);
 }

 document.getElementById("core0graph").style.top = newtopcoord;
 document.getElementById("core0graph").style.left = parseInt(9 * size);
 document.getElementById("core0graph").style.width = parseInt(110 * size);
 document.getElementById("core0graph").strokeweight = graphlinewidth;
 document.getElementById("core0graph").style.height = parseInt(30 * size);

 //color settings
 gtitle.style.color = cTitle;
 memtit.style.color = cMemUsage;
 memused.style.color = cMemUsage;
 memu.style.color = cMemMenu;
 memf.style.color = cMemMenu;
 memt.style.color = cMemMenu;
 ram1.style.color = cMemRam;
 ram2.style.color = cMemRam;
 ram3.style.color = cMemRam;
 memram.style.color = cMemRam;
 usgram.style.color = cMemRam;
 barram.style.background = cMemRam;
 memgraph.style.background = cFillGraph;
 rect1.fillcolor = cFillGraph;
 rect2.fillcolor = cFillGraph;
 rect1.strokecolor = cFillGraph;
 rect2.strokecolor = cFillGraph;
 CPUgraph.style.background = cFillGraph;
 freqscalebg.style.background = cFillGraph;
 freqscalenum.style.color = cCoreCpuspeed;
 RAMgraph.strokecolor = cMemRam;
 cRAMgraph.strokecolor = cMemRam;
 page1.style.color = cMemPage;
 page2.style.color = cMemPage;
 page3.style.color = cMemPage;
 mempage.style.color = cMemPage;
 usgpage.style.color = cMemPage;
 barpage.style.background = cMemPage;
 Pagegraph.strokecolor = cMemPage;
 cPagegraph.strokecolor = cMemPage;
 all1.style.color = cMemAll;
 all2.style.color = cMemAll;
 all3.style.color = cMemAll;
 memall.style.color = cMemAll;
 usgall.style.color = cMemAll;
 barall.style.background = cMemAll;
 VIRgraph.strokecolor = cMemAll;
 cVIRgraph.strokecolor = cMemAll;
 CPUmodel.style.color = cCPUmodel;
 core.style.color = cCoreCpuspeed;
 cpuspeed.style.color = cCoreCpuspeed;
 cpuusg.style.color = cCpuused;
 cpuused.style.color = cCpuused;
 copyright.style.color = cCopyright;
 htmark.style.color = cMemMenu;
 versionnumber.style.color = cVersion;

 switch (checkcolormode){
  case 1:
   for (var i=1; i<=maxCPUcoressupport; i++){
    document.getElementById("namCore" + i).style.color = cCpuAllinone;
    document.getElementById("usgCore" + i).style.color = cCpuAllinone;
    document.getElementById("cbar" + i).style.background = cCpuAllinone;
    document.getElementById("core" + i + "graph").strokecolor = cCpuAllinone;
   }
   break;

  case 2:
   for (var i=1; i<=maxCPUcoressupport; i++){
    document.getElementById("namCore" + i).style.color = CoreColor[i];
    document.getElementById("usgCore" + i).style.color = CoreColor[i];
    document.getElementById("cbar" + i).style.background = CoreColor[i];
    document.getElementById("core" + i + "graph").strokecolor = CoreColor[i];
   }
   break;

  default:
   for (var i=1; i<=maxCPUcoressupport; i++){
    document.getElementById("namCore" + i).style.color = defaultcorecol[i-1];
    document.getElementById("usgCore" + i).style.color = defaultcorecol[i-1];
    document.getElementById("cbar" + i).style.background = defaultcorecol[i-1];
    document.getElementById("core" + i + "graph").strokecolor = defaultcorecol[i-1];
   }
   break;
 }
 document.getElementById("core0graph").strokecolor = document.getElementById("core1graph").strokecolor;

 //left section
 memtit.style.left = parseInt(25* size);
 memscr.style.left = parseInt(7 * size);
 memu.style.left = parseInt(13 * size);
 memf.style.left =  parseInt(56 * size);
 memt.style.left = parseInt(93 * size);
 ram1.style.left = parseInt(3 * size);
 ram2.style.left = parseInt(43 * size);
 ram3.style.left = parseInt(83 * size);
 page1.style.left = parseInt(3 * size);
 page2.style.left = parseInt(43 * size);
 page3.style.left = parseInt(83 * size);
 all1.style.left = parseInt(3 * size);
 all2.style.left = parseInt(43 * size);
 all3.style.left = parseInt(83 * size);
 memram.style.left = parseInt(82 * size);
 mempage.style.left = parseInt(82 * size);
 memall.style.left = parseInt(82 * size);
 barbackram.style.left = parseInt(9 * size);
 barram.style.left = parseInt(9 * size);
 barbackpage.style.left = parseInt(9 * size);
 barpage.style.left = parseInt(9 * size);
 barbackall.style.left = parseInt(9 * size);
 barall.style.left = parseInt(9 * size);
 memgraph.style.left = parseInt(5 * size);
 memlinesx.style.left = parseInt(9 * size);
 memlinesy.style.left = parseInt(9 * size);
 memborderRAM.style.left = parseInt(9 * size);
 memborderPAGE.style.left = parseInt(47 * size);
 memborderAll.style.left = parseInt(85 * size);
 memborder.style.left = parseInt(9 * size);
 rect1.style.left = parseInt(45 * size);
 rect2.style.left = parseInt(83 * size);
 CPUmodel.style.left = parseInt(9 * size);
 core.style.left = !CoreTempgetinfoflag ? parseInt(29 * size) : parseInt(9 * size);
 cpuusg.style.left = parseInt(29 * size);
 CPUicon.style.left = parseInt(7 * size);
 cRAMgraph.style.left = parseInt(9 * size);
 cPagegraph.style.left = parseInt(9 * size);
 cVIRgraph.style.left = parseInt(9 * size);
 CPUgraph.style.left  = parseInt(5 * size);
 freqscalebg.style.left = parseInt(8 * size);
 freqscalenum.style.left = parseInt(9 * size);
 CPUlinesx.style.left = parseInt(9 * size);
 CPUlinesy.style.left = parseInt(9 * size);
 CPUborder.style.left = parseInt(9 * size);
 advertis.style.left = parseInt(10 * size);

//font-size section
 gtitle.style.fontSize = parseInt(12 * size);
 memtit.style.fontSize = parseInt(11 * size);
 memused.style.fontSize = parseInt(11 * size);
 memu.style.fontSize = parseInt(9 * size);
 memf.style.fontSize = parseInt(9 * size);
 memt.style.fontSize = parseInt(9 * size);
 ram1.style.fontSize = parseInt(9 * size);
 ram2.style.fontSize = parseInt(9 * size);
 ram3.style.fontSize = parseInt(9 * size);
 page1.style.fontSize = parseInt(9 * size);
 page2.style.fontSize = parseInt(9 * size);
 page3.style.fontSize = parseInt(9 * size);
 all1.style.fontSize = parseInt(9 * size);
 all2.style.fontSize = parseInt(9 * size);
 all3.style.fontSize = parseInt(9 * size);
 memram.style.fontSize = parseInt(9 * size);
 usgram.style.fontSize = parseInt(9 * size);
 mempage.style.fontSize = parseInt(9 * size);
 usgpage.style.fontSize = parseInt(9 * size);
 memall.style.fontSize = parseInt(9 * size);
 usgall.style.fontSize = parseInt(9 * size);
 CPUmodel.style.fontSize = parseInt(9 * size);
 freqscalebg.style.fontSize = parseInt(9 * size);
 freqscalenum.style.fontSize = parseInt(9 * size);
 core.style.fontSize = !CoreTempgetinfoflag ? parseInt(11 * size) : parseInt(9 * size);
 cpuusg.style.fontSize = parseInt(11 * size);
 cpuspeed.style.fontSize = !CoreTempgetinfoflag ? parseInt(11 * size) : parseInt(9 * size);
 cpuused.style.fontSize = parseInt(11 * size);
 advertis.style.fontSize = parseInt(10 * size);
 htmark.style.fontSize = parseInt(8 * size);
 versionnumber.style.fontSize = parseInt(9 * size);
 autoapdater.style.fontSize = parseInt(9 * size);

 //width section
 memused.style.width = parseInt(123 * size);
 ram1.style.width = parseInt(40 * size);
 ram2.style.width = parseInt(40 * size);
 ram3.style.width = parseInt(40 * size);
 page1.style.width = parseInt(40 * size);
 page2.style.width = parseInt(40 * size);
 page3.style.width = parseInt(40 * size);
 all1.style.width = parseInt(40 * size);
 all2.style.width = parseInt(40 * size);
 all3.style.width = parseInt(40 * size);
 usgram.style.width = parseInt(123 * size);
 usgpage.style.width = parseInt(123 * size);
 usgall.style.width = parseInt(123 * size);
 backbarram.style.width = parseInt(70 * size);
 backbarpage.style.width = parseInt(70 * size);
 backbarall.style.width = parseInt(70 * size);
 memgraph.style.width = parseInt(120 * size);
 memlinesx.style.width = parseInt(111 * size);
 memlinesy.style.width = parseInt(111 * size);
 memborderRAM.style.width = parseInt(35 * size);
 memborderPAGE.style.width = parseInt(35 * size);
 memborderAll.style.width = parseInt(35 * size);
 memborder.style.width = parseInt(111 * size);
 RAMgraph.style.width = parseInt(35 * size);
 RAMgraph.strokeweight = graphlinewidth;
 Pagegraph.style.width = parseInt(35 * size);
 Pagegraph.strokeweight = graphlinewidth;
 VIRgraph.style.width = parseInt(35 * size);
 VIRgraph.strokeweight = graphlinewidth;
 rect1.style.width = parseInt(Math.ceil(1 * size));
 rect2.style.width = parseInt(Math.ceil(1 * size));
 CPUmodel.style.width = parseInt(118 * size);
 cpuspeed.style.width = parseInt(123 * size);
 cpuused.style.width = parseInt(123 * size);
 cRAMgraph.style.width = parseInt(110 * size);
 cRAMgraph.strokeweight = graphlinewidth;
 cPagegraph.style.width = parseInt(110 * size);
 cPagegraph.strokeweight = graphlinewidth;
 cVIRgraph.style.width = parseInt(110 * size);
 cVIRgraph.strokeweight = graphlinewidth;
 CPUgraph.style.width = parseInt(120 * size);
 freqscalebg.style.width = parseInt(45 * size);
 freqscalebg.style.borderWidth = parseInt(1 * size);
 CPUlinesx.style.width = parseInt(110 * size);
 CPUlinesy.style.width = parseInt(110 * size);
 CPUborder.style.width = parseInt(110 * size);
 htmark.style.width = parseInt(98 * size);
 versionnumber.style.width = parseInt(120 * size);

 //height section
 backbarram.style.height = parseInt(6 * size);
 barram.style.height = parseInt(6 * size);
 imgbarram.style.height = parseInt(6 * size);
 backbarpage.style.height = parseInt(6 * size);
 barpage.style.height = parseInt(6 * size);
 imgbarpage.style.height = parseInt(6 * size);
 backbarall.style.height = parseInt(6 * size);
 barall.style.height = parseInt(6 * size);
 imgbarall.style.height = parseInt(6 * size);
 memgraph.style.height = parseInt(36 * size);
 memlinesx.style.height = parseInt(30 * size);
 memlinesy.style.height = parseInt(30 * size);
 memborderRAM.style.height = parseInt(30 * size);
 memborderPAGE.style.height = parseInt(30 * size);
 memborderAll.style.height = parseInt(30 * size);
 memborder.style.height = parseInt(30 * size);
 RAMgraph.style.height = parseInt(30 * size);
 Pagegraph.style.height = parseInt(30 * size);
 VIRgraph.style.height = parseInt(30 * size);
 rect1.style.height = parseInt(30 * size);
 rect2.style.height = parseInt(30 * size);
 cRAMgraph.style.height = parseInt(30 * size);
 cPagegraph.style.height = parseInt(30 * size);
 cVIRgraph.style.height = parseInt(30 * size);
 CPUmodel.style.height = parseInt(24 * size);
 freqscalebg.style.height = parseInt(13 * size);
 CPUgraph.style.height = parseInt(36 * size);
 CPUlinesx.style.height = parseInt(30 * size);
 CPUlinesy.style.height = parseInt(30 * size);
 CPUborder.style.height = parseInt(30 * size);

 //picture section
 memscr.style.width = parseInt(16 * size);
 memscr.style.height = parseInt(16 * size);
 CPUiconsrc.style.width = parseInt(19 * size);
 CPUiconsrc.style.height = parseInt(19 * size);
 temperatureimg.style.width = parseInt(35 * size);
 temperatureimg.style.height = parseInt(35 * size);

 gtitle.style.visibility = "visible";
 gline.style.visibility = "visible";
 memtit.style.visibility = "visible";
 memscr.style.visibility = "visible";
 memused.style.visibility = "visible";
 memu.style.visibility = "visible";
 memf.style.visibility = "visible";
 memt.style.visibility = "visible";
 ram1.style.visibility = "visible";
 ram2.style.visibility = "visible";
 ram3.style.visibility = "visible";
 page1.style.visibility = "visible";
 page2.style.visibility = "visible";
 page3.style.visibility = "visible";
 all1.style.visibility = "visible";
 all2.style.visibility = "visible";
 all3.style.visibility = "visible";
 memram.style.visibility = "visible";
 usgram.style.visibility = "visible";
 mempage.style.visibility = "visible";
 usgpage.style.visibility = "visible";
 memall.style.visibility = "visible";
 usgall.style.visibility = "visible";
 barbackram.style.visibility = "visible";
 barram.style.visibility = "visible";
 barbackpage.style.visibility = "visible";
 barpage.style.visibility = "visible";
 barbackall.style.visibility = "visible";
 barall.style.visibility = "visible";
 memgraph.style.visibility = "visible";
 memlinesx.style.visibility = "visible";
 memlinesy.style.visibility = "visible";
 memborderRAM.style.visibility = "visible";
 memborderPAGE.style.visibility = "visible";
 memborderAll.style.visibility = "visible";
 memborder.style.visibility = "visible";
 RAMgraph.style.visibility = "visible";
 Pagegraph.style.visibility = "visible";
 VIRgraph.style.visibility = "visible";
 memborderRAM.style.visibility = "visible";
 memborderPAGE.style.visibility = "visible";
 rect1.style.visibility = "visible";
 rect2.style.visibility = "visible";
 CPUgraph.style.visibility = "visible";
 freqscalebg.style.visibility = "visible";
 freqscalenum.style.visibility = "visible";
 CPUlinesx.style.visibility = "visible";
 CPUlinesy.style.visibility = "visible";
 CPUborder.style.visibility = "visible";
 CPUmodel.style.visibility = "visible";
 core.style.visibility = "visible";
 cpuspeed.style.visibility = "visible";
 cpuusg.style.visibility = "visible";
 cpuused.style.visibility = "visible";
 CPUicon.style.visibility = "visible";
 autoapdater.style.visibility = "hidden";

 for (var i=1; i<=maxCPUcoressupport; i++){
  document.getElementById("core" + i + "graph").style.visibility = "visible";
  document.getElementById("WarningCore" + i).style.visibility = "hidden";
 }
 document.getElementById("core0graph").style.visibility = "hidden";

 hideunhidegraphs();
 setupcombinedallgraph();

 if (!graphtemperature) temperatureimg.style.visibility = "hidden";
 else temperatureimg.style.visibility = "visible";

 if (!cyclegraphflag){
  curgraph = 0;
  forcyclegraph.style.cursor = "default";
 }
 else{
  curgraph = 1;
  forcyclegraph.style.cursor = "pointer";
 }

 var k;
 var z = 0;

 if (hidetitleflag){
  //title
  gtitle.style.visibility = "hidden";
  gline.style.visibility = "hidden";

  k=memtit.style.top;
  memtit.style.top = parseInt(k)-parseInt(20 * size);
  k=memscr.style.top;
  memscr.style.top = parseInt(k)-parseInt(20 * size);
  k=memused.style.top;
  memused.style.top = parseInt(k)-parseInt(20 * size);
  k=memu.style.top;
  memu.style.top = parseInt(k)-parseInt(20 * size);
  k=memf.style.top;
  memf.style.top = parseInt(k)-parseInt(20 * size);
  k=memt.style.top;
  memt.style.top = parseInt(k)-parseInt(20 * size);
  k=ram1.style.top;
  ram1.style.top = parseInt(k)-parseInt(20 * size);
  k=ram2.style.top;
  ram2.style.top = parseInt(k)-parseInt(20 * size);
  k=ram3.style.top;
  ram3.style.top = parseInt(k)-parseInt(20 * size);
  k=page1.style.top;
  page1.style.top = parseInt(k)-parseInt(20 * size);
  k=page2.style.top;
  page2.style.top = parseInt(k)-parseInt(20 * size);
  k=page3.style.top;
  page3.style.top = parseInt(k)-parseInt(20 * size);
  k=all1.style.top;
  all1.style.top = parseInt(k)-parseInt(20 * size);
  k=all2.style.top;
  all2.style.top = parseInt(k)-parseInt(20 * size);
  k=all3.style.top;
  all3.style.top = parseInt(k)-parseInt(20 * size);
  k=memram.style.top;
  memram.style.top = parseInt(k)-parseInt(20 * size);
  k=usgram.style.top;
  usgram.style.top = parseInt(k)-parseInt(20 * size);
  k=mempage.style.top;
  mempage.style.top = parseInt(k)-parseInt(20 * size);
  k=usgpage.style.top;
  usgpage.style.top = parseInt(k)-parseInt(20 * size);
  k=memall.style.top;
  memall.style.top = parseInt(k)-parseInt(20 * size);
  k=usgall.style.top;
  usgall.style.top = parseInt(k)-parseInt(20 * size);
  k=barbackram.style.top;
  barbackram.style.top = parseInt(k)-parseInt(20 * size);
  k=barram.style.top;
  barram.style.top = parseInt(k)-parseInt(20 * size);
  k=barbackpage.style.top;
  barbackpage.style.top = parseInt(k)-parseInt(20 * size);
  k=barpage.style.top;
  barpage.style.top = parseInt(k)-parseInt(20 * size);
  k=barbackall.style.top;
  barbackall.style.top = parseInt(k)-parseInt(20 * size);
  k=barall.style.top;
  barall.style.top = parseInt(k)-parseInt(20 * size);
  k=memgraph.style.top;
  memgraph.style.top = parseInt(k)-parseInt(20 * size);
  k=memlinesx.style.top;
  memlinesx.style.top = parseInt(k)-parseInt(20 * size);
  k=memlinesy.style.top;
  memlinesy.style.top = parseInt(k)-parseInt(20 * size);
  k=memborderRAM.style.top;
  memborderRAM.style.top = parseInt(k)-parseInt(20 * size);
  k=memborderPAGE.style.top;
  memborderPAGE.style.top = parseInt(k)-parseInt(20 * size);
  k=memborderAll.style.top;
  memborderAll.style.top = parseInt(k)-parseInt(20 * size);
  k=memborder.style.top;
  memborder.style.top = parseInt(k)-parseInt(20 * size);
  k=RAMgraph.style.top;
  RAMgraph.style.top = parseInt(k)-parseInt(20 * size);
  k=Pagegraph.style.top;
  Pagegraph.style.top = parseInt(k)-parseInt(20 * size);
  k=VIRgraph.style.top;
  VIRgraph.style.top = parseInt(k)-parseInt(20 * size);
  k=rect1.style.top;
  rect1.style.top = parseInt(k)-parseInt(20 * size);
  k=rect2.style.top;
  rect2.style.top = parseInt(k)-parseInt(20 * size);

  k=CPUmodel.style.top;
  CPUmodel.style.top = parseInt(k)-parseInt(20 * size);
  k=core.style.top;
  core.style.top = parseInt(k)-parseInt(20 * size);
  k=cpuusg.style.top;
  cpuusg.style.top = parseInt(k)-parseInt(20 * size);
  k=CPUicon.style.top;
  CPUicon.style.top = parseInt(k)-parseInt(20 * size);
  k=cpuspeed.style.top;
  cpuspeed.style.top = parseInt(k)-parseInt(20 * size);
  k=cpuused.style.top;
  cpuused.style.top = parseInt(k)-parseInt(20 * size);

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(20 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(20 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(20 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(20 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(20 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(20 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(20 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(20 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(20 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(20 * size);
   k=document.getElementById("namCore" + i).style.top;
   document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(20 * size);
   document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(20 * size);
   k=document.getElementById("usgCore" + i).style.top;
   document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(20 * size);
   k=document.getElementById("barback" + i).style.top;
   document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(20 * size);
   k=document.getElementById("cbar" + i).style.top;
   document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(20 * size);
   k=document.getElementById("WarningCore" + i).style.top;
   document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(20 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(20 * size);

  factheight -= 20;
  z += 20;
 }

 if (hidememnusedflag){
  //MEM usage
  memtit.style.visibility = "hidden";
  memscr.style.visibility = "hidden";
  memused.style.visibility = "hidden";

  k=memu.style.top;
  memu.style.top = parseInt(k)-parseInt(16 * size);
  k=memf.style.top;
  memf.style.top = parseInt(k)-parseInt(16 * size);
  k=memt.style.top;
  memt.style.top = parseInt(k)-parseInt(16 * size);
  k=ram1.style.top;
  ram1.style.top = parseInt(k)-parseInt(16 * size);
  k=ram2.style.top;
  ram2.style.top = parseInt(k)-parseInt(16 * size);
  k=ram3.style.top;
  ram3.style.top = parseInt(k)-parseInt(16 * size);
  k=page1.style.top;
  page1.style.top = parseInt(k)-parseInt(16 * size);
  k=page2.style.top;
  page2.style.top = parseInt(k)-parseInt(16 * size);
  k=page3.style.top;
  page3.style.top = parseInt(k)-parseInt(16 * size);
  k=all1.style.top;
  all1.style.top = parseInt(k)-parseInt(16 * size);
  k=all2.style.top;
  all2.style.top = parseInt(k)-parseInt(16 * size);
  k=all3.style.top;
  all3.style.top = parseInt(k)-parseInt(16 * size);
  k=memram.style.top;
  memram.style.top = parseInt(k)-parseInt(16 * size);
  k=usgram.style.top;
  usgram.style.top = parseInt(k)-parseInt(16 * size);
  k=mempage.style.top;
  mempage.style.top = parseInt(k)-parseInt(16 * size);
  k=usgpage.style.top;
  usgpage.style.top = parseInt(k)-parseInt(16 * size);
  k=memall.style.top;
  memall.style.top = parseInt(k)-parseInt(16 * size);
  k=usgall.style.top;
  usgall.style.top = parseInt(k)-parseInt(16 * size);
  k=barbackram.style.top;
  barbackram.style.top = parseInt(k)-parseInt(16 * size);
  k=barram.style.top;
  barram.style.top = parseInt(k)-parseInt(16 * size);
  k=barbackpage.style.top;
  barbackpage.style.top = parseInt(k)-parseInt(16 * size);
  k=barpage.style.top;
  barpage.style.top = parseInt(k)-parseInt(16 * size);
  k=barbackall.style.top;
  barbackall.style.top = parseInt(k)-parseInt(16 * size);
  k=barall.style.top;
  barall.style.top = parseInt(k)-parseInt(16 * size);
  k=memgraph.style.top;
  memgraph.style.top = parseInt(k)-parseInt(16 * size);
  k=memlinesx.style.top;
  memlinesx.style.top = parseInt(k)-parseInt(16 * size);
  k=memlinesy.style.top;
  memlinesy.style.top = parseInt(k)-parseInt(16 * size);
  k=memborderRAM.style.top;
  memborderRAM.style.top = parseInt(k)-parseInt(16 * size);
  k=memborderPAGE.style.top;
  memborderPAGE.style.top = parseInt(k)-parseInt(16 * size);
  k=memborderAll.style.top;
  memborderAll.style.top = parseInt(k)-parseInt(16 * size);
  k=memborder.style.top;
  memborder.style.top = parseInt(k)-parseInt(16 * size);
  k=RAMgraph.style.top;
  RAMgraph.style.top = parseInt(k)-parseInt(16 * size);
  k=Pagegraph.style.top;
  Pagegraph.style.top = parseInt(k)-parseInt(16 * size);
  k=VIRgraph.style.top;
  VIRgraph.style.top = parseInt(k)-parseInt(16 * size);
  k=rect1.style.top;
  rect1.style.top = parseInt(k)-parseInt(16 * size);
  k=rect2.style.top;
  rect2.style.top = parseInt(k)-parseInt(16 * size);

  k=CPUmodel.style.top;
  CPUmodel.style.top = parseInt(k)-parseInt(16 * size);
  k=core.style.top;
  core.style.top = parseInt(k)-parseInt(16 * size);
  k=cpuusg.style.top;
  cpuusg.style.top = parseInt(k)-parseInt(16 * size);
  k=CPUicon.style.top;
  CPUicon.style.top = parseInt(k)-parseInt(16 * size);
  k=cpuspeed.style.top;
  cpuspeed.style.top = parseInt(k)-parseInt(16 * size);
  k=cpuused.style.top;
  cpuused.style.top = parseInt(k)-parseInt(16 * size);

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(16 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(16 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(16 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(16 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(16 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(16 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(16 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(16 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(16 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(16 * size);
   k=document.getElementById("namCore" + i).style.top;
   document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(16 * size);
   document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(16 * size);
   k=document.getElementById("usgCore" + i).style.top;
   document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(16 * size);
   k=document.getElementById("barback" + i).style.top;
   document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(16 * size);
   k=document.getElementById("cbar" + i).style.top;
   document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(16 * size);
   k=document.getElementById("WarningCore" + i).style.top;
   document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(16 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(16 * size);

  factheight -= 16;
  z += 16;
 }

 if (hidememnumbersflag){
  //MEM Numbers
  memu.style.visibility = "hidden";
  memf.style.visibility = "hidden";
  memt.style.visibility = "hidden";
  ram1.style.visibility = "hidden";
  ram2.style.visibility = "hidden";
  ram3.style.visibility = "hidden";
  page1.style.visibility = "hidden";
  page2.style.visibility = "hidden";
  page3.style.visibility = "hidden";
  all1.style.visibility = "hidden";
  all2.style.visibility = "hidden";
  all3.style.visibility = "hidden";

  k=memram.style.top;
  memram.style.top = parseInt(k)-parseInt(40 * size);
  k=usgram.style.top;
  usgram.style.top = parseInt(k)-parseInt(40 * size);
  k=mempage.style.top;
  mempage.style.top = parseInt(k)-parseInt(40 * size);
  k=usgpage.style.top;
  usgpage.style.top = parseInt(k)-parseInt(40 * size);
  k=memall.style.top;
  memall.style.top = parseInt(k)-parseInt(40 * size);
  k=usgall.style.top;
  usgall.style.top = parseInt(k)-parseInt(40 * size);
  k=barbackram.style.top;
  barbackram.style.top = parseInt(k)-parseInt(40 * size);
  k=barram.style.top;
  barram.style.top = parseInt(k)-parseInt(40 * size);
  k=barbackpage.style.top;
  barbackpage.style.top = parseInt(k)-parseInt(40 * size);
  k=barpage.style.top;
  barpage.style.top = parseInt(k)-parseInt(40 * size);
  k=barbackall.style.top;
  barbackall.style.top = parseInt(k)-parseInt(40 * size);
  k=barall.style.top;
  barall.style.top = parseInt(k)-parseInt(40 * size);
  k=memgraph.style.top;
  memgraph.style.top = parseInt(k)-parseInt(40 * size);
  k=memlinesx.style.top;
  memlinesx.style.top = parseInt(k)-parseInt(40 * size);
  k=memlinesy.style.top;
  memlinesy.style.top = parseInt(k)-parseInt(40 * size);
  k=memborderRAM.style.top;
  memborderRAM.style.top = parseInt(k)-parseInt(40 * size);
  k=memborderPAGE.style.top;
  memborderPAGE.style.top = parseInt(k)-parseInt(40 * size);
  k=memborderAll.style.top;
  memborderAll.style.top = parseInt(k)-parseInt(40 * size);
  k=memborder.style.top;
  memborder.style.top = parseInt(k)-parseInt(40 * size);
  k=RAMgraph.style.top;
  RAMgraph.style.top = parseInt(k)-parseInt(40 * size);
  k=Pagegraph.style.top;
  Pagegraph.style.top = parseInt(k)-parseInt(40 * size);
  k=VIRgraph.style.top;
  VIRgraph.style.top = parseInt(k)-parseInt(40 * size);
  k=rect1.style.top;
  rect1.style.top = parseInt(k)-parseInt(40 * size);
  k=rect2.style.top;
  rect2.style.top = parseInt(k)-parseInt(40 * size);

  k=CPUmodel.style.top;
  CPUmodel.style.top = parseInt(k)-parseInt(40 * size);
  k=core.style.top;
  core.style.top = parseInt(k)-parseInt(40 * size);
  k=cpuusg.style.top;
  cpuusg.style.top = parseInt(k)-parseInt(40 * size);
  k=CPUicon.style.top;
  CPUicon.style.top = parseInt(k)-parseInt(40 * size);
  k=cpuspeed.style.top;
  cpuspeed.style.top = parseInt(k)-parseInt(40 * size);
  k=cpuused.style.top;
  cpuused.style.top = parseInt(k)-parseInt(40 * size);

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(40 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(40 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(40 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(40 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(40 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(40 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(40 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(40 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(40 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(40 * size);
   k=document.getElementById("namCore" + i).style.top;
   document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(40 * size);
   document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(40 * size);
   k=document.getElementById("usgCore" + i).style.top;
   document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(40 * size);
   k=document.getElementById("barback" + i).style.top;
   document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(40 * size);
   k=document.getElementById("cbar" + i).style.top;
   document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(40 * size);
   k=document.getElementById("WarningCore" + i).style.top;
   document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(40 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(40 * size);

  factheight -= 40;
  z += 40;
 }
 else{
  if (hideRAMnumbersflag){
   //RAM usage
   ram1.style.visibility = "hidden";
   ram2.style.visibility = "hidden";
   ram3.style.visibility = "hidden";

   k=page1.style.top;
   page1.style.top = parseInt(k)-parseInt(10 * size);
   k=page2.style.top;
   page2.style.top = parseInt(k)-parseInt(10 * size);
   k=page3.style.top;
   page3.style.top = parseInt(k)-parseInt(10 * size);
   k=all1.style.top;
   all1.style.top = parseInt(k)-parseInt(10 * size);
   k=all2.style.top;
   all2.style.top = parseInt(k)-parseInt(10 * size);
   k=all3.style.top;
   all3.style.top = parseInt(k)-parseInt(10 * size);
   k=memram.style.top;
   memram.style.top = parseInt(k)-parseInt(10 * size);
   k=usgram.style.top;
   usgram.style.top = parseInt(k)-parseInt(10 * size);
   k=mempage.style.top;
   mempage.style.top = parseInt(k)-parseInt(10 * size);
   k=usgpage.style.top;
   usgpage.style.top = parseInt(k)-parseInt(10 * size);
   k=memall.style.top;
   memall.style.top = parseInt(k)-parseInt(10 * size);
   k=usgall.style.top;
   usgall.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackram.style.top;
   barbackram.style.top = parseInt(k)-parseInt(10 * size);
   k=barram.style.top;
   barram.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackpage.style.top;
   barbackpage.style.top = parseInt(k)-parseInt(10 * size);
   k=barpage.style.top;
   barpage.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackall.style.top;
   barbackall.style.top = parseInt(k)-parseInt(10 * size);
   k=barall.style.top;
   barall.style.top = parseInt(k)-parseInt(10 * size);
   k=memgraph.style.top;
   memgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesx.style.top;
   memlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesy.style.top;
   memlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderRAM.style.top;
   memborderRAM.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderPAGE.style.top;
   memborderPAGE.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderAll.style.top;
   memborderAll.style.top = parseInt(k)-parseInt(10 * size);
   k=memborder.style.top;
   memborder.style.top = parseInt(k)-parseInt(10 * size);
   k=RAMgraph.style.top;
   RAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=Pagegraph.style.top;
   Pagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=VIRgraph.style.top;
   VIRgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=rect1.style.top;
   rect1.style.top = parseInt(k)-parseInt(10 * size);
   k=rect2.style.top;
   rect2.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUmodel.style.top;
   CPUmodel.style.top = parseInt(k)-parseInt(10 * size);
   k=core.style.top;
   core.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuusg.style.top;
   cpuusg.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUicon.style.top;
   CPUicon.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuspeed.style.top;
   cpuspeed.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuused.style.top;
   cpuused.style.top = parseInt(k)-parseInt(10 * size);

   k=cRAMgraph.style.top;
   cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cPagegraph.style.top;
   cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cVIRgraph.style.top;
   cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUgraph.style.top;
   CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalebg.style.top;
   freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalenum.style.top;
   freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesx.style.top;
   CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesy.style.top;
   CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUborder.style.top;
   CPUborder.style.top = parseInt(k)-parseInt(10 * size);

   for (var i=1; i<=maxCPUcoressupport; i++){
    k=document.getElementById("core" + i + "graph").style.top;
    document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("namCore" + i).style.top;
    document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("usgCore" + i).style.top;
    document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("barback" + i).style.top;
    document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("cbar" + i).style.top;
    document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("WarningCore" + i).style.top;
    document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   }
   k=document.getElementById("core0graph").style.top;
   document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

   factheight -= 10;
   z += 10;
  }

  if (hidePAGEnumbersflag){
   //PAGE usage
   page1.style.visibility = "hidden";
   page2.style.visibility = "hidden";
   page3.style.visibility = "hidden";

   k=all1.style.top;
   all1.style.top = parseInt(k)-parseInt(10 * size);
   k=all2.style.top;
   all2.style.top = parseInt(k)-parseInt(10 * size);
   k=all3.style.top;
   all3.style.top = parseInt(k)-parseInt(10 * size);
   k=memram.style.top;
   memram.style.top = parseInt(k)-parseInt(10 * size);
   k=usgram.style.top;
   usgram.style.top = parseInt(k)-parseInt(10 * size);
   k=mempage.style.top;
   mempage.style.top = parseInt(k)-parseInt(10 * size);
   k=usgpage.style.top;
   usgpage.style.top = parseInt(k)-parseInt(10 * size);
   k=memall.style.top;
   memall.style.top = parseInt(k)-parseInt(10 * size);
   k=usgall.style.top;
   usgall.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackram.style.top;
   barbackram.style.top = parseInt(k)-parseInt(10 * size);
   k=barram.style.top;
   barram.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackpage.style.top;
   barbackpage.style.top = parseInt(k)-parseInt(10 * size);
   k=barpage.style.top;
   barpage.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackall.style.top;
   barbackall.style.top = parseInt(k)-parseInt(10 * size);
   k=barall.style.top;
   barall.style.top = parseInt(k)-parseInt(10 * size);
   k=memgraph.style.top;
   memgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesx.style.top;
   memlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesy.style.top;
   memlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderRAM.style.top;
   memborderRAM.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderPAGE.style.top;
   memborderPAGE.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderAll.style.top;
   memborderAll.style.top = parseInt(k)-parseInt(10 * size);
   k=memborder.style.top;
   memborder.style.top = parseInt(k)-parseInt(10 * size);
   k=RAMgraph.style.top;
   RAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=Pagegraph.style.top;
   Pagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=VIRgraph.style.top;
   VIRgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=rect1.style.top;
   rect1.style.top = parseInt(k)-parseInt(10 * size);
   k=rect2.style.top;
   rect2.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUmodel.style.top;
   CPUmodel.style.top = parseInt(k)-parseInt(10 * size);
   k=core.style.top;
   core.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuusg.style.top;
   cpuusg.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUicon.style.top;
   CPUicon.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuspeed.style.top;
   cpuspeed.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuused.style.top;
   cpuused.style.top = parseInt(k)-parseInt(10 * size);

   k=cRAMgraph.style.top;
   cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cPagegraph.style.top;
   cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cVIRgraph.style.top;
   cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUgraph.style.top;
   CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalebg.style.top;
   freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalenum.style.top;
   freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesx.style.top;
   CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesy.style.top;
   CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUborder.style.top;
   CPUborder.style.top = parseInt(k)-parseInt(10 * size);

   for (var i=1; i<=maxCPUcoressupport; i++){
    k=document.getElementById("core" + i + "graph").style.top;
    document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("namCore" + i).style.top;
    document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("usgCore" + i).style.top;
    document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("barback" + i).style.top;
    document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("cbar" + i).style.top;
    document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("WarningCore" + i).style.top;
    document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   }
   k=document.getElementById("core0graph").style.top;
   document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

   factheight -= 10;
   z += 10;
  }

  if (hideALLnumbersflag){
   //ALL usage
   all1.style.visibility = "hidden";
   all2.style.visibility = "hidden";
   all3.style.visibility = "hidden";

   k=memram.style.top;
   memram.style.top = parseInt(k)-parseInt(10 * size);
   k=usgram.style.top;
   usgram.style.top = parseInt(k)-parseInt(10 * size);
   k=mempage.style.top;
   mempage.style.top = parseInt(k)-parseInt(10 * size);
   k=usgpage.style.top;
   usgpage.style.top = parseInt(k)-parseInt(10 * size);
   k=memall.style.top;
   memall.style.top = parseInt(k)-parseInt(10 * size);
   k=usgall.style.top;
   usgall.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackram.style.top;
   barbackram.style.top = parseInt(k)-parseInt(10 * size);
   k=barram.style.top;
   barram.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackpage.style.top;
   barbackpage.style.top = parseInt(k)-parseInt(10 * size);
   k=barpage.style.top;
   barpage.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackall.style.top;
   barbackall.style.top = parseInt(k)-parseInt(10 * size);
   k=barall.style.top;
   barall.style.top = parseInt(k)-parseInt(10 * size);
   k=memgraph.style.top;
   memgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesx.style.top;
   memlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesy.style.top;
   memlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderRAM.style.top;
   memborderRAM.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderPAGE.style.top;
   memborderPAGE.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderAll.style.top;
   memborderAll.style.top = parseInt(k)-parseInt(10 * size);
   k=memborder.style.top;
   memborder.style.top = parseInt(k)-parseInt(10 * size);
   k=RAMgraph.style.top;
   RAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=Pagegraph.style.top;
   Pagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=VIRgraph.style.top;
   VIRgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=rect1.style.top;
   rect1.style.top = parseInt(k)-parseInt(10 * size);
   k=rect2.style.top;
   rect2.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUmodel.style.top;
   CPUmodel.style.top = parseInt(k)-parseInt(10 * size);
   k=core.style.top;
   core.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuusg.style.top;
   cpuusg.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUicon.style.top;
   CPUicon.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuspeed.style.top;
   cpuspeed.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuused.style.top;
   cpuused.style.top = parseInt(k)-parseInt(10 * size);

   k=cRAMgraph.style.top;
   cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cPagegraph.style.top;
   cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cVIRgraph.style.top;
   cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUgraph.style.top;
   CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalebg.style.top;
   freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalenum.style.top;
   freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesx.style.top;
   CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesy.style.top;
   CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUborder.style.top;
   CPUborder.style.top = parseInt(k)-parseInt(10 * size);

   for (var i=1; i<=maxCPUcoressupport; i++){
    k=document.getElementById("core" + i + "graph").style.top;
    document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("namCore" + i).style.top;
    document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("usgCore" + i).style.top;
    document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("barback" + i).style.top;
    document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("cbar" + i).style.top;
    document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("WarningCore" + i).style.top;
    document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   }
   k=document.getElementById("core0graph").style.top;
   document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

   factheight -= 10;
   z += 10;
  }
 }//else

 if (hidemembarsflag){
  //MEM bars
  memram.style.visibility = "hidden";
  usgram.style.visibility = "hidden";
  mempage.style.visibility = "hidden";
  usgpage.style.visibility = "hidden";
  memall.style.visibility = "hidden";
  usgall.style.visibility = "hidden";
  barbackram.style.visibility = "hidden";
  barram.style.visibility = "hidden";
  barbackpage.style.visibility = "hidden";
  barpage.style.visibility = "hidden";
  barbackall.style.visibility = "hidden";
  barall.style.visibility = "hidden";

  k=memgraph.style.top;
  memgraph.style.top = parseInt(k)-parseInt(30 * size);
  k=memlinesx.style.top;
  memlinesx.style.top = parseInt(k)-parseInt(30 * size);
  k=memlinesy.style.top;
  memlinesy.style.top = parseInt(k)-parseInt(30 * size);
  k=memborderRAM.style.top;
  memborderRAM.style.top = parseInt(k)-parseInt(30 * size);
  k=memborderPAGE.style.top;
  memborderPAGE.style.top = parseInt(k)-parseInt(30 * size);
  k=memborderAll.style.top;
  memborderAll.style.top = parseInt(k)-parseInt(30 * size);
  k=memborder.style.top;
  memborder.style.top = parseInt(k)-parseInt(30 * size);
  k=RAMgraph.style.top;
  RAMgraph.style.top = parseInt(k)-parseInt(30 * size);
  k=Pagegraph.style.top;
  Pagegraph.style.top = parseInt(k)-parseInt(30 * size);
  k=VIRgraph.style.top;
  VIRgraph.style.top = parseInt(k)-parseInt(30 * size);
  k=rect1.style.top;
  rect1.style.top = parseInt(k)-parseInt(30 * size);
  k=rect2.style.top;
  rect2.style.top = parseInt(k)-parseInt(30 * size);

  k=CPUmodel.style.top;
  CPUmodel.style.top = parseInt(k)-parseInt(30 * size);
  k=core.style.top;
  core.style.top = parseInt(k)-parseInt(30 * size);
  k=cpuusg.style.top;
  cpuusg.style.top = parseInt(k)-parseInt(30 * size);
  k=CPUicon.style.top;
  CPUicon.style.top = parseInt(k)-parseInt(30 * size);
  k=cpuspeed.style.top;
  cpuspeed.style.top = parseInt(k)-parseInt(30 * size);
  k=cpuused.style.top;
  cpuused.style.top = parseInt(k)-parseInt(30 * size);

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(30 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(30 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(30 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(30 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(30 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(30 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(30 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(30 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(30 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(30 * size);
   k=document.getElementById("namCore" + i).style.top;
   document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(30 * size);
   document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(30 * size);
   k=document.getElementById("usgCore" + i).style.top;
   document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(30 * size);
   k=document.getElementById("barback" + i).style.top;
   document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(30 * size);
   k=document.getElementById("cbar" + i).style.top;
   document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(30 * size);
   k=document.getElementById("WarningCore" + i).style.top;
   document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(30 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(30 * size);

  factheight -= 30;
  z += 30;
 }
 else{
  if (hideRAMbarsflag){
   //RAM bars
   memram.style.visibility = "hidden";
   usgram.style.visibility = "hidden";
   barbackram.style.visibility = "hidden";
   barram.style.visibility = "hidden";

   k=mempage.style.top;
   mempage.style.top = parseInt(k)-parseInt(10 * size);
   k=usgpage.style.top;
   usgpage.style.top = parseInt(k)-parseInt(10 * size);
   k=memall.style.top;
   memall.style.top = parseInt(k)-parseInt(10 * size);
   k=usgall.style.top;
   usgall.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackpage.style.top;
   barbackpage.style.top = parseInt(k)-parseInt(10 * size);
   k=barpage.style.top;
   barpage.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackall.style.top;
   barbackall.style.top = parseInt(k)-parseInt(10 * size);
   k=barall.style.top;
   barall.style.top = parseInt(k)-parseInt(10 * size);
   k=memgraph.style.top;
   memgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesx.style.top;
   memlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesy.style.top;
   memlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderRAM.style.top;
   memborderRAM.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderPAGE.style.top;
   memborderPAGE.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderAll.style.top;
   memborderAll.style.top = parseInt(k)-parseInt(10 * size);
   k=memborder.style.top;
   memborder.style.top = parseInt(k)-parseInt(10 * size);
   k=RAMgraph.style.top;
   RAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=Pagegraph.style.top;
   Pagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=VIRgraph.style.top;
   VIRgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=rect1.style.top;
   rect1.style.top = parseInt(k)-parseInt(10 * size);
   k=rect2.style.top;
   rect2.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUmodel.style.top;
   CPUmodel.style.top = parseInt(k)-parseInt(10 * size);
   k=core.style.top;
   core.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuusg.style.top;
   cpuusg.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUicon.style.top;
   CPUicon.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuspeed.style.top;
   cpuspeed.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuused.style.top;
   cpuused.style.top = parseInt(k)-parseInt(10 * size);

   k=cRAMgraph.style.top;
   cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cPagegraph.style.top;
   cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cVIRgraph.style.top;
   cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUgraph.style.top;
   CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalebg.style.top;
   freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalenum.style.top;
   freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesx.style.top;
   CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesy.style.top;
   CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUborder.style.top;
   CPUborder.style.top = parseInt(k)-parseInt(10 * size);

   for (var i=1; i<=maxCPUcoressupport; i++){
    k=document.getElementById("core" + i + "graph").style.top;
    document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("namCore" + i).style.top;
    document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("usgCore" + i).style.top;
    document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("barback" + i).style.top;
    document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("cbar" + i).style.top;
    document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("WarningCore" + i).style.top;
    document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   }
   k=document.getElementById("core0graph").style.top;
   document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

   factheight -= 10;
   z += 10;
  }

  if (hidePAGEbarsflag){
   //PAGE bars
   mempage.style.visibility = "hidden";
   usgpage.style.visibility = "hidden";
   barbackpage.style.visibility = "hidden";
   barpage.style.visibility = "hidden";

   k=memall.style.top;
   memall.style.top = parseInt(k)-parseInt(10 * size);
   k=usgall.style.top;
   usgall.style.top = parseInt(k)-parseInt(10 * size);
   k=barbackall.style.top;
   barbackall.style.top = parseInt(k)-parseInt(10 * size);
   k=barall.style.top;
   barall.style.top = parseInt(k)-parseInt(10 * size);
   k=memgraph.style.top;
   memgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesx.style.top;
   memlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesy.style.top;
   memlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderRAM.style.top;
   memborderRAM.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderPAGE.style.top;
   memborderPAGE.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderAll.style.top;
   memborderAll.style.top = parseInt(k)-parseInt(10 * size);
   k=memborder.style.top;
   memborder.style.top = parseInt(k)-parseInt(10 * size);
   k=RAMgraph.style.top;
   RAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=Pagegraph.style.top;
   Pagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=VIRgraph.style.top;
   VIRgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=rect1.style.top;
   rect1.style.top = parseInt(k)-parseInt(10 * size);
   k=rect2.style.top;
   rect2.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUmodel.style.top;
   CPUmodel.style.top = parseInt(k)-parseInt(10 * size);
   k=core.style.top;
   core.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuusg.style.top;
   cpuusg.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUicon.style.top;
   CPUicon.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuspeed.style.top;
   cpuspeed.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuused.style.top;
   cpuused.style.top = parseInt(k)-parseInt(10 * size);

   k=cRAMgraph.style.top;
   cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cPagegraph.style.top;
   cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cVIRgraph.style.top;
   cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUgraph.style.top;
   CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalebg.style.top;
   freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalenum.style.top;
   freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesx.style.top;
   CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesy.style.top;
   CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUborder.style.top;
   CPUborder.style.top = parseInt(k)-parseInt(10 * size);

   for (var i=1; i<=maxCPUcoressupport; i++){
    k=document.getElementById("core" + i + "graph").style.top;
    document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("namCore" + i).style.top;
    document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("usgCore" + i).style.top;
    document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("barback" + i).style.top;
    document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("cbar" + i).style.top;
    document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("WarningCore" + i).style.top;
    document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   }
   k=document.getElementById("core0graph").style.top;
   document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

   factheight -= 10;
   z += 10;
  }

  if (hideALLbarsflag){
   //ALL bars
   memall.style.visibility = "hidden";
   usgall.style.visibility = "hidden";
   barbackall.style.visibility = "hidden";
   barall.style.visibility = "hidden";

   k=memgraph.style.top;
   memgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesx.style.top;
   memlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=memlinesy.style.top;
   memlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderRAM.style.top;
   memborderRAM.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderPAGE.style.top;
   memborderPAGE.style.top = parseInt(k)-parseInt(10 * size);
   k=memborderAll.style.top;
   memborderAll.style.top = parseInt(k)-parseInt(10 * size);
   k=memborder.style.top;
   memborder.style.top = parseInt(k)-parseInt(10 * size);
   k=RAMgraph.style.top;
   RAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=Pagegraph.style.top;
   Pagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=VIRgraph.style.top;
   VIRgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=rect1.style.top;
   rect1.style.top = parseInt(k)-parseInt(10 * size);
   k=rect2.style.top;
   rect2.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUmodel.style.top;
   CPUmodel.style.top = parseInt(k)-parseInt(10 * size);
   k=core.style.top;
   core.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuusg.style.top;
   cpuusg.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUicon.style.top;
   CPUicon.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuspeed.style.top;
   cpuspeed.style.top = parseInt(k)-parseInt(10 * size);
   k=cpuused.style.top;
   cpuused.style.top = parseInt(k)-parseInt(10 * size);

   k=cRAMgraph.style.top;
   cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cPagegraph.style.top;
   cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
   k=cVIRgraph.style.top;
   cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

   k=CPUgraph.style.top;
   CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalebg.style.top;
   freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
   k=freqscalenum.style.top;
   freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesx.style.top;
   CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUlinesy.style.top;
   CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
   k=CPUborder.style.top;
   CPUborder.style.top = parseInt(k)-parseInt(10 * size);

   for (var i=1; i<=maxCPUcoressupport; i++){
    k=document.getElementById("core" + i + "graph").style.top;
    document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("namCore" + i).style.top;
    document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("usgCore" + i).style.top;
    document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("barback" + i).style.top;
    document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("cbar" + i).style.top;
    document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(10 * size);
    k=document.getElementById("WarningCore" + i).style.top;
    document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   }
   k=document.getElementById("core0graph").style.top;
   document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

   factheight -= 10;
   z += 10;
  }
 }//else

 if (hidememgraphicsflag){
  //MEM Graph
  memgraph.style.visibility = "hidden";
  memlinesx.style.visibility = "hidden";
  memlinesy.style.visibility = "hidden";
  memborderRAM.style.visibility = "hidden";
  memborderPAGE.style.visibility = "hidden";
  memborderAll.style.visibility = "hidden";
  memborder.style.visibility = "hidden";
  RAMgraph.style.visibility = "hidden";
  Pagegraph.style.visibility = "hidden";
  memborderRAM.style.visibility = "hidden";
  memborderPAGE.style.visibility = "hidden";
  VIRgraph.style.visibility = "hidden";
  rect1.style.visibility = "hidden";
  rect2.style.visibility = "hidden";

  k=CPUmodel.style.top;
  CPUmodel.style.top = parseInt(k)-parseInt(38 * size);
  k=core.style.top;
  core.style.top = parseInt(k)-parseInt(38 * size);
  k=cpuusg.style.top;
  cpuusg.style.top = parseInt(k)-parseInt(38 * size);
  k=CPUicon.style.top;
  CPUicon.style.top = parseInt(k)-parseInt(38 * size);
  k=cpuspeed.style.top;
  cpuspeed.style.top = parseInt(k)-parseInt(38 * size);
  k=cpuused.style.top;
  cpuused.style.top = parseInt(k)-parseInt(38 * size);

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(38 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(38 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(38 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(38 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(38 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(38 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(38 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(38 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(38 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(38 * size);
   k=document.getElementById("namCore" + i).style.top;
   document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(38 * size);
   document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(38 * size);
   k=document.getElementById("usgCore" + i).style.top;
   document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(38 * size);
   k=document.getElementById("barback" + i).style.top;
   document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(38 * size);
   k=document.getElementById("cbar" + i).style.top;
   document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(38 * size);
   k=document.getElementById("WarningCore" + i).style.top;
   document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(38 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(38 * size);

  factheight -= 38;
  z += 38;
 }

 if (hideCPUidentflag){
  //CPU identifacation
  CPUmodel.style.visibility = "hidden";

  k=core.style.top;
  core.style.top = parseInt(k)-parseInt(23 * size);
  k=cpuusg.style.top;
  cpuusg.style.top = parseInt(k)-parseInt(23 * size);
  k=CPUicon.style.top;
  CPUicon.style.top = parseInt(k)-parseInt(23 * size);
  k=cpuspeed.style.top;
  cpuspeed.style.top = parseInt(k)-parseInt(23 * size);
  k=cpuused.style.top;
  cpuused.style.top = parseInt(k)-parseInt(23 * size);

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(23 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(23 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(23 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(23 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(23 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(23 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(23 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(23 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(23 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(23 * size);
   k=document.getElementById("namCore" + i).style.top;
   document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(23 * size);
   document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(23 * size);
   k=document.getElementById("usgCore" + i).style.top;
   document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(23 * size);
   k=document.getElementById("barback" + i).style.top;
   document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(23 * size);
   k=document.getElementById("cbar" + i).style.top;
   document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(23 * size);
   k=document.getElementById("WarningCore" + i).style.top;
   document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(23 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(23 * size);

  factheight -= 23;
  z += 23;
 }

 if (hideCPUclockflag){
  //CPU Clock
  core.style.visibility = "hidden";
  cpuspeed.style.visibility = "hidden";

  k=cpuusg.style.top;
  cpuusg.style.top = parseInt(k)-parseInt(10 * size);
  k=CPUicon.style.top;
  CPUicon.style.top = parseInt(k)-parseInt(10 * size);
  k=cpuused.style.top;
  cpuused.style.top = parseInt(k)-parseInt(10 * size);

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(10 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("namCore" + i).style.top;
   document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("usgCore" + i).style.top;
   document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("barback" + i).style.top;
   document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("cbar" + i).style.top;
   document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("WarningCore" + i).style.top;
   document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(10 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

  factheight -= 10;
  z += 10;
 }

 if (hideCPUusageflag){
  //CPU Usage
  cpuusg.style.visibility = "hidden";
  cpuused.style.visibility = "hidden";
  CPUicon.style.visibility = "hidden";

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(10 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("namCore" + i).style.top;
   document.getElementById("namCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   document.getElementById("namCore" + i + "p").style.top = parseInt(k)-parseInt(10 * size);     
   k=document.getElementById("usgCore" + i).style.top;
   document.getElementById("usgCore" + i).style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("barback" + i).style.top;
   document.getElementById("barback" + i).style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("cbar" + i).style.top;
   document.getElementById("cbar" + i).style.top = parseInt(k)-parseInt(10 * size);
   k=document.getElementById("WarningCore" + i).style.top;
   document.getElementById("WarningCore" + i).style.top = parseInt(k)-parseInt(10 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

  factheight -= 10;
  z += 10;
 }

 if (hidecpubarsflag){
  //CPU all bars
  var numc;
  var nummax;
  if (CPUBarsType == 0){
   nummax = maxCPUcoressupport;
   numc = coreCount;
  }
  else{
   //all in one
   nummax = 1;
   numc = 1;
  }

  for (var i=1; i<=nummax; i++){
   document.getElementById("namCore" + i).style.visibility = "hidden";
   document.getElementById("usgCore" + i).style.visibility = "hidden";
   document.getElementById("cbar" + i).style.visibility  = "hidden";
   document.getElementById("barback" + i).style.visibility = "hidden";
  }

  k=cRAMgraph.style.top;
  cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
  k=cPagegraph.style.top;
  cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
  k=cVIRgraph.style.top;
  cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

  k=CPUgraph.style.top;
  CPUgraph.style.top = parseInt(k)-parseInt(numc * 10 * size);
  k=CPUlinesx.style.top;
  CPUlinesx.style.top = parseInt(k)-parseInt(numc * 10 * size);
  k=CPUlinesy.style.top;
  CPUlinesy.style.top = parseInt(k)-parseInt(numc * 10 * size);
  k=CPUborder.style.top;
  CPUborder.style.top = parseInt(k)-parseInt(numc * 10 * size);

  for (var i=1; i<=maxCPUcoressupport; i++){
   k=document.getElementById("core" + i + "graph").style.top;
   document.getElementById("core" + i + "graph").style.top = parseInt(k)-parseInt(numc * 10 * size);
  }
  k=document.getElementById("core0graph").style.top;
  document.getElementById("core0graph").style.top = parseInt(k)-parseInt(numc * 10 * size);
  k=freqscalebg.style.top;
  freqscalebg.style.top = parseInt(k)-parseInt(numc * 10 * size);
  k=freqscalenum.style.top;
  freqscalenum.style.top = parseInt(k)-parseInt(numc * 10 * size);

  factheight -= numc * 10;
  z += numc * 10;
 }
 else{
  //CPU separate bars
  var numc;
  if (CPUBarsType == 0) numc = coreCount;
  else{
   //all in one
   numc = 1;
  }

  for (var i=1; i<=numc; i++){
   if (Corehidebarflag[i]){
    document.getElementById("namCore" + i).style.visibility = "hidden";
    document.getElementById("usgCore" + i).style.visibility = "hidden";
    document.getElementById("cbar" + i).style.visibility  = "hidden";
    document.getElementById("barback" + i).style.visibility = "hidden";

    for (var j=i+1; j<=maxCPUcoressupport; j++){
     k=document.getElementById("namCore" + j).style.top;
     document.getElementById("namCore" + j).style.top = parseInt(k)-parseInt(10 * size);
     k=document.getElementById("usgCore" + j).style.top;
     document.getElementById("usgCore" + j).style.top = parseInt(k)-parseInt(10 * size);
     k=document.getElementById("barback" + j).style.top;
     document.getElementById("barback" + j).style.top = parseInt(k)-parseInt(10 * size);
     k=document.getElementById("cbar" + j).style.top;
     document.getElementById("cbar" + j).style.top = parseInt(k)-parseInt(10 * size);
    }

    k=cRAMgraph.style.top;
    cRAMgraph.style.top = parseInt(k)-parseInt(10 * size);
    k=cPagegraph.style.top;
    cPagegraph.style.top = parseInt(k)-parseInt(10 * size);
    k=cVIRgraph.style.top;
    cVIRgraph.style.top = parseInt(k)-parseInt(10 * size);

    k=CPUgraph.style.top;
    CPUgraph.style.top = parseInt(k)-parseInt(10 * size);
    k=freqscalebg.style.top;
    freqscalebg.style.top = parseInt(k)-parseInt(10 * size);
    k=freqscalenum.style.top;
    freqscalenum.style.top = parseInt(k)-parseInt(10 * size);
    k=CPUlinesx.style.top;
    CPUlinesx.style.top = parseInt(k)-parseInt(10 * size);
    k=CPUlinesy.style.top;
    CPUlinesy.style.top = parseInt(k)-parseInt(10 * size);
    k=CPUborder.style.top;
    CPUborder.style.top = parseInt(k)-parseInt(10 * size);

    for (var n=1; n<=maxCPUcoressupport; n++){
     k=document.getElementById("core" + n + "graph").style.top;
     document.getElementById("core" + n + "graph").style.top = parseInt(k)-parseInt(10 * size);
    }
    k=document.getElementById("core0graph").style.top;
    document.getElementById("core0graph").style.top = parseInt(k)-parseInt(10 * size);

    factheight -= 10;
    z += 10;
   }// end if
  }// end for i
 }//else

 if (CPUGraphsTypeflag != 0){
  //One CPU Graph for whole CPU
  for (var i=1; i<=maxCPUcoressupport; i++){
   document.getElementById("core" + i + "graph").style.visibility = "hidden";
  }
  document.getElementById("core0graph").style.visibility = "visible";
 }

 if (CPUGraphsTypeflag == 2){
  //Frequency Graph
 freqscalebg.style.visibility = "visible";
 freqscalenum.style.visibility = "visible";
 }
 else{
 freqscalebg.style.visibility = "hidden";
 freqscalenum.style.visibility = "hidden";
 }

 if (hidecpugraphicsflag){
  //CPU Graph
  temperatureimg.style.visibility = "hidden";
  CPUgraph.style.visibility = "hidden";
  freqscalebg.style.visibility = "hidden";
  freqscalenum.style.visibility = "hidden";
  CPUlinesx.style.visibility = "hidden";
  CPUlinesy.style.visibility = "hidden";
  CPUborder.style.visibility = "hidden";

  cRAMgraph.style.visibility = "hidden";
  cPagegraph.style.visibility = "hidden";
  cVIRgraph.style.visibility = "hidden";

  for (var i=1; i<=maxCPUcoressupport; i++){
   document.getElementById("core" + i + "graph").style.visibility = "hidden";
  }
  document.getElementById("core0graph").style.visibility = "hidden";

  factheight -= 38;
  z += 38;
 }

 if (hidecopyrightflag){
  //copyright
  htmark.style.visibility = "hidden";
  advertis.style.visibility = "hidden";
  versionnumber.style.visibility = "hidden";

  factheight -= 12;
 }
 else{
  k=htmark.style.top;
  htmark.style.top = parseInt(k)-parseInt((z-1) * size);
  k=advertis.style.top;
  advertis.style.top = parseInt(k)-parseInt(z * size);
  k=versionnumber.style.top;
  versionnumber.style.top = parseInt(k)-parseInt(z * size);
  htmark.style.visibility = "visible";
  advertis.style.visibility = "visible";
  versionnumber.style.visibility = "visible";
 }

 if (hidegridlinesflag){
  memlinesx.style.visibility = "hidden";
  memlinesy.style.visibility = "hidden";
  CPUlinesx.style.visibility = "hidden";
  CPUlinesy.style.visibility = "hidden";
 }

 //background section
 document.body.style.height = parseInt(factheight * size);
 background.style.height = parseInt(factheight * size);
 background.src = "images/background" + numhidden + ".png";
 mainsquare.style.top = parseInt(5 * size);
 mainsquare.style.left = parseInt(5 * size);
 mainsquare.style.width =  parseInt((130 - 10) * size);
 mainsquare.style.height = parseInt((factheight - 10) * size);
 mainsquare.style.background = cBgColor;
}

function runTaskManager(){
 if (dblclcaction == 0) System.Shell.execute("taskmgr.exe");
 else if (dblclcaction == 1) System.Shell.execute("perfmon", "/res");
 else return;
}

function showFlyout(){
 if (!System.Gadget.Flyout.show){
  System.Gadget.Flyout.show = true;
  if (!disableflyoutsoundsflag) System.Sound.playSound("media/service.wav");
 }
 else System.Gadget.Flyout.show = false;
}