$(document).ready(
	function()
	{

            var distance = 7;
            var time = 250;
            var hideDelay = 1000;

            var hideDelayTimer = null;

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


            $("#social_link").mouseover(function () {
                show_social=false;
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;
                    info.css({
                        top: 10,
                        left: -236,
                        display: 'block'
                    }).animate({
                        top: '+=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                    
                }

                return false;
            });

            /*$("#socializ").mouseover(function () {
                show_social=false;
                return false;
            });

            $("#socializ").mouseout(function () {
                show_social=true;
                //$('#social_link').trigger('mouseout');
                return false;
            });*/

            jQuery('#socializ').hover(function() {
                show_social=false;
                console.debug("nad "+show_social);
                return false;
            }, function() {
                show_social=true;
                console.debug("out "+show_social);
                $('#social_link').trigger('mouseout');
                return false;
            });

            $("#social_link").mouseout(function () {
              console.debug("link1 "+show_social);
              if (show_social)

                {

                console.debug("link "+show_social);
                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;
            });
        });
