document.write("<div style='text-align:center' class='sb-frame'>");
document.write(
 "<script type='text/javascript'>"
+"var _info = navigator.userAgent;"
+"var _ns = false;"
+"var _ns6 = false;"
+"var _ie = (_info.indexOf('MSIE') > 0 && _info.indexOf('Win') > 0 && _info.indexOf('Windows 3.1') < 0);"
+"</sc"+"ript>"
+"<comment>"
+"<sc"+"ript language='JavaScript1.1'>"
+"var _ns = (navigator.appName.indexOf('Netscape') >= 0 && ((_info.indexOf('Win') > 0 && _info.indexOf('Win16') < 0 && java.lang.System.getProperty('os.version').indexOf('3.5') < 0) || (_info.indexOf('Sun') > 0) || (_info.indexOf('Linux') > 0) || (_info.indexOf('AIX') > 0) || (_info.indexOf('OS/2') > 0) || (_info.indexOf('IRIX') > 0)));"
+"var _ns6 = ((_ns == true) && (_info.indexOf('Mozilla/5') >= 0));"
+"</sc"+"ript>"
+"</comment>"
+"<sc"+"ript type='text/javascript'>"
+"if (_ie == true) document.write(\"<object id='sidebarApp' classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93' width='154' height='210' codebase='http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0'><noembed><xmp>\");"
+"else if (_ns == true && _ns6 == false) document.write(\"<embed id='sidebarApp' type='application/x-java-applet;version=1.4' code='jp.qute.s.client.F' java_codebase='http://sidebar.jp/app/' archive='s.jar' width='154' height='210' userid='"+userid+"' scriptable='true' pluginspage='http://java.sun.com/products/plugin/index.html#download'><noembed><xmp>\");"
+"</sc"+"ript>"
+"<applet id='sidebarApp' code='jp.qute.s.client.F' java_codebase='http://sidebar.jp/app/' archive='s.jar' width='154' height='210'></xmp>"
+"  <param name='userid' value='"+userid+"' />"
+"  <param name='code' value='jp.qute.s.client.F' />"
+"  <param name='codebase' value='http://sidebar.jp/app/' />"
+"  <param name='archive' value='s.jar' />"
+"  <param name='type' value='application/x-java-applet;version=1.4' />"
+"  <param name='scriptable' value='true' />"
+"  <param name='boxmessage' value='' />"
+"</applet>"
+"</noembed>"
+"</embed>"
+"</object>"
);
document.write("</div>");

document.write("<div style='text-align:center' class='sb-powered'>Powered by <a href='http://sidebar.jp/' title='サイドバー.jp'><img src='http://sidebar.jp/app/images/banner.gif' alt='サイドバー.jp' style='border:none;vertical-align:middle' /></a></div>");


var referrer = document.referrer;
try {
  if (referrer == parent.document.URL) referrer = top.document.referrer;
} catch (e) {}
var title = document.title;
if (typeof(editTitle) == "function") title = editTitle(title); else title = defEditTitle(title);
document.write("<script type='text/javascript' src='http://sidebar.jp/app/js/Record.do?noout=t&id="+userid+"&url="+encodeURL(document.URL)+"&referrer="+encodeURL(referrer)+"&title="+encodeURL(title)+"' charset='UTF-8'></scr"+"ipt>");

function defEditTitle(title) {
	if (title.match(/[：:]\s*/)) return RegExp.rightContext;
	return title;
}


// thanks a lot
// http://www.cresc.co.jp/tech/java/URLencoding/JavaScript_URLEncoding.htm
/*	Function Equivalent to java.net.URLEncoder.encode(String, "UTF-8")
	Copyright (C) 2002, Cresc Corp.
	Version: 1.0
*/
function encodeURL(str) {
	if (!str) return "";
	var s0, i, s, u;
	s0 = "";				// encoded str
	for (i = 0; i < str.length; i++){	// scan the source
		s = str.charAt(i);
		u = str.charCodeAt(i);			// get unicode of the char
		if (s == " "){s0 += "+";}		// SP should be converted to "+"
		else {
			if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){ 	  // check for escape
				s0 = s0 + s;			// don't escape
			}
			else {					// escape
				if ((u >= 0x0) && (u <= 0x7f)){ 	// single byte format
					s = "0"+u.toString(16);
					s0 += "%"+ s.substr(s.length-2);
				}
				else if (u > 0x1fffff){ 	// quaternary byte format (extended)
					s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
					s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
					s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
				else if (u > 0x7ff){		// triple byte format
					s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
					s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
				else {						// double byte format
					s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
			}
		}
	}
	return s0;
}
