/**
 * PREV AND NEXT BUTTONS v 1.0
 * Añadir posteriormente que al llegar a la última página oculte el botón next y lo
 * mismo al llegar al principio con el botón prev
 *
 * Script by Juan Astasio
 * www.ynadie.es
 * Script para programar botones prev/next sin tener que añadir las URLS una a una en * cada botón de cada página.
 * Válido para páginas del tipo:
 * estaPag01.html, estaPag02.html etc  
 * dir: Num. parámetro que indica si vas a la anterior o la siguiente (1 ó -1)
 * pagTot: Num. Número total de páginas
 * estaPag: String. el nombre del archivo html sin los números. Ej. En  
 * bonitapagina01.html, el valor que habría que dar a etaPag sería 'bonitapagina'
 */
function go(dir,pagTot,estaPag) { 
    var text = self.location.href;
    var pos = text.indexOf(estaPag);
	var n = estaPag.length;
	var num = text.substring(pos+n,pos+n+2) -0 + dir;
	num = (num < 10) ? "0" + num : num;
	var checkNum = num-0;
	if (checkNum < 1) 
	{
	pagTot = (pagTot < 10) ? "0" + pagTot : pagTot;
	window.location.href = text.substring(pos,pos+n) +
                           pagTot + 
						   text.substring(pos+n+2,text.length)
						   ;
	} else if (checkNum > pagTot) {
	num = '01';
	window.location.href = text.substring(pos,pos+n) +
                           num + 
						   text.substring(pos+n+2,text.length)
						   ;
	} else {
	window.location.href = text.substring(pos,pos+n) +
                           num + 
						   text.substring(pos+n+2,text.length)
						   ;
	}                     
}


