/*
Script Name: Simple Javascript Browser/OS detection
Authors: George Anestis, Websites: http://www.music.tuc.gr/

Version 1.0.0
Copyright (c) 18 Sep 2007

*/

/******************************************************************************
Light version, use for basic browser detection only. 

Remember, always use method or object testing as your first choice, for example, 
if ( dom ) { statement; };

The main script is separated from the initial netscape 4 detection due to 
certain bugs in netscape 4 when it comes to unknown things like d.getElementById. 
The variable declarations of course are made first to make sure that all the 
variables are global through the page, otherwise a javascript error will occur 
because you are trying to use an undeclared variable.

We test for basic browser type (ie, op, or moz/netscape > 6).
******************************************************************************/

/******************************************************************************
Lite version, tests only for main types and browsers out there, this will cover 
you in almost all normal situations out there.

Since different browsers support different objects, you can use Object Detection 
as a quick though less than infallible way of detecting various browsers.
It's important to mention that object detection's chief purpose is to help you 
detect within your script whether the browser supports a particular 
object/method/property before using it, not browser detection. As the later it 
may be convenient over probing the Navigator object, but is only as reliable as 
your understanding of which objects are supported in which browsers
******************************************************************************/

var d, n, op, konq, saf, moz, ie;

var ff2, ff15, ie6, ie7, op7, op8, op9;       
ff2 = ff15 = ie6 = ie7 = op7 = op8 = op9= false;

d = document;
n = navigator;        
nua = n.userAgent;    

if ( !d.layers ){        
   op = ( nua.indexOf( 'Opera' ) != -1 );
   konq = ( nua.indexOf( 'Konqueror' ) != -1 );
   saf = ( nua.indexOf( 'Safari' ) != -1 );
   moz = ( nua.indexOf( 'Gecko' ) != -1 && !saf && !konq);
   ie = ( d.all && !op );           
}  

if (moz) {            
   if ( window.Iterator ) {
       ff2 = true;
       ff15 = false;
   }
   else if ( Array.every ) {
       ff15 = true;
       ff2 = false;
   }
}
else if (ie) {              
   if ( document.documentElement && typeof document.documentElement.style.maxHeight!="undefined" ) {
       ie7 = true;
       ie6 = false;
   }
   else if ( ie6 = document.compatMode && document.all ) {
       ie6 = true;
       ie7 = false;
   }
} 
else if (op) {
   agt = n.userAgent.toLowerCase();
   op7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1); 
   op8 = (agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1); 
   op9 = (agt.indexOf("opera 9") != -1 || agt.indexOf("opera/9") != -1);                      
}
