(function($){
$(function(){
			$('#slides').slides({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: 5000,
				pause: 2500,
				hoverPause: true,
				animationStart: function(){
					$('.caption').animate({
						bottom:-35
					},100);
				},
				animationComplete: function(current){
					$('.caption').animate({
						bottom:0
					},200);
					if (window.console && console.log) {
						// example return of current slide number
						console.log(current);
					};
				}
			});


		});

$(function(){
// Notice Anchor Remover
	$('.fixed .notice .author').removeAttr('href').removeAttr('onclick').attr('class','author');
	
	// Text Rotation
	var $rot = $('div.tRotation'), $btns, $prev, $next, $box, $items, timer, stopped=0, animating=0, current=0, INTERVAL=5000;

	// items
	$box   = $rot.find('>.itembox');
	$items = $box.find('>.item');

	// buttons
	$btns = $rot.prev('.nav').find('button').focus(function(){$box.mouseenter()}).blur(function(){$box.mouseleave()});
	$prev = $btns.filter('.prev')
		.click(function(){
			var _stopped = stopped;
			if (animating || $items.length < 2) return;
			stop();
			animating = true;
			stopped = _stopped;
			var $tmp;
			if (!current) {
				$items.eq(0).before($tmp=$items.eq(-1).clone());
				$box.css('top', parseInt($box.css('top'))-$tmp.height());
			}
			$box.animate(
				{top : '+='+$items.eq(current).height()},
				{
					duration : 'slow',
					complete : function() {				
						animating = false;
						current--;
						if ($tmp) {
							current = $items.length-1;
							$tmp.remove();
							$box.css('top', -$items.get(-1).offsetTop);
						}
						if (!stopped) timer = setTimeout(start, INTERVAL);
					}
				}
			);
		});
	$next = $btns.filter('.next')
		.click(function(){	
			var _stopped = stopped;
			if (animating || $items.length < 2) return;
			stop();
			animating = true;
			stopped = _stopped;
			var $tmp;
			if (current == $items.length-1) $items.eq(-1).after($tmp=$items.eq(0).clone());
			$box.animate(
				{top : '-='+$items.eq(current).height()},
				{
					duration : 'slow',
					complete : function() {
						animating = false;
						current++;
						if ($tmp) {
							current = 0;
							$box.css('top', 0);
							$tmp.remove();
						}
						if (!stopped) timer = setTimeout(start, INTERVAL);
					}
				}
			);
		});
	$box.mouseenter(function(){ stop() }).mouseleave(function(){ stop();stopped=false;timer=setTimeout(start, INTERVAL) });
	$box.find('a').focus(function(){ $box.mouseenter() }).blur(function(){ $box.mouseleave() });
	function stop() {
		stopped = true;
		clearTimeout(timer);
		timer = null;
	}
	function start() {
		stopped = false;
		$next.click();
	}
	// auto start
	timer = setTimeout(start, INTERVAL);
	//

	// Text Rotation Button
	var trBtnPrev = $('.fixed .mVisual>.nav>.prev');
	function trPrevToggle(){
		var t = $(this);
		if(t.hasClass('up')){
			trBtnPrev.removeClass('up');
		} else if(!t.hasClass('up')){
			trBtnPrev.removeClass('up');
			t.addClass('up');
		}
	};
	var trBtnNext = $('.fixed .mVisual>.nav>.next');
	function trNextToggle(){
		var t = $(this);
		if(t.hasClass('down')){
			trBtnNext.removeClass('down');
		} else if(!t.hasClass('down')){
			trBtnNext.removeClass('down');
			t.addClass('down');
		}
	};
	trBtnPrev.mouseover(trPrevToggle).mouseout(trPrevToggle);
	trBtnNext.mouseover(trNextToggle).mouseout(trNextToggle);
	trBtnPrev.focus(function(){$(this).addClass('up')});
	trBtnPrev.blur(function(){$(this).removeClass('up')});
	trBtnNext.focus(function(){$(this).addClass('down')});
	trBtnNext.blur(function(){$(this).removeClass('down')});
		});
})(jQuery);
