var nav_inited = 0;
var menu_list_inited = 0;
var menu_layers_inited = 0;
var menuPosAdjusted = false;
var num_menus = 8;
var menuTextLayer = null;

var current_menu = -1;
var current_popup = -1;

var doesNotContainCursor = 0;
var containsCursor = 1;

var menu_states;
var popup_states;
var activated;

var menuBtnOn01 = null;
var menuBtnOn02 = null;
var menuBtnOn03 = null;

function initMenuGraphics ()
{
	menuBtnOn01 = new Image ();
	menuBtnOn01.src = "../images/common/menu_btn_on_01.jpg";
	menuBtnOn02 = new Image ();
	menuBtnOn02.src = "../images/common/menu_btn_on_02.jpg";
	menuBtnOn03 = new Image ();
	menuBtnOn03.src = "../images/common/menu_btn_on_03.jpg";
}

var menuTitles = [
	"Products",
	"Support",
	"Store",
	"News",
	"Images",
	"OEM",
	"Corporate"	
];


//var menu_list = new Array (num_menus);
var menu_layers = new Array (num_menus);
var menuWidths = new Array (num_menus);
var totalMenuWidths = 0;
var haveMenuWidths = 0;

menu_states = new Array (num_menus);
popup_states = new Array (num_menus);
activated = new Array (num_menus);
var menuTitleField = 0;
var menuURLField = 1;
var menuItemsField = 2;
var itemTitleField = 0;
var itemURLField = 1;

var menu_list =
[
	[
		"Products",
		"",
		[
			["Controllers",
				"/pages/controllers.html"],
			["Interfaces and Synchronizers",
				"/pages/interfaces.html"],
			["Brochures",
				"/pages/cat.html"],
			["Compatibility",
				"/cgi/compat.cgi"],
			["Images",
				"/pages/images.html"]
		]
	],
	[
		"Support",
		"",
		[
			["Registration",
				"/pages/onlinereg.html"],
			["Compatibility",
				"/cgi/compat.cgi"],
			["Downloads",
				"/pages/downloads.html"],
			["Keysets",
				"/cgi/keysets.cgi?task=ALL"],
			["Product Manuals",
				"/cgi/manuals.cgi?task=current"],
			["Support Archive",
				"/pages/support_archive.html"]
		]
	],
	[
		"Store",
		"",
		[
			["Store/Checkout",
				"javascript:checkout();"],
			["Factory Outlet",
				"/cgi/jlcshop_ns.cgi?task=specials"]
		]
	],
	[
		"News",
		"",
		[
			["News",
				"/pages/news.html"],
			["Press",
				"/pages/press.html"],
			["Events",
				"/pages/events.html"],
			["Video Gallery",
				"/cgi/videogallery.cgi"]
		]
	],
	[
		"Distributors",
		"/pages/distdeal.html",
		[
			["",
				""]
		]
	],
	[
		"Developers",
		"/dev.html",
		[
			["",
				""]
		]
	],
	[
		"OEM Services",
		"/pages/oem.html",
		[
			["",
				""]
		]
	],
	[
		"Corporate",
		"",
		[
			["About JLCooper",
				"/pages/about.html"],
			["Contact Info",
				"/pages/contact.html"],
			["Employment",
				"/pages/employment.html"]
		]
	]
];

function init_Nav ()
{
	if (!havePlatform)
		getPlatform ();
	if (!menu_list_inited)
		init_Menu_List ();
	if (!menu_layers_inited)
		init_Menu_Layers ();
	nav_inited = havePlatform && menu_list_inited && menu_layers_inited;
}

function init_Menu_List ()
{
	if (!havePlatform)
		getPlatform ();
	menu_list_inited = 1;
}

function getMenuTitleWidth (inMenuTitle)
{
	return (inMenuTitle.length * 7) + 14;
}

function CreateMenuGraphics ()
{
	if (!menu_list_inited)
		init_Menu_List ();
	if (!haveMenuWidths)
	{
		totalMenuWidths = 0;
		for (var i = 0; i < num_menus; ++i)
		{
			var title = menu_list[i][menuTitleField];
			menuWidths[i] = getMenuTitleWidth (title);
			totalMenuWidths += menuWidths[i] + 2;
		}
		haveMenuWidths = 1;
	}
	document.write('<table width="' + totalMenuWidths + '" border="0" cellspacing="0" cellpadding="0">');
		document.write('<tr>');

	for (var i = 0; i < num_menus; ++i)
	{
		var title = menu_list[i][menuTitleField];
		var wd = menuWidths [i];
		document.write ('<td width="' + wd + '">');
			document.write ('<table border="0" cellspacing="0" cellpadding="0">');
				document.write ('<tr>');
					document.write ('<td><img id="mbtnl_' + i + '" src="../images/common/menu_btn_off_01.jpg" alt="" width="1" height="22" border="0" /></td>');
					document.write ('<td><img id="mbtnm_' + i + '" src="../images/common/menu_btn_off_02.jpg" alt="" width="' + wd + '" height="22" border="0" /></td>');
					document.write ('<td align="right"><img id="mbtnr_' + i + '" src="../images/common/menu_btn_off_03.jpg" alt="" width="1" height="22" border="0" /></td>');
				document.write ('</tr>');
			document.write ('</table>');
		document.write ('</td>');
	}
		document.write ('</tr>');
	document.write ('</table>');
}

function CreateMenuText ()
{
	if (!havePlatform)
		getPlatform ();
	if (!menu_list_inited)
		init_Menu_List ();
//	if (!menuPosAdjusted)
//		AdjustMenuPos ();
	if (!haveMenuWidths)
	{
		totalMenuWidths = 0;
		for (var i = 0; i < num_menus; ++i)
		{
			var title = menu_list[i][menuTitleField];
			menuWidths[i] = getMenuTitleWidth (title);
			totalMenuWidths += menuWidths[i] + 2;
		}
		haveMenuWidths = 1;
	}

	document.write('<table width="' + totalMenuWidths + '" height="22" border="0" cellspacing="0" cellpadding="0">');
		document.write('<tr>');

	for (var i = 0; i < num_menus; ++i)
	{
		var title = menu_list[i][menuTitleField];
		var menuURL = menu_list[i][menuURLField];
		var wd = menuWidths[i] + 2;
		var vpos="middle";
		if (isIE)
			vpos = "top";
		document.write('<td width="' + wd + '">');
			document.write('<table width="' + wd + '" border="0" cellspacing="0" cellpadding="0">');
				document.write('<tr height="22">');
					document.write('<td align="center" valign="' + vpos + '" width="' + wd + ' ">');
					if (menuURL == "")
					{
						document.write('<a href = "#" class="menuTitles" onmouseover="setMenuState (' + i + ', 1);" onmouseout="setMenuState (' + i + ', 0);">');
					}
					else
					{
						document.write('<a href = "' + menuURL + '" class="menuTitles" onmousedown="setMenuBarButtonState (' + i + ', 1);" onmouseup="setMenuBarButtonState (' + i + ', 0);" onmouseout="setMenuBarButtonState (' + i + ', 0);">');
					}
					document.write('<font color="#2e2e56" onMouseOver="this.style.color=\'#2854ae\'" onMouseOut="this.style.color=\'#2e2e56\'">' + title + '</font></a></td>');
				document.write('</tr>');
			document.write('</table>');
		document.write('</td>');
	}
		document.write ('</tr>');
	document.write ('</table>');
}

function init_Menu_Layers ()
{
	if (!havePlatform)
		getPlatform ();
	menu_layers_inited = 0;
	
	for (var i = 0; i < num_menus; ++i)
	{
		menu_layers[i] = null;
		menu_states[i] = doesNotContainCursor;
		popup_states[i] = doesNotContainCursor;
		activated[i] = false;
	}

	menu_layers_inited = 1;
}

function drawMenuLayer (inLayerNum)
{
	if (menu_layers[inLayerNum] == null)
		menu_layers[inLayerNum] = GetLayerFromName ("menuLayer" + inLayerNum);
	var indent = 0;
	if (inLayerNum)
	{
		indent = -12;
		var title;
		var wd;
		for (var i = 0; i < inLayerNum; ++i)
		{
			title = menu_list[i][menuTitleField];
			wd = getMenuTitleWidth (title) + 2;
			indent += wd;
		}
	}	
	menu_layers[inLayerNum].style.left = indent + "px";
	generatePopupMenu(inLayerNum);
}

function activateMenu (inMenu)
{
	var mbtnl = document.getElementById ("mbtnl_" + inMenu);
	var mbtnm = document.getElementById ("mbtnm_" + inMenu);
	var mbtnr = document.getElementById ("mbtnr_" + inMenu);
	ShowThisLayer (menu_layers[inMenu]);
	mbtnl.src = "../images/common/menu_btn_on_01.jpg"
	mbtnm.src = "../images/common/menu_btn_on_02.jpg"
	mbtnr.src = "../images/common/menu_btn_on_03.jpg"
}

function deactivateMenu (inMenu)
{
	var mbtnl = document.getElementById ("mbtnl_" + inMenu);
	var mbtnm = document.getElementById ("mbtnm_" + inMenu);
	var mbtnr = document.getElementById ("mbtnr_" + inMenu);
	HideThisLayer (menu_layers[inMenu]);
	mbtnl.src = "../images/common/menu_btn_off_01.jpg"
	mbtnm.src = "../images/common/menu_btn_off_02.jpg"
	mbtnr.src = "../images/common/menu_btn_off_03.jpg"
}

function setMenuState (inMenu, inState)
{
	if ((inMenu != -1) &&  (menu_layers[inMenu] == null))
	{
		menu_layers[inMenu] = GetLayerFromName ("menuLayer" + inMenu);
	}
	if ((inMenu != -1) && (inState == 0))
	{
		menu_states[inMenu] = doesNotContainCursor;
		deferDeactivate (inMenu);
	}
	if ((inMenu != -1) && inState)
	{
		current_menu = inMenu;
		menu_states[inMenu] = containsCursor;
		activated[inMenu] = true;
		activateMenu (inMenu)
	}
}

function setMenuBarButtonState (inMenu, inState)
{
	if (inState)
	{
		var mbtnl = document.getElementById ("mbtnl_" + inMenu);
		var mbtnm = document.getElementById ("mbtnm_" + inMenu);
		var mbtnr = document.getElementById ("mbtnr_" + inMenu);

		mbtnl.src = "../images/common/menu_btn_on_01.jpg"
		mbtnm.src = "../images/common/menu_btn_on_02.jpg"
		mbtnr.src = "../images/common/menu_btn_on_03.jpg"
	}
	else
	{
		var mbtnl = document.getElementById ("mbtnl_" + inMenu);
		var mbtnm = document.getElementById ("mbtnm_" + inMenu);
		var mbtnr = document.getElementById ("mbtnr_" + inMenu);
	
		mbtnl.src = "../images/common/menu_btn_off_01.jpg"
		mbtnm.src = "../images/common/menu_btn_off_02.jpg"
		mbtnr.src = "../images/common/menu_btn_off_03.jpg"
	}
}

function deferDeactivate (inMenu)
{
	setTimeout ("deferedDeactivate()", 100);
}

function deferedDeactivate ()
{
	for (var i = 0; i < num_menus; ++i)
	{
		if (activated[i] && (menu_states[i] == doesNotContainCursor) &&
				(popup_states[i] == doesNotContainCursor))
		{
//			alert ("deactivated menu " + i + " because activated: " + activated[i] + " menu state: " + menu_states[i] + " popup state: " + popup_states[i]);
			deactivateMenu (i);
			activated[i] = false;
		}
	}
}

function setPopupState (inPopup, inState)
{
	if ((inPopup != -1) && (menu_layers[inPopup] == null))
		menu_layers[inPopup] = GetLayerFromName ("menuLayer" + inPopup);
		
	if (inState == 0)
	{
		popup_states[inPopup] = doesNotContainCursor;
		deferDeactivate (inPopup);
	}
	if ((inPopup != -1) && inState)
	{
		current_menu = inPopup;
		popup_states[inPopup] = containsCursor;
		activated[inPopup] = true;
		activateMenu (inPopup)
	}
}

function createPopupMenuLayers ()
{
	if (!nav_inited)
		init_Nav ();
	for (var menuNum = 0; menuNum < num_menus; ++menuNum)
	{
		document.write ('<div id="menuLayer' + menuNum + '" ');
		document.write ('style="height: auto; width: auto; left: 26px; top: 110px; position: absolute; z-index: 30; visibility: hidden;" ');
		document.write ('onmouseover="setPopupState(' + menuNum + ',1);" onmouseout="setPopupState(' + menuNum + ',0);">');
		document.write ('<script type="text/javascript" name="generatePopup"><!--\n');
			document.write ('drawMenuLayer(' + menuNum + ')\n');
		document.write ('//-->\n');
		document.write ('</script>\n');
		document.write ('</div>\n');
	}
}

function generatePopupMenu (menu_idx)
{
	if (!haveDmn)
		getDmn ();
	if (menu_idx < num_menus)
	{
		if (!menu_list_inited)
			init_Menu_List ();
		var this_menu = menu_list[menu_idx][menuItemsField];
		var item_count = this_menu.length;
		var item_idx = 1;
		var table_ht = item_count * 20;
		var thisItem;
		var item_txt = "";
		var item_url = "";
		var this_wd = 0;
		var wd = 0;
		for (var i = 0; i < item_count; ++i)
		{
			thisItem = this_menu[i];
			item_txt = thisItem[itemTitleField];
			this_wd = item_txt.length;
			if (this_wd > wd)
				wd = this_wd;
		}
		wd *= 7;
		wd += 40;
		if ((isIE && !isWin) || isNS)
		{
			document.write ('<table width="' + (wd + 10 + 19) + '" border="0" cellspacing="0" cellpadding="0" background="' + dmn + 'images/common/popup_06.png">');
			for (var i = 0; i < item_count; ++i)
			{
				thisItem = this_menu[i];
				item_txt = thisItem[itemTitleField];
				item_url = thisItem[itemURLField];
				document.write ('<tr height="20">');
					document.write ('<td class="mlf"></td>');
					document.write ('<td height="20">&nbsp;&nbsp;');
						document.write ('<a href = "' + item_url + '" class="menuItems" onMouseOver="highlightLink (this, 1);" onMouseOut="highlightLink (this, 0);">');
						document.write ('<font color = "#4c4c5c" onMouseOver="highlightLink (this, 1);" onMouseOut="highlightLink (this, 0);">' + item_txt + '</font></a>&nbsp;&nbsp;</td>');
					document.write ('<td class="mrt"></td>');
				document.write ('</tr>');
			}
		}
/*
		else if (isNS)
		{
			document.write ('<table width="' + (wd + 10 + 19) + '" border="0" cellspacing="0" cellpadding="0">');
				document.write ('<tr>');
					document.write ('<td height="9" width="10"><img src="' + dmn + 'images/common/popup_01.png" height="9" width="10" /></td>');
					document.write ('<td height="9" width="' + wd + '"><img src="' + dmn + 'images/common/popup_02.png" height="9" width="' + wd + '" /></td>');
					document.write ('<td height="9" width="19"><img src="' + dmn + 'images/common/popup_04.png" height="9" width="19" /></td>');
				document.write ('</tr>');
				for (var i = 0; i < item_count; ++i)
				{
					thisItem = this_menu[i];
					item_txt = thisItem[itemTitleField];
					item_url = thisItem[itemURLField];
					document.write ('<tr height="20">');
						document.write ('<td height="20" width="10"><img src="' + dmn + 'images/common/popup_05.png" height="20" width="10" /></td>');
						document.write ('<td class="mcnt" height="20">&nbsp;&nbsp;');
							document.write ('<a href = "' + item_url + '" class="menuItems" onMouseOver="highlightLink (this, 1);" onMouseOut="highlightLink (this, 0);">');
							document.write ('<font color = "#4c4c5c" onMouseOver="highlightLink (this, 1);" onMouseOut="highlightLink (this, 0);">' + item_txt + '</font></a>&nbsp;&nbsp;</td>');
						document.write ('<td height="20" width="19"><img src="' + dmn + 'images/common/popup_08.png" height="20" width="19" /></td>');
					document.write ('</tr>');
				}
				document.write ('<tr>');
					document.write ('<td height="18" width="10"><img src="' + dmn + 'images/common/popup_13.png" height="18" width="10" /></td>');
					document.write ('<td height="18" width="' + wd + '"><img src="' + dmn + 'images/common/popup_14.png" height="18" width="' + wd + '" /></td>');
					document.write ('<td height="18" width="10"><img src="' + dmn + 'images/common/popup_16.png" height="18" width="19" /></td>');
				document.write ('</tr>');
		}
*/
		else
		{
			document.write ('<table width="' + (wd + 10 + 19) + '" border="0" cellspacing="0" cellpadding="0">');
				document.write ('<tr>');
					document.write ('<td height="9" width="10" class="ulf"></td>');
					document.write ('<td height="9" width="' + wd + '" class="umid"></td>');
					document.write ('<td height="9" width="19" class="urt"></td>');
				document.write ('</tr>');
				for (var i = 0; i < item_count; ++i)
				{
					thisItem = this_menu[i];
					item_txt = thisItem[itemTitleField];
					item_url = thisItem[itemURLField];
					document.write ('<tr height="20">');
						document.write ('<td class="mlf"></td>');
						document.write ('<td class="mcnt" height="20">&nbsp;&nbsp;');
							document.write ('<a href = "' + item_url + '" class="menuItems" onMouseOver="highlightLink (this, 1);" onMouseOut="highlightLink (this, 0);">');
							document.write ('<font color = "#4c4c5c" onMouseOver="highlightLink (this, 1);" onMouseOut="highlightLink (this, 0);">' + item_txt + '</font></a>&nbsp;&nbsp;</td>');
						document.write ('<td class="mrt"></td>');
					document.write ('</tr>');
				}
				document.write ('<tr>');
					document.write ('<td height="18" class="blf"></td>');
					document.write ('<td class="bcnt"></td>');
					document.write ('<td class="brt"></td>');
				document.write ('</tr>');
		}
		document.write ('</table>');
	}
}

function setActiveMenu (index)
{
	if (menu_layers[index] == null)
		menu_layers[index] = GetLayerFromName ("menuLayer" + index);
//		init_Menu_Layers ();
	var old_menu = 0;
	var new_menu = 0;
	if (index >= num_menus || index == current_menu)
		index = -1;
	if (current_menu >= 0 && current_menu < num_menus)
		old_menu = menu_layers[current_menu];
	if (index >= 0 && index < num_menus)
		new_menu = menu_layers[index];
	if (old_menu && old_menu != null)
		HideThisLayer (old_menu);
	if (new_menu && new_menu != null)
		ShowThisLayer (new_menu);
	current_menu = index;
//	MySetCookie ("activeMenu", val, null, "/");
}


function HideThisLayer (destlayer) {
	if (isOldIE || isStdComplient) {
		destlayer.style.visibility = "hidden";
	} else {
		destlayer.visibility = "hide";
	}
}

function ShowThisLayer (destlayer) {
	if (isOldIE || isStdComplient) {
		destlayer.style.visibility = "visible";
	} else {
		destlayer.visibility = "show";
	}
}

function GetLayerFromName (layer_name)
{
	var the_layer = 0;
	if (isOldNS) {
		////////////////////////////////////
		///  Proprietary Navigator 4.x code 
		//
			the_layer=document.layers[layer_name];	 
	}
    else if (isOldIE) {
		////////////////////
		/// Proprietary IE4 
		//
				
		the_layer = document.all[layer_name];
	
	}
    else if (isStdComplient) {
		/////////////////////////////////////////////////
		///  The Standards Compliant Way .. recommended. 
		//  
		the_layer=document.getElementById(layer_name);
	}

	return the_layer;
}


function highlightLinkWithColors (theLink, isOver, overColor, outColor)
{
	if (isOver)
	{
		theLink.style.color = overColor; // "#247bb9";
		theLink.style.textDecoration = "underline";
	}
	else
	{
		theLink.style.color = outColor;
		theLink.style.textDecoration = "none";
	}
}

function highlightLink (theLink, isOver)
{
	if (isOver)
	{
		theLink.style.color = "#2854ae"; // "#247bb9";
		theLink.style.textDecoration = "underline";
	}
	else
	{
		theLink.style.color = "#4c4c5c";
		theLink.style.textDecoration = "none";
	}
}

function hilightNavLink (inNavLink, inOver)
{
	if (inOver)
	{
		inNavLink.style.color="#247bb9";
		inNavLink.style.textDecoration = "underline";

	}
	else
	{
		inNavLink.style.color="#4c4c4c";
		inNavLink.style.textDecoration = "none";
	}
}

function gotoClass (inClassCode)
{
	location = "../cgi/mastert.cgi?class=" + inClassCode;
}

function gotoProduct (inProdCode)
{
	location = "../cgi/mastert.cgi?prod=" + inProdCode;
}

function gotoDownloads (inFamCode)
{
	location = "../cgi/mastert.cgi?dl=" + inFamCode;
}

function gotoFamily (inFamCode)
{
	location = "../cgi/mastert.cgi?fam=" + inFamCode;
}

function gotoLit ()
{
	location = "../cgi/mastert.cgi?lit";
}

function gotoPDF (inPath, inTitle)
{
	var wf = "";	
	wf = wf + "width=" + 800;
	wf = wf + ",height=" + 600;
	wf = wf + ",resizable=yes,scrollbars=yes,menubar=no,toolbar=yes,directories=no,location=yes,status=yes";		
	var newWind = window.open(inPath,inTitle,wf);
}

function gotoPhotos (inPhotoCode)
{
	location = "../cgi/mastert.cgi?photos=" + inPhotoCode;
}

function gotoManuals(inVintageCode)
{
	location = "../cgi/mastert.cgi?manuals=" + inVintageCode;
}

function gotoSupport(inProductCode)
{
	location = "../cgi/mastert.cgi?support=" + inProductCode;
}

/*
function generateProductNavBox ()
{
	var ht = calcProdNavHeight ();
	document.write ('<table id="Table_01" border="0" cellpadding="0" cellspacing="0">');
		document.write ('<tr>');
			document.write ('<td><img src="../images/home/home_rt_frame_01.png" alt="" width="16" height="16" border="0" /></td>');
			document.write ('<td><img src="../images/home/home_rt_frame_02.png" alt="" width="172" height="16" border="0" /></td>');
			document.write ('<td><img src="../images/home/home_rt_frame_03.png" alt="" width="22" height="16" border="0" /></td>');
		document.write ('</tr>');
		document.write ('<tr>');
			document.write ('<td><img src="../images/home/home_rt_frame_04.png" alt="" width="16" height="' + ht + '" border="0" /></td>');
			document.write ('<td align="center" valign="top">');

				generateProductNav ();

			document.write ('</td>');
			document.write ('<td><img src="../images/home/home_rt_frame_06.png" alt="" width="22" height="' + ht + '" border="0" /></td>');
		document.write ('</tr>');
		document.write ('<tr>');
			document.write ('<td><font color="black"><img src="../images/home/home_rt_frame_07.png" alt="" width="16" height="22" border="0" /></font></td>');
			document.write ('<td><img src="../images/home/home_rt_frame_08.png" alt="" width="172" height="22" border="0" /></td>');
			document.write ('<td><img src="../images/home/home_rt_frame_09.png" alt="" width="22" height="22" border="0" /></td>');
		document.write ('</tr>');
	document.write ('</table>');

}

function generateProductNav2 ()
{
		document.write ('<table width="164" border="0" cellspacing="0" cellpadding="2">');
		document.write ('<tr><td align="center" valign="top"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><b>PRODUCT LINKS</b></font></td></tr>');
		document.write ('<tr><td><img src="../images/common/prod_nav_sep.jpg" /></td></tr>');
		var needSep = generatePrintLink ();
		needSep |= generatePhotosLink ();
		needSep |= generateVideoLink ();
		needSep |= generateManualLink ();
		needSep |= generateMoreInfoLink ();
		needSep |= generateKeysetLink ();
		needSep |= generateCompatLink2 ();

		if (needSep)
			document.write ('<tr><td><img src="../images/common/prod_nav_sep.jpg" /></td></tr>');
		document.write ('<tr><td align="center" valign="top"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><b>RELATED ITEMS</b></font></td></tr>');
		document.write ('<tr><td>');
			showRelatedLinks (ccode);
		document.write ('</td></tr>');

		document.write ('<tr><td><img src="../images/common/prod_nav_sep.jpg" /></td></tr>');
		generateDeveloperLink ();

	document.write ('</table>');
}

function calcProdNavHeight ()
{
	var ht = 4;
	if (printable)
		++ht;
	if (hasMorePhotos)
		++ht;
	if (hasVideo)
		++ht;
	ht += (numManuals * 2);
	if (hasMoreInfo)
		++ht;
	if (keysetCode != "")
		++ht;
	if (compatInfo)
		++ht;
	if (numRelatedLinks && ht)
		++ht;
	ht += numRelatedLinks;
	
	return 32 + (ht * 19);
}


function generateBuyNowBtn ()
{
	if (canBuy)
	{
//		document.write ('<tr>');
//			document.write ('<td align="center" valign="top">');
				document.write ('<a onmousedown="changeImages(\'buy_off\',\'../images/common/buy_on_3.jpg\');return true"');
				document.write (' onmouseup="changeImages(\'buy_off\',\'../images/common/buy_off_3.jpg\');return true"');
				document.write (' onmouseout="changeImages(\'buy_off\',\'../images/common/buy_off_3.jpg\');return true"');
				document.write (' onclick="MySetCookie(\'BuyNow\',ccode,null,\'/\');MySetCookie(\'ReturnTo\',returnTo,null,\'/\');"');
				document.write (' href="buynow.html"><img id="buy_off" src="../images/common/buy_off_3.jpg" alt="" name="buy_off" width="96" height="27" border="0">');
				document.write ('</a>');
//			document.write ('</td>');
//		document.write ('</tr>');
	}
}

function generateItemsInCart ()
{
	document.write(ItemsInCart());
}
*/

function generateDeveloperLink ()
{
	document.write ('<tr>');
		document.write ('<td align="left">');
		document.write ('<a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href="#">');
		document.write ('<font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">Developer Information</font></a></td>');
	document.write ('</tr>');
}

/*
function generatePrintLink ()
{
	if (printable)
	{
		document.write ('<tr>');
			document.write ('<td align="left">');
			document.write ('<a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href="javascript:gotoCatalogPage(catPath);">');
			document.write ('<font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">Printable Version</font></a></td>');
		document.write ('</tr>');
	}
	return printable;
}

function generatePhotosLink ()
{
	if (hasMorePhotos)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top"><a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href="javascript:gotoPhotos(\'prod\');">');
			document.write ('<font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">More Photos</font></a></td>');
		document.write ('</tr>');
	}
	return hasMorePhotos;
}

function generateMoreInfoLink ()
{
	if (hasMoreInfo)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top"><a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href="' + moreInfoLink + '">');
			document.write ('<font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">More Information</font></a>');
			document.write ('</td>');
		document.write ('</tr>');
	}
	return hasMoreInfo;
}

function generateKeysetLink ()
{
	var hasKeysets = false;
	if (keysetCode != "")
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top">');
				document.write('<a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href = "javascript:OpenAWindow(\'/cgi/mastert.cgi?kset=' + keysetCode + '\',832,600)">');
				document.write ('<font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">Download Keysets</font></a>');
			document.write ('</td>');
		document.write ('</tr>');
	}
	return hasKeysets;
}
		
function generateCompatLink2 ()
{
	if (compatInfo)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top">');
				document.write('<a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href = "#" onclick="OpenGraphicWindow(\'/cgi/compatCheck.cgi?task=' + compatName + '\',800,600)">');
			document.write ('<font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">Compatibilty Check</font></a>');
			document.write ('</td>');
		document.write ('</tr>');
	}
	return compatInfo;
}

function getRelatedLinks (inClassCode)
{
	if (!linksInited)
		buildLinksArray ();
	var found = 0;
	var offset = 0;
	for (var i = 0; i < linksArray.length; i++)
	{
		offset = linksArray[i];
		if (relatedLinks[offset] == inClassCode)
		{
			found = 1;
			break;
		}
	}
	if (found)
		return offset;
	return -1;
}

function showRelatedLinks (inClassCode)
{
	if (numRelatedLinks)
	{
		document.write ('<table  border="0" cellpadding="2" cellspacing="0">');
		offset = 0;
		for (var i = 0; i < numRelatedLinks; i++)
		{
			var name = relatedLinks[offset++];
			var ref = relatedLinks[offset++];
			document.write ("<tr>\n");
			document.write ('<td align="left" valign="top"><a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href="');
			document.write (ref);
			document.write ('"><font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">' + name);
			document.write('</font></a></td></tr>');
		}
		document.write('</table>');
	}
}

function	gotoVideo (inVCode)
{
	location = "../cgi/mastert.cgi?vid=" + inVCode; //  + "&" + vnam;
}
*/

function	gotoEvents()
{
	location = "../cgi/mastert.cgi?event";
}

function gotoOEM ()
{
	location = "../cgi/mastert.cgi?oem";
}

function	gotoCorp (inCode)
{
	location = "../cgi/mastert.cgi?corp=" + inCode;
}

function	gotoDist ()
{
	location = "../cgi/mastert.cgi?dist";
}

/*
function generateVideoLink ()
{
	if (hasVideo)
	{
//		var offset = getOffsetForClass (ccode);
//		if (offset != null)
		{
//			var fname = prodList[offset + familyOset];
			if (videoName && (videoName != null))
			{
				document.write ('<tr>');
					document.write ('<td align="left" valign="top">');
						document.write('<a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href = "javascript:gotoVideo(\'' + vcode + '\');">');
						document.write ('<font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">' + videoName + ' Video</font></a>');
					document.write ('</td>');
				document.write ('</tr>');
			}
		}
	}
}

function generateManualLink ()
{
	if (numManuals)
	{
		var pname;
		var mname;
		var msize;
		{
			var j;
			for (var i = 0; i < numManuals; i += 3)
			{
				var manSize = manuals[i];
				if (manSize == "")
					return i;
				else
				{
					var manFile = manuals[i + 1];
					var manName = manuals[i + 2];
					if (manName == "")
					{
						var temp = manFile.split ("_");
						var len = temp.length - 1
						for (j = 0; j <= len; ++j)
						{
							manName += temp[j];
							if (j < len)
								manName += " ";
						}
						manName = manName.substr (0, manName.length - 4);	// remove extension
					}
					document.write ('<tr>');
						document.write ('<td align="left" valign="top">');
							document.write('<a class="navItems" onMouseOver="hilightNavLink (this, 1);" onMouseOut="hilightNavLink (this, 0);" href = "#" onclick="OpenGraphicWindow(\'manuals/current/' + manFile + '\',800,600)">');
							document.write ('<font color = "#4c4c4c" onMouseOver="hilightNavLink(this,1);" onMouseOut="hilightNavLink(this,0);">Download ' + manName + ' (' + manSize + ')</font></a>');
						document.write ('</td>');
					document.write ('</tr>');
				}
			}		
		}
	}
	return numManuals;
}
*/

function OpenAWindow (inURL, inWidth, inHeight)
{
	var wf = "";	
	wf = wf + "width=" + inWidth;
	wf = wf + ",height=" + inHeight;
	wf = wf + ",resizable=yes,scrollbars=yes,menubar=no,toolbar=yes,directories=no,location=yes,status=yes";		
	var newWind = window.open(inURL, "", wf);
}


function checkout ()
{
	location = "/cgi/jlcshop_ns.cgi?task=purch";
}

function gotoPhotoPage3 ()
{
	MySetCookie ("ReturnTo","",null,"/");
	MySetCookie ("ReturnToClass","ALL",null,"/");
	if (!haveDmn)
		getDmn ();
	location = dmn + "pages/allphotos.html";
}

function gotoPhotoPage4 (inReturnTo, inCode)
{
	MySetCookie ("ReturnTo","",null,"/");
	MySetCookie ("ReturnToClass",inCode,null,"/");
	location = pagePath + "morephotos.html";
}



