var basePath = $('base').attr('href');
$(document).ready(function(){
  $('#album-holder img').click(function() {
    $('#album-big > img').attr('src', $(this).attr('src').replace('_thumb', ''));
    $('#album-big div span').html($(this).attr('title'));
  });
  if($('#album-holder img').length > 6) {
    var w = $('#album-holder img').length * 58;
    $('#album-left').click(function() {
      if(Number($('#album-holder').css('left').replace('px', '')) <= -58) {
        $('#album-holder').stop(true, true).animate({left:'+=58px'}, 400);
      }
    });
    $('#album-right').click(function() {
      if(Number($('#album-holder').css('left').replace('px', '')) > (336 + 58 - w)) {
        $('#album-holder').stop(true, true).animate({left:'-=58px'}, 400);
      }
    });
  }
  $('#album-big > div > img').click(function() {
    $.fancybox($('#album-big > img').attr('src').replace('.jpg', '_big.jpg'), {
      scrolling:'no',
      type:'image',
      overlayColor:'#f5f6ef',
      overlayOpacity:0.9}
    );
  });
});
function preloadImages() {
  for(var i = 0; i < arguments.length; i++) {
    var oImg = new Image();
    oImg.src = arguments[i];
  }
}
function toggleMultipleFocus() {
  for(var i = 0; i < arguments.length; i++) {
    toggleFocus(arguments[i]);
  }
}
function toggleFocus(id) {
  var val = $(id).val();
  $(id).focus(function() {
    if($(this).val() == val) {$(this).val('');}
  }).blur(function() {
    if($(this).val() == '') {$(this).val(val);}
  });
}
function tl(key, stripall, language) {
  if(stripall == undefined) { stripall = false; }
  if(language == undefined) { language = false; }
  var result = '';
  $.ajax({
    url:'tl.php',
    async: false,
    data:{key:key, stripall:stripall, language:language},
    success:function(data) {
       result = data;
    }
  });
  return result;
}
