// Carolina Pires - www.carolinapires.com.br
// Desenvolvido por: Léo Muniz
// Data: 29/06/2011

$(document).ready(function(){

	visualizador = true;
	
	/* REFLEXO NAS FOTOS */
		// O reflexo nas fotos tava bugando a visualização no IE (exceto no 9) por causa da ausência do Canvas e do hack doidão usado pra consertar
		if ((!$.browser.msie) || (($.browser.msie)&&($.browser.version >= 9)))
			$("#auto_play li img").reflect({height:30, opacity:0.30});
	/* REFLEXO NAS FOTOS */
	

	/* AUTO_PLAY GALERIA */
		//$("#auto_play li").hide();
		if (($("#abrir_na_foto").val() == "")||($("#auto_play li[id='" + $("#abrir_na_foto").val() + "']").size() == 0 )) { // Abre na primeira foto
			$("#auto_play li:first").show();
		} else { // Abre a galeria na foto estipulada
			$("#auto_play li[id='" + $("#abrir_na_foto").val() + "']").show();
		}

		if ($("#slideshow").val() == "on") { //  Iniciar slide show automaticamente
		
			automatic = setInterval(auto_play,5000); // auto_play = função definida em functions.js
			playing = true;
			$("#play_pause").attr("src","/img/icones/pause.png");
			$("#play_pause").attr("alt","pause");
			$("#play_pause").attr("title","Parar slideshow");			
		
		} else { // Não iniciar slideshow

			playing = false;
			$("#play_pause").attr("src","/img/icones/play.png");
			$("#play_pause").attr("alt","play");
			$("#play_pause").attr("title","Começar slideshow");	
		}
	
	/* AUTO_PLAY GALERIA */
	
	
	/* PLAY E PAUSE */
		
		$("#play_pause").click(function() {
			if (playing) {
				clearInterval(automatic);
				$(this).attr("src","/img/icones/play.png");
				$(this).attr("alt","play");
				$(this).attr("title","Começar slideshow");
				playing = false;
			} else { 
				auto_play();
				automatic = setInterval(auto_play,5000);
				$(this).attr("src","/img/icones/pause.png");
				$(this).attr("alt","pause");
				$(this).attr("title","Parar slideshow");
				playing = true;
			}
		});
	
	/* PLAY E PAUSE */
	
});
