var Site = {
  start: function() {
    var list = $$('#tabs li');
    var anchors = $$('#tabs li a');
    
    list.each(function(element) {
      var fx = new Fx.Styles(element, {duration: 200, wait: false});
      var bgcolor = element.getStyle('background-color');
      var height = element.getStyle('height');
      var marginTop = element.getStyle('margin-top');
      var paddingBottom = element.getStyle('padding-bottom');
      var shiftAmount = 15;

      element.addEvent('mouseenter', function() {
        fx.start({
          'height': height + 10,
          'padding-bottom': shiftAmount,
          'margin-top': shiftAmount*-1,
          'background-color': '#cc4444'
          });
        });
      
      element.addEvent('mouseleave', function() {
        fx.start({
          'height': height,
          'padding-bottom': paddingBottom,
          'margin-top': marginTop,
          'background-color': bgcolor
        });
      });
      
    });
    
    anchors.each(function(element) {
      var fx = new Fx.Styles(element, {duration: 200, wait: false});
      var color = element.getStyle('color');
      
      element.addEvent('mouseenter', function() {
        fx.start({
          'color': '#ffffff'
          });
        });
      
      element.addEvent('mouseleave', function() {
        fx.start({
          'color': color
        });      
      });
    });
    
    setWrap();
  }
};

function getX(obj)
{
  //Set the initial offset
  //This will be the final offset on some browsers
  var total = obj.offsetLeft;

  //As long as the object has a parent's offset, add it
  while (obj.offsetParent)
  {
    //Save the parent
    obj = obj.offsetParent;
    //Add the offset to the total
    total += obj.offsetLeft;
  }

  return total;
}

function getY(obj)
{
  //Set the initial offset
  //This will be the final offset on some browsers
  var total = obj.offsetTop;

  //As long as the object has a parent's offset, add it
  while (obj.offsetParent)
  {
    //Save the parent
    obj = obj.offsetParent;
    //Add the offset to the total
    total += obj.offsetTop;
  }

  return total;
}

function getWindowHeight() 
{ 
  var windowheight = 0;
  if (typeof(window.innerHeight) == 'number') 
  { 
    windowheight = window.innerHeight; 
  } 
  else 
  { 
    windowheight = document.documentElement.clientHeight;
  } 
  return windowheight; 
} 

function setWrap() 
{ 
  var windowheight = getWindowHeight();
  if (windowheight > 0) 
  { 
    var wrapElement = $('footer'); 
    wrapElement.style.position = 'absolute';
    var ycoord = getY(wrapElement);
    wrapElement.style.height = (windowheight - ycoord) + 'px';
    wrapElement.style.width = '100%';
  }
} 

function addLoadEvent(func) 
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
  {
    window.onload = func;
  } 
  else 
  {
    window.onload = function() 
    {
      if (oldonload) 
      {
        oldonload();
      }
      func();
    }
  }
}

window.onresize = function() { 
  setWrap(); 
}

window.addEvent('load', Site.start);