var LinkPos = 0;
var carousel = null;
jQuery(function() {
	jQuery('.training-schedule .table-row a:even').addClass('odd');
	
	if (jQuery('#articles').length)
	jQuery('#articles').masonry({itemSelector: '.article'});
	
	jQuery(".dropdown dt a").click(function() { 
    	var dropID = $(this).closest("dl").attr("id"); 
    	jQuery("#"+dropID+" dd ul").slideToggle(200);
		return false; 
  	});
     
  	jQuery("dl[class!=dropdown]").click(function() { 
    	jQuery(".dropdown dd ul").hide();
		return false; 
  	});
	
	if (jQuery('#gallery-carousel').length) {
		jQuery('#gallery-carousel').jcarousel({scroll: 1, start: LinkPos});
		carousel = jQuery('#gallery-carousel').data('jcarousel');
		jQuery('.gallery-thumbs a').live('click', function(){
			carousel.scroll(jQuery(this).closest('a').index() + 1);
			return false;
		});
	}
	
	equalHeight(jQuery("div.article"));
		
});

function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		var thisHeight = jQuery(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.load(function() {
		var thisHeight = jQuery(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
