/*
	copyright by kikuchi takeshi
	kikuchi@gmail.com
*/
function k_ua_writelink(str){
	if(this.os == "win" && this.type == "ie" && this.version >= 6) return;
	if(typeof(str)=="undefined") str = "";
	var css_type = "unknown";

	if(this.writecss){
		if (this.os == "win" || this.os == "unix") {
			if(this.type == "ie") {
				css_type = "winie5";
			} else if (this.type == "nn") {
				if(this.version >= 7) {
					css_type = "winnn7";
				} else {
					css_type = "winnn6";
				}
			} else if (this.type == "opera") {
				css_type = "opera";
			} else if (this.type == "gecko") {
				css_type = "gecko";
			}
		} else if (this.os == "mac"){
			if(this.type == "safari") {
				css_type = "macsafari";
			} else if (this.type == "ie") {
				css_type = "macie5";
			} else if (this.type == "nn" || this.type == "gecko") {
				css_type = "macnn7";
			}
		}
		if(css_type != "unknown") document.write ('<link rel="stylesheet" type="text/css" href="http://parts.nikkei.co.jp/parts/css3/'+str+css_type+'.css" title="priority">');
		return;
	}
	location.href="http://www.nikkei.co.jp/help/oldbrowser.html";
	return;
}

function k_ua(){

	this.type="unknown";
	this.os="unknown";
	this.version="0";
	this.writecss = true;
	this.ua=navigator.userAgent.toLowerCase();
	this.writelink = k_ua_writelink;

	if(this.ua.indexOf("win") != -1){
		this.os= "win";
	} else if(this.ua.indexOf("mac") != -1){
		this.os = "mac";
	} else if(this.ua.indexOf("x11") != -1){
		this.os = "unix";
	}
	if(this.ua.indexOf("msie") != -1){
		this.type="ie";
		this.ua.match(/msie ([0-9\.]+);/);
		this.version = parseFloat(RegExp.$1);
		if(this.version <= 4) this.writecss = false;
		return;
	}
	if(this.ua.indexOf("gecko/") != -1){
		if (this.ua.match(/netscape\/(7[\.\d]+)/)) {
			this.version = parseFloat(RegExp.$1);
			this.type = "nn";
			return;
		} else if (this.ua.match(/netscape6\/(\d\.\d(\.\d)?)/)) {
			this.version = parseFloat(RegExp.$1);
			this.type = "nn";
			return;
		} else {
			this.ua.match(/rv:(\d\.\d)/i);
			this.type = "gecko";
			this.version = parseFloat(RegExp.$1);
			return;
		}
	}

	if(this.ua.indexOf("safari") != -1){
		this.type="safari";
		this.ua.match(/safari\/(\d+\.\d+)/);
		this.version = parseFloat(RegExp.$1);
		//if(this.version >= 80) this.writecss = true;
		return;
	}

	if(this.ua.indexOf("opera") != -1){
		this.type="opera";
		this.ua.match(/opera[\/\s](\d\.\d+)/)
		this.version = parseFloat(RegExp.$1);
		//if(this.version >= 7.0) this.writecss = true;
		return;
	}

	if(this.ua.indexOf("icab") != -1){
		this.type="icab";
		return;
	}

	if(this.ua.indexOf("hotjava") != -1){
		this.type="hotjava";
		return;
	}
	if (this.ua.match(/mozilla\/(4\.[5678]\d?)/)) {
		this.version = parseFloat(RegExp.$1);
		this.type = "nn";
		this.writecss = false;
		return;
	}
	return;
}

var k = new k_ua();
self.k = k;

