//  ========================================================
//  tlab-recommend.js ---- recommend view class
//  Copyright 2008 TEAM-LAB
//  ========================================================

/*************************************************************
//sample
<html>
<head>
<script type="text/javascript" src="http://honda.teamlab-recommend.jp/js/tlab-recommend.js"></script>
</head>
<body>
	<div id="hogehoge"></div>
	<script>(new TLAB.JSImport("honda.teamlab-recommend.jp", "hogehoge")).loadScript();</script>
</body>
</html>
*************************************************************/

if ( typeof(TLAB) == 'undefined' ) TLAB = function() {};

TLAB.JSImport = function (host, elem) {
	var ts = (new Date()).getTime();

	if(window.location.hostname != 'www.honda.co.jp'){
		var colledurl = escape('http://www.honda.co.jp' + window.location.pathname);
		this.jsurl = "http://" + host + "/recommend.js?staging=true&elem=" + elem + "&colledurl=" + colledurl + "&ts=" + ts;
	}else{
		var colledurl = escape(window.location.protocol + '//' + window.location.host + window.location.pathname);
		this.jsurl = window.location.protocol + "//" + host + "/recommend.js?elem=" + elem + "&colledurl=" + colledurl + "&ts=" + ts;
	}
	this.elem = elem;
	return this;
}

TLAB.JSImport.prototype.loadScript = function () {
	var jsElement=document.createElement("script");
	jsElement.type="text/javascript";
	jsElement.src=this.jsurl;
	jsElement.characterSet="Shift_JIS";
	document.getElementById(this.elem).appendChild(jsElement);
}

TLAB.displayCheck = function () {
	this.curDir_ary = location.pathname.split('/');
	return this;
}
TLAB.displayCheck.prototype.recommendDisplay = function () {
	
	if(this.curDir_ary[1].toLowerCase() == 'fit'){
		return false;
	}else if(
		this.curDir_ary[1].toLowerCase() == 'usersvoice' &&
		this.curDir_ary[2].toLowerCase() == 'fit'
	){
		return false;
	}else if(
		this.curDir_ary[1].toLowerCase() == 'familymeeting' &&
		this.curDir_ary[2].toLowerCase() == 'fit'
	){
		return false;

	}else{
		return true;
	}
	
	return false;
}
if(
	(
		new TLAB.displayCheck()
	).recommendDisplay()
){
	document.write('<div id="tlab-recommendation"></div>');
	(new TLAB.JSImport("honda.teamlab-recommend.jp", "tlab-recommendation")).loadScript();
}

