﻿var height_of_skin_border = 39;
var width_of_skin_border = 10;


function viewPhotos(groupname, seqnum)
{            
    viewPhotosWithOptions(groupname, seqnum, true);
}

function viewPhotosWithOptions(groupname, seqnum, center)
{

    //Getting rad window manager
    var oManager = GetRadWindowManager();

    //Get window by userId - if it does not exist - create it!, else show it and set it as active            
    var wndName = "photos";
    var oWnd = oManager.GetWindowByName(wndName);
                
    //Build NavigateURL
    var navURL = 'http://www.loispaul.com/websitephotos/LaunchViewer.htm?groupname=' + groupname + '&seqnum=' + seqnum;

    if (oWnd)
    {                    
        oWnd.Show();                
        oWnd.SetActive(true);
        oWnd.SetUrl(navURL);
        oWnd.SetSize(548, 510);
        if (center)
        {
            oWnd.Center();
        }
        else
        {
            oWnd.Left = 20;
            oWnd.Top = 20;    
        }
    }
    else
    {        
        var oWnd = window.radopen(navURL, wndName);
        oWnd.SetSize(548, 510);
        if (center)
        {
            oWnd.Center();
        }
        else
        {
            oWnd.Left = 20;
            oWnd.Top = 20;    
        }
    }            

}

function openPollWindow(url)
{
    var winwidth = 400;
    var winheight = 350;

    //Getting rad window manager
    var oManager = GetRadWindowManager();

    //Get window by userId - if it does not exist - create it!, else show it and set it as active            
    var wndName = "poll";
    var oWnd = oManager.GetWindowByName(wndName);
                
    //Build NavigateURL
    var navURL = url;

    if (oWnd)
    {                    
        oWnd.Show();                
        oWnd.SetActive(true);
        oWnd.SetUrl(navURL);
        oWnd.Center();        
    }
    else
    {        
        var oWnd = window.radopen(navURL, wndName);
        oWnd.SetSize(winwidth, winheight);
        oWnd.Center();        
    }
}

/*Opens a window to play a video.  At this moment, just used for Restore Medical Launch video*/
function openWindowForVideo(url, width, height) {

    //Set popup window size
    var winwidth = (width) ? width : 400;
    var winheight = (height) ? height : 350;

    //Account for size of skin
    winwidth += width_of_skin_border;
    winheight += height_of_skin_border;

    //var features = "width=" + winwidth + ",height=" + winheight;

    //var vidWindow = window.open(url, 'video', features);

    //Getting rad window manager
    var oManager = GetRadWindowManager();

    //Get window by userId - if it does not exist - create it!, else show it and set it as active            
    var wndName = "video";
    var oWnd = oManager.GetWindowByName(wndName);

    //Build NavigateURL
    var navURL = url;

    if (oWnd) {
        oWnd.Show();
        oWnd.SetActive(true);
        oWnd.SetUrl(navURL);
        oWnd.SetSize(winwidth, winheight);
    }
    else {
        var oWnd = window.radopen(navURL, wndName);
        oWnd.SetSize(winwidth, winheight);
    }

    oWnd.set_modal(true);
    oWnd.Center();
    oWnd.add_show(OnClientShow);
    oWnd.add_close(OnClientClose);

}

function OnClientShow(radWindow) {

    //code to hide scrollbars
    if (document.documentElement && document.documentElement.scrollTop) {
        var oTop = document.documentElement.scrollTop;
        document.documentElement.scroll = "no";
        document.documentElement.style.overflow = "hidden";
        document.documentElement.scrollTop = oTop;

    } else if (document.body) {
        var oTop = document.body.scrollTop;
        document.body.scroll = "no";
        document.body.style.overflow = "hidden";
        document.body.scrollTop = oTop;
    }
}

function OnClientClose(oWnd) {

    //one way 
    oWnd.get_contentFrame().src = "about:blank";
    //basically the same but by using the setUrl method
    //oWnd.setUrl("about:blank");
    
    //code to reset scrollbars
    if (document.documentElement && document.documentElement.scrollTop) {
        document.documentElement.scroll = "";
        document.documentElement.style.overflow = "";
    } else if (document.body) {
        document.body.scroll = "";
        document.body.style.overflow = "";
    }

}

function GetRadWindow()
{
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function closeWindow(type)
{           
    var oWindow = GetRadWindow(); 
    oWindow.Argument = type;
    oWindow.Close();            
}