/* 
 スタイル読み込みスクリプト ReadStyle.js


/* ----------------- 変数宣言 -------------------*/
var FontSize;
var BGColor;
var Unit;
var Obj;

Units = new Array('%','px','pt','em');

/* ----------------- 初期設定 -------------------*/
/* IDの指定 */
//文字サイズを変更したい要素のID
Obj = 'container';
footer = 'footermenu';

/* サイズの単位（0 = %、1 = px、2 = pt, 3= em） */
Unit = 0;

/* Cookieの有効期限（日数） */
ExpireDays = 30;


/* -------------------- 実　行 ---------------------*/
ReadCookie();

/* -------------------- 関　数 ---------------------*/
/* Cookie呼出 */
function ReadCookie() {
	if (document.cookie) {
		Cookie = document.cookie;
		if (Cookie.match(/FontSize=([\d.]*)/)) {
			FontSize = RegExp.$1;
		}
		i = j = 0;
		tmp1 = " " + document.cookie + ";";
		while (i < tmp1.length) {
			j = tmp1.indexOf(";", i);
			tmp2 = tmp1.substring(i + 1, j);
			k = tmp2.indexOf("=");
			if (tmp2.substring(0, k) == "BGColor") {
				BGColor = unescape(tmp2.substring(k + 1, j - i - 1));
			}
			i = j + 1;
		}
	}
}

/* スタイル変更 */
function SetStyle() {
	if (FontSize != null) {
		document.getElementById(Obj).style.fontSize = FontSize + Units[Unit];
	}

	//背景色を黒に指定した場合
	if (BGColor != null) {
		if(BGColor=="#000000"){

			//背景色は黒
			document.getElementById(Obj).style.backgroundColor = BGColor;

			//文字色は白
			document.getElementById(Obj).style.color = "#FFFFFF";

			//フッターの文字色は黒
			document.getElementById(footer).style.color = BGColor;

			//ジャンル、コンテンツのタイトル名は黒
			var gcname = new Array('gtitle','ctitle');

			for(var k=0; k<gcname.length; k++){
				if(document.getElementById(gcname[k])){
					document.getElementById(gcname[k]).style.color = BGColor;
				}
			}

			/*infoタイトルの文字色変更(関連情報等)*/
			var title = document.all.tags("div");
			for( var i=0; i<title.length; i++){
				if(title[i].className=="infotitle"){
					title[i].style.color = "#FFFFFF";
				}
			/*基本テンプレートタイプのブロックタイトルの文字色変更*/
				if(title[i].className=="blocktitle"){
					title[i].style.color = BGColor;
				}
			}

			/*自由入力は背景色が白、文字色が黒*/
			if(document.getElementById("ctext")){
				if(document.getElementById("ctext").innerHTML.indexOf("mso-width-source") != -1){
					document.getElementById("ctext").style.backgroundColor = "#FFFFFF";
					document.getElementById("ctext").style.color = "#000000";
				}
			}

			//リンクの文字色変更（変更したい文字は、class名をlinkcolorにする）
			for(var i=0; i<document.links.length; i++) {
				if(document.links[i].className == "linkcolor"){
					document.links[i].style.color="#000000";
				}else{
					document.links[i].style.color="#FFFFFF";
				}
			}

			//各タイトルの色を変更
			var titlename = new Array('phototitle','outlinetitle','populationtitle',
																'nicetitle','posttitle','foreigntitle',
																'mobiletitle','businesstitle','parenttitle',
																'infotitle');

			for(var j=0; j<titlename.length; j++){
				if(document.getElementById(titlename[j])){
					document.getElementById(titlename[j]).style.color = "#FFFFFF";
				}
			}

		}
	}
}

