$(document).ready(function() {
	$('.butlers-dialog').dialog({autoOpen:false, resizable:false, draggable:false, width:540, height:475, modal:true, overlay:{opacity:0.5, background:'black'}});
	
	$('.facts-dialog').dialog({autoOpen:false, resizable:false, draggable:false, width:540, height:475, modal:true, overlay:{opacity:0.5, background:'black'}});
	$('a.facts-dialog-open').click(function(){
		
		// Pull the page in over AJAX
		$.get($(this).attr('href'), function(data){
			
			// Place the page content into the popups content div
			$('#facts-content').html(data);
			
			// Hide the loading image, display the content
			$('#facts-loading').css('display', 'none');
			$('#facts-content').css('display', 'block');
		
			
			var path = '/wordpress/wp-content/themes/butlers/images/butlers/';
			
		});
		
		$('.facts-dialog').css('display', 'block');
		$('.facts-dialog').dialog('open');
		
		return false;
	});	
	
	$('a.butlers-dialog-open').click(function(){
		
		// Pull the page in over AJAX
		$.get($(this).attr('href'), function(data){
			
			// Place the page content into the popups content div
			$('#butlers-content').html(data);
			
			// Hide the loading image, display the content
			$('#butlers-loading').css('display', 'none');
			$('#butlers-content').css('display', 'block');
			
			$('#butlers > ul').tabs();
			
			var path = '/wordpress/wp-content/themes/butlers/images/butlers/';
			
			$('#img-alfred').hover(
				function() { $(this).attr('src', path + 'Alfred2.jpg'); },
				function() { $(this).attr('src', path + 'Alfred1.jpg'); }
			);
			$('#img-beddows').hover(
				function() { $(this).attr('src', path + 'Beddows2.jpg'); },
				function() { $(this).attr('src', path + 'Beddows1.jpg'); }
			);
			$('#img-brabbinger').hover(
				function() { $(this).attr('src', path + 'Brabbinger2.jpg'); },
				function() { $(this).attr('src', path + 'Brabbinger1.jpg'); }
			);
			$('#img-coleman').hover(
				function() { $(this).attr('src', path + 'Coleman2.jpg'); },
				function() { $(this).attr('src', path + 'Coleman1.jpg'); }
			);
			$('#img-fairchild').hover(
				function() { $(this).attr('src', path + 'Fairchild2.jpg'); },
				function() { $(this).attr('src', path + 'Fairchild1.jpg'); }
			);
			$('#img-hobson').hover(
				function() { $(this).attr('src', path + 'Hobson2.jpg'); },
				function() { $(this).attr('src', path + 'Hobson1.jpg'); }
			);
			$('#img-hudson').hover(
				function() { $(this).attr('src', path + 'Hudson2.jpg'); },
				function() { $(this).attr('src', path + 'Hudson1.jpg'); }
			);
			$('#img-jeeves').hover(
				function() { $(this).attr('src', path + 'Jeeves2.jpg'); },
				function() { $(this).attr('src', path + 'Jeeves1.jpg'); }
			);
			$('#img-merrimen').hover(
				function() { $(this).attr('src', path + 'Merrimen2.jpg'); },
				function() { $(this).attr('src', path + 'Merrimen1.jpg'); }
			);
			$('#img-stevens').hover(
				function() { $(this).attr('src', path + 'Stevens2.jpg'); },
				function() { $(this).attr('src', path + 'Stevens1.jpg'); }
			);
		});
		
		$('.butlers-dialog').css('display', 'block');
		$('.butlers-dialog').dialog('open');
		
		return false;
	});

	$('.butlers-dialog-close').click(function() {
		$('.butlers-dialog').dialog('close');
	});
	
	$('.facts-dialog-close').click(function() {
		$('.facts-dialog').dialog('close');
	});	
	
	if ($('.wp_quotes_author').length > 0) {
		$('.wp_quotes_author').hide();
	}
	if ($('.wp_quotes_quote').length > 0) {
		$('.wp_quotes_quote').jTypeWriter({onComplete:function(){
			$('.wp_quotes_author').show();
			$('.wp_quotes_author').jTypeWriter();
		}});
	}
	
	$('#rooms').change(function(){
		var num = $(this).val();
		switch(num)
		{
			case '2':
				$('#room2_row').slideDown();
				break;
			default:
				$('#room2_row').slideUp();
		}
	});
	
	$('.datepicker').datePicker({ createButton : false, clickInput: true, startDate: (new Date()).asString() });
	
});
