jQuery(document).ready(function($) {	

	$("#wineList").accordion({
		alwaysOpen: false,
		autoHeight: false,
		collapsible:true, //needed for jQuery UI
		// jquery 1.3 requires camel case. 1.2.6 requires lowercase (tested in safari 4b,ff3)
		//In 1.2.6 (NOT 1.3), height of an accordion is the "initial" height when opened.
		//it will not allot more space for dynamically resized items, i.e. nested accordions
		//MAKE SURE THE INITIAL HEIGHT IS THE TALLEST HEIGHT REQUIRED.
		//In css set the element that needs the height to overflow: auto !important; height: auto !important;
		active: ".selected",
		header: "a.accordianLink",
		clearStyle: true //possibly unnecessary		
	}).change(function(){$(".didYouKnow p").hide();});
		
	$(".varietalTable").hide();
	
	$(".varietalsList h2 a").click(function(){
	 	var myContent = $(this).parent().next();
		//hide everything
		$(".varietalsList  .varietalTable").hide("slow");
		$(".didYouKnow p").hide();
		$(".didYouKnow").hide();
		
	 	if($(this).hasClass("selected2") ){
	 		//you're closing
	 		$(this).removeClass("selected2");
	 		//so show the dog
	 		$(".didYouKnow").show();

	 	}else{
	 		//before opening, rip any height and overflow tags out of the parent that may have been injected by accordion
	 		$(this).parent().parent().parent().parent().css('height','auto').css('overflow','auto');
			$(myContent).show("slow");
			$(this).addClass("selected2");
	 	}
		return false;
	});
	
	
	$('#memberRentalPackages .contentCol tr td:first-child').addClass("cellHeadLine");
	$('#equipment .contentCol tr td:first-child').addClass("cellHeadLine");
	$('#dining .contentCol tr td:first-child').addClass("firstCol");
	$("#dessert_wines table, #whiteVarietals table, #red_varieties table, #sparkling_wines_champagne table").tablesorter({
		widgets:['zebra'],
		sortList: [[0,0],[1,0]]
	});
	
	$("#chardonnay table").tablesorterPager({container: $("#chardonnay .pager"),positionFixed: false,size: 5});
	$("#otherWhite table").tablesorterPager({container: $("#otherWhite .pager"),positionFixed: false,size: 5});
	$("#bordeaux table").tablesorterPager({container: $("#bordeaux .pager"),positionFixed: false,size: 5});
	$("#cabernet-sauvignon table").tablesorterPager({container: $("#cabernet-sauvignon .pager"),positionFixed: false,size: 5});
	$("#shiraz-syrah table").tablesorterPager({container: $("#shiraz-syrah .pager"),positionFixed: false,size: 5});
	$("#otherRed table").tablesorterPager({container: $("#otherRed .pager"),positionFixed: false,size: 5});
	$("#champagne table").tablesorterPager({container: $("#sparkling_wines_champagne .pager"),positionFixed: false,size: 5});	
});
