/*
* JavaScript to create link bar and right click menu.
*
* Written by Gary Stimson 2004
*/

/* uses search.js, printstyle.css, screenstyle.css, mainscript.js */

var sCName     = 'Lightning Ware';
var sRefPath   = ''; // used for searching
var sAImage    = sPathCor + 'images/logo.gif';

// generic variables used to create menu and toolbar:
var saImage    = new Array(0);  // holds image names
var saText     = new Array(0);  // holds text names
var saLink     = new Array(0);  // holds links

var saSubMenu  = new Array(0);  // holds dub menu


// Buffer vars:
var saHTMLBuff;

var sStart = '';               // holds the HTML code for toolbar/menu start
var sEnd   = '';               // holds the code for toolbar/menu end
var sSep   = '';               // holds seperator

// Below sets up the generic values
function startUp()
{
  var saSubText;
  var saSubLink;

  saImage.push(sPathCor + 'images/home.gif',
   	       sPathCor + 'images/system16.gif',
               sPathCor + 'images/software16.gif',
 	       sPathCor + 'images/help16.gif'
               );

  saText.push('Home',
              //'Products',
              'Downloads',
              'Help &amp; Info'
              );

  saLink.push(sPathCor + 'index.asp',
              //sPathCor + 'pc/custom.html',
              sPathCor + 'software/lwsoftware.asp',
              sPathCor + 'help/index.html'
              );
  
  
  saSubMenu.push('');
  
  /*saSubMenu.push('<img src="' + sPathCor + 'images/system16.gif">&nbsp;<a href="' + sPathCor + 'pc/custom.html" class="Norm" onmouseover="doSubMouseIn()" onmouseout="doSubMouseOut()">AMD Systems</a><br>' +
    		 '<img src="' + sPathCor + 'images/system16.gif">&nbsp;<a href="' + sPathCor + 'pc/custom.html" class="Norm" onmouseover="doSubMouseIn()" onmouseout="doSubMouseOut()">Intel Systems</a><br>' +
    		 '<img src="' + sPathCor + 'images/laptop16.gif">&nbsp;<a href="' + sPathCor + 'pc/custom.html" class="Norm" onmouseover="doSubMouseIn()" onmouseout="doSubMouseOut()">Notebooks</a><br>' +
    		 '<img src="' + sPathCor + 'images/custom16.gif">&nbsp;<a href="' + sPathCor + 'pc/custom.html" class="Norm" onmouseover="doSubMouseIn()" onmouseout="doSubMouseOut()">Custom Systems</a><br>');
*/
  saSubMenu.push('');
  		  
  saSubMenu.push('<img src="' + sPathCor + 'images/help16.gif">&nbsp;<a href="' + sPathCor + 'help/news.asp" class="Norm" onmouseover="doSubMouseIn()" onmouseout="doSubMouseOut()">LW News</a><br>' +
  		 '<img src="' + sPathCor + 'images/help16.gif">&nbsp;<a href="' + sPathCor + 'help/contact.html" class="Norm" onmouseover="doSubMouseIn()" onmouseout="doSubMouseOut()">Contact Us</a><br>');
}
// ***

// Below is the code used to create a link bar at the top of the screen:

function setUpLinkBar()
{
  var sSearchStyle;
  var sTemp = ''; // empty string used to enter a parameter only for IE
  
  saHTMLBuff = new Array(0); // holds toolbar/menu HTML code

  //iDocument--> 0 = Home, 1 = About, 2 = Download, 3 = Contact
  var iAIndex = 0;

  for (iAIndex = 0; iAIndex < saText.length; iAIndex++){
    saHTMLBuff.push('<a id="oTheLink" onMouseOver="overLink(this,' + iAIndex + ');" onMouseOut="overLink(this,' + iDocument + ');" ' +
                    'class="Norm" href="' + saLink[iAIndex] +'">' + saText[iAIndex] + '</a>');
  }

  // Resort to table for compatablity:

  if (iBrowser == 2 && iVersion < 5) // Netscape V4 and below
  {
       sStart    = '<form name="search" method="post" action=""><div align="right"><table width="100%" border="0">' +
                   '<tr><td width="77%"><a href="' + sPathCor + 'index.html"><img src="' + sAImage + '" width="49" height="32" border="0"></a>' +
                   '<Font class="LOGO">' + sCName + '</Font></td><td width="23%" class="SearchN4">search:' +
                   '<input type="text" name="keySearch"></input><a href="javascript:doSearch();"><img alt="Search for keyword" ' +
                   'src="' + sPathCor + 'images/search_off.gif" width="20" height="20" ID="searchImage" border=0></img></a>' +
                   '</td></tr></table></div></form>' +
                   '<Table class="H1" cellspacing="0" WIDTH="100%"><TR><TD>&nbsp;<Img id="topImage" Src="' +
                   saImage[iDocument] + '"></Img>&nbsp;<Font color="#838A9F">';

       sEnd      = '&nbsp;&nbsp;</Font></TD></TR></Table>';

  }
  else
  {
    if (iBrowser == 1)
    {
      sSearchStyle = 'SrchIE';
      sTemp        = 'align="absmiddle"'
    }
    else
    if (iBrowser == 2)
    {
      sSearchStyle = 'SrchN';
    }
    else
    if (iBrowser == 3)
    {
      sSearchStyle = 'SrchO';
    }

    sStart    = '<Form id="search" name="search" onSubmit="doSearch();" action="' + sPathCor + 'index.html">' +
				'<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>' +
				'<td><a href="' + sPathCor + 'index.html"><IMG src="' + sAImage + '" border="0"></a><Font class="LOGO">' + sCName + '</Font></td>' +
				'<td align="right"><a href="javascript:doViewCart();"><img src="' + sPathCor + 
				'images/cart.gif" alt="Make payments with PayPal - it\'s fast, free and secure!" border="0"></img></a> ' +
				'<a class="Small" href="javascript:doViewCart();">View Basket</a></td>' +
				'</tr></table>' +
                '<Table class="H1" cellspacing="0" id="oLinkBar">' +
                '<TR>' +
                '<td onmouseout="doMouseLeave();"><img width="25" height="1"></td><td onmouseout="doMouseLeave();"><img width="450" height="1"></td><td onmouseout="doMouseLeave();"><img width="150" height="1"></td>' +
                '</tr><tr>' +
                '<TD class="Icon">&nbsp;<Img id="topImage" Src="' + saImage[iDocument] + '"></Img></TD>' +
                '<TD class="Links" id="tdLinks"><Font color="#838A9F" id="oLinks">';

    sEnd      = '&nbsp;&nbsp;</Font></TD>' +
    	        '<TD class="Search">Search: ' +
                '<input TYPE="text" NAME="keySearch" VALUE="" SIZE="10" class="' + sSearchStyle + '"></input>&nbsp;' +
                '<a href="javascript:doSearch();"><Img id="searchImage" alt="Search for keyword" src="' + sPathCor + 'images/search_off.gif" ' +
		'onMouseOver="overSearch(true);" onMouseOut="overSearch(false);"' +
                'border=0 ' + sTemp + '></Img></a>&nbsp;&nbsp;</TD></TR>' +
                '<tr>' +
                '<td onmouseout="doMouseLeave();"><img width="25" height="1"></td><td onmouseout="doMouseLeave();"><img width="450" height="1"></td><td onmouseout="doMouseLeave();"><img width="150" height="1"></td>' +
				'</tr>' +
                '</Table></Form>';
  }

  sSep      = ' | ';

  insertLinkBar();
}


// Write the linkbar to the screen:
function insertLinkBar()
{
  var sTemp   = sStart;
  var iAIndex = 0;

  for (iAIndex = 0; iAIndex < saHTMLBuff.length; iAIndex++){
  	sTemp += saHTMLBuff[iAIndex];
  	if (iAIndex < saHTMLBuff.length){
  		sTemp += sSep;
  	}
  }
  sTemp += sEnd;
  document.write(sTemp);
}


function setUpSubMenus(){
	sTempBuf = '<table class="XPPopUp" ID="oSubMenu" Cellspacing="0" cellpadding="1" Style="display:none; position:absolute;"><tr>' +
	           '<td onmouseout="doMouseLeave();"><img width=1 height=1></td>' +
	           '<td><div ID="oSubMenuDiv" style="padding: 5 4 4 4;"></div></td>' +
	           '<td onmouseout="doMouseLeave();"><img width=1 height=1></td></tr>' +
	           '<tr><td colspan="3" onmouseout="doMouseLeave();"><img width=1 height=1></td></tr>' +
	           '</table>';
       
        document.write(sTempBuf);
}


//**********

function setUpMenu()
{
  //iDocument--> 0 = Home, 1 = About, 2 = Software, 3 = Contact
  var iIndex = 0;
  
  saHTMLBuff = new Array(0); // holds toolbar/menu HTML code

  
  for (iAIndex = 0; iAIndex < saText.length; iAIndex++){
  
    saHTMLBuff[iAIndex]  = '<TR><TD id="oPopupItem" class="AnItem" onMouseOver="overItem(this);" ' +
                     'onMouseOut="overItem(this);"><a href="' + saLink[iAIndex] +'"><IMG src="' +
                     saImage[iAIndex] + '" Border=0></IMG></a>&nbsp;&nbsp;<a href="' + saLink[iAIndex] +'">' +
                     saText[iAIndex] +
                     '</a></TD></TR>';
  }



  sStart = '<TABLE ID="ThePopUpMenu" Style="display:none; position:absolute;"' +
           'class="XPPopUp" Cellspacing="0" cellpadding="2">';


  sEnd =   '<TR Height="1"><TD class="separator">' +
           '<hr class="separator" width="95%"></TD></TR>' +
           '<TR><TD class="AnItem" onMouseOver="overItem(this);" ' +
           'onMouseOut="overItem(this);" onClick="javascript:activateMenu(1)">' +
           'Print</TD></TR><TR><TD class="AnItem" onMouseOver="overItem(this);" ' +
           'onMouseOut="overItem(this);" onClick="javascript:activateMenu(2)">' +
           'Copy To Clipboard</TD></TR><TR Height="1"><TD class="separator">' +
           '<hr class="separator" width="95%"></TD></TR><TR><TD class="AnItem" '+
           'onMouseOver="overItem(this);" onMouseOut="overItem(this);" ' +
           'onClick="javascript:activateMenu(3)">Refresh</TD></TR></TABLE>' +
	   '<TEXTAREA ID="textbuffer" STYLE="display:none;"></TEXTAREA>';

  saHTMLBuff[iDocument] = '<TR><TD id="oPopupItem" class = "Inactive" ><IMG src="' + saImage[iDocument] +
                          '"></IMG>&nbsp;' + saText[iDocument] + '</TD></TR>'; // copy over inactive link

  insertMenu();

}


function insertMenu()
{
    var sTemp   = sStart;
    var iAIndex = 0;
  
    for (iAIndex = 0; iAIndex < saHTMLBuff.length; iAIndex++){
    	sTemp += saHTMLBuff[iAIndex];
    }
    sTemp += sEnd;
    document.write(sTemp);
}


// *******
