//-----------------------------------------------------------------------------------------------
//	Function:	writeLeftMenu
//	Purpose:	Displays webpage menu
//	Use:		Type in javascript -> writeLeftMenu(string-variable);
//				ex: 	writeLeftMenu("mirroring");
//  Parameters:	yrCopyright ->  type: string
//								enter a string for the menu item that you would like
//								to have highlighted
//								ex. you can type 'libraries' or 'LIB' or 'tape li'
//								to have 'Tape Libraries' highlighted
//-----------------------------------------------------------------------------------------------
function writeLeftMenu(section, highlightMenuItem, displayAbout)
{	
	var whichDrive = "";
	var linkStart, linkMid, noSubDir=0;
	var url = getURL();
	
	var menuHeaders = new Array(
		new Array(0, 'Home', '&nbsp;<br>', null),
		new Array(1, 'Data & Storage Management', 'HARDWARE:', null),
		new Array(1, 'Data & Storage Management', 'SOFTWARE:', null),
		new Array(2, 'System & Network Management', '&nbsp;<br>', null),
		new Array(3, 'Security', '&nbsp;<br>', null),
		new Array(4, 'Other Solutions', '&nbsp;<br>', null),
		new Array(5, "Company's Profile", '&nbsp;<br>', null),
		new Array(null, '', '&nbsp;<br>&nbsp;<br>&nbsp;<br>', null)
	);
	
	var menuItems = new Array(
		new Array(0, '<nobr>Data & Storage</nobr><br>Management', 'data_storage.html'),
		new Array(0, '<nobr>System & Network</nobr><br>Management', 'system_networks.html'),
		new Array(0, 'Security Solutions', 'security.html'),
		//new Array(0, 'Other Solutions', 'others.html'),
	
		new Array(1, 'Data Encryption', 'data_storage/ha_other.html'),
		new Array(1, 'NAS', 'data_storage/nas.html'),
		new Array(1, 'Optical/CD/DVD', 'data_storage/optical.html'),
		new Array(1, 'RAID & SAN', 'data_storage/raid.html'),
		new Array(1, 'Tape Drives', 'data_storage/tape-drives.html'),
		new Array(1, 'Tape Libraries', 'data_storage/tape_jukebox.html'),
		new Array(1, 'Tape Mirroring', 'data_storage/tape_mirroring.html'),
		new Array(1, 'Tape Replicators', 'data_storage/tape_replication.html'),
		new Array(1, 'Tape Striping', 'data_storage/ha_other.html?striping#striping'),
		//new Array(1, 'Other', 'data_storage/ha_other.html'),

		new Array(2, 'Backup', 'data_storage/backup_software.html'),
		new Array(2, 'Data Interchange', 'data_storage/data_interchange.html'),
		new Array(2, 'Disaster Recovery', 'data_storage/disaster_recovery.html'),
		new Array(2, 'High Availability', 'data_storage/software/high_availability.html'),
		new Array(2, 'Migration/Archival', 'data_storage/software/archival_migration.html'),
		new Array(2, 'Optical/CD/DVD ', 'data_storage/software/optical_software.html'),
		new Array(2, 'Replication', 'data_storage/software/replication_software.html'),
		//new Array(2, 'Other ', 'data_storage/so_other.html'),
		
		new Array(3, '<nobr>Computer Asset</nobr><br>Management', 'system_networks/assetmgt.html'),
		new Array(3, 'Clicknet', 'system_networks/ClickNet.html'),
		new Array(3, '<nobr>Cable Management</nobr><br>System', 'system_networks/csm.html'),
		
		new Array(4, 'Data Encryption', 'data_storage/hardware_other/encryption_solutions.html'),
		
		//new Array(5, '', ''),
		
		new Array(6, "Company's Profile", 'corporate/profile.html'),
		new Array(6, '<nobr>Resellers &</nobr><br>Distributors', 'corporate/resellers.html'),
		new Array(6, 'Contact Us!', 'corporate/profile.html#contact'),
		new Array(6, 'Employment<br>Opportunities', 'corporate/jobs.html'),

		new Array(null, '<p><br>', ''),
		new Array(null, '<marquee width="100%" behavior="slide"><a class="leftmenu" href="' + url + 'specials.html">Special Offers</a></marquee>', 'specials.html'),
		new Array(null, '<br>', ''),
		new Array(null, 'About Unylogix', 'corporate/profile.html'),
		new Array(null, '<nobr>Information Request</nobr>', 'request_info.html'),
		new Array(null, 'Products Index', 'products.html'),
		new Array(null, 'Search', 'ISsearch/search.asp'),
		new Array(null, 'Where to buy', 'where.html')
	);
	
	var straightLine = '<br><IMG class="line_position" height=5 src="' + url + 'images/r-line.gif" width="120" valign="bottom">';
	var straightLine2 = '<br><IMG class="line_position2" height=5 src="' + url + 'images/r-line.gif" width="120" valign="bottom">';

	//Tags for menu header that will be highlighted
	var highlightHeaderStart = '<tr><td><div class="lHeader1"><b>';
	var highlightHeaderEnd = '</b></div></td></tr>';
	//Tags for menu headers that will NOT be highlighted
	var nonHighlightHeaderStart = '<tr><td><div class="lHeader2"><b>';
	var nonHighlightHeaderEnd = '</b></a></td></tr>';	
	//Tags for the menu item that will be highlighted
	var left_margin_indent = '<p class="left_item_margin">';
	var HighlightLinkStart = '<tr><td>';
	var HighlightLinkMid = '">';
	var HighlightLinkEnd = '</a></font>&nbsp;<IMG src="' + url + 'images/blue7.gif">' + straightLine + '</p></td></tr>';
	var HighlightLinkEnd2 = '</a></font>&nbsp;<IMG src="' + url + 'images/blue7.gif">' + straightLine2 + '</p></td></tr>';
	//Tags for menu the menu item that NOT will be highlighted
	var nonHighlightLinkStart = '<tr><td>';
	var nonHighlightLinkMid = '">';
	var nonHighlightLinkEnd = '</a></font>' + straightLine + '</td></p></tr>';	
	var nonHighlightLinkEnd2 = '</a></font>' + straightLine2 + '</td></p></tr>';	
	//Space before link if item has a header, no space if item has no header above
	var linkStart = '<a class="leftmenu" href="';
	var linkHighlightStart = '<a class="onpage" href="';
	//Tag to display a blankline
	var blankLine = '<tr><td>&nbsp;<br></td></tr>';
	var blankSpace;
	var windowWidth;
	
	//Search for which menu to list
	var sectionNum;
	if(isNaN(section))
		for(iLoop=0; iLoop<menuHeaders.length; iLoop++)
		{
			iString = menuHeaders[iLoop][1];
			//convert to lowerstring and compare
			if(iString.toLowerCase().indexOf(section.toLowerCase()) >= 0)
			{
				//Find location of header then exit loop
				sectionNum = menuHeaders[iLoop][0];
				iLoop = 9999;
			}
		}
	else
		sectionNum = section;


	var	highlightSection = -1;
	var	highlightItem = -1;

	//Search for which menu header to highlight
	for(iLoop=0; iLoop<menuHeaders.length; iLoop++)
		if(menuHeaders[iLoop][0] == sectionNum)
			for(iLoop2=0; iLoop2<menuItems.length; iLoop2++)
			{	itemp = menuItems[iLoop2][0];
				if(itemp == iLoop)
				{
					iString = menuItems[iLoop2][1];
					//convert to lowerstring and compare
					if(iString.toLowerCase().indexOf(highlightMenuItem.toLowerCase()) >= 0)
					{
						highlightSection = iLoop;
						highlightItem = iLoop2;
						iLoop2 = 9999;
						iLoop = 9999;
					}
				}
			}

	//This part allows the code to modify the width of the left menu if the screen resolution is higher than 1024x800
	/*if(screen.availWidth >= 1280)
		windowWidth = "161";
	else if(screen.availWidth > 1024)
		windowWidth = "100%";
	else
	*/
		windowWidth = "156"
		
	//Begin writing table
	document.write('<link rel="stylesheet" type="text/css" href="' + url + 'css/table.css" />');
	document.write('<table cellspacing="0" cellpadding="0" height="100%" width="' + windowWidth + '" valign="top" border="0">');
	document.write('<tr><td width="100%"></td><td rowspan="2" background="' + url + 'images/dot.gif" width="1">&nbsp;&nbsp;</td></tr>');
	document.write('<tr><TD colspan="2" rowSpan="3" width="' + windowWidth + '" height="100%" valign="top">');

	document.write('<table cellspacing="0" cellpadding="2" width="100%" height="100%" border="0">');	
	document.write('<td valign="top" height="8"></td>');
	document.write('<td valign="top">');
	
	//Display the approriate items
	for(iLoop=0; iLoop<menuHeaders.length; iLoop++)
	{
		//This determines the indentation required before the menu items
		if(menuHeaders[iLoop][2].indexOf('<br>') >= 0)
		{
			spaceNoHighlight = '';
			spaceHighlight = '';
		}
		else
		{
			spaceNoHighlight = '';
			spaceHighlight = '';
		}
			
		//If this is the section desired then display it
		//Also don't print the 'About unylogix section'
		if(menuHeaders[iLoop][0] == sectionNum && menuHeaders[iLoop][0] !== null)
		{				
			//If this is the section to be highlighted or not
			if(iLoop == highlightSection)
				document.write(highlightHeaderStart + trim(menuHeaders[iLoop][2]) +
				highlightHeaderEnd);
			else
				document.write(nonHighlightHeaderStart + trim(menuHeaders[iLoop][2]) +
				nonHighlightHeaderEnd);
		
			//Loop through and display the items in the desired section
			for(iLoop2=0; iLoop2<menuItems.length; iLoop2++)
				if(menuItems[iLoop2][0] == iLoop)
				{
					//Determines if the item is to be highlighted or not and displays it
					if(iLoop2 == highlightItem)
						document.write(HighlightLinkStart + left_margin_indent + spaceHighlight + linkHighlightStart + url +
						trim(menuItems[iLoop2][2]) + HighlightLinkMid + trim(menuItems[iLoop2][1]) +
						HighlightLinkEnd);
					else
						document.write(nonHighlightLinkStart + left_margin_indent + spaceNoHighlight + linkStart + url +
						trim(menuItems[iLoop2][2]) + nonHighlightLinkMid + trim(menuItems[iLoop2][1]) +
						nonHighlightLinkEnd);
						
					//Writes an extra line after each menu item, if there is no header
					if(menuHeaders[iLoop][2].indexOf('<br>') >= 0)
						document.write('<tr><td height="10"></td></tr>');	
				}
						
			//Writes an extra line after listing all the items in the particular section
			document.write('<tr><td>&nbsp;<br></td></tr>');
		}
		
		//Print the 'about Unylogix' section
		if(menuHeaders[iLoop][0] == null)
		{	//document.write('<tr><td>&nbsp;<br>&nbsp;<br></td></tr>');
			var left_margin_indent = '<p>';
			for(iLoop2=0; iLoop2<menuItems.length; iLoop2++)
				if(menuItems[iLoop2][0] == null)
					//verifying possibility that contents of displayAbout is an error
					if(typeof(displayAbout) == "undefined")
						document.write(nonHighlightLinkStart + left_margin_indent + spaceNoHighlight + linkStart + url +
						trim(menuItems[iLoop2][2]) + nonHighlightLinkMid + trim(menuItems[iLoop2][1]) +
						nonHighlightLinkEnd2);
					else
					{	iString = menuItems[iLoop2][1];
		 				if(iString.toLowerCase().indexOf(displayAbout.toLowerCase())>=0)
						{	
							//Special case for highlighting the "Special Offers" menu item ---------------------------------------
							if(trim(displayAbout.toLowerCase()) == "special")
								document.write(HighlightLinkStart + '<marquee width="100%" behavior="slide">'+ 
								left_margin_indent + spaceHighlight + linkHighlightStart + url + trim(menuItems[iLoop2][2])
								+ HighlightLinkMid + 'Special Offers</a></font>&nbsp;<IMG src="' + url + 'images/blue7.gif"></p></marquee>' + straightLine2 + '</td></tr>');
							//-----------------------------------------------------------------------------------------------------
							else
							document.write(HighlightLinkStart + left_margin_indent + spaceHighlight + linkHighlightStart + url +
							trim(menuItems[iLoop2][2]) +HighlightLinkMid + trim(menuItems[iLoop2][1]) +
							HighlightLinkEnd2);
						}
		 				else
							document.write(nonHighlightLinkStart + spaceNoHighlight + linkStart +
							url + trim(menuItems[iLoop2][2]) + nonHighlightLinkMid + 
							trim(menuItems[iLoop2][1]) + nonHighlightLinkEnd2);
					}
		}
	}
				
	document.write(blankLine);
	document.write('<tr><td height="100%">&nbsp;</td></tr>');
	document.write('</table></td></tr></table>');

	return writeLeftMenu;	
}
