/**
 * index.js
 * (c) FOURDIGIT Inc.
 */

(function($){
	$(function() {

		$('#MainImgs .MAIN ul').innerfade({
			speed: 1500,
			timeout: 8000,
			type: 'sequence',
			containerheight: '401px'
		});

		$('#MainImgs .SUB1 ul').innerfade({
			speed: 1500,
			timeout: 8000,
			type: 'sequence',
			containerheight: '200px'
		});

		$('#MainImgs .SUB2 ul').innerfade({
			speed: 1500,
			timeout: 8000,
			type: 'sequence',
			containerheight: '199px'
		});


		//append radius
		$('#MainImgs')
			.append('<li class="tl"><img src="/imgs/index/radius-tl.png"></li>')
			.append('<li class="tr"><img src="/imgs/index/radius-tr.png"></li>')
			.append('<li class="bl"><img src="/imgs/index/radius-bl.png"></li>')
			.append('<li class="br"><img src="/imgs/index/radius-br.png"></li>');

		$.autoEnablePNG();

		//scroll pane
		$('.NewsList').jScrollPane();

		//PickUpItem!
		$('#MainPickUpItem .timepattern').hide();

		var now = new Date();
		var hour = now.getHours();

		// 7:00-9:59までの間表示
		if(hour >= 7 && hour <= 10)				{ $('#MainPickUpItem01').fadeIn(); }
		// 9:00-12:59までの間表示
		else if(hour >= 10 && hour <= 13)	{ $('#MainPickUpItem02').fadeIn(); }
		// 13:00-15:59までの間表示
		else if(hour >= 13 && hour <= 16)	{ $('#MainPickUpItem03').fadeIn(); }
		// 16:00-18:59までの間表示
		else if(hour >= 16 && hour <= 19)	{ $('#MainPickUpItem04').fadeIn(); }
		// 19:00-21:59までの間表示
		else if(hour >= 19 && hour <= 22)	{ $('#MainPickUpItem05').fadeIn(); }
		// 22:00-6:59までの間表示
		else if(hour >= 22 || hour <= 7)	{ $('#MainPickUpItem06').fadeIn(); }

		$('#MainImgs .hasImg, #PickUpItemBox .thumb, #SideLinks li, .pagetop')
			.find('img').hover(
				function(){ $(this).fadeTo(100,0.8); },
				function(){ $(this).fadeTo(100,1.0); }
			);

	  //endBox
	  $(".endBox:nth-child(3)").addClass("right").addClass("top");
	  $(".endBox:nth-child(5)").addClass("right");
	  $(".endBox:nth-child(6)").addClass("right").addClass("top");

	  $('#Newone').each(function(){
			$(this).find('a').each(function(){
				var $this = $(this);
				$(this).find('img').actualSize(function(obj){
					var iActWidth = obj.width;
					var iActHeight = obj.height;
					var thisPer = 162 / iActWidth;
					var iHeight = iActHeight * thisPer;
					if(iHeight <= 162){
						var thispadding = ( ( 162 - iHeight ) / 2 ) + 'px'; 
						$($this)
							.find('img')
								.css('height','auto')
								.css('padding-top',thispadding)
								.css('vertical-align','middle')
							.end()
						.end();
					} else {
					}
				});
			});
	  });

		//make a column lists
		$('.column2 .list').makeacolumnlists({cols: 2, colWidth: 0, equalHeight: false, startN: 1});


	});
})(jQuery);
