//　Macintosh               　->　MacOS
//　Windows95/98/NT/2000/XP 　->　Windows
//　UNIX                    　->　UNIX
function getOSType()
{
    var uAgent  = navigator.userAgent.toUpperCase();
    if (uAgent.indexOf("MAC") >= 0) return "MacOS";
    if (uAgent.indexOf("WIN") >= 0) return "Windows";
    if (uAgent.indexOf("X11") >= 0) return "UNIX";
    return "";
}

//　Firefox ->  Firefox
//　Netscape Navigator ->  Netscape
//　Internet Explorer  ->　Explorer
//　Safari  ->　Safari
//　Opera  ->　Opera
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 "";
}

function getBrowserVersion()
{
	var browser = getBrowserName();
	var version = 0;
	var s = 0;
	var e = 0;
	var appVer  = navigator.appVersion;
	var uName  = navigator.userAgent.toUpperCase();
	if (browser == "Safari")
	{
		s = uName.indexOf("SAFARI/",0);
		version = (uName.substring(s+7,s+99));
		if (version < 400) version = 1;
		if (version >= 400) version = 2;
	}
	if (browser == "Opera")
	{
		s = uName.indexOf("OPERA",0) + 6;
		e = uName.indexOf(" ",s);
		version = parseFloat(uName.substring(s,e));
	}
	if (browser == "Firefox")
	{
		s = uName.indexOf("FIREFOX/",0);
		version = parseFloat(uName.substring(s+8,s+8+3));
	}
	if (browser == "Netscape")
	{
		s = appVer.indexOf(" ",0);
		version = eval(appVer.substring(0,s));
		if (version >= 5) version++;
	}
	if (browser == "Explorer")
	{
		appVer  = navigator.userAgent;
		s = appVer.indexOf("MSIE ",0) + 5;
		e = appVer.indexOf(";",s);
		version = eval(appVer.substring(s,e));
	}
	return version;
}

//ブラウザ別スタイルシート設定
os      = getOSType();
browser = getBrowserName();
version = getBrowserVersion();
dirName = "style.css";
if (browser == "Firefox")  dirName = "style_ff.css";
if (browser == "Netscape") dirName = "style_nn.css";
if (browser == "Explorer") dirName = "style_ie.css";
if (browser == "Safari")   dirName = "style_saf.css";
if (browser == "Opera")    dirName = "style_op.css";
document.write("<link rel='stylesheet' href='"+dirName+"' type='text/css'>");

// メニュー･ロールオーバー
function rollOver(obj,val) {
	obj.className = val;
}

// URLリンク
function jumpUrl(url) {
	window.open(url,"new");
}

// 表示モード切替
function displayMode(mode) {
	document.getElementById('submenu').style.display = mode;
}

// ブラウザサイズを求める（プルダウンメニュー、位置調整用）
function getBrowserWidth ( ) { 
    if ( window.innerWidth ) { 
        return window.innerWidth; 
    } else if ( document.documentElement && document.documentElement.clientWidth != 0 ) { 
        return document.documentElement.clientWidth; 
    } else if ( document.body ) { 
        return document.body.clientWidth; 
    }   
    return 0;   
}  

// ポップアップメニュー
function popupMenu(obj, item, w, h) {

	var browser = getBrowserName();
	var submenu = document.getElementById('submenu');
	var w2 = 0;
	var h2 = 0;

	w2 = getBrowserWidth() / 2 + w;
	//if (browser == "Explorer") h2 = h-3;
    if ( h < 200 ) { 
		h2 = h-3;
    } else { 
		h2 = h+3;
    }   
	if (browser == "Firefox")  h2 = h-2;
	if (browser == "Netscape") h2 = h-2;

	// 製品情報，キャンペーン・イベント，サポート，報道資料，ジュピターオーディオについて
	// メニュー項目
	popupMenuItem = new Array();
	switch (item) {

	// 製品情報
	case 1:
		popupMenuItem.push("アナログ関連",      "analog.html");
		popupMenuItem.push("真空管アンプ関連",  "s_amplifier.html");
		popupMenuItem.push("ﾄﾗﾝｼﾞｽﾀｰｱﾝﾌﾟ関連",  "t_amplifier.html");
		popupMenuItem.push("スピーカー関連",    "speaker.html");
		popupMenuItem.push("デジタル関連",      "digital.html");
		popupMenuItem.push("チューナー関連",    "tuner.html");
		popupMenuItem.push("アクセサリー関連",  "accessory.html");
		popupMenuItem.push("オーディオその他",  "others.html");
		popupMenuItem.push("特選レコード",  "records.html");
		break;

	// サポート情報
	case 2:
		popupMenuItem.push("修理",           "repair.html");
		popupMenuItem.push("保証期間",       "guarantee.html");
		popupMenuItem.push("買取り",         "buying-up.html");
		break;

	// イベント情報
	case 3:
		popupMenuItem.push("いちおし！",   "special.html");
		break;

	// システム構成例
	case 4:
		popupMenuItem.push("ユーザー宅訪問", "owners.html");
		break;

	// 店舗案内
	case 5:
		popupMenuItem.push("アクセス",     "access.html");
		popupMenuItem.push("店舗紹介",     "inquiry.html");
		popupMenuItem.push("携帯用サイト", "keitai.html");
		break;

	}

	// メニュー作成
	var layer;
	var roop;
	var url;
        var chand;
	var subject;
        chand = "style='cursor:hand'";
        if (browser == "Firefox")  chand = "style='cursor:pointer'";
        if (browser == "Netscape") chand = "style='cursor:pointer'";
        if (browser == "Safari")   chand = "style='cursor:pointer'";
	layer = "<div id='popmenu' style='position:absolute;top:" + h2 + ";left:" + w2 + ";'>\n";
	roop = popupMenuItem.length / 2;
	for (i=0; i<roop; i++) {
		url = i * 2 + 1;
		subject = i * 2;
		layer += " <div id='submenu" + i + "' class='submenu01' " + chand;
		layer += "  onclick=window.open('" + popupMenuItem[url] + "','_top')"; //jumpUrl
		layer += "  onmouseover=rollOver(this,'submenu02');displayMode('block');";
		layer += "  onmouseout=rollOver(this,'submenu01');displayMode('none');>";
		layer += popupMenuItem[subject] + "</div>\n";
	}
	layer += "</div>\n";
	// ポップアップメニュー表示
	submenu.style.display = 'block';
	submenu.innerHTML = layer;
}

//ポップアップメッセージ
var IE = 0,NN = 0,N6 = 0;
if(document.all) IE = true;
else if(document.layers) NN = true;
else if(document.getElementById) N6 = true;

function OnLink(Msg,mX,mY,nX,nY){
	var pX = 0,pY = 0;
	var sX = 10,sY = 10;
	if(IE){
		MyMsg = document.all(Msg).style;
		MyMsg.visibility = "visible";
	}
	if(NN){
		MyMsg = document.layers[Msg];
		MyMsg.visibility = "show";
	}
	if(N6){
		MyMsg = document.getElementById(Msg).style;
		MyMsg.visibility = "visible";
	}
	if(IE){
		pX = document.body.scrollLeft;
		pY = document.body.scrollTop;
		MyMsg.left = mX + pX + sX;
		MyMsg.top = mY + pY + sY;
	}
	if(NN || N6){
		MyMsg.left = nX+ sX;
		MyMsg.top = nY + sY;
	}
}
function OffLink(Msg){
	if(IE) document.all(Msg).style.visibility = "hidden";
	if(NN) document.layers[Msg].visibility = "hide";
	if(N6) document.getElementById(Msg).style.visibility = "hidden";
}

//携帯サイト別画面表示
function keitai(){
	window.open("keitai.html","betu","width=300,height=600,scrollbars=yes,status=no,resizable=no,toolbar=no,location=no,menubar=no");
}

