﻿/*------------------------------------------------------------------------------
    フォントサイズ変更
--------------------------------------------------------------------------------*/
/* ------ 設定 [共通]------ */
var uniq_name = "fcmn_"	//クッキー名称の冠[変更可]
var keepdays = 0;			//クッキーの保存期間[変更可]

/* ------ 設定 [フォントサイズ変更]------ */
var step = 20;			//このパーセント刻みで文字の大小を変えます[変更可]
var defSize = 100;		//初期値（パーセント）[変更可]
var cookie_fs = uniq_name + "fontsize";


/*------------------------------------------------------------------------------*/
var crtSize = defSize;
function util_init(){
	//フォント設定が残っていたら反映する
	var tmp_fs= getCookie(cookie_fs);
	if (tmp_fs) {
		crtSize = parseInt(tmp_fs);
		fsChange(crtSize);
	}
}
function getCookie(key){
	var sCookie = document.cookie;
	var aData = sCookie.split(";");
	var oExp = new RegExp(" ", "g");
	key = key.replace(oExp, ""); 
	var i = 0;
	while (aData[i]) {
		var aWord = aData[i].split("=");
		aWord[0] = aWord[0].replace(oExp, ""); 
		if (key == aWord[0]) return unescape(aWord[1]);
		if (++i >= aData.length) break;
	}
	return "";
}
function setCookie(key,value){
	var str = key + "=" + escape(value) + ";";
	str += "path=/;";
	if (keepdays != 0) {
		var dt = new Date();
		dt.setDate(dt.getDate() + parseInt(keepdays));
		str += "expires=" + dt.toGMTString() + ";";
	}
	document.cookie = str;
}
function deleteCookie(key){
	var str = key + "=;";
	str += "path=/;";
	var dt = new Date();
	dt.setDate(dt.getDate() -1);
	str += "expires=" + dt.toGMTString() + ";";
	document.cookie = str;
}
function fsChange(arg){
	//未対応ブラウザ対応
	if(!document.body){
		s_message("n_use");
	}else{
		//現在のフォントサイズ値を変更
		if(arg == "d"){
			crtSize = defSize;
			deleteCookie(cookie_fs);
		}
		else if(arg == "s"){
			if (parseInt(crtSize) > parseInt(step) ){
				crtSize -= parseInt(step);
				setCookie(cookie_fs,crtSize);
			}
		}
		else if(arg == "l"){
			crtSize += parseInt(step);
			setCookie(cookie_fs,crtSize);
		}
		//フォントサイズを変更
		document.body.style.fontSize = crtSize + "%";
	}
}

function bgChange(node_id,url_id){
	var target = document.getElementById(node_id);
	//未対応ブラウザ対応
	if(!target || !target.cloneNode){
		s_message("n_use");
	}else{
		var c_node = target.cloneNode(true);
		c_node.href = eval(url_id);			//DBPSでは相対パスでURLを設定するので、毎回パスを受け取りなおします
		target.parentNode.replaceChild(c_node,target);
		setCookie(cookie_bgurl,url_id);
		setCookie(cookie_bgid,node_id);
	}
}

function s_message(arg){
	if(arg == "n_use"){
		alert("お使いのブラウザではこの機能を使用できません");
	}
}
/*===================================
  [関数 chBanner]
  バナーをランダム表示するJavascript
====================================*/

function chBanner(alt,url,img)
{
	n = Math.floor(Math.random() * img.length);
	if(url[n] != ""){
		document.write('<p><a href="'+url[n]+'" target="_blank"><img src="'+img[n]+'" alt="広告：'+alt[n]+'（新しい画面で開きます）" width="120" height="60" title="広告：'+alt[n]+'（新しい画面で開きます）" /></a></p>');
	}else{
		document.write('<p><img src="'+img[n]+'" alt="広告：'+alt[n]+'" width="120" height="60" title="広告：'+alt[n]+'" /></a></p>');
	}
}
// _______________________________________ end of function fsc() ___ 


