// class declaration
function Cases() {
	this.length = jQuery("dl.principal dt").length;
}

// properties
Cases.prototype.defaultInterval = 3;
Cases.prototype.timeout = null;
Cases.prototype.active = true;
Cases.prototype.actualCase = 0;
// methods
Cases.prototype.isActive = function()
{
	return this.active;
}
Cases.prototype.count = function()
{
	return this.length;
}
Cases.prototype.hideAll = function()
{
	jQuery("dl.principal dd").each(function(){
		$(this).hide();
		$(this).css('z-index', 1);
	});

	jQuery("ul.changecase li a").each(function(){
		$(this).removeClass('selected');
	});
}
Cases.prototype.getCase = function(n)
{
	return jQuery("dl.principal dt:eq(" + n + ")").next();
}
Cases.prototype.getLink = function(n)
{
	return jQuery("ul.changecase li:eq(" + n + ") a");
}
Cases.prototype.selectCase = function(n)
{
	if(this.actualCase != n) {
		this.actualCase = n;

		this.hideAll();

		this.getCase(n).css('z-index', 5);
		this.getCase(n).fadeIn('slow');

		this.getLink(n).addClass('selected');
	}
}
Cases.prototype.next = function()
{
	this.selectCase((this.actualCase + 1)%this.length);
}
Cases.prototype.start = function(interval)
{
	if(isNaN(this.interval) || this.interval == null) {
		if(!isNaN(interval)) this.interval = interval;
		else this.interval = this.defaultInterval;
	}

	window.clearTimeout(this.prestart);
	this.prestart = window.setTimeout("cases.play();", this.interval * 1000);
}
Cases.prototype.play = function()
{
	if(isNaN(this.interval)) this.interval = this.defaultInterval;

	if(this.active) {
		this.next();
		window.clearInterval(this.timeout);
		this.timeout = window.setInterval('cases.next()', this.interval * 1000);
	}
}
Cases.prototype.stop = function()
{
	window.clearInterval(this.timeout);
}



