function equalHeight(group) {
    var tallest = 0;
    group.each(function() {
        var thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

$(document).ready(function() {
	
	if($("#search #query").length) {
		if($("#search #query").val() == '') {
			$("#search #query").val('Search WU Law');
		}
		$("#search #query").focus(function(){
			if (this.value == 'Search WU Law') {
				this.value='';
			}
		});
		
		$("#search #query").blur(function(){
			if (this.value == '') {
				this.value='Search WU Law';
			}
		});
	}
	
	 $('#slideshow-main').cycle({
	    fx: 'fade',
		random:1,
	    speed: 400,
	    timeout: 5000,
	    pager: '#pager ul',
	    pause: true,
	    next: '#next', 
    	prev: '#prev', 
	    pagerAnchorBuilder: function(idx, slide) {
	        // return sel string for existing anchor
	        return '#pager ul li:eq(' + (idx) + ') a';
	    }
	});
	
	$('#slideshow-sub').cycle({
	    fx: 'fade',
	    speed: 400,
	    timeout: 0,
	    pause: true,
	    next: '#next-sub', 
    	prev: '#prev-sub' 
	});
	
	function megaHoverOver(){
		$(this).find(".sub").stop().slideDown('normal');
		$(this).addClass("selected");
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().slideUp('fast', function() {
		  $(this).hide();
	  });
	  $(this).removeClass("selected"); 
	}

	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$(".nav li .sub").css({'display':'none'});
	$(".nav li").hoverIntent(config);
	
	equalHeight($(".column"));
	
	$("ul.sf-menu").supersubs({ 
            minWidth:    10,   // minimum width of sub-menus in em units 
            maxWidth:    20,   // maximum width of sub-menus in em units 
            extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
        }).superfish({ 
	    delay: 500,                                     // one second delay on mouseout
	    animation: {opacity:'show',height:'show'},      // fade-in and slide-down animation
	    speed: 'fast',                                  // faster animation speed
	    autoArrows: false                              // disable generation of arrow mark-up
	});

});
