var isWin = false;

var isOldNS = false;			// proprietary netscape
var isIE = false;				// proprietary explorer
var isOldIE = false;			// proprietary explorer
var isOpera = false;
var isFirefox = false;
var isSafari = false;
var isStdComplient = false;		// standards complient

var isNetscape = false;

var havePlatform = false;	

var num_menus = 6;

var curMenu = 127;

// since there are no 2 dimensional arrays in JS
// store flattened menu data in a 1 dim. array.
// a 2nd array holds offsets to the start of each
// menu's data

var menuData = [
	"Products",
		5,
		"Controllers",
			"controllers.html",
		"Interfaces",
			"interfaces.html",
		"Synchronizers",
			"synchronizers.html",
		"Brochures",
			"cat.html",
		"Compatibility",
			"../cgi/compat.cgi",
	"Support",
		6,
		"Registration",
			"onlinereg.html",
		"Compatibility",
			"../cgi/compat.cgi",
		"Downloads",
			"downloads.html",
		"Keysets",
			"../cgi/keysets.cgi?task=ALL",
		"Product Manuals",
			"/cgi/manuals.cgi?task=current",
		"CS-32 Support",
			"cs32support.html",
	"Store",
		2,
		"Store/Checkout",
			"javascript:checkout();",
		"Factory Outlet",
			"../cgi/jlcshop_ns.cgi?task=specials",
	"News",
		5,
		"News",
			"news.html",
		"Press",
			"press.html",
		"Events",
			"events.html",
		"Product Photos",
			"javascript:gotoPhotoPage2();",
		"User Photos",
			"../cgi/userphotos.cgi",
	"OEM",
		2,
		"Developers",
			"../dev.html",
		"OEM",
			"oem.html",
	"Corporate",
		4,
		"About JLCooper",
			"about.html",
		"Contact Info",
			"contact.html",
		"Employment",
			"employment.html",
		"Distributors",
			"distdeal.html"
];

var menuOffsets = new Array (num_menus);
var menuOffset = 0;
var layerList = new Array (num_menus + 1);
var haveLayerList = 0;
for (var i = 0; i < num_menus; i++)
{
	menuOffsets[i] = menuOffset;
	var num = menuData[menuOffset + 1];

	menuOffset += (num * 2) + 2;	// two array slots for each sub item + one for name and one for count;
}

getPlatform ();


function generateMenusX (currentMenu)
{
	if (!haveLayerList)
		buildLayerList ();
	var mainlinkStyle = "mainlinks";
	if (isWin || isOpera)			// so far, all windows browsers tested + opera mac render
		mainlinkStyle = "mainlinkswin";	// text larger than the mac for the same point size.
									// so those browsers use a different text style for the
									// menus.
	document.write ('<table width="116" border="0" cellspacing="0" cellpadding="0">');

	document.write ('<tr><td colspan="3" align="center">');
	document.write ('<a href="/index.html" class="' + mainlinkStyle + '">Home</a>');
	document.write ('</td></tr>');
	document.write('<tr><td></td>');
	document.write('<td><img src="' + imagePath + 'common/header28/spacer4X15.jpg" width="15" height="4" border="0"></td>');
	document.write('<td><img src="' + imagePath + 'common/header28/spacer4X89.jpg" width="89" height="4" border="0"></td></tr>');
	
	document.write ('<tr>');
	for (var i = 0; i < num_menus; ++i)
	{
		var mOffset = menuOffsets[i];
		var menuName = menuData[mOffset];
		document.write ('<td width="15" height="15">');
		if (i == currentMenu)
		{
			document.write ('<a href="javascript:setActiveMenu(' + i + ',0);"><img src="' + imagePath + 'common/header28/ptr_d10.jpg" alt="" width="15" height="15" border="0"></a>');
			document.write ('</td>');
			document.write ('<td colspan="2"><a href="javascript:setActiveMenu(' + i + ',0);" class="' + mainlinkStyle + '">' + menuName + '</a></td>');
		}
		else
		{
			document.write ('<a href="javascript:setActiveMenu(' + i + ',1);"><img src="' + imagePath + 'common/header28/ptr_u10.jpg" alt="" width="15" height="15" border="0"></a>');
			document.write ('</td>');
			document.write ('<td colspan="2"><a href="javascript:setActiveMenu(' + i + ',1);" class="' + mainlinkStyle + '">' + menuName + '</a></td>');
		}
		document.write ('</tr>');

		if (i == currentMenu)
		{
			var itemCount = menuData[mOffset + 1];
			mOffset += 2;		// point to the first menu item

			if (itemCount)
			{
				document.write ('<tr><td><img src="' + imagePath + '/common/spacer4x4.gif" alt="" width="4" height="4" border="0"></td><td></td><td></td></tr>');
				for (var j = 0; j < itemCount; ++j)
				{
					var itm = menuData[mOffset++];
					var lnk = menuData[mOffset++];
					document.write ('<tr height="14">');
					document.write ('<td width="12"><img src="' + imagePath + '/common/spacer4x4.gif" alt="" width="12" height="14" border="0"></td>');
					document.write ('<td width="15"></td>');
					document.write ('<td><b><font size="1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">');
					if (lnk.substring (0, 11) == "javascript:")
						document.write ('<a href="' + lnk + '">' + itm + '</a>');
					else
						document.write ('<a href="' + pagePath + lnk + '">' + itm + '</a>');
					document.write ('</font></b></td>');
					document.write ('</tr>');
				}
				document.write ('<tr>');
				document.write ('<td width="12"></td>');
				document.write ('<td width="15"></td>');
				document.write ('<td><img src="' + imagePath + 'common/spacer4x4.gif" alt="" width="4" height="4" border="0"></td>');
				document.write ('</tr>');
			}
		}
	}
	document.write ('</table>');
}

function generateMenus (currentMenu)
{
	if (!haveLayerList)
		buildLayerList ();
	var mainlinkStyle = "mainlinks";
	if (isWin || isOpera)			// so far, all windows browsers tested + opera mac render
		mainlinkStyle = "mainlinkswin";	// text larger than the mac for the same point size.
									// so those browsers use a different text style for the
									// menus.
	document.write ('<table width="116" border="0" cellspacing="0" cellpadding="0">');

	document.write ('<tr><td colspan="3" align="center">');
//	document.write ('<a href="/index.html"><b><font size="2" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">Home</font></a>');
	document.write ('<a href="/index.html" class="' + mainlinkStyle + '">Home</a>');
	document.write ('</td></tr>');
	document.write('<tr><td></td>');
	document.write('<td><img src="' + imagePath + 'common/header28/spacer4X15.jpg" width="15" height="4" border="0"></td>');
	document.write('<td><img src="' + imagePath + 'common/header28/spacer4X89.jpg" width="89" height="4" border="0"></td></tr>');
	
	document.write ('<tr>');
	for (var i = 0; i < num_menus; ++i)
	{
		var mOffset = menuOffsets[i];
		var menuName = menuData[mOffset];
		document.write ('<td width="15" height="15">');
		if (i == currentMenu)
		{
			document.write ('<a href="javascript:setActiveMenu(' + i + ',0);"><img src="' + imagePath + 'common/header28/ptr_d.jpg" alt="" width="15" height="15" border="0"></a>');
			document.write ('</td>');
			document.write ('<td colspan="2"><a href="javascript:setActiveMenu(' + i + ',0);" class="' + mainlinkStyle + '">' + menuName + '</a></td>');
		}
		else
		{
			document.write ('<a href="javascript:setActiveMenu(' + i + ',1);"><img src="' + imagePath + 'common/header28/ptr_u.jpg" alt="" width="15" height="15" border="0"></a>');
			document.write ('</td>');
			document.write ('<td colspan="2"><a href="javascript:setActiveMenu(' + i + ',1);" class="' + mainlinkStyle + '">' + menuName + '</a></td>');
		}
		document.write ('</tr>');

		if (i == currentMenu)
		{
			var itemCount = menuData[mOffset + 1];
			mOffset += 2;		// point to the first menu item

			if (itemCount)
			{
				document.write ('<tr><td><img src="' + imagePath + '/common/spacer4x4.gif" alt="" width="4" height="4" border="0"></td><td></td><td></td></tr>');
				for (var j = 0; j < itemCount; ++j)
				{
					var itm = menuData[mOffset++];
					var lnk = menuData[mOffset++];
					document.write ('<tr height="14">');
					document.write ('<td width="12"><img src="' + imagePath + '/common/spacer4x4.gif" alt="" width="12" height="14" border="0"></td>');
					document.write ('<td width="15"></td>');
					document.write ('<td><b><font size="1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">');
					if (lnk.substring (0, 11) == "javascript:")
						document.write ('<a href="' + lnk + '">' + itm + '</a>');
					else
						document.write ('<a href="' + pagePath + lnk + '">' + itm + '</a>');

					document.write ('</font></b></td>');
					document.write ('</tr>');
				}
				document.write ('<tr>');
				document.write ('<td width="12"></td>');
				document.write ('<td width="15"></td>');
				document.write ('<td><img src="' + imagePath + 'common/spacer4x4.gif" alt="" width="4" height="4" border="0"></td>');
				document.write ('</tr>');
			}
		}
	}
	document.write ('</table>');
}

function buildLayerListX ()
{
	haveLayerList = 0;
	for (var i = 0; i < num_menus; i++)
	{
		layerList[i] = GetLayerFromName ("menuLayer" + i);
		if ((!layerList[i]) || (layerList[i] == null))
			return;
	}
	layerList[num_menus] = GetLayerFromName ("menuLayer" + num_menus);
	if (layerList[num_menus] && layerList[num_menus] != null)
	{
		haveLayerList = 1;
	}
}

function buildLayerList ()
{
	haveLayerList = 0;
	for (var i = 0; i < num_menus; i++)
	{
		layerList[i] = GetLayerFromName ("menuLayer" + i);
		if ((!layerList[i]) || (layerList[i] == null))
			return;
		if (isIE)
			adjustMenuPos (layerList[i]);
	}
	layerList[num_menus] = GetLayerFromName ("menuLayer" + num_menus);
	if (layerList[num_menus] && layerList[num_menus] != null)
	{
		haveLayerList = 1;
		if (isIE)
			adjustMenuPos (layerList[num_menus]);
	}
}

function adjustMenuPos (lyr)
{
	if (isStdComplient || isIE) {
			/////
			////
			///  The Standards Compliant Way .. recommended. 
			//  
		lyr.style.left= "33px";
		lyr.style.top= "122px";
	}
}

function setActiveMenu (index, active)
{
	var val = 127;
	if (active)
		val = index;
	var oldLayer;
	if (curMenu == 127)
		oldLayer = layerList[num_menus];
	else
		oldLayer = layerList[curMenu];
	var newLayer;
	if (val == 127)
		newLayer = layerList[num_menus];
	else
		newLayer = layerList[val];
	MySetCookie ("activeMenu", val, null, "/");
	curMenu = val;
	HideThisLayer (oldLayer);
	ShowThisLayer (newLayer);
}

function updateMenusOnLoad ()
{
	var newMenuLayer = GetCookie ("activeMenu");
	var actv = 1;
	if (newMenuLayer == null || newMenuLayer >= num_menus)
	{
		newMenuLayer = 127;
		actv = 0;
	}
	setActiveMenu (newMenuLayer, actv);
}

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 getPlatform () {
	if (navigator.appVersion.indexOf ("Win") != -1) {
		isWin = true;
	}
	if (navigator.userAgent.indexOf ("Opera") != -1)
	{
		isOpera = true;
	}
	else if (navigator.userAgent.indexOf ("Safari") != -1)
	{
		isSafari = true;
	}
	else if (navigator.userAgent.indexOf ("Firefox") != -1)
	{
		isFirefox = true;
	}
	else if (navigator.userAgent.indexOf("MSIE") != -1) {
		isIE = true;
	}
	if (document.layers)
		isOldNS = true;
	else if (document.all && !document.getElementById)
		isOldIE = true;
	else if (document.getElementById /* && document.body.style*/ )
		isStdComplient = true;


	if (navigator.appName.indexOf("Netscape") != -1)
	{
		isNetscape = true;
	}

	havePlatform = true;
}

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 gotoPhotoPage ()
{
	MySetCookie ("ReturnTo",returnTo,null,"/");
	MySetCookie ("ReturnToClass",ccode,null,"/");
//	location = pagePath + "morephotos.html";
	OpenFullWindow (pagePath + "morephotos.html",800,600);
}

function gotoPhotoPage2 ()
{
	MySetCookie ("ReturnTo","",null,"/");
	MySetCookie ("ReturnToClass","ALL",null,"/");
	location = pagePath + "allphotos.html";
}

function gotoCatalogPage (inPath)
{
	OpenGraphicWindow (inPath,800,600);
//	location = inPath;
}

function continueShopping ()
{
	var pg = GetCookie ("ReturnTo");
	if (pg && (pg != null))
	{
		location = pg;
	}
}

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

function	gotoVideo ()
{
	MySetCookie ("ReturnTo",returnTo,null,"/");
	MySetCookie ("ReturnToClass",ccode,null,"/");
	location = "videos.html";
}

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

function generateManualLink ()
{
	if (numManuals)
	{
		var pname;
		var mname;
		var msize;
		if (numManuals == 1)
		{
//			var offset = getOffsetForClass (ccode);
//			if (offset != null)
			{
//				pname = prodList[offset + familyOset];
				pname = getManualName (ccode);
				if (pname && (pname != null))
				{
					mname = getManualFileName (ccode);
					if (mname && (mname != null))
					{
						msize = getManualFileSize (ccode);
						if (msize && (msize != null))
						{
							document.write ('<tr>');
								document.write ('<td align="left" valign="top">');
									document.write ('<a href="#" onclick="OpenGraphicWindow(\'manuals/current/' + mname + '\',950,900);" class="Helv9DarkGray" onmouseover="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onmouseout="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
									document.write ('<font color="#4c4c5c" onMouseOver="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onMouseOut="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
									document.write ('Download ' + pname + ' (' + msize + ')</font></a>');
								document.write ('</td>');
							document.write ('</tr>');
						}
					} 
				}
			}
		}
		else if (numManuals > 1)
		{
			for (var i = 0; i < numManuals; i++)
			{
				var newccode = extraManuals[i];
				pname = getManualName (newccode);
				if (pname && (pname != null))
				{
					mname = getManualFileName (newccode);
					if (mname && (mname != null))
					{
						msize = getManualFileSize (newccode);
						if (msize && (msize != null))
						{
							document.write ('<tr>');
								document.write ('<td align="left" valign="top">');
									document.write ('<a href="#" onclick="OpenGraphicWindow(\'manuals/current/' + mname + '\',950,900);" class="Helv9DarkGray" onmouseover="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onmouseout="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
									document.write ('<font color="#4c4c5c" onMouseOver="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onMouseOut="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
									document.write ('Download ' + pname + ' (' + msize + ')</font></a>');
								document.write ('</td>');
							document.write ('</tr>');
						}
					} 
				}
			}		
		}
	}
	return numManuals;
}

function generateWhiteManualLink ()
{
	if (numManuals)
	{
		var pname;
		var mname;
		var msize;
		if (numManuals == 1)
		{
//			var offset = getOffsetForClass (ccode);
//			if (offset != null)
			{
//				pname = prodList[offset + familyOset];
				pname = getManualName (ccode);
				if (pname && (pname != null))
				{
					mname = getManualFileName (ccode);
					if (mname && (mname != null))
					{
						msize = getManualFileSize (ccode);
						if (msize && (msize != null))
						{
							document.write ('<tr>');
								document.write ('<td align="left" valign="top">');
									document.write ('<a href = "#"  class="smallLiteGrayLinks" onmouseover="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onmouseout="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');" onclick="OpenGraphicWindow(\'manuals/current/' + mname + '\',950,900)">');
									document.write ('<font color="#b8b8b8" onMouseOver="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onMouseOut="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');">');
									document.write ('Download ' + pname + ' (' + msize + ')</font></a>');
								document.write ('</td>');
							document.write ('</tr>');
						}
					} 
				}
			}
		}
		else if (numManuals > 1)
		{
			for (var i = 0; i < numManuals; i++)
			{
				var newccode = extraManuals[i];
				pname = getManualName (newccode);
				if (pname && (pname != null))
				{
					mname = getManualFileName (newccode);
					if (mname && (mname != null))
					{
						msize = getManualFileSize (newccode);
						if (msize && (msize != null))
						{
							document.write ('<tr>');
								document.write ('<td align="left" valign="top">');
									document.write('<a href = "#"  class="smallLiteGrayLinks" onmouseover="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onmouseout="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');" onclick="OpenGraphicWindow(\'manuals/current/' + mname + '\',950,900)">');
									document.write ('<font color="#b8b8b8" onMouseOver="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onMouseOut="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');">');
									document.write ('Download ' + pname + ' (' + msize + ')</font></a>');
								document.write ('</td>');
							document.write ('</tr>');
						}
					} 
				}
			}		
		}
	}
	return numManuals;
}

function generateDownloadLinks ()
{
	var numLinks = 0;
	var offset = getDownloads (ccode);
	if (offset >= 0)
	{
		numLinks = downloadLinks[offset + dldCountOffset];
		if (numLinks)
		{
			var dname;
			var dpath;
			offset += dldName1Offset;
			for (var i = 0; i < numLinks; i++)
			{
				dname = downloadLinks[offset++];
				dpath = downloadLinks[offset++];
				document.write ('<tr>\n');
					document.write ('<td align="left" valign="top">');
						document.write ('<a href="' + dpath + '" class="Helv9DarkGray" onmouseover="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onmouseout="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
						document.write ('<font color="#b8b8b8" onMouseOver="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onMouseOut="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');">');
									document.write ('Download ' + dname + '</font></a>');
					document.write ('</td>');
				document.write ('</tr>');
				
			}
		}
	}
	return numLinks;
}

function ClearReturnTo ()
{
	MySetCookie ("ReturnTo","",null,"/");
}

function generateReturnLink ()
{
	var ref = GetCookie ("ReturnTo");
	if (ref && ref != null)
	{
		var retClass = GetCookie ("ReturnToClass");
		if (retClass && retClass != null && retClass != "ALL")
		{
			var shortName = getShortNameForClass (retClass);
			if (shortName && (shortName != null))
			{
				var backBtnOnPreload = new Image (44, 16);
				backBtnOnPreload.src = '../images/common/backbutton_on.jpg';
				var backBtnOffPreload = new Image (44, 16);
				backBtnOffPreload.src = '../images/common/backbutton_off.jpg';
				var backBtnOverPreload = new Image (44, 16);
				backBtnOverPreload.src = '../images/common/backbutton_over.jpg';

				document.write ('<a');
				document.write (' onmousedown="myChangeImages(\'backbutton_off\',\''+backBtnOnPreload.src+'\');return true"');
				document.write (' onclick="myChangeImages(\'backbutton_off\',\''+backBtnOverPreload.src+'\');"');
				document.write (' onmouseup="myChangeImages(\'backbutton_off\',\''+backBtnOverPreload.src+'\');return true"');
				document.write (' onmouseout="myChangeImages(\'backbutton_off\',\''+backBtnOffPreload.src+'\');return true"');
				document.write (' onmouseover="myChangeImages(\'backbutton_off\',\''+backBtnOverPreload.src+'\');return true"');

				document.write (' href="' + ref + '" onclick="ClearReturnTo ();"><img id="backbutton_off" src="/images/common/backbutton_off.jpg" alt="" name="backbutton_off" width="44" height="16" border="0"></a><br>');

				document.write('<font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><a href = "' + ref + '" onclick="ClearReturnTo ();"> to ' + shortName + '</a></font>');
			}
		}
	}
}

function generateCloseLink ()
{
	var ref = GetCookie ("ReturnTo");
	if (ref && ref != null)
	{
		var retClass = GetCookie ("ReturnToClass");
		if (retClass && retClass != null && retClass != "ALL")
		{
			var closeBtnOnPreload = new Image (44, 16);
			closeBtnOnPreload.src = '../images/common/closebtn_on.jpg';
			var closeBtnOffPreload = new Image (44, 16);
			closeBtnOffPreload.src = '../images/common/closebtn_off.jpg';
			var closeBtnOverPreload = new Image (44, 16);
			closeBtnOverPreload.src = '../images/common/closebtn_over.jpg';

			document.write ('<a');
			document.write (' onmousedown="myChangeImages(\'closebtn_off\',\''+closeBtnOnPreload.src+'\');return true"');
			document.write (' onclick="myChangeImages(\'closebtn_off\',\''+closeBtnOverPreload.src+'\');"');
			document.write (' onmouseup="myChangeImages(\'closebtn_off\',\''+closeBtnOverPreload.src+'\');return true"');
			document.write (' onmouseout="myChangeImages(\'closebtn_off\',\''+closeBtnOffPreload.src+'\');return true"');
			document.write (' onmouseover="myChangeImages(\'closebtn_off\',\''+closeBtnOverPreload.src+'\');return true"');

			document.write (' href="javascript:window.close();" onclick="ClearReturnTo ();"><img id="closebtn_off" src="/images/common/closebtn_off.jpg" alt="" name="closebtn_off" border="0"></a>');

//			document.write('<font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">&nbsp;<a href = "javascript:window.close();" onclick="ClearReturnTo ();">Close</a></font>');
		}
	}
}

function myPreload (preloadImg, preloadUrl, iwidth, iheight)
{
	
	preloadImg = new Image (iwidth, iheight);
	preloadImg.src = preloadUrl;
}

function myChangeImages (imgID, newImg)
{
	var dest = null;
	if (document.getElementById)
		dest = document.getElementById(imgID);
	if (dest != null)
		dest.src = newImg;
	else
		alert ("couldn't find " + imgID);
}

function generateMoreInfoLink ()
{
	if (hasMoreInfo)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top">');
				document.write ('<a href="' + moreInfoLink + '" class="Helv9DarkGray" onmouseover="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onmouseout="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('<font color="#4c4c5c" onMouseOver="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onMouseOut="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('More Information</font></a>');
			document.write ('</td></tr>');
	}
	return hasMoreInfo;
}

function generateKeysetLink ()
{
	var hasKeysets = false;
	if (keysetCode != "")
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top" height="20">');
				document.write ('<a href="#" onclick="OpenFullWindow(\'/cgi/keysets.cgi?task=' + keysetCode + '\',800,600)" class="Helv9DarkGray" onmouseover="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onmouseout="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('<font color="#4c4c5c" onMouseOver="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onMouseOut="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('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" height="20">');
				document.write ('<a href="#" onclick="OpenGraphicWindow(\'/cgi/compatCheck.cgi?task=' + compatName + '\',800,600)" class="Helv9DarkGray" onmouseover="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onmouseout="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('<font color="#4c4c5c" onMouseOver="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onMouseOut="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('Compatibilty Check</font></a>');
			document.write ('</td>');
		document.write ('</tr>');
	}
	return compatInfo;
}

function generateCompatLink ()
{
	if (compatInfo)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top" height="20">');
			compatLinkSub (compatName, 0)
			document.write ('</td>');
		document.write ('</tr>');
	}
	return compatInfo;
}

function compatLinkSub (inCompatName, inFormNum)
{
	var formName = "compatForm" + inFormNum;
	document.write ('<form action="/cgi/compat.cgi?task=search" method="post" name="'+formName+'">');
	document.write ('<input type="hidden" name="searchWhat" value="searchJLC">');
	document.write ('<input type="hidden" name="selectJLCProduct" value="'+inCompatName+'">');
	document.write ('<input type="hidden" name="selectCompany" value="9 pin">');
	document.write ('<input type="hidden" name="selectProduct" value=" All">');
	document.write ('<font size="1" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">');
	document.write ('<a href="#" onClick="document.'+formName+'.submit();">Compatibilty Check</a>');
	document.write ('</font>');
	document.write ('</form>');
}

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.png\');return true"');
				document.write (' onmouseup="changeImages(\'buy_off\',\'../images/common/buy_off.png\');return true"');
				document.write (' onmouseout="changeImages(\'buy_off\',\'../images/common/buy_off.png\');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.png" alt="" name="buy_off" width="96" height="27" border="0">');
			document.write ('</a></td>');
		document.write ('</tr>');
	}
}

function generateBuyNowBtnWithBG ()
{
	if (canBuy)
	{
		document.write ('<tr>');
			document.write ('<td align="center" valign="top">');
				document.write ('<a onmousedown="changeImages(\'buy_off\',\'../images/common/buy_on_bg.jpg\');return true"');
				document.write (' onmouseup="changeImages(\'buy_off\',\'../images/common/buy_off_bg.jpg\');return true"');
				document.write (' onmouseout="changeImages(\'buy_off\',\'../images/common/buy_off_bg.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_bg.jpg" alt="" name="buy_off" width="96" height="27" border="0">');
			document.write ('</a></td>');
		document.write ('</tr>');
	}
}

function generateItemsInCart ()
{
	document.write ('<tr>');
		document.write ('<td align="center" valign="top">');
			document.write(ItemsInCart());
		document.write ('</td>');
	document.write ('</tr>');
}

function generateWhiteItemsInCart ()
{
	document.write ('<tr>');
		document.write ('<td align="center" valign="top">');
			document.write(whiteItemsInCart());
		document.write ('</td>');
	document.write ('</tr>');
}

function generatePrintLink ()
{
	if (printable)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top">');
				document.write ('<a href="javascript:gotoCatalogPage(catPath);" class="Helv9DarkGray" onmouseover="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onmouseout="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('<font color="#4c4c5c" onMouseOver="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onMouseOut="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('Printable Version</font></a>');
		document.write ('</td></tr>');
	}
	return printable;
}

function generateWhitePrintLink ()
{
	if (printable)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top">');
				document.write ('<a href="javascript:gotoCatalogPage(catPath);" class="smallLiteGrayLinks" onmouseover="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onmouseout="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');">');
				document.write ('<font color="#b8b8b8" onMouseOver="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onMouseOut="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');">');
				document.write ('Printable Version</font></a>');
		document.write ('</td></tr>');
	}
	return printable;
}

function generatePhotosLink ()
{
	if (hasMorePhotos)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top">');
				document.write ('<a href="javascript:gotoPhotoPage();" class="Helv9DarkGray" onmouseover="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onmouseout="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('<font color="#4c4c5c" onMouseOver="highlightLinkWithColors (this, 1, \'#247bb9\', \'#4c4c5c\');" onMouseOut="highlightLinkWithColors (this, 0, \'#247bb9\', \'#4c4c5c\');">');
				document.write ('More Photos</font></a>');
		document.write ('</td></tr>');
	}
	return hasMorePhotos;
}

function generateWhitePhotosLink ()
{
	if (hasMorePhotos)
	{
		document.write ('<tr>');
			document.write ('<td align="left" valign="top">');
				document.write ('<a href="javascript:gotoPhotoPage();" class="smallLiteGrayLinks" onmouseover="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onmouseout="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');">');
				document.write ('<font color="#b8b8b8" onMouseOver="highlightLinkWithColors (this, 1, \'#78b6f0\', \'#b8b8b8\');" onMouseOut="highlightLinkWithColors (this, 0, \'#78b6f0\', \'#b8b8b8\');">');
				document.write ('More Photos</font></a>');
		document.write ('</td></tr>');
	}
	return hasMorePhotos;
}

function generateBackToEvtsLink ()
{
	document.write ('<tr><td align="center" valign="top">');
		document.write ('<font size="3"><a href="' + pagePath + 'events.html">Back to Events</a></font>');
	document.write ('</td></tr>');
}

function generateEvtNav ()
{
	document.write ('<table width="150" border="0" cellspacing="0" cellpadding="2">');
		generateItemsInCart ();

		document.write ('<tr><td><hr></td></tr>');
		generateBackToEvtsLink ();
		document.write ('<tr><td><hr></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 ('</table>');
}

var lang = ["German", "Spanish", "French", "Italian",
				"Portuguese", "Japanese",
				"Korean", "Chinese&nbsp;(simp)"];
var langCode = ["de", "es", "fr", "it", "pt", "ja", "ko", "zh-CN"];

function generateTranslateLinks ()
{
	var urlA = "http://translate.google.com/translate?langpair=en%7C";
//	de
	var urlB = "&prev=%2Flanguage_tools&u=http%3A%2F%2Fwww.jlcooper.com";
	var lpn = location.pathname;
	var urlC = "";
	var rplc = "\%2F";
	for (var i = 0; i < lpn.length; ++i)
	{
		var c = lpn.charAt (i);
		if (c == "/")
			urlC += rplc;
		else
			urlC += c;
	}
	var urlD = "&hl=en&ie=UTF-8&oe=UTF-8";
	
	var urlBCD = urlB + urlC + urlD;

	document.write ('<form id="xlate" action="http://translate.google.com/translate" name="xlate">');
		document.write ('<table border="0" cellspacing="3" cellpadding="0">');
			document.write ('<tr>');
				document.write ('<td align="center" valign="top">');
					document.write ('<font size="1" face=arial,sans-serif color=#000000>');
					document.write ('<a href="#" onclick="document.xlate.submit();">Translate</a> page from English</font>');
				document.write ('</td>');
			document.write ('</tr>');
			document.write ('<tr>');
				document.write ('<td>');
					document.write ('<img src="' + imagePath + '/common/spacer4x4.gif" alt="" width="4" height="4" border="0">');
				document.write ('</td>');
			document.write ('</tr>');	
			document.write ('<tr>');
				document.write ('<td align="center" valign="top">');
					document.write ('<input type=hidden name=u value="http://www.jlcooper.com' + location.pathname + '">');
					document.write ('<select name=langpair>');
					for (var i = 0; i < lang.length; ++i)
					{
						document.write ('<option value="en|' + langCode[i] + '">to ' + lang[i] + '</option>');
					}
				document.write ('</select></td>');
			document.write ('</tr>');
			document.write ('<tr>');
				document.write ('<td align="center" valign="top">');
					document.write ('<input type=hidden name=hl value="en">');
					document.write ('<input type=hidden name=ie value=UTF-8>');
					document.write ('<input type=hidden name=oe value=UTF-8>');
					document.write ('<input type=hidden name=prev value="/language_tools">');
					document.write ('<font size="1" face=arial,sans-serif color=#000000>using </font>');
					document.write ('<b><font size="2" color="black" face="Georgia, Times New Roman, Times, serif">Google</font>');
				document.write ('</td>');
			document.write ('</tr>');
		document.write ('</table>');
	document.write ('</form>');
}

function generateProdNavWithFrame ()
{
// dont ask me why the following code works on IE
// because all I'll answer is "F**K Microsoft"
	var baseImageName = "ri_frame";
	var tbW = 215;
	var cellWL = 10;
	var cellWR = 12;
	var cellHB = 18;
	if (isIE)
	{
		baseImageName = "ri_frame_no_shadow";
		tbW = 209;
		cellWL = 12;
		cellWR = 16;
		cellHB = 9;
	}
	document.write ('<table width="' + tbW + '" border="0" cellspacing="0" cellpadding="0">');
		document.write ('<tr>');
			document.write ('<td colspan="3"><img src="../images/common/jlc35/' + baseImageName + '_top.png" alt="" width="' + tbW + '" height="11" border="0" /></td>');
		document.write ('</tr>');
		document.write ('<tr>');
			document.write ('<td align="left" width="' + cellWL + '" background="../images/common/jlc35/ri_frame_lft.png"></td>');
			document.write ('<td align="center" valign="top">');

				generateProductNav ();

			document.write ('</td>');
			if (isIE)
				document.write ('<td align="left" valign="top" width="' + cellWL + '" background="../images/common/jlc35/ri_frame_lft.png"></td>');
			else
				document.write ('<td align="left" valign="top" width="' + cellWR + '" background="../images/common/jlc35/ri_frame_rt.png"></td>');

		document.write ('</tr>');
		document.write ('<tr>');
			document.write ('<td colspan="3"><img src="../images/common/jlc35/' + baseImageName + '_bot.png" alt="" width="' + tbW + '" height="' + cellHB + '" border="0" /></td>');
		document.write ('</tr>');
	document.write ('</table>');
}

function openFrame (alignment)
{
// dont ask me why the following code works on IE
// because all I'll answer is "F**K Microsoft"
	var baseImageName = "ri_frame";
	var tbW = 215;
	var cellWL = 10;
	var cellWR = 12;
	var cellHB = 18;
	if (isIE)
	{
		baseImageName = "ri_frame_no_shadow";
		tbW = 209;
		cellWL = 12;
		cellWR = 16;
		cellHB = 9;
	}
	document.write ('<table width="' + tbW + '" border="0" cellspacing="0" cellpadding="0">');
		document.write ('<tr>');
			document.write ('<td colspan="3"><img src="../images/common/jlc35/' + baseImageName + '_top.png" alt="" width="' + tbW + '" height="11" border="0" /></td>');
		document.write ('</tr>');
		document.write ('<tr>');
			document.write ('<td align="left" width="' + cellWL + '" background="../images/common/jlc35/ri_frame_lft.png"></td>');
			document.write ('<td align="' + alignment + '" valign="top">');
}

function closeFrame ()
{
// dont ask me why the following code works on IE
// because all I'll answer is "F**K Microsoft"
	var baseImageName = "ri_frame";
	var tbW = 215;
	var cellWL = 10;
	var cellWR = 12;
	var cellHB = 18;
	if (isIE)
	{
		baseImageName = "ri_frame_no_shadow";
		tbW = 209;
		cellWL = 12;
		cellWR = 16;
		cellHB = 9;
	}

			document.write ('</td>');
			if (isIE)
				document.write ('<td align="left" valign="top" width="' + cellWL + '" background="../images/common/jlc35/ri_frame_lft.png"></td>');
			else
				document.write ('<td align="left" valign="top" width="' + cellWR + '" background="../images/common/jlc35/ri_frame_rt.png"></td>');

		document.write ('</tr>');
		document.write ('<tr>');
			document.write ('<td colspan="3"><img src="../images/common/jlc35/' + baseImageName + '_bot.png" alt="" width="' + tbW + '" height="' + cellHB + '" border="0" /></td>');
		document.write ('</tr>');
	document.write ('</table>');
}

function openFrameWithSize (alignment, frameW, frameH)
{
	if (isWin)
		frameH += 8;
	var contentW = frameW - 22;
	var contentH = frameH - 27;
	var baseImageName = "ri_frame_v";
	document.write ('<table width="' + frameW + '" border="0" cellspacing="0" cellpadding="0">');
		document.write ('<tr>');
			document.write ('<td><img src="../images/common/jlc35/' + baseImageName + '_topL.png" alt="" border="0" /></td>');
			document.write ('<td><img src="../images/common/jlc35/' + baseImageName + '_top.png"  width="' + contentW + '" height="11" "alt="" border="0" /></td>');
			document.write ('<td><img src="../images/common/jlc35/' + baseImageName + '_topR.png" alt="" border="0" /></td>');
		document.write ('</tr>');
		document.write ('<tr>');
			document.write ('<td><img src="../images/common/jlc35/' + baseImageName + '_lft.png"  height="' + contentH + '" width="10" alt="" border="0" /></td>');
			document.write ('<td align="' + alignment + '" valign="top">');

}

function closeFrameWithSize (frameW, frameH)
{
	if (isWin)
		frameH += 8;
	var contentW = frameW - 22;
	var contentH = frameH - 27;
	var baseImageName = "ri_frame_v";
			document.write ('</td>');

				document.write ('<td><img src="../images/common/jlc35/' + baseImageName + '_rt.png" height="' + contentH + '" width="12" alt="" border="0" /></td>');

		document.write ('</tr>');
		document.write ('<tr>');
			document.write ('<td><img src="../images/common/jlc35/' + baseImageName + '_botL.png" alt="" border="0" /></td>');
			document.write ('<td><img src="../images/common/jlc35/' + baseImageName + '_bot.png"  width="' + contentW + '" height="16" alt="" border="0" /></td>');
			document.write ('<td><img src="../images/common/jlc35/' + baseImageName + '_botR.png" alt="" border="0" /></td>');
		document.write ('</tr>');
	document.write ('</table>');
}

function generateProductNav ()
{
	document.write ('<table width="150" border="0" cellspacing="0" cellpadding="2">');
		generateBuyNowBtn ();
		if ((!canBuy) && notCurrentlyAvailable (ccode))
			document.write ('<tr><td align="center" valign="top"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><b>Call for Availability</b></font></td></tr>');
		generateItemsInCart ();
		document.write ('<tr><td><hr></td></tr>');
		var needSep = generatePrintLink ();
		needSep |= generatePhotosLink ();
		needSep |= generateVideoLink ();
		needSep |= generateManualLink ();
		needSep |= generateMoreInfoLink ();
		needSep |= generateKeysetLink ();
		needSep |= generateDownloadLinks ();
		needSep |= generateCompatLink2 ();
		if (needSep)
			document.write ('<tr><td><hr></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 ('</table>');
}

function generateWhiteProductNav ()
{
	document.write ('<table width="150" border="0" cellspacing="0" cellpadding="2">');
//		generateBuyNowBtnWithBG ();
		generateBuyNowBtn ();
		if ((!canBuy) && notCurrentlyAvailable (ccode))
			document.write ('<tr><td align="center" valign="top"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif" color="white"><b>Call for Availability</b></font></td></tr>');
			
		generateWhiteItemsInCart ();
		document.write ('<tr><td><hr></td></tr>');
/*		var needSep = generateWhitePrintLink ();
		needSep |= generateWhitePhotosLink ();
		needSep |= generateWhiteManualLink ();
*/
/*
needSep |= generateVideoLink ();
		needSep |= generateManualLink ();
		needSep |= generateMoreInfoLink ();
		needSep |= generateKeysetLink ();
		needSep |= generateCompatLink2 ();
*/
		var needSep = generatePrintLink ();
		needSep |= generatePhotosLink ();
		needSep |= generateVideoLink ();
		needSep |= generateManualLink ();
		needSep |= generateMoreInfoLink ();
		needSep |= generateKeysetLink ();
		needSep |= generateDownloadLinks ();
		needSep |= generateCompatLink2 ();

		if (needSep)
			document.write ('<tr><td><hr></td></tr>');
		document.write ('<tr><td align="center" valign="top"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif" color="white"><b>RELATED ITEMS</b></font></td></tr>');
		document.write ('<tr><td>');
			showRelatedLinks (ccode);
//			showWhiteRelatedLinks (ccode);
		document.write ('</td></tr>');
	document.write ('</table>');
}

function generateProductNavTest ()
{
	document.write ('<table width="150" border="0" cellspacing="0" cellpadding="2">');
		generateBuyNowBtn ();
		generateItemsInCart ();
		document.write ('<tr><td><hr></td></tr>');
		var needSep = generatePrintLink ();
		needSep |= generatePhotosLink ();
		needSep |= generateVideoLink ();
		needSep |= generateManualLink ();
		needSep |= generateMoreInfoLink ();
		needSep |= generateCompatLink ();
		if (needSep)
			document.write ('<tr><td><hr></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><hr></td></tr>');
		document.write ('<tr><td>');
			generateTranslateLinks ();
		document.write ('</td></tr>');
		
	document.write ('</table>');
}


