// Equal height columns
function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

jQuery(document).ready(function() {
// Initiate Equal Height Columns
    equalHeight($(".column"));
    equalHeight($(".funfacts-col"));
    equalHeight($(".archive-column"));
    equalHeight($(".equal"));
    
// Toggle Fun Facts
	jQuery("#funfacts").hide();
	jQuery(".open-fun").click(function() {
		jQuery("#funfacts").slideToggle("slow");
		jQuery(this).toggleClass("close-fun"); return false;
	});
	
// Testimonial Slideshow
	jQuery('#quotes').css("overflow", "hidden");

    jQuery('#slide_quotes').before('<div id="slide_nav">').cycle({
        fx:			'fade',
        speed:		400,
        timeout:	10000,
        pager:		'#slide_nav'
    });
    
// No spam, please
    jQuery('a.emailaddy').each(function(i) {
        var text = $(this).text();
        var address = text.replace(" at ", "@");
        jQuery(this).attr('href', 'mailto:' + address);
            jQuery(this).text(address);
        });

});

// Animated Scrolling
jQuery(document).ready(function() {
	$("a.scrollit").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 400
	}, settings);	
	
	return this.each(function(){
		var caller = this
		jQuery(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = jQuery(caller).attr("href")
			
			var destination = jQuery(elementClick).offset().top;
			jQuery("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}
