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


function addBoxes() {

    var buttonContainer = document.getElementById("eventModifyForm_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 newLangLabel = document.createElement("label");
    newLangLabel.setAttribute('id', 'langLabel[' + nextIndex + ']');
    newLangLabel.innerHTML = " " + 
                             document.getElementById("langLabel[0]").innerHTML +
                             " ";
    var newLangSeparatorOne = document.createElement("br");
    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 newLangSeparatorTwo = document.createElement("br");

    var newTitleLabel = document.createElement("label");
    newTitleLabel.setAttribute('id', 'titleLabel[' + nextIndex + ']');
    newTitleLabel.innerHTML = " " + 
                             document.getElementById("titleLabel[0]").innerHTML +
                             " ";
    var newTitleSeparatorOne = document.createElement("br");
    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 newTitleSeparatorTwo = document.createElement("br");

    var newDescLabel = document.createElement("label");
    newDescLabel.setAttribute('id', 'descriptionLabel[' + nextIndex + ']');
    newDescLabel.innerHTML = " " +
        document.getElementById("descriptionLabel[0]").innerHTML +
        " ";
    var newDescSeparatorOne = document.createElement("br");
    var newDescInput = document.createElement("textarea");
    newDescInput.setAttribute('id', 'description[' + nextIndex + ']');
    newDescInput.setAttribute('name', 'description[' + nextIndex + ']');
    newDescInput.className = "description";
    var newDescSeparatorTwo = document.createElement("br");

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

    newParagraph.appendChild(newTitleLabel);
    newParagraph.appendChild(newTitleSeparatorOne);
    newParagraph.appendChild(newTitleInput);
    newParagraph.appendChild(newTitleSeparatorTwo);

    newParagraph.appendChild(newDescLabel);
    newParagraph.appendChild(newDescSeparatorOne);
    newParagraph.appendChild(newDescInput);
    newParagraph.appendChild(newDescSeparatorTwo);

    buttonContainer.parentNode.insertBefore(newParagraph, buttonContainer);

}