var $j = jQuery.noConflict();
$j(document).ready(function() {	
	
	
	$j.extend($j.fn.jScrollPane.defaults, {
		showArrows:true,
		scrollbarWidth:15,
		arrowSize:15
		}
	);

	var isResizing;
	
	// and the body scrollpane
	var setContainerHeight = function()
	{
		// IE triggers the onResize event internally when you do the stuff in this function
		// so make sure we don't enter an infinite loop and crash the browser
		if (!isResizing) { 
			isResizing = true;
			$jw = $j(window);
			$jc = $j('#content');						
			$jh = $j('#header');
			$jf = $j('#footer');
			var p = (parseInt($jc.css('paddingLeft')) || 0) + (parseInt($jc.css('paddingRight')) || 0);
			//$j('body>.jScrollPaneContainer').css({'height': $jw.height() + 'px', 'width': $jw.width() + 'px'});
			$j('#content-wrap>.jScrollPaneContainer').css({'height': ($jw.height() - $jh.height() - $jf.height()) + 'px'});
			$jc.css({'height': ($jw.height()-p) + 'px', 'overflow':'auto'});
			$jc.jScrollPane();
			isResizing = false;	
			
			reinitialiseScrollPane = function(){
				$jc.jScrollPane();
			}
		}
	}
	$j(window).bind('resize', setContainerHeight);
	setContainerHeight();
	
	// it seems like you need to call this twice to get consistantly correct results cross browser...
	setContainerHeight();
		
							
/*	$j('.more-blue').click(function() {
		$j(this).parent().parent().find('.hide').toggle(reinitialiseScrollPane);	
		$j(this).find('.zuklappen').toggle();
		$j(this).find('.mehr').toggle();
	});
*/
	
	$j('.toggle').toggle(function() {
		$j(this).parent().parent().find('.hide').show(reinitialiseScrollPane);	
		$j(this).find('.zuklappen').toggle();
		$j(this).find('.mehr').toggle();
		$j(this).addClass('more-act');
	}, function() {
		$j(this).parent().parent().find('.hide').hide(reinitialiseScrollPane);	
		$j(this).find('.zuklappen').toggle();
		$j(this).find('.mehr').toggle();
		$j(this).removeClass('more-act');
	});


	
	$j('.accordion').accordion({ 
		header: '.accHeader', 
    	autoheight: false,
    	active: false
	});
	
	$j('.accordion li:last-child').css({border:'none'});

});	