//-----------------nav

jQuery.fn.navToggle = function(speed, easing, callback) { 
	return $(this).stop().animate({lineHeight: parseInt(this.css('line-height')) == 44 ? 22 : 44}, speed, easing, callback);
}

jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
        return $(this).stop().animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);  
      };

function dropmenu(jqObj, eventType, theHeight) {
	if(eventType == 'mouseenter') {
		jqObj.stop().animate({opacity: 1, height: theHeight}, 'fast');
	} else if(eventType == 'mouseleave') {
		jqObj.stop().animate({opacity: 0, height: 0}, 'fast');
	}
}

$(document).ready(function() {


	var navItem = $('#nav ul li a');
	$(navItem)
        .hover(function() {		
            $(this).stop().animate({ lineHeight: 30 }, 'fast');
        }, function() {
            $(this).stop().animate({lineHeight: 44 }, 'fast');
        });

	if($.browser.msie  && $.browser.version >=8 ) {
		var subNavItem = $('#nav ul li ul li a');
		$(subNavItem)
        .hover(function() {	
			$(this).stop()
            $(this).css({'background-color':'#6fee6c', 'color':'#024002','line-height':'30px'});
			
        }, function() {
			$(this).stop()
            $(this).css({'background-color':'#024002', 'color':'#ffffff', 'line-height':'30px'});
        });
	} else {
		$('#nav ul li ul li a').unbind('mouseover mouseout'); //remove event from sub nav	
	}
	//------------subnav
	var subnavlink = $('.subnav');
	var subnav = $('#nav ul li ul');
	
	subnav.css('display','block');
	var subnavHeight = subnav.attr('offsetHeight')
	subnav.css('display','none');
	subnav.css('height','0');
	
	subnavlink.bind("mouseenter mouseleave",
	  function(event) {
			dropmenu(subnav, event.type, subnavHeight);
		 }
	  );
	  
	
});
