// Datepicker
	$(function() {
		$( "#date" ).datepicker({
			dateFormat:'yy M dd',
			minDate: '0d',
			maxDate: '+1m +1w'
		});
	
		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); }, 
			function() { $(this).removeClass('ui-state-hover'); }
		);
	});		

//lightbox picture viewer
$(document).ready(function(){$('a.lightbox').click(function(e) {
	//hide scrollbars
	$('body').css('overflow-y', 'hidden');
	
	$('<div id="overlay"></div>')
	  .css('top', $(document).scrollTop())
	  .css('opacity', '0')
	  .animate({'opacity': '0.5'}, 'slow')
	  .appendTo('body');
	  
	$('<div id="lightbox"></div>')
	  .hide()
	  .appendTo('body');
	$('<img />')
	  .attr('src', $(this).attr('href'))
	  .load(function() {
	    positionLightboxImage();
	  })
	  .click(function() {
	    removeLightbox();
	  })
	  .appendTo('#lightbox');
	  
	return false;
}); } );

function positionLightboxImage () {
	var top = ($(window).height() - $('#lightbox').height()) / 2;
	var left = ($(window).width() - $('#lightbox').width()) / 2;
	$('#lightbox')
		.css({
			'top': top + $(document).scrollTop(),
			'left': left
		})
		.fadeIn();
}

function removeLightbox(){
	$('#overlay, #lightbox')
		.fadeOut('slow', function() {
			$(this).remove();
			$('body').css('overflow-y', 'auto'); //show scrollbars
		});
}
