//  ========================================================
//  tlab-beacon.js ---- beacon tag class
//  Copyright 2008 TEAM-LAB
//  ========================================================

/*************************************************************
//sumple
<html>
<head>
<script type="text/javascript" src="http://www.teamlab-recommend.jp/otto/js/tlab-beacon.js"></script>
</head>
<body>
    <div id="beacon_divid"></div>
    <script>(new TLAB.Beacon("beacon_divid", "item10")).sendRequest();</script>
</body>
</html>
*************************************************************/


if ( typeof(TLAB) == 'undefined' ) TLAB = function() {};

TLAB.Beacon = function (arg1, arg2) {
	this.divtag = arg1;
	this.itemid = escape(arg2);
	var getparams = TLAB.getRequest();
	this.previdParam = getparams["rcount"] == undefined ?"":"&clickItemId="+getparams["rcount"];
	this.prevTypeParam = getparams["rtype"] == undefined?"":"&clickPageId="+getparams["rtype"];
	this.url = "http://wwwt.teamlab-recommend.jp/otto/beacon.gif?item=" + this.itemid + this.previdParam + this.prevTypeParam;
	return this;
}
TLAB.getRequest = function(){
	var r = new Object();
	var pathName = location.pathname + location.search;
	var pathName_ary = pathName.split('/');
	
	if(pathName_ary.length > 1){
		var getParam = pathName_ary;
		for(var i = 0 ;i< getParam.length ; i++){
			if(getParam[i] == "rcount"){
				r["rcount"]=getParam[i+1];
			} else if(getParam[i] == "rtype"){
				r["rtype"]=getParam[i+1];
			}
		}
	}
	
	return r;
}

TLAB.Beacon.prototype.sendRequest = function () {
	document.getElementById(this.divtag).innerHTML = "<img src='" + this.url + "'>";
}





if ( typeof(TLAB2) == 'undefined' ) TLAB2 = function() {};

TLAB2.Beacon = function (arg1, arg2) {
	this.divtag = arg1;
	this.itemid = escape(arg2);
	var getparams = TLAB2.getRequest();
	this.previdParam = getparams["rcount"] == undefined ?"":"&clickItemId="+getparams["rcount"];
	this.prevTypeParam = getparams["rtype"] == undefined?"":"&clickPageId="+getparams["rtype"];
	this.url = "http://wwwt.teamlab-recommend.jp/otto2/beacon.gif?item=" + this.itemid + this.previdParam + this.prevTypeParam;
	return this;
}
TLAB2.getRequest = function(){
	var r = new Object();
	var pathName = location.pathname + location.search;
	var pathName_ary = pathName.split('/');
	
	if(pathName_ary.length > 1){
		var getParam = pathName_ary;
		for(var i = 0 ;i< getParam.length ; i++){
			if(getParam[i] == "rcount"){
				r["rcount"]=getParam[i+1];
			} else if(getParam[i] == "rtype"){
				r["rtype"]=getParam[i+1];
			}
		}
	}
	
	return r;
}

TLAB2.Beacon.prototype.sendRequest = function () {
	document.getElementById(this.divtag).innerHTML = "<img src='" + this.url + "'>";
}
