var adjustAssets = function(){

   // stretch short pages
   /**
   var bh = 
      window.innerHeight ? window.innerHeight : document.documentElement.clientHeight 
      ? document.documentElement.clientHeight : document.body.clientHeight;

   if (Ext.get('wrapper').getHeight() < bh)
   {
      var hh = Ext.get('ctl00_header').getHeight();
      var fh = Ext.get('ctl00_footer').getHeight();
      
      Ext.get('ctl00_centerColumn').setHeight(bh - hh - fh - 20);
   }
   */

};
var loadSearch = function() { 
   var searchText = document.getElementById("ttHeaderSearchTextbox"); 
   var searchButton = document.getElementById("ttHeaderSearchButton");

   var searchButtonOff = '/_media/SearchFindIt.gif';
   var searchButtonOn  = '/_media/SearchFindIt_o.gif';

   searchText.onkeyup = function() { 
      if (event.keyCode=='13') { searchButton.click();} 
   }; 

   searchButton.onmouseover = function() { 
      this.src = searchButtonOn; 
   };

   searchButton.onmouseout = function() { 
      this.src = searchButtonOff; 
   }; 

   searchButton.onclick = function() { 
      if (searchText.value != 'FOOBAR') { 
         window.location = '/search.aspx?find=' + encodeURIComponent(searchText.value).replace(/%20/g, '+'); 
         return false; 
      } 
   }; 
} 

Ext.onReady(function(){
   // auto adjust everything on page load or window resize
   //window.onresize = adjustAssets;
   //adjustAssets();
   loadSearch();
   
   // hover images for the top menu bar
   var shopCategoriesOff = '/_media/ShopCatsOff.gif';
   var shopCategoriesOn = '/_media/ShopCatsOn.gif';
   var shopBrandsOff = '/_media/ShopBrandsOff.gif';
   var shopBrandsOn = '/_media/ShopBrandsOn.gif';
   var dailyDealsOff = '/_media/DailyDealsOff.gif';
   var dailyDealsOn = '/_media/DailyDealsOn.gif';
   
   var shopCategories = document.getElementById("shopCategoriesGif"); 
   shopCategories.onmouseover = function() { 
      this.src = shopCategoriesOn; 
   };
   shopCategories.onmouseout = function() { 
      this.src = shopCategoriesOff; 
   };
   var shopBrands = document.getElementById("shopBrandsGif"); 
   shopBrands.onmouseover = function() { 
      this.src = shopBrandsOn; 
   };
   shopBrands.onmouseout = function() { 
      this.src = shopBrandsOff; 
   };       
   var dailyDeals = document.getElementById("dailyDealsGif"); 
   dailyDeals.onmouseover = function() { 
      this.src = dailyDealsOn; 
   };
   dailyDeals.onmouseout = function() { 
      this.src = dailyDealsOff; 
   }; 
});