

$( document ).ready
(
	function()
	{
		try 
		{
			document.execCommand( "BackgroundImageCache", false, true );
		} 
		catch( err )
		{}
	
		teaser_fix();
		newslist_fix();
		show_quick();
		a_ext_class();
	}
);

// fix height of .teaser-box'es
function teaser_fix()
{
	// id=4 ^= startseite

	var teaser = $( '#body_4 #content .teaser-box' );
	
	if( teaser.size() <= 0 )
		return false;
		
	var i_height = false;
	teaser.each
	(
		function()
		{
			var el = $( this );
			if( i_height < el.height() )
			{
				i_height = el.height();
			}
		}
	);
	//alert( i_height );
	
	teaser.each
	(
		function()
		{
			var el = $( this );
			el.css( 'height', i_height + 'px' );
		}
	);
}

function newslist_fix()
{
	//console.log( 'newslist-fix' );
	var newslist = $( '.news-list' );
	
	if( newslist.size() == 0 )
	{
		var newslist = $( '.news ul' );
	}
	
	if( newslist.size() == 0 )
		return false;
	
	var el = $( 'li', newslist );
	$( el.get( el.size() - 1 ) ).addClass( 'last' );
}

// show & activate quicklinks
function show_quick()
{
	var quick = $( '#quick' );
	
	if( quick.size() <= 0 )
		return false;
		
	quick.removeClass( 'hide' );
	
	$( 'select', quick ).bind
	(
		'change',
		function()
		{
			var val = this.options[this.selectedIndex].value;
			
			if( val <= 0 )
			{
				this.blur();
				return false;
			}
			
			window.location.href = '/?id=' + val;
		}
	);
}

function a_ext_class()
{
	$( '#bottom .main a[@href$=pdf]' ).each
	(
		function()
		{
			$( this ).addClass( 'ext ext-pdf' );
		}
	);
}
