﻿function ShowPopup(url)
{
    var background = document.createElement("div");
    
    background.id = "Popup_Background";
    background.innerHTML = "&nbsp;";
    background.style.background = "#000000";
    background.style.filter = "alpha(opacity = 50)";
    background.style.height = "100%";
    background.style.left = "0px";
    background.style.opacity = "0.5";
    background.style.position = "fixed";
    background.style.top = "0px";
    background.style.width = "100%";
    
    document.body.appendChild(background);
    
    var width = Math.min(1024, document.documentElement.clientWidth - 50);
    var height = Math.min(768, document.documentElement.clientHeight - 50);
    
    var layout = document.createElement("table");
    
    layout.cellPadding = 0;
    layout.cellSpacing = 0;
    layout.id = "Popup_Layout";
    layout.style.height = height + "px";
    layout.style.left = parseInt((document.documentElement.clientWidth - width) / 2) + "px";
    layout.style.position = "fixed";
    layout.style.top = parseInt((document.documentElement.clientHeight - height) / 2) + "px";
    layout.style.width = width + "px";
    
    layout.insertRow(0);
    layout.insertRow(1);
    
    layout.rows[0].insertCell(0);
    layout.rows[1].insertCell(0);
    
    layout.rows[0].cells[0].innerHTML = "<a style=\"color: #FFFFFF;\" href=\"JavaScript: HidePopup(); void(0);\">Return to Red Energy &gt;</a>";
    layout.rows[0].cells[0].style.background = "#000000";
    layout.rows[0].cells[0].style.height = "30px";
    layout.rows[0].cells[0].style.paddingRight = "10px";
    layout.rows[0].cells[0].style.textAlign = "right";
    layout.rows[0].cells[0].style.verticalAlign = "middle";
    layout.rows[0].cells[0].style.width = (width - 10) + "px";
    
    layout.rows[1].cells[0].innerHTML = "<iframe id=\"Popup_Frame\" style=\"height: " + (height - 35) + "px; width: " + width + "px\" frameborder=\"0\" src=\"" + url + "\"></iframe>";
    layout.rows[1].cells[0].style.background = "#FFFFFF";
    layout.rows[1].cells[0].style.border = "5px solid #000000";
    layout.rows[1].cells[0].style.borderTop = "none";
    layout.rows[1].cells[0].style.height = (height - 35) + "px";
    layout.rows[1].cells[0].style.width = (width - 10) + "px";
    
    document.body.appendChild(layout);
}

function HidePopup()
{
    document.getElementById("Popup_Frame").src = "about:blank";
    
    document.body.removeChild(document.getElementById("Popup_Background"));
    document.body.removeChild(document.getElementById("Popup_Layout"));
}