//------------------------------------------------------------//
//     is_mac, is_mac68k, is_macppc
//     is_unix
//        is_sun, is_sun4, is_sun5, is_suni86
//        is_irix, is_irix5, is_irix6
//        is_hpux, is_hpux9, is_hpux10
//        is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//        is_linux, is_sco, is_unixware, is_mpras, is_reliant
//        is_dec, is_sinix, is_freebsd, is_bsd
//     is_vms
//
//-----------------------------------------------------------//

var is_Legacy = true;

function isIE5() {
  return (is_ie5 && is_minor < 5.5);
}

function browserCheck(dom){

   if (is_mac) {
      macAlert(dom);
      return;
   }
  
   if(is_nav) {
       getNetscape(dom);
    }  
   else  if(is_ie) {
      getIE(dom);
   }  
   else if(is_moz || is_gecko) { 
     getMoz(dom);
   }
 
}


function  getNetscape(dom) {

if (is_win || is_linux) { 
    if(is_nav7up && is_minor >= 7.1) {
      is_Legacy = false;
      return;
    }

    if(is_nav6up) {
      notify_acceptable(dom, "Netscape", '7.1', false);    
    }
    else {
         var msg = "Unfortunately, Timeline will not run in Netscape " + is_minor + ".\n\n"
                + "Timeline is optimized for Netscape 7.1 or later\n"
                +"but it can run in versions as early as 6.2.2"
         if(dom)  
           setPopup(dom, msg);
          else alert(msg);
    }
    return;
  }

 if(is_nav7up && is_minor >= 7.1) 
     miscBrowserAlert(dom,"But Timeline does run in Netscape 7.1 on Windows and Linux"
                           + "and may run succesfully for you.", true);
 else if(is_nav6up) {
     miscBrowserAlert(dom,"But Timeline does run in Netscape 6.2.2 on Windows, "
                           + "and " + is_minor + "may\nrun succesfully for you.", true);
 }
 else {
   notify_unacceptable("Netscape", "7.1")
 }
}


function getIE(dom) {

  if(is_win) 
  {
    if(is_ie6up) {
        is_Legacy = false;
        return;  
      }
    if(is_ie5up && is_minor >= 5.5) {
       is_Legacy = false;
       notify_acceptable(dom, "Internet Explorer", '6', true);            
      }
    else if (is_ie5){
       notify_acceptable(dom, "Internet Explorer", '6', false);            
     }
    else {
      notify_unacceptable("Internet Explorer", "6")
     }
   return;
  }


}  

function getMoz(dom) {
 var otherOSmsg =
        'But Mozilla/Gecko tends to be consistent across operating systems\nand this version (';
  if(is_minor < 1) {
   notify_unacceptable("Mozilla/Gecko", "1.5");
   return;
  }
 
 if(is_fx) {  
    is_Legacy = false;
   return;
  }

  if(is_minor >= 1.5) {  
    is_Legacy = false;
    if(!is_linux && !is_win) {     
      miscBrowserAlert(dom, otherOSmsg +  is_minor + ') should work', true);
      }
      return;
    }

    if(is_minor >= 1.4) {
      is_Legacy = false;
       if(!is_linux && !is_win) {
         miscBrowserAlert(dom, otherOSmsg +  is_minor + ') should work', true);    
      }
      return;
    }

  if(is_linux || is_win)      
     notify_acceptable(dom,"Mozilla/Gecko", "1.5");
  else  
   miscBrowserAlert(dom, 'While it can\'t be guaranteed to run successfully,'
                       +' there\'s\na good chance that it will.', false);    
}

function notify_unacceptable(browser, upgrade) {
  alert(
      "Timeline will not run in " + browser + " " + is_minor 
      + "\nIt is optimized for " + browser + " " + upgrade);

}


function addLink(dom) {
var msg = "";
  if(dom) {
        msg = '\nIf you have problems try this modified version of Timeline:<br>\n'
                   + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href=\"javascript:setLegacy(true);  openTimeLine();\"'
                 + '>Timeline: Modified Version</A>';

  }

  else  {
     var msg = '\n\nNOTE:\n   If you have problems '
	      +	' open "System Requirements" at the bottom of this page\n'
   	      + 'and click on "Timeline: Modified Version."';
   }

  return msg;
   
}

function miscBrowserAlert(dom, msg, add_link) {
 var misc_msg = "Timeline has not been tested with this browser and/or operating system.\n";
  
  misc_msg  += msg;
  if(add_link) misc_msg += addLink(dom);

  if(dom) {
     setPopup(dom, misc_msg);
  }
   else alert(misc_msg);    

}



function notify_acceptable(dom, browser, opt, add_link) {

var msg = 'Timeline has been optimized for ' + browser + ' ' + opt + ' or later.\n'
          + 'But it should run succesfully in  ' + browser + ' (' + is_minor + ').\n';

  if(add_link) msg += addLink(dom);  
  if(dom) {
      setPopup(dom, msg);
  }
 else alert(msg);

}

function setPopup(dom, msg) {
 var msg_2 ="<p>It should be viewed using screen resolutions of 1024 x 768 or greater.  Not all of its " 
 + "functionality may be available at lower resolutions.  This is also true if you are using earlier versions "
 + "of some browsers on the Mac. "
 var closeSysInfoWin = 
  '<P><span class = "wlink" onclick ="document.getElementById(\'system\').style.visibility=\'hidden\';">'
  +'close window</span>';


 msg+=  msg_2;
 msg+=closeSysInfoWin;
 dom.innerHTML = msg;

}



function macAlert(dom) {
 var macmsg = "Timeline has run in a variety Mac browsers, including Netscape 6,"
              + "Mozilla 1.5, Safari, FireFox, and Internet Explorer 5 and later.";


 if(is_moz || is_gecko) {
              macmsg += "<P>"
              + "In browsers based on Mozilla's Gecko, which includes Netscape, FireFox"
              + "and Mozilla itself, there is a formatting glitch which causes internal scrollbars"
              + "to print over top of some drop-down menus. But this doesn't interefere with the functioning"
              + " of Timeline.";       

 }
 if(is_ie && !is_ie5up) {
         
     alert("Timeline may not function correctly on IE versions prior to 5");
   }	   

 if(dom)
     setPopup(dom, macmsg);
 


}

