var ieversion, base_href; // Hold base href globally for IE's benefit

jQuery(document).ready(function()
	{
	var base, List;
	
	// Test for IE
	// -----------
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) //test for MSIE x.x;
		ieversion=new Number(RegExp.$1);
	else
		ieversion = null;

	// base href for IE
	// ----------------
	base = document.getElementsByTagName('base');
	if (base && base[0] && base[0].href) base_href = base[0].href;
	else base_href = 'http://'+document.domain;

	// Animate product list - first hide it.
	List = jQuery('#product-list li').css('position', 'relative').css('left', '-5000px');
	if (List.length > 1)
		{
		jQuery(window).load(function()
			{
			// Ensure #product-list is the 'correct' size so #footer stays in the right place
			var prodLists;
			prodLists = document.getElementById('product-list');
			if (prodLists) prodLists.style.height = prodLists.offsetHeight + 'px';

			// Hide list items and position them back on the page
			List.hide().css('position', 'static').css('left', '0');

			// Animate product list - display
			function blockAppear(JQelement)
				{
				if (JQelement.length) JQelement.fadeIn(200, function () {
					if (jQuery.browser.msie) this.style.removeAttribute('filter');			
					blockAppear(jQuery(this).next());
					});
				}

			blockAppear(List.eq(0));
			});
		}
		
	else if (List.length == 1)
		{
		// Jump through this page if only one item
		window.location.href = base_href + List.find('a').attr('href');
		}
		
	else // maybe on product page?
		{
		jQuery(window).load(function()
			{
			var sph = jQuery('#single-product').height();
			if (sph >  jQuery('#product-image').height()) jQuery('#product-image').height(sph);
			});
		}
		
	// Vertically centre home page images
/*	var homeRowHeight, homeRowImgs;
	homeRowHeight = 0;
	homeRowImgs = jQuery('body#home #product-list img');
	if (homeRowImgs.length)
		{
		jQuery(window).load(function()
			{
			homeRowImgs.each(function()
				{
				if (homeRowHeight < this.offsetHeight) homeRowHeight = this.offsetHeight;
				});
			homeRowImgs.each(function()
				{
				this.style.marginTop = ((homeRowHeight - this.offsetHeight) >> 1) + 'px';
				});
			});
		}*/
	});


