//  ========================================================
//  tlab-beacon.js ---- beacon tag class
//  Copyright 2008 TEAM-LAB
//  ========================================================

/*************************************************************
//sumple
<html>
<head>
<script type="text/javascript" src="http://www.teamlab-recommend.jp/musashiya/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://www.teamlab-recommend.jp/musashiya/beacon.gif?item=" + this.itemid + this.previdParam + this.prevTypeParam;
	return this;
}
TLAB.getRequest = function(){
	var r = new Object();
	if(location.search.length > 1){
		var getParam = location.search.substring(1).split("&")
		for(var i = 0 ;i< getParam.length ; i++){
			var work = getParam[i].split("=");
			if(work.length==2){
				r[work[0]]=work[1];
			}
		}
	}
	return r;
}


TLAB.Beacon.prototype.sendRequest = function () {
	document.getElementById(this.divtag).innerHTML = "<img src='" + this.url + "'>";
}

