﻿//OS,ブラウザ判別-------------------------------------------------------
isMac    = (navigator.appVersion.toLowerCase().indexOf("mac") != -1) ? true : false;
isWin    = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
isXP     = (navigator.userAgent.indexOf("NT 5.1") != -1) ? true : false;
isVista  = (navigator.userAgent.indexOf("NT 6.0") != -1) ? true : false;
isIE     = (navigator.userAgent.indexOf("MSIE")     != -1) ? true : false;
isNS     = (navigator.userAgent.indexOf("Netscape") != -1) ? true : false;
isFF     = (navigator.userAgent.indexOf("Firefox")  != -1) ? true : false;
isSafari = (navigator.userAgent.indexOf("Safari")   != -1) ? true : false;
//ブラウザの系統で分岐
isMSIE = false;
isNN   = false;
if(isIE){
	isMSIE = true;
}
if(isNS||isFF||isSafari){
	isNN   = true;
}
//IEの場合バージョン、モードの取得 
isHit    = false;
isIE6    = false;
isIE7    = false;
isIEmode = false;
if(isIE){
	isHit = navigator.userAgent.indexOf("MSIE");
	
	if(isHit && navigator.userAgent.substr(isHit+5, 1) == "6"){// バージョンが6かどうか
		isIE6 = true;
	}
	if(isHit && navigator.userAgent.substr(isHit+5, 1) == "7"){// バージョンが7かどうか
		isIE7 = true;
	}
	if(document.compatMode == "CSS1Compat"){// 標準モードかどうか
		isIEmode = true;
	}
}
//Flashバージョンの取得-------------------------------------------------
function getFlashPlayerVersion() {
    var vsn = '';
    if( navigator.plugins && navigator.mimeTypes.length ) {     // not IE
        var tmp = navigator.plugins["Shockwave Flash"].description.split(" ");
		var ver = tmp[2].split(".");
		//document.write(navigator.plugins["Shockwave Flash"].description);
		//document.write("NN: "+tmp[2]+" / "+ver[0]);
        vsn = ver[0];
    } else {    // IE
        var tmp = new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").split(" ");
		var ver = tmp[1].split(",");
		//document.write(new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version"));
		//document.write("IE: "+tmp[1]+" / "+ver[0]);
        vsn = ver[0];
    }
    return vsn;
}
if(getFlashPlayerVersion() < 8 ){ //Flash取得ページへリンク
	location.href = "./flash-err.html";
}
//ブラウザ毎のウインドウ項目幅高さのオフセット--------------------------
function getOffset(){
	var offset = new Array();
	offset[0] = 0;//タスクバー
	offset[1] = 0;//幅
	offset[2] = 0;//高さ
	
	if(isWin){
		if(isXP){//XPの場合
		//document.write('Windows xp<br>\n');
			offset[0] = 30;
			if(isIE7){
				offset[1] = 29;
				offset[2] = 176;
			}else if(isIE){
				offset[1] = 29;
				offset[2] = 154;
			}else if(isFF){
				offset[1] = 8;
				offset[2] = 170;
			}else if(isNS){
				offset[1] = 8;
				offset[2] = 170;
			}else if(isSafari){
				offset[1] = 4;
				offset[2] = 136;
			}
		}else if(isVista){//Vistaの場合
		//document.write('Windows Vista<br>\n');
			offset[0] = 32;
			if(isIE){
				offset[1] = 37;
				offset[2] = 162;
			}else if(isFF){
				offset[1] = 16;
				offset[2] = 181;
			}else if(isNS){
				offset[1] = 16;
				offset[2] = 170;
			}else if(isSafari){
				offset[1] = 4;
				offset[2] = 136;
			}
		}else{//その他のWindows
		//document.write('Windows<br>\n');
			offset[0] = 0;
			if(isIE){
				offset[1] = 28;
				offset[2] = 124;
			}else if(isFF){
				offset[1] = 8;
				offset[2] = 167;
			}else if(isNS){
				offset[1] = 8;
				offset[2] = 163;
			}
		}
	}else if(isMac){
	//document.write('Mac OS<br>\n');
		offset[0] = 22;
		if(isSafari){
			offset[1] = 0;
			offset[2] = 111;
		}else if(isFF){
			offset[1] = 0;
			offset[2] = 102;
		}else if(isNS){
			offset[1] = 0;
			offset[2] = 119;
		}
		//Mac版IEはサポート終了のため対応せず（FlashPlayer7まで）
		//}else if(isIE){
		//	offset[1] = 37;
		//	offset[2] = 109;
		//}
	}
	return offset;
}
//インナーウインドウ幅を取得----------------------------------------------------
// 戻り値 integer(i)
function getWidth(){
	if(isIE){
		if(isIE6 && isIEmode){
			var nWidth = document.documentElement.clientWidth;
		}else{
			var nWidth = document.body.clientWidth;
		}
	}else{
		var nWidth = window.innerWidth;
	}
	return nWidth;
}
//インナーウインドウ高さを取得--------------------------------------------------
// 戻り値 integer(i)
function getHeight(){
	if(isIE){
		if(isIE6 && isIEmode){
			var nHeight = document.documentElement.clientHeight;
		}else{
			var nHeight = document.body.clientHeight;
		}
	}else{
		var nHeight = window.innerHeight;
	}
	return nHeight;
}
//ウインドウを指定サイズにする------------------------------------------
//instSizeWin(Xピクセル,Yピクセル,表示位置)
function instSizeWin(ix,iy,center){
	//ウインドウ枠などのオフセット値を求める
	var offset = getOffset();
	ix = ix + offset[1];
	iy = iy + offset[2];
	//document.write(ix + ':' + iy+ '<br>\n');
	window.resizeTo(ix,iy);
	
	//画面センター指定の場合
	if(center){
		var sw = (window.screen.availWidth - ix) / 2;
		var sh = (window.screen.availHeight - iy - offset[0]) / 2;
		window.moveTo(sw,sh);
	}
	window.focus();
}
//ウインドウをスクリーンサイズにする------------------------------------
function maxSizeWin(){
	window.moveTo(0,0);
	window.resizeTo(window.screen.availWidth, window.screen.availHeight);
	window.focus();
}
//ウインドウを開く------------------------------------------------------
function MM_openBrWindow(theURL,winName,features) { //v2.0
	//javascript:MM_openBrWindow('index2.html','WIN','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=640,height=480');
	window.open(theURL,winName,features);
	//window.focus();
}
//ウインドウをセンターにする----------------------------------------
function winCenter(){
	ix = getWidth();
	iy = getHeight();
	var sw = (window.screen.availWidth - ix) / 2;
	var sh = (window.screen.availHeight - iy) / 2;
	window.moveTo(sw,sh);
	window.focus();
}
//オープンしたウインドウを閉じる----------------------------------------
function winClose(){
	window.close();
}
//ウインドウフォーカスする----------------------------------------------
function winFocus(){
	window.focus();
}
//Flashを表示する-------------------------------------------------------
//表示タグ
function flaw(swf, ld, md, wpix, hpix, col, bk){
//初期設定
	//var swf_path  = './' + swf + '.swf?md=' + md + '&ld=./openworld/' + ld + '.swf';
	var swf_path  = './' + swf + '.swf?md=' + md + '&bk=' +bk;
	var swf_w     = wpix;
	var swf_h     = hpix;
	var swf_bgcol = col;
	var swf_scal  = 'noscale';
	var swf_clsid = 'd27cdb6e-ae6d-11cf-96b8-444553540000';
	var swf_cbase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0';
	var swf_name  = 'YOBOUSAN';
	var swf_pual  = 'high';
	var swf_asacc = 'always';
	//var swf_wmode = 'opaque';

	document.write('<object classid="clsid:'+ swf_clsid +'" codebase="'+ swf_cbase +'" width="'+ swf_w +'" height="'+ swf_h +'" id="'+ swf_name +'" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="'+ swf_asacc +'" />\n');
	document.write('<param name="movie" value="'+ swf_path +'" />\n');
	document.write('<param name="loop" value="false" />\n');
	document.write('<param name="menu" value="false" />\n');
	document.write('<param name="quality" value="'+ swf_pual +'" />\n');
	document.write('<param name="scale" value="' + swf_scal + '" />\n');
	document.write('<param name="bgcolor" value="#' + swf_bgcol + '" />\n');
	//document.write('<param name="wmode" value="' + swf_wmode + '" />\n');
	
	var embed = '<embed src="' + swf_path;
	embed += '" loop="false';
	embed += '" menu="false';
	embed += '" quality="' + swf_pual;
	embed += '" scale="noscale' + swf_scal;
	embed += '" width="' + swf_w;
	embed += '" height="' + swf_h;
	embed += '" name="' + swf_name;
	//embed += '" wmode="' + swf_wmode;
	embed += '" bgcolor="#' + swf_bgcol; 
	embed += '" align="middle" allowScriptAccess="' + swf_asacc;
	embed += '" type="application/x-shockwave-flash';
	embed += '" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
	document.write(embed);
	
	document.write('</object>\n');
}
