function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") +
        (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

//.toGMTString()

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    if (f.author != undefined)
       setCookie('mtcmtauth', f.author.value, now, '/', '', '');
    if (f.email != undefined)
       setCookie('mtcmtmail', f.email.value, now, '/', '', '');
    if (f.url != undefined)
       setCookie('mtcmthome', f.url.value, now, '/', '', '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '/', '');
    deleteCookie('mtcmthome', '/', '');
    deleteCookie('mtcmtauth', '/', '');
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}

function hideDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function showDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}

var commenter_name;

function individualArchivesOnLoad(commenter_name) {


 // comments are allowed but not required
    if (commenter_name) {
        hideDocumentElement('name-email');
    } else {
        showDocumentElement('name-email');
    }



var mtcmthome;
var mtcmtauth;

    if (document.comments_form) {
        if (!commenter_name && (document.comments_form.email != undefined) &&
            (mtcmtmail = getCookie("mtcmtmail")))
            document.comments_form.email.value = mtcmtmail;
        if (!commenter_name && (document.comments_form.author != undefined) &&
            (mtcmtauth = getCookie("mtcmtauth")))
            document.comments_form.author.value = mtcmtauth;
        if (document.comments_form.url != undefined && 
            (mtcmthome = getCookie("mtcmthome")))
            document.comments_form.url.value = mtcmthome;
        if (document.comments_form["bakecookie"]) {
            if (mtcmtauth || mtcmthome) {
                document.comments_form.bakecookie.checked = true;
            } else {
                document.comments_form.bakecookie.checked = false;
            }
        }
    }
}

function writeTypeKeyGreeting(commenter_name, entry_id) {
    if (commenter_name) {
        document.write('<p>'+commenter_name + 'さん、サイン・インを受け付けました。 '+'(<a href="http://okakick.com/mt-sys/com.cgi?__mode=handle_sign_in&amp;static=1&amp;logout=1&entry_id=' + entry_id + '">サイン・アウトする</a>)</p>');
    } else {
        document.write('<p>TypeKey IDに '+
          '<a href="https://www.typekey.com/t/typekey/login?&amp;lang=ja&amp;t=Jj8dB0gL8zTw3Q4t0Y4d&amp;v=1.1&amp;_return=http://okakick.com/mt-sys/com.cgi%3f__mode=handle_sign_in%26static=1%26entry_id=' + entry_id + '">サイン・イン</a> '+
          'してコメントできます（TypeKeyの表示名に日本語が含まれる場合、エラーとなりサインインできません）。<br />また、サイン・インしなくても、コメントは可能です。</p>');

    }


	var uri = new String(document.location);
	var sta = uri.lastIndexOf("/");
	var aid = uri.substring(sta+1,uri.length);
	if(aid.match(/\-22$/)){
		var aobj = document.getElementsByTagName("a");
		for (var i = 0; i < aobj.length ; i++){
			aobj[i].href = aobj[i].href.replace('wwwbayashinet-22',aid);
		}
	}

}

if ('okakick.com' != 'www.bayashi.net') {
    document.write('<script src="http://okakick.com/mt-sys/com.cgi?__mode=cmtr_name_js"></script>');
} else {
    commenter_name = getCookie('commenter_name');
}






function putSBMnum (url_this) {
	document.write('<a href="http://b.hatena.ne.jp/entry/' + url_this + '" target="_blank"><img src="http://b.hatena.ne.jp/entry/image/' + url_this + '" border="0" alt="" align="bottom" /></a>');
}

function putSBM (title_this, url_this) {
return;
	// Yahoo!ブックマーク
	document.write(' <a href="http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?t=' + encodeURIComponent(title_this) + '&u=' + encodeURIComponent(url_this) + '&opener=bm&ei=UTF-8" target="_blank"><img src="http://i.yimg.jp/images/sicons/ybm16.gif" width="16" height="16" alt="' + title_this + 'をYahoo!ブックマークに登録" border="0" align="bottom" /></a><a href="http://bookmarks.yahoo.co.jp/url?url=' + encodeURIComponent(url_this) + '" target="_blank"><img src="http://num.bookmarks.yahoo.co.jp/image/small/' + url_this + '" border="0" alt="' + title_this + 'のYahoo!ブックマーク登録数" align="bottom" /></a>');
	// Google Bookmarks
	document.write(' <a href="http://www.google.com/bookmarks/mark?op=edit&bkmk=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '" target="_blank"><img src="http://www.google.co.jp/favicon.ico" alt="' + title_this + 'をGoogle Bookmarksに追加" width="16" height="16" border="0" align="bottom" /></a>');
	// はてブ
	document.write(' <a href="http://b.hatena.ne.jp/append?' + encodeURIComponent(url_this) + '"><img src="http://b.hatena.ne.jp/images/append.gif" width="16" height="12" border="0" alt="' + title_this + 'をはてなブックマーク に追加" align="bottom" /></a><a href="http://b.hatena.ne.jp/entry/' + url_this + '" target="_blank"><img src="http://b.hatena.ne.jp/entry/image/' + url_this + '" border="0" alt="' + title_this + 'のはてブ数" align="bottom" /></a>');
	// livedoorクリップ
	document.write(' <a href="http://clip.livedoor.com/clip/add?link=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '"><img src="http://parts.blog.livedoor.jp/img/cmn/clip_16_12_b.gif" width="16" height="12" alt="' + title_this + 'をlivedoorクリップに追加" border="0" align="bottom" /></a><a href="http://clip.livedoor.com/page/' + url_this + '" target="_blank"><img src="http://image.clip.livedoor.com/counter/' + url_this + '" alt="' + title_this + 'をlivedoorクリップに追加" border="0" align="bottom" /></a>');
	// del.icio.us
	document.write(' <a href="http://del.icio.us/post?url=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '"><img src="http://images.del.icio.us/static/img/delicious.gif" width="12" height="12" border="0" alt="' + title_this + 'を del.icio.us に追加" align="bottom" /></a>');
	// Pookmark
	document.write(' <a href="http://pookmark.jp/post?url=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '"><img src="http://pookmark.jp/images/add/add.gif" alt="' + title_this + 'をPookmark に追加" border="0" align="bottom" /></a>');
	// FC2
	document.write(' <a href="http://bookmark.fc2.com/user/post?url=' + encodeURIComponent(url_this) + '&title=' + encodeURIComponent(title_this) + '" target="_blank"><img src="http://bayashi.daa.jp/img/fc2.gif" alt="' + title_this + 'をFC2 Bookmarkに追加" width="12" height="12" border="0" align="bottom" /></a><a href="http://bookmark.fc2.com/search/detail?url=' + encodeURIComponent(title_this) + '" target="_blank"><img src="http://bookmark.fc2.com/image/users/' + url_this + '" border="0" align="bottom" /></a>');
	// buzzurl
	document.write(' <a href="http://buzzurl.jp/config/add/confirm?url=' + encodeURIComponent(url_this) + '" target="_blank"><img src="http://buzzurl.jp/static/image/api/icon/add_icon_mini_08.gif" alt="' + title_this + 'をBuzzurlに追加" width="12" height="12" border="0" align="bottom" /></a><a href="http://buzzurl.jp/entry/' + url_this + '" target="_blank"><img src="http://api.buzzurl.jp/api/counter/' + url_this + '" border="0" alt="' + title_this + 'のBuzzurl登録数" align="bottom" /></a>');
	// twitter
	document.write(' <a href="http://twitter.com/home?status=' + encodeURIComponent(title_this) + '+' + encodeURIComponent(url_this) + '" target="_blank"><img src="http://bayashi.daa.jp/img/twitter.gif" alt="' + title_this + 'をつぶやく" width="12" height="12" border="0" align="bottom" /></a>');
}

function putCategoryRSS (title_this, url_this) {
	var u = url_this.replace(".html", ".xml");
	document.write(' <a href="'+u+'" target="_blank"><img src="http://www.bayashi.net/images/feed.gif" width="12" height="12" border="0" title="'+title_this+'" valign="bottom" /></a>');
}

function insertTxt(str) {
  if (!str) {
  	return;
  } else {
  	document.google_search.q.value = str;
  }
}

function getSel() {
  var d = document;
  if (d.selection) {
    return d.selection.createRange().text;
  } else if (d.getSelection) {
    return d.getSelection();
  } else if (window.getSelection) {
    return window.getSelection();
  } else {
  	return;
  }
}

