
function initRequest() {
	var req=false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		req = new XMLHttpRequest();
		if (req.overrideMimeType) {
			req.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) { // IE
		try { req = new ActiveXObject("Msxml2.XMLHTTP");
		}	catch (e) {
				try { req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
		 	}
	}
	if (!req) { 
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	else{
		return req;
	}
}
//------------------------------------------------------------------

function moveTb(direcao, id){
	url = "?acao=imovel&par="+direcao+"&id="+id+"&ajax=1";
	document.getElementById("imgtb").src = "img/ajax1.gif"
	executa(url, "tb");
	ab();
}

function executaComAlert( url ) {
	var	http_request = true;
	http_request= new initRequest();
	http_request.open('GET', url, true);
	http_request.onreadystatechange = function() 
					{ 	
						if (http_request.readyState == 4) {
							if (http_request.status == 200) {
								alert( http_request.responseText );
							}
							else { 
							alert('Ępa! Houve um problema ao exibir esta página.');
							}
						}
					}
	http_request.send(null);
}
//------------------------------------------------------------------

function executa(url,id) {
	var	http_request = false;
//	if (id=="residencial" || id=="T") {document.getElementById("imgf").src = "img/ajax1.gif";}
	url=url+'&at='+Date();
	http_request= new initRequest();
	http_request.open('GET', url, true);
	http_request.onreadystatechange = function() 
					{ 	
						if (http_request.readyState == 4) {
							if (http_request.status == 200) {
								if(http_request.responseText!=''){
									document.getElementById(id).innerHTML = http_request.responseText;
									if(id=="tb"){ab();}
								}
							}
							else { alert('Houve um problema ao exibir esta página.');
							}
						}
					}
	http_request.send(null);
}
//------------------------------------------------------------------

var i = new Image;
i.src = "img/ajax1.gif";

var img="";
//.......
function setImg(arq){
	if(img!="" && arq.length()==5){eUltFoto();}else{nUltFoto();}
	img=arq;
}//.......

function ajax(url) {
	var	http_request = false;
	url=url+'&at='+Date();
	http_request= new initRequest();
	http_request.open('GET', url, true);
	http_request.onreadystatechange = function() 
					{ 	
						if (http_request.readyState == 4) {
							if (http_request.status == 200) {
								if(http_request.responseText!=''){
									var r = http_request.responseText;
									setImg(r);
								}
							}
							else { alert('Ępa! Houve um problema ao exibir esta página.');
							}
						}
					}
	http_request.send(null);
}
//------------------------------------------------------------------

function ab(){
	if(navigator.appName=='Microsoft Internet Explorer'){
		document.getElementById("b2").style.left=-1;
		document.getElementById("b3tit").style.top=9;
	}
	if(navigator.userAgent.indexOf('Firefox',1)>-1){
//		document.getElementById("imgtop").style.top=-16;
	}
	if(navigator.userAgent.indexOf('Chrome',1)>-1){
		document.getElementById("b2").style.left=-1;
	}
}
function at(){
	if(navigator.appName=='Microsoft Internet Explorer'){
//		document.getElementById("info1").style.top=10;
	}
	if(navigator.userAgent.indexOf('Firefox',1)>-1){
		document.getElementById("info1").style.top="-10";
	}
	if(navigator.userAgent.indexOf('Chrome',1)>-1){
		document.getElementById("info1").style.top="-10";
	}
}
function abreBusca(){
	if(navigator.appName=='Microsoft Internet Explorer'){
			document.getElementById("buscaav").style.height=220;
	}else{	document.getElementById("buscaav").style.height=220;}
	window.scrollTo(0,0);
}
function fecharBusca(id){
	document.getElementById(id).style.height=1;
}

function ba(){
	if(navigator.userAgent.indexOf('Firefox',1)>-1){
		document.getElementById("buscaav").style.top=106;
		document.getElementById("snw").style.top=-11;
	}
	if(navigator.userAgent.indexOf('Chrome',1)>-1){
		document.getElementById("buscaav").style.top="106";
	}
	if(navigator.appName=='Microsoft Internet Explorer'){
//		document.getElementById("imgfrmcad").style.top="-277";
	}
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY){
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return pageHeight;//arrayPageSize;
}//.......


