// JavaScript Document
$(window).load(function() {


  // prvni slide
  slideFirst();
  function slideFirst() {
      var t=setTimeout("startSlide()",1200);
  }
  // mousemove slidovani
  $('#motionCarousel #leftSide').bind("mousemove", function(event){
    LeftAction();
  });
  $('#motionCarousel #rightSide').bind("mousemove", function(event){
    RightAction();
  });
  // redirect na click celeho divu
  $('#motionCarousel div').bind("click", function(event){
    window.location = $(this).children('a').attr('href');
  });
  
});

  function startSlide() {
      if ($('#motionCarousel #leftSide').width() == 460) {
          LeftAction();
      }
  }
       
    
    
 function LeftAction() {
    if ($('#motionCarousel #leftSide').width() != 634) {
       $('#motionCarousel #rightSide').unbind("mousemove");
       $('#motionCarousel #leftSide').unbind("mousemove");
        $('#motionCarousel #leftSide').animate({
          width: '634px'
        }, {
          duration: 1000,
          specialEasing: {
            width: 'easeOutQuad'
          },
          complete: function() {
            /**/
          }
        });
        $('#motionCarousel #leftSide .float').animate({
          width: '634px'
        }, {
          duration: 1200,
          specialEasing: {
            right: 'easeOutQuad'
          },
          complete: function() {
            $('#motionCarousel #leftSide').bind("mousemove", function(event){
             LeftAction();
            });
            
            $('#motionCarousel #rightSide').bind("mousemove", function(event){
             RightAction();
            });
          }
        });
        $('#motionCarousel #rightSide').animate({
          width: '286px'
        }, {
          duration: 1000,
          specialEasing: {
            width: 'easeOutQuad'
          },
          complete: function() {
            /**/
          }
        });
        $('#motionCarousel #rightSide .float').animate({
          width: '800px'
        }, {
          duration: 1200,
          specialEasing: {
            right: 'easeOutQuad'
          },
          complete: function() {
            /**/
          }
        });
      } 
    }   
    
 function RightAction() {
     if ($('#motionCarousel #rightSide').width() != 634) {
       $('#motionCarousel #rightSide').unbind("mousemove");
       $('#motionCarousel #leftSide').unbind("mousemove");
        $('#motionCarousel #leftSide').animate({
          width: '286px'
        }, {
          duration: 1000,
          specialEasing: {
            width: 'easeOutQuad'
          },
          complete: function() {
            /**/
          }
        });
        $('#motionCarousel #leftSide .float').animate({
          width: '800px'
        }, {
          duration: 1200,
          specialEasing: {
            right: 'easeOutQuad'
          },
          complete: function() {
            $('#motionCarousel #leftSide').bind("mousemove", function(event){
             LeftAction();
            });
            
            $('#motionCarousel #rightSide').bind("mousemove", function(event){
             RightAction();
            });
          }
        });
        $('#motionCarousel #rightSide').animate({
          width: '634px'
        }, {
          duration: 1000,
          specialEasing: {
            width: 'easeOutQuad'
          },
          complete: function() {
            /**/
          }
        });
        $('#motionCarousel #rightSide .float').animate({
          width: '634px'
        }, {
          duration: 1200,
          specialEasing: {
            right: 'easeOutQuad'
          },
          complete: function() {
            /**/
          }
        });
      }
       
    }
