$(document).ready(function(){
    // place last menu to the right, so it will not go beyond the right of the page
    $('ul.mainmenu > li:last ul').css('margin-left', -($('ul.mainmenu > li:last ul').width()-$('ul.mainmenu > li:last').width())+3);

    // next is actually a fix for IE7 and lower...
    $('ul.mainmenu ul').each(function() {
        $(this).css('width', $(this).width()); 
    });
    
    // create an Iframe shim for IE6
    if ($.browser.msie && $.browser.version == '6.0') {
        $('ul.mainmenu > li').hover(
            function() {
                $(this).find('ul').css('z-index', 2);
                var w = $(this).find('ul').width();
                var h = $(this).find('ul').height();
                var mt = $(this).find('ul').css('marginTop');
                var ml = $(this).find('ul').css('marginLeft');

                $(this).find('ul').before('<iframe src="javascript:\'\';" frameBorder="0" style="position: absolute; width: '+w+'px; height: '+h+'px; margin-top: '+mt+'; margin-left: '+ml+'; z-index: 1;"></iframe>');
            },
            function () {
                $(this).find('iframe').remove();
            }
        );
    }
});