// JavaScript Document
jQuery(document).ready(function() {
	var $scope = jQuery(document);
	// code
	jQuery('#mein_akkordion div.text').hide();
	jQuery('#mein_akkordion h3').bind('click', mein_akkordion_toggle);
	jQuery('.mein_akkordion_link').bind('click', mein_akkordion_link);
	
	
	if  ( jQuery('#scroll').attr('id') == 'scroll' ) {
		jQuery('#scroll').css({'height':'250px', 'overflow':'hidden'});
		jQuery('#scroll .scrollelement').css({'height':'210px'});	
		
		$.localScroll({
			target: '#scroll', // could be a selector or a jQuery object too.
		});
	}
	
});

mein_akkordion_init = function($akkordion) {
	$akkordion.find('div.text').hide();
};

mein_akkordion_toggle = function() {
	var $this = jQuery(this);
	var $text = $this.next();	
	if ($text.css('display') == 'none') {
		$text.slideDown('fast');
	} else {
		$text.slideUp('fast');
	}
};

mein_akkordion_link = function() {
	var $this = jQuery(this);
	var $meta = $this.metadata();
	var $anchor = $meta.anchor;
	
	var $text = jQuery('#mein_akkordion div.'+$anchor);	
	if ($text.css('display') == 'none') {
		$text.show(1, function() {
			var $new_position = $('[name='+$anchor+']').offset();		
			window.scrollTo($new_position.left,$new_position.top);			
		}); 

	} else {
		var $new_position = $('[name='+$anchor+']').offset();		
		window.scrollTo($new_position.left,$new_position.top);
	}	
	return false;
};


