function textCounter(id,limite){

campo=document.getElementById(id);
cont=document.getElementById('cont_'+id);

var num=0;
num= campo.value.length;

num=limite-num;

	
if (num>10)
	cont.style.color="#999";
else if ((num<=10)&&(num>=0))
	cont.style.color="#43BA1E";
else if (num<0){
	cont.style.color="#DF0606";
	}

cont.innerHTML =num;

}
function addFav(title,url){

 if (window.sidebar) window.sidebar.addPanel(title, url,"");
 else if(window.opera && window.print){
 var mbm = document.createElement('a');
 mbm.setAttribute('rel','sidebar');
 mbm.setAttribute('href',url);
 mbm.setAttribute('title',title);
 mbm.click();
 }
 else if(document.all){window.external.AddFavorite(url, title);}
}

function getfileextension(inputId)
{
var fileinput = document.getElementById(inputId);
if(!fileinput ) return "";
var filename = fileinput.value;
if( filename.length == 0 ) return "";
var dot = filename.lastIndexOf(".");
if( dot == -1 ) return "";
var extension = filename.substr(dot,filename.length);
return extension;
}
		
function checkfileType(inputId,allowedExt)
{
var ext = getfileextension(inputId);
if( ext != allowedExt ){
alert("Você deve escolher um arquivo "+allowedExt);
document.getElementById(inputId).value="";
return false;
}
}

function abreFecha(div){
	if (document.getElementById(div).style.display=='')
		document.getElementById(div).style.display='none';
	else
		document.getElementById(div).style.display='';

}

function abre(div){
		document.getElementById(div).style.display='';
}

function fecha(div){
		document.getElementById(div).style.display='none';
}


function alternaClasse(div,class1,class2){

	if (document.getElementById(div).className==class1)
		document.getElementById(div).className=class2;
	else
		document.getElementById(div).className=class1;

}