﻿function CreateModalWindow(sUrl, sTitle, iWidth, iHeight,bResizeable) {
    //oWindowManager.newWindow(txtWinID,[txtUrl],[bClose],[bMaximize],[bStatusBar],[bResizable],[bDraggable],[bIsModal]);
    if (null == bResizeable) {
        bResizeable = false;
    }
    var window_id = (new Date()).getTime();
    var oWin = oWindowManager.newWindow(window_id, sUrl, true, false, false, bResizeable, true, true);
    oWin.setTitle(sTitle);
    oWin.setSize(iWidth, iHeight);
    oWin.screenCenter();
    oWin.Open();
}
//Creates a modal window without the close button
function CreateModalWindowNoClose(sUrl, sTitle, iWidth, iHeight, bResizeable) {
    //oWindowManager.newWindow(txtWinID,[txtUrl],[bClose],[bMaximize],[bStatusBar],[bResizable],[bDraggable],[bIsModal]);
    if (null == bResizeable) {
        bResizeable = false;
    }
    var window_id = (new Date()).getTime();
    var oWin = oWindowManager.newWindow(window_id, sUrl, false, false, false, bResizeable, true, true);
    oWin.setTitle(sTitle);
    oWin.setSize(iWidth, iHeight);
    oWin.screenCenter();
    oWin.Open();
}
function GetTopWindow() {
    var modalWindow = null;
    if (null != oWindowManager) {
        var oWindows = oWindowManager.getWindows();
        if (null != oWindows) {
            var iNumWindows = oWindows.length;
            if (iNumWindows > 0) {
                modalWindow = oWindows[iNumWindows - 1];
            }
        }
    }
    return (modalWindow);
}
function CloseModalWindow() {
    var oWin = GetTopWindow();
    if( null != oWin )
    {
        oWin.Close();
    }
}

function LoadXmlResponse(sXmlResponse) {
    var xDoc = null;
    if (window.ActiveXObject) {
        try {
            xDoc = new ActiveXObject("Microsoft.XMLDOM");
            xDoc.async = "false";
            xDoc.loadXML(sXmlResponse);
        }
        catch (e) {
            xDoc = null;
        }    
    }
    if (null == xDoc) {
        try {
            var parser = new DOMParser();
            xDoc = parser.parseFromString(sXmlResponse, "text/xml");
        }
        catch (e) {
        }
    }

    return (xDoc);
}

function GetNodeValue(xDoc, sTagName) {
    var sValue = "";
    try {
        var objs = xDoc.documentElement.getElementsByTagName(sTagName);
        if (null != objs && 1 == objs.length) {
            sValue = objs[0].firstChild.nodeValue;
        }
    }
    catch (e) {
        sValue = "";
    }    
    return (sValue);
}
// Start functions for flyout
function Open() {
    Flyout1.Open();
}
function Close() {
    Attach("");
    Flyout1.Close();
}
function Attach(id) {
    Flyout1.AttachTo(id);
}
function Show(sUrl, id) {
    var ch = document.getElementById("Flyout1_content_holder");
    while (ch.hasChildNodes()) {
        ch.removeChild(ch.lastChild);
    }
    var obj = document.createElement("img");
    obj.setAttribute('src', sUrl);
    obj.style.display = "block";
    ch.appendChild(obj);
    Attach(id);
    Open();
}

function SetupFlyoutForThumbnail(sUrl, thumbnailID, delay) {
    var s = "setTimeout('Show(\"" + sUrl + "&noclear=True\", \"" + thumbnailID + "\")', " + delay.toString() + ")";
    return( eval(s) );
}
// End functions for flyout
