function clr(el, show)
{
 // alert ('clr el=' + el + ' show=' + show)
  d = document.getElementById(el);
  d.style.display = show;
}

function set(el, value)
{
  d = document.getElementById(el);
  d.value = value;
}

function sethref(db_name)
{
  document.getElementById('a_rub1').href  = '/yp/'  + db_name + '/alpha.html';
  document.getElementById('a_rub2').href  = '/yp/'  + db_name + '/alpha.html';
  document.getElementById('a_tem1').href  = '/yp/'  + db_name + '/tree.html';
  document.getElementById('a_tem2').href  = '/yp/'  + db_name + '/tree.html';

  t1 = document.getElementById('a_tree')
  if (t1) t1.href  = '/yp/'  + db_name + '/alpha.html';

  t2 = document.getElementById('a_rub_root')
  if (t2) t2.href  = '/yp/'  + db_name + '.html';


  document.getElementById('db_1').value = db_name;
  document.getElementById('db_2').value = db_name;
 
  /*  /yp/spb/rubric1246/ */

  i = 0;
  while ( document.links[i]) {
      lnk = document.links[i].href 
      document.links[i].href = lnk.replace(/yp\/\w+\/rubric/,'yp/' + db_name + '/rubric');
      i++;
  }
}

function sethref1(el_target1, el_target2, el_source)
{
  d = document.getElementById(el_source);
//  alert(d);
  index = d.selectedIndex;

  t1 = document.getElementById(el_target1);
  t2 = document.getElementById(el_target2);

  t1.href = '/yp/' + d[index].value + '/alpha.html';
  t2.href = '/yp/' + d[index].value + '/tree.html';
}

function check(el, form)
{
  d = document.getElementById(el);  
  f = document.getElementById(form);
  var str = d.value;
  var re = /\S+/;
//  if(d.value != '')
  if(str.match(re))
    f.submit();
  else
    alert("Вы не ввели строку для поиска");
}

function checkent(el1, el2, el3, el4, el5, form)
{
  d1 = document.getElementById(el1);  
  d2 = document.getElementById(el2);  
  d3 = document.getElementById(el3);  
  d4 = document.getElementById(el4);  
  d5 = document.getElementById(el5);  

  view = document.getElementById('view');

  f = document.getElementById(form);
  if((d2.value != '') || (d3.value != '') || (d4.value != '') ||
     (d5.value != ''))
    view.value = 'adv';

  var str1 = d1.value;
  var str2 = d2.value;
  var str3 = d3.value;
  var str4 = d4.value;
  var str5 = d5.value;

  var re = /\S+/;
  if((!str1.match(re)) && (!str2.match(re)) && (!str3.match(re)) &&
     (!str4.match(re)) && (!str5.match(re)))
    alert("Вы не ввели строку для поиска");
  else
    f.submit();
}

function setrubric(source1, source2, total)
{
  d1 = window.opener.document.getElementById(source1);
  d2 = window.opener.document.getElementById(source2);
  for(i=1; i<=total; i++)
    {
      s  = window.document.getElementById(i);
      if(s.checked)
        {
          idents = s.value.split(",");
          if(d1.value)
            d1.value = d1.value + ',' + idents[1]; 
          else
            d1.value = idents[1];
          if(d2.value)
            d2.value = d2.value + ',' + idents[0]; 
          else
            d2.value = idents[0];
        }
    }
  window.close();
}

function listrubrics(el)
{
  d  = document.getElementById(el);
  db = d.options[d.selectedIndex].id;
//  alert(d.options[d.selectedIndex].id);

  window.open('/yp/'+db+'/add.html?popup=true&nosession=true', '', 'width=700, height=600, scrollbars=yes, toolbar=no, status=1');
//  window.open('/?mode=alph&popup=true&db='+db+'&nosession=true', '', 'width=700, height=600, scrollbars=yes, toolbar=no, status=0');
}

