// JavaScript Document

//Для обычных ячеек
function expand_menu(id) {
  if (exp_obj_id != null && exp_obj_id != id)
  {
    if (exp_obj_type == 'norm') {cont(exp_obj_id);}
    else if (exp_obj_type == 'sel') {cont_sel(exp_obj_id);}
  }
  var item=document.getElementById(id);
  if (item.className != 'menuitemover'){item.className = 'menuitemover'; }
  obj = document.getElementById('menu' + id);

  var l=item.offsetLeft - 3;
  var t=item.offsetTop + 31;
  var w=item.offsetWidth;

  while (item.offsetParent != null)
  {
    item = item.offsetParent;
    l+=item.offsetLeft;
    t+=item.offsetTop;
  }
   
  if (obj)
  {
    obj.style.left = l + 'px';
    obj.style.top  = t + 'px';
    obj.style.display = 'block';
    if (obj.offsetWidth < w + 6)
    {
      obj.style.width = w + 6 + 'px';
    }
  }
   
  lobj = document.getElementById('left' + id);
  if (lobj.className != 'menuleftover'){lobj.className = 'menuleftover';}
  robj = document.getElementById('right' + id);
  if (robj.className != 'menurightover') {robj.className = 'menurightover';}

  expanded = true;
  exp_obj_id = id;
  exp_obj_type = 'norm';
}

function cont_menu(id) {
  expanded = false;
  obj_id = id;
  setTimeout("cm(obj_id)", 10);
}

function cm(id)
{ obj = id;
  if (expanded == false)
  {
    cont(obj);
  }
}

function cont(id)
{
  exp_obj_id = null;
  var item=document.getElementById(id);
  item.className = 'menuitem';
  obj = document.getElementById('menu' + id);

  if (obj)
  {
    obj.style.display = 'none';
  }

  lobj = document.getElementById('left' + id);
  lobj.className = 'menuleft';
  robj = document.getElementById('right' + id);
  robj.className = 'menuright';

}


//Для выделенных ячеек на внутренних страницах
function expand_menu_sel(id) {
  if (exp_obj_id != null && exp_obj_id != id)
  {
    if (exp_obj_type == 'norm') {cont(exp_obj_id);}
    else if (exp_obj_type == 'sel') {cont_sel(exp_obj_id);}
  }
  var item=document.getElementById(id);
  if (item.className != 'menuitemover') {item.className = 'menuitemover';}
  obj = document.getElementById('menu' + id);

  var l=item.offsetLeft - 3;
  var t=item.offsetTop + 31;
  var w=item.offsetWidth;

  while (item.offsetParent != null)
  {
    item = item.offsetParent;
    l+=item.offsetLeft;
    t+=item.offsetTop;
  }

  if (obj)
  {
    obj.style.left = l + 'px';
    obj.style.top  = t + 'px';
    obj.style.display = 'block';
    if (obj.offsetWidth < w + 6)
    {
      obj.style.width = w + 6 + 'px';
    }
  }

  lobj = document.getElementById('left' + id);
  if (lobj.className != 'menuleftover') {lobj.className = 'menuleftover'};
  robj = document.getElementById('right' + id);
  if (robj.className != 'menurightover') {robj.className = 'menurightover';}

  expanded = true;
  exp_obj_id = id;
  exp_obj_type = 'sel';
}

function cont_menu_sel(id) {
  expanded = false;
  obj_id = id;
  setTimeout("cm_sel(obj_id)", 10);

}

function cm_sel(id)
{ obj = id;
  if (expanded == false)
  {
    cont_sel(obj);
  }
}

function cont_sel(id)
{
  exp_obj_id = null;
  var item=document.getElementById(id);
        item.className = 'menuitemsel';
  obj = document.getElementById('menu' + id);

        if (obj)
        {
    obj.style.display = 'none';
        }

  lobj = document.getElementById('left' + id);
  lobj.className = 'menuleftsel';
  robj = document.getElementById('right' + id);
  robj.className = 'menurightsel';

}

function view_photo(a,b,c,d)
{
  var par='width='+b+',height='+c+',status=no,toolbar=no,menubar=no,location=no';
  view_win=window.open('','photo',par);
  if(d.length==0) d='Oioia?oea';
  view_win.document.write('<html><head><title>'+d+'</title></head>');
  view_win.document.write('<body topmargin=0 marginheight=0 leftmargin=0 marginwidth=0 bgcolor=#ffffff>');
  view_win.document.write('<img src="'+a+'" width='+b+' height='+c+' hspace=0 vspace=0 border=0 alt="'+d+'">');
  view_win.document.write('</body></html>');
}

function select_date(url)
{
    document.location = url + '01.01.' +
    document.calendar.year.options[document.calendar.year.options.selectedIndex].value+'/';
}
