function closeGalerie(){
	$('#galerie').hide('slow',function(){
		$('#galerie #old').remove();
		$('#galerie #new').remove();	
	});

}

function showGalerie(cat, start){
	$('#galerie').show('slow');
	$('#galerie').css('background','#000');
	$('#galerie').append('<img id="old" src="images/galerie/'+cat+'/'+start+'_1.jpg" alt=""/>');
}

function next(){
	if( aktion == false){
		 aktion = true;
		var name = $('#old').attr('src');

		var patt=/\url|\(|\"|\"|\'|\)/g;
		var name = name.replace(patt,'');

		var tmp = name.split('/');
			
		var pos = jQuery.inArray('images/galerie/'+tmp[tmp.length-2]+'/'+tmp[tmp.length-1],gal[tmp[tmp.length-2]]);
		if(pos+1>=gal[tmp[tmp.length-2]].length){
			$('#galerie').append('<img id="new" src="'+gal[tmp[tmp.length-2]][0]+'" alt=""/>');
			$('#old').fadeOut('slow', function() {
				$('#old').remove();
				$('#new').attr('id','old');
				aktion = false;
			});
			 
		}else{	
			$('#galerie').append('<img id="new" src="'+gal[tmp[tmp.length-2]][pos+1]+'" alt=""/>');
			$('#old').fadeOut('slow', function() {
				$('#old').remove();
				$('#new').attr('id','old');
				aktion = false;
			});	

		}
		 
	}
}

function pre(){
	if(aktion == false){
		aktion = true;
		var name = $('#old').attr('src');

		var patt=/\url|\(|\"|\"|\'|\)/g;
		var name = name.replace(patt,'');
		var tmp = name.split('/');
		
		var pos = jQuery.inArray('images/galerie/'+tmp[tmp.length-2]+'/'+tmp[tmp.length-1],gal[tmp[tmp.length-2]]);
		
		if(pos-1<0){
			$('#galerie').append('<img id="new" src="'+gal[tmp[tmp.length-2]][(gal[tmp[tmp.length-2]].length)-1]+'" alt=""/>');
			$('#old').fadeOut('slow', function() {
				$('#old').remove();
				$('#new').attr('id','old');
				aktion = false;
			});
			
			//$('#galerie').css('background-image','url('+gal[tmp[tmp.length-2]][(gal[tmp[tmp.length-2]].length)-1]+')');
		}else{				
			$('#galerie').append('<img id="new" src="'+gal[tmp[tmp.length-2]][pos-1]+'" alt=""/>');
			$('#old').fadeOut('slow', function() {
				$('#old').remove();
				$('#new').attr('id','old');
				aktion = false;
			});
		}

	}
}
