	var hitCount = 0;
	var presentPage = 0;
	var allPage = 0;
	var perPage = 10;
	var hists = new Array();
	var urlBase = '/co/bs_short.html';

	window.onload = function(){
		var d = $('hit_count');
		if (!d) {
			return;
		}
		hitCount = Number(d.innerHTML);

		allPage = Math.floor((hitCount - 1) / perPage) + 1;
		firstPage();
	}

	function firstPage() {
		for (i = 0; i < hitCount; i++) {
			var bs_div =$('bs_id' + i);
			hists[i] = bs_div.innerHTML;

			if (i >= perPage) {
				bs_div.innerHTML = "";
			} else {
				_hide2(i);
				_show(i);
			}
		}
		presentPage = 1;
		setNavbar();
	}

	function setNavbar(){

		var searchIndex2 = $('searchIndex2');
		searchIndex2.innerHTML = "";

		new Insertion.Bottom('searchIndex2', "<div style='text-align: left;'>検索結果ページ</div>");
		if (presentPage != 1) {
			new Insertion.Bottom('searchIndex2', "<span><a href='javascript:getPage(presentPage - 1);' id='pr'>前へ</a></span>");
		}
		for (i = 1; i <= allPage; i++) {
			if (i == presentPage) {
				new Insertion.Bottom('searchIndex2', "<span id=" + "'page" + i + "'> " + i + " " + " </span>");
			} else {
				new Insertion.Bottom('searchIndex2', "<span><a href='javascript:getPage(" + i + ");' id=" + "'page" + i + "'>" + i + " " + "</a></span>");
			}
		}
		if (presentPage != allPage) {
			new Insertion.Bottom('searchIndex2', "<span><a href='javascript:getPage(presentPage + 1);' id='nr'>次へ</a></span>");
		}
		for (i = 1; i <= allPage; i++) {
			if (presentPage != i) {
				id = 'page' + i;
			}
		}

		var searchIndex = $('searchIndex');
		searchIndex.innerHTML = "";

		new Insertion.Bottom('searchIndex', "<div style='text-align: left;'>検索結果ページ</div>");
		if (presentPage != 1) {
			new Insertion.Bottom('searchIndex', "<span><a href='javascript:getPage(presentPage - 1);' id='pr'>前へ</a></span>");
		}
		for (i = 1; i <= allPage; i++) {
			if (i == presentPage) {
				new Insertion.Bottom('searchIndex', "<span id=" + "'page" + i + "'>" + i + " " + "</span>");
			} else {
				new Insertion.Bottom('searchIndex', "<span><a href='javascript:getPage(" + i + ");' id=" + "'page" + i + "'>" + i + " " + "</a></span>");
			}
		}

		if (presentPage != allPage) {
			new Insertion.Bottom('searchIndex', "<span><a href='javascript:getPage(presentPage + 1);' id='nr'>次へ</a></span>");
		}
		for (i = 1; i <= allPage; i++) {
			if (presentPage != i) {
				id = 'page' + i;
			}
		}

	}

	function _hide(num) {
		var coId = $('bs_id' + num);
		coId.innerHTML = "<image src='/img/ajax-loader.gif'>";
	}

	function _hide2(num) {
		var coId = $('bs_id' + num);
		coId.innerHTML = "";
	}


	function _show(num) {
		var coId = $('bs_id' + num);
		coId.innerHTML = "";
		new Ajax.Updater(coId, urlBase, {method : 'get', parameters : 'bs_id=' + hists[num]});
	}

	function getPage(num) {
		for (i = 0; i < perPage; i++) {
			var d = perPage * presentPage - (i + 1);
			if (d < hitCount) {
				_hide(d);
				setTimeout("_hide2('"+d+"')", 100);
				Element.scrollTo($('global_header'));
			}
		}

		presentPage = Number(num);

		for (i = 0; i < perPage; i++) {
			var d = perPage * (presentPage - 1) + i;
			if (d < hitCount) {
				_show(d);
			}
		}
		setNavbar();
	}

