// Detect browser type and version
//
var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var br, bv;
if ( bName == "Netscape" ) { br = "nn"; }
else if ( bName == "Microsoft Internet Explorer" ) { br = "ie"; }
else { br = "unknown" };
if ((br == "nn" && bVer >=3) || (br == "ie" && bVer >=4)) { bv = "n3"; }
else { bv = "n2"; }

// Get the base URL
var currentUrl = document.location.href;
var xend = currentUrl.lastIndexOf("/") + 1;
var baseUrl = currentUrl.substring(0, xend);


function setCursor(cell, cursorType)
{
   if ( br == "ie" )
   {
      cell.style.cursor = cursorType;
   }
   else
   {
      cell.style.setProperty('cursor', cursorType, '');
   }
}
function getLink(cell)
{
   if ( br == "ie" )
   {
      return cell.children.tags('A')[0];
   }
   else
   {
      var children = cell.childNodes;
      var j=0;
      while ( children[j] )
      {
         if ( children[j].nodeType == 1 && children[j].tagName == 'A' )
         {
            return children[j];
         }
         j++;
      }
      return null;
   }
}
function getHref(cell)
{
   var atag = getLink(cell);
   return atag.href;
}
// cell functions
function kmOver(cell)
{ // change cursor back to default but no change in class (bgcolor)
   setCursor(cell, 'pointer');//alert(getHref(cell));
   window.status = getHref(cell);
}
function kmOut(cell)
{ // change cursor back to default but no change in class (bgcolor)
   setCursor(cell, 'default');
   window.status = '';
}

function nmOver(cell, styleClass)
{  //alert('style='+styleClass + ' current=' + cell.className);
   cell.className = styleClass;
   kmOver(cell);
}

function nmOut(cell, styleClass)
{
   cell.className = styleClass;
   return kmOut(cell);
}

function nmClick(cell)
{
   window.location = getLink(cell).href;
}

function tdmOver(cell, styleClass, url)
{
   cell.className = styleClass;
   setCursor(cell, 'pointer');
   window.status = baseUrl + url;
}

function tdmClick(url)
{
   window.location = baseUrl + url;
}

// top menu bar
//var mm = new Array();
var mm = new Array(
   new Array("home", "Home", "12%", "./"),
   new Array("about", "About Us", "15%", "background.html"),
   new Array("smb", "SMB Solutions", "22%", "smb.html"),
   new Array("sc", "Supply Chain Solutions", "30%", "supplychain_vis.html"),
   new Array("lims", "LIMS Solutions", "21%", "lims.html")
);

function mm_disp()
{
   //alert(mm.length);
   for (i = 0; i < mm.length; i++)
   {
      if ( i > 0 )
      {
         document.write('<td WIDTH="2" BGCOLOR="white"><img SRC="images/space.gif" WIDTH="2" HEIGHT="23" ALT=""></td>');
      }
      var current = (pg == i);
      var td_str = '<td width="' + mm[i][2] + '"';
      if (current)
      {
         td_str += ' class="selTab"';
         if ( spg >= 0 )
         {
            td_str += ' onClick="nmClick(this)"';
            td_str += ' onMouseOver="kmOver(this)"';
            td_str += ' onMouseOut="kmOut(this)"';
         }
      }
      else
      {
         td_str += ' class="tab"';
         td_str += ' onClick="nmClick(this);"';
         td_str += ' onMouseOver="nmOver(this,\'selTab\');return true;"';
         td_str += ' onMouseOut="nmOut(this,\'tab\');return true;"';
      }
      var text_str = ( current && spg < 0 ) ? mm[i][1]
                     : '<a href="' + mm[i][3] + '">' + mm[i][1] + '</a>';
      td_str += '>' + text_str + '</td>';
      //alert(td_str);
      document.write(td_str);
   }
}

// submenus
var sm = new Array();
sm[0] = "./"; // Home
sm[1] = new Array(
   new Array("ourbg","Our Background","background.html"),
   new Array("contact","Contact Us","contact.html"),
   new Array("careers","Careers","careers.html")
); // About Us
sm[2] = new Array(
   new Array("ns", "NetSuite", "netsuite.html"),
   new Array("nssb", "NetSuite Small Business", "netsuite_smallbiz.html"),
   new Array("nscrm", "NetSuite CRM", "netsuite_crm.html"),
   new Array("nscrm+", "NetSuite CRM+", "netsuite_crmplus.html"),
   new Array("nserp", "NetERP", "netsuite_neterp.html"),
   new Array("nscm", "NetCommerce", "netsuite_netcommerce.html"),
   new Array("nsflex", "NetFlex", "netsuite_netflex.html"),
   new Array("auto", "Integration Services", "integration.html")
); // SMB
sm[3] = new Array(
   new Array("vis", "Supply Chain Visibility","supplychain_vis.html"),
   new Array("china", "Connect with China","supplychain_china.html"),
   new Array("plm", "Product Lifecycle Management","supplychain_plm.html")
); // Supply Chain
sm[4] = new Array(
   new Array("bis","BioInfoStream","bioinfostream.html"),
   new Array("fis","FabInfoStream","fabinfostream.html"),
   new Array("eqsch","EquipScheduler","equip.html"),
   new Array("prstr","ProjStreamer","projstreamer.html")
); // LIMS

function mm_path()
{
   var path_str = '<a href="./">Home</a> &gt; ';
   if ( pg > 0 )
   {
      path_str += '<a href="' + mm[pg][3] + '">' + mm[pg][1] + '</a>';
      if ( spg >= 0 )
      {
         path_str += ' &gt; <a href="' + sm[pg][spg][2] + '">' +
                     sm[pg][spg][1] + '</a>';
      }
   }
   //alert(pg + path_str);
   document.write(path_str);
}

function sm_disp()
{
   var subm = sm[pg];
   //alert(subm.length);
   for (i = 0; i < subm.length; i++)
   {
      var current = (spg == i);
      var str = '<tr class="sub"><td';
      if (current)
      {
         str += ' class="selSub"';
      }
      else
      {
         str += ' class="sub"';
         str += ' onClick="nmClick(this)"';
         str += ' onMouseOver="nmOver(this,\'selSub\')";return true;';
         str += ' onMouseOut="nmOut(this,\'sub\');return true;"';
      }
      var text_str = current ? subm[i][1]
                             : '<a href="' + subm[i][2] + '">'+ subm[i][1] + '</a>';
         str += '>' + text_str + '</td></tr>';
      //alert(str);
      document.write(str);
   }
   document.write('<tr class="subbot"><td>&nbsp;</td></tr>');
}
