$(document).ready(function() {

  // form
  $('#response-form').submit(xsCheckResponseForm);

  // lightbox
  $(function() {
    $('a[rel*=lightbox]').lightBox({
     fixedNavigation:true,
	   containerResizeSpeed: 350,
	   txtImage: 'Obrázek',
	   txtOf: 'z'
   });
  });

});

function xsCheckResponseForm() {
  var name = $('#name');
  if (!name.val()) {
    if (name.focus()) name.focus();
    alert('Zadeje prosím vaše jméno');
    return false;
  }
  var email = $('#email');
  if (!email.val()) {
    if (email.focus()) email.focus();
    alert('Zadeje prosím váš 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())) {
      if (email.focus) email.focus();
      alert('Zadaný e-mail neodpovídá formátu e-mailové adresy');
      return false;
    }
  }
  var question = $('#question');
  if (!question.val()) {
    if (question.focus()) question.focus();
    alert('Zadeje prosím váš dotaz');
    return false;
  }
  return true;
}

function Swap(which,state)
{
	var elm=document.getElementById(which);
	switch (state)
	{
		case 'over':
			elm.src='./_layout/_e-shop/'+which+'-image-'+state+'.png';
		break;
		case 'out':
			elm.src='./_layout/_e-shop/'+which+'-image.png';
		break;
	}
}

