$(function(){
	Cufon.replace('.news_header span, .news_header h2, h2.title, h2.subtitle, h3, .galerie_photo a');
	Cufon.now();
	
	$(".gallery a").fancybox({
		'titleShow'     : false
	});
	
	var mood = $('#news ul').moodular({

        controls: 'index',
		speed: 1000,
		dispTimeout     : 8000,
		api: true
	});
	
	jQuery('#next').bind('click', function () { mood.next(); return false; });
	jQuery('#prev').bind('click', function () { mood.prev(); return false; });
	
	$('#text-3 ul').moodular({
		speed: 1000,
		dispTimeout     : 1000
	});
	
	
	/* menu */
		//add indicator and hovers to submenu parents
		var nav = $("#menu");

		nav.find("li").each(function() {
			if ($(this).find("ul").length > 0) {
				//show subnav on hover
				$(this).mouseenter(function() {
					$(this).find("ul").stop(true, true).slideDown();
				});
				
				//hide submenus on exit
				$(this).mouseleave(function() {
					$(this).find("ul").stop(true, true).slideUp();
				});
			}
		});



	/* bonus*/
	
	var li = $('.galleryBonus').find('li');
		
	li.each(function(i){
		var t = $(this),
			img = t.find('img'),
			src = img.attr('src'),
			width = li.width(),
			height = li.height();
			
		img.hide().after($('<div />').attr('id', 'holder'+i).addClass('holder'));

		var r = Raphael('holder'+i, width*2, height*2),
			rimg = r.image(src, width/2, height/2, width, height);
		
		rimg.hover(function(event) {
		    this.animate({
				scale: 2,
				rotation : 360
			}, 1200, 'elastic');
		}, function (event) {
		    this.animate({
				scale: 1,
				rotation : 0
			}, 1200, 'elastic');
		});
		
	});
	
	li.hover(function(){
		li.css({ 'z-index': 1 });
		$(this).css({ 'z-index': 2 });
	});
	
});


