$(function() {
      $(".aktualityhome").jCarouselLite({
          btnNext: ".next",
          btnPrev: ".prev",
          vertical: true,
          visible: 3,
          shuffle: 0
      }); 
      $(".fotky").jCarouselLite({
          btnNext: ".nextf",
          btnPrev: ".prevf",
          vertical: false,
          visible: 1,
          shuffle: 0
      });
  
      
     /* $('#slider1').bxSlider({
        displaySlideQty: 3,
        moveSlideQty: 1,
        mode: 'vertical',
        controls: false,
        tickerSpeed: 2500
      }); */
  });   

function prazdnyForm() {
   
       if (document.getElementsByName("email")[0].value == 'email...')  document.getElementsByName("email")[0].value = '';
       if (document.getElementsByName("subject")[0].value == 'subject...')  document.getElementsByName("subject")[0].value = '';   
}    
  

function nactiGaler(idGal) { //alert("nacitam galerii" + idGal);
        $("#fotky").load("/galerie-ajax?idgal=" + idGal, function(response, status, xhr) {  
          if (status == "error") {  
            var msg = "Sorry but there was an error: ";  
            $("#error").html(msg + xhr.status + " " + xhr.statusText);  
          }  
        });
         }
         
function nactiVideoGaler() {  //alert("nacitam videogalerii");
        $("#fotky").load("/videogalerie-ajax", function(response, status, xhr) {  
          if (status == "error") {  
            var msg = "Sorry but there was an error: ";  
            $("#error").html(msg + xhr.status + " " + xhr.statusText);  
          }  
        });
         }         
         
function nactiProj(idPro) {  //alert("nacitam projekt" + idPro);
        $("#projects-left").load("/projekty-ajax/detail/" + idPro, function(response, status, xhr) {  
          if (status == "error") {  
            var msg = "Sorry but there was an error: ";  
            $("#error").html(msg + xhr.status + " " + xhr.statusText);  
          }  
        });
         }         


/*$(function(){
  $('#slider1').bxSlider({
    mode: 'vertical',
    pager: true,
    displaySlideQty: 3,
    moveSlideQty: 1
  });
});    */


$("document").ready(function() {			
				
         
				
				
				$('.m1').click(function(){										   
					$('html, body').animate({
						scrollTop: $("#homepage").offset().top
					}, 2000);				   
				 });
				 
				 $('.m2').click(function(){										   
					$('html, body').animate({
						scrollTop: $("#gallery").offset().top
					}, 2000);				   
				 });
				 $('.m2odk').click(function(){										   
					$('html, body').animate({
						scrollTop: $("#gallery").offset().top
					}, 2000);			   
				 });
				 
				 $('.m3').click(function(){										   
					$('html, body').animate({
						scrollTop: $("#projects").offset().top
					}, 2000);				   
				 });
				 
				 $('.m4').click(function(){										   
					$('html, body').animate({
						scrollTop: $("#about").offset().top
					}, 2000);				   
				 });
				 
				 $('.gotop').click(function(){										   
					$('html, body').animate({
						scrollTop: $("#homepage").offset().top
					}, 2000);				   
				 });
				 
				 $('.m5').click(function(){										   
					$('html, body').animate({
						scrollTop: $("#contact").offset().top
					}, 2000);				   
				 });

		  $("a[rel=skupinaFotek]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
		
			$(".newska").fancybox({
				'width'				: '55%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'type'				: 'iframe',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.6,
			});
			
			$(".video-play").fancybox({
				'width'				: '5',
				'height'			: '4',
				'autoScale'			: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'type'				: 'iframe'
			});


      sY = 24; /* height of li.sub */
      fY = 115; /* height of maximum sub lines * sub line height */
      /* open first list item */
      animate (fY)
      $("#slide .sub").click(function() {
      	if (this.className.indexOf('clicked') != -1 ) {
      		animate(sY)
      		$(this)			.removeClass('clicked')
      		}
      		else {
      		animate(sY)
      		$('.clicked')	.removeClass('clicked')
      		$(this)			.addClass('clicked');
      		animate(fY)
      	}
      });
      
      function animate(pY) {
      $('.clicked').animate({"height": pY + "px"}, 500);
      }
      $("#slide .sub")		.hover(function(){
      $(this)					
      },function(){
      if (this.className.indexOf('clicked') == -1) {
      $(this)					
      }
      });
      
      $("#fotky").load("/galerie-ajax?idgal=012", function(response, status, xhr) {  
          if (status == "error") {  
            var msg = "Sorry but there was an error: ";  
            $("#error").html(msg + xhr.status + " " + xhr.statusText);  
          }  
        }); 
    

    	//slides the element with class "menu_body" when mouse is over the paragraph
    	$("#secondpane p.menu_head").mouseover(function()
        {
    	     $(this).css({backgroundImage:"url(obr/menu_dolu.png)"}).next("div.menu_body").slideDown(500).siblings("div.menu_body").slideUp("slow");
             $(this).siblings().css({backgroundImage:"url(obr/menu_vodorovne.png)"});
    	});
    
      
		});
