jQuery(function($){
  $("li#teaType, li#gift-situation").hover(
    function(){
      $(this).stop();
      $(this).children("ul").slideDown();
    },
    function(){
      $(this).stop();
      $(this).children("ul").slideUp();
    }        
  );
})

function countdownTimer( elementID, timeLimit, endMessage, messageClass ) {
	this.initialize.apply( this, arguments );
}

countdownTimer.prototype = 	{

	/**
	* コンストラクタ
	*/
	initialize: function( elementID, timeLimit, endMessage, messageClass ) {
		this.element = document.getElementById( elementID );
		this.timeLimit = timeLimit;
		this.endMessage = endMessage;
		this.messageClass = messageClass;
	},

	/**
	* カウントダウン
	*/
	countDown : function()	{
		var timer;
		var now = new Date();
		var days = Math.floor( ( this.timeLimit - now ) / ( 24 * 60 * 60 * 1000 ) );
		var hours = Math.floor( ( ( this.timeLimit - now ) % ( 24 * 60 * 60 * 1000 ) ) / ( 60 * 60 * 1000 ) );
		var mins = Math.floor( ( ( this.timeLimit - now ) % ( 24 * 60 * 60 * 1000 ) ) / ( 60 * 1000 ) ) % 60;
		var secs = Math.floor( ( ( this.timeLimit - now ) % ( 24 * 60 * 60 * 1000 ) ) / 1000 ) % 60 % 60;
		var milis = Math.floor( ( ( this.timeLimit - now ) % ( 24 * 60 * 60 * 1000 ) ) / 10 ) % 100;
		var myself = this;

		if( ( this.timeLimit - now ) > 0 ){
			timer = '販売終了まで ' + this.addZero( hours ) + '時間 ' + this.addZero( mins ) + '分 '+ this.addZero( secs ) + '秒';
			this.element.innerHTML = timer;
			setTimeout( function() { myself.countDown(); }, 10 );
		}else{
			this.element.innerHTML = this.endMessage;
			if( this.messageClass )	this.element.setAttribute( 'class', this.messageClass );
			return;
		}
	},

	/**
	* ゼロ詰め
	*/
	addZero : function( num )	{
		num = '00' + num;
		num = num.substring( num.length - 2, num.length );
		return num ;
	}
}
