﻿// PopupWindow Control functions

function GetRadWin()
{
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function popupWindow_showWindow(popupWindowID, url, nWidth, nHeight, title)
{
    var oManager = GetRadWindowManager();
    var oWnd = oManager.GetWindowByName("popupWindow");
    
    //Always reset the radwindow
    oWnd.SetUrl('');                
    oWnd.Show();
    oWnd.Close();
                        
    //Sets the new parameters to show the popup
    if (clientBrowser() == 0)
    {
        oWnd.SetSize(nWidth, nHeight);
    }
    else
    {
        oWnd.SetSize(nWidth + 7, nHeight + 7);
    }
    
    oWnd.SetUrl(url);
    oWnd.SetTitle(title);
    oWnd.Show();
}

function popupWindow_closeWindow(popupWindowID)
{
        
    var oManager = GetRadWindowManager();
    
    var oWnd = oManager.GetWindowByName("popupWindow");
    
    oWnd.Close();
}

function popupWindow_Move(nWidth, nHeight)
{
    var nLeft = 0;
    var nTop = 0;
    var nscrollT = 0;
    var nscrollL = 0;
    
    var option = 0;

    var de_cw = window.parent.document.documentElement.clientWidth;
    var de_ch = window.parent.document.documentElement.clientHeight;
    var de_st = window.parent.document.documentElement.scrollTop;
    var de_sl = window.parent.document.documentElement.scrollLeft;
    var bd_cw = window.parent.document.body.clientWidth;
    var bd_ch = window.parent.document.body.clientHeight;
    var bd_st = window.parent.document.body.scrollTop;
    var bd_sl = window.parent.document.body.scrollLeft;
    
    if (de_cw + de_ch == 0)
        option = 1;
    
    if (((de_st + de_sl == 0) && (bd_cw <= de_cw) && (bd_ch <= de_ch)))
        option = 1;
    
    if (option == 1)
    {
        nLeft = Math.round(window.parent.document.body.clientWidth / 2);
        nTop = Math.round(window.parent.document.body.clientHeight / 2);
        nscrollT = window.parent.document.body.scrollTop;
        nscrollL = window.parent.document.body.scrollLeft;
    }
    else
    {
        nLeft = Math.round(window.parent.document.documentElement.clientWidth / 2);
        nTop = Math.round(window.parent.document.documentElement.clientHeight / 2);
        nscrollT = de_st;
        nscrollL = de_sl;
    }

    nLeft = nscrollL + (nLeft - Math.round(nWidth / 2));
    nTop = nscrollT + (nTop - Math.round(nHeight / 2));

    var oWnd = GetRadWin();
    oWnd.MoveTo(nLeft,nTop);
}

//Invoked from editTranslationControl.aspx
function closePopup()
{
    popupWindow_closeWindow('popupWnd');
}

function ShowPrintToPdf(url, ViewKey, title, viewType, menuKey)
{
    popupWindow_showWindow('popupWndWnd', url + '?ViewKey=' + ViewKey + '&viewType=' + viewType + "&menuKey=" + menuKey, 689, 273, title);
}
    
function closepopupPrintWindow()
{
    popupWindow_closeWindow('popupWnd');
}





