// JavaScript methods for the Recipe Form for Recipe Press.

function rp_add_ingredient() {
    var table = document.getElementById('rp_ingredients');
    var rows = table.rows.length;
    var row = table.insertRow(rows);

    // Insert Quantity Cell
    var cellQ = row.insertCell(0);
    var quantity = document.createElement('input');
    quantity.type = 'text';
    quantity.name = 'ingredients[' + rows + '][quantity]';
    quantity.style.width = '50px';
    cellQ.appendChild(quantity);

    // Insert Size Cell
    var cellS = row.insertCell(1);
    var select = document.getElementById('sizeselect').cloneNode(true);
    select.name = 'ingredients[' + rows + '][size]';
    select.style.display = '';
    cellS.appendChild(select);

    // Insert item cell
    var cellI = row.insertCell(2);
    var item = document.createElement('input');
    item.type = 'text';
    item.name = 'ingredients[' + rows + '][item]';
    cellI.appendChild(item);

    table.appendChild(row);
}

function rp_add_divider() {
    var table = document.getElementById('rp_ingredients');
    var rows = table.rows.length;
    var row = table.insertRow(rows);

    // Insert blank cell
    var cellQ = row.insertCell(0);

    // Insert Note Cell
    var cellS = row.insertCell(1);
    var item = document.createElement('input');
    item.type = 'text';
    item.name = 'ingredients[' + rows + '][size]';
    item.value = 'divider';
    item.style.width = '55px';
    item.readOnly = true;
    cellS.appendChild(item);

    // Insert item cell
    var cellI = row.insertCell(2);
    item = document.createElement('input');
    item.type = 'text';
    item.name = 'ingredients[' + rows + '][item]';
    cellI.appendChild(item);

    table.appendChild(row);
}


