function ImageCollection() {
	this.aImgs = [];
	this.cCount = 0;
	this.cImg = 1;
	this.oContainer = null;
}

ImageCollection.prototype = {
		
	init : function () {
		this.oContainer = $('#CollectionContainer');
		this.aImgs = this.oContainer.find('.collectionItem');
		this.cCount = this.aImgs.length;
		
		// binds
		$('#ArrowLeft').bind('click', { oo : this }, function (e) { e.data.oo.move(-1); });
		$('#ArrowRight').bind('click', { oo : this }, function (e) { e.data.oo.move(1); });
		
	},
	
	move : function (d) {
		var oldImg = this.cImg;
		if (d == -1) {
			// backward
			if (this.cImg <= 1)
				return;
			this.cImg -= 1;
			var zz = this;
		} else {
			// forward
			if (this.cImg >= this.cCount ) 
				return;
			this.cImg += 1;
		}
		var newImg = this.cImg;
		$('#collectionItem_' + oldImg).fadeOut(100, function () { $(this).removeClass('startOne'); $('#collectionItem_' + newImg).fadeIn(200); });
		$('#CollectionCountCurrent').html(this.cImg);
	}

}
var aICollection = null;
$(document).ready( function () { aICollection = new ImageCollection(); aICollection.init(); } );