$.fn.maximizeToWindow = function(){
  $(this).css({
    "position": "fixed",
    "left": 0,
    "top": 0
  })
  .width($(window).width())
  .height($(window).height());
  return $(this);
}
$.fn.centerAlign = function(target, offset){
  if(typeof(offset) == "undefined" ) offset = 0;
  $(this).css({
    "left": Math.round(halfWidth(target) - halfWidth($(this)))
  });
  return $(this);
}

$.fn.alignToWindow = function(){
  $(this).css({
    "left": ($(window).width()/2)-($(this).width()/2),
    "top": ($(window).height()/2)-($(this).height()/2)
  });
  return $(this);
}

function halfWidth(element){return element.width()/2;}
function halfHeight(element){return element.height()/2;}


