//---------------------------------------------------------------
// Class: Catalog
// Some functions for spiffing up the catalog.
//---------------------------------------------------------------
var Catalog = 
{
	
	//-----------------------------------------------------------
	// Member Variables
	//-----------------------------------------------------------
	active_listing: "",
	heights: {},
	
	
	//-----------------------------------------------------------
	// Member Functions
	//-----------------------------------------------------------	
	//-----------------------------------------------------------
	// Function: toggleListing()
	// Toggles whether a listing is active or not.
	//-----------------------------------------------------------
	toggleListing: function( id )
	{
		
		// Hide the active listing.
		if ( Catalog.active_listing != "" )
		{
			
			var active_listing = document.getElementById( "listing" + Catalog.active_listing );
			var active_heading = document.getElementById( "heading" + Catalog.active_listing );
			
			LW_DOM_Library.setStyle( active_heading, "color", "#82350B" );
			
			var anim = new LW_Animation( active_listing, 1000 );
			anim.controller.height.to = 1;
			anim.onFinish = function(){ LW_DOM_Library.setStyle( active_listing, "height", Catalog.heights[Catalog.active_listing] + "px" ); 
			                            LW_DOM_Library.setStyle( active_listing, "display", "none" ); };
			anim.start();
			
		}
		
		if ( Catalog.active_listing != id && id != 0 )
		{
		
			Catalog.active_listing = id;
			
			var listing = document.getElementById( "listing" + id );
			var heading = document.getElementById( "heading" + id );
			
			LW_DOM_Library.setStyle( heading, "color", "#361300" );
			LW_DOM_Library.setStyle( listing, "display", "block" );	
			
			if ( !Catalog.heights[id] )
				Catalog.heights[id] = LW_DOM_Library.getHeight( listing );
			
			LW_DOM_Library.setStyle( listing, "height", "0px" );
			
			var anim = new LW_Animation( listing, 1000 );
			anim.controller.height.to = Catalog.heights[id];
			anim.controller.height.ease = LW_Animation.STRONG_EASE_IN;
			anim.start();
			
		}
		else
			Catalog.active_listing = "";
		
	}
	
}