$(document).ready(function() {

var slides = $('#slideshow .slide');
slidecount = slides.length;
if(slidecount > 1)
{
	var delay = 12000;
	var currentslide = 0;
	var timer;
	
	function setupSlideshow()
	{
		$('#slideshow .slide:gt(0)').css('left','-680px');
		for(i=0; i<slidecount; i++)
			$('#slideshownav').append('<a rel="'+i+'">'+i+'</a>');
		$('#slideshownav a').bind('click',function(){gotoSlide($(this).attr('rel'));});
		$('#slideshownav a:eq(0)').addClass('currentSlideButton');
		$('#slideshownav').fadeIn(800);
		$('#slideshow .slide:eq(0)').delay(300).animate({'left':'30px'},800,function(){
			timer=setTimeout(function(){gotoSlide(currentslide+1);},delay);	
		});
	}
	
	function gotoSlide(slidenum)
	{
		if(slidenum != currentslide)
		{
			clearTimeout(timer);
			slidenum = slidenum%slidecount;
			$('#slideshownav a').removeClass('currentSlideButton');
			$('#slideshow .slide:eq('+currentslide+')').animate({'left':'-680px'},800,function(){
				$('#slideshow .slide:eq('+slidenum+')').delay(300).animate({'left':'30px'},800,function(){
					$('#slideshownav a:eq('+slidenum+')').addClass('currentSlideButton');
					currentslide = slidenum;
					timer=setTimeout(function(){gotoSlide(currentslide+1);},delay);
				});
			});
		}
	}
	
	setupSlideshow();
}
else
{
	$('#slideshow .slide:eq(0)').css('left','30px');	
}



$("#sidebar .ngg_images a").hover(function() {

	$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 

	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/

		.animate({

			marginTop: '-75px', /* The next 4 lines will vertically align this image */ 

			marginLeft: '-75px',

			top: '50%',

			left: '50%',

			width: '100px', /* Set new width */

			height: '100px', /* Set new height */

			padding: '20px'

		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */



	} , function() {

	$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */

	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/

		.animate({

			marginTop: '0', /* Set alignment back to default */

			marginLeft: '0',

			top: '0',

			left: '0',

			width: '75px', /* Set width back to default */

			height: '75px', /* Set height back to default */

			padding: '5px'

		}, 400);

});


$("a.fancyboxgroup").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false,
		'enableEscapeButton': true,
		'hideOnOverlayClick' : true,
		'hideOnContentClick': true
});



$(".movieclip").fancybox({
			'padding'	: 0,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'width'	: 680,
			'height' : 495,
			'type'	: 'swf',
			'swf'	: {
			   	'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			},
			'onComplete' : function() {
	    $("#musicplayer").hide();
	},
	'onClosed' : function() {
	    $("#musicplayer").show();
	}
});

    });

