﻿// js code for global navigation menu
// patches ie 6 hover issues & spaces out tabs to full width
$(function() {
    //document.execCommand("BackgroundImageCache",false,true);
    // inject dropdown trigger for elements with subnav
    $('ul.globalnav > li.multi').append('<span class="subnavTrigger"></span>');
    
    // patch ie hover holes
    if ($.browser.msie && parseInt($.browser.version) < 7) {
		$('ul.globalnav > li').bind('mouseover', function() { 
			$(this).addClass('iehover');
		}).bind('mouseleave', function() {
			$(this).removeClass('iehover');
		});
	}
		
	// on mouseover on mouseleave/out events
	$('ul.globalnav > li.multi').bind('mouseover', function() {
	   $(this).addClass('dropdown');
	   $('#js_simple input.js_textbox').blur();
	});
	
	var bindevent = 'mouseleave';
	if ($.browser.mozilla) bindevent = 'mouseout';
	
	$('ul.globalnav > li.multi').bind( bindevent, function() {
	   $(this).removeClass('dropdown');
	});

	
	// update min-width of elements to be size of their parents + inject divs for rounded bottom

	$('ul.globalnav > li.multi > div.subnav').each(function() {
		if ($.browser.msie && parseInt($.browser.version) < 7) {
			if ($(this).width()<$(this).parent().width()) $(this).width($(this).parent().width());
		}
		else {
			$(this).css('min-width', $(this).parent().width()+'px');
		}
		$(this).append('<div class="subnav-bottom"><div class="subnav-bottomL"></div><div class="subnav-bottomR"></div></div>');
	});

});