var BrowserDetect =
{
  browser: function ()
  {
    return this.searchString(this.dataBrowser) || "An unknown browser";
  },

  version: function ()
  {
    return this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
  },

  OS: function ()
  {
    return this.searchString(this.dataOS) || "an unknown OS";
  },

  searchString: function (data)
  {
    for (var i=0;i<data.length;i++)
    {
      var dataString = data[i].string;
      var dataProp = data[i].prop;
      this.versionSearchString = data[i].versionSearch || data[i].identity;

      if (dataString)
      {
        if (dataString.indexOf(data[i].subString) != -1)
          return data[i].identity;
      }
      else if (dataProp)
        return data[i].identity;
    }
  },

  searchVersion: function (dataString)
  {
    var index = dataString.indexOf(this.versionSearchString);

    if (index == -1) return;
      return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
  },

  dataBrowser:
  [
    {
      string: navigator.userAgent,
      subString: "OmniWeb",
      versionSearch: "OmniWeb/",
      identity: "OmniWeb"
    },
    {
      string: navigator.vendor,
      subString: "Apple",
      identity: "Safari"
    },
    {
      prop: window.opera,
      identity: "Opera"
    },
    {
      string: navigator.vendor,
      subString: "iCab",
      identity: "iCab"
    },
    {
      string: navigator.vendor,
      subString: "KDE",
      identity: "Konqueror"
    },
    {
      string: navigator.userAgent,
      subString: "Firefox",
      identity: "Firefox"
    },
    {
      string: navigator.vendor,
      subString: "Camino",
      identity: "Camino"
    },
    { // for newer Netscapes (6+)
      string: navigator.userAgent,
      subString: "Netscape",
      identity: "Netscape"
    },
    {
      string: navigator.userAgent,
      subString: "MSIE",
      identity: "Explorer",
      versionSearch: "MSIE"
    },
    {
      string: navigator.userAgent,
      subString: "Gecko",
      identity: "Mozilla",
      versionSearch: "rv"
    },
    { // for older Netscapes (4-)
      string: navigator.userAgent,
      subString: "Mozilla",
      identity: "Netscape",
      versionSearch: "Mozilla"
    }
  ],

  dataOS:
  [
    {
      string: navigator.platform,
      subString: "Win",
      identity: "Windows"
    },
    {
      string: navigator.platform,
      subString: "Mac",
      identity: "Mac"
    },
    {
      string: navigator.platform,
      subString: "Linux",
      identity: "Linux"
    }
  ]
};

function loadTopMenu()
{
  document.write('<!-- Top Menu Code -->');
  document.write('<div id="topMenu">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:0px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:40px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:80px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:120px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:160px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:200px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:240px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:280px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:320px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:360px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:400px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:440px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:480px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:520px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:560px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:600px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:640px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:680px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:720px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:760px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:800px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:840px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:880px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:920px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:960px" src="images/topMenuBackground.jpg" alt="">');
  document.write('  <img class="m2" style="position:absolute; top:0px; left:1000px; width:3px; height:30px" src="images/topMenuBackground.jpg" alt="">');
  document.write('<!-- Logo Code -->');
  document.write('<div id="logoCode">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:0px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:100px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:200px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:300px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:400px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:500px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:600px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:700px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:800px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:900px" src="images/logoBackground.jpg" alt="">');
  document.write('  <img class="l1" style="position:absolute; top:30px; left:1000px; width:3px; height:70px;" src="images/logoBackground.jpg" alt="">');      
  document.write('  <table>');
  document.write('    <tr>');
  document.write('      <td nowrap>');
  document.write('        <p class="36W" style="position:absolute; top:40px; left:30px">Jim Colyn &amp; Associates Quality Consultants, LLC</p>');
  document.write('      </td>');
  document.write('    </tr>');
  document.write("  </table>");
  document.write("</div>");
}

function loadSidePanel()
{
  document.write('<!-- Side Panel Buttons -->');
  document.write('<div id="sidePanelTop">');
  document.write('  <img class="m1" style="position:absolute; top:105px; left:0px" src="images/menuButton.gif" alt="">');
  document.write('  <p class="14W"><a class="white" style="position:absolute; top:112px; left:5px" href="index.html">Home</a>');

  document.write('  <img class="m1" style="position:absolute; top:140px; left:0px" src="images/menuButton.gif" alt="">');
  document.write('  <p class="14W"><a class="white" style="position:absolute; top:147px; left:5px" href="about.html">About Us</a>');

  document.write('  <img class="m1" style="position:absolute; top:175px; left:0px" src="images/menuButton.gif" alt="">');
  document.write('  <p class="14W"><a class="white" rel="ServicesSubMenu" style="position:absolute; top:182px; left:5px" href="services.html">Services</a>');
  document.write('  <div id="ServicesSubMenu">');
  document.write('    <img class="m1" style="position:absolute; top:185px; left:80px; width:10px; height:10px" src="images/menuButton.gif" alt="">');
  document.write('    <img class="m1" style="position:absolute; z-index:1; top:105px; left:90px; width:225px; height:195px" src="images/menuButton.gif" alt="">');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:110px; left:100px" href="services.html">Services</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:127px; left:100px" href="qualitysystemdevelopment.html">Quality System Development</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:144px; left:100px" href="qualitydocumentation.html">Quality Documentation</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:161px; left:100px" href="correctiveaction.html">Corrective and Preventive Action (CA/PA)</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:178px; left:100px" href="rootcauseanalysis.html">Root Cause Analysis</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:195px; left:100px" href="training.html">Training / Training Programs</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:212px; left:100px" href="managementtraining.html">Management Training</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:229px; left:100px" href="auditmanagement.html">Audit Management</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:246px; left:100px" href="validationplanning.html">Validation Planning</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:263px; left:100px" href="warningletters.html">483 &amp; Warning Letters</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:280px; left:100px" href="jointcommissiontissuecompliance.html">Joint Commission Tissue Compliance</a>');
  document.write('  </div>');

  document.write('  <img class="m1" style="position:absolute; top:210px; left:0px" src="images/menuButton.gif" alt="">');
  document.write('  <p class="14W"><a class="white" rel="ResourcesSubMenu" style="position:absolute; top:217px; left:5px" href="resources.html">Resources</a>');
  document.write('  <div id="ResourcesSubMenu">');
  document.write('    <img class="m1" style="position:absolute; top:220px; left:80px; width:10px; height:10px" src="images/menuButton.gif" alt="">');
  document.write('    <img class="m1" style="position:absolute; z-index:1; top:212px; left:90px; width:225px; height:40px" src="images/menuButton.gif" alt="">');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:217px; left:100px" href="resources.html">Resources</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:234px; left:100px" href="resources.html">Corrective and Preventive Action (CAPA)</a>');
  document.write('  </div>');

  document.write('  <img class="m1" style="position:absolute; top:245px; left:0px" src="images/menuButton.gif" alt="">');
  document.write('  <p class="14W"><a class="white" rel="ContactSubMenu" style="position:absolute; top:252px; left:5px" href="contactjim.html">Contact</a>');
  document.write('  <div id="ContactSubMenu">');
  document.write('    <img class="m1" style="position:absolute; top:255px; left:80px; width:10px; height:10px" src="images/menuButton.gif" alt="">');
  document.write('    <img class="m1" style="position:absolute; z-index:1; top:240px; left:90px; width:90px; height:40px" src="images/menuButton.gif" alt="">');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:245px; left:100px" href="contactjim.html">Jim</a>');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:262px; left:100px" href="contactjudy.html">Judy</a>');
  document.write('  </div>');

  document.write('  <img class="m1" style="position:absolute; top:280px; left:0px" src="images/menuButton.gif" alt="">');
  document.write('  <p class="14W"><a class="white" rel="LinkSubMenu" style="position:absolute; top:287px; left:5px" href="links.html">Links</a>');
  document.write('  <div id="LinkSubMenu">');
  document.write('    <img class="m1" style="position:absolute; top:290px; left:80px; width:10px; height:10px" src="images/menuButton.gif" alt="">');
  document.write('    <img class="m1" style="position:absolute; z-index:1; top:282px; left:90px; width:90px; height:25px" src="images/menuButton.gif" alt="">');
  document.write('    <p class="10W"><a class="white" style="position:absolute; z-index:1; top:287px; left:100px" href="links.html">Reference</a>');
  document.write('  </div>');
  document.write('</div>');
}

var expandingMenu=
{
  subcontainers:[], variableName:null, variableShift:null, variableNormal:null, timeOut:null,

  startTimer:function()
  {
    expandingMenu.timeOut = window.setTimeout('expandingMenu.hideAllSubMenu()', 500)
  },

  stopTimer:function()
  {
    window.clearTimeout(expandingMenu.timeOut)
  },

  revealSubMenu:function(currentItem)
  {
    expandingMenu.stopTimer()

    this.hideAllSubMenu()

    if (currentItem.getAttribute("rel"))
    {
      if (variableName == "variableDisplay")
      {
        var value=document.getElementById(currentItem.getAttribute("rel")).getAttribute("id")

        if (value == "ServicesSubMenu" || value == "ResourcesSubMenu")
        {
          variableShift.style.display="block"
          variableNormal.style.display="none"
        }
        else
        {
          variableShift.style.display="none"
          variableNormal.style.display="block"
        }
      }

      document.getElementById(currentItem.getAttribute("rel")).style.display="block"
      document.getElementById(currentItem.getAttribute("rel")).onmouseover=function(){expandingMenu.stopTimer()}
      document.getElementById(currentItem.getAttribute("rel")).onmouseout=function(){expandingMenu.startTimer()}
    }
  },

  hideAllSubMenu:function()
  {
    for (var i=0; i<this.subcontainers.length; i++)
      document.getElementById(this.subcontainers[i]).style.display="none"

    if (variableName == "variableDisplay") 
    {
      variableShift.style.display="none"
      variableNormal.style.display="block"
    }
  },

  initMenu:function(menuName, itemName)
  {
    variableName=itemName

    if (variableName == "variableDisplay")
    {
      var item=document.getElementById(variableName).getElementsByTagName("div")

      for (var i=0; i<item.length; i++)
      {
        if (item[i].getAttribute("id") == "shift")
          variableShift = item[i]
        else if (item[i].getAttribute("id") == "normal")
          variableNormal = item[i]
      }
    }

    var menuItem=document.getElementById(menuName).getElementsByTagName("a")

    for (var i=0; i<menuItem.length; i++)
    {
      if (menuItem[i].getAttribute("rel"))
      {
        this.subcontainers[this.subcontainers.length]=menuItem[i].getAttribute("rel")
        menuItem[i].onmouseover=function(){expandingMenu.revealSubMenu(this)}
        menuItem[i].onmouseout=function(){expandingMenu.startTimer()}
      }
    }
    
    this.hideAllSubMenu()
  }
}