$(window).load(function() {
	$("div#photos").smoothDivScroll({ autoScroll: "always", autoScrollDirection: "endlessloopright", autoScrollStep: 2, autoScrollInterval: 40});

	$("div#shopbag a.flyer").colorbox({opacity:"0.8"});
	
	$("div#photos a").colorbox({opacity:"0.8"});
	
	$("div#the_photo_gallery_photos a").colorbox({opacity:"0.8"});
	
	// Pause autoscrolling if the mouse is hover one of the images
	$("div#photos").mouseenter(function() {
		$(this).smoothDivScroll("stopAutoScroll");
	});
	
	// Start autoscrolling again when the mouse goes outside the images
	$("div#photos").mouseleave(function(){
		$(this).smoothDivScroll("startAutoScroll");
	});

	// Pause autoscrolling if the user clicks one of the images
	$("div#photos").bind("click", function() {
		$(this).smoothDivScroll("stopAutoScroll");
	});
	
	// Start autoscrolling again when the user closes
	// the colorbox overlay
	$(document).bind('cbox_closed', function(){
		$("div#photos").smoothDivScroll("startAutoScroll");
	});
});


$(document).ready(function () {
  
  if ($('#jcart').length) {
  	var top = $('#jcart').offset().top + 320;
  
	$(window).scroll(function (event) {
	// what the y position of the scroll is
	var y = $(this).scrollTop();
	
	// whether that's below the form
	if (y >= top) {
	  // if so, ad the fixed class
	  $('#jcart').addClass('fixed');
	} else {
	  // otherwise remove it
	  $('#jcart').removeClass('fixed');
	}
	});
  }
});
