﻿function mtRollover() {
	if(document.getElementsByTagName) {
		
		var images = document.getElementsByTagName("img");
		var current;
		
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("group") == "gnavi"){
				//gnavi
				if(!current){
					current = images[i].getAttribute("current");
				}
				//current属性を含む時のみ処理を実行
				if(current){
					current = current.substr(current.indexOf("_")+1);
					var me = images[i].getAttribute("src");
					//画像がnaviフォルダ内にあることが前提
					me = me.substring(me.indexOf("/navi/")+6, me.indexOf("_off."));
					
					if(me == current){
						//フォーカス固定
						images[i].setAttribute("src", images[i].getAttribute("src").replace("_off.", "_on."))
					}
					else
					{							
						if(images[i].getAttribute("src").match("_off."))
						{
							images[i].onmouseover = function() {
								this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
							}
							images[i].onmouseout = function() {
								this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
							}
						}
					}
				}
			}
		}
		current = null;
		for(var i=0; i < images.length; i++) {		
			if(images[i].getAttribute("group") == "subnavi"){
				//subnavi
				if(!current){
					current = images[i].getAttribute("current");
					if(!current){
						current = "00_all"
					}
				}
				var me = images[i].getAttribute("src");
				//画像がsubnaviフォルダ内にあることが前提
				me = me.substring(me.indexOf("/subnavi")+9, me.indexOf("_off."));
				me = me.substr(me.indexOf("/")+1);		
				
				if(me == current){
					//フォーカス固定
					images[i].setAttribute("src", images[i].getAttribute("src").replace("_off.", "_on."))
				}
				else
				{							
					if(images[i].getAttribute("src").match("_off."))
					{
						images[i].onmouseover = function() {
							this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
						}
						images[i].onmouseout = function() {
							this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
						}
					}
				}
			}
		}
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("group") == "banner"){
				if(images[i].getAttribute("src").match("_off."))
				{
					images[i].onmouseover = function() {
						this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
					}
					images[i].onmouseout = function() {
						this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
					}
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", mtRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", mtRollover);
}