var isMac = (navigator.userAgent.indexOf("Macintosh") != -1);
var isWin = (navigator.userAgent.indexOf("Windows 95") != -1 || navigator.userAgent.indexOf("Windows NT") != -1);
var isNS =  (navigator.appName == "Netscape");
var isIE =  (navigator.userAgent.indexOf("MSIE") != -1);
var ieWin = (navigator.userAgent.indexOf("MSIE") != -1 && (navigator.userAgent.indexOf("Windows 95") != -1 || navigator.userAgent.indexOf("Windows NT") != -1));


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}






var oMenuDisp = 'hide' // 
var pMenuDisp = 'hide' // 
var hMenuDisp = 'hide' // 
function ColorLinks(sPageID)
{ 
   // take page id and split into components
   var aResult = sPageID.split("_");

   //split the page id that is delimited with "_"
   var sMain = aResult[0]; // indicates which section of the site the user is in
   var sSecond = aResult[1]; // indicates which sub-item has been clicked
   var objY
  
  if (sMain != "NONE")
  {
    var ie5=(document.getElementById && document.all); // check if it is IE5
    var ns6=(document.getElementById && !document.all); // check if it is ns6 (Moz.9+)
    // if Moz.9x+ or NN6+ (document.getElementByID), highlight the correct main menu item
    if (ns6)
    {  
      if (sMain == "ourcompany")
      { 
        // ns6/moz use document.getElementById("") to access elements
        document.getElementById("subOurcompany").style.visibility = "visible";
        document.getElementById("ourcompany").src = "/images/nav_ourcompany_on.gif"
        oMenuDisp = "show" // sets variable to use when in ourcompany section of the 
                           // site. makes sure subOurcompany menu is always showing, even 
                           // when you mouse over another menu
      }
      if (sMain == "ourservices")
      {
        document.getElementById("ourservices").src = "/images/nav_ourservices_on.gif"      
      }
      if (sMain == "ourcustomers")
      {
        document.getElementById("ourcustomers").src = "/images/nav_ourcustomers_on.gif"      
      }
      if (sMain == "publisher")
      {
        document.getElementById("subPublisher").style.visibility = "visible";
        document.getElementById("publisher").src = "/images/nav_publisher_on.gif"      
        pMenuDisp = "show" // same as oMenuDisp, only for capabilities section
      }
      if (sMain == "contact")
      {
        document.getElementById("contact").src = "/images/subnav_contact_on.gif"      
      }
      if (sMain == "help")
      {
        document.getElementById("subHelp").style.visibility = "visible";
        document.getElementById("help").src = "/images/subnav_help_on.gif"      
        hMenuDisp = "show" // same as oMenuDisp, only for capabilities section
      }
      // highlight the second level menu item
      if (sSecond != "NONE")
      {
        // define the variable = to the image in the menu
        objY = eval("document.getElementById('" + sSecond + "')");
        // set the source of the image in the variable
        objY.src = "/images/subnav_" + sSecond + "_on.gif";
      }
    }
    
    // if IE (document.all), highlight the correct main menu item
    if (ie5)
    {
      //alert(sMain);
      //alert(sSecond);
      if (sMain == "ourcompany")
      {  
        document.all.subOurcompany.style.visibility = "visible";
        document.all.ourcompany.src = "/images/nav_ourcompany_on.gif";
        oMenuDisp = "show" // sets variable to use when in ourcompany section of the 
                           // site. makes sure subOurcompany menu is always showing, even 
                           // when you mouse over another menu
      }
      if (sMain == "ourservices")
      {
        document.all.ourservices.src = "/images/nav_ourservices_on.gif";
      }
      if (sMain == "ourcustomers")
      {
        document.all.ourcustomers.src = "/images/nav_ourcustomers_on.gif";
      }
      if (sMain == "publisher")
      {
        document.all.subPublisher.style.visibility = "visible";
        document.all.publisher.src = "/images/nav_publisher_on.gif";
        pMenuDisp = "show"
      }
      if (sMain == "contact")
      {
        document.all.contact.src = "/images/subnav_contact_on.gif";
      }
      if (sMain == "help")
      {
        document.all.subHelp.style.visibility = "visible";
        document.all.help.src = "/images/subnav_help_on.gif";
        hMenuDisp = "show"
      }
      // highlight the second level menu item
      if (sSecond != "NONE")
      {
        // define the variable = to the image in the menu
        objY = eval("document.all." + sSecond);
        // set the source of the image in the variable
        objY.src = "/images/subnav_" + sSecond + "_on.gif";
      }
    }
    
    // if NN4.x (document.layers), highlight the correct main menu item...
    // because the images are in layers, and netscape sees each
    // layer as a window entity, you have to access the images
    // through document.divID.document.images.imageName...
    if (document.layers)
    { 
      var sDiv // variable to assign divID when highlighting
               // the second level menu item below
      if (sMain == "ourcompany")
      {
        document.menu.document.images.ourcompany.src = "/images/nav_ourcompany_on.gif"
        sDiv = "subOurcompany"; // because 4.7 struggles with divs, we will use this below
                          // to identify the correct section menu to display when 
                          // setting the highlighting of the second level menu items
							// 4.7 doesn't use '.style.' for setting styles. Imagine that.
        document.subOurcompany.visibility = "show";
        oMenuDisp = "show" // sets variable to use when in portfolio section of the 
                           // site makes sure portfolio menu is always showing, even 
                           // when you mouse over another menu
      }
      if (sMain == "ourservices")
      {
        document.menu.document.images.ourservices.src = "/images/nav_ourservices_on.gif"
      }
      if (sMain == "ourcustomers")
      {
        document.menu.document.images.ourcustomers.src = "/images/nav_ourcustomers_on.gif"
      }
      if (sMain == "publisher")
      {
        document.subPublisher.visibility = "show";
        document.menu.document.images.publisher.src = "/images/nav_publisher_on.gif"
        sDiv = "subPublisher";
        pMenuDisp = "show"
      }
      if (sMain == "contact")
      {
        document.menu.document.images.contact.src = "/images/subnav_contact_on.gif"
      }
      if (sMain == "help")
      {
        document.subHelp.visibility = "show";
        document.menu.document.images.help.src = "/images/subnav_help_on.gif"
        sDiv = "subHelp";
        hMenuDisp = "show"
      }
      // highlight the second level menu item
      if (sSecond != "NONE")
      {
        // define the variable = to the image in the menu
        objY = eval("document." + sDiv + ".document.images." + sSecond);
        // set the source of the image in the variable
        objY.src = "/images/subnav_" + sSecond + "_on.gif";
      }
    }
  }
}
