jQuery.fn.exists = function(){return jQuery(this).length>0;}
$(document).ready(function() {
	if($('div#noscript').exists()){$('div#noscript').remove();}
	equalall('section#headinfo article div');
	equaltwo('div#sitemap','div#ticker');
	$('div#cwrap').height($('div#menu').height());
	$('div#menu h2,div#cwrap h1').wrapInner('<span />');
	$('a.button').wrapInner('<span />');
	$('a.prev').click(function(){slideto('prev');return false;});
	$('a.next').click(function(){slideto('next');return false;});
	setTimeout('slidetimer()',5000);
});
function equaltwo(a,b)
{
	aheight=$(a).height();
	bheight=$(b).height();
	c=Math.max(aheight,bheight);
	$(a).height(c);
	$(b).height(c);
}
function equalall(a)
{
	var c=0;
	for(i=0;i<($(a).length);i++)
	{
		c=Math.max(c,$(a).eq(i).height());
	}
	$(a).height(c);
}
function slideto(to)
{
if(to==-1 || to=='next'){to=$('a.next').attr('href').substr(1,$('a.next').attr('href').length);}
if(to=='prev'){to=$('a.prev').attr('href').substr(1,$('a.prev').attr('href').length);}
if(!$('div#slider > div img').eq(to).exists()){to=0;}
to=parseInt(to);
$('div#slider > div img').hide();
$('div#slider > div img').eq(to).fadeIn(1000);
$('a.prev').attr('href','#' + (to-1));
$('a.next').attr('href','#' + (to+1));
}
function slidetimer()
{
	slideto('next');
	setTimeout('slidetimer()',5000);
}
