$(function () {

	$('#slider-images ul').cycle({
		fx: 'scrollHorz',
		speed: 1500,
		timeout: 7500,
		//next: '#next-'+i,
		//prev: '#prev-'+i,
		slideExpr: 'li',
		pager: '#slider-nav div',
		activePagerClass: 'current'
	});
	
	resizePips();

	/* Calendar thru addition*/	
	$('div.event ul').each(function(){
		var dates = $(this).children('li').length;
		if(dates > 1){
			$(this).children('li:first').append('<li class="thru">thru</li>');
		}
	});
	
});

function resizePips() {
	
	$('#slider-nav div').css({
		'left': ((totWidth/2)-(pipWidth/2))
	});
}

function artists(){	
}

function gallery(){
}

function lightbox(){
	
	$('.gallery-thumbs li a').bind('click',function(e){
	
		e.preventDefault();
		var fullsize = $(this).attr('href');
		var title = $(this).attr('title');
		var artist = $(this).attr('artist');
		var media = $(this).attr('media');
		
		$('body').css({
			'overflow-y':'hidden',
			'padding-right':'15px'
		});

		$('<div id="overlay"><div>').css({
				'top':$(document).scrollTop(),
				'opacity':'0',
				'background':'#3f3f3f',
				'cursor':'pointer'
			})
			.animate({'opacity':'0.5'},'slow')
			.prependTo('body');

		$('div id="lightbox-content"></div>')
		//	.hide()
			.prependTo('body');

		$('<img />').attr('src', fullsize).load(function(){
			positionLightboxImage();
		}).appendTo('#lightbox-content');
	});

	$('#overlay').click(function(e){
		e.preventDefault();
		removeLightbox();
	});

	function removeLightbox(){
		$('#overlay #lightbox-content').fadeOut(function(){
			$(this).remove();
		});
		$('body').css({
			'overflow-y':'auto',
			'padding-right':'0px'
		});
	}
	
	function positionLightboxImage(){

	  var top = ($(window).height() - $('#lightbox-content').height()) / 2;
	  var left = ($(window).width() - $('#lightbox-content').width()) / 2;

	  $('#lightbox-content')
	    .css({
	      'top': top + $(document).scrollTop(),
	      'left': left
	    })
	    .fadeIn();
	}	
}

	/*


	ADAMS GARBAGE!
	
	
	
	//lightbox();
	var numberOfheros = $('#hero-images img').length;
	var heroNavWidth = (numberOfheros) * 15	
	
	if (numberOfheros > 1){
		buildHeros();
	}
	
	if(numberOfheros == 0){
		$('div#hero').remove();
		$('div#content').css('padding-top','25px');
	}
	
	*/
	
	/*
	
	function buildHeros(){

		$('#hero-images img').each(function(i){
			var imageId = i+1;
			var imageIndex = (i+1)-5;
			
			$(this).attr('id','image-'+imageId+'');
			$('#hero-nav ul').append('<li><a href="#image-'+imageId+'"><span class="hidden">Image-'+imageId+'</span></a></li>');
			$('#hero-nav ul li:first').addClass('active');
			$('#hero-images img:first').addClass('active');
			$('#hero-nav ul').css({
				'display':'block',
				'width':''+heroNavWidth+''
			});
		});
		
		var playSlideshow = setInterval(function(){
			slideSwitch();
		},5000);

		function slideSwitch() {
			var activeHero = $('#hero-images img.active');
			var activeHeroNav = $('#hero-nav li.active');
			
			if ( activeHero.length == 0 ) activeHero = $('#hero-images img:last');
			if ( activeHeroNav.length == 0 ) activeHeroNav = $('#hero-nav li:last')
			
			var nextHero = activeHero.next().length ? activeHero.next(): $('#hero-images img:first');
			var nextHeroNav = activeHeroNav.next().length ? activeHeroNav.next(): $('#hero-nav li:first')
		
			activeHero.addClass('last-active');
			activeHeroNav.addClass('last-active');
			
			nextHero.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				activeHero.removeClass('active last-active');
			});
			
			nextHeroNav.addClass('active');
			activeHeroNav.removeClass('active last-active');
		}

		$('#hero-nav li').bind('click',function(e){
			e.preventDefault();
						
			$('#hero-nav li.active').removeClass('active');
			$(this).addClass('active');

			var heroNavTabActive = $('#hero-nav li.active').children('a').attr('href');
			playSlideshow = clearInterval(playSlideshow);
			
			$('#hero-images img.active').removeClass('active');
			$('#hero-images img'+heroNavTabActive+'').addClass('active');
		});
	}
	
	*/



