var hvorher;
var whatToRestore;
function flow1(what){
	if($(what).hasClass('accordeon-wrap-closed')){
		$(what).removeClass('accordeon-wrap-closed');
		$(what).addClass('accordeon-wrap-open');
	}else if($(what).hasClass('accordeon-wrap-open')){
		$(what).removeClass('accordeon-wrap-open');
		$(what).addClass('accordeon-wrap-closed');
		//hvorher = $(what).parent("div").height();
		hvorher = $('#main-content').height();
		
		
		
		//$('#main-content').css('height',20000);

		//window.setTimeout("restoreHeight()", 500);
		
	}
}


function restoreHeight(){
	//$('#main-content').css('height', 20000).css('height', 1600);
}

function show_modal(content, div)
{
	// set default modal
	if (div == null) div = 'modal_error';
	
	// get screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();

	//Set height and width to mask to fill up the whole screen
	$('#mask').css({'top':0,'left':0,'width':maskWidth,'height':maskHeight});
	
	// fade in mask
	$('#mask').fadeTo("slow", 0.2);

	// get window height and width
	var winH = $(window).height();
	var winW = $(window).width();

	// insert message
	$('#' + div + ' p.message').html(content);

	// get modal
	var modal = $("#" + div);
	
	// center modal window
	modal.css('top', winH / 2 - modal.height() / 2 + $(document).scrollTop() - 20);
	modal.css('left', winW / 2 - modal.width() / 2);

	// fade in modal
	modal.fadeIn(500);		
	
	$(document).bind('scroll.modal', function()
	{
		var winH = $(window).height();
		modal.css('top', winH / 2 - modal.height() / 2 + $(document).scrollTop() - 20);
	});
	
	$(window).bind('resize.modal', function()
	{
		var winW = $(window).width();
		var winH = $(window).height();
		
		modal.css('left', winW / 2 - modal.width() / 2);
		modal.css('top', winH / 2 - modal.height() / 2 + $(document).scrollTop() - 20);
	});				
}

// close modal when close button is clicked
$('div.modal .close').live('click', close_modal);		

// close modal when mask is clicked
$('#mask').live('click', close_modal);	

function close_modal()
{
	$('#mask').hide();
	$('div.modal').hide();
	$(document).unbind('scroll.modal');
	$(window).unbind('resize.modal');
	return false;	
}

var initFBLinks = function(){
	window.setTimeout(function(){
		$('a.fb-link').click(function(){
			var $this = $(this), $img = $this.find('img');
			// check if the image is a fb image
			var src = $img.attr('src');
			if(src && /^http:\/\/photos.*?fbcdn.net/i.exec(src) != ''){
				$('body').append('<div class="modal" id="modal_image"><p class="message"></p></div><div id="mask"></div>');
				// suffix _s is for a small image, _n for normal. replace _s with _n
				var href = src.replace(/_s(\.\w{3,4})$/i, '_n$1');
				$('<img />').attr('src', href).load(function()
				{
					var image = '<img src="' + href + '" />';
					show_modal(image, 'modal_image');		
				});
				return false;
			}
			return false;
		});
	}, 500);
	return false;
}
//main-content-leftcol
