﻿// JScript File for rad popups and modal windows


// Rad windows stuff
function GetRadWindow()
 {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz az well)            
    return oWindow;
 }
 
 // close the pop window
 function CloseOnReload()
 {
    //alert ("Dialog is about to close itself");
    //GetRadWindow().Close();
    top.location.reload()
 }
 
 // refresh the parent page - needs the URL of the page e.g. ../../page.aspx
 function RefreshParentPage(fileURL)
 {
    GetRadWindow().BrowserWindow.location.href= fileURL; 
 }
 
 // will redirect the parent page to the new URL
 function RedirectParentPage(newUrl)
 {
    GetRadWindow().BrowserWindow.document.location.href = newUrl;
 }
 
 // will call a function on the parent page - 
 function CallFunctionOnParentPage(fnName)
 {
    var oWindow = GetRadWindow();
    if (oWindow.BrowserWindow[fnName] && typeof(oWindow.BrowserWindow[fnName]) == "function")
    {
       oWindow.BrowserWindow[fnName](oWindow);
    }
 }      
         
         
         
// Rad window control stuff
// so as to close the modal one if present
function editclose()
    { 
        __doPostBack('onEditClose', ''); 
    } 
     

function confirmCallBackFn(arg)
    {
    if (arg){
        __doPostBack('CONFIRM_TRUE', '');
        }
    }

function PromptCallBackFn(arg)
    {
        if (arg != ''){
            //alert(arg);
            __doPostBack('PROMPT_TRUE', arg);
            }
    }           



function rad_popup(popID, popURL, popGrey, popHeight, popWidth, popFullScreen)
{            
    //Get window manager
    var oManager = GetRadWindowManager();

    if (popURL != '') // if URL is not blank
    {
          var oEditWnd = window.radopen(popURL, 'RadWindow1');
          oEditWnd.SetSize(popHeight, popWidth);
          if (popFullScreen == 'True')
          {
                oEditWnd.SetSize(document.body.offsetWidth-50, document.body.offsetHeight-50);
                oEditWnd.MoveTo(25,25);  
          }
    }
    else
    {
        var oEditWnd = oManager.GetWindowByName('error' );
        var oEditWnd = window.radopen( '../error/errorpage.aspx', "error" );
        oEditWnd.SetSize(popHeight, popWidth);
        oEditWnd.Maximize
    }    
}             

