function toggle_seasons()
{
	if(!$(this).next().is(':visible'))
	{
		$('#collections-menu ul:visible').slideUp('normal');
		$(this).next().slideDown('normal');	
	}
}

function handle_collections_menu() 
{
  $('#collections-menu ul').hide();
  $('#collections-menu li a').click(toggle_seasons);

};

function show_collections()
{
	$('#collections-menu').show();
}

function hide_collections()
{
	$('#collections-menu').hide();
}

function toggle_collections_menu()
{
	$('#collections-menu').hide();
	$('#collections').mouseover(show_collections);
	// Uncomment line below to automatically open first element.
	//$('#collections-menu ul:first').show();
}

function main_loop()
{
	$('.general_menu_item').mouseover(hide_collections);
	$('img').mouseover(hide_collections);

	$().mousemove( function(e) 
		{
			padding = 5;
			top_buffer = 15;
			x = e.pageX;
			y = e.pageY;
			pos = $("#collections-menu").offset();
			width = $("#collections-menu").width();
			height = $("#collections-menu").eq(0).height();

			left = pos.left-padding;
			right = width+pos.left+padding;
			top	= pos.top - padding - top_buffer;
			bottom = pos.top + height + padding;

			if(x < left || x > right || y < top || y > bottom)
			{
				hide_collections();
			};
		});
	handle_collections_menu();
	toggle_collections_menu();
}

$(document).ready(main_loop);
 // var pos = $("#placeholder").offset();  
//  var width = $("#placeholder").width();

