﻿function GetRadWindow()
{
    var oWindow = null;
    if (window.radWindow)
        oWindow = window.radWindow;
    else if (window.frameElement.radWindow)
        oWindow = window.frameElement.radWindow;

    return oWindow;
}

function RadWindowRedirect(page, width, height) {
    var window = GetRadWindow();
    window.SetSize(width, height);
    window.SetUrl(page);
}

function RadWindowResize(width, height) {
    var win = GetRadWindow();
    win.SetSize(width, height);
}

function OpenWindow(page, width, height) {
    var win = radopen(page, null);
    win.SetSize(width, height);
}

function Close() {
    GetRadWindow().Close();
}

function CloseAndRefresh() {
    Close();
    RefreshParentPage();
}

function CloseAndRedirect(url) {
    Close();
    alert(url);
    GetRadWindow().BrowserWindow.location = url;
}

function RefreshParentPage() {
    GetRadWindow().BrowserWindow.location.reload();
}

function GetUrlParameter(name)
{
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}