/*******************************************************************
 * common_difference.js                                            *
 *                                                                 *
 * Copyright (c) 2008 Christopher Wirsing. All Rights Reserved.    *
 *                                                                 *
 * Permission to use, copy, modify, and distribute this software   *
 * and its documentation for any purposes and without              *
 * fee is hereby denied!                                           *
 *                                                                 *
 ******************************************************************/
 
// register this first in your html code 
// bevore you use this script:
// document.onkeydown = keyDown;
// document.onkeyup = keyUp;
 
var RightKey = false;

function keyDown(Ereignis) {
  
  if (!Ereignis) {
  	Ereignis = window.event;
  }
  
  if (Ereignis.which) {
    PressedKeyCode = Ereignis.which;
  } else if (Ereignis.keyCode) {
    PressedKeyCode = Ereignis.keyCode;
  }
  
  if (PressedKeyCode == 122) {
    RightKey = true;
  } else {
    RightKey = false;
  }
}

function keyUp() {
  
  // here we get the whole height of the showen screen
  var PixelsTotal = getHeightOfShowenScreen();
  
  // here we set the pixel which we dont want to give it to the element which height we want to set dynamically
  var PixelsNeeded = 1*(document.getElementById('results_box').offsetTop + 130);
  
  // here we set the height of the element which height we want to set dynamically
  document.getElementById('results_box').style.height = 1*(PixelsTotal - PixelsNeeded) + 'px';
  
  // so, the key f11 has done it works... cya later ;-)
  RightKey = false;
  return true;
}

function getHeightOfShowenScreen() {
  var myHeight = 0;
  
  // check if the browser is non-ie
  if( typeof( window.innerHeight ) == 'number' ) {
    myHeight = window.innerHeight;
    
  // now check if its IE 6+ in 'standards compliant mode'
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    myHeight = document.documentElement.clientHeight;
    
  // or is it IE 4 compatible ?
  } else if( document.body && ( document.body.clientHeight ) ) {
    myHeight = document.body.clientHeight;
  }
  
  return myHeight;
}

