/************************************************************************************
    Copyright © 2010 xhub.com

    Bill Bennert
    cb@xhub.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Any system sensitive data such as IP addresses, usernames, and passwords 
    must be removed from this file before distribution.

************************************************************************************/

var browserWidth;
var browserHeight;

function getBrowserWidth()
{
  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;
  }
  browserHeight = myHeight;
  browserWidth = myWidth;
}

function reSize()
{
  getBrowserWidth();
  positionElements();
  t=setTimeout("reSize()",250);
}

function positionElement(elementId, position, xoffset, yoffset)
{
  var element = document.getElementById(elementId);
  if (position == "TopLeft")
  {
    element.style.top = yoffset+"px";
    element.style.left = xoffset+"px";
  }
  else if (position == "TopRight")
  {
    element.style.top = yoffset+"px";
    element.style.left = browserWidth-element.clientWidth-xoffset+"px";
  }
  else if (position == "BottomLeft")
  {
    element.style.top = browserHeight-element.clientHeight-yoffset+"px";
    element.style.left = xoffset+"px";
  }
  else if (position == "BottomRight")
  {
    element.style.top = browserHeight-element.clientHeight-yoffset+"px";
    element.style.left = browserWidth-element.clientWidth-xoffset+"px";
  }
  else if (position == "Center")
  {
    element.style.top = (browserHeight/2)-(element.clientHeight/2)+"px";
    element.style.left = (browserWidth/2)-(element.clientWidth/2)+"px";
  }
  else if (position == "HorizontalCenter")
  {
    element.style.left = (browserWidth/2)-(element.clientWidth/2)+"px";
  }
  else if (position == "VerticalCenter")
  {
    element.style.top = (browserHeight/2)-(element.clientHeight/2)+"px";
  }
  else if (position == "TopCenter")
  {
    element.style.top = yoffset+"px";
    element.style.left = (browserWidth/2)-(element.clientWidth/2)+"px";
  }
  else if (position == "BottomCenter")
  {
    element.style.top = browserHeight-element.clientHeight-yoffset+"px";
    element.style.left = (browserWidth/2)-(element.clientWidth/2)+"px";
  }
  else if (position == "LeftCenter")
  {
    element.style.top = (browserHeight/2)-(element.clientHeight/2)+"px";
    element.style.left = xoffset+"px";
  }
  else if (position == "RightCenter")
  {
    element.style.top = (browserHeight/2)-(element.clientHeight/2)+"px";
    element.style.left = browserWidth-element.clientWidth-xoffset+"px";
  }
  else
  {}
}

function positionElements()
{
  positionElement("id_debian", "BottomRight", 5, 5);
  positionElement("id_rackspace", "BottomCenter", 0, 5);
  positionElement("id_main", "Center", 0, 0);
}