/*
 * SimpleModal OSX Style Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2009 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: osx.js 213 2009-09-17 04:10:02Z emartin24 $
 */

jQuery(function($) {
    $("input.osx, a.osx").click(function(e) {
        e.preventDefault();

        $("#osx-modal-content").modal({
            overlayId: 'osx-overlay',
            zIndex:1000,
            containerId: 'osx-container',
            closeHTML: '<div class="close"><a href="#" class="simplemodal-close">x</a></div>',
            minHeight: 80,
            opacity: 65,
            position: ['0', ],
            overlayClose: true,
            onOpen: OSX.open,
            onClose: OSX.close
        });
    });
    
    

    var OSX = {
        container: null,
        open: 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 },
							200,
							function() {
							    $("div.close", self.container).show();
							    $("#osx-modal-data", self.container).show();
							}
						);
                    }, 300);
                });
            })
        },
        close: function(d) {
            var self = this;
            d.container.animate(
				{ top: "-" + (d.container.height() + 20) },
				500,
				function() {
				    self.close(); // or $.modal.close();
				}
			);
        }
    };







    //ORDER LEASINGNYTT
    $("input.osx2, a.osx2").click(function(e) {
        e.preventDefault();

        $("#osx-modal-content-leasingnytt").modal({
            overlayId: 'osx-overlay-leasingnytt',
            zIndex: 1000,
            containerId: 'osx-container-leasingnytt',
            closeHTML: '<div class="close-leasingnytt"><a href="#" class="simplemodal-close-leasingnytt">x</a></div>',
            minHeight: 80,
            opacity: 65,
            position: ['0', ],
            overlayClose: true,
            onOpen: OSX2.open,
            onClose: OSX2.close
        });
    });



    var OSX2 = {
        container: null,
        open: function(d) {
            var self = this;
            self.container = d.container[0];
            d.overlay.fadeIn('slow', function() {
            $("#osx-modal-content-leasingnytt", self.container).show();
            var title = $("#osx-modal-title-leasingnytt", self.container);
                title.show();
                d.container.slideDown('slow', function() {
                    setTimeout(function() {
                    var h = $("#osx-modal-data-leasingnytt", self.container).height()
							+ title.height()
							+ 20; // padding
                        d.container.animate(
							{ height: h },
							200,
							function() {
							$("div.close-leasingnytt", self.container).show();
							    $("#osx-modal-data-leasingnytt", self.container).show();
							}
						);
                    }, 300);
                });
            })
        },
        close: function(d) {
            var self = this;
            d.container.animate(
				{ top: "-" + (d.container.height() + 20) },
				500,
				function() {
				    self.close(); // or $.modal.close();
				}
			);
        }
    };

});
