function loadImage(){

$.getJSON("slideshow.php",
    function(data){
        //alert("Data Loaded: " + data.photoid );

      var img = new Image();


      // wrap our new image in jQuery, then:
      $(img).load(function () {
          // set the image hidden by default
          $(this).hide();


          $('.slideshow img').fadeOut('slow').remove();
          $('.slideshow').append(this);
          // fade our image in to create a nice effect
          $(this).fadeIn('slow');
            setTimeout('loadImage()', 3000);

        })

        // if there was an error loading the image, react accordingly
        .error(function () {
          // notify the user that the image could not be loaded
            setTimeout('loadImage()', 3000);
        })

        // *finally*, set the src attribute of the new image to our image
        .attr('src', data.photoid).attr('width',data.width).attr('height',data.height).attr('alt','slideshow');




    }); //ajax request

}


//run after load
$(document).ready(function(){

    	$('.thumbs_all a').attr('rel', 'gallery').fancybox({
            	'showCloseButton'	: false,
            	'titlePosition' 	: 'inside'

            });

  $('.dulezite').css('display','none');

    //handles fading when mouse over thumbnail


	$('.thumbs_all img,.album IMG').hover(function() {
		//grayscale( $(this) );
		$(this).stop().fadeTo("fast",0.7);

	}, function() {
		$(this).stop().fadeTo("slow",1);
        //grayscale.reset( $(this) );

	});

	//zobrazeni nabidky svateb
	$('.clickme').toggle(function(){
		$(this).next('p').slideDown('slow');
		},
		function(){
		$(this).next('p').slideUp('slow');
		});

    //slideshow timer
    if($('.slideshow').size() == 1) setTimeout('loadImage()', 3000);


 }); //document ready
