function testaclickradio()
{
	
}

function testacamporadio(formulario, quanttotal, quantquest)
{
	soma_importancia=0
	soma_satisfacao=0
	elementos = document.forms[formulario]
	//alert (elementos)
	var itemform;
	var stringerro = ""
	var ultimaquestao
	for(itemform in document.forms[formulario])
	{
		stringnome=itemform.substr(0,2)
		//alert (stringnome)
		if (stringnome=='ah')
		{
			//alert(elementos.item(itemform).value)
			//for (contint1 = 0; contint1 < graumaximo; contint1++)
			//{
				if (document.forms[formulario].elements[itemform].value == 1)
				{
					soma_importancia++
				}
				else
				{
					
					numquestaoerro=itemform.substring(4,itemform.indexOf('_',4))
					if (numquestaoerro != ultimaquestao)
					{
						ultimaquestao = numquestaoerro
						stringerro = stringerro + "Questão de número "+ numquestaoerro + "\n"
					}
				}
			//}
		}
		
		/*if (stringnome=='ahs')
		{
			if (document.forms[formulario].item(itemform).value == 1)
				soma_satisfacao++
		}*/
	}
	//alert (soma_importancia + '/' + soma_satisfacao + '/' + quanttotal + '/' + quantquest)
	//if (!(soma_importancia == quantquest && soma_satisfacao == quanttotal) )
	if (stringerro!="")
	{
		alert ("Você deixou de preencher completamente as seguintes questões objetivas:\n" + stringerro)
		
	}
	else
	{
		document.form1.submitbutton.disabled = true;
		document.form1.submitbutton.value = 'Processando...';
		document.form1.submit()
	}
}

function calculaquotas(campototal, formulario, caso)
{
	soma=0
	elementos = document.forms[formulario]
	//alert (elementos)
	var itemform;
	for(itemform in document.forms[formulario])
	{
		stringnome=itemform.substr(0,3)
		//alert (stringnome)
		if (stringnome=='edt' && elementos.item(itemform).value!='' && elementos.item(itemform).value!=0)
		{
			//alert(elementos.item(itemform).value)
			soma=soma + parseInt(elementos.item(itemform).value)
			if (soma <= elementos.item('totalmax').value)
			{
				elementos.item(campototal).value = soma
			}
			else
			{
				elementos.item(itemform).value=0
				alert('A soma das Quotas NAO pode ultrapassar\n o valor total de '+elementos.item('totalmax').value)
			}
		}
		
		//alert(document.forms[formulario].itemform[])
		//
		//if (elementos.item(itemform).name=="edt")
		//{
		//	alert (elementos.item(itemform).value)
		//	
		//}
	}

}
function localizasrclist(texto)
{
	srcList = window.document.forms[0].cod; 
	tamtextproc=texto.length;
	for(var i = 0; i < srcList.length; i++)
	{
		srcList.options[i].selected=false;
	}
	for(var i = 0; i < srcList.length; i++)
	{
		itematual=srcList.options[i].text;
		segitematual=itematual.substr(0,tamtextproc);
		texto=texto.toLowerCase();
		segitematual=segitematual.toLowerCase();
		//alert(segitematual + '/' + texto);
		if (segitematual==texto)
		{
			srcList.options[i].selected=true;
			break;
		}
	}
}
function parametriza(nome, valor, pagina)
{
	window.open(pagina+"?"+nome+"="+valor,"_self")
}
//funcoes de limitacao de caracteres
/////////////////////////////////////////////////////////////////////////////////////////
function limitanumeros()
{
	if (
		window.event.keyCode>=48 && window.event.keyCode<=57 ||
		window.event.keyCode>=96 && window.event.keyCode<=105 ||
		window.event.keyCode==8 ||
		window.event.keyCode==9
	)
	{
		return true
	}
	else
	{
		return false
	}
}
/////////////////////////////////////////////////////////////////////////////////////////
function mascaracampohora(campo)
{
	

	var valor = new String(campo.value);
	valor = valor.replace(":", "");

	if (valor.length > 2) {valor = valor.substring(0,2) + ":" + valor.substring(2,valor.length);}
		
	campo.value=valor;

}
/////////////////////////////////////////////////////////////////////////////////////////
function mascaracampocnpj(campo)
{
	

	var valor = new String(campo.value);
	valor = valor.replace(".", "");
	valor = valor.replace(".", "");
	valor = valor.replace("/", "");
	valor = valor.replace("-", "");

	if (valor.length > 2) {valor = valor.substring(0,2) + "." + valor.substring(2,valor.length);}
	if (valor.length > 6) {valor = valor.substring(0,6) + "." + valor.substring(6,valor.length);}
	if (valor.length > 10) {valor = valor.substring(0,10) + "/" + valor.substring(10,valor.length);}
	if (valor.length > 15) {valor = valor.substring(0,15) + "-" + valor.substr(15,2);}
		
	campo.value=valor;

}
/////////////////////////////////////////////////////////////////////////////////////////
function mascaracampocpf(campo)
{
		valor = new String(campo.value);
	//alert(window.event.keyCode);
		valor = valor.replace(".", "");
		valor = valor.replace(".", "");
		valor = valor.replace("-", "");
		
		if (valor.length > 3) {valor = valor.substring(0,3) + "." + valor.substring(3,valor.length);}
		if (valor.length > 7) {valor = valor.substring(0,7) + "." + valor.substring(7,valor.length);}
		if (valor.length > 11) {valor = valor.substring(0,11) + "-" + valor.substr(11,2);}
		
/*		switch (valor.length)
		{
		case :
			valor = valor.substring(0,2) + "." + valor.substring(3,valor.length-1);
			break;
		case 8:
			valor = valor.substring(0,2) + "." + valor.substr(3,5)+ "." + valor.substring(3,valor.length-1);
			break;
		case 9:
			valor = "(" + valor.substr(0,2) + ")" + valor.substr(2,3) + "-" + valor.substr(5,4);
			break;
		case 10:
			valor = "(" + valor.substr(0,2) + ")" + valor.substr(2,4) + "-" + valor.substr(6,4);
			break;
		}*/	
	campo.value=valor;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
function mascaracampodata(campo)
{
	valor = new String(campo.value);
		if (valor.length==2)
		{valor=valor + "/"}
		
		if (valor.length==5)
		{valor=valor + "/"}
		
		if (valor.length==10)
		{
			dia=valor.substr(0,10);
			mes=valor.substr(3,10);
			ano=valor.substr(6,10);
			ultimodiames = new Array(12);
			ultimodiames[1]=31;
			if (ano % 4  == 0)
			{ultimodiames[2]=29;}
			else
			{ultimodiames[2]=28;}
			ultimodiames[03]=31;
			ultimodiames[04]=30;
			ultimodiames[05]=31;
			ultimodiames[06]=30;
			ultimodiames[07]=31;
			ultimodiames[08]=31;
			ultimodiames[09]=30;
			ultimodiames[10]=31;
			ultimodiames[11]=30;
			ultimodiames[12]=31;
			if (parseInt(dia,10)<=0 || parseInt(dia,10)>ultimodiames[parseInt(mes,10)])
			{
			alert('Este mês só tem '+ ultimodiames[parseInt(mes,10)] +' dias');
			}
			if (parseInt(mes,10)<=0 || parseInt(mes,10)>12)
			{
			alert('Só existem 12 meses')
			}
			if (parseInt(ano,10)<=1500 || parseInt(ano,10)>3000)
			{
			alert('Indique um ano de 1500 a 3000')
			}
		}
	campo.value=valor;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
function mascaracamponumerodecimal(campo,casas)
{
	valor = new String(campo.value);
	for (contponto=1;contponto<=10;contponto++)
	{valor=valor.replace('.','')}
	valor=valor.replace(',','')
	for (i=0;i<valor.length;i++)
		{
			if (valor.substr(i,1)!='0' || i==valor.length-1)
			{
			valor=valor.substr(i,valor.length)	
			break;
			}
		}
		
	if (valor.length==0)
	{
		valor='0'	
		for (qc1=1;qc1<=casas;qc1++){valor = valor + '0' }
	}
	else if (valor.length<=casas)
	{
		zeros='0'
		for (qc1=1;qc1<=casas-valor.length;qc1++){zeros = zeros + '0' }
		valor=zeros + valor
	}

inteiro = valor.substr(0,valor.length-casas)
inteironovo = ''
decimal = valor.substr(valor.length-casas,casas)

quantint = inteiro.length
contintaux = 1
for (contint=quantint-1;contint > - 1;contint--)
{
	//alert('entrou for')
	if (contintaux % 4 == 0)
	{
		//alert('entrou mod')
		inteironovo = '.' + inteironovo
		inteironovo = inteiro.substr(contint,1) + inteironovo
		contintaux = 1
	}
	else
	{
		//alert('entrou nao mod ' + contint)
		inteironovo = inteiro.substr(contint,1) + inteironovo
	}
	contintaux++
}
	//alert(inteiro)
	//alert(inteironovo)
	valor = inteironovo + "," + decimal
	campo.value=valor;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
function mascaracampocep(campo)
{
	valor = new String(campo.value);
	//alert(window.event.keyCode);
		if (valor.length>5 && valor.length<10)
		{
			valor = valor.replace("-", "");
			valor = valor.substr(0,5) + "-" + valor.substr(5,3);
		}
	campo.value=valor;
}
////////////////////////////////////////////////////////////////////////////////////////////////
function mascaracampotelefone(campo)
{
	valor = new String(campo.value);
	//alert(window.event.keyCode);
		if (valor.length<14)
		{
			valor = valor.replace("(", "");
			valor = valor.replace(")", "");
			valor = valor.replace("-", "");
			valor = valor.replace(" ", "");
		}
		switch (valor.length)
		{
		case 7:
			valor = valor.substr(0,3) + "-" + valor.substr(3,4);
			break;
		case 8:
			valor = valor.substr(0,4) + "-" + valor.substr(4,4);
			break;
		case 9:
			valor = "(" + valor.substr(0,2) + ")" + valor.substr(2,3) + "-" + valor.substr(5,4);
			break;
		case 10:
			valor = "(" + valor.substr(0,2) + ")" + valor.substr(2,4) + "-" + valor.substr(6,4);
			break;
		}	
	campo.value=valor;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//funcoes gerais de validacao
//////////////////////////////////////////////////////////////////////////////////////////////////
function testadatas(form,campo1,campo2)
{
	valor1=document.forms[form].item(campo1).value;
	valor2=document.forms[form].item(campo2).value;
	ano1=valor1.substr(6,4)
	ano2=valor2.substr(6,4)
	mes1=valor1.substr(3,2)
	mes2=valor2.substr(3,2)
	dia1=valor1.substr(0,2)
	dia2=valor2.substr(0,2)
	
	if (ano1>ano2)
	{
		return false
	}
	else
	{
		if ((mes1>mes2) && (ano1==ano2))
		{
			return false
		}
		else
		{
			if ((dia1>dia2) && (mes1==mes2) && (ano1==ano2))
			{
				return false
			}
			else
			{
				return true
			}
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function testacamposiguais(form,campo1,campo2)
{
	valor1=document.forms[form].item(campo1).value;
	valor2=document.forms[form].item(campo2).value;
	if (valor1!=valor2)
	{
		//alert(mensagem);
		return false;
	}
	else
	{return true;}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
function testacampogenerico(form,campo)
{
	valor=document.forms[form].item(campo).value;
	if (valor=="")
	{
		//alert(mensagem);
		return false;
	}
	else
	{return true;}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
function testacampoemail(form, campo, mensagem)
{
	//alert("teste");
	valor=document.forms[form].item(campo).value;
	if (valor!="")
	{
		a=valor.indexOf('@');
		if ( (a<1) || (a==(valor.length-1)) )
		{
			//alert(mensagem);
			return false;
		}
		else
		{return true;}
	}
	else
	{
		return true;
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function testacampocombo(form,campo)
{
valor = document.forms[form].item(campo).selectedIndex;
if (valor==0)
{return false}
else
{return true}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
function testacampocnpj(form,campo)
{
	pcgc = document.forms[form].item(campo).value;
	// verifica o tamanho
	pcgc = pcgc.replace(".", "");
	pcgc = pcgc.replace(".", "");
	pcgc = pcgc.replace("/", "");
	pcgc = pcgc.replace("-", "");	
	if (pcgc.length != 14) 
	{
		sim=false
		//alert ("Tamanho Inválido de CNPJ")
		return false
	}
	else {sim=true}
	if (sim ) // verifica se e numero
	{
		for (i=0;((i<=(pcgc.length-1))&& sim); i++)
		{
			val = pcgc.charAt(i)
			// alert (val)
			if
			((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") &&
			(val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
		}
		if (sim) // se for numero continua
		{
			m2 = 2
			soma1 = 0
			soma2 = 0
			for (i=11;i>=0;i--)
			{
				val = eval(pcgc.charAt(i))
				// alert ("Valor do Val: "+val)
				m1 = m2
				if (m2<9) { m2 = m2+1}
				else {m2 = 2}
				soma1 = soma1 + (val * m1)
				soma2 = soma2 + (val * m2)
			} // fim do for de soma
			
			soma1 = soma1 % 11
			if (soma1 < 2) { d1 = 0}
			else { d1 = 11- soma1}
			
			soma2 = (soma2 + (2 * d1)) % 11
			if (soma2 < 2) { d2 = 0}
			else { d2 = 11- soma2}
			// alert (d1)
			// alert (d2)
			if ((d1==pcgc.charAt(12)) && (d2==pcgc.charAt(13)))
			{ //alert("CNPJ Válido")
				return true
			}
			return false//else alert("Valor inválido de CNPJ")
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////
function testacampodata(form,campo)
{
	valor = new String(document.forms[form].item(campo).value);
	
		if (valor.length==10)
		{
			dia=valor.substr(0,2);
			mes=valor.substr(3,2);
			ano=valor.substr(6,4);
			ultimodiames = new Array(12);
			ultimodiames[1]=31;
			if (ano % 4  == 0)
			{ultimodiames[2]=29;}
			else
			{ultimodiames[2]=28;}
			ultimodiames[03]=31;
			ultimodiames[04]=30;
			ultimodiames[05]=31;
			ultimodiames[06]=30;
			ultimodiames[07]=31;
			ultimodiames[08]=31;
			ultimodiames[09]=30;
			ultimodiames[10]=31;
			ultimodiames[11]=30;
			ultimodiames[12]=31;
			//alert(dia+mes+ano)
			
			if (parseInt(dia,10)<=0 || parseInt(dia,10)>ultimodiames[parseInt(mes,10)])
			{return false}
			if (parseInt(mes,10)<=0 || parseInt(mes,10)>12)
			{return false}
			if (parseInt(ano,10)<1500 || parseInt(ano,10)>3000)
			{return false}
		}
		else
		{return false}
		return true
}
////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////
//set $form1 = new phpform()

//$form1->addedit(nome, tamanho, largura, tipo, mensagem, tabela, campo)
//$form1->addcombo(nome, largura, mensagem, "select ", codigo)
