//////////////////////////////////////////////////////////////////////////////////////////////
//valida formulario Contato
function ValidaForm_Contato(form){
	if(form.nome.value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	var str_email = form.email.value ;
    if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' )){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}
	if(form.telefone.value.length<=1){
		alert("O campo Telefone deve estar preenchido corretamente.");
		form.telefone.focus();
		return false;
	}
		if(form.celular.value.length<=1){
		alert("O campo Celular deve estar preenchido corretamente.");
		form.celular.focus();
		return false;
	}

	if(form.cidade.value.length<=1){
		alert("O campo Cidade deve estar preenchido corretamente.");
		form.cidade.focus();
		return false;
	}
	if(form.estado.value.length<=1){
		alert("O campo Estado deve estar selecionado corretamente.");
		form.estado.focus();
		return false;
	}
	if(form.mensagem.value.length<=1){
		alert("O campo Mensagem deve estar preenchido corretamente.");
		form.mensagem.focus();
		return false;
	}
	if(form.cod.value.length<=1){
		alert("O campo Código de Segurança deve estar preenchido corretamente.");
		form.cod.focus();
		return false;
	}
}

function fnMascara(objeto, evt, mask){ 
	var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
	var Letras  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';	
	var Numeros = '0123456789';
	var Fixos  = '().-:/ ';
	var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";
	evt = (evt) ? evt : (window.event) ? window.event : "";
	var value = objeto.value;
	if(evt){
		var ntecla = (evt.which) ? evt.which : evt.keyCode;
		tecla = Charset.substr(ntecla - 32, 1);
		if(ntecla < 32) return true;
		var tamanho = value.length;
		if(tamanho >= mask.length) return false;
		var pos = mask.substr(tamanho,1);
		while(Fixos.indexOf(pos) != -1){
 	 		value += pos;
 	 		tamanho = value.length;
 	 		if (tamanho >= mask.length) return false;
 	 		pos = mask.substr(tamanho,1);
		}
		switch(pos){
   			case '#' : if (Numeros.indexOf(tecla) == -1) return false; break;
   			case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break;
   			case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break;
   			case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break;
   			case '*' : objeto.value = value; return true; break;
   			default : return false; break;
 		}
	}
	objeto.value = value;
	return true;
}

function ValidaForm_OfertasNovos(form){
	if(form.dpnome.value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		form.dpnome.focus();
		return false;
	}
	if(form.dpdataNascimento.value.length<=1){
		alert("O campo Data de Nascimento deve estar preenchido corretamente.");
		form.dpdataNascimento.focus();
		return false;
	}
	
	var contador ;
	var flag ;
	
	flag = false ;
	
	for ( contador = 0 ; contador < form.dpsexo.length ; contador ++ )
	{
		if ( form.dpsexo[contador].checked )
		{
			flag = true ;
		}
	}
	
	if ( !flag )
	{
		alert("O campo Sexo deve estar preenchido corretamente.");
		return false ;
	}
	return true;	

		if(form.dpendereco.value.length<=1){
		alert("O campo Endereço deve estar preenchido corretamente.");
		form.dpendereco.focus();
		return false;
	}

	if(form.dpbairro.value.length<=1){
		alert("O campo Bairro deve estar preenchido corretamente.");
		form.dpbairro.focus();
		return false;
	}
	if(form.dpcep.value.length<=1){
		alert("O campo CEP deve estar selecionado corretamente.");
		form.dpcep.focus();
		return false;
	}
	if(form.dpcidade.value.length<=1){
		alert("O campo Cidade deve estar preenchido corretamente.");
		form.dpcidade.focus();
		return false;
	}
	if(form.dpestado.value.length<=1){
		alert("O campo Estado deve estar selecionado corretamente.");
		form.dpestado.focus();
		return false;
	}
	if(form.dptelefone.value.length<=1){
		alert("O campo Telefone deve estar selecionado corretamente.");
		form.dptelefone.focus();
		return false;
	}
	if(form.dpcelular.value.length<=1){
		alert("O campo Celular deve estar selecionado corretamente.");
		form.dpcelular.focus();
		return false;
	}
	var str_email = form.dpemail.value ;
    if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' )){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.dpemail.focus();
    	return false;
	}
}
