jQuery(document).ready(function($){

	$("#faq h2").toggle(function() {
		$(this).siblings('div').slideDown();
	}, function() {
		$(this).siblings('div').slideUp();
	});
	
	$("#collection-color-order-sample .sample-add-to-cart").click(function(){
		var sample = $(this).siblings('.sample-selection').val();
		if (sample > 0){
			$.ajax({
				type: "POST",
				url: "/cart_addsku.cfm",
				data: "sku="+sample,
				success: function(msg){
					$("#collection-color-order-sample .sample-add-to-cart-success").fadeIn();
					$("#breadcrumb .breadcrumb-shopping-cart").fadeIn('slow');
				}
			});
		}else{
			$("#collection-color-order-sample .sample-add-to-cart-error").fadeIn('slow');
		}		
	});
	
	$("#collection-color-order-sample select").change(function(){
		$("#collection-color-order-sample .sample-add-to-cart-success").fadeOut();
		$("#collection-color-order-sample .sample-add-to-cart-error").fadeOut('slow');
	});
	
	$("#collection-quicklinks .quicklink-select").change(function(){
		location.href = $(this).val();
	});
	
	$("#collection-color-views li").click(function(){
		/*view_image = $(this).attr("src");
		if(view_image.search('slab')>-1){
			view_image = view_image.replace("thumb", "small");
			$('#collection-color-photo .photo.slab .photo-image img').attr("src", view_image);
		}else{
			view_image = view_image.replace("thumb", "large");
		}
		$('#collection-color-photo').fadeOut('slow', function() {
			$('#collection-color-photo .photo-caption').html(view_caption);
			
			$('#collection-color-photo').fadeIn('slow', function() {});
		});
		*/
		id = $(this).attr('class').split('-')[1];
		$('#collection-color-photo .photo.'+id).siblings().fadeOut('slow',function(){
			$('#collection-color-photo .photo.'+id).fadeIn('slow');
		});
		
		
	});
	
	
	$('#collection-color-photo .photo.detail #photo-pan').hover(function(){
		$('#photo-pan .panning').css('margin-left',($('#photo-pan').width()-$('#photo-pan .panning').width())/2);
		$('#photo-pan .panning').css('margin-top',($('#photo-pan').height()-$('#photo-pan .panning').height())/2);
		$('#photo-pan').bind('mousemove', function(event){
			MouseMove(event);									  
		});
		$('#photo-pan .panning').css('margin-top',($('#photo-pan').height()-$('#photo-pan .panning').height())/2+'px');
		photo_containerWidth=$('#photo-pan').width();
		photo_containerHeight=$('#photo-pan').height();
		totalContentW=$('#photo-pan .panning').width();
		totalContentH=$('#photo-pan .panning').height();
		$('#photo-pan .photo-container').css("width",totalContentW);
		$('#photo-pan .photo-container').css("height",totalContentH);
		function MouseMove(e){
			  var mouseCoordsX=(e.pageX - $('#photo-pan').offset().left);
			  var mouseCoordsY=(e.pageY - $('#photo-pan').offset().top);
			  var mousePercentX=mouseCoordsX/photo_containerWidth;
			  var mousePercentY=mouseCoordsY/photo_containerHeight;
			  var destX=-(((totalContentW-(photo_containerWidth))-photo_containerWidth)*(mousePercentX));
			  var destY=-(((totalContentH-(photo_containerHeight))-photo_containerHeight)*(mousePercentY));
			  var thePosA=mouseCoordsX-destX;
			  var thePosB=destX-mouseCoordsX;
			  var thePosC=mouseCoordsY-destY;
			  var thePosD=destY-mouseCoordsY;
			  var marginL=$('#photo-pan .panning').css('marginLeft').replace("px", "");
			  var marginT=$('#photo-pan .panning').css('marginTop').replace("px", "");
			  var animSpeed=500; //ease amount
			  var easeType='easeOutCirc';
			  if(mouseCoordsX>destX || mouseCoordsY>destY){
				  //$('#photo-pan .photo-container').css('left',-thePosA-marginL); $('#photo-pan .photo-container').css('top',-thePosC-marginT); //without easing
				  $('#photo-pan .photo-container').stop().animate({left: -thePosA-marginL, top: -thePosC-marginT}, animSpeed,easeType); //with easing
			  }
			  else if(mouseCoordsX<destX || mouseCoordsY<destY){
				  //$('#photo-pan .photo-container').css('left',thePosB-marginL); $('#photo-pan .photo-container').css('top',thePosD-marginT); //without easing
				  $('#photo-pan .photo-container').stop().animate({left: thePosB-marginL, top: thePosD-marginT}, animSpeed,easeType); //with easing
			  } else {
				  $('#photo-pan .photo-container').stop();
			  }
		}
	});
	
	
	/*var gallery = $('#thumbs').galleriffic({
        delay:                     3000, // in milliseconds
        numThumbs:                 20, // The number of thumbnails to show page
        preloadAhead:              40, // Set to -1 to preload all images
        enableTopPager:            false,
        enableBottomPager:         true,
        maxPagesToShow:            7,  // The maximum number of pages to display in either the top or bottom pager
        imageContainerSel:         '', // The CSS selector for the element within which the main slideshow image should be rendered
        controlsContainerSel:      '', // The CSS selector for the element within which the slideshow controls should be rendered
        captionContainerSel:       '', // The CSS selector for the element within which the captions should be rendered
        loadingContainerSel:       '', // The CSS selector for the element within which should be shown when an image is loading
        renderSSControls:          true, // Specifies whether the slideshow's Play and Pause links should be rendered
        renderNavControls:         true, // Specifies whether the slideshow's Next and Previous links should be rendered
        playLinkText:              'Play',
        pauseLinkText:             'Pause',
        prevLinkText:              'Previous',
        nextLinkText:              'Next',
        nextPageLinkText:          'Next &rsaquo;',
        prevPageLinkText:          '&lsaquo; Prev',
        enableHistory:             false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes
        enableKeyboardNavigation:  true, // Specifies whether keyboard navigation is enabled
        autoStart:                 false, // Specifies whether the slideshow should be playing or paused when the page first loads
        syncTransitions:           false, // Specifies whether the out and in transitions occur simultaneously or distinctly
        defaultTransitionDuration: 1000, // If using the default transitions, specifies the duration of the transitions
        onSlideChange:             undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
        onTransitionOut:           undefined, // accepts a delegate like such: function(slide, caption, isSync, callback) { ... }
        onTransitionIn:            undefined, // accepts a delegate like such: function(slide, caption, isSync) { ... }
        onPageTransitionOut:       undefined, // accepts a delegate like such: function(callback) { ... }
        onPageTransitionIn:        undefined, // accepts a delegate like such: function() { ... }
        onImageAdded:              undefined, // accepts a delegate like such: function(imageData, $li) { ... }
        onImageRemoved:            undefined  // accepts a delegate like such: function(imageData, $li) { ... }
    });*/
	
});
