  // DETECTTOUCHDEVICES.JS

  // Self contained external JS file that tests and defines the following useful variables
  // that are related to identifying whether a device is a touch device or not:
  // 
  // IsATouchDevice  (true or false)  If true then built in browser support exists for JS ontouchstart, ontouchend, ontouchmove and ontouchcancel event triggers
  // IsIPad  (true or false)
  // IsIPhoneOrIPod  (true or false)
  // IsMac  (true or false)  - includes IPad, IPhones, IPod Touch and other Apple devices
  // IsMacOnlyNotTabletOrPhoneEtc  (true or false)
  // IsWindows  (true or false)  - includes Windows tablets, Windows CE devices and Windows phones
  // IsWindowsComputerNotTabletOrPhone  (true or false)

  NavUserAgent = navigator.userAgent;
  NavUserAgent = NavUserAgent.toLowerCase();

  var IsATouchDevice = false; // Default value before testing below
  // This cannot detect everything, but it is remarkably thorough
  //
  // IMPORTANT: Do NOT base test on browser support of:
  // ontouchstart, ontouchend, ontouchmove and ontouchcancel
  // Browser support does NOT mean that it is "active" on the particular device
  //
  // Start testing to determine value of IsATouchDevice
  if (NavUserAgent.indexOf("tablet") != -1)
    {
      // "tablet" is used by Windows tablets
      IsATouchDevice = true;
    };
  if (NavUserAgent.indexOf("mobile") != -1)
    {
      IsATouchDevice = true;
    };
  if (NavUserAgent.indexOf("phone") != -1)
    {
      IsATouchDevice = true;
    };
  if (NavUserAgent.indexOf("windows ce") != -1)
    {
      IsATouchDevice = true;
    };
 if (NavUserAgent.indexOf("like mac") != -1)
    {
      // "like mac" is used by Apple for all non Macintosh devices
      IsATouchDevice = true;
    };
  if ((NavUserAgent.indexOf("iphone") != -1) || (NavUserAgent.indexOf("ipad") != -1) || (NavUserAgent.indexOf("ipod") != -1))
    {
      // Known Apple touch devices (just to be safe)
      IsATouchDevice = true;
    };
 if ((NavUserAgent.indexOf("applewebkit") != -1) && (NavUserAgent.indexOf("mac") == -1) && (NavUserAgent.indexOf("win") == -1))
    {
      // Best method for detecting Android, Blackberry Playbook and other remaining devices
      IsATouchDevice = true;
    };
  // End testing to determine value of IsATouchDevice

  var IsIPad = (NavUserAgent.indexOf('ipad') != -1);  // Also note that iPhones and iPods are identified as being "Macs"

  var IsIPhoneOrIPod = false; // Default value before being tested below
  if ((NavUserAgent.indexOf("iphone") != -1) || (NavUserAgent.indexOf("ipod") != -1))
    {
      // Also note that iPhones and iPods are identified as being "Macs"
      IsIPhoneOrIPod = true;
    };

  var IsMac = (NavUserAgent.indexOf("mac") != -1);
  // Note: iPads, iPhones and iPods are also identified as being "Macs"

  var IsMacOnlyNotTabletOrPhoneEtc = false; // Default value before being tested below
  if ((IsMac) && (!IsATouchDevice))
    {
      IsMacOnlyNotTabletOrPhoneEtc = true;
    };

  var IsWindows = (NavUserAgent.indexOf("win") != -1);
  // Note: Windows tablets, Windows CE devices and Windows phones are included

  var IsWindowsComputerNotTabletOrPhone = false; // Default value before being tested below
  if ((IsWindows) && (!IsATouchDevice))
    {
      IsWindowsComputerNotTabletOrPhone = true;
    };





