/*
 * top.js - Basic Configuration for Top Pages
 *
 * author: thirozumi(thirozumi@gmail.com)
 * date: 2008-06-17
 * rev: 0.11
 */

$(function(){
	
	// カルーセル対象ブロックの高さを動的に取得して一番高いものに合わせる
	$('.cyclebody2 li,.cyclebody2').flatHeights();
	$('.cyclebody3 li,.cyclebody3').flatHeights();

	// カルーセルを有効にする
		// Topics
		$('.cyclebody').cycle({ 
		    fx:      'fade', 
		    next:    '#cyclerotate',
			speed:   1000,
		    timeout: 15000,
			pause:   1
		});
		
		// Books
		$('.cyclebody2').cycle({ 
		    fx:      'scrollHorz', 
		    prev:    '#cycleprev2', 
		    next:    '#cyclenext2', 
			speed:   250,
		    timeout: 0 
		});
		
		// Cinema
		$('.cyclebody3').cycle({ 
		    fx:      'scrollHorz', 
		    prev:    '#cycleprev3', 
		    next:    '#cyclenext3', 
			speed:   250,
		    timeout: 0 
		});
	
	// カルーセルのナビゲーション表示・非表示、フォーカスとウエイトを入れる処理
		// Topics
		$('.cycle').hoverIntent({
			sensitivity: 7,
			interval: 300,
			over: showNav,
			timeout: 300,
			out: hideNav
		});
		function showNav(){$('.cycleanchor').fadeIn(200);};
		function hideNav(){$('.cycleanchor').fadeOut(1000);};
		
		// Books
		$('.cycle2').hoverIntent({
			sensitivity: 7,
			interval: 50,
			over: showNav2,
			timeout: 100,
			out: hideNav2
		});
		
		function showNav2(){
			$('.cycleanchor2').animate({
				opacity:'1'
				},100);
			};
			
		function hideNav2(){
			$('.cycleanchor2').animate({
				opacity:'0.5'
				},600);
			};
		
		// Cinema
		$('.cycle3').hoverIntent({
			sensitivity: 7,
			interval: 50,
			over: showNav3,
			timeout: 100,
			out: hideNav3
		});
		
		function showNav3(){
			$('.cycleanchor3').animate({
				opacity:'1'
				},100);
			};
			
		function hideNav3(){
			$('.cycleanchor3').animate({
				opacity:'0.5'
				},600);
			};
	
	// 各カテゴリブロックの2つ目以降の要素のポジションを調整する
	$('#mn > div:nth(2), #sd1 > div:nth(2), #sd2 > div:nth(2)').css({
		position: 'relative',
		top: '-5px',
		left: '0'
	});
	
	$('#mn > div:nth(3), #sd1 > div:nth(3), #sd2 > div:nth(3)').css({
		position: 'relative',
		top: '-10px',
		left: '0'
	});

});