//Frame Free Web Player PluginがインストールされていればIsPluginをtrueにセットする
var IsPlugin=false;
var BrowserType;

function detectFFPLug(){
	getBrowserType();
	if (BrowserType == "Macintosh") {
		IsPlugin = detectPlugin('FrameFree Web Player for Mac-5'); // ID=5
	} else if (BrowserType == "Mozilla") {
		IsPlugin = detectPlugin('FrameFree Web Player for Mozilla Win-5'); // ID=5
	} else if (BrowserType == "MSIE") {
		IsPlugin = detectActiveX('FFPREVIEWER_AX_L.ffpreviewer_ax_lCtrl.5'); // ID=5
	}
}

function detectPlugin(obj) {
	var i;
	var plugins = window.navigator.plugins;
	for (i = 0; i < plugins.length; i++) {
		if (plugins[i].name == obj) {
			return true;
		}
	}
	return false;
}

function detectActiveX(obj) {
	try {
		var pluginName = obj;
		var testObj = new ActiveXObject(pluginName);
		if (testObj) {
			return true;
		} else {
			return false;
		}
	} catch(e) {
		return false;
	}
}

//ブラウザ種類を検出
//@param OS OSタイプ('Windows' , 'Macintosh')
function getBrowserType() {
	var winNav = window.navigator;
	var OS;
	var index;
	var verno;
	if (winNav.userAgent.indexOf('Windows') != -1) {
		OS = 'Windows';
	} else if (winNav.userAgent.indexOf('Macintosh') != -1) {
		OS = 'Macintosh';
	}
	if (winNav.userAgent.indexOf('Safari/') != -1) {
		// Safari
		if (OS == "Macintosh") {
			BrowserType = "Macintosh";
		}
	} else if ((index = winNav.userAgent.indexOf('Opera')) != -1) {
		//Opera
		verno = parseInt(winNav.userAgent.substr(index+6,3));
		if (OS == 'Windows' && verno> 7) {
			BrowserType = "Mozilla";
		}
	} else if (winNav.userAgent.indexOf('Firefox/') != -1) {
		// Firefox
		if (OS == 'Windows') {
			BrowserType = "Mozilla";
		}
	} else if ((index = winNav.userAgent.indexOf('MSIE ')) != -1) {
		// Microsoft Internet Explorer
		verno = parseInt(winNav.userAgent.substr(index+5,3));
		// Support MSIE 6.X and 7.X on Windows
		if (OS == 'Windows' && verno > 5) {
			BrowserType = "MSIE";
		}
	} else if ((index = winNav.userAgent.indexOf('Netscape/')) != -1) {
		// Netscape
		verno = parseInt(winNav.userAgent.substr(index+9,3));
		if (OS == "Windows" && verno > 7) {
			BrowserType = "Mozilla";
		}
	} else if ((index = winNav.userAgent.indexOf('Gecko/')) != -1) {
		// Gecko
		var dateno = parseInt(winNav.userAgent.substr(index+6,4));
		if (OS == "Windows" && dateno > 2003) {
			BrowserType = "Mozilla";
		}
	}
}

detectFFPLug();
