﻿////cookie設定//////////////////////////////////////////////////////////////////////////////
function getCookie(name){
	if(!name) return;
	var val = "";
	var cookieName = name+"=";
	var tmpCookie = document.cookie + ";";
	var start = tmpCookie.indexOf(cookieName);
	if (start != -1) {
		var end = tmpCookie.indexOf(";", start);
		val = tmpCookie.substring(start + cookieName.length, end);
	}
	return val;
}
function setCookie(name,value){
	if(!name || !value) return;
	var cookieName = name+"=";
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = cookieName + value + "; path=/" + "; expires=" + exp.toGMTString();
}
////色合いの変更　//////////////////////////////////////////////////////////////////////////////
var targetLINK  = "changecss";
var css_keyword = "color";
var dir_path = "/library/style/color/";
//
function setColorCookie(s){
	siteName = "WakoColor=";
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = siteName + s + "; path=/" + "; expires=" + exp.toGMTString();
}
//
function changeCSS(par) {
	if(!par || par=="") return;
	var target = document.getElementById(targetLINK);
	if(!target) {
		links = document.getElementsByTagName('link');
		for(var i=0;i<links.length;i++) {
			temp = links[i].href;
			chk = temp.indexOf(css_keyword);
			if(chk!=-1) {
				target = links[i];
				break;
			}
		}
	}
	//
	if(!target) return;
	if(!target.cloneNode) {
		alert('ご利用のブラウザでは文字の大きさ・色の変更機能はご利用いただけないようです.\n[Element]or[cloneNode Method] None');
		return;
	}
	//
	var css_path = dir_path + par;
	//
	var newNode = target.cloneNode(true);
	newNode.href = css_path;
	target.parentNode.replaceChild(newNode,target);
	//
	setColorCookie(par);
}

////文字拡大・縮小//////////////////////////////////////////////////////////////////////////////
function textSizeUp(){
	var currentSize = "90%";
	var selectSize = "";
	currentSize = document.body.style.fontSize;
	if(!currentSize) currentSize = "90%";
	if ( currentSize=="90%"){
		selectSize = "110%";
	} else if(currentSize=="110%") {
		selectSize = "130%";
	} else if(currentSize=="130%") {
		alert("これ以上文字を拡大することはできません。");
		selectSize = "130%";
	} else {
		selectSize = "90%";
	}

	setFontSize(document.getElementsByTagName('body'),selectSize);
//	if(checkBrowser()=="ie6"){
//		setFontSize(document.getElementsByTagName('th'),selectSize);
//		setFontSize(document.getElementsByTagName('td'),selectSize);
//		setFontSize(document.getElementsByTagName('caption'),selectSize);
//	}

	setCookie('WakoText',selectSize);
	return false;
}
//
function textSizeDown(){
	var currentSize = "90%";
	var selectSize = "";
	currentSize = document.body.style.fontSize;
	if(!currentSize) currentSize = "90%";
	if ( currentSize=="130%"){
		selectSize = "110%";
	} else if(currentSize=="110%") {
		selectSize = "90%";
	} else if(currentSize=="90%") {
		selectSize = "80%";
	} else if(currentSize=="80%") {
		alert("これ以上文字を縮小することはできません。");
		selectSize = "80%";
	} else {
		selectSize = "90%";
	}

	setFontSize(document.getElementsByTagName('body'),selectSize);
//	if(checkBrowser()=="ie6"){
//		setFontSize(document.getElementsByTagName('th'),selectSize);
//		setFontSize(document.getElementsByTagName('td'),selectSize);
//		setFontSize(document.getElementsByTagName('caption'),selectSize);
//	}

	setCookie('WakoText',selectSize);
	return false;
}
//
function setFontSize(target,size){
	for(var i=0; i<target.length; i++){
		target[i].style.fontSize = size;	
	}
}
//// ロールオーバー////////////////////////////////////////////////////////////////////
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//// フォーカスで文字を消去 //////////////////////////////////////////////////////////////////////////
function searchText(){
	if(!document.getElementById("query")) return;
	var obj = document.getElementById("query");
	obj.onfocus = function() {
		if(this.value == 'キーワードを入力') {
			this.value = '';
		}
	}
	obj.onblur=function() {
		if(this.value == '') {
			this.value = 'キーワードを入力';
		}
	}
}

//// ie6判別 //////////////////////////////////////////////////////////////////////////
function checkBrowser(){
	var uName = navigator.userAgent;
	if (uName.indexOf("MSIE 6.0") > -1)	return "ie6";
}

//// faviconリンクタグ ///////////////////////////////////////////////////////////////
function setFavicon() {
	document.write('<link rel="shortcut icon" href="/library/favicon.ico" type="image/x-icon" />');
}

//// onload //////////////////////////////////////////////////////////////////////////
window.onload = function() {
	searchText();
	var val = getCookie('WakoText');
	if(val) {
		document.body.style.fontSize = val;
		//setFontSize(document.getElementsByTagName('body'),val);
//		if(checkBrowser()=="ie6"){
//			setFontSize(document.getElementsByTagName('th'),val);
//			setFontSize(document.getElementsByTagName('td'),val);
//			setFontSize(document.getElementsByTagName('caption'),val);
//		}
	}
	var val2 = getCookie('WakoColor');
	changeCSS(val2);
}

setFavicon();


//// closeUpIssue //////////////////////////////////////////////////////////////////////////
var trackingUrl = "";


function close_upStart(){
	var thisHtImage = document.getElementById("closeUpIssue");
	
	var obPhotos = new Array();
	obPhotos[0] = "";
	obPhotos[1] = [ "aiaoi.gif" , "広告：藍葵麹町法律事務所" , "http://aakojimachi-hp.hp1.allin1.jp/", "/banner-ads/001-aiaoi" ];
	obPhotos[2] = [ "lifcom.gif" , "広告：株式会社リフコム" , "http://www.lifcom.co.jp/", "/banner-ads/002-lifcom" ];
	obPhotos[3] = [ "celemony.gif" , "広告：しののめの里市民葬登録業者セレモニー" , "http://www.sougi.info/", "/banner-ads/003-celemony" ];
	obPhotos[4] = [ "hanawa.gif" , "広告：花輪式典" , "http://shiminso.jp/", "/banner-ads/004-hanawa" ];
	obPhotos[5] = [ "saison.gif" , "広告：セゾン自動車火災保険株式会社" , "http://www.ins-saison.co.jp/", "/banner-ads/005-saison" ];
	obPhotos[6] = [ "satojimusyo.gif" , "広告：行政書士佐藤事務所" , "http://www.officesato.info/", "/banner-ads/006-sato" ];


	var thisPhotoID = Math.floor(Math.random()*(obPhotos.length-1))+1;
	thisHtImage.src = "/library/images/top/banner/" + obPhotos[thisPhotoID][0];
	thisHtImage.alt = obPhotos[thisPhotoID][1];
	thisHtImage.parentNode.href = obPhotos[thisPhotoID][2];
	
	trackingUrl = obPhotos[thisPhotoID][3];
}

function sendTracking() {
	if (trackingUrl) {
		urchinTracker(trackingUrl);
	}
	return;
}


//// closeUpIssue2 by wako city /////////////////////////////////////////////////////////////////////
var trackingUrl2 = "";

function close_upStart2(){
	var thisHtImage2 = document.getElementById("closeUpIssue2");
	var obPhotos2 = new Array();
	obPhotos2[0] = "";
	obPhotos2[1] = [ "celemony.gif" , "広告：しののめの里市民葬登録業者セレモニー" , "http://www.sougi.info/", "/banner-ads/003-celemony"];
	obPhotos2[2] = [ "hanawa.gif" , "広告：花輪式典" , "http://shiminso.jp/", "/banner-ads/004-hanawa" ];
	obPhotos2[3] = [ "saison.gif" , "広告：セゾン自動車火災保険株式会社" , "http://www.ins-saison.co.jp/", "/banner-ads/005-saison" ];
	obPhotos2[4] = [ "satojimusyo.gif" , "広告：行政書士佐藤事務所" , "http://www.officesato.info/", "/banner-ads/006-sato" ];
	obPhotos2[5] = [ "aiaoi.gif" , "広告：藍葵麹町法律事務所" , "http://aakojimachi-hp.hp1.allin1.jp/", "/banner-ads/001-aiaoi" ];


	var thisPhotoID2 = Math.floor(Math.random()*(obPhotos2.length-1))+1;
	thisHtImage2.src = "/library/images/top/banner2/" + obPhotos2[thisPhotoID2][0];
	thisHtImage2.alt = obPhotos2[thisPhotoID2][1];
	thisHtImage2.parentNode.href = obPhotos2[thisPhotoID2][2];
	
	trackingUrl2 = obPhotos2[thisPhotoID2][3];
}

function sendTracking2() {
	if (trackingUrl2) {
		urchinTracker(trackingUrl2);
	}
	return;
}

