/*@cc_on 
var doc = document;
eval('var document = doc');
@*/

var ua = navigator.userAgent;
var na = navigator.appName;
var ve = navigator.appVersion;

var Win = (ua.indexOf ("Win") != -1);
var Mac = (ua.indexOf ("Mac") != -1);
var Explorer = (na.indexOf ("Explorer") != -1);
var Netscape= (na.indexOf ("Netscape") != -1);
var Opera = (ua.indexOf ("Opera") != -1);
var Safari = (ua.indexOf ("Safari") != -1);

if (Explorer) {
    if (ua.indexOf ("MSIE 3") != -1) { var Version = "3"; }
    else if (ua.indexOf ("MSIE 4") != -1) { var Version = "4"; }
    else if (ua.indexOf ("MSIE 5") != -1) { var Version = "5"; }
    else if (ua.indexOf ("MSIE 6") != -1) { var Version = "6"; }
    else { var Version = "7"; }
} else {
    var Version = ve.charAt(0);
}

if (Safari) { type = "Gecko"; }
else if (Mac && Opera && Version == "5") { type = "error"; }
else if (Opera) { type = "Gecko"; }
else if (Win && Explorer && Version == "7") { type = "IE7"; }
else if (Win && Explorer && Version == "6") { type = "IE6"; }
else if (Win && Explorer && Version != "6") { type = "error"; }
else if (Win && Netscape && Version == "4") { type = "error"; }
else if (Mac && Explorer && Version != "5" && Version != "6") { type = "error"; }
else if (Mac && Explorer && Version == "5") { type = "error"; }
else if (Mac && Explorer && Version == "6") { type = "error"; }
else if (Mac && Netscape && Version == "5") { type = "Gecko"; }
else if (Mac && Netscape && Version == "4") { type = "error"; }
else { type = "Gecko" }

path = "";
pn = window.location.pathname;
pn = pn.substr (1);
pn = pn.split ("/");
p = pn.length - 5;
for (i=0; i<p; i++) {
    path += "../";
}

if (type == "error") { location.href = "/error/" + type + ".html"; }

path += "/shared/css/";

document.write ("<link rel=\"stylesheet\" href=\"" + path + "font_" + type + ".css\" type=\"text/css\" media=\"screen,print\">");


/* Jump Menu */
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/* アーカイブとカテゴリーをプルダウンメニューとして表示 */
function selectUrl(sel){
    if(sel.options[sel.selectedIndex].value){
        location.href = sel.options[sel.selectedIndex].value;
    }
}
 
function addSelectForMonthly(data){
    var year = data.substring(0,4);
    var month = data.substring(12,14);
    var nodes = document.getElementById('monthlylist').getElementsByTagName("option");
    for (var i = 0; i < nodes.length; i++) {
        var selectYear = nodes[i].innerHTML.substring(0,4);
        var selectMonth = nodes[i].innerHTML.substring(5,7);
        if(year == selectYear && month == selectMonth){
            nodes[i].selected = true;
        }
    }
}
 
function addSelectForCategory(data){
    var nodes = document.getElementById('categorylist').getElementsByTagName("option");
    for (var i = 0; i < nodes.length; i++) {
        if(nodes[i].innerHTML.indexOf(data) == 0){
            nodes[i].selected = true;
        }
    }
}

/* Google Analytics */
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-51765-2']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
  })();
