$(document).ready(function(){

		// Auto-populate form fields with their titles
		$('.populate').each(function(){
			var e = $(this);
			if (!e.val()) { e.val(e.attr('title')); }
			e.focus(function(){
				var e = $(this);
				if (e.attr('title') == e.val()) { e.val(''); }
			});
					
			e.blur(function(){
				var e = $(this);
				if (!e.val()) { e.val(e.attr('title')); }
			});
		});
		
		// Simple animation for #top links
		$('a[href=#top]').click(function(){
			$('html, body').animate(
				{ scrollTop:0 }, 500
			);
			return false;
		});
					
		// Make external links open in new windows	
		$('a').each(function(){
			if (this.href.match('^https?://(?!'+document.location.hostname+')')) {
				this.target = '_blank';
			}
		});
		
		// Menus
		$("ul#nav li").hoverIntent(showMenu, hideMenu);
		
		function showMenu(){
			$(this).addClass('current');
			$("ul", this).slideDown('fast');
		}
		
		function hideMenu(){
			current = $(this);
			$("ul", this).slideUp('fast', function(){$(current).removeClass('current')});
		}
		
		// Book Now links
		$('a.bn-btn').colorbox({width:"600px", href:"/_global/_booknow"});

		// Gallery
		$('.gallery a').colorbox();
});
