function ds_show(el)
{
  el.className = 'item';
}
function ds_hide(el)
{
  el.className = 'item item_hidden';
}
function show_sub(el)
{
  el2 = document.getElementById(el.id + 'menu');
  if (el2)
  {
    //el.className = (el2.style.display == 'none') ? 'hover' : '';
    el2.style.display = (el2.style.display == 'none') ? '' : 'none';
    return false;
  }
  return true;
}
function checkForm(frm, arr)
{
  el = null;
  err = '';
  for(i in arr)
  {
    switch(frm.elements[i].type)
    {
      case 'text':
      case 'password':
      case 'textarea':
        if (frm.elements[i].value == '')
        {
          if (!el) el = frm.elements[i];
          err += arr[i] + "\n";
        }
    	break;
      case 'select-one':
        if (frm.elements[i].selectedIndex == 0)
        {
          if (!el) el = frm.elements[i];
          err += arr[i] + "\n";
        }
    	break;
    }
  }
  if (err == '') return true;
  else
  {
    el.focus();
    alert("Пожалуйста заполните обязательные поля:\n-----------------------------------\n" + err + "-----------------------------------");
    return false;
  }
}
var scr_width = 0;
var scr_total = 0;
var this_scroller = 0;
var scr_need = 0;
var scr_cur = 0;
function do_scroller(cnt, inc, width, total)
{
  this_scroller+=inc;
  if (this_scroller < 0) this_scroller = 0;
  if (this_scroller > cnt - 1) this_scroller = cnt - 1;
  scr_need = (width + 1)*this_scroller;
  if (this_scroller == cnt - 1)
  {
    scr_need -= total % (width + 1) + 1;
  }
  /*for(var i=1; i<=this_scroller; i++)
  {
  	document.getElementById('scr_div' + i).style.display = 'none';
  }
  if (i<=cnt - 1) document.getElementById('scr_div' + i).style.display = '';
  */
  if (!scr_width)
  {
    scr_width = width;
    scr_total = total;
  }
  window.setTimeout('do_scroller_()', 20);
}
function do_scroller_()
{
  var sp = parseInt(Math.abs(scr_need - scr_cur) / 5);
  if (sp < 5) sp = 5;
  if (scr_need > scr_cur)
  {
    scr_cur = scr_cur + sp;
    if (scr_cur > scr_need) scr_cur = scr_need;
  }
  if (scr_need < scr_cur)
  {
    scr_cur = scr_cur - sp;
    if (scr_cur < scr_need) scr_cur = scr_need;
  }
  if (scr_need != scr_cur)
  {
    window.setTimeout('do_scroller_()', 20);
  }
  var i=1;
  while (i*(scr_width + 1) <= scr_cur)
  {
    document.getElementById('scr_div' + i).style.marginLeft = '0px';
    document.getElementById('scr_div' + i).style.display = 'none';
    i++;
  }
  document.getElementById('scr_div' + i).style.display = '';
  if ((i-1)*(scr_width + 1) == scr_cur)
  {
    document.getElementById('scr_div' + i).style.marginLeft = '0px';
  }
  else 
  {
    document.getElementById('scr_div' + i).style.marginLeft = '-' + (scr_cur - (scr_width + 1)*(i - 1)) + 'px';
  }
}
