var isIE = false;      // Microsoft Internet Explorer
var isIEOld = false;      // Microsoft Internet Explorer
var isNS4 = false;     // Netscape 4+
var isW3C = false;     // W3C compliant (inc NS6)
var isNav = false;     // Netscape
var isUnknown = true;  // in case something else comes along

//var userOS = "Unknown";

function sniffBrowserCapabilities()
{
   //userOS = getUserSystem();
   var ua = navigator.userAgent.toLowerCase();
   //alert ("Stai usando un sistema operativo " + userOS);
   var ieVers = 0;
   var ieSubVers = 0;
   
//    prompt ("Impostazioni: ", "navigator.appCodeName: " + navigator.appCodeName + ", navigator.appVersion:" + navigator.appVersion + ", navigator.appMinorVersion:" + navigator.appMinorVersion + ", navigator.appName:" + navigator.appName  + ", navigator.userAgent:" + navigator.userAgent)
  if (document.getElementById) {
    isW3C = true ; // NS6, MSIE 5+, Mozilla, Opera 6 in Opera (W3C) mode
  }
  if (document.all) 
  {
      isIE = true ; // MSIE (all versions) and Opera 6 in MSIE 5 mode
      var iePos = ua.indexOf ("msie ");
      if (iePos  > 0)
      {
         ua = ua.substr ((iePos + 5), ua.length);
         ua = ua.substr (0, ua.indexOf (";"));
         ieVers = parseInt(ua)
         ieSubVers = parseInt(ua.substr(ua.indexOf (".") + 1, 1))
         if (ieVers < 5 || (ieVers == 5 && ieSubVers < 5))
            isIEOld = true;
      }
      ua = navigator.userAgent.toLowerCase();
      isUnknown = false;
  }
  if (document.layers) {
    isNS4 = true ; // NS 4
    isUnknown = false;
    alert ("Questo sito richiede l'utilizzo di un browser più recente, come:\n Netscape 6.2 o superiori, Mozilla, Microsoft Internet Explorer 5.5 o superiori")
  }
  if (navigator.appName == "Netscape")
  {
      isNav = true;
      isUnknown = false;
  }

  if (ua.indexOf("mac") != -1) 
  {
     if (!isIE || (isIE && ieVers < 5))
     {
         if (confirm ("Si sta utilizzando un sistema macintosh sul quale l'applicazione non è stata testata.\nIl presente sito è ottimizzato per lavorare con le versioni più recenti di Microsoft Internet Explorer.\nE' possibile proseguire, ma non verrà garantito il corretto funzionamento di tutte le operazioni.\nSi desidera scaricare l'ultima versione di Internet Explorer ?"))
            window.open ("http://www.microsoft.com/mac/products/internetexplorer/internetexplorer.aspx?pid=internetexplorer", "wMac", "");
     }
     isIEOld = false;
  }

  if ((ua.indexOf("opera") != -1) || (ua.indexOf("webtv") != -1) || (ua.indexOf("hotjava") != -1))
  {
      isIE = true;      
      isIEOld = false;   
      isNS4 = false;     
      isNav = false;     
      isUnknown = false; 
      if (confirm ("Si sta utilizzando un browser o un sistema sul quale l'applicazione non è stata testata.\nIl presente sito è progettato per lavorare con le versioni più recenti di Microsoft Internet Explorer.\nSebbene sia possibile proseguire, non verrà garantito il corretto funzionamento di tutte le operazioni.\nSi desidera scaricare l'ultima versione di Internet Explorer ?"))
         window.open ("http://www.microsoft.com/ie/", "wIE", "");
  }


/*  
  if (isNav)
  {
      if (confirm ("Si sta utilizzando un browser Mozilla o Netscape.\nIl presente sito è progettato per lavorare con le versioni più recenti di Microsoft Internet Explorer.\nSebbene sia possibile proseguire, non verrà garantito il corretto funzionamento di tutte le operazioni.\nSi desidera scaricare l'ultima versione di Internet Explorer ?"))
         window.open ("http://www.microsoft.com/ie/", "wIE", "");
  }
*/
}

/*
function getUserSystem()
{
		var ua = navigator.userAgent.toLowerCase();

		if (ua.indexOf('xp') > -1 || ua.indexOf('windows nt 5.1') > -1)                                    return "Windows XP";
		if (ua.indexOf('windows 98') > -1 || ua.indexOf('win98') > -1 || ua.indexOf('windows98') > -1)     return "Windows 98";
		if (ua.indexOf('windows me') > -1)	                                                               return "Windows ME";
		if (ua.indexOf('windows nt 5.0') > -1 || ua.indexOf('windows 2000') > -1)                          return "Windows 2000";
		if (ua.indexOf('windows nt 4.0') > -1 || ua.indexOf('winnt') > -1)                                 return "Windows NT";
		if (ua.indexOf('windows 95') > -1 || ua.indexOf('win95') > -1)                                     return "Windows 95";  
		if (ua.indexOf('linux') > -1)		                                                                  return "Linux";       
		if (ua.indexOf('mac os x') > -1)		                                                               return "Mac OS X";    
		if (ua.indexOf('mac_powerpc') > -1 || ua.indexOf('ppc') > -1)                                      return "Mac Power PC";
		if (ua.indexOf('sun os') > -1 || ua.indexOf('sunos') > -1)		                                    return "Sun OS";      
		if (ua.indexOf('hp-ux') > -1)                                                                      return "HP-UX";       
		
		return "Unknown";
}

*/