/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function addAreaBoxes() {

    var buttonContainer = document.getElementById("areaModifyForm_addBoxes");

    var nextIndex = 0;
    for (var i = 0; i < buttonContainer.parentNode.childNodes.length; ++i) {
        if (buttonContainer.parentNode.childNodes.item(i).className == 'langParagraph') {
            nextIndex++;
        }
    }

    var newParagraph = document.createElement("p");
    newParagraph.className = "langParagraph";

    var newRadio = document.createElement("input");
    newRadio.setAttribute('type', 'radio');
    newRadio.setAttribute('id', 'defaultValue' + (1 + nextIndex));
    newRadio.setAttribute('name', 'defaultValue');
    newRadio.setAttribute('value', nextIndex);

    var newLangLabel = document.createElement("label");
    newLangLabel.innerHTML = " " +
        document.getElementById("lang[0]").previousSibling.previousSibling.innerHTML +
        " ";
    var newLangInput = document.createElement("input");
    newLangInput.setAttribute('maxlength', 2);
    newLangInput.setAttribute('type', 'text');
    newLangInput.setAttribute('id', 'lang[' + nextIndex + ']');
    newLangInput.setAttribute('name', 'lang[' + nextIndex + ']');
    newLangInput.className = "lang";

    var newTitleLabel = document.createElement("label");
    newTitleLabel.innerHTML = " " +
        document.getElementById("title[0]").previousSibling.previousSibling.innerHTML +
        " ";
    var newTitleInput = document.createElement("input");
    newTitleInput.setAttribute('maxlength', 255);
    newTitleInput.setAttribute('type', 'text');
    newTitleInput.setAttribute('id', 'title[' + nextIndex + ']');
    newTitleInput.setAttribute('name', 'title[' + nextIndex + ']');
    newTitleInput.className = "title";
    var newTitleSeparator = document.createElement("br");

    newParagraph.appendChild(newRadio);

    newParagraph.appendChild(newLangLabel);
    newParagraph.appendChild(newLangInput);

    newParagraph.appendChild(newTitleLabel);
    newParagraph.appendChild(newTitleInput);
    newParagraph.appendChild(newTitleSeparator);

    buttonContainer.parentNode.insertBefore(newParagraph, buttonContainer);

}