// 古賀市役所向けJavaScript
// 文字コードはEUCにてお願いします。

// --------------------------------------------------------------------------------------------
// ここから読込時に実行するプログラムです。
// --------------------------------------------------------------------------------------------
// CSSの任意切替JavaScript
// JavaScriptをオフられるとどうにもできないことはご容赦を。
var cookieName = "kogacityfont";// クッキーの名前。
var cookieExpDays = 30;// クッキーの有効期限。日数で指定。
var cookiePath = "/";
var FontSizeEm = 0; //
FontSizeEm = getCookie(cookieName); //Cookieから読み込みます。
if ((FontSizeEm == "")||(FontSizeEm == "10")) { //Cookieが空だったら。
	//何もしなくて良い。
} else {
	FontSizeEm = Math.round( (FontSizeEm * 10) ) / 100;
	FontSizeEm = FontSizeEm +"em";

	document.write("<style type=\"text/css\">");
	document.write("<!--");
	document.write("body{ ");
	document.write("	font-size: "+FontSizeEm+";");
	document.write("}");
	document.write("-->");
	document.write("</style>");
}




// --------------------------------------------------------------------------------------------
// ここからfunctionです。
// --------------------------------------------------------------------------------------------

// 検索窓向けのスクリプトです。
function funcOnFocus(txtTargetIn,strNameIn) {
	if(txtTargetIn.value==strNameIn){
		txtTargetIn.value = "" ;
		txtTargetIn.style.color   = '' 
	} else {
		txtTargetIn.select() ; //入力済みのときは選択
	}
}

function funcOnBlur(txtTargetIn,strNameIn) {
	if(txtTargetIn.value=="") {
		txtTargetIn.value = strNameIn ;
		txtTargetIn.style.color   = '#CCCCCC' 
	}
}



// いつものマウスオンイベント系です。
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_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_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];}
}



// マウスオンでidタグのvisible/hiddenの切替を行います。
function GoshowId (showid) {
	if ( document.getElementById )
		document.getElementById( showid ).style.visibility   = 'visible' 
	else if ( document.all ) document.all( showid ).style.visibility = 'visible' 
	else if ( document.layers ) document.layers[ showid ].visibility = 'show' 

	//document.getElementById(hideid).style.visibility = "hidden";
	//document.getElementById(showid).style.visibility = "visible";
}

function GohideId (showid) {
	if ( document.getElementById )
		document.getElementById( showid ).style.visibility   = 'hidden' 
	else if ( document.all ) document.all( showid ).style.visibility = 'hidden' 
	else if ( document.layers ) document.layers[ showid ].visibility = 'hide' 

	//document.getElementById(showid).style.visibility = "hidden";
}


// CSSのfont-sizeを調整します。
function ChangeFONTSIZE (FontSize) {
	// CSSの任意切替JavaScript
	// JavaScriptをオフられるとどうにもできないことはご容赦を。
	// クッキーの名前。
	var cookieName = "kogacityfont";
	
	// クッキーの有効期限。日数で指定。
	var cookieExpDays = 30;

	// クッキーのパス設定。例えば、サイトのホームディレクトリのパス("/" や
	// "/~user/")を指定すれば、1ページでのスタイル切替をサイト内のすべての
	// ページに反映させるようなことも可能です。
	var cookiePath = "/";

	//alert (document.body.style);
	var FontSizeEm = 0; //
	FontSizeEm = getCookie(cookieName); //Cookieから読み込みます。
	//alert (FontSizeEm);
	if (FontSizeEm == "") { //Cookieが空だったら。
		if (FontSize == "+") {
			FontSizeEm = 11;
			setCookie(cookieName, FontSizeEm, cookieExpDays, cookiePath);
			FontSizeEm = Math.round( (FontSizeEm * 10) ) / 100;
			FontSizeEm = FontSizeEm +"em";
			document.body.style.fontSize = FontSizeEm;
		}
		else if (FontSize == "-") {
			FontSizeEm = 10;
			setCookie(cookieName, FontSizeEm, cookieExpDays, cookiePath);
			FontSizeEm = Math.round( (FontSizeEm * 10) ) / 100;
			FontSizeEm = FontSizeEm +"em";
			document.body.style.fontSize = FontSizeEm;
		}
		else {
			//何もしない
		}
	} else {
		if (FontSize == "+") {
			//FontSizeEm = 1.1;
			FontSizeEm++; //加算代入します。
			setCookie(cookieName, FontSizeEm, cookieExpDays, cookiePath);
			FontSizeEm = Math.round( (FontSizeEm * 10) ) / 100;
			FontSizeEm = FontSizeEm +"em";
			document.body.style.fontSize = FontSizeEm;
		} 
		else if (FontSize == "-") {
			FontSizeEm = 10;
			setCookie(cookieName, FontSizeEm, cookieExpDays, cookiePath);
			FontSizeEm = Math.round( (FontSizeEm * 10) ) / 100;
			FontSizeEm = FontSizeEm +"em";
			document.body.style.fontSize = FontSizeEm;
		}
		else {
			//何もしない
		}
	}
}


/*
 * クッキーを取得する。
 */
function getCookie(name) {
	return document.cookie.match("\\b" + name + "=([^;]*)")
	? unescape(RegExp.$1) : "";
}

/*
 * クッキーを発行する。
 */
function setCookie(name, value, days, path) {
	var       temp  =   name + "=" + escape(value);
	if (days) temp += "; expires=" + expires(days);
	if (path) temp += "; path="    + escape(path);
	document.cookie = temp;
}

function expires(days) {
	var date = new Date();
	date.setTime(date.getTime() + (days * 24*60*60*1000));
	return date.toGMTString();
}

/*
 * get変数を解析します。
 */
function getArg() {
	getArg.data = new Array();
	getArg.string = location.search.substring(1);//?をサプレス
	if (getArg.string) {
		getArg.string = getArg.string.split('&');
		for(var i = 0; i != getArg.string.length; i++) {
			getArg.data[ck_shikibetushi(getArg.string[i].split('=')[0])] 
	        =  Escape(unescape(getArg.string[i].split('=')[1]));
		}
	}
}

function ck_shikibetushi(shiki) { //識別子（プロパティ）の命名チェック
	shiki_TOP = shiki.substring(0,1);
	if(shiki_TOP.match(/[a-zA-Z_$]/g) == null) {
		alert(shiki+"の引数が不正です。（一文字目は、ASCII、_、$、のいずれかです。）");
		return null;
	}
	else if(shiki.match(/[^a-zA-Z0-9_$]/g) != null) {
		alert(shiki+"の引数が不正です。（命名文字は、ASCII、数字、_、$、のいずれかです。）");
		return null;
	} 
	return shiki;
}

function Escape(str) { //文字参照へ変換 
	str = str.replace( /\&/g, '&amp;' );
	str = str.replace( /</g, '&lt;' ); 
	str = str.replace( />/g, '&gt;' ); 
	str = str.replace( /\"/g, '&quot;' );
	str = str.replace( /\'/g, '&#39;' );
	return str;
}


function SWwopen(WO){
  NewWin=window.open("","SWindow","toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=680");
  NewWin.location.href=WO;
  NewWin.focus();
  NewWin.moveTo(20,20);
}

function kogaBss(w){
	window.status=w;
	return true;
}
function kogaBcs(){
	window.status='';
}