// JavaScript Document
	function cargarTabla2(frmSelect, tabla1Select, oTableContainer){

/*
colorTable="lightslategray";
colorTHead = "lightskyblue";
colorTBody = "lemonchiffon";
colorCell = "lightskyblue";
*/
colorTransparente= "";
colorTable =colorTransparente;
colorTHead = colorTransparente;
colorTBody = colorTransparente;
colorCell = colorTransparente;
colorTextHead= "#FF0000";
colorTextBody= "#0099FF";
colorTextBody1= "#0000FF";
colorTextBody2= "#0000FF";
colorBackgroundBody1="#ffffff";
colorBackgroundBody2="#EEFECD";

/*
colorTable ="#00FF00";
colorTHead = "#00FF80";
colorTBody = "#00FF80";
colorCell = "#00FF80";
*/


/*
alert("Hola")

alert("frmSelect " + frmSelect)
alert("tabla1Select " + tabla1Select)
alert("tabla2Select " + tabla2Select)
alert("tabla2Select.length " + tabla2Select.length)

alert("oTableContainer" + oTableContainer)
//alert("oTableContainer.hasChildNodes" + oTableContainer.hasChildNodes)
alert("oTableContainer.childNodes[0]" + oTableContainer.childNodes[0])
*/



	if (oTableContainer.hasChildNodes()) {
//		oTable.remove(0);
//		oTable=null
		oTableContainer.removeChild(oTableContainer.childNodes[0]);
	}

//oTableContainer.childNodes[0]=null

//alert("paso0")
//	Array2=Array1b[document.frmSelect.tabla1Select.selectedIndex]

	familia=tabla1Select.selectedIndex
	
	if (familia == 0){
		//addOpt(tabla2Select,  0, "Pendiente de seleccionar Producto", 0)
	}
	else{


		// Declare variables and create the header, footer, and caption.
		var oTable = document.createElement("TABLE");
		var oTHead = document.createElement("THEAD");
		var oTBody0 = document.createElement("TBODY");
		//var oTBody1 = document.createElement("TBODY");
//		var oTFoot = document.createElement("TFOOT");
		var oCaption = document.createElement("CAPTION");
		var oRow, oCell;
		var i, j;

	// Insert the created elements into oTable.
		oTable.appendChild(oTHead);
		
		oTable.appendChild(oTBody0);
		//oTable.appendChild(oTBody1);
//		oTable.appendChild(oTFoot);
		oTable.appendChild(oCaption);
		
		// Set the table's border width and colors.
		oTable.border=1;
//		oTable.bgColor="lightslategray";
		oTable.bgColor=colorTable;
		
		// Insert a row into the header and set its background color.
		oRow = document.createElement("TR");
		
		oTHead.appendChild(oRow);
//		oTHead.bgColor = "lightskyblue";
		oTHead.bgColor = colorTHead;
		
		// Create and insert cells into the header row.
		for (i=0;i<heading1.length;i++)
		//for (i=0; i<4; i++)
		{
		if (heading1[i] != "")
		{
		  oCell = document.createElement("TH");
//		  oCell.innerText = heading1[i];
          currenttext=document.createTextNode(heading1[i].toString());
          oCell.appendChild(currenttext);
		  oCell.style.color = colorTextHead;
		

		  for (x=i+1;x<heading1.length;x++)
		  {
		  if (heading1[x] == ""){
		  	oCell.colSpan++
			}else{
			break
			}
		  }		  

		  //oCell.colSpan = "4";
		  oRow.appendChild(oCell);

		  }

		}

		// Create and insert rows and cells into the first body.
		Array2=Array1b[familia]
		for (i=0;i<Array2.length;i++)
		//for (i=0; i<2; i++)
		{
		  oRow = document.createElement("TR");
		  oTBody0.appendChild(oRow);
		
			Array2a=Array2[i]
		
		  for (j=0; j<Array2a.length; j++)
		  {
			oCell = document.createElement("TD");
		//	oCell.innerText = stock[i + "," + j];
//			oCell.innerText = Array2a[j];
            currenttext=document.createTextNode(Array2a[j]);
//			alert(j + " " + Array2a[j]);
			switch (j){
			case 2:
  	    	  oCell.align="right";
			  break;
			case 3:
  	    	  oCell.align="right";
			  break;
			default:
  	    	  oCell.align="left";
			  break;
			  }
			  if ((i%2)>0){
				  oCell.style.color = colorTextBody1;
				  oCell.style.background = colorBackgroundBody1;				  
			  }else{
	  			  oCell.style.color = colorTextBody2;
				  oCell.style.background = colorBackgroundBody2;				  				  
			  }




            oCell.appendChild(currenttext);
			oRow.appendChild(oCell);

//                mycurrent_cell=document.createElement("TD");
//                currenttext=document.createTextNode("cell is row "+j+", column "+i);
//                mycurrent_cell.appendChild(currenttext);
//                mycurrent_row.appendChild(mycurrent_cell);



		  }
		}
		
		// Set the background color of the first body.
//		oTBody0.bgColor = "lemonchiffon";
		oTBody0.bgColor = colorTBody
		
		// Create and insert rows and cells into the footer row.
/*
		oRow = document.createElement("TR");
		oTFoot.appendChild(oRow);
		oCell = document.createElement("TD");
		oRow.appendChild(oCell);
		oCell.innerText = "Quotes are for example only.";
		oCell.colSpan = "4";
		oCell.bgColor = "lightskyblue";
*/		

		// Set the innerText of the caption and position it at the bottom of the table.
//		oCaption.innerText = "Famila " + Array1[familia]

/*
        currenttext=document.createTextNode("Famila " + Array1[familia]);
        oCaption.appendChild(currenttext);


		oCaption.style.fontSize = "30";
		oCaption.align = "top";
*/
		
		// Insert the table into the document tree.
		oTableContainer.appendChild(oTable);
	}
}



