var CurrentOpenPage = 'About';

function GoTo(base)
{
  window.location = base + '#' + CurrentOpenPage;
}

function ShowMenu(id)
{
  var options = {};
  if (CurrentOpen)
  {
    $("#Lang" + CurrentOpen + "").attr('class', '');
    if (id == CurrentOpen)
    {
      $("#Menu" + CurrentOpen + ":visible").slideUp("fast");
      CurrentOpen = 0;
    }
    else
    {
      $("#Menu" + CurrentOpen + ":visible").slideUp("fast", ShowMenu2);
      CurrentOpen = id;
    }
  }
  else
  {
    CurrentOpen = id;
    ShowMenu2();
  }
}
  
function ShowPage(NewPage)
{
  if (CurrentOpenPage != NewPage)
  {
    $("#" + CurrentOpenPage + "Block").slideUp("slow", ShowPage2);
    CurrentOpenPage = NewPage;
    location.hash = '#' + NewPage;
  }
}

function ShowPage2(NewPage)
{
  $("#" + CurrentOpenPage + "Block").slideDown("slow");
}



jQuery(function(){
  $('div#AboutBlockSlider').slide({title_id: 1});
  $('div#GalleryBlockSlider').slide({title_id: 1});
  $(window).hashchange(function() { updateState(location.hash, false) });
  updateState(location.hash, true);
})

$(function() {
  $('#collection a').lightBox();
  $('#AboutCollection a').lightBox();
});


function updateState(hash, firstTime)
{
  if (in_array(hash, ['#About', '#Collection', '#Contacts']))
  {
    var page = hash.substr(1);
    if (page != CurrentOpenPage)
      ShowPage(page);
  }
  else if (hash.substr(1, 10) == 'Collection')
  {
    if (CurrentOpenPage != 'Collection')
      ShowPage('Collection');
  }
  //if (CurrentOpenPage)
  //alert(hash);
}



