﻿// JScript File

function checkAttachments(el) {
    el = $(el);
    var elp = $(el.parentNode);
    if (el.value=='' && elp.childElements().length>1) elp.removeChild(el);
    else if (el.value!='')
    {
        var o = document.createElement('input');
        o.type='file';
        o.id = 'attachment' + ((elp.childElements()[elp.childElements().length - 1].id.substring(10) - 0) + 1);
        o.name = o.id;
        elp.appendChild(o);
        o.onchange = function() {
            checkAttachments(this);
        }        
    }
}