
	var enviar = true;
	
	
	function validaEmail(b)
	{
		if(b.value!="")
		{
			var c=new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
			if(!c.exec(b.value))
			{
				b.style.borderColor = "#fd0505";
				exibirError("O e-mail não está correto!");
				enviar = false;
			}
			else
			{
				closeError(b);
			}
		}
	}
	
	/*
	var soLetras=function(c)
	{
		var b=c.value;b=b.replace(/\d/g,"");
		c.value=b;
	};
	*/
	function telValid(c)
	{
		var b=c.value;
		b=b.replace(/\D/g,"");
		b=b.replace(/^(\d\d)(\d)/g,"($1)$2");
		b=b.replace(/(\d{4})(\d)/,"$1-$2");
		c.value=b;
	}
	function horaValid(c)
	{
		var b=c.value;
		b=b.replace(/\D/g,"");
		b=b.replace(/(\d{2})(\d)/,"$1:$2");
		c.value=b;
	}
	/*
	var data=function(c)
	{
		var b=c.value;
		b=b.replace(/\D/g,"");
		b=b.replace(/(\d{2})(\d)/,"$1/$2");
		b=b.replace(/(\d{2})(\d)/,"$1/$2");
		c.value=b;
	};
	
	
	var maiuscula=function(c)
	{
		var b=c.value;
		b=b.toUpperCase();
		c.value=b;
	};
	
	var confirmaSenha=function(c,b)
	{
		if(c!=b.value)
		{
			a[b.name]=b;
			throw"As senhas n?o conferem";
		}
		else
		{
			a[b.name]=undefined;
		}
	};
	*/
	var validaObrigatorios=function(form)
	{
		var els = form.elements;
		
		if(!enviar)
			return false;	

			for(var i=0;i<els.length;i++)
				if(els[i].getAttribute("style") != null){ els[i].removeAttribute("style"); };
				
			for(var i=0;i<els.length;i++)
			{
				if( els[i].nodeName!="FIELDSET" && els[i].nodeName!="LEGEND" )
				{
					if(els[i].className == "obrigatorio" && els[i].value == "")
					{	
						els[i].style.borderColor = "#fd0505";
						exibirError("Favor preencher os campos obrigatórios!");
						return false;
					}
				}
			}		

	};
	
	function exibirError(error)
	{
		var box = document.getElementById("msgError");
		box.style.visibility = "visible";
		box.innerHTML = error;
	}
	function closeError(el)
	{
		enviar = true;
		if(el.getAttribute("style") != null){el.removeAttribute("style");};
		var box = document.getElementById("msgError");
		box.style.visibility = "hidden";
		box.innerHTML = "&nbsp;";
	}

