function getPageSize() {
  var xs = document.documentElement.offsetWidth;
  var ww = document.documentElement.clientWidth;
  var ys = document.documentElement.offsetHeight;
  var wh = document.documentElement.clientHeight;
  var oh = document.body.offsetHeight;
  var ph = ys < wh ? wh : ys;
  var pw = xs < ww ? xs : ww;
  settings = {
    width: pw,
    height: oh,
    windowWidth: ww,
    windowHeight: wh,
    scrollX: document.documentElement.scrollLeft,
    scrollY: document.documentElement.scrollTop
  };
  return settings;
};

function animarEntrada(callback){
  $('#coluna2 button, #coluna2 select, #coluna2 input, #coluna2 textarea').css('visibility', 'hidden');
  var w = $('#popup').width();
  var h = $('#popup').height();
  $('#popup')
      .css({width: 0, height: 0})
      .animate({width: w, height: h}, 200, function(){
        if(typeof callback == 'function'){
            callback();
          }
      });
}

function animarSaida() {
  $('.fundo, .close_overlayer').click(function(){
    $('#overlayer').fadeOut(500, function(){
      $(this).remove();
      $(window).unbind('resize');
      $(window).unbind('scroll');
    });
    $('#coluna2 button, #coluna2 select, #coluna2 input, #coluna2 textarea').css('visibility', 'visible');
  });
}

function abrirOverlayer(pagina, callback){
  $('body').append('<div id="overlayer"></div>');
  $('#overlayer')
      .css(getPageSize())
      .show()
      .append('<div class="fundo"></div>')
      .append('<div class="corpo"></div>');
  $('#overlayer .fundo')
      .css({opacity: 0.0})
      .animate({opacity: 0.8}, 400, function(){
        $('#overlayer .corpo').load(pagina, function(){
          if(typeof callback == 'function'){
            callback();
          }
        });
      });
}