// list swap images
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];}
}
//end of list


//PreLoad Images
var preloadflag = false;
function PreLoad(){
	var preimgs = new Array();
	for(i = 0 ; i < Imglist.length ; i++){
		preimgs[i] = new Image();
		preimgs[i].src = Imglist[i];
	}
	preloadflag = true;
}



<!--
function page45(){
     window,open("kusyon.html","subwindow_sample","width=700,height=370,status=no,location=no,scrollbars=yes,toolbar=no,menubar=no,resizable=yes");
}

//-->



// O p e n   N e w   W i n d o w
function winOpener(url,winname,ToolBar,Loc,ScrlBar,Resize,Dir,Stats,Menu,wsize,hsize){
window.open(url,winname,"toolbar="+ToolBar+",location="+Loc+",directories="+Dir+",status="+Stats+",menubar="+Menu+",scrollbars="+ScrlBar+",resizable="+Resize+",width="+wsize+",height="+hsize);
}


/********************************************************************************
	関数名		SetStyleByPath
	機能		ページのURLからディレクトリ名を取得し、
				"接頭語+ディレクトリ名"というIDのタグに対してスタイルを
				設定する（<body onLoad="">で使用する）
	
	使い方		各カテゴリごとのサイドメニューに対して現在のカテゴリ名に
				装飾を行う、といった使い方です。
				
				http://aaa.com/bbb/ccc/ddd.html
				というページであった場合
				深度(iDirDepth)を3にすると、id="ddd"のタグに対してスタイルを
				設定します。
				深度(iDirDepth)を2にすると、id="ccc"のタグに対してスタイルを
				設定します。
				
				
	入力		bLocalFlg	Windows環境で動作確認をするための設定（1: Windows上 0:Server上）
				sPrefix		接頭語
				iDirDepth	チェックディレクトリ階層(ルートを1とする）
				
				sColor				スタイル設定: color
				sFontSize			スタイル設定: font-size
				sFontWeight			スタイル設定: font-weihgt
				sTextDecoration		スタイル設定: font-decoration
				sBackgroundColor	背景色: background-color
				sBackgroundImage	背景画像: background-img:url()
				sBorderTopColor		ボーダー色：border-top-color
				sBorderRightColor	ボーダー色：border-right-color
				sBorderBottomColor	ボーダー色：border-bottom-color
				sBorderLeftColor	ボーダー色：border-left-color
				
	出力		なし
	
	処理概要
				1. URLからパスを取得する
				2. パスを"/"で切り分け、配列に格納する
				3. チェック対象のディレクトリ名を取得する
				4. 対象のディレクトリ名と接頭語から対象IDを作成する
				5. 対象IDセレクタが存在しない場合
				 5.1. 終了する
				6. 各スタイルを設定する
				7. 終了する
********************************************************************************/
function SetStyleByPath(bLocalFlg, sPrefix, iDirDepth, sColor, sFontSize, sFontWeight, sTextDecoration, sBackgroundColor, sBackgroundImage, sBorderTopColor, sBorderRightColor, sBorderBottomColor, sBorderLeftColor) {

	var iPathCnt = 0;
	
	sPath = new String();
	aPathList = new Array();
	sTargetPath = new String();
	sTargetId = new String();
	
	// URLからパスを取得する
	sPath = location.pathname;
	
	// ローカル動作の場合
	if(bLocalFlg == 1){
		// パスを"\"で切り分ける
		aPathList = sPath.split("\\");
	} else {
		// パスを"/"で切り分ける
		aPathList = sPath.split("/");
	}
	
	// 指定階層が実際の階層よりも深い場合
	if(iDirDepth >= aPathList.length){
		iDirDepth = aPathList.length - 1;
	}
	// パスのリストに対して繰り返す
	for( iPathCnt = iDirDepth; iPathCnt >= 0; iPathCnt--){
		
		// チェック対象のディレクトリ名を取得する
		sTargetPath = aPathList[iPathCnt];
		
//		alert(sTargetPath + iPathCnt);
		
		// 対象のパスがファイル名の場合（"."を含む場合)
		if(sTargetPath.indexOf(".",0) != -1){
			// 拡張子以外の部分を取得する。
			sTargetPath = sTargetPath.substr(0, sTargetPath.indexOf(".", 0));
		}
		
		// 対象のパス（もしくはファイル名）に"-"が含まれる場合
		if(sTargetPath.indexOf("-",0) != -1){
			// アンダーバーを削除する。
			sTargetPath = sTargetPath.replace(/-/g, "");
		}
		// 対象のパス（もしくはファイル名）に"_"が含まれる場合
		if(sTargetPath.indexOf("_",0) != -1){
			// アンダーバーを削除する。
			sTargetPath = sTargetPath.replace(/_/g, "");
		}
		
		// 対象のディレクトリ名と接頭語から対象IDを作成する
		sTargetId = sPrefix + sTargetPath;
		
		// 対象IDセレクタが存在しない場合
		if(!document.getElementById(sTargetId)){
			
			// ルートパスにもマッチしない（すべてのパスにマッチしなかった場合）
			if(iPathCnt == 0){
				// 終了する
				return;
			}
			
			// 対象のパス名が"index"でない場合（単純な設定ミスの場合）
			if(sTargetPath != "index" && sTargetPath != ""){
				// 終了する
				return;
			}
		} else {
			// ID設定を有効と判断しパスチェックを終了する
			break;
		}
	}
	
	// 各スタイルを設定する
	if(sColor){
		document.getElementById(sTargetId).style.color = sColor;
	}
	if(sFontSize){
		document.getElementById(sTargetId).style.fontSize = sFontSize;
	}
	if(sFontWeight){
		document.getElementById(sTargetId).style.fontWeight = sFontWeight;
	}
	if(sTextDecoration){
		document.getElementById(sTargetId).style.textDecoration = sTextDecoration;
	}
	if(sBackgroundColor){
		document.getElementById(sTargetId).style.backgroundColor = sBackgroundColor;
	}
	if(sBackgroundImage){
		document.getElementById(sTargetId).style.backgroundImage = "url(" + sBackgroundImage + ")";
	}
	if(sBorderTopColor){
		document.getElementById(sTargetId).style.borderTopColor = sBorderTopColor;
	}
	if(sBorderRightColor){
		document.getElementById(sTargetId).style.borderRightColor = sBorderRightColor;
	}
	if(sBorderBottomColor){
		document.getElementById(sTargetId).style.borderBottomColor = sBorderBottomColor;
	}
	if(sBorderLeftColor){
		document.getElementById(sTargetId).style.borderLeftColor = sBorderLeftColor;
	}
	return;
}

