STDENV.prototype.meta = {
"@prefix": "<http://purl.org/net/ns/doas#>",
"@about": "<http://www.kanzaki.com/parts/std.js>", a: ":JavaScript",
 title: "The Web KANZAKI standard utility scripts",
 shortdesc: "ulitity scripts to be used throughout this site.",
 created: "2002-05-08", release: {revision: "2.5.9", created: "2007-01-30"},
 author: {name: "KANZAKI, Masahide", homepage: "<http://www.kanzaki.com/>"},
 license: "<http://creativecommons.org/licenses/GPL/2.0/>"};


var ge = new STDENV();
ge.noframe();
ge.linkattrs(); 
ge.ecomment();

function init(lv){
	if(! document.getElementById) return;
	if(ge.initvars() == -1) return;
	if(lv == 'min' || lv == 'slide') {ge.notify(''); return;}
	ge.preptoc();
	ge.hrefp();
	ge.abac();
	ge.notify('');
}

/**
 * Standard environment object. To be instantiated as 'ge'. 
 * All function prototypes are private unless specified as @access public.
 * Some properties are public accessible:
 * @property	ge.isIE : browser type (also, isMozilla, etc.)
 * @property	ge.dbase : DOM document base object
 * @property	ge.docLang : document language (ja, en, etc.)
 * @property	ge.userLang : browser's default language
 * @property	ge.localhost : current host type
 * @property	ge.orguri : document's authorized URI
 * @property	ge.oAddr : DOM object for document's last address element
 */
function STDENV(){
	var ua = navigator.userAgent;
	this.isOpera = this.isIE = this.isMacIE = this.isWinIE = this.isSafari = this.isMozilla = this.isIcab = false;
	if(ua.indexOf('Opera') != -1) this.isOpera = true;
	else if(ua.indexOf('MSIE') != -1) {
		this.isIE = true;
		if(ua.indexOf('Mac') != -1) this.isMacIE = true;
		else if(ua.indexOf('Win') != -1) this.isWinIE = true;
	}
	else if(ua.indexOf('Safari') != -1) this.isSafari = true;
	else if(ua.indexOf('Gecko') != -1) this.isMozilla = true;
	else if(ua.indexOf('iCab') != -1) this.isIcab = true;
	this.usrLang = (navigator.userLanguage || navigator.language);
	this.toc = new Object; // popup toc object
	this.creator = {name:"KANZAKI Masahide",fn:"kanzaki",mailTld:".cc"}
	this.nkeylink = []; // for accesskey function of TOC
	this.mw = {check:880, set:860, ad:1000, showad:false};
	this.head = document.getElementsByTagName("head")[0];

//--------------------  prototypes (STDENV continues) --------------

/**
 * Initialize environtmet variables to be used by other functions.
 * Some of them can be accessed from public as ge.*. See properties
 * described at STDENV().
 */
STDENV.prototype.initvars = function(){
	if((this.oH1 = document.getElementsByTagName("H1").item(0))){
		if(this.oH1.getAttribute("id")){
			this.topid = this.oH1.getAttribute("id");
		}else{
			this.topid = "_genid_tophdng";
			this.oH1.setAttribute("id",this.topid);
		}
	}
	this.nkeylink[0] = this.topid;
	this.dbase = document.documentElement || document.body;
	this.isHome = document.getElementById("mytopimg");
	this.docLang = document.documentElement.getAttribute("lang"); //html
	var hr =  document.getElementsByTagName("HR");
	if(hr.length) this.oSepHr = hr.item(hr.length -1);
//this.localhost = (location.host.indexOf("kanzaki.com") >= 0) ? "kanzaki" : (location.host.indexOf("192.168") >= 0 ? "192" : "-1");
this.localhost = (location.host.indexOf("logue.tk") >= 0) ? "logue" : (location.host.indexOf("192.168") >= 0 ? "192" : "-1");
	this.oAddr = this.addrelts();
	if(this.isvalid() == -1) return -1; //2005-04-18
	this.docmeta = false; // set true in stinfo() if grddl present
	this.stInfo = this.stinfo();
	window.document.onkeypress = _procKey;
	return 1;
}

/** Collects link types from head element. */
STDENV.prototype.linkattrs = function(){
	var x,link = document.getElementsByTagName("link");
	var hasmeta, hashome, hassearch;
	this.next = this.prev = ""; // for toc
	this.hasEversion = false;
	for(var i=0,n=link.length; i<n; i++){
		x = link.item(i);
		switch(x.getAttribute("rel")){
			case 'next':
				this.next = x.getAttribute("href"); break;
			case 'prev':
			case 'previous':
				this.prev = x.getAttribute("href"); break;
			case 'up':
				this.up = x.getAttribute("href");
				this.up_title = x.getAttribute("title"); break;
			case 'index':
				this.index = x.getAttribute("href");
				this.index_title = x.getAttribute("title"); break;
			case 'alternate':
				if(x.getAttribute("hreflang") == 'en') this.hasEversion = true;
				break;
			case 'transformation':
				this.grddltrans = x.getAttribute("href");
				hasmeta = x.getAttribute("href"); break;
			case 'home':
				hashome = true; break;
			case 'search':
				hassearch = true; break;
			case 'meta':
				if(! x.getAttribute("type")) hasmeta = 'meta';
				break;
			case 'help':
				this.help = x.getAttribute("href");
				this.help_title = x.getAttribute("title");
				break;
		}
		if(x.getAttribute("rev") == 'made'){
			this.creator.email = x.getAttribute("href");
			this.creator.email = this.creator.email.replace(/\.com$/,this.creator.mailTld);
			x.setAttribute("href",this.creator.email);
		}
	}
	if(! hasmeta) 
		this.addlinkelt('meta','/meta'+document.location.pathname,'RDF metadata of this page');
	if(! hashome && location.pathname != '/') this.addlinkelt('home','/');
	if(! hassearch) this.addlinkelt('search','/info/navi#search-site');
	this.addlinkelt('author','/info/who');
}

STDENV.prototype.addlinkelt = function(linktype, ref, title){
	var meta = document.createElement('link');
	meta.setAttribute('rel',linktype);
	meta.setAttribute('href',ref);
	if(title) meta.setAttribute('title',title);
	this.head.appendChild(meta);
}

/**
 * Processes address element.
 * - expand signature (M.K.) to long name for print.
 * - set old (commented) original URI as an element.
 * - add QR code.
 * @return	a DOM object of the last address element
 */
STDENV.prototype.addrelts = function(){
	var ouri;
	var addrl = document.getElementsByTagName("ADDRESS");
	if(addrl.length){
		var addr = addrl.item(addrl.length - 1);
		// addr.innerHTML = addr.innerHTML.replace(/M\.?K\.?<\/a>/i,"M. K<span class='cpr'>anzaki</span>.</a>");
		if((ouri = document.getElementById("orguri"))) this.orguri = this.nodeText(ouri);//ouri.firstChild.data;
		else{
			addr.innerHTML = addr.innerHTML.replace(/<!-- (Original URI is )(.*) -->/,"<cite class='cpr'><br/>$1$2</cite>");
			this.orguri = RegExp.$2;
		}
		this.orguri = this.orguri.replace(/index.html$/,"");
		this.orguri = this.orguri.replace(/FrontPage.html$/,"");
		addr.innerHTML = 
		//"<span id='qrcode'><span class='pseudobutton' title='will get a QR code for title and URL of this page' onclick='ge.qrcode(0);return false;'>get QR code</span> or <span class='pseudobutton' title='will get a QR code for title and mobile version URL of this page' onclick='ge.qrcode(1);return false;'>mobile ver.</span></span>" + addr.innerHTML;
		"<span id='qrcode'><span class='pseudobutton' title='will get a QR code for title and URL of this page' onclick='ge.qrcode(0);return false;'>get QR code</span></span>" + addr.innerHTML;
		// addr.innerHTML + 
		//"<span class='cpr'><br/>For non commercial use only. See http://www.kanzaki.com/info/disclaimer</span>";
		return addr;
	}else
		return '';
}

/**
 * Generates a QR code link, insetead of embed, to avoid unnecessary trafic.
 * @param	mode : 1 => mobile
 */
STDENV.prototype.qrcode = function(mode){
	var qrpos = document.getElementById("qrcode");
	var im = (mode == 1) ? '/i' : '';
//	qrpos.innerHTML = "<img src='http://masaka.dw.land.to/qr/genqr.php?u=http://www.kanzaki.com" + im + location.pathname + "&amp;t=" + String(encodeURI(document.title)).replace("'","%27") + "' alt='QR Code of this page' />";
	qrpos.innerHTML = "<img src='/?plugin=qrcode&amp;d=MEBKM%3ATITLE%3A" + String(encodeURI(document.title)).replace("'","%27") + "%3BURL%3Ahttp%5C%3A%2F%2F" + location.host + im + location.pathname + "%3B%3B&amp;s=2' alt='QR Code of this page' />";
	qrpos.style.padding = "0";
}

/**
 * Shows update information on page top
 * @return	string status information
 */
STDENV.prototype.stinfo = function(){
	var x, y, z, nsl, c, prof, si="";
	this.notify('prepating status info...');
	if((y = document.getElementById('pst'))){
		si = this.nodeText(y);
	}
	if((nsl = document.getElementById('bnsl')) && this.topid)
		nsl.setAttribute('href','#'+this.topid);
	if((x = document.getElementById('snavi'))){
		if(! x.firstChild) return ""; //e.g. iCab
		if(si){x.firstChild.data = si;}
		if((y = document.getElementById('stinfo'))){
			z = this.nodeText(y);
			if((c = document.getElementById('mycounter'))) this.mct(x, c, z);
			else x.setAttribute('title', z);
		}
	}
	if((prof = document.getElementsByTagName("head").item(0).getAttribute("profile")))
		if(prof.match(/(data-view|metaprof)/)){
			this.grddl(RegExp.$1);
			this.docmeta = true;
		}
	return si;
}

STDENV.prototype.grddl = function(profile){
	var x, l, uri, hash;
	if(String(document.location).indexOf('kanzaki.com/memo') != -1) return;
	if((x = document.getElementById('stinfo'))){
		uri = String(document.location);
		if((hash = uri.indexOf('#',0)) > 0) uri = uri.substr(0,hash);
		var xslt = (profile == 'data-view' && this.grddltrans) ? 
			this.grddltrans :
			"http://www.kanzaki.com/parts/xh2rdf.xsl";
		x.innerHTML += " <a id='grddllink' href='http://www.w3.org/2005/08/online_xslt/xslt?xslfile=" + xslt + "&amp;xmlfile=" + uri + "&amp;content-type=application/xml'><img src='/parts/grddl.png' alt='GRDDL' /> enhanced</a>.";
	}
}

STDENV.prototype.showMeta = function(tgElt){
}

/**
 * 'my counter' function: get counter value and set it on the title attribute of navibar. Called from stinfo(), works site top page only.
 * @param	x : destination element to set title attribute
 * @param	c : counter element
 * @param	z : info text to include counter value
 */
STDENV.prototype.mct = function(x, c, z){
	var v = c.getAttribute('title').match(/[\d,]+/);
	z = z.replace("invaluable",v);
	x.setAttribute('title',z);
	if(v.toString().match(/000$/)) x.firstChild.data = ("Wow! " + v);
}

/** an experimental link to babelfish J-E translation (not used now) */
STDENV.prototype.translink = function(){
	var navi, trns;
	if(this.usrLang.match(/ja/i) || this.docLang != 'ja' || this.hasEversion) return;
	
	if((navi = document.getElementById("banner"))){
		navi.innerHTML += (String(document.location).substr(0,12)=='http://babel') ?
			"<p class='note' style='font-weight:normal'>This page is translated by machine. Might be very odd, but hope to be of your help.</p>" :
			"<p class='dopo noprint' style='margin-bottom:0'><a href='http://babelfish.altavista.com/babelfish/urltrurl?url=" + document.location + "&amp;lp=ja_en' title='This is a trial link to machine translation of this document'>Babelfish J-&gt;E translation</a></p>";
	}
	
}

/**
 * Internally convert abbr elements to acromym elements for IE
 * to display title attribute as a tool tip
 */
STDENV.prototype.abac = function(){
	if(this.isWinIE){
		var ab, abp, m;
		this.notify('preparing abbreviations...');
		ab = document.getElementsByTagName("abbr"); //For HPR3.01
		while((m = ab.length)){
			abp = ab.item(m-1).parentNode;
			abp.innerHTML = abp.innerHTML.replace(/(<\/?)abbr/ig,'$1acronym');
		}
	}
	this.pflb();
}

/** add hypelink URLs as printable text after anchor texts for print. */
STDENV.prototype.hrefp = function(){
	if(! this.isIE && ! this.isOpera)return;
	var divlist, main, alist, a;
	this.notify('prepating href print...');
	divlist = document.getElementsByTagName("DIV");
	for(var i=0,n=divlist.length; i<n; i++){
		if(divlist.item(i).className == 'main'){
			main = divlist.item(i);
			break;
		}
	}
	if(main){
		alist = main.getElementsByTagName("A");
		for(i=0,n=alist.length; i<n; i++){
			a = alist.item(i);
//			if(String(a.getAttribute("href")).substr(0,5) == "http:" && (a.getAttribute("href").indexOf(this.localhost) == -1)){
			if(a.getAttribute("href").indexOf(location.host) == -1){
//				a.innerHTML = a.innerHTML + "<img src=" + IMAGE_DIR + "'netref.gif' class='noprint' alt=''/><span class='hrefprint'> &lt;" + a.getAttribute("href") + "&gt; </span>";
				a.innerHTML = '<img src="' + IMAGE_DIR + 'arrow.gif" alt="-&gt;" title="' + a.getAttribute("href") + '" />' + a.innerHTML;
			}
		}
	}
}

/** Makes left-top bg image as Pseudo Fixed Link Banner */
STDENV.prototype.pflb = function(){
	var pf, lb, path, subm, myhome;
	if((path = String(location.pathname)) == '/') return;
	(pf = document.createElement("a")).setAttribute('id','pflb');
	myhome = this.findHome(path);
	pf.setAttribute('href',myhome);
	pf.setAttribute('title','To toc page of this group of contents');
	lb = document.createElement("img");
	lb.setAttribute('src',IMAGE_DIR +'top.png');
	lb.setAttribute('alt',' ');
	pf.appendChild(lb);
	this.oAddr.appendChild(pf);
	pf.style.display='block';
	if(this.isMozilla){
		pf.style.position ="fixed";
		if((subm = document.getElementById('smenu1'))) subm.style.position ="fixed";
	}
	this.addlinkelt('up',path.match(/\/$/) ? 
		(myhome == '/works/' ? myhome : '/') : myhome);
}

/** find link destination for pflb(). */
STDENV.prototype.findHome = function(cp){
	if(cp.match(/\/docs\/(html|xml)\//)) return "/docs/htminfo.html";
	if(cp.match(/\/memo\//)) return "/memo/";
	if(cp.match(/\/music\/(mw|perf|cahier|ecrit)/)) return "/music/";
	if(cp.match(/\/(info|test|w3c|art)\//)) return "/";
	if(cp.match(/\/works\/20/)) return "/works/";
	return "./";
}


//-------------------- misc functions --------------------

/** avoid to be included in a frame from outside. */
STDENV.prototype.noframe = function(){
	if(top.frames.length > 0) top.window.location = self.window.location;
}

/** Makes English summary text (class="esum") visible for non Japanese users */
STDENV.prototype.ecomment = function(){
	if(this.usrLang.match(/ja/i)) document.write("<style type='text/css'>.esum {display:none}<\/style>");
}

/* Notify the process in the UA's status bar. Avoid Mozilla conflicts */
STDENV.prototype.notify = function(str){
	if(this.isMozilla) return;
	status = ((str == '') ? defaultStatus : str);
}

//-------------------- public accessible utilities ----------

/**
 * Replace textual representation of mail box with valid address
 * to avoid mail address collector robots.
 */
STDENV.prototype.mailme = function(id){
	if(! id) id = 'webmastermail';
	var o = document.getElementById(id);
	var str = o.innerHTML.replace(/ at /,"<i class='c'> </i>@<i class='c'> </i>");
	str = str.replace(/ dot /g,".");
	str = str.replace("thisdo"+"main",this.creator.fn+"<strong>"+this.creator.mailTld+"</strong>");
	o.innerHTML = str;
	o.setAttribute('href','#'+id);
	o.onmouseover = ge.setmailto;
	o.onfocus = ge.setmailto;
	o.onkeypress = ge.setmailto;
	var s = o.getElementsByTagName('STRONG');
	if(s.length) s[0].onmouseover = ge.setmailto;
}

STDENV.prototype.setmailto = function(ev){
	var o;
	var scheme = String.fromCharCode(109,97,105)+String.fromCharCode(108,116,111,58);
	if(window.event) o = event.srcElement
	else if(ev) o = ev.target;
	if(o.nodeType == 3) o = o.parentNode;
	if(o.nodeName == 'STRONG') o = o.parentNode;
	if(o && o.nodeName == 'A' && o.getAttribute('href').substr(0,7) != scheme){
		o.innerHTML = o.innerHTML.replace(/<i.*?> <\/i>/gi,"");
		o.setAttribute('href',scheme+o.innerHTML.replace(/<.*?>/g,''));
	}
}

/** 
 * Set stylesheet element via script
 * @param	styles : style declarations.
 * @access	public
 */
STDENV.prototype.setstyle = function(styles){
	if(document.createStyleSheet) {
		document.createStyleSheet("javascript:'"+styles+"'");
	}else{
		var ss = document.createElement('link');
		ss.rel = 'stylesheet';
		ss.href = 'data:text/css,'+escape(styles);
		document.documentElement.childNodes[0].appendChild(ss);
	}
}

/** Emulates CSS max-width for UAs that do not support the property */
STDENV.prototype.maxwidth = function(){
	var ad = document.getElementById('ggladr');
	if((x = document.body.clientWidth) > ge.mw.check){
		var dWidth = document.documentElement.clientWidth;
		document.body.style.paddingRight=(document.body.clientWidth - ge.mw.set) + 'px';
		if(dWidth > 0 && document.body.clientWidth > dWidth){
			return;
		}
	}else{
		document.body.style.paddingRight = "3em";
		if(ad) ad.style.display = 'none';
	}
}

/** 
 * Get text from child nodes in DOM.
 * @param	m : target node.
 * @return	text in the node m.
 * @access	public
 */
STDENV.prototype.nodeText = function(m){
	if(typeof(m) != 'object') return m;
	var res='';
	for(var i=0,n=m.childNodes;i<n.length;i++){
		if(n.item(i).nodeType == 3) res += n.item(i).data;
		else if(n.item(i).nodeType == 1) res += this.nodeText(n.item(i));
	}
	res = res.replace(/^\s*/,"");
	return res.replace(/\s*$/,"");
}

/** 
 * Convert 2 digit hex to dicimal number
 * @param	h : 2 digit hex string
 * @return	decimal number
 * @access	public
 */
STDENV.prototype.h2d = function(h){
	return ("0123456789abcdef".indexOf(h.charAt(1),0) + "0123456789abcdef".indexOf(h.charAt(0),0) * 16);
}

STDENV.prototype.about = function(o,type){
	if(o == 'all'){
		var res = '';
		for(var obj in window){
			if(obj == 'top') break;
			try{
			if(window[obj].prototype && window[obj].prototype.meta)
				res += _get_meta(window[obj].prototype.meta,'vt') + "\n";
			}catch(e){
				break;
			}
		}
		return res;
	}else{
		var meta = o ? (o.meta ? o.meta : o.prototype.meta) : this.meta;
		return _get_meta(meta,type);
	}
	
	function _get_meta(meta,type){
		return type == 'v' ?
		"ver " + meta.release.revision + ", " + meta.release.created :
		(type == 'vt' ? meta.title + " (ver " + meta.release.revision + ", " + meta.release.created + ")" :
		meta.title + "\noriginal: "+meta.created + "\nmodified: " + meta.release.created + " (ver " + meta.release.revision + ")" );
	}
};



/** preparation of popup TOC on init() */
STDENV.prototype.preptoc = function(){
	var lis;
	if(this.isMacIE) return;// || this.isIcab
	this.notify('prepating pop toc ...');
	if((lis = this.prepHdngs(document.getElementsByTagName('H2'),
		this.getTocList("div"))))
			this.genTocDiv(lis);
}

/** check if the page has elements to be used as TOC */
STDENV.prototype.getTocList = function(tagName){
	var toc, tocl = document.getElementsByTagName(tagName);
	for(var i=0, n=tocl.length; i<n; i++){
//		if(tocl.item(i).className == "toc") {toc = tocl.item(i); break;}
		if(tocl.item(i).className == "contents") {toc = tocl.item(i); break;}
	}
	return toc;
}

STDENV.prototype.prepHdngs = function(hd, pageToc){
	var x, xid, lis, n;
//	var ptocImg = " <img src='/parts/ptoc.gif' class='tocpic' title='Table of Contents of this page' alt='' />";
	var ptocImg = " <img src='" + IMAGE_DIR + "toc.png' class='tocpic' title='Table of Contents of this page' alt='' />";
	var ptocMsg = "Click heading, and Table of Contents will pop up";
	var numH2 = hd.length;
	if(pageToc){
		for(var i = ge.isHome ? 3 : 0; i<numH2; i++){
			x = hd.item(i);
			xid = x.getAttribute("id") ? x.getAttribute("id") :
				(x.firstChild.getAttribute ?
					x.firstChild.getAttribute("id") : '');
			if(! xid) x.setAttribute("id",(xid = "_genid_"+i));
			this.prepHd(x, xid ,i, ptocImg, ptocMsg);
		}
		hd = document.getElementsByTagName('H3');
		for(i=0, n=hd.length; i<n; i++){
			x = hd.item(i);
			if(x.getAttribute("id") || x.firstChild.nodeName=="A")
				x.innerHTML += ptocImg;
		}
		lis = pageToc.innerHTML;
		
		
	}else if(numH2 > 1){
		lis = this.genPseudoToc(hd, ptocImg, ptocMsg);
	}else if(numH2 == 0 && (hd = document.getElementsByTagName('DT')).length > 2){
		lis = this.genPseudoToc(hd, ptocImg, ptocMsg);
	}
	return lis;
}

/** generate TOC from specified elements */
STDENV.prototype.genPseudoToc = function(hd, ptocImg, ptocMsg){
	var x, xid, lis = "";
	for(var i=0, n=hd.length; i<n; i++){
		x = hd.item(i);
		if(x.firstChild.getAttribute && x.firstChild.getAttribute("id"))
			xid = x.firstChild.getAttribute("id");
		else if(x.getAttribute("id"))
			xid = x.getAttribute("id");
		else
			x.setAttribute("id",(xid = "_genid_"+i));
		lis += '<li><a href="#' + xid + '" onclick="new Effect.ScrollTo(\'' + xid + '\',{offset:-140}); return false;">' + this.nodeText(x) + "</a></li>";
		this.prepHd(x, xid, i, ptocImg, ptocMsg);
	}
	return lis;
}

//-- set up each TOC item ----------

STDENV.prototype.prepHd = function(heading, xid, i, ptocImg, ptocMsg){
	heading.innerHTML += ptocImg;
	heading.setAttribute("title",ptocMsg);
	if(xid) this.nkeylink[i+1] = xid;
}

/** generate the popup TOC division */
STDENV.prototype.genTocDiv = function(lis){
	(this.toc = document.createElement("div")).setAttribute("id","poptoc");
	this.toc.appendChild(document.createTextNode(" "));
	this.toc.innerHTML = this.oH1 ?
		"<h2><a href='#" + this.topid + "'>"
		+ this.oH1.innerHTML.replace(/<img.*alt=\"([^\"]+)\"[^>]*>/i,"$1") + "</a><span class='c'> [TOC]</span></h2>" :
		"<h2><a href='#'>Page Top</a><span class='c'> [TOC]</span></h2>";
	this.toc.innerHTML += '<ol style="padding-left:16px;margin-left:16px">'
		+ lis.replace(/href/g,"tabindex='1' href") + "</ol>"
		+ this.getNaviLink() + "</div>";
//		+ this.getNaviLink() + "<div class='nav'><a tabindex='1' href='/'>Home page</a> - "
//		+ "<a tabindex='1' href='/info/navi'>Help &amp; search</a></div>";
	document.body.appendChild(this.toc);
	window.document.onclick = this.popToc;
	this.calcObj(this.toc,300);
//	this.oAddr.innerHTML = "<img src='/parts/ptoc.gif' class='tocpic' style='float:right'/>" + this.oAddr.innerHTML;
	this.oAddr.innerHTML = "<img src='" + IMAGE_DIR + "toc.png' class='tocpic' style='float:right'/>" + this.oAddr.innerHTML;
}

/** if the page has prev/next link(s)... */
STDENV.prototype.getNaviLink = function(){
	var navi="";

	if(this.prev){
		navi += "&lt;&lt; <a href='" + this.prev + "' title='" + this.prev_title + "' accesskey=','>Prev page</a>";
	}else{
		navi += "<span style='color:gray'>&lt;&lt; Prev page</span>";
	}
	navi += " | ";
	if(this.up){
		navi += "<a href='" + this.up + "' title='" + this.up_title + "' accesskey='u'>Up</a>";
	}else{
		navi += "<span style='color:gray'>Up</span>";
	}
	navi += " | ";
	if(this.next){
		navi += "<a href='" + this.next + "' title='" + this.next_title + "' accesskey='.'>Next page</a> &gt;&gt;<br />";
	}else{
		navi += "<span style='color:gray'>Next page &gt;&gt;</span><br >";
	}
	navi += "[ ";
	if(this.home){
		navi += "<a href='" + this.home + "' title='" + this.home_title + "' accesskey='h'>Home</a>";
	}else{
		navi += "<span style='color:gray'>Home</span>";
	}
	navi += " | ";
	if(this.index){
		navi += "<a href='" + this.index + "' title='" + this.index_title + "' accesskey='i'>Index</a>";
	}else{
		navi += "<span style='color:gray'>Index</span>";
	}
	navi += " | ";
	if(this.search){
		navi += "<a href='" + this.search + " 'title='" + this.search_title + "' accesskey='s'>Search</a>";
	}else{
		navi += "<span style='color:gray'>Search</span>";
	}
	navi += " | ";
	if(this.help){
		navi += "<a href='" + this.help + "' title='" + this.help_title + "' accesskey='h'>Help</a>";
	}else{
		navi += "<span style='color:gray'>Help</span>";
	}
	navi += " ]";
	return (navi ?  "<p class='nav'>" + navi + "</p>" : "");
}

/** determin the size of popup TOC */
STDENV.prototype.calcObj = function(o, maxw){
	this.notify('prepating toc size ...'); // test
	var orgX = self.pageXOffset;
	var orgY = self.pageYOffset;
	o.style.visibility = "hidden";
	o.style.display = "block";
	o.width = o.offsetWidth;
	if(o.width > maxw){
		o.width = maxw;
		o.style.width = maxw + "px";
	}
	o.height = o.offsetHeight;
	o.style.display = "none";
	o.style.visibility = "visible";
	if(orgY) scroll(orgX,orgY);
}

//-- click event handlers ----
/** Show/hide TOC on click event according to its location */
STDENV.prototype.popToc = function(ev){
	var tg,tgn;
	if(window.event){
		ev = event; tg = ev.srcElement;
	}else if(ev){
		tg = ev.target;
	}

	if(ev.altKey) _dispToc(ev,tg,0);
	else if(tg.className=='tocpic' || tg.className=='snum') _dispToc(ev,tg,2);
	else{
			_hideToc();
		
		
		var dv = document.defaultView;
		var x = tg, mp="";
	}
}


STDENV.prototype.setCurPos = function(tg,type){
	var tid = (type==1) ? tg.getAttribute("id") :
		(tg.parentNode.getAttribute("id") ? tg.parentNode.getAttribute("id") :
			(tg.parentNode.firstChild.getAttribute ? tg.parentNode.firstChild.getAttribute("id") :''));
	if(tid) _hiliteHd(tid);
}



/** warning for copy */
STDENV.prototype.isvalid = function(){
	var navi, adr, status, sideimg, notice;
	if(this.localhost != "-1") return 1;
	notice = "For archive/cache only. This copy may not be the latest version of this content.";
	status = 'a copy of ';
	if((navi = document.getElementById("banner"))){
		navi.innerHTML += "<p class='note' style='font-weight:normal; font-size:100%'>" + notice + "</p>";
	}
	
	adr = document.getElementsByTagName("address").item(0);
	adr.innerHTML = adr.innerHTML.replace(/This is/,'This is <strong class="hot">' + status + '</strong> ');
	
	return -1;
}

/** Generates hcard info for experiment.
 * Document.write here in order to be recognized by plugins
 * that parses data before onload() event. */
STDENV.prototype.genvc = function (){
	var st='', et='';
	if(this.creator.email){
		st = "<a href='" + ge.creator.email + "' class='email'>";
		et = "</a>";
	}
	document.write(" by <span class='vcard'>"+st+"<span class='fn'>"+this.creator.name+"</span>"+et+", <span class='title'>a bassist</span>, <span class='adr'><span class='region'>Tokyo</span>,<span class='country-name'>Japan</span><a href='/' class='url'><img class='photo' src='/info/masakabas-s.gif' alt='' / ></a></span></span>");
}


}
//-- - end of STDENV object -


// separated from STDENV due to some problems ...

/** display on mouseclick */
function _dispToc(ev,tg,type){
	var doc = new eventDocPos(ev);
	var scr = new eventScrPos(ev);
	if(scr.h < ge.toc.height){
		ge.toc.style.height = scr.h + "px";
		ge.toc.style.overflow = "auto";
		ge.toc.style.top = (doc.y - scr.y) + "px";
	}else{
		ge.toc.style.height = ge.toc.height + "px";
		ge.toc.style.top = ((scr.h - scr.y > ge.toc.height) ? doc.y + "px" :
			((scr.y > ge.toc.height) ? (doc.y - ge.toc.height) + "px" :
				((scr.y < scr.h/2) ? (doc.y - scr.y) + "px" :
					(doc.y + scr.h - scr.y - ge.toc.height) + "px")));
	}
	ge.toc.style.left = ((scr.x < scr.w - ge.toc.width) ? doc.x + "px" :
		(doc.x - ge.toc.width) + "px");
	if(type) ge.setCurPos(tg,type);
	ge.toc.style.display = "block";
}

/** display on kbd request */
function _dispTocKey(ev){
	ge.toc.style.top = ((document.body.scrollTop + document.documentElement.scrollTop) | self.pageYOffset) + "px";
	ge.toc.style.left = 0;
	ge.toc.style.display = "block";
}

/** hilite current heading */
function _hiliteHd(tid){
	var pat = "#" + tid + "\"";
	var rep = pat + " class=\"here\"";
	ge.toc.innerHTML = ge.toc.innerHTML.replace(pat,rep);
}

/** close TOC and clear hilite */
function _hideToc(){
	ge.toc.style.display = "none"
	ge.toc.innerHTML = ge.toc.innerHTML.replace(/ class=\"?here\"?/,"");
}

/** keyboard event handler */
function _procKey(e){
	var key, kl, tg;
	if(e){
		key = e.which; tg = e.target;
	}else{
		key = event.keyCode; tg = event.srcElement;
	}
	if(tg.nodeName.match(/(INPUT|TEXTAREA)/i)) return true;
	kl = String.fromCharCode(key).toLowerCase();
	if(kl == '?'){
		if(location.href.indexOf("/info/navi") == -1){
			if(confirm("Go to help/search page ?"))
				location.href= "/info/navi";
		}else
			alert("This key should bring you our help, i.e. this page :-)");
		return false;
	}else if(ge.toc && ge.toc.style){
		if(ge.toc.style.display == 'block'){
			if(key == 27 || key == 47) _hideToc(); //Esc, slash
			else if(key >= 48 && key <=57){ //0-9
				key -= 48;
				if(ge.nkeylink[key]){
					location.href = "#" + ge.nkeylink[key];
					_hideToc();
				}
			}
		}else{
			if(key == 47) _dispTocKey();
		}
	}
	return true;
}


/**
 * Get event coordinates relative to current document
 * @access : public
 * @param	e : event
 * @return	the coordinates as Object
 */
function eventDocPos(e){
	if(ge.isOpera){
		this.x = e.clientX + document.body.scrollLeft;
		this.y = e.clientY + document.body.scrollTop;
	}else if(ge.isIE){// if(e.x){
		this.x = e.x + document.body.scrollLeft + document.documentElement.scrollLeft;
		this.y = e.y + document.body.scrollTop + document.documentElement.scrollTop;
	}else{
		this.x = e.pageX;
		this.y = e.pageY;
	}
	return this;
}

/**
 * Get event coordinates relative to the screen
 * @access : public
 * @param	e : event
 * @return	the coordinates as Object
 */
function eventScrPos(e){
	if(ge.isOpera){
		this.x = e.clientX;
		this.y = e.clientY;
		this.w = document.body.clientWidth;
		this.h = document.body.clientHeight;
	}else if(ge.isIE){//if(e.x){
		this.x = e.x;
		this.y = e.y;
		this.w = document.body.clientWidth;
		this.h = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
	}else if(ge.isSafari){
		this.x = e.screenX;
		this.y = self.innerHeight - self.screenY - e.screenY; //Safari doesn't seem to have location relative to current window. Tricky but Safari's screenY counts form the bottom of the screen (or window)
		this.w = self.innerWidth;
		this.h = self.innerHeight;
	}else{
		this.x = e.clientX;
		this.y = e.clientY;
		this.w = self.innerWidth;
		this.h = self.innerHeight;
	}
	return this;
}


/** experimant to show google ads on right most side of large window */
function maxwindowad(){
	var threshold = ge.mw.check > 1024 ? ge.mw.check : 1024;
	var ad = document.getElementById('ggladr');
	if(document.body.clientWidth > threshold && location.pathname.indexOf('/edu/') == -1){
		window.onresize = ge.maxwidth;
		ge.maxwidth();
	}else{
		document.write('<!-- ' + document.body.clientWidth + ' -->');
		if(ad){
			ad.style.display = 'none';
		}
		if(ge.isIE) {window.onresize = ge.maxwidth;ge.maxwidth();}
	}

}

//var __kanzaki_onload_save = window.onload;
//window.onload = function() {
//	if (__kanzaki_onload_save) __kanzaki_onload_save();
//	init();
//}

FastInit.addOnLoad(init);