var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

function getRef(id) 
{
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}
function getSty(id) 
{
return (isNS4 ? getRef(id) : getRef(id).style);
}

function pinta_menu(x)
{
	elems = getRef("mnu_empresa").getElementsByTagName("A");
	for(i=0;i<elems.length;i++)
		elems[i].style.backgroundColor = '#4d99f2';
	elems[x].style.backgroundColor='#99c4f6';
}
//##########################
//Resinas
//##########################
function busca_res() 
{		
	if(document.frm_busca.sl_tipo.value!="") x = document.frm_busca.sl_tipo.value.toUpperCase(); else x=" ";	
	if(document.frm_busca.txt_cod.value!="") y = document.frm_busca.txt_cod.value.toUpperCase(); else y=" ";
	cpaint_call(
	  'Scripts/func.php',
	  'GET',
	  'busca_cod',
	  x,
	  y,
	  atualiza_busca,
	  'TEXT');
}

function atualiza_busca(valorDeRetorno)
{
	//Exibe as resinas que obedecem aos parāmetros
	//alert(valorDeRetorno);
	var aux = valorDeRetorno.split("||");	
	if(aux.length > 3)
	{
		//getSty("res_conteudo").display = "none";
		resp = "<p style='font-size:08pt;line-height:130%'>";
		v_segm = "";
		v_tipo = "";
		for (var i=1;i<aux.length-1;i++)
		{			
			var linha = aux[i].split("|");
			if(linha[3] != v_tipo)
			{
				v_tipo = linha[3];
				resp += "<span style='color:#300;font-weight:bold;border-bottom:1px solid #000'>" + linha[3] + "</span><br />";
			}
			if (linha[1] != v_segm) 
			{
				v_segm = linha[1];
				resp += "<span style='color:#008'>" + v_segm + "</span><br />";
			}
			resp += "<a href='pg_res_result.php?ref=" + linha[2] + "&cod_res=" + linha[3] + "' target='frm_centro'>" + linha[0] + "</a><br />"
		}
		getRef("resina_res").innerHTML = "<span style='font-size:10px'>" + resp + "</span>";
	}
	else
	{
		getRef("resina_res").innerHTML = "N&atilde;o foram encontradas resinas com esta grade...";
		document.frm_centro.window.location = "pg_res_result.php";
	}
}
