// Method called by the flash header.
var jumpToSection;

$.fn.delay = function(time, callback) {
    // Empty function:
    jQuery.fx.step.delay = function() { };
    // Return meaningless animation, (will be added to queue)
    return this.animate({ delay: 1 }, time, callback);
}

$(function() {
	
  // News "more" links.
  $("#news a.more, #news h3 a").click(function(e) {
    e.preventDefault();

    var modalOptions = $.extend(modal.getOptions(), {
      containerCss: { width: "554px", height: "335px" }
    });

    // Need to find the content div if either of the details links were clicked.
    $(this).closest("li").find(".article").clone().modal(modalOptions);
  });

  // Portfolio links.
  $("#portfolio li > a").click(function(e) {
    e.preventDefault();

    var modalOptions = $.extend(modal.getOptions(), {
      containerCss: { width: "1131px", height: "679px" }
    });

    $(this).closest("li").find(".article").clone().modal(modalOptions);
  });


  // Modal configuration.
  var modal = {
    speed: 300,
    closeButton: "<a href='' title='Close' class='close'>x</a>",

    getOptions: function() {
      return {
        closeHTML: modal.closeButton,
        onOpen: modal.open,
        onClose: modal.close
      };
    },

    open: function(dialog) {
      dialog.data.show();
      dialog.overlay.fadeIn(modal.speed);
      dialog.container.fadeIn(modal.speed);
    },

    close: function(dialog) {
      dialog.overlay.fadeOut(modal.speed);
      dialog.container.fadeOut(modal.speed, function() {
        $.modal.close();
      });
    }
  };

  // Define the method here to make use of the jQuery closure awesomeness.
  jumpToSection = function(section) {
    var speed = 500;

    switch (section) {
      case "artwork":
        $(window).scrollTo("#portfolio", speed);
        break;

      case "solutions":
        $(window).scrollTo("#services", speed);
        break;

      case "contact":
        $(window).scrollTo("#contact", speed);
        break;
    }
  };
});
