$(document).ready(function(){
	var chipsDiplayed=false;
	$(".swatchCarousel").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		circular: false
	});
	
	$('#colordetails').click(function () {
		if (chipsDiplayed==false) {
			$('#color-chips').stop().fadeIn(200);
			$(this).text("Click here to hide color details");
			chipsDiplayed=true;
		}
		else
		{
			$('#color-chips').stop().fadeOut(200);
			$(this).text("Get color details about this scene by clicking here");
			chipsDiplayed=false;
		}
	});

	$('#color-chips li').hover(function () {
		if (jQuery.browser.msie) {
			if (jQuery.browser.version==6) {
				$(this).find('p').show();
			}
			else
			{
				$(this).find('p').fadeIn(200);
			}
		}
		else
		{
			$(this).find('p').fadeIn(200);
		}
	}, 
	function () {
		if (jQuery.browser.msie) {
			if (jQuery.browser.version==6) {
				$(this).find('p').hide();
			}
			else
			{
				$(this).find('p').fadeOut(200);
			}
		}
		else
		{
			$(this).find('p').fadeOut(200);
		}
	});
	
	/*----------- CONTROL DEAD PREV/NEXT CAROUSEL BUTTONS -------------*/
	
	var currentSwatch=1;


	var totalSwatches=$('div.swatchCarousel ul.swatchList li').length;
	

	//$('div#swatches .prev').removeClass("hiddencontent");
	//$('div#swatches .next').removeClass("hiddencontent");

	
	$('div#swatches .prev').addClass("arrowL");
	$('div#swatches .prev').addClass("inactive");
	$('div#swatches .next').addClass("arrowR");
	
	$('div#swatches .prev img').addClass("hidden");
	$('div#swatches .next img').addClass("hidden");

	
	$('div#swatches .next').click(function() {

				

		if (currentSwatch==totalSwatches-1)

		{
			currentSwatch++;
			$('div#swatches .next').addClass("inactive");

		}

		else if (currentSwatch==1)

		{
			currentSwatch++;
			$('div#swatches .prev').removeClass("inactive")			

		} else if(currentSwatch == totalSwatches){
			// do nothing, there is nothing to do
		} else {
			currentSwatch++;
		}


		return false;

	});

	

	$('div#swatches .prev').click(function() {

				

		if (currentSwatch==2)

		{
			currentSwatch--;
			$('div#swatches .prev').addClass("inactive");

		}

		else if (currentSwatch==totalSwatches)

		{
			currentSwatch--;
			$('div#swatches .next').removeClass("inactive");

		}
		else if (currentSwatch == 1) {
			// do nothing, there is nothing to do
		} else {
			currentSwatch--;
		}

		return false;

	});
		
});// document ready
