// JavaScript Document


function mostraSpan(span) {
	document.getElementById(span).style.display = "block";
}

function escondeSpan(span) {
	document.getElementById(span).style.display = "none";
}
// Altura, Largura, Top, Left -> integer
// Location, menuBar, toolBar, Status, scrollBar -> yes/no
function abrePopUp(Arquivo, Codigo1, Codigo2, Codigo3, Altura, Largura, Top, Left, Location, menuBar, toolBar, Status, scrollBars)
{
	sec = window.open(Arquivo+'?cod1='+Codigo1+'&cod2='+Codigo2+'&cod3='+Codigo3,"","width="+Altura+",height="+Largura+",top="+Top+",left="+Left+",location="+Location+",menubar="+menuBar+",toolbar="+toolBar+",status="+Status+",scrollbars="+scrollBars+"");
	sec.focus();
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  if (selObj.options[selObj.selectedIndex].value!="") {
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
  }
}

//funcao que retira acentos e ç das descricoes
function criaCampoIndex(sThis) {
	var valCampo = sThis.value;
	var nomeCampo = sThis.name + "_Index";
	var i = 0;
	var j = 0;
	valCampo = valCampo.toUpperCase();
	  for (i = 0;  i < valCampo.length;  ++i) {
		for (j = 0;  j < LetrasComAcentos.length;  ++j) {
		  if (valCampo.charAt(i) == LetrasComAcentos.charAt(j)) {
			valCampo = valCampo.replace(valCampo.charAt(i), LetrasSemAcentos.charAt(j));
		  }
		}
	  }

	document.getElementById(nomeCampo).value = valCampo;
}

//Busca nome no ComboBox
function buscaRegistro(campoBusca, comboBox)
{
	if (document.getElementById(campoBusca).value.length != 0)
	{
		var i;
		var re = new RegExp("^" + document.getElementById(campoBusca).value, "i");
		re.compile;
		for (i = 0; i < document.getElementById(comboBox).length; i++) {
			if (re.test(document.getElementById(comboBox).item(i).text)) {
				document.getElementById(comboBox).selectedIndex = i;
				break;
			}
		}
	}
}

function pesquisa(id, tipo) {
	textoUp = document.getElementById(id+"Normal").value;
	textoUp = textoUp.toUpperCase();
	for (i = 0;  i < textoUp.length;  ++i) {
		for (j = 0;  j < LetrasComAcentos.length;  ++j) {
			if (textoUp.charAt(i) == LetrasComAcentos.charAt(j)) {
				textoUp = textoUp.replace(textoUp.charAt(i), LetrasSemAcentos.charAt(j));
			}
		}
	}
	document.getElementById(id+'IFrame').src = "pesquisaIFrame.asp?id="+id+"&tipo="+tipo+"&texto="+textoUp;
}

function exibe(id, w, h) {
//	alert(id);
	iframe = document.getElementById(id+'IFrame');
	iframe.width = w;
	iframe.height = h;
	iframe.style.top = document.getElementById(id+"Div").style.top;
	iframe.style.left = document.getElementById(id+"Div").style.left-5;
	iframe.style.display = '';
}

function esconde(id) {
	iframe = document.getElementById(id+'IFrame');
	iframe.width = 0;
	iframe.height = 0;
	iframe.style.top = 0;
	iframe.style.left = 0;
	iframe.style.display = 'none';
}
