$(document).ready(function(){
	$(window).scroll(function(){return false;});

	var style = 'ul.news > li a.more { display: none; } ul.news > li { cursor: pointer; }';
	$("<style type='text/css'>"+style+"</style>").appendTo("head");
	$("ul.news > li").live('click',function(){
		top.location.href = $(this).find('a.more').attr('href');
	});

	/* activate local links */
	$('a').click(function(e){
		/* local links, load via ajax */
		if ($(this).attr('href').match(/^\//)){
			//return false;
		}
		/* game details, load in a thinbox */
		if ($(this).attr('href').match(/regioleague.*spiel_details\.asp/)){
			$.fancybox({
				'autoScale'		: false,
				'scrolling' : 'auto',
				'width'			: 760,
				'height'		: 680,
				'href'			: '/fancybox/spieldetails/'+
					$(this).attr('href').replace(/.*asp\?Spiel=/,''),
				'type'			: 'iframe',
				'onStart' : function() {
					//$("body").css({'overflow':'hidden'});
					},
				'onClosed' : function() {
					//$("body").css({'overflow-y':'scroll'});
					},
			});
			return false;
		}

		/* show google calendar in iframe */
		if ($(this).attr('href').match(/^kalender\/(woche|liste)/)){
			$.fancybox({
				'padding' : 2,
				'autoScale' : false,
				'scrolling' : 'no',
				'width' : 760,
				'height' : 620,
				'href' : $(this).attr('href'),
				'type' : 'iframe',
				});
			return false;
		}
	});

	/* login eyecandy */
	$('#loginbar a.login').click(function(e){
		e.preventDefault();
		$('#loginbar form.login').each(function(){
			if ($(this).hasClass('hidden')){
				$(this).height(0);
				$(this).removeClass('hidden');
				$(this).animate({height:68},300);
			}else{
				$(this).animate({height:0},300,function(){
					$(this).addClass('hidden');
				});
			}
		});
	});
});

