// The original script is located under
// http://freeware.sgi.com/shared/js/style_sniffer.js
// Thanks to SGI

var win_ns = "win_ns.css";
var win_ie = "win_ie.css";
var mac_ns = "mac_ns.css";
var mac_ie = "mac_ie.css";
var unix_css = "unix.css";
var opera_css = "opera.css";

// convert all characters to lowercase to simplify testing 
var agt=navigator.userAgent.toLowerCase(); 

// *** BROWSER VERSION *** 
var vers = parseInt(navigator.appVersion); 

// *** BROWSER TYPE ***
var opera = (agt.indexOf("opera") != -1);
var opera7 = (opera && (vers >= 7));
var moz = (agt.indexOf("gecko") != -1);
var ie = ((agt.indexOf("msie") != -1) && !moz && !opera);
var ie4 = (ie && (vers >= 4));
var nn = ((agt.indexOf("mozilla") != -1) && !ie && !moz && !opera);
var nav4 = (nn && (vers >= 4));  

// *** PLATFORM ***
var is_win  = (agt.indexOf("win")!=-1);
var is_mac  = (agt.indexOf("mac")!=-1);
var is_unix = (agt.indexOf("x11")!=-1);

// Select the appropriate stylesheet
if (nav4 || ie4 || moz || opera7 || (!nn && !ie && !moz && !opera)) {
	//var isFour = true;

	var styles = "/styles/";

	// var styles = location.protocol + "//www.sgi.com/styles/";
	//if ((location.host != "freeware.sgi.com") &&
	//    (location.host != "www.sgi.com")) {
	//   // Let mirror sites mirror the styles directory too.
	//   styles = "/styles/";
	//}
	//else if (location.protocol == "ftp:") {
	//   // www.sgi.com does not allow anonymous ftp
	//  styles = "http://www.sgi.com/styles/";
	//}
	//else {
	//   // Avoid https: -> http: warnings
	//   styles = location.protocol + "//www.sgi.com/styles/";
	//}


	if 	(opera) styles += opera_css;	               // Opera
	else if 	(is_win) styles += (nn)?win_ns:win_ie;	// Microsoft Windows 
	else if (is_mac) styles += (nn)?mac_ns:mac_ie;	// Apple Macintosh
	else 		 styles += unix_css;	// UNIX
	
	//alert(styles);
	document.write('<LINK REL="stylesheet" HREF="' + styles + '" TYPE="text/css">');
}

