function nav(direction)
{
var array1 = new Array(28)
  for (i = 0; i < 29; i++) {		
  	array1[i] = i+1};

  var url = window.location.href;						// Retrieve the full url ie: 'http://www.motorhometouring.com/e_xxxx_5.html'
  var lastUnderscore = url.lastIndexOf("_");  // Locate the position of the last '_' ei: 7
  var lastDot = url.lastIndexOf(".");  // Locate the position of the last '.' ei: 9
  var url_without_number = url.substring(0,lastUnderscore);   // Retrieve the html name without page number and '.html' ie: 'e_xxxx_'
  var url_number = url.substring(lastUnderscore+1,lastDot);   // Retrieve the html page number ie: '5'
  var result = 0;
  if (url_number == 1 && direction == '-1'){ result = 28;}	// Current page is # 1 and direction is "Previous", result=Last page
  else if (url_number == 28 && direction == '1'){ result = 1;}	// Current page is # 18 (last one) and direction is "Next", result=First page				
  var sens =0;
   /*for (i = 0; i < array1.length; i++) {window.alert(array1[i])
  	};*/
  if (direction == '-1') {sens = -1;}
  if (direction == '1') {sens = 1;}
  var url_number2 =url_number * 1;
 /*window.alert(url_number2);*/

  if (result == 0) {
  		for (i = 0; i < array1.length; i++) {
			if (url_number2 == array1[i]) {
				result = array1[i + sens];}
			};
  };

// If page # < 10, add 0 before page # in order to have '03' instead of '3'
  if (result < 10) {
  	var new_url = url_without_number + "_0" + result + ".html"}	  
  else {
  	var new_url = url_without_number + "_" + result + ".html"}	// Add the new page # to the html name without page number  ei: 'e_xxxx_6'
/*window.alert(url_number2);
window.alert(url_without_number);*/
document.location=new_url
}
