
   // Start Rad Window   

         //This code is used to provide a reference to the radwindow "wrapper"
      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;
         
         var oWindow = null;
            if (window.radWindow)
            {
            oWindow = window.radWindow;
            }
            else if (window.frameElement != null && window.frameElement.radWindow)
            {
            oWindow = window.frameElement.radWindow;
            }
            return oWindow;
      }

      function CloseOnReload()
      {
         GetRadWindow().Close();
      }


      function RefreshParentPage()
      {
         GetRadWindow().BrowserWindow.location.reload();
      }
      

         function OpenRw(varPage, var1, var2, varWidth, varHeight) {
         
         var myWidth = 0, myHeight = 0;
         if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
         } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
         } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
         }
         
         var oRadWindow = GetRadWindow();
            var oManager = null;

            if (oRadWindow == null) { 
            oManager = GetRadWindowManager(); 
            }
            else {
            oManager = oRadWindow.BrowserWindow.GetRadWindowManager(); 
            //oManager.closeActiveWindow();
            }
    

         var oWnd = oManager.GetWindowByName("pgRadWindow"); 
         if (!oWnd) return;

         if (varPage == "1"){
            var newUrl = "Slideshows.aspx?id="+var1 ;
            oWnd.SetSize(565,545);
            }
            
         if (varPage == "2"){
            var newUrl = "Videos.aspx?id="+var1 ;
                if(varWidth && varHeight){
                oWnd.SetSize(varWidth,varHeight);
                }
                else{
                oWnd.SetSize(389,358);
                }
            oWnd.SetModal(true);
            }
            
         if (varPage == "3"){
            var newUrl = "Slideshows.aspx?id="+var1 ;
            oWnd.SetSize(354,390);
            
            }
            
         if (varPage == "4"){
            var newUrl = "ProductBrowser.aspx?id="+var1 ;
            oWnd.SetModal(true);
            oWnd.SetSize(650,400);
            }
            
         if (varPage == "5"){
            var newUrl = "TruPulse-360-Demo.aspx" ;
         // oWnd.setSize(875,550);
            oWnd.SetModal(true);
            oWnd.SetSize(myWidth - 20, myHeight - 20);
         // oWnd.Maximize();
            }
            
         if (varPage == "6"){
            var newUrl = "../PageBrowser.aspx?id="+var1 ;
            oWnd.SetSize(650,400);
            }
            
         if (varPage == "7"){
            var newUrl = "NewProductEditor.aspx?id="+var1+"&subtype="+var2 ;
            oWnd.SetModal(true);
            oWnd.SetSize(720,530);
            oWnd.add_close(RefreshGrid); 
            }
            
         if (varPage == "8"){
            var newUrl = "video/TruSpeed_Action.htm" ;
         // oWnd.SetModal(true);
            oWnd.SetSize(492,365);
            oWnd.SetModal(true);
            }
            
         if (varPage == "9"){
            var newUrl = "QuoteRequest.aspx?mode="+var1 ;
         // oWnd.SetModal(true);
            oWnd.SetSize(510,420);
            oWnd.SetModal(true);
         // oWnd.add_close(UpdateProdQuoteList);
            }
            
         if (varPage == "10"){
            var newUrl = "FileEditor.aspx?id="+var1 ;
            oWnd.SetSize(700,430);
            oWnd.add_close(RefreshGrid); 
            }
            
         if (varPage == "11"){
            var newUrl = "PageEditor.aspx?id="+var1 ;
            oWnd.SetSize(700,400);
            if (var2 == undefined){
            oWnd.add_close(RefreshGrid);
            }
            }
            
         if (varPage == "12"){
            var newUrl = "http://www.lasertech.com/360DemoWeb/" ;
         // oWnd.setSize(875,550);
            oWnd.SetModal(true);
            oWnd.SetSize(myWidth, myHeight);
         // oWnd.Maximize();
            }
            
            if (varPage == "13"){
            var newUrl = "../EventRegistration.aspx?id="+var1 ;
            oWnd.SetModal(true);
            oWnd.SetSize(520,400);
            }
            
            if (varPage == "14"){
            var newUrl = "AddToQuote.aspx?id="+var1 ;
            oWnd.SetSize(350,130);
            oWnd.SetModal(true);       
                oWnd.add_close(UpdateProdQuoteList);
            }
            
            if (varPage == "15"){
            var newUrl = "EventRegistration.aspx?id="+var1 ;
            oWnd.SetModal(true);
            oWnd.SetSize(520,400);
            }

            if (varPage == "16"){          
            var newUrl = "EventRequest.aspx?type="+var1+"&id="+var2 ;
            oWnd.SetModal(true);
            oWnd.SetSize(600,450);                  
            }
            
            if (varPage == "17"){          
            var newUrl = "Translate.aspx?id="+var1 ;
            oWnd.SetModal(true);
            oWnd.SetSize(400,300);                  
            }
            if (varPage == "18"){          
            var newUrl = "FaqEditor.aspx?id="+var1 ;
            oWnd.SetModal(true);
            oWnd.SetSize(700,520);                  
            }
            if (varPage == "19"){          
            var newUrl = "kdvr-video.htm";
            oWnd.SetModal(true);
            oWnd.SetSize(617,495);                
            }
            if (varPage == "20"){          
            var newUrl = "InfoRequest.aspx?type="+var1;
            oWnd.SetModal(true);
            oWnd.SetSize(600,450);                  
            }
            if (varPage == "21"){          
            var newUrl = var1;
            oWnd.SetModal(true);
            oWnd.set_title(var2);
            oWnd.SetSize(600,450);                  
            }
                     
               //oWnd.ReloadOnShow;
            oWnd.SetUrl(newUrl);
            
            
            oWnd.center();
            oWnd.Show();
            //oWnd.Restore();

         }
            
         function OnClientClose(oWnd)   
            {   
                //one way  
                oWnd.get_contentFrame().src = "about:blank";   
                //basically the same but by using the setUrl method  
                //oWnd.setUrl("about:blank");   
            } 

         
      function OnClientCloseHandler()   
        {   
         // window['<%= AjaxManager.ClientID %>'].AjaxRequest('Rebind');   
         //  $find("<%=AjaxManager.ClientID%>").ajaxRequest('Rebind');    
          // $find("<%=RadAjaxManager1.ClientID%>").ajaxRequestWithTarget("<%=RadAjaxManager1.ClientID%>", "test")
          //  __doPostBack("<%= AjaxManager %>", "Rebind");
          
            var ajaxManager1 = $find("<%= RadAjaxManager1.ClientID %>");
                ajaxManager1.ajaxRequest("RebindProdGrid2");

        }         
         
         // Call JS Function in other opened window
         function CallFn()   
            {   
               var oWnd = $find("<%=RadWindowManager1.ClientID %>").getWindowByName("RadWindow1");   
               oWnd.get_ContentFrame().contentWindow.CalledFn(); //CalledFn() must exists in the RadWindow's content   
            }   

         
         
      // radprompt('Please enter a number here:', promptCallBackFn, 330, 100);
        //    return false;
            
            function TestCallBack()   
            {    
                alert ("Callback Initiated");   
            }           
            
         function promptCallBackFn()
                {
                    alert ("Prompt returned the following result: ");
                } 
         
         function OpenRwEditor(varPage, varMode) {
         
         // Get window size
         var myWidth = 0, myHeight = 0;
         if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
         } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
         } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
         }
         
         
         var oManager = GetRadWindowManager();
         var oWnd = oManager.GetWindowByName("pgRadWindow"); 
         if (!oWnd) return;
         
         var newUrl = "Editor.aspx?id="+varPage+"&mode="+varMode ;
            oWnd.SetSize(800,490);
            oWnd.ReloadOnShow
            oWnd.SetUrl(newUrl);
            oWnd.Show();
            oWnd.MoveTo((myWidth-800)/2,10)

         // var oWin = window.open("Editor.aspx", "Editor", "width=600px,height=400px,resizable=1,status=1");
         }
      


//            function CloseProductDetailForm()   
//            {  
//            
//              // ajaxMngrRequest("RebindProdQuoteList");
//                
//                setTimeout(function(){ 
//                    var controller = Telerik.Web.UI.RadToolTipController.getInstance();
//                    var tooltip = controller.get_activeToolTip();
//                    if (tooltip) tooltip.hide();
//                    ajaxMngrRequest("RebindProdQuoteList");
//                }, 1000);
//                                 
//            }
            
            function UpdateProdQuoteList(closeWindow)   
            {  
                //if(closeWindow){CloseOnReload();}           
                ajaxMngrRequest("RebindProdQuoteList");                           
            }

            function RefreshGrid()
            {
                //ajaxManager.ajaxRequest("RebindGrid");
                ajaxMngrRequest("RebindGrid");
            }


        function get_RadWindow() {    
          var oWindow = null;    
          if (window.radWindow) {    
            oWindow = window.radWindow;    
          }    
          else if (window.frameElement.radWindow) {   
            oWindow = window.frameElement.radWindow;    
          }   
          return oWindow;   
        }
               
        function nudgeWindow(x,y) {    
          var oWnd = get_RadWindow();    
          var bounds = oWnd.getWindowBounds();    
          var t = bounds.y;    
          var l = bounds.x;    
          oWnd.MoveTo(l + x, t + y);   
        }  
         
          function GetSelectedWindow()
        {
            var oManager = GetRadWindowManager();
            return oManager.getActiveWindow();        
        }
            
         function maximizeWindow()
        {
            var oWnd = GetSelectedWindow()
            
        if (oWnd){
            oWnd.maximize();
      }
        return false;
        }
        
        
        // OnClientShow="ReplaceMaximizeFunction"
        function ReplaceMaximizeFunction(oWnd)  
            {  
                //Replace the maximize/restore function  
                var oldMaximize = oWnd.Maximize;  
                var oldRestore = oWnd.Restore;  
                var prevHeight = oWnd.GetHeight();  
                var prevWidth = oWnd.GetWidth();  
  
                oWnd.Maximize = function()  
                {  
                    oldMaximize.call(oWnd);  
                    if (navigator.userAgent.indexOf("Firefox") != -1) {  
                        oWnd.MoveTo(0, 0);  
                        var width = oWnd.GetWidth();  
                        var height = oWnd.GetHeight();  
                        var newWidth = width-20;  
                        var newHeight = height-5;  
                        oWnd.SetWidth(newWidth);  
                        oWnd.SetHeight(newHeight);  
                    }  
                }  
                oWnd.Restore = function()  
                {  
                    if (navigator.userAgent.indexOf("Firefox") != -1) {  
                        oldRestore.call(oWnd);  
                        oWnd.SetWidth(600);  
                        oWnd.SetHeight(465);  
                        oWnd.MoveTo(154, 179);  
                    } else {  
                        oldRestore.call(oWnd);  
                    }  
                }  
            }  


   // End Rad Window
   
   
      function GoToBookmark(bkmk)
      {
//       if (bkmk <> ""){
         self.location.hash=bkmk; 
//       }
      }
      
      //add to titlebar
      
      
      
