// Contents


// 1) Style Sheet Finder

// 3a) Pop Up Windows (argh) (fixed size)

// 3b) Pop Up Windows (size values can be passed in)

// -----------------------

// (1) Style Sheet Finder 

// Style Sheet Finder tests for operating system, browser, and 
// browser version, and then document.writes a line into the
// header of each html page that points to the appropriate style
// sheet for each set up.  Works for Netscape and IE versions 3 and
// 4 on Macintosh, Win environment, Sun, AIX, IRIX, and HP.


// set variables

var whatStyle;
whatStyle = "Default";

// The first thing we need to do is find the directory with all the
// shared stuff like style sheets and graphics.  This is
// /devmodules/shared/; we have to figure out where /devmodules/ is in
// relation to the file being viewed.  It would be nice if we could
// always just say "/devmodules/", indicating that it is a
// subdirectory of the web root directory, but if we are using the
// file: protocol, as with a CD, there is no web root directory.  But
// in this case, with any luck, the tree structure will be more or
// less intact, and the file will be under one of the top-level
// directories.  We'll have to search to see which one.

// If we are using http:, then we will assume that /devmodules/ is in
// fact a top-level directory.  If you install the modules
// somewhere else in the hierarchy, you must change the following
// value.  It should begin and end with a slash.
var http_module_root = "/devmodules/";

// If we are running off a CD, or for some other reason not using
// http:, then we have to search through the current page's location
// for the name of (what is supposed to be) a top-level directory.
// These are sort of in order by how likely they are to be hit; also,
// words which might be subdirectories (like "shared") come last.
var top_level_directories = new Array();
top_level_directories[top_level_directories.length++] = "devmodules";
top_level_directories[top_level_directories.length++] = "webhtml";
top_level_directories[top_level_directories.length++] = "otm";
top_level_directories[top_level_directories.length++] = "oldmodules";
top_level_directories[top_level_directories.length++] = "search";
top_level_directories[top_level_directories.length++] = "documentation_mw";
top_level_directories[top_level_directories.length++] = "codebase";
top_level_directories[top_level_directories.length++] = "restricted";
top_level_directories[top_level_directories.length++] = "webgraphics";
top_level_directories[top_level_directories.length++] = "vrml";
top_level_directories[top_level_directories.length++] = "ibm";
top_level_directories[top_level_directories.length++] = "shared";

// The following does not begin with a slash.
var file_module_root = "devmodules/";

var module_root_search_string;
var module_root_string = null;
function module_root()
  {
    var h, i = -1, j, z;

    // Maybe we've already done this.  Maybe not.
    if (module_root_string == null)
      {
	h = new String(document.location);

	if (h.indexOf("http:") == 0)
	  {
	    module_root_string = http_module_root;
	  }
	else
	  {
	    // OK, we are probably using file:.
	    for (z = 0; (z < top_level_directories.length) && (i < 0); z++)
	      {
		module_root_search_string = top_level_directories[z];
		i = h.indexOf(module_root_search_string);
	      }
	    if (i < 0)
		module_root_string =
		  h.substring(0, h.lastIndexOf("/") + 1) + file_module_root;
	    else
		module_root_string = h.substring(0, i) + file_module_root;
	  }
      }
    return (module_root_string);
  }


function getStyle() {
	// OS
	if (navigator.userAgent.indexOf("Win") >= 0) {
		
		// find which browser
		if (navigator.appName.indexOf("Netscape") >= 0) {
				
			// find which version
			if (navigator.appVersion.indexOf("3.") >=0) {
					whatStyle= "Front_Win_Net_4";
			}
			else if (navigator.appVersion.indexOf("4.") >=0) {
					whatStyle= "Front_Win_Net_4";
			}
			else if (navigator.appVersion.indexOf("5.") >=0) {
					whatStyle= "Front_Win_Net_4";
			}
		}
					
		else if (navigator.appName.indexOf("Microsoft") >= 0) {
					
			// find which version
			if (navigator.appVersion.indexOf("3.") >=0) {
					whatStyle= "Front_Win_Ie_5";
			}
			else if (navigator.appVersion.indexOf("4.") >=0) {
					whatStyle= "Front_Win_Ie_5";
			}
			else if (navigator.appVersion.indexOf("5.") >=0) {
					whatStyle= "Front_Win_Ie_5";
			}
		}
	}		
	else if (navigator.appVersion.indexOf("Mac") >= 0) {
		
		// find which browser
		if (navigator.appName.indexOf("Netscape") >= 0) {
				
			// find which version
			if (navigator.appVersion.indexOf("3.") >=0) {
				whatStyle= "Front_Mac_Net_4";
			}
			else if (navigator.appVersion.indexOf("4.") >=0) {
				whatStyle= "Front_Mac_Net_4";
			}
			else if (navigator.appVersion.indexOf("5.") >=0) {
				whatStyle= "Front_Mac_Net_4";
			}
		}
		else if (navigator.appName.indexOf("Microsoft") >= 0) {
					
			// find which version
			if (navigator.appVersion.indexOf("3.") >=0) {
				whatStyle= "Front_Mac_Ie_4";
			}
			if (navigator.appVersion.indexOf("4.") >=0) {
				whatStyle= "Front_Mac_Ie_4";
			}
			if (navigator.appVersion.indexOf("5.") >=0) {
				whatStyle= "Front_Mac_Ie_4";
			}
		}
	}
								
	else if ((navigator.appVersion.indexOf("AIX")>=0)||
		   (navigator.appVersion.indexOf("IRIX")>=0)||
		   (navigator.appVersion.indexOf("irix")>=0)||
		   (navigator.appVersion.indexOf("hpux")>=0)||
		   (navigator.appVersion.indexOf("linux")>=0)||
		   (navigator.appVersion.indexOf("bsd")>=0)||
		   (navigator.appVersion.indexOf("freebsd")>=0)||
		   (navigator.appVersion.indexOf("sco")>=0)||
		   (navigator.appVersion.indexOf("unixware")>=0)||
		   (navigator.appVersion.indexOf("mpras")>=0)||
		   (navigator.appVersion.indexOf("reliant")>=0)||
		   (navigator.appVersion.indexOf("dec")>=0)||
		   (navigator.appVersion.indexOf("sinix")>=0)||
		   (navigator.appVersion.indexOf("Sun")>= 0)) 

		{
		
		// find which browser
		if (navigator.appName.indexOf("Netscape") >= 0) {
			// find which version
			if (navigator.appVersion.indexOf("3.") >=0) {
				whatStyle= "Unix_Net_4";
			}
			else if (navigator.appVersion.indexOf("4.") >=0)			  {
			   whatStyle= "Unix_Net_4";
			   if (navigator.appVersion.indexOf("Sun")>= 0)			     {			       whatStyle = "Unix_Sun_Net_4";			     }			}
			else if (navigator.appVersion.indexOf("5.") >=0) {
				whatStyle= "Unix_Net_4";
			}
		}
		else if (navigator.appName.indexOf("Microsoft") >= 0) {
			// find which version
			if (navigator.appVersion.indexOf("3.") >=0) {
				whatStyle= "Unix_Ie_4";
			}
			else if (navigator.appVersion.indexOf("4.") >=0) {
				whatStyle= "Unix_Ie_4";
			}
			else if (navigator.appVersion.indexOf("5.") >=0) {
				whatStyle= "Unix_Ie_4";
			}
		}
	}

}

getStyle();	

document.write('<LINK REL=StyleSheet HREF="' + module_root() +
     	       'shared/frontstyles/' + whatStyle +
               '.css" TYPE="text/css">');



// -----------------

// (3a) Pop Up Windows 

function popUpAnswer(whichHTMLfile) {
	remoteWin = window.open( whichHTMLfile, "popUpAnswer", "width=320 ,height=240 ,resizable=yes,status=no,menubar=yes,scrollbars=yes" );
    remoteWin.focus()
}

// (3b) Pop Up Windows 
function popUpAnswersize(whichHTMLfile, w, h) {
	var params = 'width='+w+' ,height='+h+' ,resizable=yes,status=no,menubar=yes,scrollbars=yes';
	remoteWin = window.open( whichHTMLfile, "popUpAnswer", params );
    remoteWin.focus()

}
// End Pop Up Windows


// 4 Copyright Notice

	function fullCopyrightNotice() {
		document.writeln( 
	 		 "Copyright &copy; " 
			+ "<a href=\"http://www.rpi.edu/\">Rensselaer Polytechnic Institute</a>. "
			+ "All Rights Reserved.<br>" );
	}


// 5 Developers' Connection Footer

// function devFooter() {

// 	document.writeln( "<P CLASS=\"normal\" ALIGN=\"center\">" );
// 	document.writeln( "<STRONG>Developers' Connection: </STRONG>" );
// 	document.writeln( "home | " );
// 	document.writeln( "for content developers | " );
// 	document.writeln( "for programmers | " );
// 	document.writeln( "for instructors" );
// 	document.writeln( "</P>" );

// }