document.write('<script type="text/javascript" src="/.shared-cocolog/js/comment_suspend.js"></script>');

function suspend(course) {
    try {
        var pattern = new RegExp("ax([0-9]+)\.\a\.[a-zA-Z]+-[a-zA-Z]+\.com");
        var array = pattern.exec(CCAX_SV);
        if (course == which_plan(array[1])) {
            comment_maintenance_mode();
            trackback_maintenance_mode();
        }
    } catch(e) {
        setTimeout('suspend("' + course + '")', 10);
    }
}

function which_plan(ax_server_id) {
    var nifty_plan_list = new Array();
    nifty_plan_list[0] = 'none';
    nifty_plan_list[1] = 'nifty';
    nifty_plan_list[2] = 'nifty';
    nifty_plan_list[3] = 'nifty';
    nifty_plan_list[4] = 'nifty';
    nifty_plan_list[5] = 'nifty';
    nifty_plan_list[6] = 'nifty';
    nifty_plan_list[7] = 'nifty';
    nifty_plan_list[8] = 'nifty';
    nifty_plan_list[9] = 'nifty';
    nifty_plan_list[10] = 'nifty';
    nifty_plan_list[11] = 'nifty';
    nifty_plan_list[12] = 'nifty';
    nifty_plan_list[13] = 'pleasy';
    nifty_plan_list[14] = 'pleasy';
    nifty_plan_list[15] = 'pleasy';
    nifty_plan_list[16] = 'pleasy';
    nifty_plan_list[17] = 'pleasy';
    nifty_plan_list[18] = 'pleasy';
    nifty_plan_list[19] = 'pleasy';
    nifty_plan_list[20] = 'pleasy';
    nifty_plan_list[21] = 'pleasy';
    nifty_plan_list[22] = 'pleasy';

    return nifty_plan_list[ax_server_id];
}

function comment_maintenance_mode() {
    var comment_form_data = document.getElementById('comment-form-data');
    if (comment_form_data != null) {
        comment_form_data.innerHTML = ' メンテナンス中のためコメントをご利用いただくことができません。メンテナンスについては<a href="http://info.cocolog-nifty.com/">お知らせココログ</a>をご覧下さい。';
        return;
    }
    var comment_form = document.getElementById('comment-form');
    if (comment_form != null) {
        comment_form.innerHTML = 'メンテナンス中のためコメントをご利用いただくことができません。メンテナンスについては<a href="http://info.cocolog-nifty.com/">お知らせココログ</a>をご覧下さい。';
        return;
    }
    setTimeout("comment_maintenance_mode()", 10);
}

function trackback_maintenance_mode() {
    var p_tags = document.getElementsByTagName('p');
    if (p_tags == null) {
        setTimeout("trackback_maintenance_mode", 10);
    }
    for (var i = 0; i < p_tags.length; i++) {
        if (p_tags[i].className == 'trackback-url') {
            p_tags[i].innerHTML = ' メンテナンス中のためトラックバックをご利用いただくことができません。メンテナンスについては<a href="http://info.cocolog-nifty.com/">お知らせココログ</a>をご覧下さい。';
            return;
        }
    }
    var div_tags = document.getElementsByTagName('div');
    if (div_tags == null) {
        setTimeout("trackback_maintenance_mode", 10);
    }
    for (var i = 0; i < div_tags.length; i++) {
        if (div_tags[i].className == 'trackbacks-info') {
            div_tags[i].getElementsByTagName('p')[0].innerHTML = ' メンテナンス中のためトラックバックをご利用いただくことができません。メンテナンスについては<a href="http://info.cocolog-nifty.com/">お知らせココログ</a>をご覧下さい。';
            return;
        }
    }
    setTimeout("trackback_maintenance_mode()", 10);
}

var hasChanged = 0;
var hostName = '.cocolog-nifty.com';

function setCookie (name, value, expires) {
    document.cookie = name + '=' + escape(value) + '; expires=' + expires.toGMTString() + '; domain=' + hostName + '; path=/';
}

function getCookie (name) {
    var key = name + '=';
    var c = document.cookie;
    var i = c.indexOf(key);
    if (i < 0) return '';
    var j = c.indexOf(';', i + key.length);
    if (j < 0) j = c.length;
    return unescape(c.substring(i + key.length, j));
}

function deleteCookie (name) {
    if (getCookie(name))
        setCookie(name, '', new Date(70, 0, 1, 0, 0, 1));
}

function rememberMe (f) {
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    if( f.author )
    	setCookie('typepadauthor', f.author.value, now);
    if( f.email )
    	setCookie('typepademail', f.email.value, now);
    if( f.url )
    	setCookie('typepadurl', f.url.value, now);
}

function forgetMe () {
    deleteCookie('typepadauthor');
    deleteCookie('typepademail');
    deleteCookie('typepadurl');
}

function setFormValues (f) {
    var val = getCookie("typepadauthor");
    if( f.author && !f.author.value && val)
    	f.author.value = val;
    val = getCookie("typepademail");
    if( f.email && !f.email.value && val)
    	f.email.value = val;
    val = getCookie("typepadurl");
    if( f.url && !f.url.value && val)
    	f.url.value = val;
}

function unsetFormValues (f) {
    f.author.value = '';
    f.email.value = '';
    f.url.value = '';
}

function handleSubmit (f) {
    if (f.bakecookie && f.bakecookie.checked)
        rememberMe(f);
    else
        forgetMe();
}

function handleSubmitEvent( evt )
{
	evt = evt || event;
	var f = document.getElementById( "comment-form" ) ||
		document.comment_form || document.comments_form;
	return handleSubmit( f );
}

function handleCheck (e) {
    if (hasChanged) return;
    if (e.checked)
        setFormValues(e.form);
    else
        unsetFormValues(e.form);
}

function handleChange (e) {
    hasChanged = 1;
}

function doLoaded () {
	var f = document.getElementById( "comment-form" ) ||
		document.comment_form || document.comments_form;
    if( !f )
   		return;
   	f.onsubmit = handleSubmitEvent;
    setFormValues( f );
	if( f.author && f.author.value && f.bakecookie )
		f.bakecookie.checked = 1;
}
onload = doLoaded;

var theForm;
var requestSubmitted = false;
function disableButton (e) {
    if (!requestSubmitted) {
        e.disabled = true;
        theForm = e.form;
        requestSubmitted = true;
        setTimeout('submitIt()', 250);
    } else {
        return false;
    }
}

function submitIt () {
    // make sure we're posting
    if (theForm.bakecookie) handleSubmit(theForm);
    theForm.submit();
    return false;
}


/* comment registration */	
var showHideElements =
{
	"comments-open-login" : "none",
	"comments-open-logout" : "block",
	"comments-open-data" : "none",
	"comments-open-text" : "block",
	"comments-open-footer" : "block"
};

function commentSignIn()
{
	if( typeof commenterName == "undefined" || !commenterName )
		return;
	
	// insert name
	var e = document.getElementById( "commenter-name" );
	if( e )
		e.innerHTML = commenterName;
	
	// hide/show various elements
	for( var i in showHideElements )
	{
		e = document.getElementById( i );
		if( e )
			e.style.display = showHideElements[ i ];
	}
}
