function menu()
{
document.write ("<table border=0 cellpadding=2 cellspacing=1 colorborder=silver width=100% class=modulo_color_borde >");
for (i=0;i<mcats.length ;i++ )
{
	document.write ("<tr><td class=modulo_color>");
	if (mcats[i][0]==0) document.write ("<b>&#187; ");
	if (mcats[i][0]==1) document.write ("&nbsp;&nbsp;&nbsp; ");
	if (mcats[i][0]==2) document.write ("&nbsp;&nbsp;&nbsp;&nbsp; &#187;");
	if (mcats[i][0]==3) document.write ("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#187;");


	document.write ("<a href='/catalogo/"+mcats[i][4]+"/'>");


	document.write (mcats[i][3]+" </a> ");
	//if (mcats[i][5]!=0) document.write ("<small>("+mcats[i][5]+")");  //
}
document.write ("</table>");
}
















var matrix = new Array(); //matriz temporal para filtrar
var indice=0;



function filtrar_categoria(cat)
{
	matrix.length= 0; // verificar largo de la matriz
	indice=0;

	for (i1=0;i1<mp.length ; i1++)
	{							

		if (cat==mp[i1][5])
		{			
			matrix[indice]=mp[i1];
			indice=indice+1;			
		}
	}
}




function ultimos()
{
	matrix=mp; // igualar matrices
	matrix.reverse();
}



function traspasar()
{	//matrix.length=0;
	matrix=mp; // igualar matrices
	indice=0;
	for (i1=0;i1<mp.length ; i1++)
	{
			matrix[indice]=mp[i1];
			indice++;
	}
}
















function catalogo(cols,rows,orden,categoria,limite,codigos,carro,dominio) //ORDEN 0 ORDENADO , 1-AZAR 2-ULTIMOS 3-PRIMEROS
{

	if (categoria != 0) filtrar_categoria(categoria);
	if (categoria == 0) traspasar();

	//ordenes
	if (orden==1) matrix.sort( function() {return 0.5 - Math.random()} );  //AZAR
	if (orden==2) ultimos();
	

	// ESTABLECER LIMITE DEL RECORRIDO LIMITE_FOR
	limite_for=rows*cols;   // limite columna por filas
	if (limite!=0 && limite<(rows*cols)) limite_for=limite; // limite si el limite es menor a rows*cols
	if (matrix.length<limite_for ) limite_for=matrix.length; // si el limite calculado es mas que lo que existe


	document.write("<table border=0 cellpadding=0 cellspacing=5 width=100% class=modulo_color_borde >");


	document.write("<tr>  ");


	for (i=0;i<cols ;i++ )//recorre, columnas por filas, analizar limite
	{
			document.write("<td width="+(parseInt(100/cols)-1)+"%></td>");
			
			if (i<cols-1)
				document.write("<td rowspan=100 background=/images/linea2.gif  style='width:1px'></td>  ");
			
			
	}


	for (i=0;i<limite_for ;i++ )//recorre, columnas por filas, analizar limite
	{
		if (i%cols==0)	{
			document.write("<tr height=1><td colspan=10 height=1 background=/images/linea.gif ></td> </tr><tr align=center>");  // si i % las columnas == 0 , entonces tirar corte tr

		}
		
		document.write("<td class=modulo_color ><a href="+matrix[i][3] + ">");
		
		//SI FOTO PRINCIPAL <>0 IMPRIME FOTO
		if (matrix[i][1]!=0) 
			document.write("<img  src=/files/"+dominio+"/foto_"+matrix[i][1] + "_t.jpg?><BR>");
		else
			document.write("<img  src=/images/sin_imagen.jpg?><BR>");

		document.write("<B>"+matrix[i][2] + "</B><br>");   //imprimer una celda

		if (parseInt(matrix[i][4])!=0)
				document.write("$ "+matrix[i][4] + "<br>");




	}
	document.write("</table>");
}



//var mp = new Array(); //matriz de productos
// COD PRODUCTO, FOTO, NOMBRE,URL , PRECIO, COD CATEGORIA ,  DESCR



