//	JS ENHANCEMENTS

$ = jQuery.noConflict();

$(function(){
	$('#nav > ul > li').setNav();
});

(function($) {

	$.fn.setNav = function(){
		if (this.length == 0){
			return $(this);
		}
		var $dd = $(this).children('div.dd');
		for (i=0; i<$dd.length; i++){
			var $d = $dd.eq(i);
			var ht = $d.height();
			$d.data('ht', ht).height(0);
		}
		$('body').addClass('js');

		if ($.browser.msie && $.browser.version == '7.0'){
			$('body').addClass('ie7');
		}

		var onfn = function(){
			if ($(this).hasClass('on') || !$(this).children('a').hasClass('dd')){
				return false;
			}
			var $menu = $(this).addClass('on').children('div.dd');
			var ht = $menu.data('ht');
			$menu.stop(true, true).animate({
				height: ht
			}, 200);
		}
		var offn = function(){
			var $li = $(this);
			$li.children('div.dd').stop(true, true).animate({
				height: 0
			}, 200, function(){ $li.removeClass('on'); });
		}
		$(this).hover(onfn, offn);
		return $(this);
	}

//	LOGGING FUNCTIONS FOR TROUBLESHOOTING

	$.fn.log = function(){
		if (window.console){
			console.log($(this));
		}
		return $(this);
	}

	$.log = function(inp){
		if (window.console){
			console.log(inp);
		}
		return inp;
	}

})(jQuery);

