// needed to auto-center the #page div
// but only for high resolutions
(function ($) {
   $.fn.vAlign = function() {
     return this.each(function(i) {
       var ah = $(this).height();
       var ph = $(window).height();
       var mh = (ph - ah) / 2;

       if (mh > 0) $(this).css('margin-top', mh);
     });
   };
})(jQuery);

(function ($) {
  $.fn.hAlign = function() {
    return this.each(function(i){
      var w = $(this).width();
      var ow = $(this).outerWidth();
      var ml = (w + (ow - w)) / 2;
      
      $(this).css("margin-left", "-" + ml + "px");
      $(this).css("left", "50%");
      $(this).css("position", "absolute");
    });
  };
})(jQuery);

$(window).resize(function() {
  $("#page").vAlign();
});

$(document).ready(function() {
  $("#content > div").hide();
  $("#content_home").show();

  $("#menu_home").click(function() {
    $("#content > div").hide();
    $("#content_home").show();
  });

  $("#menu_about").click(function() {
    $("#content > div").hide();
    $("#content_about").show();
  });

  $("#menu_gallery").click(function() {
    $("#content > div").hide();
    $("#content_gallery").show();
  });

  $("#menu_contact").click(function() {
    $("#content > div").hide();
    $("#content_contact").show();
  });

  $("a.gallery").openDOMWindow({
    height: 720,
    width: 750,
    eventType: 'click',
    windowSource: 'iframe',
    windowPadding: 0
  });

  $("#page").vAlign();
});

