/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category  Symmetrics
 * @package   Symmetrics_Lv
 * @author    symmetrics gmbh <info@symmetrics.de>
 * @author    Eduard Melnitskiy <eduard.melnitskiy@symmetrics.de>
 * @copyright 2011 symmetrics gmbh
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 * @link      http://www.symmetrics.de/
 */

(function($) {
    $.toolTip = {
        tooltipId: 'tooltip-box',
        pageX: 0,
        pageY: 0,
        
        init: function() {
            $.toolTip.bind();
            $.toolTip.show();
            $.toolTip.hide();
        },
        
        bind: function() {
            $('.abo-price').mouseover(function(event) {
                $.toolTip.pageX = event.pageX;
                $.toolTip.pageY = event.pageY;
                content = $(event.target).children('div');
                if (content.length > 0) {
                    $.toolTip.show($(content).html());
                } else {
                    $.toolTip.show($($(event.target).next()).html());
                }
            }); 
            
            $('.abo-price').mousemove(function(event) {
                $.toolTip.pageX = event.pageX;
                $.toolTip.pageY = event.pageY;
                $('#' + $.toolTip.tooltipId).css({
                    'left': $.toolTip.pageX + 'px',
                    'top': $.toolTip.pageY + 15 + 'px'
                });
            }); 

            $('.abo-price').bind('mouseout', $.toolTip.hide);
        },

        show: function(content) {
            $.toolTip.build(content);
        },
        
        hide: function() {
            $.toolTip.destroy();
        },
        
        build: function(content) {
            $('body').append('<div id="'+ $.toolTip.tooltipId +'"></div>');
            $('#' + $.toolTip.tooltipId).html(content)
            $('#' + $.toolTip.tooltipId).addClass('abo-tooltip').css({
                'position': 'absolute',
                'left': $.toolTip.pageX + 'px',
                'top': $.toolTip.pageY + 15 + 'px'
            });
        },
        
        destroy: function() {
            $('#' + $.toolTip.tooltipId).remove();
        }
    }
})(jQuery);

jQuery(window).load(function(){
    jQuery.toolTip.init();
}); 
