/*
**************************************
* Event Listener Function v1.4       *
* Autor: Carlos R. L. Rodrigues      *
**************************************
*/
addEvent = function(o, e, f, s){
	var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
	r[r.length] = [f, s || o], o[e] = function(e){
		try{
			(e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
			e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
			e.target || (e.target = e.srcElement || null);
			e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
		}catch(f){}
		for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
		return e = null, !!d;
    }
};

removeEvent = function(o, e, f, s){
	for(var i = (e = o["_on" + e] || []).length; i;)
		if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
			return delete e[i];
	return false;
};











function goPesquisa(tipo,idEmp,idSta,idReg){



	//if(idReg !="" && idSta !=""){

	//	tipo=2

	//}

	//if((idReg != "" && idSta =="")||(idReg == "" && idSta !="")){

		tipo=2	

	//}



	url="/inc/fixed/gravaStat.php?function=gravaPesquisa&tipo=" + tipo + "&id_empreendimento=" + idEmp + "&id_status=" + idSta + "&id_regiao=" + idReg

	

	new Ajax.Request(url, {

	method: 'post',

	onSuccess: function(response) {

		if(response.responseText){

			if(response.responseText=="1"){

				this.location="/busca/empreendimentos.php?tipo=" + tipo + "&id_empreendimento=" + idEmp + "&id_status=" + idSta + "&id_regiao=" + idReg

			}

		}

	}

	})

}







function goEmpreendimento(urlx){

	if(urlx!=""){

		this.location=urlx

	}

}



function redirPesquisa(){

	tipo=2

	idEmp=0

	idSta=document.getElementById("lista3").value

	idReg=document.getElementById("lista2").value

	

	if (idReg==''){

		idReg==0

	}

	if (idSta==''){

		idSta==0

	}



	goPesquisa(tipo,'',idSta,idReg)

}
