// JavaScript Document
//*********************************************************//
// File name: common.js
// Author: Turbine Interactive
// Last modified: 2004/12/24
//*********************************************************//

/* ブラウザ判別
---------------------------------------------------------*/
var Win=(navigator.userAgent.indexOf("Win")!=-1);
var Mac=(navigator.userAgent.indexOf("Mac")!=-1);
var Explorer=(navigator.appName.indexOf("Explorer")!=-1);
var Netscape=(navigator.appName.indexOf("Navigator")==-1);
var opera=(navigator.userAgent.indexOf("Opera")!=-1);
var Version=navigator.appVersion.charAt(0);

/* CSSの読み込み
呼び出しページにてpathを設定
---------------------------------------------------------*/
function Loadcss(_path){
	var cssfile = "";
	if(opera){
		cssfile = "pixel.css";
	} else if(Win && Explorer && Version == "4"){
		cssfile = "keyword.css";
	} else if(Win && Netscape && Version == "4"){
		cssfile = "win_nn4.css";
	} else if(Mac && Explorer && Version == "4"){
		cssfile = "keyword.css";
	} else if(Mac && Netscape && Version == "5"){
		cssfile = "mac_nn6.css";
	} else if(Mac && Netscape && Version == "4"){
		cssfile = "mac_nn4.css";
	} else {
		cssfile = "pixel.css";
	}
	cssfile = "css/" + cssfile;
	document.write('<link rel = "stylesheet" href="' + _path + cssfile + '" type="text/css">');
}

/*画像の先読み
nImgs: ファイルへのパスを要素とする配列
-------------------------------------------------------*/
function preload(nImgs){
	if (arguments.length == 0) return;
	var data = arguments;
	var preImg = new Array;
	for (var i = 0; i < data.length; i++) {
		preImg[i] = new Image();
		preImg[i].src = data[i];
	}
}
	
/* スワッピングイメージ
iName: スワップする元イメージのname属性を指定
str: スワップする先イメージのパス（相対or絶対）
onMouseOver, onMouseOut 双方に使用可
---------------------------------------------------------*/
function swImg(iName,str){
	document.images[iName].src = str;
}
	
/* ポップアップウインドウ
theURL: ポップするページのURL
winName: ポップウインドウのname
features: 詳細
---------------------------------------------------------*/
function OpenBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*フラッシュオブジェクト挿入
---------------------------------------------------------*/
function getswf(flashVersion){
	if(!flashVersion || flashVersion <= 5){
		document.write('<img src="image/top.jpg" width="680" height="300" alt="">');
	}else{
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" width="680" height="300">\n');
		document.write('	<param name="movie" value="top.swf">\n');
		document.write('	<param name="menu" value="false">\n');
		document.write('	<param name="quality" value="high">\n');
		document.write('	<embed src="top.swf" quality="high" width="680" height="300" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">\n');
		document.write('	</embed>\n');
		document.write('</object>\n');
	}
}

/*フラッシュバージョンチェック
---------------------------------------------------------*/
function chkFlash(){
	var flashVersion = false;
	var nn = (navigator.appName.charAt(0) == "N");
	var n6 = (document.getElementById && nn) || false;
	var ie = (document.all && !nn) || false;
	var op = (navigator.userAgent.indexOf("Opera") != -1);
	var mac = (navigator.userAgent.indexOf("Mac") != -1) || false;
	var ver = "" + navigator.appVersion;
	var fno = ver.indexOf(" ");
	ver = eval(ver.substring(0, fno));
	
	if(ie && !mac && !op){
		flashVersion = new ActiveXObject("ShockwaveFlash.ShockwaveFlash").FlashVersion();
		flashVersion = Math.floor(flashVersion / 0x10000);
	}
	
	if(!flashVersion){
		if(!ie && mac && navigator.plugins){
			flashVersion = navigator.plugins["Shockwave Flash"].description.charAt(16);
		}else if(nn && !document.plugins){
			flashVersion = false;
		}else if((nn || n6) && navigator.plugins){
			flashVersion = navigator.plugins["Shockwave Flash"].description.charAt(16);
		}else if(op && !mac && navigator.plugins){
			flashVersion = navigator.plugins["Shockwave Flash"].description.charAt(16);
		}else{
			flashVersion = false;
		}
	}
	
	if(ie && mac){
		flashVersion = 6;
	}
	
	return flashVersion;
}

