var iImgCount = 0;
var iNowCount = 0;

var bMove = false;

$(function() {
  
      
    $('#galleryLeft').click(function() {
      if (!bMove && iNowCount - 3 >= 0)  {
        iNowCount -= 3;    
        bMove = true;  
        $('#gallerySlider').animate({
          left: '+=648'
        }, 1500, function() {
          bMove = false;
        });
      }
    });

    $('#galleryRight').click(function() {
      if (!bMove && iNowCount + 3 < iImgCount)  {
        iNowCount += 3;
        bMove = true;  
        $('#gallerySlider').animate({
          left: '-=648'
        }, 1500, function() {
          bMove = false;
        });
      }
  });


});

function initGallerySlieder()  {

  $('#gallerySlider li').each(function(){ 
    iImgCount++;    
    });   
  $('#gallerySlider').attr('style', 'width:' + iImgCount * 216 + 'px!important');  
}
