actual = 0;
max = 0;
autopager = false;
pict = false;
pages = false;

function ref_display(){
	$(pict).hide();
	$(pages).hide();
	$(pict[actual]).fadeIn(2000);
	$(pages[actual]).show();
	$(".actual",".pager_navigate").html(actual+1);
	$(".max",".pager_navigate").html(max+1);
}
function ref_play(){
	ref_next();
	clearTimeout(timer);
	timer = setTimeout("ref_play()",8000);
}

function ref_prev(){			
	if (  (actual-1) < 0 ){ 
		actual = max;
	} else {
		actual = actual - 1;
	}
	ref_display();
}

function ref_next(){
	if (  (actual+1) > max ){ 
		actual = 0;
	} else {
		actual = actual + 1;
	}
	ref_display();
}

function ref_pause(){
	if (timer){ 
		clearTimeout(timer);
		timer = false;
		$(".pause",".ref_pause").hide();
		$(".play",".ref_pause").show();
	}else{
		$(".play",".ref_pause").hide();
		$(".pause",".ref_pause").show();
		ref_play();
	}				
}

$("body").ready(function(){
	pict = $("img",".head_ref_pict");
	pages = $(".head_ref_pages");

	max = (pict.length-1);
	actual = (-1);
	
	$(".ref_pause").click(function(){ ref_pause(); });
	$(".ref_prev").click(function(){ ref_prev(); });
	$(".ref_next").click(function(){ ref_next(); });
	
	
	ref_play();
});
