// JavaScript Document
var gsLastTree = '';

function SetNodeStatus(sStr)
{
	var oObj = document.getElementById(sStr);
	if(oObj)
	{
		ShowHideChild(sStr);
	}
}

function ShowHideChild(sStr)
{
	var sDisplay = '';
	var oChild = document.getElementById(sStr);
	
	if(oChild == null) return;

	sDisplay = oChild.style.display;
	if(sDisplay == 'none') sDisplay = ''; else sDisplay = 'none';
	oChild.style.display = sDisplay;
	
	if(gsLastTree != '' && gsLastTree != sStr)
	{
		ShowHideChild(gsLastTree);
	}
	
	var oChild_1 = document.getElementById(sStr + '_1');
	var oChild_2 = document.getElementById(sStr + '_2');

	if(oChild_1.style.display != 'none') 
	{
		oChild_1.style.display = 'none';
		oChild_2.style.display = '';
		gsLastTree = sStr;
	}else{
		oChild_1.style.display = '';
		oChild_2.style.display = 'none';
		gsLastTree = '';
	}

	$("iframe[name=Products]").height($(".BodyLeft").height() - 20);
	$(".BodyRight").height($(".BodyLeft").height() + 20);
}

function GetPageList(iPage, iCount, iPageCount, iListSize, sLinks, sKeyWord)
{
	var iCurrPage
	document.write("<div style='text-align:left;float:left;width:160px;'>&nbsp;</div>");
	if(iPageCount <= 1) return false;
	if(iPage > iPageCount) iPage = iPageCount;
	iCurrPage = Math.ceil(iPage / iListSize);
	
	document.write("<div style=\"text-align:right;float:right;width:390px;padding-top:4px;\">&nbsp;");
	document.write("" + iPageCount + " Pages, " + iCount + " Prodcuts&nbsp;");
	document.write("<img src=\"Images/pageList1.gif\" style=\"cursor:hand;\" onclick=\"window.location='?" + sLinks + "Page=1';\">");

	if(iCurrPage > 1)
	{
		document.write("<img src=\"Images/pageList2.gif\" style=\"cursor:hand;\" onclick=\"window.location='?" + sLinks + "Page=" + ((iCurrPage - 2) * iListSize + 1) + "';\">&nbsp;");
	}else{
		document.write("<img src=\"Images/pageList2.gif\" style=\"cursor:hand;\" onclick=\"window.location='?" + sLinks + "Page=1';\">&nbsp;");
	}

	for(var i = (iCurrPage - 1) * iListSize + 1; i <= iCurrPage * iListSize; i++)
	{
		if(i > iPageCount) break;

		document.write("<a href=\"?" + sLinks + "Page=" + i + "\" style='text-decoration:none;padding-bottom:0px;height:20px;'>");

		if(i == iPage) document.write("<strong>" + i + "</strong>"); else document.write(i);

		document.write("</a>&nbsp;");
	}

	if(iCurrPage < Math.ceil(iPageCount / iListSize))
	{
		document.write("<img src=\"Images/pageList3.gif\" style=\"cursor:hand;\" onclick=\"window.location='?" + sLinks + "Page=" + (iCurrPage * iListSize + 1) + "';\">")
	}else{
		document.write("<img src=\"Images/pageList3.gif\">");
	}

	document.write("<img src=\"Images/pageList4.gif\" style=\"cursor:hand;\" onclick=\"window.location='?" + sLinks + "Page=" + iPageCount + "';\">");
	
	if(Math.ceil(iPageCount / iListSize) >= 2) document.write("&nbsp;<input id=\"page\" value=\"" + iPage + "\" style=\"width:24px;height:14px;text-align:center;\" />&nbsp;<input type=\"button\" value=\"GO\" onclick=\"window.location='?" + sLinks + "Page=' + document.getElementById('page').value;\" class='button' />");
	
	document.write("&nbsp;&nbsp;</div>");
}

var pInterval = null;

function ShowLeftBar()
{
//	var aImages = new Array("4.jpg", "1.gif", "2.jpg", "3.jpg", "0.jpg");
	var aImages = new Array('axial fan motor.jpg','coils.jpg','compressor.jpg','copper tube.jpg','detector.jpg','filter drier.jpg','R22.jpg','Three Color Filling Hose.jpg','vacuum pumps.jpg','Z21.jpg');

	document.write("<div id='LeftBar' style='overflow:hidden;overflow-x:hidden;text-align:center;height:335px;width:179px;background-color:#F0F0F0;margin:0px 8px 0px 8px;' onmouseover=\"clearInterval(pInterval);\" onmouseout=\"clearInterval(pInterval);pInterval=setInterval('ScrollLeftBar();', 50);\">");
	for(var i = 0; i < aImages.length; i++)
	{
		document.write("<div class=\"JsLeftBar\" style=\"background-image:url(Images/Samples/" + aImages[i] + ");\"></div>")
	}
	document.write("<div class=\"JsLeftBar\" style=\"background-image:url(Images/Samples/" + aImages[0] + ");\"></div>")
	document.write("<div class=\"JsLeftBar\" style=\"background-image:url(Images/Samples/" + aImages[1] + ");\"></div>")
	document.write("<div class=\"JsLeftBar\" style=\"background-image:url(Images/Samples/" + aImages[2] + ");\"></div>")
	document.write("</div>");
	pInterval = setInterval('ScrollLeftBar();', 50);
}

function ScrollLeftBar()
{
	var obj = document.getElementById("LeftBar");
	obj.scrollTop = obj.scrollTop + 2;

	if(obj.scrollTop >= obj.scrollHeight - 430)
	{
		obj.scrollTop = 5;
	}
/*		clearInterval(pInterval);
		setTimeout("clearInterval(pInterval);pInterval=setInterval('ScrollLeftBar();', 40);", 1500);
	} else if((obj.scrollTop % 143 == 0)||(obj.scrollTop % 143 == 1)) {
		clearInterval(pInterval);
		setTimeout("clearInterval(pInterval);pInterval=setInterval('ScrollLeftBar();', 40);", 1500);
	}*/
}

function SetClassName(obj, sStr)
{
	var o = document.getElementById('jsClassName');
	if(o)
	{
		o.innerHTML = obj.innerHTML;
	}

	if(sStr != '') ShowHideChild(sStr);
}

$(function(){
	$(".BodyRight").height($(".BodyLeft").height() + 20);
	if($('iframe[name=Products]').html() != null) $('#_plus_search').css("display", "");
	$("#_plus_search").keydown(function(event){
	   if(event.keyCode == 13)
	   {
			Search();
	   }
	}); 
});

function Search()
{
	$("#jsClassName").text("Search: " + $('#TxtKeyword').val());
	$('#TxtKeyword').focus();
	$('iframe[name=Products]').attr("src", "about:blank");
	$('iframe[name=Products]').attr("src", "Products.asp?Operate=True&ClassId=0&Keyword=" + escape($('#TxtKeyword').val()))
}
