geck.requireScript('js/jquery.ui.js');
geck.requireScript('js/jquery.timers.js');


$(function() {

	$('#topmenu a').hover( function() {
		//on hover start animation
		$('#topmenu a.selected .bullet').css('display','none');
		$('.bullet',this).css('display','block');
		menuAnim.animation(this);
	}, function() {
		//stop animation
		menuAnim.stop();
		$('.bullet',this).css({'display':'none','left':0}).stop(true);
		$('#topmenu a.selected .bullet').css('display','block');
	});

    //intro animation
    $('#intro img:last').animate({opacity:0},6000,'easeInOutQuad');
    //start loop
    $(document).everyTime(8000, function() {
        $('#intro img:last').animate({opacity:1},2500,'easeInOutQuad', function() {
            $('#intro .step:last').animate({opacity:0},1500,'easeInOutQuad', function() {
                $(this).prependTo('#intro').css({opacity:1});
                $('#intro img:last').animate({opacity:0},2000,'easeInOutQuad');
            });
        });
    });

    //pretty photo
    $("a[rel^='gallery']").prettyPhoto({animationSpeed:'slow',slideshow:5000, autoplay_slideshow: false});
});

var menuAnim = {
	
	_enable : false,
	_object : null,
	animation : function( object ) {
		var t = this;
		t._object = object;
		t._enable = true;
		
		$('.bullet',object).animate({'left':10},500,'easeInOutSine', function() {
			$(this).animate({'left':-5},500,'easeInOutSine', function() {
				if (t._enable) {
					menuAnim.animation(object);
				}
			});
		});
	},
	stop : function() {
		this._object = null;
		this._enable = false;
	}
};

