
function includeJS(url) { document.writeln("<script type=\"text/javascript\" src=\"" + url + "\"></script>"); }
function includeCSS(url) { document.writeln("<style type=\"text/css\">@import url(\"" + url + "\");</style>"); }

includeJS("_assets/_js/UtilityFunctions.js");


/* css drop downs */
var totalLists = 1;
var ua = navigator.userAgent.toLowerCase();
var av = navigator.appVersion.toLowerCase();
var mac = ( av.indexOf( 'mac' ) != -1 );
var saf = ( ua.indexOf( 'safari' ) != -1 );
var ie5x = ( document.all && document.getElementById );
var ie5mac = ( mac && ie5x );

function calcHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    /*Non-IE*/
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    /*IE 6+ in 'standards compliant mode'*/
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    /*IE 4 compatible*/
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}


function hideall(ListNum) {
  divItem = document.getElementById('Lst'+ListNum);
  divItem.style.display="none";
  document.getElementById('dropPlus'+ListNum).className = "dropPlus"; // change the drop down icon
}

/* css drop downs - modified js */

var LastListNum = "";

function checkHeightNew(listNum)
{
  var list = document.getElementById("Lst" + listNum);  
    list.parentNode.style.position = "relative";
    list.parentNode.style.zIndex = "2000";
    
  var winHeight = calcHeight();
  var scrollOffset = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
  list.style.overflow = "auto";
  list.style.height = "";
      
  var drop = document.getElementById("Drp" + listNum);
  var dropPos = getTotalOffset(drop);
  var dropHeight = drop.offsetHeight;
  var magicNumber = 30; // ????
  var spaceBelow = winHeight - (dropPos + dropHeight - scrollOffset) - magicNumber;
  var spaceAbove = dropPos - scrollOffset - magicNumber;

  var maxSpace = Math.max(spaceAbove, spaceBelow);
  var lstHeight = (list.offsetHeight > maxSpace)? maxSpace : list.offsetHeight;
            

    // decrease height of footer subscription links dropdown on video archive pages to prevent overlap of video and dhtml            
  if (document.URL.indexOf('videoarchives/?designer') != -1 && ListNum == 10) 
    lstHeight = lstHeight - 140;

  var magicNumber2 = -2;
  list.style.width = (drop.offsetWidth + magicNumber2) + "px";            
  list.style.height = lstHeight + "px"; // adjust the menu height according to the space available

  var lstTop = dropHeight;  
  list.style.bottom = "";
  list.style.top = dropHeight + "px";
  
  if(spaceBelow < lstHeight) { // Display above
    list.style.top = "";
    list.style.bottom = dropHeight + "px";
  }

    var listTable = document.getElementById("LstTable" + listNum);
    listTable.style.width = "";
  if (isIE && list.offsetHeight > maxSpace) {
    var magicNumber3 = -17;
    listTable.style.width = (listTable.offsetWidth + magicNumber3) + "px";
  }
}

function showListNew(listNum)
{
    if (LastListNum == listNum)
    closeDropDownNew();
  else {
    closeDropDownNew();
    LastListNum = listNum;
    var listId = "Lst" + listNum;
    var list = document.getElementById(listId);
    if (list) {
      list.style.display = "block"; 

      var dropdown_iframe = document.getElementById("dropdown_iframe");
      if (document.all && dropdown_iframe) {
        var iframe_height = list.offsetHeight - 3 + "px";
        dropdown_iframe.style.height = iframe_height;
        dropdown_iframe.style.display = "block";
        dropdown_iframe.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
      }
                        
      document.getElementById("dropPlus" + listNum).className = "dropPlusOver"; // change the pull down icon
      checkHeightNew(listNum); 
    }
  }
}

function closeDropDownNew()
{
  if (LastListNum != "") {
    var listId = "Lst" + LastListNum;
    var list = document.getElementById(listId);
    if (list) {
          list.style.display = "none";
        list.parentNode.style.position = "";
        list.parentNode.style.zIndex = "";
            
            var dropdown_iframe = document.getElementById("dropdown_iframe");
      if (document.all && dropdown_iframe)
        dropdown_iframe.style.display = "none";
            
          document.getElementById("dropPlus" + LastListNum).className = "dropPlus";
    }
      LastListNum = ""; // set the menu ID to null 
  }
}









/* cache css bg images for IE6 */
if ( document.all )
{  
    try {
      document.execCommand("BackgroundImageCache", false, true);
    } catch(err) {}
}



