var archiveActive = 0;
var players = [];



function locateNavi() {
	var wW = $(window).width();
	if (wW <= 968){
		$("body").addClass("narrow");
	} else {
		$("body").removeClass("narrow");
	}
}


function setSearchParameter( var1, var2, var3 )
{
	if(var1==1)
	{   //alert($('#dummy').html());
		$("#bereich").text(var2);
		$("#input-bereich").val(var3);
	}
	else if(var1==2)
	{   //alert($('#dummy').html());
		$("#jahr").text(var2);
		$("#input-jahr").val(var3);
	}
	else if(var1==3)
	{   //alert($('#dummy').html());
		$("#genre").text(var2);
		$("#input-genre").val(var3);
	}
	else if(var1==4)
	{   //alert($('#dummy').html());
		$("#instrument").text(var2);
		$("#input-instrument").val(var3);
	}
	$("section.ul.subnav").removeClass("subhover"); //On click .section li a, remove class "subhover" 


	$('#loading-info').fadeIn();
	var formData = $.param($("#search-form").serializeArray());							
	$.get("index.php?eID=enjott_async", formData, function(data) {
		//alert("Data was loaded" + data );
		$("#search-form").html(data);
		$('#loading-info').fadeOut();
	});						
	
}


$(document).ready(function() {

	locateNavi();
	$(window).resize(function() {  locateNavi(); });


	$(document).click(function(){
		$('#repertoire-background').css('display', 'none');
		$(this).parent().find('#arrowNavi').css('display', 'inline');
	});
	$("#repertoire-background, .repertoire-navi").click(function(e){
		$('#repertoire-background').css('display', 'block');
		$(this).find('#arrowNavi').css('display', 'none');
		
		e.stopPropagation();
	});




	
	// Changed to "live" event handler for ajax usage
	$(".section").live('click', function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown(100).show(); //Drop down the subnav on click
		$(this).css('background-color','#FFFFFF');

		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp(100); //When the mouse hovers out of the subnav, move it back up
			$(this).find(".section").css('background-color','#F0F0F0');
		});

		$(this).parent().find(".subnav li").click(function() {
			$(this).parent().parent().parent().find("ul.subnav").slideUp(100);
			$(this).parent().parent().parent().removeClass("subhover"); //On hover out, remove class "subhover"
			$(this).parent().parent().find(".section").css('background-color','#F0F0F0');
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
			$(this).parent().find(".section").css('background-color','#FFFFFF'); 
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
			$(this).parent().find(".section").css('background-color','#FF0000');
	});

	$(".section").hover(function() {
	}, function(){	
		$(this).css('background-color','#F0F0F0');
	});
	
	$("a[rel=fotos_group]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	
	
	if( $('#notes').css('visibility') == 'visible' )
	{
	$("a[rel=notenbeispiele_group]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	} 
		
	if( $('#fotos').css('visibility') == 'visible' )
	{	
		$("a[rel=fotos_videos_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
		}
			
			$("#video").click(function() {
				$.fancybox({
						'padding'			: 0,
						'autoScale'			: false,
						'transitionIn'		: 'none',
						'transitionOut'		: 'none',
						'title'				: this.title,
						'width'				: 680,
						'height'			: 495,
						'href'				: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
						'type'				: 'swf',
						'swf'				: {
						'wmode'				: 'transparent',
						'allowfullscreen'	: 'true'
						}
					});

				return false;
			});  
});


