/*
	This code is called by a script reference in the head of an htm file and it writes 
	in a link to a css override file based on the current user agent. It assumes that all 
	pages are located in the root directory (path issue) but has a provision for pages that 
	are one level below the root. If the page's href is added to the PagesInSubDirs
	variable (PagesInSubDirs = "mySubdirpage.html myOtherSubditpage.htm etc...") 
	then the path to the CSS override will be written correctly
	
	RL
*/

/* figure out if we are called by a subdirectory page
	THIS IS NOT IMPLEMENTED IN THIS VERSION. */

	var UseSubDirectory 	= false;
	
	var PagesInSubDirs 		= ""; // keep this uptodate and accurate!
	var TheCallingURL 		= document.location.href;
	var ThePageToSetup 		= TheCallingURL.substring(document.location.href.lastIndexOf('/') + 1);
	
	if (PagesInSubDirs.indexOf(ThePageToSetup) >= 0) { 
		UseSubDirectory 	= true; }
	else {
		UseSubDirectory 	= false; }


/* collect some basic browser info */
	agent = navigator.userAgent;
	agent = agent.toUpperCase();

// alert(agent);

/* IE */
	if(navigator.appName == "Microsoft Internet Explorer") {
		// alert ("debug message: looks like this is IE, writing in IE adjustments - ie_adjustments.css. RL");
		document.write("<link rel='stylesheet' type='text/css' href='../styles/ie_adjustments.css'>");}


/* Safari */
	var found = agent.indexOf("SAFARI");
	
	if(found > -1) {
		// alert ("debug message: looks like this is safari, writing in Safari adjustments - safari_adjustments.css. RL");
		if (UseSubDirectory) {
			document.write("<link rel='stylesheet' type='text/css' href='../styles/safari_adjustments.css'>");}
		else  {
			document.write("<link rel='stylesheet' type='text/css' href='../styles/safari_adjustments.css'>");}
	}



/* Firefox */
	var found = agent.indexOf("FIREFOX");
	
	if(found > -1) {
		// alert ("debug message: looks like this is FireFox, writing in FireFox adjustments - FireFox_adjustments.css.css. RL");
		if (UseSubDirectory) {
			document.write("<link rel='stylesheet' type='text/css' href='../styles/firefox_adjustments.css'>");}
		else  {
			document.write("<link rel='stylesheet' type='text/css' href='../styles/firefox_adjustments.css'>");}
	}		
		
		

/* Netscape */
	var found = agent.indexOf("NETSCAPE");
	
	if(found > -1) {
		// alert ("debug message: looks like this is some version/platform of Netscape Navigator, writing in Netscape adjustments - netscape_adjustments.css. RL");
		if (UseSubDirectory) {
			document.write("<link rel='stylesheet' type='text/css' href='../styles/netscape_adjustments.css'>");}
		else  {
			document.write("<link rel='stylesheet' type='text/css' href='../styles/netscape_adjustments.css'>");}
	}		

		


/* Opera */
	var found = agent.indexOf("OPERA");
	
	if(found > -1) {
		// alert ("debug message: looks like this is some version/platform of Opera, writing in Opera adjustments - opera_adjustments.css. RL");
		if (UseSubDirectory) {
			document.write("<link rel='stylesheet' type='text/css' href='../styles/opera_adjustments.css'>");}
		else  {
			document.write("<link rel='stylesheet' type='text/css' href='../styles/opera_adjustments.css'>");}
	}		



/* Isn't this fun! sigh. */







