/* クッキー */
function class_cookielib(){
	this.getCookie = getCookie;
	this.setCookie = setCookie;
	this.removeCookie = removeCookie;
	
	var expireDate = new Date();
	expireDate.setFullYear(expireDate.getFullYear()+1);
	expireStr = "expires=" + expireDate.toUTCString();

	function getCookie(name){
		var gc=name+"=";
		var Cookie=document.cookie;
		if (Cookie.length>0) {
			var start=Cookie.indexOf(gc);
			if (start!=-1) {
				start+=gc.length;
				terminus=Cookie.indexOf(";",start);
				if (terminus==-1) terminus=Cookie.length;
				return unescape(Cookie.substring(start,terminus));
			}
		}
		return '';
	}
	
	function setCookie() {
		var key = arguments[0];
		var val = arguments[1];
		var path = (typeof(arguments[2]) != 'undefined' ? arguments[2] : '/');
		var exp = (typeof(arguments[3]) != 'undefined' ? arguments[3] : expireStr);
		var sc = key + "=" + escape(val) + "; path=" + path + "; " + exp;
		document.cookie = sc;
	}
	
	function removeCookie(key,path) {
		if(!path){
			path = '/';
		}
		var rc = key + "=; path=" + path + "; expires=Thu, 1 Jan 1970 00:00:00 UTC";
		document.cookie = rc;
	}
}
	
var cookieObj = new class_cookielib();

/* テキストサイズの変更 */
var fontsize_val = 1;
var fontsize_css_size = new Array();
fontsize_css_size[0] = '70%';
fontsize_css_size[1] = '80%';
fontsize_css_size[2] = '95%';

function setFontSize(){
	if(cookieObj.getCookie('fontsize') != ''){
		fontsize_val = 1 * cookieObj.getCookie('fontsize');
	}
	document.write('<style type="text/css">');
	document.write('html { font-size:' + fontsize_css_size[fontsize_val] + '; }');
	document.write('</style>');
}

function changeFontSize(num){
	var fl_update = false;
	//var tmp_val = fontsize_val + num;
	var tmp_val = num;
	if(tmp_val >= 0 && tmp_val < fontsize_css_size.length){
		fontsize_val = tmp_val;
		fl_update = true;
	}
	if(fl_update){
		cookieObj.setCookie('fontsize',fontsize_val,'/','');
		window.location.reload();
	}
}

function FontSizeUI(IMGDIR){
	if(document.layers){
		return;
	}

	document.write('<img border="0" src="' + blogurl + 'fontsize/fontsize.gif" id="font_size_title" /><br />');
	
	if(fontsize_val != 2){
		document.write('<a href="#" onclick="changeFontSize(2);return false;"><img border="0" src="' + blogurl + 'fontsize/font-l_off.gif" alt="大" /></a>');
	}
	else{
		document.write('<img border="0" src="' + blogurl + 'fontsize/font-l_on.gif" alt="大" />');
	}
	
	if(fontsize_val != 1){
		document.write('<a href="#" onclick="changeFontSize(1);return false;"><img border="0" src="' + blogurl + 'fontsize/font-m_off.gif" alt="中" /></a>');
	}
	else{
		document.write('<img border="0" src="' + blogurl + 'fontsize/font-m_on.gif" alt="中" />');
	}
	
	if(fontsize_val != 0){
		document.write('<a href="#" onclick="changeFontSize(0);return false;"><img border="0" src="' + blogurl + 'fontsize/font-s_off.gif" alt="小" /></a>');
	}
	else{
		document.write('<img border="0" src="' + blogurl + 'fontsize/font-s_on.gif" alt="小" />');
	}
	document.write('');

}

setFontSize();
