function writePages (n_pages) {
	var n_links = 5;

	// get the url of the page
	var s_fullPath = window.location;

	// extract the path, prefix, index and ext.
	var re_fileName = /([^\/]+)$/;
	var re_nameIdxExt = /^(.+?)(\d+)(\..+)$/;
	
	if (!re_fileName.exec(s_fullPath)) return;
	var s_fileName = RegExp.$1;
	var s_filePath = RegExp.leftContext;

	if (!re_nameIdxExt.exec(s_fileName)) return;
	var s_prefix = RegExp.$1,
		n_index = Number(RegExp.$2),
		s_ext = RegExp.$3;

	
	if (n_index != 1)
		document.write('&nbsp;<a href="' + s_filePath + s_prefix + 1 + s_ext + '" class="snormal" title="go to first page"><<</a>&nbsp;&nbsp;<a href="' + s_filePath + s_prefix + (n_index - 1) + s_ext + '" class="snormal" title="go to previous page"><</a>&nbsp;');
	

	if (n_links) {
		if (n_links > n_pages)
			n_links = n_pages;
		
		var n_sideLinks = Math.floor((n_links - 1) / 2),
			n_firstLink, n_lastLink;
		
		if (n_index + n_sideLinks >= n_pages) {
			n_firstLink = n_pages - n_links + 1;
			n_lastLink = n_pages;
		}
		else if (n_index - n_sideLinks <= 0) {
			n_firstLink = 1;
			n_lastLink = n_links;
		}
		else {
			n_firstLink = n_index - n_sideLinks;
			n_lastLink = n_firstLink + n_links - 1;
		}
		for (var i = n_firstLink; i <= n_lastLink; i++)
			document.write(i == n_index ? i + ' ' : '<a href="' + s_filePath + s_prefix + i + s_ext + '" title="go to page ' + i + '" class="snormal">' + i + '</a> ');
		
	}
	
	if (n_index != n_pages)
		document.write('&nbsp;<a href="' + s_filePath + s_prefix + (n_index + 1) + s_ext + '" class="snormal" title="go to next page">></a>&nbsp;&nbsp;<a href="' + s_filePath + s_prefix + n_pages + s_ext + '" class="snormal" title="go to last page">>></a>');
	}