/*
 * フォントサイズ変更ユーティリティ
 */

// 初期設定のセレクタ
var selecter = [ "div.maincontents" ];
// cookie 生存期間（日数指定）
var expires = 30;
var savedfontsize = 0;
// font size 12段階
// 標準は 3、小 1、大 5
var sizearray = [
	"77%",
	"85%",
	"93%",
	"100%",
	"108%",
	"116%",
	"123.1%",
	"131%",
	"138.5%",
	"146.5%",
	"153.9%",
	"161.6%"
];
/*
var sizearray = [
	"10px",
	"11px",
	"12px",
	"13px",
	"14px",
	"15px",
	"16px",
	"17px",
	"18px",
	"20px",
	"22px",
	"24px"
];
*/
function expansionsize() {
	
	++savedfontsize;
	if (savedfontsize > sizearray.length) {
		savedfontsize = sizearray.length - 1;
	}
	setcookie('fontsize', savedfontsize);
	for (var i = 0; i < selecter.length; i++) {
		$(selecter[i]).css("font-size", sizearray[savedfontsize]);
	}
	
}
function defaultsize() {
	
	savedfontsize = 0;
	removecookie('fontsize');
	for (var i = 0; i < selecter.length; i++) {
		$(selecter[i]).css("font-size", sizearray[3]);
	}
	
}
function largesize() {
	setcookie('fontsize', 5);
	for (var i = 0; i < selecter.length; i++) {
		$(selecter[i]).css("font-size", sizearray[5]);
	}
}
function smallsize() {
	setcookie('fontsize', 1);
	for (var i = 0; i < selecter.length; i++) {
		$(selecter[i]).css("font-size", sizearray[1]);
	}
}

function loadfontsize(args) {

	if ($.cookie('fontsize')) {
		savedfontsize = $.cookie('fontsize');
	} else
	{
		savedfontsize = 3;
	}
	if (args) selecter = args;
	for (var i = 0; i < selecter.length; i++) {
		$(selecter[i]).css("font-size", sizearray[savedfontsize]);
	}

}



/**
 * 色調変更
 */
function changecolor(color) {
	
	if ( color == "text" && $.cookie('color') == "text") {
		color = "default" ;
	} else
	{
		if (color == undefined || color == null || color == "") {
			color = $.cookie('color');
		}
		
	}
	
	
//	if ($.cookie('color').length > 0) {
//		color = $.cookie('color');
//	}
	
	if (color == "black") {
		$(".iepngfix").css("filter","none");
		$("#colorchanger").attr("href", "/share/style/black.css");

		if (window["navi"] && window["benrixml"] && window["shisetsuxml"]) {

			loadflashguide(navi, benrixml, shisetsuxml);
		}
		setcookie('color', color);
	} else
	if (color == "text") {
		
		$(".iepngfix").css("filter","none");
		$("#colorchanger").attr("href", "/share/style/text.css");

		if (window["navi"] && window["benrixml"] && window["shisetsuxml"]) {

			var loadurl = "/noflashguide.html";
			if (window["benrixml"].match(/jigyosha/)) {
				loadurl = "/jigyosha/shiminbenri/noflashguide2.html";
			} else
			if (window["benrixml"].match(/kyouikuiinkai/)) {
				loadurl = "/kyouikuiinkai/shiminbenri/noflashguide2.html";
			}
			$("#flashguide object").remove();
			$("#flashguide").load(loadurl,null,function(){
				$("#altContent").css("visibility","visible");
				$("div.htmlvarlink").remove(); // 100526 add
			});
			
		}

		
		// マイタウンクラブボタン
		$("#home .mytownclubheader h2 a").html("マイタウンクラブ");
		$("#home .mytownclubheader .bot a").html("詳細を見る");
		// 各サイトのナビゲーションイメージ
		$(".sitenavigation a img").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});
		// ページ下部の広報厚木
		$("#selector02 .photo").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});
		// 事業者のバナー
		$("#gammabanner1 a img").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});		
		// 広告バナー
		$(".banner a img").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});
		// サイドメニューバナー
		$(".sidebaritem a img").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});
		// 記事本文のイメージ
		$(".bodytext img").each(function(){
			var alt = $(this).attr("alt");
			$(this).remove();
		});
		// サイドバーの特集
		$("#sidebar_special img").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});
		// サイドバーバナー
		$("#sidebar_banner a img").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});
		// 広報あつぎ
		$("#home .movekouhou a img").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});
		// 外国語リンク
		$(".foreignerlinks a img").each(function(){
			var alt = $(this).attr("alt");
			$(this).parent("a").html(alt);
			$(this).remove();
		});

		setcookie('color', color);
	} else
	if (color == "default") {
		$("#colorchanger").attr("href", "");
		removecookie('color');
		location.reload();
	} else
	{

		$("#colorchanger").attr("href", "");
		removecookie('color');
		
	}

	
}
function loadcolor() {
	
//	var color = $.cookie('color');
	changecolor();
	
}

function setcookie(name, value) {
	
	var cookieparam = {
		expires: expires,
		path: '/'
	};
	$.cookie(name, value, cookieparam);

}
function removecookie(name) {
	
	var cookieparam = {
		expires: -1,
		path: '/'
	};
	$.cookie(name, "", cookieparam);

}



function setIE6Filter(el, path, mode) {
	var fs = el.attr("filters");
	var alpha = "DXImageTransform.Microsoft.AlphaImageLoader";
	if (fs[alpha]) {
		fs[alpha].enabled = true;
		fs[alpha].src = path; 
		fs[alpha].sizingMethod = mode;
	} else {
		el.css("filter", 'progid:' + alpha + '(enabled="true", sizingMethod="' + mode + '", src="' + path + '")');			
	}
}


function goHtmlVer() {
	
	$(".iepngfix").css("filter","none");
	if (window["navi"] && window["benrixml"] && window["shisetsuxml"]) {

		var loadurl = "/noflashguide.html";
		if (window["benrixml"].match(/jigyosha/)) {
			loadurl = "/jigyosha/shiminbenri/noflashguide2.html";
		} else
		if (window["benrixml"].match(/kyouikuiinkai/)) {
			loadurl = "/kyouikuiinkai/shiminbenri/noflashguide2.html";
		}
		$("#flashguide object").remove();
		$("#flashguide").load(loadurl,null,function(){
			$("#altContent").css("visibility","visible");
			$("div.getflashplayer").remove();
			$("div.htmlvarlink").remove();
			$("div.flashvarlink").show();
		});
		
	}

}


function goFlashVer() {
	location.reload();
}

