//featured_post.js
//controls the home page featured post divs

//put all the needed globals into array FPOST_GLOBALS
//to avoid potential global namespace conflicts.  
//should do this with function too...baby steps
//featured-post-1:blog
//featured-post-2:podcast
//featured-post-3:videos
var FPOST_GLOBALS = {
	'element_id_prefix':'featured-post-',
	'post_count':4,
	'featured_post':1
};

// shows the featured post
function showFeaturedPost (post_num) {
	//update globals
	if (post_num) {
		FPOST_GLOBALS['featured_post'] = post_num;
	}

	// hide all featured posts
	for (i=1; i<=FPOST_GLOBALS['post_count']; i++) {
		document.getElementById(FPOST_GLOBALS['element_id_prefix']+i).style.display = 'none';
		document.getElementById(FPOST_GLOBALS['element_id_prefix']+"btn-"+i).style.fontWeight = 'normal';
	}

	//show the featured post
	document.getElementById(FPOST_GLOBALS['element_id_prefix']+FPOST_GLOBALS['featured_post']).style.display = 'block';
	document.getElementById(FPOST_GLOBALS['element_id_prefix']+"btn-"+FPOST_GLOBALS['featured_post']).style.fontWeight = 'bold';
}

function previousFeaturedPost () {
	if (FPOST_GLOBALS['featured_post']==1) {
		FPOST_GLOBALS['featured_post'] = FPOST_GLOBALS['post_count'];
	} else {
		FPOST_GLOBALS['featured_post']--;
	}
	showFeaturedPost();
}

function nextFeaturedPost () {
	if (FPOST_GLOBALS['featured_post']==FPOST_GLOBALS['post_count']) {
		FPOST_GLOBALS['featured_post'] = 1;
	} else {
		FPOST_GLOBALS['featured_post']++;
	}
	showFeaturedPost();
}
