/***************************************************
check user
***************************************************/

function UserAgent() {
  n = navigator;
  this.name = n.appName;
  this.mozilla_version = n.appVersion.substring( 0, n.appVersion.indexOf( ' ' ) );
  this.isIE = ( n.appName == 'Microsoft Internet Explorer' );
  this.isNN = ( n.appName == 'Netscape' );
  if ( this.isIE ) {
    s_pos = n.appVersion.indexOf( 'MSIE' ) + 5;
    e_pos = n.appVersion.indexOf( ';', s_pos );
    this.version = n.appVersion.substring( s_pos, e_pos );
  } else if ( this.isNN ) {
    this.version = this.mozilla_version;
    this.isN4 = this.mozilla_version.substring( 0, 1 ) == '4';
    this.isN6 = this.mozilla_version.substring( 0, 1 ) >= '5';
  }
  if ( n.platform ) {
    this.isMac   = ( n.platform.substring( 0, 3 ) == 'Mac' );
    this.isWin   = ( n.platform.substring( 0, 3 ) == 'Win' );
    this.isLinux = ( n.platform.substring( 0, 5 ) == 'Linux' );
    if ( this.isMac ) {
      this.platform = 'Mac';
    } else if ( this.isWin ) {
      this.platform = 'Windows';
    } else if ( this.isLinux ) {
      this.platform = 'Linux';
    } else {
      this.platform = n.platform;
    }
  } else {
    this.isMac   = ( n.appVersion.indexOf( 'Mac' )   != -1 );
    this.isWin   = ( n.appVersion.indexOf( 'Win' )   != -1 );
    this.isLinux = ( n.appVersion.indexOf( 'Linux' ) != -1 );
    if ( this.isMac ) {
      this.platform = 'Mac';
    } else if ( this.isWin ) {
      this.platform = 'Windows';
    } else if ( this.isLinux ) {
      this.platform = 'Linux';
    } else {
      this.platform = 'unknown';
    }
  }
}

var __AGENT__ = new UserAgent();


/***************************************************
select browser
***************************************************/

function css_select ( path, ie_suffix, nc_suffix ) {
  if ( __AGENT__.isMac ) {
    filename = 'mac';
  } else {
    filename = 'win';
  }
  document.write( '<link rel="stylesheet" href="' + path + filename + ( __AGENT__.isIE ? ie_suffix : nc_suffix ) + '.css" type="text/css">' );
  document.write( '<link rel="stylesheet" href="' + path + 'common.css" type="text/css">' );
}
