var ativaLoader = true;

jQuery('#loader').hide();


// DOM ready
jQuery(function () {
	//alert('test');
	jQuery('#showcase2 li a').click( function(){
		if (ativaLoader) jQuery('#loader').show();
		jQuery('#featured2').load(function () {
			if (ativaLoader) jQuery('#loader').hide();
			return;
		}).error(function () {
			alert("Failed to load image");
		}).attr('src', this.href);
		
		var linkout = jQuery(this).attr('rel');
		//alert(linkout);
		jQuery('#featured-link2').attr('href',linkout);
		jQuery('#showcase2 li a').removeClass('active');
		jQuery(this).addClass('active');
		return false;
	});
	
	
	
	
});


// DOM ready
jQuery(function () {
	//alert('test');
	jQuery('#showcase li a').click( function(){
		if (ativaLoader) jQuery('#loader').show();
		jQuery('#featured').load(function () {
			if (ativaLoader) jQuery('#loader').hide();
			return;
		}).error(function () {
			alert("Failed to load image");
		}).attr('src', this.href);
		
		var linkout = jQuery(this).attr('rel');
		//alert(linkout);
		jQuery('#featured-link').attr('href',linkout);
		jQuery('#showcase li a').removeClass('active');
		jQuery(this).addClass('active');
		return false;
	});
	
	
	
	
});



/// Ajuste para mudanca automatica da imagem
/// by @luisleao 13/01/2009

var itens = jQuery('#showcase li a');
var totalItens = itens.length;
var itemAtual = 0;
var TEMPO = 3000; //3 segundos

setTimeout(mudaImagem, TEMPO);

function mudaImagem() {
    itemAtual++;
    if (itemAtual==totalItens) itemAtual = 0;


    ativaLoader = false;
    jQuery('#showcase li a:eq('+itemAtual+')').click();
    ativaLoader = true;
    setTimeout(mudaImagem, TEMPO);
}
