var fix_interval = null;
var widefont = false;
var EM = 12;

$(function(){
    fix_fontsize_init('12px/12px Tahoma, "DejaVu Sans", Geneva, sans-serif', 12);
});

function fix_fontsize_init(font, expectedSize, $fix)
{
    if (typeof font == 'undefined' || font == '')
        font = 'normal 16px/16px Arial, sans-serif';
    if (typeof expectedSize == 'undefined' || expectedSize == 0)
        expectedSize = 16;
    if (typeof $fix == 'undefined' || !$fix.length)
        $fix = $('body');

    $fix.prepend('<div id="fontsize_tester">A</div>');

    var $tester = $('#fontsize_tester');
    var $topmenu = $('#header_top .submenu div').eq(0);

    $tester.css({
        font:        font,
        position:   'absolute',
        left:       '-999em'
    });

    _fix_fontsize(expectedSize, $fix, $tester, $topmenu);

    fix_interval = setInterval(function(){
        _fix_fontsize(expectedSize, $fix, $tester, $topmenu);
    }, 1000);
}

function _fix_fontsize(expectedSize, $fix, $tester, $topmenu)
{
    if (!$.browser.opera && !$.browser.safari && !$.browser.msie) {
	var size = Math.round(expectedSize * expectedSize / $tester.height());
	$fix.css({ fontSize: size + 'px' });
    }

    EM = $tester.height();

}

