//===================================================
// browser.js
//
// Determines browser, platform
//
// String values from http://developer.netscape.com/docs/examples/javascript/browser_type.html
//===================================================

var IE = (navigator.appName == "Microsoft Internet Explorer");
var Mozilla = (navigator.userAgent.indexOf("Gecko") > -1);
var Gecko = Mozilla;
var Opera = (navigator.userAgent.indexOf("Opera") > -1);
var NN4 = (navigator.userAgent.indexOf("Mozilla/4") == 0) && !IE && !Opera && !Gecko;

var styleSheet = "style.css";
if (Opera) 
	styleSheet = "opera.css";
else if (Gecko)
	styleSheet = "gecko.css";
else if (!IE && !Gecko && navigator.userAgent.indexOf("Mozilla") == 0)
	styleSheet = "nn4.css";

// What directory are we in?  Examine the pathname of our URL.  
// Pathname of www.rationalchristianity.net/test.html = /test.html
var dir = "";
if (location.protocol.indexOf("file") == -1) {
	var i = 1;
	var path = location.pathname;
	while (i < path.length && path.indexOf("/", i) > -1) {
		dir += "../";
		i = path.indexOf("/", i) + 1;
	}
} else {
	var path = location.pathname;
	var parentDir = "web%20site";
	if (path.indexOf(parentDir) == -1) 
		parentDir = "web site";
	var i = path.indexOf(parentDir);
	i += parentDir.length + 1;
	var c = path.charAt(i-1);
	while (i < path.length && path.indexOf(c, i) > -1) {
		dir += "../";
		i = path.indexOf(c, i) + 1;
	}
}

document.writeln('<link rel=stylesheet type="text/css" href="' + dir + styleSheet + '">');
