$(document).ready(function() {

  // external links
/*
  $(function() {
    $("a:not([href*='policovaokna.cz'])").click(function(){
      window.open(this.href);
      return false;
    }).attr("title", this.title + " [externí odkaz]");
  });
*/

  // lightbox
  $(function() {
    $('a[rel*=lightbox]').lightBox({
     fixedNavigation:true,
     containerResizeSpeed: 350,
     txtImage: 'Obrázek',
     txtOf: 'z'
   });
  });

  $('form#response-form').bind('submit', function(){

    var name = $('input#name');
    if (!name.val()) {
      name.focus();
      alert('Zadejte prosím své jméno');
      return false;
    }

    var email = $('input#email');
    if (!email.val()) {
      email.focus();
      alert('Zadejte prosím svůj e-mail');
      return false;
    } else {
      var emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;
      if (!emailRegExp.test(email.val())){
        email.focus();
        alert('Zadaný e-mail neodpovídá formátu e-mailové adresy');
        return false;
      }
    }

    var question = $('textarea#question');
    if (!question.val()) {
      question.focus();
      alert('Zadejte prosím dotaz');
      return false;
    }

  });

});

