var xml = loadXml("distribuidores.xml");
var xsl;

function ListarProvincias()
{
	
	xsl = loadXsl("distribuidores.xsl");
	var nodos_provincias = xml.getElementsByTagName("Provincia");
	var provincias = new Array();
	for ( var i=0; i<nodos_provincias.length; i++ )
	{
		if ( !in_array(nodos_provincias[i].firstChild.nodeValue, provincias) )
		{
			provincias.push( nodos_provincias[i].firstChild.nodeValue );
		}
	}
	var selector = document.getElementById("sel_box");
	selector.options.length=0; // vacio el selector
	for ( i=0; i<provincias.length; i++ )
	{
		var opcion = document.createElement("option");
		opcion.setAttribute("value",provincias[i]);
		opcion.innerHTML= (provincias[i]=='-') ? 'Capital Federal' : provincias[i];
		selector.appendChild(opcion);
	}
}

function refresh_table()
{
	var selector = document.getElementById("sel_box");
	var provincia = selector.options[selector.selectedIndex].value;

	document.getElementById("td_canales").innerHTML = XSLTransformToString( xml, xsl, {p_provincia: provincia} );

	var filas = document.getElementById("td_canales").childNodes[0].childNodes[1].childNodes;
	var i = 1;
	while ( filas[i] != null )
	{
		if ( i % 2 == 0 )
		{
			filas[i].setAttribute( (window.ActiveXObject ? "className" : "class"), "gris" );
		}
		i++;
	}
}