// JavaScript Document
function validar(nombre,campos)
{
	if ((!campos) || (!nombre))
		return false;
	
	formulario = document.getElementById(nombre);
	
	error = false;
	for (x in campos)
	{
		tmp = document.getElementById(campos[x]);
		tmp2 = document.getElementById(campos[x]+'2');

		if (!tmp)
			continue;
		
		if ((tmp.type == "text") || (tmp.type == "textarea") || (tmp.type == "file"))
		{
			if (tmp.value == "")
			{
				if (!tmp2) 
				{
					error = true;
					tmp.className = "input_error";
					continue;
				}
				if ((tmp2.selectedIndex <= 0) || (tmp2.selectedIndex == null))
				{
					
					error = true;
					tmp.className = "input_error";
					tmp2.className = "input_error";
				}
			}
		}
		else if (tmp.type == "select-one")
		{
			if ((tmp.selectedIndex <= 0) || (tmp.selectedIndex == null))
			{
				error = true;
				tmp.className = "input_error";
			}					
		}
	}
	if (error == true)
		alert("Por favor complete todos los campos");
	else
		formulario.submit();
}
