/*
gurakoro-doumei blog parts
Copyright (C) 2009 by TADA Tadashi <t@tdtds.jp>
*/

function gurakoroCountdown( today, target ) {
	document.write( '<div class="gurakoro" style="width: 200px; height: 140px; background-image: url(http://sho.tdiary.net/images/gurakoro2009pre.jpg); background-repeat: no-repeat; padding-top: 60px; text-align: center; font-family: mono-spac;" title="Gurakoro Doumei 2009"><span style="font-weight: bold; font-size: 80px; color: #c00;">' );
	document.write( target.getDate() - today.getDate() );
	document.write( '</span></div>' );
}

function gurakoroCounter() {
	var s = 284;

	document.write( '<div class="gurakoro" style="width: 200px; height: 200px; background-image: url(http://sho.tdiary.net/images/gurakoro-back.png); background-repeat: no-repeat;"><a href="http://sho.tdiary.net/20091011.html#p01"><img src="http://sho.tdiary.net/image/gurakoro-top.png" style="border-width: 0px;">' );
	for (i = 0; i < Math.floor( s / 100 ); i++ ) {
		document.write( '<img src="http://sho.tdiary.net/images/gurakoro-100.gif" style="float: left; border-width: 0px;">' );
		}
	for (i = 0; i < Math.floor( s / 10 ) - Math.floor( s / 100 ) * 10; i++ ) {
		document.write( '<img src="http://sho.tdiary.net/images/gurakoro-10.gif" style="float: left; border-width: 0px;">' );
	}
	for (i = 0; i < s % 10; i++ ) {
		document.write( '<img src="http://sho.tdiary.net/images/gurakoro-1.gif" style="float: left; border-width: 0px;">' );
	}
	document.write( '</a></div>' );
}

function gurakoroNull() {
	document.write( '<!-- gurakoro, see you next year. -->' );
}

function gurakoro() {
	var today = new Date();
	var target = new Date( "Oct 11,2009 09:00:00" );
	var end_target = new Date( "Nov 06,2009 00:00:00" );
	if ( today.getTime() < target.getTime() ) {
		gurakoroCountdown( today, target );
	} else if ( today.getTime() > end_target.getTime() ) {
		gurakoroNull();
	} else {
		gurakoroCounter();
	}
}
