// JavaScript Document


/*
01.PageTop
02.RollOver 
03.Current 
04.popup window
*/


/*  01.PageTop
---------------------------------------------------------------------------------- */

var ScrollWin = {
	w3c : document.getElementById,
	iex : document.all,
	scrollLoop : false, 
	scrollInterval : null, // setInterval id
	currentBlock : null,   // object reference
	getWindowHeight : function(){
		if(this.iex) return (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		else return window.innerHeight;
	},
	getScrollLeft : function(){
		if(this.iex) return (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		else return window.pageXOffset;
	},
	getScrollTop : function(){
		if(this.iex) return (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		else return window.pageYOffset;
	},
	getElementYpos : function(el){
		var y = 0;
		while(el.offsetParent){
			y += el.offsetTop
			el = el.offsetParent;
		}
		return y;
	},
	scroll : function(num){
		if(!this.w3c){
			location.href = "#"+this.anchorName+num;
			return;
		}
		if(this.scrollLoop){
			clearInterval(this.scrollInterval);
			this.scrollLoop = false;
			this.scrollInterval = null;
		}
		if(this.currentBlock != null) this.currentBlock.className = this.offClassName;
		this.currentBlock = document.getElementById(this.blockName+num);
		this.currentBlock.className = this.onClassName;
		var doc = document.getElementById(this.containerName);
		var documentHeight = this.getElementYpos(doc) + doc.offsetHeight;
		var windowHeight = this.getWindowHeight();
		var ypos = this.getElementYpos(this.currentBlock);
		if(ypos > documentHeight - windowHeight) ypos = documentHeight - windowHeight;
		this.scrollTo(0,ypos);
	},
	scrollTo : function(x,y){
		if(this.scrollLoop){
			var left = this.getScrollLeft();
			var top = this.getScrollTop();
			if(Math.abs(left-x) <= 1 && Math.abs(top-y) <= 1){
				window.scrollTo(x,y);
				clearInterval(this.scrollInterval);
				this.scrollLoop = false;
				this.scrollInterval = null;
			}else{
				window.scrollTo(left+(x-left)/2, top+(y-top)/2);
			}
		}else{
			this.scrollInterval = setInterval("ScrollWin.scrollTo("+x+","+y+")",50);
			this.scrollLoop = true;
		}
	}
};


//  ↓↓Edit these variables
ScrollWin.containerName = "container";
ScrollWin.anchorName    = "top";
ScrollWin.blockName     = "block";
//　↑↑ Edit these variables								　　　

ScrollWin.onClassName   = "active";
ScrollWin.offClassName  = "visited";





/*  02.RollOver 
---------------------------------------------------------------------------------- 

	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/


function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}





/*  03.Current ---------------------------------------------------------------------------------- */

/*ChangeImageNum*/
	function imgChangeNum(nam,num) {
		if(document.images && (checkObj != 1)) {
			document[nam].src = arrowSecond[num].src;
		}
	}

	/*ChangeImage*/
	imgId = "";
	stayId = "";
	function imgChange(imgName,imgState) {
		if(document.images) {
			stringId0 = imgName.substring(0,4);
			stringId = imgName
			if(((stringId0 == "navi") || (stringId0 == "navs")) && (stringId == imgId)){
				document[imgName].src = eval(imgName + "stay" + ".src");
			} else {
				document[imgName].src = eval(imgName + imgState + ".src");
			}
		}
	}

	function stayMenu(stayId){
		imgChange(stayId,"stay");
		imgId = stayId;
	}


/*  03-01
------------------------------------------------------------ */

function curentImg_01(){
	gnavi_01off.src = gnavi_01stay.src
	stayMenu('gnavi_01');
 	}

function curentImg_02(){
	gnavi_02off.src = gnavi_02stay.src
	stayMenu('gnavi_02');
 	}

function curentImg_03(){
	gnavi_03off.src = gnavi_03stay.src
	stayMenu('gnavi_03');
 	}

function curentImg_04(){
	gnavi_04off.src = gnavi_04stay.src
	stayMenu('gnavi_04');
 	}

function curentImg_05(){
	gnavi_05off.src = gnavi_05stay.src
	stayMenu('gnavi_05');
 	}
	
function curentImg_06(){
	gnavi_06off.src = gnavi_06stay.src
	stayMenu('gnavi_06');
 	}





/*  04. popup window 
 ---------------------------------------------------------------------------------- */
function openwin4(file,name,h,w) {//ʒuw_Z^[
	
	sw=screen.availWidth/2-w/2;
	sh=screen.availHeight/2-h/2
 	//h=screen.height

	
	mac = (navigator.appVersion.indexOf("Mac") != -1) ?true:false;
	ie = (navigator.appName.charAt(0) == "M") ?true:false;
	nn = (navigator.appName.charAt(0) == "N") ?true:false;
	
	if (mac){
		if (ie){
		// mac IE
		w+=1;
		h-=0;
		}
		
		else{
		// mac NN etc.
		w+=16;
		h-=0;
		}
	}
	else{
		if (ie){
		// win IE
		w+=17;
		h-=0;
		}
		else{
		// win NN etc.
		w+=16;
		h-=0;
		}
	}


newWin4= window.open(file,name,"height="+h+",width="+w+",top="+sh+",screenY="+sh+",left="+sw+",screenX="+sw+",toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1");
document.MM_returnValue = false;
newWin4.focus()
}
