function addRowImage(){
  count_image++;
	
  var up = document.getElementById("upload");
 
  var inp_l = document.createElement('input');
  var inp_b = document.createElement('input');
  
  var name_l = "image_l_" + count_image;
  var name_b = "image_b_" + count_image;
  
  var break_ = document.createElement('br');
  if(count_image <= 10){
	  inp_l.setAttribute('type', 'file');
	  inp_l.setAttribute('name', name_l);
	  up.appendChild(inp_l);
	    
	  
	  inp_b.setAttribute('type', 'file');  
	  inp_b.setAttribute('name', name_b);  
	  up.appendChild(inp_b);  
	  
	  up.appendChild(break_); 
  } else {
    hideLayer("addnew");
  }
}

function addRowPub(){
  count_pub++;
	
  var publ = document.getElementById("publication");
 
  var inp = document.createElement('input');
  var inpt = document.createElement('input');
  
  var name = "pub_" + count_pub;
  var namet = "title_" + count_pub;
  
  var hr_ = document.createElement('hr');
  var break_ = document.createElement('br'); 
  
  if(count_pub <= 10){
	  inpt.setAttribute('type', 'text');
	  inpt.setAttribute('size', '50');
	  inpt.setAttribute('name', namet);
	  publ.appendChild(inpt);
	  
	  publ.appendChild(break_); 
	  
    inp.setAttribute('type', 'file');
	  inp.setAttribute('name', name);
	  publ.appendChild(inp);
    	  
	  publ.appendChild(hr_); 
  } else {
    hideLayer("addPub");
  }
}



function hideLayer(div) {
  document.getElementById(div).style.visibility='hidden';
}

function showLayer(div) {
  document.getElementById(div).style.visibility='visible';
}

function hideImage(id) {
  document.getElementById(id).src='/images/empty.png';
  document.getElementById(id).heigth='0';
}


function publDelete(id) {
  hideLayer('public_'+id);
  
  tmp = document.form1.publications_for_delete.value;
  document.form1.publications_for_delete.value = tmp + " " + id;
}

function imageDelete(id, is_main) {
  hideLayer('img_'+id);
  hideImage('i_'+id);
  
  tmp = document.form1.images_for_delete.value;
  document.form1.images_for_delete.value = tmp + " " + id;
  document.form1.image_main.value = '';
  
  if (is_main == '1') {
    showLayer('main_pic1');
    showLayer('main_pic2');
  }
}
