function limparCampos(idFld,valorPadrao)
{
	objeto = document.getElementById(idFld);

	if(objeto.value == valorPadrao)
	{
		objeto.value = "";
	}
}



function montaModal(id, msg, fcn)
{
	if(document.getElementById(id))
	{
		document.getElementById(id).style.display='';
		document.getElementById("container" + id).innerHTML = msg;
		return;
	}

	modal = document.createElement("div");
	modal.setAttribute("id",id);
	document.body.appendChild(modal);


	objModal = document.getElementById(id);


	objModal.style.position = "absolute";
	objModal.style.top="0";
	objModal.style.left="0";


	alturaModal = document.body.scrollHeight;
	if(document.body.scrollHeight < document.body.clientHeight)
	{
		alturaModal = document.body.clientHeight;
	}

	objModal.style.height = alturaModal;
	objModal.style.width  = document.body.scrollWidth;
	objModal.style.backgroundColor='black';
	objModal.style.zIndex=10;
	objModal.style.opacity=0.8;
	objModal.style.filter="alpha(opacity=90)";


	msgModal = document.createElement("div");
	msgModal.setAttribute("id","msg" + id);
	objModal.appendChild(msgModal);

	objMsgModal = document.getElementById("msg" + id);

	objMsgModal.style.backgroundColor='#FFF'
	objMsgModal.style.zIndex=11;
	objMsgModal.style.height='200px';
	objMsgModal.style.width='350px';
	objMsgModal.style.position = "absolute";
	objMsgModal.style.top  = (document.body.scrollHeight / 2) - 100;
	objMsgModal.style.left = (document.body.scrollWidth / 2) - 175;

	objMsgModal.style.opacity=2;
	objMsgModal.style.filter="alpha(opacity=180)";

	btnModal = document.createElement("input");
	btnModal.setAttribute("id","btn" + id);
	btnModal.setAttribute("type","button");
	btnModal.setAttribute("value","Ok");


	objMsgModal.appendChild(btnModal);

	objBtnModal = document.getElementById("btn" + id);

	fcnEx = "void(0)";
	if(fcn != "")
	{
		fcnEx = fcn;
	}
	
	
	objBtnModal.onclick= function() {objModal.style.display='none'; eval(fcnEx)};

	objBtnModal.style.zIndex=101;
	objBtnModal.style.width='65px';
	objBtnModal.style.position = "relative";
	objBtnModal.style.top = 160;
	objBtnModal.style.left = 145;


	containerModal = document.createElement("div");
	containerModal.setAttribute("id","container" + id);
	objMsgModal.appendChild(containerModal);

	objContainerModal = document.getElementById("container" + id);

	objContainerModal.style.fontFamily="Verdana";
	objContainerModal.style.fontSize='10pt';
	objContainerModal.style.zIndex=200;
	objContainerModal.style.fontWeight="bold";
	objContainerModal.style.textAlign="center";

	objContainerModal.innerHTML = msg;

}




function makeObjAjax()
{
	try
	{
		myObj = new ActiveXObject("Microsoft.XMLHTTP");
	}

	catch(e)
	{
		myObj = new XMLHttpRequest();
	}

	return myObj;
}




function makeRequest1(pagina,objeto)
{
	if(!objeto)
	{
		objeto = new makeObjAjax();
	}
	objeto.open("get",pagina,true);
	objeto.send(null);
}


function makeRequest2(pagina, objeto, variaveis, valores, fcn)
{
	strQuery = null;
	fcnE = "void(0)";
	if(!objeto)
	{
		objeto = new makeObjAjax();
	}
	
	if(variaveis.length > 0 && variaveis.length == valores.length)
	{
		strQuery = "1=1";
		for(i = 0; i < variaveis.length; i++)
		{
			variavel	= variaveis[i];
			valor		= valores[i]
			strQuery	+= "&" + variavel + "=" + valor;
		}
	}
	

	objeto.open("post", pagina, true);
	objeto.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	objeto.onreadystatechange = function()
	{
		if(objeto.readyState == 4)
		{
				if(fcn != "")
				{
					fcnE = fcn + "('" + objeto.responseText + "')";
				}
				eval(fcnE);
		}
	}
	objeto.send(strQuery);

	
}

function buscar()
{
	txtBusca = (document.getElementById("busca").value);
	if(txtBusca.length < 4)
	{
		montaModal("homeModal", "Sua deve ter mais do que 3 letras");

	}
	
	else
	{
		location.replace("internas.php?param=busca&str=" + txtBusca);
	}
}