var CT = 
{
	init:function($)
	{
		this.imageArea($);
		if (!$('body').hasClass('ProductPage')) {
			this.messageArea($);
		}
		else
		{
			this.messageArea($);
			this.gallery($);	
			this.lightBox($);
		}
		this.IE6($);
	},
	
	imageArea:function($)
	{
		$('#ImageHolder ul').cycle({
			fx: 'fade',
			timeout: 4500,
			speed: 3000,
			pause: 1
		});
	},
	
	messageArea:function($)
	{
		$('#MessageArea').serialScroll(
		{
			target:'#Messages',
			items:'div.message', // Selector to the items ( relative to the matched elements, '#sections' in this case )
			prev:'#MessageNav span.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
			next:'#MessageNav span.next',// Selector to the 'next' button (absolute too)
			axis:'x',// The default is 'y' scroll on both ways
			duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
			force:true // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)	
		});
		
		$('div.message')
			.append("<div></div>")
			.hover(
				function()
				{
					$('div.message *').css('visibility', 'visible');
					$(this).css('cursor', 'pointer');
				},
				function()
				{
					$('div.message *').css('visibility', 'hidden');
			
				})
			.click(function(e)
			{
				window.location = this.getElementsByTagName("a")[0].href;
			});
		

		$('div.message *').css('visibility', 'hidden');
		
		$('div.message div').css('opacity',.8);

		$('.next').mouseover(function(e)
		{
			$(this).css("cursor", "pointer");
		});
		
		$('.prev').mouseover(function(e)
		{
			$(this).css("cursor", "pointer");
		});
	},
	
	gallery:function($)
	{
		$('#Thumbs').serialScroll(
		{
			target:'#ThumbsList',
			items:'#ThumbsList li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
			prev:'span.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
			next:'span.next',// Selector to the 'next' button (absolute too)
			axis:'x',// The default is 'y' scroll on both ways
			duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
			force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)	
			step:3
		});
		
		$('#Mediums li')
			.css('visibility', 'hidden')
			.eq(0).css('visibility', 'visible');
		$('#Thumbs a').hover(
			function(){
				$("#Mediums li").css("visibility", "hidden");
				$("#Mediums li a[href='"+$(this).attr("href")+"']").parent().css("visibility", "visible");	
			}		
		);
	},
	
	lightBox:function($)
	{
		$('a[rel=lightbox]').lightBox({
        		imageLoading: 'themes/courtneythorne/images/lightbox-ico-loading.gif', // (string) Path and the name of the loading icon
		        imageBtnPrev: 'themes/courtneythorne/images/lightbox-btn-prev.gif', // (string) Path and the name of the prev button image
		        imageBtnNext: 'themes/courtneythorne/images/lightbox-btn-next.gif', // (string) Path and the name of the next button image
		        imageBtnClose: 'themes/courtneythorne/images/lightbox-btn-close.gif', // (string) Path and the name of the close btn
		        imageBlank: 'themes/courtneythorne/images/lightbox-blank.gif'
		});
	},
	
	IE6:function($)
	{
		$("#Menu li")
			.hover(
				function(e){$(this).addClass("hover");},
				function(e){$(this).removeClass("hover");});
	}
}

jQuery.noConflict();
jQuery(function($) 
{
	CT.init($);
});