function iniContentGallery()
{
	$("#content div.thumbscontainer").carousel( { dispItems: 2,  effect: "fade", nextBtn:'#content div.gal-next', prevBtn:'#content div.gal-prev', btnsPosition:'inside', nextBtnInsert:'prependTo' } );
	$.fn.fancyzoom.defaultsOptions.imgDir='assets/templates/andreas00/img/fancy/'; //very important must finish with a /
	$('#content a.fancy').fancyzoom({Speed:400,showoverlay:false});

	// Content Galerie Navi nur einblenden, wenn Bilder vorhanden
	if ($('#content').find("ul.thumbs").length > 0)
	{
 		$("#content div.gal-next, #content div.gal-prev").show();
	} 
}

function iniLoadContent()
{

	
	$("div#leftside a:not(.extern), div#footer ul.thumbs a").click(function(){  
		var href = $(this).attr('href');
		href = href + '&ajax_request';
		
		$('ul.avmenu li a').removeClass('active').removeClass('current');
		$(this).addClass('active').addClass('current');
		
		$('#content').animate
				({
       				opacity: 0
    			
				}, 300, "linear", function()
					
					{
    				$('#content div.thumbscontainer').hide();
    				//alert("all done");
    				$('#extras').animate
				({
       				opacity: 0
    			
				}, 300, "linear", function()
					
					{
						$.ajax({
								url: href,
								cache: false,
								success: function(html){
				
								var content = $('#content', html).html();
								var extras = $('#extras', html).html();
								
								$("#content").empty().append(content).animate
								({
				       				opacity: 1
				    			
								}, 1000, "linear", function()									
									{
										
					    				iniContentGallery();
					    				$("#extras").empty().append(extras).animate
											({
				       							opacity: 1
				    			
											}, 500, "linear", function()
									
									{
				    						iniLoadLabels();
				    						$('#content div.thumbscontainer').css("visibility", "visible");
				    						//$('#content div.thumbscontainer').fadeIn(500);
									
									}			    				
				    			);
									
									});
								}
						});	    				
					
					});
					});
	return false;
	});
	
	$("div#footer ul.thumbs a").click(function(){  
		$('ul.avmenu li a[title="Labels"]').addClass('active').addClass('current');
	});	
	
}


function iniLoadLabels()
{
	$("div#extras ul.labelmenu a").click(function(){  
		var href = $(this).attr('href');
		href = href + '&ajax_request';
		
		$('ul.labelmenu li a').removeClass('active').removeClass('current');
		$(this).addClass('active, current');
		
		$('#content').animate
				({
       				opacity: 0
    			
				}, 300, "linear", function()
					
					{
						$.ajax({
								url: href,
								cache: false,
								success: function(html){
				
								var content = $('#content', html).html();
								
								$("#content").empty().append(content).animate
								({
				       				opacity: 1
				    			
								}, 1000, "linear", function()									
									{
										
					    				iniContentGallery();
				    				
				    						$('#content div.thumbscontainer').css("visibility", "visible");
									});
								}
//alert("all done");
						});	    				
					});
	return false;
	});
}


$(document).ready(function()
{
$=jQuery.noConflict();

/// Load Content via AJAX
iniLoadContent();
iniLoadLabels();
iniContentGallery();


//Start load effect
$(function() {

	$("#musik").animate
	({
			opacity: 0
	
	}, 2000, "linear", function()									
		{
	
	
	
	$("#content").animate
	({
			opacity: 1
	
	}, 1000, "linear", function()									
		{
			$("#extras").animate
				({
						opacity: 1
	
				}, 500, "linear", function()
		
		{
				$('#content div.thumbscontainer').css("visibility", "visible");
		}			    				
	);
		
		});	});

});


$("#footer div.thumbscontainer").carousel( { dispItems: 4, nextBtn:'#footer div.gal-next', prevBtn:'#footer div.gal-prev', effect: "fade", btnsPosition:'inside', nextBtnInsert:'prependTo', loop:'true' } );
//$("#content div.thumbscontainer").carousel( { dispItems: 1,  effect: "fade", nextBtn:'#content div.gal-next', prevBtn:'#content div.gal-prev', btnsPosition:'inside', nextBtnInsert:'prependTo' } );



$("#musik").jPlayer({
	ready: function () {
		$(this).setFile('http://www.jule-avantgarde.de/assets/templates/andreas00/music/avril.mp3').play();
	},
    swfPath: "assets/templates/andreas00/js"

})
.jPlayerId("play", "play")
.jPlayerId("pause", "pause")
.jPlayerId("stop", "stop")
.onSoundComplete( function() {
  $(this).play();});



// Galerie COntent Navi nur einblenden, wenn Bilder vorhanden
/*
if ($('#content').find("ul.thumbs").length > 0)
{
 $("#content div.gal-next, #content div.gal-prev").show();
} 
*/

});
