// スタイルシート（ブラウザの判別）
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 { var Version = "6"; }
} else {
    var Version = ve.charAt(0);
}

if (Safari) { type = "mac_nn6"; }
else if (Mac && Opera && Version == "5") { type = "error"; }
else if (Opera) { type = "pixel"; }
else if (Win && Explorer && Version != "6") { type = "error"; }
else if (Win && Explorer && Version == "6") { type = "key_tra"; }
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 = "pixel"; }
else if (Mac && Explorer && Version == "6") { type = "pixel"; }
else if (Mac && Netscape && Version == "5") { type = "mac_nn6"; }
else if (Mac && Netscape && Version == "4") { type = "error"; }
else { type = "pixel" }

path = "";
pn = window.location.pathname;
pn = pn.substr (1);
pn = pn.split ("/");
p = pn.length - 3; // ドメインから下の階層数+1
for (i=0; i<p; i++) {
    path += "../";
}

// 未対応ブラウザ
if (type == "error") { location.href = "http://www.hd-studio.com/" + type + ".html"; }


path += "/shared/css/";

// テキスト関連CSS
document.write ("<link rel=\"stylesheet\" href=\"" + path + type + ".css\" type=\"text/css\" media=\"screen,print\">");


// Archives
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;
        }
    }
}

// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-51765-5']);
_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';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
