/*
	scripts used in the category-list.php page
	-----
	2 objects use scripts :
		- gondola
		- the sort panel
*/



function initGondola ()
{
	$('.full-list').css('display', 'none');

	var numSpecials = $('.name-image').length;
	if (numSpecials > 3)
		$('.more-specials').css('display', 'block');

	// -----[ click ]
	$('#more-link').click(function() { 
		$('.full-list').slideToggle('fast');

		return false;
	}); 


	// -----[ hover ]
	$('#more-link').hover(function() {
		$(this).animate({ paddingRight: '8px' }, 200);
	}, function() {
		$(this).animate({ paddingRight: '0px' }, 200);
	}); 

}


function initSortPanel ()
{
	$('#config-tab').css('display', 'none');


	// -----[ click ]
	$('#title-tab h3').click(function()
	{
		var url = $(this).css('background-image');
		var fullpath = url.substr(0, url.lastIndexOf('/')+1);

		var currState = parseInt($('#config-tab').css('height'));
		if (currState > 40)
		{
			$(this).css('background-image', fullpath+'bk-sort-closed.jpg)'); 
			$('#curr-view-str').show();
			$('#config-tab').slideToggle('fast');
		}
		else
		{
			$('#config-tab').slideToggle('fast');
			$(this).css('background-image', fullpath+'bk-sort-open.jpg)'); 
			$('#curr-view-str').hide();
		}

		return false;
	}); 


	// -----[ hover ]
	$('#title-tab h3').hover(function() {
		$(this).animate({ paddingLeft: '28px' }, 200);
	}, function() {
		$(this).animate({ paddingLeft: '24px' }, 200);
	}); 


}



function initListTooltips ()
{
	$('.name-cell a').tooltip({ 
		delay: 100, 
		fade: 500,
		top: -20,
		track: true,
		showURL: false 
	});
	$('.prod-frame a').tooltip({ 
		delay: 100, 
		fade: 500,
		top: -20,
		track: true,
		showURL: false 
	});
}



	// ----- init functions
$(document).ready(function() {

	initGondola();
	initSortPanel();

	initListTooltips();

});

