function bookingModal() {

	// Append the modal background to the body
	jQuery('<div />').attr({'id' : 'modal-background'}).prependTo('body');

	var $modalLink = jQuery('.modal-link');
	
	var $modalBackground = jQuery('#modal-background');
	var $modalWindow = jQuery('#modal-window');
	var $modalContainer = jQuery('#modal-container');
	var $modalClose = jQuery('#modal-close');

	var modalWindowWidth = parseFloat($modalWindow.css('width'));

	$modalLink.click(function(){

		$modalBackground.css({'display':'block'});
		$modalWindow.css({
			'display' : 'block',
			'position' : 'absolute',
			'left' : (wSize().w - modalWindowWidth) / 2 +'px'
		});
		
		var bookType = jQuery(this).attr('id');
		if (bookType == 'modal-link-edit') { 
			$modalContainer.html('<iframe id="modal-iframe-edit" class="modal-iframe" src="http://bookingv2.experimentarium.dk/edit.php" allowtransparency="true" frameborder="0"></iframe>');
		} else {
			$modalContainer.html('<iframe id="modal-iframe-book" class="modal-iframe" src="http://bookingv2.experimentarium.dk/booking_start.php?type=date" allowtransparency="true" frameborder="0"></iframe>');
		}

		jQuery('iframe.modal-iframe').load(function() { $modalClose.show(); });


	});


	$modalClose.click(function() {
		$modalWindow.css({'display' : 'none'});
		$modalContainer.empty();
		$modalClose.hide();
		$modalBackground.css({'display' : 'none'});
	});



	jQuery(window).bind('resize', function() {
		var height = wSize().h;
		if (dSize().h > wSize().h) { height = dSize().h; }
		$modalBackground
			.css({
				'width':wSize().w+'px',
				'height':height+50+'px'
			});
		$modalWindow.css({ 'left' : (wSize().w - modalWindowWidth) / 2 +'px' });
	});
}


function wSize() {
	var h = jQuery(window).height();
	var w = jQuery(window).width();
	return {h : h, w : w}
}

function dSize() {
	var h = jQuery(document).height();
	var w = jQuery(document).width();
	return {h : h, w : w}
}
