// v1.1.3
// 5/27/01 cro - Factored out GetCSS()
// 7/11/01 cro - Dropped Mac IE5 from the IE custom stylesheet because it was flaky. These users now get the generic stylesheet.
// 7/28/01 cro - Added WriteSecureCSS(), added bSecure param to GetCSS() so all SSL elements are secure

var isNav = navigator.appName.indexOf("Netscape") != -1;
var isIE  = navigator.appName.indexOf("Microsoft") != -1;
var isMac = (navigator.appVersion.indexOf("Macintosh") >= 0);
var gVersion = GetVersion();

//
//	Returns the URL to the custom stylesheet for the client.  For IE, if the
//	client is not a Mac, they get a custom stylesheet.  For Netscape, if the
//	client is a Mac with Mozilla they get the same custom stylesheet other
//	Netscape users get.  Other Macs and (and other platforms and browsers)
//	will get the generic stylesheet, on the offhand hope that they will 
//	respect it.
//
function GetCSS(bSecure) 
{
	var sCSS;
	
	// Determine which platform stylesheet to use...
	if (isIE) {
		if (!isMac)
			sCSS = "nt-ie.css";	
		else
			sCSS = "nt.css";
	}
	else if (isNav) {
		if (!isMac) 
			sCSS = "nt-nav.css";
		else if (gVersion >= 5)
			sCSS = "nt-nav.css";
		else
			sCSS = "nt.css";
	}
	else sCSS = "nt.css";
	
	// From the secure server or normal server?
	if (bSecure)
		sCSS = "https://www.norwoodtower.com/" + "style/" + sCSS;
	else
		sCSS = "http://www.norwoodtower.com/" + "style/" + sCSS;
	
	return (sCSS);
}

//
//	Includes the correct stylesheet in the HTML
//
function WriteCSS() 
{
	var sCSS = GetCSS(false);
	if (sCSS.length > 0) document.write("<link rel=\"stylesheet\" href=\"" + sCSS + "\">");
}

//
//	Includes the correct stylesheet in the HTML
//
function WriteSecureCSS() 
{
	var sCSS = GetCSS(true);
	if (sCSS.length > 0) document.write("<link rel=\"stylesheet\" href=\"" + sCSS + "\">");
}

//	Includes text of current stylesheet, for debug purposes
function DebugWriteCSS() 
{
	var sCSS = GetCSS(false);
	if (sCSS.length > 0) document.write("nt.js writes: &lt;link rel=\"stylesheet\" href=\"" + sCSS + "\"&gt;");
}
// Get the browser version.  Digs into appVersion for IE, since MS doesn't 
// understand what version numbers are for. Otherwise just parses the appVersion.
function GetVersion() {
	var s = navigator.appVersion;
	var n = s.indexOf("MSIE");
	var v = 0;
	// Grab the first number appearing after "MSIE"
	if (n != -1) {
		v = parseFloat(s.substr(n + 4));
	}
	else {
		v = parseFloat(s);
	}
	return v;
}
