// cookie setting

var fonttype = 'normal';
gDay = new Date;
gDay.setMonth(gDay.getMonth() + 1);
gDay = gDay.toGMTString();
gPath = "/";

// Eat Cookie
function eat(fonttype) {
	setCookie("FONTTYPE",fonttype);
}

function setCookie(keys,val) {
	tmp = keys + "=" + escape(val) + ";path=" + gPath + ";expires=" + gDay + ";";
	document.cookie = tmp;
}

// Tasting Cookie :-)
function get() {
	fonttype = getCookie("FONTTYPE");
	return fonttype;
}

function getCookie(keys) {
	tmp = document.cookie + ";";
	tmp1 = tmp.indexOf(keys,0);
	if (tmp1 != -1){
		tmp = tmp.substring(tmp1,tmp.length);
		index2 = tmp.indexOf("=",0)+1;
		index3 = tmp.indexOf(";",index2);
		return(unescape(tmp.substring(index2,index3)));
	}
	else {
		return ("normal");
	}
}

// Fontsize Change
function chgsize(fontsize){
	eat(fontsize);
	location.reload();
}

// Get Web Client Name & Version
function getnavi(style){
	ua = new Array();
	ua[0] = '';
	ua[1] = navigator.appName;
	ua[2] = navigator.appVersion;
	ua[3] = navigator.appVersion.charAt(0);
	if (ua[2].indexOf("MSIE") > -1){
		ua[0] = 'IE';
	}
	else if (ua[2].indexOf("Apple") > -1){
		ua[0] = 'safari';
	}
	else if ((ua[3].indexOf("5") > -1) && (ua[1].indexOf("Netscape") > -1)){
		ua[0] = 'NN6';
	}
	else if ((ua[3].indexOf("4") > -1) && (ua[1].indexOf("Netscape") > -1)){
		ua[0] = 'NN4';
	}
	else if (ua[1].indexOf("Opera") > -1){
		ua[0] = 'Opera';
	}
	else {
		ua[0] = 'other';
	}
	if (style == 'simple'){
		return ua[0];
	}
	else {
		return ua;
	}
}

// CSS File Call
function call_css (path_num){
	ua = new Array();
	ua = getnavi();
	switch(ua[0]){
		case 'safari':
			cssfile = 'mac_safari.css';
			break;
		case 'IE':
			if (ua[2].indexOf('Win') > -1){
				cssfile = 'win_ie.css';
			}
			else {
				cssfile = 'mac_ie.css';
			}
			break;
		case 'NN6':
			if (ua[2].indexOf('Win') > -1){
				cssfile = 'win_gecko.css';
			}
			else {
				cssfile = 'mac_gecko.css';
			}
			break;
		case 'NN4':
			if (ua[2].indexOf('Win') > -1){
				cssfile = 'win_nn4.css';
			}
			else {
				cssfile = 'mac_nn4.css';
			}
			break;
		case 'Opera':
			if (ua[2].indexOf('Win') > -1){
				cssfile = 'win_opera.css';
			}
			else {
				cssfile = 'mac_safari.css';
			}
			break;
		default:
			cssfile = 'win_ie.css';
			break;
	}
	
	switch(path_num){
		case '':
			css_path = '/';
			break;
		case 0:
			css_path = './';
			break;
		default:
			css_path = '';
			for (i = 0; i < path_num; i++){
				css_path = css_path + '../';
			}
			break;
	}
	document.write('<link rel="stylesheet" type="text/css" href="' + css_path + 'css/common.css">');
	
// Fontsize Setting
	fonttype = get();
	switch(fonttype){
		case 'normal':
		default:
			font_path = 'css/';
			break;
		case 'larger':
		case 'largest':
			font_path = 'css_' + fonttype + '/';
			break;
	}
	
	css_load = css_path + font_path + cssfile;
	document.write('<link rel="stylesheet" type="text/css" href="' + css_load + '">\n');
	
}

//open popup window
function open_popup(wURL,wName,wOption){
	newwin = window.open(wURL,wName,wOption);
	newwin.focus();
}