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

// Animated Scrolling
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;
		})
	})
}

jQuery(document).ready(function() {

// Main Navigation Drop Down Menu
	jQuery("ul#main_nav li.dropdown ul").hide();

    jQuery("ul#main_nav li.dropdown").hover(function(){
    
        jQuery(this).addClass("hover");
        jQuery('ul:first',this).slideDown('fast').show();
    
    }, function(){
    
        jQuery(this).removeClass("hover");
        jQuery('ul:first',this).slideUp('slow');
    
    });
    
// Home Page Slider
	jQuery("#controller").jFlow({
		slides: "#slides",
		width: "660px",
		height: "395px",
		duration: 400,
		auto: true
	});
	
// Initiate Equal Height Columns
    equalHeight(jQuery(".callout_text"));

    
// No spam, please
    jQuery('a.emailaddy').each(function(i) {
        var text = jQuery(this).text();
        var address = text.replace(" at ", "@");
        jQuery(this).attr('href', 'mailto:' + address);
            jQuery(this).text(address);
        });
        
// Initiate Animated Scrolling
	jQuery("a.scrollit").anchorAnimate();   
});
