﻿////文字拡大・縮小//////////////////////////////////////////////////////////////////////////////

function setCookie(s){
	cName = "FontSize_TomeCity :";
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = cName + s + "; path=/" + "; expires=" + exp.toGMTString();
}

function getCookie(){
	zoom = "";
	cName = "FontSize_TomeCity :";
	tmpCookie = document.cookie + ";";
	s = tmpCookie.indexOf(cName);
	if (s != -1)
	{
		e = tmpCookie.indexOf(";", s);
		zoom = tmpCookie.substring(s + cName.length, e);
		document.body.style.fontSize = zoom;
	} else {
		document.body.style.fontSize = "100%";		
	}
}

function textSizeUp(){
	currentSize = document.body.style.fontSize;
	selectSize = "";
	if ( currentSize == "80%" ){
		selectSize = "100%";
	} else if ( currentSize == "100%" ){
		selectSize = "120%";
	} else if ( currentSize == "120%" ){
		m = escape("これ以上文字のサイズを大きくできません。");
		alert(unescape(m));
		selectSize = "120%";
	} else {
		selectSize = "120%";
	}
	document.body.style.fontSize = selectSize;
	setCookie(selectSize);
}

function textSizeDown(){
	currentSize = document.body.style.fontSize;
	selectSize = "";
	if ( currentSize == "120%" ){
		selectSize = "100%";
	} else if ( currentSize == "100%" ){
		selectSize = "80%";
	} else if ( currentSize == "80%" ){
		m = escape("これ以上文字のサイズを小さくできません。");
		alert(unescape(m));
		selectSize = "80%";
	} else {
		selectSize = "80%";
	}
	document.body.style.fontSize = selectSize;
	setCookie(selectSize);
}

window.onload = function(e) {
	getCookie();
	
	var header = document.getElementById('top');
	var count = 9;
	var rdm = Math.floor(Math.random()*count);
	if(rdm==0) rdm = 9;
	var path = "/shared/images/header0"+rdm+".jpg";
	header.src = path;
}
//前のページに戻る
$(function(){
	
	var backpage = function(){};
	
	backpage.prototype = {
		panId: '#pankuzu',	
		pnaviId: '#pagenavi',
		insert: function(){
			var
				href = $(this.panId).find('a:last').attr('href'),
				source = '<td align="left" valign="top"><p><a href="' + href + '"><img src="/shared/templates/free/images/icon_back.gif" alt="" width="15" height="15" class="icon-back" border="0">前のページへ</a></p></td>';
				
			if(!href) return;
			$(this.pnaviId + ' tr').prepend(source);
		}
	}
	
	var obj = new backpage();
	
	obj.insert();
});

////文字拡大・縮小//////////////////////////////////////////////////////////////////////////////

function setUI() {
	document.write('<a href="javascript:textSizeUp()"><img src="/shared/images/btn_font_b.gif" alt="文字の拡大" width="97" height="23" border="0"></a><a href="javascript:textSizeDown()"><img src="/shared/images/btn_font_s.gif" alt="文字の縮小" width="97" height="23" border="0"></a>');
}