/*
jQuery().ready(function() {
	init_spotlight();	// tabs in the footer
	resize_footer(); // set footer height
});
*/

jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function
  init_spotlight();	// tabs in the footer
	resize_footer(); // set footer height
});


function resize_footer() {
	var content_h = jQuery("#footer").height();
	jQuery(".push").height(content_h);
	jQuery("#wrapper-container").css('margin-bottom','-'+content_h+'px');
}

// turn on active testimonial tab buttons 
function init_spotlight() {
	var MAX_ITEMS = 6;
	var max_height = 0;
	for(i = 0; i < MAX_ITEMS; i++) {
		var s = jQuery("#news_item"+i);
		var btn = jQuery("#news_tab"+i);
		
		if(s.height() > max_height) {
			max_height = s.height();
		}
		
		if(s != null && btn != null){
			btn.css('display', 'block');
		}
	}
	
	for(i = 0; i < MAX_ITEMS; i++) {
		var s = jQuery("#news_item"+i);
		s.height(max_height);
	}
	
	jQuery("#news-items-holder").height(max_height);
	jQuery("#news-items-holder").css('overflow', 'hidden');
	
	//make first tab active
	toggle_spotlight('0');
}

// homepage spotlight toggle
function toggle_spotlight(spotlight_id) {
	var MAX_ITEMS = 6;
	//turn off all others
	for(i = 0; i < MAX_ITEMS; i++) {
		// tab content
		var s = jQuery("#news_item"+i);
		if(s != null) {
			s.css('display', 'none');
		}
		
		// tab button
		var b = jQuery("#news_tab"+i);
		if(b != null) {
			b.css({'background-color':'#596f4f'});
		}
	}
	
	//turn on requested div
	s = jQuery("#news_item"+spotlight_id);
	if(s != null) {
		s.css('display', 'block');

		b = jQuery("#news_tab"+spotlight_id);
		if(b != null) {
			b.css({'background-color':'#849b7a'});
		}
	}
}
