// Include API
document.write('<script language="javascript" src="/wwx/javascript/api.js" type="text/javascript"></script>');

// BEGIN BROWSER global / STYLESHEET global

// *************************************************************
//  GLOBAL VARIABLES.
// *************************************************************
// Files and directory structures
var cssDir = "/wwx/stylesheets/";
var winNSCSS = "ns.css";
var winIECSS = "ie.css";
var macCSS = "mac_ns.css";

// *************************************************************
//  CLIENT_SIDE globalER CODE
// *************************************************************
// convert all characters to lowercase to simplify testing 
var agt=navigator.userAgent.toLowerCase(); 

// *** BROWSER VERSION *** 
// Note: On IE5, these return 4, so use is_ie5up to detect IE5. 
var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 

// *** BROWSER type *** 
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
            && (agt.indexOf('webtv')==-1));
var is_nav4up = (is_nav && (is_major >= 4));  
var is_nav6up = (is_nav && (is_major > 4));
var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie3  = (is_ie && (is_major < 4)); 
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) );
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );  
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);  

// *** PLATFORM ***
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);


// *********************************************************************
//  STYLESHEET SELECTION
// *********************************************************************

ChooseBaseStyleSheet();

// Insert print media stylesheet
document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/wwx/print.css\" MEDIA=\"PRINT\">");

// *********************************************************************
//  UTILITY FUNCTIONS
// *********************************************************************

// Function to choose the style sheet for use based on the platform
// and browser version
function ChooseStyleSheet() {
  var fileHead;
  if (arguments.length > 0) {
    fileHead = cssDir + arguments[0];
  } else {
    fileHead = cssDir;
  }
  //window.status =fileHead;
  var styles;
  if (is_win) {
	if ((is_nav) && (is_nav6up)){
      styles = fileHead + winIECSS;
    } else if (is_nav){
      styles = fileHead + winNSCSS;          
	} else {
	  styles = fileHead + winIECSS;
	}
  } else if (((is_mac) && (is_nav)) && (!is_nav6up) ) {
    styles = fileHead + macCSS;
  } else {
  	styles = fileHead + winIECSS;
  }
	var link = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + styles + "\">";
	document.write(link);
	// return true;
}

// Sets the primary stylesheet
function ChooseBaseStyleSheet() {
	ChooseStyleSheet();
}