function setarEventos() {
	$("#tabela tr:not(#trh)").each(function() {
		eventosLinha($(this));
	})
}

function eventosLinha(obj) {
	obj.mouseover(function() {
		obj.addClass("highlight");
	})
		
	obj.mouseout(function() {
		$(this).removeClass("highlight");
	})
}

function efeito(obj) {
	var classe = obj.attr("class");
	obj.removeClass(classe);
	obj.effect("highlight", {
		color: "E0C97B"
	}, 2000);

	obj.queue(function() {
		obj.addClass(classe);
		obj.dequeue();
	})
}

function assinarPlano(nomePlano, idProduto) {
	var perfis = "";
	$(".perfil").each(function() {
		if ($(this).attr("checked")) {
			if (perfis == "") {
				perfis = "&perfis=";
			} else {
				perfis += ",";
			}
			perfis += $(this).attr("id");
		}
	});
	window.location.href = "inscricao.bling.php?pl=" + nomePlano + "&pr=" + idProduto + perfis;
}

function assinarPlanoVirig(nomePlano, idProduto) {
	var perfis = "";
	$(".perfil").each(function() {
		if ($(this).attr("checked")) {
			if (perfis == "") {
				perfis = "&perfis=";
			} else {
				perfis += ",";
			}
			perfis += $(this).attr("id");
		}
	});
	window.location.href = "inscricao.virig.php?pl=" + nomePlano + "&pr=" + idProduto + perfis;
}

function entrarEmContato() {
	window.location.href = "contato.email.php";
}

function assinarPlanoTinyMed(nomePlano, idProduto) {
	window.location.href = "inscricao.tinymed.php?pl=" + nomePlano + "&pr=" + idProduto;
}

function assinarPlanoTinyPro(nomePlano, idProduto) {
	window.location.href = "inscricao.tinypro.php?pl=" + nomePlano + "&pr=" + idProduto;
}

function assinarPlanoTiraNota(nomePlano, idProduto) {
	window.location.href = "inscricao.tiranota.php?pl=" + nomePlano + "&pr=" + idProduto;
}

$(document).ready(function() {
	$(".tabela tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
	
	$(".perfil").bind("click", function() {
		testarPerfis();
	});

	testarPerfis();
});

function testarPerfis() {
	$(".perfil").each(function() {
		if (! $(this).attr("checked")) {
			habilitarDesabilitarClass($(this).attr("id"), false);
		}
	})
	
	$(".perfil").each(function() {
		if ($(this).attr("checked")) {
			habilitarDesabilitarClass($(this).attr("id"), true);
		}
	})
}

function habilitarDesabilitarClass(aClass, opcao) {
	if (opcao) {
		//$("." + aClass).css("color", "");
		//$("." + aClass).css("background-color", "");
		//$("." + aClass + ".checked").css("background", "url(\"styles/images/yes.png\") no-repeat scroll center center");
		$("." + aClass + ".title").parent().show();
	} else {
		//$("." + aClass).css("color", "#AAAAAA");
		//$("." + aClass).css("background-color", "#EEEEEE");
		//$("." + aClass + ".checked").css("background", "url(\"styles/images/dyes.png\") no-repeat scroll center center #EEEEEE");
		$("." + aClass + ".title").parent().hide();
	}
}
