
function checkContatoPublicidade(){
	var emField = document.getElementById('email'); 
	
	var fieldValue = emField.value;
	
	if(fieldValue != ""){  
		var atSymbol = 0;
	
		for(var a = 0; a < fieldValue.length; a++){ 
			if(fieldValue.charAt(a) == "@"){ 
			atSymbol++;
			}
		}
		
		if(atSymbol > 1){ 
			alert("Por Favor, digite um email válido.") ;
			emField.focus();
		    emField.select();
			return false;
		}
		
		if(atSymbol == 1 && fieldValue.charAt(0) != "@"){  
			var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2) ;
			var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false ;
				  
		
			if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
				alert("Por Favor, digite um email válido.");
				emField.focus();
				emField.select();
				return false;
			}
		  		  
		}
		else{  
			alert("Por Favor, digite um email válido.");
			emField.focus();
		    emField.select();
			return false ;
		}
	}
	else{  
		alert("Por Favor, digite um email válido.");
		emField.focus();
		emField.select();
		return false  ;
	}
	
	
	
return true;
}
//End checkContatoPublicidade

function checkRodapeEcoNews(){
	var emField = document.getElementById('econewsemail1'); 
	var emNome = document.getElementById('econewsnome1'); 
	
	var fieldValue = emField.value;
	var fieldValueNome = emNome.value;
	
	if(fieldValueNome != ""){  
	
	}
	else{  
		alert("Por Favor, digite seu nome.");
		emNome.focus();
		emNome.select();
		return false  ;
	}
	
	if(fieldValue != ""){  
		var atSymbol = 0;
	
		for(var a = 0; a < fieldValue.length; a++){ 
			if(fieldValue.charAt(a) == "@"){ 
			atSymbol++;
			}
		}
		
		if(atSymbol > 1){ 
			alert("Por Favor, digite um email válido.") ;
			emField.focus();
		    emField.select();
			return false;
		}
		
		if(atSymbol == 1 && fieldValue.charAt(0) != "@"){  
			var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2) ;
			var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false ;
				  
		
			if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
				alert("Por Favor, digite um email válido.");
				emField.focus();
				emField.select();
				return false;
			}
		  		  
		}
		else{  
			alert("Por Favor, digite um email válido.");
			emField.focus();
		    emField.select();
			return false ;
		}
	}
	else{  
		alert("Por Favor, digite um email válido.");
		emField.focus();
		emField.select();
		return false  ;
	}
	
	
	
return true;
}
//End checkRodapeEcoNews

function checkContatoAnuncio(){
	var emField = document.getElementById('contemail'); 
	var emNome = document.getElementById('contnome'); 
	var fbereser = document.getElementById('contenviar'); 
	
	var fieldValue = emField.value;
	var fieldValueNome = emNome.value;
	
	
	if(fieldValue != ""){  
		var atSymbol = 0;
	
		for(var a = 0; a < fieldValue.length; a++){ 
			if(fieldValue.charAt(a) == "@"){ 
			atSymbol++;
			}
		}
		
		if(atSymbol > 1){ 
			alert("Por Favor, digite um email válido.") ;
			emField.focus();
		    emField.select();
			return false;
		}
		
		if(atSymbol == 1 && fieldValue.charAt(0) != "@"){  
			var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2) ;
			var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false ;
				  
		
			if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
				alert("Por Favor, digite um email válido.");
				emField.focus();
				emField.select();
				return false;
			}
		  		  
		}
		else{  
			alert("Por Favor, digite um email válido.");
			emField.focus();
		    emField.select();
			return false ;
		}
	}
	else{  
		alert("Por Favor, digite um email válido.");
		emField.focus();
		emField.select();
		return false  ;
	}
	
if(fieldValueNome != ""){  
	
}
else{  
	alert("Por Favor, digite seu nome.");
	emNome.focus();
	emNome.select();
	return false  ;
}
	
if (fbereser) { 
	fbereser.style.visibility = "hidden";
	fbereser.style.display = "none";	
}

//return true;
return true;
}
//End checkContatoAnuncio

function textCounterLimitar(field,maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}
}
//End textCounterLimitar

function textLimitarAnuncioReserva() {
	var field = document.getElementById('contcomentario'); 
	var maxlimit = 250;
	if (field) { 
		if (field.value.length > maxlimit) {
			field.value = field.value.substring(0, maxlimit);
		}
	}
}
//End textLimitarAnuncioReserva









window.onload=function(){
 	//Busca
	var buscaf = document.getElementById('formgoogpesq'); 
	if (buscaf && buscaf.q) { 
		var buscaQ = buscaf.q; 
		var buscaL = location; 
		var buscaB = function() { 
			if (buscaQ.value == '') { 
				buscaQ.style.background = '#FFFFFF url(http:\x2F\x2Fwww.ecoviagem.com.br\x2Fimagens\x2Fleiaute2\x2Ffundo-procura-06.gif) left no-repeat'; 
			} 
		}; 
		var buscaC = function() { 
			buscaQ.style.background = '#ffffff'; 
		}; 
		buscaQ.onfocus = buscaC; 
		buscaQ.onblur = buscaB; 
		if (!/[&?]q=[^&]/.test(buscaL.search)) { 
			buscaB(); 
		} 
	}
	
	//Anuncio - Form Contato
	var anuncioFormContato = document.getElementById('formcontato1'); 
	if (anuncioFormContato) { 
		anuncioFormContato.onsubmit = checkContatoAnuncio;
	}
	
	//Anuncio - Form Contato - Campo TextArea Limit Caracter
	var anuncioFormContatoTextArea = document.getElementById('contcomentario'); 
	if (anuncioFormContatoTextArea) { 
		anuncioFormContatoTextArea.onkeyup = function(){
			var field = document.getElementById('contcomentario'); 
			var maxlimit = 250;
			if (field) { 
				if (field.value.length > maxlimit) {
					field.value = field.value.substring(0, maxlimit);
				}
			}
			
		};
		anuncioFormContatoTextArea.onkeydown =  function(){
			var field = document.getElementById('contcomentario'); 
			var maxlimit = 250;
			if (field) { 
				if (field.value.length > maxlimit) {
					field.value = field.value.substring(0, maxlimit);
				}
			}
			
		};
	}
	
	//EcoNews Form Rodape
	var econewsFormRodape = document.getElementById('feconews'); 
	if (econewsFormRodape) { 
		econewsFormRodape.onsubmit = checkRodapeEcoNews;
	}
	
	//Contato - Form 
	var anuncioFormContato = document.getElementById('formcontatopubli'); 
	if (anuncioFormContato) { 
		anuncioFormContato.onsubmit = checkContatoPublicidade;
	}
}
