/**
 *CountdownTimerクラス
 *
 * Noriko Shimazaki
 * 2008/09/15(Mon.)
 */
function CountdownTimer( elemID, timeLimit, limitMessage, msgClass ) {
	this.initialize.apply( this, arguments );
}

CountdownTimer.prototype = 	{

	/**
	 * Constructor
	 */
	initialize: function( elemID, timeLimit, limitMessage, msgClass ) {
		this.elem = document.getElementById( elemID );
		this.timeLimit = timeLimit;
		this.limitMessage = limitMessage;
		this.msgClass = msgClass;
	},

	/**
	 * カウントダウン
	 */
	countDown : function()	{
		var	timer;
		var	today = new Date()
		var	days = Math.floor( ( this.timeLimit - today ) / ( 24 * 60 * 60 * 1000 ) );
		var	hours = Math.floor( ( ( this.timeLimit - today ) % ( 24 * 60 * 60 * 1000 ) ) / ( 60 * 60 * 1000 ) );
		var	mins = Math.floor( ( ( this.timeLimit - today ) % ( 24 * 60 * 60 * 1000 ) ) / ( 60 * 1000 ) ) % 60;
		var	secs = Math.floor( ( ( this.timeLimit - today ) % ( 24 * 60 * 60 * 1000 ) ) / 1000 ) % 60 % 60;
		var	milis = Math.floor( ( ( this.timeLimit - today ) % ( 24 * 60 * 60 * 1000 ) ) / 10 ) % 100;
		var	me = this;

	        if( ( this.timeLimit - today ) > 0 ){
			timer = '残り ' + days + '日 ' + this.addZero( hours ) + '時間 ' + this.addZero( mins ) + '分 '+ 'です'
			this.elem.innerHTML = timer;
			tid = setTimeout( function() { me.countDown(); }, 10 );

	        }else{
			this.elem.innerHTML = this.limitMessage;
			if( this.msgClass )	{
				this.elem.setAttribute( 'class', this.msgClass );
			}
			return;
	        }
	},

	/**
	 * ゼロを付与
	 */
	addZero : function( num )	{
		num = '00' + num;
		str = num.substring( num.length - 2, num.length );

		return str ;
	}
}


function cdTimer1()	{

// 設定項目 ここから---------------------------------------------
	// タグ要素のID名
	var	elemID = 'sampleA';

	// 期限日を設定
	var	year	=	2012;			// 年
	var	month	=	03;				// 月
	var	day		=	01;				// 日

	// 期限終了後のメッセージ
	var	limitMessage	=	'恐れ入りますが、受付を中断しています';

	// メッセージのスタイルクラス名（変更しない場合は空欄）
	var	msgClass = 'msg_1';
// 設定項目 ここまで---------------------------------------------


	var	timeLimit = new Date( year, month - 1, day );
	var	timer = new CountdownTimer( elemID, timeLimit, limitMessage, msgClass );
	timer.countDown();
}

function cdTimer2()	{

// 設定項目 ここから---------------------------------------------
	// タグ要素のID名
	var	elemID = 'sampleB';

	// 期限日を設定
	var	year	=	2012;			// 年
	var	month	=	03;				// 月
	var	day		=	01;				// 日

	// 期限終了後のメッセージ
	var	limitMessage	=	'恐れ入りますが、受付を中断しています';

	// メッセージのスタイルクラス名（変更しない場合は空欄）
	var	msgClass = 'msg_1';
// 設定項目 ここまで---------------------------------------------


	var	timeLimit = new Date( year, month - 1, day );
	var	timer = new CountdownTimer( elemID, timeLimit, limitMessage, msgClass );
	timer.countDown();
}

function cdTimer3()	{

// 設定項目 ここから---------------------------------------------
	// タグ要素のID名
	var	elemID = 'sampleC';

	// 期限日を設定
	var	year	=	2012;			// 年
	var	month	=	03;				// 月
	var	day		=	01;				// 日

	// 期限終了後のメッセージ
	var	limitMessage	=	'恐れ入りますが、受付を中断しています';

	// メッセージのスタイルクラス名（変更しない場合は空欄）
	var	msgClass = 'msg_1';
// 設定項目 ここまで---------------------------------------------


	var	timeLimit = new Date( year, month - 1, day );
	var	timer = new CountdownTimer( elemID, timeLimit, limitMessage, msgClass );
	timer.countDown();
}

function cdTimer4()	{

// 設定項目 ここから---------------------------------------------
	// タグ要素のID名
	var	elemID = 'sampleD';

	// 期限日を設定
	var	year	=	2012;			// 年
	var	month	=	03;				// 月
	var	day		=	01;				// 日

	// 期限終了後のメッセージ
	var	limitMessage	=	'恐れ入りますが、受付を中断しています';

	// メッセージのスタイルクラス名（変更しない場合は空欄）
	var	msgClass = 'msg_1';
// 設定項目 ここまで---------------------------------------------


	var	timeLimit = new Date( year, month - 1, day );
	var	timer = new CountdownTimer( elemID, timeLimit, limitMessage, msgClass );
	timer.countDown();
}

function cdTimer5()	{

// 設定項目 ここから---------------------------------------------
	// タグ要素のID名
	var	elemID = 'sampleE';

	// 期限日を設定
	var	year	=	2012;			// 年
	var	month	=	03;				// 月
	var	day		=	01;				// 日

	// 期限終了後のメッセージ
	var	limitMessage	=	'恐れ入りますが、受け付けは終了しました。';

	// メッセージのスタイルクラス名（変更しない場合は空欄）
	var	msgClass = 'msg_1';
// 設定項目 ここまで---------------------------------------------


	var	timeLimit = new Date( year, month - 1, day );
	var	timer = new CountdownTimer( elemID, timeLimit, limitMessage, msgClass );
	timer.countDown();
}



// 右クリックすると警告ウィンドウを表示する
function alt() {
window.alert("右クリック禁止");
}


