//ロールオーバースクリプト----------------------------------------------------
//画像に-offを記述するとマウスオーバーで-onに切り替わる
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("-off."))
			//if(images[i].getAttribute("src").match(/_off＼./))
            {
            fileName = new Array(images[i].getAttribute("src").replace("-off.", "-on."));
            preImages = new Array();
            for (j=0; j<fileName.length; j++)
            {
            preImages[j] = new Image();
            preImages[j].src = fileName[j]; //「_on」の画像をプリロード
            }
				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", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}


//pulldownメニュー--------------------------------------------------------------
function popupMenu( id ){
	var obj = document.getElementById( id );
	obj.style.display = "block";
}

function popupHidden( id ){
	var obj = document.getElementById( id );
	obj.style.display = "none";
}

//ページスクロール------------------------------------------------------------------------------
function backToTop() {
  var x1 = x2 = x3 = 0;
  var y1 = y2 = y3 = 0;
  if (document.documentElement) {
      x1 = document.documentElement.scrollLeft || 0;
      y1 = document.documentElement.scrollTop || 0;
  }
  if (document.body) {
      x2 = document.body.scrollLeft || 0;
      y2 = document.body.scrollTop || 0;
  }
  x3 = window.scrollX || 0;
  y3 = window.scrollY || 0;
  var x = Math.max(x1, Math.max(x2, x3));
  var y = Math.max(y1, Math.max(y2, y3));
  window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
  if (x > 0 || y > 0) {
      window.setTimeout("backToTop()", 25);
  }
}

//プリント------------------------------------------------------------------------------
function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();		//印刷をします
	}
}


//new window
var yomotsuOpenWin = {
	
	conf : {
		className : "external",//リンク先を別ウインドウで開きたいa要素につけるclass名
		fileTypes : ["pdf","doc","xls","ppt"]//リンク先を別ウインドウで開きたいファイルの拡張子
	},

	main : function(){
		var fileTypesReg = "/";
		for(i = 0; i <yomotsuOpenWin.conf.fileTypes.length; i++){
			fileTypesReg += "\\."+yomotsuOpenWin.conf.fileTypes[i]+"$|";
		}
		fileTypesReg=fileTypesReg.slice(0, -1)+"/";
	
		var a = document.links;
		for (i = 0; i < a.length; i++) {
			if (new RegExp("\\b" + yomotsuOpenWin.conf.className + "\\b").exec(a[i].className)||
		    	(new RegExp(fileTypesReg).exec(a[i].getAttribute("href")))){
				a[i].onclick = yomotsuOpenWin.openWin;
				a[i].onkeypress = yomotsuOpenWin.openWin;
			}
		}
	},
		
	openWin : function(){
		window.open(this.href, "", "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, close=yes");
		return false;
	},
	
	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
	
}

yomotsuOpenWin.addEvent();