/** * Helper functions for caching */ //Global variables for cache mechanism var cache_d0; var cache = []; var tooSmall = false; var fetches = 0; /** * Shows a "Loading..." window and starts caching */ function loadStart() { //Build window cache_d0 = document.createElement("DIV"); cache_d0.style.width = "150px"; cache_d0.style.height = "50px"; cache_d0.style.backgroundColor = "#FFFFFF"; cache_d0.style.borderStyle = "Solid"; cache_d0.style.borderWidth = "1px"; cache_d0.style.borderColor = "#000000"; cache_d0.style.position = "absolute"; var winwidth, winheight; if (document.all) { winwidth = document.body.clientWidth; winheight = document.body.clientHeight; } else { winwidth = window.innerWidth; winheight = window.innerHeight; } if (winwidth < 970 || winheight < 580) { tooSmall = true; alert("Your current configuration may cause this application not to work properly.\nFirst, check that your screen resolution is at least 1024x768. If this message still apears you may try the following:\n - Maximize your browser's window\n - Remove/hide additional toolbars in your browser\n - Decrease your browser's text size (Select \"View\", then \"Text size\")"); } cache_d0.style.left = (winwidth / 2 - 75) + "px"; cache_d0.style.top = (winheight / 2 - 25) + "px"; cache_d0.style.lineHeight = "50px"; cache_d0.style.textAlign = "center"; cache_d0.style.verticalAlign = "middle"; cache_d0.dir = "ltr"; cache_d0.innerHTML = "Loading VIC..."; document.body.appendChild(cache_d0); //Create threads for caching and loading and time them setTimeout(cacheImages, 10); setTimeout(loadComputer, 1000); } /** * Caches the images used in the application */ function cacheImages() { var borders = []; borders.push("computer_bottom.gif"); borders.push("computer_bottomleft.gif"); borders.push("computer_bottomright.gif"); borders.push("computer_left.gif"); borders.push("computer_right.gif"); borders.push("computer_top.gif"); borders.push("computer_topleft.gif"); borders.push("computer_topright.gif"); borders.push("register_all.gif"); var controls = []; controls.push("about_s.gif"); controls.push("clear.gif"); controls.push("execute.gif"); controls.push("execute_dis.gif"); controls.push("fetch.gif"); controls.push("fetch_dis.gif"); controls.push("help_s.gif"); controls.push("load.gif"); controls.push("p_about_s.gif"); controls.push("p_execute.gif"); controls.push("p_execute_dis.gif"); controls.push("p_fetch.gif"); controls.push("p_fetch_dis.gif"); controls.push("p_help_s.gif"); controls.push("p_load.gif"); controls.push("p_reset.gif"); controls.push("p_run.gif"); controls.push("p_single.gif"); controls.push("p_stop.gif"); controls.push("p_clear.gif"); controls.push("reset.gif"); controls.push("run.gif"); controls.push("separator.gif"); controls.push("single.gif"); controls.push("single_dis.gif"); controls.push("stop.gif"); for (var item in borders) { var image = new Image(); image.src = "../Borders/" + borders[item]; cache.push(image); } borders = null; for (var item in controls) { var image = new Image(); image.src = IMAGES_DIR + controls[item]; cache.push(image); } controls = null; } /** * Loads the application */ function loadComputer() { document.computer = new Computer(document.getElementById("computerContainer")); new ControlUnit(document.computer, document.getElementById("controlsContainer")); setTimeout(loadDone, 100); } /** * Removes the "Loading..." window */ function loadDone() { document.getElementById("tblTools").style.visibility = "visible"; document.body.removeChild(cache_d0); document.getElementById("tblTools").style.width = "780px"; loadHelp(); if (loadPostedData) loadPostedData(); } /** * Loads help frame */ function loadHelp() { document.body.style.overflow = "hidden"; var help = document.getElementById("frmHelp"); help.style.position = "Absolute"; help.style.left = document.computer.width + 58; help.style.top = 0; var winW, winH; if (!document.all) { winW = window.innerWidth; winH = window.innerHeight; } else { winW = document.body.offsetWidth; winH = document.body.offsetHeight; } help.style.height = (winH) + "px"; help.style.width = (winW - document.computer.width - 58) + "px"; help.style.borderStyle = "None"; help.style.display = "block"; help.src = "../common/help.asp?lang=en"; var _hide = function() { help.style.display = "none"; } setTimeout(_hide, 0); }