/**
 *  ギャラリーオブジェクト
 */
function Gallery(title, subtitle, design) {
  this.title        = title;       // ページタイトル
  this.subtitle     = subtitle;    // サブタイトル
  this.design       = design;
  this.pageArray    = new Array(); // このギャラリーに属するページオブジェクトの配列
  this.selectedPage = 0;           // 現在表示されているページ番号
}

// toStringメソッド
Gallery.prototype.toString = function() {
  return this.title + ' (' + this.subtitle + ') : has ' + this.pageArray.length + ' page';
}
// pageArrayのgetter
Gallery.prototype.getPageArray = function() {
  return this.pageArray;
}
Gallery.prototype.getPage = function(index) {
  return this.pageArray[index];
}
// getPageCountメソッド
Gallery.prototype.getPageCount = function() {
  return this.getPageArray().length;
}

// getCurrentPageメソッド
Gallery.prototype.getCurrentPage = function() {
  return this.getPage(this.selectedPage);
}
// changePageメソッド
Gallery.prototype.changePage = function(index) {
  this.selectedPage = index;
}

// ページオブジェクト追加メソッド
Gallery.prototype.addPage = function(obj) {
  this.pageArray[this.pageArray.length] = obj;
}
// 写真オブジェクト追加メソッド
Gallery.prototype.addPhoto = function(index, obj) {
  this.pageArray[index].addPhoto(obj);
}

// hasPreviousPageメソッド
Gallery.prototype.hasPreviousPage = function() {
  return (this.selectedPage > 0) ? true : false;
}
// hasNextPageメソッド
Gallery.prototype.hasNextPage = function() {
  return (this.selectedPage < (this.pageArray.length - 1)) ? true : false;
}
// previousPageメソッド
Gallery.prototype.previousPage = function() {
  return (this.hasPreviousPage()) ? this.pageArray[--this.selectedPage] : this.pageArray[this.selectedPage];
}
// nextPageメソッド
Gallery.prototype.nextPage = function() {
  return (this.hasNextPage()) ? this.pageArray[++this.selectedPage] : this.pageArray[this.selectedPage];
}
