$(document).ready(function(){

//	$("a[rel^='prettyPhoto']").prettyPhoto({
//		animationSpeed: 'normal', /* fast/slow/normal */
//		padding: 40, /* padding for each side of the picture */
//		opacity: 0.35, /* Value betwee 0 and 1 */
//		showTitle: true, /* true/false */
//		allowresize: true, /* true/false */
//		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
//		theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square */
//		callback: function(){}
//	});

//	$("a[rel^='prettyPhoto']").click(function(){
//		
//	});

//	$(".mp3").jmp3();
		// custom options
		$("#mysong").jmp3({
			backcolor: "008AAE",
			forecolor: "00ff00",
//			width: 300,
			width: 25,
			autoplay: "true",
			showdownload: "false",
			showfilename: "false",
			volume: 20,
			file: "/music/bgr.mp3"
		});

	


	$(".expandable").next(".hidden").hide( );
	$(".expandable").click(function(){

		if( $(this).hasClass("collapsable") )
		{
			$(this).next(".hidden").slideUp( );
			$(this).removeClass("collapsable");
		}
		else
		{
			$(this).next(".hidden").slideDown( );
			$(this).addClass("collapsable");
		}
		
	});
	
	//todo: pause onclick of an image

	$(".carousel").carousel( { 
		dispItems: 1,
//		dispItems: 2,
		loop: true,
		pagination: false,
		autoSlide: true,
		autoSlideInterval: 3000,
		delayAutoSlide: 500,
		effect: "slide",
		loop: true,
//		btnsPosition: "outside",
		prevBtn: '<div><span class="label" title="Previous"></span></div>',
		nextBtn: '<div><span class="label" title="Next"></span></div>',
		nextBtnInsert: "appendTo",
		prevBtnInsert: "appendTo"
	});
	
	
	$(".carousel a").click(function(event){
		
//		console.log( event.target.tagName );

		if( event.target.tagName == 'IMG' ) // => mouseclicked
		{
			window.clearInterval( $(".carousel").data( "autoslideinterval" ) );
		}
		
		$(".carousel .active").removeClass( 'active' );
		$(this).addClass( 'active' );

		$("#big-pic").addClass( 'loading' );
		var pic = new Image;
		pic.src = $(this).attr( 'href' );
		var album_title = $(this).attr('title');
		var height = $("#big-pic img").height( );
//		console.log( $(this).attr('title') );

		$("#big-pic").fadeOut( "fast", function(){
				$("#big-pic")
				.css( "height", height )
				.empty( )
				.append( pic )
		if( album_title != '' )
		{
			$("#big-pic").append( '<span class="label">'+ album_title +'</span>' )
		}
			$("#big-pic").removeClass( 'loading' )
				.css( "height", "auto" )
				.fadeIn( "slow" );
		});
		
		return false;
	});

//	$(".carousel a:first").click( );
	preload( );
});


function preload( )
{
	$(".carousel a").each(function(){
		var pic = new Image;
		pic.src = $(this).attr( 'href' );
	})
}
