$(document).ready(function() {	
	
	var hashVar = '#section';
	var cntAll = $('.r-slider li').size();
	
	$('.r-slider-nav a.up').live('click', function() {
		var selSection = getSelSection(location.href, hashVar);
		if (selSection > 1) {
			var newItemUp = parseInt(selSection)-1;
			$('.r-slider-nav a.up').attr("href", '#section'+newItemUp);
		}
		else {
			$(this).removeClass('active');
		}
		if (selSection < cntAll-1) {
			$('.r-slider-nav a.down').addClass('active');
		}		
		var newItemDown = parseInt(selSection)+1;
		$('.r-slider-nav a.down').attr("href", '#section'+newItemDown);
		
		
		return false;
	}); 
	
	$('.r-slider-nav a.down').live('click', function() {
		
		var selSection = getSelSection(location.href, hashVar);
	
		if (selSection < cntAll-1) {
			var newItemDown = parseInt(selSection)+1;
			$('.r-slider-nav a.down').attr("href", '#section'+newItemDown);
		}
		else {
			$(this).removeClass('active');
		}
		if (selSection > 0) {
			$('.r-slider-nav a.up').addClass('active');
		}
		var newItemUp = parseInt(selSection)-1;
		$('.r-slider-nav a.up').attr("href", '#section'+newItemUp);
		

		return false;
	}); 
	
	function getSelSection(url, hashVar) {
		return url.substr(url.indexOf(hashVar)+1+hashVar.length-1);	
	}

	$(function() {
        $('#gallery a').lightBox();
    });

	
});

