jsOn();

function jsOn() {

	// ---- exec for html only
	var uri = document.URL;
	if (uri.match(/_\d\d\d.html$/)) {
		// ---- attach key event
		if (window.attachEvent) { // IE
			var htmls = document.getElementsByTagName("html");
			htmls[0].attachEvent("onkeydown", keyNavi);
		}
		if (window.addEventListener) { // Fx
			window.addEventListener("keydown", keyNavi, false);
		}
	}
}

function keyNavi(event) {
	var code = event.keyCode || event.charCode;

	if (!event.shiftKey) {
		return;
	}

	var mode = 0;
	// ---- prev (LEFT, -, PageDown) UP=38,p=80
	if (code == 37 || code == 109 || code == 34) {
		mode = -1;
	// ---- next (RIGHT, +, PageUp) DOWN=40,n=78
	} else if (code == 39 || code == 107 || code == 33) {
		mode = +1;
	// ---- index (Home)
	} else if (code == 36) {
		mode = 0;
	} else {
		return;
	}

	var uri = document.URL;
	uri.match(/^(.*\/)([a-z_].*)(\d\d\d)(\.html)$/);
	var uri_prefix = RegExp.$1;
	var contype = RegExp.$2;
	var no = RegExp.$3;
	var uri_suffix = RegExp.$4;

	var newuri = "";
	// ---- to index
	if (mode == 0) {
		// ---- magic...
		contype = contype.substring(0, contype.length - 1);
		if (contype.match(/^(.*)_rc$/)) {
			contype = RegExp.$1;
		}
		newuri = uri_prefix + "index_full_" + contype + uri_suffix;

	// ---- to prev or next
	} else {
		no = no - 0 + mode;
		if (no < 1) {return;}
		var numberStr = '00' + Math.abs(no);
		numberStr = numberStr.substring(numberStr.length-3, numberStr.length);
		newuri = uri_prefix + contype + numberStr + uri_suffix;
	}

	location = newuri;
}

