$(document).ready(function(){
	$(function() {
	  $("a[rel^='lightbox']").lightbox();
	});
  /*
  $("#jGalerie").cycle({
		fx: "fade"
  });
  */
  var z = 0; //for setting the initial z-index's
  var inAnimation = false; //flag for testing if we are in a animation

  $('#jGalerie img').each(function() { //set the initial z-index's
    z++; //at the end we have the highest z-index value stored in the z variable
    $(this).css('z-index', z); //apply increased z-index to <img>
  });

  function swapFirstLast(isFirst) {
    if(inAnimation) return false; //if already swapping pictures just return
    else inAnimation = true; //set the flag that we process a image

    var processZindex, direction, newZindex, inDeCrease; //change for previous or next image

    if(isFirst) { processZindex = z; direction = '-'; newZindex = 1; inDeCrease = 1; } //set variables for "next" action
    else { processZindex = 1; direction = ''; newZindex = z; inDeCrease = -1; } //set variables for "previous" action

    $('#jGalerie img').each(function() { //process each image
      if($(this).css('z-index') == processZindex) { //if its the image we need to process
        $(this).animate({ 'top' : direction + $(this).height() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
          $(this).css('z-index', newZindex) //set new z-index
            .animate({ 'top' : '0' }, 'slow', function() { //animate the image back to its original position
              inAnimation = false; //reset the flag
            });
        });
      } else { //not the image we need to process, only in/de-crease z-index
        $(this).animate({ 'top' : '0' }, 'slow', function() { //make sure to wait swapping the z-index when image is above/under the gallery
          $(this).css('z-index', parseInt($(this).css('z-index')) + inDeCrease); //in/de-crease the z-index by one
        });
      }
    });
    return false; //don't follow the clicked link
  }
  
  setInterval(function() {swapFirstLast(true); }, 4000);

});
re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$/;


function Otevri(item) {
	if (document.getElementById(item)) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none");
   if (visible) {
     obj.style.display="none";
   } else {
      obj.style.display="block";
   }
  }
}

function Aktivni(item) {
	if (document.getElementById(item)) {
   document.getElementById(item).className = "aktivni"; 
  }
}


function kontrola() {
	
 if (document.uprav.jmeno.value== ""){
			alert("Prosím, vložte své jméno");
    document.uprav.jmeno.focus();
    document.uprav.jmeno.select();
			return false;
			}
 if (document.uprav.email.value== ""){
			alert("Prosím, vložte svůj email");
    document.uprav.email.focus();
    document.uprav.email.select();
			return false;
			}

//	Kontrola e-mailu
	if ( document.uprav.email.value != "" ) {
		if (re.test(document.uprav.email.value) == 0) {
			alert ("E-mailová adresa není správná");
			document.uprav.email.focus();
			document.uprav.email.select();
			return false;
		}
	}
 if (document.uprav.telefon.value== ""){
			alert("Prosím, vložte svůj telefon");
    document.uprav.telefon.focus();
    document.uprav.telefon.select();
			return false;
			}



}

