﻿/*
  Tray (explore, explode, gallery):
*/

(function() {
    jQ(document).ready(function() {
        tray();
    });

    var tray = function() {
        var speed = 400;
        var delay = 200;
        var jQtrayObj = jQ('#tY-sections');
        var trayActive = false;
        var curTimer;
        var mousePos = false;

        jQtrayObj.height(0);

        jQ('#tY-nav').css({ 'position': 'absolute', 'bottom': 0 }).mouseleave(function() {
            mousePos = false;
            curTimer = setTimeout(closeTray, delay);
        });
        
        jQ('#tY-nav .ic').mouseenter(function() {
            mousePos = true;
            curTimer = setTimeout(openTray, delay);
        });

        var openTray = function() {
            if (mousePos) {
                jQtrayObj.stop();
                jQtrayObj.animate({ height: 73 }, speed );
            }
        }

        var closeTray = function() {
            if (!mousePos) {
                jQtrayObj.stop();
                jQtrayObj.animate({ height: 0 }, speed );
            }
        }
    }
})();