/*
	*************************************************************
						FUNÇÕES PARA VALIDAÇÃO
						
						(c)2005 TrevoWebDesign
	*************************************************************
*/

function verficaritems(nome, formulario)
{
	//verificar se existem checkboxes true
	for (var i=0;i<formulario.elements.length;i++)
	{
		//e = elemento actual
		var e=formulario.elements[i];
		//se a checkbox for diferente de ALLBOX e igual a item entao subtituir estado pelo o da ALLBOX
		var string = e.name
		prefixo = string.substring(0, 4); //buscar prefixo da checkbox
		string = string.substring(4, e.name.length); //retirar prefixo da checkbox
		if ((e.checked==true) && (string!='allbox') && (e.type=='checkbox') && (prefixo==nome))
		{
			//confirmar submissão
			resposta=confirm ("Deseja submeter as informações?")
			if (resposta==false)
			{
				return false;
			}
			
			return true;
		}
	}
	alert('É necessário seleccionar items para realizar uma acção!');
	return false;
}

function verficarcampos(campos)
{
	cancel = false;
	
	//verificar se os campos estão preenchidos
	for (i=0; i<campos.elements.length; i++)
	{
		if (campos.elements[i].type=="text" || campos.elements[i].type=="password")
		{
			if (campos.elements[i].value=="" && campos.elements[i].alt=="*")
			{
				//mostrar mensagem retirando o prefixo de indentificação do formulario [pre_]
				
				campos.elements[i].style.background = '#FFAEAE';
				cancel = true;
			}
			else
			{
				campos.elements[i].style.background = '#FFFFFF';	
			}
		}
	}
	if (cancel == true) 
	{
		alert("Please fill all the requested fields!");
		return false;
	}
	/*confirmar submissão
	resposta=confirm ("Deseja submeter as informações?")
	if (resposta==false)
	{
		return false;
	}*/
	
	return true;
}