﻿/*
#########################################################
#get Flash version method.
#show Flash Movie & image method.
#ex.JavaScript & VB Script.
#copyright: http://www.enneaplanet.com/
#editing: medal, Co,Ltd.
#########################################################
*/
// Judgment of version of a browser.
function versionCheck(){
	var is = new Is_env();
	var flag = (( is.OPERA && is.getBrowserVersion().substr(0,1)>= 6 ) ||
		( is.NN4X && is.getBrowserVersion().substr(0,3).toString()!='4.0' ) ||
		is.IE5X_UP || is.NN6X_UP || !is.IE45 ) ? true : false;

	return flag;
}

// Browsers other than WIN+MSIE are judged with JS.
function getJSFlashVersion() {
	var versionDelimiter = "r";

	for(var i=0; i<navigator.plugins.length; i++){
		var myPlugin = navigator.plugins[i]
		var myName = myPlugin.name;
		var myDesc = myPlugin.description;

		if(myName.indexOf("Shockwave")!=-1 && myName.indexOf("Flash")!=-1){
			var flashVersion = myDesc.substring(myDesc.indexOf("Flash")+6);
			var delimiterPos = flashVersion.indexOf(versionDelimiter);

			if(delimiterPos !=-1){
				var majarVersion = flashVersion.substring(0, delimiterPos);
				var minorVersion = parseInt(flashVersion.substring(delimiterPos+2));

				if(majarVersion<10) {
					minorVersion = "0"+minorVersion;
					return parseFloat(majarVersion + minorVersion);
				}else{
					return parseFloat(flashVersion);
				}
			}else{ //OS X Flash player 8 bata
				return parseFloat(flashVersion);
			}
		}
	}

	return Number(0);
}


// It judges with VBScript for WIN+MSIE.
function getVBFlashVersion(max) {
	var count_max = max; //Version examined first
	for( var i=count_max; i>0; i--){
		var flashVersion = getFlashControlVersion(i); //VBScript loading
		if(flashVersion !=0){
			var majarVersion = flashVersion >> 16;
			var minorVersion = flashVersion & 0x0000ffff;
			return parseFloat(majarVersion + '.' + minorVersion);
		}
	}

	return Number(0);
}


// Judgment of version of FLASH
function getFlashVersion() {
	var is = new Is_env();
	var max=6; //Version examined with VBScript first

	if(is.IE45) var flashVarsion = Number(0);
	else if(is.WIN && document.all && !is.OPERA) var flashVarsion = getVBFlashVersion(max);
	else var flashVarsion = getJSFlashVersion();

	//alert(flashVarsion);
	return flashVarsion;
}


/* 
#####################################################################################################################
# Plug-in of FlashPlayer is investigated, when there is nothing a problem, SWF is written out, 
# and a still picture is displayed at the time of NG.
# //new FlashDispatcher( requestVersion, swfFile, altImage, width, height,menuitem[true|false],bgcolor,
# windowmode[opaque|transparent], [JumpURL])
#####################################################################################################################
*/
function FlashDispatcher( requestVersion, swfFile, altImage, width, height, 
			menuitem, bgcolor, winmode, JumpURL, JumpTarget, pram, align, swfName ){
	this.requestVersion = requestVersion;
	this.swfFile  = swfFile;
	this.altImage = altImage;
	this.width    = width;
	this.height   = height;
	this.menuitem = menuitem;
	this.bgcolor  = bgcolor;
	this.wmode    = winmode;
	this.value    = pram;
	this.align    = align;
	this.name     = swfName;

	if( JumpURL ){
		if( JumpTarget ){
			this.pageJump( JumpURL, JumpTarget );
		}else{
			this.pageJump( JumpURL, null );
		}
	}
}

//A page is changed when the jump place is specified.
FlashDispatcher.prototype.pageJump = function( JumpURL, JumpTarget ){
	var targetBrowser = versionCheck();
	var flashVersion  = getFlashVersion();

	if( !targetBrowser || (flashVersion < this.requestVersion)){
		//the case where the window name is not specified -- or -- Case where it is _self
		//It's page changed.
		if(JumpTarget == null || JumpTarget == "_self" || JumpTarget == ""){
			//location.replace( JumpURL );
			top.location.href=JumpURL;
		}else{
			//A new page is displayed when the window name is specified.
			openWin( JumpURL, JumpTarget, true, 'width=800,height=600', 0, 0);
		}
	}
}


FlashDispatcher.prototype.writeimages = function( pram, path ){
	if(pram == '_root'){
document.write( '<div id="altmessage" class="m1em">\n' );
document.write( '<h2>ご使用の Adobe Flash Player は最新バージョンではありません。最新バージョンをインストールしてください。</h2>\n');
document.write( '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="'+ path +'images/common/get_shock_player.gif" border="0" width="88" height="31" alt="get Flash player" title="get Flash player" class="mt6" /></a><br />\n');
document.write( '<p>この Web サイトは、');
document.write( '<a href="http://www.adobe.com/jp/products/studio/" target="_blank">Adobe<sup>&reg;</sup> Flash<sup>TM</sup></a> ');
document.write( 'ソフトウェアを使用しています。</p>\n' );
document.write( '<p>ご使用の Adobe Flash Player のバージョンが古い、または、インストールされていないため、当サイトのコンテンツを再生することができません。</p>\n');
document.write( '<p>上のバナーをクリックして最新バージョンを今すぐダウンロードおよびインストールしてください。作業はごく短時間で済みます。</p>\n');
document.write( '<hr class="mt6 mb6" />\n' );
document.write( '<p>Adobe<sup>&reg;</sup> および Flash<sup>TM</sup> は、Adobe Systems Incorporated. の商標です。</p>\n' );
document.write( '</div>' );
	}
}


//A still picture is written out when a browser and plug-in is below the demand here.
//* A still picture will be displayed if true is passed to thisPageVisited.
//(It uses by cookie after the second time to display a still picture)
FlashDispatcher.prototype.writeContents = function( thisPageVisited, path ){
	var targetBrowser = versionCheck();
	var flashVersion  = getFlashVersion();

	document.open("text/html");

	if( targetBrowser ){
		if(( flashVersion < this.requestVersion ) || thisPageVisited ){
			this.writeimages( '_root', path );
		}else{
//flash write
document.write( '<object classid ="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
document.write( 'codebase ="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
document.write( 'id    ="'+ this.name +'" ');
document.write( 'width ="'+ this.width +'" ');
document.write( 'height="'+ this.height +'" ');
document.write( 'align ="'+ this.align +'"');
document.write( '>\n');
document.write( '<param name="movie" value="'+ this.swfFile +'" />\n');
document.write( '<param name="quality" value="high" />\n' );
document.write( '<param name="scale" value="showall" />\n');
document.write( '<param name="menu" value="'+ this.menuitem +'" />\n');
document.write( '<param name="bgcolor" value="'+ this.bgcolor +'" />\n');
document.write( '<param name="wmode" value="'+ this.wmode +'" />\n');
document.write( '<param name="flashvars" value="pram='+ this.value +'" />\n');
document.write( '<embed src ="'+ this.swfFile +'" ');
document.write( 'quality="high" ');
document.write( 'scale  ="showall" ');
document.write( 'name   ="'+ this.name +'" ');
document.write( 'menu   ="'+ this.menuitem +'" ');
document.write( 'bgcolor="'+ this.bgcolor +'" ');
document.write( 'width  ="'+ this.width +'" ');
document.write( 'height ="'+ this.height +'" ');
document.write( 'wmode  ="'+ this.wmode +'" ');
document.write( 'align  ="'+ this.align +'" ');
document.write( 'flashvars ="pram='+ this.value +'" ');
document.write( 'type   ="application/x-shockwave-flash" ');
document.write( 'pluginspage ="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
document.write( '</embed></object>');
		}
	}

	document.close();
}

