﻿$j(function() {

    var isIE6 = false;

    if ($j.browser.msie && $j.browser.version.substring(0,1) === '6') 
        isIE6 = true;
        
    if(isIE6) {
        var $shim = $j('<iframe frameBorder="0" />');
        $shim.css({ 'z-index': '0', 'position': 'absolute', 'top': '31px' }).hide().appendTo('body');
    }

    $j('.nav-menu > li:has(ul)').hover(function() {

        $j(this).find('a img').first().hide().end().last().show();

        $j(this).children('ul').show();

        if(isIE6) {
            $shim.css({ 'width': $j(this).children('ul').width(), 'height': $j(this).children('ul').height() })
                 .prependTo(this).show();
        }

    }, function() {

        if(isIE6) {
            $shim.hide();
        }

        $j(this).children('ul').slideUp(function() {
            $j(this).parent('li').find('a img').first().show().end().last().hide();
        });

    });

    //Makes the entire list item clickable, rather than just the anchor tag text.
    $j('.nav-menu ul li:has(a)').click(function() { window.location = $j(this).find('a')[0].href; });
});
