//ARTWORK HOVER ANIMATION
$(function(){
	$(".art-overlay").hover(
		function() {
			$(this).stop().fadeTo("normal", 1);
		},
		function() {
			$(this).stop().fadeTo('normal', 0);
	});
});

//HEADER EXHIBITION LIST DROPDOWN ANIMATION
$(function(){
	$('#exhi-dropdown').hover(
		function(){
			$(this).find('#exhi-dropdown-menu').stop(true,true).slideToggle();
		}
	);
});

//NOTIFICATIONS DROPDOWN ANIMATION
$(function(){
	$('#log-dropdown').hover(
		function(){
			$(this).find('#log-dropdown-menu').stop(true,true).fadeIn();
		},
		function(){
			$(this).find('#log-dropdown-menu').stop(true,true).hide();
		}
	);
});

//SIGN UP BOX
$(function() {
    $("#signup-link").click(function(e) {
        e.preventDefault();
        $("#signup-box").fadeTo("fast", 1);
        $("#signup-link").toggleClass("menu-open");
    });

    $("#signup-box").mouseup(function() {
        return false
    });
    
    $(document).mouseup(function(e) {
        if($(e.target).parent("a#signup-link").length==0) {
            $("#signup-link").removeClass("menu-open");
            $("#signup-box").hide();
        }
    });
});



//TOOLTIP ANIMATIONS
$(function () {
    $('.tooltip_wrap').each(function () {
        var distance = 10;
        var time = 250;
        var hideDelay = 100;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var trigger = $('.tooltip-trigger', this);
        var info = $('.tooltip-popup', this).css('opacity', 0);


        $([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                return;
            } else {
                beingShown = true;

                info.css({
                    top: 46,
                    left: -54,
                    display: 'block'
                }).animate({
                    top: '-=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }

            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    top: '-=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });

            }, hideDelay);

            return false;
        });
    });
});
