$(document).ready(function(){

	$(".reservation_sold_out_close").bind('click', function(){
		$('#reservation_sold_out_notice_wrap_link').hide_fade();
		return false;
	});

	// add hover class
	$("table.reservations_results tr.results").livequery("mouseover",function(event){
		$(this).addClass("tr_hover");
	});

	// remove hover class
	$("table.reservations_results tr.results").livequery("mouseout",function(event){
		$(this).removeClass("tr_hover");
	});

	// onclick, get resid & redirect page
	$("table.reservations_results tr.results").livequery("click",function(event){

		if($(this).hasClass("sold_out")){ // if sold out, show "sold out" thickbox
			$.create_fade_box('id',
				'reservation_sold_out_notice_wrap',
				"We're sorry. This trip is sold out.",
				'reservation_sold_out_message',
				{
					height: 200,
					width: 500,
					wrapping_class: 'reservation_sold_out_notice',
					fade_height: 15,
					fade_width:15,
					fade_click_close: false,
					auto_scroll: false,
					show_title: false,
					corners: true
				}
			);
		} else { // else if not sold out, redirect page
			var tr_id = $(this).attr("id");
			var resid = tr_id.substring(6); // cut off "resid_" before ####
			document.location.href=("/index.php/reservations/addon/" + resid);
		}
	});

	// "sold out" thickbox onclick "sold out" link
	$('a.sold_out').click(function() {
		$.create_fade_box('id',
			'reservation_sold_out_notice_wrap',
			"We're sorry. This trip is sold out.",
			'reservation_sold_out_message',
			{
				height: 200,
				width: 500,
				wrapping_class: 'reservation_sold_out_notice',
				fade_height: 15,
				fade_width:15,
				fade_click_close: false,
				auto_scroll: false,
				show_title: false,
				corners: true
			}
		);
		return false;
	});

});
