// window.js

// Define a function to create new window popup
function openPopup(url,target,pW,pH) {
	new_window_width = pW;                                   // width of new window
	new_window_height = pH;                                  // height of new window

	screen_height = getScreenHeight();				// funciton from screen.js
	screen_width = getScreenWidth();					// funciton from screen.js

	new_window_top = (screen_height / 2) - (new_window_height / 2);
    new_window_left = (screen_width / 2) - (new_window_width / 2);

	popupWin = window.open(url, target, "toolbar=no,location=no,scrollbars=no,width=" + new_window_width + ",height=" + new_window_height + ",left=" + new_window_left + ",top=" + new_window_top);
	popupWin.focus(); 
}

function getWindowWidth() {
  myWidth = 0;

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement &&document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && document.body.clientWidth ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }

  return myWidth;
}

function getWindowHeight() {
  myHeight = 0;

  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }

  return myHeight;
}

function getWindowLeft() {
  myLeft = 0;

  if( typeof( window.innerLeft ) == 'number' ) {
    //Non-IE
    myLeft = window.innerLeft;
  } else if( document.documentElement && document.documentElement.clientLeft ) {
    //IE 6+ in 'standards compliant mode'
    myLeft = document.documentElement.clientLeft;
  } else if( document.body && document.body.clientLeft ) {
    //IE 4 compatible
    myLeft = document.body.clientLeft;
  }

  return myLeft;
}

function getWindowTop() {
  myTop = 0;

  if( typeof( window.innerTop ) == 'number' ) {
    //Non-IE
    myTop = window.innerTop;
  } else if( document.documentElement && document.documentElement.clientTop ) {
    //IE 6+ in 'standards compliant mode'
    myTop = document.documentElement.clientTop;
  } else if( document.body && document.body.clientTop ) {
    //IE 4 compatible
    myTop = document.body.clientTop;
  }

  return myTop;
}