// auto show/hide input value
var swap_text_boxes = [];
function init_swap_text_boxes(){
  //Store the default value for each box
  $('input[type=text][value].swaptextbox').each(function() {
    swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
  });
  //Add focus and blur events to set or clear the value
  $('input[type=text][value].swaptextbox').bind('focus', function() {
    if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
      $(this).val('');
    }
  });
  $('input[type=text][value].swaptextbox').bind('blur', function() {
    if($(this).val() == '') {
      $(this).val(swap_text_boxes[$(this).attr('id')]);
    }
  });
}

$(document).ready(
  function() {
    // init_swap_text_boxes();
    
    $('.tooltip').tooltip({ 
      track: true, 
      delay: 0, 
      showURL: false, 
      showBody: " - ", 
      fade: 250 
    });
  }
);

$(function() {
  var $panel = $('#panel');
  $panel.jScrollPane({scrollbarWidth:0, scrollbarMargin:0, animateTo:true});
  // $panel.jScrollPane({animateTo:true});
  
  // posun o x PX
  $('a.scroll').bind('click', // click mouseover
    function() {
      $('#panel')[0].scrollBy(parseInt($(this).attr('rel')));
      return false;
    }
  );
  
  // posun dle paragrafu
	$('a.scrollp').bind('click',
		function() {
      var targetElementSelectorString = '#'+$(this).attr('rel');
      $panel[0].scrollTo(targetElementSelectorString);
      return false;
		}
	);
});

$(function() {
  $('div.overbox div.box a').bind('click',
    function() {
      $('#fotogalerie').empty();
      $('#fotogalerie').addClass('loading');

      var img = new Image();
      $(img).load(
        function() {
          $(this).hide();
          $('#fotogalerie').removeClass('loading').empty().append(this);
          $(this).fadeIn(1000);
        }
      ).error(
        function() {
          alert('Chyba!');
        }
      ).attr('src', $(this).attr('href'));
      
      return false;
    }
  );
});
