/* ----- jQuery Functions Below ----- */

(function(jQuery) {
	jQuery.fn.accordion_list = function(hideElement, toggleBtn) {
		
		/* Sets default values */
		if (!hideElement) hideElement = '.blog_entry .blog_entry_content';
		if (!toggleBtn) toggleBtn = '.blog_entry h3 a';
		
		/* Initial Stuff */
		jQuery(hideElement).hide();
			
		jQuery(toggleBtn).click(function() {
			
			var caller = this
			
			if (jQuery(caller).parent().next().is(':visible')) {
			
				jQuery(caller).parent().parent().removeClass('expanded');
				jQuery(caller).parent().next().slideUp();
				
			} else if(jQuery(hideElement).is(':visible')) {
			
				jQuery(hideElement).slideUp().parent().removeClass('expanded');
				jQuery(caller).parent().parent().addClass('expanded');
				jQuery(caller).parent().next().slideDown();
				
			} else {
			
				jQuery(caller).parent().parent().addClass('expanded');
				jQuery(caller).parent().next().slideDown();
				
			}
			
			return false;
			
		});
			
	};
})(jQuery);


jQuery.fn.anchorAnimate = function(settings) {
	settings = jQuery.extend({speed : 800 }, 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
				jQuery('nav li.active').removeClass('active');
				jQuery(caller).parent().addClass('active');
			});

			return false;
		})
	})
};