//BUSCA
do_search = function( form ){
	if( form.elements['query'].value.length < 1 ){
		alert( 'Digite o item de busca' );
		form.elements['query'].focus();
		return false;
	}
	//url = ('./busca/' + form.elements['query'].value + '/1/').split(" ").join("+");
return false;	
url = 'http://www.estacaoalegria.com.br/busca/search.php?q=' + form.elements['query'].value;
	location.href = url;
	return false;
}


//AJAX - newsletter
function Dados() {
	
	//verifica se o browser tem suporte a ajax
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				alert("Esse browser não tem recursos para uso do Ajax");
				xmlhttp = false;
			}
		}
	}
	//se tiver suporte ajax
	if(xmlhttp) {
	 
		var digEmail = document.getElementById("email").value;
		var boxNovi = document.getElementById("msg_novidades");
		xmlhttp.open("GET","http://www.estacaoalegria.com.br/ajax/ajax.php?email="+digEmail,true);
		xmlhttp.onreadystatechange=function() {

			if (xmlhttp.readyState==4){

			var texto = eval(xmlhttp.responseText)?"Receba nossas novidades e promoções no seu e-mail.":"<span class='alerta'>O e-mail <b>"+digEmail+"</b> já foi cadastrado.</span>";

            //Exibe o texto no div conteúdo
            var conteudo=document.getElementById("msg_novidades")
            conteudo.innerHTML=texto
			}
		}
	}
    xmlhttp.send(null)
}

//AJAX
function cadastraNews() {

	//verifica se o browser tem suporte a ajax
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				alert("Esse browser não tem recursos para uso do Ajax");
				xmlhttp = false;
			}
		}
	}
	//alert(xmlhttp);
	//se tiver suporte ajax
	if(xmlhttp) {
	 
		var digEmail = document.getElementById("email").value;
		var digNome = document.getElementById("nome").value;
		var boxNovi = document.getElementById("msg_novidades");
		xmlhttp.open("GET","http://www.estacaoalegria.com.br/ajax/novidades.php?nome="+digNome+"&email="+digEmail,true);
		xmlhttp.onreadystatechange=function() {

			//enquanto estiver processando...exibe a msg de verificando
			if(xmlhttp.readyState == 1) {
				
				var enviando="<h4>Cadastrando...</h4>";
				var conteudo=document.getElementById("statusnews");
				conteudo.innerHTML=enviando;

			}
			//após ser processado
			if (xmlhttp.readyState==4){

				var enviando="";
				var conteudo=document.getElementById("statusnews");
				conteudo.innerHTML=enviando;
				var txnovi = eval(xmlhttp.responseText)?"<b>Para confirmar o cadastro, por favor verifique seu e-mail!</b>":"<span class='alerta'>O e-mail <b>"+digEmail+"</b> já foi cadastrado.</span>";
				//Exibe o texto no div conteúdo
				var conteudo=document.getElementById("msg_novidades");
				conteudo.innerHTML=txnovi;
        }
    }
    xmlhttp.send(null)
	}
	return false;
}


//DESTAQUE
destaque = new FlashObject("http://www.estacaoalegria.com.br/images/destaque.swf", "swfdestaque", "438", "181", 6, "#FFFFFF");
destaque.altTxt = '<a href="http://www.macromedia.com/go/getflashplayer/" target="_blank"><img src="images/no_destaque.gif" alt="Instalar plugin Macromedia Flash" /></a>';
destaque.bypassTxt = '';

//SETAR BLANK
blank_it = function(){
	if( !document.getElementsByTagName ){ return; }
	c = ( arguments.length == 1 )? arguments[0] : '_blank';
	t = document.getElementsByTagName('A');
	for( i = 0; i < t.length; i++ ){ if( t[i].className.indexOf(c) != -1 ){ t[i].target = "_blank"; } }
}
set_i = function( field, check, val ){
	if( field.value == check ){ field.value = val; }
}


window.onload = function(){ blank_it(); }