var currentMenuItem;
var currentIcon;

function LeftMenuElement(flag)
{
	this.td = GI("LeftMenuTd_"+flag);
	this.div = GI("LeftMenuChild_Div_"+flag);
	this.icon = GI("areaIcon_" + flag);
	this.iconSrc = "/images/Left_item_icon_";
	this.class0 = "LeftMenuChildDiv_0";
	this.class1 = "LeftMenuChildDiv_1";
	this.class2 = "SearchList_leftMenuItem_On";
	this.class3 = "SearchList_leftMenuItem_";
	
}

function childOnEvent(o, flag, showCount, type)
{
	//alert(o.tagName + "< * " + flag + " * " + type);
	var tr = GI("LeftMenuChildTr_"+flag+"_"+showCount);
	var td = GI("LeftMenuChildTd_"+flag+"_"+showCount)
	var img = GI("childIcon_"+flag+"_"+showCount);
	if(type==0)
	{
		tr.className = "LeftMenuChildTr_1";
		img.src = "/images/childIcon_1.gif";
	}
	else
	{
		tr.className = "LeftMenuChildTr_0";
		img.src = "/images/childIcon_0.gif";
	}
}

function onMouseEvent(o, c, sc, type, imgFlag)
{
	if(type==0)
	{
		o.className = "SearchList_leftMenuItem_On";
		GI("areaIcon_" + sc).src = "/images/Left_item_icon_2.gif";
	}
	else
	{
		o.className = c;
		GI("areaIcon_" + sc).src = "/images/Left_item_icon_"+ imgFlag +".gif";
	}
}

function attachItem(flag, total, classFlag)
{
	currentMenuItem = flag;
	for(var i=0; i<total; i++)
	{
		var e = new LeftMenuElement(i);
		if(i==flag)	
		{
		    if(e)
		    {
			currentIcon = e.icon.src;
			e.div.className = e.class0;
			e.td.className = e.class2;
			e.icon.src = e.iconSrc + "2.gif";
			}
		}
		else
		{
		    if(e.div)
			e.div.className = e.class1;
		}
	}
}

function attachItem2(flag, total, classFlag)
{
	currentMenuItem = flag;
		var e = new LeftMenuElement(currentMenuItem);

		    if(e)
		    {
			currentIcon = e.icon.src;
			e.div.className = e.class0;
			e.td.className = e.class2;
			e.icon.src = e.iconSrc + "2.gif";
			}
		

}

function unAttachItem(flag)
{
	currentMenuItem = null;
	window.setTimeout("springAttachEvent("+ flag +")", 10);
}

function springAttachEvent(flag)
{
	if(currentMenuItem!=flag)
	{
		var e = new LeftMenuElement(flag);
		var classFlag = 1;
		if(flag%2==0)
			classFlag = 2;
		e.div.className = e.class1;
		e.td.className = e.class3 + classFlag;
		e.icon.src = e.iconSrc + (classFlag-1) + ".gif";
	}
}

function leftMenuClick(version, areano, categoryno)
{
	var bound = "exp";
	if(areano.indexOf("IM")!=-1)
		bound = "imp";
	//alert(bound + ":" + areano);
	location.href = "/pages/searchList.aspx?TopPage_search_type=0&version="+ version +"&TopPage_search_bound="+ bound +"&areano="+areano+"&categoryno="+categoryno;	
}