$().ready(function() {
	
	//Loop through H2 elements and build sub menu. 
	i = 0;
	$('div.section_content h2').each(function(){
		i++;
		$(this).attr('id', 'anchor_' +i);
		
		var txt = $(this).html();
		if(txt != ""){
			$('div#this_page ul').append('<li><a class="#anchor_'+i+'" href="#anchor_'+i+'">'+txt+'</a></li>');
		}
		
	});
	
	//Animated scroll to anchor points
	$('div#this_page a').click(function(){
		var tagertId = $(this).attr('class');
		$.scrollTo(tagertId, 1500);
		return false;
	});
	
	//Center floating divs - Media Region Template specific:
	$('div.single_inner').width($('div.inner_media').width() + $('div.inner_caption').width() + 210);
	
	// MINIMIZE unused regions
	$('div.wrap').each(function(){
		
		var h1_content = $(this).find('.section_content').children('h1').text().length > 2;
		var h2_content = $(this).find('.section_content').children('h2').text().length > 2;
		var col_content = $(this).find('.col').children('*').text().length > 2;
		
		if( h1_content || h2_content || col_content ){
			// Do nothing
		} else {
			$(this).remove();
			//$("div.wrap:nth-child(odd)").addClass("wrap_on");
		}
	});
	
	//Zebra Stripe repeating content areas
	$("div.wrap:nth-child(odd)").addClass("wrap_on");
	
	// LINK FEATURE PANEL IMAGES
	$('.feature_panel img').css('cursor','pointer').click(function(){
		
		var img_link = $(this).parent().find('a').attr('href');
		window.location = img_link;
		
	});
	
});
