var tipTitleArray = new Array();
var tipTextUnuArray = new Array();
var tipLinkUnuArray = new Array();
var tipImageArray = new Array();
var tipIArticle = 0;
var tipIndexCurent = 0;
var tipNextAll = '';

var tipsOnPage = 5;  //numarul de itemuri afisate pe pagina

function fillDivTrei( fromIndex )
{
	document.getElementById("tipsArticole").innerHTML = '';
	for( var i = fromIndex; i < fromIndex + tipsOnPage; i++ )
	{
		if( i < tipIArticle )
		{
			umpleDivTrei(i);
		}
	}
	if( fromIndex > 0 )
	{
		document.getElementById("Prev").innerHTML = '   <a href="#" class="linkArticol" onClick="clickOnPrevTrei()">Inapoi</a>';
	}
	else
	{
		document.getElementById("Prev").innerHTML = '      ';
	}

	for( var i = 0; i <= Math.floor( tipIArticle/tipsOnPage ); i++ )
	{
		if ( ( i * tipsOnPage ) != tipIArticle )
		{
			tipNextAll += '   <a href="#" class="linkArticol" onClick="fillDivTrei(' + ( i * tipsOnPage ) + ')">' + ( i + 1 ) + '</a>';
		}
	}

	document.getElementById("All").innerHTML = tipNextAll;
	tipNextAll = '';

	if( fromIndex + tipsOnPage < tipIArticle )
	{
		document.getElementById("Next").innerHTML = '<a href="#" class="linkArticol" onClick="clickOnNextTrei()">Inainte</a>   ';
	}
	else
	{
		document.getElementById("Next").innerHTML = '            ';
	}
	tipIndexCurent = fromIndex;	
}

function initDivTrei()
{
	fillDivTrei( 0 );
}

function clickOnNextTrei()
{
	fillDivTrei( tipIndexCurent + tipsOnPage );
}

function clickOnPrevTrei()
{
	fillDivTrei( tipIndexCurent - tipsOnPage );
}

function umpleDivTrei(indexArticol)
{
	textArticol  = '<div id="home_news_1">';
	textArticol += '	<img src="/eKontentParilotoFiles/home/images/19.jpg" width="19" height="19" hspace="4" align="left" />';
	textArticol += '	<h2 class="title blue">' + tipTitleArray[ indexArticol ] + '</h2>';
	textArticol += '	<img src="/eKontentParilotoFiles/home/images/20.jpg" width="193" height="4" class="title_hr"/>';
	textArticol += '	<div class="news_content">';
	if (tipImageArray[ indexArticol ])
	{
		textArticol += '<img src="' + tipImageArray[ indexArticol ] + '"  align="right" class="margin_1" border="0"/>';
	}
					
	textArticol += '		<div class="main_text">';
	textArticol +=				tipTextUnuArray[ indexArticol ];
	textArticol +=				'<p class="details"><img src="/eKontentParilotoFiles/home/images/26.jpg" width="9" height="9" border="0" hspace="4" /> <a href="'+tipLinkUnuArray[ indexArticol ]+'" class="link_details"> Detalii... </a></p>';
	textArticol += '		</div>';
	textArticol += '	</div>';
	textArticol += '</div>';
	
	document.getElementById("tipsArticole").innerHTML += textArticol;
}