
function checkEqual(campos, names) {
var campo=campos.split(",");
var campovalue=campo[0];

var cvl=document.getElementById(campovalue).value;
 for (var i=1;i<campo.length;i++)
 {
	var testevalor=document.getElementById(campo[i]).value;
 if (testevalor!=cvl)
 {
	alert ('Os campos '+names+' precisam ser iguais');
 	return false
	}
 }
 return true;
}


function validaFormAuto(form)
{
  for (i=0;i<form.length;i++)
{
  if (form[i].value == "")
  {
    if (form[i].id.length > 0)
      {
        var nome = form[i].name.substring(1,form[i].name.length);
        var ident = form[i].id;
        alert("Preencha o campo " + ident + ".");
        form[i].focus();
        return false
      }
    }
  }
return true
}

function desabilita(campos) {
	var campo;
	campo=campos.split(",");
	
	for (var i=0;i<campo.length;i++)
	{ 
	var div_id=campo[i];
	document.getElementById(div_id).disabled=true;
	}
}

function habilita(campos) {
	var campo;
	campo=campos.split(",");
	
	for (var i=0;i<campo.length;i++)
	{ 
	var div=campo[i];
	document.getElementById(div).disabled=false;
	}
}

function checkEmptyNames(campos,nomes)
{
	var campo;
	var divid;
	campo=campos.split(",");
	nome=nomes.split(",");
	
	
	for (var i=0;i<campo.length;i++)
	{ 
	divid=campo[i];
	if (document.getElementById(divid))
	{
	if (document.getElementById(divid).value=='')
	{
		alert('Preencha '+nome[i]+'.');
		document.getElementById(divid).focus();
		return false;
	}
	}
	else
	{ alert('Erro: ID '+divid+' inexistente');}
	}
	
  return true
}

function fill(ident,valor) {
	var ident;
	var valor;
	
	if (valor!="" && document.getElementById(ident))
	{document.getElementById(ident).value=valor;}
	}
	
function jump(campo,maxim,next) {
	var campo;
	var maxim;
	var next;
	
	if (document.getElementById(campo).value.length==maxim)
	{
		document.getElementById(next).focus();
		document.getElementById(next).select();}
								
}
function checkquiz(){
    var i
    for (i=0;i<document.form1.correta.length;i++){
       if (document.form1.correta[i].checked)
       { return true;}
    }
    
	alert('Marque a opção que for correta');
	return false;
}

function checkquiz2(){
    var i
    for (i=0;i<document.questao.resposta.length;i++){
       if (document.questao.resposta[i].checked)
       { return true;}
    }
    
	alert('Escolha uma opção');
	return false;
}

function addtag(name)
{
	var name;
	var tagvalue=document.getElementById("tags").value;
	var ultimo=tagvalue.charAt(tagvalue.length-1);
  	
  	if ((ultimo==',') || (ultimo=='') || (tagvalue==""))
  	{
  	document.getElementById("tags").value = tagvalue + name + ",";
  	}
  	else
  	{
  	document.getElementById("tags").value= tagvalue +","+name+",";
  	}

}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
{field.value = field.value.substring(0, maxlimit);}
else  // otherwise, update 'characters left' counter
{countfield.value = maxlimit - field.value.length;}

}