﻿(function(){
    // div要素内に表示するHTML
    var innerHTML = 'アナログ';
    // fixed.jsのURL
    var fixedURL = 'http://driftwoodtable.web.fc2.com/blog/fixed.js';
    // ie6_analog.cssのURL
    var cssURL = 'http://driftwoodtable.web.fc2.com/blog/ie6_analog.css';
    // 上の余白
    var topMargin = 0;
    // 左の余白
    var rightMargin = 0;
    // 自動消去するまでの時間（秒）
    var timeOut = 0;

    var elmId = 'ie6_analog';
    var ua = navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_ie = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1));
    var is_ie6 = (is_ie && (is_major == 4) && (ua.indexOf("msie 6.")!=-1) );

    if (is_ie6) {
        var head = document.getElementsByTagName('head')[0];
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = fixedURL;
        head.appendChild(script);
        var link = document.createElement('link');
        link.type = 'text/css';
        link.href = cssURL;
        link.rel = 'stylesheet';
        head.appendChild(link);
        window.attachEvent('onload', function() {
            var body = document.getElementsByTagName('body')[0];
            var elm = document.createElement('div');
            elm.id = elmId;
            elm.innerHTML = innerHTML;
            elm.style.position = 'fixed';
            elm.style.top = topMargin + 'px';
            elm.style.right = rightMargin + 'px';
            body.appendChild(elm);
        });
        if (timeOut) {
            var tid = setInterval(function() {
                timeOut--;
                elm = document.getElementById(elmId);
                if (!timeOut && elm) {
                    var body = document.getElementsByTagName('body')[0];
                    body.removeChild(elm);
                    clearInterval(tid);
                }
            }, 1000);
        }
    }
})();
