$(document).ready(function(){

	var fields = $("input[type=text], textarea");

	if (fields.length){
		fields.each(function(){
			var self = $(this);

			if (self.parents('form').find('.erro, .aviso').length == 0){
				if (self.attr('defaultValue')) {
					self.blur(function(){
						if (self.val() == ''){
							self.val(self.attr('defaultValue'));
						}
					});
		
					self.focus(function(){
						if (self.val() == self.attr('defaultValue')) {
							self.val('');
						}
					});
				}
			}
		});
	}
	
	// ------------------------------------------------------ //

	var buttons = $('li.itens').prev().find('a');

	buttons.each(function(){
		var self = $(this);
		var item = $(this).parent().next();

		self.removeAttr('href').css('cursor', 'pointer');

		self.click(function(){
			item.slideToggle("normal", function(){
				if (item.css('display') != 'none')
					item.css('display', 'list-item');
			});
		});
	});

	// ------------------------------------------------------ //

	var container = $("#cabecalho + table");

	var lateral = $("#lateral .borda");
	var conteudo = $("#pagina .wrapper");

	if (conteudo.length){
		container.resize(function(){
			if (conteudo.height() > lateral.height())
				lateral.css('height', conteudo.height());

			if (lateral.height() > conteudo.height())
				lateral.css('height', 'auto');
		});
	}

	// ------------------------------------------------------ //
	
	var programacao = $('.links .programacao, .links .site');

	if (programacao.length){
		programacao.each(function(){
			var self = $(this);
			var list = self.parents('.horario, .expositor').find('.eventos, .editoras');

			self.click(function(){
				self.removeAttr('href').css('cursor', 'pointer');
				list.toggle();
			});
		});
	}

	// ------------------------------------------------------ //
	
	/*
	$("a.expositores").hover(function(){
		$(this).text('Em Breve!');
	}, function(){
		$(this).text('Expositores');
	});
	*/

	// ------------------------------------------------------ //

	$(".fotos .thumbnail").lightBox();

});
