//TOPページ

$(document).ready(function() {
	
	//slider
	$('.slider').mobilyslider({
		content: '.sliderContent',
		children: 'div',
		transition: 'horizontal',
		animationSpeed: 300,
		autoplay: true,
		autoplaySpeed: 4000,
		pauseOnHover: true,
		bullets: true,
		arrows: true,
		arrowsHide: true,
		prev: 'prev',
		next: 'next',
		animationStart: function(){ jQuery.easing.def="easeOutQuart"; },
		animationComplete: function(){ }
	});
	
	//Twitter qTip
	$('#tLogo[title]').qtip({
		content: { title:false },
		position: {
						my: 'bottom center', //tipの出現ポジション
						at:'top center',
				//target: 'mouse',
			viewport: $(window), //表示エリアの指定
				adjust: { x: 0,  y: -2 } //吹き出しとマウスの位置関係 [ 'y:'マイナスの値は上に移動 ]
																	//adjust:{mouse:true だとマウスのtop部分にくっつく
		},
		hide: {
			fixed: true
		},
		style: 'twitterTip' //'ui-tooltip-dark'
		});
	
	//Facebook Wall
	$('#example1').fbWall({ id:'194596860555153',accessToken:'206158599425293|4b112a8fc695368ccf2a8e6f.1-100001978853397|9qtFA0TnQXo55yZ2zIZjOWpdsQY'});
	
	//Links Rolling
	var interval;
	var $rounder = $('#rounder');

	$rounder.roundabout({
	
		maxScale:0.81,
		easing:'easeInOutCubic',
		duration:500
	
	}).hover(function() {
		clearInterval(interval);
	},
	function() {
		interval = startAutoPlay();
	});
	
	interval = startAutoPlay();
	
	function startAutoPlay() {
		return setInterval (function() {
			$rounder.roundabout_animateToPreviousChild();
		}, 3000);
	}

	//twitter
	$.jTwitter('climaxcoffee', 5, function(data){ //'uerName', 表示数
			$('#posts').empty();
				$.each(data, function(i, post){
						$('#posts').append(
								'<div class="post" rel="' +i+ '">'
								+' <div class="txt">'
								+    post.text.slice(0,70) + '...' //表示テキスト
								+' </div>'
								+'</div>'
						);
				});
	});
	
	function monsterBall() {
		if ( i <= 3 ) {
			$('#posts').animate({ position:"absolute" , top:"-=30px", left:"0px"}, 200, 'easeInOutQuad');
			i++;
			//alert('i='+i);
		} else {
			$('#posts').fadeOut();
			$('#posts').animate({ position:"absolute" , top:"0px", left:"0px"}, 0, 'easeInOutQuad');
			$('#posts').fadeIn();
			i = 0;
		}
		
	}

	var i = 0;
	setInterval(monsterBall,7000);
	
	
	var $cardLink = $('a#ccCardA');
	var $cardBg = $('#ccCard-top');
	
	$cardLink.hover(
		
		function(){ $cardBg.css('backgroundPosition','left -204px') },
		function(){ $cardBg.css('backgroundPosition','left top') }
		
	);
});
