$(function(){
	
//	var offset = new Date().getTimezoneOffset() / 60 * (-1);
	
	$.ajaxSetup ({cache: false});
	
	$('.paginate_me').paginateMe({show:6});
	
	if ($('div.email_secured').length) {
		  var at = / AT /;
		  var dot = / DOT /g;

		$('div.email_secured').each(function(){
			var $link = $(this);
			var addr = $link.text().replace(at, '@').replace(dot, '.');
			$link.after('<a href="mailto:'+addr+'">'+addr+'</a>');
			$link.remove();
		});
	}
	
	// Scroll back to top
	$('#backToTop').click(function(e){
		e.preventDefault();
		$('body').scrollTo(0,500);
	});
	
	// Featured post image slider
	$('#infiniteslider').infiniteSlider({
		easing: "swing",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		startButton: false,				  // Show start/stop button or not	
		delay: 6000,                    // How long between slide transitions in AutoPlay mode
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 1000,            // How long the slide transition takes
		hashTags: true,                 // Should links change the hashtag in the URL?
		buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "Go",  	           // Start text
		stopText: "Stop",               // Stop text
		offset: -444,						  // Sets the offset in px (can be negative)
		rollin: true,
		fades: true
	});
	
	// Featured post content div
	$('.headline').hover(function(){
		$hl = $(this);
		var hlTitle = $('.hl_title', $hl).outerHeight(),
			hlContent = $('.hl_content', $hl).outerHeight(),
			hlHeight = hlTitle + hlContent;
		$hl.stop().animate({top:'-'+hlHeight+'px'},{queue:false,duration:500});
	}, function() {
		$hl.stop().animate({top:'-30px'},{queue:false,duration:500});
	});

	// Advocacy client gallery
	$('#client_scroller').infiniteSliderLite(100000);

	// Main navigation tabs
	$('#nav').tabs(); 
	
	if ($('body').attr('id') == 'Home') $('#nav').tabs({selected:0});
	if ($('body').attr('id') == 'About') $('#nav').tabs({selected:1}); 
	if ($('body').attr('id') == 'Programs') $('#nav').tabs({selected:2});
	if ($('body').attr('id') == 'Business') $('#nav').tabs({selected:3});
	if ($('body').attr('id') == 'Residential') $('#nav').tabs({selected:4});
	if ($('body').attr('id') == 'Involved') $('#nav').tabs({selected:5});
	if ($('body').attr('id') == 'Posts') $('#nav').tabs({selected:6});
	$('#blog_cat_nav').tabs();
	$('#main_content').tabs();
	$('.recreation_database').parent().find('.page-item-255').addClass('current_page_ancestor');
	$('.single_blog').parent().find('.page-item-331').addClass('current_page_ancestor');
	$('.single_event').parent().find('.page-item-333').addClass('current_page_ancestor');
	$('.single_announcement').parent().find('.page-item-530').addClass('current_page_ancestor');
	$('.single_staff').parent().find('.page-item-283').addClass('current_page_ancestor');
	$('.single_vacancy').parent().find('.page-item-296').addClass('current_page_ancestor');
	$('.single_chair').parent().find('.page-item-4612').addClass('current_page_ancestor');
	
	$('#donate').hover(function(){
		$('a',this).animate({top:'0px'},{queue:false,duration:100});
	}, function(){
		$('a',this).animate({top:'-10px'},{queue:false,duration:100});
	});
	
	// Text Resizer
	$('div.breadcrumbs').after('<div class="resize"></div>');
	
	$rs = $('div.resize');
	$entry = $('div.leftmain');
	var entryOrig = $entry.css('fontSize');
	
	$rs.toggle(function(){
		$entry.css('fontSize','20px');
		if(window.location.hash) $('#page_slider_cont').scrollTo(window.location.hash);
		getNewHeight();
	}, function(){
		$entry.css('fontSize',entryOrig);
		if(window.location.hash) $('#page_slider_cont').scrollTo(window.location.hash);
		getNewHeight();
	});

});
