/*
 * Shows the correct image by clicking on the thumbnail in the detail section
 */
function showImage(image)
{
	var detailImageDivs = Element.immediateDescendants($('detailImages'));
	var num = new Array();
	for(k=0;k<detailImageDivs.length;k++)
	{
		num[k] = Element.readAttribute(detailImageDivs[k], 'id').replace(/detailImage/, '');
	}
	function numberorder(a,b) { return a - b; }
	var foo = num.sort(numberorder).reverse();
	
	for(var i=1;i<=foo[0];i++)
	{
		if($('detailImage'+i))
		{
			$('detailImage'+i).hide();
			
			if($('image'+i))
				Element.removeClassName($('image'+i).parentNode, 'active');
		}
	}
	$('detailAnchor'+image).rev = "type:img group:productImages";
	fb.anchors.length = 0;
	fb.tagAnchors($('detailImages'));
	$('detailImage'+image).show();
	if(image>12)
		Element.addClassName($('image12').parentNode, 'active');
	else
		Element.addClassName($('image'+image).parentNode, 'active');
	
	return false;
}

// loads a product
function loadProduct(articleId, categoryId, collection)
{
	new Ajax.Updater('product_detail', absCorrect + 'templates/components/ajax_product_detail.html', {
		method: 'post',
		parameters: { articleId: articleId, categoryId: categoryId, collection: collection, cache: 'no'  },
		evalScripts: true,
		evalJS: true,
		encodeing: 'ISO-8859-1',
		onComplete: function(transport) {
			Cufon.replace('h1');
			$('product_desc').style.display = 'block';
		}
	})
	if(typeof($$('.active')[0]) == 'undefined')
	{
		$('carouselAnchor' + categoryId).addClassName('active');
	}
	else if($$('.active')[0] != $('carouselAnchor' + categoryId))
	{
		$$('.active')[0].removeClassName('active');
		$('carouselAnchor' + categoryId).addClassName('active');
	}
}

// loads search result page
function loadSearchPage(page, q)
{
	new Ajax.Updater('searchPage', absCorrect + 'templates/components/search_shop/ajax_shop_search.html', {
		method: 'post',
		parameters: { page: page, q: q},
		evalScripts: true,
		evalJS: true,
		encodeing: 'ISO-8859-1'
	})
}

