jQuery(document).ready(function($){
	//superfish
	//==============================
    $('ul.primary_navigation').superfish({
      delay:    50,              // one second delay on mouseout
      speed:    'fast',             // faster animation speed
      autoArrows: false,              // disable generation of arrow mark-up
      dropShadows: false              // disable drop shadows
    });
	
	// TEXT SHADOW
	//==============================
	var textShading = {
	  x:      2, 
	  y:      -1, 
	  radius: 0,
	  color:  "#ffffff"
	}	
	$("h1 ").textShadow( textShading);

	// COLORBOX $('a[rel="examples"]').colorbox({rel:'nofollow'}); 
	//==============================
	$("a[rel='colorboxGallery']").colorbox({rel:'nofollow'}); 
	$("a[rel='colorboxGalleryExtracts']").colorbox({current:'Extract {current} of {total}'});  
	$("a[rel='colorBoxGalleryExternal']").colorbox({rel:'nofollow', width:"95%", height:"95%", iframe:true});

	// animated collapse
	//==============================
	animatedcollapse.addDiv('newsletterDropdown', 'fade=10')
	animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
		//$: Access to jQuery
		//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
		//state: "block" or "none", depending on state
	}
	animatedcollapse.init()	
	
	// carousel sideshow - home
	//==============================
	$('#homeSlideshow .slideshowItems').before('<div id="slideshowNav" class="slideshowNav"><a id="prev" href="#">Prev</a> <a id="next" href="#">Next</a>').after('<div class="clear"></div><ul class="slideshowPager" id="homeSlideshowPager">').cycle({ 
			fx:     'scrollHorz',			
			easing: 'bounceout', 
			timeout:  0,
			delay:  -2000,
			startingSlide: 7,     
			cleartypeNoBg: true,/* DO NOT REMOVE - PRODUCES BIZARRE BEHAVIOUR IN IE OTHERWISE */
			//cleartype:  false,
			pager:  '#homeSlideshowPager', 
			next:   '#next', 
			prev:   '#prev', 
			// callback fn that creates a thumbnail to use as pager anchor 
		   pagerAnchorBuilder: function(idx, slide) {
			  var thumb_prefix = "t_";
			  var img = $(slide).children('.jacket284x367').eq(0).attr("id");

			  return '<li><a href="#"><img class="'+img+'" src="../img/'+ img  +'_th_183x286.png" width="165" height="213" /></a></li>';
			}

	});

	// carousel sideshow - books
	//==============================
	$('#booksSlideshow .slideshowItems').before('<div id="slideshowNav" class="slideshowNav"><a id="prev" href="#">Prev</a> <a id="next" href="#">Next</a>').after('<div class="clear"></div><ul class="slideshowPager" id="booksSlideshowPager">').cycle({ 
			fx:     'scrollHorz',			
			easing: 'bounceout', 
			timeout:  0,
			delay:  -2000,
			cleartypeNoBg: true,/* DO NOT REMOVE - PRODUCES BIZARRE BEHAVIOUR IN IE OTHERWISE */
			//cleartype:  false,
			next:   '#next', 
			prev:   '#prev' 
			// callback fn that creates a thumbnail to use as pager anchor 
	});

	// carousel sideshow - colfer confidential
	//==============================
	$('#authorSlideshow .slideshowItems').after('<div id="slideshowNav" class="slideshowNav"><a id="prev" href="#">Prev</a> <a id="next" href="#">Next</a>').before('<div class="clear"></div><ul class="slideshowPager" id="aurhorSlideshowPager">').cycle({ 
			fx:     'scrollHorz',			
			easing: 'bounceout', 
			timeout:  0,
			delay:  -2000,
			cleartypeNoBg: true,
			//cleartype:  false,
			pager:  '#aurhorSlideshowPager', 
			next:   '#next', 
			prev:   '#prev', 
			// callback fn that creates a thumbnail to use as pager anchor 
		   pagerAnchorBuilder: function(idx, slide) {
			  var myClass = $(slide).attr("class");
			  var desc = $(slide).children("h2").text();
			  return '<li><a class="btn btnLrg '+myClass+'" href="#"><span>'+desc+'</span></a></li>';
			}

	});

	//NEWS TICKER
 	//==============================
     $(function(){
      	$("ul#newsTicker").liScroll({travelocity: 0.1});
     }); 

	// This initialises carousels on the container elements specified, in this case, carousel1.
	$("#carousel1").CloudCarousel(		
		{	
			reflHeight: 26,
			reflGap:1,	
			xPos: 115,
			yPos: 25,
			buttonLeft: $("#left-but"),
			buttonRight: $("#right-but"),
			altBox: $("#alt-text"),
			titleBox: $("#title-text"),
			bringToFront:true,
			mouseWheel:true
		}
	);

	// IMAGE ROTATOR
	jQuery('div.imgRotator').imgRotator({
		startRotation:-45,
		dragstart:function(angle){},
		dragfinish:function(angle){},
		drag:function(angle){},
		disableDrag:false
	});				
	// When the document is ready, hook up the puzzle
	// functionality to the targeted DIVs.
	$(
		function(){
			$( "div.puzzle" ).puzzle( 50 );			
		}		
	);
	
});

		
	
 

