
$(document).ready(function(){	
  // Tag cloud concertina
  // is there a tagcloud?
  if($('#tags').length > 0 ){
    $('.tags_left').append('<span></span>');
    $('.tags_left span').click(function(){
      $('#tags').find('ul').slideToggle(function() {
      $('.tags_left span').toggleClass('active');
	if ($('#tags').find('ul').is(':visible')){
	  document.cookie = 'menu=yes; expires=10000000';
	} else {
	  document.cookie = 'menu=no; expires=Thu, 01-Jan-1970 00:00:01 GMT';
	}
      });
    });

    // tag cloud state check
    (function tagCloudState(){
      if ((document.cookie.indexOf('menu=yes') == null) || (document.cookie.indexOf('menu=yes') == -1)) {
        // tag cloud is closed (default action)
        $('#tags').find('ul').slideUp();
        $('.tags_left span').addClass('active');
	document.cookie = 'menu=no; expires=Thu, 01-Jan-1970 00:00:01 GMT';
      } else {
        // tag cloud is open
        $('.tags_left span').removeClass('active');
	document.cookie = 'menu=yes; expires=10000';
      }
    })();
  }

	
  if($('#featured_container').length > 0 ){
    $('#featured_intro').append('<span class="arrow"></span>');
  }
	
});	

var load_featured_shows = function() {
  // The show carousel
  // check if there's a carousel first
  if ($('#show_carousel').length > 0) {
    // resize the items container to be the height of th first element
    var setHeight = $('#show_carousel .items > div.details:eq(0)').height();
    $('#show_carousel .items').height(setHeight);
    // check to see there's more than one item and if so set the pagination
    if ($('#show_carousel .items > div').length > 1){
      $('#show_carousel').prepend('<div class="carousel_controls"><span class="featured-show-prev" title="Previous"></span><span class="featured-show-next" title="Next"></span></div>');
    }
    // init the carousel
    $('#show_carousel').scrollable({
       onSeek: (function(event,target){
          // as we are using circular, must add one to the target
          target += 1;
	  setHeight = $('#show_carousel .items > div:eq('+ target +')').height();
          if(setHeight > 0) {
	     $('#show_carousel .items').animate({
	        height: setHeight
	     });
          }
      }),
      circular: true,
      items: '.items',
      prev: '.featured-show-prev',
      next: '.featured-show-next'
    }).autoscroll(10000); // 10 seconds
  }
}
