// Submenu controls

sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
      sfEls[i].onmouseover=function() {
        this.className+=" sfhover";
      }
      sfEls[i].onmouseout=function() {
        this.className=this.className.replace(new RegExp(" sfhover"), "");
      }
    }
  }

if (window.attachEvent) window.attachEvent("onload", sfHover);



// Column controls

function layoutColumns() {
    // set default column heights - these need to match the css
    var defaultLeft = 501;
    var defaultRight = 501;
    var defaultCol1 = 422;
    var defaultCol2 = 422;
    var defaultCol3 = 422;

    // set top + bottom padding
    var paddingLeft = 0;
    var paddingRight = 34;
    var paddingCol1 = 34;
    var paddingCol2 = 34;
    var paddingCol3 = 34;


    if (document.getElementById){
      var heightDifference = 0;
      var colDisplace = 0; // we add this to the left and right columns when the product breadcrumb is present

      if (document.getElementById('productBreadcrumb')){
        var colDisplace = document.getElementById('productBreadcrumb').offsetHeight;
      }

      var heightLeft = document.getElementById('leftcol').offsetHeight;
      if (heightLeft > defaultLeft){
        thisDiff = heightLeft - defaultLeft;
        if (thisDiff > heightDifference){
          heightDifference = thisDiff;
        }
      }

      var heightRight = document.getElementById('rightcol').offsetHeight;
      if (heightRight > defaultRight){
        thisDiff = heightRight - defaultRight;
        if (thisDiff > heightDifference){
          heightDifference = thisDiff;
        }
      }

      if (document.getElementById('column1')){
        var heightCol1 = document.getElementById('column1').offsetHeight;
        if (heightCol1 > defaultCol1){
          thisDiff = heightCol1 - defaultCol1;
          if (thisDiff > heightDifference){
            heightDifference = thisDiff;
          }
        }
      }

      if (document.getElementById('column2')){
        var heightCol2 = document.getElementById('column2').offsetHeight;
        if (heightCol2 > defaultCol2){
          thisDiff = heightCol2 - defaultCol2;
          if (thisDiff > heightDifference){
            heightDifference = thisDiff;
          }
        }
      }

      if (document.getElementById('column3')){
        var heightCol3 = document.getElementById('column3').offsetHeight;
        if (heightCol3 > defaultCol3){
          thisDiff = heightCol3 - defaultCol3;
          if (thisDiff > heightDifference){
            heightDifference = thisDiff;
          }
        }
      }

      var newLeft = defaultLeft + heightDifference + colDisplace - paddingLeft;
      document.getElementById('leftcol').style.height=newLeft+"px";

      var newRight = defaultRight + heightDifference + colDisplace - paddingRight;
      document.getElementById('rightcol').style.height=newRight+"px";

      if (document.getElementById('column1')){
        var newCol1 = defaultCol1 + heightDifference - paddingCol1;
        document.getElementById('column1').style.height=newCol1+"px";
      }

      if (document.getElementById('column2')){
        var newCol2 = defaultCol2 + heightDifference - paddingCol2;
        document.getElementById('column2').style.height=newCol2+"px";
      }

      if (document.getElementById('column3')){
        var newCol3 = defaultCol3 + heightDifference - paddingCol3;
        document.getElementById('column3').style.height=newCol3+"px";
      }
    }
  }

