var cRow = 4;

var kol_pole=1;

var d = document;

function addRow() {
  cRow++;
  if (cRow>10) {
    alert("Ограничение - максимум 10 полей.");
  } else {
    var tbody = d.getElementById('vd').getElementsByTagName('TBODY')[0];

    var row = d.createElement("TR");
    tbody.appendChild(row);

    var td1 = d.createElement("TD");
    var td2 = d.createElement("TD");
    row.appendChild(td1);
    row.appendChild(td2);
 
    td1.innerHTML = '<input class="textInputA" maxlength="200" name="shp_vd'+cRow+'" id="shp_vd'+cRow+'"  size="30" type="text">'+"\n";
    td2.innerHTML = '<input class="textInput" maxlength="200" name="shp_naz'+cRow+'" id="shp_naz'+cRow+'" size="40" type="text">'+"\n";
  }

}

function fValidate1() {
  var vCount = 0;

  for (i=1; i<(cRow+1); i++){
     vd = d.getElementById("shp_vd"+i).value;
     naz = d.getElementById("shp_naz"+i).value;
     
     if ((vd.length>1)&&(naz.length>1)){
       vCount++;
//       alert(vd+" = "+naz+" - "+vCount);
     }
  }
  d.getElementById("dcount").value = vCount;
  return true;
}

function addBookM(a) { 
  title=document.title; 
  url=document.location; 
  try { 
    // Internet Explorer 
    window.external.AddFavorite(url, title); 
  } 
  catch (e) { 
    try { 
      // Mozilla 
      window.sidebar.addPanel(title, url, ""); 
    } 
    catch (e) { 
      // Opera 
      if (typeof(opera)=="object") { 
        a.rel="sidebar"; 
        a.title=title; 
        a.url=url; 
        return true; 
      } 
      else { 
        // Unknown 
        alert('Для добавления в избранное нажмите Ctrl-D '); 
      } 
    } 
  } 
  return false; 
}


function addRow2() {
  if (kol_pole==3) {
    alert("Ограничение - максимум 3 поля");
  } else {
    if (kol_pole==1)
    {
        var table_2 = d.getElementById('vd_2');
        table_2.style.display='';
    } else if (kol_pole==2) {
        var table_3 = d.getElementById('vd_3');
        table_3.style.display='';
        var bb=d.getElementById('b_add');
        bb.style.display='none';
    }
  }
  kol_pole++;
}