﻿//--- ◆ ブラウザ判別 ◆ -----------------------------------------------
//プロパティの値をすべて小文字に変更して代入
var uAnt = navigator.userAgent.toLowerCase();

var SAF = uAnt.indexOf("safari") > -1;
var OP = uAnt.indexOf("opera") > -1;
var winFF = uAnt.indexOf("firefox") > -1 && (uAnt.indexOf("win") > -1);
var macFF = uAnt.indexOf("firefox") > -1 && (uAnt.indexOf("mac") > -1);
var winIE = uAnt.indexOf("msie") > -1 && (uAnt.indexOf("win") > -1);;
var macIE = uAnt.indexOf("msie") > -1 && (uAnt.indexOf("mac") > -1);
var NS4 = document.layers?1:0;
var NS6 = document.getElementById && !document.all?1:0;

//alert( "SAF：" + SAF );
//alert( "OP：" + OP );
//alert( "winFF：" + winFF );
//alert( "macFF：" + macFF );
//alert( "winIE：" + winIE );
//alert( "macIE：" + macIE );
//alert( "NS4：" + NS4 );
//alert( "NS6：" + NS6 );

//-- ◆ Valueを引数から受け取る ◆ -------------------------------------
flashObj = new Object();

flashObj.f_getValue = function(fileName, idNumber, xSize, ySize){
	v_name = fileName;
	v_id = idNumber;
	v_width = xSize;
	v_height = ySize;
	v_version = "7,0,0,0"	//Playerのバージョン設定
	v_loop = "false";	// ループ再生：true→ループ / false→ループなし
	v_quality = "high";	// アンチエイリアス：LOW, HIGH, AUTOHIGH, AUTOLOW
}

//-- ◆ Param追加用Function ◆ -----------------------------------------
var v_color;
var v_mode;
var v_vars;
var v_base;

//【bgcolor】 背景色
flashObj.f_getValue.prototype.f_getColor = function( color ){
	v_color = color;
}

//【wmode】 背景透明：transparent　処理高速化：opaque
flashObj.f_getValue.prototype.f_getMode = function( mode ){
	v_mode = mode;
}

//【FlashVars】
flashObj.f_getValue.prototype.f_getVars = function( vars ){
	v_vars = vars;
}

// 【base】
flashObj.f_getValue.prototype.f_getBase = function( base ){
	v_base = base;
}



//-- ◆ Flashのタグをセット ◆ ------------------------------------------
flashObj.f_getValue.prototype.f_writeHTML = function(){
	document.write( this.f_setTAG() );
	//alert( this.f_setTAG() );
}

flashObj.f_getValue.prototype.f_setTAG = function(){
	var v_set = "";
	
	v_set += '<object ';
	v_set += 'width="' + v_width + '" ';
	v_set += 'height="' + v_height + '" ';
	
	// objectの中身をブラウザで分岐(<embed>排除)	
	if( winIE && !OP ){	//IEのみ
		v_set += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
		v_set += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + v_version + '"';
	}else{
		v_set += 'data="' + v_name + '"';
		v_set += ' type="application/x-shockwave-flash"'
	}
	
	v_set += ' id="' + v_id + '"';
	v_set += '>' + "\n";

	v_set += '<param name="movie" value="' + v_name + '" />' + "\n";
	v_set += '<param name="loop" value="' + v_loop + '" />' + "\n";
	v_set += '<param name="quality" value="' + v_quality + '" />' + "\n";
	
	if(v_color != null){
		v_set += '<param name="bgcolor" value="' + v_color + '" />' + "\n";
	}
	if(v_mode != null){
		v_set += '<param name="wmode" value="' + v_mode + '" />' + "\n";
	}
	if(v_vars != null){
		v_set += '<param name="flashvars" value="' + v_vars + '" />' + "\n";
	}
	if(v_base != null){
		v_set += '<param name="base" value="' + v_base + '" />' + "\n";
	}
	
	
	if( macIE ){
		v_set += '<embed src="' + v_name;
		v_set += '" quality="' + v_quality + '"';
		v_set += ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"'
		v_set += ' type="application/x-shockwave-flash"'
		v_set += ' width="' + v_width + '" height="' + v_height;
		v_set += '"></embed>' + "\n";
	}
	
	v_set += '</object>' + "\n";

	return v_set;
}


