var siteRoot='or.jp/';
var curPg;
checkPageLoc();
//addPopup('gaiyou,gakkou,boshu,oshirase,jouhou');

//----- get current location -----
function checkPageLoc() {
	var pgSrc = document.location.href;
	var pgLoc = pgSrc.substring(pgSrc.indexOf(siteRoot)+siteRoot.length);
	if (pgLoc.indexOf('/') >= 0) { top.setMenuLoc(pgLoc) }
	else { activeBtns = 'top' }
}

//----- setup activeBtns -----
function setMenuLoc(loc){
	if (window.activeBtns == null) { window.activeBtns = '' }
	var bi = [0];
	for ( i=0; i<2; i++ ) {
		bi[i+1] = loc.indexOf('/',bi[i])+1;
		if (bi[i+1] > bi[i]) {
			if (activeBtns != '') { activeBtns += ',' }
			activeBtns += loc.substring(bi[i],bi[i+1]-1);
		}
	}
}
//----- button/link methods -----
function initBtn(who, closePopups) {
	who.onload = '';
	var s = splitRovrSrc(who.src);
	if (window.activeBtns != null && activeBtns.indexOf(getRovrName(who)) >= 0) { who.src = s[0]+'a'+s[1]; return }
	who.onmouseover = (closePopups != null && closePopups == true) ? function() { setRovrState(who,'o'); closeAllPopups() } : function() { setRovrState(who,'o') };
	who.onmouseout = function() { setRovrState(who,'n') };
	var img = new Image(); img.src = s[0]+'o'+s[1];
}
function initLinkIcn(who) {
	who.onload = '';
	var s = splitRovrSrc(who.src);
	var a = who.parentNode;
	if (a.tagName.toLowerCase() == 'a') {
		a.onmouseover = function() { setRovrState(who,'o'); };
		a.onmouseout = function() { setRovrState(who,'n'); };
		var img = new Image(); img.src = s[0]+'o'+s[1];
	} else {
		setRovrState(who,'s');
	}
}
function setRovrState(who, state) {
	if (window.activeBtns != null && activeBtns.indexOf(getRovrName(who)) >= 0) { state = 'a' }
	if (state == null) { state = "n" }
	var s = splitRovrSrc(who.src);
	who.src = s[0]+state+s[1];
}
function splitRovrSrc(src) {
	var i = src.lastIndexOf('_')+1;
	return [src.substring(0,i),src.substring(i+1)];
}
function getRovrName(who) {
	var s = splitRovrSrc(who.src);
	s = s[0].substring(0,s[0].lastIndexOf('_'));
	return s.substring(s.lastIndexOf('_')+1);
}

//----- popup methods -----

//----- init popup methods -----
//-- right now this is only set up for single popups --
/*
function addPopup(who) {
	if (window.popDB == null) { window.popDB = { menus:{}, curPop:null }; }
	who = who.split(',');
	for (var i=0; i<who.length; i++) {
		popDB.menus[who[i]] = { menu:null, trgr:null, open:false, timer:null }
	}
}
function initPopups() {
	for (var who in popDB.menus) {
		var p = popDB.menus[who];
		if ((p.menu = getById('pop_'+who)) != null) {
			p.menu.onmouseover = function () { stopPopTimer() };
			p.menu.onmouseout = function () { hidePopup() };
		} else { error('pop_'+who) }
		if ((p.trgr = getById('popTrgr_'+who)) != null) {
			p.trgr.onmouseover = function () { showPopup(this) };
			p.trgr.onmouseout = function () { hidePopup() };
			setPopTrgrState(p.trgr);
		} else { error('popTrgr_'+who) }
		delete p;
	}
	function error(a) { alert('ERROR: >> [initPopups()] オブジェクト“'+a+'”が見つかりません。');};
}
function showPopup(who) {
	who = popDB.menus[who.id.substring(who.id.indexOf('_')+1)];
	if (who != popDB.curPop && popDB.curPop != null) { closePopup() }
	popDB.curPop = who;
	setPopTrgrState(who.trgr,'o');
	who.menu.style.left = 0; who.menu.style.top = 0;
	var offset = getPos(who.trgr);
	if (browserIs('ie:mac')) { offset.x -= getPos(getById('page')).x }
//	who.menu.style.left = offset.x + (who.trgr.offsetWidth/2) - (who.menu.offsetWidth/2);
	who.menu.style.left = offset.x;
	who.menu.style.top = offset.y + who.trgr.offsetHeight;
	who.menu.style.display = '';
	//-- fix "map info" offset for mac ie
	if (browserIs('ie:mac') && setMapInfoPos != null) { setMapInfoPos(0,-(offset.y + who.trgr.offsetHeight)-1) }
	//-- 
	who.open=true;
	setClass(who.trgr,'o');
	stopPopTimer(who);
}
function hidePopup() {
	if (popDB.curPop != null) { popDB.curPop.timer = setTimeout('closePopup()',100) }
}
function closePopup(who) {
	if (who == null) who = popDB.curPop;
	setPopTrgrState(who.trgr,'n');
	who.menu.style.display = 'none';
	setClass(who.trgr,'n');
	stopPopTimer();
}
function closeAllPopups() {
	for (var a in popDB.menus) { closePopup(popDB.menus[a]) }
}
function stopPopTimer() { clearTimeout(popDB.curPop.timer) }
function setPopTrgrState(who,state) {
	setRovrState(who.firstChild,state);
}
*/
//----- new window methods -----
function openSubWindow(winName,link){
	var w,h,p1,p2,params;
	if (link == null) { link = '' }
	switch (winName) {
		case 'shousai' : w = 600; h = 600; p1 = 'scrollbars,resizable,status=1'; break;
//		case 'shousai' : w = 600; h = Math.round(screen.height*0.8); p1 = 'scrollbars,resizable,status=1'; break;
		default : w = 0; h = 0; p = ''; p1=''; if (winName == null) { winName ='new' }
	}
	winName += '_win';
	if (w > 0 && h > 0) {
		var x = (screen.width - w) / 2;
		var y = (screen.height - h) / 2;
		if (browserIs('ie')) { y -= 32 }
		p2 = ',height=' + h + ',width=' + w + ',top=' + y + ',left=' + x;
	}
	if (window[winName] != null) {
		window[winName].focus();
	} else { w = window.open(link,winName,p1+p2); w.focus() }
}

//----- display methods -----
function toggleDisplay(who) {
	if (typeof who == "string") {
		who = getById(who);
	} else {
		who = who.nextSibling;
		while (who.tagName == null) { who = who.nextSibling }
	}
	who.style.display = (who.style.display == 'none') ? '' : 'none';
}
//----- misc methods -----
function checkLocationPD(who) {
	if (who.value == "-") { who.selectedIndex = 0 }
}


