﻿// handy...
// http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

var pre_avail = 0;
var myWidth = 0, myHeight = 0;

function setAvail() 
{
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
    pre_avail = myHeight;
}

function expandDoc()
{
    setAvail();
    // for firefox, use the value set at before page load
    if (pre_avail>0) 
    { // allow for toolbars
        availH = (pre_avail+170);
    }

    // no scrollbars
    if ((availH>600) && (document.body.style))
    {   // allow the doc the have scrolling content
        {
            // max doc size
            makeHeight ('idLower', (availH - 300), '');
            makeHeight ('idMain', (availH - 425), 'auto');
            makeHeight ('idDoc', (availH), '');
//            window.document.body.style.overflow = 'hidden';
        }
    }
    else
    {
        var allHTML = window.document.getElementById('idHTML');
        if (allHTML)
        {
            allHTML.style.overflow = 'auto';
            makeHeight ('idLower', '100%', '');
            makeHeight ('idMain', '100%', 'auto');
        }
    }

    //window.status = 'Avail = ' + availH;
    //window.status = 'Avail = ' + availH + ' Doc =' + window.document.getElementById('idDoc').style.height + ' height. lower=' + window.document.getElementById('idLower').style.height + ' main=' + window.document.getElementById('idMain').style.height;
}

function makeHeight(id,h,flow)
{
    var o = window.document.getElementById(id);
    if (o)
    {
        if (h=='100%') {o.style.height = '100%';}
        else
        if (h>0) {o.style.height = h + 'px';}
        if (flow!='') {o.style.overflow = flow;}
    }
}

function showProducts()
{
    var m = window.document.getElementById('idSubMenu');
    if (m)
    {
        m.style.display = 'block';
        m.style.visibility = 'visible';
    }
}