// JavaScript Document
// ContentChanger 0.1
// by Leo Gerber, diewebdesigner.com
// using Prototype and Sriptaculous
Element.Methods.showBlock = function(element) {
	element.setStyle({
		'display': 'block'
	});
	return element;
}
Element.addMethods();

var myContentChange = Class.create({
	options: {
		
	},
	initialize: function(container, childName, duration) {
		this.changeContainer = $(container);
		//this.children = new Selector.findChildElements(this.changeContainer, childName);
		this.children = this.changeContainer.getElementsBySelector(childName);
		this.numChilds = this.children.length;
		this.extendChildren();
		var pe = new PeriodicalExecuter(function(){ this.cycle(); }.bind(this), duration);
	},
	extendChildren: function() {
		this.hideChildren();
		//this.showChild(this.children[0]);
		this.children[0].showBlock();
		this.shiftpush();
	},
	hideChildren: function() {
		this.children.each(function(child){
			child.hide();
		});
	},
	cycle: function(){
		//this.showChild(this.children[0]);
		this.children[0].showBlock();
		this.shiftpush();
	},
	shiftpush: function() {
		var delChild = this.children.shift();
		this.hideChildren();
		this.children.push(delChild);
	}
});
