
function showGourmetProd(ind)
{
	for(var i=1; i<=3; i++)
		if (ind != i)
		{
			$('#divGourmetProd'+i).fadeOut("fast");
			$('#idGourmetBC'+i).fadeOut();
		}

	if (ind == 0)
		setTimeout(function() { $('#divGourmetInro').fadeIn("fast"); }, 300);
	else {
		$('#divGourmetInro').fadeOut("fast");
		setTimeout(function() {
				$('#divGourmetProd'+ind).fadeIn("fast");
				$('#idGourmetBC'+ind).fadeIn("fast");
			}, 300
		);
	}
	return true;
}



var strLeftMenu =
	"<li><h1 %%sel1%%><a href='/Home/Our+Brands/Special+Offers/Conditions/' title='Условия'>Условия</a></h1></li>"+
	"<li><h1 %%sel2%%><a href='/Home/Our+Brands/Special+Offers/Products/' title='Продукти'>Продукти</a></h1></li>"+
	"<li><h1 %%sel3%%><a href='/Home/Our+Brands/Special+Offers/Winners/' title='Победители'>Победители</a></h1>";

$(document).ready(function() {

	// Fix left menu of promotions
	if (document.location.href.indexOf('/Home/Our+Brands/Special+Offers/') > -1)
	{
		var itemHtml = $('ul#leftnav').html();
		var posDiv = itemHtml.toLowerCase().indexOf('</div>');
		if (posDiv > 0)
		{
			itemHtml = itemHtml.substring(0, posDiv + 6);

			strLeftMenu = strLeftMenu.replace('%%sel1%%', (location.href.indexOf('/Conditions/') > 0 ? 'class="LeftNavSelected"' : ''));
			strLeftMenu = strLeftMenu.replace('%%sel2%%', (location.href.indexOf('/Products/') > 0 ? 'class="LeftNavSelected"' : ''));
			strLeftMenu = strLeftMenu.replace('%%sel3%%', (location.href.indexOf('/Winners/') > 0 ? 'class="LeftNavSelected"' : ''));

			$('ul#leftnav').html(itemHtml + strLeftMenu);
		}
	}

	// Gourmet clicks
	if (document.location.href.indexOf('/Home/Our+Brands/Gourmet/') > -1 ||
		document.location.href.indexOf('/Home/Our+Brands/Special+Offers/Products/') > -1)
	{
		$('a#prodGourmet1,a#prodGourmet2,a#prodGourmet3').click(function() {
			var ind = this.id.replace('prodGourmet', '');
			return showGourmetProd(ind);
		});
		$('#idIntroTable a').click(function() {
			var ind = this.href.substr(this.href.indexOf('#')+1, 1);
			return showGourmetProd(ind);
		});
	}

	var ind = 0;
	if (document.location.href.indexOf('#') > -1)
		ind = document.location.href.substr(document.location.href.indexOf('#')+1, 1);
	showGourmetProd(ind);
});


