var style;
var stylesheets = new Array();
regStyleSheet("./css/style01.css", "Win IE6/5.5/5.0, Win Opera7");
regStyleSheet("./css/style02.css", "Win Netscape4.7 later");
regStyleSheet("./css/style03.css", "Win Gecko, Mac IE5.1/5.0");
regStyleSheet("./css/style04.css", "Mac Gecko, Mac Safari");
regStyleSheet("./css/style05.css", "Win Opera6");
regStyleSheet("./css/style06.css", "Mac IE5.2, Mac Netscape4.7 later");
regStyleSheet("./css/style07.css", "Win/Mac Netscape 4.xiolder than 4.7j");
regStyleSheet("./css/style08.css", "Mac iCab2.9.1");

var UA     = navigator.userAgent;
var Mac    = navigator.appVersion.indexOf('Mac',0) != -1;
var Win    = navigator.appVersion.indexOf('Win',0) != -1;
var IE     = navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1;
var NN     = navigator.appName.indexOf("Netscape",0) != -1;
var NN4    = document.layers;
var Moz    = UA.indexOf("Gecko/") != -1;
var Opera  = window.opera;
var Safari = UA.indexOf("Safari") != -1;

// style01.css Win IE6/5.5/5.0, Win Opera7;
if (Win) {
 if (Opera) {
  if (UA.indexOf("Opera 7") != -1 || UA.indexOf("Opera/7") != -1) {
   style = stylesheets[0];
  } else if (UA.indexOf("Opera 6") != -1 || UA.indexOf("Opera/6") != -1){
   style = stylesheets[4];
  }
 } else if ((Win && UA.indexOf('MSIE 5.',0) != -1) || (Win && UA.indexOf('MSIE 6.',0) != -1)) {
  style = stylesheets[0];
 }
}

// style02.css Win Netscape4.7 later
// style06.css Mac IE5.2, Mac Netscape4.7 later
if (Win && NN4 && parseFloat(navigator.appVersion) >= 4.7) {
 style = stylesheets[1];
}
if ((Mac && NN4 && parseFloat(navigator.appVersion) >= 4.7) || (Mac && UA.indexOf('MSIE 5.2',0) != -1)) {  style = stylesheets[5];
}

// style07.css Win/Mac Netscape 4.xiolder than 4.7j
if (NN4 && parseFloat(navigator.appVersion) < 4.7) {
 style = stylesheets[6];
}

// style03.css Win Gecko, Mac IE5.1/5.0
if ((Mac && UA.indexOf('MSIE 5.1',0) != -1) || (Mac && UA.indexOf('MSIE 5.0',0) != -1) || Win && Moz) {
 style = stylesheets[2];
}

// style04.css Mac Gecko, Mac Safari
if ((Mac && Moz) || Safari) {
 style = stylesheets[3];
}

// style08.css Mac iCab2.9.1
if ((UA.indexOf("iCab 2.9.1") != -1)) {
 style = stylesheets[7];
}
if(style){
	if (style.href) addStyleSheet(style.href);
}

function regStyleSheet(src, note) {
 var index = stylesheets.length;
 stylesheets[index] = new Array();
 stylesheets[index].href = src;
 stylesheets[index].note = note;
}

function addStyleSheet(src) {
 if (document.getElementsByTagName && document.createElement && !Opera && !(UA.indexOf("Netscape6/6.0") != -1) && !(Mac && UA.indexOf('MSIE 5.0',0) != -1)) {
  var newLink = document.createElement('link');
  var head = document.getElementsByTagName('head').item(0);
  newLink.rel = "stylesheet";
  newLink.type = "text/css";
  newLink.href = src;
  head.appendChild(newLink);
 } else {
  document.open();
  document.write('<link rel="stylesheet" href="' + src + '" type="text\/css">\n');
  document.close();
 }
}


