var ObjectIterator = Class.create();

ObjectIterator.prototype = {

	initialize: function(obj)
		{
		this.current = 0;
		this.length  = 0;

		if (obj != undefined)
			{
			this.obj = obj;
			this.main();
		}
	},
	
	main: function()
		{
		this.setLength();
	},
	
	next: function()
		{
		return this.obj[this.current++];
	},
	
	previous: function()
		{
		return this.obj[this.current--];
	},
	
	hasNext: function()
		{
		return (this.current < this.length);
	},

	hasPrevious: function()
		{
		return (this.current > 0);
	},
	
	setObject: function(obj)
		{
		this.obj = obj;
		this.setLength();
	},
	
	setLength: function()
		{
		for (var i = 0; this.obj[i] != undefined; i++)
			this.length = i + 1;
	},

	getLength: function()
		{
		return this.length;
	},
	
	reset: function()
		{
		this.current = 0;
	},
	
	getCurrentIndex: function()
		{
		return this.current;
	},
	
	setIndex: function(index)
		{
		this.current = index;
	},
	
	getCurrentObject: function()
		{
		return this.obj[this.current];
	}

}


/* XMLParser
---------------------------------------------------------------------*/
var XMLParser = Class.create();

XMLParser.prototype = {

	// コンストラクタ
	initialize: function()
		{
		this.main();
	},
	
	main: function()
		{
		this.url = "";
		this.xotree = new XML.ObjTree();
		this.method = "post";
		this.parameters = "";
	},

	// ロード開始
	load: function()
		{
		if (this.url == "") return;

		options = {
			method:     this.method,
			parameters: this.parameters,
			onLoaded:   this.onLoaded,
			onLoading:  this.onLoading,
			onSuccess:  this.onSuccess,
			onFailure:  this.onFailure
		}
		this.xotree.parseHTTP( this.url, options, this.onComplete );
	},
	
	// 以下は使用可能なイベント
	onComplete: new Function(),
	onSuccess:  new Function(),
	onFailure:  new Function(),
	onLoading:  new Function(),
	onLoaded:   new Function()
}


/* Config
---------------------------------------------------------------------*/
var Config = Class.create();

Config.prototype = {

	// コンストラクタ
	initialize: function()
		{
		this.main();
	},
	
	main: function()
		{
		this.url = "";
		this.parameters = "";
		this.xmlParser = new XMLParser();
	},
	
	// ロード
	load: function()
		{
		this.xmlParser.url = this.url;
		this.xmlParser.prameters  = (new Date()).getTime();
		this.xmlParser.onComplete = this.onComplete;
		this.xmlParser.load();
	},

	onComplete: new Function()
}


/* PictureCtrl
---------------------------------------------------------------------*/
var PictureCtrl = Class.create();

PictureCtrl.prototype = {

	// コンストラクタ
	initialize: function()
		{
		this.listCtrl = new ObjectIterator();
		this.pictures = new Array();
	},
	
	// 読み込み完了後初期化
	init: function()
		{
		this.listCtrl.setObject(this.pictures);
		this.reset();
	},
	
	next: function()
		{
		return this.listCtrl.next();
	},
	
	previous: function()
		{
		return this.listCtrl.previous();
	},

	hasNext: function()
		{
		return this.listCtrl.hasNext();
	},

	hasPrevious: function()
		{
		return this.listCtrl.hasPrevious();
	},
	
	pushXMLObject: function(xmlObject)
		{
		this.pictures.push(xmlObject);
	},
	
	getLength: function()
		{
		return this.listCtrl.getLength();
	},
	
	reset: function()
		{
		this.listCtrl.reset();
	},
	
	getCurrentIndex: function()
		{
		return this.listCtrl.getCurrentIndex();
	},
	
	setIndex: function(index)
		{
		this.listCtrl.setIndex(index);
	},

	getCurrentObject: function()
		{
		return this.listCtrl.getCurrentObject();
	}
}


/* 
---------------------------------------------------------------------*/