//	Navigation
$("document").ready(function(){



if(document.getElementById("uid54")) {

scoutid = document.URL.split("/")[7];
scoutid = scoutid.split(".html");

document.getElementById("uid54").value = scoutid[0];
}

/*
$('#wohntraumfinderpic').mouseenter(function(){
$('#fixed-element').fadeOut('fast');
$('#fixed-element').fadeIn('fast');
});
*/


/*	//	Headerbild
	var zahl = Math.ceil(Math.random()*8);
	if(zahl<1 || zahl>8){
		zahl = 1;
	}
	bild = "fileadmin/templates/images/basics/header_" + zahl + ".jpg";
	$("#headerimg").attr('src', bild);
	$("#headerimg").attr('visibilty', 'visible');
*/
	
	// Hauptnavigation
	$("ul.hm > li").mouseenter(function(){
		$(this).addClass("hover");
		$("ul.hm2", this).show();
	});
	$("ul.hm > li").mouseleave(function(){
		$(this).removeClass("hover");
		$("ul.hm2", this).hide();
	});
	
	
	// Change picture (in maps)
	function change_map_pic(image_id, new_pic) {
		var src = document.getElementById(image_id).src;
		var srcSplitResult = src.split("/");
		var newSrc = "";
	
		for(i = 0; i < srcSplitResult.length; i++){
			if(i+1 == srcSplitResult.length) {
				 srcSplitResult[i] = new_pic;
			}
			newSrc += srcSplitResult[i];
			
			if(i+1 < srcSplitResult.length) {
			  newSrc += '/';
			}
			
			 document.getElementById(image_id).src = newSrc;
		}
	}
});


/* Slideshow */
var mySlide;
$("document").ready(function(){
	$("#slide_content img").removeAttr("width").removeAttr("height");
	mySlide = $("ul#flip").jcoverflip({
		current: 1,
		beforeCss: fnBeforeCSS,
		afterCss: fnAfterCSS,
		currentCss: fnCurrentCSS
	});
	$("#slide_left").click(function(){
		mySlide.jcoverflip("previous");
	});
	$("#slide_right").click(function(){
		mySlide.jcoverflip("next");
	});
	
	if('#wrapper_fb') {
		$('fieldset p br').remove();
		$('label > br').remove();
		$content = $('fieldset p').html();
		$('fieldset p').remove();
		h1 = $('.tx-alto-ewgmap h1').html();
		$('.tx-alto-ewgmap h1').remove();
		$('.tx-alto-ewgmap').prepend('<p>'+$content+'</p>');
		$('.tx-alto-ewgmap').prepend('<h1>'+h1+'</h1>');
			$('.tx-alto-ewgmap').append('<div id="newcnd"'+h1+'</div>');
			$('.tx-alto-ewgmap fieldset strong').remove();
			$('fieldset').prepend('<h1 style="margin-bottom:0px;">Legende</h1>');
		}
		
	

	
});

function fnBeforeCSS(el, container, offset){
	if(offset>0){
		return [
		        $.jcoverflip.animationElement( el, { opacity: 0, zIndex: 0, left: ( container.width( )/2 - 270)+'px', bottom: '60px' }, { } ),
		        $.jcoverflip.animationElement( el.find( 'img' ), { width: '145px' }, {} )
		        ]
	}
	else{
		return [
		        $.jcoverflip.animationElement( el, { opacity: 0.5, zIndex: 5, left: ( container.width( )/2 - 270)+'px', bottom: '60px' }, { } ),
		        $.jcoverflip.animationElement( el.find( 'img' ), { width: '145px' }, {} )
		        ];
	}
}

function fnAfterCSS(el, container, offset){
	if(offset>0){
		return [
		        $.jcoverflip.animationElement( el, { opacity: 0, zIndex: 0, left: ( container.width( )/2 +125 )+'px', bottom: '60px' }, { } ),
		        $.jcoverflip.animationElement( el.find( 'img' ), { width: '145px' }, {} )
		        ]
	}
	else{
		return [
		        $.jcoverflip.animationElement( el, { opacity: 0.5, zIndex: 5, left: ( container.width( )/2 +125 )+'px', bottom: '60px' }, { } ),
		        $.jcoverflip.animationElement( el.find( 'img' ), { width: '145px' }, {} )
		        ];
	}
}

function fnCurrentCSS(el, container){
    return [
            $.jcoverflip.animationElement( el, { zIndex: 10, opacity: 1, left: ( container.width( )/2 - 145 )+'px', bottom: '16px' }, { } ),
            $.jcoverflip.animationElement( el.find( 'img' ), { width: '290px' }, { } )
          ];	
}
