var Geral = {

	legendas: [
	"Praticidade",
	"Organização",
	"e Padronização",
	"Para o seu comércio!"
	],

	imgs: [
	"fotodestaque1.jpg",
	"fotodestaque2.jpg",
	"fotodestaque3.jpg",
	"fotodestaque4.jpg"
	],

	atual: 0,
	foto: '',
	legenda: '',

	__construct: function() 
	{
		_this = Geral;
		$.ifixpng('pics/pixel.gif');
		$('img[@src$=.png]').ifixpng(); //png transparent no IEca
		$("input[type='text'],textarea").resetDefaultValue();
		$("input[type='text']").addClass("text");
		_this.foto = _this.imgs[0];
		_this.legenda = _this.legendas[0];

		//borda azul no fim do mainContent
		$("#mainContent").append("<img class='abaBottom' src='pics/abaBottom.gif' alt='' />");  
		$("#destaques div.foto").hide().html("<img src='fotos/"+_this.foto+"' alt='' />").fadeIn("normal");
		$("div.descricao p.desc").html(_this.legenda);
		$("#destaques img.prev").click(_this.voltar);
		$("#destaques img.next").click(_this.avancar);
		_this.timer();
	},

	voltar: function() 
	{
		_this = Geral;
		atual = _this.atual;
		var tam = _this.legendas.length;
		if ((atual > 0) && (tam > 1)) {
			_this.foto = _this.imgs[atual-1];
			_this.legenda = _this.legendas[atual-1];
			_this.atual--;
		} else if (atual <= 0)
		{
			_this.foto = _this.imgs[tam-1];
			_this.legenda = _this.legendas[tam-1];
			_this.atual = tam-1;
		}
		$("#destaques div.foto").hide().html("<img src='fotos/"+_this.foto+"' alt='' />").fadeIn("normal");
		$("div.descricao p.desc").html(_this.legenda);
	},

	avancar: function() 
	{
		_this = Geral;
		atual = _this.atual;
		var tam = _this.legendas.length;
		if (atual < (tam-1)) {
			_this.foto = _this.imgs[atual+1];
			_this.legenda = _this.legendas[atual+1];
			_this.atual++;
		} else {
			_this.foto = _this.imgs[0];
			_this.legenda = _this.legendas[0];
			_this.atual = 0;
		}
		$("#destaques div.foto").hide().html("<img src='fotos/"+_this.foto+"' alt='' />").fadeIn("normal");
		$("div.descricao p.desc").html(_this.legenda);
	},

	timer: function() {
		_this = Geral;
		setInterval(function() {
			_this.avancar();
		},3000)
	}
}

$(document).ready(function()
{
	Geral.__construct();
});