var Headlines_MaxCount=10
function GetNewsSetCounter()
{
      try
	{
		var hidCntr=document.getElementById('hidNewsSetCntr');
		if(!hidCntr) 
			return 0;
		else
			return hidCntr.value;
	}
	catch(e)
	{
		
	}
}

function ShowNext_NewsSet()
{
	try
	{
		var BlockCntr=parseInt(GetNewsSetCounter());
		BlockCntr=BlockCntr+1;	
		HideData();
		var TempSet=document.getElementById('NewsSet_'+BlockCntr);
		
		if (!TempSet)
		{	
			if(BlockCntr<=Headlines_MaxCount)
			{
				GetData(BlockCntr);				
				MVJS.SetValue('hidNewsSetCntr',BlockCntr);
				BlockCntr=BlockCntr-1;			
				MVJS.Hide('NewsSet_'+BlockCntr);
			}
			else
			{
				BlockCntr=BlockCntr-1;
				MVJS.Hide('NewsSet_'+BlockCntr);			
				MVJS.Show('NewsSet_'+0);			
				MVJS.SetValue('hidNewsSetCntr',0);
			}
		}
		else
		{	
			MVJS.Show('NewsSet_'+BlockCntr);
			MVJS.SetValue('hidNewsSetCntr',BlockCntr);
			BlockCntr=BlockCntr-1
			MVJS.Hide('NewsSet_'+BlockCntr);			
		}
	}	
	catch(e)
	{
		
	}
}

function ShowPrevious_NewsSet()
{
	try
	{
		var BlockCntr=parseInt(GetNewsSetCounter());
		MVJS.Hide('NewsSet_'+BlockCntr);
		BlockCntr=BlockCntr-1;				
		if(BlockCntr<0)
		{
			for(var i=0;i<12;i++)
			{
				if(!document.getElementById('NewsSet_'+i))
				{
					BlockCntr=i-1;					
					break;
				}
			}
		}
		var TempSet=document.getElementById('NewsSet_'+BlockCntr);
		if (!TempSet)
		{
			BlockCntr=BlockCntr-1;
			MVJS.Show('NewsSet_'+0);
			MVJS.Hide('NewsSet_'+BlockCntr);
			MVJS.SetValue('hidNewsSetCntr',0);
		}
		else
		{	
			MVJS.Show('NewsSet_'+BlockCntr);
			MVJS.SetValue('hidNewsSetCntr',BlockCntr);
			BlockCntr=BlockCntr+1
			MVJS.Hide('NewsSet_'+BlockCntr);			
		}		
	}
	catch(e)
	{
		
	}
}

function GetData(NewsSetCntr)
{
	try
	{
		Invoke ("GetHeadlineData",Result,"NewsSetCntr="+NewsSetCntr);
	}
	catch(e)
	{
		
	}
}

function Result(res)
{
	try
	{	
		if(res)
		{
			var data=res.stripTags();	
			
			if(data && data.length>0)
			{				
				data=data.replace(/&lt;/gi,'<').replace(/&gt;/gi,'>');	
				data=trim(data);				
				if(data.length>0)
				{				   
					var ExistingData=document.getElementById('tblHeadlineData').innerHTML;
					data=ExistingData+data;
					data ="<table  border=\"0\" cellpadding=\"5\" cellspacing=\"0\" align=\"left\"><tbody id=\"tblHeadlineData\">"+data+"</tbody></table>";
					document.getElementById('HeadLineContainer').innerHTML=data;
					
				}				
				else
				{
					BlockCntr=0;
					MVJS.SetValue('hidNewsSetCntr',0);
					var TempSet=document.getElementById('NewsSet_'+BlockCntr);
					if(TempSet)
					{
						MVJS.Show(TempSet);
					}					
				}
			}
		}
		
	}
	catch(e)
	{
		
	}	
}

function HideData()
{
    try
    {   
        for(var i=0;i<=Headlines_MaxCount;i++)
        {
            var tempData=document.getElementById('NewsSet_'+i);
            if(tempData)
            {
                MVJS.Hide(tempData);
            }
        }
    }
    catch(e)
    {
        
    }
}
function stripTags() {
return this.replace(/<\/?[^>]+>/gi, '');
}

// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

