$(document).ready(function() {
	if ($('#slideshow').length) {
		//console.log('slideshow exists');
		$('#slideshow').cycle({
			fx: 'fade',
			speed: 500,
			timeout: 4000,
			slideExpr: 'li.slide'
		});
	}
	
	//get parent page name for page h2
	if($('body').hasClass('public')){
		//console.log('replace h2');
		var sectionName = $('#secondary > li.on > a').text();
		$('h2.page_name').text(sectionName);
		//pull from sifr config
		sIFR.replace(mich, {
		  selector: 'h2.page_name',
			wmode: 'opaque',
		  //css: '.sIFR-root {background-color:#E6E2CC; color: #6e6455;}'
		  css: '.sIFR-root {background-color:#E6E2CC; color: #993702; font-size:35px;}'
		});
	}
	
	//edit slideshow
	$('#edit_slideshow').css('opacity',0.9);
	
	//label first and last list items
	$('ul li:first-child').addClass('firstChild');
	$('ul li:last-child').addClass('lastChild');
	
	//add third level navigation
	$('#secondary ul.nav2 > li.on ul.nav3').addClass('indie').insertAfter('ul#secondary');
	
	//get original width
	var container = $('.wrapper');
	var content = $('#membercenter');
	var containerWidth = $(container).width();
	var contentWidth = $(content).width();
	var origWidth = contentWidth;
	
	//get largest width of items inside content
	$(content).find('table:visible, div:visible').not('.clear, #calendar_agenda div').each(function(){
		if($(this).outerWidth()>contentWidth){
			//console.log($(this).attr('id'));
			contentWidth = $(this).outerWidth();
		}
	});
	
	//get difference and apply to content and container
	if (contentWidth > origWidth){
		$(content).css('width', contentWidth+'px');
		var pxDiff = contentWidth - origWidth;
		$(container).css('width', containerWidth+pxDiff+'px');
		$('body').addClass('expanded');
	}

});
