// função para facilitar a vida.. heeh
function gE(ID){
	return document.getElementById(ID);
}

//função para mostrar algum elemento com displau none
function mostraElemento(param){
	var p = gE(param);
	
	if (p.style.display == 'none'){
		p.style.display = 'block';	
	}else{
		p.style.display = 'none';		
	}
	
}

// abre pop-up
function abrePopUp(url, id, largura, altura){
	window.open(url, id, 'width='+largura+', height='+altura+', scrollbars=no');
}

var Validacao = {
	ValidaItens: function(){
		var args = Validacao.ValidaItens.arguments; // coloca os parametros em uma variavel no qual se tornará um Array
		if (args.length > 0){ // verifica se há parametros atribuidos a função
			for (var x = 0; x < args.length; x++){
				var vItem = gE(args[x]);
				if (vItem.value == "" || vItem.value == null){
					vItem.focus();
					vItem.style.border = 'solid 1px #006600';
					alert("Campo em branco");
					return(false);
				}else{
					vItem.style.border = '';
				}				
				//verifica se há algum campo de e-mail para chamar o validaEmail
				var vCampo = args[x].toLowerCase();		
				if (vCampo.indexOf('email') > 0){
					if (Validacao.ValidaEmail(vItem) == false)
						return(false);
				}				
			} // fim do for			
			return(true);
		}else{
			alert('Ocorreu um erro ao realizar operação');
			return(false);			
		}// else (args.length > 0){
	}, // fim do ValidaItens
	
	ValidaEmail: function(pCampo){
		var email = pCampo.value;
		var resp = email.search(/(\w[\w\.\+]+)@(.+)\.(\w+)$/)==0;
		
		if (resp == false){
			pCampo.focus();
			pCampo.style.border = 'solid 1px red';
			alert('E-mail inválido');
			return(false);
		}else{
			return(true);
		}
	}
};