// http://www.eyemedia.ro
// Written by Marian Vlad (eyemedia@gmail.com)
// Redistribution and use of this code, with or without modification, is NOT permitted.

  function addAttachment(nrVal, container) {
    var content = '';
    var prtMain = '';
    var newNr = 0;
     
    newNr = nrVal + 1;
//    if(newNr == 1) prtMain = ' mark as main';  // COMMENT THIS TO HIDE
//    prtMain = ' mark as main'; // COMMENT THIS FOR 1st ONE ONLY
     
    content = content + "      <div id='content" + newNr + "'>\n";
    content = content + "        <div style='padding: 3px;' class='table_line'>\n";
    content = content + "          <div style='height: 24px;'>\n";
    content = content + "            <div style='float: left; clear: both;'><input type='text' id='paint_size" + newNr + "' name='editor_paint_size[]' size='6'>&nbsp;</div>\n";
    content = content + "            <div style='float: left;'><input type='text' id='paint_info" + newNr + "' name='editor_paint_info[]' size='40'>&nbsp;</div>\n";
    content = content + "            <div style='float: left;'><input type='text' id='paint_price" + newNr + "' name='editor_paint_price[]' size='6'>&nbsp;</div>\n";
    content = content + "            <div style='float: right; cursor: pointer; width: 22px; height: 10px; padding: 5px; background-color: #cc0000;' align='center' onClick=\"removeAttachment('" + newNr + "');\"><a style='color: white;'><b>X</b></a></div>\n";
    content = content + "          </div>\n";
    content = content + "          <div id='input" + newNr + "'></div>\n";
    content = content + "        </div>\n";
    content = content + "      </div>\n";
    content = content + "      <div id='space" + newNr + "'><div style='height: 4px;'></div></div>\n";
    content = content + "      <div id='" + container + newNr + "'><div align='right'><a style='cursor: pointer;' onClick=\"addAttachment(" + newNr + ", '" + container + newNr + "');\">another painting sale</a></div></div>\n";
     
    document.getElementById(container).innerHTML = content;
    document.getElementById("submit" + container).style.display = "block";
  }
   
  function removeAttachment(index) {
    document.getElementById("content" + index).innerHTML = "";
    document.getElementById("content" + index).style.display = "none";
    document.getElementById("space" + index).innerHTML = "";
    document.getElementById("space" + index).style.display = "none";
  }