jQuery(document).ready(function(){
  /*
  $('.main_img #zoom1').hover(function(){
    $(this).addClass('cloud-zoom').click(function () { 
      $('.cloud-zoom').CloudZoom();
      return false;
    });
  },
  function () {
    $(this).removeClass('cloud-zoom');
  }
);
*/

  Cufon.replace( $('.footer'), { fontFamily: 'HeliosCondC' })

  jQuery('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();
  
  jQuery('#mycarousel').jcarousel({
    scroll: 4,
    auto: 3,
    wrap: 'circular',
    initCallback: mycarousel_initCallback
  });
  jQuery('#product-carousel').jcarousel({
    scroll: 1,
    wrap: 'circular'
  });
  // jQuery("a#init-error-popup").fancybox();

  jQuery("a.button").wrapInner('<span><span>');
  
  jQuery(".thumbnails li").click(function () { 
      $(this).addClass("active"); 
  });

  $("#table_of_sizes").click(function() {
		$.fancybox({
			//'orig'			: $(this),
			'padding'		    : 0,
			'href'			    : '/common/img/shop/table_of_sizes.jpg',
			'title'   		    : 'Таблица размеров',
			'transitionIn'	    : 'elastic',
			'transitionOut'	    : 'elastic',
			'autoScale'         : false,
			'type'              : 'image'
		});
  });
  
  $("#rules_link").fancybox({
        'width'				: '85%',
		'height'			: '85%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
  });

  jQuery("#page-title").prependTo($('#extra-content'));
});

function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
