// Style Sheet browser/platform detection script
// Version Verdana 2.3
// Author contact: im1webteam@lanl.gov


// Base path to .css files. Must remain a hard link for those using the styles on external hosts. 
var path = "http://www.lanl.gov/styles/v2.3/";

// Change this variable to set the font face used. 
// Use "verd" for Verdana, "arial" for Arial/Helvetica.
var font = "verd";


// Convert the Browser value to lower case
var agt         =  navigator.userAgent.toLowerCase(); 


// Browser variables
var is_major    =  parseInt(navigator.appVersion); 
var is_minor    =  parseFloat(navigator.appVersion);
var is_nav      = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1));
var is_nav2     = (is_nav && (is_major == 2));
var is_nav3     = (is_nav && (is_major == 3));
var is_nav4     = (is_nav && (is_major == 4));
var is_nav4up   = (is_nav && (is_major >= 4));
var is_navonly  = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
var is_nav5     = (is_nav && (is_major == 5));
var is_nav5up   = (is_nav && (is_major >= 5));
var is_ie       = (agt.indexOf("msie") != -1);
var is_ie3      = (is_ie && (is_major < 4));
var is_ie4      = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.")==-1) );
var is_ie4up    = (is_ie  && (is_major >= 4));
var is_ie5      = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.")!=-1) );
var is_ie5up    = (is_ie  && !is_ie3 && !is_ie4);


// Platform variables
var is_win	=  (agt.indexOf("win")!=-1);
var is_mac 	=  (agt.indexOf("mac")!=-1);
var is_linux 	= (agt.indexOf("inux")!=-1);
var is_sun 	= (agt.indexOf("sunos")!=-1);
var is_sun4  	= (agt.indexOf("sunos 4")!=-1);
var is_sun5  	= (agt.indexOf("sunos 5")!=-1);
var is_suni86	= (is_sun && (agt.indexOf("i86")!=-1));
var is_irix  	= (agt.indexOf("irix") !=-1);    // SGI
var is_irix5 	= (agt.indexOf("irix 5") !=-1);
var is_irix6 	= ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
var is_hpux  	= (agt.indexOf("hp-ux")!=-1);
var is_hpux9 	= (is_hpux && (agt.indexOf("09.")!=-1));
var is_hpux10	= (is_hpux && (agt.indexOf("10.")!=-1));
var is_aix   	= (agt.indexOf("aix") !=-1);      // IBM
var is_aix1  	= (agt.indexOf("aix 1") !=-1);    
var is_aix2  	= (agt.indexOf("aix 2") !=-1);    
var is_aix3  	= (agt.indexOf("aix 3") !=-1);    
var is_aix4  	= (agt.indexOf("aix 4") !=-1);    
var is_sco   	= (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
var is_unixware = (agt.indexOf("unix_system_v")!=-1); 
var is_mpras    = (agt.indexOf("ncr")!=-1); 
var is_reliant  = (agt.indexOf("reliantunix")!=-1);
var is_dec   	= ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
var is_sinix 	= (agt.indexOf("sinix")!=-1);
var is_freebsd 	= (agt.indexOf("freebsd")!=-1);
var is_bsd 	= (agt.indexOf("bsd")!=-1);
var is_unix  	= ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || is_sco || is_unixware || is_mpras || is_reliant || is_dec || is_sinix || is_aix || is_bsd || is_freebsd);


// Base style sheet used by all browsers on all platforms 
document.write('<link rel="stylesheet" href="' + path + 'basic.css" type="text/css">');

// Macintosh detects
if (is_mac && is_ie5up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-mac-ie5.css" type="text/css">');
	<!--alert("Mac IE 5");-->	
	}
else if (is_mac && is_ie4up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-mac-ie4.css" type="text/css">');
	<!--alert("Mac IE 4");-->	
	}
else if (is_mac && is_nav5up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-mac-ns6.css" type="text/css">');
	<!--alert("Mac NN 6 / Mozilla 1");-->	
	}
else if (is_mac && is_nav4up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-mac-ns4.css" type="text/css">');
	<!--alert("Mac NN 4");-->	
	}
else if (is_mac) {
	document.write('<link rel="stylesheet" href="' + path + font + '-mac-ns4.css" type="text/css">');
	<!--alert("Mac, can't determine browser");-->	
	}

// Windows detects
else if (is_win && is_ie5up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-win-ie.css" type="text/css">');
	}
else if (is_win && is_ie4up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-win-ie.css" type="text/css">');
	}
else if (is_win && is_nav5up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-win-ns6.css" type="text/css">');
	}
else if (is_win && is_nav4up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-win-ns4.css" type="text/css">');
	}
else if (is_win) {
	document.write('<link rel="stylesheet" href="' + path + font + '-win-ie.css" type="text/css">');
	}

// UNIX Detects
else if (is_unix && is_ie5up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-unix-ie.css" type="text/css">');
	}
else if (is_unix && is_ie4up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-unix-ie.css" type="text/css">');
	}
else if (is_unix && is_nav5up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-unix-ns6.css" type="text/css">');
	}
else if (is_unix && is_nav4up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-unix-ns.css" type="text/css">');
	}
else if (is_unix) {
	document.write('<link rel="stylesheet" href="' + path + font + '-unix-ns.css" type="text/css">');
	}

// LINUX Detects
else if (is_linux && is_nav5up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-linux-ns6.css" type="text/css">');
	<!--alert("Linux NN 6.x/7.x or Mozilla 1.x")-->
	}
else if (is_linux && is_nav4up) {
	document.write('<link rel="stylesheet" href="' + path + font + '-linux-ns4.css" type="text/css">');
	<!--alert("Linux NN 4")-->
	}
else if (is_linux) {
	document.write('<link rel="stylesheet" href="' + path + font + '-linux-ns4.css" type="text/css">');
	}	

// Default
else {
	document.write('<link rel="stylesheet" href="' + path + font + '-default.css" type="text/css">');
	<!--alert("Can't determine platform, can't determine browser");-->	
	}
