// JavaScript Document
var isLoading = false ;



function activateCateg( id )
{
	activeItems = document.getElementById( 'subcat_'+id );	
}

function nextPage()
{
	if( !isLoading )
	{	
		page_number++;
		displayNav() ;
	//	alert( ' next ');	
		isLoading = true ;	
	}
}

function prevPage()
{
	if( !isLoading )
	{
		page_number--;
		displayNav() ;
	//	alert( ' next ');	
		isLoading = true ;	
	}
}

function displayNav()
{
	
	for( i=0; i<30; i++)
	{
		categoryItemContent = '<div class="popularItem">                    	<div class="pic90"></div>                        <div class="flft" style="width:110px;"><b><a href="#">Loading ..</a></b></div>                        <div class="flft" style="width:110px;font-size:10px;">0 views</div>                    </div>';
		eval( 'obj=document.getElementById( \'categoryItem_'+i+ '\' );');
		obj.innerHTML = categoryItemContent ;
		
	}
	
	document.getElementById('pgNav').innerHTML = '';
	if( page_number > 1 ) 
		document.getElementById('pgNav').innerHTML += '<div class="prevPage" onclick="javascript:prevPage();"></div>';
	if( page_number < total_pages ) 
		document.getElementById('pgNav').innerHTML += '<div class="nextPage" onclick="javascript:nextPage();"></div>';
	document.getElementById('pgNav').innerHTML += 'Page '+page_number+' / '+total_pages;
	
	categoryItemsCall();
}

/***
 *	Functie ce afiseaza noile contenturi din featured additions
 **/
function categoryItemsShow()
{ 
	//alert( ajax.response );
	eval( 'var ar = ' + ajax.response + ';' ) ;
	for ( x in ar )
	if( x < 30 )
	{
		y = ar[x] ;
//		alert( "File: "+y.file );
		featureItemContent = '		<div class="popularItem">                    	<div class="pic90"><a href="'+root_path+'show/'+y.key+'/'+y.file+'"><img src="'+root_path+'data/thumbs/ff_'+y.key+'.jpg" width="90" height="67" border="0"></a></div>                        <div class="flft" style="width:110px;"><b><a href="'+root_path+'show/'+y.key+'/'+y.file+'">'+y.title+'</a></b></div>                        <div class="flft" style="width:110px;font-size:10px;">'+y.views+' views</div>                    </div>';
		eval( 'obj=document.getElementById( \'categoryItem_'+x+ '\' );');
		obj.innerHTML = featureItemContent ;
		z = x ;			
		
	}
	for( i=++z; i<30; i++)
	{
		categoryItemContent = '<div class="popularItem"></div>';
		eval( 'obj=document.getElementById( \'categoryItem_'+i+ '\' );');
		obj.innerHTML = categoryItemContent ;
		
	}
	isLoading = false ;	
	
}


function categoryItemsCall( )
{
	ajax.requestFile = '../../application/ajax/www/categoryItems.php?page='+page_number+'&ks=ba';	// Specifying which file to get
	ajax.onCompletion = categoryItemsShow;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function		
}

	var activeItems = null ;
	var page_number = 1 ;
	var total_pages = 6 ;
