$(document).ready(function(){
	
	if($('.mitgliederorganisation_link').length > 0)
	{
			$('.mitgliederorganisation_link').click(function(){
				var item = $(this).attr("class");
				var pos = item.indexOf(" ")+1;
				var getit = item.substring(pos);
				var left_offset = $(this).offset();
				
				//alert("Offset-left: " + offset.left);
				
				$('.mitgliedorganisation_info_region:visible').hide();

				show_info(getit, left_offset);
			}, function(){

			});
		
	}
	
/*
	if($('.mitgliedorganisation_info_region:visible').length > 0)
	{
		
		if (document.documentElement.scrollTop == 0)
			$('.mitgliedorganisation_info_region:visible').css('top', 365 + "px");	
		else
			$('.mitgliedorganisation_info_region:visible').css('top', document.documentElement.scrollTop + "px");	
		
	}
*/
	$('a[rel=lightbox]').lightBox();
	
	$('#user-login-form :text, #user-login-form :password').each(function(i, e){
		if(supports_input_placeholder()){
			$(e).attr('placeholder', $(e).prev('label').text().replace(':', '').replace('*', ''));
		} else {
			$(e).attr('placeholder', $(e).prev('label').fadeIn());
		}
	});
	
	if($('input[id=edit-forum-node-form]').length == 1)
	{
		$('.teaser-checkbox').hide();
		$('.collapsed').hide();
	}
	
});



$(window).bind('resize', function() {

	if($('.mitgliedorganisation_info_region:visible').length > 0)
	{
		var offset = $('.mitgliederorganisation_link').offset();
		$('.mitgliedorganisation_info_region:visible').css('left', offset.left + 240 + "px");
	}

});





function show_info(region, left_offset)
{
	
	$('#'+region).css('left', left_offset.left + 240 + "px");
	
	var offset = $('#'+region).offset();
		
		if(offset.top < document.documentElement.scrollTop)
		{
		$('#'+region).css('top', $(this).scrollTop() + 10 + "px");
 		}
		
    	else if (document.documentElement.scrollTop == 0 || document.documentElement.scrollTop < 364)
 		{
    		$('#'+region).css('top', 365 + "px");
 		}
		
 		else if (document.documentElement.scrollTop > 365)
 		{
 			$('#'+region).css('top', $(this).scrollTop() + 10 + "px");
 		}
		
	
	$('#'+region).show();	
	
	if (offset.top > 0){
	$('html, body').animate({
		scrollTop: $(".minfo_1_block_1").offset().top + offset.top}, 1000);
	}
	
}

function hide_info(region)
{
 	$('#'+region).hide();
}

$(window).scroll(function() {

	if($('.mitgliedorganisation_info_region').length > 0)
	{
		
		if( $('.mitgliedorganisation_info_region').is(':visible') ) 
		{
		
		
			var offset = $('.mitgliedorganisation_info_region:visible').offset();
		
			if(offset.top < document.documentElement.scrollTop)
			{
				$('.mitgliedorganisation_info_region:visible').css('top', $(this).scrollTop() +10 + "px");
	     		}
	        	else if (document.documentElement.scrollTop == 0 || document.documentElement.scrollTop < 364)
	     		{
	        		$('.mitgliedorganisation_info_region:visible').css('top', 365 + "px");
	     		}
	     		 else if (document.documentElement.scrollTop > 365)
	     		{
	     			$('.mitgliedorganisation_info_region:visible').css('top', $(this).scrollTop()+ 10 + "px");
	     		}
	     	}
	}
});


function supports_input_placeholder() {
	var i = document.createElement('input');
	return 'placeholder' in i;
}
