/*==============================================================================
 *
 * PACKAGE NAME  :#NA
 * FILE NAME     :judgeUA.js
 * REVISION      :1.0
 * SUMMARY       :UserAgent定義Javascript
 * DESCRIPTION   :クライアントのUserAgentを判定し、サイト製作ポリシーに叶う定義をします。
 *               :定義はcssSwitcherでCSSファイルの割り振りに使用されます。
 * AUTHOR:       :FJ
 * CREATED       :2010/04/01
 * UPDATED       :
 * REMARK        :
 *
 * Copyright(c) ChaseSystems Co.,Ltd.
 =============================================================================*/
/** 
 * 変数
 */
// UserAgent定義用変数宣言
var ua;

// navigatorオブジェクトのuserAgentプロパティの全文字列を小文字化
// ※コーディングの記述ミスを低減する為の準備処理
var agt = navigator.userAgent.toLowerCase();

// UserAgentのメジャーバージョンとマイナーバージョンの取得
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);



// UserAgent種別定義 (以下をNETSCAPE NAVIGATERとします)
this.nav = ((agt.indexOf("mozilla") != -1) && (agt.indexOf("spoofer") == -1) &&
            (agt.indexOf("compatible") == -1) && (agt.indexOf("opera") == -1) &&
            (agt.indexOf("webtv") == -1) && (agt.indexOf("hotjava") == -1));

// NETSCAPE NAVIGATERバージョン定義
this.nav2    = (this.nav && (this.major == 2));
this.nav3    = (this.nav && (this.major == 3));
this.nav4    = (this.nav && (this.major == 4));
this.nav4up  = (this.nav && (this.major >= 4));
this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) ||
               (agt.indexOf("; nav") != -1)) );
this.nav6    = (this.nav && (this.major == 5));
this.nav6up  = (this.nav && (this.major >= 5));
this.gecko   = (agt.indexOf('gecko') != -1);



// UserAgent種別定義 (以下をINTERNET EXPLORERとします)
this.ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

// INTERNET EXPLORERバージョン定義
this.ie3     = (this.ie && (this.major < 4));
this.ie4     = (this.ie && (this.major == 4) && (agt.indexOf("msie 4") != -1));
this.ie4up   = (this.ie && (this.major >= 4));
this.ie5     = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0") != -1) ||
               (agt.indexOf("msie 5.") != -1 && agt.indexOf("mac") != -1));
this.ie5_5   = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") != -1));
this.ie5up   = (this.ie &&
               !this.ie3 && !this.ie4) ||
               (this.ie5 || this.ie5_5);
this.ie5_5up = (this.ie &&
               !this.ie3 && !this.ie4 && !this.ie5) ||
                this.ie5_5;
this.ie6     = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.") != -1));
this.ie6up   = (this.ie &&
               !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5) ||
                this.ie6;
this.ie7     = (this.ie && (this.major == 4) && (agt.indexOf("msie 7.") != -1));
this.ie7up   = (this.ie &&
               !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5 && !this.ie6) ||
                this.ie7;
this.ie8     = (this.ie && (this.major == 4) && (agt.indexOf("msie 8.") != -1));
this.ie8up   = (this.ie &&
               !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5 && !this.ie6 && !this.ie7) ||
                this.ie8;



// UserAgent種別定義 (以下をOPERAとします)
this.opera = (agt.indexOf("opera") != -1);

// OPERAバージョン定義
this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
this.opera5up = (this.opera &&
                !this.opera2 && !this.opera3 && !this.opera4) ||
                 this.opera5;
this.opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
this.opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1);
this.opera8 = (agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1);
this.opera9 = (agt.indexOf("opera 9") != -1 || agt.indexOf("opera/9") != -1);
this.opera9up = (this.opera &&
                !this.opera2 && !this.opera3 && !this.opera4 &&
                !this.opera5 && !this.opera6 && !this.opera7 && !this.opera8) ||
                 this.opera9;



// UserAgent種別定義 (以下をAOLとします)
this.aol   = (agt.indexOf("aol") != -1);

// AOLバージョン定義
this.aol3  = (this.aol && this.ie3);
this.aol4  = (this.aol && this.ie4);
this.aol5  = (agt.indexOf("aol 5") != -1);
this.aol6  = (agt.indexOf("aol 6") != -1);



// UserAgent種別定義 (以下をWEBTVとします)
this.webtv = (agt.indexOf("webtv") != -1);



// UserAgent種別定義 (以下をTVNavigatorとします)
this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 



// UserAgent種別定義 (以下をAOLTVとします)
this.AOLTV = this.TVNavigator;



// UserAgent種別定義 (以下をhotjavaとします)
this.hotjava = (agt.indexOf("hotjava") != -1);

// hotjavaバージョン定義
this.hotjava3 = (this.hotjava && (this.major == 3));
this.hotjava3up = (this.hotjava && (this.major >= 3));



/** 
 * UserAgent定義
 * ※ウェブサイト製作ポリシーにより、以下のカテゴライズとします。
 */
// NETSCAPE NAVIGATER (Version.6以上)
if(this.nav && this.nav6up){
    ua = "NS6";   
}
// NETSCAPE NAVIGATER (Version.6未満)
else if(this.nav && !this.nav6up){
    ua = "NS6_under";  
}

// INTERNET EXPLORER (Version.8以上)
else if(this.ie && this.ie8up){
    ua = "MSIE8";   
}

// INTERNET EXPLORER (Version.7)
else if(this.ie && this.ie7){
    ua = "MSIE7";
}

// INTERNET EXPLORER (Version.7未満)
else if(this.ie && !this.ie7up){
    ua = "MSIE6_under";
}

// OPERA (Version.5以上)
else if(this.opera && this.opera9up){
    ua = "NS6";
}

// OPERA (Version.5未満)
else if(this.opera && !this.opera9up){
    ua = "NS6_under";
}

// 上記に当てはまらないUserAgent    
else{
    ua = "ETC";
}

