function hide_failure_layer(){
  
  document.getElementById("failure").style.display = 'none';
  document.getElementById("failure-header").style.display = 'none';
}



function validate(){
 var theForm = document.form;
 var isError = true;
 for(i=0;i<theForm.elements.length;i++) {
  if( (theForm.elements[i].type).toLowerCase()=="file" && trim(theForm.elements[i].value)!="") {
      isError=false;
     }
 }
 if(isError) alert("Bitte mindestens eine Datei auswählen!");
 return !isError;
}

function trim(str) {
 return str.replace( /^\s*/, '').replace( /\s*$/, '' );
}

function AddRowsToTable() {
 var tbl = document.getElementById('dateiupload');
 var lastRow = tbl.rows.length;
 var iteration = lastRow;   
 if (iteration < 5) {   
   var row = tbl.insertRow(lastRow);
 
   var cellRight = row.insertCell(0);
   var el = document.createElement('input');
   el.setAttribute('type', 'file');
   el.setAttribute('name', 'uploadfile[]');

   el.setAttribute('size', '40');
   cellRight.setAttribute('id',iteration)
   cellRight.appendChild(el);
   var aa = document.createElement("a");
   aa.setAttribute('href', '#');
   var clickName = new Function("DeleteRow(this)");
   aa.onclick = clickName;
   aa.innerHTML = "&nbsp;entfernen";
   cellRight.appendChild(aa);
 } else {
   alert('Maximal 5 Dateien gleichzeitig zugelassen.');
 }
}
function DeleteRow(x)
{
     while (x.tagName.toLowerCase() !='tr')
     {
          if(x.parentElement)
             x=x.parentElement;
        else if(x.parentNode)
             x=x.parentNode;
        else
             return;
     }
     var rowNum=x.rowIndex;
     while (x.tagName.toLowerCase() !='table')
     {
          if(x.parentElement)
             x=x.parentElement;
        else if(x.parentNode)
             x=x.parentNode;
        else
             return;
     }
     x.deleteRow(rowNum); 
}

function RemoveRowFromTable(rowid) {
 var tbl = document.getElementById(iteration);
 //var lastRow = tbl.rows.length;
 //if (lastRow > 1)
 tbl.deleteRow(rowid);
} 
