/*
※埋め込みスクリプト例
<script
	language="javascript"
	src="***.js"
	title="スクリプトタイトル"	ページのタイトルよりも優先される
	id | name="analyzerjs"		固定値
></script>
*/
function xDef() {
	for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
	return true;
}
function xCreateElement(sTag) {
  if (document.createElement) return document.createElement(sTag);
  else return null;
}
function xGetElementById(e) {
	if (e==null) return e;
	else if (document.all) return document.all[e];
	else if (document.getElementById) return document.getElementById(e);
	else return null;
}
function xGetElementsByName(e) {
	if (e==null) return e;
	else if (document.all) return document.all[e];
	else if (document.getElementsByName) return document.getElementsByName(e);
	else return null;
}
function xGetElementsByTagName(t,p) {
	var list = null;
	t = t || '*';
	p = xGetElementById(p) || document;
	if (typeof p.getElementsByTagName != 'undefined') { // DOM1
		list = p.getElementsByTagName(t);
		if (t=='*' && (!list || !list.length)) list = p.all; // IE5 '*' bug
	}
	else { // IE4 object model
		if (t=='*') list = p.all;
		else if (p.all && p.all.tags) list = p.all.tags(t);
	}
	return list || [];
}
function getScriptTitle() {
	var e = xGetElementById("analyzerjs");
	if (!e) {
		e = xGetElementsByName("analyzerjs");
		if (e) {
			e = e[0];
		}
	}
	if (e == null) {
		e = xGetElementsByName("analyzerjs");
		if (e != null) e = e[0];
	}
	if (e != null) {
		return e.title;
	}
}
function selectTitle() {
	var s = getScriptTitle();
	if (s != null && s.length > 0) return s;
	return document.title;
}
function isChild(w) {
	if(w == w.parent) return false;
	if(w.document.referrer == w.parent.document.location.href) return true;
	return false;
}
function getReferrer(w) {
	if (!isChild(w)) {
		// トップ
		return w.document.referrer;
	} else {
		// 自分の親を指定する
		return getReferrer(w.parent);
	}
}
function encode(str){
	if(str==null) return "";
    var val;
    var i;
    var s;
    var u;
    val = "";
    for(i=0;i<str.length;i++) {
        s = str.charAt(i);
        u = str.charCodeAt(i);
        if(s==" ") {
        	val += "+";
        } else {
            if(u==0x2a||u==0x2d||u==0x2e||u==0x5f||((u>=0x30)&&(u<=0x39))
            	||((u>=0x41)&&(u<=0x5a))||((u>=0x61)&&(u<=0x7a))) { 
                val = val + s;
            } else {
                if((u>=0x0)&&(u<=0x7f)) {
                    s = "0"+u.toString(16);
                    val += "%"+ s.substr(s.length-2);
                } else if(u>0x1fffff) {
                    val += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
                    val += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
                    val += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    val += "%" + (0x80 + (u & 0x3f)).toString(16);
                } else if(u>0x7ff) {
                    val += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
                    val += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    val += "%" + (0x80 + (u & 0x3f)).toString(16);
                } else {
                    val += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
                    val += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
            }
        }
    }
    return val;
}
// 解析
var title		= selectTitle();
var href		= document.location.href;
var referrer	= getReferrer(window);
var server		= "http://www.johospace.net/accana/";
var src 		= server + "access?" +
	encode(title)+","+encode(href)+","+encode(referrer);
document.open();
document.write("<script type=\"text/javascript\" src=\"" + src + "\"></script>");
document.close();
