// #################### CSSのためのブラウザ判定

function getOSType(){
	var uAgent = navigator.userAgent.toUpperCase();
	if (uAgent.indexOf("MAC") >= 0) return "MacOS";
	if (uAgent.indexOf("WIN") >= 0) return "Windows";
	return "";
}

function getBrowserName(){

	var aName  = navigator.appName.toUpperCase();
	var uName = navigator.userAgent.toUpperCase();
	if (uName.indexOf("SAFARI") >= 0)  return "Safari";
	if (uName.indexOf("OPERA") >= 0)  return "Opera";
	if (uName.indexOf("FIREFOX") >= 0)  return "FireFox";
	if (aName.indexOf("NETSCAPE") >= 0)  return "Netscape";
	if (aName.indexOf("MICROSOFT") >= 0) return "Explorer";
	return "";
}

os = getOSType();
browser = getBrowserName();

if (os == "MacOS")   fileName = "mac";
if (os == "Windows") fileName = "win";
document.write("<link rel=stylesheet href=css/all_" + fileName + ".css type=text/css>");

if (os == "MacOS")                            fileName = "mac_ie";
if (os == "Windows")                          fileName = "win_ie";
if (os == "MacOS"   && browser == "Explorer") fileName = "mac_ie";
if (os == "MacOS"   && browser == "Netscape") fileName = "mac_nn";
if (os == "MacOS"   && browser == "Safari")   fileName = "mac_sf";
if (os == "Windows" && browser == "Explorer") fileName = "win_ie";
if (os == "Windows" && browser == "Netscape") fileName = "win_nn";
if (os == "Windows" && browser == "Opera")    fileName = "win_op";
if (os == "Windows" && browser == "FireFox")  fileName = "win_ff";
document.write("<link rel=stylesheet href=./css/all_" + fileName + ".css type=text/css>");


// #################### マウスオーバー時の画像切り替え

function m_over(file_name,imgname) {
	document.images[imgname].src = "./img_cmn/btn_" + file_name + "_anim.gif";
}

function m_out(file_name,imgname) {
	document.images[imgname].src = "./img_cmn/btn_" + file_name + ".gif";
}

// #################### ウィンドウ　オープン
// ########## Sub Window Open (Win,Mac-IE4不具合回避済み)
//## WindowのFocus()処理はサブウィンドウ側にonLoadイベントで仕込む事
var newwin = "";
var winie4 = ( navigator.userAgent.indexOf('MSIE 4')!=-1 && win );
function WinOpen(URL,WN,F) {
	if( sbwin_closed(newwin) ){
		newwin = window.open(URL,WN,F);
	}else{
		newwin.location.href = URL;
	}
}
//## Win IE4／Mac IE4でclosed判定バグ回避
function sbwin_closed(winVar) {
	if( !winVar ) {
		if( winie4 ) return winVar.closed;
		else return typeof winVar.document != 'object';
	}else{
		return true;
	}
}
