
	var Des = {

		init : function() {

			Des.booking_dropdown();
			Des.before_after();
			Des.tweaks();

		},	//	init : function()

		booking_dropdown : function() {

			$('#booking_dropdown select').change(function() {
				window.location = $(this).val();
			});

		},

		before_after : function() {

			if ($('ul.before_after').get(0)) {
				if (css_on()) {
					$('ul.before_after a').click(function() {
						ba_href = $(this).attr('href');
						if (!$('.modal_overlay').get(0)) {
							modal_overlay(ba_href);
						} else {
							modal_get(ba_href);
						}
						return false;
					});
				}
			}

			function modal_close() {
				$('.modal_content')
					.stop()
					.animate({ opacity : 0 }, 250, 'linear', function() {
						$(this).remove();
						$('.modal_overlay').animate({ opacity : 0 }, 250, 'linear', function() { $(this).remove(); });
				});

				return false;
			}

			function modal_get(ba_href) {
				$.ajax({
					type:     'GET',
					url:      ba_href,
					data:     'ajax=true',
					dataType: 'html',
					success:  function(response) {
						modal_react(response);
					}
				});
			}
			
			function modal_overlay(ba_href) {
				body = { height : $('body').height(), width : $('body').width() }
			
				$('<div class="modal_overlay"> </div>')
					.appendTo('body')
					.stop()
					.css({ cursor : 'pointer', height : body.height, opacity : 0, width : body.width })
					.animate({ opacity : .5 }, 250, 'linear', function() {
						modal_get(ba_href);						
					})
					.click(function() {
						if ($('.modal_content').get(0)) {
							$('.modal_content').animate({ opacity : 0 }, 250, 'linear', function() { $(this).remove(); });
						}

						$(this)
							.stop()
							.animate({ opacity : 0 }, 500, 'linear', function() { $(this).remove(); });
					});
			}
		
			function modal_react(response) {
				if (!$('.modal_content').get(0)) {
					$('<div class="modal_content"></div>')
						.appendTo('body')
						.stop()
						.css({ opacity : 0 });
						
					modal_insert(response);
				} else {
					$('.modal_content').animate({ opacity : 0 }, 250, 'linear', function() {
						$(this).empty();
						modal_insert(response);
					});
				}
			}

			function modal_insert(response) {
				$(response).appendTo('.modal_content');

				modal_height = $('.modal_content').height();
				margin_top = '-' + Math.round(modal_height / 2).toString();

				$('.modal_content')
					.css({ marginTop : margin_top + 'px' })
					.animate({ opacity : 1 }, 250, 'linear', function() {

						$(window).keydown(function(e) {
							if (e.keyCode == 27) modal_close();
						});
					
						$('.button a').click(function() {
							modal_close();
							return false;
						});

						$('a#nav_before').click(function() {
							if (!$('.before_after_content.before').get(0)) {
								ba_href = $(this).attr('href');
								modal_get(ba_href);
							}

							return false;
						});

						$('a#nav_after').click(function() {
							if (!$('.before_after_content.after').get(0)) {
								ba_href = $(this).attr('href');
								modal_get(ba_href);
							}

							return false;
						});
				});
			}
		
		},



		tweaks : function () {

			//	CSS TEST MARKUP, YEAH?
			$('<div class="css_test"><p></p></div>').appendTo('body');

			//	TWEAK CSS AND THAT
			if ($('.quick_links').get(0)) {
				$('.quick_links').equalHeights(true);
				$('.quick_links a').bigTarget();
			}

			if ($('.navigation').get(0)) {
				$('.navigation li:last').addClass('last');
				$('.navigation li li:last').addClass('last');
			}

			//	FIREBUG - Load it up, load it up real good!
			if ($.isFunction(window.loadFirebugConsole)) window.loadFirebugConsole();

		}	//	tweaks : function ()

	};	//	var Des = {}

	//	Set this thing on fire!
	$(function() { Des.init(); });

