// スタイルシート（ブラウザの判別）
var ua = navigator.userAgent;
var na = navigator.appName;
var ve = navigator.appVersion;

var Win = (ua.indexOf ("Win") != -1);
var Mac = (ua.indexOf ("Mac") != -1);
var Explorer = (na.indexOf ("Explorer") != -1);
var Netscape= (na.indexOf ("Netscape") != -1);
var Opera = (ua.indexOf ("Opera") != -1);
var Safari = (ua.indexOf ("Safari") != -1);

if (Explorer) {
    if (ua.indexOf ("MSIE 3") != -1) { var Version = "3"; }
    else if (ua.indexOf ("MSIE 4") != -1) { var Version = "4"; }
    else if (ua.indexOf ("MSIE 5") != -1) { var Version = "5"; }
    else { var Version = "6"; }
} else {
    var Version = ve.charAt(0);
}

if (Safari) { type = "mac_nn6"; }
else if (Mac && Opera && Version == "5") { type = "error"; }
else if (Opera) { type = "pixel"; }
else if (Win && Explorer && Version != "6") { type = "key_tra"; }
else if (Win && Explorer && Version == "6") { type = "key_tra"; }
else if (Win && Netscape && Version == "4") { type = "error"; }
else if (Mac && Explorer && Version != "5" && Version != "6") { type = "error"; }
else if (Mac && Explorer && Version == "5") { type = "pixel"; }
else if (Mac && Explorer && Version == "6") { type = "pixel"; }
else if (Mac && Netscape && Version == "5") { type = "mac_nn6"; }
else if (Mac && Netscape && Version == "4") { type = "error"; }
else { type = "pixel" }

path = "";
pn = window.location.pathname;
pn = pn.substr (1);
pn = pn.split ("/");
p = pn.length - 4; // ドメインから下の階層数+1
for (i=0; i<p; i++) {
    path += "../";
}

// 未対応ブラウザ
if (type == "error") { location.href = "http://www.838.fm/siteinfo/" + type + ".html"; }


path += "/shared/css/";

// テキスト関連CSS
document.write ("<link rel=\"stylesheet\" href=\"" + path + type + ".css\" type=\"text/css\" media=\"screen,print\">");




// SWFから別ウインドウを表示
function openWin(W,H,C) {
	// 開きたいウィンドウの大きさをW,Hに、Cが1なら中央、0なら左上に配置
	if (C == 1) {
		scrW=screen.width;
		scrH=screen.height;
		
		openX = ((scrW/2) - (W/2));
		openY = ((scrH/2) - (H/2));
	} else {
		openX = 0;
		openY = 0;
	}
	//以下、各ブラウザ用のウィンドウ起動、また、微調整出来るように分岐
	//今回は同じ開き方に設定しているが、ステータスバーを表示したり、メニューバーを表示させたりすると、
	//IEとNNでは領域の扱いが異なるため、微調整が必要になるかもねん。
	if (navigator.appName == "Microsoft Internet Explorer") {
		if (navigator.platform.substr(0,3) == "Mac") {
			//Mac IE用に調整
			childWin = window.open("request/","childwin","scrollbars=yes,width=" + W+ ",height=" + H + ",left=" +  openX + ",top=" + openY );
		} else{
			//Win IE用に調整
			childWin = window.open("request/","childwin","scrollbars=yes,width=" + W+ ",height=" + H + ",left=" +  openX + ",top=" + openY );
		}
	} else {
	//Netscape用に調整
	childWin = window.open("request/","childwin","scrollbars=yes,width=" + W+ ",height=" + H + ",screenX=" +  openX + ",screenY=" + openY );
	}
}


// セレクトメニューによる別ウインドウ表示
function Navi()
{url=document.navi.program.selectedIndex;
if (url == 0){
url=document.navi.program.options[url].value;
location.href=url;}
else{
url=document.navi.program.options[url].value;
window.open(url,"program","width=500,height=500,scrollbars=yes");}
}

// サブウインドウ表示
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// イメージをプリロード
/* preload images */
function preloadImages() {
	var d = document;
	if (d.images) {
		if (!d.p) d.p = new Array();
		var i, j = d.p.length, a = preloadImages.arguments;
		for (i = 0; i < a.length; i++)
		if (a[i].indexOf("#")) {
			d.p[j] = new Image();
			d.p[j++].src = a[i];
		}
	}
}

/* find object */
function findObj(n,d) {
	var p, i, x;
	if (!d) d = document;
	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0,p);
	}
	if (!(x = d[n]) && d.all) x = d.all[n];
	for (i = 0; !x && i < d.forms.length; i++)
	x = d.forms[i][n];
	for (i = 0; !x && d.layers && i < d.layers.length; i++)
	x = findObj(n,d.layers[i].document);
	return x;
}

/* swap image */
function swapImage() {
	var i, j = 0, x, a = swapImage.arguments;
	document.sr = new Array;
	for (i = 0; i < (a.length - 2); i += 3)
	if ((x = findObj(a[i]))) {
		document.sr[j++] = x;
		if (!x.oSrc) x.oSrc = x.src; x.src = a[i+2];
	}
}

/* swap image restore */
function swapImgRestore() {
	var i, x, a = document.sr;
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
	x.src = x.oSrc;
}

/* preload images array */
preloadImages (
	'/shared/img/btn1_f2.gif',
	'/shared/img/btn2_f2.gif',
	'/shared/img/btn3_f2.gif',
	'/shared/img/btn4_f2.gif',
	'/shared/img/btn5_f2.gif',
	'/shared/img/btn6_f2.gif'
);



