/*  triangle.js
    for use with Triangle website
    */
function init()
{
    centerPage();
    window.onresize = centerPage;
}

function centerPage()
{
    var bigDiv = document.getElementById( 'containest' );
/*  The top margin should be the
    ( window.height - bigDiv.height ) / 2 in pixels */
    var windowHeight = getWindowHeight();   
    var divHeight = bigDiv.offsetHeight;
    divHeight += 30;    // bump it up a little
    if( windowHeight > divHeight )
    {
        var newTop = ( windowHeight - divHeight ) / 2;
    }
    else
    {
        var newTop = 5;
    }
    bigDiv.style.marginTop = newTop + "px";
}


/*  Taken from http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=16 */
function getWindowHeight() {
  var myWidth = 0, myHeight = 0;
  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;
  }
    return myHeight;
}

