$(document).ready(function(){
	//loadMaschineShow();
	loadNavigation();
	loadShare();
	//loadMaschineModuleForm();
	loadSlideShow();

	$("a#inline, a.aktuell").fancybox({
		autoScale: true
	});
	$("a.messButtonLayerSide").fancybox({
		autoScale: true,
		hideOnContentClick: false
	});
});

function loadMaschineModuleForm() {
	$('div#showForm').hide();
	$('a#setShowForm').click().toggle(function(){
		$('div#showForm').show('slide');
	}, function() {
		$('div#showForm').hide('slide');
	});
}

function loadNavigation() {
	$("ul#topNavigation li").hover(function(){
		$(this).addClass("hover");
	}, function(){
		$(this).removeClass("hover");
	});
//	$("ul#topNavigation li ul li:has(ul)").find("a:first").append(" &raquo; ");
	$("li:has(ul)", "ul#topNavigation").find("a:first").append(" &raquo; ");
}

function loadShare() {
	var $box = $('#box').wrap('<div id="box-outer"></div>');
	$('#shareButton').click().toggle(function(){
		$box.blindToggle('slow', 22);
	}, function() {
		$box.blindToggle('slow', +185);
	});
}

jQuery.fn.blindToggle = function(speed, height, easing, callback) {
	return this.animate({marginTop: height}, speed, easing, callback);
};

function loadSlideShow() {
	$('#newsList').newsScroll({
		speed: 3000,
		delay: 8500
	});
}

function loadMaschineShow() {
	//$(".coda-slider").children('.panel').hide().end().prepend('<p class="loading">Loading...<br /><img src="./html/images/ajax-loader.gif" alt="loading..." /></p>');
	$('#coda-slider-1').codaSlider();
}

jQuery.fn.panelScroll = function(options) {
	return this.each(function() {

		var intCountPlanel = 0;
		var $this = $(this);
		$('div.scrollTop').attr('id', intCountPlanel);
		$('div.scrollDown').attr('id', intCountPlanel);

		$('div.scrollTop').click(function() {
			intCountPlanel++;
		});
		$('div.scrollDown').click(function() {
			--intCountPlanel;
		});

		$this.children('li:last', intCountPlanel)
			.animate({
				marginBottom : '+' + $this.children('li').outerHeight(),
				marginTop : '0',
				opacity: 'hide'},
				2000,
				function() {
					$this.children('li:first')
						.appendTo($this)
						.css('marginTop', 0)
						.fadeOut(300);
				}
			);
	});
};
