$j(document).ready(function() {
	
	$j(".accordion").accordion({
		autoHeight: false,
		collapsible: true,
		active: false
	});
	
	$j(".tabbox").tabs();
	$j(".tabbed").tabs();
	
	if ($j('#slideshow').length > 0) {
		$j('#slideshow, .quote').cycle({
			'cleartype':true,
			'cleartypeNoBg':true,
			next: '.next',
			prev: '.prev'
		});
		
	};
	
	$j(".more, #searchbar b, #signup b, h3, .learn, h2, ._date, #visit .desc, #navbar>#nav, ._title, h4, ._calendar ._header, .heading").addClass("fontReplace");
	
	var album = $j("._albums");
	
	if(album.length > 0) {
		album.parent().addClass("_albumwrap");
		album.each(function(i){
			if(i % 3 == '2') {
				$j(this).addClass("last");
			}
			$j(this).hover(function(){
				var img = $j(this).find("img");
				var href = img.attr("src").replace(/&e=invert/,"");
				img.attr("src",href);
				
			},function(){
				var img = $j(this).find("img");
				var curHref = img.attr("src")+"&e=invert";
				img.attr("src",curHref);
			});
		});
	};
	
	if($j("._gallery").length > 0) {
		$j("._gallery ul li").each(function(i){
			if(i % 4 == '3') {
				$j(this).addClass("last");
			}
		});
	};
	
	if($j("._event.details").parent("._eventsList").length > 0 ) {
		$j("._event.details").parent().removeClass("_eventsList");
	}
	
	if($j("#autoLoadContent").length > 0) {
		$j("#autoLoadContent").appendTo($j(".main-content"));
	}
	
	$j(".heading").parent("p").css("margin","0");

	// # IE Helpers
	$j('#nav>li:last-child').addClass('_last-child');
	$j('._featurebox:last-child').addClass('_last-child'); 
	$j('fieldset:last-child').addClass('_last-child'); 
	$j('p:last-child').addClass('_last-child'); 
	$j('#content table td:last-child, #content table th:last-child').addClass('_last-child'); 

	$j('a.submit').unbind();
	$j('a.submit').click(function(e){
		e.preventDefault();
		var href = $j(this).attr('href');
		var form = $j(this).parents('form');
		if (href != '' && href != '#') {
			form.attr('action',href);
		}
		form.submit();		
	});	
	
	$j('.alert-button a').click(function(e){
		e.preventDefault();
		$j('.alert-msg').fadeOut();
	});
	
});

if ($j.browser.msie && ($j.browser.version == "6.0")) {
}
else {
	Cufon.replace('.fontReplace', { fontFamily: 'Georgia', hover: true });
}
