$(function() {
	$('.fancybox').fancybox();
	$('#phantom img.contentImage').unwrap().unwrap();
	if ($('#phantom img.contentImage').length == 1){
		$('#phantom p').addClass('contentImagePadding');
	}
   	$('ul#submenu').accordion({
		autoHeight: false,
		event:'mouseover',
		collapsible: true,
		active:'li.current_page_ancestor a'
	});
	$('#submenu a').click(function(){
		if($(this).next().html() == null){
			//	location.href = $(this).attr('href');
		}
	});
	$('#newsbar').cycle({
		fx:'turnDown',
		pause:true,
		sync:true
	});
	$('a.backlink').each(function(){
		var href = $(this).attr('href');
		$(this).attr('href',href + '?b=l');
	});
	if((location.href.split('?')[1]) == 'b=l') {
		$('#phantom h2').after('<a href="javascript:history.back();" style="margin:0 0 10px; display:block;">zur&uuml;ck</a>');
		if((location.href.split('/')[3]) == 'news') {
			$.ajax({
                url: '/',
				type: 'POST',
				success: function(result) {
                    newFragment = $('#submenu', result);
					$('#submenu').replaceWith(newFragment).accordion();
				}
			});
		}
	}
	$('#logo').css('cursor','pointer').click(function(){
		location.href = 'http://kjp-gr.ch';
	});
});
