/*
 * SimpleModal OSX Style Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2010 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: osx.js 238 2010-03-11 05:56:57Z emartin24 $
 */

  function osxmodal(sStartDate, sStartTime, sEndDate, sEndTime, sLocation, sLink, sHeaderText, sDescription){
  
    $("#osx-modal-data").html(
        "<br><h2>" + sHeaderText + "</h2>" + 
        "<table>" +
        "<tr><td>Starttid:</td><td>" + sStartDate + " " + sStartTime + "</td></tr>" +
        "<tr><td>Sluttid:</td><td>" + sEndDate + " " + sEndTime + "</td></tr>" +
        "<tr><td>Sted:</td><td>" + sLocation + "</td></tr>" +
        "<tr><td>Link:</td><td><a href='" + sLink + "' target='_blank'>" + sLink + "</a></td></tr>" +
        "</table>" + 
        "<p>" + sDescription + "</p><p><button class=\"simplemodal-close\">Luk</button></p>");

    $("#osx-modal-content").modal({
          overlayId: 'osx-overlay',
          containerId: 'osx-container',
          closeHTML: null,
          minHeight: 80,
          opacity: 65, 
          position: ['30%',],
          overlayClose: true,

          onOpen: function (d) {
      var self = this;
      self.container = d.container[0];
      d.overlay.fadeIn('slow', function () {
        $("#osx-modal-content", self.container).show();
        var title = $("#osx-modal-title", self.container);
        title.show();
        d.container.slideDown('slow', function () {
          setTimeout(function () {
            var h = $("#osx-modal-data", self.container).height()
              + title.height()
              + 20; // padding
            d.container.animate(
              {height: h}, 
              300,
              function () {
                $("div.close", self.container).show();
                $("#osx-modal-data", self.container).show();
              }
            );
          }, 200);
        });
      })
    },
                     
      onClose: function (d) {
      var self = this; // this = SimpleModal object
      d.container.animate(
        {top:"-" + (d.container.height() + 20)},
        500,
        function () {
          self.close(); // or $.modal.close();
}
);
}
});
}
