var menuDropDownInterval=null;
var menuDropDownTimeDelay=1;
var menuDropDownHeightIncPercent=5;

var menuDropDownBlock;
var menuDropDownBlockH;
var menuDropDownBlockHeight;

menuDropDownInit();


function menuDropDownInit()
{
var re=/ig_menu_shop_item_/;
var elems=document.body.getElementsByTagName("li");
var elem;
var elemID;
var elemBlockID;

	for(var i=0; i<elems.length; i++)
	{
	elem=elems[i];
		if(elem.id)
		{
		elemID=elem.id;
			if(elemID.search(re)!=-1)
			{
			elemBlockID=elemID.replace("_item", "_block");
				if($(elemBlockID))
				{
				$(elemBlockID).style.display=(elem.className=="active")?"block":"none";
				elem.onclick=menuDropDownLevelExpandCollapse;
				elem.style.cursor="pointer";
					if(elem.childNodes[0].tagName.toLowerCase()=="a")
					{
					elem.childNodes[0].href='javascript:void(0);';
					}
				}
			}
		}
		else
		{
			if(elem.className=="active")
			{
			elem.style.cursor="default";
				if(elem.childNodes[0].tagName && elem.childNodes[0].tagName.toLowerCase()=="a")
				{
				elem.childNodes[0].href='javascript:void(0);';
				elem.childNodes[0].style.cursor="default";
				}
			}
		}
	}
}


function menuDropDownLevelExpandCollapse(event)
{
event = event || window.event;
var elem = event.target || event.srcElement;

	if(elem.tagName.toLowerCase()=="a")
	{
	elem=elem.parentNode;
	}

var elemBlockID=elem.id.replace("_item", "_block");

	if(elemBlockID>"" && $(elemBlockID))
	{
		if($(elemBlockID).style.display=="block")
		{
		menuDropDownCollapse(elemBlockID);
		}
		else
		{
		menuDropDownExpand(elemBlockID);
		}
	}
event.cancelBubble = true;
}


function menuDropDownCollapse(elemBlockID)
{
clearInterval(menuDropDownInterval);
menuDropDownBlock=$(elemBlockID);
menuDropDownBlockHeight=parseInt(menuDropDownBlock.scrollHeight);
menuDropDownBlockH=menuDropDownBlockHeight;
menuDropDownInterval=setInterval(menuDropDownBlockDecreaseHeight, menuDropDownTimeDelay);
}


function menuDropDownExpand(elemBlockID)
{
clearInterval(menuDropDownInterval);
menuDropDownBlock=$(elemBlockID);
menuDropDownBlock.style.display="block";
menuDropDownBlock.style.height="auto";
menuDropDownBlockHeight=parseInt(menuDropDownBlock.scrollHeight);
menuDropDownBlock.style.height=0;
menuDropDownBlockH=0;
menuDropDownInterval=setInterval(menuDropDownBlockIncreaseHeight, menuDropDownTimeDelay);
}


function menuDropDownBlockIncreaseHeight()
{
var menuDropDownHeightInc=parseInt(menuDropDownBlockHeight*menuDropDownHeightIncPercent/100);
	if(!menuDropDownHeightInc)
	{
	menuDropDownHeightInc=1;
	}
	if(menuDropDownBlockH<menuDropDownBlockHeight)
	{
	menuDropDownBlockH+=menuDropDownHeightInc;
	menuDropDownBlock.style.height=menuDropDownBlockH+"px";
	}
	else
	{
	menuDropDownBlock.style.height=menuDropDownBlockHeight+"px";
	menuDropDownBlock.style.height="auto";
	clearInterval(menuDropDownInterval);
	}
}


function menuDropDownBlockDecreaseHeight()
{
var menuDropDownHeightInc=parseInt(menuDropDownBlockHeight*menuDropDownHeightIncPercent/100);
	if(!menuDropDownHeightInc)
	{
	menuDropDownHeightInc=1;
	}
	if(menuDropDownBlockH>0)
	{
	menuDropDownBlockH-=menuDropDownHeightInc;
	menuDropDownBlockH=(menuDropDownBlockH>0)?menuDropDownBlockH:0;
	menuDropDownBlock.style.height=menuDropDownBlockH+"px";
	}
	else
	{
	menuDropDownBlock.style.height=0;
	menuDropDownBlock.style.display="none";
	clearInterval(menuDropDownInterval);
	}
}



