//************************************************************
// AHB hack to make the top Admin and Host menus work with 
// the third-party Inventua TopMenu  
//************************************************************
// After changing the main menu (invtopmenu) to rootonly, the Admin and Host 
// links in the menu would not drop down, and were instead pointing to tabid's 
// that didn't have pages associated with them.  So this hack assigns the 
// Admin Settings and Host Settings pages for the Admin and Host links 
// respectively so that these menus instead work like the rest of the menus 
// in the AHB site.

if (document.getElementById('invtopmenu-Admin')) {  // For Admin and Host user
  document.getElementById('invtopmenu-Admin').innerHTML = '<a href="/Default.aspx?tabid=39"><span class="Link">Admin</span></a>';
}
if (document.getElementById('invtopmenu-Host')) {  // For Host user
  document.getElementById('invtopmenu-Host').innerHTML = '<a href="/Default.aspx?tabid=16"><span class="Link">Host</span></a>';
}


//************************************************************
// Add default text and functions to search field
//************************************************************

if (document.getElementById('dnn_dnnOPENSEARCH_txtSearch')) {
  var searchText = 'Search...';
  
  var mySearch = document.getElementById('dnn_dnnOPENSEARCH_txtSearch');
  mySearch.value = searchText;
  //document.getElementById('dnn_dnnSEARCH_txtSearch').Attributes.Add('onfocus', 'javascript:clearText(this);')
  //document.getElementById('dnn_dnnSEARCH_txtSearch').Attributes.Add('onblur', 'javascript:restoreText(this);')
  
  // Clear the search field onfocus
  mySearch.onfocus = function(){
    if (mySearch.value == 'Search...') {
      mySearch.value = '';
    }
  }
  
  // Restore the search field onblur
  mySearch.onblur = function(){
    if(mySearch.value == '') {
      mySearch.value = searchText;
    }
  }
}



 // Hide "<script>window.open ..."  javascript script element injected above the DOCTYPE when print or RSS links are clicked because it breaks the page's CSS when the page reloads on required postback

// first find the element
// then inject this styled div around the script element <div style="display: none; visibility: hidden;"> script here </div> 

