var $j = jQuery.noConflict();



jQuery().ready(function() {
	// startup
	// MENUS
	loadMenus();
	// slider
	$j("#slider1").slideView();

	$j('#footer').supersleight({shim: '/fileadmin/templates/site/_gfx/x.gif'});

	// ticker
	if($j('.news-ticker').length > 0) {
		$j('.news-ticker .news-item').hide();

		switchNews(0, $j('.news-ticker .news-item').size() - 1);
	
	}
	
	// shadowbox?
	if(typeof(Shadowbox) !== 'undefined') {
		Shadowbox.init();
	}
	
	
	// slideshow
	$j('#slideshow').innerfade({ 
		animationtype: 'fade', 
		speed: 750, 
		timeout: 5000, 
		type: 'random'
	});
	
	// slideshow
	$j('#siteheader ul.slideshowgallery').innerfade({ 
		animationtype: 'fade', 
		speed: 750, 
		timeout: 5000, 
		type: 'random'
	});
});


// Text Ersetzung
if(typeof Cufon != 'undefined') {
	Cufon.replace('h1:not(.notcufon),h2:not(.notcufon),h3:not(.notcufon)');
	Cufon.replace('#siteheader h1, #siteheader h2, #swimmingpoolsteaser h1,#swimmingpoolsteaser h3,#swimmingpoolsteaser p', {hover: true, textShadow: '1px 1px #000'});
	Cufon.replace('#topsubmenu a', {hover:true});
	
}
/** loads the mouse over logic */
function loadMenus() {
	// main menu
	$j('#menu .submenu').hide();
	$j('#menu > li').hover(function() {
			$j(this).addClass("hover");
			$j(this).find('.submenu').show();
			//$j(this).find('.submenu tr');
		},
		function() {
			$j(this).removeClass("hover");
			$j('#menu .submenu').fadeOut('fast');
		}
	);
	// submenu slideout	
	$j('#leftpan.sliding').hover(function() {
			$j('#submenuclip').removeClass('in');
			$j('#leftmenu').animate({ width: 'show' });
		}
	);	
	$j('#leftpan.sliding').hover(void(0), function() {
			$j('#submenuclip').addClass('in');
			$j('#leftmenu').hide();
		}
	);
	// submenu tr hover
	$j('.productteaser li').hover(function() {
			$j('.productteaser li').animate({ opacity: 0.7 }, 0);
			$j(this).animate({ opacity: 1 }, 0);
		}
		, function() {
			$j(this).animate({ opacity: 0.7 }, 0);
		}
	);
	
	// flags
	$j('.language').hover(function() {
			$j(this).addClass("hover");
			$j('#servicenavi #flags').show();
		},
		function() {
			$j(this).removeClass("hover");
			$j('#servicenavi #flags').hide();
		}
	);	
	

}

function switchNews(curr, max){
	prev = (curr == 0) ? max : curr - 1;

	$j('.news-ticker .news-item').eq(prev).hide();
	$j('.news-ticker .news-item').eq(curr).fadeIn("slow");

	
	curr = (curr == max) ? 0 : curr + 1;
	window.setTimeout("switchNews(" + curr + "," + max + ")", 5000);	
}

