if (typeof(YAHOO) == 'object')	{

	/** 
	 Featured Post Plugin Script
	 */
	YAHOO.namespace("expressitech_featured_posts.container");
	
	var featured_posts_counter = 6;
	var featured_post_array = Array();
	var featured_post_default_color;
	var featured_post_highlight_color;
	var current_feature_post = 1;
	
	YAHOO.util.Event.onDOMReady(function () {
		
		// featured_posts_counter = parseInt(document.getElementById('featured_posts_counter').value);		
		if (featured_posts_counter > 0)	{
			
			var i;
			var easing_attributes = { opacity: { to: 1 }, duration: 5 };
			
			for(var i=1; i<featured_posts_counter;i++)	{
			    
				var feature_el_id = 'stage'+i.toString();
				var show_el_id = 'show'+i.toString();
				
				var feature_visible = false;
				
				if (i == current_feature_post)	{
					featured_post_highlight_color = YAHOO.util.Dom.getStyle(show_el_id, 'backgroundColor');
					feature_visible = true;
				}
				else	{
					featured_post_default_color = YAHOO.util.Dom.getStyle(show_el_id, 'backgroundColor');
				}
				
				featured_post_array[i] = new YAHOO.widget.Module(feature_el_id, { visible: feature_visible });
			    featured_post_array[i].render();
			    
			    YAHOO.util.Event.addListener(show_el_id, "click", showHideFeaturePosts, featured_post_array[i], true);
			    
			}
		}
		
		setInterval ( 'advanceFeature()', 45000 );
	});
}

function advanceFeature()	{
	
	var next_feature = current_feature_post + 1;
	if (next_feature >= featured_posts_counter)	{
		next_feature = featured_posts_counter - current_feature_post;
	}
	
	for (var i=1; i < featured_posts_counter; i++)	{
		
		if (i != next_feature)	{
			YAHOO.util.Dom.setStyle(featured_post_array[i].id, 'display', 'none');
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'backgroundColor', featured_post_default_color);
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'color', featured_post_highlight_color);
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'fontWeight', 'normal');
		}
		else	{
			if (YAHOO.env.ua.ie == 0) {
				YAHOO.util.Dom.setStyle(featured_post_array[i].id, 'opacity', '0');
				YAHOO.util.Dom.setStyle(featured_post_array[i].id, 'display', 'block');
				var fadeInAnim = new YAHOO.util.Anim(featured_post_array[i].id, { opacity: {to: 1} }, 1 );
				fadeInAnim.animate();
			}
			else	{
				YAHOO.util.Dom.setStyle(featured_post_array[i].id, 'display', 'block');
			}
			
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'backgroundColor', featured_post_highlight_color);
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'color', featured_post_default_color);
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'fontWeight', 'bold');			
		}
	}
	
	current_feature_post = next_feature;
}

function showHideFeaturePosts(e)	{
	
	var targ;
	if (!e)	{ var e = window.event;	}
	if (e.target)	{ targ = e.target;	}
	else if (e.srcElement)	{ targ = e.srcElement;	}
	if (targ.nodeType == 3)	{ 	targ = targ.parentNode; } // defeat Safari bug
	
	YAHOO.util.Dom.setStyle(targ, 'backgroundColor', featured_post_highlight_color);
	YAHOO.util.Dom.setStyle(targ, 'color', featured_post_default_color);
	YAHOO.util.Dom.setStyle(targ, 'fontWeight', 'bold');			
	
	for(var i=1; i < featured_posts_counter; i++)	{
		
		if (YAHOO.util.Dom.getStyle(featured_post_array[i].id, 'display') == 'block')	{
			YAHOO.util.Dom.setStyle(featured_post_array[i].id, 'display', 'none');
		}
		
		if (featured_post_array[i].id != this.id)	{
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'backgroundColor', featured_post_default_color);
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'color', featured_post_highlight_color);
			YAHOO.util.Dom.setStyle('show'+i.toString(), 'fontWeight', 'normal');
		}
		else	{
			current_feature_post = i;
		}
		
	}
	
	if (YAHOO.env.ua.ie == 0) {
		YAHOO.util.Dom.setStyle(this.id, 'opacity', '0');
		YAHOO.util.Dom.setStyle(this.id, 'display', 'block');
		var fadeInAnim = new YAHOO.util.Anim(this.id, { opacity: {to: 1} }, 1 );
		fadeInAnim.animate();
	}
	else	{
		YAHOO.util.Dom.setStyle(this.id, 'display', 'block');
	}
}

// end Demo Code