
var refreshParentWindow = false;

function ShowWindowInformation(control, trainingOnlineId, memberId, courseId)
{            
    var navigateUrl = "Ga_Information.aspx?trainingOnlineId=" + trainingOnlineId + "&courseId=" + courseId + "&memberId=" + memberId;

    // Edited by Aki on 12/1/2009
    // Use parent RadWindow manager
    //var oWindow = window.radopen(navigateUrl, "rwInformation");
    var radWindowManager = $find(GetClientId("rwmGamble"));

    var oWindow = radWindowManager.Open(navigateUrl, "rwInformation");
        
    oWindow.SetSize (document.documentElement.clientWidth/1.5, document.documentElement.clientHeight/1.1);

    document.getElementById(GetClientId("hiResizeWindow")).value = "information";
}

function SetWindowFeedbackBit(courseId)
{
    parent.window.document.getElementById(GetClientId("hiLaunchFeedbackCourseId")).value = courseId;
    
    refreshParentWindow = true;

    parent.window.document.getElementById(GetClientId("hiResizeWindow")).value = "feedback";
    
    GetRadWindow().Close();
    
    if (courseId > 0)
    {
        // in order to use rad window, widnow has to be launched from parent
        // calling "ShowWindowFeedback" method directly from a child window does not work
        // since "radopen" does not work with "RegisterClientScriptBlock" from server side
        parent.window.document.forms[0].submit();
    }
}

var navigateUrl = null;
                      
function ShowWindowFeedback(server, memberId, trainingId, courseId)
{
    navigateUrl = "http://" + server + "Training3.1/IndexTraining.aspx?memberId=" + memberId + "&trainingId=" + trainingId + "&courseId=" + courseId + "&windowTitle=Comments_System_-_Kansas_Problem_Gambling";

    // a new rad window needs to have delay when it loads from on load event
    setTimeout("OpenFeedbackWindow()", 1000);    
}

function OpenFeedbackWindow() {
    // Edited by Aki on 12/1/2009
    // Use parent RadWindow manager
    //var oWindow = window.radopen(navigateUrl, "rwFeedback");
    var radWindowManager = $find(GetClientId("rwmGamble"));

    var oWindow = radWindowManager.Open(navigateUrl, "rwFeedback");

    oWindow.SetSize(document.documentElement.clientWidth / 1.5, document.documentElement.clientHeight / 1.005);

    document.getElementById(GetClientId("hiResizeWindow")).value = "feedback";
}        
        
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;
}

function OnClientClose(radWindow)
{
    if (refreshParentWindow)
    {
        window.location = "KansasGamblingProblems.aspx";
    }
}

function onResizeWindow() 
{
    var oManager = GetRadWindowManager();

    if (oManager == null) return;

    var oMailWnd = null;

    var windowType = document.getElementById(GetClientId("hiResizeWindow")).value;
    
    if (windowType == "information")
    {
        oMailWnd = oManager.GetWindowByName("rwInformation");

        if (oMailWnd)
        {
            oMailWnd.Width = document.documentElement.clientWidth/2
            
            oMailWnd.Height = document.documentElement.clientHeight/1.5
           
            oMailWnd.SetSize (document.documentElement.clientWidth/1.5, document.documentElement.clientHeight/1.1);
        }               
    }
    else //if (windowType == "feedback")
    {
        oMailWnd = oManager.GetWindowByName("rwFeedback");

        if (oMailWnd)
        {
            oMailWnd.Width = document.documentElement.clientWidth/1.5
            
            oMailWnd.Height = document.documentElement.clientHeight/1.005	
            
            oMailWnd.SetSize(document.documentElement.clientWidth/1.5, document.documentElement.clientHeight/1.005);
        }        
    }
}