

var currentPSStart = 0;
var currentPSEnd = 0;
var psMax = 0;


// General on page load functionality
$(document).ready(function(){


});

function psProgress(progress, dir) {
	var plus = '';
	
	if (dir == "down") p = psMax - currentPSEnd;
	else if (dir == "up") p = currentPSStart-1;
	
	if (language == "en_EN")
	{
		plus = 'more';
	}
	else
		if(language == "fr_FR")
		{
			plus = 'de plus';
		}

	if (p > 0) 
		$(progress).html(p+ " "+plus);
	else 
		$(progress).html("");
}

function postSlider(pageItems, up, down, progress) {
		
	// Hide all items
	$('.news').hide();
	
	// Prepare navigation
	currentPSStart = 1;
	currentPSEnd = pageItems;
	psMax = $('.news').length;

	// Show first items
	for (i = 1; i <= pageItems; i++) {
		$('#news-'+i).show(500);
	}
	
	// Show progress
	$(down).mouseover(function() { psProgress(progress, "down"); });
	$(up).mouseover(function() { psProgress(progress, "up"); });

	// Show progress
	$(down).mouseout(function() { $(progress).html("") });
	$(up).mouseout(function() { $(progress).html("") });


	// Link sliders
	$(down).click(function() {

		if (currentPSEnd < psMax ) {
		
			// Change current range
			currentPSStart++;
			currentPSEnd++;
			
			// Hide previous item
			$('#news-'+(currentPSStart-1)).hide(300);
			
			// Show Next Item
			$('#news-'+currentPSEnd).show(600);
			
			// Update progress
			psProgress(progress, "down");
		}

	});


	// Link sliders
	$(up).click(function() {
		
		if (currentPSStart > 1) {
		
			// Change current range
			currentPSStart--;
			currentPSEnd--;
			
			// Show previous item
			$('#news-'+(currentPSStart)).show(600);
			
			// Show next Item
			$('#news-'+(currentPSEnd+1)).hide(300);

			// Update progress
			psProgress(progress, "up");
		}

	});
	
}


