﻿// JScript File
         function PageLoadForSettingModalZIndex()
         {  
            var ctl06_ctl00_popupAddOrUpdateTopic = $find('popupAddOrUpdateTopic');
            if(ctl06_ctl00_popupAddOrUpdateTopic!=null)
            {
                ForumTopicModal_ZIndex();
            }
            
            var ctl06_ctl00_popupPanelEditForumPost = $find('popupPanelEditForumPost');
            if(ctl06_ctl00_popupPanelEditForumPost!=null)
            {
                ForumPostModal_ZIndex();
            }
        }
        
        addToPageLoadEvent(PageLoadForSettingModalZIndex);

        
        
       function ForumPopupOnShow(senderTable)
        {

            //Set the height of the divScroller
            var tbl_Popup_Id = senderTable;
            var tbl_Popup = document.getElementById(tbl_Popup_Id);
            
            if(tbl_Popup!=null)
            {
                var currentWindowHeight = GetWindowHeight();
                
                if(currentWindowHeight<650)
                {
                    var newHeight = Math.round(currentWindowHeight - 40);
                    if( (newHeight-100)<0 )
                    {
                        tbl_Popup.style.height = "0px";
                    }
                    else
                    {
                        tbl_Popup.style.height = (newHeight-100)+"px";
                    }
                }
                else
                {
                    var newHeight = Math.round(650 - 40);
                    tbl_Popup.style.height = (newHeight-100)+"px";
                }
            }
        }
        
        function GetWindowHeight()
        {
                var y = 0;
                if (self.innerHeight)
                {
                        y = self.innerHeight;
                }
                else if (document.documentElement && document.documentElement.clientHeight)
                {
                        y = document.documentElement.clientHeight;
                }
                else if (document.body)
                {
                        y = document.body.clientHeight;
                }
                return y;
        }
        
        function ForumTopicModal_ZIndex()
        {
            //if we are not using ie then get the styles drop down link
            if(getBrowser()!='ie')
            {
                ResetZIndex('popupAddOrUpdateTopic_');
                            
                //find the style drop down list and set up the add_click event
                var rade_dropdown = getElementsByClassName('rade_dropdown')[0];
                if(rade_dropdown != null)
                {
                    rade_dropdown.setAttribute('onclick', 'topic_rade_dropdown_onclick();');
                }
            }
        }
        

        function ForumPostModal_ZIndex()
        {
            //if we are not using ie then get the styles drop down link
            if(getBrowser()!='ie')
            {
                ResetZIndex('popupPanelEditForumPost_');

                //find the style drop down list and set up the add_click event
                var rade_dropdown = getElementsByClassName('rade_dropdown')[0];
                if(rade_dropdown != null)
                {             
                    rade_dropdown.setAttribute('onclick', 'post_rade_dropdown_onclick();');
                }
            }
        }
        

        function topic_rade_dropdown_onclick()
        {
            //if style drop down is clicked scroll to the top of the page so the list can be seen
            ResetZIndex('popupAddOrUpdateTopic_');
            scroll(0,0);
        }
        
        function post_rade_dropdown_onclick()
        {
            //if style drop down is clicked scroll to the top of the page so the list can be seen
            ResetZIndex('popupPanelEditForumPost_');
            scroll(0,0);
        }
        
        function ResetZIndex(modalpopup_id)
        {
            var foregroundElement = document.getElementById(modalpopup_id + 'foregroundElement');
            if(foregroundElement != null)
            {
                foregroundElement.style.zIndex = "997";
            }
            
            var popupElement = document.getElementById(modalpopup_id + 'popupElement');
            if(popupElement != null)
            {
                popupElement.style.zIndex = "996";
            }
            
            var backgroundElement = document.getElementById(modalpopup_id + 'backgroundElement');
            if(backgroundElement != null)
            {
                backgroundElement.style.zIndex = "995";
            }
        }

      
      function getElementsByClassName(classname, node) 
      {
          if(!node) node = document.getElementsByTagName("body")[0];
          var a = [];
          var re = new RegExp('\\b' + classname + '\\b');
          var els = node.getElementsByTagName("*");
          for(var i=0,j=els.length; i<j; i++)
          if(re.test(els[i].className))a.push(els[i]);
          return a;
      }
      
      function getBrowser() 
      {
          var sBrowser = navigator.userAgent;
          if (sBrowser.toLowerCase().indexOf('msie') > -1) return 'ie';
          else if (sBrowser.toLowerCase().indexOf('firefox') > -1) return 'firefox';
          else return 'mozilla';
      }
        

