+ img.src = url;
+ parent_node.appendChild(img);
+ return img;
+}
+
+function rename_element(old_name, new_name)
+{
+ // Remove any element that's in the way.
+ var elem = document.getElementById(new_name);
+ if (elem !== null) {
+ elem.parentNode.removeChild(elem);
+ }
+
+ elem = document.getElementById(old_name);
+ if (elem !== null) {
+ elem.id = new_name;
+ }
+ return elem;
+}
+
+function display_image(width, height, evt, filename, element_id)
+{
+ var url = window.location.origin + "/" + evt + "/" + width + "x" + height + "/nobox/" + filename;
+ var main = document.getElementById("iehack");
+ var preload = document.getElementById("preload");
+ var dpr = find_dpr();
+ var img;
+ // See if we have a preload going on that we can reuse.
+ if (element_id == "image" && preload !== null && preload.src == url) {
+ rename_element("preload_box", "image_box");
+ img = rename_element("preload", "image");
+ } else {
+ img = replace_image_element(url, element_id, main);
+ }
+ img.style.position = "absolute";
+ img.style.left = "0px";
+ img.style.top = "0px";
+ img.style.transformOrigin = "top left";
+ img.style.transform = "scale(" + (1.0 / dpr) + ")";
+
+ if (global_infobox != 'nobox/') {
+ var url;
+ if (dpr == 1) {
+ url = window.location.origin + "/" + evt + "/" + width + "x" + height + "/box/" + filename;
+ } else {
+ url = window.location.origin + "/" + evt + "/" + width + "x" + height + "@" + dpr.toFixed(2) + "/box/" + filename;
+ }
+ var boximg = replace_image_element(url, element_id + "_box", main);
+
+ boximg.style.position = "absolute";
+ boximg.style.left = "0px";
+ boximg.style.bottom = "-1px";
+ boximg.style.transformOrigin = "bottom left";
+ boximg.style.transform = "scale(" + (1.0 / dpr) + ")";
+ }
+
+ return img;
+}