var campos = new Array();

$(document).ready(function() {

	$(':text, textarea, .input-text').focusin(function() {
	 	var str = $(this).attr('name'); 

		if (!campos[str]) {
			campos[str] = new Array();
		}

		if (!campos[str]['userContent']) {
			if (!campos[str]['defaultValue']) {
				campos[str]['defaultValue'] = $(this).attr('value');
			}

			campos[str]['userContent'] = true;
			$(this).attr('value', '');

			if ($(this).hasClass('senha')) {
				this.type = 'password';
			}
		}
	});

	$(':text, textarea, .input-text').focusout(function() {
		var str = $(this).attr('name');

		if (!campos[str]['userContent'] || ($(this).attr('value') == '')) {
			campos[str]['userContent'] = false;
			$(this).attr('value', campos[str]['defaultValue']);

			if ($(this).hasClass('senha')) {
				this.type = 'text';
			}
		}
	});

});

function abrir(id, ico) {
	$(".clausulas div").slideUp(500, "easeOutCubic");
	$(".clausulas h4").css("background-image","url('/css/img/regulamento-clausula-bg-close.png')");
	$(".clausulas h4").attr("title","Clique para abrir");

	if ($("#clausula-"+id).css("display") != "block") {
		$("#clausula-"+id).slideToggle(500, "easeOutCubic");
		$(ico).css("background-image","url('/css/img/regulamento-clausula-bg-open.png')");
		$(ico).attr("title","Clique para fechar");
	}
}

