// JavaScript Document


$(document).ready(function(){
	
	/* MENU */
	
	$("#menucontainer ul li ul").css({ opacity: 0.95 });
	
	$("#menucontainer ul li").mouseover(function(){
		$(this).children('ul.children').show();
		
	}).mouseout(function(){
		$(this).children('ul.children').hide();
	});
	
	
	/* slideshow */
	if($(".mainslideshow .images img").size() > 1){
		$('.mainslideshow .images img:first').addClass('active');
		
		setInterval( "slideSwitch()", 4000 );
		
		$(".mainslideshow .images img").click(function(){
			slideSwitch();
		});
	}
	
	
});

function slideSwitch() {
    var $active = $('.mainslideshow .images img.active');

    if ( $active.length == 0 ) $active = $('.mainslideshow .images img:last');

    var $next =  $active.next().length ? $active.next()
        : $('.mainslideshow .images img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


