﻿// <![CDATA[

        function GetRadWindow()
        {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }
        
        function showPopWin(url, width, height, returnFunc) {
        oWnd = window.radopen(url,'DialogWindow');
        oWnd.SetSize(width,height);
        oWnd.Center();
        
       }
       
       function closePopWin() {
        
          GetRadWindow().Close(); 
        
       }
        
      function SizeToFit()
       {
       var oWnd = GetRadWindow();
        window.setTimeout(
            function()
            {
            var parentPage = GetRadWindow().BrowserWindow;
            var myWidth = 0, myHeight = 0;
	        if( typeof( window.innerWidth ) == 'number' ) {
		        myWidth = window.innerWidth; myHeight = window.innerHeight;
	        } else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		        myWidth = parentPage.document.documentElement.clientWidth; myHeight = parentPage.document.documentElement.clientHeight;
	        } else if( parentPage.document.body && ( document.body.clientWidth || parentPage.document.body.clientHeight ) ) {
		        myWidth = parentPage.document.body.clientWidth; myHeight = parentPage.document.body.clientHeight;
	        }
            
               oWnd.Center(); 
                oWnd.SetWidth(document.body.scrollWidth + 25);
                oWnd.SetHeight(myHeight- 75);
                oWnd.Center(); 
                //oWnd.SetHeight(document.body.scrollHeight + 70);

            }, 400);oWnd.Center(); 
            
       }


       function CloseOnReload()
         {
          //alert ("Dialog is about to close itself");
          GetRadWindow().Close(); 
            
         }
         //refresh current window
//         var sURL = unescape(window.location.pathname);
//         
//         function RefreshRadWindow()
//         {
//         window.location.replace = sURL;
//         }
         
         function RefreshParentPage()
         {
          //alert ("Dialog is about to reload parent page.");
          //GetRadWindow().BrowserWindow.location.reload();
          
          //GetRadWindow().BrowserWindow.refreshGrid(null);   
          GetRadWindow().BrowserWindow.location.reload();
          //GetRadWindow().Close(); 
         }
         
         function RedirectParentPage(newUrl)
         {
          alert ("Dialog is about to redirect parent page to " + newUrl);
          GetRadWindow().BrowserWindow.document.location.href = newUrl;
         }
         
         function CallFunctionOnParentPage(fnName)
         {
          alert ("Calling the function " + fnName + " defined on the parent page");
          var oWindow = GetRadWindow();
          if (oWindow.BrowserWindow[fnName] && typeof(oWindow.BrowserWindow[fnName]) == "function")
          {
            oWindow.BrowserWindow[fnName](oWindow);
          }
         }

// ]]>
      