/**
 * クライアントの環境を調べる為のクラスです
 *
 *
 * @access public
 * @author Jigorou Masuda    
 */
function ClientNavigator() {
}

// prototypeプロパティの生成
new ClientNavigator();

/**
 * OSがWindowsかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isWinOS = (navigator.platform.indexOf("Win") != -1);

/**
 * OSがMacintoshかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isMacOS = (navigator.platform.indexOf("Mac") != -1);

/**
 * OSがSunOSかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isSunOS = (navigator.platform.indexOf("SunOS") != -1);

/**
 * OSがLinuxかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isLinux = (navigator.platform.indexOf("Linux") != -1);

/**
 * OSがFreeBSDかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */	
ClientNavigator.prototype._isFreeBSD = (navigator.platform.indexOf("FreeBSD") != -1);

/**
 * OSがIRIXかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isIRIX = (navigator.platform.indexOf("IRIX") != -1);

/**
 * OSがBeOSかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isBeOS = (navigator.platform.indexOf("BeOS") != -1);

/**
 * OSがRISC(TRON)かどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isRISC = (navigator.platform.indexOf("RISC") != -1);

/**
 * OSがDreamCastかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isDC = (navigator.platform.indexOf("Dreamcast") != -1);

/**
 * OSがPlayStationかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isPS = (navigator.platform.indexOf("NFPS") != -1 || navigator.platform.indexOf("PlanetWeb") != -1);

/**
 * ブラウザがIEかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isIE = (navigator.appName == "Microsoft Internet Explorer" &&
						 navigator.userAgent.indexOf("Opera") == -1);

/**
 * ブラウザがNNかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isNN = (navigator.appName == "Netscape" && 
						 ((parseInt(navigator.appVersion) <= 4 && parseInt(navigator.appVersion) > 2) ||
						  navigator.userAgent.indexOf("Netscape6") != -1 ||
						  navigator.userAgent.indexOf("Netscape/7.0") != -1));

/**
 * ブラウザがMozilaかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isMozila = (navigator.appName == "Netscape" && 
							 navigator.userAgent.indexOf("Gecko") != -1 &&
							 navigator.userAgent.indexOf("Netscape") == -1);

/**
 * ブラウザがOperaかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isOpera = (navigator.userAgent.indexOf("Opera") != -1);

/**
 * ブラウザがSafariかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isSafari = (navigator.appName == "Netscape" &&
							 navigator.userAgent.indexOf("Safari") != -1);

/**
 * ブラウザがiCabかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isiCab = (navigator.appName == "iCab");

/**
 * ブラウザがKonquerorかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isKonqueror = (navigator.appName == "Konqueror");

/**
 * ブラウザがNetFrontかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isNetFront = (navigator.appName == "NetFront");;

/**
 * ブラウザがEGBrowserかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isEGBrowser = (navigator.appCodeName == "Planetweb");

/**
 * ブラウザがDreamPassportかどうかの真偽値
 *
 *
 * @access private
 * @var    bool
 */
ClientNavigator.prototype._isDreamPassport = (navigator.appVersion.indexOf("DreamPassport") != -1);

/**
 * OSがWindowsかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         WindowsであればTRUE
 */
ClientNavigator.prototype.isWinOS = function () {
	return (this._isWinOS);
};

/**
 * OSがMacintoshかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         MacintoshであればTRUE
 */
ClientNavigator.prototype.isMacOS = function () {
	return (this._isMacOS);
};

/**
 * OSがSun OSかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         Sun OSであればTRUE
 */
ClientNavigator.prototype.isSunOS = function () {
	return (this._isSunOS);
};

/**
 * OSがLinuxかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         LinuxであればTRUE
 */
ClientNavigator.prototype.isLinux = function () {
	return (this._isLinux);
};

/**
 * OSがFreeBSDかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         FreeBSDであればTRUE
 */
ClientNavigator.prototype.isFreeBSD = function () {
	return (this._isFreeBSD);
};

/**
 * OSがIRIXかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         IRIXであればTRUE
 */
ClientNavigator.prototype.isIRIX = function () {
	return (this._isIRIX);
};

/**
 * OSがBeOSかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         BeOSであればTRUE
 */
ClientNavigator.prototype.isBeOS = function () {
	return (this._isBeOS);
};

/**
 * OSがRISCかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         RISCであればTRUE
 */
ClientNavigator.prototype.isRISC = function () {
	return (this._isRISC);
};

/**
 * OSがDreamCastかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         DreamCastであればTRUE
 */
ClientNavigator.prototype.isDC = function () {
	return (this._isDC);
};

/**
 * OSがPlayStationかどうかを調べます
 *
 *
 * @access public
 * @return bool
 *         PlayStationであればTRUE
 */
ClientNavigator.prototype.isPS = function () {
	return (this._isPS);
};

/**
 * ブラウザがIEかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         IEであればTRUE
 */
ClientNavigator.prototype.isIE = function () {
	return (this._isIE);
};

/**
 * ブラウザがNNかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         NNであればTRUE
 */
ClientNavigator.prototype.isNN = function () {
	return (this._isNN);
};

/**
 * ブラウザがMozilaかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         MozilaであればTRUE
 */
ClientNavigator.prototype.isMozila = function () {
	return (this._isMozila);
};

/**
 * ブラウザがOperaかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         OperaであればTRUE
 */
ClientNavigator.prototype.isOpera = function () {
	return (this._isOpera);
};

/**
 * ブラウザがSafariかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         SafariであればTRUE
 */
ClientNavigator.prototype.isSafari = function () {
	return (this._isSafari);
};

/**
 * ブラウザがiCabかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         iCabであればTRUE
 */
ClientNavigator.prototype.isiCab = function () {
	return (this._isiCab);
};

/**
 * ブラウザがKonquerorかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         KonquerorであればTRUE
 */
ClientNavigator.prototype.isKonqueror = function () {
	return (this._isKonqueror);
};

/**
 * ブラウザがNetFrontかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         NetFrontであればTRUE
 */
ClientNavigator.prototype.isNetFront = function () {
	return (this._isNetFront);
};

/**
 * ブラウザがEGBrowserかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         EGBrowserであればTRUE
 */
ClientNavigator.prototype.isEGBrowser = function () {
	return (this._isEGBrowser);
};

/**
 * ブラウザがDreamPassportかどうか調べます
 *
 *
 * @access public
 * @return bool
 *         DreamPassportであればTRUE
 */
ClientNavigator.prototype.isDreamPassport = function () {
	return (this._isDreamPassport);
};

/**
 * IEのバージョンを取得します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getIEVersion = function () {
	var ua     = navigator.userAgent;
	var offset = ua.indexOf("MSIE ");

	if (offset == -1) {
		return (0);
	}
	else {
		return (parseFloat(ua.substring(offset + 5, ua.indexOf(";", offset))));
	}
};

/**
 * NNのバージョンを取得します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getNNVersion = function () {
	var appVer = parseFloat(navigator.appVersion);

	if (appVer < 5) {
		return (appVer);
	}
	else {
		if (typeof navigator.vendorSub != "undefined") {
			return (parseFloat(navigator.vendorSub));
		}
	}
};

/**
 * Mozilaのバージョンを取得します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getMozilaVersion = function () {
	var ua     = navigator.userAgent;
	var offset = ua.indexOf("rv:");

	if (offset == -1) {
		return (0);
	}
	else {
		return (parseFloat(ua.substring(offset + 3, ua.indexOf(")", offset))));
	}
};

/**
 * Operaのバージョンを取得します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getOperaVersion = function () {
	var ua     = navigator.userAgent;
	var offset = ua.indexOf("Opera ");

	if (offset == -1) {
		offset = ua.indexOf("Opera/");
		
		if (offset == -1) {
			return (0);
		}
	}

	return (parseFloat(ua.substring(offset + 6, ua.indexOf(" ", offset))));
};

/**
 * Safariのバージョンを取得します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getSafariVersion = function () {
	var appVer = navigator.appVersion;
	var offset = appVer.indexOf("Safari/");

	if (offset == -1) {
		return (0);
	}
	else {
		return (parseFloat(appVer.substring(offset + 7, appVer.length - offset - 7)));
	}
};

/**
 * iCabのバージョンを返します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getiCabVersion = function () {
	return (parseFloat(navigator.appVersion));
};

/**
 * Konquerorのバージョンを返します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getKonquerorVersion = function () {
	var appVer = navigator.appVersion;
	var offset = appVer.indexOf("Konqueror/");

	if (offset == -1) {
		return (0);
	}
	else {
		return (parseFloat(appVer.substring(offset + 10, indexOf("-", offset))));
	}
};

/**
 * NetFrontのバージョンを返します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getNetFrontVersion = function () {
	var appVer = navigator.appVersion;
	var offset = appVer.indexOf("AveFront/");

	if (offset == -1) {
		return (0);
	}
	else {
		return (parseFloat(appVer.substring(offset + 9, indexOf(")", offset))));
	}
};

/**
 * EGBrowserのバージョンを返します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getEGBrowserVersion = function () {
	var ua     = navigator.userAgent;
	var offset = ua.indexOf("Planetweb/v");

	if (offset == -1) {
		return (0);
	}
	else {
		return (parseFloat(ua.substring(offset + 11, indexOf(" ", offset))));
	}
};

/**
 * DreamPassportのバージョンを返します
 *
 *
 * @access private
 * @return float
 */
ClientNavigator.prototype._getDreamPassportVersion = function () {
	var appVer = navigator.appVersion;
	var offset = ua.indexOf("DreamPassport/");

	if (offset == -1) {
		return (0);
	}
	else {
		return (parseFloat(appVersion.substring(offset + 14, indexOf(")", offset))));
	}
};

/**
 * ブラウザがIEの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doIE = function (version) {
};

/**
 * ブラウザがNNの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doNN = function (version) {
};

/**
 * ブラウザがMozilaの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doMozila = function (version) {
};

/**
 * ブラウザがOperaの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doOpera = function (version) {
};

/**
 * ブラウザがSafariの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doSafari = function (version) {
};

/**
 * ブラウザがiCabの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doiCab = function (version) {
};

/**
 * ブラウザがKonquerorの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doKonqueror = function (version) {
};

/**
 * ブラウザがNetFrontの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doNetFront = function (version) {
};

/**
 * ブラウザがEGBrowserの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doEGBrowser = function (version) {
};

/**
 * ブラウザがDreamPassportの時の処理です
 *
 *
 * @access public
 * @param  version float
 * @return void
 */
ClientNavigator.prototype.doDreamPassport = function (version) {
};

/**
 * ブラウザが不明の時の処理です
 *
 *
 * @access public
 * @return void
 */
ClientNavigator.prototype.doUnknown = function () {
};

/**
 * ブラウザの判別を行い、ブラウザ別の処理をコールします
 *
 *
 * @access protected
 * @final
 * @return void
 */
ClientNavigator.prototype.service = function () {
	if (this.isIE()) {
		this.doIE(this._getIEVersion());
	} 
	else if (this.isNN()) {
		this.doNN(this._getNNVersion());
	}
	else if (this.isMozila()) {
		this.doMozila(this._getMozilaVersion());
	}
	else if (this.isOpera()) {
		this.doOpera(this._getOperaVersion());
	}
	else if (this.isSafari()) {
		this.doSafari(this._getSafariVersion());
	}
	else if (this.isiCab()) {
		this.doiCab(this._getiCabVersion());
	}
	else if (this.isKonqueror()) {
		this.doKonqueror(this._getKonquerorVersion());
	}
	else if (this.isNetFront()) {
		this.doNetFront(this._getNetFrontVersion());
	}
	else if (this.isEGBrowser()) {
		this.doEGBrowser(this._getEGBrowserVersion());
	}
	else if (this.isDreamPassport()) {
		this.doDreamPassport(this._getDreamPassportVersion());
	}
	else {
		this.doUnknown();
	}
};
