﻿/**
 * view page 용 슬라이드 자바스크립.
 * 일반 뷰페이지 전용입니다.
 *
 *
 * 2010. 7. 6 modified by jeeyong
 * 수정 내용 - total_page까지 갔을 경우 추가적으로 불러오도록 수정.
 *
 * slider = new slide(id, pixel, total_page, next_function);
 * id - ul태그를 감싸고있는 div태그 id
 * pixel - 리스트의 크기
 * total_page - 리스트 페이징수
 * next_function - 읽어온 페이지이후 작업 function()
 */
var slide = Class.create ({
	initialize : function (id, pixel, total_page, next_function) {
		this.id = $(id);
		this.pixel = pixel;
		this.now_page = 1;
		this.total_page = total_page;
		this.j_next_function = next_function;
		this.limit_page = 9;	// 11page 이상 갈경우 디자인이 깨지는 현상 발생. 3페이지씩 생성 되므로 9페이지까지 생성하도록 수정.
	},

	play : function (type) {
		switch (type) {
			case 'prev':
				if (type == 'prev' && this.now_page > 1) this.now_page--;
				else this.now_page = this.total_page;
			break;

			case 'next':
				if (type == 'next' && this.now_page < this.total_page){
					 this.now_page++;
				}else{
					if(typeof(this.j_next_function) != "undefined" && this.now_page < this.limit_page){
						this.j_next_function();
					}else{
						this.now_page = 1;
					}
				}
			break;
		}


		new Effect.Move(this.id, {x : '-'+((this.now_page - 1) * this.pixel), y : 0, mode : 'absolute',  duration: .5});

	},

	page : function (page) {
		if (page > 0 && page <= this.total_page) {
			new Effect.Move(this.id, {x : '-'+((page - 1) * this.pixel), y : 0, mode : 'absolute',  duration: .5});
			this.now_page = page;
		}
	},

	more : function () {

	}

});





