/* updates - function for getting older updates */
window.addEvent('domready', function(){
	
	$('older').setProperty('class','inline'); // hidden if javascript disabled
	$('newer').setProperty('class','inline'); // hidden if javascript disabled
	
	var $limit = 0;
	
	new Ajax('/inc/updates.php', {method: 'get', onComplete:rowNumber, data:'getNum=1'}).request(); // get total number of rows from updates
	var url = "/inc/updates.php"; // url of the php actionoly
	var reqy = new Ajax(url, {method: 'get', update: $('rupdates')}) // new ajax object used by paging buttons
	
	$('older').addEvent('click', function(e) {
		e = new Event(e);
		if($limit < ($maxRows - 5)){
			$limit = $limit + 5;
			reqy.url = url + "?limit=" + $limit;
			reqy.request();
		}else{
			disableDown();
		}
		checkBut($limit,$maxRows);
		e.stop();
	});
	$('newer').addEvent('click', function(e) {
		e = new Event(e);
		if($limit > 0){
			$limit = $limit - 5;
			reqy.url = url + "?limit=" + $limit;
			reqy.request();
		}else{
			disableUp();
		}
		checkBut($limit,$maxRows);
		e.stop();
	});
		
}); 

function checkBut(x){
	if(x < 5){
		disableUp();
	}else{
		enableUp();
	}
	if(x < ($maxRows - 5)){
		enableDown();
	}else{
		disableDown();
	}
}

function disableUp(){
	$('newerimg').setProperty('src','/images/arrowup2.gif');
}
function enableUp(){
	$('newerimg').setProperty('src','/images/arrowup.gif');
}
function disableDown(){
	$('olderimg').setProperty('src','/images/arrowdown2.gif');
}
function enableDown(){
	$('olderimg').setProperty('src','/images/arrowdown.gif');
}


function rowNumber(request,$limit){
	$maxRows = request;
	disableUp();
}	
