// JavaScript Document
ImageShow = Class.create(Abstract, {

	initialize: function(container, name, pic){
		pic.split(',').each(function(img, index){
			var element = Builder.node('div', { className: name, id: name + index });
			element = $(element);
			element.setStyle({
				backgroundImage: 'url(_img/' + img + ')'
			});
			element.hide();
			
			$(container).insert(element);
		});
		
		this.c = 0;
		this.e = $$('#' + container + ' .' + name);
		
		this.show();
	},
	
	show: function(){	
		if(!this.e[this.c]){
			this.e[0].appear();
			this.fadePrev(0);
		} else {
			this.e[this.c].appear();
			this.fadePrev(this.c);
		}
			
		if(this.c == (this.e.size() - 1)){
			this.c =0;
		} else {
			this.c++;
		}
	},
	
	fadePrev : function(h){
		if(h == 0){
			this.e.last().fade({duration: 3});
		} else {
			this.e[this.c-1].fade({duration: 3});
		}
	}

});