//function for displaying the file you've just uploaded in the file list
function addToList()
{
	var count = document.getElementById('listCount').value;		
    var tbody = document.getElementById("plist-tbody");
    var tbody_id = tbody.id;
    var row = document.createElement("tr");

    var productDDStr = document.getElementById('productDD').innerHTML;
    var colorDDStr = document.getElementById('colorDD').innerHTML;
    
    productDDStr = productDDStr.replace('name=""', 'name="product[' + count + ']"');
    productDDStr = productDDStr.replace('id=""', 'id="product_' + count + '"');
    
    colorDDStr = colorDDStr.replace('name=""', 'name="color[' + count + ']"');
    colorDDStr = colorDDStr.replace('id=""', 'id="color_' + count + '"');
    
    //alert(productDDStr);
    row.id = "row-" + count;
           
    //Cell 0 -- contains the product DD 
    var cell0 = document.createElement("td");
    cell0.align = "left";
    cell0.innerHTML = productDDStr; 
           
    //Cell 1 -- contains the qty
    var cell1 = document.createElement("td");
    cell1.align = "left";
    cell1.innerHTML = '<input type="text" name="qty[' + count + ']" size="3"/>';

     //Cell 2 -- contains the color DD
    var cell2 = document.createElement("td");
    cell2.align = "left";
    cell2.innerHTML = colorDDStr; 
        
    //Cell 3 -- contains the delete button
    var cell3 = document.createElement("td");
    cell3.className = "cell-clear-btn";
    cell3.align = "center";
                
    var btnClear = document.createElement("a");
    btnClear.id = "clear_" + count;
    btnClear.className = "clear-file";
    btnClear.href = "javascript: clearListItem('row-" + count + "')"; 
    btnClear.innerHTML = "<img src='images/icons/sc_cancel_16.gif' />";
                
    cell3.appendChild(btnClear);
                
    row.appendChild(cell0);
    row.appendChild(cell1);
    row.appendChild(cell2);
    row.appendChild(cell3);
    //flist_tbody.appendChild(row);  
    tbody.appendChild(row);  
    
    count++;
    document.getElementById('listCount').value = count;   
}
    

//clears a file newly added to the list
function clearListItem(row)
{
    //CLEAR VISIBLE FILE ENTRY    
    //Get the tbody element that holds the list of files
    var tbody = document.getElementById("plist-tbody");
    
    //Get the row that visibly displays the file
    var remove_row = document.getElementById(row);
    
    //Remove the visible row
    tbody.removeChild(remove_row);
}

