/* [campos obrigatórios] */
var varEnv = false;
function fncObrigatorios(objObrig, Alerta){
	if(varEnv) return false;
	for(var f=0; f<objObrig.length; f++){
		var campo = objObrig[f].split(":");
		if(document.getElementById(campo[0])){
			fncRetSpc(document.getElementById(campo[0]));
			if(!document.getElementById(campo[0]).value){
				if(Alerta) window.alert("Os campos marcados com asterisco são de preenchimento obrigatório.");
				document.getElementById(campo[0]).focus();
				return false;
			}
			if(campo[1] && !fncValidaMail(document.getElementById(campo[0]))){
				if(Alerta) window.alert("O e-mail está incorreto.");
				document.getElementById(campo[0]).select();
				return false;
			}
		}
	}
	varEnv = true;
	return true;
}
/* [campos apenas com nï¿½meros - uso: onKeyPress="return fncNumeros(event);"] */
function fncNumeros(e){
	var whichCode = (window.Event)? e.which : e.keyCode;
	if(whichCode>=48 && whichCode<=57 || whichCode==8 || whichCode==9 || whichCode==32 || whichCode==45) return true;
	return true; // TODO trocar para false quando descobrir problema no IE //
}
/* [retira espaï¿½os do inicio] */
function fncRetSpc(obj){
	var ret = obj.value;
	if(ret.indexOf(" ")==0){
		do{
			ret = ret.substr(1);
		}while(ret.indexOf(" ")==0)
		obj.value = ret;
	}
	return;
}
/* [valida e-mail] */
function fncValidaMail(obj){
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/; 
	if (!re_mail.test(obj.value)) return false;
	return true;
}
