$(document).ready(function() {

	centerCartFooter();
	$(window).resize(centerCartFooter);
	
	$(".accordion").click(function () {
		$(this).next().slideToggle();
		return false;
	}).next().hide();

	$("a[rel='lightbox']").fancybox({
		cyclic: true,
		titlePosition: 'over',
		transitionIn: 'elastic',
		transitionOut: 'elastic'
	});
	
	$("a[rel='sidebar-lightbox']").fancybox({
		showNavArrows: false,
		titlePosition: 'over',
		transitionIn: 'elastic',
		transitionOut: 'elastic'
	});
	
	$('.rotating-images').plusSlider({
		width: 250,
		height: 475,
		displayTime: 5000, // The amount of time (in milliseconds) the slide waits before automatically moving on to the next one.
        speed: 500, // The amount of time (in milliseconds) the transition between slides takes.
		autoPlay: true,
		createArrows: false,
        createPagination: false,
		keyboardNavigation: false,
		sliderType: 'fader'
	});

	$("#swatches .draggable").draggable({
		appendTo: "body", //Allow dragging outside of original container (so it can be moved onto the bottom droppable area)
		helper: "clone", //copy of the original stays in original spot.
		cursor: "move"
	});
	//$("#swatches .draggable").addTouch();
	
	$("#strands .droppable").droppable({
		hoverClass: "droppable-hover", //class added to drop area when mouse hovers above
		tolerance: "pointer", //as long as the mouse pointer is over a drop area, the item will be dropped there
		drop: dropSwatch
	});
	
	//Make the entire price area clickable
	// $.each(['#price', '#shipping', '#checkout'], function(index, value) {
	// 	$(value).click(function() {
	// 		$('#checkout-form').submit();
	// 	});
	// });
	
	$('#checkout').click(function() {
		$('#checkout-form').submit();
	});
	
	$('#checkout-form').submit(function() {
		if (validateCart()) {
			serializeCart();
		} else {
			return false;
		}
	});
	
	$('.quantity').keyup(function() {
		refreshCalculations();
	});
	$('.quantity').change(function() {
		refreshCalculations();
	});
	
	thicknessMeter = initializeThicknessMeterDisplay(); //We want this in the global namespace so don't use "var".

	resetCartStrandLabels();
	refreshCalculations();
	
	$('#amount').focus();
});

