var nCount = 0;

$(document).ready(function()
{
	//setSameHeight('#content.home div.cell');
	$('#content.standard .cell.mid a:has(img)').not('.printer').addClass('lightbox').attr('rel', 'pics');
	$('#content.standard .cell.right .title:empty').remove();
	$('#content .cell.right').each(function(){
		$('.image:first', this).css('margin-top', '0');
		$('.image:last', this).css({'margin-bottom':'0', 'border':'0', 'padding-bottom':'0'});
	});
	$('#content.standard .cell.right .link li:last-child a').css('margin', '0');
	$('#content.sitemap .cell.mid .cell:even').css('float', 'left');
	$('#content.sitemap .cell.mid .cell:odd').css({'float':'left', 'margin-left':'15px'});
	$('#content.sitemap .cell.mid .cell:odd').after('<div style="clear:both;">');	
	$('#content.standard .block.video .title:empty').remove();	
	$('#content.standard .cell.mid .block img, #content.home img').each(function(){
		if($(this).attr('align') == "right")
		{
			$(this).removeAttr('hspace').css('margin-left', '10px');
		}
		else
		{
			$(this).removeAttr('hspace').css('margin-right', '10px');
		}
	});
	$('#content.standard .cell.mid .block table').each(function(){
		$(this).removeAttr('border').removeAttr('cellspacing').removeAttr('cellpadding');
		$('td', this).removeAttr('style');
	});
	//$('#content.standard .cell.mid .block.text a, #content.home a, #content.standard .cell.mid .block.video span.link').each(function(){
	$('#content.home a').not('.cell.left.menu a').each(function(){
		$(this).css({'font-weight':'bold', 'text-decoration':'none', 'white-space':'nowrap'});
		$(this).not(':has(img)').append('&nbsp;<img src="/images/elements/a_bg.png" alt="blue-arrow" />');
		$('br', this).remove();
	});
	$('.cell.mid td:last-child').each(function()
	{
		$(this).addClass('noBdRt');
	});
	
	$('.cell.mid tr:last-child').each(function()
	{
		$('td', this).addClass('noBdBt');
	});
	
	$('#menu .button').hover(function()
	{
		$('a:first', this).addClass('on');
		/*
		$('.nav', this).addClass('on');
		$('.nav li', this).hover(function()
		{
			$('ul', this).addClass('on');
			$('a:first', this).addClass('on');
		},function()
		{
			$('ul', this).removeClass('on');
			$('a:first', this).removeClass('on');
		});
		*/
	}, function()
	{
		$('a', this).removeClass('on');
		//$('.nav', this).removeClass('on');
	});
	
	
	$('.line', '#menu .button:last-child').css('display', 'none');
	
	$('.breadcrumb a:not(:last)').each(function()
	{
		$(this).append(' >');
	});
});

function setMenuButtonWidth()
{
	var nMenuWidth = $('#wrapper').width();
	$('#menu .button').each(function()
	{
		nCount++;
	}), $('#menu .button').each(function()
	{
		$(this).css('width', Math.floor( (nMenuWidth / nCount) ) );
	});
}

function setSameHeight(sCell)
{
	var nHeight = new Number();
	if($(sCell).length)
	{
		$(sCell).each(function() 
		{
			if($(this).is(':first-child') )
			{
				nHeight = $(this).height();
			}
			else
			{
				if($(this).height() > nHeight)
				{
					nHeight = $(this).height();
				}
			}
		}), $(sCell).each(function()
		{
			$(this).css('height', function(index)
			{
				return nHeight;
			});
		});
	}
	else
	{
		alert('Keine Zellen gefunden!');
	}
};

$(function()
{
	var offset = $('#slideshow').offset();
	var xBG = 0;
	$('#slideshow').cycle(
	{
		fx: 'fade',
		random: 0,
		speed: 3000,
		timeout: 5000,
		slideExpr: 'img'
	}), 
	$('#counter a').each(function()
	{
		xBG++;
		$(this).empty();
		$(this).append('<div style="background:url(images/elements/nav_bg_' + xBG + '.png)" >');
	}), 
	$('.imageslider').hover(function()
	{
		$('#slideshow').cycle('pause');
	}, function()
	{
		$('#slideshow').cycle('resume');
	});
	
	$('.imageslider').mouseenter(function()
	{
		$(this).mousemove(function(e)
		{
			if( (e.pageX - offset.left) < 100)
			{
				$('.imageslider .arrow.left').fadeIn('fast');
			}
			else
			{
				$('.imageslider .arrow.left').fadeOut('fast');
			}
			
			if( (e.pageX - offset.left) > $('#slideshow').innerWidth() - 100)
			{
				$('.imageslider .arrow.right').fadeIn('fast');
			}
			else
			{
				$('.imageslider .arrow.right').fadeOut('fast');
			}
		});
	});
	
	$('.imageslider').mouseleave(function()
	{
		$('.imageslider .arrow.left').fadeOut('slow');
		$('.imageslider .arrow.right').fadeOut('slow');
	});
});
