/* 최신게시물 이미지 */
var _LatestImage = function() {
	this.ul = null;
	this.left = null;
	this.right = null;
	this.page = 1;
};
_LatestImage.prototype.init = function(container) {
	this.ul = container.find('ul')[0];
	this.left = container.find('div.left')[0];
	this.right = container.find('div.right')[0];
};
_LatestImage.prototype.moveLeft = function() {
	if(this.page <= 1) return;

	--this.page;
	$(this.right).css('display', 'block');
	if(this.page == 1) $(this.left).css('display', 'none');

	var left = (this.page - 1) * -800;
	$(this.ul).animate({left: left}, 500);
};
_LatestImage.prototype.moveRight = function() {
	var page = this.page;
	if(page >= 3) return;

	++this.page;
	$(this.left).css('display', 'block');
	if(this.page == 3) $(this.right).css('display', 'none');

	var left = (this.page - 1) * -800;
	$(this.ul).animate({left: left}, 500);
};

var LatestImage = new _LatestImage();



/* 한줄게시판 슬라이드 */
var _LatestOneLine = function() {
	this.container = null;
	this.count = null;
	this.index = null;
	this.step = null;
};
_LatestOneLine.prototype.init = function(ol) {
	this.container = ol;
	this.count = $(this.container).find('li').length;
	this.step = $($(this.container).find('li')[0]).outerHeight();
	this.index = -1;
	$(this.container).parent().css('height', this.step);
	this.start();
}
_LatestOneLine.prototype.start = function() {
	var self = this;
	if(this.index + 2 == this.count) {
		this.index = -1;
		$(this.container).css('top', 0);
	}
	++this.index;
	setTimeout(function(){self.animate();}, 5000);
}
_LatestOneLine.prototype.animate = function() {
	var self = this, container = $(this.container);

	var top = (this.index + 1) * this.step * -1;

	$(this.container).animate({top: top}, 1000, 'swing', function(){self.start();});
};

var LatestOneLine = new _LatestOneLine();
