// Make link to cascading stylesheets according to browser/OS.
//  - They are *cascading*, i.e., we give the main stylesheet first,
//     (defaulting to the most common, MSIE browsers)
//      and then provide stylesheet with diffs for other browsers/OSs.
//  - Write the stylesheet link directly into the header of the html page.
//  - Write the stylesheet link according to the level of subdirectory
//     is the calling page, (rather than leading slash '/lib/stylsheet.css')
//     so that this can be used on a standalone machine without webserver.
//  15 jul 2003 - modified for friendsoftibet.
//   5 jun 2003 - wrote.

  // All our stylesheets begin with this name:
  var cssname = 'fot';

  // Get the location of the calling page,
  //  and make 'updots' accordingly to how far down we
  //  are in subdirectories.
  var a_pathparts = location.href.split('/');

  var updots = '';

// alert(a_pathparts.length);

  if (a_pathparts.length == '4') {
    updots = '../';
  } else if (a_pathparts.length == '5') {
    updots = '../';
  } else if (a_pathparts.length == '6') {
    updots = '../../';
  } else if (a_pathparts.length == '7') {
    updots = '../../../';
  }

  // Give the default stylsheet:
  stylesheet = cssname + '.css';
  document.write('<link rel="stylesheet" href="' + updots + 'lib/' +
        stylesheet +
        '" type="text/css">'
        );

  // Now determine OS and browser, and give alternate(s):
  var name = navigator.appName;
  var version = navigator.appVersion;
  var agent = navigator.userAgent;

  if ( navigator.appVersion.indexOf("X11") > 0 ) {
    stylesheet = cssname + '-linux.css';

  document.write('<link rel="stylesheet" href="' + updots + '/lib/' +
        stylesheet +
        '" type="text/css">'
        );
  }
  if ( navigator.appVersion.indexOf("Mac") > 0 ) {
    stylesheet = cssname + '-mac.css';
  document.write('<link rel="stylesheet" href="' + updots + 'lib/' +
        stylesheet +
        '" type="text/css">'
        );
  }

  // Special stylesheet for admin section:
  if ( location.href.indexOf("admin") > 0 ) {
      cssname = cssname + '_admin';
	  document.write('<link rel="stylesheet" href="' + updots + 'lib/' +
	        stylesheet +
	        '" type="text/css">'
	        );
	  if ( navigator.appVersion.indexOf("X11") > 0 ) {
	    stylesheet = cssname + '-linux.css';
	  document.write('<link rel="stylesheet" href="' + updots + '/lib/' +
	        stylesheet +
	        '" type="text/css">'
	        );
	  }
	  if ( navigator.appVersion.indexOf("Mac") > 0 ) {
	    stylesheet = cssname + '-mac.css';
	  document.write('<link rel="stylesheet" href="' + updots + 'lib/' +
	        stylesheet +
	        '" type="text/css">'
	        );
	  }
  }

// -- EOF 
