// *************************************************************
//  GLOBAL VARIABLES.
// *************************************************************
// Files and directory structures
// Si es local
// var cssDir = "/fischertechnik/inc/";
// Si esta liberado
var cssDir = "/nuevoweb/inc/";
var winNSCSS = "global_pc_mozilla.css";
var winIECSS = "global_ie.css";
var macCSS = "global_mac.css";

// *************************************************************
//  CLIENT_SIDE SNIFFER 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 > 6));
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
// *********************************************************************
ChooseStyleSheet();

// *********************************************************************
//  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;
  }
  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)) {
    styles = fileHead + macCSS;
  } else {
  	 styles = fileHead + macCSS;
  }

  var link = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + styles + "\">";
  document.write(link);
  //alert(styles);
  //document.write ("####" + styles + "####");  
  //document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssDir + "print.css\" MEDIA=\"PRINT\">");
  return true;
}
