// JavaScript Document
var m_iNewsCurrentIndex = 0;
var m_$newsDiv;// = $("#"+dynamic_news_list);
var m_$PreButton;// = $("#"+switchPre);
var m_$PostButton;// = $("#"+switchPost);
var m_iNewsLength;// = m_$newsDiv.find(">li").length;
$(document).ready(function()
{
	m_$newsDiv = $("#dynamic_news_list");
	m_$PreButton = $("#switchPre");
	m_$PostButton = $("#switchPost");
	m_iNewsLength = m_$newsDiv.find(">li").length;
	hideAllNews();
	showArrow(m_iNewsCurrentIndex);
	showNews(m_iNewsCurrentIndex);	
	
})

function hideAllNews()
{
	m_$newsDiv.find(">li").each(function(){
		$(this).hide();   
	})		
}	
function showNews(iIndex)
{
	if(iIndex >= 0 && iIndex < m_iNewsLength)
	{
		var liNode = m_$newsDiv.find(">li").eq(iIndex);
		$(liNode).show();			
	}	
	
}
function showArrow(iIndex)
{
	if(m_iNewsLength == 0 || m_iNewsLength == 1)
	{
		$(".pre_news_image").attr("src","groupspace/css/images/myteam/arrow_gray_pre.gif");
		$(".next_news_image").attr("src","groupspace/css/images/myteam/arrow_gray_next.gif");			
	}
	else
	{
		if(iIndex >= 0 && iIndex < m_iNewsLength)
		{
		
			if(iIndex == 0)
			{			
				$(".pre_news_image").attr("src","groupspace/css/images/myteam/arrow_gray_pre.gif");
				$(".next_news_image").attr("src","groupspace/css/images/myteam/arrow_black_next.gif");				
			}
			else if(iIndex == m_iNewsLength -1)
			{
				$(".pre_news_image").attr("src","groupspace/css/images/myteam/arrow_black_pre.gif");
				$(".next_news_image").attr("src","groupspace/css/images/myteam/arrow_gray_next.gif");
			}
			else
			{
				$(".pre_news_image").attr("src","groupspace/css/images/myteam/arrow_black_pre.gif");
				$(".next_news_image").attr("src","groupspace/css/images/myteam/arrow_black_next.gif");	
			}
			
		}
	
	}
	
}
function gotoNext()
{
	if(m_iNewsLength > 0)
	{
		//m_iNewsCurrentIndex = (m_iNewsCurrentIndex+1)%m_iNewsLength;
		if(m_iNewsCurrentIndex !== m_iNewsLength -1)
		{
			hideAllNews();
			m_iNewsCurrentIndex++;
			showArrow(m_iNewsCurrentIndex);
			showNews(m_iNewsCurrentIndex);		
			
		}			
		
	}
	
}

function gotoPre()
{
	if(m_iNewsLength > 0)
	{
		//m_iNewsCurrentIndex = (m_iNewsCurrentIndex-1+m_iNewsLength)%m_iNewsLength;	
		if(m_iNewsCurrentIndex != 0)
		{
			hideAllNews();
			m_iNewsCurrentIndex--;
			showArrow(m_iNewsCurrentIndex);
			showNews(m_iNewsCurrentIndex);				
		}	
	}		
}


