/*
	File: global.js
	Created: 10/12/09
	Created by: Eddy Bennett
	Version: 1.00_jquery
	
	Adds common functionality to pages.

	Dependencies: 
	
	 - jquery library
	
*/

$(document).ready(function() {
	$(window).load(function() {
		customiseSearch(); 
		runPageFunctions();		
	});	
});

/* Functions */
/* Public variables */
var thumbSlider;

/* Page specific */
function runPageFunctions()
{
	if($('#content').hasClass("product"))
	{
		var thumbSlider = VerticalSlider('#thumbs ul','#thumb_list_up_btn','#thumb_list_dwn_btn',400,104,'marginTop');
	}
	if($('#content').hasClass("category"))
	{	/* Fix product div heights */
		// Set product div height
		var productDivHeight = 0;

		// Get each product div and update 
		$('#products div.product').each(function(p)
		{	// If highest div then update
			if($(this).attr('offsetHeight') > productDivHeight)
			{
				productDivHeight = $(this).attr('offsetHeight');
			}
		});
		$('.product').each(function(product)
		{	// Set new height to each div
			$(this).css('height',productDivHeight + 'px');	
		});		
	}
	if($('#content').hasClass("shopping_bag"))
	{
		// Add odd and even classes to shopping bag table
		$('#shopping_bag tbody tr:odd').addClass('odd');
	}
}
function customiseSearch()
{
	/* Add in a nice button for search */
	//$('#search_submit_btn').replaceWith('<a href="#" title="Search" class="search_submit_btn" onclick="$(\'#search\').submit(); return false;">Search</a></form>');
}
