function getPermission(text){
	var answer = confirm(text);
	
	if(answer == false){
		return false;
	}else{
		return true;
	}
}

function check(cookie){
	if(cookie){
		animateNav('new', false);
	}else{
		if(location.hash != ""){
			animateNav(location.hash.substr(1),false);
		}else{
			animateNav('new', false);
		}
	}
}

function animateNav(param, blendBg){
	if(blendBg=="")
		blendBg = true;
	location.hash = param;
	$('.button-container a[class*='+param+']').addClass('active');
	$('.button-container a:not([class*='+param+'])').removeClass('active');
	
	if(!blendBg){
		$('#layer').fadeIn(1000, function(){
			$('#stripe').removeClass().addClass(param);
			$('li.nav-item[class*="'+param+'"]').animate({
				marginLeft: '0px'
			}, 500);
			
			$('li.nav-item:not([class*="'+param+'"])').animate({
				marginLeft: '90px'
			}, 500);
		});
		$('#layer').fadeOut(1000);
	}else{
		$('#stripe').removeClass().addClass(param);
			$('li.nav-item[class*="'+param+'"]').animate({
				marginLeft: '0px'
			}, 500);
			
			$('li.nav-item:not([class*="'+param+'"])').animate({
				marginLeft: '90px'
			}, 500);
	}
	$('.logo a, .lang-link, .nav-item > a, .subnav a, area').not('#content a[href*="mailto"], #content a[href*="tel"]').each(function(){
		if($(this).attr('href').indexOf('#') < 0)
			$(this).attr('href', $(this).attr('href')+'#'+param);
		else{
			var parts = $(this).attr('href').split('#');
			$(this).attr('href', parts[0]+'#'+param);
		}
	});
	$.cookie('nav-state', param);
}

function toggleLogin(){
	if($('#login-container').css('top') != '0px'){
		$('#login-container').animate({
			top: '0px'
		}, 1000);
	}else{
		$('#login-container').animate({
			top: '-'+$('#outer-container').css('height')
		}, 1000);
	}
}

function toggle(index){

	if($('#'+index).css('marginLeft') == '90px'){
		$('#'+index).animate({marginLeft: '0px'},200);
		$('#'+index).attr('rel', 'foldable');
	}
	
	if(($('#'+index).css('marginLeft') == '0px') && $('#'+index).attr('rel') == 'foldable'){
		$('#'+index).removeAttr('rel');
		$('#'+index).animate({marginLeft: '90px'},200);
	}
}

function initGallery(id){
	$("#gallery-container").load("includes/load_gallery.inc.php?g_id="+id, function(response, status, xhr) {
	  if (status == "error") {
		var msg = "Sorry but there was an error: ";
		$("#gallery-container").html(msg + xhr.status + " " + xhr.statusText);
	  }
	});
	$('#gallery-container').css('marginTop',parseInt($('#content-container').css('height'))-parseInt($('#stripe').css('height'))+'px').show();
	
	var new_margin = parseInt($('.button-container').css('height'))+parseInt($('.icon-container').css('height'))+parseInt($('#content-top').css('height'))+parseInt($('#content-middle').css('height'))+20;
	var body_height=parseInt($('body').css('height'))
	$('#stripe').animate({
		marginTop: '-'+new_margin+'px'
	}, 2000);
	$('.logo').css('top', '7px');
	$('.bild').show();
}

function discardGallery(){
	$('#stripe').animate({
		marginTop: '0px'
	}, 2000);
	$('.logo').css('top', '40px');
	$('.bild').hide();
	$('#gallery-container').hide();
}
