(function($){ 
	$(function(){
		// Towns we serve toggler
		$('.toggler-trigger').each(function(){
			var target = $(this).attr('href');
			$(target).hide();
		});
		$('.toggler-trigger').click(function(){
			$(this).toggleClass('active');
			var target = $(this).attr('href');
			$(target).toggle();
			return false;
		});
		// Cufon
		if ($('#headline-text').length > 0){
			Cufon.replace('#headline-text', { hover: true, fontFamily: 'Gotham Light' });
			Cufon.replace('#headline-text strong', { hover: true, fontFamily: 'Gotham Medium' });
			Cufon.replace('#content h1', { hover: true, fontFamily: 'Gotham Medium' });
		}
		// Dropdown Menu
		$('#mainNav ul li:not(.current_page_item, .current_page_ancestor, .current_page_parent) ul').slideUp(0).addClass('jquery');
		$('#mainNav ul > li:not(.current_page_item, .current_page_ancestor, .current_page_parent)').hover(function () {
			$("ul", this).stop(true, true).slideDown(200);
		},function () {
			$("ul", this).stop(true, true).delay(140).slideUp(100);
		});
		$('#mainNav ul:first > li').addClass('first-children');
		if ($('#mainNav li.current_page_item ul, #mainNav li.current_page_ancestor ul, #mainNav li.current_page_parent ul').is(':visible')){
			$('body').addClass('hasSubNav');
		}
		// Homepage Showcase
		if ($('body.page-template-homepage-php ').length > 0){
			var desc = $('.showcase-entry:first .description').html();
			$('#showcase-description').html(desc);
			$.getScript('/wp-content/themes/nextsteplivinginc.com/js/jquery.cycle.min.js',function(){ 
				$('#showcase-inner').cycle({
					fx:     	'fade', 
					speed:  	500, 
					after:	showDesc,
					timeout:	5000
				});
				function showDesc(curr, next, opts) {
					var index = opts.currSlide;
					var desc = $('.showcase-entry:eq('+index+') .description').html();
					$('#showcase-description').html(desc);
				}
			});
		}
		// In The News
		if ($('body.page-template-homepage-php').length > 0){
			$.getScript('/wp-content/themes/nextsteplivinginc.com/js/jquery.cycle.min.js',function(){ 
				$('#in-the-news').cycle({
					fx:     	'fade', 
					speed:  	500, 
					timeout:	5000
				});
			});
		}
		// Unload Form Submit for Surveys
		if ($('body.page-template-survey-php').length > 0){
			var button = $('.gform_footer').html();
			$('.gform_heading').prepend(button);
		}
	});
})(jQuery);

