function BuscaConteudoHTML (pstrParam,pstrURL, pstrDivResposta, pstrDivRetorno, pstrBotao, funcao)
{	
	var objAjax; 
	/** Criando o objeto Ajax **/ 
	objAjax = createXMLHTTP();	
	if(pstrDivResposta != '')
		document.getElementById(""+pstrDivResposta+"").innerHTML = "Aguarde, processando...";

	if (pstrBotao != '') 
	{
		if (eval("document.form1."+ pstrBotao) == '[object]') document.getElementById(pstrBotao).disabled = true;
	}
	
	//Efetuando a abertura da requisição, Tipo, URL Requirida, Tipo de Conexão true - Assincrona e false sincrona 
	objAjax.open("post", pstrURL+"?"+pstrParam, true);
	
	//Informando o tipo da página de requisição 
//	objAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	objAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");

	//Informando o controle de cachê no caso abaixo informando para ignorar o cachê 
	objAjax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	objAjax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	objAjax.setRequestHeader("Pragma", "no-cache");

	objAjax.onreadystatechange=function()
	{		
		//Validando o status do retorno 
		if (objAjax.readyState==4)
		{
			if (objAjax.responseText != '')
			{
				var Conteudo = objAjax.responseText
				var ExisteFALHOU = Conteudo.indexOf("|FALHOU|");
				if (ExisteFALHOU >= 0) 
				{ 
					Conteudo = Conteudo.replace("|FALHOU|", "")
					alert(Conteudo);
				}

				var ExisteOK = Conteudo.indexOf("|OK|");
				if (ExisteOK >= 0) 
				{ 
					Conteudo = Conteudo.replace("|OK|", "")
					alert(ConverteTexto(Conteudo));
				}
				
				var ExisteFuncaoJS = Conteudo.indexOf("|FUNCAOJS|");
				if (ExisteFuncaoJS >= 0) 
				{ 
					Conteudo = Conteudo.replace("|FUNCAOJS|", "")
//					alert(Conteudo)
					eval(ConverteTexto(Conteudo));
					Conteudo = ""
				}
			}

			document.getElementById(pstrDivRetorno).innerHTML = Conteudo;

			if (pstrBotao != '') 
			{
				if (eval("document.form1."+ pstrBotao) == '[object]') document.getElementById(pstrBotao).disabled = false;
			}

			// Se Houver alguma mensagem de alerta, exiba a mensagem
			if (funcao != '') 
			{ 
//				alert(funcao)
				eval(funcao); 
			}
		}
	}
	
	//Perceba que a requesição deve ser feita abaixo da função onreadystatechange, Não esqueça de colocar null se não houver nenhum parâmetro senão não funciona nos outros navegadores. 
	objAjax.send(pstrParam);
}

// Função responsável por retornar a posição X de um objeto
function pegarPosicaoX(objeto)
{
 
    var atual_left = 0;
 
    if (objeto.offsetParent) {
        while (objeto.offsetParent) {
            atual_left += objeto.offsetLeft
            objeto = objeto.offsetParent;
        }
    }
    return atual_left;
}

// Função responsável por retornar a posição Y de um objeto
function pegarPosicaoY(objeto)
{
    var atual_top = 0;
    if (objeto.offsetParent) {
        while (objeto.offsetParent) {
            atual_top += objeto.offsetTop
            objeto = objeto.offsetParent;
        }
    }
    return atual_top;
} 

// Função responsável por buscar as cidades de um determinado estado através ajax
function buscarCidades(pstrEstado, pintCidade, strCampoCidade)
{
	var arrListaCidade;
	var arrCidade;
	var objCidade;
	var strConteudo = "";
	var objAjax = createXMLHTTP();
	var params = "strNomeFuncao=listarCidadeAjax&strEstado=" + pstrEstado + "&strCidade=&strTipo=ajax";
	
	limparCombo(document.getElementById(strCampoCidade));
	if (pstrEstado != "")
	{
		document.getElementById(strCampoCidade).options[document.getElementById(strCampoCidade).options.length] = new Option('Aguarde, carregando...', '');

		objAjax.open("post", "http://" + location.host + "/hoteleiro/includes/lib_funcoes_gerais.asp?" + params, true);
		objAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		objAjax.onreadystatechange=function()
		{
			if (objAjax.readyState == 4)
			{
				if (objAjax.responseText != "")
				{
					strConteudo = objAjax.responseText;
					montaCombo(strConteudo, strCampoCidade, pintCidade);
				}
			}
		}
		objAjax.send(params);
	}
}

// Função responsável por montar a combo ajax
function montaCombo(pstrConteudo, pstrCampoCidade, pintCidade)
{
	limparCombo(document.getElementById(pstrCampoCidade));
	arrListaCidade = pstrConteudo.split("#");
	document.getElementById(pstrCampoCidade).options[document.getElementById(pstrCampoCidade).options.length] = new Option("", "");
	if (arrListaCidade.length >= 0)
	{
		for (var intCont in arrListaCidade)
		{
			arrCidade = arrListaCidade[intCont].split("|");
			if ((arrCidade[1] != undefined) && (arrCidade[1] != "undefined"))
			{
				document.getElementById(pstrCampoCidade).options[document.getElementById(pstrCampoCidade).options.length] = new Option(arrCidade[1], arrCidade[0]);
				if (pintCidade == arrCidade[0])
				{
					document.getElementById(pstrCampoCidade).options[document.getElementById(pstrCampoCidade).options.length-1].selected = true;
				}
			}
		}
	}
}

// Função responsável por limpar o combobox informado
function limparCombo(objCombo)
{
	while (objCombo.length >= 1)
	{
		objCombo.options[objCombo.length - 1] = null;
	}
}

function maxHeight() 
{
	var h=0;
	
	if (window.document.innerHeight>h)
		h=window.document.innerHeight;
	
	if (window.document.documentElement.clientHeight>h)
		h=window.document.documentElement.clientHeight;

	if (window.document.body.clientHeight>h)
		h=window.document.body.clientHeight;

	return h;
}

function maxWidth() 
{
	var w=0;
	
	if (window.document.innerWidth>w)
		w=window.document.innerWidth;
		
	if (window.document.documentElement.clientWidth>w)
		w=window.document.documentElement.clientWidth;
		
	if (window.document.body.clientWidth>w)
		w=window.document.body.clientWidth;
		
	return w;
}
