function ShowBody(obj,state) {
  var bookmarks='4'; // pocet zalozek
  switch (state) {
    case '1':
      for(var i=1;i<=bookmarks;i++) {
        document.getElementById('body' + i).style.display='none';
      }
      document.getElementById('body' + obj).style.display='block';
    break;
  }
}

$(document).ready(function() {

  // external links
  $(function() {
    $('div.text a:not([href*="ekopanely.cz"],[href*="mailto"],[href*="#top"])').each(function(){
      $(this).bind('click', function(){
        window.open(this.href);
        return false;
      }).attr("title", this.title + " [externí odkaz]");
    });
  });

  // bookmarks
  $('div#bookmarks div.bookmark').each(function(index){
    var bookmark = $(this);
    var bookmark_index = index;
    bookmark.find('div.title, div.body').mouseover(function(){
      $('div#bookmarks div.bookmark div.body').each(function(index){
        if (index == bookmark_index) {
          $(this).attr('style', 'display:block');
        } else {
          $(this).attr('style', 'display:none');
        }
      });
    });
  });

  // search form
  var searchingText = $('input#searching-text');
  $('form#searching-form').bind('submit', function(){
    if (searchingText.val() == '') {
      alert('Zadejte prosím hledaný výraz');
      return false;
    }
    if (searchingText.val().length < 3) {
      alert('Hledaný výraz musí obsahovat alespoň tři znaky');
      return false
    }
  });
  searchingText.bind('focus', function(){
    if (searchingText.val() == 'Hledat') searchingText.val('');
  });
  searchingText.bind('blur', function(){
    if (searchingText.val() == '') searchingText.val('Hledat');
  });

  // newsleter
  var newsletterName = $('#newsletter-name');
  var newsletterEmail = $('#newsletter-email');
  newsletterName.bind('focus', function(){
    if (newsletterName.val() == 'Vaše jméno') newsletterName.val('');
  });
  newsletterName.bind('blur', function(){
    if (newsletterName.val() == '') newsletterName.val('Vaše jméno');
  });
  newsletterEmail.bind('focus', function(){
    if (newsletterEmail.val() == 'Váš e-mail') newsletterEmail.val('');
  });
  newsletterEmail.bind('blur', function(){
    if (newsletterEmail.val() == '') newsletterEmail.val('Váš e-mail');
  });
  $('#newsletter-form').bind('submit', function(){
    if (newsletterEmail.val() == '') {
      alert('Zadejte prosím e-mailovou adresu');
      return false;
    } else {
      emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;
      if (!emailRegExp.test(newsletterEmail.val())){
        if (newsletterEmail.focus) newsletterEmail.focus();
        alert('Zadaný e-mail neodpovídá formátu e-mailové adresy');
        return false;
      }
    }
  });

  // lightbox
  $(function() {
    $('div.photogallery a[rel*=lightbox]').lightBox({
     fixedNavigation:true,
     containerResizeSpeed: 350,
     txtImage: 'Obrázek',
     txtOf: 'z'
   });
  });

  // hover effects
  $('input#searching-button').mouseover(function(){
    $(this).attr('src', 'http://www.ekopanely.cz/_layout/_www/hledat-over.png');
  });
  $('input#searching-button').mouseout(function(){
    $(this).attr('src', 'http://www.ekopanely.cz/_layout/_www/hledat.png');
  });

  $('input#newsletter-button').mouseover(function(){
    $(this).attr('src', 'http://www.ekopanely.cz/_layout/_www/ok-over.png');
  });
  $('input#newsletter-button').mouseout(function(){
    $(this).attr('src', 'http://www.ekopanely.cz/_layout/_www/ok.png');
  });

});

