//body、onload設定
//#####################################################################

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


function subNaviOpen() {
	var btnAll = document.getElementById('btnAll').getElementsByTagName('img')[0];
	var guideMenu = document.getElementById('globalNavi').getElementsByTagName('ul')[0].getElementsByTagName('ul');

	if (guideMenu[0].style.display == 'block') {
		btnAll.setAttribute('src', btnAll.src.replace('btn_all_none', 'btn_all_block'));
		btnAll.setAttribute('alt', btnAll.alt.replace('ガイドメニューをすべて閉じる', 'ガイドメニューをすべて見る'));

		for (var i=0; i<guideMenu.length; i++) {
			guideMenu[i].style.display = 'none';
		}
	}
	else {
		btnAll.setAttribute('src', btnAll.src.replace('btn_all_block', 'btn_all_none'));
		btnAll.setAttribute('alt', btnAll.alt.replace('ガイドメニューをすべて見る', 'ガイドメニューをすべて閉じる'));

		for (var i=0; i<guideMenu.length; i++) {
			guideMenu[i].style.display = 'block';
		}
	}

}

function popWindow() {
	var aTag = document.getElementsByTagName('a');
	var ua = navigator.userAgent;

	for (var i=0; i<aTag.length; i++) {
		if (aTag[i].className == 'openParent') {
			if (ua.indexOf('MSIE') >= 0) {
				aTag[i].setAttribute("onclick", new Function ("parentWindow(this.href); return false;"));
			}
			else {
				aTag[i].setAttribute("onclick","parentWindow(this.href); return false;");
			}
		}
		else if(aTag[i].className == 'openWindow') {
			if (ua.indexOf('MSIE') >= 0) {
				aTag[i].setAttribute("onclick", new Function ("openWindow(this.href,'miniWin'," + 700 + ',' + 650 + ") ; return false;"));
			}
			else {
				aTag[i].setAttribute("onclick","openWindow(this.href,'miniWin'," + 700 + ',' + 650 + ") ; return false;");
			}
		}
		else if(aTag[i].className == 'openClub-bellemaison') {
			if (ua.indexOf('MSIE') >= 0) {
				aTag[i].setAttribute("onclick", new Function ("openWindow(this.href,'miniWin'," + 700 + ',' + 350 + ") ; return false;"));
			}
			else {
				aTag[i].setAttribute("onclick","openWindow(this.href,'miniWin'," + 700 + ',' + 350 + ") ; return false;");
			}
		}
		else if(aTag[i].className == 'openKiyaku') {
			if (ua.indexOf('MSIE') >= 0) {
				aTag[i].setAttribute("onclick", new Function ("openWindow(this.href,'miniWin'," + 600 + ',' + 540 + ") ; return false;"));
			}
			else {
				aTag[i].setAttribute("onclick","openWindow(this.href,'miniWin'," + 600 + ',' + 540 + ") ; return false;");
			}
		}

	}
}

function openWindow(url,n,w,h) {
	window.open(url,n,"width=" + w + ", height=" + h + ", menubar=no, toolbar=no, scrollbars=yes, resizable=yes");
}

function parentWindow(url) {
	if (window.opener && !window.opener.closed) {
		window.opener.location.href = url;
	}
	else {
		window.open(url, null);
	}
}

