jQuery(document).ready(function(){
	
	jQuery('#topStageScrollable .items').children('a').each(function(){
		console.log(jQuery(this));
		if(jQuery(this).attr('href') == null)
			jQuery(this).remove();
		
	});
	
	
	//
	// Scroller unter der Hauptnavigation
	//
	if(jQuery('#topStageScrollable .items').children().length < 2){
		jQuery('#topStageNext, #topStagePrev').hide();
	}
	else {
		topStageScroller = jQuery('#topStageScrollable').scrollable({circular: true, next:'#topStageNext', prev:'#topStagePrev',keyboard: false});
	}
	
	//
	// Scroller in der Sidebar
	//
	jQuery('#sidebarcontent .sidebarslider .csc-textpic-imagecolumn').each(function(){
		
			if(jQuery(this).children('ul').children().length > 1) {
				jQuery(this).parent().prepend('<div class="prev pfeil" /><div class="next pfeil"/>');
				jQuery(this).scrollable({circular: true, next:jQuery(this).parent().find('.next'), prev:jQuery(this).parent().find('.prev'),keyboard: false}).autoscroll().each(function() {
					var jQueryitemsToClone = jQuery(this).scrollable().getItems().slice(1);
					var jQuerywrap = jQuery(this).scrollable().getItemWrap();
					var clonedClass = jQuery(this).scrollable().getConf().clonedClass;
					jQueryitemsToClone.each(function() {
						jQuery(this).clone(true).appendTo(jQuerywrap)
							.addClass(clonedClass + ' hacked-' + clonedClass);
					});
				});
			}
		
	});
	
	
	//
	//hover effekt in der Hauptnavigation
	//
	jQuery('#mainNavi > li').each(function(){
		jQuery(this).hover(
			function(){
				image = jQuery(this).find('a .imagewrap img');
				temp = image.attr('src');
				image.attr('src',image.attr('longdesc'));
				image.attr('longdesc', temp);
			},
			function(){
				image = jQuery(this).find('a .imagewrap img');
				temp = image.attr('src');
				image.attr('src',image.attr('longdesc'));
				image.attr('longdesc', temp);
			}
		);
	});
	
	/*
	 * Parkanimation 
	 */
	
	jQuery('.fancyAnimation').each(function(){
		jQuery(this).click(function() {
			jQuery.fancybox({
				'padding'		: 0,
				'margin'		: 15,
				'opacity'		: true,
				'scrolling'		: 'no',
				'width'			: 980,
				'height'		: 420,
				'autoScale' 	: false,
				'autoDimensions': false,
				'overlayOpacity': 0.8,
				'overlayColor'	: '#F08500',
				'titleShow'		: false,
				'type'			: 'iframe',
				'showNavArrows'	: false,
				'href' : jQuery(this).attr('href')
			});
			return false;
		
		})
	});
	
	
	
});
