﻿var PopTimer = null
var x, y

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }

    x = curleft;
    y = curtop;
}

function ShowPop(which, title, srcURL, offsetT, offsetL, height, width) {
    var oDiv = GetElement("PopOut2");
    var htmlContent = GetElement("divContent");

    if (which) {
        findPos(which);

        x += 20; //offset a bit
        y += 20;

        if (offsetL) { x += offsetL }
        if (offsetT) { y += offsetT }

        oDiv.style.left = x + "px";
        oDiv.style.top = y + "px";
    }
    else {
        oDiv.style.left = offsetL + "px";
        oDiv.style.top = offsetT + "px";
    }

    oDiv.style.height = height + "px";
    oDiv.style.width = width + "px";

    GetElement("tdTitle").innerText = title;
    GetElement("tdTitle").textContent = title;

    htmlContent.innerHTML = "<iframe height='" + height + "' width='100%' src='" + srcURL + "' style='border: 2px solid #996633'></iframe>";

    oDiv.className = "ShowDIV"

    if (PopTimer != null) {
        clearTimeout(PopTimer);
    }

}

function HidePop() {
    GetElement("PopOut2").className = "HideDIV"
}

function ClosePop() {
    PopTimer = setTimeout("HidePop()", 2000);
}
