$(function(){
	
	$('a[rel*=lightbox]').lightBox({
		overlayOpacity: 0.6
	});
	
	$('#content p span').hide();
	$('#runningtotal').show();
	$('.expand').css('display','inline');
	$('.summarize').css('display','inline');
	
	// show/hide summarised content sections
	
	$('.expand').click(function(){
		$(this).siblings('span').show();
		$(this).hide();
		return false;
	});
	
	$('.summarize').click(function(){
		$(this).parents('span').css('display','none');
		$(this).parents('span').siblings('.expand').css('display','inline');
		return false;
	});
	
	// calculate the running total
	
	calculateRunningTotal();
	
	$('.table-a input[type=text]').bind('keyup',function(){
		calculateRunningTotal();
	});
	
	function calculateRunningTotal() {
		var rTotal = 0.00;
		$('.table-a input[type=text]').each(function(){
			rTotal += $(this).val() * $(this).attr('alt');
		});
		$('#runningtotal').text(rTotal.toFixed(2));
	}
	
	// force input:hover on IE6
	if (typeof document.body.style.maxHeight == 'undefined'){
		$('input.button')
		.live('mouseover', function(){
			$(this).css('background-position-x', '-' + $(this).css('width'));
		})
		.live('mouseout', function(){
			$(this).css('background-position-x', 0);
		});
	}
	
});
