var full_w = screen.width - 230;
var spec_width = 350; // 370
var novs_width = 250; // 270
var spec_offs = 0;


function show_spec_fishki(num)
{
   if (document.getElementById('spec_cnt'))
   {
   var spec_cnt = document.getElementById('spec_cnt').value;
   var firstspec = num;
   //var spec_per_page = document.getElementById('spec_per_page').value;
   var spec_per_page = 2;

   // стираем все кнопки нафиг. потом выставим.
   for (var i=1; i<=spec_cnt; i++)
   {
      if (document.getElementById('spec_'+i+'but')) document.getElementById('spec_'+i+'but').src = "/new_d/pager/"+i+".gif";
      if (document.getElementById('spec_div_'+i)) {document.getElementById('spec_div_'+i).style.display = 'none';}
   }

   // первый-последний
   if (firstspec==spec_cnt) // последний
   {
     firstspec = parseInt(firstspec)-1;
   }
   if (firstspec==1 && spec_per_page>2) // первый
   {
     firstspec = 2;
   }

   if (firstspec)
   {
      // кнопки
      if (document.getElementById('spec_'+firstspec+'but')) document.getElementById('spec_'+firstspec+'but').src = "/new_d/pager/"+firstspec+"a.gif";
      if (document.getElementById('spec_'+(parseInt(firstspec)+1)+'but')) document.getElementById('spec_'+(parseInt(firstspec)+1)+'but').src = "/new_d/pager/"+(parseInt(firstspec)+1)+"a.gif";
      if (document.getElementById('spec_'+(parseInt(firstspec)-1)+'but') && spec_per_page>2) document.getElementById('spec_'+(parseInt(firstspec)-1)+'but').src = "/new_d/pager/"+(parseInt(firstspec)-1)+"a.gif";

      // дивы
      if (document.getElementById('spec_div_'+firstspec)) document.getElementById('spec_div_'+firstspec).style.display = 'block';
      if (document.getElementById('spec_div_'+(parseInt(firstspec)+1))) document.getElementById('spec_div_'+(parseInt(firstspec)+1)).style.display = 'block';
      if (document.getElementById('spec_div_'+(parseInt(firstspec)-1)) && spec_per_page>2) document.getElementById('spec_div_'+(parseInt(firstspec)-1)).style.display = 'block';
   }
   document.getElementById('firstspec').value=firstspec;
   }
}

function sub_menu(id,hide)
{
   if(hide)
   {
      document.getElementById('subm'+id).style.display='none';
   }
   else
   {
      document.getElementById('subm'+id).style.display='block';
      var itemX = document.getElementById('topm'+id).offsetParent.offsetLeft;
      if (document.getElementById('topm'+(id+1)))
      {
         var itemXn = document.getElementById('topm'+(id+1)).offsetParent.offsetLeft;
      }
      var totalX = document.getElementById('topm_main').offsetWidth;
      var tablX = document.getElementById('subm'+id).offsetWidth;

      if (itemX == 0) // первый
      {
         Xp = 17;
      }
      else if (itemX <= (totalX - tablX))  // до половины
      {
         Xp = itemX;
      }
     // else if(itemXn && itemXn - tablX > 17) // половина
      //{
         //Xp = itemXn - tablX;
     // }
      else  // после половины
      {
         Xp = totalX - tablX + 18;
      }
      document.getElementById('subm'+id).style.left = Xp + 'px';
      document.getElementById('subm'+id).style.display='block';
   }
}
