$().ready( function() {
	confirmacao();
	zebra();
	printing();
	target();
	ieFlickerFix();
	//masks();
});


function confirmacao() {
	$('a.confirmacao').bind('click', function() {
		var title = $(this).attr('title');
		if (!confirm(title)) return false;
		return true;
	});
}


function printing() {
	$('.printit').click( function() {
		window.print();
	});
}


function target() {
	$("a[@rel$='external'], .external").each( function(){
		$(this).attr('target','_blank');
		$(this).attr('title', $(this).attr('title')+' (este link abre em nova janela)');
	});
}


function zebra() {
	$('table:not(.nozebra) tr:nth-child(odd)').addClass('par');
}


function ieFlickerFix() {
	try {
	  document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
}


function masks() {
	$('.maskdate').mask('99/99/9999');
	$('.maskphone').mask('(99) 9999-9999');
	$('.maskcep').mask('99999-999');	
}


function affectedFields(form,el) {
	var classname = 'affected';
	$(form+' *').each( function() {
		if (el!='') {
			if ($(this).attr('id')==el) {
				$(this).focus().addClass(classname);
			} else {
				$(this).removeClass(classname);
			}
		} else {
			$(this).removeClass(classname);
			$(form).resetForm();
		}
	});
	return false;
}


function get(el) {
	return document.getElementById(el);
}
