var big_pic_w = 603;

function di_store_count()
{
  if (di_def || di_count_stored || !album_ct) return;

  var xml_url = '/xml/inc_count.php?name='+album_ct;
  diXMLRequest.get(xml_url, di_store_count_response);
}

function di_store_count_response(xmlDoc)
{
  di_count_stored = true;
}

function right_small()
{
  var e = document.getElementById('g_ul');

  var x = parseInt(e.style.marginLeft);
  if (isNaN(x)) x = 0;
  x -= m_step;
  var y = Math.round((subphotos_cc - 4.7) * m_step);
  if (y + x < 0) x = -y;

  //_ge('dump').innerHTML = 'x='+x+', y='+y;

  e.style.marginLeft = x+'px';
}

function left_small()
{
  var e = document.getElementById('g_ul');

  var x = parseInt(e.style.marginLeft);
  if (isNaN(x)) x = 0;
  x += m_step;
  if (x > 0) x = 0;

  //_ge('dump').innerHTML = 'x='+x+', y='+0;

  e.style.marginLeft = x+'px';
}

function g_ul_go_to(idx)
{
  var e = document.getElementById('g_ul');

  if (idx > 4 && idx < album_pics_count - 3)
    idx -= 2;
  else if (idx >= album_pics_count - 3)
    idx -= 3.7;

  var x = - m_step * idx;

  e.style.marginLeft = x+'px';
}

function check_g_ul()
{
  var e = document.getElementById('g_ul');
  var e1 = e.firstChild;

  var i = 0;

  var max_left = big_pic_w - m_step;

  do {
    if (e1.nodeName == 'LI')
    {
      if (e1.className.indexOf('active') != -1)
      {
        g_ul_go_to(i);

        break;
      }

      i++;
    }
  } while (e1 = e1.nextSibling);
}

/*
function check_g_ul()
{
  var e = document.getElementById('g_ul');
  var e1 = e.firstChild;

  var m = parseInt(e.style.marginLeft+'');

  do {
    if (e1.nodeName == 'LI' && e1.className.indexOf('active') != -1)
    {
      if (e1.offsetLeft > 500)
      {
        e.style.marginLeft = (470-e1.offsetLeft)+'px';
      }
      else
      {
        e.style.marginLeft = '0px';
      }
    }
  } while (e1 = e1.nextSibling);
}
*/

function hide_main_gray_bar2()
{
  var e = document.getElementById('main_gray_bar2');

  if (e) e.style.display = 'none';
}


function right_small2()
{
  var e = document.getElementById('g_ul');

  var x = parseInt(e.style.marginLeft);
  if (isNaN(x)) x = 0;
  x -= m_step;
  var y = Math.round((subphotos_cc - 4.7) * m_step);

  //if (y + x < 0) x = -y;
  if (y + x < 0) x = 0;

  //_ge('dump').innerHTML = 'x='+x+', y='+y;

  e.style.marginLeft = x+'px';
}

function left_small2()
{
  var e = document.getElementById('g_ul');

  var x = parseInt(e.style.marginLeft);
  if (isNaN(x)) x = 0;
  x += m_step;
  if (x > 0) x = 0;

  //_ge('dump').innerHTML = 'x='+x+', y='+0;

  e.style.marginLeft = x+'px';
}

function check_window_location_href()
{
  if (!album_cover_photo_pic)
    return;

  if (window.location.href.indexOf('#') == -1)
    window.location.href = window.location.href+'#'+album_cover_photo_pic;
  else if (window.location.href.indexOf('#') == window.location.href.length - 1)
    window.location.href = window.location.href+album_cover_photo_pic;
  else if (window.location.href.indexOf('#undefined') != -1)
    window.location.href = window.location.href.substr(0, window.location.href.indexOf('#'))+'#'+album_cover_photo_pic;
}

