// JavaScript Document
function checkboxlimit(checkgroup, limit){
	var checkgroup=checkgroup
	var limit=limit
	for (var i=0; i<checkgroup.length; i++){
		checkgroup[i].onclick=function(){
		var checkedcount=0
		for (var i=0; i<checkgroup.length; i++)
			checkedcount+=(checkgroup[i].checked)? 1 : 0
		if (checkedcount>limit){
			alert("Você só pode selecionar no máximo "+limit+" colunas")
			this.checked=false
			}
		}
	}
}

function vcardOn(elemento) {
	fadeIn(elemento, 0.1);
	document.getElementById(elemento).className = 'on';
}

function vcardOff(elemento) {
	fadeOut(elemento, 0.1);
	document.getElementById(elemento).className = 'off';
}

function visivel(elemento) {
	
	if (document.getElementById(elemento).className == 'off') {
			fadeIn(elemento, 0.1);
		document.getElementById(elemento).className = 'on';
} else if (document.getElementById(elemento).className == 'on') {
		fadeOut(elemento, 0.1);
		document.getElementById(elemento).className = 'off';
	}
}

function TamFonte(num, id)
{
	document.getElementById(id).className = "ft"+num;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha <= 0)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha -= 2;
			}, timer);
}

function fadeIn(id, time) {
	target = document.getElementById(id);
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= 100)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha += 2;
			}, timer);
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}

