jQuery(function(){
	
	var $=jQuery;
	var lightbox_images = '/javascripts/jquery-lightbox-0.5/images/'
	
	if($('a.jqueryLightbox').lightBox){
		$('a.jqueryLightbox').lightBox({
		  fixedNavigation: true,  // when true, prev and next buttons display constantly, not just on hover
		  imageBlank: lightbox_images + 'lightbox-blank.gif',
		  imageLoading: lightbox_images + 'lightbox-blank.gif', //'lightbox-ico-loading.gif',  // the "loading" image doesn't display properly, so use "blank" image instead
		  imageBtnClose: lightbox_images + 'lightbox-btn-close.gif',
		  imageBtnPrev: lightbox_images + 'lightbox-btn-prev.gif',
		  imageBtnNext: lightbox_images + 'lightbox-btn-next.gif'
		});
	}
	
	/*
		Bind preview links to modal window handler
	*/
	(function(){
		$('.previewPanelOpener').click(function(e){
			var el=$(this);
			e.preventDefault();
			
			var p = $('#PanelContainer');
			
			$.blockUI({
				allowBodyStretch: true,
				message:p,
				css: {
					cursor:'arrow',
					width:'60%',
					top:'10%',
					left:'20%',
					'border':'none'/* this is key to getting the panel to display properly with variable heights */
				}
			});
			
			$('.panelBody', p).html('Loading...');
			
			$.get(el.attr('href'), function(data){
				$('.panelBody', p).html(data);
				$('.panelCloseButton', p).click(function(e){
					e.preventDefault();
					$.unblockUI();
					$('.panelBody', p).html('');
					p.hide();
				});
				
				
			});
		})
	})();
});