var siteRoot='.co.jp/';
var curPg;
checkPageLoc();

//----- 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]+'s'+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);
}

//----- new window methods -----
function openSubWindow(winName,link){
	var w,h,p1,p2,params;
	if (link == null) { link = '' }
	switch (winName) {
		case 'outlet' : w = 600; h = 800; p1 = 'scrollbars,resizable,status=1'; break;
		case 'shouhin' : w = 600; h = 480; p1 = 'scrollbars,resizable,status=1'; break;
		case 'toi' : w = 600; h = 500; p1 = 'scrollbars,resizable,status=1'; break;
		case 'toi2' : w = 600; h = 700; p1 = 'scrollbars,resizable,status=1'; break;
		case 'toi3' : w = 750; h = 600; p1 = 'scrollbars,resizable,status=1'; break;
		case 'osusume' : w = 630; h = 700; p1 = 'scrollbars,resizable,status=1'; break;
		case 'size' : w = 860; h = 620; p1 = 'scrollbars,resizable,status=0'; break;
		case 'shousai' : w = 600; h = 600; p1 = 'scrollbars,resizable,status=1'; break;
		case 'hinoki' : w = 750; h = Math.round(screen.height*0.8); p1 = 'scrollbars,resizable,status=1'; break;
		case 'maetsubo' : w = 600; h = 480; p1 = 'scrollbars,resizable,status=1'; break;
		case 'mai' : w = 750; h = 520; 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() }
}

function openInOpener(link){
	if(window.opener != null) {
		opener.location.href = link;
		opener.focus();
		return true;
	} else { return false }
}
//----- 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 }
}



