$(function(){
    
    var url = "http://strahovik.net.ua/";
    
    var ttts = false;
    
    if(ttts == false)
    {
        window.top.$('head').html(window.top.$('head').html()+'<link rel="stylesheet" type="text/css" href="'+url+'css/popup.css"/>');
        ttts = true;
    }
    
    var eltooltip = $('img.help');
    
    var tooltip = $('div#crr');
    
    var toolp = $('.texts');
    
    var title;
    
    eltooltip.live('mouseenter', function(){
                
        var span_calc = window.top.$('.span_calc_span');
        
        var ifr_adr = window.top.$(('iframe#calc'));
        
        //alert(ifr_adr.position().top);
    
        title = $(this).attr('title');
        
        $(this).removeAttr('title');
        
        toolp.html(title);
        
        $(this).mousemove(function(e){
            
            //alert(ifr_adr.position().top+e.pageX-55);
            
            var lisfy = e.pageY-tooltip.height()-53+ifr_adr.position().left;
            
            var rightfx = ifr_adr.position().top-81+e.pageX;
            
            span_calc.html('<div id="crr">'+tooltip.html()+'</div>');
                        
            span_calc.show().css({left: rightfx, top: lisfy});
            
        });
        
    });
    
    eltooltip.live('mouseleave', function(){
        
        var span_calc = window.top.$('.span_calc_span');
        
        span_calc.hide();
        
        $(this).attr('title', title);
        
    });
    
    eltooltip.live('click', function(){
        
        var span_calc = window.top.$('.span_calc_span');
        
        span_calc.fadeOut('slow');
        
        $(this).attr('title', title);
        
    });    
});
