var BASE = "http://www.filmladen.de/dokfest";
var jQ = jQuery;

jQuery(document).ready(function()
{
	if (jQ('#SearchForm_ScreeningSearchForm')){
		
			var $ScreeningSearchInput = jQ('#SearchForm_ScreeningSearchForm_ScreeningSearch');
			var SearchForm_Search_Val = $ScreeningSearchInput.val();
			
			$ScreeningSearchInput.focus(function() 
			{	
						if ($ScreeningSearchInput.val() == "Suche" || 
								$ScreeningSearchInput.val() == "Search") 
									jQ(this).val("");	
			});
			$ScreeningSearchInput.blur(function() 
			{	
				if ($ScreeningSearchInput.val() == "")
							jQ(this).val(SearchForm_Search_Val);
				
			});
	}
	if (jQ('.screeningGroup')) {
		jQ('.screeningGroup')
			.not('.current')
			.hide();
		jQ('#earlier').hide();
		$screeningGroups = $('.screeningGroup');
 	}

	jQ('#centerCol_head .right')
		.css({"cursor":"pointer"})
		.click(function() {
			window.print();
		});
		initPlayer();
	
});

function initPlayer()
{

	if (jQ('.pl').length > 0) {
			var player = "<h3>Podcasts</h3>";
			jQ('.pl').each(function(index) { player+= jQ(this).html(); })
							 .remove();
			jQ('#podcasts').html(player);
	}
}

var group = 0;

function nextScreenings(){


	if (group < $screeningGroups.length && group >= 0) {
			group++;		
			$('#earlier').show();
			$('.screeningGroup.current').removeClass("current").hide();
			$($screeningGroups[group]).addClass("current").show();		
	} 		
	if (group >= $screeningGroups.length-1)
			{
				$('#later').hide();
				$('#earlier').show();
				group = $screeningGroups.length-1;
			}
}
function previousScreenings(){

	if (group <= 0)
	{
			$('#earlier').hide();
			$('#later').show();
			group = 0;
	}
	if (group >= 1 && group < $screeningGroups.length) {

			group--;
			$('#later').show();
			$('.screeningGroup.current').removeClass("current").hide();
			$($screeningGroups[group]).addClass("current").show();
	}
	if (group <= 0){
		$('#earlier').hide();
	}

}


function protectedMail(id)
{
	var acc = jQ.get(BASE+'/kuenstler-datenbank/Mailto/'+id, function(data){
		if (data.length > 0) { window.location.href = data; }		
	} );


}