﻿// JScript File

matchHeight=function(){ 
  
     var divs, contDivs, maxHeight, divHeight, d; 

     divs=document.getElementsByTagName('div');     // get all <div> elements in the document 

     contDivs=[]; 

     maxHeight=0;   // initialize maximum height value 
    
     //====================
     // Bug Fix 
     //====================
     //
     // Date: Oct 24, 2007
     // By: Walter
     // Reason: Fixes the New Product Specials from Overlapping the Right Bottom Nav Images.
     //
     // Description: Basically Calculates the height of the right column with the product
     // specials and then adds 300pixels (the image its self is only about 288px, so gives a
     // spacer of 12px.)
     
     if (document.getElementById('right-sub-navigation'))       //Fixes JS Error On homepage
     {
         maxHeight = document.getElementById('right-sub-navigation').offsetHeight + 300;
     }
    
    
    
    // iterate over all <div> elements in the document 
     for (var i=0; i < divs.length; i++)
     { 
          // make collection with <div> elements with class attribute 'matchcolumn' 
          if(/\bmatchcolumn\b/.test(divs[i].className)){ 

                d = divs[i];

                contDivs[contDivs.length]=d; 

                if (d.offsetHeight) // determine height for <div> element 
                { 
                     divHeight=d.offsetHeight; 
                } 

                else if(d.style.pixelHeight)
                { 
                     divHeight=d.style.pixelHeight; 
                } 

                // calculate maximum height 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 
     
     //====================
     // Bug Fix 
     //====================
     //
     // Date: Sept 26, 2007
     // By: Walter
     // Reason: Give the Page  Default Height of 600.
     //
     // Description: If the max height from the columns is less then 600 it will set it to 600,
     // otherwise it will remain whatever the column max height is above 600px;
     
     if (maxHeight < 600) { maxHeight = 600;}
     
     //====================
     
     //====================
     // Update 
     //====================
     //
     // Date: Sept 26, 2007
     // Reason: Give the bottom of the content area a 10 px padding;
     
     maxHeight = maxHeight + 10;
     
     //====================
     
     for(var i=0;i<contDivs.length;i++)
     { 
          contDivs[i].style.height = maxHeight + 'px'; // assign maximum height value                                               // to all of container <div> elements 
     }
     
     var varBottomLeftColContent = document.getElementById('left-col-bottom-links');
     maxHeight = maxHeight - 475;
     
     //June 15, 2009.
     //No longer require this code, because template has changed.  
     //varBottomLeftColContent.style.marginTop = maxHeight + 'px';
} 


// execute function when page loads 
window.onload=function()
{ 
     if(document.getElementsByTagName)
     { 
          matchHeight(); 
     } 
	 
}


