<!--

if(isie)
	windowWidth = document.body.clientWidth;
if(isns)
	windowWidth = window.innerWidth;

var layerMenuArray = new Array();
var tableStr = "";
var currentChapter;
var currentSection;
var timeoutid;
var currentOnLayerObj;
var layerFromTop = 146;
var layerFromLeft = 189;
//var layerFromLeft = 0;

var windowWidth;

getCurrentChapterAndSection();

function getCurrentChapterAndSection()
{
	url = document.location.href;
	url = url.substr(url.indexOf("/products/")+1,url.length);
	currentChapter = url.split("/")[1];
	currentSection = url.split("/")[2];
}

// -----------------------------
// layer menu mouse action
// -----------------------------
function layerOnMouseOverFunction()
{
	window.clearTimeout(timeoutid);
}

function layerOnMouseOutFunction()
{
	timeoutid = setTimeout("hideChapterLayer(currentOnLayerObj)", 500);
}

// -----------------------------
// sub menu mouse action
// -----------------------------
function chapterOnMouseOverFunction(chapterName)
{
	window.clearTimeout(timeoutid);
	var layerObj = null;
	layerName = "layer_"+chapterName;
	if(isie)
		layerObj = eval('document.all["'+layerName+'"]');
	if(isns)
		layerObj = document.layers[layerName];

	hideChapterLayer(currentOnLayerObj,chapterName);
	showChapterLayer(layerObj);

	currentOnLayerObj = layerObj;
}

function chapterOnMouseOutFunction(chapterName)
{	
	timeoutid = setTimeout("hideChapterLayer(currentOnLayerObj);", 500);
}

function showChapterLayer(arg_layerObj)
{
	if(arg_layerObj != null)
	{
		if(isie)
		{
			if(document.body.clientWidth > 770)
				arg_layerObj.style.left = (document.body.clientWidth-770)/2 + layerFromLeft;
			else
				arg_layerObj.style.left = layerFromLeft;
			arg_layerObj.style.visibility = "visible";
		}
		if(isns)
		{
			if(window.innerWidth > 770)
				arg_layerObj.left = (window.innerWidth-770)/2 + layerFromLeft - 9;
			else
				arg_layerObj.left = layerFromLeft - 9;
			arg_layerObj.visibility = 'show';
		}
	}

}

function hideChapterLayer(arg_layerObj)
{
	if(arg_layerObj != null)
	{
		if(isie)
			arg_layerObj.style.visibility = "hidden";
		if(isns)
			arg_layerObj.visibility = "hide";
		currentOnLayerObj = null;
	}
}


function genChapterMenu(arg_chapterObj,tableStr,indexj)
{
	var tco, tso;  // tempChapterObject, tempSectionObject;
	tco = arg_chapterObj;

	if(arg_chapterObj.displayType == "sidemenu")
	{
		if(arg_chapterObj.sectionObj[0].type == "image")
		{
			tableStr = '<table width="190" border="0" cellspacing="0" cellpadding="0" background="/products/images/menu_bg.gif">'+"\n";
			tableStr += '<tr><td><img src="/products/images/menu_top.gif" width="190" height="13"></td></tr>'+"\n";
		}
		else
			tableStr = '<table width="186" border="0" cellspacing="0" cellpadding="8">'+"\n";

		for(indexj=0; indexj<tco.sectionObj.length; indexj++)
		{
			tso = arg_chapterObj.sectionObj[indexj];
			tableStr += "<tr>"+"\n";
		
			if(tso.type == "image")
			{
				imgName = tso.name;
				imgSrc = "/products/images/menu_"+imgName+".gif";
				href = tso.href;
				onMouseOutStr = "MM_swapImgRestore()";
				onMouseOverStr = "MM_swapImage('"+imgName+"','','/products/images/menu_"+imgName+"_r.gif',1)";
				tableStr += '<td><a href="'+href+'" onMouseOut="'+onMouseOutStr+'" onMouseOver="'+onMouseOverStr+'"><img name="'+imgName+'" src="'+imgSrc+'" width="190" height="33" border="0"></td>'+"\n";
			}
			else
			{
				if(isie)
					var layerObj = eval('document.all["layer_'+tso.name+'"]');
				if(isns)
					var layerObj = eval('document.layers["layer_'+tso.name+'"]');

				onMouseOverStr = "chapterOnMouseOverFunction('"+tso.name+"')";
				onMouseOutStr = "chapterOnMouseOutFunction('"+tso.name+"')";

				if(tso.chapterObj == null)
					href = tso.href;
				else
					href = "#";

				if(currentSection == tso.name)
					css = "menuover";
				else
					css = "menu";

				tableStr += '<td><img src="/products/images/menu_icon.gif" width="18" height="7"><a href="'+href+'" class="'+css+'" onMouseOver="'+onMouseOverStr+'" onMouseOut="'+onMouseOutStr+'">'+unescape(escape(tso.text))+"</a></td>"+"\n";
			}
			tableStr += "</tr>"+"\n";

			if(tso.chapterObj != null && tso.chapterObj.displayType == "sidemenu" && tso.chapterObj.name == currentChapter)
			{
				genLayerDefinition();
				tableStr += "<tr>"+"\n";
				tableStr += "<td>"+"\n";
				tableStr += genChapterMenu(tso.chapterObj, "str"+indexj, "index"+indexj);
				tableStr += "</td>"+"\n";
				tableStr += "</tr>"+"\n";
			}
		}

		if(arg_chapterObj.sectionObj[0].type == "image")
		{
			tableStr += '<tr><td><img src="/products/images/menu_bottom.gif" width="190" height="17"></td></tr>'+"\n";
			tableStr += "</table>"+"\n";
		}
		else
			tableStr += "</table>"+"\n";
	}

	return tableStr;
}

function genLayerMenu(arg_chapterObj,tableStr,indexj)
{
	var tco, tso;  // tempChapterObject, tempSectionObject;
	tco = arg_chapterObj;

//	alert(tco.parentSectionObj.parentChapterObj.parentSectionObj.index + " " + tco.parentSectionObj.index);
	layerx = layerFromLeft;
	layery = tco.parentSectionObj.parentChapterObj.parentSectionObj.index * 33 + (tco.parentSectionObj.index-1)*30 + layerFromTop;

	if(isie)
	{
		layerName = "layer_" + arg_chapterObj.name;
		visibility = "hidden"; // hidden, show
		onMouseOverStr = "layerOnMouseOverFunction()";
		onMouseOutStr = "layerOnMouseOutFunction()";
		tableStr = '<div id="'+layerName+'" style="position:absolute; z-index:10; left: '+layerx+'px; top: '+layery+'px; visibility: '+visibility+';" onMouseOver="'+onMouseOverStr+'" onMouseOut="'+onMouseOutStr+'">'+"\n";
	}
	if(isns)
	{
		layerName = "layer_" + arg_chapterObj.name;
		visibility = "hide"; // hide, visible
		onMouseOverStr = "layerOnMouseOverFunction()";
		onMouseOutStr = "layerOnMouseOutFunction()";
		tableStr = '<layer id="'+layerName+'" left="'+layerx+'" top="'+layery+'" z-index="10" visibility="'+visibility+'" onMouseOver="'+onMouseOverStr+'" onMouseOut="'+onMouseOutStr+'" overflow="true">'+"\n";
	}
	
	tableStr += '<table width="200" border="0" cellspacing="0" cellpadding="0" bgcolor="#BFBFBF" background="/images/box.gif">'+"\n";
	tableStr += '<tr>'+"\n";
	tableStr += '<td>'+"\n";
	tableStr += '<table width="200" border="0" cellspacing="1" cellpadding="4" bgcolor="#BFBFBF">'+"\n";
	for(indexj=0; indexj<tco.sectionObj.length; indexj++)
	{
		tso = arg_chapterObj.sectionObj[indexj];
		href = tso.href;
		onMouseOverStr = "";
		onMouseOutStr = "";
		tableStr += "<tr>"+"\n";
		tableStr += '<td bgcolor="#D8EDF8"><img src="/products/images/menu_icon.gif" width="18" height="7"><a href="'+href+'" onMouseOver="'+onMouseOverStr+'" onMouseOut="'+onMouseOutStr+'" class="menu">'+tso.text+"</a></td>"+"\n";
		tableStr += "</tr>"+"\n";
	}
	tableStr += "</table>"+"\n";
	tableStr += "</td></tr></table>"+"\n";

	if(isie)
		tableStr += '</div>'+"\n";
	if(isns)
		tableStr += '</layer>'+"\n";

	return tableStr;
}

function genMenu()
{
	menuTableCode = genChapterMenu(productsChap,"str","index");
	menuTableCode1 = escape(menuTableCode);
	menuTableCode2 = unescape(menuTableCode1);
//alert(menuTableCode1);
//alert(menuTableCode2);
//	document.write(unescape(menuTableCode));
	document.write(menuTableCode2);
}

function genLayerDefinition()
{
	for(i=0; i<layerMenuArray.length; i++)
	{
		layerMenuCode = genLayerMenu(layerMenuArray[i], "str","index");
		document.write(layerMenuCode);
	}
}

//-->