/*
 * Requisição
 */
function devolveRq(){
	try{
		rq = new XMLHttpRequest();
	}
	catch(erro1){
		try{
			rq = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(erro2){
			try{
				rq = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(erro3){
				window.alert('Seu navegador não tem suporte a Ajax');
				rq = false;
			}
		}
	}
	return rq;
}
var ajax = devolveRq();

/*
 * NEWS
 */
function add(nome,email){
	var rand = parseInt(Math.random()*999999999999);
	var nome = nome;
	var email = email;
	var url = "_inc/newsletter.php?r="+rand+"&act=add&nome="+nome+"&email="+email;
	ajax.open("GET", url, true);
	ajax.onreadystatechange = Gravar;
	ajax.send(null);
}

function Gravar(){
	if(ajax.readyState == 4){
		if(ajax.status == 200){
			var Resp = ajax.responseText;
			document.getElementById("news-home").innerHTML = Resp;
		}else{
			window.alert('ERRO: '+ ajax.statusText);
		}
	}else{
		document.getElementById("news-home").innerHTML = "<div style='padding:10px;font-size:10px;font-weight:bold;text-align:center;'><img src='images/loading.gif' alt='' border='0' width='24' height='24' /><br />Carregando...</div>";
	}
}

	/*
	 * CAMPO BUSCA
	**/
   
$(function(){
  $("#busca").attr({ value: 'O que você procura?' }).focus(function(){
    if($(this).val() == "O que você procura?"){
      $(this).val("");
    }
  }).blur(function(){
    if($(this).val() == ""){
      $(this).val("O que você procura?");
    }
  });
}); 

/* DHTML */
function fechaDHTML(){
	document.getElementById('dhtml').style.visibility = "hidden";
}
