﻿/*
 *  カウントダウン JavaScript, version 1.01
 *
 *	Copyright (C) 2009 0円のWEB素材屋さん <info@it-work.jp>
 *
 *  CountDown is freely distributable under the terms of an MIT-style license.
 *  For details, see the CountDown web site: http://www.image-seed.com/
 */


//=====================================================
// 変更可能な箇所 - ここから
//=====================================================

// カウントダウンを表示したい場所のID
var countdown_container_id = 'countdown';

// カウントダウン終了時のメッセージ
var end_message = 'カウントダウンセールは終了しました！';

var x_year  = 2013;		// 終了日時（年）
var x_month = 1;		// 終了日時（月）
var x_day   = 1;		// 終了日時（日）
var x_hour  = 0;		// 終了日時（時間）
var x_min   = 0;		// 終了日時（分）

//=====================================================
// 変更可能な箇所 - ここまで
//=====================================================

var x_date  = new Date( x_year, x_month - 1, x_day, x_hour, x_min, 0 );

var countdown_timer_id;

function initialize_countdown()
{
	countdown_timer_id = setInterval( 'execute_countdown()', 10 );
}

function execute_countdown()
{
	now_date = new Date();

	interval_time = x_date.getTime() - now_date.getTime();

	interval_day  = Math.floor( interval_time / ( 1000 * 60 * 60 * 24 ) );
	interval_time = interval_time - ( interval_day * ( 1000 * 60 * 60 * 24 ) );

	interval_hour = Math.floor( interval_time / ( 1000 * 60 * 60 ) );
	interval_time = interval_time - ( interval_hour * ( 1000 * 60 * 60 ) );

	interval_min  = Math.floor( interval_time / ( 1000 * 60 ) );
	interval_time = interval_time - ( interval_min * ( 1000 * 60 ) );

	interval_sec  = Math.floor( interval_time / 1000 );
	interval_time = interval_time - ( interval_sec * ( 1000 ) );

	interval_msec = Math.floor( interval_time / 10 );

	if( interval_min < 10 )
	{
		interval_min = '0' + interval_min;
	}

	if( interval_sec < 10 )
	{
		interval_sec = '0' + interval_sec;
	}

	if( interval_msec < 10 )
	{
		interval_msec = '0' + interval_msec;
	}

	if( ( x_date - now_date ) > 0 )
	{
		document.getElementById( countdown_container_id ).innerHTML = '<span style="font:bold 18px/1.4 Trebuchet MS, Osaka, \'ＭＳ Ｐゴシック\';color:#f30;">' + "あと " + interval_day + "日と " + interval_hour + "時間" + interval_min + "分" + interval_sec + "秒" + interval_msec + '</span>';
	}
	else
	{
		document.getElementById( countdown_container_id ).innerHTML = '<span style="font:bold 18px/1.4 Trebuchet MS, Osaka, \'ＭＳ Ｐゴシック\';color:#f30;">' + end_message + '</span>';

		clearInterval( countdown_timer_id );
	}
}

if( window.attachEvent )
{
	window.attachEvent( 'onload', initialize_countdown );
}
else
{
	window.addEventListener( 'DOMContentLoaded', initialize_countdown, false );
}

