if (Object.isUndefined(CodeCompany)) { var CodeCompany = {}; }
if (Object.isUndefined(console)) { var console = { log: function() { } }; } // IE7-"helper"

CodeCompany.ClassCycler = Class.create({
	log: function(str) {
		console.log('CodeCompany.ClassCycler: '+str);
	},
	initialize: function(element,options) {
		this.options = Object.extend({
			'classes': ['alpha','beta'],
			'delay': 1000
		},options || {});	
		this.element = element;

		this.index = 0;
		this.classes = this.options.classes.length;

		this.log('Initialized with '+this.classes+' classes');
		this.onTimeout();
	},
	onTimeout: function() {
		this.log('Timeout');

		if (undefined!==this.lastIndex) {
			this.element.removeClassName(this.options.classes[this.lastIndex]);
		}
		this.element.addClassName(this.options.classes[this.index]);
		this.lastIndex = this.index;

		this.index++;
		this.index %= this.classes;

		this.timeout = setTimeout(this.onTimeout.bind(this),this.options.delay);
	}
});

