/////////////////////////////////
// Insere Teaser na Home
///////////////////////////////
//(function($){
//	$(document).ready(function(){
//		
//		$(".title-cursos-dados li a").hover(function(){
//			var rel = $(this).attr('rel');
//			$(".title-cursos-dados li a[rel="+ rel +"]").addClass('ativo');
//		},function(){
//			var rel = $(this).attr('rel');
//			$(".title-cursos-dados li a[rel="+ rel +"]").removeClass('ativo');
//		});
//	});
//})(jQuery);


// função para o banner home
destaque = 0
function alterna(){
	$('.noticias ul li').removeClass('ativo');
	$('.noticias ul li:eq('+destaque+')').addClass('ativo');
	$('.bannerNews img:not(:eq('+destaque+'))').hide();
	$('.bannerNews img:eq('+destaque+')').fadeIn();
	destaque = destaque == 3 ? 0 : destaque += 1;
}
/////////////
// No Label //
//////////////
noLabel = {
	init: function(){
		$(".noLabel").each(function(){
			$(this).addClass("vazio");
			noLabel.buffer[$(this).attr("id")] = $(this).val();
			$(this).unbind('focus',noLabel.foco).unbind('blur',noLabel.desfoco).bind('focus',noLabel.foco).bind('blur',noLabel.desfoco);
		}).parents("form:eq(0)").unbind('submit',noLabel.formulario).bind('submit',noLabel.formulario);
	},
	
	buffer: {},
	
	foco: function(obj){
		obj = typeof($(obj).attr("id")) == "undefined" ? this : obj;
		if($(obj).hasClass("vazio")){
			if($(obj).is("textarea")){
				$(obj).html("");
			}else{
				$(obj).val("");
			}
			$(obj).removeClass("vazio");
		}
	},
	
	desfoco: function(){
		if($.trim($(this).val()) == ""){
			if($(this).is("textarea")){
				$(this).html(noLabel.buffer[$(this).attr("id")]);
			}else{
				$(this).val(noLabel.buffer[$(this).attr("id")]);
			}
			$(this).addClass("vazio");
		}
	},
	
	formulario: function(){
		$(".vazio",this).each(function(){
			noLabel.foco(this);
		});
		return true;
	}
}


$(document).ready( function(){
	noLabel.init();
});
