$(document).ready(function() {
	
	$('#bargains_scroller li').css({cursor : 'pointer'}).hover(
		function() { $(this).children('a').css({textDecoration : 'underline'}); },
		function() { $(this).children('a').css({textDecoration : 'none'}); }
	);
	
	$('#select_travel_area select').change(function() {
		$('#bargains_scroller li').hide().removeClass('last_in_line');
		
		var count = 1;		
		$('#bargains_scroller ul').children('.'+$(this).val()).show().each(function() {
			if(count % 3 == 0) { $(this).addClass('last_in_line'); }
			count ++;
		});
		
		$('#bargains_scroller .scroller').jScrollPane({showArrows:true, scrollbarWidth: 30, arrowSize: 12});
	});

	$('#bargains_scroller li').click(function() {
			
		$element = $(this);
		
		var title = $element.children('.title').html()+' &nbsp;&nbsp; '+$element.children('.price').html()+'<br/>'+$element.children('.nights').html()+' &nbsp;&nbsp; '+$element.children('.dates').html();
		var description = $element.children('.description').html();
			
		$('#bargains_scroller .scroller').prepend('<div id="bargainInfo"><h5>'+title+'</h5>'+description+'<a href="#" id="bargainBackButton" onclick="removebargain(); return false;">Return</a></div>').children('ul').hide();
			
		$('#bargains_scroller .scroller').jScrollPane({showArrows:true, scrollbarWidth: 30, arrowSize: 12});
		
		return false;
	});
	
});

function removebargain()
{
	$('#bargainInfo').remove();
	$('#bargains_scroller ul').show();
	
	$('#bargains_scroller .scroller').jScrollPane({showArrows:true, scrollbarWidth: 30, arrowSize: 12});
}