/************************************************
 Traffic Confusion情報クラス		2008-05-30変
************************************************/
/*---------------------------
 コンストラクタ
	input:	uid..ユーザID
---------------------------*/
var	tc2class = function(uid){
	// アプリケーションURLの作成
	this.ClickOnceApplication = "http://xima.jp/exe/tc2/bin/TrafficConfusion.application?UID=" + uid;
}

/*---------------------------
 リンクURLの獲得
	return:	.NetFrameworkのインストール状況に応じ、
			アプリケーションURL or .NetFrameworkインストールURLのどちらかを返す
---------------------------*/
tc2class.prototype.GetURL = function(){
	if( this.Framework() )	return(this.ClickOnceApplication);
	return("http://xima.jp/exe/tc2/bin/setup.exe");
}

/*---------------------------
 アプリケーションURLの獲得
	return:	アプリケーションURL
---------------------------*/
tc2class.prototype.GetApplicationURL = function(){
	return(this.ClickOnceApplication);
}
/*---------------------------
 .NetFrameworkインストールURLの獲得
	return:	.NetFrameworkのインストールURL
---------------------------*/
tc2class.prototype.GetSetupURL = function(){
	return("http://xima.jp/exe/tc2/bin/setup.exe");
}

/*---------------------------
 .NetFrameworkのインストール状況確認
	return:	結果(true= インストール済, false= 未インストール)
---------------------------*/
tc2class.prototype.Framework = function(){
var	va = this.GetVersion("2.0.0");
var	i;
var	a = navigator.userAgent.match(/\.NET CLR [0-9.]+/g);
	if(a != null){
		for(i = 0; i < a.length; i++){
			if(this.CompareVersions(va, this.GetVersion(a[i])) <= 0)	return true;
		}
	}
	return false;
}

/*-------------------------------------
 (以下、内部サブルーチン)
-------------------------------------*/
/*---------------------------
 .NetFrameworkのバージョン比較
---------------------------*/
tc2class.prototype.CompareVersions = function(v1, v2){
	for (i = 0; i < v1.length; i++){
		var n1 = new Number(v1[i]);
		var n2 = new Number(v2[i]);

		if(n1 < n2)	return -1;
		if(n1 > n2)	return  1;
	}
	return 0;
}
/*---------------------------
 バージョン(数字部分)の獲得
---------------------------*/
tc2class.prototype.GetVersion = function(v){
var	a = v.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/i);
	return a.slice(1);
}
